Jump to content
  • Advertisement
Sign in to follow this  
Evil Steve

Quick question about vertex shader constants

This topic is 3939 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
Advertisement
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!