Quantcast
Channel: GameDev.net
Viewing all articles
Browse latest Browse all 17560

Constant buffer strategy and thoughts

$
0
0

Hi all,

I've arrived at the moment that my shaders/shaderpacks and shader manager is up and running. All nice and abstracted within the renderer. The next stop is constant buffers.

 

Before I dive in/ run off and implement, I'd like to share some thoughts and hear your opinion on how you handle this.

The approach I have in mind for now, is based on articles I've read and experience I have with playing around with the CBuffers:

 

- I will have different CBuffers in my shaders, based on update frequency

- so far I've come up with the following 'types'

-- CB per frame (camera etc.)

-- CB per object (world orientiation for mesh instance etc.)

-- CB per material (will also set the texture in the unexposed part of the renderer)

- I don't see a reason yet, to have a CB per application, because for example the projection matrix, is multiplied with view on the CPU side, and then sent 'per object' (to prevent this calculation for each vertex)

 

- assuming each CBuffer will need updating through the application, I will need predefined structs for each type of CBuffer

-- meaning the unique CBuffers for all shaders, need to be known structs in the application (I can force this in the asset pipeline I guess)

-- this means that I will not use the D3D shader reflect API to dynamically figure out what CBuffers are used within which shader. I could do this, but in the end I cannot support unlimited CBuffer types, because I wouldn't have the structs in the application, to be able to update them. Is this a correct assumption, or could i somehow 'work around' this and create a block of memory with the needed variables in the dynamic struct?

 

- I will link 'n' CBuffer handles in each shaderpack (pack consists of combination of VS, PS etc.)

-- my CBufferManager will either set another CB or simply leave it, when it's already bound to 1 of the 14(?) slots)

- this also means I will not distinct CBuffers per shader type (i.e. separate for the PS, VS etc.).

 

I'm curious what your view in on this approach and/or how I can do this otherwise/ better.

All input is appreciated is always.


Viewing all articles
Browse latest Browse all 17560

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>