How do I do something like Effect.SetValue<T> in DX11?

Started by
10 comments, last by Narf the Mouse 12 years ago
It's not using a constant buffer, it's using a set of global registers that's shared among all shaders. In D3D10/D3D11 a constant buffer is an actual Buffer resource, much like a vertex buffer or a texture. This means that if shader A uses registers 0-10 for a bunch of variables and then shader B uses register 0-10 for an entirely different set of variables, then all of those registers have to be set before both draw calls. This is true even if those variables never change during the lifetime of the program. With constant buffers, you could make two static constant buffers, fill them with data during initialization, and then at runtime you could just bind each constant buffer before drawing with each shader. Even setting the variable values are slower in D3D9, since all of the register values have to get copied into the command buffer. With constant buffers you can use the same dynamic resource update methods you use for other buffer types, which can make it a lot more efficient.
Advertisement
Ok, think I got it now, thanks.

This topic is closed to new replies.

Advertisement