Jump to content
  • Advertisement
Sign in to follow this  

How does exactly semantic mapping work between ps and vs?

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

Hello, I'm studying the data flow between the vertex shader and pixel shader in shader model 3.0 to model it in a GPU simulator. Reading directx sdk docs it seems that vs declares semantics for its output and ps declares semantics for its input. Then the vs output registers are paired with the ps input registers that have the same semantics. Sdk docs also talk about packing semantics, but for now I will forget this. According to that this code is legal (it compiles as well): Vertex shader
dcl_normal0 v0
dcl_normal1 v1
dcl_color0 v2
dcl_color1 v3
dcl_position v4

dcl_normal0 o0
dcl_normal1 o1
dcl_color0  o2
dcl_color1  o3
dcl_position o4

mov o0, v0
mov o1, v1
mov o2, v2
mov o3, v3
mov o4, v4

Pixel shader

dcl_color0 v0
dcl_normal0 v1
dcl_color1 v2
dcl_normal1 v3

def c0, 0.0f, 0.0f, 0.0f, 0.0f
def c1, 1.0f, 1.0f, 1.0f, 1.0f

mov r0, c0
add r0, r0, v0
add r0, r0, v1
mov r1, c1
mul r1, r1, v2
mul r1, r1, v3
mul oC0, r0, r1

The mapping seems to be:
VS     Semantic   PS
This it what I think reading SDK docs, but when I go for real world examples everybody seems to use Texcoord# semantics to pass data for VS output to PS input. The questions are: Are this pixel-vertex shaders legal? Have I interpreted the data flow correctly? Why can't I find any example of this kind of data flow? Why everybody uses Texcoord#? Any kind of help/orientation will be very appreciated.

Share this post

Link to post
Share on other sites
I imagine that the main reason you don't see this is that texture coord semantics are compatible with all shader models, and therefore a better choice if you're not writing exclusively for SM3.

Share this post

Link to post
Share on other sites
Yes, it seems a good reason to stick to texture coords, everybody seems to use it. Thank you.

This leaves my first question. In the case someone decide not to use texture coords semantics exclusively...Have I understand how the data flow should work?

Share this post

Link to post
Share on other sites
It looks correct to me, but frankly I'm only using HLSL. You should have no problem trying it, though.

Share this post

Link to post
Share on other sites
I will make some little application to test this... Well, this is all the info that I needed.

Thank you :)

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!