Jump to content

  • Log In with Google      Sign In   
  • Create Account

Vertex shader output - cumulative questions!


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 hupsilardee   Members   -  Reputation: 486

Like
0Likes
Like

Posted 22 January 2013 - 10:58 AM

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



Sponsor:

#2 MJP   Moderators   -  Reputation: 11343

Like
3Likes
Like

Posted 22 January 2013 - 04:05 PM

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.



#3 Hodgman   Moderators   -  Reputation: 30384

Like
2Likes
Like

Posted 22 January 2013 - 04:08 PM

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!




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS