diff options
Diffstat (limited to 'mesalib/src/mesa/main')
-rw-r--r-- | mesalib/src/mesa/main/api_validate.c | 56 | ||||
-rw-r--r-- | mesalib/src/mesa/main/api_validate.h | 6 | ||||
-rw-r--r-- | mesalib/src/mesa/main/attrib.c | 3 | ||||
-rw-r--r-- | mesalib/src/mesa/main/context.c | 11 | ||||
-rw-r--r-- | mesalib/src/mesa/main/errors.c | 172 | ||||
-rw-r--r-- | mesalib/src/mesa/main/extensions.c | 1 | ||||
-rw-r--r-- | mesalib/src/mesa/main/get_hash_params.py | 5 | ||||
-rw-r--r-- | mesalib/src/mesa/main/imports.c | 19 | ||||
-rw-r--r-- | mesalib/src/mesa/main/imports.h | 3 | ||||
-rw-r--r-- | mesalib/src/mesa/main/mtypes.h | 5 | ||||
-rw-r--r-- | mesalib/src/mesa/main/shaderapi.c | 6 | ||||
-rw-r--r-- | mesalib/src/mesa/main/sse_minmax.c | 97 | ||||
-rw-r--r-- | mesalib/src/mesa/main/sse_minmax.h | 30 | ||||
-rw-r--r-- | mesalib/src/mesa/main/streaming-load-memcpy.c | 3 | ||||
-rw-r--r-- | mesalib/src/mesa/main/texformat.c | 3 | ||||
-rw-r--r-- | mesalib/src/mesa/main/texstore.c | 4 | ||||
-rw-r--r-- | mesalib/src/mesa/main/uniform_query.cpp | 260 | ||||
-rw-r--r-- | mesalib/src/mesa/main/uniforms.c | 98 | ||||
-rw-r--r-- | mesalib/src/mesa/main/uniforms.h | 4 | ||||
-rw-r--r-- | mesalib/src/mesa/main/viewport.c | 8 |
20 files changed, 439 insertions, 355 deletions
diff --git a/mesalib/src/mesa/main/api_validate.c b/mesalib/src/mesa/main/api_validate.c index 9b80600de..bf4fa3ea8 100644 --- a/mesalib/src/mesa/main/api_validate.c +++ b/mesalib/src/mesa/main/api_validate.c @@ -55,52 +55,6 @@ index_bytes(GLenum type, GLsizei count) /** - * Find the max index in the given element/index buffer - */ -GLuint -_mesa_max_buffer_index(struct gl_context *ctx, GLuint count, GLenum type, - const void *indices, - struct gl_buffer_object *elementBuf) -{ - const GLubyte *map = NULL; - GLuint max = 0; - GLuint i; - - if (_mesa_is_bufferobj(elementBuf)) { - /* elements are in a user-defined buffer object. need to map it */ - map = ctx->Driver.MapBufferRange(ctx, 0, elementBuf->Size, - GL_MAP_READ_BIT, elementBuf, - MAP_INTERNAL); - /* Actual address is the sum of pointers */ - indices = (const GLvoid *) ADD_POINTERS(map, (const GLubyte *) indices); - } - - if (type == GL_UNSIGNED_INT) { - for (i = 0; i < count; i++) - if (((GLuint *) indices)[i] > max) - max = ((GLuint *) indices)[i]; - } - else if (type == GL_UNSIGNED_SHORT) { - for (i = 0; i < count; i++) - if (((GLushort *) indices)[i] > max) - max = ((GLushort *) indices)[i]; - } - else { - ASSERT(type == GL_UNSIGNED_BYTE); - for (i = 0; i < count; i++) - if (((GLubyte *) indices)[i] > max) - max = ((GLubyte *) indices)[i]; - } - - if (map) { - ctx->Driver.UnmapBuffer(ctx, elementBuf, MAP_INTERNAL); - } - - return max; -} - - -/** * Check if OK to draw arrays/elements. */ static GLboolean @@ -749,17 +703,17 @@ _mesa_validate_DrawTransformFeedback(struct gl_context *ctx, return GL_FALSE; } - if (!obj->EndedAnytime) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glDrawTransformFeedback*"); - return GL_FALSE; - } - if (stream >= ctx->Const.MaxVertexStreams) { _mesa_error(ctx, GL_INVALID_VALUE, "glDrawTransformFeedbackStream*(index>=MaxVertexStream)"); return GL_FALSE; } + if (!obj->EndedAnytime) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glDrawTransformFeedback*"); + return GL_FALSE; + } + if (numInstances <= 0) { if (numInstances < 0) _mesa_error(ctx, GL_INVALID_VALUE, diff --git a/mesalib/src/mesa/main/api_validate.h b/mesalib/src/mesa/main/api_validate.h index 8238df16c..0bb91c675 100644 --- a/mesalib/src/mesa/main/api_validate.h +++ b/mesalib/src/mesa/main/api_validate.h @@ -35,12 +35,6 @@ struct gl_context; struct gl_transform_feedback_object; -extern GLuint -_mesa_max_buffer_index(struct gl_context *ctx, GLuint count, GLenum type, - const void *indices, - struct gl_buffer_object *elementBuf); - - extern bool _mesa_is_valid_prim_mode(struct gl_context *ctx, GLenum mode); diff --git a/mesalib/src/mesa/main/attrib.c b/mesalib/src/mesa/main/attrib.c index 5345339f6..4684615a8 100644 --- a/mesalib/src/mesa/main/attrib.c +++ b/mesalib/src/mesa/main/attrib.c @@ -1345,7 +1345,8 @@ _mesa_PopAttrib(void) if (xform->DepthClamp != ctx->Transform.DepthClamp) _mesa_set_enable(ctx, GL_DEPTH_CLAMP, ctx->Transform.DepthClamp); - _mesa_ClipControl(xform->ClipOrigin, xform->ClipDepthMode); + if (ctx->Extensions.ARB_clip_control) + _mesa_ClipControl(xform->ClipOrigin, xform->ClipDepthMode); } break; case GL_TEXTURE_BIT: diff --git a/mesalib/src/mesa/main/context.c b/mesalib/src/mesa/main/context.c index 25b9bfc4c..400c158a7 100644 --- a/mesalib/src/mesa/main/context.c +++ b/mesalib/src/mesa/main/context.c @@ -719,6 +719,9 @@ _mesa_init_constants(struct gl_constants *consts, gl_api api) /** GL_ARB_gpu_shader5 */ consts->MinFragmentInterpolationOffset = MIN_FRAGMENT_INTERPOLATION_OFFSET; consts->MaxFragmentInterpolationOffset = MAX_FRAGMENT_INTERPOLATION_OFFSET; + + /** GL_KHR_context_flush_control */ + consts->ContextReleaseBehavior = GL_CONTEXT_RELEASE_BEHAVIOR_FLUSH; } @@ -729,6 +732,8 @@ _mesa_init_constants(struct gl_constants *consts, gl_api api) static void check_context_limits(struct gl_context *ctx) { + (void) ctx; + /* check that we don't exceed the size of various bitfields */ assert(VARYING_SLOT_MAX <= (8 * sizeof(ctx->VertexProgram._Current->Base.OutputsWritten))); @@ -1622,9 +1627,11 @@ _mesa_make_current( struct gl_context *newCtx, } if (curCtx && - (curCtx->WinSysDrawBuffer || curCtx->WinSysReadBuffer) && + (curCtx->WinSysDrawBuffer || curCtx->WinSysReadBuffer) && /* make sure this context is valid for flushing */ - curCtx != newCtx) + curCtx != newCtx && + curCtx->Const.ContextReleaseBehavior == + GL_CONTEXT_RELEASE_BEHAVIOR_FLUSH) _mesa_flush(curCtx); /* We used to call _glapi_check_multithread() here. Now do it in drivers */ diff --git a/mesalib/src/mesa/main/errors.c b/mesalib/src/mesa/main/errors.c index 25171f0ee..7d622bb16 100644 --- a/mesalib/src/mesa/main/errors.c +++ b/mesalib/src/mesa/main/errors.c @@ -676,22 +676,41 @@ debug_pop_group(struct gl_debug_state *debug) /** - * Return debug state for the context. The debug state will be allocated - * and initialized upon the first call. + * Lock and return debug state for the context. The debug state will be + * allocated and initialized upon the first call. When NULL is returned, the + * debug state is not locked. */ static struct gl_debug_state * -_mesa_get_debug_state(struct gl_context *ctx) +_mesa_lock_debug_state(struct gl_context *ctx) { + mtx_lock(&ctx->DebugMutex); + if (!ctx->Debug) { ctx->Debug = debug_create(); if (!ctx->Debug) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "allocating debug state"); + GET_CURRENT_CONTEXT(cur); + mtx_unlock(&ctx->DebugMutex); + + /* + * This function may be called from other threads. When that is the + * case, we cannot record this OOM error. + */ + if (ctx == cur) + _mesa_error(ctx, GL_OUT_OF_MEMORY, "allocating debug state"); + + return NULL; } } return ctx->Debug; } +static void +_mesa_unlock_debug_state(struct gl_context *ctx) +{ + mtx_unlock(&ctx->DebugMutex); +} + /** * Set the integer debug state specified by \p pname. This can be called from * _mesa_set_enable for example. @@ -699,7 +718,7 @@ _mesa_get_debug_state(struct gl_context *ctx) bool _mesa_set_debug_state_int(struct gl_context *ctx, GLenum pname, GLint val) { - struct gl_debug_state *debug = _mesa_get_debug_state(ctx); + struct gl_debug_state *debug = _mesa_lock_debug_state(ctx); if (!debug) return false; @@ -716,6 +735,8 @@ _mesa_set_debug_state_int(struct gl_context *ctx, GLenum pname, GLint val) break; } + _mesa_unlock_debug_state(ctx); + return true; } @@ -729,9 +750,12 @@ _mesa_get_debug_state_int(struct gl_context *ctx, GLenum pname) struct gl_debug_state *debug; GLint val; + mtx_lock(&ctx->DebugMutex); debug = ctx->Debug; - if (!debug) + if (!debug) { + mtx_unlock(&ctx->DebugMutex); return 0; + } switch (pname) { case GL_DEBUG_OUTPUT: @@ -756,6 +780,8 @@ _mesa_get_debug_state_int(struct gl_context *ctx, GLenum pname) break; } + mtx_unlock(&ctx->DebugMutex); + return val; } @@ -769,9 +795,12 @@ _mesa_get_debug_state_ptr(struct gl_context *ctx, GLenum pname) struct gl_debug_state *debug; void *val; + mtx_lock(&ctx->DebugMutex); debug = ctx->Debug; - if (!debug) + if (!debug) { + mtx_unlock(&ctx->DebugMutex); return NULL; + } switch (pname) { case GL_DEBUG_CALLBACK_FUNCTION_ARB: @@ -786,9 +815,49 @@ _mesa_get_debug_state_ptr(struct gl_context *ctx, GLenum pname) break; } + mtx_unlock(&ctx->DebugMutex); + return val; } +/** + * Insert a debug message. The mutex is assumed to be locked, and will be + * unlocked by this call. + */ +static void +log_msg_locked_and_unlock(struct gl_context *ctx, + enum mesa_debug_source source, + enum mesa_debug_type type, GLuint id, + enum mesa_debug_severity severity, + GLint len, const char *buf) +{ + struct gl_debug_state *debug = ctx->Debug; + + if (!debug_is_message_enabled(debug, source, type, id, severity)) { + _mesa_unlock_debug_state(ctx); + return; + } + + if (ctx->Debug->Callback) { + GLenum gl_source = debug_source_enums[source]; + GLenum gl_type = debug_type_enums[type]; + GLenum gl_severity = debug_severity_enums[severity]; + GLDEBUGPROC callback = ctx->Debug->Callback; + const void *data = ctx->Debug->CallbackData; + + /* + * When ctx->Debug->SyncOutput is GL_FALSE, the client is prepared for + * unsynchronous calls. When it is GL_TRUE, we will not spawn threads. + * In either case, we can call the callback unlocked. + */ + _mesa_unlock_debug_state(ctx); + callback(gl_source, gl_type, id, gl_severity, len, buf, data); + } + else { + debug_log_message(ctx->Debug, source, type, id, severity, len, buf); + _mesa_unlock_debug_state(ctx); + } +} /** * Log a client or driver debug message. @@ -798,24 +867,12 @@ log_msg(struct gl_context *ctx, enum mesa_debug_source source, enum mesa_debug_type type, GLuint id, enum mesa_debug_severity severity, GLint len, const char *buf) { - struct gl_debug_state *debug = _mesa_get_debug_state(ctx); + struct gl_debug_state *debug = _mesa_lock_debug_state(ctx); if (!debug) return; - if (!debug_is_message_enabled(debug, source, type, id, severity)) - return; - - if (debug->Callback) { - GLenum gl_type = debug_type_enums[type]; - GLenum gl_severity = debug_severity_enums[severity]; - - debug->Callback(debug_source_enums[source], gl_type, id, gl_severity, - len, buf, debug->CallbackData); - return; - } - - debug_log_message(debug, source, type, id, severity, len, buf); + log_msg_locked_and_unlock(ctx, source, type, id, severity, len, buf); } @@ -956,7 +1013,7 @@ _mesa_GetDebugMessageLog(GLuint count, GLsizei logSize, GLenum *sources, return 0; } - debug = _mesa_get_debug_state(ctx); + debug = _mesa_lock_debug_state(ctx); if (!debug) return 0; @@ -991,6 +1048,8 @@ _mesa_GetDebugMessageLog(GLuint count, GLsizei logSize, GLenum *sources, debug_delete_messages(debug, 1); } + _mesa_unlock_debug_state(ctx); + return ret; } @@ -1027,7 +1086,7 @@ _mesa_DebugMessageControl(GLenum gl_source, GLenum gl_type, return; } - debug = _mesa_get_debug_state(ctx); + debug = _mesa_lock_debug_state(ctx); if (!debug) return; @@ -1039,6 +1098,8 @@ _mesa_DebugMessageControl(GLenum gl_source, GLenum gl_type, else { debug_set_message_enable_all(debug, source, type, severity, enabled); } + + _mesa_unlock_debug_state(ctx); } @@ -1046,10 +1107,11 @@ void GLAPIENTRY _mesa_DebugMessageCallback(GLDEBUGPROC callback, const void *userParam) { GET_CURRENT_CONTEXT(ctx); - struct gl_debug_state *debug = _mesa_get_debug_state(ctx); + struct gl_debug_state *debug = _mesa_lock_debug_state(ctx); if (debug) { debug->Callback = callback; debug->CallbackData = userParam; + _mesa_unlock_debug_state(ctx); } } @@ -1059,18 +1121,10 @@ _mesa_PushDebugGroup(GLenum source, GLuint id, GLsizei length, const GLchar *message) { GET_CURRENT_CONTEXT(ctx); - struct gl_debug_state *debug = _mesa_get_debug_state(ctx); const char *callerstr = "glPushDebugGroup"; + struct gl_debug_state *debug; struct gl_debug_message *emptySlot; - if (!debug) - return; - - if (debug->GroupStackDepth >= MAX_DEBUG_GROUP_STACK_DEPTH-1) { - _mesa_error(ctx, GL_STACK_OVERFLOW, "%s", callerstr); - return; - } - switch(source) { case GL_DEBUG_SOURCE_APPLICATION: case GL_DEBUG_SOURCE_THIRD_PARTY: @@ -1086,10 +1140,15 @@ _mesa_PushDebugGroup(GLenum source, GLuint id, GLsizei length, if (!validate_length(ctx, callerstr, length)) return; /* GL_INVALID_VALUE */ - log_msg(ctx, gl_enum_to_debug_source(source), - MESA_DEBUG_TYPE_PUSH_GROUP, id, - MESA_DEBUG_SEVERITY_NOTIFICATION, length, - message); + debug = _mesa_lock_debug_state(ctx); + if (!debug) + return; + + if (debug->GroupStackDepth >= MAX_DEBUG_GROUP_STACK_DEPTH-1) { + _mesa_unlock_debug_state(ctx); + _mesa_error(ctx, GL_STACK_OVERFLOW, "%s", callerstr); + return; + } /* pop reuses the message details from push so we store this */ emptySlot = debug_get_group_message(debug); @@ -1101,6 +1160,12 @@ _mesa_PushDebugGroup(GLenum source, GLuint id, GLsizei length, length, message); debug_push_group(debug); + + log_msg_locked_and_unlock(ctx, + gl_enum_to_debug_source(source), + MESA_DEBUG_TYPE_PUSH_GROUP, id, + MESA_DEBUG_SEVERITY_NOTIFICATION, length, + message); } @@ -1108,35 +1173,43 @@ void GLAPIENTRY _mesa_PopDebugGroup(void) { GET_CURRENT_CONTEXT(ctx); - struct gl_debug_state *debug = _mesa_get_debug_state(ctx); const char *callerstr = "glPopDebugGroup"; - struct gl_debug_message *gdmessage; + struct gl_debug_state *debug; + struct gl_debug_message *gdmessage, msg; + debug = _mesa_lock_debug_state(ctx); if (!debug) return; if (debug->GroupStackDepth <= 0) { + _mesa_unlock_debug_state(ctx); _mesa_error(ctx, GL_STACK_UNDERFLOW, "%s", callerstr); return; } debug_pop_group(debug); + /* make a shallow copy */ gdmessage = debug_get_group_message(debug); - log_msg(ctx, gdmessage->source, - gl_enum_to_debug_type(GL_DEBUG_TYPE_POP_GROUP), - gdmessage->id, - gl_enum_to_debug_severity(GL_DEBUG_SEVERITY_NOTIFICATION), - gdmessage->length, gdmessage->message); - - debug_message_clear(gdmessage); + msg = *gdmessage; + gdmessage->message = NULL; + gdmessage->length = 0; + + log_msg_locked_and_unlock(ctx, + msg.source, + gl_enum_to_debug_type(GL_DEBUG_TYPE_POP_GROUP), + msg.id, + gl_enum_to_debug_severity(GL_DEBUG_SEVERITY_NOTIFICATION), + msg.length, msg.message); + + debug_message_clear(&msg); } void _mesa_init_errors(struct gl_context *ctx) { - /* no-op */ + mtx_init(&ctx->DebugMutex, mtx_plain); } @@ -1148,6 +1221,8 @@ _mesa_free_errors_data(struct gl_context *ctx) /* set to NULL just in case it is used before context is completely gone. */ ctx->Debug = NULL; } + + mtx_destroy(&ctx->DebugMutex); } @@ -1362,6 +1437,8 @@ _mesa_error( struct gl_context *ctx, GLenum error, const char *fmtString, ... ) debug_get_id(&error_msg_id); do_output = should_output(ctx, error, fmtString); + + mtx_lock(&ctx->DebugMutex); if (ctx->Debug) { do_log = debug_is_message_enabled(ctx->Debug, MESA_DEBUG_SOURCE_API, @@ -1372,6 +1449,7 @@ _mesa_error( struct gl_context *ctx, GLenum error, const char *fmtString, ... ) else { do_log = GL_FALSE; } + mtx_unlock(&ctx->DebugMutex); if (do_output || do_log) { char s[MAX_DEBUG_MESSAGE_LENGTH], s2[MAX_DEBUG_MESSAGE_LENGTH]; diff --git a/mesalib/src/mesa/main/extensions.c b/mesalib/src/mesa/main/extensions.c index 15d66a744..0df04c2e6 100644 --- a/mesalib/src/mesa/main/extensions.c +++ b/mesalib/src/mesa/main/extensions.c @@ -320,6 +320,7 @@ static const struct extension extension_table[] = { /* KHR extensions */ { "GL_KHR_debug", o(dummy_true), GL, 2012 }, + { "GL_KHR_context_flush_control", o(dummy_true), GL | ES2, 2014 }, /* Vendor extensions */ { "GL_3DFX_texture_compression_FXT1", o(TDFX_texture_compression_FXT1), GL, 1999 }, diff --git a/mesalib/src/mesa/main/get_hash_params.py b/mesalib/src/mesa/main/get_hash_params.py index aa9f282d8..09a61acc1 100644 --- a/mesalib/src/mesa/main/get_hash_params.py +++ b/mesalib/src/mesa/main/get_hash_params.py @@ -318,6 +318,9 @@ descriptor=[ [ "PERFQUERY_COUNTER_NAME_LENGTH_MAX_INTEL", "CONST(MAX_PERFQUERY_COUNTER_NAME_LENGTH), extra_INTEL_performance_query" ], [ "PERFQUERY_COUNTER_DESC_LENGTH_MAX_INTEL", "CONST(MAX_PERFQUERY_COUNTER_DESC_LENGTH), extra_INTEL_performance_query" ], [ "PERFQUERY_GPA_EXTENDED_COUNTERS_INTEL", "CONST(PERFQUERY_HAVE_GPA_EXTENDED_COUNTERS), extra_INTEL_performance_query" ], + +# GL_KHR_context_flush_control + [ "CONTEXT_RELEASE_BEHAVIOR", "CONTEXT_ENUM(Const.ContextReleaseBehavior), NO_EXTRA" ], ]}, # GLES3 is not a typo. @@ -624,7 +627,7 @@ descriptor=[ # == GL_CURRENT_MATRIX_NV [ "CURRENT_MATRIX_ARB", "LOC_CUSTOM, TYPE_MATRIX, 0, extra_ARB_vertex_program_ARB_fragment_program" ], # == GL_CURRENT_MATRIX_NV - [ "TRANSPOSE_CURRENT_MATRIX_ARB", "LOC_CUSTOM, TYPE_MATRIX, 0, extra_ARB_vertex_program_ARB_fragment_program" ], + [ "TRANSPOSE_CURRENT_MATRIX_ARB", "LOC_CUSTOM, TYPE_MATRIX_T, 0, extra_ARB_vertex_program_ARB_fragment_program" ], # == GL_PROGRAM_ERROR_POSITION_NV [ "PROGRAM_ERROR_POSITION_ARB", "CONTEXT_INT(Program.ErrorPos), extra_ARB_vertex_program_ARB_fragment_program" ], diff --git a/mesalib/src/mesa/main/imports.c b/mesalib/src/mesa/main/imports.c index b8c754815..4f5a2d11f 100644 --- a/mesalib/src/mesa/main/imports.c +++ b/mesalib/src/mesa/main/imports.c @@ -499,25 +499,6 @@ _mesa_strdup( const char *s ) } } -/** Wrapper around strtof() */ -float -_mesa_strtof( const char *s, char **end ) -{ -#if defined(_GNU_SOURCE) && !defined(__CYGWIN__) && !defined(__FreeBSD__) && \ - !defined(ANDROID) && !defined(__HAIKU__) && !defined(__UCLIBC__) && \ - !defined(__NetBSD__) - static locale_t loc = NULL; - if (!loc) { - loc = newlocale(LC_CTYPE_MASK, "C", NULL); - } - return strtof_l(s, end, loc); -#elif defined(_ISOC99_SOURCE) || (defined(_XOPEN_SOURCE) && _XOPEN_SOURCE >= 600) - return strtof(s, end); -#else - return (float)strtod(s, end); -#endif -} - /** Compute simple checksum/hash for a string */ unsigned int _mesa_str_checksum(const char *str) diff --git a/mesalib/src/mesa/main/imports.h b/mesalib/src/mesa/main/imports.h index 436d1651a..0fcba4fb9 100644 --- a/mesalib/src/mesa/main/imports.h +++ b/mesalib/src/mesa/main/imports.h @@ -540,9 +540,6 @@ _mesa_half_is_negative(GLhalfARB h) extern char * _mesa_strdup( const char *s ); -extern float -_mesa_strtof( const char *s, char **end ); - extern unsigned int _mesa_str_checksum(const char *str); diff --git a/mesalib/src/mesa/main/mtypes.h b/mesalib/src/mesa/main/mtypes.h index e1f1f1dde..7389baa1d 100644 --- a/mesalib/src/mesa/main/mtypes.h +++ b/mesalib/src/mesa/main/mtypes.h @@ -2843,6 +2843,7 @@ struct gl_shader_program /* post-link info: */ unsigned NumUserUniformStorage; + unsigned NumHiddenUniforms; struct gl_uniform_storage *UniformStorage; /** @@ -3680,6 +3681,9 @@ struct gl_constants GLboolean FakeSWMSAA; + /** GL_KHR_context_flush_control */ + GLenum ContextReleaseBehavior; + struct gl_shader_compiler_options ShaderCompilerOptions[MESA_SHADER_STAGES]; }; @@ -4390,6 +4394,7 @@ struct gl_context GLuint ErrorDebugCount; /* GL_ARB_debug_output/GL_KHR_debug */ + mtx_t DebugMutex; struct gl_debug_state *Debug; GLenum RenderMode; /**< either GL_RENDER, GL_SELECT, GL_FEEDBACK */ diff --git a/mesalib/src/mesa/main/shaderapi.c b/mesalib/src/mesa/main/shaderapi.c index 2be9092c1..66578204f 100644 --- a/mesalib/src/mesa/main/shaderapi.c +++ b/mesalib/src/mesa/main/shaderapi.c @@ -565,13 +565,15 @@ get_programiv(struct gl_context *ctx, GLuint program, GLenum pname, GLint *param *params = _mesa_longest_attribute_name_length(shProg); return; case GL_ACTIVE_UNIFORMS: - *params = shProg->NumUserUniformStorage; + *params = shProg->NumUserUniformStorage - shProg->NumHiddenUniforms; return; case GL_ACTIVE_UNIFORM_MAX_LENGTH: { unsigned i; GLint max_len = 0; + const unsigned num_uniforms = + shProg->NumUserUniformStorage - shProg->NumHiddenUniforms; - for (i = 0; i < shProg->NumUserUniformStorage; i++) { + for (i = 0; i < num_uniforms; i++) { /* Add one for the terminating NUL character for a non-array, and * 4 for the "[0]" and the NUL for an array. */ diff --git a/mesalib/src/mesa/main/sse_minmax.c b/mesalib/src/mesa/main/sse_minmax.c new file mode 100644 index 000000000..222ac1454 --- /dev/null +++ b/mesalib/src/mesa/main/sse_minmax.c @@ -0,0 +1,97 @@ +/* + * Copyright © 2014 Timothy Arceri + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + * + * Author: + * Timothy Arceri <t_arceri@yahoo.com.au> + * + */ + +#ifdef __SSE4_1__ +#include "main/sse_minmax.h" +#include <smmintrin.h> +#include <stdint.h> + +void +_mesa_uint_array_min_max(const unsigned *ui_indices, unsigned *min_index, + unsigned *max_index, const unsigned count) +{ + unsigned max_ui = 0; + unsigned min_ui = ~0U; + unsigned i = 0; + unsigned aligned_count = count; + + /* handle the first few values without SSE until the pointer is aligned */ + while (((uintptr_t)ui_indices & 15) && aligned_count) { + if (*ui_indices > max_ui) + max_ui = *ui_indices; + if (*ui_indices < min_ui) + min_ui = *ui_indices; + + aligned_count--; + ui_indices++; + } + + /* TODO: The actual threshold for SSE begin useful may be higher than 8. + * Some careful microbenchmarks and measurement are required to + * find the actual tipping point. + */ + if (aligned_count >= 8) { + unsigned max_arr[4] __attribute__ ((aligned (16))); + unsigned min_arr[4] __attribute__ ((aligned (16))); + unsigned vec_count; + __m128i max_ui4 = _mm_setzero_si128(); + __m128i min_ui4 = _mm_set1_epi32(~0U); + __m128i ui_indices4; + __m128i *ui_indices_ptr; + + vec_count = aligned_count & ~0x3; + ui_indices_ptr = (__m128i *)ui_indices; + for (i = 0; i < vec_count / 4; i++) { + ui_indices4 = _mm_load_si128(&ui_indices_ptr[i]); + max_ui4 = _mm_max_epu32(ui_indices4, max_ui4); + min_ui4 = _mm_min_epu32(ui_indices4, min_ui4); + } + + _mm_store_si128((__m128i *)max_arr, max_ui4); + _mm_store_si128((__m128i *)min_arr, min_ui4); + + for (i = 0; i < 4; i++) { + if (max_arr[i] > max_ui) + max_ui = max_arr[i]; + if (min_arr[i] < min_ui) + min_ui = min_arr[i]; + } + i = vec_count; + } + + for (; i < aligned_count; i++) { + if (ui_indices[i] > max_ui) + max_ui = ui_indices[i]; + if (ui_indices[i] < min_ui) + min_ui = ui_indices[i]; + } + + *min_index = min_ui; + *max_index = max_ui; +} + +#endif diff --git a/mesalib/src/mesa/main/sse_minmax.h b/mesalib/src/mesa/main/sse_minmax.h new file mode 100644 index 000000000..953c4e9eb --- /dev/null +++ b/mesalib/src/mesa/main/sse_minmax.h @@ -0,0 +1,30 @@ +/* + * Copyright © 2014 Timothy Arceri + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + * + * Author: + * Timothy Arceri <t_arceri@yahoo.com.au> + * + */ + +void +_mesa_uint_array_min_max(const unsigned *ui_indices, unsigned *min_index, + unsigned *max_index, const unsigned count); diff --git a/mesalib/src/mesa/main/streaming-load-memcpy.c b/mesalib/src/mesa/main/streaming-load-memcpy.c index 8427149c5..d7147afdc 100644 --- a/mesalib/src/mesa/main/streaming-load-memcpy.c +++ b/mesalib/src/mesa/main/streaming-load-memcpy.c @@ -26,7 +26,6 @@ * */ -#ifdef __SSE4_1__ #include "main/macros.h" #include "main/streaming-load-memcpy.h" #include <smmintrin.h> @@ -84,5 +83,3 @@ _mesa_streaming_load_memcpy(void *restrict dst, void *restrict src, size_t len) memcpy(d, s, len); } } - -#endif diff --git a/mesalib/src/mesa/main/texformat.c b/mesalib/src/mesa/main/texformat.c index 832e66128..ec16af9d2 100644 --- a/mesalib/src/mesa/main/texformat.c +++ b/mesalib/src/mesa/main/texformat.c @@ -155,12 +155,14 @@ _mesa_choose_tex_format(struct gl_context *ctx, GLenum target, case GL_ALPHA4: case GL_ALPHA8: RETURN_IF_SUPPORTED(MESA_FORMAT_A_UNORM8); + RETURN_IF_SUPPORTED(MESA_FORMAT_L8A8_UNORM); break; case GL_ALPHA12: case GL_ALPHA16: RETURN_IF_SUPPORTED(MESA_FORMAT_A_UNORM16); RETURN_IF_SUPPORTED(MESA_FORMAT_A_UNORM8); + RETURN_IF_SUPPORTED(MESA_FORMAT_L8A8_UNORM); break; /* Luminance formats */ @@ -224,6 +226,7 @@ _mesa_choose_tex_format(struct gl_context *ctx, GLenum target, case GL_COMPRESSED_ALPHA_ARB: RETURN_IF_SUPPORTED(MESA_FORMAT_A_UNORM8); + RETURN_IF_SUPPORTED(MESA_FORMAT_L8A8_UNORM); break; case GL_COMPRESSED_LUMINANCE_ARB: RETURN_IF_SUPPORTED(MESA_FORMAT_L_UNORM8); diff --git a/mesalib/src/mesa/main/texstore.c b/mesalib/src/mesa/main/texstore.c index f913e42d3..f858cef50 100644 --- a/mesalib/src/mesa/main/texstore.c +++ b/mesalib/src/mesa/main/texstore.c @@ -1667,8 +1667,10 @@ texstore_rgba_integer(TEXSTORE_PARAMS) assert(is_array && !normalized); - if (!is_array) + if (!is_array) { + free(tmp_row); return GL_FALSE; + } invert_swizzle(dst2rgba, rgba2dst); compute_component_mapping(GL_RGBA, baseInternalFormat, base2rgba); diff --git a/mesalib/src/mesa/main/uniform_query.cpp b/mesalib/src/mesa/main/uniform_query.cpp index fcb14c4e2..32870d0c4 100644 --- a/mesalib/src/mesa/main/uniform_query.cpp +++ b/mesalib/src/mesa/main/uniform_query.cpp @@ -176,46 +176,13 @@ validate_uniform_parameters(struct gl_context *ctx, struct gl_shader_program *shProg, GLint location, GLsizei count, unsigned *array_index, - const char *caller, - bool negative_one_is_not_valid) + const char *caller) { - if (!shProg || !shProg->LinkStatus) { + if (shProg == NULL) { _mesa_error(ctx, GL_INVALID_OPERATION, "%s(program not linked)", caller); return NULL; } - if (location == -1) { - /* For glGetUniform, page 264 (page 278 of the PDF) of the OpenGL 2.1 - * spec says: - * - * "The error INVALID_OPERATION is generated if program has not been - * linked successfully, or if location is not a valid location for - * program." - * - * For glUniform, page 82 (page 96 of the PDF) of the OpenGL 2.1 spec - * says: - * - * "If the value of location is -1, the Uniform* commands will - * silently ignore the data passed in, and the current uniform - * values will not be changed." - * - * Allowing -1 for the location parameter of glUniform allows - * applications to avoid error paths in the case that, for example, some - * uniform variable is removed by the compiler / linker after - * optimization. In this case, the new value of the uniform is dropped - * on the floor. For the case of glGetUniform, there is nothing - * sensible to do for a location of -1. - * - * The negative_one_is_not_valid flag selects between the two behaviors. - */ - if (negative_one_is_not_valid) { - _mesa_error(ctx, GL_INVALID_OPERATION, "%s(location=%d)", - caller, location); - } - - return NULL; - } - /* From page 12 (page 26 of the PDF) of the OpenGL 2.1 spec: * * "If a negative number is provided where an argument of type sizei or @@ -226,10 +193,26 @@ validate_uniform_parameters(struct gl_context *ctx, return NULL; } - /* Check that the given location is in bounds of uniform remap table. */ - if (location >= (GLint) shProg->NumUniformRemapTable) { - _mesa_error(ctx, GL_INVALID_OPERATION, "%s(location=%d)", - caller, location); + /* Check that the given location is in bounds of uniform remap table. + * Unlinked programs will have NumUniformRemapTable == 0, so we can take + * the shProg->LinkStatus check out of the main path. + */ + if (unlikely(location >= (GLint) shProg->NumUniformRemapTable)) { + if (!shProg->LinkStatus) + _mesa_error(ctx, GL_INVALID_OPERATION, "%s(program not linked)", + caller); + else + _mesa_error(ctx, GL_INVALID_OPERATION, "%s(location=%d)", + caller, location); + + return NULL; + } + + if (location == -1) { + if (!shProg->LinkStatus) + _mesa_error(ctx, GL_INVALID_OPERATION, "%s(program not linked)", + caller); + return NULL; } @@ -269,27 +252,30 @@ validate_uniform_parameters(struct gl_context *ctx, struct gl_uniform_storage *const uni = shProg->UniformRemapTable[location]; - if (uni->array_elements == 0 && count > 1) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "%s(count > 1 for non-array, location=%d)", - caller, location); - return NULL; - } + if (uni->array_elements == 0) { + if (count > 1) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "%s(count > 1 for non-array, location=%d)", + caller, location); + return NULL; + } - /* The array index specified by the uniform location is just the uniform - * location minus the base location of of the uniform. - */ - *array_index = location - uni->remap_location; + assert((location - uni->remap_location) == 0); + *array_index = 0; + } else { + /* The array index specified by the uniform location is just the uniform + * location minus the base location of of the uniform. + */ + *array_index = location - uni->remap_location; - /* If the uniform is an array, check that array_index is in bounds. - * If not an array, check that array_index is zero. - * array_index is unsigned so no need to check for less than zero. - */ - const unsigned limit = MAX2(uni->array_elements, 1); - if (*array_index >= limit) { - _mesa_error(ctx, GL_INVALID_OPERATION, "%s(location=%d)", - caller, location); - return NULL; + /* If the uniform is an array, check that array_index is in bounds. + * array_index is unsigned so no need to check for less than zero. + */ + if (*array_index >= uni->array_elements) { + _mesa_error(ctx, GL_INVALID_OPERATION, "%s(location=%d)", + caller, location); + return NULL; + } } return uni; } @@ -308,9 +294,39 @@ _mesa_get_uniform(struct gl_context *ctx, GLuint program, GLint location, struct gl_uniform_storage *const uni = validate_uniform_parameters(ctx, shProg, location, 1, - &offset, "glGetUniform", true); - if (uni == NULL) + &offset, "glGetUniform"); + if (uni == NULL) { + /* For glGetUniform, page 264 (page 278 of the PDF) of the OpenGL 2.1 + * spec says: + * + * "The error INVALID_OPERATION is generated if program has not been + * linked successfully, or if location is not a valid location for + * program." + * + * For glUniform, page 82 (page 96 of the PDF) of the OpenGL 2.1 spec + * says: + * + * "If the value of location is -1, the Uniform* commands will + * silently ignore the data passed in, and the current uniform + * values will not be changed." + * + * Allowing -1 for the location parameter of glUniform allows + * applications to avoid error paths in the case that, for example, some + * uniform variable is removed by the compiler / linker after + * optimization. In this case, the new value of the uniform is dropped + * on the floor. For the case of glGetUniform, there is nothing + * sensible to do for a location of -1. + * + * If the location was -1, validate_unfirom_parameters will return NULL + * without raising an error. Raise the error here. + */ + if (location == -1) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glGetUniform(location=%d)", + location); + } + return; + } { unsigned elements = (uni->type->is_sampler()) @@ -342,8 +358,7 @@ _mesa_get_uniform(struct gl_context *ctx, GLuint program, GLint location, */ if (returnType == uni->type->base_type || ((returnType == GLSL_TYPE_INT - || returnType == GLSL_TYPE_UINT - || returnType == GLSL_TYPE_SAMPLER) + || returnType == GLSL_TYPE_UINT) && (uni->type->base_type == GLSL_TYPE_INT || uni->type->base_type == GLSL_TYPE_UINT @@ -583,93 +598,22 @@ _mesa_propagate_uniforms_to_driver_storage(struct gl_uniform_storage *uni, extern "C" void _mesa_uniform(struct gl_context *ctx, struct gl_shader_program *shProg, GLint location, GLsizei count, - const GLvoid *values, GLenum type) + const GLvoid *values, + enum glsl_base_type basicType, + unsigned src_components) { unsigned offset; - unsigned components; - unsigned src_components; - enum glsl_base_type basicType; struct gl_uniform_storage *const uni = validate_uniform_parameters(ctx, shProg, location, count, - &offset, "glUniform", false); + &offset, "glUniform"); if (uni == NULL) return; /* Verify that the types are compatible. */ - switch (type) { - case GL_FLOAT: - basicType = GLSL_TYPE_FLOAT; - src_components = 1; - break; - case GL_FLOAT_VEC2: - basicType = GLSL_TYPE_FLOAT; - src_components = 2; - break; - case GL_FLOAT_VEC3: - basicType = GLSL_TYPE_FLOAT; - src_components = 3; - break; - case GL_FLOAT_VEC4: - basicType = GLSL_TYPE_FLOAT; - src_components = 4; - break; - case GL_UNSIGNED_INT: - basicType = GLSL_TYPE_UINT; - src_components = 1; - break; - case GL_UNSIGNED_INT_VEC2: - basicType = GLSL_TYPE_UINT; - src_components = 2; - break; - case GL_UNSIGNED_INT_VEC3: - basicType = GLSL_TYPE_UINT; - src_components = 3; - break; - case GL_UNSIGNED_INT_VEC4: - basicType = GLSL_TYPE_UINT; - src_components = 4; - break; - case GL_INT: - basicType = GLSL_TYPE_INT; - src_components = 1; - break; - case GL_INT_VEC2: - basicType = GLSL_TYPE_INT; - src_components = 2; - break; - case GL_INT_VEC3: - basicType = GLSL_TYPE_INT; - src_components = 3; - break; - case GL_INT_VEC4: - basicType = GLSL_TYPE_INT; - src_components = 4; - break; - case GL_BOOL: - case GL_BOOL_VEC2: - case GL_BOOL_VEC3: - case GL_BOOL_VEC4: - case GL_FLOAT_MAT2: - case GL_FLOAT_MAT2x3: - case GL_FLOAT_MAT2x4: - case GL_FLOAT_MAT3x2: - case GL_FLOAT_MAT3: - case GL_FLOAT_MAT3x4: - case GL_FLOAT_MAT4x2: - case GL_FLOAT_MAT4x3: - case GL_FLOAT_MAT4: - default: - _mesa_problem(NULL, "Invalid type in %s", __func__); - return; - } - - if (uni->type->is_sampler()) { - components = 1; - } else { - components = uni->type->vector_elements; - } + const unsigned components = uni->type->is_sampler() + ? 1 : uni->type->vector_elements; bool match; switch (uni->type->base_type) { @@ -690,7 +634,7 @@ _mesa_uniform(struct gl_context *ctx, struct gl_shader_program *shProg, return; } - if (ctx->_Shader->Flags & GLSL_UNIFORMS) { + if (unlikely(ctx->_Shader->Flags & GLSL_UNIFORMS)) { log_uniform(values, basicType, components, 1, count, false, shProg, location, uni); } @@ -713,9 +657,7 @@ _mesa_uniform(struct gl_context *ctx, struct gl_shader_program *shProg, * GL_INVALID_VALUE error and ignore the command. */ if (uni->type->is_sampler()) { - int i; - - for (i = 0; i < count; i++) { + for (int i = 0; i < count; i++) { const unsigned texUnit = ((unsigned *) values)[i]; /* check that the sampler (tex unit index) is legal */ @@ -730,9 +672,7 @@ _mesa_uniform(struct gl_context *ctx, struct gl_shader_program *shProg, } if (uni->type->is_image()) { - int i; - - for (i = 0; i < count; i++) { + for (int i = 0; i < count; i++) { const int unit = ((GLint *) values)[i]; /* check that the image unit is legal */ @@ -772,9 +712,8 @@ _mesa_uniform(struct gl_context *ctx, struct gl_shader_program *shProg, (const union gl_constant_value *) values; union gl_constant_value *dst = &uni->storage[components * offset]; const unsigned elems = components * count; - unsigned i; - for (i = 0; i < elems; i++) { + for (unsigned i = 0; i < elems; i++) { if (basicType == GLSL_TYPE_FLOAT) { dst[i].i = src[i].f != 0.0f ? ctx->Const.UniformBooleanTrue : 0; } else { @@ -791,19 +730,16 @@ _mesa_uniform(struct gl_context *ctx, struct gl_shader_program *shProg, * the changes through. */ if (uni->type->is_sampler()) { - int i; - bool flushed = false; - for (i = 0; i < MESA_SHADER_STAGES; i++) { + for (int i = 0; i < MESA_SHADER_STAGES; i++) { struct gl_shader *const sh = shProg->_LinkedShaders[i]; - int j; /* If the shader stage doesn't use the sampler uniform, skip this. */ if (sh == NULL || !uni->sampler[i].active) continue; - for (j = 0; j < count; j++) { + for (int j = 0; j < count; j++) { sh->SamplerUnits[uni->sampler[i].index + offset + j] = ((unsigned *) values)[j]; } @@ -845,13 +781,11 @@ _mesa_uniform(struct gl_context *ctx, struct gl_shader_program *shProg, * uniforms to image units present in the shader data structure. */ if (uni->type->is_image()) { - int i, j; - - for (i = 0; i < MESA_SHADER_STAGES; i++) { + for (int i = 0; i < MESA_SHADER_STAGES; i++) { if (uni->image[i].active) { struct gl_shader *sh = shProg->_LinkedShaders[i]; - for (j = 0; j < count; j++) + for (int j = 0; j < count; j++) sh->ImageUnits[uni->image[i].index + offset + j] = ((GLint *) values)[j]; } @@ -878,7 +812,7 @@ _mesa_uniform_matrix(struct gl_context *ctx, struct gl_shader_program *shProg, struct gl_uniform_storage *const uni = validate_uniform_parameters(ctx, shProg, location, count, - &offset, "glUniformMatrix", false); + &offset, "glUniformMatrix"); if (uni == NULL) return; @@ -902,17 +836,17 @@ _mesa_uniform_matrix(struct gl_context *ctx, struct gl_shader_program *shProg, } /* GL_INVALID_VALUE is generated if `transpose' is not GL_FALSE. - * http://www.khronos.org/opengles/sdk/docs/man/xhtml/glUniform.xml */ - if (ctx->API == API_OPENGLES - || (ctx->API == API_OPENGLES2 && ctx->Version < 30)) { - if (transpose) { + * http://www.khronos.org/opengles/sdk/docs/man/xhtml/glUniform.xml + */ + if (transpose) { + if (ctx->API == API_OPENGLES2 && ctx->Version < 30) { _mesa_error(ctx, GL_INVALID_VALUE, "glUniformMatrix(matrix transpose is not GL_FALSE)"); return; } } - if (ctx->_Shader->Flags & GLSL_UNIFORMS) { + if (unlikely(ctx->_Shader->Flags & GLSL_UNIFORMS)) { log_uniform(values, GLSL_TYPE_FLOAT, components, vectors, count, bool(transpose), shProg, location, uni); } diff --git a/mesalib/src/mesa/main/uniforms.c b/mesalib/src/mesa/main/uniforms.c index c30710772..d2d70e7f7 100644 --- a/mesalib/src/mesa/main/uniforms.c +++ b/mesalib/src/mesa/main/uniforms.c @@ -151,7 +151,7 @@ void GLAPIENTRY _mesa_Uniform1f(GLint location, GLfloat v0) { GET_CURRENT_CONTEXT(ctx); - _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, 1, &v0, GL_FLOAT); + _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, 1, &v0, GLSL_TYPE_FLOAT, 1); } void GLAPIENTRY @@ -161,7 +161,7 @@ _mesa_Uniform2f(GLint location, GLfloat v0, GLfloat v1) GLfloat v[2]; v[0] = v0; v[1] = v1; - _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, 1, v, GL_FLOAT_VEC2); + _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, 1, v, GLSL_TYPE_FLOAT, 2); } void GLAPIENTRY @@ -172,7 +172,7 @@ _mesa_Uniform3f(GLint location, GLfloat v0, GLfloat v1, GLfloat v2) v[0] = v0; v[1] = v1; v[2] = v2; - _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, 1, v, GL_FLOAT_VEC3); + _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, 1, v, GLSL_TYPE_FLOAT, 3); } void GLAPIENTRY @@ -185,14 +185,14 @@ _mesa_Uniform4f(GLint location, GLfloat v0, GLfloat v1, GLfloat v2, v[1] = v1; v[2] = v2; v[3] = v3; - _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, 1, v, GL_FLOAT_VEC4); + _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, 1, v, GLSL_TYPE_FLOAT, 4); } void GLAPIENTRY _mesa_Uniform1i(GLint location, GLint v0) { GET_CURRENT_CONTEXT(ctx); - _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, 1, &v0, GL_INT); + _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, 1, &v0, GLSL_TYPE_INT, 1); } void GLAPIENTRY @@ -202,7 +202,7 @@ _mesa_Uniform2i(GLint location, GLint v0, GLint v1) GLint v[2]; v[0] = v0; v[1] = v1; - _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, 1, v, GL_INT_VEC2); + _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, 1, v, GLSL_TYPE_INT, 2); } void GLAPIENTRY @@ -213,7 +213,7 @@ _mesa_Uniform3i(GLint location, GLint v0, GLint v1, GLint v2) v[0] = v0; v[1] = v1; v[2] = v2; - _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, 1, v, GL_INT_VEC3); + _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, 1, v, GLSL_TYPE_INT, 3); } void GLAPIENTRY @@ -225,63 +225,63 @@ _mesa_Uniform4i(GLint location, GLint v0, GLint v1, GLint v2, GLint v3) v[1] = v1; v[2] = v2; v[3] = v3; - _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, 1, v, GL_INT_VEC4); + _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, 1, v, GLSL_TYPE_INT, 4); } void GLAPIENTRY _mesa_Uniform1fv(GLint location, GLsizei count, const GLfloat * value) { GET_CURRENT_CONTEXT(ctx); - _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, count, value, GL_FLOAT); + _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, count, value, GLSL_TYPE_FLOAT, 1); } void GLAPIENTRY _mesa_Uniform2fv(GLint location, GLsizei count, const GLfloat * value) { GET_CURRENT_CONTEXT(ctx); - _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, count, value, GL_FLOAT_VEC2); + _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, count, value, GLSL_TYPE_FLOAT, 2); } void GLAPIENTRY _mesa_Uniform3fv(GLint location, GLsizei count, const GLfloat * value) { GET_CURRENT_CONTEXT(ctx); - _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, count, value, GL_FLOAT_VEC3); + _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, count, value, GLSL_TYPE_FLOAT, 3); } void GLAPIENTRY _mesa_Uniform4fv(GLint location, GLsizei count, const GLfloat * value) { GET_CURRENT_CONTEXT(ctx); - _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, count, value, GL_FLOAT_VEC4); + _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, count, value, GLSL_TYPE_FLOAT, 4); } void GLAPIENTRY _mesa_Uniform1iv(GLint location, GLsizei count, const GLint * value) { GET_CURRENT_CONTEXT(ctx); - _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, count, value, GL_INT); + _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, count, value, GLSL_TYPE_INT, 1); } void GLAPIENTRY _mesa_Uniform2iv(GLint location, GLsizei count, const GLint * value) { GET_CURRENT_CONTEXT(ctx); - _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, count, value, GL_INT_VEC2); + _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, count, value, GLSL_TYPE_INT, 2); } void GLAPIENTRY _mesa_Uniform3iv(GLint location, GLsizei count, const GLint * value) { GET_CURRENT_CONTEXT(ctx); - _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, count, value, GL_INT_VEC3); + _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, count, value, GLSL_TYPE_INT, 3); } void GLAPIENTRY _mesa_Uniform4iv(GLint location, GLsizei count, const GLint * value) { GET_CURRENT_CONTEXT(ctx); - _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, count, value, GL_INT_VEC4); + _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, count, value, GLSL_TYPE_INT, 4); } /** Same as above with direct state access **/ @@ -292,7 +292,7 @@ _mesa_ProgramUniform1f(GLuint program, GLint location, GLfloat v0) struct gl_shader_program *shProg = _mesa_lookup_shader_program_err(ctx, program, "glProgramUniform1f"); - _mesa_uniform(ctx, shProg, location, 1, &v0, GL_FLOAT); + _mesa_uniform(ctx, shProg, location, 1, &v0, GLSL_TYPE_FLOAT, 1); } void GLAPIENTRY @@ -304,7 +304,7 @@ _mesa_ProgramUniform2f(GLuint program, GLint location, GLfloat v0, GLfloat v1) v[0] = v0; v[1] = v1; shProg = _mesa_lookup_shader_program_err(ctx, program, "glProgramUniform2f"); - _mesa_uniform(ctx, shProg, location, 1, v, GL_FLOAT_VEC2); + _mesa_uniform(ctx, shProg, location, 1, v, GLSL_TYPE_FLOAT, 2); } void GLAPIENTRY @@ -318,7 +318,7 @@ _mesa_ProgramUniform3f(GLuint program, GLint location, GLfloat v0, GLfloat v1, v[1] = v1; v[2] = v2; shProg = _mesa_lookup_shader_program_err(ctx, program, "glProgramUniform3f"); - _mesa_uniform(ctx, shProg, location, 1, v, GL_FLOAT_VEC3); + _mesa_uniform(ctx, shProg, location, 1, v, GLSL_TYPE_FLOAT, 3); } void GLAPIENTRY @@ -333,7 +333,7 @@ _mesa_ProgramUniform4f(GLuint program, GLint location, GLfloat v0, GLfloat v1, v[2] = v2; v[3] = v3; shProg = _mesa_lookup_shader_program_err(ctx, program, "glProgramUniform4f"); - _mesa_uniform(ctx, shProg, location, 1, v, GL_FLOAT_VEC4); + _mesa_uniform(ctx, shProg, location, 1, v, GLSL_TYPE_FLOAT, 4); } void GLAPIENTRY @@ -343,7 +343,7 @@ _mesa_ProgramUniform1i(GLuint program, GLint location, GLint v0) struct gl_shader_program *shProg = _mesa_lookup_shader_program_err(ctx, program, "glProgramUniform1i"); - _mesa_uniform(ctx, shProg, location, 1, &v0, GL_INT); + _mesa_uniform(ctx, shProg, location, 1, &v0, GLSL_TYPE_INT, 1); } void GLAPIENTRY @@ -355,7 +355,7 @@ _mesa_ProgramUniform2i(GLuint program, GLint location, GLint v0, GLint v1) v[0] = v0; v[1] = v1; shProg = _mesa_lookup_shader_program_err(ctx, program, "glProgramUniform2i"); - _mesa_uniform(ctx, shProg, location, 1, v, GL_INT_VEC2); + _mesa_uniform(ctx, shProg, location, 1, v, GLSL_TYPE_INT, 2); } void GLAPIENTRY @@ -369,7 +369,7 @@ _mesa_ProgramUniform3i(GLuint program, GLint location, GLint v0, GLint v1, v[1] = v1; v[2] = v2; shProg = _mesa_lookup_shader_program_err(ctx, program, "glProgramUniform3i"); - _mesa_uniform(ctx, shProg, location, 1, v, GL_INT_VEC3); + _mesa_uniform(ctx, shProg, location, 1, v, GLSL_TYPE_INT, 3); } void GLAPIENTRY @@ -384,7 +384,7 @@ _mesa_ProgramUniform4i(GLuint program, GLint location, GLint v0, GLint v1, v[2] = v2; v[3] = v3; shProg = _mesa_lookup_shader_program_err(ctx, program, "glProgramUniform4i"); - _mesa_uniform(ctx, shProg, location, 1, v, GL_INT_VEC4); + _mesa_uniform(ctx, shProg, location, 1, v, GLSL_TYPE_INT, 4); } void GLAPIENTRY @@ -395,7 +395,7 @@ _mesa_ProgramUniform1fv(GLuint program, GLint location, GLsizei count, struct gl_shader_program *shProg = _mesa_lookup_shader_program_err(ctx, program, "glProgramUniform1fv"); - _mesa_uniform(ctx, shProg, location, count, value, GL_FLOAT); + _mesa_uniform(ctx, shProg, location, count, value, GLSL_TYPE_FLOAT, 1); } void GLAPIENTRY @@ -406,7 +406,7 @@ _mesa_ProgramUniform2fv(GLuint program, GLint location, GLsizei count, struct gl_shader_program *shProg = _mesa_lookup_shader_program_err(ctx, program, "glProgramUniform2fv"); - _mesa_uniform(ctx, shProg, location, count, value, GL_FLOAT_VEC2); + _mesa_uniform(ctx, shProg, location, count, value, GLSL_TYPE_FLOAT, 2); } void GLAPIENTRY @@ -417,7 +417,7 @@ _mesa_ProgramUniform3fv(GLuint program, GLint location, GLsizei count, struct gl_shader_program *shProg = _mesa_lookup_shader_program_err(ctx, program, "glProgramUniform3fv"); - _mesa_uniform(ctx, shProg, location, count, value, GL_FLOAT_VEC3); + _mesa_uniform(ctx, shProg, location, count, value, GLSL_TYPE_FLOAT, 3); } void GLAPIENTRY @@ -428,7 +428,7 @@ _mesa_ProgramUniform4fv(GLuint program, GLint location, GLsizei count, struct gl_shader_program *shProg = _mesa_lookup_shader_program_err(ctx, program, "glProgramUniform4fv"); - _mesa_uniform(ctx, shProg, location, count, value, GL_FLOAT_VEC4); + _mesa_uniform(ctx, shProg, location, count, value, GLSL_TYPE_FLOAT, 4); } void GLAPIENTRY @@ -439,7 +439,7 @@ _mesa_ProgramUniform1iv(GLuint program, GLint location, GLsizei count, struct gl_shader_program *shProg = _mesa_lookup_shader_program_err(ctx, program, "glProgramUniform1iv"); - _mesa_uniform(ctx, shProg, location, count, value, GL_INT); + _mesa_uniform(ctx, shProg, location, count, value, GLSL_TYPE_INT, 1); } void GLAPIENTRY @@ -450,7 +450,7 @@ _mesa_ProgramUniform2iv(GLuint program, GLint location, GLsizei count, struct gl_shader_program *shProg = _mesa_lookup_shader_program_err(ctx, program, "glProgramUniform2iv"); - _mesa_uniform(ctx, shProg, location, count, value, GL_INT_VEC2); + _mesa_uniform(ctx, shProg, location, count, value, GLSL_TYPE_INT, 2); } void GLAPIENTRY @@ -461,7 +461,7 @@ _mesa_ProgramUniform3iv(GLuint program, GLint location, GLsizei count, struct gl_shader_program *shProg = _mesa_lookup_shader_program_err(ctx, program, "glProgramUniform3iv"); - _mesa_uniform(ctx, shProg, location, count, value, GL_INT_VEC3); + _mesa_uniform(ctx, shProg, location, count, value, GLSL_TYPE_INT, 3); } void GLAPIENTRY @@ -472,7 +472,7 @@ _mesa_ProgramUniform4iv(GLuint program, GLint location, GLsizei count, struct gl_shader_program *shProg = _mesa_lookup_shader_program_err(ctx, program, "glProgramUniform4iv"); - _mesa_uniform(ctx, shProg, location, count, value, GL_INT_VEC4); + _mesa_uniform(ctx, shProg, location, count, value, GLSL_TYPE_INT, 4); } @@ -481,7 +481,7 @@ void GLAPIENTRY _mesa_Uniform1ui(GLint location, GLuint v0) { GET_CURRENT_CONTEXT(ctx); - _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, 1, &v0, GL_UNSIGNED_INT); + _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, 1, &v0, GLSL_TYPE_UINT, 1); } void GLAPIENTRY @@ -491,7 +491,7 @@ _mesa_Uniform2ui(GLint location, GLuint v0, GLuint v1) GLuint v[2]; v[0] = v0; v[1] = v1; - _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, 1, v, GL_UNSIGNED_INT_VEC2); + _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, 1, v, GLSL_TYPE_UINT, 2); } void GLAPIENTRY @@ -502,7 +502,7 @@ _mesa_Uniform3ui(GLint location, GLuint v0, GLuint v1, GLuint v2) v[0] = v0; v[1] = v1; v[2] = v2; - _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, 1, v, GL_UNSIGNED_INT_VEC3); + _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, 1, v, GLSL_TYPE_UINT, 3); } void GLAPIENTRY @@ -514,35 +514,35 @@ _mesa_Uniform4ui(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3) v[1] = v1; v[2] = v2; v[3] = v3; - _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, 1, v, GL_UNSIGNED_INT_VEC4); + _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, 1, v, GLSL_TYPE_UINT, 4); } void GLAPIENTRY _mesa_Uniform1uiv(GLint location, GLsizei count, const GLuint *value) { GET_CURRENT_CONTEXT(ctx); - _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, count, value, GL_UNSIGNED_INT); + _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, count, value, GLSL_TYPE_UINT, 1); } void GLAPIENTRY _mesa_Uniform2uiv(GLint location, GLsizei count, const GLuint *value) { GET_CURRENT_CONTEXT(ctx); - _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, count, value, GL_UNSIGNED_INT_VEC2); + _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, count, value, GLSL_TYPE_UINT, 2); } void GLAPIENTRY _mesa_Uniform3uiv(GLint location, GLsizei count, const GLuint *value) { GET_CURRENT_CONTEXT(ctx); - _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, count, value, GL_UNSIGNED_INT_VEC3); + _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, count, value, GLSL_TYPE_UINT, 3); } void GLAPIENTRY _mesa_Uniform4uiv(GLint location, GLsizei count, const GLuint *value) { GET_CURRENT_CONTEXT(ctx); - _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, count, value, GL_UNSIGNED_INT_VEC4); + _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, count, value, GLSL_TYPE_UINT, 4); } @@ -583,7 +583,7 @@ _mesa_ProgramUniform1ui(GLuint program, GLint location, GLuint v0) struct gl_shader_program *shProg = _mesa_lookup_shader_program_err(ctx, program, "glProgramUniform1ui"); - _mesa_uniform(ctx, shProg, location, 1, &v0, GL_UNSIGNED_INT); + _mesa_uniform(ctx, shProg, location, 1, &v0, GLSL_TYPE_UINT, 1); } void GLAPIENTRY @@ -596,7 +596,7 @@ _mesa_ProgramUniform2ui(GLuint program, GLint location, GLuint v0, GLuint v1) v[1] = v1; shProg = _mesa_lookup_shader_program_err(ctx, program, "glProgramUniform2ui"); - _mesa_uniform(ctx, shProg, location, 1, v, GL_UNSIGNED_INT_VEC2); + _mesa_uniform(ctx, shProg, location, 1, v, GLSL_TYPE_UINT, 2); } void GLAPIENTRY @@ -611,7 +611,7 @@ _mesa_ProgramUniform3ui(GLuint program, GLint location, GLuint v0, GLuint v1, v[2] = v2; shProg = _mesa_lookup_shader_program_err(ctx, program, "glProgramUniform3ui"); - _mesa_uniform(ctx, shProg, location, 1, v, GL_UNSIGNED_INT_VEC3); + _mesa_uniform(ctx, shProg, location, 1, v, GLSL_TYPE_UINT, 3); } void GLAPIENTRY @@ -626,7 +626,7 @@ _mesa_ProgramUniform4ui(GLuint program, GLint location, GLuint v0, GLuint v1, v[2] = v2; v[3] = v3; shProg = _mesa_lookup_shader_program_err(ctx, program, "glProgramUniform4ui"); - _mesa_uniform(ctx, shProg, location, 1, v, GL_UNSIGNED_INT_VEC4); + _mesa_uniform(ctx, shProg, location, 1, v, GLSL_TYPE_UINT, 4); } void GLAPIENTRY @@ -637,7 +637,7 @@ _mesa_ProgramUniform1uiv(GLuint program, GLint location, GLsizei count, struct gl_shader_program *shProg = _mesa_lookup_shader_program_err(ctx, program, "glProgramUniform1uiv"); - _mesa_uniform(ctx, shProg, location, count, value, GL_UNSIGNED_INT); + _mesa_uniform(ctx, shProg, location, count, value, GLSL_TYPE_UINT, 1); } void GLAPIENTRY @@ -648,7 +648,7 @@ _mesa_ProgramUniform2uiv(GLuint program, GLint location, GLsizei count, struct gl_shader_program *shProg = _mesa_lookup_shader_program_err(ctx, program, "glProgramUniform2uiv"); - _mesa_uniform(ctx, shProg, location, count, value, GL_UNSIGNED_INT_VEC2); + _mesa_uniform(ctx, shProg, location, count, value, GLSL_TYPE_UINT, 2); } void GLAPIENTRY @@ -659,7 +659,7 @@ _mesa_ProgramUniform3uiv(GLuint program, GLint location, GLsizei count, struct gl_shader_program *shProg = _mesa_lookup_shader_program_err(ctx, program, "glProgramUniform3uiv"); - _mesa_uniform(ctx, shProg, location, count, value, GL_UNSIGNED_INT_VEC3); + _mesa_uniform(ctx, shProg, location, count, value, GLSL_TYPE_UINT, 3); } void GLAPIENTRY @@ -670,7 +670,7 @@ _mesa_ProgramUniform4uiv(GLuint program, GLint location, GLsizei count, struct gl_shader_program *shProg = _mesa_lookup_shader_program_err(ctx, program, "glProgramUniform4uiv"); - _mesa_uniform(ctx, shProg, location, count, value, GL_UNSIGNED_INT_VEC4); + _mesa_uniform(ctx, shProg, location, count, value, GLSL_TYPE_UINT, 4); } @@ -1208,7 +1208,7 @@ _mesa_GetActiveUniformName(GLuint program, GLuint uniformIndex, struct gl_shader_program *shProg; if (!ctx->Extensions.ARB_uniform_buffer_object) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glGetActiveUniformBlockiv"); + _mesa_error(ctx, GL_INVALID_OPERATION, "glGetActiveUniformName"); return; } diff --git a/mesalib/src/mesa/main/uniforms.h b/mesalib/src/mesa/main/uniforms.h index 6575a52f4..0a9ee7de9 100644 --- a/mesalib/src/mesa/main/uniforms.h +++ b/mesalib/src/mesa/main/uniforms.h @@ -265,7 +265,9 @@ _mesa_get_uniform_location(struct gl_shader_program *shProg, void _mesa_uniform(struct gl_context *ctx, struct gl_shader_program *shader_program, GLint location, GLsizei count, - const GLvoid *values, GLenum type); + const GLvoid *values, + enum glsl_base_type basicType, + unsigned src_components); void _mesa_uniform_matrix(struct gl_context *ctx, struct gl_shader_program *shProg, diff --git a/mesalib/src/mesa/main/viewport.c b/mesalib/src/mesa/main/viewport.c index d6a9e290a..0adce9c78 100644 --- a/mesalib/src/mesa/main/viewport.c +++ b/mesalib/src/mesa/main/viewport.c @@ -459,15 +459,14 @@ _mesa_ClipControl(GLenum origin, GLenum depth) ctx->Transform.ClipDepthMode == depth) return; - FLUSH_VERTICES(ctx, 0); + /* Affects transform state and the viewport transform */ + FLUSH_VERTICES(ctx, _NEW_TRANSFORM | _NEW_VIEWPORT); if (ctx->Transform.ClipOrigin != origin) { ctx->Transform.ClipOrigin = origin; /* Affects the winding order of the front face. */ ctx->NewState |= _NEW_POLYGON; - /* Affects the y component of the viewport transform. */ - ctx->NewState |= _NEW_VIEWPORT; if (ctx->Driver.FrontFace) ctx->Driver.FrontFace(ctx, ctx->Polygon.FrontFace); @@ -476,9 +475,6 @@ _mesa_ClipControl(GLenum origin, GLenum depth) if (ctx->Transform.ClipDepthMode != depth) { ctx->Transform.ClipDepthMode = depth; - /* Affects the z part of the viewpoint transform. */ - ctx->NewState |= _NEW_VIEWPORT; - if (ctx->Driver.DepthRange) ctx->Driver.DepthRange(ctx); } |