Graphics Reference
In-Depth Information
Example 8-7
Vertex Skinning Shader with Checks of Whether
Matrix Weight = 0 (continued)
{
m_indx = int ( a_matrixindices[1] ) * c_three;
skin_position( position, m_wt, m_indx, skinned_position );
skin_normal ( normal, m_wt, m_indx, skinned_normal );
}
m_wt = a_matrixweights[2] ;
if ( m_wt > 0.0 )
{
m_indx = int ( a_matrixindices[2] ) * c_three;
skin_position( position, m_wt, m_indx, skinned_position );
skin_normal ( normal, m_wt, m_indx, skinned_normal );
}
m_wt = a_matrixweights[3];
if ( m_wt > 0.0 )
{
m_indx = int ( a_matrixindices[3] ) * c_three;
skin_position( position, m_wt, m_indx, skinned_position );
skin_normal ( normal, m_wt, m_indx, skinned_normal );
}
}
At first glance, we might conclude that the vertex skinning shader in
Example 8-7 offers better performance than the vertex skinning shader
in Example 8-6. This is not necessarily true; indeed, the answer can vary
across GPUs. Such variations occur because in the conditional expression
if (m_wt > 0.0) , m_wt is a dynamic value and can be different for
vertices being executed in parallel by the GPU. We now run into divergent
flow control where vertices being executed in parallel may have different
values for m_wt , which in turn can cause execution to serialize. If a GPU
does not implement divergent flow control efficiently, the vertex shader
in Example 8-7 might not be as efficient as the version in Example 8-6.
Applications should, therefore, test performance of divergent flow
control by executing a test shader on the GPU as part of the application
initialization phase to determine which shaders to use.
Transform Feedback
The transform feedback mode allows for capturing the outputs of the
vertex shader into buffer objects. The output buffers then can be used
as sources of the vertex data in a subsequent draw call. This approach is
 
 
 
Search WWH ::




Custom Search