diff options
author | Paul Berry <[email protected]> | 2012-12-11 19:14:33 -0800 |
---|---|---|
committer | Paul Berry <[email protected]> | 2012-12-13 10:09:03 -0800 |
commit | 6267853055e4ecb5ce0580316c4aa77935f541d3 (patch) | |
tree | 55039101fe5f59b747e8914acd815a095e3b0369 /src/mesa/main/varray.c | |
parent | 11cea472466f731fa9c44d56f1643dec26e6601c (diff) |
mesa: Fix computation of default vertex attrib stride for 2_10_10_10 formats.
Previously, if the client program didn't specify a stride when setting
up a vertex attribute, we used _mesa_sizeof_type() to compute the size
of the type, and multiplied it by the number of components.
This didn't work for the 2_10_10_10 formats, since _mesa_sizeof_type()
returns -1 for those types, resulting in all kinds of havoc, since it
was causing the hardware to be programmed with a negative stride
value.
This patch adds a new function _mesa_bytes_per_vertex_attrib(), which
is similar to the existing function _mesa_bytes_per_pixel(), but which
computes the size of a vertex attribute based on the type and the
number of formats. For packed formats (currently only the 2_10_10_10
formats), it verifies that the number of components is correct and
returns the size of the packed format. For unpacked formats, it
returns the size of the type times the number of components.
In addition, this patch adds an assertion so that if we ever forget to
update _mesa_bytes_per_vertex_attrib() when adding a new vertex
format, we'll see the problem quickly rather than having to debug a
subtle conformance test failure.
Fixes GLES3 conformance tests
vertex_type_2_10_10_10_rev_{conversion,divisor,stride_pointer}.test.
Reviewed-by: Brian Paul <[email protected]>
Diffstat (limited to 'src/mesa/main/varray.c')
-rw-r--r-- | src/mesa/main/varray.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/mesa/main/varray.c b/src/mesa/main/varray.c index f770143972c..5e4d6c3e638 100644 --- a/src/mesa/main/varray.c +++ b/src/mesa/main/varray.c @@ -251,7 +251,8 @@ update_array(struct gl_context *ctx, return; } - elementSize = _mesa_sizeof_type(type) * size; + elementSize = _mesa_bytes_per_vertex_attrib(size, type); + assert(elementSize != -1); array = &ctx->Array.ArrayObj->VertexAttrib[attrib]; array->Size = size; |