I’m having troubles with EXT_vertex_shader on my Radeon 8500. I wonder if it’s me, or if the documentation is really bad. I’m so confused i can’t believe it… anyone, enlighten me :
I’m simply trying to make a world-space displacement vector applied by the vertex shader. I’m trying to use variant arrays.
First confusion; in ATI’s tutorials Hardware Shading with EXT_vertex_shader and ATI_fragment_shader, it is written:
If rendering with vertex arrays, the application can specify the values of the variant in the following manner:
glVariantPointerEXT(var1, stride, type, addr)
However, in the EXT_vertex_shader specification:
Variant arrays are specified by the call:
void VariantPointerEXT( uint id, enum type, uint stride, void *addr )
Type and stride are reverted, wtf? I’m assuming the specifcation is correct, so let’s continue for more fun:
In the specification we find an identifier
VARIANT_ARRAY_EXT (0x87E8) which is only used in IsVariantEnabled. Nowhere it’s mentionned that i need to use glEnable(GL_VARIANT_ARRAY_EXT) or glDisable… it seems the correct way is to just enable the variant array with glEnableVariantClientStateEXT, but that doesn’t sound logical… why would there be a IsVariantEnabled if you can’t enable/disable it ?!
But it’s not finished. Fun, fun and more fun:
in the specification…
The type and stride parameters hold the same meaning as all other array calls. The size parameter is missing as in NormalPointer, and the size is fixed at 4. The id parameter specifies which variant this array is to be used with.
It was already bad, but now i’m just lost. What’s up with “size fixed at 4” ? 4 components in a variant array ? So basically it’s not possible to build a scalar array ? Although it’s possible to declare the variant id with GenSymbolsEXT(GL_SCALAR_EXT, …) as in:
This is done by calling
uint GenSymbolsEXT( enum datatype, enum storagetype, enum range, uint components );
where datatype can be one of SCALAR_EXT, VECTOR_EXT, MATRIX_EXT, and storagetype can be one of VARIANT_EXT, INVARIANT_EXT, LOCAL_CONSTANT_EXT, LOCAL_EXT, range can be NORMALIZED_RANGE_EXT or FULL_RANGE_EXT
Ok, now i’ve described what’s confusing me, but here’s my problem. I want to submit a displacement vector per-vertex, and just add it to the world position in the vertex shader. This works well if i try with a local constant; but as soon as i use a variant array, it’s as if the displacement vector was 0.
Here’s my code:
/// variant array declaration…
vertex = glBindParameterEXT(GL_CURRENT_VERTEX_EXT);
modelview = glBindParameterEXT(GL_MODELVIEW_MATRIX);
projection = glBindParameterEXT(GL_PROJECTION_MATRIX);
m_weightsID = glGenSymbolsEXT(GL_VECTOR_EXT, GL_VARIANT_EXT, GL_FULL_RANGE_EXT, 1);/// shader definition:
glBindVertexShaderEXT(m_shader); glBeginVertexShaderEXT();
GLuint eyeVertex = glGenSymbolsEXT(GL_VECTOR_EXT, GL_LOCAL_EXT, GL_FULL_RANGE_EXT, 1);
glShaderOp2EXT(GL_OP_ADD_EXT, eyeVertex, vertex, m_weightsID);
glShaderOp2EXT(GL_OP_MULTIPLY_MATRIX_EXT, eyeVertex, modelview, eyeVertex);
glShaderOp2EXT(GL_OP_MULTIPLY_MATRIX_EXT, GL_OUTPUT_VERTEX_EXT, projection, eyeVertex);
glEndVertexShaderEXT();/// Finally, the drawElements call:
glEnable(GL_VERTEX_SHADER_EXT);
glBindVertexShaderEXT(m_shader);
glEnableVariantClientStateEXT(m_weightsID);
glVariantPointerEXT(m_weightsID, GL_FLOAT, 0, m_weights);
glDrawElements(GL_TRIANGLES, m_nbExtIndices, GL_UNSIGNED_INT, m_extIndices);
glDisable(GL_VERTEX_SHADER_EXT);
glDisableVariantClientStateEXT(m_weightsID);
The array m_weights is filled with constant scalars (20.0f). I have the same behavior wether i try to use a scalar variant array, or a vector variant array.
Y.