Jump to content
  • Advertisement
Sign in to follow this  
thedodgeruk

cant comprehend input of hlsl ??

This topic is 2947 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 can understand what is going on in the hlsl code , but for the life of me , i cant see in the c++ code were you set the input and get the out put arguments



// Input to Pixel Shader
// Per-pixel input data from the previous stages of the pipeline
struct PS_Input
{
float4 DiffuseColourll : COLOR0;
// Not using input from previous stages yet
};

// Output from Pixel Shader
// The data that this pixel shader outputs to the remainder of the pipeline, usually just a colour
struct PS_Output
{
float4 Colour : COLOR0;
};


// Main pixel shader function. Pass the name of this entry function when compiling the shader
void main( in PS_Input i, out PS_Output o )
{

o = i;

}

Share this post


Link to post
Share on other sites
Advertisement
That's because C++ doesn't call HLSL functions. Your C++ code instructs DirectX to draw a primitive shape, and HLSL is used at certain stages of the pipeline by the internals of DirectX.

e.g. The vertices that are assembled into those primitives are passed as inputs to your HLSL vertex shader. It's outputs are passed to the rasteriser. The rasteriser's outputs are the inputs to the pixel shader. The pixel shader's outputs get carried off to a render-target.

Share this post


Link to post
Share on other sites
You don't directly access the inputs and outputs of a pixel shader from within the host program (C++ side). The pixel shader program is invoked by the GPU upon rendering each pixel that your geometry covers.

Generally, a vertex shader outputs stuff for the pixel shader to use. Vertex shader gets its inputs from an "input assembler". Input assembler loads and arranges streams of vertex data based on the active stream sources (vertex buffers) and input layout.

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!