Quick question about vertex shader constants
Hi all,
I have a few quick questions about vertex shader constants:
1. What size is a constant register? Is it float4? If so, what if I set a single float from my code? Does it get expanded to float4(value, 0, 0, 0) or something? And if it is a float4, does a float4x4 then take up 4 constants?
2. Is the minimum number of constant registers well defined for the different vertex shader versions? If so, is there somewhere (presumably in the SDK) that lists the minimum number of constant registers for each vertex shader version?
Cheers,
Steve
1) One register is 128bit wide, containing 4 floats. If you put a single float into a constant, it will be stored as (float, 0, 0, 1) AFAIK.
2) The DirectX documentation can tell you the limits of each shader version. Look in DirectX -> Direct3D 9 (or 10) -> Reference -> Asm Shader Reference -> Shader Model of your choice
Bye, Thomas
[edit] typos
2) The DirectX documentation can tell you the limits of each shader version. Look in DirectX -> Direct3D 9 (or 10) -> Reference -> Asm Shader Reference -> Shader Model of your choice
Bye, Thomas
[edit] typos
1a) yes, they're float4's. It's useful to look at ASM shaders to get a better idea about what's going on at the hardware level (D3Ds shader models are still abstracted/'ideal', but they're closer to what the GPU specific microcode is doing than HLSL).
1b) AFAIK by default it'll expand it to a full float4. I think newer versions of the compiler allow you to specify which component to shove smaller items into. Personally I don't favour automatic (or even controlled) compiler packing but would still do it manually (e.g. shoving an unrelated scalar into the extra component of a vec3) if running low on VS constants. If you ever have to write your own equivilent of the effect system for any shader based platforms you'll know why [wink]
1c) yep, a float4x4 will take 4 constant registers.
2) take a look at MaxVertexShaderConst in the card caps spreadsheet.
1b) AFAIK by default it'll expand it to a full float4. I think newer versions of the compiler allow you to specify which component to shove smaller items into. Personally I don't favour automatic (or even controlled) compiler packing but would still do it manually (e.g. shoving an unrelated scalar into the extra component of a vec3) if running low on VS constants. If you ever have to write your own equivilent of the effect system for any shader based platforms you'll know why [wink]
1c) yep, a float4x4 will take 4 constant registers.
2) take a look at MaxVertexShaderConst in the card caps spreadsheet.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement