Graphics Reference
In-Depth Information
3.2.1 Stage-to-Stage Communication
As data is processed by the individual pipeline stages, it must be transmitted from one stage
to the next. To do this, each programmable stage defines its required inputs and outputs for
its shader program. We will refer to these inputs and outputs as attributes, which consist
of vector variables (from 1 to 4 elements). All of the elements in each vector consist of
one of the scalar types (both integer and floating point types are available). We can also
refer to these attributes as semantics or binding semantics, which is the name given to the
text-based identifier for each input/output attribute. In general, it should be clear from the
context in which they are used when we are referring to these types of stage-to-stage vari-
ables by either of these names.
The input attributes to a shader program define the information required for that pro-
gram to execute. Quite literally, the input attributes are the input parameters to the shader
program function. Likewise, the function's return value defines its output attributes. Thus,
each previous stage must produce output parameters that match the required input parame-
ters for the next stage. These input and output attributes are implemented with the input and
output registers we discussed in the "Shader Core Architecture" section. The brief example
in Listing 3.1 provides a sample declaration for two shader functions, with each function
defining its inputs and outputs. Notice that the output from the first function matches the
input from the second function.
struct VS_INPUT
{
float3 position : POSITION;
float2 coords : TEXCOORDS;
uint vertexID : SV_VertexID;
};
Struct VS_OUTPUT
{
float4 position : SV_POSITION;
float4 color : COLOR;
};
VS_OUTPUT VSMAIN( in VS_INPUT v )
{
// Perform vertex processing here...
}
float4 PSMAIN( in VSJXJTPUT input ) : SV_Target
{
// Perform pixel processing here...
}
Listing 3.1. Two shader functions defining their input and output attributes which must match.
Search WWH ::




Custom Search