How to use persistent shader buffers?

I am trying to understand constant buffers in DirectX. I saw two syntaxes

float4 myVar;

declared at the top level of the shader file and

cbuffer myBuffer
{
    float4 myVar;
}

as described in http://msdn.microsoft.com/en-gb/library/windows/desktop/bb509581(v=vs.85).aspx

I understand that constant buffers need to be assigned slots (indexing with a zero mark) and they can be set in the code.

It seems that the two structures that I was looking at (SlimDX vs SharpDX) use different conventions to configure them - SlimDX by line name (through shader reflection?) And SharpDX by slot number - although it is not clear where the slot number is obtained from?

- , , .fx ?

+5
3

SharpDX SlimDX API Direct3D10/Direct3D11 ( Direct3D10.Device.XXX.SetConstantBuffers Direct3D11.DeviceContext.XXX.SetConstantBuffers).

MSDN, " ". , , , , "$ Global".

, ( RAW Direct3D10 + API) . ShaderReflection // . , GPU, ( ). , , ShaderReflection.

. (. cbuffer MSDN), cbuffer. , , .

+10

:

float4 myVar;

- Microsoft, - hlsl. , , .

SharpDX, 1 :

cbuffer myBuffer: register(b1)
{
    float4 myVar;
}
+1

, , D3D api. (SlimDX SharpDX) .

, ( ), , . , , . , , . , " " , , - / .

Last question: why do you care about implementation / mapping? The whole point of these libraries is to abstract the details in a convenient way. Personally, I can understand why this can be frustrating (especially if you resort to canonical documentation instead of a platform for any reason), but the associated cost is a consequence / compromise between choosing such a platform instead of using the library core directly.

0
source

All Articles