Jump to content
  • Advertisement
Sign in to follow this  
hupsilardee

Vertex shader output - cumulative questions!

This topic is 2152 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

I want to use several different pixel shaders with several different vertex shaders in any combination. D3D11 seems to complain if the linkage doesn't match up perfectly, so to solve this I created the requirement that every vertex shader must use this and only this

 

struct VSCommonOut
{     float4 Position : SV_POSITION;     float2 TexCoord : TEXCOORD0;     float3 Normal : TEXCOORD1;     float3 WorldPos : TEXCOORD2;     float4 DiffuseColor : COLOR0;
};

 

as output, and every pixel shader must use this and only this as input. However I have a series of questions!

 

1. Will unwritten outputs be removed by the compiler as an optimization?

3. If so can I prevent this by writing dummy outputs (eg just 0 for unused texcoords and 1 for unused colors?)

4. If I do that, there might be several unnecessary outputs going to the pixel shader (eg texcoord and color going to a write-shadow-depth pixel shader), would that damage performance?

 

NB-1. Targeting vs_4_0_level_9_3

NB-2. Assume that the HLSL compiler I am using is the latest one, ie I downloaded the windows8 kit last week when I upgraded to 8

Share this post


Link to post
Share on other sites
Advertisement

1. You're required to write to all outputs of a vertex shader. The compiler will give you an error if don't write to them.
2. Yes, you can just set the outputs to a constant value if you don't want to use them.

3. Yes, vertex shader outputs can adversely affect performance. Ideally you don't want to have any vs outputs/ps inputs that don't get used.

Share this post


Link to post
Share on other sites
1) unwritten outputs should be a warning/error (uninitialized variable used).
3) yes, writing default values should make the warning/error go away.
4) yes, every member of that structure will take, for example, 1 cycle per pixel to be interpolated, regardless of whether the pixel shader actually reads it or not.
[edit]damn, ninja'ed!

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!