Jump to content
Posted 03 April 2012 - 11:14 AM
Posted 03 April 2012 - 02:37 PM
In time the project grows, the ignorance of its devs it shows, with many a convoluted function, it plunges into deep compunction, the price of failure is high, Washu's mirth is nigh.
ScapeCode - Blog | SlimDX
Posted 04 April 2012 - 01:24 AM
...How is making something harder, progress?
I believe you should be using cbuffers with DX11.
Posted 04 April 2012 - 02:09 AM
Posted 04 April 2012 - 04:15 PM
D3DXCompileShaderFromFile(W_STR(shaderfilename), NULL, NULL, C_STR(functionName), C_STR(versionString), shaderflags, &m_vertexShaderSourceCode, &compileErrors, &m_constantTable);
Posted 04 April 2012 - 07:07 PM
float3 Color : register(c0);
Posted 05 April 2012 - 05:10 PM
Ok; so why is it slower if it's still justusing a constant buffer?
In DX9 there are 2 sets of constant registers, one for the vertex shader and one for the pixel shader. Each register is a float4. The way it worked is when you compile a shader, the compiler assigns your constants to a register, and that register is used in the resulting assembly. Then at runtime when you want to run that shader, you have to set the value of the corresponding register by calling SetVertexShaderConstantF or SetPixelShaderConstantF. Larger variables could also span multiple registers, so for instance a float4x4 will take up 4 consecutive registers.
There are two ways to know which register a variable is mapped to. The first way is to manually assign a register to your variable in your HLSL code. The syntax is like this:float3 Color : register(c0);
The other way is to ID3DXConstantTable to reflect the shader, and get the register index. Like the above poster mentioned, ID3DXConstantTable can also set values for you by string or by handle so that you don't need to explicitly query the index and call Set*ShaderConstantF yourself. Under the hood an ID3DXEffect maintains its own constant table for all compiled shaders, which is how it's able to set variables for you.
Posted 06 April 2012 - 11:01 PM