diff options
author | Brian Paul <brianp@vmware.com> | 2014-04-17 09:00:29 -0700 |
---|---|---|
committer | Brian Paul <brianp@vmware.com> | 2014-04-17 11:29:33 -0700 |
commit | 851645a3e7f06348d60180ec122b9ad0dc3cf432 (patch) | |
tree | 6ff45de67a75286fd7fa9ca94636f67f3887d9c8 /src/gallium/drivers/svga/svga_pipe_vertex.c | |
parent | 615a356ee38d882e9f073dba0b8918a903094124 (diff) |
svga: add VS code to set attribute W component to 1
There's a few 3-component vertex attribute formats that have no
equivalent SVGA3D_DECLTYPE_x format. Previously, we had to use
the swtnl code to handle them. This patch lets us use hwtnl for
more vertex attribute types by fetching 3-component attributes as
4-component attributes and explicitly setting the W component to 1.
This lets us handle PIPE_FORMAT_R16G16B16_SNORM/UNORM and
PIPE_FORMAT_R8G8B8_UNORM vertex attribs without using the swtnl path.
Fixes piglit normal3b3s GL_SHORT test.
Reviewed-by: Charmaine Lee <charmainel@vmware.com>
Diffstat (limited to 'src/gallium/drivers/svga/svga_pipe_vertex.c')
-rw-r--r-- | src/gallium/drivers/svga/svga_pipe_vertex.c | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/src/gallium/drivers/svga/svga_pipe_vertex.c b/src/gallium/drivers/svga/svga_pipe_vertex.c index d679ad3bdf3..f951c0da189 100644 --- a/src/gallium/drivers/svga/svga_pipe_vertex.c +++ b/src/gallium/drivers/svga/svga_pipe_vertex.c @@ -94,9 +94,14 @@ translate_vertex_format(enum pipe_format format) case PIPE_FORMAT_R16G16_FLOAT: return SVGA3D_DECLTYPE_FLOAT16_2; case PIPE_FORMAT_R16G16B16A16_FLOAT: return SVGA3D_DECLTYPE_FLOAT16_4; - /* See attrib_needs_adjustment() below */ + /* See attrib_needs_adjustment() and attrib_needs_w_to_1() below */ case PIPE_FORMAT_R8G8B8_SNORM: return SVGA3D_DECLTYPE_UBYTE4N; + /* See attrib_needs_w_to_1() below */ + case PIPE_FORMAT_R16G16B16_SNORM: return SVGA3D_DECLTYPE_SHORT4N; + case PIPE_FORMAT_R16G16B16_UNORM: return SVGA3D_DECLTYPE_USHORT4N; + case PIPE_FORMAT_R8G8B8_UNORM: return SVGA3D_DECLTYPE_UBYTE4N; + default: /* There are many formats without hardware support. This case * will be hit regularly, meaning we'll need swvfetch. @@ -123,6 +128,25 @@ attrib_needs_range_adjustment(enum pipe_format format) } +/** + * Does the given vertex attrib format need to have the W component set + * to one in the VS? + */ +static boolean +attrib_needs_w_to_1(enum pipe_format format) +{ + switch (format) { + case PIPE_FORMAT_R8G8B8_SNORM: + case PIPE_FORMAT_R8G8B8_UNORM: + case PIPE_FORMAT_R16G16B16_SNORM: + case PIPE_FORMAT_R16G16B16_UNORM: + return TRUE; + default: + return FALSE; + } +} + + static void * svga_create_vertex_elements_state(struct pipe_context *pipe, unsigned count, @@ -138,6 +162,7 @@ svga_create_vertex_elements_state(struct pipe_context *pipe, memcpy(velems->velem, attribs, sizeof(*attribs) * count); velems->adjust_attrib_range = 0x0; + velems->adjust_attrib_w_1 = 0x0; /* Translate Gallium vertex format to SVGA3dDeclType */ for (i = 0; i < count; i++) { @@ -147,6 +172,9 @@ svga_create_vertex_elements_state(struct pipe_context *pipe, if (attrib_needs_range_adjustment(f)) { velems->adjust_attrib_range |= (1 << i); } + if (attrib_needs_w_to_1(f)) { + velems->adjust_attrib_w_1 |= (1 << i); + } } } return velems; |