diff options
author | Christoph Bumiller <[email protected]> | 2012-01-03 23:00:31 +0100 |
---|---|---|
committer | Christoph Bumiller <[email protected]> | 2012-01-03 23:00:31 +0100 |
commit | 7e291e922e53a70d84751538b15c6c16310cca7f (patch) | |
tree | ea737fa0fa0f4f83a71b7ffd9bc0cb374efe8d89 | |
parent | 69111847a2bed4c4c2c61001b8bdff3bbe42dc98 (diff) |
st/mesa: use SINT/UINT formats for VertexAttribIPointer
Reviewed-by: Dave Airlie <[email protected]>
v2: added assertion that packed formats are not pure integer
-rw-r--r-- | src/mesa/state_tracker/st_draw.c | 64 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_draw.h | 2 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_draw_feedback.c | 3 |
3 files changed, 63 insertions, 6 deletions
diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index 954f15a3437..a21160c956d 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -102,6 +102,13 @@ static GLuint uint_types_scale[4] = { PIPE_FORMAT_R32G32B32A32_USCALED }; +static GLuint uint_types_int[4] = { + PIPE_FORMAT_R32_UINT, + PIPE_FORMAT_R32G32_UINT, + PIPE_FORMAT_R32G32B32_UINT, + PIPE_FORMAT_R32G32B32A32_UINT +}; + static GLuint int_types_norm[4] = { PIPE_FORMAT_R32_SNORM, PIPE_FORMAT_R32G32_SNORM, @@ -116,6 +123,13 @@ static GLuint int_types_scale[4] = { PIPE_FORMAT_R32G32B32A32_SSCALED }; +static GLuint int_types_int[4] = { + PIPE_FORMAT_R32_SINT, + PIPE_FORMAT_R32G32_SINT, + PIPE_FORMAT_R32G32B32_SINT, + PIPE_FORMAT_R32G32B32A32_SINT +}; + static GLuint ushort_types_norm[4] = { PIPE_FORMAT_R16_UNORM, PIPE_FORMAT_R16G16_UNORM, @@ -130,6 +144,13 @@ static GLuint ushort_types_scale[4] = { PIPE_FORMAT_R16G16B16A16_USCALED }; +static GLuint ushort_types_int[4] = { + PIPE_FORMAT_R16_UINT, + PIPE_FORMAT_R16G16_UINT, + PIPE_FORMAT_R16G16B16_UINT, + PIPE_FORMAT_R16G16B16A16_UINT +}; + static GLuint short_types_norm[4] = { PIPE_FORMAT_R16_SNORM, PIPE_FORMAT_R16G16_SNORM, @@ -144,6 +165,13 @@ static GLuint short_types_scale[4] = { PIPE_FORMAT_R16G16B16A16_SSCALED }; +static GLuint short_types_int[4] = { + PIPE_FORMAT_R16_SINT, + PIPE_FORMAT_R16G16_SINT, + PIPE_FORMAT_R16G16B16_SINT, + PIPE_FORMAT_R16G16B16A16_SINT +}; + static GLuint ubyte_types_norm[4] = { PIPE_FORMAT_R8_UNORM, PIPE_FORMAT_R8G8_UNORM, @@ -158,6 +186,13 @@ static GLuint ubyte_types_scale[4] = { PIPE_FORMAT_R8G8B8A8_USCALED }; +static GLuint ubyte_types_int[4] = { + PIPE_FORMAT_R8_UINT, + PIPE_FORMAT_R8G8_UINT, + PIPE_FORMAT_R8G8B8_UINT, + PIPE_FORMAT_R8G8B8A8_UINT +}; + static GLuint byte_types_norm[4] = { PIPE_FORMAT_R8_SNORM, PIPE_FORMAT_R8G8_SNORM, @@ -172,6 +207,13 @@ static GLuint byte_types_scale[4] = { PIPE_FORMAT_R8G8B8A8_SSCALED }; +static GLuint byte_types_int[4] = { + PIPE_FORMAT_R8_SINT, + PIPE_FORMAT_R8G8_SINT, + PIPE_FORMAT_R8G8B8_SINT, + PIPE_FORMAT_R8G8B8A8_SINT +}; + static GLuint fixed_types[4] = { PIPE_FORMAT_R32_FIXED, PIPE_FORMAT_R32G32_FIXED, @@ -186,7 +228,7 @@ static GLuint fixed_types[4] = { */ enum pipe_format st_pipe_vertex_format(GLenum type, GLuint size, GLenum format, - GLboolean normalized) + GLboolean normalized, GLboolean integer) { assert((type >= GL_BYTE && type <= GL_DOUBLE) || type == GL_FIXED || type == GL_HALF_FLOAT || @@ -199,6 +241,7 @@ st_pipe_vertex_format(GLenum type, GLuint size, GLenum format, if (type == GL_INT_2_10_10_10_REV || type == GL_UNSIGNED_INT_2_10_10_10_REV) { assert(size == 4); + assert(!integer); if (format == GL_BGRA) { if (type == GL_INT_2_10_10_10_REV) { @@ -234,7 +277,18 @@ st_pipe_vertex_format(GLenum type, GLuint size, GLenum format, return PIPE_FORMAT_B8G8R8A8_UNORM; } - if (normalized) { + if (integer) { + switch (type) { + case GL_INT: return int_types_int[size-1]; + case GL_SHORT: return short_types_int[size-1]; + case GL_BYTE: return byte_types_int[size-1]; + case GL_UNSIGNED_INT: return uint_types_int[size-1]; + case GL_UNSIGNED_SHORT: return ushort_types_int[size-1]; + case GL_UNSIGNED_BYTE: return ubyte_types_int[size-1]; + default: assert(0); return 0; + } + } + else if (normalized) { switch (type) { case GL_DOUBLE: return double_types[size-1]; case GL_FLOAT: return float_types[size-1]; @@ -407,7 +461,8 @@ setup_interleaved_attribs(struct gl_context *ctx, velements[attr].src_format = st_pipe_vertex_format(array->Type, array->Size, array->Format, - array->Normalized); + array->Normalized, + array->Integer); assert(velements[attr].src_format); if (!usingVBO) { @@ -564,7 +619,8 @@ setup_non_interleaved_attribs(struct gl_context *ctx, velements[attr].src_format = st_pipe_vertex_format(array->Type, array->Size, array->Format, - array->Normalized); + array->Normalized, + array->Integer); assert(velements[attr].src_format); } diff --git a/src/mesa/state_tracker/st_draw.h b/src/mesa/state_tracker/st_draw.h index 2623cdbb1ff..47bdb11f81c 100644 --- a/src/mesa/state_tracker/st_draw.h +++ b/src/mesa/state_tracker/st_draw.h @@ -73,7 +73,7 @@ st_feedback_draw_vbo(struct gl_context *ctx, */ extern enum pipe_format st_pipe_vertex_format(GLenum type, GLuint size, GLenum format, - GLboolean normalized); + GLboolean normalized, GLboolean integer); /** diff --git a/src/mesa/state_tracker/st_draw_feedback.c b/src/mesa/state_tracker/st_draw_feedback.c index a99eb2bf7d5..fbf0349b41b 100644 --- a/src/mesa/state_tracker/st_draw_feedback.c +++ b/src/mesa/state_tracker/st_draw_feedback.c @@ -196,7 +196,8 @@ st_feedback_draw_vbo(struct gl_context *ctx, st_pipe_vertex_format(arrays[mesaAttr]->Type, arrays[mesaAttr]->Size, arrays[mesaAttr]->Format, - arrays[mesaAttr]->Normalized); + arrays[mesaAttr]->Normalized, + arrays[mesaAttr]->Integer); assert(velements[attr].src_format); /* tell draw about this attribute */ |