[Mesa-dev] [PATCH 03/21] glsl: protect anonymous struct id with a mutex
There may be two contexts compiling shaders at the same time, and we want the anonymous struct id to be globally unique. Signed-off-by: Chia-I Wu --- src/glsl/glsl_parser_extras.cpp | 10 -- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/glsl/glsl_parser_extras.cpp b/src/glsl/glsl_parser_extras.cpp index 91c9285..30e284b 100644 --- a/src/glsl/glsl_parser_extras.cpp +++ b/src/glsl/glsl_parser_extras.cpp @@ -1332,9 +1332,15 @@ ast_struct_specifier::ast_struct_specifier(const char *identifier, ast_declarator_list *declarator_list) { if (identifier == NULL) { + static mtx_t mutex = _MTX_INITIALIZER_NP; static unsigned anon_count = 1; - identifier = ralloc_asprintf(this, "#anon_struct_%04x", anon_count); - anon_count++; + unsigned count; + + mtx_lock(&mutex); + count = anon_count++; + mtx_unlock(&mutex); + + identifier = ralloc_asprintf(this, "#anon_struct_%04x", count); } name = identifier; this->declarations.push_degenerate_list_at_head(&declarator_list->link); -- 1.8.5.3 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 07/21] mesa: refactor debug output set_message_state
Move message state update to debug_set_message_filter. Signed-off-by: Chia-I Wu --- src/mesa/main/errors.c | 70 -- 1 file changed, 39 insertions(+), 31 deletions(-) diff --git a/src/mesa/main/errors.c b/src/mesa/main/errors.c index 66896c4..c478aac 100644 --- a/src/mesa/main/errors.c +++ b/src/mesa/main/errors.c @@ -217,6 +217,43 @@ debug_create(void) return debug; } +/* + * Sets the state of the given message source/type/ID tuple. + */ +static void +debug_set_message_filter(struct gl_debug_state *debug, + enum mesa_debug_source source, + enum mesa_debug_type type, + GLuint id, GLboolean enabled) +{ + GLint gstack = debug->GroupStackDepth; + struct gl_debug_namespace *nspace = + &debug->Namespaces[gstack][source][type]; + uintptr_t state; + + /* In addition to not being able to store zero as a value, HashTable also +* can't use zero as a key. +*/ + if (id) + state = (uintptr_t)_mesa_HashLookup(nspace->IDs, id); + else + state = nspace->ZeroID; + + if (state == NOT_FOUND) + state = enabled ? ENABLED : DISABLED; + else { + if (enabled) + state |= ENABLED_BIT; + else + state &= ~ENABLED_BIT; + } + + if (id) + _mesa_HashInsert(nspace->IDs, id, (void*)state); + else + nspace->ZeroID = state; +} + /** * Returns if the given message source/type/ID tuple is filtered. */ @@ -316,9 +353,6 @@ should_log(struct gl_context *ctx, } -/** - * Sets the state of the given message source/type/ID tuple. - */ static void set_message_state(struct gl_context *ctx, enum mesa_debug_source source, @@ -327,34 +361,8 @@ set_message_state(struct gl_context *ctx, { struct gl_debug_state *debug = _mesa_get_debug_state(ctx); - if (debug) { - GLint gstack = debug->GroupStackDepth; - struct gl_debug_namespace *nspace = - &debug->Namespaces[gstack][source][type]; - uintptr_t state; - - /* In addition to not being able to store zero as a value, HashTable also - * can't use zero as a key. - */ - if (id) - state = (uintptr_t)_mesa_HashLookup(nspace->IDs, id); - else - state = nspace->ZeroID; - - if (state == NOT_FOUND) - state = enabled ? ENABLED : DISABLED; - else { - if (enabled) -state |= ENABLED_BIT; - else -state &= ~ENABLED_BIT; - } - - if (id) - _mesa_HashInsert(nspace->IDs, id, (void*)state); - else - nspace->ZeroID = state; - } + if (debug) + debug_set_message_filter(debug, source, type, id, enabled); } -- 1.8.5.3 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 09/21] mesa: refactor debug output get_msg
Move message fetching to debug_fetch_message and message deletion to debug_delete_messages. Signed-off-by: Chia-I Wu --- src/mesa/main/errors.c | 61 +- 1 file changed, 50 insertions(+), 11 deletions(-) diff --git a/src/mesa/main/errors.c b/src/mesa/main/errors.c index 930e801..0d26285 100644 --- a/src/mesa/main/errors.c +++ b/src/mesa/main/errors.c @@ -346,6 +346,18 @@ debug_store_message(struct gl_debug_state *debug, } } +static void +debug_clear_message(struct gl_debug_state *debug, +struct gl_debug_msg *msg) +{ + (void) debug; + + if (msg->message != (char*)out_of_memory) + free(msg->message); + msg->message = NULL; + msg->length = 0; +} + /** * 'buf' is not necessarily a null-terminated string. When logging, copy * 'len' characters from it, store them in a new, null-terminated string, @@ -380,6 +392,37 @@ debug_log_message(struct gl_debug_state *debug, debug->NumMessages++; } +/** + * Return the oldest debug message out of the log. + */ +static const struct gl_debug_msg * +debug_fetch_message(const struct gl_debug_state *debug) +{ + return (debug->NumMessages) ? &debug->Log[debug->NextMsg] : NULL; +} + +/** + * Delete the oldest debug messages out of the log. + */ +static void +debug_delete_messages(struct gl_debug_state *debug, unsigned count) +{ + if (count > debug->NumMessages) + count = debug->NumMessages; + + while (count--) { + struct gl_debug_msg *msg = &debug->Log[debug->NextMsg]; + + assert(msg->length > 0 && msg->length == debug->NextMsgLength); + debug_clear_message(debug, msg); + + debug->NumMessages--; + debug->NextMsg++; + debug->NextMsg %= MAX_DEBUG_LOGGED_MESSAGES; + debug->NextMsgLength = debug->Log[debug->NextMsg].length; + } +} + /** * Return debug state for the context. The debug state will be allocated @@ -480,10 +523,14 @@ get_msg(struct gl_context *ctx, GLenum *source, GLenum *type, GLuint *id, GLenum *severity, GLsizei bufSize, char *buf) { struct gl_debug_state *debug = _mesa_get_debug_state(ctx); - struct gl_debug_msg *msg; + const struct gl_debug_msg *msg; GLsizei length; - if (!debug || debug->NumMessages == 0) + if (!debug) + return 0; + + msg = debug_fetch_message(debug); + if (!msg) return 0; msg = &debug->Log[debug->NextMsg]; @@ -515,15 +562,7 @@ get_msg(struct gl_context *ctx, GLenum *source, GLenum *type, (void) strncpy(buf, msg->message, (size_t)length); } - if (msg->message != (char*)out_of_memory) - free(msg->message); - msg->message = NULL; - msg->length = 0; - - debug->NumMessages--; - debug->NextMsg++; - debug->NextMsg %= MAX_DEBUG_LOGGED_MESSAGES; - debug->NextMsgLength = debug->Log[debug->NextMsg].length; + debug_delete_messages(debug, 1); return length; } -- 1.8.5.3 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 04/21] glsl: protect glsl_type with a mutex
glsl_type has several static hash tables and a static ralloc context. They need to be protected by a mutex as they are not thread-safe. Signed-off-by: Chia-I Wu --- src/glsl/glsl_types.cpp | 57 +++-- src/glsl/glsl_types.h | 15 + 2 files changed, 62 insertions(+), 10 deletions(-) diff --git a/src/glsl/glsl_types.cpp b/src/glsl/glsl_types.cpp index 849a79a..562cf00 100644 --- a/src/glsl/glsl_types.cpp +++ b/src/glsl/glsl_types.cpp @@ -31,6 +31,7 @@ extern "C" { #include "program/hash_table.h" } +mtx_t glsl_type::mutex = _MTX_INITIALIZER_NP; hash_table *glsl_type::array_types = NULL; hash_table *glsl_type::record_types = NULL; hash_table *glsl_type::interface_types = NULL; @@ -55,9 +56,14 @@ glsl_type::glsl_type(GLenum gl_type, vector_elements(vector_elements), matrix_columns(matrix_columns), length(0) { + mtx_lock(&glsl_type::mutex); + init_ralloc_type_ctx(); assert(name != NULL); this->name = ralloc_strdup(this->mem_ctx, name); + + mtx_unlock(&glsl_type::mutex); + /* Neither dimension is zero or both dimensions are zero. */ assert((vector_elements == 0) == (matrix_columns == 0)); @@ -73,9 +79,14 @@ glsl_type::glsl_type(GLenum gl_type, glsl_base_type base_type, sampler_array(array), sampler_type(type), interface_packing(0), length(0) { + mtx_lock(&glsl_type::mutex); + init_ralloc_type_ctx(); assert(name != NULL); this->name = ralloc_strdup(this->mem_ctx, name); + + mtx_unlock(&glsl_type::mutex); + memset(& fields, 0, sizeof(fields)); if (base_type == GLSL_TYPE_SAMPLER) { @@ -97,11 +108,14 @@ glsl_type::glsl_type(const glsl_struct_field *fields, unsigned num_fields, { unsigned int i; + mtx_lock(&glsl_type::mutex); + init_ralloc_type_ctx(); assert(name != NULL); this->name = ralloc_strdup(this->mem_ctx, name); this->fields.structure = ralloc_array(this->mem_ctx, glsl_struct_field, length); + for (i = 0; i < length; i++) { this->fields.structure[i].type = fields[i].type; this->fields.structure[i].name = ralloc_strdup(this->fields.structure, @@ -112,6 +126,8 @@ glsl_type::glsl_type(const glsl_struct_field *fields, unsigned num_fields, this->fields.structure[i].sample = fields[i].sample; this->fields.structure[i].row_major = fields[i].row_major; } + + mtx_unlock(&glsl_type::mutex); } glsl_type::glsl_type(const glsl_struct_field *fields, unsigned num_fields, @@ -125,6 +141,8 @@ glsl_type::glsl_type(const glsl_struct_field *fields, unsigned num_fields, { unsigned int i; + mtx_lock(&glsl_type::mutex); + init_ralloc_type_ctx(); assert(name != NULL); this->name = ralloc_strdup(this->mem_ctx, name); @@ -140,6 +158,8 @@ glsl_type::glsl_type(const glsl_struct_field *fields, unsigned num_fields, this->fields.structure[i].sample = fields[i].sample; this->fields.structure[i].row_major = fields[i].row_major; } + + mtx_unlock(&glsl_type::mutex); } @@ -287,6 +307,8 @@ const glsl_type *glsl_type::get_scalar_type() const void _mesa_glsl_release_types(void) { + mtx_lock(&glsl_type::mutex); + if (glsl_type::array_types != NULL) { hash_table_dtor(glsl_type::array_types); glsl_type::array_types = NULL; @@ -296,6 +318,8 @@ _mesa_glsl_release_types(void) hash_table_dtor(glsl_type::record_types); glsl_type::record_types = NULL; } + + mtx_unlock(&glsl_type::mutex); } @@ -318,7 +342,10 @@ glsl_type::glsl_type(const glsl_type *array, unsigned length) : * NUL. */ const unsigned name_length = strlen(array->name) + 10 + 3; + + mtx_lock(&glsl_type::mutex); char *const n = (char *) ralloc_size(this->mem_ctx, name_length); + mtx_unlock(&glsl_type::mutex); if (length == 0) snprintf(n, name_length, "%s[]", array->name); @@ -454,12 +481,6 @@ glsl_type::get_instance(unsigned base_type, unsigned rows, unsigned columns) const glsl_type * glsl_type::get_array_instance(const glsl_type *base, unsigned array_size) { - - if (array_types == NULL) { - array_types = hash_table_ctor(64, hash_table_string_hash, - hash_table_string_compare); - } - /* Generate a name using the base type pointer in the key. This is * done because the name of the base type may not be unique across * shaders. For example, two shaders may have different record types @@ -468,9 +489,19 @@ glsl_type::get_array_instance(const glsl_type *base, unsigned array_size) char key[128]; snprintf(key, sizeof(key), "%p[%u]", (void *) base, array_size); + mtx_lock(&glsl_type::mutex); + + if (array_types == NULL) { + array_types = hash_table_ctor(64, hash_table_string_hash, + hash_table_string_compare); + } + const glsl_type *t = (glsl_type *) hash_table_find(array_types, key); + if (t == NULL)
[Mesa-dev] [PATCH 06/21] mesa: refactor debug output should_log
Move the message filtering logic to debug_is_message_filtered. Signed-off-by: Chia-I Wu --- src/mesa/main/errors.c | 111 +++-- 1 file changed, 61 insertions(+), 50 deletions(-) diff --git a/src/mesa/main/errors.c b/src/mesa/main/errors.c index 66d3146..66896c4 100644 --- a/src/mesa/main/errors.c +++ b/src/mesa/main/errors.c @@ -217,6 +217,63 @@ debug_create(void) return debug; } +/** + * Returns if the given message source/type/ID tuple is filtered. + */ +static bool +debug_is_message_filtered(struct gl_debug_state *debug, + enum mesa_debug_source source, + enum mesa_debug_type type, + GLuint id, + enum mesa_debug_severity severity) +{ + const GLint gstack = debug->GroupStackDepth; + struct gl_debug_namespace *nspace = + &debug->Namespaces[gstack][source][type]; + uintptr_t state = 0; + + if (!debug->DebugOutput) + return true; + + /* In addition to not being able to store zero as a value, HashTable also +* can't use zero as a key. +*/ + if (id) + state = (uintptr_t)_mesa_HashLookup(nspace->IDs, id); + else + state = nspace->ZeroID; + + /* Only do this once for each ID. This makes sure the ID exists in, +* at most, one list, and does not pointlessly appear multiple times. +*/ + if (!(state & KNOWN_SEVERITY)) { + struct gl_debug_severity *entry; + + if (state == NOT_FOUND) { + if (debug->Defaults[gstack][severity][source][type]) +state = ENABLED; + else +state = DISABLED; + } + + entry = malloc(sizeof *entry); + if (!entry) + goto out; + + state |= KNOWN_SEVERITY; + + if (id) + _mesa_HashInsert(nspace->IDs, id, (void*)state); + else + nspace->ZeroID = state; + + entry->ID = id; + insert_at_tail(&nspace->Severity[severity], &entry->link); + } +out: + return !(state & ENABLED_BIT); +} + /** * Return debug state for the context. The debug state will be allocated @@ -237,9 +294,6 @@ _mesa_get_debug_state(struct gl_context *ctx) -/** - * Returns the state of the given message source/type/ID tuple. - */ static GLboolean should_log(struct gl_context *ctx, enum mesa_debug_source source, @@ -248,7 +302,6 @@ should_log(struct gl_context *ctx, enum mesa_debug_severity severity) { struct gl_debug_state *debug; - uintptr_t state = 0; if (!ctx->Debug) { /* no debug state set so far */ @@ -256,52 +309,10 @@ should_log(struct gl_context *ctx, } debug = _mesa_get_debug_state(ctx); - if (debug) { - const GLint gstack = debug->GroupStackDepth; - struct gl_debug_namespace *nspace = - &debug->Namespaces[gstack][source][type]; - - if (!debug->DebugOutput) - return GL_FALSE; - - /* In addition to not being able to store zero as a value, HashTable also - * can't use zero as a key. - */ - if (id) - state = (uintptr_t)_mesa_HashLookup(nspace->IDs, id); - else - state = nspace->ZeroID; - - /* Only do this once for each ID. This makes sure the ID exists in, - * at most, one list, and does not pointlessly appear multiple times. - */ - if (!(state & KNOWN_SEVERITY)) { - struct gl_debug_severity *entry; - - if (state == NOT_FOUND) { -if (debug->Defaults[gstack][severity][source][type]) - state = ENABLED; -else - state = DISABLED; - } - - entry = malloc(sizeof *entry); - if (!entry) -goto out; - - state |= KNOWN_SEVERITY; - - if (id) -_mesa_HashInsert(nspace->IDs, id, (void*)state); - else -nspace->ZeroID = state; - - entry->ID = id; - insert_at_tail(&nspace->Severity[severity], &entry->link); - } - } -out: - return !!(state & ENABLED_BIT); + if (debug) + return !debug_is_message_filtered(debug, source, type, id, severity); + else + return GL_FALSE; } -- 1.8.5.3 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 13/21] mesa: refactor _mesa_GetDebugMessageLog
Merge get_msg into the function. Signed-off-by: Chia-I Wu --- src/mesa/main/errors.c | 99 +- 1 file changed, 26 insertions(+), 73 deletions(-) diff --git a/src/mesa/main/errors.c b/src/mesa/main/errors.c index 139e31d..5136f75 100644 --- a/src/mesa/main/errors.c +++ b/src/mesa/main/errors.c @@ -683,66 +683,6 @@ log_msg(struct gl_context *ctx, enum mesa_debug_source source, /** - * Pop the oldest debug message out of the log. - * Writes the message string, including the null terminator, into 'buf', - * using up to 'bufSize' bytes. If 'bufSize' is too small, or - * if 'buf' is NULL, nothing is written. - * - * Returns the number of bytes written on success, or when 'buf' is NULL, - * the number that would have been written. A return value of 0 - * indicates failure. - */ -static GLsizei -get_msg(struct gl_context *ctx, GLenum *source, GLenum *type, -GLuint *id, GLenum *severity, GLsizei bufSize, char *buf) -{ - struct gl_debug_state *debug = _mesa_get_debug_state(ctx); - const struct gl_debug_msg *msg; - GLsizei length; - - if (!debug) - return 0; - - msg = debug_fetch_message(debug); - if (!msg) - return 0; - - msg = &debug->Log[debug->NextMsg]; - length = msg->length; - - assert(length > 0 && length == debug->NextMsgLength); - - if (bufSize < length && buf != NULL) - return 0; - - if (severity) { - *severity = debug_severity_enums[msg->severity]; - } - - if (source) { - *source = debug_source_enums[msg->source]; - } - - if (type) { - *type = debug_type_enums[msg->type]; - } - - if (id) { - *id = msg->id; - } - - if (buf) { - assert(msg->message[length-1] == '\0'); - (void) strncpy(buf, msg->message, (size_t)length); - } - - debug_delete_messages(debug, 1); - - return length; -} - - -/** * Verify that source, type, and severity are valid enums. * * The 'caller' param is used for handling values available @@ -921,6 +861,7 @@ _mesa_GetDebugMessageLog(GLuint count, GLsizei logSize, GLenum *sources, GLsizei *lengths, GLchar *messageLog) { GET_CURRENT_CONTEXT(ctx); + struct gl_debug_state *debug; GLuint ret; if (!messageLog) @@ -933,29 +874,41 @@ _mesa_GetDebugMessageLog(GLuint count, GLsizei logSize, GLenum *sources, return 0; } + debug = _mesa_get_debug_state(ctx); + if (!debug) + return 0; + for (ret = 0; ret < count; ret++) { - GLsizei written = get_msg(ctx, sources, types, ids, severities, -logSize, messageLog); - if (!written) + const struct gl_debug_msg *msg = debug_fetch_message(debug); + + if (!msg) + break; + + assert(msg->length > 0 && msg->length == debug->NextMsgLength); + + if (logSize < msg->length && messageLog != NULL) break; if (messageLog) { - messageLog += written; - logSize -= written; - } - if (lengths) { - *lengths = written; - lengths++; + assert(msg->message[msg->length-1] == '\0'); + (void) strncpy(messageLog, msg->message, (size_t)msg->length); + + messageLog += msg->length; + logSize -= msg->length; } + if (lengths) + *lengths++ = msg->length; if (severities) - severities++; + *severities++ = debug_severity_enums[msg->severity]; if (sources) - sources++; + *sources++ = debug_source_enums[msg->source]; if (types) - types++; + *types++ = debug_type_enums[msg->type]; if (ids) - ids++; + *ids++ = msg->id; + + debug_delete_messages(debug, 1); } return ret; -- 1.8.5.3 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 12/21] mesa: refactor _mesa_PopDebugGroup and _mesa_free_errors_data
Move group clearing to debug_clear_group. Add debug_pop_group and debug_destroy for use in _mesa_PopDebugGroup and _mesa_free_errors_data respectively. Signed-off-by: Chia-I Wu --- src/mesa/main/errors.c | 127 + 1 file changed, 64 insertions(+), 63 deletions(-) diff --git a/src/mesa/main/errors.c b/src/mesa/main/errors.c index 9873dfc..139e31d 100644 --- a/src/mesa/main/errors.c +++ b/src/mesa/main/errors.c @@ -217,7 +217,57 @@ debug_create(void) return debug; } -/* +static void +debug_clear_group_cb(GLuint key, void *data, void *userData) +{ +} + +/** + * Free debug state for the given stack depth. + */ +static void +debug_clear_group(struct gl_debug_state *debug, GLint gstack) +{ + enum mesa_debug_type t; + enum mesa_debug_source s; + enum mesa_debug_severity sev; + + /* Tear down state for filtering debug messages. */ + for (s = 0; s < MESA_DEBUG_SOURCE_COUNT; s++) { + for (t = 0; t < MESA_DEBUG_TYPE_COUNT; t++) { + struct gl_debug_namespace *nspace = &debug->Namespaces[gstack][s][t]; + + _mesa_HashDeleteAll(nspace->IDs, debug_clear_group_cb, NULL); + _mesa_DeleteHashTable(nspace->IDs); + for (sev = 0; sev < MESA_DEBUG_SEVERITY_COUNT; sev++) { +struct simple_node *node, *tmp; +struct gl_debug_severity *entry; + +foreach_s(node, tmp, &nspace->Severity[sev]) { + entry = (struct gl_debug_severity *)node; + free(entry); +} + } + } + } +} + +/** + * Loop through debug group stack tearing down states for + * filtering debug messages. Then free debug output state. + */ +static void +debug_destroy(struct gl_debug_state *debug) +{ + GLint i; + + for (i = 0; i <= debug->GroupStackDepth; i++) + debug_clear_group(debug, i); + + free(debug); +} + +/** * Sets the state of the given message source/type/ID tuple. */ static void @@ -538,6 +588,15 @@ out: debug->GroupStackDepth++; } +static void +debug_pop_group(struct gl_debug_state *debug) +{ + const GLint gstack = debug->GroupStackDepth; + + debug->GroupStackDepth--; + debug_clear_group(debug, gstack); +} + /** * Return debug state for the context. The debug state will be allocated @@ -840,47 +899,6 @@ message_insert(GLenum source, GLenum type, GLuint id, } -static void -do_nothing(GLuint key, void *data, void *userData) -{ -} - - -/** - * Free context state pertaining to error/debug state for the given stack - * depth. - */ -static void -free_errors_data(struct gl_context *ctx, GLint gstack) -{ - struct gl_debug_state *debug = ctx->Debug; - enum mesa_debug_type t; - enum mesa_debug_source s; - enum mesa_debug_severity sev; - - assert(debug); - - /* Tear down state for filtering debug messages. */ - for (s = 0; s < MESA_DEBUG_SOURCE_COUNT; s++) { - for (t = 0; t < MESA_DEBUG_TYPE_COUNT; t++) { - _mesa_HashDeleteAll(debug->Namespaces[gstack][s][t].IDs, - do_nothing, NULL); - _mesa_DeleteHashTable(debug->Namespaces[gstack][s][t].IDs); - for (sev = 0; sev < MESA_DEBUG_SEVERITY_COUNT; sev++) { -struct simple_node *node, *tmp; -struct gl_debug_severity *entry; - -foreach_s(node, tmp, - &debug->Namespaces[gstack][s][t].Severity[sev]) { - entry = (struct gl_debug_severity *)node; - free(entry); -} - } - } - } -} - - void GLAPIENTRY _mesa_DebugMessageInsert(GLenum source, GLenum type, GLuint id, GLenum severity, GLint length, @@ -1044,7 +1062,6 @@ _mesa_PopDebugGroup(void) struct gl_debug_state *debug = _mesa_get_debug_state(ctx); const char *callerstr = "glPopDebugGroup"; struct gl_debug_msg *gdmessage; - GLint prevStackDepth; if (!debug) return; @@ -1054,10 +1071,9 @@ _mesa_PopDebugGroup(void) return; } - prevStackDepth = debug->GroupStackDepth; - debug->GroupStackDepth--; + debug_pop_group(debug); - gdmessage = &debug->DebugGroupMsgs[prevStackDepth]; + gdmessage = debug_get_group_message(debug); /* using log_msg() directly here as verification of parameters * already done in push */ @@ -1067,13 +1083,7 @@ _mesa_PopDebugGroup(void) gl_enum_to_debug_severity(GL_DEBUG_SEVERITY_NOTIFICATION), gdmessage->length, gdmessage->message); - if (gdmessage->message != (char*)out_of_memory) - free(gdmessage->message); - gdmessage->message = NULL; - gdmessage->length = 0; - - /* free popped debug group data */ - free_errors_data(ctx, prevStackDepth); + debug_clear_message(debug, gdmessage); } @@ -1084,20 +1094,11 @@ _mesa_init_errors(struct gl_context *ctx) } -/** - * Loop through debug group stack tearing down states for - * filtering debug messages. Then free debug output state. - */ void _mesa_free_errors_data(struct gl_co
[Mesa-dev] [PATCH 00/21] deferred and threaded glCompileShader
Hi list, This series adds a thread pool to the GLSL compiler, and a drirc option to defer glCompileShader calls to the pool. The goal is to reduce the start-up time of applications that are aware of this feature. That is, applications that compile shaders first and check the compile status later. I do not have numbers from real applications yet. But trying to compiling a set of 2882 shaders extracted from some trace file, with everything else idled, the time it takes is 8 threads: 17.8s 4 threads: 20.3s 2 threads: 31.2s 1 threads: 58.0s no thread pool: 54.5 on a quad core system. Patches 1-4 fix potential races in the GLSL compiler. As the compiler is already shared by all contexts, these patches could be desirable even without the thread pool that I am going to add. Patches 5-18 adds true GL_DEBUG_OUTPUT_SYNCHRONOUS support to the KHR_debug code. All except patch 18 are clean-ups. Patch 18 adds a mutex to protect gl_debug_state. Patch 19 defines a simple API to create and work with thread pools, as well as a test for the API. Patch 20 adds the singleton GLSL thread pool and allows glCompileShader to be deferred to the pool. This feature needs to be explicitly enabled with _mesa_enable_glsl_threadpool. Patch 21 adds a drirc option to enable the thread pool. The idea is that only applications that can benefit from it will enable it. ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 05/21] mesa: refactor _mesa_get_debug_state
Move gl_debug_state allocation to a new function, debug_create. Signed-off-by: Chia-I Wu --- src/mesa/main/errors.c | 62 ++ 1 file changed, 37 insertions(+), 25 deletions(-) diff --git a/src/mesa/main/errors.c b/src/mesa/main/errors.c index d80fda0..66d3146 100644 --- a/src/mesa/main/errors.c +++ b/src/mesa/main/errors.c @@ -181,6 +181,42 @@ enum { ENABLED = ENABLED_BIT | FOUND_BIT }; +/** + * Allocate and initialize context debug state. + */ +static struct gl_debug_state * +debug_create(void) +{ + struct gl_debug_state *debug; + int s, t, sev; + + debug = CALLOC_STRUCT(gl_debug_state); + if (!debug) + return NULL; + + /* Enable all the messages with severity HIGH or MEDIUM by default. */ + memset(debug->Defaults[0][MESA_DEBUG_SEVERITY_HIGH], GL_TRUE, + sizeof debug->Defaults[0][MESA_DEBUG_SEVERITY_HIGH]); + memset(debug->Defaults[0][MESA_DEBUG_SEVERITY_MEDIUM], GL_TRUE, + sizeof debug->Defaults[0][MESA_DEBUG_SEVERITY_MEDIUM]); + memset(debug->Defaults[0][MESA_DEBUG_SEVERITY_LOW], GL_FALSE, + sizeof debug->Defaults[0][MESA_DEBUG_SEVERITY_LOW]); + + /* Initialize state for filtering known debug messages. */ + for (s = 0; s < MESA_DEBUG_SOURCE_COUNT; s++) { + for (t = 0; t < MESA_DEBUG_TYPE_COUNT; t++) { + debug->Namespaces[0][s][t].IDs = _mesa_NewHashTable(); + assert(debug->Namespaces[0][s][t].IDs); + + for (sev = 0; sev < MESA_DEBUG_SEVERITY_COUNT; sev++) { +make_empty_list(&debug->Namespaces[0][s][t].Severity[sev]); + } + } + } + + return debug; +} + /** * Return debug state for the context. The debug state will be allocated @@ -190,34 +226,10 @@ struct gl_debug_state * _mesa_get_debug_state(struct gl_context *ctx) { if (!ctx->Debug) { - ctx->Debug = CALLOC_STRUCT(gl_debug_state); + ctx->Debug = debug_create(); if (!ctx->Debug) { _mesa_error(ctx, GL_OUT_OF_MEMORY, "allocating debug state"); } - else { - struct gl_debug_state *debug = ctx->Debug; - int s, t, sev; - - /* Enable all the messages with severity HIGH or MEDIUM by default. */ - memset(debug->Defaults[0][MESA_DEBUG_SEVERITY_HIGH], GL_TRUE, -sizeof debug->Defaults[0][MESA_DEBUG_SEVERITY_HIGH]); - memset(debug->Defaults[0][MESA_DEBUG_SEVERITY_MEDIUM], GL_TRUE, -sizeof debug->Defaults[0][MESA_DEBUG_SEVERITY_MEDIUM]); - memset(debug->Defaults[0][MESA_DEBUG_SEVERITY_LOW], GL_FALSE, -sizeof debug->Defaults[0][MESA_DEBUG_SEVERITY_LOW]); - - /* Initialize state for filtering known debug messages. */ - for (s = 0; s < MESA_DEBUG_SOURCE_COUNT; s++) { -for (t = 0; t < MESA_DEBUG_TYPE_COUNT; t++) { - debug->Namespaces[0][s][t].IDs = _mesa_NewHashTable(); - assert(debug->Namespaces[0][s][t].IDs); - - for (sev = 0; sev < MESA_DEBUG_SEVERITY_COUNT; sev++) { - make_empty_list(&debug->Namespaces[0][s][t].Severity[sev]); - } -} - } - } } return ctx->Debug; -- 1.8.5.3 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 10/21] mesa: refactor debug output control_messages
Move most of the code to debug_set_default_filter. Signed-off-by: Chia-I Wu --- src/mesa/main/errors.c | 113 +++-- 1 file changed, 62 insertions(+), 51 deletions(-) diff --git a/src/mesa/main/errors.c b/src/mesa/main/errors.c index 0d26285..1dc4d3a 100644 --- a/src/mesa/main/errors.c +++ b/src/mesa/main/errors.c @@ -254,6 +254,67 @@ debug_set_message_filter(struct gl_debug_state *debug, nspace->ZeroID = state; } +/* + * Set the state of all message IDs found in the given intersection of + * 'source', 'type', and 'severity'. The _COUNT enum can be used for + * GL_DONT_CARE (include all messages in the class). + * + * This requires both setting the state of all previously seen message + * IDs in the hash table, and setting the default state for all + * applicable combinations of source/type/severity, so that all the + * yet-unknown message IDs that may be used in the future will be + * impacted as if they were already known. + */ +static void +debug_set_default_filter(struct gl_debug_state *debug, + enum mesa_debug_source source, + enum mesa_debug_type type, + enum mesa_debug_severity severity, + GLboolean enabled) +{ + const GLint gstack = debug->GroupStackDepth; + int s, t, sev, smax, tmax, sevmax; + + if (source == MESA_DEBUG_SOURCE_COUNT) { + source = 0; + smax = MESA_DEBUG_SOURCE_COUNT; + } else { + smax = source+1; + } + + if (type == MESA_DEBUG_TYPE_COUNT) { + type = 0; + tmax = MESA_DEBUG_TYPE_COUNT; + } else { + tmax = type+1; + } + + if (severity == MESA_DEBUG_SEVERITY_COUNT) { + severity = 0; + sevmax = MESA_DEBUG_SEVERITY_COUNT; + } else { + sevmax = severity+1; + } + + for (sev = severity; sev < sevmax; sev++) { + for (s = source; s < smax; s++) { + for (t = type; t < tmax; t++) { +struct simple_node *node; +struct gl_debug_severity *entry; + +/* change the default for IDs we've never seen before. */ +debug->Defaults[gstack][sev][s][t] = enabled; + +/* Now change the state of IDs we *have* seen... */ +foreach(node, &debug->Namespaces[gstack][s][t].Severity[sev]) { + entry = (struct gl_debug_severity *)node; + debug_set_message_filter(debug, s, t, entry->ID, enabled); +} + } + } + } +} + /** * Returns if the given message source/type/ID tuple is filtered. */ @@ -647,17 +708,6 @@ error: } -/** - * Set the state of all message IDs found in the given intersection of - * 'source', 'type', and 'severity'. The _COUNT enum can be used for - * GL_DONT_CARE (include all messages in the class). - * - * This requires both setting the state of all previously seen message - * IDs in the hash table, and setting the default state for all - * applicable combinations of source/type/severity, so that all the - * yet-unknown message IDs that may be used in the future will be - * impacted as if they were already known. - */ static void control_messages(struct gl_context *ctx, enum mesa_debug_source source, @@ -666,50 +716,11 @@ control_messages(struct gl_context *ctx, GLboolean enabled) { struct gl_debug_state *debug = _mesa_get_debug_state(ctx); - int s, t, sev, smax, tmax, sevmax; - const GLint gstack = debug ? debug->GroupStackDepth : 0; if (!debug) return; - if (source == MESA_DEBUG_SOURCE_COUNT) { - source = 0; - smax = MESA_DEBUG_SOURCE_COUNT; - } else { - smax = source+1; - } - - if (type == MESA_DEBUG_TYPE_COUNT) { - type = 0; - tmax = MESA_DEBUG_TYPE_COUNT; - } else { - tmax = type+1; - } - - if (severity == MESA_DEBUG_SEVERITY_COUNT) { - severity = 0; - sevmax = MESA_DEBUG_SEVERITY_COUNT; - } else { - sevmax = severity+1; - } - - for (sev = severity; sev < sevmax; sev++) { - for (s = source; s < smax; s++) { - for (t = type; t < tmax; t++) { -struct simple_node *node; -struct gl_debug_severity *entry; - -/* change the default for IDs we've never seen before. */ -debug->Defaults[gstack][sev][s][t] = enabled; - -/* Now change the state of IDs we *have* seen... */ -foreach(node, &debug->Namespaces[gstack][s][t].Severity[sev]) { - entry = (struct gl_debug_severity *)node; - set_message_state(ctx, s, t, entry->ID, enabled); -} - } - } - } + debug_set_default_filter(debug, source, type, severity, enabled); } -- 1.8.5.3 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 01/21] glsl: make static constant variables "static const"
This allows them to be moved to .rodata, and allow us to be sure that they will not be modified. Signed-off-by: Chia-I Wu --- src/glsl/builtin_types.cpp | 2 +- src/glsl/builtin_variables.cpp | 63 + src/glsl/glsl_parser.yy | 4 +-- src/glsl/glsl_parser_extras.cpp | 4 +-- src/glsl/ir.cpp | 2 +- src/mesa/main/uniforms.h| 2 +- 6 files changed, 39 insertions(+), 38 deletions(-) diff --git a/src/glsl/builtin_types.cpp b/src/glsl/builtin_types.cpp index dd42ecb..0a0fa8c 100644 --- a/src/glsl/builtin_types.cpp +++ b/src/glsl/builtin_types.cpp @@ -241,7 +241,7 @@ const static struct builtin_type_versions { T(atomic_uint, 420, 999) }; -const glsl_type *const deprecated_types[] = { +static const glsl_type *const deprecated_types[] = { glsl_type::struct_gl_PointParameters_type, glsl_type::struct_gl_MaterialParameters_type, glsl_type::struct_gl_LightSourceParameters_type, diff --git a/src/glsl/builtin_variables.cpp b/src/glsl/builtin_variables.cpp index 4176ae6..9b35850 100644 --- a/src/glsl/builtin_variables.cpp +++ b/src/glsl/builtin_variables.cpp @@ -30,21 +30,21 @@ #include "program/prog_statevars.h" #include "program/prog_instruction.h" -static struct gl_builtin_uniform_element gl_NumSamples_elements[] = { +static const struct gl_builtin_uniform_element gl_NumSamples_elements[] = { {NULL, {STATE_NUM_SAMPLES, 0, 0}, SWIZZLE_} }; -static struct gl_builtin_uniform_element gl_DepthRange_elements[] = { +static const struct gl_builtin_uniform_element gl_DepthRange_elements[] = { {"near", {STATE_DEPTH_RANGE, 0, 0}, SWIZZLE_}, {"far", {STATE_DEPTH_RANGE, 0, 0}, SWIZZLE_}, {"diff", {STATE_DEPTH_RANGE, 0, 0}, SWIZZLE_}, }; -static struct gl_builtin_uniform_element gl_ClipPlane_elements[] = { +static const struct gl_builtin_uniform_element gl_ClipPlane_elements[] = { {NULL, {STATE_CLIPPLANE, 0, 0}, SWIZZLE_XYZW} }; -static struct gl_builtin_uniform_element gl_Point_elements[] = { +static const struct gl_builtin_uniform_element gl_Point_elements[] = { {"size", {STATE_POINT_SIZE}, SWIZZLE_}, {"sizeMin", {STATE_POINT_SIZE}, SWIZZLE_}, {"sizeMax", {STATE_POINT_SIZE}, SWIZZLE_}, @@ -54,7 +54,7 @@ static struct gl_builtin_uniform_element gl_Point_elements[] = { {"distanceQuadraticAttenuation", {STATE_POINT_ATTENUATION}, SWIZZLE_}, }; -static struct gl_builtin_uniform_element gl_FrontMaterial_elements[] = { +static const struct gl_builtin_uniform_element gl_FrontMaterial_elements[] = { {"emission", {STATE_MATERIAL, 0, STATE_EMISSION}, SWIZZLE_XYZW}, {"ambient", {STATE_MATERIAL, 0, STATE_AMBIENT}, SWIZZLE_XYZW}, {"diffuse", {STATE_MATERIAL, 0, STATE_DIFFUSE}, SWIZZLE_XYZW}, @@ -62,7 +62,7 @@ static struct gl_builtin_uniform_element gl_FrontMaterial_elements[] = { {"shininess", {STATE_MATERIAL, 0, STATE_SHININESS}, SWIZZLE_}, }; -static struct gl_builtin_uniform_element gl_BackMaterial_elements[] = { +static const struct gl_builtin_uniform_element gl_BackMaterial_elements[] = { {"emission", {STATE_MATERIAL, 1, STATE_EMISSION}, SWIZZLE_XYZW}, {"ambient", {STATE_MATERIAL, 1, STATE_AMBIENT}, SWIZZLE_XYZW}, {"diffuse", {STATE_MATERIAL, 1, STATE_DIFFUSE}, SWIZZLE_XYZW}, @@ -70,7 +70,7 @@ static struct gl_builtin_uniform_element gl_BackMaterial_elements[] = { {"shininess", {STATE_MATERIAL, 1, STATE_SHININESS}, SWIZZLE_}, }; -static struct gl_builtin_uniform_element gl_LightSource_elements[] = { +static const struct gl_builtin_uniform_element gl_LightSource_elements[] = { {"ambient", {STATE_LIGHT, 0, STATE_AMBIENT}, SWIZZLE_XYZW}, {"diffuse", {STATE_LIGHT, 0, STATE_DIFFUSE}, SWIZZLE_XYZW}, {"specular", {STATE_LIGHT, 0, STATE_SPECULAR}, SWIZZLE_XYZW}, @@ -89,67 +89,67 @@ static struct gl_builtin_uniform_element gl_LightSource_elements[] = { {"quadraticAttenuation", {STATE_LIGHT, 0, STATE_ATTENUATION}, SWIZZLE_}, }; -static struct gl_builtin_uniform_element gl_LightModel_elements[] = { +static const struct gl_builtin_uniform_element gl_LightModel_elements[] = { {"ambient", {STATE_LIGHTMODEL_AMBIENT, 0}, SWIZZLE_XYZW}, }; -static struct gl_builtin_uniform_element gl_FrontLightModelProduct_elements[] = { +static const struct gl_builtin_uniform_element gl_FrontLightModelProduct_elements[] = { {"sceneColor", {STATE_LIGHTMODEL_SCENECOLOR, 0}, SWIZZLE_XYZW}, }; -static struct gl_builtin_uniform_element gl_BackLightModelProduct_elements[] = { +static const struct gl_builtin_uniform_element gl_BackLightModelProduct_elements[] = { {"sceneColor", {STATE_LIGHTMODEL_SCENECOLOR, 1}, SWIZZLE_XYZW}, }; -static struct gl_builtin_uniform_element gl_FrontLightProduct_elements[] = { +static const struct gl_builtin_uniform_element gl_FrontLightProduct_elements[] = { {"ambient", {STATE_LIGHTPROD, 0, 0, STATE_AMBIENT}, SWIZZLE_XYZW}, {"diffuse", {S
[Mesa-dev] [PATCH 08/21] mesa: refactor debug out log_msg
Move message logging to debug_log_message. Signed-off-by: Chia-I Wu --- src/mesa/main/errors.c | 136 - 1 file changed, 77 insertions(+), 59 deletions(-) diff --git a/src/mesa/main/errors.c b/src/mesa/main/errors.c index c478aac..930e801 100644 --- a/src/mesa/main/errors.c +++ b/src/mesa/main/errors.c @@ -311,6 +311,75 @@ out: return !(state & ENABLED_BIT); } +static void +debug_store_message(struct gl_debug_state *debug, +struct gl_debug_msg *msg, +enum mesa_debug_source source, +enum mesa_debug_type type, GLuint id, +enum mesa_debug_severity severity, +GLsizei len, const char *buf) +{ + (void) debug; + assert(!msg->message && !msg->length); + + msg->message = malloc(len+1); + if (msg->message) { + (void) strncpy(msg->message, buf, (size_t)len); + msg->message[len] = '\0'; + + msg->length = len+1; + msg->source = source; + msg->type = type; + msg->id = id; + msg->severity = severity; + } else { + static GLuint oom_msg_id = 0; + debug_get_id(&oom_msg_id); + + /* malloc failed! */ + msg->message = out_of_memory; + msg->length = strlen(out_of_memory)+1; + msg->source = MESA_DEBUG_SOURCE_OTHER; + msg->type = MESA_DEBUG_TYPE_ERROR; + msg->id = oom_msg_id; + msg->severity = MESA_DEBUG_SEVERITY_HIGH; + } +} + +/** + * 'buf' is not necessarily a null-terminated string. When logging, copy + * 'len' characters from it, store them in a new, null-terminated string, + * and remember the number of bytes used by that string, *including* + * the null terminator this time. + */ +static void +debug_log_message(struct gl_debug_state *debug, + enum mesa_debug_source source, + enum mesa_debug_type type, GLuint id, + enum mesa_debug_severity severity, + GLsizei len, const char *buf) +{ + GLint nextEmpty; + struct gl_debug_msg *emptySlot; + + assert(len >= 0 && len < MAX_DEBUG_MESSAGE_LENGTH); + + if (debug->NumMessages == MAX_DEBUG_LOGGED_MESSAGES) + return; + + nextEmpty = (debug->NextMsg + debug->NumMessages) + % MAX_DEBUG_LOGGED_MESSAGES; + emptySlot = &debug->Log[nextEmpty]; + + debug_store_message(debug, emptySlot, source, type, + id, severity, len, buf); + + if (debug->NumMessages == 0) + debug->NextMsgLength = debug->Log[debug->NextMsg].length; + + debug->NumMessages++; +} + /** * Return debug state for the context. The debug state will be allocated @@ -366,45 +435,9 @@ set_message_state(struct gl_context *ctx, } -static void -store_message_details(struct gl_debug_msg *emptySlot, - enum mesa_debug_source source, - enum mesa_debug_type type, GLuint id, - enum mesa_debug_severity severity, GLint len, - const char *buf) -{ - assert(!emptySlot->message && !emptySlot->length); - - emptySlot->message = malloc(len+1); - if (emptySlot->message) { - (void) strncpy(emptySlot->message, buf, (size_t)len); - emptySlot->message[len] = '\0'; - - emptySlot->length = len+1; - emptySlot->source = source; - emptySlot->type = type; - emptySlot->id = id; - emptySlot->severity = severity; - } else { - static GLuint oom_msg_id = 0; - debug_get_id(&oom_msg_id); - - /* malloc failed! */ - emptySlot->message = out_of_memory; - emptySlot->length = strlen(out_of_memory)+1; - emptySlot->source = MESA_DEBUG_SOURCE_OTHER; - emptySlot->type = MESA_DEBUG_TYPE_ERROR; - emptySlot->id = oom_msg_id; - emptySlot->severity = MESA_DEBUG_SEVERITY_HIGH; - } -} - /** - * 'buf' is not necessarily a null-terminated string. When logging, copy - * 'len' characters from it, store them in a new, null-terminated string, - * and remember the number of bytes used by that string, *including* - * the null terminator this time. + * Log a client or driver debug message. */ static void log_msg(struct gl_context *ctx, enum mesa_debug_source source, @@ -412,14 +445,10 @@ log_msg(struct gl_context *ctx, enum mesa_debug_source source, enum mesa_debug_severity severity, GLint len, const char *buf) { struct gl_debug_state *debug = _mesa_get_debug_state(ctx); - GLint nextEmpty; - struct gl_debug_msg *emptySlot; if (!debug) return; - assert(len >= 0 && len < MAX_DEBUG_MESSAGE_LENGTH); - if (!should_log(ctx, source, type, id, severity)) return; @@ -432,19 +461,7 @@ log_msg(struct gl_context *ctx, enum mesa_debug_source source, return; } - if (debug->NumMessages == MAX_DEBUG_LOGGED_MESSAGES) - return; - - nextEmpty = (debug->NextMsg + debug->NumMessages) - % MAX_DEBUG_LOGGED_MESSAGES; - emptySlot = &debug->Log[nex
[Mesa-dev] [PATCH 02/21] glsl: protect locale_t with a mutex
There may be two contexts compiling shaders at the same time. locale_t needs to be protected. Signed-off-by: Chia-I Wu --- src/glsl/glsl_lexer.ll | 1 + src/glsl/ir_reader.cpp | 2 ++ src/glsl/strtod.c | 36 src/glsl/strtod.h | 3 +++ 4 files changed, 30 insertions(+), 12 deletions(-) diff --git a/src/glsl/glsl_lexer.ll b/src/glsl/glsl_lexer.ll index 7602351..eb23120 100644 --- a/src/glsl/glsl_lexer.ll +++ b/src/glsl/glsl_lexer.ll @@ -567,6 +567,7 @@ classify_identifier(struct _mesa_glsl_parse_state *state, const char *name) void _mesa_glsl_lexer_ctor(struct _mesa_glsl_parse_state *state, const char *string) { + glsl_initialize_strtod(); yylex_init_extra(state, & state->scanner); yy_scan_string(string, state->scanner); } diff --git a/src/glsl/ir_reader.cpp b/src/glsl/ir_reader.cpp index 28923f3..38b445b 100644 --- a/src/glsl/ir_reader.cpp +++ b/src/glsl/ir_reader.cpp @@ -79,6 +79,8 @@ void _mesa_glsl_read_ir(_mesa_glsl_parse_state *state, exec_list *instructions, const char *src, bool scan_for_protos) { + glsl_initialize_strtod(); + ir_reader r(state); r.read(instructions, src, scan_for_protos); } diff --git a/src/glsl/strtod.c b/src/glsl/strtod.c index 5d4346b..f37b3f5 100644 --- a/src/glsl/strtod.c +++ b/src/glsl/strtod.c @@ -25,6 +25,7 @@ #include +#include "c11/threads.h" #ifdef _GNU_SOURCE #include @@ -35,6 +36,27 @@ #include "strtod.h" +#if defined(_GNU_SOURCE) && !defined(__CYGWIN__) && !defined(__FreeBSD__) && \ + !defined(__HAIKU__) && !defined(__UCLIBC__) +#define GLSL_HAVE_LOCALE_T +#endif + +#ifdef GLSL_HAVE_LOCALE_T +static mtx_t loc_lock = _MTX_INITIALIZER_NP; +static locale_t loc = NULL; +#endif + +void +glsl_initialize_strtod(void) +{ +#ifdef GLSL_HAVE_LOCALE_T + mtx_lock(&loc_lock); + if (!loc) + loc = newlocale(LC_CTYPE_MASK, "C", NULL); + mtx_unlock(&loc_lock); +#endif +} + /** @@ -44,12 +66,7 @@ double glsl_strtod(const char *s, char **end) { -#if defined(_GNU_SOURCE) && !defined(__CYGWIN__) && !defined(__FreeBSD__) && \ - !defined(__HAIKU__) && !defined(__UCLIBC__) - static locale_t loc = NULL; - if (!loc) { - loc = newlocale(LC_CTYPE_MASK, "C", NULL); - } +#ifdef GLSL_HAVE_LOCALE_T return strtod_l(s, end, loc); #else return strtod(s, end); @@ -64,12 +81,7 @@ glsl_strtod(const char *s, char **end) float glsl_strtof(const char *s, char **end) { -#if defined(_GNU_SOURCE) && !defined(__CYGWIN__) && !defined(__FreeBSD__) && \ - !defined(__HAIKU__) && !defined(__UCLIBC__) - static locale_t loc = NULL; - if (!loc) { - loc = newlocale(LC_CTYPE_MASK, "C", NULL); - } +#ifdef GLSL_HAVE_LOCALE_T return strtof_l(s, end, loc); #elif _XOPEN_SOURCE >= 600 || _ISOC99_SOURCE return strtof(s, end); diff --git a/src/glsl/strtod.h b/src/glsl/strtod.h index ad847db..8062928 100644 --- a/src/glsl/strtod.h +++ b/src/glsl/strtod.h @@ -31,6 +31,9 @@ extern "C" { #endif +extern void +glsl_initialize_strtod(void); + extern double glsl_strtod(const char *s, char **end); -- 1.8.5.3 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 16/21] mesa: eliminate debug output message_insert
Add validate_length and use it and log_msg directly. Signed-off-by: Chia-I Wu --- src/mesa/main/errors.c | 46 -- 1 file changed, 20 insertions(+), 26 deletions(-) diff --git a/src/mesa/main/errors.c b/src/mesa/main/errors.c index bf0886f..0aa9c8a 100644 --- a/src/mesa/main/errors.c +++ b/src/mesa/main/errors.c @@ -724,33 +724,18 @@ error: } -/** - * This is a generic message insert function. - * Validation of source, type and severity parameters should be done - * before calling this funtion. - */ -static void -message_insert(GLenum source, GLenum type, GLuint id, - GLenum severity, GLint length, const GLchar *buf, - const char *callerstr) +static GLboolean +validate_length(struct gl_context *ctx, const char *callerstr, GLsizei length) { - GET_CURRENT_CONTEXT(ctx); - - if (length < 0) - length = strlen(buf); - if (length >= MAX_DEBUG_MESSAGE_LENGTH) { _mesa_error(ctx, GL_INVALID_VALUE, "%s(length=%d, which is not less than " "GL_MAX_DEBUG_MESSAGE_LENGTH=%d)", callerstr, length, MAX_DEBUG_MESSAGE_LENGTH); - return; + return GL_FALSE; } - log_msg(ctx, - gl_enum_to_debug_source(source), - gl_enum_to_debug_type(type), id, - gl_enum_to_debug_severity(severity), length, buf); + return GL_TRUE; } @@ -765,8 +750,16 @@ _mesa_DebugMessageInsert(GLenum source, GLenum type, GLuint id, if (!validate_params(ctx, INSERT, callerstr, source, type, severity)) return; /* GL_INVALID_ENUM */ + if (!validate_length(ctx, callerstr, length)) + return; /* GL_INVALID_VALUE */ - message_insert(source, type, id, severity, length, buf, callerstr); + if (length < 0) + length = strlen(buf); + + log_msg(ctx, gl_enum_to_debug_source(source), + gl_enum_to_debug_type(type), id, + gl_enum_to_debug_severity(severity), + length, buf); } @@ -916,12 +909,16 @@ _mesa_PushDebugGroup(GLenum source, GLuint id, GLsizei length, return; } + if (!validate_length(ctx, callerstr, length)) + return; /* GL_INVALID_VALUE */ + if (length < 0) length = strlen(message); - message_insert(source, GL_DEBUG_TYPE_PUSH_GROUP, id, - GL_DEBUG_SEVERITY_NOTIFICATION, length, - message, callerstr); + log_msg(ctx, gl_enum_to_debug_source(source), + MESA_DEBUG_TYPE_PUSH_GROUP, id, + MESA_DEBUG_SEVERITY_NOTIFICATION, length, + message); /* pop reuses the message details from push so we store this */ emptySlot = debug_get_group_message(debug); @@ -955,9 +952,6 @@ _mesa_PopDebugGroup(void) debug_pop_group(debug); gdmessage = debug_get_group_message(debug); - /* using log_msg() directly here as verification of parameters -* already done in push -*/ log_msg(ctx, gdmessage->source, gl_enum_to_debug_type(GL_DEBUG_TYPE_POP_GROUP), gdmessage->id, -- 1.8.5.3 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 11/21] mesa: refactor _mesa_PushDebugGroup
Move group copying to debug_push_group. Save group message in the group before pushing instead of after. Signed-off-by: Chia-I Wu --- src/mesa/main/errors.c | 100 + 1 file changed, 59 insertions(+), 41 deletions(-) diff --git a/src/mesa/main/errors.c b/src/mesa/main/errors.c index 1dc4d3a..9873dfc 100644 --- a/src/mesa/main/errors.c +++ b/src/mesa/main/errors.c @@ -484,6 +484,60 @@ debug_delete_messages(struct gl_debug_state *debug, unsigned count) } } +static struct gl_debug_msg * +debug_get_group_message(struct gl_debug_state *debug) +{ + return &debug->DebugGroupMsgs[debug->GroupStackDepth]; +} + +static void +debug_push_group(struct gl_debug_state *debug) +{ + const GLint gstack = debug->GroupStackDepth; + int s, t, sev; + + /* inherit the control volume of the debug group previously residing on +* the top of the debug group stack +*/ + for (s = 0; s < MESA_DEBUG_SOURCE_COUNT; s++) { + for (t = 0; t < MESA_DEBUG_TYPE_COUNT; t++) { + const struct gl_debug_namespace *nspace = +&debug->Namespaces[gstack][s][t]; + struct gl_debug_namespace *next = +&debug->Namespaces[gstack + 1][s][t]; + + /* copy id settings */ + next->IDs = _mesa_HashClone(nspace->IDs); + + for (sev = 0; sev < MESA_DEBUG_SEVERITY_COUNT; sev++) { +struct simple_node *node; + +/* copy default settings for unknown ids */ +debug->Defaults[gstack + 1][sev][s][t] = + debug->Defaults[gstack][sev][s][t]; + +/* copy known id severity settings */ +make_empty_list(&next->Severity[sev]); +foreach(node, &nspace->Severity[sev]) { + const struct gl_debug_severity *entry = + (const struct gl_debug_severity *) node; + struct gl_debug_severity *copy; + + copy = malloc(sizeof *entry); + if (!copy) + goto out; + + copy->ID = entry->ID; + insert_at_tail(&next->Severity[sev], ©->link); +} + } + } + } + +out: + debug->GroupStackDepth++; +} + /** * Return debug state for the context. The debug state will be allocated @@ -943,9 +997,6 @@ _mesa_PushDebugGroup(GLenum source, GLuint id, GLsizei length, GET_CURRENT_CONTEXT(ctx); struct gl_debug_state *debug = _mesa_get_debug_state(ctx); const char *callerstr = "glPushDebugGroup"; - int s, t, sev; - GLint prevStackDepth; - GLint currStackDepth; struct gl_debug_msg *emptySlot; if (!debug) @@ -966,18 +1017,15 @@ _mesa_PushDebugGroup(GLenum source, GLuint id, GLsizei length, return; } + if (length < 0) + length = strlen(message); + message_insert(source, GL_DEBUG_TYPE_PUSH_GROUP, id, GL_DEBUG_SEVERITY_NOTIFICATION, length, message, callerstr); - prevStackDepth = debug->GroupStackDepth; - debug->GroupStackDepth++; - currStackDepth = debug->GroupStackDepth; - /* pop reuses the message details from push so we store this */ - if (length < 0) - length = strlen(message); - emptySlot = &debug->DebugGroupMsgs[debug->GroupStackDepth]; + emptySlot = debug_get_group_message(debug); debug_store_message(debug, emptySlot, gl_enum_to_debug_source(source), gl_enum_to_debug_type(GL_DEBUG_TYPE_PUSH_GROUP), @@ -985,37 +1033,7 @@ _mesa_PushDebugGroup(GLenum source, GLuint id, GLsizei length, gl_enum_to_debug_severity(GL_DEBUG_SEVERITY_NOTIFICATION), length, message); - /* inherit the control volume of the debug group previously residing on -* the top of the debug group stack -*/ - for (s = 0; s < MESA_DEBUG_SOURCE_COUNT; s++) { - for (t = 0; t < MESA_DEBUG_TYPE_COUNT; t++) { - /* copy id settings */ - debug->Namespaces[currStackDepth][s][t].IDs = -_mesa_HashClone(debug->Namespaces[prevStackDepth][s][t].IDs); - - for (sev = 0; sev < MESA_DEBUG_SEVERITY_COUNT; sev++) { -struct gl_debug_severity *entry, *prevEntry; -struct simple_node *node; - -/* copy default settings for unknown ids */ -debug->Defaults[currStackDepth][sev][s][t] = - debug->Defaults[prevStackDepth][sev][s][t]; - -/* copy known id severity settings */ - make_empty_list(&debug->Namespaces[currStackDepth][s][t].Severity[sev]); -foreach(node, &debug->Namespaces[prevStackDepth][s][t].Severity[sev]) { - prevEntry = (struct gl_debug_severity *)node; - entry = malloc(sizeof *entry); - if (!entry) - return; - - entry->ID = prevEntry->ID; - insert_at_tail(&debug->Namespaces[currStackDepth][s][t].Severity[sev], &entry->link); -} - } -
[Mesa-dev] [PATCH 14/21] mesa: refactor _mesa_DebugMessageControl
Merge set_message_state, control_messages, and control_app_messages into the function. Signed-off-by: Chia-I Wu --- src/mesa/main/errors.c | 83 +++--- 1 file changed, 17 insertions(+), 66 deletions(-) diff --git a/src/mesa/main/errors.c b/src/mesa/main/errors.c index 5136f75..a5a7425 100644 --- a/src/mesa/main/errors.c +++ b/src/mesa/main/errors.c @@ -639,20 +639,6 @@ should_log(struct gl_context *ctx, } -static void -set_message_state(struct gl_context *ctx, - enum mesa_debug_source source, - enum mesa_debug_type type, - GLuint id, GLboolean enabled) -{ - struct gl_debug_state *debug = _mesa_get_debug_state(ctx); - - if (debug) - debug_set_message_filter(debug, source, type, id, enabled); -} - - - /** * Log a client or driver debug message. */ @@ -761,54 +747,6 @@ error: } -static void -control_messages(struct gl_context *ctx, - enum mesa_debug_source source, - enum mesa_debug_type type, - enum mesa_debug_severity severity, - GLboolean enabled) -{ - struct gl_debug_state *debug = _mesa_get_debug_state(ctx); - - if (!debug) - return; - - debug_set_default_filter(debug, source, type, severity, enabled); -} - - -/** - * Debugging-message namespaces with the source APPLICATION or THIRD_PARTY - * require special handling, since the IDs in them are controlled by clients, - * not the OpenGL implementation. - * - * 'count' is the length of the array 'ids'. If 'count' is nonzero, all - * the given IDs in the namespace defined by 'esource' and 'etype' - * will be affected. - * - * If 'count' is zero, this sets the state of all IDs that match - * the combination of 'esource', 'etype', and 'eseverity'. - */ -static void -control_app_messages(struct gl_context *ctx, GLenum esource, GLenum etype, - GLenum eseverity, GLsizei count, const GLuint *ids, - GLboolean enabled) -{ - GLsizei i; - enum mesa_debug_source source = gl_enum_to_debug_source(esource); - enum mesa_debug_type type = gl_enum_to_debug_type(etype); - enum mesa_debug_severity severity = gl_enum_to_debug_severity(eseverity); - - for (i = 0; i < count; i++) - set_message_state(ctx, source, type, ids[i], enabled); - - if (count) - return; - - control_messages(ctx, source, type, severity, enabled); -} - - /** * This is a generic message insert function. * Validation of source, type and severity parameters should be done @@ -920,9 +858,12 @@ _mesa_DebugMessageControl(GLenum gl_source, GLenum gl_type, GLenum gl_severity, GLsizei count, const GLuint *ids, GLboolean enabled) { - const char *callerstr = "glDebugMessageControl"; - GET_CURRENT_CONTEXT(ctx); + enum mesa_debug_source source = gl_enum_to_debug_source(gl_source); + enum mesa_debug_type type = gl_enum_to_debug_type(gl_type); + enum mesa_debug_severity severity = gl_enum_to_debug_severity(gl_severity); + const char *callerstr = "glDebugMessageControl"; + struct gl_debug_state *debug; if (count < 0) { _mesa_error(ctx, GL_INVALID_VALUE, @@ -944,8 +885,18 @@ _mesa_DebugMessageControl(GLenum gl_source, GLenum gl_type, return; } - control_app_messages(ctx, gl_source, gl_type, gl_severity, -count, ids, enabled); + debug = _mesa_get_debug_state(ctx); + if (!debug) + return; + + if (count) { + GLsizei i; + for (i = 0; i < count; i++) + debug_set_message_filter(debug, source, type, ids[i], enabled); + } + else { + debug_set_default_filter(debug, source, type, severity, enabled); + } } -- 1.8.5.3 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 19/21] glsl: add a generic thread pool data structure
It will be used to implement threaded glCompileShader. Signed-off-by: Chia-I Wu --- src/glsl/Makefile.am | 12 +- src/glsl/Makefile.sources | 3 +- src/glsl/tests/threadpool_test.cpp | 137 + src/glsl/threadpool.c | 394 + src/glsl/threadpool.h | 62 ++ 5 files changed, 606 insertions(+), 2 deletions(-) create mode 100644 src/glsl/tests/threadpool_test.cpp create mode 100644 src/glsl/threadpool.c create mode 100644 src/glsl/threadpool.h diff --git a/src/glsl/Makefile.am b/src/glsl/Makefile.am index 534eaa3..abb0515 100644 --- a/src/glsl/Makefile.am +++ b/src/glsl/Makefile.am @@ -35,6 +35,7 @@ TESTS = glcpp/tests/glcpp-test \ tests/general-ir-test \ tests/optimization-test \ tests/ralloc-test \ + tests/threadpool-test \ tests/sampler-types-test\ tests/uniform-initializer-test @@ -48,6 +49,7 @@ check_PROGRAMS = \ glsl_test \ tests/general-ir-test \ tests/ralloc-test \ + tests/threadpool-test \ tests/sampler-types-test\ tests/uniform-initializer-test @@ -92,6 +94,14 @@ tests_ralloc_test_LDADD =\ $(top_builddir)/src/gtest/libgtest.la \ $(PTHREAD_LIBS) +tests_threadpool_test_SOURCES =\ + tests/threadpool_test.cpp \ + $(top_builddir)/src/glsl/threadpool.c +tests_threadpool_test_CFLAGS = $(PTHREAD_CFLAGS) +tests_threadpool_test_LDADD = \ + $(top_builddir)/src/gtest/libgtest.la \ + $(PTHREAD_LIBS) + tests_sampler_types_test_SOURCES = \ $(top_srcdir)/src/mesa/program/prog_hash_table.c\ $(top_srcdir)/src/mesa/program/symbol_table.c \ @@ -115,7 +125,7 @@ glcpp_glcpp_LDADD = \ libglcpp.la \ -lm -libglsl_la_LIBADD = libglcpp.la +libglsl_la_LIBADD = libglcpp.la $(PTHREAD_LIBS) libglsl_la_SOURCES = \ glsl_lexer.cpp \ glsl_parser.cpp \ diff --git a/src/glsl/Makefile.sources b/src/glsl/Makefile.sources index 5945590..b82fbc7 100644 --- a/src/glsl/Makefile.sources +++ b/src/glsl/Makefile.sources @@ -102,7 +102,8 @@ LIBGLSL_FILES = \ $(GLSL_SRCDIR)/opt_tree_grafting.cpp \ $(GLSL_SRCDIR)/opt_vectorize.cpp \ $(GLSL_SRCDIR)/s_expression.cpp \ - $(GLSL_SRCDIR)/strtod.c + $(GLSL_SRCDIR)/strtod.c \ + $(GLSL_SRCDIR)/threadpool.c # glsl_compiler diff --git a/src/glsl/tests/threadpool_test.cpp b/src/glsl/tests/threadpool_test.cpp new file mode 100644 index 000..63f55c5 --- /dev/null +++ b/src/glsl/tests/threadpool_test.cpp @@ -0,0 +1,137 @@ +/* + * Copyright © 2014 LunarG, Inc. + * + * 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. + */ +#include +#include +#include +#include +#include +#include +#include "c11/threads.h" + +#include "threadpool.h" + +#define NUM_THREADS 10 +#define OPS_PER_THREAD 100 +#define MAX_TASKS 10 + +static void +race_cb(void *data) +{ + usleep(1000 * 5); +} + +static int +race_random_op(void *data) +{ + struct _mesa_threadpool *pool = (struct _mesa_threadpool *) data; + struct _mesa_threadpool_task *tasks[MAX_TASKS]; + int num_tasks = 0; + int num_ops = 0; + int i; + + while (num_ops < OPS_PER_THREAD) { + int op = (random() % 1000); + +
[Mesa-dev] [PATCH 18/21] mesa: protect the debug state with a mutex
When GL_DEBUG_OUTPUT_SYNCHRONOUS is GL_TRUE, drivers are allowed to log debug messages from other threads. The debug state needs to be protected. We are about to change mesa to spawn threads for deferred glCompileShader calls and we will need this groundwork. Signed-off-by: Chia-I Wu --- src/mesa/drivers/dri/common/dri_util.c | 3 +- src/mesa/main/enable.c | 6 +- src/mesa/main/errors.c | 163 + src/mesa/main/errors.h | 5 +- src/mesa/main/get.c| 30 -- src/mesa/main/getstring.c | 20 +++- src/mesa/main/mtypes.h | 1 + src/mesa/state_tracker/st_manager.c| 3 +- 8 files changed, 178 insertions(+), 53 deletions(-) diff --git a/src/mesa/drivers/dri/common/dri_util.c b/src/mesa/drivers/dri/common/dri_util.c index aed73c7..c085a21 100644 --- a/src/mesa/drivers/dri/common/dri_util.c +++ b/src/mesa/drivers/dri/common/dri_util.c @@ -449,9 +449,10 @@ driContextSetFlags(struct gl_context *ctx, uint32_t flags) if ((flags & __DRI_CTX_FLAG_FORWARD_COMPATIBLE) != 0) ctx->Const.ContextFlags |= GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT; if ((flags & __DRI_CTX_FLAG_DEBUG) != 0) { -struct gl_debug_state *debug = _mesa_get_debug_state(ctx); +struct gl_debug_state *debug = _mesa_lock_debug_state(ctx); if (debug) { debug->DebugOutput = GL_TRUE; +_mesa_unlock_debug_state(ctx); } ctx->Const.ContextFlags |= GL_CONTEXT_FLAG_DEBUG_BIT; } diff --git a/src/mesa/main/enable.c b/src/mesa/main/enable.c index edd4751..23e2239 100644 --- a/src/mesa/main/enable.c +++ b/src/mesa/main/enable.c @@ -372,9 +372,10 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state) goto invalid_enum_error; } else { -struct gl_debug_state *debug = _mesa_get_debug_state(ctx); +struct gl_debug_state *debug = _mesa_lock_debug_state(ctx); if (debug) { debug->DebugOutput = state; + _mesa_unlock_debug_state(ctx); } } break; @@ -383,9 +384,10 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state) goto invalid_enum_error; } else { -struct gl_debug_state *debug = _mesa_get_debug_state(ctx); +struct gl_debug_state *debug = _mesa_lock_debug_state(ctx); if (debug) { debug->SyncOutput = state; + _mesa_unlock_debug_state(ctx); } } break; diff --git a/src/mesa/main/errors.c b/src/mesa/main/errors.c index b9f8fc6..89ac2c0 100644 --- a/src/mesa/main/errors.c +++ b/src/mesa/main/errors.c @@ -599,22 +599,87 @@ 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. If the allocation fails, + * return NULL and the debug state is not locked. */ 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"); + /* + * This function may be called from other threads. When that is the + * case, we cannot record this OOM error. + */ + GET_CURRENT_CONTEXT(cur); + bool can_record = (cur == ctx); + + mtx_unlock(&ctx->DebugMutex); + + if (can_record) +_mesa_error(ctx, GL_OUT_OF_MEMORY, "allocating debug state"); + + return NULL; } } return ctx->Debug; } +void +_mesa_unlock_debug_state(struct gl_context *ctx) +{ + mtx_unlock(&ctx->DebugMutex); +} + +/** + * Call the debug callback. + */ +static void +log_msg_call_locked(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, +bool unlock) +{ + 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; + + if (unlock) + _mesa_unlock_debug_state(ctx); + + callback(gl_source, gl_type, id, gl_severity, len, buf, data); +} + +/** + * Log a client group message. + */ +static void +log_msg_group_locked(struct gl_context *ctx, + enum mesa_debug_source source, + enum mesa_debug_type ty
[Mesa-dev] [PATCH 15/21] mesa: eliminate debug output should_log
In both call sites, it could be easily replaced by direct debug_is_message_filtered calls. Signed-off-by: Chia-I Wu --- src/mesa/main/errors.c | 40 +++- 1 file changed, 11 insertions(+), 29 deletions(-) diff --git a/src/mesa/main/errors.c b/src/mesa/main/errors.c index a5a7425..bf0886f 100644 --- a/src/mesa/main/errors.c +++ b/src/mesa/main/errors.c @@ -616,29 +616,6 @@ _mesa_get_debug_state(struct gl_context *ctx) } - -static GLboolean -should_log(struct gl_context *ctx, - enum mesa_debug_source source, - enum mesa_debug_type type, - GLuint id, - enum mesa_debug_severity severity) -{ - struct gl_debug_state *debug; - - if (!ctx->Debug) { - /* no debug state set so far */ - return GL_FALSE; - } - - debug = _mesa_get_debug_state(ctx); - if (debug) - return !debug_is_message_filtered(debug, source, type, id, severity); - else - return GL_FALSE; -} - - /** * Log a client or driver debug message. */ @@ -652,7 +629,7 @@ log_msg(struct gl_context *ctx, enum mesa_debug_source source, if (!debug) return; - if (!should_log(ctx, source, type, id, severity)) + if (debug_is_message_filtered(debug, source, type, id, severity)) return; if (debug->Callback) { @@ -1220,11 +1197,16 @@ _mesa_error( struct gl_context *ctx, GLenum error, const char *fmtString, ... ) debug_get_id(&error_msg_id); do_output = should_output(ctx, error, fmtString); - do_log = should_log(ctx, - MESA_DEBUG_SOURCE_API, - MESA_DEBUG_TYPE_ERROR, - error_msg_id, - MESA_DEBUG_SEVERITY_HIGH); + if (ctx->Debug) { + do_log = !debug_is_message_filtered(ctx->Debug, + MESA_DEBUG_SOURCE_API, + MESA_DEBUG_TYPE_ERROR, + error_msg_id, + MESA_DEBUG_SEVERITY_HIGH); + } + else { + do_log = GL_FALSE; + } if (do_output || do_log) { char s[MAX_DEBUG_MESSAGE_LENGTH], s2[MAX_DEBUG_MESSAGE_LENGTH]; -- 1.8.5.3 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 17/21] mesa: kill wasted type conversions in debug output
Signed-off-by: Chia-I Wu --- src/mesa/main/errors.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/mesa/main/errors.c b/src/mesa/main/errors.c index 0aa9c8a..b9f8fc6 100644 --- a/src/mesa/main/errors.c +++ b/src/mesa/main/errors.c @@ -924,9 +924,9 @@ _mesa_PushDebugGroup(GLenum source, GLuint id, GLsizei length, emptySlot = debug_get_group_message(debug); debug_store_message(debug, emptySlot, gl_enum_to_debug_source(source), - gl_enum_to_debug_type(GL_DEBUG_TYPE_PUSH_GROUP), + MESA_DEBUG_TYPE_PUSH_GROUP, id, - gl_enum_to_debug_severity(GL_DEBUG_SEVERITY_NOTIFICATION), + MESA_DEBUG_SEVERITY_NOTIFICATION, length, message); debug_push_group(debug); @@ -953,9 +953,9 @@ _mesa_PopDebugGroup(void) gdmessage = debug_get_group_message(debug); log_msg(ctx, gdmessage->source, - gl_enum_to_debug_type(GL_DEBUG_TYPE_POP_GROUP), + MESA_DEBUG_TYPE_POP_GROUP, gdmessage->id, - gl_enum_to_debug_severity(GL_DEBUG_SEVERITY_NOTIFICATION), + MESA_DEBUG_SEVERITY_NOTIFICATION, gdmessage->length, gdmessage->message); debug_clear_message(debug, gdmessage); -- 1.8.5.3 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 21/21] i965: add drirc option multithread_glsl_compiler
Setting it to a non-zero value N will cause glCompileShader to be deferred to a thread pool. When N is greater than 1, it indicates the maximum number of threads in the pool. When N is 1, the number of threads is up to the driver. Signed-off-by: Chia-I Wu --- src/mesa/drivers/dri/common/xmlpool/t_options.h | 4 src/mesa/drivers/dri/i965/brw_context.c | 9 + src/mesa/drivers/dri/i965/intel_screen.c| 2 ++ 3 files changed, 15 insertions(+) diff --git a/src/mesa/drivers/dri/common/xmlpool/t_options.h b/src/mesa/drivers/dri/common/xmlpool/t_options.h index 3bf804a..a99c930 100644 --- a/src/mesa/drivers/dri/common/xmlpool/t_options.h +++ b/src/mesa/drivers/dri/common/xmlpool/t_options.h @@ -293,6 +293,10 @@ DRI_CONF_OPT_BEGIN_V(texture_heaps,enum,def,"0:2") \ DRI_CONF_DESC_END \ DRI_CONF_OPT_END +#define DRI_CONF_MULTITHREAD_GLSL_COMPILER(def) \ +DRI_CONF_OPT_BEGIN(multithread_glsl_compiler, int, def) \ +DRI_CONF_DESC(en,gettext("Enable multithreading in the GLSL compiler")) \ +DRI_CONF_OPT_END /** diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c index 28118b9..9be320f 100644 --- a/src/mesa/drivers/dri/i965/brw_context.c +++ b/src/mesa/drivers/dri/i965/brw_context.c @@ -565,6 +565,15 @@ brw_process_driconf_options(struct brw_context *brw) ctx->Const.DisableGLSLLineContinuations = driQueryOptionb(options, "disable_glsl_line_continuations"); + + const int multithread_glsl_compiler = + driQueryOptioni(options, "multithread_glsl_compiler"); + if (multithread_glsl_compiler > 0) { + const int max_threads = (multithread_glsl_compiler > 1) ? + multithread_glsl_compiler : 2; + + _mesa_enable_glsl_threadpool(ctx, max_threads); + } } GLboolean diff --git a/src/mesa/drivers/dri/i965/intel_screen.c b/src/mesa/drivers/dri/i965/intel_screen.c index 8cb1260..1a3f6cc 100644 --- a/src/mesa/drivers/dri/i965/intel_screen.c +++ b/src/mesa/drivers/dri/i965/intel_screen.c @@ -48,6 +48,8 @@ static const __DRIconfigOptionsExtension brw_config_options = { DRI_CONF_BEGIN DRI_CONF_SECTION_PERFORMANCE DRI_CONF_VBLANK_MODE(DRI_CONF_VBLANK_ALWAYS_SYNC) + DRI_CONF_MULTITHREAD_GLSL_COMPILER(0) + /* Options correspond to DRI_CONF_BO_REUSE_DISABLED, * DRI_CONF_BO_REUSE_ALL */ -- 1.8.5.3 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 20/21] mesa: add support for threaded glCompileShader
From: Chia-I Wu Threaded glCompileShader can be enabled for a context by calling _mesa_enable_glsl_threadpool. It will initialize the singleton GLSL thread pool and defer glCompileShader calls to the thread pool. For applications to benefit from threaded glCompileShader, they have to compile shaders in this fashion for (i = 0; i < num_shaders; i++) glCompileShader(shaders[i]); for (i = 0; i < num_shaders; i++) glGetShaderiv(shaders[i], GL_COMPILE_STATUS, &val); As each glGetShaderiv call will force mesa to wait for the deferred glCompileShader to complete, compiling shaders in the traditional way will defeat this feature. This is also why the feature needs to be explicitly enabled with _mesa_enable_glsl_threadpool. Signed-off-by: Chia-I Wu --- src/glsl/glsl_parser_extras.cpp | 4 +++ src/glsl/threadpool.c | 72 + src/glsl/threadpool.h | 9 ++ src/mesa/main/context.c | 25 ++ src/mesa/main/context.h | 3 ++ src/mesa/main/mtypes.h | 13 src/mesa/main/shaderapi.c | 48 +-- src/mesa/main/shaderobj.c | 20 src/mesa/main/shaderobj.h | 2 ++ 9 files changed, 194 insertions(+), 2 deletions(-) diff --git a/src/glsl/glsl_parser_extras.cpp b/src/glsl/glsl_parser_extras.cpp index 30e284b..c035474 100644 --- a/src/glsl/glsl_parser_extras.cpp +++ b/src/glsl/glsl_parser_extras.cpp @@ -37,6 +37,7 @@ extern "C" { #include "glsl_parser.h" #include "ir_optimization.h" #include "loop_analysis.h" +#include "threadpool.h" /** * Format a short human-readable description of the given GLSL version. @@ -1567,6 +1568,8 @@ extern "C" { void _mesa_destroy_shader_compiler(void) { + _mesa_glsl_destroy_threadpool(); + _mesa_destroy_shader_compiler_caches(); _mesa_glsl_release_types(); @@ -1580,6 +1583,7 @@ _mesa_destroy_shader_compiler(void) void _mesa_destroy_shader_compiler_caches(void) { + _mesa_glsl_wait_threadpool(); _mesa_glsl_release_builtin_functions(); } diff --git a/src/glsl/threadpool.c b/src/glsl/threadpool.c index 0aaac3a..3d54ec0 100644 --- a/src/glsl/threadpool.c +++ b/src/glsl/threadpool.c @@ -55,6 +55,7 @@ struct _mesa_threadpool_task { struct _mesa_threadpool { mtx_t mutex; int refcnt; + bool shutdown; enum _mesa_threadpool_control thread_control; thrd_t *threads; @@ -158,6 +159,12 @@ _mesa_threadpool_queue_task(struct _mesa_threadpool *pool, mtx_lock(&pool->mutex); + if (unlikely(pool->shutdown)) { + mtx_unlock(&pool->mutex); + free(task); + return NULL; + } + while (unlikely(pool->thread_control != MESA_THREADPOOL_NORMAL)) cnd_wait(&pool->thread_joined, &pool->mutex); @@ -297,6 +304,17 @@ _mesa_threadpool_join(struct _mesa_threadpool *pool, bool graceful) } /** + * After this call, no task can be queued. + */ +static void +_mesa_threadpool_set_shutdown(struct _mesa_threadpool *pool) +{ + mtx_lock(&pool->mutex); + pool->shutdown = true; + mtx_unlock(&pool->mutex); +} + +/** * Decrease the reference count. Destroy \p pool when the reference count * reaches zero. */ @@ -392,3 +410,57 @@ _mesa_threadpool_create(int max_threads) return pool; } + +static mtx_t threadpool_lock = _MTX_INITIALIZER_NP; +static struct _mesa_threadpool *threadpool; + +/** + * Get the singleton GLSL thread pool. \p max_threads is honored only by the + * first call to this function. + */ +struct _mesa_threadpool * +_mesa_glsl_get_threadpool(int max_threads) +{ + mtx_lock(&threadpool_lock); + if (!threadpool) + threadpool = _mesa_threadpool_create(max_threads); + if (threadpool) + _mesa_threadpool_ref(threadpool); + mtx_unlock(&threadpool_lock); + + return threadpool; +} + +/** + * Wait until all tasks are completed and threads are joined. + */ +void +_mesa_glsl_wait_threadpool(void) +{ + mtx_lock(&threadpool_lock); + if (threadpool) + _mesa_threadpool_join(threadpool, true); + mtx_unlock(&threadpool_lock); +} + +/** + * Destroy the GLSL thread pool. + */ +void +_mesa_glsl_destroy_threadpool(void) +{ + mtx_lock(&threadpool_lock); + if (threadpool) { + /* + * This is called from _mesa_destroy_shader_compiler(). No new task is + * allowed since this point. But contexts, who also own references to + * the pool, can still complete tasks that have been queued. + */ + _mesa_threadpool_set_shutdown(threadpool); + + _mesa_threadpool_join(threadpool, false); + _mesa_threadpool_unref(threadpool); + threadpool = NULL; + } + mtx_unlock(&threadpool_lock); +} diff --git a/src/glsl/threadpool.h b/src/glsl/threadpool.h index 9447115..59ea260 100644 --- a/src/glsl/threadpool.h +++ b/src/glsl/threadpool.h @@ -55,6 +55,15 @@ bool _mesa_threadpool_complete_task(struct _mesa_threadpool *pool, struct _mesa_threadpool_task *task); +struct _mesa_
Re: [Mesa-dev] [PATCH] mesa/st: enable EXT_shader_integer_mix when NativeIntegers is on
Reviewed-by: Marek Olšák Marek On Tue, Apr 22, 2014 at 4:27 AM, Ilia Mirkin wrote: > Signed-off-by: Ilia Mirkin > --- > > This just maps to the UCMP instruction which should be supported by everyone > who supports native integers in shaders. Tested on nv50, llvmpipe, and > softpipe. > > src/mesa/state_tracker/st_extensions.c | 4 > 1 file changed, 4 insertions(+) > > diff --git a/src/mesa/state_tracker/st_extensions.c > b/src/mesa/state_tracker/st_extensions.c > index 8b1101a..a245fdf 100644 > --- a/src/mesa/state_tracker/st_extensions.c > +++ b/src/mesa/state_tracker/st_extensions.c > @@ -636,6 +636,8 @@ void st_init_extensions(struct st_context *st) >if (!st->options.disable_shader_bit_encoding) { > ctx->Extensions.ARB_shader_bit_encoding = GL_TRUE; >} > + > + ctx->Extensions.EXT_shader_integer_mix = GL_TRUE; > } else { >/* Optional integer support for GLSL 1.2. */ >if (screen->get_shader_param(screen, PIPE_SHADER_VERTEX, > @@ -643,6 +645,8 @@ void st_init_extensions(struct st_context *st) >screen->get_shader_param(screen, PIPE_SHADER_FRAGMENT, > PIPE_SHADER_CAP_INTEGERS)) { > ctx->Const.NativeIntegers = GL_TRUE; > + > + ctx->Extensions.EXT_shader_integer_mix = GL_TRUE; >} > } > > -- > 1.8.3.2 > > ___ > mesa-dev mailing list > mesa-dev@lists.freedesktop.org > http://lists.freedesktop.org/mailman/listinfo/mesa-dev ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 5/6] mesa: Implement INTEL_performance_query.
On 04/19/2014 12:34 AM, Ian Romanick wrote: On 03/17/2014 01:43 AM, Petri Latvala wrote: + if (queryName) { + strncpy(queryName, group_obj->Name, queryNameLength); + /* No specification given about whether the string needs to be + * zero-terminated. Zero-terminate the string anyway, no way for the + * application to know if the buffer was large enough. + */ Ugh... there's no way to ask the length of the longest name (like you can do with program uniforms)? Bad spec, bad! There's GL_PERFQUERY_QUERY_NAME_LENGTH_MAX_INTEL etc. for all these string getters, so the comment might be a bit misleading. I'll rewrite it. The intention is to ensure that the written data is always null-terminated, even if the given buffer was too small. strncpy will already write the \0 at the end unless the buffer was too small. glGetActiveUniform() and pals return the length of the actual data written (not to mention explicitly specifying that the string is null-terminated), this API does not. ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 16/21] mesa: eliminate debug output message_insert
On Tue, 2014-04-22 at 16:58 +0800, Chia-I Wu wrote: > Add validate_length and use it and log_msg directly. > > Signed-off-by: Chia-I Wu > --- > src/mesa/main/errors.c | 46 -- > 1 file changed, 20 insertions(+), 26 deletions(-) > > diff --git a/src/mesa/main/errors.c b/src/mesa/main/errors.c > index bf0886f..0aa9c8a 100644 > --- a/src/mesa/main/errors.c > +++ b/src/mesa/main/errors.c > @@ -724,33 +724,18 @@ error: > } > > > -/** > - * This is a generic message insert function. > - * Validation of source, type and severity parameters should be done > - * before calling this funtion. > - */ > -static void > -message_insert(GLenum source, GLenum type, GLuint id, > - GLenum severity, GLint length, const GLchar *buf, > - const char *callerstr) > +static GLboolean > +validate_length(struct gl_context *ctx, const char *callerstr, GLsizei > length) > { > - GET_CURRENT_CONTEXT(ctx); > - > - if (length < 0) > - length = strlen(buf); > - > if (length >= MAX_DEBUG_MESSAGE_LENGTH) { >_mesa_error(ctx, GL_INVALID_VALUE, > "%s(length=%d, which is not less than " > "GL_MAX_DEBUG_MESSAGE_LENGTH=%d)", callerstr, length, > MAX_DEBUG_MESSAGE_LENGTH); > - return; > + return GL_FALSE; > } > > - log_msg(ctx, > - gl_enum_to_debug_source(source), > - gl_enum_to_debug_type(type), id, > - gl_enum_to_debug_severity(severity), length, buf); > + return GL_TRUE; > } > > > @@ -765,8 +750,16 @@ _mesa_DebugMessageInsert(GLenum source, GLenum type, > GLuint id, > > if (!validate_params(ctx, INSERT, callerstr, source, type, severity)) >return; /* GL_INVALID_ENUM */ > + if (!validate_length(ctx, callerstr, length)) > + return; /* GL_INVALID_VALUE */ > > - message_insert(source, type, id, severity, length, buf, callerstr); > + if (length < 0) > + length = strlen(buf); > + The validate call should be here i.e after checking buf length. "The error INVALID_VALUE will be generated if the number of characters in , excluding the null terminator when is negative, is not less than the value of MAX_DEBUG_MESSAGE_LENGTH." > + log_msg(ctx, gl_enum_to_debug_source(source), > + gl_enum_to_debug_type(type), id, > + gl_enum_to_debug_severity(severity), > + length, buf); > } > > > @@ -916,12 +909,16 @@ _mesa_PushDebugGroup(GLenum source, GLuint id, GLsizei > length, >return; > } > > + if (!validate_length(ctx, callerstr, length)) > + return; /* GL_INVALID_VALUE */ > + > if (length < 0) >length = strlen(message); As above the validate should be here > > - message_insert(source, GL_DEBUG_TYPE_PUSH_GROUP, id, > - GL_DEBUG_SEVERITY_NOTIFICATION, length, > - message, callerstr); > + log_msg(ctx, gl_enum_to_debug_source(source), > + MESA_DEBUG_TYPE_PUSH_GROUP, id, > + MESA_DEBUG_SEVERITY_NOTIFICATION, length, > + message); > > /* pop reuses the message details from push so we store this */ > emptySlot = debug_get_group_message(debug); > @@ -955,9 +952,6 @@ _mesa_PopDebugGroup(void) > debug_pop_group(debug); > > gdmessage = debug_get_group_message(debug); > - /* using log_msg() directly here as verification of parameters > -* already done in push > -*/ > log_msg(ctx, gdmessage->source, > gl_enum_to_debug_type(GL_DEBUG_TYPE_POP_GROUP), > gdmessage->id, ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 12/21] mesa: refactor _mesa_PopDebugGroup and _mesa_free_errors_data
On Tue, 2014-04-22 at 16:58 +0800, Chia-I Wu wrote: > Move group clearing to debug_clear_group. Add debug_pop_group and > debug_destroy for use in _mesa_PopDebugGroup and _mesa_free_errors_data > respectively. debug_destroy is not very specific debug_destroy_groups maybe? > > Signed-off-by: Chia-I Wu > --- > src/mesa/main/errors.c | 127 > + > 1 file changed, 64 insertions(+), 63 deletions(-) > > diff --git a/src/mesa/main/errors.c b/src/mesa/main/errors.c > index 9873dfc..139e31d 100644 > --- a/src/mesa/main/errors.c > +++ b/src/mesa/main/errors.c > @@ -217,7 +217,57 @@ debug_create(void) > return debug; > } > > -/* > +static void > +debug_clear_group_cb(GLuint key, void *data, void *userData) > +{ > +} > + > +/** > + * Free debug state for the given stack depth. > + */ > +static void > +debug_clear_group(struct gl_debug_state *debug, GLint gstack) > +{ > + enum mesa_debug_type t; > + enum mesa_debug_source s; > + enum mesa_debug_severity sev; > + > + /* Tear down state for filtering debug messages. */ > + for (s = 0; s < MESA_DEBUG_SOURCE_COUNT; s++) { > + for (t = 0; t < MESA_DEBUG_TYPE_COUNT; t++) { > + struct gl_debug_namespace *nspace = > &debug->Namespaces[gstack][s][t]; > + > + _mesa_HashDeleteAll(nspace->IDs, debug_clear_group_cb, NULL); > + _mesa_DeleteHashTable(nspace->IDs); > + for (sev = 0; sev < MESA_DEBUG_SEVERITY_COUNT; sev++) { > +struct simple_node *node, *tmp; > +struct gl_debug_severity *entry; > + > +foreach_s(node, tmp, &nspace->Severity[sev]) { > + entry = (struct gl_debug_severity *)node; > + free(entry); > +} > + } > + } > + } > +} > + > +/** > + * Loop through debug group stack tearing down states for > + * filtering debug messages. Then free debug output state. > + */ > +static void > +debug_destroy(struct gl_debug_state *debug) > +{ > + GLint i; > + > + for (i = 0; i <= debug->GroupStackDepth; i++) > + debug_clear_group(debug, i); > + > + free(debug); > +} > + > +/** > * Sets the state of the given message source/type/ID tuple. > */ > static void > @@ -538,6 +588,15 @@ out: > debug->GroupStackDepth++; > } > > +static void > +debug_pop_group(struct gl_debug_state *debug) > +{ > + const GLint gstack = debug->GroupStackDepth; > + > + debug->GroupStackDepth--; > + debug_clear_group(debug, gstack); > +} > + > > /** > * Return debug state for the context. The debug state will be allocated > @@ -840,47 +899,6 @@ message_insert(GLenum source, GLenum type, GLuint id, > } > > > -static void > -do_nothing(GLuint key, void *data, void *userData) > -{ > -} > - > - > -/** > - * Free context state pertaining to error/debug state for the given stack > - * depth. > - */ > -static void > -free_errors_data(struct gl_context *ctx, GLint gstack) > -{ > - struct gl_debug_state *debug = ctx->Debug; > - enum mesa_debug_type t; > - enum mesa_debug_source s; > - enum mesa_debug_severity sev; > - > - assert(debug); > - > - /* Tear down state for filtering debug messages. */ > - for (s = 0; s < MESA_DEBUG_SOURCE_COUNT; s++) { > - for (t = 0; t < MESA_DEBUG_TYPE_COUNT; t++) { > - _mesa_HashDeleteAll(debug->Namespaces[gstack][s][t].IDs, > - do_nothing, NULL); > - _mesa_DeleteHashTable(debug->Namespaces[gstack][s][t].IDs); > - for (sev = 0; sev < MESA_DEBUG_SEVERITY_COUNT; sev++) { > -struct simple_node *node, *tmp; > -struct gl_debug_severity *entry; > - > -foreach_s(node, tmp, > - &debug->Namespaces[gstack][s][t].Severity[sev]) { > - entry = (struct gl_debug_severity *)node; > - free(entry); > -} > - } > - } > - } > -} > - > - > void GLAPIENTRY > _mesa_DebugMessageInsert(GLenum source, GLenum type, GLuint id, > GLenum severity, GLint length, > @@ -1044,7 +1062,6 @@ _mesa_PopDebugGroup(void) > struct gl_debug_state *debug = _mesa_get_debug_state(ctx); > const char *callerstr = "glPopDebugGroup"; > struct gl_debug_msg *gdmessage; > - GLint prevStackDepth; > > if (!debug) >return; > @@ -1054,10 +1071,9 @@ _mesa_PopDebugGroup(void) >return; > } > > - prevStackDepth = debug->GroupStackDepth; > - debug->GroupStackDepth--; > + debug_pop_group(debug); > > - gdmessage = &debug->DebugGroupMsgs[prevStackDepth]; > + gdmessage = debug_get_group_message(debug); > /* using log_msg() directly here as verification of parameters > * already done in push > */ > @@ -1067,13 +1083,7 @@ _mesa_PopDebugGroup(void) > gl_enum_to_debug_severity(GL_DEBUG_SEVERITY_NOTIFICATION), > gdmessage->length, gdmessage->message); > > - if (gdmessage->message != (char*)out_of_memory) > - free(gdmessage-
Re: [Mesa-dev] [PATCH 00/21] deferred and threaded glCompileShader
On Tue, 2014-04-22 at 16:58 +0800, Chia-I Wu wrote: > Hi list, > > This series adds a thread pool to the GLSL compiler, and a drirc option to > defer glCompileShader calls to the pool. The goal is to reduce the start-up > time of applications that are aware of this feature. That is, applications > that compile shaders first and check the compile status later. > > I do not have numbers from real applications yet. But trying to compiling a > set of 2882 shaders extracted from some trace file, with everything else > idled, the time it takes is > > 8 threads: 17.8s > 4 threads: 20.3s > 2 threads: 31.2s > 1 threads: 58.0s > no thread pool: 54.5 > > on a quad core system. > > Patches 1-4 fix potential races in the GLSL compiler. As the compiler is > already shared by all contexts, these patches could be desirable even without > the thread pool that I am going to add. > > Patches 5-18 adds true GL_DEBUG_OUTPUT_SYNCHRONOUS support to the KHR_debug > code. All except patch 18 are clean-ups. Patch 18 adds a mutex to protect > gl_debug_state. I've skimmed over patches 5-17 looks like some good clean ups. I've made some comments for patch 12 and 16. > > Patch 19 defines a simple API to create and work with thread pools, as well as > a test for the API. > > Patch 20 adds the singleton GLSL thread pool and allows glCompileShader to be > deferred to the pool. This feature needs to be explicitly enabled with > _mesa_enable_glsl_threadpool. > > Patch 21 adds a drirc option to enable the thread pool. The idea is that only > applications that can benefit from it will enable it. > ___ > mesa-dev mailing list > mesa-dev@lists.freedesktop.org > http://lists.freedesktop.org/mailman/listinfo/mesa-dev ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 12/21] mesa: refactor _mesa_PopDebugGroup and _mesa_free_errors_data
On Tue, 2014-04-22 at 21:31 +1000, Timothy Arceri wrote: > On Tue, 2014-04-22 at 16:58 +0800, Chia-I Wu wrote: > > Move group clearing to debug_clear_group. Add debug_pop_group and > > debug_destroy for use in _mesa_PopDebugGroup and _mesa_free_errors_data > > respectively. > > debug_destroy is not very specific debug_destroy_groups maybe? Please ignore my comment I see now that this is does free the debug context too. > > > > > Signed-off-by: Chia-I Wu > > --- > > src/mesa/main/errors.c | 127 > > + > > 1 file changed, 64 insertions(+), 63 deletions(-) > > > > diff --git a/src/mesa/main/errors.c b/src/mesa/main/errors.c > > index 9873dfc..139e31d 100644 > > --- a/src/mesa/main/errors.c > > +++ b/src/mesa/main/errors.c > > @@ -217,7 +217,57 @@ debug_create(void) > > return debug; > > } > > > > -/* > > +static void > > +debug_clear_group_cb(GLuint key, void *data, void *userData) > > +{ > > +} > > + > > +/** > > + * Free debug state for the given stack depth. > > + */ > > +static void > > +debug_clear_group(struct gl_debug_state *debug, GLint gstack) > > +{ > > + enum mesa_debug_type t; > > + enum mesa_debug_source s; > > + enum mesa_debug_severity sev; > > + > > + /* Tear down state for filtering debug messages. */ > > + for (s = 0; s < MESA_DEBUG_SOURCE_COUNT; s++) { > > + for (t = 0; t < MESA_DEBUG_TYPE_COUNT; t++) { > > + struct gl_debug_namespace *nspace = > > &debug->Namespaces[gstack][s][t]; > > + > > + _mesa_HashDeleteAll(nspace->IDs, debug_clear_group_cb, NULL); > > + _mesa_DeleteHashTable(nspace->IDs); > > + for (sev = 0; sev < MESA_DEBUG_SEVERITY_COUNT; sev++) { > > +struct simple_node *node, *tmp; > > +struct gl_debug_severity *entry; > > + > > +foreach_s(node, tmp, &nspace->Severity[sev]) { > > + entry = (struct gl_debug_severity *)node; > > + free(entry); > > +} > > + } > > + } > > + } > > +} > > + > > +/** > > + * Loop through debug group stack tearing down states for > > + * filtering debug messages. Then free debug output state. > > + */ > > +static void > > +debug_destroy(struct gl_debug_state *debug) > > +{ > > + GLint i; > > + > > + for (i = 0; i <= debug->GroupStackDepth; i++) > > + debug_clear_group(debug, i); > > + > > + free(debug); > > +} > > + > > +/** > > * Sets the state of the given message source/type/ID tuple. > > */ > > static void > > @@ -538,6 +588,15 @@ out: > > debug->GroupStackDepth++; > > } > > > > +static void > > +debug_pop_group(struct gl_debug_state *debug) > > +{ > > + const GLint gstack = debug->GroupStackDepth; > > + > > + debug->GroupStackDepth--; > > + debug_clear_group(debug, gstack); > > +} > > + > > > > /** > > * Return debug state for the context. The debug state will be allocated > > @@ -840,47 +899,6 @@ message_insert(GLenum source, GLenum type, GLuint id, > > } > > > > > > -static void > > -do_nothing(GLuint key, void *data, void *userData) > > -{ > > -} > > - > > - > > -/** > > - * Free context state pertaining to error/debug state for the given stack > > - * depth. > > - */ > > -static void > > -free_errors_data(struct gl_context *ctx, GLint gstack) > > -{ > > - struct gl_debug_state *debug = ctx->Debug; > > - enum mesa_debug_type t; > > - enum mesa_debug_source s; > > - enum mesa_debug_severity sev; > > - > > - assert(debug); > > - > > - /* Tear down state for filtering debug messages. */ > > - for (s = 0; s < MESA_DEBUG_SOURCE_COUNT; s++) { > > - for (t = 0; t < MESA_DEBUG_TYPE_COUNT; t++) { > > - _mesa_HashDeleteAll(debug->Namespaces[gstack][s][t].IDs, > > - do_nothing, NULL); > > - _mesa_DeleteHashTable(debug->Namespaces[gstack][s][t].IDs); > > - for (sev = 0; sev < MESA_DEBUG_SEVERITY_COUNT; sev++) { > > -struct simple_node *node, *tmp; > > -struct gl_debug_severity *entry; > > - > > -foreach_s(node, tmp, > > - &debug->Namespaces[gstack][s][t].Severity[sev]) { > > - entry = (struct gl_debug_severity *)node; > > - free(entry); > > -} > > - } > > - } > > - } > > -} > > - > > - > > void GLAPIENTRY > > _mesa_DebugMessageInsert(GLenum source, GLenum type, GLuint id, > > GLenum severity, GLint length, > > @@ -1044,7 +1062,6 @@ _mesa_PopDebugGroup(void) > > struct gl_debug_state *debug = _mesa_get_debug_state(ctx); > > const char *callerstr = "glPopDebugGroup"; > > struct gl_debug_msg *gdmessage; > > - GLint prevStackDepth; > > > > if (!debug) > >return; > > @@ -1054,10 +1071,9 @@ _mesa_PopDebugGroup(void) > >return; > > } > > > > - prevStackDepth = debug->GroupStackDepth; > > - debug->GroupStackDepth--; > > + debug_pop_group(debug); > > > > - gdmessage =
Re: [Mesa-dev] Broadcom VideoCore IV
Le 21 avr. 2014 13:16, "Rob Clark" a écrit : > > On Sat, Apr 19, 2014 at 9:32 AM, Mohamed MEDIOUNI > wrote: > > The VideoCore IV GPU has 14 cores: > > > > - 2 VPU Cores : Full-blown cores which run the ThreadX RTOS. > > There is an experimental LLVM port to it and also the VBCC C89 > > compiler(which has'nt time support so classic benchmarks run indefinitely). > > The binary blob run on that. > > 5 GFlops > > > > - 12 QPU Cores : 3D cores officially documented by Broadcom and using a > > tile-mode rendering architecture. > > The full Android driver for that was open-sourced at the end of February. > > > > 24Gflops > > > > Questions: > > > > Can Gallium3D run with tile-mode rendering architecture ? > > yes, adreno (freedreno) is a tiler > Thank you. > > Is it better using Mesa and the Broadcom shader compiler ? > > Allegedly it may be easier to shoehorn in the blob compiler with a > mesa/dri driver vs mesa/gallium driver. That probably shouldn't be > too much of a concern in the long run. Overall I think a gallium > driver would be much easier to implement... gallium plus helpers > provide a lot to the driver writer. > > > Is it better using the VPU and an adapted LLVMpipe ? > > I guess you are talking about keeping the driver-on-videocore > approach? That may have some advantages when it comes to handling > security (lack of mmu) on r-pi. But other than that, I suspect > everything else will be easier to develop/debug on the arm side. And > I suspect avoiding round trips to the coprocessor will help > performance in a lot of cases. > > so if you can figure out a way to deal with security aspect with arm > side driver, then I'd go for arm side gallium driver as my first > choice. > No, use only the VPU and forget anything about the 3D unit. > BR, > -R > > > > > ___ > > mesa-dev mailing list > > mesa-dev@lists.freedesktop.org > > http://lists.freedesktop.org/mailman/listinfo/mesa-dev > > Is there any documentation for Gallium3D ? ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 03/19] mesa: Optimize unbind_texobj_from_texunits()
On 04/21/2014 03:57 PM, Fredrik Höglund wrote: The texture can only be bound to the index that corresponds to its target, so there is no need to loop over all possible indices for every unit and checking if the texture is bound to it. --- v2: Restructure the loop to avoid using continue, and use &= ~(1 << index) to clear bits in _BoundTextures. src/mesa/main/texobj.c | 20 +++- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/mesa/main/texobj.c b/src/mesa/main/texobj.c index 054b41b..7e43472 100644 --- a/src/mesa/main/texobj.c +++ b/src/mesa/main/texobj.c @@ -1093,18 +1093,20 @@ static void unbind_texobj_from_texunits(struct gl_context *ctx, struct gl_texture_object *texObj) { - GLuint u, tex; + const GLuint index = texObj->TargetIndex; Should that be const gl_texture_index index = ... ? + GLuint u; + + if (texObj->Target == 0) + return; for (u = 0; u < Elements(ctx->Texture.Unit); u++) { struct gl_texture_unit *unit = &ctx->Texture.Unit[u]; - for (tex = 0; tex < NUM_TEXTURE_TARGETS; tex++) { - if (texObj == unit->CurrentTex[tex]) { -_mesa_reference_texobj(&unit->CurrentTex[tex], - ctx->Shared->DefaultTex[tex]); -ASSERT(unit->CurrentTex[tex]); -unit->_BoundTextures &= ~(1 << tex); -break; - } + + if (texObj == unit->CurrentTex[index]) { + /* Bind the default texture for this unit/target */ + _mesa_reference_texobj(&unit->CurrentTex[index], +ctx->Shared->DefaultTex[index]); + unit->_BoundTextures &= ~(1 << index); } } } ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 14/19] mesa: Implement glBindBuffersBase
On 04/21/2014 03:57 PM, Fredrik Höglund wrote: --- src/mesa/main/bufferobj.c | 368 ++ 1 file changed, 368 insertions(+) diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c index 856b246..3e45ae0 100644 --- a/src/mesa/main/bufferobj.c +++ b/src/mesa/main/bufferobj.c @@ -2790,6 +2790,357 @@ bind_atomic_buffer(struct gl_context *ctx, set_atomic_buffer_binding(ctx, binding, bufObj, offset, size); } +static bool +error_check_bind_uniform_buffers(struct gl_context *ctx, + GLuint first, GLsizei count, + const char *caller) +{ + if (!ctx->Extensions.ARB_uniform_buffer_object) { + _mesa_error(ctx, GL_INVALID_ENUM, + "%s(target=GL_UNIFORM_BUFFER)", caller); + return false; + } + + /* The ARB_multi_bind_spec says: +* +* "An INVALID_OPERATION error is generated if + is +* greater than the number of target-specific indexed binding points, +* as described in section 6.7.1." +*/ + if (first + count > ctx->Const.MaxUniformBufferBindings) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "%s(first=%u + count=%u > the value of " count=%d + "GL_MAX_UNIFORM_BUFFER_BINDINGS=%u)", + caller, first, count, + ctx->Const.MaxUniformBufferBindings); + return false; + } + + return true; +} + +/** + * Unbind all uniform buffers in the range + * through +-1 + */ +static void +unbind_uniform_buffers(struct gl_context *ctx, GLuint first, GLsizei count) +{ + struct gl_buffer_object *bufObj = ctx->Shared->NullBufferObj; + int i; + + for (i = 0; i < count; i++) + set_ubo_binding(ctx, &ctx->UniformBufferBindings[first + i], + bufObj, -1, -1, GL_TRUE); +} + +static void +bind_uniform_buffers_base(struct gl_context *ctx, GLuint first, GLsizei count, + const GLuint *buffers) +{ + GLuint i; + + if (!error_check_bind_uniform_buffers(ctx, first, count, "glBindBuffersBase")) + return; + + /* Assume that at least one binding will be changed */ + FLUSH_VERTICES(ctx, 0); + ctx->NewDriverState |= ctx->DriverFlags.NewUniformBuffer; + + if (!buffers) { + /* The ARB_multi_bind spec says: + * + * "If is NULL, all bindings from through + *+-1 are reset to their unbound (zero) state." + */ + unbind_uniform_buffers(ctx, first, count); + return; + } + + /* Note that the error semantics for multi-bind commands differ from +* those of other GL commands. +* +* The Issues section in the ARB_multi_bind spec says: +* +*"(11) Typically, OpenGL specifies that if an error is generated by a +* command, that command has no effect. This is somewhat +* unfortunate for multi-bind commands, because it would require a +* first pass to scan the entire list of bound objects for errors +* and then a second pass to actually perform the bindings. +* Should we have different error semantics? +* +* RESOLVED: Yes. In this specification, when the parameters for +* one of the binding points are invalid, that binding point +* is not updated and an error will be generated. However, other +* binding points in the same command will be updated if their +* parameters are valid and no other error occurs." +*/ + + _mesa_begin_bufferobj_lookups(ctx); + + for (i = 0; i < count; i++) { + struct gl_uniform_buffer_binding *binding = + &ctx->UniformBufferBindings[first + i]; + struct gl_buffer_object *bufObj; + + if (binding->BufferObject && binding->BufferObject->Name == buffers[i]) + bufObj = binding->BufferObject; + else + bufObj = _mesa_multi_bind_lookup_bufferobj(ctx, GL_UNIFORM_BUFFER, +buffers, i, +"glBindBuffersBase"); + + if (bufObj) { + if (bufObj == ctx->Shared->NullBufferObj) +set_ubo_binding(ctx, binding, bufObj, -1, -1, GL_TRUE); + else +set_ubo_binding(ctx, binding, bufObj, 0, 0, GL_TRUE); + } + } + + _mesa_end_bufferobj_lookups(ctx); +} + +static bool +error_check_bind_xfb_buffers(struct gl_context *ctx, + struct gl_transform_feedback_object *tfObj, + GLuint first, GLsizei count, const char *caller) +{ + if (!ctx->Extensions.EXT_transform_feedback) { + _mesa_error(ctx, GL_INVALID_ENUM, + "%s(target=GL_TRANSFORM_FEEDBACK_BUFFER", caller); + return false; + } + + /* Page 398 of the PDF of the OpenGL 4.4 (Core Profile) spec says: +* +* "An INVALID_OPERATION error is generated : +* +* ... +* • by BindBufferR
Re: [Mesa-dev] [PATCH 00/19] Implement GL_ARB_multi_bind v2
On 04/21/2014 03:57 PM, Fredrik Höglund wrote: So here is version two of the ARB_multi_bind series. This incorporates feedback from Brian, Matt and Francisco, and also fixes an issue I happened to notice myself. It occurred to me that the BindTexture driver hook doesn't have a parameter for the texture index, and that drivers might want to know which texture was changed. It turns out that the only driver that implements the hook is nouveau, and the index is the only thing it cares about. So there is now a new patch that adds an index parameter and adjusts the driver accordingly. I have also updated my branch at: git://people.freedesktop.org/~fredrik/mesa arb-multi-bind The series looks good to me. Just some minor nit-picks. When we print a GLsizei we need to use %d, not %u, since GLsizei is a signed type. I think I saw about 10 instances of that. For the series: Reviewed-by: Brian Paul BTW, do we have piglit tests for this extension? Note that the BindBuffers patches have still not been reviewed. That's a different patch series? I don't remember it. -Brian ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] st/omx/enc: replace omx buffer with texture buffer
Am 17.04.2014 18:19, schrieb Leo Liu: From: Leo Liu Signed-off-by: Leo Liu Reviewed & pushed. Thanks, Christian. --- src/gallium/state_trackers/omx/vid_enc.c | 214 ++- 1 file changed, 185 insertions(+), 29 deletions(-) diff --git a/src/gallium/state_trackers/omx/vid_enc.c b/src/gallium/state_trackers/omx/vid_enc.c index 88d15a9..8a95999 100644 --- a/src/gallium/state_trackers/omx/vid_enc.c +++ b/src/gallium/state_trackers/omx/vid_enc.c @@ -50,6 +50,7 @@ #include "pipe/p_video_codec.h" #include "state_tracker/drm_driver.h" #include "util/u_memory.h" +#include "vl/vl_video_buffer.h" #include "entrypoint.h" #include "vid_enc.h" @@ -64,6 +65,9 @@ struct encode_task { struct input_buf_private { struct list_head tasks; + + struct pipe_resource *resource; + struct pipe_transfer *transfer; }; struct output_buf_private { @@ -78,6 +82,10 @@ static OMX_ERRORTYPE vid_enc_GetParameter(OMX_HANDLETYPE handle, OMX_INDEXTYPE i static OMX_ERRORTYPE vid_enc_SetConfig(OMX_HANDLETYPE handle, OMX_INDEXTYPE idx, OMX_PTR config); static OMX_ERRORTYPE vid_enc_GetConfig(OMX_HANDLETYPE handle, OMX_INDEXTYPE idx, OMX_PTR config); static OMX_ERRORTYPE vid_enc_MessageHandler(OMX_COMPONENTTYPE *comp, internalRequestMessageType *msg); +static OMX_ERRORTYPE vid_enc_AllocateInBuffer(omx_base_PortType *port, OMX_INOUT OMX_BUFFERHEADERTYPE **buf, + OMX_IN OMX_U32 idx, OMX_IN OMX_PTR private, OMX_IN OMX_U32 size); +static OMX_ERRORTYPE vid_enc_UseInBuffer(omx_base_PortType *port, OMX_BUFFERHEADERTYPE **buf, OMX_U32 idx, + OMX_PTR private, OMX_U32 size, OMX_U8 *mem); static OMX_ERRORTYPE vid_enc_FreeInBuffer(omx_base_PortType *port, OMX_U32 idx, OMX_BUFFERHEADERTYPE *buf); static OMX_ERRORTYPE vid_enc_EncodeFrame(omx_base_PortType *port, OMX_BUFFERHEADERTYPE *buf); static OMX_ERRORTYPE vid_enc_AllocateOutBuffer(omx_base_PortType *comp, OMX_INOUT OMX_BUFFERHEADERTYPE **buf, @@ -226,6 +234,8 @@ static OMX_ERRORTYPE vid_enc_Constructor(OMX_COMPONENTTYPE *comp, OMX_STRING nam port->sPortParam.nBufferCountMin = 4; port->Port_SendBufferFunction = vid_enc_EncodeFrame; + port->Port_AllocateBuffer = vid_enc_AllocateInBuffer; + port->Port_UseBuffer = vid_enc_UseInBuffer; port->Port_FreeBuffer = vid_enc_FreeInBuffer; port = (omx_base_video_PortType *)priv->ports[OMX_BASE_FILTER_OUTPUTPORT_INDEX]; @@ -293,6 +303,42 @@ static OMX_ERRORTYPE vid_enc_Destructor(OMX_COMPONENTTYPE *comp) return omx_workaround_Destructor(comp); } +static OMX_ERRORTYPE enc_AllocateBackTexture(omx_base_PortType *port, + struct pipe_resource **resource, + struct pipe_transfer **transfer, + OMX_U8 **map) +{ + OMX_COMPONENTTYPE* comp = port->standCompContainer; + vid_enc_PrivateType *priv = comp->pComponentPrivate; + struct pipe_resource buf_templ; + struct pipe_box box = {}; + OMX_U8 *ptr; + + memset(&buf_templ, 0, sizeof buf_templ); + buf_templ.target = PIPE_TEXTURE_2D; + buf_templ.format = PIPE_FORMAT_I8_UNORM; + buf_templ.bind = PIPE_BIND_LINEAR; + buf_templ.usage = PIPE_USAGE_STAGING; + buf_templ.flags = 0; + buf_templ.width0 = port->sPortParam.format.video.nFrameWidth; + buf_templ.height0 = port->sPortParam.format.video.nFrameHeight * 3 / 2; + buf_templ.depth0 = 1; + buf_templ.array_size = 1; + + *resource = priv->s_pipe->screen->resource_create(priv->s_pipe->screen, &buf_templ); + if (!*resource) + return OMX_ErrorInsufficientResources; + + box.width = (*resource)->width0; + box.height = (*resource)->height0; + box.depth = (*resource)->depth0; + ptr = priv->s_pipe->transfer_map(priv->s_pipe, *resource, 0, PIPE_TRANSFER_WRITE, &box, transfer); + if (map) + *map = ptr; + + return OMX_ErrorNone; +} + static OMX_ERRORTYPE vid_enc_SetParameter(OMX_HANDLETYPE handle, OMX_INDEXTYPE idx, OMX_PTR param) { OMX_COMPONENTTYPE *comp = handle; @@ -313,12 +359,20 @@ static OMX_ERRORTYPE vid_enc_SetParameter(OMX_HANDLETYPE handle, OMX_INDEXTYPE i if (def->nPortIndex == OMX_BASE_FILTER_INPUTPORT_INDEX) { omx_base_video_PortType *port; unsigned framesize; + struct pipe_resource *resource; + struct pipe_transfer *transfer; port = (omx_base_video_PortType *)priv->ports[OMX_BASE_FILTER_INPUTPORT_INDEX]; - framesize = port->sPortParam.format.video.nFrameWidth* + enc_AllocateBackTexture(priv->ports[OMX_BASE_FILTER_INPUTPORT_INDEX], + &resource, &transfer, NULL); + port->sPortParam.format.video.nStride = transfer->stride; + pipe_transfer_unmap(priv->s_pipe, transfer); + pipe_resource_reference(&resource, NULL); + + framesize = port->sPor
Re: [Mesa-dev] Regressions due to commit 1afe3359258
On 04/19/2014 11:44 AM, Jordan Justen wrote: > On Sat, Apr 19, 2014 at 10:03 AM, Ilia Mirkin wrote: >> On Fri, Apr 18, 2014 at 1:35 PM, Jordan Justen >> wrote: >>> On 2014-04-18 08:46:00, Kenneth Graunke wrote: On 04/18/2014 12:09 AM, Ilia Mirkin wrote: > Hi Ken, > > I just did a bisect looking for the failure that's causing a few > gs-related piglits to fail on nv50, and it came up with the below. Any > ideas? Here are the tests that are failing: > > tests/spec/glsl-1.50/execution/geometry/clip-distance-out-values.shader_test > tests/spec/glsl-1.50/execution/geometry/max-input-components.shader_test > tests/spec/glsl-1.50/execution/geometry/point-size-out.shader_test > tests/spec/glsl-1.50/execution/geometry/primitive-id-out.shader_test > tests/spec/glsl-1.50/execution/gs-redeclares-both-pervertex-blocks.shader_test > tests/spec/glsl-1.50/execution/interface-vs-named-to-gs-array.shader_test > tests/spec/glsl-1.50/execution/redeclare-pervertex-out-subset-gs.shader_test > tests/spec/glsl-1.50/execution/redeclare-pervertex-subset-vs-to-gs.shader_test > > 1afe3359258a9e89b62c8638761f52d78f6d1cbc is the first bad commit > commit 1afe3359258a9e89b62c8638761f52d78f6d1cbc > Author: Kenneth Graunke > Date: Thu Mar 20 11:53:16 2014 -0700 > > mesa: In core profile, refuse to draw unless a VAO is bound. > > Core profile requires a non-default VAO to be bound. Currently, calls > to glVertexAttribPointer raise INVALID_OPERATION unless a VAO is > bound, > and we never actually get any vertex data set. Trying to draw without > any vertex data can only cause problems. In i965, it causes a crash. > > Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=76400 > Signed-off-by: Kenneth Graunke > Reviewed-by: Ian Romanick > Cc: mesa-sta...@lists.freedesktop.org > > Reverting this commit on top of master makes it work again. I have no > idea whether it's the tests/piglit infra that are wrong, or if it's > the commit that's wrong, but wanted to raise the issue. This still > happens with the (almost-)latest piglit (latest doesn't compile due to > EGL stuff...) > > Let me know if you'd like any additional info. > > Thanks, > > -ilia Yeah, we're seeing those too. I believe the commit is wrong: with geometry shaders, you can just generate vertices using a GS program and not actually ever upload any vertex data. At which point, you probably don't need a VAO. I haven't double checked the rules, though. >>> >>> I'm not sure spec-wise, but I found that nvidia requires a VAO, even >>> without vertex data. (See piglit b28cdc88, but note that this commit >>> caused some other issues and was reverted in c20596b8). >> >> So this is what the spec says (GL4.4, page 322/323): >> >> An INVALID_OPERATION error is generated by any commands which >> modify, draw from, or query vertex array state when no vertex array is bound. >> This occurs in the initial GL state, and may occur as a result of >> BindVertexArray >> or a side effect of DeleteVertexArrays. >> >> And this is what one of the piglits in question does: >> >> [test] >> clear color 0.0 0.0 0.0 0.0 >> clear >> draw arrays GL_TRIANGLES 0 3 >> probe all rgba 0.0 1.0 0.0 1.0 >> >> and this is what shader_runner does: >> >> if (link_ok && vertex_data_start != NULL) { >> program_must_be_in_use(); >> if (gl_version.num >= 31) { >> GLuint vao; >> >> glGenVertexArrays(1, &vao); >> glBindVertexArray(vao); >> } >> >> num_vbo_rows = setup_vbo_from_text(prog, vertex_data_start, >> vertex_data_end); >> vbo_present = true; >> } >> >> So what's the right move here? I think it might actually be to >> change shader_runner to always generate a VAO even if there is no >> vertex data. The thing that isn't clear to me from the previous discussion... on up-to-date NVIDIA drivers, do these tests pass or fail? AMD? If the tests run, unmodified, on other vendors and we think the spec is overly restrictive, we (I) should file a spec bug. If the test fails (due to GL_INVALID_OPERATION being generated), we should fix shader_runner. > Right, and that is what I did in piglit b28cdc88, but: > http://lists.freedesktop.org/archives/piglit/2014-April/010179.html > caused me to revert it (c20596b8). That bug sounds like shader_runner was using a VAO without a VBO. Presumably the use of piglit_draw_rect* is to blame. > Brian pointed out tests/shaders/glsl-fs-any.shader_test as an example > that failed on nvidia with b28cdc88. > > Yet, b28cdc88 fixes > tests/spec/glsl-1.50/execution/geometry/point-size-out.shader_test on > nvidia, so hopefully there is a way to make nvidia happy on both > tests. :) > > -Jordan > ___ > mesa-dev mailing list > mesa-dev@lists.freedesktop.org > http://lists.fre
[Mesa-dev] [Bug 77749] PRAGMA_EXPORT_SUPPORTED defined incorrectly on OS X
https://bugs.freedesktop.org/show_bug.cgi?id=77749 --- Comment #3 from tha...@chromium.org --- Created attachment 97758 --> https://bugs.freedesktop.org/attachment.cgi?id=97758&action=edit patch Here's how a patch to remove this might look. I removed "pragma import" too -- while this doesn't cause warnings, it looks like this was used only on very old versions on OS X. -- You are receiving this mail because: You are the assignee for the bug. ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH] radeonsi: Don't use anonymous struct trick in atom tracking
I'm somewhat impressed that current gccs will let you do this, but sufficiently old ones (including 4.4.7 in RHEL6) won't. Signed-off-by: Adam Jackson --- src/gallium/drivers/radeonsi/si_descriptors.c | 6 +++--- src/gallium/drivers/radeonsi/si_hw_context.c | 2 +- src/gallium/drivers/radeonsi/si_pipe.c| 6 +++--- src/gallium/drivers/radeonsi/si_pipe.h| 2 +- src/gallium/drivers/radeonsi/si_state.c | 2 +- src/gallium/drivers/radeonsi/si_state_draw.c | 2 +- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/gallium/drivers/radeonsi/si_descriptors.c b/src/gallium/drivers/radeonsi/si_descriptors.c index 0c58d5f..e0b211f 100644 --- a/src/gallium/drivers/radeonsi/si_descriptors.c +++ b/src/gallium/drivers/radeonsi/si_descriptors.c @@ -987,9 +987,9 @@ void si_init_all_descriptors(struct si_context *sctx) si_init_sampler_views(sctx, &sctx->samplers[i].views, i); - sctx->atoms.const_buffers[i] = &sctx->const_buffers[i].desc.atom; - sctx->atoms.rw_buffers[i] = &sctx->rw_buffers[i].desc.atom; - sctx->atoms.sampler_views[i] = &sctx->samplers[i].views.desc.atom; + sctx->atoms.s.const_buffers[i] = &sctx->const_buffers[i].desc.atom; + sctx->atoms.s.rw_buffers[i] = &sctx->rw_buffers[i].desc.atom; + sctx->atoms.s.sampler_views[i] = &sctx->samplers[i].views.desc.atom; } diff --git a/src/gallium/drivers/radeonsi/si_hw_context.c b/src/gallium/drivers/radeonsi/si_hw_context.c index 383157b..d2a1dbe 100644 --- a/src/gallium/drivers/radeonsi/si_hw_context.c +++ b/src/gallium/drivers/radeonsi/si_hw_context.c @@ -63,7 +63,7 @@ void si_need_cs_space(struct si_context *ctx, unsigned num_dw, } /* Count in framebuffer cache flushes at the end of CS. */ - num_dw += ctx->atoms.cache_flush->num_dw; + num_dw += ctx->atoms.s.cache_flush->num_dw; #if SI_TRACE_CS if (ctx->screen->b.trace_bo) { diff --git a/src/gallium/drivers/radeonsi/si_pipe.c b/src/gallium/drivers/radeonsi/si_pipe.c index a1aea7b..2627571 100644 --- a/src/gallium/drivers/radeonsi/si_pipe.c +++ b/src/gallium/drivers/radeonsi/si_pipe.c @@ -105,10 +105,10 @@ static struct pipe_context *si_create_context(struct pipe_screen *screen, void * /* Initialize cache_flush. */ sctx->cache_flush = si_atom_cache_flush; - sctx->atoms.cache_flush = &sctx->cache_flush; + sctx->atoms.s.cache_flush = &sctx->cache_flush; - sctx->atoms.streamout_begin = &sctx->b.streamout.begin_atom; - sctx->atoms.streamout_enable = &sctx->b.streamout.enable_atom; + sctx->atoms.s.streamout_begin = &sctx->b.streamout.begin_atom; + sctx->atoms.s.streamout_enable = &sctx->b.streamout.enable_atom; switch (sctx->b.chip_class) { case SI: diff --git a/src/gallium/drivers/radeonsi/si_pipe.h b/src/gallium/drivers/radeonsi/si_pipe.h index a74bbcf..1601a4b 100644 --- a/src/gallium/drivers/radeonsi/si_pipe.h +++ b/src/gallium/drivers/radeonsi/si_pipe.h @@ -110,7 +110,7 @@ struct si_context { struct r600_atom *streamout_begin; struct r600_atom *streamout_enable; /* must be after streamout_begin */ struct r600_atom *framebuffer; - }; + } s; struct r600_atom *array[0]; } atoms; diff --git a/src/gallium/drivers/radeonsi/si_state.c b/src/gallium/drivers/radeonsi/si_state.c index 921264e..734054f 100644 --- a/src/gallium/drivers/radeonsi/si_state.c +++ b/src/gallium/drivers/radeonsi/si_state.c @@ -2954,7 +2954,7 @@ void si_init_state_functions(struct si_context *sctx) { int i; - si_init_atom(&sctx->framebuffer.atom, &sctx->atoms.framebuffer, si_emit_framebuffer_state, 0); + si_init_atom(&sctx->framebuffer.atom, &sctx->atoms.s.framebuffer, si_emit_framebuffer_state, 0); sctx->b.b.create_blend_state = si_create_blend_state; sctx->b.b.bind_blend_state = si_bind_blend_state; diff --git a/src/gallium/drivers/radeonsi/si_state_draw.c b/src/gallium/drivers/radeonsi/si_state_draw.c index 0676b15..c7c94fc 100644 --- a/src/gallium/drivers/radeonsi/si_state_draw.c +++ b/src/gallium/drivers/radeonsi/si_state_draw.c @@ -964,7 +964,7 @@ void si_draw_vbo(struct pipe_context *ctx, const struct pipe_draw_info *info) /* Check flush flags. */ if (sctx->b.flags) - sctx->atoms.cache_flush->dirty = true; + sctx->atoms.s.cache_flush->dirty = true; si_need_cs_space(sctx, 0, TRUE); -- 1.8.5.3 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [Piglit] Regressions due to commit 1afe3359258
On Apr 22, 2014 10:56 AM, "Ian Romanick" wrote: > > The thing that isn't clear to me from the previous discussion... on > up-to-date NVIDIA drivers, do these tests pass or fail? AMD? If the > tests run, unmodified, on other vendors and we think the spec is overly > restrictive, we (I) should file a spec bug. If the test fails (due to > GL_INVALID_OPERATION being generated), we should fix shader_runner. > The unmodified amd and nvidia drivers display a extreme ression ( on commit id b28cdc887aefb1e766719e1f74d457f77bdf9a18 ) where 3000+ tests go from pass/fail to crash. This is fixed by the revert in question ( commit id c20596b85f666de470648decbac20b7643a50570 ). ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [Bug 77502] libOpenVG contains no vg Symbols
https://bugs.freedesktop.org/show_bug.cgi?id=77502 --- Comment #4 from dagg --- the commit that introduced this regression is 75143ef05576ee9f25ee176bc28c3c4d03705bf5 I've got hit by this bug too, cannot update at least 3 pkgs on my system (using Gentoo). what is worst is that include/VG/openvg.h exposes the vg* api while the code uses the vega* api. frankly I'm not sure how this commit was approved, it broke backwards comparability and is partial. -- You are receiving this mail because: You are the assignee for the bug. ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [Bug 77502] libOpenVG contains no vg Symbols
https://bugs.freedesktop.org/show_bug.cgi?id=77502 dagg changed: What|Removed |Added CC||stompdagg...@yahoo.com -- You are receiving this mail because: You are the assignee for the bug. ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [Bug 77502] libOpenVG contains no vg Symbols
https://bugs.freedesktop.org/show_bug.cgi?id=77502 --- Comment #5 from dagg --- (In reply to comment #4) > the commit that introduced this regression is > 75143ef05576ee9f25ee176bc28c3c4d03705bf5 > > I've got hit by this bug too, cannot update at least 3 pkgs on my system > (using Gentoo). > > what is worst is that include/VG/openvg.h exposes the vg* api while the code > uses the vega* api. > > frankly I'm not sure how this commit was approved, it broke backwards > comparability and is partial. s/comparability/compatibility/g -- You are receiving this mail because: You are the assignee for the bug. ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [Bug 77502] libOpenVG contains no vg Symbols
https://bugs.freedesktop.org/show_bug.cgi?id=77502 --- Comment #6 from Matt Turner --- Did you try the next commit (34f15903d6f5807b34a4c9be6d8daaedbbdd64bc)? It fixed a mistake in the patch this was bisected to. -- You are receiving this mail because: You are the assignee for the bug. ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] Broadcom VideoCore IV
On Tue, Apr 22, 2014 at 8:55 AM, Mohamed MEDIOUNI wrote: > > Is there any documentation for Gallium3D ? indeed there is.. it is in git under src/gallium/docs and in generated html form, conveniently kept up to date: http://gallium.readthedocs.org BR, -R ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] Regressions due to commit 1afe3359258
On Tue, Apr 22, 2014 at 8:54 AM, Ian Romanick wrote: > On 04/19/2014 11:44 AM, Jordan Justen wrote: >> On Sat, Apr 19, 2014 at 10:03 AM, Ilia Mirkin wrote: >>> On Fri, Apr 18, 2014 at 1:35 PM, Jordan Justen >>> wrote: On 2014-04-18 08:46:00, Kenneth Graunke wrote: > On 04/18/2014 12:09 AM, Ilia Mirkin wrote: >> Hi Ken, >> >> I just did a bisect looking for the failure that's causing a few >> gs-related piglits to fail on nv50, and it came up with the below. Any >> ideas? Here are the tests that are failing: >> >> tests/spec/glsl-1.50/execution/geometry/clip-distance-out-values.shader_test >> tests/spec/glsl-1.50/execution/geometry/max-input-components.shader_test >> tests/spec/glsl-1.50/execution/geometry/point-size-out.shader_test >> tests/spec/glsl-1.50/execution/geometry/primitive-id-out.shader_test >> tests/spec/glsl-1.50/execution/gs-redeclares-both-pervertex-blocks.shader_test >> tests/spec/glsl-1.50/execution/interface-vs-named-to-gs-array.shader_test >> tests/spec/glsl-1.50/execution/redeclare-pervertex-out-subset-gs.shader_test >> tests/spec/glsl-1.50/execution/redeclare-pervertex-subset-vs-to-gs.shader_test >> >> 1afe3359258a9e89b62c8638761f52d78f6d1cbc is the first bad commit >> commit 1afe3359258a9e89b62c8638761f52d78f6d1cbc >> Author: Kenneth Graunke >> Date: Thu Mar 20 11:53:16 2014 -0700 >> >> mesa: In core profile, refuse to draw unless a VAO is bound. >> >> Core profile requires a non-default VAO to be bound. Currently, >> calls >> to glVertexAttribPointer raise INVALID_OPERATION unless a VAO is >> bound, >> and we never actually get any vertex data set. Trying to draw >> without >> any vertex data can only cause problems. In i965, it causes a crash. >> >> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=76400 >> Signed-off-by: Kenneth Graunke >> Reviewed-by: Ian Romanick >> Cc: mesa-sta...@lists.freedesktop.org >> >> Reverting this commit on top of master makes it work again. I have no >> idea whether it's the tests/piglit infra that are wrong, or if it's >> the commit that's wrong, but wanted to raise the issue. This still >> happens with the (almost-)latest piglit (latest doesn't compile due to >> EGL stuff...) >> >> Let me know if you'd like any additional info. >> >> Thanks, >> >> -ilia > > Yeah, we're seeing those too. I believe the commit is wrong: with > geometry shaders, you can just generate vertices using a GS program and > not actually ever upload any vertex data. At which point, you probably > don't need a VAO. I haven't double checked the rules, though. I'm not sure spec-wise, but I found that nvidia requires a VAO, even without vertex data. (See piglit b28cdc88, but note that this commit caused some other issues and was reverted in c20596b8). >>> >>> So this is what the spec says (GL4.4, page 322/323): >>> >>> An INVALID_OPERATION error is generated by any commands which >>> modify, draw from, or query vertex array state when no vertex array is >>> bound. >>> This occurs in the initial GL state, and may occur as a result of >>> BindVertexArray >>> or a side effect of DeleteVertexArrays. >>> >>> And this is what one of the piglits in question does: >>> >>> [test] >>> clear color 0.0 0.0 0.0 0.0 >>> clear >>> draw arrays GL_TRIANGLES 0 3 >>> probe all rgba 0.0 1.0 0.0 1.0 >>> >>> and this is what shader_runner does: >>> >>> if (link_ok && vertex_data_start != NULL) { >>> program_must_be_in_use(); >>> if (gl_version.num >= 31) { >>> GLuint vao; >>> >>> glGenVertexArrays(1, &vao); >>> glBindVertexArray(vao); >>> } >>> >>> num_vbo_rows = setup_vbo_from_text(prog, vertex_data_start, >>> vertex_data_end); >>> vbo_present = true; >>> } >>> >>> So what's the right move here? I think it might actually be to >>> change shader_runner to always generate a VAO even if there is no >>> vertex data. > > The thing that isn't clear to me from the previous discussion... on > up-to-date NVIDIA drivers, do these tests pass or fail? AMD? If the > tests run, unmodified, on other vendors and we think the spec is overly > restrictive, we (I) should file a spec bug. If the test fails (due to > GL_INVALID_OPERATION being generated), we should fix shader_runner. > >> Right, and that is what I did in piglit b28cdc88, but: >> http://lists.freedesktop.org/archives/piglit/2014-April/010179.html >> caused me to revert it (c20596b8). > > That bug sounds like shader_runner was using a VAO without a VBO. > Presumably the use of piglit_draw_rect* is to blame. I don't think tests/spec/glsl-1.50/execution/geometry/point-size-out.shader_test will use draw_rect, right? There is no VBO with attributeless rendering, right? It's a draw-arrays call w/o a VBO, right? -Jordan >> Brian pointed out
[Mesa-dev] [Bug 77502] libOpenVG contains no vg Symbols
https://bugs.freedesktop.org/show_bug.cgi?id=77502 --- Comment #7 from farmboy0+freedesk...@googlemail.com --- Tried now. Still bad. -- You are receiving this mail because: You are the assignee for the bug. ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] egl: Add GetSyncValuesCHROMIUM extension.
On Sat, Apr 19, 2014 at 12:34:37PM -0700, Stéphane Marchesin wrote: > On Fri, Apr 18, 2014 at 3:37 PM, Sarah Sharp > wrote: > > > Chromium defined a new GL extension (that isn't registered with Khronos). > > > > This here is the problem IMO. I'll see next week what we can do about > pushing for this to become a registered extension. Intel would be our 2nd > implementation, so I think we have enough support at this point. Sure. How long does getting an extension registered take? Should I hold off on this patch until it lands, or should we just remove the EGL definition from eglmesaext.h once it gets imported into eglext.h? Sarah Sharp > > We need to add an EGL extension for it, so we can migrate ChromeOS on > > Intel systems to use EGL instead of GLX. > > > > > > http://git.chromium.org/gitweb/?p=chromium/src/third_party/khronos.git;a=commitdiff;h=27cbfdab35c601f70aa150581ad1448d0401f447 > > > > The extension is similar to the GLX extension OML_sync_control, but only > > defines one function, eglGetSyncValuesCHROMIUM, which is equivalent to > > glXGetSyncValuesOML. > > > > http://www.opengl.org/registry/specs/OML/glx_sync_control.txt > > > > One open question: > > > > I've used the normal (error checked) version of xcb_dri2_get_msc. The > > GLX implementation of glXGetSyncValuesOML uses the unchecked version, > > but I'm not convinced it's necessary. > > > > I talked to Jamey Sharp, and he doesn't understand why most of Mesa > > calls the unchecked versions of XCB functions. He thought most > > developers would want to use the normal (checked) versions, since the > > unchecked versions may segfault on errors. Mesa can always call the > > checked version, but ignore the error that's set, so it doesn't have to > > use the unchecked version. > > > > I talked to Kristen Høgsberg, who added most of the Mesa XCB calls, and > > he said he copied the style from Chris Wilson. If using the unchecked > > versions isn't required, we should look into moving the XCB calls in > > Mesa to the normal checked versions. Otherwise people will just keep > > copy-pasting the unchecked versions around. > > > > Signed-off-by: Sarah Sharp > > Cc: Chad Versace > > Cc: Kristian Høgsberg > > Cc: Jamey Sharp > > --- > > include/EGL/eglext.h | 10 ++ > > src/egl/drivers/dri2/egl_dri2.c | 15 +++ > > src/egl/drivers/dri2/egl_dri2.h | 4 > > src/egl/drivers/dri2/egl_dri2_fallbacks.h | 8 > > src/egl/drivers/dri2/platform_android.c | 1 + > > src/egl/drivers/dri2/platform_drm.c | 1 + > > src/egl/drivers/dri2/platform_wayland.c | 1 + > > src/egl/drivers/dri2/platform_x11.c | 27 +++ > > src/egl/main/eglapi.c | 27 +++ > > src/egl/main/eglapi.h | 7 +++ > > src/egl/main/egldisplay.h | 1 + > > src/egl/main/eglmisc.c| 1 + > > 12 files changed, 103 insertions(+) > > > > diff --git a/include/EGL/eglext.h b/include/EGL/eglext.h > > index 243da4a..097ad68 100644 > > --- a/include/EGL/eglext.h > > +++ b/include/EGL/eglext.h > > @@ -588,6 +588,16 @@ EGLAPI EGLBoolean EGLAPIENTRY eglPostSubBufferNV > > (EGLDisplay dpy, EGLSurface sur > > #endif > > #endif /* EGL_NV_post_sub_buffer */ > > > > +#if KHRONOS_SUPPORT_INT64 /* EGLSyncControlCHROMIUM requires 64-bit > > uint support */ > > +#ifndef EGL_CHROMIUM_sync_control > > +#define EGL_CHROMIUM_sync_control 1 > > +#ifdef EGL_EGLEXT_PROTOTYPES > > +EGLAPI EGLBoolean EGLAPIENTRY eglGetSyncValuesCHROMIUM(EGLDisplay dpy, > > EGLSurface surface, EGLuint64KHR *ust, EGLuint64KHR *msc, EGLuint64KHR > > *sbc); > > +#endif /* EGL_EGLEXT_PROTOTYPES */ > > +typedef EGLBoolean (EGLAPIENTRYP > > PFNEGLGETSYNCVALUESCHROMIUMPROC)(EGLDisplay dpy, EGLSurface surface, > > EGLuint64KHR *ust, EGLuint64KHR *msc, EGLuint64KHR *sbc); > > +#endif > > +#endif > > + > > #ifndef EGL_NV_stream_sync > > #define EGL_NV_stream_sync 1 > > #define EGL_SYNC_NEW_FRAME_NV 0x321F > > diff --git a/src/egl/drivers/dri2/egl_dri2.c > > b/src/egl/drivers/dri2/egl_dri2.c > > index dc541ad..df8d9af 100644 > > --- a/src/egl/drivers/dri2/egl_dri2.c > > +++ b/src/egl/drivers/dri2/egl_dri2.c > > @@ -1386,6 +1386,18 @@ dri2_create_image_wayland_wl_buffer(_EGLDisplay > > *disp, _EGLContext *ctx, > > } > > #endif > > > > +#ifdef EGL_CHROMIUM_sync_control > > +static EGLBoolean > > +dri2_get_sync_values_chromium(_EGLDisplay *dpy, _EGLSurface *surf, > > + EGLuint64KHR *ust, EGLuint64KHR *msc, > > + EGLuint64KHR *sbc) > > +{ > > + struct dri2_egl_display *dri2_dpy = dri2_egl_display(dpy); > > + return dri2_dpy->vtbl->get_sync_values(dpy, surf, ust, msc, sbc); > > +} > > +#endif > > + > > + > > /** > > * Set the error code after a call to > > * dri2_egl_image::dri_image::createImageFromTexture. > > @@ -2177,6 +2189,9 @@ _eglBui
Re: [Mesa-dev] [PATCH] egl: Add GetSyncValuesCHROMIUM extension.
On Tue, Apr 22, 2014 at 12:19 PM, Sarah Sharp wrote: > On Sat, Apr 19, 2014 at 12:34:37PM -0700, Stéphane Marchesin wrote: > > On Fri, Apr 18, 2014 at 3:37 PM, Sarah Sharp > > wrote: > > > > > Chromium defined a new GL extension (that isn't registered with > Khronos). > > > > > > > This here is the problem IMO. I'll see next week what we can do about > > pushing for this to become a registered extension. Intel would be our 2nd > > implementation, so I think we have enough support at this point. > > Sure. How long does getting an extension registered take? Should I > hold off on this patch until it lands, No, don't hold off anything, it can take a bit. Stéphane > or should we just remove the EGL > definition from eglmesaext.h once it gets imported into eglext.h? > > Sarah Sharp > > > > We need to add an EGL extension for it, so we can migrate ChromeOS on > > > Intel systems to use EGL instead of GLX. > > > > > > > > > > http://git.chromium.org/gitweb/?p=chromium/src/third_party/khronos.git;a=commitdiff;h=27cbfdab35c601f70aa150581ad1448d0401f447 > > > > > > The extension is similar to the GLX extension OML_sync_control, but > only > > > defines one function, eglGetSyncValuesCHROMIUM, which is equivalent to > > > glXGetSyncValuesOML. > > > > > > http://www.opengl.org/registry/specs/OML/glx_sync_control.txt > > > > > > One open question: > > > > > > I've used the normal (error checked) version of xcb_dri2_get_msc. The > > > GLX implementation of glXGetSyncValuesOML uses the unchecked version, > > > but I'm not convinced it's necessary. > > > > > > I talked to Jamey Sharp, and he doesn't understand why most of Mesa > > > calls the unchecked versions of XCB functions. He thought most > > > developers would want to use the normal (checked) versions, since the > > > unchecked versions may segfault on errors. Mesa can always call the > > > checked version, but ignore the error that's set, so it doesn't have to > > > use the unchecked version. > > > > > > I talked to Kristen Høgsberg, who added most of the Mesa XCB calls, and > > > he said he copied the style from Chris Wilson. If using the unchecked > > > versions isn't required, we should look into moving the XCB calls in > > > Mesa to the normal checked versions. Otherwise people will just keep > > > copy-pasting the unchecked versions around. > > > > > > Signed-off-by: Sarah Sharp > > > Cc: Chad Versace > > > Cc: Kristian Høgsberg > > > Cc: Jamey Sharp > > > --- > > > include/EGL/eglext.h | 10 ++ > > > src/egl/drivers/dri2/egl_dri2.c | 15 +++ > > > src/egl/drivers/dri2/egl_dri2.h | 4 > > > src/egl/drivers/dri2/egl_dri2_fallbacks.h | 8 > > > src/egl/drivers/dri2/platform_android.c | 1 + > > > src/egl/drivers/dri2/platform_drm.c | 1 + > > > src/egl/drivers/dri2/platform_wayland.c | 1 + > > > src/egl/drivers/dri2/platform_x11.c | 27 > +++ > > > src/egl/main/eglapi.c | 27 > +++ > > > src/egl/main/eglapi.h | 7 +++ > > > src/egl/main/egldisplay.h | 1 + > > > src/egl/main/eglmisc.c| 1 + > > > 12 files changed, 103 insertions(+) > > > > > > diff --git a/include/EGL/eglext.h b/include/EGL/eglext.h > > > index 243da4a..097ad68 100644 > > > --- a/include/EGL/eglext.h > > > +++ b/include/EGL/eglext.h > > > @@ -588,6 +588,16 @@ EGLAPI EGLBoolean EGLAPIENTRY eglPostSubBufferNV > > > (EGLDisplay dpy, EGLSurface sur > > > #endif > > > #endif /* EGL_NV_post_sub_buffer */ > > > > > > +#if KHRONOS_SUPPORT_INT64 /* EGLSyncControlCHROMIUM requires 64-bit > > > uint support */ > > > +#ifndef EGL_CHROMIUM_sync_control > > > +#define EGL_CHROMIUM_sync_control 1 > > > +#ifdef EGL_EGLEXT_PROTOTYPES > > > +EGLAPI EGLBoolean EGLAPIENTRY eglGetSyncValuesCHROMIUM(EGLDisplay dpy, > > > EGLSurface surface, EGLuint64KHR *ust, EGLuint64KHR *msc, EGLuint64KHR > > > *sbc); > > > +#endif /* EGL_EGLEXT_PROTOTYPES */ > > > +typedef EGLBoolean (EGLAPIENTRYP > > > PFNEGLGETSYNCVALUESCHROMIUMPROC)(EGLDisplay dpy, EGLSurface surface, > > > EGLuint64KHR *ust, EGLuint64KHR *msc, EGLuint64KHR *sbc); > > > +#endif > > > +#endif > > > + > > > #ifndef EGL_NV_stream_sync > > > #define EGL_NV_stream_sync 1 > > > #define EGL_SYNC_NEW_FRAME_NV 0x321F > > > diff --git a/src/egl/drivers/dri2/egl_dri2.c > > > b/src/egl/drivers/dri2/egl_dri2.c > > > index dc541ad..df8d9af 100644 > > > --- a/src/egl/drivers/dri2/egl_dri2.c > > > +++ b/src/egl/drivers/dri2/egl_dri2.c > > > @@ -1386,6 +1386,18 @@ dri2_create_image_wayland_wl_buffer(_EGLDisplay > > > *disp, _EGLContext *ctx, > > > } > > > #endif > > > > > > +#ifdef EGL_CHROMIUM_sync_control > > > +static EGLBoolean > > > +dri2_get_sync_values_chromium(_EGLDisplay *dpy, _EGLSurface *surf, > > > + EGLuint64KHR *ust, EGLuint64KHR *msc, > > > +
[Mesa-dev] [Bug 77502] libOpenVG contains no vg Symbols
https://bugs.freedesktop.org/show_bug.cgi?id=77502 --- Comment #8 from Emil Velikov --- Dagg, The issue introduced by 75143ef05576ee9f25ee176bc28c3c4d03705bf5 is different from this one. Please try to keep one bugeport per issue - open a new ticket and add the commit author to the Cc list. Matt, I'm guessing that you will be able to easily reproduce, at least I did without even trying (don't think I'll have time to look into it any time soon). Just an idea: considering the way the whole dispatch is build (almost every time 2 different libraries are built), we might be off moving the headers to noinst_HEADERS. That will keep automake/make dist happy. -- You are receiving this mail because: You are the assignee for the bug. ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] New, web-based, live view of stable-branch queue
I'm now publishing a web page that categorizes the patches that have been nominated for the stable branch. Check it out: http://cworth.org/~cworth/mesa-stable-queue/ (I've also added a link to this page from the mesa-stable mailing list description page so that you can find this in the future.) The contents of this page should be updated automatically each day based on the state of my email. This is where I've always maintained the stable-branch queue, but now anyone can actually inspect it. I'm hoping that this extra transparency helps motivate me to not fall behind the queue as badly as I did with 10.1.1. Additionally, this can be a useful place for people to look for patches that could really use some review (it's a nice, small list compared to the overwhelming load in patchwork). Finally, this page also has the advantage that it shows when I've "accepted" a patch by merging it into my local stable branch, but before I've actually pushed to the upstream stable branch. (There's a delay between acceptance and push because I batch up several days of patches, then do a round of testing before pushing). I'd be happy to hear any feedback on the page. As we get close to deadlines for stable releases, I'll likely send out a pointer to this page again requesting review for any apparently neglected patches in the "Nominated, awaiting review" state. Thanks to everyone for all their hard work making mesa such a high-quality library. -Carl -- carl.d.wo...@intel.com pgpRYuvJx1Tgf.pgp Description: PGP signature ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] 3 element vectors in opencl 1.1+
On Mon, Apr 21, 2014 at 10:02:27PM -0400, Jan Vesely wrote: > Hi, > > I ran into a problem caused by this part of the OCL specs (6.1.5 > Alignment of Types): > "For 3-component vector data types, the size of the data type is 4 * > sizeof(component)." > > and the corresponding part of Khronos cl_platform.h (with all types, not > just float): > /* cl_float3 is identical in size, alignment and behavior to cl_float4. > See section 6.1.5. */ > typedef cl_float4 cl_float3; > > So when I try to run kernel that takes 3 element vectors as arguments I > get 'invalid arg size' error. > > Not sure whether this is best solved in clang, libclc or clover. I tried > changing float3 to have 4 elements in libclc, it caused clang to > complain in thousand places. I don't think this can be handled cleanly > in clang, unless we add something like __attribute__((padding)). > > I have attached a workaround that I use now. > You may want to ask this question on the pocl mailing list as they have likely solved this issue already. Ideally, TD.getTypeStoreSize would return the correct value. Also, maybe look at the DataLayout description for R600 and see if there is a way to specify the correct type size. -Tom > any advice welcome, > Jan > > -- > Jan Vesely > diff --git a/src/gallium/state_trackers/clover/llvm/invocation.cpp > b/src/gallium/state_trackers/clover/llvm/invocation.cpp > index a81bdf8..71ee01f 100644 > --- a/src/gallium/state_trackers/clover/llvm/invocation.cpp > +++ b/src/gallium/state_trackers/clover/llvm/invocation.cpp > @@ -62,6 +62,8 @@ > #include > #endif > > +#include > + > #include "pipe/p_state.h" > #include "util/u_memory.h" > > @@ -309,6 +311,13 @@ namespace { > > llvm::Type *arg_type = arg.getType(); > unsigned arg_size = TD.getTypeStoreSize(arg_type); > +if (arg_type->isVectorTy() && > + ::llvm::cast<::llvm::VectorType>(arg_type)->getNumElements() > == 3) { > + ::llvm::dbgs() << "Fixing argument type: " << *arg_type > + << " size: " << arg_size << "->" > + << (arg_size / 3) * 4 << "\n"; > + arg_size = (arg_size / 3) * 4; > +} > > llvm::Type *target_type = arg_type->isIntegerTy() ? > TD.getSmallestLegalIntType(mod->getContext(), arg_size * 8) : > ___ > mesa-dev mailing list > mesa-dev@lists.freedesktop.org > http://lists.freedesktop.org/mailman/listinfo/mesa-dev ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [cfe-dev] 3 element vectors in opencl 1.1+
On 04/22/2014 02:35 PM, Tom Stellard wrote: On Mon, Apr 21, 2014 at 10:02:27PM -0400, Jan Vesely wrote: Hi, I ran into a problem caused by this part of the OCL specs (6.1.5 Alignment of Types): "For 3-component vector data types, the size of the data type is 4 * sizeof(component)." and the corresponding part of Khronos cl_platform.h (with all types, not just float): /* cl_float3 is identical in size, alignment and behavior to cl_float4. See section 6.1.5. */ typedef cl_float4 cl_float3; So when I try to run kernel that takes 3 element vectors as arguments I get 'invalid arg size' error. Not sure whether this is best solved in clang, libclc or clover. I tried changing float3 to have 4 elements in libclc, it caused clang to complain in thousand places. I don't think this can be handled cleanly in clang, unless we add something like __attribute__((padding)). I have attached a workaround that I use now. You may want to ask this question on the pocl mailing list as they have likely solved this issue already. Ideally, TD.getTypeStoreSize would return the correct value. Also, maybe look at the DataLayout description for R600 and see if there is a way to specify the correct type size. -Tom I think this is what v96:128 is for any advice welcome, Jan -- Jan Vesely diff --git a/src/gallium/state_trackers/clover/llvm/invocation.cpp b/src/gallium/state_trackers/clover/llvm/invocation.cpp index a81bdf8..71ee01f 100644 --- a/src/gallium/state_trackers/clover/llvm/invocation.cpp +++ b/src/gallium/state_trackers/clover/llvm/invocation.cpp @@ -62,6 +62,8 @@ #include #endif +#include + #include "pipe/p_state.h" #include "util/u_memory.h" @@ -309,6 +311,13 @@ namespace { llvm::Type *arg_type = arg.getType(); unsigned arg_size = TD.getTypeStoreSize(arg_type); +if (arg_type->isVectorTy() && + ::llvm::cast<::llvm::VectorType>(arg_type)->getNumElements() == 3) { + ::llvm::dbgs() << "Fixing argument type: " << *arg_type + << " size: " << arg_size << "->" + << (arg_size / 3) * 4 << "\n"; + arg_size = (arg_size / 3) * 4; +} llvm::Type *target_type = arg_type->isIntegerTy() ? TD.getSmallestLegalIntType(mod->getContext(), arg_size * 8) : ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev ___ cfe-dev mailing list cfe-...@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] XorgEvoc participation and GL/GLSL tests for GL 4.0 and newer
Hi, I am Nyah Check, a sophomore student of computer engineering at the University of Buea in Cameroon(Africa), and a GSoC participant for 2013, where i worked with BRL-CAD. I'll like to work on the Xorg project through the XorgEvoc program. I would like to work on the GL/GLSL tests project for this year's summer. So i'll like to get some directives on what i should focus on, the milestones required and aspects of the code related to the project. Thanks for the reply and looking forward to an awesome summer with you guys this year. :) Cheers! Nyah ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [Mesa-stable] [PATCH] mesa: Fix querying location of nth element of an array variable
On Fri, Apr 18, 2014 at 3:41 PM, Ian Romanick wrote: > On 04/03/2014 04:13 PM, Anuj Phogat wrote: >> This patch changes the behavior of glGetAttribLocation(), >> glGetFragDataLocation() and glGetFragDataIndex() functions. >> >> Code changes handle the cases described in following example: >> vertex shader: >> layout(location = 1)in vec4[4] a; >> void main() >> { >> } >> >> fragment shader: >> layout (location = 1) out vec4[4] c; >> void main() >> { >> } >> >> Currently glGetAttribLocation("a") and glGetFragDataLocation("c") returns >> 1. glGetAttribLocation("a[i]") and glGetFragDataLocation("c[i]"), where >> i = {0, 1, 2, 3}, returns -1. But expected locations for array indices >> are: 1, 2, 3 and 4 respectively. >> >> OpenGL spec doesn't say anything specific about getting the location >> of an array element. But it looks sensible to allow such query. >> >> Fixes failures in Khronos OpenGL CTS tests: >> explicit_attrib_location_room >> draw_instanced_max_vertex_attribs >> >> Proprietary linux drivers of AMD and NVIDIA matches current output on >> Mesa (i.e. returns -1). > > I think this is a change (clarification?) that occured when > ARB_program_interface_query was added in OpenGL 4.3. (Did the drivers > you tested support OpenGL 4.3?) Specifically, the page 345 (page 367 of > the PDF) of the OpenGL 4.4 spec says: Yes, OpenGL 4.3 was supported on both the drivers. Updating NVIDIA drivers to OpenGL 4.4 matched the new behavior expected by spec. > > "Otherwise, [GetAttribLocation] is equivalent to > > GetProgramResourceLocation(program, PROGRAM_INPUT, name);" > > And page 107 (page 192 of the PDF) says: > > "A string provided to GetProgramResourceLocation or > GetProgramResourceLocationIndex is considered to match an active > variable if > > • the string exactly matches the name of the active variable; > • if the string identifies the base name of an active array, where > the string would exactly match the name of the variable if the > suffix "[0]" were appended to the string; or > • if the string identifies an active element of the array, where > the string ends with the concatenation of the "[" character, an > integer (with no "+" sign, extra leading zeroes, or whitespace) > identifying an array element, and the "]" character, the integer > is less than the number of active elements of the array variable, > and where the string would exactly match the enumerated name of > the array if the decimal integer were replaced with zero." > > We should capture this information in the commit message. > I think this information can be considered as a clarification for GetAttribLocation(). I'll add this to commit message. Thanks for looking it up Ian. > I think this code is much more complex than necessary. It seems like > the inner search looks should be something like: > I'll work on simplifying this code. Thanks for the suggestion. >const char *const paren = strchr(name, '['); >const unsigned len = (paren != NULL) ? paren - name : strlen(name); >unsigned idx = 0; > >... > >if (paren != NULL) { > /* Validate format of index. */ > ... > > idx = (unsigned) strtol(paren + 1, 10, NULL); >} > >for (...) { > if (strncmp(var->name, name, len) && var->name[len] == '\0') { > /* This part should be refactored. */ > if (var->type->is_array()) { > if (idx >= var->type->length) > /* error */ > > /* return something sensible. */ > } else { > /* Can't have an array index if variable isn't an array. > */ > if (paren != NULL) > /* error */ > > /* return something sensible. */ > } > } >} > >> Cc: >> Signed-off-by: Anuj Phogat >> --- >> src/mesa/main/shader_query.cpp | 76 >> +- >> 1 file changed, 75 insertions(+), 1 deletion(-) >> >> diff --git a/src/mesa/main/shader_query.cpp b/src/mesa/main/shader_query.cpp >> index e1afe53..2256482 100644 >> --- a/src/mesa/main/shader_query.cpp >> +++ b/src/mesa/main/shader_query.cpp >> @@ -131,6 +131,59 @@ _mesa_GetActiveAttrib(GLhandleARB program, GLuint >> desired_index, >> _mesa_error(ctx, GL_INVALID_VALUE, "glGetActiveAttrib(index)"); >> } >> >> +/* This function checks if the 'name' matches with var->name appended with >> + * valid array index for the variable. For example the var->name = "color" >> + * is declared as an array in shader program: >> + * in vec4[4] color; >> + * >> + * Match the queried 'name' with "color[0]", "color[1]", "color[2]" and >> + * "color[3]" to return the matched index of array. >> + */ >> +int static inline >> +get_matching_array_index(const ir_variable *const var, >> + const char *name, >> + const char *gl_func_name) { >> + /* Allowed array length for an input attribute or fr
[Mesa-dev] bloat-blame results for megadriver
I was reading an article on LTO in firefox today, and it pointed to https://github.com/wmanley/bloat-blame so I decided to try it on Mesa (i965_dri.so in a release build). It looks like it's pointing at some silly inlines we're doing that we can probably fix up to reduce the size of our built library (s_texfilter.c:775 as an example). Just a pointer in case someone's interested in looking into this. anholt@eliezer:anholt/src/mesa-release% tail -n 50 bloat 2632 /home/anholt/src/mesa-release/src/mesa/drivers/dri/i965/brw_blorp_blit_eu.h:111 2638/home/anholt/src/mesa-release/src/mesa/drivers/dri/i965/brw_fs.cpp:395 2647/home/anholt/src/mesa-release/src/mesa/main/format_pack.c:70 2655/home/anholt/src/mesa-release/src/mesa/swrast/s_triangle.c:253 2811 /home/anholt/src/mesa-release/src/mesa/../../src/gallium/auxiliary/util/u_format_r11g11b10f.h:125 2915/home/anholt/src/mesa-release/src/mesa/drivers/dri/i965/brw_fs.h:188 2942 /home/anholt/src/mesa-release/src/glsl/../../src/glsl/builtin_functions.cpp:1231 2954 /home/anholt/src/mesa-release/src/mesa/drivers/dri/i915/intel_batchbuffer.h:87 3058 /home/anholt/src/mesa-release/src/mesa/../../src/gallium/auxiliary/util/u_format_r11g11b10f.h:112 3108 /home/anholt/src/mesa-release/src/mesa/drivers/dri/i965/intel_batchbuffer.h:147 3119/home/anholt/src/mesa-release/src/glsl/ast.h:52 3162 /home/anholt/src/mesa-release/src/mesa/drivers/dri/i965/brw_blorp_blit_eu.h:90 3189 /home/anholt/src/mesa-release/src/mesa/drivers/dri/i965/../../../../../src/glsl/list.h:277 3225/home/anholt/src/mesa-release/src/mesa/swrast/s_texfilter.c:798 3227 /home/anholt/src/mesa-release/src/mesa/../../src/gallium/auxiliary/util/u_format_r11g11b10f.h:116 3228/home/anholt/src/mesa-release/src/glsl/../../src/glsl/ir_builder.h:55 3239/home/anholt/src/mesa-release/src/mesa/./main/imports.h:325 3269/home/anholt/src/mesa-release/src/mesa/vbo/vbo_attrib_tmp.h:148 3335/home/anholt/src/mesa-release/src/mesa/./main/context.h:311 3427/home/anholt/src/mesa-release/src/glsl/glsl_parser_extras.h:104 3450 /home/anholt/src/mesa-release/src/mesa/drivers/dri/i965/../../../../../src/glsl/list.h:278 3543 /home/anholt/src/mesa-release/src/mesa/drivers/dri/i965/intel_batchbuffer.h:139 3758/home/anholt/src/mesa-release/src/mesa/drivers/dri/i965/brw_reg.h:702 3800/home/anholt/src/mesa-release/src/mesa/./main/macros.h:745 3813/home/anholt/src/mesa-release/src/mesa/swrast/s_texfilter.c:775 3870/home/anholt/src/mesa-release/src/mesa/./main/imports.h:324 4025 /home/anholt/src/mesa-release/src/mesa/drivers/dri/i965/intel_batchbuffer.h:95 4056 /home/anholt/src/mesa-release/src/mesa/drivers/dri/nouveau/nouveau_local.h:29 4437 /home/anholt/src/mesa-release/src/mesa/drivers/dri/i965/brw_blorp_blit_eu.h:148 4572/home/anholt/src/mesa-release/src/glsl/../../src/glsl/ir_builder.h:56 4601/home/anholt/src/mesa-release/src/mesa/main/dlist.c:1068 5212/home/anholt/src/mesa-release/src/mesa/./main/imports.h:322 5384/home/anholt/src/mesa-release/src/mesa/drivers/dri/i965/brw_fs.h:145 5476 /home/anholt/src/mesa-release/src/mesa/drivers/dri/i965/intel_batchbuffer.h:121 5638 /home/anholt/src/mesa-release/src/mesa/../../src/gallium/auxiliary/util/u_format_r11g11b10f.h:122 5801/home/anholt/src/mesa-release/src/mesa/program/ir_to_mesa.cpp:391 5954 /home/anholt/src/mesa-release/src/mesa/drivers/dri/i965/intel_batchbuffer.h:123 6841 /home/anholt/src/mesa-release/src/mesa/drivers/dri/i965/intel_batchbuffer.h:130 7058 /home/anholt/src/mesa-release/src/mesa/drivers/dri/i965/intel_batchbuffer.h:107 7191/home/anholt/src/mesa-release/src/mesa/./main/imports.h:253 7556/home/anholt/src/mesa-release/src/mesa/./main/imports.h:156 7898/home/anholt/src/mesa-release/src/mesa/main/imports.h:253 8248 /home/anholt/src/mesa-release/src/mesa/drivers/dri/i965/brw_blorp_blit_eu.h:104 9299 /home/anholt/src/mesa-release/src/mesa/drivers/dri/nouveau/nouveau_local.h:36 14795 /home/anholt/src/mesa-release/src/mesa/drivers/dri/nouveau/nouveau_local.h:43 23218 /home/anholt/src/mesa-release/src/mesa/drivers/dri/i965/intel_batchbuffer.h:106 24881 /home/anholt/src/mesa-release/src/glsl/../../src/glsl/list.h:79 45371 :? 226963 xform4.o:? 35845145??:0 pgprbZt66IISc.pgp Description: PGP signature ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] clover : clEnqueueMarkerWithWaitList and clEnqueueBarrierWithWaitList
EdB writes: > Hello > > I would be interested in developing for clover. > As a first exercise I implement clEnqueueMarkerWithWaitList and > clEnqueueBarrierWithWaitList needed for OpenCL 1.2 > > This patch is more a proof of concept than a real one. > > Please tell me if I get it wrong. Thanks for looking into this, some suggestions below. > diff --git a/src/gallium/state_trackers/clover/api/dispatch.cpp > b/src/gallium/state_trackers/clover/api/dispatch.cpp > index 746372c..e4f7ea3 100644 > --- a/src/gallium/state_trackers/clover/api/dispatch.cpp > +++ b/src/gallium/state_trackers/clover/api/dispatch.cpp > @@ -129,8 +129,8 @@ namespace clover { >NULL, // clEnqueueFillBuffer >NULL, // clEnqueueFillImage >NULL, // clEnqueueMigrateMemObjects > - NULL, // clEnqueueMarkerWithWaitList > - NULL, // clEnqueueBarrierWithWaitList > + clEnqueueMarkerWithWaitList, > + clEnqueueBarrierWithWaitList, >NULL, // clGetExtensionFunctionAddressForPlatform >NULL, // clCreateFromGLTexture >NULL, // clGetDeviceIDsFromD3D11KHR > diff --git a/src/gallium/state_trackers/clover/api/event.cpp > b/src/gallium/state_trackers/clover/api/event.cpp > index 6b1956c..e0349a7 100644 > --- a/src/gallium/state_trackers/clover/api/event.cpp > +++ b/src/gallium/state_trackers/clover/api/event.cpp > @@ -179,6 +179,37 @@ clEnqueueMarker(cl_command_queue d_q, cl_event *rd_ev) > try { > } > > CLOVER_API cl_int > +clEnqueueMarkerWithWaitList(cl_command_queue d_q, cl_uint num_evs, > +const cl_event *d_evs, cl_event *rd_ev) try { > + if (!d_evs and num_evs > 0) > + throw error(CL_INVALID_EVENT_WAIT_LIST); > + > + if (d_evs and !num_evs) > + throw error(CL_INVALID_EVENT_WAIT_LIST); > + > + auto &q = obj(d_q); > + > + ref_vector evs = {}; > + > + if (num_evs) > + evs = objs(d_evs, num_evs); > + The wait_list_tag specialization of objs() already takes care of the argument validation with wait-list-like semantics. You could replace all the code above with something like: | auto &q = obj(d_q); | auto deps = objs(d_deps, num_deps); > + for (auto &ev : evs) { > + if (ev.context() != q.context()) > + throw error(CL_INVALID_CONTEXT); > + } > + > + auto hev = new hard_event(q, CL_COMMAND_MARKER, evs); > + if (rd_ev) > + *rd_ev = desc(hev); > + > + return CL_SUCCESS; > + This is going to leak memory whenever 'rd_ev' is NULL, how about: | // Create a hard event that depends on the events in the wait list. | auto hev = create(q, CL_COMMAND_MARKER, deps); | | ret_object(rd_ev, hev); | return CL_SUCCESS; The create() helper creates an instance of some object and returns it as a smart pointer that takes ownership of the object, so it's less likely to make mistakes like this. > +} catch (error &e) { > + return e.get(); > +} > + > +CLOVER_API cl_int > clEnqueueBarrier(cl_command_queue d_q) try { > obj(d_q); > > @@ -191,6 +222,40 @@ clEnqueueBarrier(cl_command_queue d_q) try { > } > > CLOVER_API cl_int > +clEnqueueBarrierWithWaitList(cl_command_queue d_q, cl_uint num_evs, > + const cl_event *d_evs, cl_event *rd_ev) try { > + if (!d_evs and num_evs > 0) > + throw error(CL_INVALID_EVENT_WAIT_LIST); > + > + if (d_evs and !num_evs) > + throw error(CL_INVALID_EVENT_WAIT_LIST); > + > + auto &q = obj(d_q); > + > + ref_vector evs = {}; > + > + if (num_evs) > + evs = objs(d_evs, num_evs); > + Same as before: | auto &q = obj(d_q); | auto deps = objs(d_deps, num_deps); > + for (auto &ev : evs) { > + if (ev.context() != q.context()) > + throw error(CL_INVALID_CONTEXT); > + } > + > + > +#define TMP_CL_COMMAND_BARRIER 0x1205 //a temporary DEFINE, it needed to be > in cl.h We should probably update the CL headers to 1.2 before implementing this. > + auto hev = new hard_event(q, TMP_CL_COMMAND_BARRIER, evs); > + if (rd_ev) > + *rd_ev = desc(hev); > +#undef TMP_CL_COMMAND_BARRIER > + Use create() and ret_object() as before. How about implementing clEnqueueWaitForEvents() in terms of this entry point? It should be equivalent to: | // The wait list is mandatory for clEnqueueWaitForEvents(). | objs(d_evs, num_evs); | | clEnqueueBarrierWithWaitList(d_q, num_evs, d_evs, NULL); Thank you. > + return CL_SUCCESS; > + > +} catch (error &e) { > + return e.get(); > +} > + > +CLOVER_API cl_int > clEnqueueWaitForEvents(cl_command_queue d_q, cl_uint num_evs, > const cl_event *d_evs) try { > auto &q = obj(d_q); > ___ > mesa-dev mailing list > mesa-dev@lists.freedesktop.org > http://lists.freedesktop.org/mailman/listinfo/mesa-dev pgpDQLd1AzaiS.pgp Description: PGP signature ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [cfe-dev] 3 element vectors in opencl 1.1+
On Tue, 2014-04-22 at 14:40 -0700, Matt Arsenault wrote: > On 04/22/2014 02:35 PM, Tom Stellard wrote: > > On Mon, Apr 21, 2014 at 10:02:27PM -0400, Jan Vesely wrote: > >> Hi, > >> > >> I ran into a problem caused by this part of the OCL specs (6.1.5 > >> Alignment of Types): > >> "For 3-component vector data types, the size of the data type is 4 * > >> sizeof(component)." > >> > >> and the corresponding part of Khronos cl_platform.h (with all types, not > >> just float): > >> /* cl_float3 is identical in size, alignment and behavior to cl_float4. > >> See section 6.1.5. */ > >> typedef cl_float4 cl_float3; > >> > >> So when I try to run kernel that takes 3 element vectors as arguments I > >> get 'invalid arg size' error. > >> > >> Not sure whether this is best solved in clang, libclc or clover. I tried > >> changing float3 to have 4 elements in libclc, it caused clang to > >> complain in thousand places. I don't think this can be handled cleanly > >> in clang, unless we add something like __attribute__((padding)). > >> > >> I have attached a workaround that I use now. > >> > > You may want to ask this question on the pocl mailing list as they > > have likely solved this issue already. Ideally, TD.getTypeStoreSize > > would return the correct value. Also, maybe look at the DataLayout > > description for R600 and see if there is a way to specify the > > correct type size. > > > > -Tom > I think this is what v96:128 is for according to [0], it specifies only alignment, not size. I could not find an __attribute__ that would change size either. It should be possible to have ADMGPUDataLayout: public DataLayout class that would intercept the call and fix the reported value, but I think it would only move the hack to different place. I have added pocl-devel list as suggested. regards, Jan [0]http://llvm.org/docs/LangRef.html#data-layout > > > > > >> any advice welcome, > >> Jan > >> > >> -- > >> Jan Vesely > >> diff --git a/src/gallium/state_trackers/clover/llvm/invocation.cpp > >> b/src/gallium/state_trackers/clover/llvm/invocation.cpp > >> index a81bdf8..71ee01f 100644 > >> --- a/src/gallium/state_trackers/clover/llvm/invocation.cpp > >> +++ b/src/gallium/state_trackers/clover/llvm/invocation.cpp > >> @@ -62,6 +62,8 @@ > >> #include > >> #endif > >> > >> +#include > >> + > >> #include "pipe/p_state.h" > >> #include "util/u_memory.h" > >> > >> @@ -309,6 +311,13 @@ namespace { > >> > >> llvm::Type *arg_type = arg.getType(); > >> unsigned arg_size = TD.getTypeStoreSize(arg_type); > >> +if (arg_type->isVectorTy() && > >> + > >> ::llvm::cast<::llvm::VectorType>(arg_type)->getNumElements() == 3) { > >> + ::llvm::dbgs() << "Fixing argument type: " << *arg_type > >> + << " size: " << arg_size << "->" > >> + << (arg_size / 3) * 4 << "\n"; > >> + arg_size = (arg_size / 3) * 4; > >> +} > >> > >> llvm::Type *target_type = arg_type->isIntegerTy() ? > >> TD.getSmallestLegalIntType(mod->getContext(), arg_size * > >> 8) : > > > > > > > >> ___ > >> mesa-dev mailing list > >> mesa-dev@lists.freedesktop.org > >> http://lists.freedesktop.org/mailman/listinfo/mesa-dev > > ___ > > cfe-dev mailing list > > cfe-...@cs.uiuc.edu > > http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev > -- Jan Vesely signature.asc Description: This is a digitally signed message part ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [cfe-dev] 3 element vectors in opencl 1.1+
On 04/22/2014 05:22 PM, Jan Vesely wrote: On Tue, 2014-04-22 at 14:40 -0700, Matt Arsenault wrote: On 04/22/2014 02:35 PM, Tom Stellard wrote: On Mon, Apr 21, 2014 at 10:02:27PM -0400, Jan Vesely wrote: Hi, I ran into a problem caused by this part of the OCL specs (6.1.5 Alignment of Types): "For 3-component vector data types, the size of the data type is 4 * sizeof(component)." and the corresponding part of Khronos cl_platform.h (with all types, not just float): /* cl_float3 is identical in size, alignment and behavior to cl_float4. See section 6.1.5. */ typedef cl_float4 cl_float3; So when I try to run kernel that takes 3 element vectors as arguments I get 'invalid arg size' error. Not sure whether this is best solved in clang, libclc or clover. I tried changing float3 to have 4 elements in libclc, it caused clang to complain in thousand places. I don't think this can be handled cleanly in clang, unless we add something like __attribute__((padding)). I have attached a workaround that I use now. You may want to ask this question on the pocl mailing list as they have likely solved this issue already. Ideally, TD.getTypeStoreSize would return the correct value. Also, maybe look at the DataLayout description for R600 and see if there is a way to specify the correct type size. -Tom I think this is what v96:128 is for according to [0], it specifies only alignment, not size. I could not find an __attribute__ that would change size either. It should be possible to have ADMGPUDataLayout: public DataLayout class that would intercept the call and fix the reported value, but I think it would only move the hack to different place. I have added pocl-devel list as suggested. regards, Jan [0]http://llvm.org/docs/LangRef.html#data-layout Only the size in memory matters, which is what the required alignment specifies. DataLayout::getTypeAllocSize accounts for the alignment, but getTypeStoreSize does not. I actually thought this was half of what getTypeStoreSize was for, but it turns out it isn't. ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 00/21] deferred and threaded glCompileShader
On Tue, Apr 22, 2014 at 8:10 PM, Timothy Arceri wrote: > On Tue, 2014-04-22 at 16:58 +0800, Chia-I Wu wrote: >> Hi list, >> >> This series adds a thread pool to the GLSL compiler, and a drirc option to >> defer glCompileShader calls to the pool. The goal is to reduce the start-up >> time of applications that are aware of this feature. That is, applications >> that compile shaders first and check the compile status later. >> >> I do not have numbers from real applications yet. But trying to compiling a >> set of 2882 shaders extracted from some trace file, with everything else >> idled, the time it takes is >> >> 8 threads: 17.8s >> 4 threads: 20.3s >> 2 threads: 31.2s >> 1 threads: 58.0s >> no thread pool: 54.5 >> >> on a quad core system. >> >> Patches 1-4 fix potential races in the GLSL compiler. As the compiler is >> already shared by all contexts, these patches could be desirable even without >> the thread pool that I am going to add. >> >> Patches 5-18 adds true GL_DEBUG_OUTPUT_SYNCHRONOUS support to the KHR_debug >> code. All except patch 18 are clean-ups. Patch 18 adds a mutex to protect >> gl_debug_state. > > I've skimmed over patches 5-17 looks like some good clean ups. I've made > some comments for patch 12 and 16. Thanks. I've fixed patch 16. The series is also available at https://github.com/olvaffe/mesa/commits/threaded-2 if you are interested. > >> >> Patch 19 defines a simple API to create and work with thread pools, as well >> as >> a test for the API. >> >> Patch 20 adds the singleton GLSL thread pool and allows glCompileShader to be >> deferred to the pool. This feature needs to be explicitly enabled with >> _mesa_enable_glsl_threadpool. >> >> Patch 21 adds a drirc option to enable the thread pool. The idea is that >> only >> applications that can benefit from it will enable it. >> ___ >> mesa-dev mailing list >> mesa-dev@lists.freedesktop.org >> http://lists.freedesktop.org/mailman/listinfo/mesa-dev > > -- o...@lunarg.com ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [Bug 77789] New: Account request for Andreas Hartmetz
https://bugs.freedesktop.org/show_bug.cgi?id=77789 Priority: medium Bug ID: 77789 Assignee: mesa-dev@lists.freedesktop.org Summary: Account request for Andreas Hartmetz Severity: normal Classification: Unclassified OS: All Reporter: ahartm...@gmail.com Hardware: Other Status: NEW Version: unspecified Component: Other Product: Mesa Created attachment 97793 --> https://bugs.freedesktop.org/attachment.cgi?id=97793&action=edit SSH public key Hello, I've already sent a few patches to the mesa-dev list and I've been asked to get an account. I can't find the e-mail suggesting it right now, but you can see my name in the archives. Real name: Andreas Hartmetz E-Mail address: ahartm...@gmail.com Preferred account name: ahartmetz -- You are receiving this mail because: You are the assignee for the bug. ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [Bug 77789] Account request for Andreas Hartmetz
https://bugs.freedesktop.org/show_bug.cgi?id=77789 --- Comment #1 from Andreas Hartmetz --- Created attachment 97794 --> https://bugs.freedesktop.org/attachment.cgi?id=97794&action=edit GPG public key -- You are receiving this mail because: You are the assignee for the bug. ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev