diff options
Diffstat (limited to 'mesalib/src/mesa/main/varray.c')
-rw-r--r-- | mesalib/src/mesa/main/varray.c | 130 |
1 files changed, 80 insertions, 50 deletions
diff --git a/mesalib/src/mesa/main/varray.c b/mesalib/src/mesa/main/varray.c index 46956efb5..230fb30cb 100644 --- a/mesalib/src/mesa/main/varray.c +++ b/mesalib/src/mesa/main/varray.c @@ -24,6 +24,8 @@ */ +#include <inttypes.h> /* for PRId64 macro */ + #include "glheader.h" #include "imports.h" #include "bufferobj.h" @@ -46,21 +48,22 @@ /** Used to indicate which GL datatypes are accepted by each of the * glVertex/Color/Attrib/EtcPointer() functions. */ -#define BOOL_BIT 0x1 -#define BYTE_BIT 0x2 -#define UNSIGNED_BYTE_BIT 0x4 -#define SHORT_BIT 0x8 -#define UNSIGNED_SHORT_BIT 0x10 -#define INT_BIT 0x20 -#define UNSIGNED_INT_BIT 0x40 -#define HALF_BIT 0x80 -#define FLOAT_BIT 0x100 -#define DOUBLE_BIT 0x200 -#define FIXED_ES_BIT 0x400 -#define FIXED_GL_BIT 0x800 -#define UNSIGNED_INT_2_10_10_10_REV_BIT 0x1000 -#define INT_2_10_10_10_REV_BIT 0x2000 -#define UNSIGNED_INT_10F_11F_11F_REV_BIT 0x4000 +#define BOOL_BIT (1 << 0) +#define BYTE_BIT (1 << 1) +#define UNSIGNED_BYTE_BIT (1 << 2) +#define SHORT_BIT (1 << 3) +#define UNSIGNED_SHORT_BIT (1 << 4) +#define INT_BIT (1 << 5) +#define UNSIGNED_INT_BIT (1 << 6) +#define HALF_BIT (1 << 7) +#define FLOAT_BIT (1 << 8) +#define DOUBLE_BIT (1 << 9) +#define FIXED_ES_BIT (1 << 10) +#define FIXED_GL_BIT (1 << 11) +#define UNSIGNED_INT_2_10_10_10_REV_BIT (1 << 12) +#define INT_2_10_10_10_REV_BIT (1 << 13) +#define UNSIGNED_INT_10F_11F_11F_REV_BIT (1 << 14) +#define ALL_TYPE_BITS ((1 << 15) - 1) /** Convert GL datatype enum into a <type>_BIT value seen above */ @@ -179,6 +182,53 @@ vertex_binding_divisor(struct gl_context *ctx, GLuint bindingIndex, /** + * Examine the API profile and extensions to determine which types are legal + * for vertex arrays. This is called once from update_array_format(). + */ +static GLbitfield +get_legal_types_mask(const struct gl_context *ctx) +{ + GLbitfield legalTypesMask = ALL_TYPE_BITS; + + if (_mesa_is_gles(ctx)) { + legalTypesMask &= ~(FIXED_GL_BIT | + DOUBLE_BIT | + UNSIGNED_INT_10F_11F_11F_REV_BIT); + + /* GL_INT and GL_UNSIGNED_INT data is not allowed in OpenGL ES until + * 3.0. The 2_10_10_10 types are added in OpenGL ES 3.0 or + * GL_OES_vertex_type_10_10_10_2. GL_HALF_FLOAT data is not allowed + * until 3.0 or with the GL_OES_vertex_half float extension, which isn't + * quite as trivial as we'd like because it uses a different enum value + * for GL_HALF_FLOAT_OES. + */ + if (ctx->Version < 30) { + legalTypesMask &= ~(UNSIGNED_INT_BIT | + INT_BIT | + UNSIGNED_INT_2_10_10_10_REV_BIT | + INT_2_10_10_10_REV_BIT | + HALF_BIT); + } + } + else { + legalTypesMask &= ~FIXED_ES_BIT; + + if (!ctx->Extensions.ARB_ES2_compatibility) + legalTypesMask &= ~FIXED_GL_BIT; + + if (!ctx->Extensions.ARB_vertex_type_2_10_10_10_rev) + legalTypesMask &= ~(UNSIGNED_INT_2_10_10_10_REV_BIT | + INT_2_10_10_10_REV_BIT); + + if (!ctx->Extensions.ARB_vertex_type_10f_11f_11f_rev) + legalTypesMask &= ~UNSIGNED_INT_10F_11F_11F_REV_BIT; + } + + return legalTypesMask; +} + + +/** * Does error checking and updates the format in an attrib array. * * Called by update_array() and VertexAttrib*Format(). @@ -208,40 +258,19 @@ update_array_format(struct gl_context *ctx, GLuint elementSize; GLenum format = GL_RGBA; - if (_mesa_is_gles(ctx)) { - legalTypesMask &= ~(FIXED_GL_BIT | DOUBLE_BIT | UNSIGNED_INT_10F_11F_11F_REV_BIT); - - /* GL_INT and GL_UNSIGNED_INT data is not allowed in OpenGL ES until - * 3.0. The 2_10_10_10 types are added in OpenGL ES 3.0 or - * GL_OES_vertex_type_10_10_10_2. GL_HALF_FLOAT data is not allowed - * until 3.0 or with the GL_OES_vertex_half float extension, which isn't - * quite as trivial as we'd like because it uses a different enum value - * for GL_HALF_FLOAT_OES. + if (ctx->Array.LegalTypesMask == 0) { + /* One-time initialization. We can't do this in _mesa_init_varrays() + * below because extensions are not yet enabled at that point. */ - if (ctx->Version < 30) { - legalTypesMask &= ~(UNSIGNED_INT_BIT - | INT_BIT - | UNSIGNED_INT_2_10_10_10_REV_BIT - | INT_2_10_10_10_REV_BIT - | HALF_BIT); - } + ctx->Array.LegalTypesMask = get_legal_types_mask(ctx); + } + + legalTypesMask &= ctx->Array.LegalTypesMask; + if (_mesa_is_gles(ctx) && sizeMax == BGRA_OR_4) { /* BGRA ordering is not supported in ES contexts. */ - if (sizeMax == BGRA_OR_4) - sizeMax = 4; - } else { - legalTypesMask &= ~FIXED_ES_BIT; - - if (!ctx->Extensions.ARB_ES2_compatibility) - legalTypesMask &= ~FIXED_GL_BIT; - - if (!ctx->Extensions.ARB_vertex_type_2_10_10_10_rev) - legalTypesMask &= ~(UNSIGNED_INT_2_10_10_10_REV_BIT | - INT_2_10_10_10_REV_BIT); - - if (!ctx->Extensions.ARB_vertex_type_10f_11f_11f_rev) - legalTypesMask &= ~UNSIGNED_INT_10F_11F_11F_REV_BIT; + sizeMax = 4; } typeBit = type_to_bit(ctx, type); @@ -1397,7 +1426,8 @@ _mesa_BindVertexBuffer(GLuint bindingIndex, GLuint buffer, GLintptr offset, */ if (offset < 0) { _mesa_error(ctx, GL_INVALID_VALUE, - "glBindVertexBuffer(offset=%lld < 0)", (long long)offset); + "glBindVertexBuffer(offset=%" PRId64 " < 0)", + (int64_t) offset); return; } @@ -1523,15 +1553,15 @@ _mesa_BindVertexBuffers(GLuint first, GLsizei count, const GLuint *buffers, */ if (offsets[i] < 0) { _mesa_error(ctx, GL_INVALID_VALUE, - "glBindVertexBuffer(offsets[%u]=%lldd < 0)", - i, (long long int) offsets[i]); + "glBindVertexBuffer(offsets[%u]=%" PRId64 " < 0)", + i, (int64_t) offsets[i]); continue; } if (strides[i] < 0) { _mesa_error(ctx, GL_INVALID_VALUE, - "glBindVertexBuffer(strides[%u]=%lld < 0)", - i, (long long int) strides[i]); + "glBindVertexBuffer(strides[%u]=%d < 0)", + i, strides[i]); continue; } |