CBV
CBV (Constant Buffer View) is a mechanism in graphics APIs such as Direct3D 12 that allows constant data to be passed to shaders. CBV represents a special view of a Constant Buffer, which is used to store small amounts of data that are frequently updated between rendering calls.
Key Features of CBV
- Small Data Volume – Designed for storing transformation matrices, lighting parameters, and other small data structures.
- High Access Speed – Data stored in CBV is cached and accessible to shaders with minimal latency.
- Separate Usage with Other Resources – CBV can be used independently or in combination with SRV (Shader Resource View) and UAV (Unordered Access View).
Using CBV in Direct3D 12
In Direct3D 12, constant buffers are passed to shaders through the Root Signature. Example of creating a CBV:
D3D12_CONSTANT_BUFFER_VIEW_DESC cbvDesc = {};
cbvDesc.BufferLocation = constantBuffer->GetGPUVirtualAddress();
cbvDesc.SizeInBytes = (sizeof(ConstantData) + 255) & ~255; // 256-byte alignment
device->CreateConstantBufferView(&cbvDesc, cbvHandle);
Where is CBV Used?
- Transformation Matrix Passing – Used to store model, view, and projection matrices in 3D graphics.
- Lighting Settings – Stores parameters for light sources, color, and intensity.
- Global Shader Variables – Allows common rendering parameters to be passed without using textures or buffers.
Conclusion
CBV (Constant Buffer View) is a key component for passing constant data in graphics APIs such as Direct3D 12. Due to its high access speed and ease of use, it is widely applied in rendering to efficiently transfer important parameters to shaders, ensuring optimal GPU performance.