Re: [Mesa-dev] void operation in glsl
It's just a simple, portable way to make the `unused parameter` warning shut up, when you're deliberately ignoring your parameters. There are other ways [__attribute__(( unused )), etc] but they cease to be simple or portable fairly quickly. -- Chris On Mon, Aug 26, 2013 at 5:07 PM, Liu Xin liu...@icubecorp.com wrote: HI, list, i don't understand why glsl source have so many 'cast to void' operations, like this. ir_rvalue * ast_node::hir(exec_list *instructions, struct _mesa_glsl_parse_state *state) { (void) instructions; (void) state; return NULL; } i think it's totally void operation, do you guy just make gcc compiler happy? thanks, --lx ___ 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] void operation in glsl
On Sun, Aug 25, 2013 at 10:07 PM, Liu Xin liu...@icubecorp.com wrote: HI, list, i don't understand why glsl source have so many 'cast to void' operations, like this. ir_rvalue * ast_node::hir(exec_list *instructions, struct _mesa_glsl_parse_state *state) { (void) instructions; (void) state; return NULL; } i think it's totally void operation, do you guy just make gcc compiler happy? Yes, the purpose is only to avoid unused variable warnings emitted by the compiler. ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH] i965: Allocate just enough space for user clip planes in uniform arrays.
Previously, we allocated space in brw_vs_prog_data's params and pull_params arrays for MAX_CLIP_PLANES vec4s---even when it wasn't necessary. On a 64-bit architecture, this used 0.5 kB of space (8 clip planes * 4 floats per plane * 8 bytes per float pointer * 2 arrays of pointers = 512 bytes). Since this cost is per-vertex shader, it added up. Conveniently, we already store the number of clip plane constants in the program key. By using that, we can allocate the exact amount of space needed. For the common case where user clipping is disabled, this means 0 bytes. While we're here, mention exactly what code requires this extra space, since it wasn't obvious. Signed-off-by: Kenneth Graunke kenn...@whitecape.org --- src/mesa/drivers/dri/i965/brw_vs.c | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) No Piglit regressions on Ivybridge. Portal still works as well (it uses a lot of user clipping). diff --git a/src/mesa/drivers/dri/i965/brw_vs.c b/src/mesa/drivers/dri/i965/brw_vs.c index 6a67bc4..a5a9fb1 100644 --- a/src/mesa/drivers/dri/i965/brw_vs.c +++ b/src/mesa/drivers/dri/i965/brw_vs.c @@ -234,8 +234,10 @@ do_vs_prog(struct brw_context *brw, } else { param_count = vp-program.Base.Parameters-NumParameters * 4; } - /* We also upload clip plane data as uniforms */ - param_count += MAX_CLIP_PLANES * 4; + /* vec4_visitor::setup_uniform_clipplane_values() also uploads user clip +* planes as uniforms. +*/ + param_count += c.key.base.nr_userclip_plane_consts * 4; prog_data.base.param = rzalloc_array(NULL, const float *, param_count); prog_data.base.pull_param = rzalloc_array(NULL, const float *, param_count); -- 1.8.3.4 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] tgsi dump and parsing
Hi TGSI guys mostly :-) So I'm wondering how circular and perfect tgsi-text-tgsi roundabouts should be, currently the TGSI dump code uses .4f in one place, which makes things like 1e6 not make it across the divide, I was thinking of dumping immediates in 32-bit hex format so we know for definite what happens on the other side, I've been thinking of maybe adding a debug option to softpipe to dump to text and read it back, to see what other regression lie in wait. Dave. ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] void operation in glsl
On 08/26/2013 02:42 PM, Matt Turner wrote: On Sun, Aug 25, 2013 at 10:07 PM, Liu Xin liu...@icubecorp.com wrote: HI, list, i don't understand why glsl source have so many 'cast to void' operations, like this. ir_rvalue * ast_node::hir(exec_list *instructions, struct _mesa_glsl_parse_state *state) { (void) instructions; (void) state; return NULL; } i think it's totally void operation, do you guy just make gcc compiler happy? Yes, the purpose is only to avoid unused variable warnings emitted by the compiler. yes it is. now i understood. clean code! --lx ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 00/15] Implement KHR_debug
The following patchset implements the KHR_debug extension. Here are some notes/assumptions I have made: * These patches only enable the extension for GL not ES * MAX_LABEL_LENGTH and MAX_DEBUG_GROUP_STACK_DEPTH are set to the minimum values defined in the spec. * Assume its fine that Push/Pop also filter the output of the ARB_debug_output extension * From the KHR_debug spec If the DEBUG_OUTPUT state is disabled then no messages are added to the message log. To allow for this the state of DEBUG_OUTPUT now affects the ARB_debug_output extension meaning callbacks and messages are now not called/stored unless either DEBUG_OUTPUT is enabled or CONTEXT_DEBUG_BIT_ARB is set. The existing Mesa implementation allowed callbacks/messages to be stored without CONTEXT_DEBUG_BIT_ARB being set. * As both arb_debug_output and khr_debug have the same message log the messages returned by the arb_debug_output functions need to be filtered to return types/severitys that the caller expects (rather than new type introduced byt khr_debug). To work around this just the types are just remap them to types arb_debug_output understands. Timothy Arceri (15): mesa: Add some constants and state variables for KHR_debug functions mesa: Share common code between ARB_debug_output and KHR_debug functions mesa: Add a clone function to mesa hash mesa: Implement glPushDebugGroup and glPopDebugGroup mesa: make _mesa_lookup_arrayobj() non-static mesa: make _mesa_lookup_list() non-static mesa: add debug Label field to several data structures mesa: free object labels when deleting mesa: make _mesa_validate_sync() non-static mesa: Implement KHR_debug ObjectLabel functions mesa: Update builds scripts to build object labels mesa: Implement GL_DEBUG_OUTPUT mesa: Remap debug type and severity glapi: Setup autogeneration infrastructure for KHR_debug mesa: Setup remaining infrastucture and enable KHR_debug src/mapi/glapi/gen/gl_API.xml| 149 +- src/mapi/glapi/gen/gl_genexec.py |1 + src/mesa/Makefile.sources|1 + src/mesa/SConscript |1 + src/mesa/drivers/dri/i965/brw_context.c |2 + src/mesa/main/arrayobj.c | 11 +- src/mesa/main/arrayobj.h |3 + src/mesa/main/bufferobj.c|1 + src/mesa/main/config.h |7 +- src/mesa/main/dlist.c| 13 +- src/mesa/main/dlist.h|2 + src/mesa/main/enable.c |9 + src/mesa/main/errors.c | 633 +++--- src/mesa/main/errors.h | 20 + src/mesa/main/extensions.c |3 + src/mesa/main/framebuffer.c |1 + src/mesa/main/get_hash_params.py | 14 +- src/mesa/main/hash.c | 26 ++ src/mesa/main/hash.h |3 + src/mesa/main/mtypes.h | 34 +- src/mesa/main/objectlabel.c | 277 +++ src/mesa/main/objectlabel.h | 61 +++ src/mesa/main/queryobj.c |1 + src/mesa/main/renderbuffer.c |1 + src/mesa/main/samplerobj.c |1 + src/mesa/main/shaderobj.c|3 + src/mesa/main/syncobj.c |3 +- src/mesa/main/syncobj.h |3 + src/mesa/main/texobj.c |2 + src/mesa/main/transformfeedback.c|1 + src/mesa/state_tracker/st_cb_bufferobjects.c |1 + src/mesa/state_tracker/st_cb_syncobj.c |1 + src/mesa/state_tracker/st_manager.c |6 +- 33 files changed, 1105 insertions(+), 190 deletions(-) create mode 100644 src/mesa/main/objectlabel.c create mode 100644 src/mesa/main/objectlabel.h -- 1.7.9.5 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 01/15] mesa: Add some constants and state variables for KHR_debug functions
Signed-off-by: Timothy Arceri t_arc...@yahoo.com.au --- src/mesa/main/config.h |7 ++- src/mesa/main/errors.c |4 src/mesa/main/mtypes.h | 15 ++- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/mesa/main/config.h b/src/mesa/main/config.h index 1d2ab4d..0bcf27c 100644 --- a/src/mesa/main/config.h +++ b/src/mesa/main/config.h @@ -249,12 +249,17 @@ #define MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS 1024 /*@}*/ -/** For GL_ARB_debug_output */ +/** For GL_ARB_debug_output and GL_KHR_debug */ /*@{*/ #define MAX_DEBUG_LOGGED_MESSAGES 10 #define MAX_DEBUG_MESSAGE_LENGTH4096 /*@}*/ +/** For GL_KHR_debug */ +/*@{*/ +#define MAX_LABEL_LENGTH 256 +#define MAX_DEBUG_GROUP_STACK_DEPTH 64 +/*@}*/ /* * Color channel component order diff --git a/src/mesa/main/errors.c b/src/mesa/main/errors.c index cc93d3b..eea7291 100644 --- a/src/mesa/main/errors.c +++ b/src/mesa/main/errors.c @@ -66,12 +66,16 @@ static const GLenum debug_type_enums[] = { GL_DEBUG_TYPE_PORTABILITY, GL_DEBUG_TYPE_PERFORMANCE, GL_DEBUG_TYPE_OTHER, + GL_DEBUG_TYPE_MARKER, + GL_DEBUG_TYPE_PUSH_GROUP, + GL_DEBUG_TYPE_POP_GROUP, }; static const GLenum debug_severity_enums[] = { GL_DEBUG_SEVERITY_LOW, GL_DEBUG_SEVERITY_MEDIUM, GL_DEBUG_SEVERITY_HIGH, + GL_DEBUG_SEVERITY_NOTIFICATION, }; static enum mesa_debug_source diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 22bb58c..fd71fa7 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -3315,8 +3315,8 @@ struct gl_dlist_state /** @{ * - * These are a mapping of the GL_ARB_debug_output enums to small enums - * suitable for use as an array index. + * These are a mapping of the GL_ARB_debug_output/GL_KHR_debug enums + * to small enums suitable for use as an array index. */ enum mesa_debug_source { @@ -3336,6 +3336,9 @@ enum mesa_debug_type { MESA_DEBUG_TYPE_PORTABILITY, MESA_DEBUG_TYPE_PERFORMANCE, MESA_DEBUG_TYPE_OTHER, + MESA_DEBUG_TYPE_MARKER, + MESA_DEBUG_TYPE_PUSH_GROUP, + MESA_DEBUG_TYPE_POP_GROUP, MESA_DEBUG_TYPE_COUNT }; @@ -3343,6 +3346,7 @@ enum mesa_debug_severity { MESA_DEBUG_SEVERITY_LOW, MESA_DEBUG_SEVERITY_MEDIUM, MESA_DEBUG_SEVERITY_HIGH, + MESA_DEBUG_SEVERITY_NOTIFICATION, MESA_DEBUG_SEVERITY_COUNT }; @@ -3350,7 +3354,7 @@ enum mesa_debug_severity { /** * An error, warning, or other piece of debug information for an application - * to consume via GL_ARB_debug_output. + * to consume via GL_ARB_debug_output/GL_KHR_debug. */ struct gl_debug_msg { @@ -3372,12 +3376,13 @@ struct gl_debug_namespace struct gl_debug_state { - GLDEBUGPROCARB Callback; + GLDEBUGPROC Callback; const void *CallbackData; GLboolean SyncOutput; GLboolean Defaults[MESA_DEBUG_SEVERITY_COUNT][MESA_DEBUG_SOURCE_COUNT][MESA_DEBUG_TYPE_COUNT]; struct gl_debug_namespace Namespaces[MESA_DEBUG_SOURCE_COUNT][MESA_DEBUG_TYPE_COUNT]; struct gl_debug_msg Log[MAX_DEBUG_LOGGED_MESSAGES]; + GLint GroupStackDepth; GLint NumMessages; GLint NextMsg; GLint NextMsgLength; /* redundant, but copied here from Log[NextMsg].length @@ -3624,7 +3629,7 @@ struct gl_context const char *ErrorDebugFmtString; GLuint ErrorDebugCount; - /* GL_ARB_debug_output */ + /* GL_ARB_debug_output/GL_KHR_debug */ struct gl_debug_state Debug; GLenum RenderMode;/** either GL_RENDER, GL_SELECT, GL_FEEDBACK */ -- 1.7.9.5 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 02/15] mesa: Share common code between ARB_debug_output and KHR_debug functions
Signed-off-by: Timothy Arceri t_arc...@yahoo.com.au --- src/mesa/main/errors.c | 308 +--- src/mesa/main/errors.h | 15 +++ 2 files changed, 226 insertions(+), 97 deletions(-) diff --git a/src/mesa/main/errors.c b/src/mesa/main/errors.c index eea7291..8e97b52 100644 --- a/src/mesa/main/errors.c +++ b/src/mesa/main/errors.c @@ -392,13 +392,19 @@ _mesa_get_msg(struct gl_context *ctx, GLenum *source, GLenum *type, * glDebugMessageInsertARB only accepts two values for 'source', * and glDebugMessageControlARB will additionally accept GL_DONT_CARE * in any parameter, so handle those cases specially. + * + * There is also special cases for handling values available in + * GL_KHR_debug that are not avaliable in GL_ARB_debug_output */ static GLboolean validate_params(struct gl_context *ctx, unsigned caller, -GLenum source, GLenum type, GLenum severity) +const char *callerstr, GLenum source, GLenum type, +GLenum severity) { #define INSERT 1 #define CONTROL 2 +#define INSERT_ARB 3 +#define CONTROL_ARB 4 switch(source) { case GL_DEBUG_SOURCE_APPLICATION_ARB: case GL_DEBUG_SOURCE_THIRD_PARTY_ARB: @@ -407,10 +413,10 @@ validate_params(struct gl_context *ctx, unsigned caller, case GL_DEBUG_SOURCE_SHADER_COMPILER_ARB: case GL_DEBUG_SOURCE_WINDOW_SYSTEM_ARB: case GL_DEBUG_SOURCE_OTHER_ARB: - if (caller != INSERT) + if (caller != INSERT || caller == INSERT_ARB) break; case GL_DONT_CARE: - if (caller == CONTROL) + if (caller == CONTROL || caller == CONTROL_ARB) break; default: goto error; @@ -424,8 +430,12 @@ validate_params(struct gl_context *ctx, unsigned caller, case GL_DEBUG_TYPE_PORTABILITY_ARB: case GL_DEBUG_TYPE_OTHER_ARB: break; + case GL_DEBUG_TYPE_MARKER: + /* this value is only valid for GL_KHR_debug functions */ + if (caller == CONTROL || caller == INSERT) + break; case GL_DONT_CARE: - if (caller == CONTROL) + if (caller == CONTROL || caller == CONTROL_ARB) break; default: goto error; @@ -436,8 +446,12 @@ validate_params(struct gl_context *ctx, unsigned caller, case GL_DEBUG_SEVERITY_MEDIUM_ARB: case GL_DEBUG_SEVERITY_LOW_ARB: break; + case GL_DEBUG_SEVERITY_NOTIFICATION: + /* this value is only valid for GL_KHR_debug functions */ + if (caller == CONTROL || caller == INSERT) + break; case GL_DONT_CARE: - if (caller == CONTROL) + if (caller == CONTROL || caller == CONTROL_ARB) break; default: goto error; @@ -446,93 +460,13 @@ validate_params(struct gl_context *ctx, unsigned caller, error: { - const char *callerstr; - if (caller == INSERT) - callerstr = glDebugMessageInsertARB; - else if (caller == CONTROL) - callerstr = glDebugMessageControlARB; - else - return GL_FALSE; - - _mesa_error( ctx, GL_INVALID_ENUM, bad values passed to %s + _mesa_error(ctx, GL_INVALID_ENUM, bad values passed to %s (source=0x%x, type=0x%x, severity=0x%x), callerstr, source, type, severity); } return GL_FALSE; } -void GLAPIENTRY -_mesa_DebugMessageInsertARB(GLenum source, GLenum type, GLuint id, -GLenum severity, GLint length, -const GLcharARB* buf) -{ - GET_CURRENT_CONTEXT(ctx); - - if (!validate_params(ctx, INSERT, source, type, severity)) - return; /* GL_INVALID_ENUM */ - - if (length 0) - length = strlen(buf); - - if (length = MAX_DEBUG_MESSAGE_LENGTH) { - _mesa_error(ctx, GL_INVALID_VALUE, glDebugMessageInsertARB - (length=%d, which is not less than - GL_MAX_DEBUG_MESSAGE_LENGTH_ARB=%d), length, - MAX_DEBUG_MESSAGE_LENGTH); - return; - } - - _mesa_log_msg(ctx, - gl_enum_to_debug_source(source), - gl_enum_to_debug_type(type), id, - gl_enum_to_debug_severity(severity), length, buf); -} - -GLuint GLAPIENTRY -_mesa_GetDebugMessageLogARB(GLuint count, GLsizei logSize, GLenum* sources, -GLenum* types, GLenum* ids, GLenum* severities, -GLsizei* lengths, GLcharARB* messageLog) -{ - GET_CURRENT_CONTEXT(ctx); - GLuint ret; - - if (!messageLog) - logSize = 0; - - if (logSize 0) { - _mesa_error(ctx, GL_INVALID_VALUE, glGetDebugMessageLogARB - (logSize=%d : logSize must not be negative), logSize); - return 0; - } - - for (ret = 0; ret count; ret++) { - GLsizei written = _mesa_get_msg(ctx, sources, types, ids, severities, - logSize, messageLog); - if (!written) - break; - - if (messageLog) { - messageLog += written; - logSize -= written; - } - if
[Mesa-dev] [PATCH 03/15] mesa: Add a clone function to mesa hash
Signed-off-by: Timothy Arceri t_arc...@yahoo.com.au --- src/mesa/main/hash.c | 26 ++ src/mesa/main/hash.h |3 +++ 2 files changed, 29 insertions(+) diff --git a/src/mesa/main/hash.c b/src/mesa/main/hash.c index 6591af9..8dde8b1 100644 --- a/src/mesa/main/hash.c +++ b/src/mesa/main/hash.c @@ -302,6 +302,32 @@ _mesa_HashDeleteAll(struct _mesa_HashTable *table, /** + * Clone all entries in a hash table, into a new table. + * + * \param table the hash table to clone + */ +struct _mesa_HashTable * +_mesa_HashClone(struct _mesa_HashTable *table) +{ + struct hash_entry *entry; + struct _mesa_HashTable *clonetable; + + ASSERT(table); + _glthread_LOCK_MUTEX(table-Mutex); + + clonetable = _mesa_NewHashTable(); + assert(clonetable); + hash_table_foreach(table-ht, entry) { + _mesa_HashInsert(clonetable, (GLint)(uintptr_t)entry-key, entry-data); + } + + _glthread_UNLOCK_MUTEX(table-Mutex); + + return clonetable; +} + + +/** * Walk over all entries in a hash table, calling callback function for each. * Note: we use a separate mutex in this function to avoid a recursive * locking deadlock (in case the callback calls _mesa_HashRemove()) and to diff --git a/src/mesa/main/hash.h b/src/mesa/main/hash.h index 142d284..9208701 100644 --- a/src/mesa/main/hash.h +++ b/src/mesa/main/hash.h @@ -50,6 +50,9 @@ _mesa_HashDeleteAll(struct _mesa_HashTable *table, void (*callback)(GLuint key, void *data, void *userData), void *userData); +extern struct _mesa_HashTable * +_mesa_HashClone(struct _mesa_HashTable *table); + extern void _mesa_HashWalk(const struct _mesa_HashTable *table, void (*callback)(GLuint key, void *data, void *userData), -- 1.7.9.5 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 04/15] mesa: Implement glPushDebugGroup and glPopDebugGroup
Signed-off-by: Timothy Arceri t_arc...@yahoo.com.au --- src/mesa/main/errors.c | 275 src/mesa/main/errors.h |5 + src/mesa/main/mtypes.h |5 +- 3 files changed, 214 insertions(+), 71 deletions(-) diff --git a/src/mesa/main/errors.c b/src/mesa/main/errors.c index 8e97b52..dbad585 100644 --- a/src/mesa/main/errors.c +++ b/src/mesa/main/errors.c @@ -189,8 +189,9 @@ should_log(struct gl_context *ctx, GLuint id, enum mesa_debug_severity severity) { + GLint gstack = ctx-Debug.GroupStackDepth; struct gl_debug_namespace *nspace = - ctx-Debug.Namespaces[source][type]; + ctx-Debug.Namespaces[gstack][source][type]; uintptr_t state; /* In addition to not being able to store zero as a value, HashTable also @@ -206,7 +207,7 @@ should_log(struct gl_context *ctx, struct gl_debug_severity *entry; if (state == NOT_FOUND) { - if (ctx-Debug.Defaults[severity][source][type]) + if (ctx-Debug.Defaults[gstack][severity][source][type]) state = ENABLED; else state = DISABLED; @@ -240,8 +241,9 @@ set_message_state(struct gl_context *ctx, enum mesa_debug_type type, GLuint id, GLboolean enabled) { + GLint gstack = ctx-Debug.GroupStackDepth; struct gl_debug_namespace *nspace = - ctx-Debug.Namespaces[source][type]; + ctx-Debug.Namespaces[gstack][source][type]; uintptr_t state; /* In addition to not being able to store zero as a value, HashTable also @@ -266,6 +268,39 @@ set_message_state(struct gl_context *ctx, nspace-ZeroID = state; } +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, @@ -301,30 +336,7 @@ _mesa_log_msg(struct gl_context *ctx, enum mesa_debug_source source, % MAX_DEBUG_LOGGED_MESSAGES; emptySlot = ctx-Debug.Log[nextEmpty]; - 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; - } + store_message_details(emptySlot, source, type, id, severity, len, buf); if (ctx-Debug.NumMessages == 0) ctx-Debug.NextMsgLength = ctx-Debug.Log[ctx-Debug.NextMsg].length; @@ -486,6 +498,7 @@ control_messages(struct gl_context *ctx, GLboolean enabled) { int s, t, sev, smax, tmax, sevmax; + GLint gstack = ctx-Debug.GroupStackDepth; if (source == MESA_DEBUG_SOURCE_COUNT) { source = 0; @@ -515,10 +528,10 @@ control_messages(struct gl_context *ctx, struct gl_debug_severity *entry; /* change the default for IDs we've never seen before. */ -ctx-Debug.Defaults[sev][s][t] = enabled; +ctx-Debug.Defaults[gstack][sev][s][t] = enabled; /* Now change the state of IDs we *have* seen... */ -foreach(node, ctx-Debug.Namespaces[s][t].Severity[sev]) { +foreach(node, ctx-Debug.Namespaces[gstack][s][t].Severity[sev]) { entry = (struct gl_debug_severity *)node; set_message_state(ctx, s, t, entry-ID, enabled); } @@
[Mesa-dev] [PATCH 05/15] mesa: make _mesa_lookup_arrayobj() non-static
Signed-off-by: Timothy Arceri t_arc...@yahoo.com.au --- src/mesa/main/arrayobj.c | 10 +- src/mesa/main/arrayobj.h |3 +++ 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/mesa/main/arrayobj.c b/src/mesa/main/arrayobj.c index 9226050..006a2ea 100644 --- a/src/mesa/main/arrayobj.c +++ b/src/mesa/main/arrayobj.c @@ -60,8 +60,8 @@ * non-existent. */ -static inline struct gl_array_object * -lookup_arrayobj(struct gl_context *ctx, GLuint id) +struct gl_array_object * +_mesa_lookup_arrayobj(struct gl_context *ctx, GLuint id) { if (id == 0) return NULL; @@ -353,7 +353,7 @@ bind_vertex_array(struct gl_context *ctx, GLuint id, GLboolean genRequired) } else { /* non-default array object */ - newObj = lookup_arrayobj(ctx, id); + newObj = _mesa_lookup_arrayobj(ctx, id); if (!newObj) { if (genRequired) { _mesa_error(ctx, GL_INVALID_OPERATION, glBindVertexArray(non-gen name)); @@ -439,7 +439,7 @@ _mesa_DeleteVertexArrays(GLsizei n, const GLuint *ids) } for (i = 0; i n; i++) { - struct gl_array_object *obj = lookup_arrayobj(ctx, ids[i]); + struct gl_array_object *obj = _mesa_lookup_arrayobj(ctx, ids[i]); if ( obj != NULL ) { ASSERT( obj-Name == ids[i] ); @@ -545,7 +545,7 @@ _mesa_IsVertexArray( GLuint id ) if (id == 0) return GL_FALSE; - obj = lookup_arrayobj(ctx, id); + obj = _mesa_lookup_arrayobj(ctx, id); if (obj == NULL) return GL_FALSE; diff --git a/src/mesa/main/arrayobj.h b/src/mesa/main/arrayobj.h index 6dee1af..492ef35 100644 --- a/src/mesa/main/arrayobj.h +++ b/src/mesa/main/arrayobj.h @@ -46,6 +46,9 @@ struct gl_context; */ extern struct gl_array_object * +_mesa_lookup_arrayobj(struct gl_context *ctx, GLuint id); + +extern struct gl_array_object * _mesa_new_array_object( struct gl_context *ctx, GLuint name ); extern void -- 1.7.9.5 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 06/15] mesa: make _mesa_lookup_list() non-static
Signed-off-by: Timothy Arceri t_arc...@yahoo.com.au --- src/mesa/main/dlist.c | 12 ++-- src/mesa/main/dlist.h |2 ++ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/mesa/main/dlist.c b/src/mesa/main/dlist.c index af2b468..a82436c 100644 --- a/src/mesa/main/dlist.c +++ b/src/mesa/main/dlist.c @@ -561,8 +561,8 @@ make_list(GLuint name, GLuint count) /** * Lookup function to just encapsulate casting. */ -static inline struct gl_display_list * -lookup_list(struct gl_context *ctx, GLuint list) +struct gl_display_list * +_mesa_lookup_list(struct gl_context *ctx, GLuint list) { return (struct gl_display_list *) _mesa_HashLookup(ctx-Shared-DisplayList, list); @@ -785,7 +785,7 @@ destroy_list(struct gl_context *ctx, GLuint list) if (list == 0) return; - dlist = lookup_list(ctx, list); + dlist = _mesa_lookup_list(ctx, list); if (!dlist) return; @@ -7278,7 +7278,7 @@ _mesa_compile_error(struct gl_context *ctx, GLenum error, const char *s) static GLboolean islist(struct gl_context *ctx, GLuint list) { - if (list 0 lookup_list(ctx, list)) { + if (list 0 _mesa_lookup_list(ctx, list)) { return GL_TRUE; } else { @@ -7314,7 +7314,7 @@ execute_list(struct gl_context *ctx, GLuint list) return; } - dlist = lookup_list(ctx, list); + dlist = _mesa_lookup_list(ctx, list); if (!dlist) return; @@ -9309,7 +9309,7 @@ print_list(struct gl_context *ctx, GLuint list) return; } - dlist = lookup_list(ctx, list); + dlist = _mesa_lookup_list(ctx, list); if (!dlist) return; diff --git a/src/mesa/main/dlist.h b/src/mesa/main/dlist.h index cd0b523..7726e77 100644 --- a/src/mesa/main/dlist.h +++ b/src/mesa/main/dlist.h @@ -53,6 +53,8 @@ _mesa_CallLists( GLsizei n, GLenum type, const GLvoid *lists ); void GLAPIENTRY _mesa_ListBase(GLuint base); +extern struct gl_display_list * +_mesa_lookup_list(struct gl_context *ctx, GLuint list); extern void _mesa_compile_error( struct gl_context *ctx, GLenum error, const char *s ); -- 1.7.9.5 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 07/15] mesa: add debug Label field to several data structures
Signed-off-by: Timothy Arceri t_arc...@yahoo.com.au --- src/mesa/main/mtypes.h | 12 1 file changed, 12 insertions(+) diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index bd3560a..2277b95 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -1128,6 +1128,7 @@ struct gl_sampler_object { GLuint Name; GLint RefCount; + GLchar *Label; /** GL_KHR_debug */ GLenum WrapS; /** S-axis texture image wrap mode */ GLenum WrapT; /** T-axis texture image wrap mode */ @@ -1155,6 +1156,7 @@ struct gl_texture_object _glthread_Mutex Mutex; /** for thread safety */ GLint RefCount; /** reference count */ GLuint Name;/** the user-visible texture object ID */ + GLchar *Label; /** GL_KHR_debug */ GLenum Target; /** GL_TEXTURE_1D, GL_TEXTURE_2D, etc. */ struct gl_sampler_object Sampler; @@ -1403,6 +1405,7 @@ struct gl_buffer_object _glthread_Mutex Mutex; GLint RefCount; GLuint Name; + GLchar *Label; /** GL_KHR_debug */ GLenum Usage;/** GL_STREAM_DRAW_ARB, GL_STREAM_READ_ARB, etc. */ GLsizeiptrARB Size; /** Size of buffer storage in bytes */ GLubyte *Data; /** Location of storage either in RAM or VRAM. */ @@ -1467,6 +1470,7 @@ struct gl_array_object { /** Name of the array object as received from glGenVertexArrayAPPLE. */ GLuint Name; + GLchar *Label; /** GL_KHR_debug */ GLint RefCount; _glthread_Mutex Mutex; @@ -1704,6 +1708,7 @@ struct gl_transform_feedback_info struct gl_transform_feedback_object { GLuint Name; /** AKA the object ID */ + GLchar *Label; /** GL_KHR_debug */ GLint RefCount; GLboolean Active; /** Is transform feedback enabled? */ GLboolean Paused; /** Is transform feedback paused? */ @@ -2108,6 +2113,7 @@ struct gl_shader */ GLenum Type; GLuint Name; /** AKA the handle */ + GLchar *Label; /** GL_KHR_debug */ GLint RefCount; /** Reference count */ GLboolean DeletePending; GLboolean CompileStatus; @@ -2279,6 +2285,7 @@ struct gl_shader_program { GLenum Type; /** Always GL_SHADER_PROGRAM (internal token) */ GLuint Name; /** aka handle or ID */ + GLchar *Label; /** GL_KHR_debug */ GLint RefCount; /** Reference count */ GLboolean DeletePending; @@ -2515,6 +2522,7 @@ struct gl_query_object { GLenum Target; /** The query target, when active */ GLuint Id; /** hash table ID/name */ + GLchar *Label; /** GL_KHR_debug */ GLuint64EXT Result; /** the counter */ GLboolean Active; /** inside Begin/EndQuery */ GLboolean Ready;/** result is ready? */ @@ -2550,6 +2558,7 @@ struct gl_sync_object { GLenum Type; /** GL_SYNC_FENCE */ GLuint Name; /** Fence name */ + GLchar *Label; /** GL_KHR_debug */ GLint RefCount;/** Reference count */ GLboolean DeletePending; /** Object was deleted while there were still * live references (e.g., sync not yet finished) @@ -2632,6 +2641,7 @@ struct gl_renderbuffer _glthread_Mutex Mutex; /** for thread safety */ GLuint ClassID;/** Useful for drivers */ GLuint Name; + GLchar *Label; /** GL_KHR_debug */ GLint RefCount; GLuint Width, Height; GLuint Depth; @@ -2715,6 +2725,7 @@ struct gl_framebuffer * polygon face orientation, and polygon stipple will have to be inverted. */ GLuint Name; + GLchar *Label; /** GL_KHR_debug */ GLint RefCount; GLboolean DeletePending; @@ -3280,6 +3291,7 @@ union gl_dlist_node; struct gl_display_list { GLuint Name; + GLchar *Label; /** GL_KHR_debug */ GLbitfield Flags; /** DLIST_x flags */ /** The dlist commands are in a linked list of nodes */ union gl_dlist_node *Head; -- 1.7.9.5 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 08/15] mesa: free object labels when deleting
Signed-off-by: Timothy Arceri t_arc...@yahoo.com.au --- src/mesa/main/arrayobj.c |1 + src/mesa/main/bufferobj.c|1 + src/mesa/main/dlist.c|1 + src/mesa/main/framebuffer.c |1 + src/mesa/main/queryobj.c |1 + src/mesa/main/renderbuffer.c |1 + src/mesa/main/samplerobj.c |1 + src/mesa/main/shaderobj.c|3 +++ src/mesa/main/syncobj.c |1 + src/mesa/main/texobj.c |2 ++ src/mesa/main/transformfeedback.c|1 + src/mesa/state_tracker/st_cb_bufferobjects.c |1 + src/mesa/state_tracker/st_cb_syncobj.c |1 + 13 files changed, 16 insertions(+) diff --git a/src/mesa/main/arrayobj.c b/src/mesa/main/arrayobj.c index 006a2ea..5d50d29 100644 --- a/src/mesa/main/arrayobj.c +++ b/src/mesa/main/arrayobj.c @@ -115,6 +115,7 @@ _mesa_delete_array_object( struct gl_context *ctx, struct gl_array_object *obj ) unbind_array_object_vbos(ctx, obj); _mesa_reference_buffer_object(ctx, obj-ElementArrayBufferObj, NULL); _glthread_DESTROY_MUTEX(obj-Mutex); + free(obj-Label); free(obj); } diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c index bd71688..b22340f 100644 --- a/src/mesa/main/bufferobj.c +++ b/src/mesa/main/bufferobj.c @@ -265,6 +265,7 @@ _mesa_delete_buffer_object(struct gl_context *ctx, bufObj-Name = ~0; _glthread_DESTROY_MUTEX(bufObj-Mutex); + free(bufObj-Label); free(bufObj); } diff --git a/src/mesa/main/dlist.c b/src/mesa/main/dlist.c index a82436c..5956419 100644 --- a/src/mesa/main/dlist.c +++ b/src/mesa/main/dlist.c @@ -769,6 +769,7 @@ _mesa_delete_list(struct gl_context *ctx, struct gl_display_list *dlist) } } + free(dlist-Label); free(dlist); } diff --git a/src/mesa/main/framebuffer.c b/src/mesa/main/framebuffer.c index 4ec4118..2fad458 100644 --- a/src/mesa/main/framebuffer.c +++ b/src/mesa/main/framebuffer.c @@ -195,6 +195,7 @@ _mesa_destroy_framebuffer(struct gl_framebuffer *fb) { if (fb) { _mesa_free_framebuffer_data(fb); + free(fb-Label); free(fb); } } diff --git a/src/mesa/main/queryobj.c b/src/mesa/main/queryobj.c index 60356b8..6b636f4 100644 --- a/src/mesa/main/queryobj.c +++ b/src/mesa/main/queryobj.c @@ -126,6 +126,7 @@ _mesa_check_query(struct gl_context *ctx, struct gl_query_object *q) static void _mesa_delete_query(struct gl_context *ctx, struct gl_query_object *q) { + free(q-Label); free(q); } diff --git a/src/mesa/main/renderbuffer.c b/src/mesa/main/renderbuffer.c index d2bde80..2ff96e5 100644 --- a/src/mesa/main/renderbuffer.c +++ b/src/mesa/main/renderbuffer.c @@ -84,6 +84,7 @@ void _mesa_delete_renderbuffer(struct gl_context *ctx, struct gl_renderbuffer *rb) { _glthread_DESTROY_MUTEX(rb-Mutex); + free(rb-Label); free(rb); } diff --git a/src/mesa/main/samplerobj.c b/src/mesa/main/samplerobj.c index 3857eda..39cfcd0 100644 --- a/src/mesa/main/samplerobj.c +++ b/src/mesa/main/samplerobj.c @@ -155,6 +155,7 @@ static void _mesa_delete_sampler_object(struct gl_context *ctx, struct gl_sampler_object *sampObj) { + free(sampObj-Label); free(sampObj); } diff --git a/src/mesa/main/shaderobj.c b/src/mesa/main/shaderobj.c index a62ad04..0d794ad 100644 --- a/src/mesa/main/shaderobj.c +++ b/src/mesa/main/shaderobj.c @@ -125,6 +125,7 @@ static void _mesa_delete_shader(struct gl_context *ctx, struct gl_shader *sh) { free((void *)sh-Source); + free(sh-Label); _mesa_reference_program(ctx, sh-Program, NULL); ralloc_free(sh); } @@ -351,6 +352,8 @@ _mesa_free_shader_program_data(struct gl_context *ctx, shProg-_LinkedShaders[sh] = NULL; } } + + free(shProg-Label); } diff --git a/src/mesa/main/syncobj.c b/src/mesa/main/syncobj.c index c8d25cd..e426474 100644 --- a/src/mesa/main/syncobj.c +++ b/src/mesa/main/syncobj.c @@ -83,6 +83,7 @@ static void _mesa_delete_sync_object(struct gl_context *ctx, struct gl_sync_object *syncObj) { (void) ctx; + free(syncObj-Label); free(syncObj); } diff --git a/src/mesa/main/texobj.c b/src/mesa/main/texobj.c index 7c8f04d..cc2c786 100644 --- a/src/mesa/main/texobj.c +++ b/src/mesa/main/texobj.c @@ -238,6 +238,8 @@ _mesa_delete_texture_object(struct gl_context *ctx, /* destroy the mutex -- it may have allocated memory (eg on bsd) */ _glthread_DESTROY_MUTEX(texObj-Mutex); + free(texObj-Label); + /* free this object */ free(texObj); } diff --git a/src/mesa/main/transformfeedback.c b/src/mesa/main/transformfeedback.c index 03f1883..3f8a7f4 100644 --- a/src/mesa/main/transformfeedback.c +++ b/src/mesa/main/transformfeedback.c @@ -195,6 +195,7 @@ delete_transform_feedback(struct gl_context *ctx, _mesa_reference_buffer_object(ctx, obj-Buffers[i], NULL); } +
[Mesa-dev] [PATCH 09/15] mesa: make _mesa_validate_sync() non-static
Signed-off-by: Timothy Arceri t_arc...@yahoo.com.au --- src/mesa/main/syncobj.c |2 +- src/mesa/main/syncobj.h |3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/mesa/main/syncobj.c b/src/mesa/main/syncobj.c index e426474..92c7cb0 100644 --- a/src/mesa/main/syncobj.c +++ b/src/mesa/main/syncobj.c @@ -161,7 +161,7 @@ _mesa_free_sync_data(struct gl_context *ctx) } -static int +int _mesa_validate_sync(struct gl_context *ctx, struct gl_sync_object *syncObj) { return (syncObj != NULL) diff --git a/src/mesa/main/syncobj.h b/src/mesa/main/syncobj.h index faa3f55..025a9b1 100644 --- a/src/mesa/main/syncobj.h +++ b/src/mesa/main/syncobj.h @@ -53,6 +53,9 @@ _mesa_ref_sync_object(struct gl_context *ctx, struct gl_sync_object *syncObj); extern void _mesa_unref_sync_object(struct gl_context *ctx, struct gl_sync_object *syncObj); +extern int +_mesa_validate_sync(struct gl_context *ctx, struct gl_sync_object *syncObj); + extern GLboolean GLAPIENTRY _mesa_IsSync(GLsync sync); -- 1.7.9.5 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 10/15] mesa: Implement KHR_debug ObjectLabel functions
Signed-off-by: Timothy Arceri t_arc...@yahoo.com.au --- src/mesa/main/objectlabel.c | 277 +++ src/mesa/main/objectlabel.h | 61 ++ 2 files changed, 338 insertions(+) create mode 100644 src/mesa/main/objectlabel.c create mode 100644 src/mesa/main/objectlabel.h diff --git a/src/mesa/main/objectlabel.c b/src/mesa/main/objectlabel.c new file mode 100644 index 000..78f9b33 --- /dev/null +++ b/src/mesa/main/objectlabel.c @@ -0,0 +1,277 @@ +/* + * Mesa 3-D graphics library + * + * Copyright (C) 2013 Timothy Arceri All Rights Reserved. + * + * 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 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 arrayobj.h +#include bufferobj.h +#include context.h +#include dlist.h +#include enums.h +#include fbobject.h +#include objectlabel.h +#include queryobj.h +#include samplerobj.h +#include shaderobj.h +#include syncobj.h +#include texobj.h +#include transformfeedback.h + + +/** + * Helper for _mesa_ObjectLabel() and _mesa_ObjectPtrLabel(). + */ +static void +set_label(struct gl_context *ctx, char **labelPtr, const char *label, + int length, const char *caller) +{ + if (*labelPtr) { + /* free old label string */ + free(*labelPtr); + } + + if (label) { + /* set new label string */ + + if (length = 0) { + /* explicit length */ + *labelPtr = (char *) malloc(length); + if (*labelPtr) { +memcpy(*labelPtr, label, length); + } + } + else { + /* null-terminated string */ + int len = strlen(label); + if (len = MAX_LABEL_LENGTH) { +/* An INVALID_VALUE error is generated if the number of characters + * in label, excluding the null terminator when length is + * negative, is not less than the value of MAX_LABEL_LENGTH. + */ +_mesa_error(ctx, GL_INVALID_VALUE, +%s(length=%d, which is not less than +GL_MAX_LABEL_LENGTH=%d), caller, length, +MAX_LABEL_LENGTH); +return; + } + *labelPtr = _mesa_strdup(label); + } + } +} + +/** + * Helper for _mesa_GetObjectLabel() and _mesa_GetObjectPtrLabel(). + */ +static void +copy_label(char **labelPtr, char *label, int *length, int bufSize) +{ + int labelLen = 0; + + if (*labelPtr) + labelLen = strlen(*labelPtr); + + if (label) { + if (bufSize = labelLen) + labelLen = bufSize-1; + + memcpy(label, *labelPtr, labelLen); + label[labelLen] = '\0'; + } + + if (length) + *length = labelLen; +} + +/** + * Helper for _mesa_ObjectLabel() and _mesa_GetObjectLabel(). + */ +static char ** +get_label_pointer(struct gl_context *ctx, GLenum identifier, GLuint name, + const char *caller) +{ + char **labelPtr = NULL; + + switch (identifier) { + case GL_BUFFER: + { + struct gl_buffer_object *bufObj = _mesa_lookup_bufferobj(ctx, name); + if (bufObj) +labelPtr = bufObj-Label; + } + break; + case GL_SHADER: + { + struct gl_shader *shader = _mesa_lookup_shader(ctx, name); + if (shader) +labelPtr = shader-Label; + } + break; + case GL_PROGRAM: + { + struct gl_shader_program *program = +_mesa_lookup_shader_program(ctx, name); + if (program) +labelPtr = program-Label; + } + break; + case GL_VERTEX_ARRAY: + { + struct gl_array_object *obj = _mesa_lookup_arrayobj(ctx, name); + if (obj) +labelPtr = obj-Label; + } + break; + case GL_QUERY: + { + struct gl_query_object *query = _mesa_lookup_query_object(ctx, name); + if (query) +labelPtr = query-Label; + } + break; + case GL_TRANSFORM_FEEDBACK: + { + struct gl_transform_feedback_object *tfo = +
[Mesa-dev] [PATCH 11/15] mesa: Update builds scripts to build object labels
Signed-off-by: Timothy Arceri t_arc...@yahoo.com.au --- src/mesa/Makefile.sources |1 + src/mesa/SConscript |1 + 2 files changed, 2 insertions(+) diff --git a/src/mesa/Makefile.sources b/src/mesa/Makefile.sources index a5c1f5d..122ea8e 100644 --- a/src/mesa/Makefile.sources +++ b/src/mesa/Makefile.sources @@ -62,6 +62,7 @@ MAIN_FILES = \ $(SRCDIR)main/mipmap.c \ $(SRCDIR)main/mm.c \ $(SRCDIR)main/multisample.c \ +$(SRCDIR)main/objectlabel.c \ $(SRCDIR)main/pack.c \ $(SRCDIR)main/pbo.c \ $(SRCDIR)main/pixel.c \ diff --git a/src/mesa/SConscript b/src/mesa/SConscript index d328fc1..2cdb79c 100644 --- a/src/mesa/SConscript +++ b/src/mesa/SConscript @@ -94,6 +94,7 @@ main_sources = [ 'main/mipmap.c', 'main/mm.c', 'main/multisample.c', +'main/objectlabel.c', 'main/pack.c', 'main/pbo.c', 'main/pixel.c', -- 1.7.9.5 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 12/15] mesa: Implement GL_DEBUG_OUTPUT
Signed-off-by: Timothy Arceri t_arc...@yahoo.com.au --- src/mesa/drivers/dri/i965/brw_context.c |2 ++ src/mesa/main/enable.c |9 + src/mesa/main/errors.c |3 +++ src/mesa/main/mtypes.h |1 + src/mesa/state_tracker/st_manager.c |6 +- 5 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c index 6308446..536d204 100644 --- a/src/mesa/drivers/dri/i965/brw_context.c +++ b/src/mesa/drivers/dri/i965/brw_context.c @@ -468,8 +468,10 @@ brwCreateContext(int api, if ((flags __DRI_CTX_FLAG_FORWARD_COMPATIBLE) != 0) ctx-Const.ContextFlags |= GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT; + ctx-Debug.DebugOutput = GL_FALSE; if ((flags __DRI_CTX_FLAG_DEBUG) != 0) { ctx-Const.ContextFlags |= GL_CONTEXT_FLAG_DEBUG_BIT; + ctx-Debug.DebugOutput = GL_TRUE; /* Turn on some extra GL_ARB_debug_output generation. */ brw-perf_debug = true; diff --git a/src/mesa/main/enable.c b/src/mesa/main/enable.c index 21e5931..5e2fd80 100644 --- a/src/mesa/main/enable.c +++ b/src/mesa/main/enable.c @@ -364,6 +364,11 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state) FLUSH_VERTICES(ctx, _NEW_DEPTH); ctx-Depth.Test = state; break; + case GL_DEBUG_OUTPUT: + if (!_mesa_is_desktop_gl(ctx)) +goto invalid_enum_error; + ctx-Debug.DebugOutput = state; + break; case GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB: if (!_mesa_is_desktop_gl(ctx)) goto invalid_enum_error; @@ -1201,6 +1206,10 @@ _mesa_IsEnabled( GLenum cap ) return ctx-Light.ColorMaterialEnabled; case GL_CULL_FACE: return ctx-Polygon.CullFlag; + case GL_DEBUG_OUTPUT: + if (!_mesa_is_desktop_gl(ctx)) +goto invalid_enum_error; + return ctx-Debug.DebugOutput; case GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB: if (!_mesa_is_desktop_gl(ctx)) goto invalid_enum_error; diff --git a/src/mesa/main/errors.c b/src/mesa/main/errors.c index dbad585..6e877e3 100644 --- a/src/mesa/main/errors.c +++ b/src/mesa/main/errors.c @@ -194,6 +194,9 @@ should_log(struct gl_context *ctx, ctx-Debug.Namespaces[gstack][source][type]; uintptr_t state; + if (!ctx-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) diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 2277b95..b15394f 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -3391,6 +3391,7 @@ struct gl_debug_state GLDEBUGPROC Callback; const void *CallbackData; GLboolean SyncOutput; + GLboolean DebugOutput; GLboolean Defaults[MAX_DEBUG_GROUP_STACK_DEPTH][MESA_DEBUG_SEVERITY_COUNT][MESA_DEBUG_SOURCE_COUNT][MESA_DEBUG_TYPE_COUNT]; struct gl_debug_namespace Namespaces[MAX_DEBUG_GROUP_STACK_DEPTH][MESA_DEBUG_SOURCE_COUNT][MESA_DEBUG_TYPE_COUNT]; struct gl_debug_msg Log[MAX_DEBUG_LOGGED_MESSAGES]; diff --git a/src/mesa/state_tracker/st_manager.c b/src/mesa/state_tracker/st_manager.c index 9c2b4d2..098e6c0 100644 --- a/src/mesa/state_tracker/st_manager.c +++ b/src/mesa/state_tracker/st_manager.c @@ -626,8 +626,12 @@ st_api_create_context(struct st_api *stapi, struct st_manager *smapi, return NULL; } - if (attribs-flags ST_CONTEXT_FLAG_DEBUG) + st-ctx-Debug.DebugOutput = GL_FALSE; + if (attribs-flags ST_CONTEXT_FLAG_DEBUG){ st-ctx-Const.ContextFlags |= GL_CONTEXT_FLAG_DEBUG_BIT; + st-ctx-Debug.DebugOutput = GL_TRUE; + } + if (attribs-flags ST_CONTEXT_FLAG_FORWARD_COMPATIBLE) st-ctx-Const.ContextFlags |= GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT; -- 1.7.9.5 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 13/15] mesa: Remap debug type and severity
Remap any type or severity exclusive to KHR_debug to something suitable for ARB_debug_output Signed-off-by: Timothy Arceri t_arc...@yahoo.com.au --- src/mesa/main/errors.c | 65 ++-- src/mesa/main/mtypes.h |1 + 2 files changed, 58 insertions(+), 8 deletions(-) diff --git a/src/mesa/main/errors.c b/src/mesa/main/errors.c index 6e877e3..83033dc 100644 --- a/src/mesa/main/errors.c +++ b/src/mesa/main/errors.c @@ -39,6 +39,9 @@ #include hash_table.h #include glapi/glthread.h +#define MESSAGE_LOG 1 +#define MESSAGE_LOG_ARB 2 + _glthread_DECLARE_STATIC_MUTEX(DynamicIDMutex); static GLuint NextDynamicID = 1; @@ -304,6 +307,38 @@ store_message_details(struct gl_debug_msg *emptySlot, } } + /** + * Remap any type exclusive to KHR_debug to something suitable + * for ARB_debug_output + */ +inline static int +remap_type(GLenum type) { + + switch(type) { + case GL_DEBUG_TYPE_MARKER: + case GL_DEBUG_TYPE_PUSH_GROUP: + case GL_DEBUG_TYPE_POP_GROUP: + type = GL_DEBUG_TYPE_OTHER; + default: + ; + } + + return type; +} + +/** + * Remap severity exclusive to KHR_debug to something suitable + * for ARB_debug_output + */ +inline static int +remap_severity(GLenum severity) { + + if (GL_DEBUG_SEVERITY_NOTIFICATION == severity) + severity = GL_DEBUG_SEVERITY_LOW; + + return severity; +} + /** * 'buf' is not necessarily a null-terminated string. When logging, copy * 'len' characters from it, store them in a new, null-terminated string, @@ -324,10 +359,17 @@ _mesa_log_msg(struct gl_context *ctx, enum mesa_debug_source source, return; if (ctx-Debug.Callback) { + GLenum gl_type = debug_type_enums[type]; + GLenum gl_severity = debug_severity_enums[severity]; + + if (ctx-Debug.ARBCallback) { + gl_severity = remap_severity(gl_severity); + gl_type = remap_type(gl_type); + } ctx-Debug.Callback(debug_source_enums[source], - debug_type_enums[type], + gl_type, id, - debug_severity_enums[severity], + gl_severity, len, buf, ctx-Debug.CallbackData); return; } @@ -359,7 +401,8 @@ _mesa_log_msg(struct gl_context *ctx, enum mesa_debug_source source, */ static GLsizei _mesa_get_msg(struct gl_context *ctx, GLenum *source, GLenum *type, - GLuint *id, GLenum *severity, GLsizei bufSize, char *buf) + GLuint *id, GLenum *severity, GLsizei bufSize, char *buf, + unsigned caller) { struct gl_debug_msg *msg; GLsizei length; @@ -375,12 +418,18 @@ _mesa_get_msg(struct gl_context *ctx, GLenum *source, GLenum *type, if (bufSize length buf != NULL) return 0; - if (severity) + if (severity) { *severity = debug_severity_enums[msg-severity]; + if (caller == MESSAGE_LOG_ARB) + *severity = remap_severity(*severity); + } if (source) *source = debug_source_enums[msg-source]; - if (type) + if (type) { *type = debug_type_enums[msg-type]; + if (caller == MESSAGE_LOG_ARB) + *type = remap_type(*type); + } if (id) *id = msg-id; @@ -648,8 +697,6 @@ get_message_log(GLuint count, GLsizei logSize, GLenum* sources, GLsizei* lengths, GLchar* messageLog, unsigned caller, const char *callerstr) { -#define MESSAGE_LOG 1 -#define MESSAGE_LOG_ARB 2 GET_CURRENT_CONTEXT(ctx); GLuint ret; @@ -665,7 +712,7 @@ get_message_log(GLuint count, GLsizei logSize, GLenum* sources, for (ret = 0; ret count; ret++) { GLsizei written = _mesa_get_msg(ctx, sources, types, ids, severities, - logSize, messageLog); + logSize, messageLog, caller); if (!written) break; @@ -766,6 +813,7 @@ _mesa_DebugMessageCallback(GLDEBUGPROC callback, const void *userParam) GET_CURRENT_CONTEXT(ctx); ctx-Debug.Callback = callback; ctx-Debug.CallbackData = userParam; + ctx-Debug.ARBCallback = GL_FALSE; } void GLAPIENTRY @@ -925,6 +973,7 @@ _mesa_DebugMessageCallbackARB(GLDEBUGPROCARB callback, const void *userParam) GET_CURRENT_CONTEXT(ctx); ctx-Debug.Callback = callback; ctx-Debug.CallbackData = userParam; + ctx-Debug.ARBCallback = GL_TRUE; } void diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index b15394f..ee30cba 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -3392,6 +3392,7 @@ struct gl_debug_state const void *CallbackData; GLboolean SyncOutput; GLboolean DebugOutput; + GLboolean ARBCallback; /* Used to track if current callback is of type ARB_debug_output or KHR_debug */ GLboolean Defaults[MAX_DEBUG_GROUP_STACK_DEPTH][MESA_DEBUG_SEVERITY_COUNT][MESA_DEBUG_SOURCE_COUNT][MESA_DEBUG_TYPE_COUNT]; struct
[Mesa-dev] [PATCH 15/15] mesa: Setup remaining infrastucture and enable KHR_debug
Signed-off-by: Timothy Arceri t_arc...@yahoo.com.au --- src/mesa/main/extensions.c |3 +++ src/mesa/main/get_hash_params.py | 14 +- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c index 1a040ee..f60157f 100644 --- a/src/mesa/main/extensions.c +++ b/src/mesa/main/extensions.c @@ -283,6 +283,9 @@ static const struct extension extension_table[] = { { GL_OES_texture_npot, o(ARB_texture_non_power_of_two), ES1 | ES2, 2005 }, { GL_OES_vertex_array_object, o(dummy_true), ES1 | ES2, 2010 }, + /* KHR extensions */ + { GL_KHR_debug, o(dummy_true), GL, 2012 }, + /* Vendor extensions */ { GL_3DFX_texture_compression_FXT1, o(TDFX_texture_compression_FXT1), GL, 1999 }, { GL_AMD_conservative_depth, o(ARB_conservative_depth), GL, 2009 }, diff --git a/src/mesa/main/get_hash_params.py b/src/mesa/main/get_hash_params.py index fde4537..30855c3 100644 --- a/src/mesa/main/get_hash_params.py +++ b/src/mesa/main/get_hash_params.py @@ -695,11 +695,15 @@ descriptor=[ # GL_ARB_robustness [ RESET_NOTIFICATION_STRATEGY_ARB, CONTEXT_ENUM(Const.ResetStrategy), NO_EXTRA ], -# GL_ARB_debug_output - [ DEBUG_LOGGED_MESSAGES_ARB, CONTEXT_INT(Debug.NumMessages), NO_EXTRA ], - [ DEBUG_NEXT_LOGGED_MESSAGE_LENGTH_ARB, CONTEXT_INT(Debug.NextMsgLength), NO_EXTRA ], - [ MAX_DEBUG_LOGGED_MESSAGES_ARB, CONST(MAX_DEBUG_LOGGED_MESSAGES), NO_EXTRA ], - [ MAX_DEBUG_MESSAGE_LENGTH_ARB, CONST(MAX_DEBUG_MESSAGE_LENGTH), NO_EXTRA ], +# GL_KHR_debug (GL 4.3)/ GL_ARB_debug_output + [ DEBUG_LOGGED_MESSAGES, CONTEXT_INT(Debug.NumMessages), NO_EXTRA ], + [ DEBUG_NEXT_LOGGED_MESSAGE_LENGTH, CONTEXT_INT(Debug.NextMsgLength), NO_EXTRA ], + [ MAX_DEBUG_LOGGED_MESSAGES, CONST(MAX_DEBUG_LOGGED_MESSAGES), NO_EXTRA ], + [ MAX_DEBUG_MESSAGE_LENGTH, CONST(MAX_DEBUG_MESSAGE_LENGTH), NO_EXTRA ], + [ MAX_LABEL_LENGTH, CONST(MAX_LABEL_LENGTH), NO_EXTRA ], + [ MAX_DEBUG_GROUP_STACK_DEPTH, CONST(MAX_DEBUG_GROUP_STACK_DEPTH), NO_EXTRA ], + [ DEBUG_GROUP_STACK_DEPTH, CONTEXT_INT(Debug.GroupStackDepth), NO_EXTRA ], + [ MAX_DUAL_SOURCE_DRAW_BUFFERS, CONTEXT_INT(Const.MaxDualSourceDrawBuffers), extra_ARB_blend_func_extended ], # GL_ARB_uniform_buffer_object -- 1.7.9.5 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 14/15] glapi: Setup autogeneration infrastructure for KHR_debug
Signed-off-by: Timothy Arceri t_arc...@yahoo.com.au --- src/mapi/glapi/gen/gl_API.xml| 149 +- src/mapi/glapi/gen/gl_genexec.py |1 + 2 files changed, 149 insertions(+), 1 deletion(-) diff --git a/src/mapi/glapi/gen/gl_API.xml b/src/mapi/glapi/gen/gl_API.xml index 82b908f..71aa9a7 100644 --- a/src/mapi/glapi/gen/gl_API.xml +++ b/src/mapi/glapi/gen/gl_API.xml @@ -1107,6 +1107,7 @@ type name=voidsize=1/ type name=DEBUGPROCARB size=4 pointer=true/ +type name=DEBUGPROC size=4 pointer=true/ function name=NewList offset=0 deprecated=3.1 param name=list type=GLuint/ @@ -8309,7 +8310,153 @@ xi:include href=ARB_texture_storage.xml xmlns:xi=http://www.w3.org/2001/XInclude/ -!-- ARB extensions #118...#126 -- +!-- ARB extension #118 -- + +category name=GL_KHR_debug number=119 + enum name=DEBUG_OUTPUT value=0x92E0/ + enum name=DEBUG_OUTPUT_SYNCHRONOUS value=0x8242/ + + enum name=CONTEXT_FLAG_DEBUG_BIT value=0x0002/ + + enum name=MAX_DEBUG_MESSAGE_LENGTH count=1 value=0x9143 +size name=Get mode=get/ + /enum + enum name=MAX_DEBUG_LOGGED_MESSAGES count=1value=0x9144 +size name=Get mode=get/ + /enum + enum name=DEBUG_LOGGED_MESSAGES count=1value=0x9145 +size name=Get mode=get/ + /enum + enum name=DEBUG_NEXT_LOGGED_MESSAGE_LENGTH count=1 value=0x8243 +size name=Get mode=get/ + /enum + enum name=MAX_DEBUG_GROUP_STACK_DEPTH count=1 value=0x826C +size name=Get mode=get/ + /enum + enum name=DEBUG_GROUP_STACK_DEPTH count=1 value=0x826D +size name=Get mode=get/ + /enum + enum name=MAX_LABEL_LENGTH count=1 value=0x82E8 +size name=Get mode=get/ + /enum + + enum name=DEBUG_CALLBACK_FUNCTION count=1 value=0x8244 + size name=GetPointerv mode=get/ + /enum + enum name=DEBUG_CALLBACK_USER_PARAM count=1value=0x8245 +size name=GetPointerv mode=get/ + /enum + + enum name=DEBUG_SOURCE_API value=0x8246/ + enum name=DEBUG_SOURCE_WINDOW_SYSTEM value=0x8247/ + enum name=DEBUG_SOURCE_SHADER_COMPILER value=0x8248/ + enum name=DEBUG_SOURCE_THIRD_PARTY value=0x8249/ + enum name=DEBUG_SOURCE_APPLICATION value=0x824A/ + enum name=DEBUG_SOURCE_OTHER value=0x824B/ + + enum name=DEBUG_TYPE_ERROR value=0x824C/ + enum name=DEBUG_TYPE_DEPRECATED_BEHAVIOR value=0x824D/ + enum name=DEBUG_TYPE_UNDEFINED_BEHAVIOR value=0x824E/ + enum name=DEBUG_TYPE_PORTABILITY value=0x824F/ + enum name=DEBUG_TYPE_PERFORMANCE value=0x8250/ + enum name=DEBUG_TYPE_OTHER value=0x8251/ + enum name=DEBUG_TYPE_MARKER value=0x8268/ + + enum name=DEBUG_TYPE_PUSH_GROUP value=0x8269/ + enum name=DEBUG_TYPE_POP_GROUP value=0x826A/ + + enum name=DEBUG_SEVERITY_HIGHvalue=0x9146/ + enum name=DEBUG_SEVERITY_MEDIUM value=0x9147/ + enum name=DEBUG_SEVERITY_LOW value=0x9148/ + enum name=DEBUG_SEVERITY_NOTIFICATIONvalue=0x826B/ + + enum name=STACK_UNDERFLOWvalue=0x0504/ + enum name=STACK_OVERFLOW value=0x0503/ + + enum name=BUFFER value=0x82E0/ + enum name=SHADER value=0x82E1/ + enum name=PROGRAMvalue=0x82E2/ + enum name=QUERY value=0x82E3/ + enum name=PROGRAM_PIPELINE value=0x82E4/ + enum name=SAMPLERvalue=0x82E6/ + !-- Compatibility Profile -- + enum name=DISPLAY_LIST value=0x82E7/ + + function name=DebugMessageControl offset=assign +param name=source type=GLenum/ +param name=type type=GLenum/ +param name=severity type=GLenum/ +param name=count type=GLsizei counter=true/ +param name=ids type=const GLuint * count=count/ +param name=enabled type=GLboolean/ + /function + + function name=DebugMessageInsert offset=assign +param name=source type=GLenum/ +param name=type type=GLenum/ +param name=id type=GLuint/ +param name=severity type=GLenum/ +param name=length type=GLsizei/ +param name=buf type=const GLchar */ + /function + + function name=DebugMessageCallback offset=assign +param name=callback type=GLDEBUGPROC/ +param name=userParam type=const GLvoid */ + /function + + function name=GetDebugMessageLog offset=assign +return type=GLuint/ +param name=count type=GLuint/ +param name=bufsize type=GLsizei/ +param name=sources type=GLenum *
[Mesa-dev] [Bug 67046] [radeonsi] pixmark_piano benchmark from geeks3D gputest fail with a llvm error output
https://bugs.freedesktop.org/show_bug.cgi?id=67046 Michel Dänzer mic...@daenzer.net changed: What|Removed |Added CC||arek.r...@gmail.com --- Comment #4 from Michel Dänzer mic...@daenzer.net --- *** Bug 68568 has been marked as a duplicate of this bug. *** -- 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] tgsi dump and parsing
On 08/26/2013 02:38 AM, Dave Airlie wrote: Hi TGSI guys mostly :-) So I'm wondering how circular and perfect tgsi-text-tgsi roundabouts should be, Ideally, they should be consistent. currently the TGSI dump code uses .4f in one place, which makes things like 1e6 not make it across the divide, I was thinking of dumping immediates in 32-bit hex format so we know for definite what happens on the other side, Yeah, I think we'd have to dump floats as hex to always preserve their value. However, I'd like to maintain the readability of float immediates in dumps. Maybe they could be displayed as a comment. Something like: IMM[0] FLT32 { 0x, 0x, 0x, 0x } # 1.0, 3.0, 2.0, 4.0 I've been thinking of maybe adding a debug option to softpipe to dump to text and read it back, to see what other regression lie in wait. Sounds OK to me but it could be a TGSI debug option that would test dumping + reassembling a shader whenever tgsi_dump() is called. -Brian ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 00/15] Implement KHR_debug
On 08/26/2013 04:43 AM, Timothy Arceri wrote: The following patchset implements the KHR_debug extension. The series looks good to me. Just a few minor comments to follow. Reviewed-by: Brian Paul bri...@vmware.com ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 03/15] mesa: Add a clone function to mesa hash
On 08/26/2013 04:43 AM, Timothy Arceri wrote: Signed-off-by: Timothy Arceri t_arc...@yahoo.com.au --- src/mesa/main/hash.c | 26 ++ src/mesa/main/hash.h |3 +++ 2 files changed, 29 insertions(+) diff --git a/src/mesa/main/hash.c b/src/mesa/main/hash.c index 6591af9..8dde8b1 100644 --- a/src/mesa/main/hash.c +++ b/src/mesa/main/hash.c @@ -302,6 +302,32 @@ _mesa_HashDeleteAll(struct _mesa_HashTable *table, /** + * Clone all entries in a hash table, into a new table. + * + * \param table the hash table to clone + */ +struct _mesa_HashTable * +_mesa_HashClone(struct _mesa_HashTable *table) Can that be const qualified? +{ + struct hash_entry *entry; + struct _mesa_HashTable *clonetable; + + ASSERT(table); + _glthread_LOCK_MUTEX(table-Mutex); + + clonetable = _mesa_NewHashTable(); + assert(clonetable); + hash_table_foreach(table-ht, entry) { + _mesa_HashInsert(clonetable, (GLint)(uintptr_t)entry-key, entry-data); + } + + _glthread_UNLOCK_MUTEX(table-Mutex); + + return clonetable; +} + + +/** * Walk over all entries in a hash table, calling callback function for each. * Note: we use a separate mutex in this function to avoid a recursive * locking deadlock (in case the callback calls _mesa_HashRemove()) and to diff --git a/src/mesa/main/hash.h b/src/mesa/main/hash.h index 142d284..9208701 100644 --- a/src/mesa/main/hash.h +++ b/src/mesa/main/hash.h @@ -50,6 +50,9 @@ _mesa_HashDeleteAll(struct _mesa_HashTable *table, void (*callback)(GLuint key, void *data, void *userData), void *userData); +extern struct _mesa_HashTable * +_mesa_HashClone(struct _mesa_HashTable *table); + extern void _mesa_HashWalk(const struct _mesa_HashTable *table, void (*callback)(GLuint key, void *data, void *userData), ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 04/15] mesa: Implement glPushDebugGroup and glPopDebugGroup
On 08/26/2013 04:43 AM, Timothy Arceri wrote: [...] @@ -722,13 +769,112 @@ void GLAPIENTRY _mesa_PushDebugGroup(GLenum source, GLuint id, GLsizei length, const GLchar *message) { + const char *callerstr = glPushDebugGroup; + int s, t, sev; + GLint prevStackDepth; + GLint currStackDepth; + struct gl_debug_msg *emptySlot; + GET_CURRENT_CONTEXT(ctx); + + if (ctx-Debug.GroupStackDepth = MAX_DEBUG_GROUP_STACK_DEPTH-1) { + _mesa_error( ctx, GL_STACK_OVERFLOW, callerstr ); + return; + } + + switch(source) { + case GL_DEBUG_SOURCE_APPLICATION: + case GL_DEBUG_SOURCE_THIRD_PARTY: + break; + default: + _mesa_error(ctx, GL_INVALID_ENUM, bad value passed to %s + (source=0x%x), callerstr, source); + return; + } + + message_insert(source, GL_DEBUG_TYPE_PUSH_GROUP, id, + GL_DEBUG_SEVERITY_NOTIFICATION, length, + message, callerstr); + + prevStackDepth = ctx-Debug.GroupStackDepth; + ctx-Debug.GroupStackDepth++; + currStackDepth = ctx-Debug.GroupStackDepth; + + /* pop reuses the message details from push so we store this */ + if (length 0) + length = strlen(message); + emptySlot = ctx-Debug.DebugGroupMsgs[ctx-Debug.GroupStackDepth]; + store_message_details(emptySlot, gl_enum_to_debug_source(source), + gl_enum_to_debug_source(GL_DEBUG_TYPE_PUSH_GROUP), + id, + 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 */ + ctx-Debug.Namespaces[currStackDepth][s][t].IDs = +_mesa_HashClone(ctx-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 */ +ctx-Debug.Defaults[currStackDepth][sev][s][t] = ctx-Debug.Defaults[prevStackDepth][sev][s][t]; + +/* copy know id severity settings */ s/know/known/ ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 10/15] mesa: Implement KHR_debug ObjectLabel functions
On 08/26/2013 04:43 AM, Timothy Arceri wrote: Signed-off-by: Timothy Arceri t_arc...@yahoo.com.au --- src/mesa/main/objectlabel.c | 277 +++ src/mesa/main/objectlabel.h | 61 ++ 2 files changed, 338 insertions(+) create mode 100644 src/mesa/main/objectlabel.c create mode 100644 src/mesa/main/objectlabel.h diff --git a/src/mesa/main/objectlabel.c b/src/mesa/main/objectlabel.c new file mode 100644 index 000..78f9b33 --- /dev/null +++ b/src/mesa/main/objectlabel.c @@ -0,0 +1,277 @@ +/* + * Mesa 3-D graphics library + * + * Copyright (C) 2013 Timothy Arceri All Rights Reserved. + * + * 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 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 arrayobj.h +#include bufferobj.h +#include context.h +#include dlist.h +#include enums.h +#include fbobject.h +#include objectlabel.h +#include queryobj.h +#include samplerobj.h +#include shaderobj.h +#include syncobj.h +#include texobj.h +#include transformfeedback.h + + +/** + * Helper for _mesa_ObjectLabel() and _mesa_ObjectPtrLabel(). + */ +static void +set_label(struct gl_context *ctx, char **labelPtr, const char *label, + int length, const char *caller) +{ + if (*labelPtr) { + /* free old label string */ + free(*labelPtr); + } + + if (label) { + /* set new label string */ Indentation ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 24/30] i965/gs: Support UBOs by generating surface state and binding tables.
On 22 August 2013 13:58, Kenneth Graunke kenn...@whitecape.org wrote: On 08/20/2013 11:30 AM, Paul Berry wrote: From: Eric Anholt e...@anholt.net All but two of the piglit GLSL 1.50/uniform_buffer tests work, and maxuniformblocksize and referenced-by-shader work. v2 (Paul Berry stereotype...@gmail.com): Account for Ken's recent binding table re-work. Use brw-vec4_gs.bind_bo_offset instead of brw-gs.bind_bo_offset. --- src/mesa/drivers/dri/i965/**Makefile.sources | 1 + src/mesa/drivers/dri/i965/brw_**context.h | 17 ++- src/mesa/drivers/dri/i965/brw_**gs_emit.c | 2 +- src/mesa/drivers/dri/i965/brw_**gs_surface_state.c | 182 +++ src/mesa/drivers/dri/i965/brw_**state.h| 3 + src/mesa/drivers/dri/i965/brw_**state_upload.c | 3 + src/mesa/drivers/dri/i965/**gen6_sol.c | 6 +- 7 files changed, 208 insertions(+), 6 deletions(-) create mode 100644 src/mesa/drivers/dri/i965/brw_**gs_surface_state.c diff --git a/src/mesa/drivers/dri/i965/**Makefile.sources b/src/mesa/drivers/dri/i965/**Makefile.sources index 290cd93..81a16ff 100644 --- a/src/mesa/drivers/dri/i965/**Makefile.sources +++ b/src/mesa/drivers/dri/i965/**Makefile.sources @@ -63,6 +63,7 @@ i965_FILES = \ brw_gs.c \ brw_gs_emit.c \ brw_gs_state.c \ + brw_gs_surface_state.c \ brw_interpolation_map.c \ brw_lower_texture_gradients.**cpp \ brw_misc_state.c \ diff --git a/src/mesa/drivers/dri/i965/**brw_context.h b/src/mesa/drivers/dri/i965/**brw_context.h index 4f6c767..a6d0786 100644 --- a/src/mesa/drivers/dri/i965/**brw_context.h +++ b/src/mesa/drivers/dri/i965/**brw_context.h @@ -148,6 +148,7 @@ enum brw_state_id { BRW_STATE_BATCH, BRW_STATE_INDEX_BUFFER, BRW_STATE_VS_CONSTBUF, + BRW_STATE_GS_CONSTBUF, BRW_STATE_PROGRAM_CACHE, BRW_STATE_STATE_BASE_ADDRESS, BRW_STATE_VUE_MAP_VS, @@ -184,6 +185,7 @@ enum brw_state_id { /** \see brw.state.depth_region */ #define BRW_NEW_INDEX_BUFFER (1 BRW_STATE_INDEX_BUFFER) #define BRW_NEW_VS_CONSTBUF(1 BRW_STATE_VS_CONSTBUF) +#define BRW_NEW_GS_CONSTBUF(1 BRW_STATE_GS_CONSTBUF) #define BRW_NEW_PROGRAM_CACHE (1 BRW_STATE_PROGRAM_CACHE) #define BRW_NEW_STATE_BASE_ADDRESS(1 BRW_STATE_STATE_BASE_ADDRESS) #define BRW_NEW_VUE_MAP_VS(1 BRW_STATE_VUE_MAP_VS) @@ -654,8 +656,19 @@ struct brw_vec4_gs_prog_data #define SURF_INDEX_VS_SHADER_TIME(SURF_INDEX_VS_UBO(12)) #define BRW_MAX_VS_SURFACES (SURF_INDEX_VS_SHADER_TIME + 1) -#define SURF_INDEX_SOL_BINDING(t)((t)) -#define BRW_MAX_GS_SURFACES SURF_INDEX_SOL_BINDING(BRW_** MAX_SOL_BINDINGS) +#define SURF_INDEX_GEN6_SOL_BINDING(t) (t) +#define BRW_MAX_GEN6_GS_SURFACES SURF_INDEX_GEN6_SOL_BINDING(** BRW_MAX_SOL_BINDINGS) It's not a big deal, but it would be nice to do the SURF_INDEX_SOL_BINDING renames in a separate patch. Good point. +#define SURF_INDEX_GS_GEN6_SOL_BUFFER 0 +#define SURF_INDEX_GS_CONST_BUFFER (SURF_INDEX_GS_GEN6_SOL_**BUFFER) + +#define SURF_INDEX_GS_TEXTURE(t) (SURF_INDEX_GS_CONST_BUFFER + 1 + (t)) +#define SURF_INDEX_GS_UBO(u) (SURF_INDEX_GS_TEXTURE(BRW_**MAX_TEX_UNIT) + u) +#define SURF_INDEX_GS_SHADER_TIME(SURF_INDEX_GS_UBO(12)) +#define BRW_MAX_GEN7_GS_SURFACES (SURF_INDEX_GS_SHADER_TIME + 1) + +#define BRW_MAX_GS_SURFACES MAX2(BRW_MAX_GEN6_GS_SURFACES, \ + BRW_MAX_GEN7_GS_SURFACES) /** * Stride in bytes between shader_time entries. diff --git a/src/mesa/drivers/dri/i965/**brw_gs_emit.c b/src/mesa/drivers/dri/i965/**brw_gs_emit.c index fff3585..f576a81 100644 --- a/src/mesa/drivers/dri/i965/**brw_gs_emit.c +++ b/src/mesa/drivers/dri/i965/**brw_gs_emit.c @@ -432,7 +432,7 @@ gen6_sol_program(struct brw_gs_compile *c, struct brw_gs_prog_key *key, final_write ? c-reg.temp : brw_null_reg(), /* dest */ 1, /* msg_reg_nr */ c-reg.header, /* src0 */ - SURF_INDEX_SOL_BINDING(**binding), /* binding_table_index */ + SURF_INDEX_GEN6_SOL_BINDING(**binding), /* binding_table_index */ final_write); /* send_commit_msg */ } } diff --git a/src/mesa/drivers/dri/i965/**brw_gs_surface_state.c b/src/mesa/drivers/dri/i965/**brw_gs_surface_state.c new file mode 100644 index 000..ed99d65 --- /dev/null +++ b/src/mesa/drivers/dri/i965/**brw_gs_surface_state.c @@ -0,0 +1,182 @@ +/* + * Copyright © 2013 Intel Corporation + * + * 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
Re: [Mesa-dev] [PATCH] i965: Don't try to fall back when creating unrecognized program targets.
On 23 August 2013 14:55, Kenneth Graunke kenn...@whitecape.org wrote: On 08/23/2013 11:50 AM, Paul Berry wrote: If brwNewProgram is asked to create a program for an unrecognized target, don't bother falling back on _mesa_new_program(). That just hides bugs. --- src/mesa/drivers/dri/i965/brw_**program.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/mesa/drivers/dri/i965/**brw_program.c b/src/mesa/drivers/dri/i965/**brw_program.c index c40d506..b683681 100644 --- a/src/mesa/drivers/dri/i965/**brw_program.c +++ b/src/mesa/drivers/dri/i965/**brw_program.c @@ -114,7 +114,8 @@ static struct gl_program *brwNewProgram( struct gl_context *ctx, } default: - return _mesa_new_program(ctx, target, id); + _mesa_problem(ctx, Unsupported target %d in brwNewProgram()\n, target); + return NULL; } } Why not do: assert(!Unsupported target in brwNewProgram()); return NULL; I'd really like it to abort... Still, this is better than the old crap, so, Reviewed-by: Kenneth Graunke kenn...@whitecape.org Yeah, you're right. Asserting is better. Thanks! ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 1/3] softpipe: support nested/overlapping queries for all query types
On 08/23/2013 03:10 PM, srol...@vmware.com wrote: From: Roland Scheidegger srol...@vmware.com There's just no way resetting the counters is working with nested/overlapping queries. --- src/gallium/drivers/softpipe/sp_prim_vbuf.c |2 +- src/gallium/drivers/softpipe/sp_query.c | 33 +-- 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/src/gallium/drivers/softpipe/sp_prim_vbuf.c b/src/gallium/drivers/softpipe/sp_prim_vbuf.c index 5d0b5e1..80c6450 100644 --- a/src/gallium/drivers/softpipe/sp_prim_vbuf.c +++ b/src/gallium/drivers/softpipe/sp_prim_vbuf.c @@ -595,7 +595,7 @@ sp_vbuf_so_info(struct vbuf_render *vbr, uint primitives, uint vertices, struct softpipe_context *softpipe = cvbr-softpipe; softpipe-so_stats.num_primitives_written += primitives; - softpipe-so_stats.primitives_storage_needed = + softpipe-so_stats.primitives_storage_needed += vertices * 4 /*sizeof(float|int32)*/ * 4 /*x,y,z,w*/; softpipe-num_primitives_generated += prim_generated; } diff --git a/src/gallium/drivers/softpipe/sp_query.c b/src/gallium/drivers/softpipe/sp_query.c index daeef53..ca15f03 100644 --- a/src/gallium/drivers/softpipe/sp_query.c +++ b/src/gallium/drivers/softpipe/sp_query.c @@ -99,22 +99,17 @@ softpipe_begin_query(struct pipe_context *pipe, struct pipe_query *q) sq-start = os_time_get_nano(); break; case PIPE_QUERY_SO_STATISTICS: - sq-so.primitives_storage_needed = 0; - sq-num_primitives_generated = 0; - softpipe-num_primitives_generated = 0; - sq-so.num_primitives_written = 0; - softpipe-so_stats.num_primitives_written = 0; + sq-so.num_primitives_written = softpipe-so_stats.num_primitives_written; + sq-so.primitives_storage_needed = softpipe-num_primitives_generated; break; case PIPE_QUERY_SO_OVERFLOW_PREDICATE: sq-end = FALSE; break; case PIPE_QUERY_PRIMITIVES_EMITTED: - sq-so.num_primitives_written = 0; - softpipe-so_stats.num_primitives_written = 0; + sq-so.num_primitives_written = softpipe-so_stats.num_primitives_written; break; case PIPE_QUERY_PRIMITIVES_GENERATED: - sq-num_primitives_generated = 0; - softpipe-num_primitives_generated = 0; + sq-num_primitives_generated = softpipe-num_primitives_generated; break; case PIPE_QUERY_TIMESTAMP: case PIPE_QUERY_GPU_FINISHED: @@ -158,21 +153,25 @@ softpipe_end_query(struct pipe_context *pipe, struct pipe_query *q) sq-end = os_time_get_nano(); break; case PIPE_QUERY_SO_OVERFLOW_PREDICATE: - sq-end = (softpipe-num_primitives_generated - softpipe-so_stats.num_primitives_written); + sq-so.num_primitives_written = + softpipe-so_stats.num_primitives_written - sq-so.num_primitives_written; + sq-num_primitives_generated = + softpipe-num_primitives_generated - sq-num_primitives_generated; + sq-end = sq-num_primitives_generated sq-so.num_primitives_written; break; case PIPE_QUERY_SO_STATISTICS: - sq-num_primitives_generated = - softpipe-num_primitives_generated; sq-so.num_primitives_written = - softpipe-so_stats.num_primitives_written; + softpipe-so_stats.num_primitives_written - sq-so.num_primitives_written; + sq-so.primitives_storage_needed = + softpipe-num_primitives_generated - sq-so.primitives_storage_needed; break; case PIPE_QUERY_PRIMITIVES_EMITTED: sq-so.num_primitives_written = - softpipe-so_stats.num_primitives_written; + softpipe-so_stats.num_primitives_written - sq-so.num_primitives_written; break; case PIPE_QUERY_PRIMITIVES_GENERATED: - sq-num_primitives_generated = softpipe-num_primitives_generated; + sq-num_primitives_generated = + softpipe-num_primitives_generated - sq-num_primitives_generated; break; case PIPE_QUERY_GPU_FINISHED: case PIPE_QUERY_TIMESTAMP_DISJOINT: @@ -219,7 +218,7 @@ softpipe_get_query_result(struct pipe_context *pipe, struct pipe_query_data_so_statistics *stats = (struct pipe_query_data_so_statistics *)vresult; stats-num_primitives_written = sq-so.num_primitives_written; - stats-primitives_storage_needed = sq-num_primitives_generated; + stats-primitives_storage_needed = sq-so.primitives_storage_needed; } break; case PIPE_QUERY_PIPELINE_STATISTICS: For the series: Reviewed-by: Brian Paul bri...@vmware.com ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 1/2] mesa: init dst values in COPY_CLEAN_4V_TYPE_AS_FLOAT()
to silence gcc 4.8.1 warnings. And improve the ASSERT(0) call. --- src/mesa/main/macros.h |3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/mesa/main/macros.h b/src/mesa/main/macros.h index ddfeee2..1052f75 100644 --- a/src/mesa/main/macros.h +++ b/src/mesa/main/macros.h @@ -607,7 +607,8 @@ COPY_CLEAN_4V_TYPE_AS_FLOAT(GLfloat dst[4], int sz, const GLfloat src[4], UINT_AS_FLT(0), UINT_AS_FLT(1)); break; default: - ASSERT(0); + ASSIGN_4V(dst, 0.0f, 0.0f, 0.0f, 1.0f); /* silence warnings */ + ASSERT(!Unexpected type in COPY_CLEAN_4V_TYPE_AS_FLOAT macro); } COPY_SZ_4V(dst, sz, src); } -- 1.7.10.4 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 2/2] swrast: init i0, i1 values to silence warnings
--- src/mesa/swrast/s_texfilter.c |1 + 1 file changed, 1 insertion(+) diff --git a/src/mesa/swrast/s_texfilter.c b/src/mesa/swrast/s_texfilter.c index 0920a64..312b9ce 100644 --- a/src/mesa/swrast/s_texfilter.c +++ b/src/mesa/swrast/s_texfilter.c @@ -274,6 +274,7 @@ linear_texel_locations(GLenum wrapMode, break; default: _mesa_problem(NULL, Bad wrap mode); + *i0 = *i1 = 0; u = 0.0F; break; } -- 1.7.10.4 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH] eglut/wayland: Port to 1.0 API.
--- src/egl/eglut/eglut_wayland.c | 129 +++--- 1 file changed, 97 insertions(+), 32 deletions(-) diff --git a/src/egl/eglut/eglut_wayland.c b/src/egl/eglut/eglut_wayland.c index 61207d2..809d8b4 100644 --- a/src/egl/eglut/eglut_wayland.c +++ b/src/egl/eglut/eglut_wayland.c @@ -7,42 +7,92 @@ struct display { struct wl_display *display; struct wl_compositor *compositor; struct wl_shell *shell; - uint32_t mask; + struct wl_registry *registry; }; struct window { struct wl_surface *surface; struct wl_shell_surface *shell_surface; struct wl_callback *callback; + struct wl_egl_window *native; + int configured; }; static struct display display = {0, }; static struct window window = {0, }; static void -display_handle_global(struct wl_display *display, uint32_t id, - const char *interface, uint32_t version, void *data) +registry_handle_global(void *data, struct wl_registry *registry, + uint32_t name, const char *interface, uint32_t version) { - struct display *d = data; - if (strcmp(interface, wl_compositor) == 0) { - d-compositor = - wl_display_bind(display, id, wl_compositor_interface); + display.compositor = + wl_registry_bind(registry, name, + wl_compositor_interface, 1); } else if (strcmp(interface, wl_shell) == 0) { - d-shell = wl_display_bind(display, id, wl_shell_interface); + display.shell = wl_registry_bind(registry, name, + wl_shell_interface, 1); } } -static int -event_mask_update(uint32_t mask, void *data) +static void +registry_handle_global_remove(void *data, struct wl_registry *registry, + uint32_t name) +{ +} + +static const struct wl_registry_listener registry_listener = { + registry_handle_global, + registry_handle_global_remove +}; + +static void +handle_ping(void *data, struct wl_shell_surface *shell_surface, +uint32_t serial) +{ + wl_shell_surface_pong(shell_surface, serial); +} + +static void +handle_configure(void *data, struct wl_shell_surface *shell_surface, + uint32_t edges, int32_t width, int32_t height) +{ + struct eglut_window *win = _eglut-current; + + if (win-native.u.window) + wl_egl_window_resize(win-native.u.window, win-native.width, + win-native.height, 0, 0); +} + +static void +handle_popup_done(void *data, struct wl_shell_surface *shell_surface) +{ +} + +static const struct wl_shell_surface_listener shell_surface_listener = { +handle_ping, +handle_configure, +handle_popup_done +}; + +static void +draw(void *data, struct wl_callback *callback, uint32_t time); + +static void +configure_callback(void *data, struct wl_callback *callback, uint32_t time) { - struct display *d = data; + wl_callback_destroy(callback); - d-mask = mask; + window.configured = 1; - return 0; + if (window.callback == NULL) + draw(window, NULL, time); } +static struct wl_callback_listener configure_callback_listener = { + configure_callback, +}; + void _eglutNativeInitDisplay(void) { @@ -51,11 +101,11 @@ _eglutNativeInitDisplay(void) if (!_eglut-native_dpy) _eglutFatal(failed to initialize native display); - wl_display_add_global_listener(_eglut-native_dpy, - display_handle_global, display); + display.registry = wl_display_get_registry(_eglut-native_dpy); + wl_registry_add_listener(display.registry, +registry_listener, display); - wl_display_get_fd(_eglut-native_dpy, event_mask_update, display); - wl_display_iterate(_eglut-native_dpy, WL_DISPLAY_READABLE); + wl_display_dispatch(_eglut-native_dpy); _eglut-surface_type = EGL_WINDOW_BIT; } @@ -63,6 +113,14 @@ _eglutNativeInitDisplay(void) void _eglutNativeFiniDisplay(void) { + if (display.shell) + wl_shell_destroy(display.shell); + + if (display.compositor) + wl_compositor_destroy(display.compositor); + + wl_registry_destroy(display.registry); + wl_display_flush(_eglut-native_dpy); wl_display_disconnect(_eglut-native_dpy); } @@ -71,16 +129,21 @@ void _eglutNativeInitWindow(struct eglut_window *win, const char *title, int x, int y, int w, int h) { - struct wl_egl_window *native; + struct wl_callback *callback; window.surface = wl_compositor_create_surface(display.compositor); window.shell_surface = wl_shell_get_shell_surface(display.shell, - window.surface); - native = wl_egl_window_create(window.surface, w, h); + window.surface); + window.native = wl_egl_window_create(window.surface, w, h); + wl_shell_surface_set_title(window.shell_surface, title); wl_shell_surface_set_toplevel(window.shell_surface); - win-native.u.window = native; + callback =
[Mesa-dev] [PATCH 01/19] Xephyr: stop loading the host's keymap
From: Julien Cristau jcris...@debian.org This isn't used anywhere. v2: Rebase to the top of the patch series (anholt) Reviewed-by: Mikhail Gusarov dotted...@dottedmag.net (v1) Signed-off-by: Julien Cristau jcris...@debian.org Signed-off-by: Eric Anholt e...@anholt.net --- hw/kdrive/ephyr/ephyr.c | 2 +- hw/kdrive/ephyr/hostx.c | 33 + hw/kdrive/ephyr/hostx.h | 3 --- 3 files changed, 2 insertions(+), 36 deletions(-) diff --git a/hw/kdrive/ephyr/ephyr.c b/hw/kdrive/ephyr/ephyr.c index 02d4970..b34b5cc 100644 --- a/hw/kdrive/ephyr/ephyr.c +++ b/hw/kdrive/ephyr/ephyr.c @@ -1091,7 +1091,7 @@ EphyrKeyboardInit(KdKeyboardInfo * ki) ki-driverPrivate = (EphyrKbdPrivate *) calloc(sizeof(EphyrKbdPrivate), 1); hostx_load_keymap(); -if (!ephyrKeySyms.map) { +if (!ephyrKeySyms.minKeyCode) { ErrorF(Couldn't load keymap from host\n); return BadAlloc; } diff --git a/hw/kdrive/ephyr/hostx.c b/hw/kdrive/ephyr/hostx.c index 5071289..f46770f 100644 --- a/hw/kdrive/ephyr/hostx.c +++ b/hw/kdrive/ephyr/hostx.c @@ -840,45 +840,14 @@ hostx_paint_debug_rect(struct EphyrHostScreen *host_screen, void hostx_load_keymap(void) { -XID *keymap; -int host_width, min_keycode, max_keycode, width; -int i, j; +int min_keycode, max_keycode; XDisplayKeycodes(HostX.dpy, min_keycode, max_keycode); EPHYR_DBG(min: %d, max: %d, min_keycode, max_keycode); -keymap = XGetKeyboardMapping(HostX.dpy, - min_keycode, - max_keycode - min_keycode + 1, host_width); - -/* Try and copy the hosts keymap into our keymap to avoid loads - * of messing around. - * - * kdrive cannot can have more than 4 keysyms per keycode - * so we only copy at most the first 4 ( xorg has 6 per keycode, XVNC 2 ) - */ -width = (host_width 4) ? 4 : host_width; - -ephyrKeySyms.map = (CARD32 *) calloc(sizeof(CARD32), - (max_keycode - min_keycode + 1) * - width); -if (!ephyrKeySyms.map) -goto out; - -for (i = 0; i (max_keycode - min_keycode + 1); i++) -for (j = 0; j width; j++) -ephyrKeySyms.map[(i * width) + j] = -(CARD32) keymap[(i * host_width) + j]; - -EPHYR_DBG(keymap width, host:%d kdrive:%d, host_width, width); - ephyrKeySyms.minKeyCode = min_keycode; ephyrKeySyms.maxKeyCode = max_keycode; -ephyrKeySyms.mapWidth = width; - - out: -XFree(keymap); } static struct EphyrHostScreen * diff --git a/hw/kdrive/ephyr/hostx.h b/hw/kdrive/ephyr/hostx.h index f47297c..f165606 100644 --- a/hw/kdrive/ephyr/hostx.h +++ b/hw/kdrive/ephyr/hostx.h @@ -51,12 +51,9 @@ typedef enum EphyrHostXEventType { EPHYR_EV_CONFIGURE, } EphyrHostXEventType; -/* I can't believe it's not a KeySymsRec. */ typedef struct { int minKeyCode; int maxKeyCode; -int mapWidth; -CARD32 *map; } EphyrKeySyms; struct EphyrHostXEvent { -- 1.8.4.rc3 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 03/19] Xephyr: use xcb-shape instead of XShape*
From: Julien Cristau jcris...@debian.org Reviewed-by: Mikhail Gusarov dotted...@dottedmag.net Reviewed-by: Eric Anholt e...@anholt.net Signed-off-by: Julien Cristau jcris...@debian.org --- hw/kdrive/ephyr/hostx.c | 40 +++- 1 file changed, 27 insertions(+), 13 deletions(-) diff --git a/hw/kdrive/ephyr/hostx.c b/hw/kdrive/ephyr/hostx.c index 2ecda14..f4948b9 100644 --- a/hw/kdrive/ephyr/hostx.c +++ b/hw/kdrive/ephyr/hostx.c @@ -54,7 +54,6 @@ #include X11/Xlib.h #include X11/Xutil.h #include X11/keysym.h -#include X11/extensions/shape.h #include xcb/xcb.h #include xcb/xproto.h #include X11/Xlib-xcb.h @@ -1300,15 +1299,16 @@ hostx_set_window_bounding_rectangles(int a_window, EphyrRect * a_rects, int a_num_rects) { Bool is_ok = FALSE; -Display *dpy = hostx_get_display(); int i = 0; -XRectangle *rects = NULL; +xcb_rectangle_t *rects = NULL; -EPHYR_RETURN_VAL_IF_FAIL(dpy a_rects, FALSE); +EPHYR_RETURN_VAL_IF_FAIL(a_rects, FALSE); EPHYR_LOG(enter. num rects:%d\n, a_num_rects); -rects = calloc(a_num_rects, sizeof(XRectangle)); +rects = calloc(a_num_rects, sizeof (xcb_rectangle_t)); +if (!rects) +goto out; for (i = 0; i a_num_rects; i++) { rects[i].x = a_rects[i].x1; rects[i].y = a_rects[i].y1; @@ -1317,11 +1317,17 @@ hostx_set_window_bounding_rectangles(int a_window, EPHYR_LOG(borders clipped to rect[x:%d,y:%d,w:%d,h:%d]\n, rects[i].x, rects[i].y, rects[i].width, rects[i].height); } -/*this aways returns 1 */ -XShapeCombineRectangles(dpy, a_window, ShapeBounding, 0, 0, -rects, a_num_rects, ShapeSet, YXBanded); +xcb_shape_rectangles(HostX.conn, + XCB_SHAPE_SO_SET, + XCB_SHAPE_SK_BOUNDING, + XCB_CLIP_ORDERING_YX_BANDED, + a_window, + 0, 0, + a_num_rects, + rects); is_ok = TRUE; +out: free(rects); rects = NULL; EPHYR_LOG(leave\n); @@ -1335,13 +1341,15 @@ hostx_set_window_clipping_rectangles(int a_window, Bool is_ok = FALSE; Display *dpy = hostx_get_display(); int i = 0; -XRectangle *rects = NULL; +xcb_rectangle_t *rects = NULL; EPHYR_RETURN_VAL_IF_FAIL(dpy a_rects, FALSE); EPHYR_LOG(enter. num rects:%d\n, a_num_rects); -rects = calloc(a_num_rects, sizeof(XRectangle)); +rects = calloc(a_num_rects, sizeof (xcb_rectangle_t)); +if (!rects) +goto out; for (i = 0; i a_num_rects; i++) { rects[i].x = a_rects[i].x1; rects[i].y = a_rects[i].y1; @@ -1350,11 +1358,17 @@ hostx_set_window_clipping_rectangles(int a_window, EPHYR_LOG(clipped to rect[x:%d,y:%d,w:%d,h:%d]\n, rects[i].x, rects[i].y, rects[i].width, rects[i].height); } -/*this aways returns 1 */ -XShapeCombineRectangles(dpy, a_window, ShapeClip, 0, 0, -rects, a_num_rects, ShapeSet, YXBanded); +xcb_shape_rectangles(HostX.conn, + XCB_SHAPE_SO_SET, + XCB_SHAPE_SK_CLIP, + XCB_CLIP_ORDERING_YX_BANDED, + a_window, + 0, 0, + a_num_rects, + rects); is_ok = TRUE; +out: free(rects); rects = NULL; EPHYR_LOG(leave\n); -- 1.8.4.rc3 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 04/19] Xephyr: no need for XDisplayKeycodes
From: Julien Cristau jcris...@debian.org Reviewed-by: Mikhail Gusarov dotted...@dottedmag.net Reviewed-by: Eric Anholt e...@anholt.net Signed-off-by: Julien Cristau jcris...@debian.org --- hw/kdrive/ephyr/hostx.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hw/kdrive/ephyr/hostx.c b/hw/kdrive/ephyr/hostx.c index f4948b9..699805b 100644 --- a/hw/kdrive/ephyr/hostx.c +++ b/hw/kdrive/ephyr/hostx.c @@ -910,7 +910,8 @@ hostx_load_keymap(void) { int min_keycode, max_keycode; -XDisplayKeycodes(HostX.dpy, min_keycode, max_keycode); +min_keycode = xcb_get_setup(HostX.conn)-min_keycode; +max_keycode = xcb_get_setup(HostX.conn)-max_keycode; EPHYR_DBG(min: %d, max: %d, min_keycode, max_keycode); -- 1.8.4.rc3 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 05/19] Xephyr: xcb-ify pointer/keyboard grab
From: Julien Cristau jcris...@debian.org Reviewed-by: Mikhail Gusarov dotted...@dottedmag.net Reviewed-by: Eric Anholt e...@anholt.net Signed-off-by: Julien Cristau jcris...@debian.org --- hw/kdrive/ephyr/hostx.c | 45 - 1 file changed, 32 insertions(+), 13 deletions(-) diff --git a/hw/kdrive/ephyr/hostx.c b/hw/kdrive/ephyr/hostx.c index 699805b..2ebf978 100644 --- a/hw/kdrive/ephyr/hostx.c +++ b/hw/kdrive/ephyr/hostx.c @@ -1016,30 +1016,49 @@ hostx_get_event(EphyrHostXEvent * ev) host_screen_from_window(xev.xexpose.window); if (grabbed_screen != -1) { -XUngrabKeyboard(HostX.dpy, CurrentTime); -XUngrabPointer(HostX.dpy, CurrentTime); +xcb_ungrab_keyboard(HostX.conn, XCB_TIME_CURRENT_TIME); +xcb_ungrab_pointer(HostX.conn, XCB_TIME_CURRENT_TIME); grabbed_screen = -1; hostx_set_win_title(host_screen-info, (ctrl+shift grabs mouse and keyboard)); } else { /* Attempt grab */ -if (XGrabKeyboard(HostX.dpy, host_screen-win, True, - GrabModeAsync, - GrabModeAsync, CurrentTime) == 0) { -if (XGrabPointer(HostX.dpy, host_screen-win, True, - NoEventMask, - GrabModeAsync, - GrabModeAsync, - host_screen-win, None, - CurrentTime) == 0) { +xcb_grab_keyboard_cookie_t kbgrabc = +xcb_grab_keyboard(HostX.conn, + True, + host_screen-win, + XCB_TIME_CURRENT_TIME, + XCB_GRAB_MODE_ASYNC, + XCB_GRAB_MODE_ASYNC); +xcb_grab_keyboard_reply_t *kbgrabr; +xcb_grab_pointer_cookie_t pgrabc = +xcb_grab_pointer(HostX.conn, + True, + host_screen-win, + 0, + XCB_GRAB_MODE_ASYNC, + XCB_GRAB_MODE_ASYNC, + host_screen-win, + XCB_NONE, + XCB_TIME_CURRENT_TIME); +xcb_grab_pointer_reply_t *pgrabr; +kbgrabr = xcb_grab_keyboard_reply(HostX.conn, kbgrabc, NULL); +if (!kbgrabr || kbgrabr-status != XCB_GRAB_STATUS_SUCCESS) { +xcb_discard_reply(HostX.conn, pgrabc.sequence); +xcb_ungrab_pointer(HostX.conn, XCB_TIME_CURRENT_TIME); +} else { +pgrabr = xcb_grab_pointer_reply(HostX.conn, pgrabc, NULL); +if (!pgrabr || pgrabr-status != XCB_GRAB_STATUS_SUCCESS) +{ +xcb_ungrab_keyboard(HostX.conn, +XCB_TIME_CURRENT_TIME); +} else { grabbed_screen = host_screen-mynum; hostx_set_win_title (host_screen-info, (ctrl+shift releases mouse and keyboard)); } -else/* Failed pointer grabm ungrab keyboard */ -XUngrabKeyboard(HostX.dpy, CurrentTime); } } } -- 1.8.4.rc3 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 02/19] Xephyr: start converting hostx.c over to xcb
From: Julien Cristau jcris...@debian.org v2: Dropped the hostx_load_keymap changes, now that that function is gutted (anholt). Reviewed-by: Mikhail Gusarov dotted...@dottedmag.net (v1) Signed-off-by: Julien Cristau jcris...@debian.org Signed-off-by: Eric Anholt e...@anholt.net --- configure.ac| 4 +- hw/kdrive/ephyr/hostx.c | 614 +++- hw/kdrive/ephyr/hostx.h | 7 + 3 files changed, 357 insertions(+), 268 deletions(-) diff --git a/configure.ac b/configure.ac index d27ca23..2c9585d 100644 --- a/configure.ac +++ b/configure.ac @@ -2116,12 +2116,12 @@ if test $KDRIVE = yes; then AC_DEFINE(KDRIVE_MOUSE, 1, [Enable KDrive mouse driver]) fi -XEPHYR_REQUIRED_LIBS=x11 = 1.6 $LIBXEXT xau xdmcp +XEPHYR_REQUIRED_LIBS=x11 = 1.6 $LIBXEXT xau xdmcp xcb x11-xcb xcb-shape xcb-aux xcb-image xcb-icccm xcb-shm if test x$XV = xyes; then XEPHYR_REQUIRED_LIBS=$XEPHYR_REQUIRED_LIBS xv fi if test x$DRI = xyes test x$GLX = xyes; then -XEPHYR_REQUIRED_LIBS=$XEPHYR_REQUIRED_LIBS $LIBGL libdrm +XEPHYR_REQUIRED_LIBS=$XEPHYR_REQUIRED_LIBS $LIBGL libdrm xcb-glx xcb-xf86dri fi if test x$XEPHYR = xauto; then diff --git a/hw/kdrive/ephyr/hostx.c b/hw/kdrive/ephyr/hostx.c index f46770f..2ecda14 100644 --- a/hw/kdrive/ephyr/hostx.c +++ b/hw/kdrive/ephyr/hostx.c @@ -53,20 +53,22 @@ #include X11/Xlib.h #include X11/Xutil.h -#include X11/Xatom.h #include X11/keysym.h -#include X11/extensions/XShm.h #include X11/extensions/shape.h +#include xcb/xcb.h +#include xcb/xproto.h +#include X11/Xlib-xcb.h +#include xcb/xcb_icccm.h +#include xcb/xcb_aux.h +#include xcb/shm.h +#include xcb/xcb_image.h +#include xcb/shape.h #ifdef XF86DRI -#include GL/glx.h -#endif /* XF86DRI */ +#include xcb/xf86dri.h +#include xcb/glx.h +#endif /* XF86DRI */ #include ephyrlog.h -#ifdef XF86DRI -extern Bool XF86DRIQueryExtension(Display * dpy, - int *event_basep, int *error_basep); -#endif - /* * All xlib calls go here, which gets built as its own .a . * Mixing kdrive and xlib headers causes all sorts of types @@ -77,11 +79,11 @@ struct EphyrHostScreen { Window win; Window win_pre_existing;/* Set via -parent option like xnest */ Window peer_win;/* Used for GL; should be at most one */ -XImage *ximg; +xcb_image_t*ximg; int win_width, win_height; int server_depth; unsigned char *fb_data; /* only used when host bpp != server bpp */ -XShmSegmentInfo shminfo; +xcb_shm_segment_info_t shminfo; void *info; /* Pointer to the screen this is associated with */ int mynum; /* Screen number */ @@ -90,10 +92,11 @@ struct EphyrHostScreen { struct EphyrHostXVars { char *server_dpy_name; Display *dpy; +xcb_connection_t *conn; int screen; Visual *visual; Window winroot; -GC gc; +xcb_gcontext_t gc; int depth; Bool use_host_cursor; Bool use_fullscreen; @@ -126,11 +129,6 @@ char *ephyrTitle = NULL; static void hostx_set_fullscreen_hint(void); -/* X Error traps */ - -static int trapped_error_code = 0; -static int (*old_error_handler) (Display * d, XErrorEvent * e); - #define host_depth_matches_server(_vars) (HostX.depth == (_vars)-server_depth) static struct EphyrHostScreen * @@ -146,27 +144,6 @@ host_screen_from_screen_info(EphyrScreenInfo * screen) return NULL; } -static int -error_handler(Display * display, XErrorEvent * error) -{ -trapped_error_code = error-error_code; -return 0; -} - -static void -hostx_errors_trap(void) -{ -trapped_error_code = 0; -old_error_handler = XSetErrorHandler(error_handler); -} - -static int -hostx_errors_untrap(void) -{ -XSetErrorHandler(old_error_handler); -return trapped_error_code; -} - int hostx_want_screen_size(EphyrScreenInfo screen, int *width, int *height) { @@ -223,9 +200,13 @@ hostx_set_win_title(EphyrScreenInfo screen, const char *extra_text) return; if (ephyrTitle) { -XStoreName(HostX.dpy, host_screen-win, ephyrTitle); -} -else { +xcb_icccm_set_wm_name(HostX.conn, + host_screen-win, + XCB_ATOM_STRING, + 8, + strlen(ephyrTitle), + ephyrTitle); +} else { #define BUF_LEN 256 char buf[BUF_LEN + 1]; @@ -234,7 +215,12 @@ hostx_set_win_title(EphyrScreenInfo screen, const char *extra_text) HostX.server_dpy_name, host_screen-mynum, (extra_text != NULL) ? extra_text : ); -XStoreName(HostX.dpy, host_screen-win, buf); +xcb_icccm_set_wm_name(HostX.conn, + host_screen-win, + XCB_ATOM_STRING, + 8, +
[Mesa-dev] [PATCH 10/19] Xephyr: move HostX.visual to xcb
From: Julien Cristau jcris...@debian.org Reviewed-by: Mikhail Gusarov dotted...@dottedmag.net Reviewed-by: Eric Anholt e...@anholt.net Signed-off-by: Julien Cristau jcris...@debian.org --- hw/kdrive/ephyr/hostx.c | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/hw/kdrive/ephyr/hostx.c b/hw/kdrive/ephyr/hostx.c index 4bcc902..d984db9 100644 --- a/hw/kdrive/ephyr/hostx.c +++ b/hw/kdrive/ephyr/hostx.c @@ -94,7 +94,7 @@ struct EphyrHostXVars { Display *dpy; xcb_connection_t *conn; int screen; -Visual *visual; +xcb_visualtype_t *visual; Window winroot; xcb_gcontext_t gc; int depth; @@ -371,7 +371,7 @@ hostx_init(void) HostX.winroot = RootWindow(HostX.dpy, HostX.screen); HostX.gc = xcb_generate_id(HostX.conn); HostX.depth = DefaultDepth(HostX.dpy, HostX.screen); -HostX.visual = DefaultVisual(HostX.dpy, HostX.screen); +HostX.visual = xcb_aux_find_visual_by_id(screen, screen-root_visual); xcb_create_gc(HostX.conn, HostX.gc, HostX.winroot, 0, NULL); cookie_WINDOW_STATE = xcb_intern_atom(HostX.conn, False, @@ -593,10 +593,10 @@ hostx_get_bpp(EphyrScreenInfo screen) if (!host_screen) return 0; -if (host_depth_matches_server(host_screen)) -return HostX.visual-bits_per_rgb; +if (host_depth_matches_server (host_screen)) +return HostX.visual-bits_per_rgb_value; else -return host_screen-server_depth; /*XXX correct ? */ +return host_screen-server_depth; /*XXX correct ?*/ } void -- 1.8.4.rc3 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 11/19] Xephyr: some more hostx.c xcb-ification
From: Julien Cristau jcris...@debian.org Reviewed-by: Mikhail Gusarov dotted...@dottedmag.net Reviewed-by: Eric Anholt e...@anholt.net Signed-off-by: Julien Cristau jcris...@debian.org --- hw/kdrive/ephyr/hostx.c | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/hw/kdrive/ephyr/hostx.c b/hw/kdrive/ephyr/hostx.c index d984db9..3d3519b 100644 --- a/hw/kdrive/ephyr/hostx.c +++ b/hw/kdrive/ephyr/hostx.c @@ -368,9 +368,9 @@ hostx_init(void) HostX.conn = XGetXCBConnection(HostX.dpy); HostX.screen = DefaultScreen(HostX.dpy); screen = xcb_aux_get_screen(HostX.conn, HostX.screen); -HostX.winroot = RootWindow(HostX.dpy, HostX.screen); +HostX.winroot = screen-root; HostX.gc = xcb_generate_id(HostX.conn); -HostX.depth = DefaultDepth(HostX.dpy, HostX.screen); +HostX.depth = screen-root_depth; HostX.visual = xcb_aux_find_visual_by_id(screen, screen-root_visual); xcb_create_gc(HostX.conn, HostX.gc, HostX.winroot, 0, NULL); @@ -439,8 +439,8 @@ hostx_init(void) (ctrl+shift grabs mouse and keyboard)); if (HostX.use_fullscreen) { -host_screen-win_width = DisplayWidth(HostX.dpy, HostX.screen); -host_screen-win_height = DisplayHeight(HostX.dpy, HostX.screen); +host_screen-win_width = screen-width_in_pixels; +host_screen-win_height = screen-height_in_pixels; hostx_set_fullscreen_hint(); } @@ -1123,7 +1123,7 @@ hostx_get_xcbconn(void) int hostx_get_screen(void) { -return DefaultScreen(HostX.dpy); +return HostX.screen; } int -- 1.8.4.rc3 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 06/19] Xephyr: xcb-ify visual list construction
From: Julien Cristau jcris...@debian.org Reviewed-by: Mikhail Gusarov dotted...@dottedmag.net Reviewed-by: Eric Anholt e...@anholt.net Signed-off-by: Julien Cristau jcris...@debian.org --- hw/kdrive/ephyr/hostx.c | 59 +++-- 1 file changed, 33 insertions(+), 26 deletions(-) diff --git a/hw/kdrive/ephyr/hostx.c b/hw/kdrive/ephyr/hostx.c index 2ebf978..2b69b0e 100644 --- a/hw/kdrive/ephyr/hostx.c +++ b/hw/kdrive/ephyr/hostx.c @@ -1175,43 +1175,50 @@ hostx_get_extension_info(const char *a_ext_name, int hostx_get_visuals_info(EphyrHostVisualInfo ** a_visuals, int *a_num_entries) { -Display *dpy = hostx_get_display(); Bool is_ok = False; -XVisualInfo templ, *visuals = NULL; EphyrHostVisualInfo *host_visuals = NULL; -int nb_items = 0, i = 0; +int nb_items = 0, i = 0, screen_num; +xcb_screen_iterator_t screens; +xcb_depth_iterator_t depths; -EPHYR_RETURN_VAL_IF_FAIL(a_visuals a_num_entries dpy, False); +EPHYR_RETURN_VAL_IF_FAIL(a_visuals a_num_entries, False); EPHYR_LOG(enter\n); -memset(templ, 0, sizeof(templ)); -visuals = XGetVisualInfo(dpy, VisualNoMask, templ, nb_items); -if (!visuals) { -EPHYR_LOG_ERROR(host does not advertise any visual\n); -goto out; + +screens = xcb_setup_roots_iterator(xcb_get_setup(HostX.conn)); +for (screen_num = 0; screens.rem; screen_num++, xcb_screen_next(screens)) { +depths = xcb_screen_allowed_depths_iterator(screens.data); +for (; depths.rem; xcb_depth_next(depths)) { +xcb_visualtype_t *visuals = xcb_depth_visuals(depths.data); +EphyrHostVisualInfo *tmp_visuals = +realloc(host_visuals, +(nb_items + depths.data-visuals_len) +* sizeof(EphyrHostVisualInfo)); +if (!tmp_visuals) { +goto out; +} +host_visuals = tmp_visuals; +for (i = 0; i depths.data-visuals_len; i++) { +host_visuals[nb_items + i].visualid = visuals[i].visual_id; +host_visuals[nb_items + i].screen = screen_num; +host_visuals[nb_items + i].depth = depths.data-depth; +host_visuals[nb_items + i].class = visuals[i]._class; +host_visuals[nb_items + i].red_mask = visuals[i].red_mask; +host_visuals[nb_items + i].green_mask = visuals[i].green_mask; +host_visuals[nb_items + i].blue_mask = visuals[i].blue_mask; +host_visuals[nb_items + i].colormap_size = visuals[i].colormap_entries; +host_visuals[nb_items + i].bits_per_rgb = visuals[i].bits_per_rgb_value; +} +nb_items += depths.data-visuals_len; +} } + EPHYR_LOG(host advertises %d visuals\n, nb_items); -host_visuals = calloc(nb_items, sizeof(EphyrHostVisualInfo)); -for (i = 0; i nb_items; i++) { -host_visuals[i].visualid = visuals[i].visualid; -host_visuals[i].screen = visuals[i].screen; -host_visuals[i].depth = visuals[i].depth; -host_visuals[i].class = visuals[i].class; -host_visuals[i].red_mask = visuals[i].red_mask; -host_visuals[i].green_mask = visuals[i].green_mask; -host_visuals[i].blue_mask = visuals[i].blue_mask; -host_visuals[i].colormap_size = visuals[i].colormap_size; -host_visuals[i].bits_per_rgb = visuals[i].bits_per_rgb; -} *a_visuals = host_visuals; *a_num_entries = nb_items; host_visuals = NULL; is_ok = TRUE; - out: -if (visuals) { -XFree(visuals); -visuals = NULL; -} +out: free(host_visuals); host_visuals = NULL; EPHYR_LOG(leave\n); -- 1.8.4.rc3 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 08/19] Xephyr: delete unused hostx_get_extension_info function
From: Julien Cristau jcris...@debian.org v2: Also remove the prototype (anholt) Reviewed-by: Mikhail Gusarov dotted...@dottedmag.net (v1) Signed-off-by: Julien Cristau jcris...@debian.org Signed-off-by: Eric Anholt e...@anholt.net --- hw/kdrive/ephyr/hostx.c | 15 --- hw/kdrive/ephyr/hostx.h | 5 - 2 files changed, 20 deletions(-) diff --git a/hw/kdrive/ephyr/hostx.c b/hw/kdrive/ephyr/hostx.c index 2b69b0e..1261487 100644 --- a/hw/kdrive/ephyr/hostx.c +++ b/hw/kdrive/ephyr/hostx.c @@ -1158,21 +1158,6 @@ hostx_get_window_attributes(int a_window, EphyrHostWindowAttributes * a_attrs) } int -hostx_get_extension_info(const char *a_ext_name, - int *a_major_opcode, - int *a_first_event, int *a_first_error) -{ -if (!a_ext_name || !a_major_opcode || !a_first_event || !a_first_error) -return 0; -if (!XQueryExtension(HostX.dpy, - a_ext_name, - a_major_opcode, a_first_event, a_first_error)) { -return 0; -} -return 1; -} - -int hostx_get_visuals_info(EphyrHostVisualInfo ** a_visuals, int *a_num_entries) { Bool is_ok = False; diff --git a/hw/kdrive/ephyr/hostx.h b/hw/kdrive/ephyr/hostx.h index c065f2d..1c01f8b 100644 --- a/hw/kdrive/ephyr/hostx.h +++ b/hw/kdrive/ephyr/hostx.h @@ -220,11 +220,6 @@ int hostx_get_window_attributes(int a_window, EphyrHostWindowAttributes * a_attr); int - -hostx_get_extension_info(const char *a_ext_name, - int *a_major_opcode, - int *a_first_even, int *a_first_error); -int hostx_get_visuals_info(EphyrHostVisualInfo ** a_visuals, int *a_num_entries); int hostx_create_window(int a_screen_number, -- 1.8.4.rc3 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 12/19] Xephyr: use xcb for event handling
From: Julien Cristau jcris...@debian.org v2: Rebase on indentation changes, squash in a simpler variant of the later event compression patch, fix server hang or segfault on window close by reimplementing the x_io_error_handler in the new XCB event loop (anholt). Reviewed-by: Mikhail Gusarov dotted...@dottedmag.net (v1) Signed-off-by: Julien Cristau jcris...@debian.org Signed-off-by: Eric Anholt e...@anholt.net --- hw/kdrive/ephyr/hostx.c | 284 ++-- 1 file changed, 155 insertions(+), 129 deletions(-) diff --git a/hw/kdrive/ephyr/hostx.c b/hw/kdrive/ephyr/hostx.c index 3d3519b..07a2772 100644 --- a/hw/kdrive/ephyr/hostx.c +++ b/hw/kdrive/ephyr/hostx.c @@ -942,169 +942,195 @@ host_screen_from_window(Window w) int hostx_get_event(EphyrHostXEvent * ev) { -XEvent xev; +xcb_generic_event_t *xev; static int grabbed_screen = -1; static xcb_key_symbols_t *keysyms; if (!keysyms) keysyms = xcb_key_symbols_alloc(HostX.conn); -if (XPending(HostX.dpy)) { -XNextEvent(HostX.dpy, xev); - -switch (xev.type) { -case Expose: -/* Not so great event compression, but works ok */ -while (XCheckTypedWindowEvent(HostX.dpy, xev.xexpose.window, - Expose, xev)); -{ -struct EphyrHostScreen *host_screen = -host_screen_from_window(xev.xexpose.window); -if (host_screen) { -hostx_paint_rect(host_screen-info, 0, 0, 0, 0, - host_screen-win_width, - host_screen-win_height); -} -else { -EPHYR_LOG_ERROR(failed to get host screen\n); -ev-type = EPHYR_EV_EXPOSE; -ev-data.expose.window = xev.xexpose.window; -return 1; -} -} -return 0; - -case MotionNotify: -{ -struct EphyrHostScreen *host_screen = -host_screen_from_window(xev.xmotion.window); - -ev-type = EPHYR_EV_MOUSE_MOTION; -ev-data.mouse_motion.x = xev.xmotion.x; -ev-data.mouse_motion.y = xev.xmotion.y; -ev-data.mouse_motion.window = xev.xmotion.window; -ev-data.mouse_motion.screen = -(host_screen ? host_screen-mynum : -1); +xev = xcb_poll_for_event(HostX.conn); +if (!xev) { +/* If our XCB connection has died (for example, our window was + * closed), exit now. + */ +if (xcb_connection_has_error(HostX.conn)) { +CloseWellKnownConnections(); +OsCleanup(1); +exit(1); } -return 1; -case ButtonPress: -ev-type = EPHYR_EV_MOUSE_PRESS; -ev-key_state = xev.xkey.state; -/* - * This is a bit hacky. will break for button 5 ( defined as 0x10 ) - * Check KD_BUTTON defines in kdrive.h - */ -ev-data.mouse_down.button_num = 1 (xev.xbutton.button - 1); -return 1; +return 0; +} -case ButtonRelease: -ev-type = EPHYR_EV_MOUSE_RELEASE; -ev-key_state = xev.xkey.state; -ev-data.mouse_up.button_num = 1 (xev.xbutton.button - 1); -return 1; +switch (xev-response_type 0x7f) { +case XCB_EXPOSE: { +xcb_expose_event_t *expose = (xcb_expose_event_t *)xev; +struct EphyrHostScreen *host_screen = +host_screen_from_window(expose-window); -case KeyPress: -{ -ev-type = EPHYR_EV_KEY_PRESS; -ev-key_state = xev.xkey.state; -ev-data.key_down.scancode = xev.xkey.keycode; +/* Wait for the last expose event in a series of cliprects + * to actually paint our screen. + */ +if (expose-count != 0) +break; + +if (host_screen) { +hostx_paint_rect(host_screen-info, 0, 0, 0, 0, + host_screen-win_width, + host_screen-win_height); +} +else { +EPHYR_LOG_ERROR(failed to get host screen\n); +ev-type = EPHYR_EV_EXPOSE; +ev-data.expose.window = expose-window; +free(xev); return 1; } -case KeyRelease: -if ((xcb_key_symbols_get_keysym(keysyms,xev.xkey.keycode, 0) == XK_Shift_L - || xcb_key_symbols_get_keysym(keysyms,xev.xkey.keycode, 0) == XK_Shift_R) - (xev.xkey.state XCB_MOD_MASK_CONTROL)) { -struct EphyrHostScreen *host_screen = -host_screen_from_window(xev.xexpose.window); - -if (grabbed_screen != -1) { -xcb_ungrab_keyboard(HostX.conn,
[Mesa-dev] [PATCH 14/19] Xephyr: move ephyrdri over to xcb
From: Julien Cristau jcris...@debian.org Require new xcb-xf86dri to get fixed GetDrawableInfo. Reviewed-by: Mikhail Gusarov dotted...@dottedmag.net Signed-off-by: Julien Cristau jcris...@debian.org --- configure.ac | 2 +- hw/kdrive/ephyr/ephyrdri.c | 201 - 2 files changed, 144 insertions(+), 59 deletions(-) diff --git a/configure.ac b/configure.ac index b8d9a25..a6c466e 100644 --- a/configure.ac +++ b/configure.ac @@ -2121,7 +2121,7 @@ if test $KDRIVE = yes; then XEPHYR_REQUIRED_LIBS=$XEPHYR_REQUIRED_LIBS xcb-xv fi if test x$DRI = xyes test x$GLX = xyes; then -XEPHYR_REQUIRED_LIBS=$XEPHYR_REQUIRED_LIBS $LIBGL libdrm xcb-glx xcb-xf86dri +XEPHYR_REQUIRED_LIBS=$XEPHYR_REQUIRED_LIBS $LIBGL libdrm xcb-glx xcb-xf86dri 1.6 fi if test x$XEPHYR = xauto; then diff --git a/hw/kdrive/ephyr/ephyrdri.c b/hw/kdrive/ephyr/ephyrdri.c index 3a4a063..16678fc 100644 --- a/hw/kdrive/ephyr/ephyrdri.c +++ b/hw/kdrive/ephyr/ephyrdri.c @@ -29,10 +29,8 @@ #include kdrive-config.h #endif -#include X11/Xutil.h -#include X11/Xlibint.h -#include GL/glx.h -#include xf86dri.h +#include X11/Xdefs.h +#include xcb/xf86dri.h #include hostx.h #include ephyrdri.h #define _HAVE_XALLOC_DECLS @@ -49,13 +47,21 @@ Bool ephyrDRIQueryDirectRenderingCapable(int a_screen, Bool *a_is_capable) { -Display *dpy = hostx_get_display(); +xcb_connection_t *conn = hostx_get_xcbconn(); Bool is_ok = FALSE; +xcb_xf86dri_query_direct_rendering_capable_cookie_t cookie; +xcb_xf86dri_query_direct_rendering_capable_reply_t *reply; EPHYR_RETURN_VAL_IF_FAIL(a_is_capable, FALSE); EPHYR_LOG(enter\n); -is_ok = XF86DRIQueryDirectRenderingCapable(dpy, DefaultScreen(dpy), - a_is_capable); +cookie = xcb_xf86dri_query_direct_rendering_capable(conn, +hostx_get_screen()); +reply = xcb_xf86dri_query_direct_rendering_capable_reply(conn, cookie, NULL); +if (reply) { +is_ok = TRUE; +*a_is_capable = reply-is_capable; +free(reply); +} EPHYR_LOG(leave. is_capable:%d, is_ok=%d\n, *a_is_capable, is_ok); return is_ok; @@ -65,31 +71,48 @@ Bool ephyrDRIOpenConnection(int a_screen, drm_handle_t * a_sarea, char **a_bus_id_string) { -Display *dpy = hostx_get_display(); +xcb_connection_t *conn = hostx_get_xcbconn(); Bool is_ok = FALSE; +xcb_xf86dri_open_connection_cookie_t cookie; +xcb_xf86dri_open_connection_reply_t *reply; EPHYR_RETURN_VAL_IF_FAIL(a_bus_id_string, FALSE); EPHYR_LOG(enter. screen:%d\n, a_screen); -is_ok = XF86DRIOpenConnection(dpy, DefaultScreen(dpy), - a_sarea, a_bus_id_string); -if (*a_bus_id_string) { -EPHYR_LOG(leave. bus_id_string:%s, is_ok:%d\n, - *a_bus_id_string, is_ok); -} -else { -EPHYR_LOG(leave. bus_id_string:null, is_ok:%d\n, is_ok); +cookie = xcb_xf86dri_open_connection(conn, hostx_get_screen()); +reply = xcb_xf86dri_open_connection_reply(conn, cookie, NULL); +if (!reply) +goto out; +*a_sarea = reply-sarea_handle_low; +if (sizeof(drm_handle_t) == 8) { +int shift = 32; +*a_sarea |= ((drm_handle_t) reply-sarea_handle_high) shift; } +*a_bus_id_string = malloc(reply-bus_id_len + 1); +if (!*a_bus_id_string) +goto out; +memcpy(*a_bus_id_string, xcb_xf86dri_open_connection_bus_id(reply), reply-bus_id_len); +*a_bus_id_string[reply-bus_id_len] = '\0'; +is_ok = TRUE; +out: +free(reply); +EPHYR_LOG(leave. bus_id_string:%s, is_ok:%d\n, *a_bus_id_string, is_ok); return is_ok; } Bool ephyrDRIAuthConnection(int a_screen, drm_magic_t a_magic) { -Display *dpy = hostx_get_display(); +xcb_connection_t *conn = hostx_get_xcbconn(); +int screen = hostx_get_screen(); +xcb_xf86dri_auth_connection_cookie_t cookie; +xcb_xf86dri_auth_connection_reply_t *reply; Bool is_ok = FALSE; EPHYR_LOG(enter\n); -is_ok = XF86DRIAuthConnection(dpy, DefaultScreen(dpy), a_magic); +cookie = xcb_xf86dri_auth_connection(conn, screen, a_magic); +reply = xcb_xf86dri_auth_connection_reply(conn, cookie, NULL); +is_ok = reply-authenticated; +free(reply); EPHYR_LOG(leave. is_ok:%d\n, is_ok); return is_ok; } @@ -97,13 +120,13 @@ ephyrDRIAuthConnection(int a_screen, drm_magic_t a_magic) Bool ephyrDRICloseConnection(int a_screen) { -Display *dpy = hostx_get_display(); -Bool is_ok = FALSE; +xcb_connection_t *conn = hostx_get_xcbconn(); +int screen = hostx_get_screen(); EPHYR_LOG(enter\n); -is_ok = XF86DRICloseConnection(dpy, DefaultScreen(dpy)); +xcb_xf86dri_close_connection(conn, screen); EPHYR_LOG(leave\n); -return is_ok; +return TRUE; } Bool @@ -113,7
[Mesa-dev] [PATCH 13/19] Xephyr: use xcb-xv instead of libXv
From: Julien Cristau jcris...@debian.org v2: Massive, conflict-filled rebase. I think I resolved everything right, but this host xv code makes my eyes bleed. Touch-tested XV after the rebase (anholt). Reviewed-by: Mikhail Gusarov dotted...@dottedmag.net (v1) Signed-off-by: Julien Cristau jcris...@debian.org Signed-off-by: Eric Anholt e...@anholt.net --- configure.ac | 2 +- hw/kdrive/ephyr/ephyrhostvideo.c | 892 +++ hw/kdrive/ephyr/ephyrhostvideo.h | 45 +- hw/kdrive/ephyr/ephyrvideo.c | 45 +- 4 files changed, 382 insertions(+), 602 deletions(-) diff --git a/configure.ac b/configure.ac index db7ef7c..b8d9a25 100644 --- a/configure.ac +++ b/configure.ac @@ -2118,7 +2118,7 @@ if test $KDRIVE = yes; then XEPHYR_REQUIRED_LIBS=x11 = 1.6 $LIBXEXT xau xdmcp xcb x11-xcb xcb-shape xcb-aux xcb-image xcb-icccm xcb-shm xcb-keysyms if test x$XV = xyes; then -XEPHYR_REQUIRED_LIBS=$XEPHYR_REQUIRED_LIBS xv +XEPHYR_REQUIRED_LIBS=$XEPHYR_REQUIRED_LIBS xcb-xv fi if test x$DRI = xyes test x$GLX = xyes; then XEPHYR_REQUIRED_LIBS=$XEPHYR_REQUIRED_LIBS $LIBGL libdrm xcb-glx xcb-xf86dri diff --git a/hw/kdrive/ephyr/ephyrhostvideo.c b/hw/kdrive/ephyr/ephyrhostvideo.c index 99f0f50..8b71687 100644 --- a/hw/kdrive/ephyr/ephyrhostvideo.c +++ b/hw/kdrive/ephyr/ephyrhostvideo.c @@ -38,12 +38,8 @@ #ifdef _XSERVER64 #undef _XSERVER64 #endif -#include X11/Xutil.h -#include X11/Xlibint.h -#include X11/extensions/Xvlib.h -#include X11/extensions/Xvproto.h -#include X11/extensions/Xext.h -#include X11/extensions/extutil.h +#include xcb/xv.h +#include xcb/xcb_aux.h #define _HAVE_XALLOC_DECLS #include hostx.h @@ -56,295 +52,114 @@ #ifndef FALSE #define FALSE 0 #endif /*FALSE*/ -static XExtensionInfo _xv_info_data; -static XExtensionInfo *xv_info = _xv_info_data; -static const char *xv_extension_name = XvName; -static char *xv_error_string(Display * dpy, int code, XExtCodes * codes, - char *buf, int n); -static int xv_close_display(Display * dpy, XExtCodes * codes); -static Bool xv_wire_to_event(Display * dpy, XEvent * host, xEvent *wire); - -static XExtensionHooks xv_extension_hooks = { -NULL, /* create_gc */ -NULL, /* copy_gc */ -NULL, /* flush_gc */ -NULL, /* free_gc */ -NULL, /* create_font */ -NULL, /* free_font */ -xv_close_display, /* close_display */ -xv_wire_to_event, /* wire_to_event */ -NULL, /* event_to_wire */ -NULL, /* error */ -xv_error_string /* error_string */ -}; - -static const char *xv_error_list[] = { -BadPort, /* XvBadPort */ -BadEncoding, /* XvBadEncoding */ -BadControl/* XvBadControl */ -}; - -#define XvCheckExtension(dpy, i, val) \ - XextCheckExtension(dpy, i, xv_extension_name, val) -#define XvGetReq(name, req) \ -WORD64ALIGN\ -if ((dpy-bufptr + SIZEOF(xv##name##Req)) dpy-bufmax)\ -_XFlush(dpy);\ -req = (xv##name##Req *)(dpy-last_req = dpy-bufptr);\ -req-reqType = info-codes-major_opcode;\ -req-xvReqType = xv_##name; \ -req-length = (SIZEOF(xv##name##Req))2;\ -dpy-bufptr += SIZEOF(xv##name##Req);\ -dpy-request++ - -static -XEXT_GENERATE_CLOSE_DISPLAY(xv_close_display, xv_info) - -static -XEXT_GENERATE_FIND_DISPLAY(xv_find_display, xv_info, - xv_extension_name, - xv_extension_hooks, XvNumEvents, NULL) - -static -XEXT_GENERATE_ERROR_STRING(xv_error_string, xv_extension_name, - XvNumErrors, xv_error_list) - -struct _EphyrHostXVAdaptorArray { -XvAdaptorInfo *adaptors; -unsigned int nb_adaptors; -}; - -/*heavily copied from libx11*/ -#define BUFSIZE 2048 -static void -ephyrHostXVLogXErrorEvent(Display * a_display, - XErrorEvent * a_err_event, FILE * a_fp) -{ -char buffer[BUFSIZ]; -char mesg[BUFSIZ]; -char number[32]; -const char *mtype = XlibMessage; -register _XExtension *ext = (_XExtension *) NULL; -_XExtension *bext = (_XExtension *) NULL; -Display *dpy = a_display; - -XGetErrorText(dpy, a_err_event-error_code, buffer, BUFSIZ); -XGetErrorDatabaseText(dpy, mtype, XError, X Error, mesg, BUFSIZ); -(void) fprintf(a_fp, %s: %s\n , mesg, buffer); -XGetErrorDatabaseText(dpy, mtype, MajorCode, Request Major code %d, - mesg, BUFSIZ); -(void) fprintf(a_fp, mesg, a_err_event-request_code); -if (a_err_event-request_code 128) { -snprintf(number, sizeof(number), %d, a_err_event-request_code); -XGetErrorDatabaseText(dpy, XRequest, number, , buffer, BUFSIZ); -} -else { -
[Mesa-dev] [PATCH 07/19] Xephyr: delete unused proxy code
From: Julien Cristau jcris...@debian.org Reviewed-by: Mikhail Gusarov dotted...@dottedmag.net Reviewed-by: Eric Anholt e...@anholt.net Signed-off-by: Julien Cristau jcris...@debian.org --- hw/kdrive/ephyr/ephyrhostproxy.c | 91 --- hw/kdrive/ephyr/ephyrhostproxy.h | 51 - hw/kdrive/ephyr/ephyrproxyext.c | 115 --- hw/kdrive/ephyr/ephyrproxyext.h | 33 --- 4 files changed, 290 deletions(-) delete mode 100644 hw/kdrive/ephyr/ephyrhostproxy.c delete mode 100644 hw/kdrive/ephyr/ephyrhostproxy.h delete mode 100644 hw/kdrive/ephyr/ephyrproxyext.c delete mode 100644 hw/kdrive/ephyr/ephyrproxyext.h diff --git a/hw/kdrive/ephyr/ephyrhostproxy.c b/hw/kdrive/ephyr/ephyrhostproxy.c deleted file mode 100644 index a4f25c1..000 --- a/hw/kdrive/ephyr/ephyrhostproxy.c +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Xephyr - A kdrive X server thats runs in a host X window. - * Authored by Matthew Allum mal...@openedhand.com - * - * Copyright © 2007 OpenedHand Ltd - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of OpenedHand Ltd not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. OpenedHand Ltd makes no - * representations about the suitability of this software for any purpose. It - * is provided as is without express or implied warranty. - * - * OpenedHand Ltd DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL OpenedHand Ltd BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - * - * Authors: - *Dodji Seketeli do...@openedhand.com - */ - -#ifdef HAVE_CONFIG_H -#include kdrive-config.h -#endif - -#include X11/Xlibint.h -#define _HAVE_XALLOC_DECLS -#include ephyrlog.h -#include ephyrhostproxy.h -#include hostx.h - -/* byte swap a short */ -#define swaps(x, n) { \ -n = ((char *) (x))[0];\ -((char *) (x))[0] = ((char *) (x))[1];\ -((char *) (x))[1] = n; } - -#define GetXReq(req) \ -WORD64ALIGN ;\ -if ((dpy-bufptr + SIZEOF(xReq)) dpy-bufmax)\ -_XFlush(dpy);\ -req = (xReq *)(dpy-last_req = dpy-bufptr);\ -dpy-bufptr += SIZEOF(xReq);\ -dpy-request++ - -Bool -ephyrHostProxyDoForward(pointer a_request_buffer, -struct XReply *a_reply, Bool a_do_swap) -{ -Bool is_ok = FALSE; -int n = 0; -Display *dpy = hostx_get_display(); -xReq *in_req = (xReq *) a_request_buffer; -xReq *forward_req = NULL; -struct XReply reply; - -EPHYR_RETURN_VAL_IF_FAIL(in_req dpy, FALSE); - -EPHYR_LOG(enter\n); - -if (a_do_swap) { -swaps(in_req-length); -} -EPHYR_LOG(Req {type:%d, data:%d, length:%d}\n, - in_req-reqType, in_req-data, in_req-length); -GetXReq(forward_req); -memmove(forward_req, in_req, 4); - -if (!_XReply(dpy, (xReply *) reply, 0, FALSE)) { -EPHYR_LOG_ERROR(failed to get reply\n); -goto out; -} -EPHYR_LOG(XReply{type:%d, foo:%d, seqnum:%d, length:%d}\n, - reply.type, reply.foo, reply.sequence_number, reply.length); - -if (a_reply) { -memmove(a_reply, reply, sizeof(reply)); -} -is_ok = TRUE; - - out: -EPHYR_LOG(leave\n); -return is_ok; -} diff --git a/hw/kdrive/ephyr/ephyrhostproxy.h b/hw/kdrive/ephyr/ephyrhostproxy.h deleted file mode 100644 index 1372160..000 --- a/hw/kdrive/ephyr/ephyrhostproxy.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Xephyr - A kdrive X server thats runs in a host X window. - * Authored by Matthew Allum mal...@openedhand.com - * - * Copyright © 2007 OpenedHand Ltd - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of OpenedHand Ltd not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. OpenedHand Ltd makes no - * representations about the suitability of this software for any purpose. It - * is provided as is without express or implied warranty. - * - * OpenedHand Ltd DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - *
[Mesa-dev] [PATCH 15/19] Xephyr: remove unused DRI1 code
From: Julien Cristau jcris...@debian.org Reviewed-by: Mikhail Gusarov dotted...@dottedmag.net Signed-off-by: Julien Cristau jcris...@debian.org --- hw/kdrive/ephyr/Makefile.am | 2 - hw/kdrive/ephyr/XF86dri.c | 654 hw/kdrive/ephyr/xf86dri.h | 124 - 3 files changed, 780 deletions(-) delete mode 100644 hw/kdrive/ephyr/XF86dri.c delete mode 100644 hw/kdrive/ephyr/xf86dri.h diff --git a/hw/kdrive/ephyr/Makefile.am b/hw/kdrive/ephyr/Makefile.am index ab02437..7648e14 100644 --- a/hw/kdrive/ephyr/Makefile.am +++ b/hw/kdrive/ephyr/Makefile.am @@ -34,8 +34,6 @@ HOSTDRI_SRCS =\ ephyrdriext.h \ ephyrdri.c \ ephyrdri.h \ - XF86dri.c \ - xf86dri.h \ ephyrglxext.c \ ephyrglxext.h \ ephyrhostglx.c \ diff --git a/hw/kdrive/ephyr/XF86dri.c b/hw/kdrive/ephyr/XF86dri.c deleted file mode 100644 index 15b6219..000 --- a/hw/kdrive/ephyr/XF86dri.c +++ /dev/null @@ -1,654 +0,0 @@ -/* $XFree86: xc/lib/GL/dri/XF86dri.c,v 1.13 2002/10/30 12:51:25 alanh Exp $ */ -/** - -Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas. -Copyright 2000 VA Linux Systems, Inc. -All Rights Reserved. - -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, sub license, 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 NON-INFRINGEMENT. -IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS 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. - -**/ - -/* - * Authors: - * Kevin E. Martin mar...@valinux.com - * Jens Owen j...@tungstengraphics.com - * Rickard E. (Rik) Faith fa...@valinux.com - * - */ - -/* - * This file has been copied from the mesa source tree and a little bit - * modified by: - * - * Dodji Seketeli do...@openedhand.com - */ - -#ifdef HAVE_CONFIG_H -#include kdrive-config.h -#endif -/* - * including some server headers (like kdrive-config.h) - * might define the macro _XSERVER64 - * on 64 bits machines. That macro must _NOT_ be defined for Xlib - * client code, otherwise bad things happen. - * So let's undef that macro if necessary. - */ -#ifdef _XSERVER64 -#undef _XSERVER64 -#endif - -/* THIS IS NOT AN X CONSORTIUM STANDARD */ - -#include X11/Xlibint.h -#include X11/extensions/Xext.h -#include X11/extensions/extutil.h -#include GL/glx.h -#include xf86dri.h -#include X11/dri/xf86driproto.h -#include limits.h - -static XExtensionInfo _xf86dri_info_data; -static XExtensionInfo *xf86dri_info = _xf86dri_info_data; -static char xf86dri_extension_name[] = XF86DRINAME; - -#define XF86DRICheckExtension(dpy,i,val) \ - XextCheckExtension (dpy, i, xf86dri_extension_name, val) - -/* - * * - *private utility routines * - * * - */ - -static int close_display(Display * dpy, XExtCodes * extCodes); - -static /* const */ XExtensionHooks xf86dri_extension_hooks = { -NULL, /* create_gc */ -NULL, /* copy_gc */ -NULL, /* flush_gc */ -NULL, /* free_gc */ -NULL, /* create_font */ -NULL, /* free_font */ -close_display, /* close_display */ -NULL, /* wire_to_event */ -NULL, /* event_to_wire */ -NULL, /* error */ -NULL, /* error_string */ -}; - -static -XEXT_GENERATE_FIND_DISPLAY(find_display, xf86dri_info, - xf86dri_extension_name, - xf86dri_extension_hooks, 0, NULL) - -static
[Mesa-dev] [PATCH 09/19] Xephyr: replace XKeycodeToKeysym with xcb-keysyms
From: Julien Cristau jcris...@debian.org Reviewed-by: Mikhail Gusarov dotted...@dottedmag.net Reviewed-by: Eric Anholt e...@anholt.net Signed-off-by: Julien Cristau jcris...@debian.org --- configure.ac| 2 +- hw/kdrive/ephyr/hostx.c | 13 - 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/configure.ac b/configure.ac index 2c9585d..db7ef7c 100644 --- a/configure.ac +++ b/configure.ac @@ -2116,7 +2116,7 @@ if test $KDRIVE = yes; then AC_DEFINE(KDRIVE_MOUSE, 1, [Enable KDrive mouse driver]) fi -XEPHYR_REQUIRED_LIBS=x11 = 1.6 $LIBXEXT xau xdmcp xcb x11-xcb xcb-shape xcb-aux xcb-image xcb-icccm xcb-shm +XEPHYR_REQUIRED_LIBS=x11 = 1.6 $LIBXEXT xau xdmcp xcb x11-xcb xcb-shape xcb-aux xcb-image xcb-icccm xcb-shm xcb-keysyms if test x$XV = xyes; then XEPHYR_REQUIRED_LIBS=$XEPHYR_REQUIRED_LIBS xv fi diff --git a/hw/kdrive/ephyr/hostx.c b/hw/kdrive/ephyr/hostx.c index 1261487..4bcc902 100644 --- a/hw/kdrive/ephyr/hostx.c +++ b/hw/kdrive/ephyr/hostx.c @@ -62,6 +62,7 @@ #include xcb/shm.h #include xcb/xcb_image.h #include xcb/shape.h +#include xcb/xcb_keysyms.h #ifdef XF86DRI #include xcb/xf86dri.h #include xcb/glx.h @@ -943,6 +944,10 @@ hostx_get_event(EphyrHostXEvent * ev) { XEvent xev; static int grabbed_screen = -1; +static xcb_key_symbols_t *keysyms; + +if (!keysyms) +keysyms = xcb_key_symbols_alloc(HostX.conn); if (XPending(HostX.dpy)) { XNextEvent(HostX.dpy, xev); @@ -1007,11 +1012,9 @@ hostx_get_event(EphyrHostXEvent * ev) return 1; } case KeyRelease: - -if ((XKeycodeToKeysym(HostX.dpy, xev.xkey.keycode, 0) == XK_Shift_L - || XKeycodeToKeysym(HostX.dpy, xev.xkey.keycode, - 0) == XK_Shift_R) - (xev.xkey.state ControlMask)) { +if ((xcb_key_symbols_get_keysym(keysyms,xev.xkey.keycode, 0) == XK_Shift_L + || xcb_key_symbols_get_keysym(keysyms,xev.xkey.keycode, 0) == XK_Shift_R) + (xev.xkey.state XCB_MOD_MASK_CONTROL)) { struct EphyrHostScreen *host_screen = host_screen_from_window(xev.xexpose.window); -- 1.8.4.rc3 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 18/19] Xephyr: handle errors in event loop
From: Julien Cristau jcris...@debian.org Signed-off-by: Julien Cristau jcris...@debian.org Reviewed-by: Eric Anholt e...@anholt.net Reviewed-by: Mikhail Gusarov dotted...@dottedmag.net --- hw/kdrive/ephyr/hostx.c | 15 +++ 1 file changed, 15 insertions(+) diff --git a/hw/kdrive/ephyr/hostx.c b/hw/kdrive/ephyr/hostx.c index 68bb48a..1eef64e 100644 --- a/hw/kdrive/ephyr/hostx.c +++ b/hw/kdrive/ephyr/hostx.c @@ -947,6 +947,21 @@ hostx_get_event(EphyrHostXEvent * ev) } switch (xev-response_type 0x7f) { +case 0: { /* error */ +xcb_generic_error_t *e = (xcb_generic_error_t *)xev; +fprintf(stderr, X11 error\n +Error code: %hhu\n +Sequence number: %hu\n +Major code: %hhu\tMinor code: %hu\n +Error value: %u\n, +e-error_code, +e-sequence, +e-major_code, e-minor_code, +e-resource_id); +free(xev); +exit(1); +} + case XCB_EXPOSE: { xcb_expose_event_t *expose = (xcb_expose_event_t *)xev; struct EphyrHostScreen *host_screen = -- 1.8.4.rc3 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 17/19] Xephyr: drop remaining Xlib dependency
From: Julien Cristau jcris...@debian.org Reviewed-by: Mikhail Gusarov dotted...@dottedmag.net Reviewed-by: Eric Anholt e...@anholt.net Signed-off-by: Julien Cristau jcris...@debian.org --- configure.ac| 4 ++-- hw/kdrive/ephyr/hostx.c | 64 - hw/kdrive/ephyr/hostx.h | 2 -- 3 files changed, 22 insertions(+), 48 deletions(-) diff --git a/configure.ac b/configure.ac index a6c466e..8c72cc0 100644 --- a/configure.ac +++ b/configure.ac @@ -2116,12 +2116,12 @@ if test $KDRIVE = yes; then AC_DEFINE(KDRIVE_MOUSE, 1, [Enable KDrive mouse driver]) fi -XEPHYR_REQUIRED_LIBS=x11 = 1.6 $LIBXEXT xau xdmcp xcb x11-xcb xcb-shape xcb-aux xcb-image xcb-icccm xcb-shm xcb-keysyms +XEPHYR_REQUIRED_LIBS=xau xdmcp xcb xcb-shape xcb-aux xcb-image xcb-icccm xcb-shm xcb-keysyms if test x$XV = xyes; then XEPHYR_REQUIRED_LIBS=$XEPHYR_REQUIRED_LIBS xcb-xv fi if test x$DRI = xyes test x$GLX = xyes; then -XEPHYR_REQUIRED_LIBS=$XEPHYR_REQUIRED_LIBS $LIBGL libdrm xcb-glx xcb-xf86dri 1.6 +XEPHYR_REQUIRED_LIBS=$XEPHYR_REQUIRED_LIBS libdrm xcb-glx xcb-xf86dri 1.6 fi if test x$XEPHYR = xauto; then diff --git a/hw/kdrive/ephyr/hostx.c b/hw/kdrive/ephyr/hostx.c index 07a2772..68bb48a 100644 --- a/hw/kdrive/ephyr/hostx.c +++ b/hw/kdrive/ephyr/hostx.c @@ -51,12 +51,9 @@ #include sys/shm.h #include sys/time.h -#include X11/Xlib.h -#include X11/Xutil.h #include X11/keysym.h #include xcb/xcb.h #include xcb/xproto.h -#include X11/Xlib-xcb.h #include xcb/xcb_icccm.h #include xcb/xcb_aux.h #include xcb/shm.h @@ -91,7 +88,6 @@ struct EphyrHostScreen { struct EphyrHostXVars { char *server_dpy_name; -Display *dpy; xcb_connection_t *conn; int screen; xcb_visualtype_t *visual; @@ -151,7 +147,7 @@ hostx_want_screen_size(EphyrScreenInfo screen, int *width, int *height) if (host_screen (host_screen-win_pre_existing != None || - HostX.use_fullscreen == True)) { + HostX.use_fullscreen == TRUE)) { *width = host_screen-win_width; *height = host_screen-win_height; return 1; @@ -233,7 +229,7 @@ hostx_want_host_cursor(void) void hostx_use_host_cursor(void) { -HostX.use_host_cursor = True; +HostX.use_host_cursor = TRUE; } int @@ -252,7 +248,7 @@ hostx_want_preexisting_window(EphyrScreenInfo screen) void hostx_use_fullscreen(void) { -HostX.use_fullscreen = True; +HostX.use_fullscreen = TRUE; } int @@ -323,15 +319,6 @@ hostx_set_title(char *title) #pragma does_not_return(exit) #endif -static int _X_NORETURN -x_io_error_handler(Display * dpy) -{ -ErrorF(Lost connection to X server: %s\n, strerror(errno)); -CloseWellKnownConnections(); -OsCleanup(1); -exit(1); -} - int hostx_init(void) { @@ -358,15 +345,11 @@ hostx_init(void) EPHYR_DBG(mark); -if ((HostX.dpy = XOpenDisplay(getenv(DISPLAY))) == NULL) { +if ((HostX.conn = xcb_connect(NULL, HostX.screen)) == NULL) { fprintf(stderr, \nXephyr cannot open host display. Is DISPLAY set?\n); exit(1); } -XSetIOErrorHandler(x_io_error_handler); - -HostX.conn = XGetXCBConnection(HostX.dpy); -HostX.screen = DefaultScreen(HostX.dpy); screen = xcb_aux_get_screen(HostX.conn, HostX.screen); HostX.winroot = screen-root; HostX.gc = xcb_generate_id(HostX.conn); @@ -374,11 +357,11 @@ hostx_init(void) HostX.visual = xcb_aux_find_visual_by_id(screen, screen-root_visual); xcb_create_gc(HostX.conn, HostX.gc, HostX.winroot, 0, NULL); -cookie_WINDOW_STATE = xcb_intern_atom(HostX.conn, False, +cookie_WINDOW_STATE = xcb_intern_atom(HostX.conn, FALSE, strlen(_NET_WM_STATE), _NET_WM_STATE); cookie_WINDOW_STATE_FULLSCREEN = -xcb_intern_atom(HostX.conn, False, +xcb_intern_atom(HostX.conn, FALSE, strlen(_NET_WM_STATE_FULLSCREEN), _NET_WM_STATE_FULLSCREEN); @@ -519,7 +502,7 @@ hostx_init(void) shm_rep = xcb_get_extension_data(HostX.conn, xcb_shm_id); if (!shm_rep || !shm_rep-present || getenv(XEPHYR_NO_SHM)) { fprintf(stderr, \nXephyr unable to use SHM XImages\n); -HostX.have_shm = False; +HostX.have_shm = FALSE; } else { /* Really really check we have shm - better way ?*/ @@ -528,19 +511,19 @@ hostx_init(void) xcb_void_cookie_t cookie; xcb_shm_seg_t shmseg; -HostX.have_shm = True; +HostX.have_shm = TRUE; shminfo.shmid = shmget(IPC_PRIVATE, 1, IPC_CREAT|0777); shminfo.shmaddr = shmat(shminfo.shmid,0,0); shmseg = xcb_generate_id(HostX.conn); cookie = xcb_shm_attach_checked(HostX.conn, shmseg, shminfo.shmid, -True); +
[Mesa-dev] [PATCH 16/19] Xephyr: move glx code to xcb
From: Julien Cristau jcris...@debian.org v2: Rebase on master, notably adding XCB for X_GLXvop_MakeCurrentReadSGI (anholt). Reviewed-by: Mikhail Gusarov dotted...@dottedmag.net (v1) Signed-off-by: Julien Cristau jcris...@debian.org Signed-off-by: Eric Anholt e...@anholt.net --- hw/kdrive/ephyr/ephyrglxext.c | 11 +- hw/kdrive/ephyr/ephyrhostglx.c | 665 + hw/kdrive/ephyr/ephyrhostglx.h | 11 +- 3 files changed, 211 insertions(+), 476 deletions(-) diff --git a/hw/kdrive/ephyr/ephyrglxext.c b/hw/kdrive/ephyr/ephyrglxext.c index 22d5108..1231b0d 100644 --- a/hw/kdrive/ephyr/ephyrglxext.c +++ b/hw/kdrive/ephyr/ephyrglxext.c @@ -380,10 +380,9 @@ ephyrGLXQueryServerString(__GLXclientState * a_cl, GLbyte * a_pc) int length = 0; EPHYR_LOG(enter\n); -if (!ephyrHostGLXGetStringFromServer(req-screen, - req-name, - EPHYR_HOST_GLX_QueryServerString, - server_string)) { +if (!ephyrHostGLXQueryServerString(req-screen, + req-name, + server_string)) { EPHYR_LOG_ERROR(failed to query string from host\n); goto out; } @@ -724,9 +723,7 @@ ephyrGLXGetStringReal(__GLXclientState * a_cl, GLbyte * a_pc, Bool a_do_swap) a_pc += __GLX_SINGLE_HDR_SIZE; name = *(GLenum *) (a_pc + 0); EPHYR_LOG(context_tag:%d, name:%d\n, context_tag, name); -if (!ephyrHostGLXGetStringFromServer(context_tag, - name, - EPHYR_HOST_GLX_GetString, string)) { +if (!ephyrHostGLXGetString(context_tag, name, string)) { EPHYR_LOG_ERROR(failed to get string from server\n); goto out; } diff --git a/hw/kdrive/ephyr/ephyrhostglx.c b/hw/kdrive/ephyr/ephyrhostglx.c index 5ecb02d..1c1ac45 100644 --- a/hw/kdrive/ephyr/ephyrhostglx.c +++ b/hw/kdrive/ephyr/ephyrhostglx.c @@ -42,11 +42,10 @@ #undef _XSERVER64 #endif -#include X11/Xlibint.h -#include GL/glx.h -#include GL/internal/glcore.h +#include X11/Xdefs.h +#include X11/Xmd.h #include GL/glxproto.h -#include GL/glxint.h +#include xcb/glx.h #include ephyrhostglx.h #define _HAVE_XALLOC_DECLS #include ephyrlog.h @@ -62,41 +61,20 @@ enum VisualConfRequestType { static Bool ephyrHostGLXGetVisualConfigsInternal (enum VisualConfRequestType a_type, + xcb_glx_get_visual_configs_reply_t *reply, int32_t a_screen, - int32_t * a_num_visuals, - int32_t * a_num_props, int32_t * a_props_buf_size, int32_t ** a_props_buf); -Bool -ephyrHostGLXGetMajorOpcode(int *a_opcode) -{ -Bool is_ok = FALSE; -Display *dpy = hostx_get_display(); -static int opcode; -int first_event_return = 0, first_error_return = 0; - -EPHYR_RETURN_VAL_IF_FAIL(dpy, FALSE); -EPHYR_LOG(enter\n); -if (!opcode) { -if (!XQueryExtension(dpy, GLX_EXTENSION_NAME, opcode, - first_event_return, first_error_return)) { -EPHYR_LOG_ERROR(XQueryExtension() failed\n); -goto out; -} -} -*a_opcode = opcode; -is_ok = TRUE; - out: -EPHYR_LOG(release\n); -return is_ok; -} + int32_t *a_num_visuals, + int32_t *a_num_props, + int32_t *a_props_buf_size, + int32_t **a_props_buf); Bool ephyrHostGLXQueryVersion(int *a_major, int *a_minor) { Bool is_ok = FALSE; -Display *dpy = hostx_get_display(); -int major_opcode = 0; -xGLXQueryVersionReq *req = NULL; -xGLXQueryVersionReply reply; +xcb_connection_t *conn = hostx_get_xcbconn(); +xcb_glx_query_version_cookie_t cookie; +xcb_glx_query_version_reply_t *reply; EPHYR_RETURN_VAL_IF_FAIL(a_major a_minor, FALSE); EPHYR_LOG(enter\n); @@ -107,26 +85,14 @@ ephyrHostGLXQueryVersion(int *a_major, int *a_minor) return TRUE; } -if (!ephyrHostGLXGetMajorOpcode(major_opcode)) { -EPHYR_LOG_ERROR(failed to get major opcode\n); -goto out; -} -EPHYR_LOG(major opcode: %d\n, major_opcode); - /* Send the glXQueryVersion request */ -memset(reply, 0, sizeof(reply)); -LockDisplay(dpy); -GetReq(GLXQueryVersion, req); -req-reqType = major_opcode; -req-glxCode = X_GLXQueryVersion; -req-majorVersion = 2; -req-minorVersion = 1; -_XReply(dpy, (xReply *) reply, 0, False); -UnlockDisplay(dpy); -SyncHandle(); - -*a_major = glx_major = reply.majorVersion; -*a_minor = glx_minor = reply.minorVersion; +cookie = xcb_glx_query_version(conn, 2, 1); +reply = xcb_glx_query_version_reply(conn, cookie, NULL); +if (!reply) +goto out; +*a_major = reply-major_version; +*a_minor = reply-minor_version; +free(reply); EPHYR_LOG(major:%d, minor:%d\n, *a_major, *a_minor); @@ -136,129 +102,63 @@ ephyrHostGLXQueryVersion(int *a_major, int
[Mesa-dev] [PATCH 19/19] Xephyr: we're not using Xlib anymore, no need to undef _XSERVER64
From: Julien Cristau jcris...@debian.org Drop obsolete comments about interaction between Xlib code and that macro, and stop undefining it. Signed-off-by: Julien Cristau jcris...@debian.org Reviewed-by: Eric Anholt e...@anholt.net --- hw/kdrive/ephyr/ephyrhostglx.c | 11 --- hw/kdrive/ephyr/ephyrhostvideo.c | 10 -- hw/kdrive/ephyr/hostx.c | 17 - 3 files changed, 38 deletions(-) diff --git a/hw/kdrive/ephyr/ephyrhostglx.c b/hw/kdrive/ephyr/ephyrhostglx.c index 1c1ac45..9967f9d 100644 --- a/hw/kdrive/ephyr/ephyrhostglx.c +++ b/hw/kdrive/ephyr/ephyrhostglx.c @@ -31,17 +31,6 @@ #include kdrive-config.h #endif -/* - * including some server headers (like kdrive-config.h) - * might define the macro _XSERVER64 - * on 64 bits machines. That macro must _NOT_ be defined for Xlib - * client code, otherwise bad things happen. - * So let's undef that macro if necessary. - */ -#ifdef _XSERVER64 -#undef _XSERVER64 -#endif - #include X11/Xdefs.h #include X11/Xmd.h #include GL/glxproto.h diff --git a/hw/kdrive/ephyr/ephyrhostvideo.c b/hw/kdrive/ephyr/ephyrhostvideo.c index 8b71687..ea5fc9b 100644 --- a/hw/kdrive/ephyr/ephyrhostvideo.c +++ b/hw/kdrive/ephyr/ephyrhostvideo.c @@ -28,16 +28,6 @@ #ifdef HAVE_CONFIG_H #include kdrive-config.h #endif -/* - * including some server headers (like kdrive-config.h) - * might define the macro _XSERVER64 - * on 64 bits machines. That macro must _NOT_ be defined for Xlib - * client code, otherwise bad things happen. - * So let's undef that macro if necessary. - */ -#ifdef _XSERVER64 -#undef _XSERVER64 -#endif #include xcb/xv.h #include xcb/xcb_aux.h #define _HAVE_XALLOC_DECLS diff --git a/hw/kdrive/ephyr/hostx.c b/hw/kdrive/ephyr/hostx.c index 1eef64e..97b2dc0 100644 --- a/hw/kdrive/ephyr/hostx.c +++ b/hw/kdrive/ephyr/hostx.c @@ -27,17 +27,6 @@ #include kdrive-config.h #endif -/* - * including some server headers (like kdrive-config.h) - * might define the macro _XSERVER64 - * on 64 bits machines. That macro must _NOT_ be defined for Xlib - * client code, otherwise bad things happen. - * So let's undef that macro if necessary. - */ -#ifdef _XSERVER64 -#undef _XSERVER64 -#endif - #include hostx.h #include stdlib.h @@ -66,12 +55,6 @@ #endif /* XF86DRI */ #include ephyrlog.h -/* - * All xlib calls go here, which gets built as its own .a . - * Mixing kdrive and xlib headers causes all sorts of types - * to get clobbered. - */ - struct EphyrHostScreen { Window win; Window win_pre_existing;/* Set via -parent option like xnest */ -- 1.8.4.rc3 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [RFC PATCH] i965: Allow C++ type safety in the use of enum brw_urb_write_flags.
On 08/24/2013 10:41 AM, Francisco Jerez wrote: Chad Versace chad.vers...@linux.intel.com writes: On 08/23/2013 02:18 PM, Paul Berry wrote: The disadvantages are that (a) we need an explicit enum value for 0, and (b) we can't use related operators like |= unless we define additional overloads. Disadvantage (a) is trivial, not really a problem. I agree, it's not a real disadvantage, you can always define an empty enumerant that evaluates to zero. If that seems inconvenient or ugly we can define a global constant that may be implicitly converted to any bitmask-like enumeration type evaluating to zero, as in: | templatetypename T | struct bitmask_enumeration_traits; | | struct __empty_bitmask { |templatetypename T |operator T() const { | bitmask_enumeration_traitsT(); | return T(); |} | |operator unsigned() const { | return 0; |} | }; | | const __empty_bitmask empty; The bitmask_numeration_traits structure makes sure that the polymorphic conversion operator won't be instantiated for non-bitmask types. The enum declaration would look like: | enum E { | A = 1, | B = 2, | C = 4, | D = 8 | }; | | template | struct bitmask_enumeration_traitsE {}; | Actually, it *is* possible to arrange for the literal 0 to be implicitly converted to our bitmask enum types in a type-safe way by exploiting the fact that the language allows it to be implicitly converted to any pointer type (while implicit conversion of any other integral expression to a pointer type is disallowed). Though I believe it would involve using an actual object instead of plain enums because it's not possible to define a conversion constructor for an enum type. Disadvantage (b) can be made painless with the macro I discuss below. IMHO it would be nicer to define generic templates implementing overloads for all bitwise operators. They would have to reference the bitmask_enumeration_traits structure so they would be discarded for non-bitmask types. Aside from being nicer and safer it would have two clear advantages. First, if we decide to use the __empty_bitmask type defined above, we wouldn't have to keep around three different overloads for each binary operator (T op T, empty op T, T op empty), we'd just define a general one 'T op S' that would be discarded by the SFINAE rule for incompatible T and S. Second, we could arrange for the expression 'FOO op BAR' (with 'FOO' and 'BAR' enumerants from different incompatible bitmask types) to be rejected by the compiler by means of a static assertion in the definition of 'T op S'. If we use the macro solution below the compiler will accept that expression by downgrading both T and S to integers and then applying the built-in definition of 'op'. Though it would still refuse to assign the result to a variable of any of both types *if* the user is doing that. As a non-C++ programmer, that explanation gave me a headache. I don't think this project is ready yet for its developers to need that level of knowledge of the C++ type system. I can immediately understand Chad's macro, and I can also (nearly immediately) understand that it's probably not the C++ way. So what do folks think? Is it worth it? Yes, I think it's worth it. The code becomes more readable and more type safe, as evidenced by the diff lines like this: - unsigned flags, + enum brw_urb_write_flags flags, If we continue to do this to other enums, then we should probably define a convenience macro to define all the needed overloaded bit operators. Like this: #define BRW_CXX_ENUM_OPS(type_name) \ static inline type_name \ operator|(type_name x, type_name y) \ { \ return (type_name) ((int) x | (int) y); \ } \ \ static inline type_name \ operator() \ and more operators +/** + * Allow brw_urb_write_flags enums to be ORed together (normally C++ wouldn't + * allow this without a type cast). + */ +inline enum brw_urb_write_flags +operator|(enum brw_urb_write_flags x, enum brw_urb_write_flags y) +{ + return (enum brw_urb_write_flags) ((int) x | (int) y); +} +#endif I think the comment is distracting rather than helpful. There is no need for C++ code to apologize for being C++ code. You keep forgetting that a number of the people on this project are not C++ programmers. Every one of them will ask, Why is this necessary? Comments are for communicating with humans. I agree, the comment seems redundant to me (as well as using the 'enum' keyword before enum names, though that's just a matter of taste). In a Again, this communicates to other humans what the thing is. If I just see foo x; as a declaration, I don't know what kind of a thing (class, POD struct, enum, typedef, etc.) x is. While the compiler doesn't care, humans do. general definition you might want to use the static_cast operator instead of a c-style cast, to make clear
Re: [Mesa-dev] [PATCH 01/19] Xephyr: stop loading the host's keymap
Did this patch series go to the wrong list? Did you intend xorg-devel instead? On 08/26/2013 11:16 AM, Eric Anholt wrote: From: Julien Cristau jcris...@debian.org This isn't used anywhere. v2: Rebase to the top of the patch series (anholt) Reviewed-by: Mikhail Gusarov dotted...@dottedmag.net (v1) Signed-off-by: Julien Cristau jcris...@debian.org Signed-off-by: Eric Anholt e...@anholt.net --- hw/kdrive/ephyr/ephyr.c | 2 +- hw/kdrive/ephyr/hostx.c | 33 + hw/kdrive/ephyr/hostx.h | 3 --- 3 files changed, 2 insertions(+), 36 deletions(-) diff --git a/hw/kdrive/ephyr/ephyr.c b/hw/kdrive/ephyr/ephyr.c index 02d4970..b34b5cc 100644 --- a/hw/kdrive/ephyr/ephyr.c +++ b/hw/kdrive/ephyr/ephyr.c @@ -1091,7 +1091,7 @@ EphyrKeyboardInit(KdKeyboardInfo * ki) ki-driverPrivate = (EphyrKbdPrivate *) calloc(sizeof(EphyrKbdPrivate), 1); hostx_load_keymap(); -if (!ephyrKeySyms.map) { +if (!ephyrKeySyms.minKeyCode) { ErrorF(Couldn't load keymap from host\n); return BadAlloc; } diff --git a/hw/kdrive/ephyr/hostx.c b/hw/kdrive/ephyr/hostx.c index 5071289..f46770f 100644 --- a/hw/kdrive/ephyr/hostx.c +++ b/hw/kdrive/ephyr/hostx.c @@ -840,45 +840,14 @@ hostx_paint_debug_rect(struct EphyrHostScreen *host_screen, void hostx_load_keymap(void) { -XID *keymap; -int host_width, min_keycode, max_keycode, width; -int i, j; +int min_keycode, max_keycode; XDisplayKeycodes(HostX.dpy, min_keycode, max_keycode); EPHYR_DBG(min: %d, max: %d, min_keycode, max_keycode); -keymap = XGetKeyboardMapping(HostX.dpy, - min_keycode, - max_keycode - min_keycode + 1, host_width); - -/* Try and copy the hosts keymap into our keymap to avoid loads - * of messing around. - * - * kdrive cannot can have more than 4 keysyms per keycode - * so we only copy at most the first 4 ( xorg has 6 per keycode, XVNC 2 ) - */ -width = (host_width 4) ? 4 : host_width; - -ephyrKeySyms.map = (CARD32 *) calloc(sizeof(CARD32), - (max_keycode - min_keycode + 1) * - width); -if (!ephyrKeySyms.map) -goto out; - -for (i = 0; i (max_keycode - min_keycode + 1); i++) -for (j = 0; j width; j++) -ephyrKeySyms.map[(i * width) + j] = -(CARD32) keymap[(i * host_width) + j]; - -EPHYR_DBG(keymap width, host:%d kdrive:%d, host_width, width); - ephyrKeySyms.minKeyCode = min_keycode; ephyrKeySyms.maxKeyCode = max_keycode; -ephyrKeySyms.mapWidth = width; - - out: -XFree(keymap); } static struct EphyrHostScreen * diff --git a/hw/kdrive/ephyr/hostx.h b/hw/kdrive/ephyr/hostx.h index f47297c..f165606 100644 --- a/hw/kdrive/ephyr/hostx.h +++ b/hw/kdrive/ephyr/hostx.h @@ -51,12 +51,9 @@ typedef enum EphyrHostXEventType { EPHYR_EV_CONFIGURE, } EphyrHostXEventType; -/* I can't believe it's not a KeySymsRec. */ typedef struct { int minKeyCode; int maxKeyCode; -int mapWidth; -CARD32 *map; } EphyrKeySyms; struct EphyrHostXEvent { ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 2/2] swrast: init i0, i1 values to silence warnings
Series is Reviewed-by: Chad Versace chad.vers...@linux.intel.com ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] radeonsi: add flexible shader descriptor management and use it for sampler views
Hi 15.08.2013 13:54, Marek Olšák wrote: On Thu, Aug 15, 2013 at 10:27 AM, Christian König deathsim...@vodafone.de wrote: Am 15.08.2013 05:25, schrieb Marek Olšák: (This should be applied before MSAA, which will need to be rebased.) It moves all sampler view descriptors to a buffer. It supports partial resource updates and it can also unbind resources (required for FMASK texturing). The buffer contains all sampler view descriptors for one shader stage, represented as an array. On top of that, there are N arrays in the buffer, which are used to emulate context registers as implemented by the previous ASICs (each array is a context). This uses the RCU synchronization approach to avoid read-after-write hazards as discussed in the thread: radeonsi: add FMASK texture binding slots and resource setup CP DMA is used to clear the descriptors at context initialization and to copy the descriptors from one context to the next. IMPORTANT: 128 resource contexts are needed, 64 doesn't work. If I set SH_KCACHE_ACTION_ENA before every draw call, only 2 contexts are needed. I don't have an explanation for this. --- The idea itself looks really good to me, but we should probably also move the all resources and samplers to the new model and then rip out the code that stores them directly into the IB. I'd like MSAA to land first, but yes, the plan is to eventually move all resources and samplers to the new model. +/* Emit a CP DMA packet to do a copy from one buffer to another. + * The size must fit in bits [20:0]. Notes: + * + * 1) Set sync to true if you want the 3D engine to wait until CP DMA is done. + * + * 2) Set raw_hazard_wait to true if the source data was used as a destination + *in a previous CP DMA packet. It's for preventing a read-after-write hazard + *between two CP DMA packets. + */ +static void si_emit_cp_dma_copy_buffer(struct r600_context *rctx, + uint64_t dst_va, uint64_t src_va, + unsigned size, + bool sync, bool raw_hazard_wait) +{ + struct radeon_winsys_cs *cs = rctx-cs; + uint32_t sync_flag = sync ? PKT3_CP_DMA_CP_SYNC : 0; + uint32_t raw_wait = raw_hazard_wait ? PKT3_CP_DMA_CMD_RAW_WAIT : 0; + + assert(size); + assert((size ((121)-1)) == size); + + cs-buf[cs-cdw++] = PKT3(PKT3_CP_DMA, 4, 0); + cs-buf[cs-cdw++] = src_va;/* SRC_ADDR_LO [31:0] */ + cs-buf[cs-cdw++] = sync_flag | ((src_va 32) 0xff); /* CP_SYNC [31] | SRC_ADDR_HI [7:0] */ + cs-buf[cs-cdw++] = dst_va;/* DST_ADDR_LO [31:0] */ + cs-buf[cs-cdw++] = (dst_va 32) 0xff; /* DST_ADDR_HI [7:0] */ + cs-buf[cs-cdw++] = size | raw_wait; /* COMMAND [29:22] | BYTE_COUNT [20:0] */ +} + +/* Emit a CP DMA packet to clear a buffer. The size must fit in bits [20:0]. */ +static void si_emit_cp_dma_clear_buffer(struct r600_context *rctx, + uint64_t dst_va, unsigned size, + uint32_t clear_value, + bool sync, bool raw_hazard_wait) +{ + struct radeon_winsys_cs *cs = rctx-cs; + uint32_t sync_flag = sync ? PKT3_CP_DMA_CP_SYNC : 0; + uint32_t raw_wait = raw_hazard_wait ? PKT3_CP_DMA_CMD_RAW_WAIT : 0; + + assert(size); + assert((size ((121)-1)) == size); + + cs-buf[cs-cdw++] = PKT3(PKT3_CP_DMA, 4, 0); + cs-buf[cs-cdw++] = clear_value; /* DATA [31:0] */ + cs-buf[cs-cdw++] = sync_flag | PKT3_CP_DMA_SRC_SEL(2); /* CP_SYNC [31] | SRC_SEL[30:29] */ + cs-buf[cs-cdw++] = dst_va;/* DST_ADDR_LO [31:0] */ + cs-buf[cs-cdw++] = (dst_va 32) 0xff; /* DST_ADDR_HI [7:0] */ + cs-buf[cs-cdw++] = size | raw_wait; /* COMMAND [29:22] | BYTE_COUNT [20:0] */ +} Can we use some kind of macro or inline function instead of cs-buf[cs-cdw++] ? That should help of we need to port that over to a different CS mechanism. How about this? static INLINE void r600_write_value(struct radeon_winsys_cs *cs, unsigned value) { cs-buf[cs-cdw++] = value; } And IIRC the CP DMA is identical on all chipset generation (maybe excluding early R6xx, but I'm not 100% sure of that), so it might be a good idea to start sharing code again by putting this under src/gallium/drivers/radeon/radeon_cp_dma.c. Not necessary now, but more as a general idea. What do you think? I agree. CP DMA is indeed identical on all chipsets. The copying is supported since R600 and the clearing is supported since Evergreen. Maybe you already thought: One way to emulate clearing is to copy with CP DMA from a constant cleared memory area. Regards, Marko Ristola Marek ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH] Fixed and/or order mistake, resulting in compiling llvmpipe without llvm installed
--- configure.ac | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index 40e052c..e20a228 100644 --- a/configure.ac +++ b/configure.ac @@ -1925,8 +1925,8 @@ AM_CONDITIONAL(NEED_GALLIUM_SOFTPIPE_DRIVER, test x$HAVE_GALLIUM_SVGA = xyes - x$HAVE_GALLIUM_I915 = xyes -o \ x$HAVE_GALLIUM_SOFTPIPE = xyes) AM_CONDITIONAL(NEED_GALLIUM_LLVMPIPE_DRIVER, test x$HAVE_GALLIUM_I915 = xyes -o \ - x$HAVE_GALLIUM_SOFTPIPE = xyes -a \ - x$MESA_LLVM = x1) + x$HAVE_GALLIUM_SOFTPIPE = xyes \ + test x$MESA_LLVM = x1) if test x$enable_gallium_loader = xyes; then GALLIUM_WINSYS_DIRS=$GALLIUM_WINSYS_DIRS sw/null -- 1.8.3.4 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH] Fixed and/or order mistake, resulting in compiling llvmpipe without llvm installed
--- configure.ac | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index 40e052c..e20a228 100644 --- a/configure.ac +++ b/configure.ac @@ -1925,8 +1925,8 @@ AM_CONDITIONAL(NEED_GALLIUM_SOFTPIPE_DRIVER, test x$HAVE_GALLIUM_SVGA = xyes - x$HAVE_GALLIUM_I915 = xyes -o \ x$HAVE_GALLIUM_SOFTPIPE = xyes) AM_CONDITIONAL(NEED_GALLIUM_LLVMPIPE_DRIVER, test x$HAVE_GALLIUM_I915 = xyes -o \ - x$HAVE_GALLIUM_SOFTPIPE = xyes -a \ - x$MESA_LLVM = x1) + x$HAVE_GALLIUM_SOFTPIPE = xyes \ + test x$MESA_LLVM = x1) if test x$enable_gallium_loader = xyes; then GALLIUM_WINSYS_DIRS=$GALLIUM_WINSYS_DIRS sw/null -- 1.8.3.4 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [RFC PATCH] i965: Allow C++ type safety in the use of enum brw_urb_write_flags.
Ian Romanick i...@freedesktop.org writes: [...] Disadvantage (b) can be made painless with the macro I discuss below. IMHO it would be nicer to define generic templates implementing overloads for all bitwise operators. They would have to reference the bitmask_enumeration_traits structure so they would be discarded for non-bitmask types. [...] Second, we could arrange for the expression 'FOO op BAR' (with 'FOO' and 'BAR' enumerants from different incompatible bitmask types) to be rejected by the compiler by means of a static assertion in the definition of 'T op S'. If we use the macro solution below the compiler will accept that expression by downgrading both T and S to integers and then applying the built-in definition of 'op'. Though it would still refuse to assign the result to a variable of any of both types *if* the user is doing that. As a non-C++ programmer, that explanation gave me a headache. I don't think this project is ready yet for its developers to need that level of knowledge of the C++ type system. I can immediately understand Chad's macro, and I can also (nearly immediately) understand that it's probably not the C++ way. My explanation is exactly as relevant if we stick to Chad's solution or not, using macros doesn't save you from getting the unexpected effect I was trying to describe -- quite the opposite, I can't think of any simple way to work around that problem without using templates. The thing is that defining bitwise operators separately for each enum type, as this patch and the macro solution do, doesn't stop the compiler From using the corresponding built-in integer operators when it doesn't find a match among the user-defined ones. That means that if we have two bitfield enumerants from two different disjoint types e.g. SEASON_OF_THE_YEAR_SUMMER and a CPU_ARCHITECTURE_I386, the compiler is still going to accept expressions like SEASON_OF_THE_YEAR_SUMMER | CPU_ARCHITECTURE_I386, which might not be what had been expected if the BRW_CXX_ENUM_OPS macro was used in an attempt to improve the code's type safety. The template-based solution might seem somewhat obscure to the inexperienced C++ programmer, but unlike the macro-based one it would be semantically sound, and this is just one of many reasons why it's a good idea for anyone dealing with C++ code to have at least some basic knowledge on using templates -- it's the cleanest way to do static polymorphism and generic programming in C++. That said, I agree that it would be a bad idea to make a sudden transition to template metaprogramming in components of our tree where the majority of maintainers have a strong preference towards old-school C programming, but that's no reason to reject a small, non-intrusive and potentially useful change in the good direction a priori before having seen any of the code... [...] pgpAlZKw5443E.pgp Description: PGP signature ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 01/19] Xephyr: stop loading the host's keymap
Ian Romanick i...@freedesktop.org writes: Did this patch series go to the wrong list? Did you intend xorg-devel instead? Yes, I intended the other list, just mis-typed. pgpiOoE6RwZ_a.pgp Description: PGP signature ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] i965: Allocate just enough space for user clip planes in uniform arrays.
Kenneth Graunke kenn...@whitecape.org writes: Previously, we allocated space in brw_vs_prog_data's params and pull_params arrays for MAX_CLIP_PLANES vec4s---even when it wasn't necessary. On a 64-bit architecture, this used 0.5 kB of space (8 clip planes * 4 floats per plane * 8 bytes per float pointer * 2 arrays of pointers = 512 bytes). Since this cost is per-vertex shader, it added up. Conveniently, we already store the number of clip plane constants in the program key. By using that, we can allocate the exact amount of space needed. For the common case where user clipping is disabled, this means 0 bytes. While we're here, mention exactly what code requires this extra space, since it wasn't obvious. Reviewed-by: Eric Anholt e...@anholt.net pgpOBx0JgJLHZ.pgp Description: PGP signature ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 03/15] i965/fs: Add support for translating ir_triop_fma into MAD.
On 23 August 2013 17:45, Matt Turner matts...@gmail.com wrote: On Fri, Aug 23, 2013 at 8:27 AM, Paul Berry stereotype...@gmail.com wrote: On 22 August 2013 16:08, Matt Turner matts...@gmail.com wrote: --- src/mesa/drivers/dri/i965/brw_fs.cpp | 1 + src/mesa/drivers/dri/i965/brw_fs.h | 1 + src/mesa/drivers/dri/i965/brw_fs_channel_expressions.cpp | 1 + src/mesa/drivers/dri/i965/brw_fs_visitor.cpp | 7 +++ 4 files changed, 10 insertions(+) diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp index 52fa6f4..b770c0e 100644 --- a/src/mesa/drivers/dri/i965/brw_fs.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs.cpp @@ -179,6 +179,7 @@ ALU3(BFI2) ALU1(FBH) ALU1(FBL) ALU1(CBIT) +ALU3(MAD) /** Gen4 predicated IF. */ fs_inst * diff --git a/src/mesa/drivers/dri/i965/brw_fs.h b/src/mesa/drivers/dri/i965/brw_fs.h index 9d240b5..cb4ac3b 100644 --- a/src/mesa/drivers/dri/i965/brw_fs.h +++ b/src/mesa/drivers/dri/i965/brw_fs.h @@ -285,6 +285,7 @@ public: fs_inst *FBH(fs_reg dst, fs_reg value); fs_inst *FBL(fs_reg dst, fs_reg value); fs_inst *CBIT(fs_reg dst, fs_reg value); + fs_inst *MAD(fs_reg dst, fs_reg c, fs_reg b, fs_reg a); int type_size(const struct glsl_type *type); fs_inst *get_instruction_generating_reg(fs_inst *start, diff --git a/src/mesa/drivers/dri/i965/brw_fs_channel_expressions.cpp b/src/mesa/drivers/dri/i965/brw_fs_channel_expressions.cpp index 4afae24..fa02d9b 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_channel_expressions.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_channel_expressions.cpp @@ -360,6 +360,7 @@ ir_channel_expressions_visitor::visit_leave(ir_assignment *ir) assert(!not yet supported); break; + case ir_triop_fma: case ir_triop_lrp: case ir_triop_bitfield_extract: for (i = 0; i vector_elements; i++) { diff --git a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp index 964ad40..ac85d25 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp @@ -717,6 +717,13 @@ fs_visitor::visit(ir_expression *ir) break; } + case ir_triop_fma: + /* Note that the instruction's argument order is reversed from GLSL + * and the IR. + */ + emit(MAD(this-result, op[2], op[1], op[0])); + break; + What happens if one of the ops is in a form that we can't encode in a 3-op instruction (e.g. a constant)? That's handled in patch 4/15 for the vs, and it's handled inside emit_lrp, but I don't see it handled here. I read your reply and thought oh crap, I bet that doesn't work but it actually does work. I honestly don't have any idea how or why. With fma(a, b, c) I get: mad(8) g141F g34,1,1F.x g2.44,1,1F.x g24,1,1F.x mad(8) g131F g3.14,1,1F.x g2.54,1,1F.x g2.14,1,1F.x mad(8) g121F g3.24,1,1F.x g2.64,1,1F.x g2.24,1,1F.x mad(8) g111F g3.34,1,1F.x g2.74,1,1F.x g2.34,1,1F.x With fma(a, vec4(1.0, 1.0, 2.0, 2.0), c) I get: mov(8) g131F 1F mov(8) g101F 1F mov(8) g71F 2F mov(8) g41F 2F mad(8) g141F g2.44,1,1F.x g134,1,1F g24,1,1F.x mad(8) g111F g2.54,1,1F.x g104,1,1F g2.14,1,1F.x mad(8) g81F g2.64,1,1F.x g74,1,1F g2.24,1,1F.x mad(8) g51F g2.74,1,1F.x g44,1,1F g2.34,1,1F.x The IR just looks like it contains inline (constant float (...)) in the fma expression, so it doesn't seem to be something in the frontend doing it. Any guess what's going on? Aha! I see what it is. If you look at fs_visitor::visit(ir_constant *), you'll see that it emits MOVs. Which means that in the code we were discussing, op[i] will never be a constant. I double checked this with Eric, and both of us think that op[i] will only ever be of type GRF or UNIFORM, so probably this code is fine. But it would be nice to have an assertion near the top of fs_visitor::visit(ir_expression *) to verify that this-result is 3-source compatible before we store it in op[operand]. ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] i965: Allocate just enough space for user clip planes in uniform arrays.
On 25 August 2013 23:46, Kenneth Graunke kenn...@whitecape.org wrote: Previously, we allocated space in brw_vs_prog_data's params and pull_params arrays for MAX_CLIP_PLANES vec4s---even when it wasn't necessary. On a 64-bit architecture, this used 0.5 kB of space (8 clip planes * 4 floats per plane * 8 bytes per float pointer * 2 arrays of pointers = 512 bytes). Since this cost is per-vertex shader, it added up. Conveniently, we already store the number of clip plane constants in the program key. By using that, we can allocate the exact amount of space needed. For the common case where user clipping is disabled, this means 0 bytes. While we're here, mention exactly what code requires this extra space, since it wasn't obvious. Signed-off-by: Kenneth Graunke kenn...@whitecape.org Reviewed-by: Paul Berry stereotype...@gmail.com ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH] glsl: Disallow uniform block layout qualifiers on non-uniform block vars.
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=68460 Cc: 9.2 mesa-sta...@lists.freedesktop.org --- src/glsl/ast_to_hir.cpp | 17 + 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp index feff586..bb25d81 100644 --- a/src/glsl/ast_to_hir.cpp +++ b/src/glsl/ast_to_hir.cpp @@ -1849,9 +1849,18 @@ is_varying_var(ir_variable *var, _mesa_glsl_parser_targets target) static void validate_matrix_layout_for_type(struct _mesa_glsl_parse_state *state, YYLTYPE *loc, - const glsl_type *type) +const glsl_type *type, +ir_variable *var) { - if (!type-is_matrix()) { + if (var !var-is_in_uniform_block()) { + /* Layout qualifiers may only apply to interface blocks and fields in + * them. + */ + _mesa_glsl_error(loc, state, + uniform block layout qualifiers row_major and + column_major may not be applied to variables + outside of uniform blocks); + } else if (!type-is_matrix()) { /* The OpenGL ES 3.0 conformance tests did not originally allow * matrix layout qualifiers on non-matrices. However, the OpenGL * 4.4 and OpenGL ES 3.0 (revision TBD) specifications were @@ -2302,7 +2311,7 @@ apply_type_qualifier_to_variable(const struct ast_type_qualifier *qual, } if (qual-flags.q.row_major || qual-flags.q.column_major) { - validate_matrix_layout_for_type(state, loc, var-type); + validate_matrix_layout_for_type(state, loc, var-type, var); } } @@ -4476,7 +4485,7 @@ ast_process_structure_or_interface_block(exec_list *instructions, row_major and column_major can only be applied to uniform interface blocks); } else - validate_matrix_layout_for_type(state, loc, field_type); + validate_matrix_layout_for_type(state, loc, field_type, NULL); } if (qual-flags.q.uniform qual-has_interpolation()) { -- 1.8.3.2 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH] clover: work around altivec build failure with GNU C++ and -std=c++
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=68504 Bugzilla: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58241 CC: mesa-sta...@lists.freedesktop.org --- configure.ac | 11 +++ src/gallium/state_trackers/clover/Makefile.am | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 40e052c..15831fd 100644 --- a/configure.ac +++ b/configure.ac @@ -1390,6 +1390,17 @@ if test x$enable_opencl = xyes; then AC_MSG_ERROR([pkg-config cannot use libclc.pc which is required to build clover]) fi +dnl +dnl Workaround for altivec failure with GNU C++ and -std=c++0x, PR58241 +dnl + +if test x${ac_cv_cxx_compiler_gnu} = xyes ; then +CLOVER_CXX_STD=gnu++0x +else +CLOVER_CXX_STD=c++0x +fi +AC_SUBST([CLOVER_CXX_STD]) + GALLIUM_STATE_TRACKERS_DIRS=$GALLIUM_STATE_TRACKERS_DIRS clover GALLIUM_TARGET_DIRS=$GALLIUM_TARGET_DIRS opencl enable_gallium_loader=yes diff --git a/src/gallium/state_trackers/clover/Makefile.am b/src/gallium/state_trackers/clover/Makefile.am index b4c197a..e339c1f 100644 --- a/src/gallium/state_trackers/clover/Makefile.am +++ b/src/gallium/state_trackers/clover/Makefile.am @@ -30,7 +30,7 @@ libclllvm_la_SOURCES = \ llvm/invocation.cpp libclover_la_CXXFLAGS = \ - -std=c++0x + -std=$(CLOVER_CXX_STD) libclover_la_LIBADD = \ libcltgsi.la libclllvm.la -- 1.8.1.5 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH] configure.ac: Fix order of and/or for AM_CONDITIONAL
From: Kris em...@zero-io.net Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=68544 CC: mesa-sta...@lists.freedesktop.org --- configure.ac | 11 +-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index 40e052c..f135f81 100644 --- a/configure.ac +++ b/configure.ac @@ -1924,10 +1924,17 @@ AM_CONDITIONAL(HAVE_GALLIUM_LLVMPIPE, test x$HAVE_GALLIUM_LLVMPIPE = xyes) AM_CONDITIONAL(NEED_GALLIUM_SOFTPIPE_DRIVER, test x$HAVE_GALLIUM_SVGA = xyes -o \ x$HAVE_GALLIUM_I915 = xyes -o \ x$HAVE_GALLIUM_SOFTPIPE = xyes) -AM_CONDITIONAL(NEED_GALLIUM_LLVMPIPE_DRIVER, test x$HAVE_GALLIUM_I915 = xyes -o \ - x$HAVE_GALLIUM_SOFTPIPE = xyes -a \ + +if test x$HAVE_GALLIUM_I915 = xyes -o x$HAVE_GALLIUM_SOFTPIPE = xyes; then + NEED_GALLIUM_LLVMPIPE=yes +else + NEED_GALLIUM_LLVMPIPE=no +fi + +AM_CONDITIONAL(NEED_GALLIUM_LLVMPIPE_DRIVER, test x$NEED_GALLIUM_LLVMPIPE = xyes -a \ x$MESA_LLVM = x1) + if test x$enable_gallium_loader = xyes; then GALLIUM_WINSYS_DIRS=$GALLIUM_WINSYS_DIRS sw/null -- 1.8.1.5 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [Bug 68504] 9.2-rc1 workaround for clover build failure on ppc/altivec: cannot convert 'bool' to '__vector(4) __bool int' in return
https://bugs.freedesktop.org/show_bug.cgi?id=68504 Chí-Thanh Christopher Nguyễn chith...@gentoo.org changed: What|Removed |Added Status|RESOLVED|REOPENED Resolution|NOTOURBUG |--- Summary|9.2-rc1 clover fails to |9.2-rc1 workaround for |build on ppc: cannot|clover build failure on |convert 'bool' to |ppc/altivec: cannot convert |'__vector(4) __bool int' in |'bool' to '__vector(4) |return |__bool int' in return --- Comment #6 from Chí-Thanh Christopher Nguyễn chith...@gentoo.org --- Patch with workaround sent: http://lists.freedesktop.org/archives/mesa-dev/2013-August/043890.html Tested to build successfully on Gentoo PPC. -- 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 00/22] i965/gen7: Initial geometry shader support, part 2
This is a re-spin of patches 23-30 of my series i965/gen7: Initial geometry shader support. from 8/20. Based on code review, I've made the following changes: - Rather than using vec4_gs to refer to the new user-programmable geometry shader functionality, and gs to refer to the old fixed-function stuff, we use gs to refer to the user-programmable geometry shaders and ff_gs to refer to the old fixed-function stuff. - The contents of brw-vs and brw-gs are reorganized into three categories: brw-vec4, which contains global register allocation data structures that are shared between VS and GS, brw-{vs,gs}-base, which contains the the data that needs to be replicated between VS and GS, and brw-{vs,gs}-prog_data, which is different between VS and GS. - The existing state atoms brw_vs_pull_constants, brw_vs_binding_table, gen6_vs_push_constants, brw_texture_surfaces, and gen7_vs_state are all refactored into general-purpose functions that implement functionality that is shared between vs and gs, and special-purpose functions that are vs-specific. This makes it a lot simpler to add gs versions of all of these state atoms. - I believe the code for setting up the sampler state is now correct (it's largely shared with VS so there's not much to it), but I have not yet had a chance to test it. Once this series is applied, i965/gen7 users should be able to try out geometry shaders by setting the environment variables: MESA_GL_VERSION_OVERRIDE=3.2 MESA_GLSL_VERSION_OVERRIDE=150 As before, the following tasks still need to be done: - Support EndPrimitive() - Support gl_PrimitiveID (and gl_PrimitiveIDIn) - Support 64 varying components - Support new primitive types (e.g. GL_TRIANGLES_ADJACENCY) - Support built-in variables being used as GS inputs (e.g. gl_in[].gl_PointSize) - A lot more testing This series is available on branch gs-phase-3 of https://github.com/stereotype441/mesa.git. Additional unfinished geometry shader work is in branch gs. Note that the gs branch is rebased very frequently. [PATCH 01/22] i965: rename legacy gs structs and functions to ff_gs. [PATCH 02/22] i965: Rename user-defined gs structs from vec4_gs to gs. [PATCH 03/22] i965: Move vec4 register allocation data structures to brw-vec4. [PATCH 04/22] i965/gs: Update defines related to GS surface organization. [PATCH 05/22] i965: Move data from brw-vs into a base class if gs will also need it. [PATCH 06/22] i965/gs: Create brw_context::gs structure to track GS program state. [PATCH 07/22] i965: Make CACHE_NEW_GS_PROG. [PATCH 08/22] i965/gs: Allocate URB space for use by GS. [PATCH 09/22] i965/gs: Allocate push constant space for use by GS. [PATCH 10/22] i965: Make sure constants re-sent after constant buffer reallocation. [PATCH 11/22] i965: generalize brw_vs_pull_constants in preparation for GS. [PATCH 12/22] i965/vs: generalize brw_vs_binding_table in preparation for GS. [PATCH 13/22] i965/gs: Implement support for geometry shader surfaces. [PATCH 14/22] i965/gs: make the state atom for compiling Gen7 geometry shaders. [PATCH 15/22] i965/vs: generalize gen6_vs_push_constants in preparation for GS. [PATCH 16/22] i965: Modify signature to update_texture_surface functions. [PATCH 17/22] i965/gs: generalize brw_texture_surfaces in preparation for gs. [PATCH 18/22] i965/gs: add geometry shader support to brw_texture_surfaces. [PATCH 19/22] i965/gs: Implement support for geometry shader samplers. [PATCH 20/22] i965/gen7: merge defines for 3DSTATE{VS,GS,WM} dword 2 [PATCH 21/22] i965/gen7: Generalize gen7_vs_state in preparation for GS. [PATCH 22/22] i965/gs: Add a state atom to set up geometry shader state. ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 02/22] i965: Rename user-defined gs structs from vec4_gs to gs.
Now that the name gs is no longer used to refer to the legacy fixed function geometry shaders, we can use it to refer to user-defined geometry shaders. --- src/mesa/drivers/dri/i965/brw_context.h | 4 ++-- src/mesa/drivers/dri/i965/brw_vec4_gs_visitor.cpp | 2 +- src/mesa/drivers/dri/i965/brw_vec4_gs_visitor.h | 12 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h index 381fe1f..4045c86 100644 --- a/src/mesa/drivers/dri/i965/brw_context.h +++ b/src/mesa/drivers/dri/i965/brw_context.h @@ -531,10 +531,10 @@ struct brw_vs_prog_data { }; -/* Note: brw_vec4_gs_prog_data_compare() must be updated when adding fields to +/* Note: brw_gs_prog_data_compare() must be updated when adding fields to * this struct! */ -struct brw_vec4_gs_prog_data +struct brw_gs_prog_data { struct brw_vec4_prog_data base; diff --git a/src/mesa/drivers/dri/i965/brw_vec4_gs_visitor.cpp b/src/mesa/drivers/dri/i965/brw_vec4_gs_visitor.cpp index 3549d5d..91a24ee 100644 --- a/src/mesa/drivers/dri/i965/brw_vec4_gs_visitor.cpp +++ b/src/mesa/drivers/dri/i965/brw_vec4_gs_visitor.cpp @@ -34,7 +34,7 @@ const unsigned MAX_GS_INPUT_VERTICES = 6; namespace brw { vec4_gs_visitor::vec4_gs_visitor(struct brw_context *brw, - struct brw_vec4_gs_compile *c, + struct brw_gs_compile *c, struct gl_shader_program *prog, struct brw_shader *shader, void *mem_ctx) diff --git a/src/mesa/drivers/dri/i965/brw_vec4_gs_visitor.h b/src/mesa/drivers/dri/i965/brw_vec4_gs_visitor.h index e998666..87b58ab 100644 --- a/src/mesa/drivers/dri/i965/brw_vec4_gs_visitor.h +++ b/src/mesa/drivers/dri/i965/brw_vec4_gs_visitor.h @@ -33,7 +33,7 @@ #include brw_vec4.h -struct brw_vec4_gs_prog_key +struct brw_gs_prog_key { struct brw_vec4_prog_key base; @@ -44,11 +44,11 @@ struct brw_vec4_gs_prog_key /** * Scratch data used when compiling a GLSL geometry shader. */ -struct brw_vec4_gs_compile +struct brw_gs_compile { struct brw_vec4_compile base; - struct brw_vec4_gs_prog_key key; - struct brw_vec4_gs_prog_data prog_data; + struct brw_gs_prog_key key; + struct brw_gs_prog_data prog_data; struct brw_geometry_program *gp; }; @@ -61,7 +61,7 @@ class vec4_gs_visitor : public vec4_visitor { public: vec4_gs_visitor(struct brw_context *brw, - struct brw_vec4_gs_compile *c, + struct brw_gs_compile *c, struct gl_shader_program *prog, struct brw_shader *shader, void *mem_ctx); @@ -82,7 +82,7 @@ private: int setup_varying_inputs(int payload_reg, int *attribute_map); src_reg vertex_count; - const struct brw_vec4_gs_compile * const c; + const struct brw_gs_compile * const c; }; } /* namespace brw */ -- 1.8.4 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 01/22] i965: rename legacy gs structs and functions to ff_gs.
ff is for fixed function. This frees up the name gs to refer to user-defined geometry shaders. --- src/mesa/drivers/dri/i965/brw_context.h | 14 +-- src/mesa/drivers/dri/i965/brw_gs.c | 42 src/mesa/drivers/dri/i965/brw_gs.h | 19 ++-- src/mesa/drivers/dri/i965/brw_gs_emit.c | 150 ++- src/mesa/drivers/dri/i965/brw_gs_state.c | 17 +-- src/mesa/drivers/dri/i965/brw_misc_state.c | 10 +- src/mesa/drivers/dri/i965/brw_state.h| 2 +- src/mesa/drivers/dri/i965/brw_state_dump.c | 4 +- src/mesa/drivers/dri/i965/brw_state_upload.c | 8 +- src/mesa/drivers/dri/i965/gen6_gs_state.c| 10 +- src/mesa/drivers/dri/i965/gen6_sol.c | 12 +-- src/mesa/drivers/dri/i965/gen6_urb.c | 8 +- src/mesa/drivers/dri/i965/gen7_disable.c | 2 +- src/mesa/drivers/dri/i965/gen7_urb.c | 4 +- 14 files changed, 156 insertions(+), 146 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h index c456e61..381fe1f 100644 --- a/src/mesa/drivers/dri/i965/brw_context.h +++ b/src/mesa/drivers/dri/i965/brw_context.h @@ -474,7 +474,7 @@ struct brw_clip_prog_data { GLuint total_grf; }; -struct brw_gs_prog_data { +struct brw_ff_gs_prog_data { GLuint urb_read_length; GLuint total_grf; @@ -678,8 +678,8 @@ enum brw_cache_id { BRW_SF_UNIT, /* scissor state on gen6 */ BRW_VS_UNIT, BRW_VS_PROG, - BRW_GS_UNIT, - BRW_GS_PROG, + BRW_FF_GS_UNIT, + BRW_FF_GS_PROG, BRW_CLIP_VP, BRW_CLIP_UNIT, BRW_CLIP_PROG, @@ -768,8 +768,8 @@ enum shader_time_shader_type { #define CACHE_NEW_SF_UNIT(1BRW_SF_UNIT) #define CACHE_NEW_VS_UNIT(1BRW_VS_UNIT) #define CACHE_NEW_VS_PROG(1BRW_VS_PROG) -#define CACHE_NEW_GS_UNIT(1BRW_GS_UNIT) -#define CACHE_NEW_GS_PROG(1BRW_GS_PROG) +#define CACHE_NEW_FF_GS_UNIT (1BRW_FF_GS_UNIT) +#define CACHE_NEW_FF_GS_PROG (1BRW_FF_GS_PROG) #define CACHE_NEW_CLIP_VP(1BRW_CLIP_VP) #define CACHE_NEW_CLIP_UNIT (1BRW_CLIP_UNIT) #define CACHE_NEW_CLIP_PROG (1BRW_CLIP_PROG) @@ -1162,7 +1162,7 @@ struct brw_context } vs; struct { - struct brw_gs_prog_data *prog_data; + struct brw_ff_gs_prog_data *prog_data; bool prog_active; /** Offset in the program cache to the CLIP program pre-gen6 */ @@ -1171,7 +1171,7 @@ struct brw_context uint32_t bind_bo_offset; uint32_t surf_offset[BRW_MAX_GS_SURFACES]; - } gs; + } ff_gs; struct { struct brw_clip_prog_data *prog_data; diff --git a/src/mesa/drivers/dri/i965/brw_gs.c b/src/mesa/drivers/dri/i965/brw_gs.c index bd32db1..3882c06 100644 --- a/src/mesa/drivers/dri/i965/brw_gs.c +++ b/src/mesa/drivers/dri/i965/brw_gs.c @@ -45,10 +45,10 @@ #include glsl/ralloc.h -static void compile_gs_prog( struct brw_context *brw, -struct brw_gs_prog_key *key ) +static void compile_ff_gs_prog(struct brw_context *brw, + struct brw_ff_gs_prog_key *key) { - struct brw_gs_compile c; + struct brw_ff_gs_compile c; const GLuint *program; void *mem_ctx; GLuint program_size; @@ -114,13 +114,13 @@ static void compile_gs_prog( struct brw_context *brw, */ switch (key-primitive) { case _3DPRIM_QUADLIST: -brw_gs_quads( c, key ); +brw_ff_gs_quads( c, key ); break; case _3DPRIM_QUADSTRIP: -brw_gs_quad_strip( c, key ); +brw_ff_gs_quad_strip( c, key ); break; case _3DPRIM_LINELOOP: -brw_gs_lines( c ); +brw_ff_gs_lines( c ); break; default: ralloc_free(mem_ctx); @@ -142,16 +142,16 @@ static void compile_gs_prog( struct brw_context *brw, printf(\n); } - brw_upload_cache(brw-cache, BRW_GS_PROG, + brw_upload_cache(brw-cache, BRW_FF_GS_PROG, c.key, sizeof(c.key), program, program_size, c.prog_data, sizeof(c.prog_data), - brw-gs.prog_offset, brw-gs.prog_data); + brw-ff_gs.prog_offset, brw-ff_gs.prog_data); ralloc_free(mem_ctx); } -static void populate_key( struct brw_context *brw, - struct brw_gs_prog_key *key ) +static void populate_key(struct brw_context *brw, + struct brw_ff_gs_prog_key *key) { static const unsigned swizzle_for_offset[4] = { BRW_SWIZZLE4(0, 1, 2, 3), @@ -225,34 +225,34 @@ static void populate_key( struct brw_context *brw, /* Calculate interpolants for triangle and line rasterization. */ static void -brw_upload_gs_prog(struct brw_context *brw) +brw_upload_ff_gs_prog(struct brw_context *brw) { - struct brw_gs_prog_key key; + struct brw_ff_gs_prog_key key; /* Populate the key: */
[Mesa-dev] [PATCH 03/22] i965: Move vec4 register allocation data structures to brw-vec4.
This will avoid confusion when we add geometry shaders, since these data structures will be shared by vertex and geometry shaders. --- src/mesa/drivers/dri/i965/brw_context.h| 31 -- .../drivers/dri/i965/brw_vec4_reg_allocate.cpp | 31 +++--- 2 files changed, 33 insertions(+), 29 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h index 4045c86..13daf1e 100644 --- a/src/mesa/drivers/dri/i965/brw_context.h +++ b/src/mesa/drivers/dri/i965/brw_context.h @@ -1120,20 +1120,11 @@ struct brw_context */ struct brw_vue_map vue_map_geom_out; + /** +* Data structures used by all vec4 program compiles (not specific to any +* particular program). +*/ struct { - struct brw_vs_prog_data *prog_data; - - drm_intel_bo *scratch_bo; - drm_intel_bo *const_bo; - /** Offset in the program cache to the VS program */ - uint32_t prog_offset; - uint32_t state_offset; - - uint32_t push_const_offset; /* Offset in the batchbuffer */ - int push_const_size; /* in 256-bit register increments */ - - /** @{ register allocator */ - struct ra_regs *regs; /** @@ -1147,7 +1138,19 @@ struct brw_context * GRF for that object. */ uint8_t *ra_reg_to_grf; - /** @} */ + } vec4; + + struct { + struct brw_vs_prog_data *prog_data; + + drm_intel_bo *scratch_bo; + drm_intel_bo *const_bo; + /** Offset in the program cache to the VS program */ + uint32_t prog_offset; + uint32_t state_offset; + + uint32_t push_const_offset; /* Offset in the batchbuffer */ + int push_const_size; /* in 256-bit register increments */ uint32_t bind_bo_offset; uint32_t surf_offset[BRW_MAX_VS_SURFACES]; diff --git a/src/mesa/drivers/dri/i965/brw_vec4_reg_allocate.cpp b/src/mesa/drivers/dri/i965/brw_vec4_reg_allocate.cpp index 7984203..3777027 100644 --- a/src/mesa/drivers/dri/i965/brw_vec4_reg_allocate.cpp +++ b/src/mesa/drivers/dri/i965/brw_vec4_reg_allocate.cpp @@ -114,14 +114,14 @@ brw_vec4_alloc_reg_set(struct brw_context *brw) ra_reg_count += base_reg_count - (class_sizes[i] - 1); } - ralloc_free(brw-vs.ra_reg_to_grf); - brw-vs.ra_reg_to_grf = ralloc_array(brw, uint8_t, ra_reg_count); - ralloc_free(brw-vs.regs); - brw-vs.regs = ra_alloc_reg_set(brw, ra_reg_count); + ralloc_free(brw-vec4.ra_reg_to_grf); + brw-vec4.ra_reg_to_grf = ralloc_array(brw, uint8_t, ra_reg_count); + ralloc_free(brw-vec4.regs); + brw-vec4.regs = ra_alloc_reg_set(brw, ra_reg_count); if (brw-gen = 6) - ra_set_allocate_round_robin(brw-vs.regs); - ralloc_free(brw-vs.classes); - brw-vs.classes = ralloc_array(brw, int, class_count + 1); + ra_set_allocate_round_robin(brw-vec4.regs); + ralloc_free(brw-vec4.classes); + brw-vec4.classes = ralloc_array(brw, int, class_count + 1); /* Now, add the registers to their classes, and add the conflicts * between them and the base GRF registers (and also each other). @@ -129,17 +129,17 @@ brw_vec4_alloc_reg_set(struct brw_context *brw) int reg = 0; for (int i = 0; i class_count; i++) { int class_reg_count = base_reg_count - (class_sizes[i] - 1); - brw-vs.classes[i] = ra_alloc_reg_class(brw-vs.regs); + brw-vec4.classes[i] = ra_alloc_reg_class(brw-vec4.regs); for (int j = 0; j class_reg_count; j++) { -ra_class_add_reg(brw-vs.regs, brw-vs.classes[i], reg); +ra_class_add_reg(brw-vec4.regs, brw-vec4.classes[i], reg); -brw-vs.ra_reg_to_grf[reg] = j; +brw-vec4.ra_reg_to_grf[reg] = j; for (int base_reg = j; base_reg j + class_sizes[i]; base_reg++) { - ra_add_transitive_reg_conflict(brw-vs.regs, base_reg, reg); + ra_add_transitive_reg_conflict(brw-vec4.regs, base_reg, reg); } reg++; @@ -147,7 +147,7 @@ brw_vec4_alloc_reg_set(struct brw_context *brw) } assert(reg == ra_reg_count); - ra_set_finalize(brw-vs.regs, NULL); + ra_set_finalize(brw-vec4.regs, NULL); } void @@ -191,13 +191,14 @@ vec4_visitor::reg_allocate() int node_count = virtual_grf_count; int first_payload_node = node_count; node_count += payload_reg_count; - struct ra_graph *g = ra_alloc_interference_graph(brw-vs.regs, node_count); + struct ra_graph *g = + ra_alloc_interference_graph(brw-vec4.regs, node_count); for (int i = 0; i virtual_grf_count; i++) { int size = this-virtual_grf_sizes[i]; assert(size = 1 size = 2 Register allocation relies on split_virtual_grfs().); - ra_set_node_class(g, i, brw-vs.classes[size - 1]); + ra_set_node_class(g, i, brw-vec4.classes[size - 1]); for (int j = 0; j i; j++) { if (virtual_grf_interferes(i, j)) { @@ -230,7 +231,7 @@ vec4_visitor::reg_allocate() for (int i = 0; i virtual_grf_count;
[Mesa-dev] [PATCH 04/22] i965/gs: Update defines related to GS surface organization.
Defines that previously referred to VS now refer to VEC4, since they will be shared by the user-programmable vertex shader and geometry shader stages. Defines that previously referred to the Gen6 geometry shader stage (which is only used for transform feedback) are now renamed to explicitly refer to Gen6, to avoid confusion with the Gen7 user-programmable geometry shader stage. Based on work by Eric Anholt e...@anholt.net. --- src/mesa/drivers/dri/i965/brw_context.h | 22 +++--- src/mesa/drivers/dri/i965/brw_gs_emit.c | 2 +- src/mesa/drivers/dri/i965/brw_vec4_emit.cpp | 10 +- src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp | 4 ++-- src/mesa/drivers/dri/i965/brw_vec4_vp.cpp| 2 +- src/mesa/drivers/dri/i965/brw_vs_surface_state.c | 8 src/mesa/drivers/dri/i965/brw_wm_surface_state.c | 4 ++-- src/mesa/drivers/dri/i965/gen6_sol.c | 6 +++--- 8 files changed, 29 insertions(+), 29 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h index 13daf1e..dcd4c9a 100644 --- a/src/mesa/drivers/dri/i965/brw_context.h +++ b/src/mesa/drivers/dri/i965/brw_context.h @@ -615,10 +615,10 @@ struct brw_gs_prog_data *| 36 | UBO 11 | *+---+ * - * Our VS binding tables are programmed as follows: + * Our VS (and Gen7 GS) binding tables are programmed as follows: * *+-+-+ - *| 0 | VS Pull Constant Buffer | + *| 0 | Pull Constant Buffer| *+-+-+ *| 1 | Texture 0 | *| . | . | @@ -648,14 +648,14 @@ struct brw_gs_prog_data /** Maximum size of the binding table. */ #define BRW_MAX_WM_SURFACES (SURF_INDEX_WM_SHADER_TIME + 1) -#define SURF_INDEX_VERT_CONST_BUFFER (0) -#define SURF_INDEX_VS_TEXTURE(t) (SURF_INDEX_VERT_CONST_BUFFER + 1 + (t)) -#define SURF_INDEX_VS_UBO(u) (SURF_INDEX_VS_TEXTURE(BRW_MAX_TEX_UNIT) + u) -#define SURF_INDEX_VS_SHADER_TIME(SURF_INDEX_VS_UBO(12)) -#define BRW_MAX_VS_SURFACES (SURF_INDEX_VS_SHADER_TIME + 1) +#define SURF_INDEX_VEC4_CONST_BUFFER (0) +#define SURF_INDEX_VEC4_TEXTURE(t) (SURF_INDEX_VEC4_CONST_BUFFER + 1 + (t)) +#define SURF_INDEX_VEC4_UBO(u) (SURF_INDEX_VEC4_TEXTURE(BRW_MAX_TEX_UNIT) + u) +#define SURF_INDEX_VEC4_SHADER_TIME (SURF_INDEX_VEC4_UBO(12)) +#define BRW_MAX_VEC4_SURFACES(SURF_INDEX_VEC4_SHADER_TIME + 1) -#define SURF_INDEX_SOL_BINDING(t)((t)) -#define BRW_MAX_GS_SURFACES SURF_INDEX_SOL_BINDING(BRW_MAX_SOL_BINDINGS) +#define SURF_INDEX_GEN6_SOL_BINDING(t) (t) +#define BRW_MAX_GEN6_GS_SURFACES SURF_INDEX_GEN6_SOL_BINDING(BRW_MAX_SOL_BINDINGS) /** * Stride in bytes between shader_time entries. @@ -1153,7 +1153,7 @@ struct brw_context int push_const_size; /* in 256-bit register increments */ uint32_t bind_bo_offset; - uint32_t surf_offset[BRW_MAX_VS_SURFACES]; + uint32_t surf_offset[BRW_MAX_VEC4_SURFACES]; /** SAMPLER_STATE count and table offset */ uint32_t sampler_count; @@ -1173,7 +1173,7 @@ struct brw_context uint32_t state_offset; uint32_t bind_bo_offset; - uint32_t surf_offset[BRW_MAX_GS_SURFACES]; + uint32_t surf_offset[BRW_MAX_GEN6_GS_SURFACES]; } ff_gs; struct { diff --git a/src/mesa/drivers/dri/i965/brw_gs_emit.c b/src/mesa/drivers/dri/i965/brw_gs_emit.c index 7fff53e..2c94eb0 100644 --- a/src/mesa/drivers/dri/i965/brw_gs_emit.c +++ b/src/mesa/drivers/dri/i965/brw_gs_emit.c @@ -436,7 +436,7 @@ gen6_sol_program(struct brw_ff_gs_compile *c, struct brw_ff_gs_prog_key *key, final_write ? c-reg.temp : brw_null_reg(), /* dest */ 1, /* msg_reg_nr */ c-reg.header, /* src0 */ - SURF_INDEX_SOL_BINDING(binding), /* binding_table_index */ + SURF_INDEX_GEN6_SOL_BINDING(binding), /* binding_table_index */ final_write); /* send_commit_msg */ } } diff --git a/src/mesa/drivers/dri/i965/brw_vec4_emit.cpp b/src/mesa/drivers/dri/i965/brw_vec4_emit.cpp index 1f00260..bf04bd9 100644 --- a/src/mesa/drivers/dri/i965/brw_vec4_emit.cpp +++ b/src/mesa/drivers/dri/i965/brw_vec4_emit.cpp @@ -155,7 +155,7 @@ vec4_generator::~vec4_generator() void vec4_generator::mark_surface_used(unsigned surf_index) { - assert(surf_index BRW_MAX_VS_SURFACES); + assert(surf_index BRW_MAX_VEC4_SURFACES); prog_data-binding_table_size = MAX2(prog_data-binding_table_size, surf_index + 1); @@ -386,7 +386,7 @@ vec4_generator::generate_tex(vec4_instruction *inst, dst, inst-base_mrf, src, - SURF_INDEX_VS_TEXTURE(inst-sampler), +
[Mesa-dev] [PATCH 05/22] i965: Move data from brw-vs into a base class if gs will also need it.
This paves the way for sharing the code that will set up the vertex and geometry shader pipeline state. --- src/mesa/drivers/dri/i965/brw_context.h | 47 ++-- src/mesa/drivers/dri/i965/brw_draw.c | 3 +- src/mesa/drivers/dri/i965/brw_misc_state.c | 6 +-- src/mesa/drivers/dri/i965/brw_vs.c | 12 +++--- src/mesa/drivers/dri/i965/brw_vs_state.c | 24 ++-- src/mesa/drivers/dri/i965/brw_vs_surface_state.c | 43 -- src/mesa/drivers/dri/i965/brw_vtbl.c | 2 +- src/mesa/drivers/dri/i965/brw_wm_sampler_state.c | 8 ++-- src/mesa/drivers/dri/i965/brw_wm_surface_state.c | 4 +- src/mesa/drivers/dri/i965/gen6_sampler_state.c | 2 +- src/mesa/drivers/dri/i965/gen6_vs_state.c| 23 +++- src/mesa/drivers/dri/i965/gen7_vs_state.c| 18 + 12 files changed, 107 insertions(+), 85 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h index dcd4c9a..9784956 100644 --- a/src/mesa/drivers/dri/i965/brw_context.h +++ b/src/mesa/drivers/dri/i965/brw_context.h @@ -818,6 +818,32 @@ struct brw_query_object { /** + * Data shared between brw_context::vs and brw_context::gs + */ +struct brw_vec4_context_base +{ + drm_intel_bo *scratch_bo; + drm_intel_bo *const_bo; + /** Offset in the program cache to the program */ + uint32_t prog_offset; + uint32_t state_offset; + + uint32_t push_const_offset; /* Offset in the batchbuffer */ + int push_const_size; /* in 256-bit register increments */ + + uint32_t bind_bo_offset; + uint32_t surf_offset[BRW_MAX_VEC4_SURFACES]; + + /** SAMPLER_STATE count and table offset */ + uint32_t sampler_count; + uint32_t sampler_offset; + + /** Offsets in the batch to sampler default colors (texture border color) */ + uint32_t sdc_offset[BRW_MAX_TEX_UNIT]; +}; + + +/** * brw_context is derived from gl_context. */ struct brw_context @@ -1141,27 +1167,8 @@ struct brw_context } vec4; struct { + struct brw_vec4_context_base base; struct brw_vs_prog_data *prog_data; - - drm_intel_bo *scratch_bo; - drm_intel_bo *const_bo; - /** Offset in the program cache to the VS program */ - uint32_t prog_offset; - uint32_t state_offset; - - uint32_t push_const_offset; /* Offset in the batchbuffer */ - int push_const_size; /* in 256-bit register increments */ - - uint32_t bind_bo_offset; - uint32_t surf_offset[BRW_MAX_VEC4_SURFACES]; - - /** SAMPLER_STATE count and table offset */ - uint32_t sampler_count; - uint32_t sampler_offset; - - /** Offsets in the batch to sampler default colors (texture border color) - */ - uint32_t sdc_offset[BRW_MAX_TEX_UNIT]; } vs; struct { diff --git a/src/mesa/drivers/dri/i965/brw_draw.c b/src/mesa/drivers/dri/i965/brw_draw.c index c7164ac..96ba817 100644 --- a/src/mesa/drivers/dri/i965/brw_draw.c +++ b/src/mesa/drivers/dri/i965/brw_draw.c @@ -376,7 +376,8 @@ static bool brw_try_draw_prims( struct gl_context *ctx, * index. */ brw-wm.sampler_count = _mesa_fls(ctx-FragmentProgram._Current-Base.SamplersUsed); - brw-vs.sampler_count = _mesa_fls(ctx-VertexProgram._Current-Base.SamplersUsed); + brw-vs.base.sampler_count = + _mesa_fls(ctx-VertexProgram._Current-Base.SamplersUsed); /* We have to validate the textures *before* checking for fallbacks; * otherwise, the software fallback won't be able to rely on the diff --git a/src/mesa/drivers/dri/i965/brw_misc_state.c b/src/mesa/drivers/dri/i965/brw_misc_state.c index 3492ea9..16a41cc 100644 --- a/src/mesa/drivers/dri/i965/brw_misc_state.c +++ b/src/mesa/drivers/dri/i965/brw_misc_state.c @@ -77,7 +77,7 @@ static void upload_binding_table_pointers(struct brw_context *brw) { BEGIN_BATCH(6); OUT_BATCH(_3DSTATE_BINDING_TABLE_POINTERS 16 | (6 - 2)); - OUT_BATCH(brw-vs.bind_bo_offset); + OUT_BATCH(brw-vs.base.bind_bo_offset); OUT_BATCH(0); /* gs */ OUT_BATCH(0); /* clip */ OUT_BATCH(0); /* sf */ @@ -113,7 +113,7 @@ static void upload_gen6_binding_table_pointers(struct brw_context *brw) GEN6_BINDING_TABLE_MODIFY_GS | GEN6_BINDING_TABLE_MODIFY_PS | (4 - 2)); - OUT_BATCH(brw-vs.bind_bo_offset); /* vs */ + OUT_BATCH(brw-vs.base.bind_bo_offset); /* vs */ OUT_BATCH(brw-ff_gs.bind_bo_offset); /* gs */ OUT_BATCH(brw-wm.bind_bo_offset); /* wm/ps */ ADVANCE_BATCH(); @@ -150,7 +150,7 @@ static void upload_pipelined_state_pointers(struct brw_context *brw ) BEGIN_BATCH(7); OUT_BATCH(_3DSTATE_PIPELINED_POINTERS 16 | (7 - 2)); OUT_RELOC(brw-batch.bo, I915_GEM_DOMAIN_INSTRUCTION, 0, -brw-vs.state_offset); +brw-vs.base.state_offset); if (brw-ff_gs.prog_active) OUT_RELOC(brw-batch.bo, I915_GEM_DOMAIN_INSTRUCTION, 0, brw-ff_gs.state_offset | 1); diff --git
[Mesa-dev] [PATCH 06/22] i965/gs: Create brw_context::gs structure to track GS program state.
v2: Change name from vec4_gs to simply gs. --- src/mesa/drivers/dri/i965/brw_context.h | 5 + 1 file changed, 5 insertions(+) diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h index 9784956..d5ca4dd 100644 --- a/src/mesa/drivers/dri/i965/brw_context.h +++ b/src/mesa/drivers/dri/i965/brw_context.h @@ -1172,6 +1172,11 @@ struct brw_context } vs; struct { + struct brw_vec4_context_base base; + struct brw_gs_prog_data *prog_data; + } gs; + + struct { struct brw_ff_gs_prog_data *prog_data; bool prog_active; -- 1.8.4 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 07/22] i965: Make CACHE_NEW_GS_PROG.
--- src/mesa/drivers/dri/i965/brw_context.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h index d5ca4dd..be5175f 100644 --- a/src/mesa/drivers/dri/i965/brw_context.h +++ b/src/mesa/drivers/dri/i965/brw_context.h @@ -680,6 +680,7 @@ enum brw_cache_id { BRW_VS_PROG, BRW_FF_GS_UNIT, BRW_FF_GS_PROG, + BRW_GS_PROG, BRW_CLIP_VP, BRW_CLIP_UNIT, BRW_CLIP_PROG, @@ -770,6 +771,7 @@ enum shader_time_shader_type { #define CACHE_NEW_VS_PROG(1BRW_VS_PROG) #define CACHE_NEW_FF_GS_UNIT (1BRW_FF_GS_UNIT) #define CACHE_NEW_FF_GS_PROG (1BRW_FF_GS_PROG) +#define CACHE_NEW_GS_PROG(1BRW_GS_PROG) #define CACHE_NEW_CLIP_VP(1BRW_CLIP_VP) #define CACHE_NEW_CLIP_UNIT (1BRW_CLIP_UNIT) #define CACHE_NEW_CLIP_PROG (1BRW_CLIP_PROG) -- 1.8.4 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 08/22] i965/gs: Allocate URB space for use by GS.
Previously, we gave all of the URB space (other than the small amount that is used for push constants) to the vertex shader. However, when a geometry shader is active, we need to divide it up between the vertex and geometry shaders. The size of the URB entries for the vertex and geometry shaders can vary dramatically from one shader to the next. So it doesn't make sense to simply split the available space in two. In particular: - On Ivy Bridge GT1, this would not leave enough space for the worst case geometry shader, which requires 64k of URB space. - Due to hardware-imposed limits on the maximum number of URB entries, sometimes a given shader stage will only be capable of using a small amount of URB space. When this happens, it may make sense to allocate substantially less than half of the available space to that stage. Our algorithm for dividing space between the two stages is to first compute (a) the minimum amount of URB space that each stage needs in order to function properly, and (b) the amount of additional URB space that each stage wants (i.e. that it would be capable of making use of). If the total amount of space available is not enough to satisfy needs + wants, then each stage's wants amount is scaled back by the same factor in order to fit. When only a vertex shader is active, this algorithm produces equivalent results to the old algorithm (if the vertex shader stage can make use of all the available URB space, we assign all the space to it; if it can't, we let it use as much as it can). In the future, when we need to support tessellation control and tessellation evaluation pipeline stages, it should be straightforward to expand this algorithm to cover them. v2: Use unsigned rather than GLuint. --- src/mesa/drivers/dri/i965/brw_context.h | 6 +- src/mesa/drivers/dri/i965/gen7_blorp.cpp | 16 ++-- src/mesa/drivers/dri/i965/gen7_urb.c | 155 +-- 3 files changed, 142 insertions(+), 35 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h index be5175f..77f2a6b 100644 --- a/src/mesa/drivers/dri/i965/brw_context.h +++ b/src/mesa/drivers/dri/i965/brw_context.h @@ -1511,8 +1511,10 @@ void gen7_allocate_push_constants(struct brw_context *brw); void -gen7_emit_urb_state(struct brw_context *brw, GLuint nr_vs_entries, -GLuint vs_size, GLuint vs_start); +gen7_emit_urb_state(struct brw_context *brw, +unsigned nr_vs_entries, unsigned vs_size, +unsigned vs_start, unsigned nr_gs_entries, +unsigned gs_size, unsigned gs_start); diff --git a/src/mesa/drivers/dri/i965/gen7_blorp.cpp b/src/mesa/drivers/dri/i965/gen7_blorp.cpp index a387836..6c798b1 100644 --- a/src/mesa/drivers/dri/i965/gen7_blorp.cpp +++ b/src/mesa/drivers/dri/i965/gen7_blorp.cpp @@ -51,14 +51,16 @@ static void gen7_blorp_emit_urb_config(struct brw_context *brw, const brw_blorp_params *params) { - /* The minimum valid value is 32. See 3DSTATE_URB_VS, -* Dword 1.15:0 VS Number of URB Entries. + /* The minimum valid number of VS entries is 32. See 3DSTATE_URB_VS, Dword +* 1.15:0 VS Number of URB Entries. */ - int num_vs_entries = 32; - int vs_size = 2; - int vs_start = 2; /* skip over push constants */ - - gen7_emit_urb_state(brw, num_vs_entries, vs_size, vs_start); + gen7_emit_urb_state(brw, + 32 /* num_vs_entries */, + 2 /* vs_size */, + 2 /* vs_start */, + 0 /* num_gs_entries */, + 1 /* gs_size */, + 2 /* gs_start */); } diff --git a/src/mesa/drivers/dri/i965/gen7_urb.c b/src/mesa/drivers/dri/i965/gen7_urb.c index 927af37..2d10cc12 100644 --- a/src/mesa/drivers/dri/i965/gen7_urb.c +++ b/src/mesa/drivers/dri/i965/gen7_urb.c @@ -74,34 +74,136 @@ gen7_upload_urb(struct brw_context *brw) { const int push_size_kB = brw-is_haswell brw-gt == 3 ? 32 : 16; - /* Total space for entries is URB size - 16kB for push constants */ - int handle_region_size = (brw-urb.size - push_size_kB) * 1024; /* bytes */ - /* CACHE_NEW_VS_PROG */ unsigned vs_size = MAX2(brw-vs.prog_data-base.urb_entry_size, 1); - - int nr_vs_entries = handle_region_size / (vs_size * 64); - if (nr_vs_entries brw-urb.max_vs_entries) - nr_vs_entries = brw-urb.max_vs_entries; - - /* According to volume 2a, nr_vs_entries must be a multiple of 8. */ - brw-urb.nr_vs_entries = ROUND_DOWN_TO(nr_vs_entries, 8); - - /* URB Starting Addresses are specified in multiples of 8kB. */ - brw-urb.vs_start = push_size_kB / 8; /* skip over push constants */ - - assert(brw-urb.nr_vs_entries % 8 == 0); - assert(brw-urb.nr_gs_entries % 8 == 0); - /* GS requirement */ - assert(!brw-ff_gs.prog_active); + unsigned vs_entry_size_bytes = vs_size * 64; + /*
[Mesa-dev] [PATCH 09/22] i965/gs: Allocate push constant space for use by GS.
Previously, we would always use the same push constant allocation regardless of what shader programs were being run: the available push constant space was split into 2 equal size partitions, one for the vertex shader, and one for the fragment shader. Now that we are adding geometry shader support, we need to do something smarter. This patch adjusts things so that when a geometry shader is in use, we split the available push constant space into 3 nearly-equal size partitions instead of 2. Since the push constant allocation is now affected by GL state, it can no longer be set up by brw_upload_initial_gpu_state(); instead it must be set up by a state atom. --- src/mesa/drivers/dri/i965/brw_context.h | 3 +- src/mesa/drivers/dri/i965/brw_defines.h | 1 + src/mesa/drivers/dri/i965/brw_state.h| 4 +- src/mesa/drivers/dri/i965/brw_state_upload.c | 5 +- src/mesa/drivers/dri/i965/gen7_blorp.cpp | 6 ++ src/mesa/drivers/dri/i965/gen7_urb.c | 101 +++ 6 files changed, 98 insertions(+), 22 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h index 77f2a6b..95f9bb2 100644 --- a/src/mesa/drivers/dri/i965/brw_context.h +++ b/src/mesa/drivers/dri/i965/brw_context.h @@ -1508,7 +1508,8 @@ gen6_get_sample_position(struct gl_context *ctx, /* gen7_urb.c */ void -gen7_allocate_push_constants(struct brw_context *brw); +gen7_emit_push_constant_state(struct brw_context *brw, unsigned vs_size, + unsigned gs_size, unsigned fs_size); void gen7_emit_urb_state(struct brw_context *brw, diff --git a/src/mesa/drivers/dri/i965/brw_defines.h b/src/mesa/drivers/dri/i965/brw_defines.h index 832ff55..8d9a824 100644 --- a/src/mesa/drivers/dri/i965/brw_defines.h +++ b/src/mesa/drivers/dri/i965/brw_defines.h @@ -1284,6 +1284,7 @@ enum brw_message_target { # define GEN7_URB_STARTING_ADDRESS_SHIFT25 #define _3DSTATE_PUSH_CONSTANT_ALLOC_VS 0x7912 /* GEN7+ */ +#define _3DSTATE_PUSH_CONSTANT_ALLOC_GS 0x7915 /* GEN7+ */ #define _3DSTATE_PUSH_CONSTANT_ALLOC_PS 0x7916 /* GEN7+ */ # define GEN7_PUSH_CONSTANT_BUFFER_OFFSET_SHIFT 16 diff --git a/src/mesa/drivers/dri/i965/brw_state.h b/src/mesa/drivers/dri/i965/brw_state.h index 85f82fe..4814639 100644 --- a/src/mesa/drivers/dri/i965/brw_state.h +++ b/src/mesa/drivers/dri/i965/brw_state.h @@ -112,6 +112,7 @@ extern const struct brw_tracked_state gen7_cc_viewport_state_pointer; extern const struct brw_tracked_state gen7_clip_state; extern const struct brw_tracked_state gen7_disable_stages; extern const struct brw_tracked_state gen7_ps_state; +extern const struct brw_tracked_state gen7_push_constant_space; extern const struct brw_tracked_state gen7_sbe_state; extern const struct brw_tracked_state gen7_sf_clip_viewport; extern const struct brw_tracked_state gen7_sf_state; @@ -220,9 +221,6 @@ uint32_t get_attr_override(const struct brw_vue_map *vue_map, int urb_entry_read_offset, int fs_attr, bool two_side_color, uint32_t *max_source_attr); -/* gen7_urb.c */ -void gen7_allocate_push_constants(struct brw_context *brw); - #ifdef __cplusplus } #endif diff --git a/src/mesa/drivers/dri/i965/brw_state_upload.c b/src/mesa/drivers/dri/i965/brw_state_upload.c index b883002..9638c69 100644 --- a/src/mesa/drivers/dri/i965/brw_state_upload.c +++ b/src/mesa/drivers/dri/i965/brw_state_upload.c @@ -188,6 +188,7 @@ static const struct brw_tracked_state *gen7_atoms[] = gen7_cc_viewport_state_pointer, /* must do after brw_cc_vp */ gen7_sf_clip_viewport, + gen7_push_constant_space, gen7_urb, gen6_blend_state, /* must do before cc unit */ gen6_color_calc_state, /* must do before cc unit */ @@ -251,10 +252,6 @@ brw_upload_initial_gpu_state(struct brw_context *brw) return; brw_upload_invariant_state(brw); - - if (brw-gen = 7) { - gen7_allocate_push_constants(brw); - } } void brw_init_state( struct brw_context *brw ) diff --git a/src/mesa/drivers/dri/i965/gen7_blorp.cpp b/src/mesa/drivers/dri/i965/gen7_blorp.cpp index 6c798b1..9df3d92 100644 --- a/src/mesa/drivers/dri/i965/gen7_blorp.cpp +++ b/src/mesa/drivers/dri/i965/gen7_blorp.cpp @@ -51,6 +51,12 @@ static void gen7_blorp_emit_urb_config(struct brw_context *brw, const brw_blorp_params *params) { + unsigned urb_size = (brw-is_haswell brw-gt == 3) ? 32 : 16; + gen7_emit_push_constant_state(brw, + urb_size / 2 /* vs_size */, + 0 /* gs_size */, + urb_size / 2 /* fs_size */); + /* The minimum valid number of VS entries is 32. See 3DSTATE_URB_VS, Dword * 1.15:0 VS Number of URB Entries. */ diff --git a/src/mesa/drivers/dri/i965/gen7_urb.c b/src/mesa/drivers/dri/i965/gen7_urb.c index 2d10cc12..4dc8f6e 100644 ---
[Mesa-dev] [PATCH 10/22] i965: Make sure constants re-sent after constant buffer reallocation.
The hardware requires that after constant buffers for a stage are allocated using a 3DSTATE_PUSH_CONSTANT_ALLOC_{VS,HS,DS,GS,PS} command, and prior to execution of a 3DPRIMITIVE, the corresponding stage's constant buffers must be reprogrammed using a 3DSTATE_CONSTANT_{VS,HS,DS,GS,PS} command. Previously we didn't need to worry about this, because we only programmed 3DSTATE_PUSH_CONSTANT_ALLOC_{VS,HS,DS,GS,PS} once on startup. But now that we reallocate the constant buffers whenever geometry shaders are switched on and off, we need to make sure the constant buffers are reprogrammed. We do this by adding a new bit, BRW_NEW_PUSH_CONSTANT_ALLOCATION, to brw-state.dirty.brw. --- src/mesa/drivers/dri/i965/brw_context.h | 2 ++ src/mesa/drivers/dri/i965/gen6_gs_state.c | 2 +- src/mesa/drivers/dri/i965/gen6_vs_state.c | 3 ++- src/mesa/drivers/dri/i965/gen6_wm_state.c | 3 ++- src/mesa/drivers/dri/i965/gen7_urb.c | 13 + src/mesa/drivers/dri/i965/gen7_vs_state.c | 3 ++- src/mesa/drivers/dri/i965/gen7_wm_state.c | 3 ++- 7 files changed, 24 insertions(+), 5 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h index 95f9bb2..35193a6 100644 --- a/src/mesa/drivers/dri/i965/brw_context.h +++ b/src/mesa/drivers/dri/i965/brw_context.h @@ -158,6 +158,7 @@ enum brw_state_id { BRW_STATE_UNIFORM_BUFFER, BRW_STATE_META_IN_PROGRESS, BRW_STATE_INTERPOLATION_MAP, + BRW_STATE_PUSH_CONSTANT_ALLOCATION, BRW_NUM_STATE_BITS }; @@ -194,6 +195,7 @@ enum brw_state_id { #define BRW_NEW_UNIFORM_BUFFER (1 BRW_STATE_UNIFORM_BUFFER) #define BRW_NEW_META_IN_PROGRESS(1 BRW_STATE_META_IN_PROGRESS) #define BRW_NEW_INTERPOLATION_MAP (1 BRW_STATE_INTERPOLATION_MAP) +#define BRW_NEW_PUSH_CONSTANT_ALLOCATION (1 BRW_STATE_PUSH_CONSTANT_ALLOCATION) struct brw_state_flags { /** State update flags signalled by mesa internals */ diff --git a/src/mesa/drivers/dri/i965/gen6_gs_state.c b/src/mesa/drivers/dri/i965/gen6_gs_state.c index ac78286..9648fb7 100644 --- a/src/mesa/drivers/dri/i965/gen6_gs_state.c +++ b/src/mesa/drivers/dri/i965/gen6_gs_state.c @@ -81,7 +81,7 @@ upload_gs_state(struct brw_context *brw) const struct brw_tracked_state gen6_gs_state = { .dirty = { .mesa = _NEW_TRANSFORM, - .brw = BRW_NEW_CONTEXT, + .brw = BRW_NEW_CONTEXT | BRW_NEW_PUSH_CONSTANT_ALLOCATION, .cache = CACHE_NEW_FF_GS_PROG }, .emit = upload_gs_state, diff --git a/src/mesa/drivers/dri/i965/gen6_vs_state.c b/src/mesa/drivers/dri/i965/gen6_vs_state.c index c099342..9f99db8 100644 --- a/src/mesa/drivers/dri/i965/gen6_vs_state.c +++ b/src/mesa/drivers/dri/i965/gen6_vs_state.c @@ -206,7 +206,8 @@ const struct brw_tracked_state gen6_vs_state = { .mesa = _NEW_TRANSFORM | _NEW_PROGRAM_CONSTANTS, .brw = (BRW_NEW_CONTEXT | BRW_NEW_VERTEX_PROGRAM | - BRW_NEW_BATCH), + BRW_NEW_BATCH | +BRW_NEW_PUSH_CONSTANT_ALLOCATION), .cache = CACHE_NEW_VS_PROG | CACHE_NEW_SAMPLER }, .emit = upload_vs_state, diff --git a/src/mesa/drivers/dri/i965/gen6_wm_state.c b/src/mesa/drivers/dri/i965/gen6_wm_state.c index e286785..6725805 100644 --- a/src/mesa/drivers/dri/i965/gen6_wm_state.c +++ b/src/mesa/drivers/dri/i965/gen6_wm_state.c @@ -229,7 +229,8 @@ const struct brw_tracked_state gen6_wm_state = { _NEW_POLYGON | _NEW_MULTISAMPLE), .brw = (BRW_NEW_FRAGMENT_PROGRAM | - BRW_NEW_BATCH), + BRW_NEW_BATCH | +BRW_NEW_PUSH_CONSTANT_ALLOCATION), .cache = (CACHE_NEW_SAMPLER | CACHE_NEW_WM_PROG) }, diff --git a/src/mesa/drivers/dri/i965/gen7_urb.c b/src/mesa/drivers/dri/i965/gen7_urb.c index 4dc8f6e..1bca9cd 100644 --- a/src/mesa/drivers/dri/i965/gen7_urb.c +++ b/src/mesa/drivers/dri/i965/gen7_urb.c @@ -81,6 +81,19 @@ gen7_allocate_push_constants(struct brw_context *brw) gen7_emit_push_constant_state(brw, multiplier * vs_size, multiplier * gs_size, multiplier * fs_size); + + /* From p115 of the Ivy Bridge PRM (3.2.1.4 3DSTATE_PUSH_CONSTANT_ALLOC_VS): +* +* Programming Restriction: +* +* The 3DSTATE_CONSTANT_VS must be reprogrammed prior to the next +* 3DPRIMITIVE command after programming the +* 3DSTATE_PUSH_CONSTANT_ALLOC_VS. +* +* Similar text exists for the other 3DSTATE_PUSH_CONSTANT_ALLOC_* +* commands. +*/ + brw-state.dirty.brw |= BRW_NEW_PUSH_CONSTANT_ALLOCATION; } void diff --git a/src/mesa/drivers/dri/i965/gen7_vs_state.c b/src/mesa/drivers/dri/i965/gen7_vs_state.c index 36ab229..36fccf7 100644 --- a/src/mesa/drivers/dri/i965/gen7_vs_state.c +++ b/src/mesa/drivers/dri/i965/gen7_vs_state.c @@ -116,7 +116,8 @@ const struct brw_tracked_state gen7_vs_state = { .brw = (BRW_NEW_CONTEXT |
[Mesa-dev] [PATCH 11/22] i965: generalize brw_vs_pull_constants in preparation for GS.
--- src/mesa/drivers/dri/i965/brw_state.h| 8 +++ src/mesa/drivers/dri/i965/brw_vs_surface_state.c | 66 +++- 2 files changed, 50 insertions(+), 24 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_state.h b/src/mesa/drivers/dri/i965/brw_state.h index 4814639..e7a1b40 100644 --- a/src/mesa/drivers/dri/i965/brw_state.h +++ b/src/mesa/drivers/dri/i965/brw_state.h @@ -221,6 +221,14 @@ uint32_t get_attr_override(const struct brw_vue_map *vue_map, int urb_entry_read_offset, int fs_attr, bool two_side_color, uint32_t *max_source_attr); +/* brw_vs_surface_state.c */ +void +brw_upload_vec4_pull_constants(struct brw_context *brw, + GLbitfield64 brw_new_constbuf, + const struct gl_program *prog, + struct brw_vec4_context_base *vec4_ctx, + const struct brw_vec4_prog_data *prog_data); + #ifdef __cplusplus } #endif diff --git a/src/mesa/drivers/dri/i965/brw_vs_surface_state.c b/src/mesa/drivers/dri/i965/brw_vs_surface_state.c index 629eb96..48124bf 100644 --- a/src/mesa/drivers/dri/i965/brw_vs_surface_state.c +++ b/src/mesa/drivers/dri/i965/brw_vs_surface_state.c @@ -35,56 +35,50 @@ #include brw_context.h #include brw_state.h -/* Creates a new VS constant buffer reflecting the current VS program's - * constants, if needed by the VS program. - * - * Otherwise, constants go through the CURBEs using the brw_constant_buffer - * state atom. - */ -static void -brw_upload_vs_pull_constants(struct brw_context *brw) -{ - struct brw_vec4_context_base *vec4_ctx = brw-vs.base; - /* BRW_NEW_VERTEX_PROGRAM */ - struct brw_vertex_program *vp = - (struct brw_vertex_program *) brw-vertex_program; +void +brw_upload_vec4_pull_constants(struct brw_context *brw, + GLbitfield64 brw_new_constbuf, + const struct gl_program *prog, + struct brw_vec4_context_base *vec4_ctx, + const struct brw_vec4_prog_data *prog_data) +{ int i; /* Updates the ParamaterValues[i] pointers for all parameters of the * basic type of PROGRAM_STATE_VAR. */ - _mesa_load_state_parameters(brw-ctx, vp-program.Base.Parameters); + _mesa_load_state_parameters(brw-ctx, prog-Parameters); - /* CACHE_NEW_VS_PROG */ - if (!brw-vs.prog_data-base.nr_pull_params) { + if (!prog_data-nr_pull_params) { if (vec4_ctx-const_bo) { drm_intel_bo_unreference(vec4_ctx-const_bo); vec4_ctx-const_bo = NULL; vec4_ctx-surf_offset[SURF_INDEX_VEC4_CONST_BUFFER] = 0; -brw-state.dirty.brw |= BRW_NEW_VS_CONSTBUF; +brw-state.dirty.brw |= brw_new_constbuf; } return; } /* _NEW_PROGRAM_CONSTANTS */ drm_intel_bo_unreference(vec4_ctx-const_bo); - uint32_t size = brw-vs.prog_data-base.nr_pull_params * 4; - vec4_ctx-const_bo = drm_intel_bo_alloc(brw-bufmgr, vp_const_buffer, + uint32_t size = prog_data-nr_pull_params * 4; + vec4_ctx-const_bo = drm_intel_bo_alloc(brw-bufmgr, vec4_const_buffer, size, 64); drm_intel_gem_bo_map_gtt(vec4_ctx-const_bo); - for (i = 0; i brw-vs.prog_data-base.nr_pull_params; i++) { + + for (i = 0; i prog_data-nr_pull_params; i++) { memcpy(vec4_ctx-const_bo-virtual + i * 4, -brw-vs.prog_data-base.pull_param[i], +prog_data-pull_param[i], 4); } if (0) { - for (i = 0; i ALIGN(brw-vs.prog_data-base.nr_pull_params, 4) / 4; + for (i = 0; i ALIGN(prog_data-nr_pull_params, 4) / 4; i++) { float *row = (float *)vec4_ctx-const_bo-virtual + i * 4; -printf(vs const surface %3d: %4.3f %4.3f %4.3f %4.3f\n, +printf(const surface %3d: %4.3f %4.3f %4.3f %4.3f\n, i, row[0], row[1], row[2], row[3]); } } @@ -95,7 +89,31 @@ brw_upload_vs_pull_constants(struct brw_context *brw) brw-vtbl.create_constant_surface(brw, vec4_ctx-const_bo, 0, size, vec4_ctx-surf_offset[surf], false); - brw-state.dirty.brw |= BRW_NEW_VS_CONSTBUF; + brw-state.dirty.brw |= brw_new_constbuf; +} + + +/* Creates a new VS constant buffer reflecting the current VS program's + * constants, if needed by the VS program. + * + * Otherwise, constants go through the CURBEs using the brw_constant_buffer + * state atom. + */ +static void +brw_upload_vs_pull_constants(struct brw_context *brw) +{ + struct brw_vec4_context_base *vec4_ctx = brw-vs.base; + + /* BRW_NEW_VERTEX_PROGRAM */ + struct brw_vertex_program *vp = + (struct brw_vertex_program *) brw-vertex_program; + + /* CACHE_NEW_VS_PROG */ + const struct brw_vec4_prog_data *prog_data = brw-vs.prog_data-base; + + /* _NEW_PROGRAM_CONSTANTS */ + brw_upload_vec4_pull_constants(brw, BRW_NEW_VS_CONSTBUF,
[Mesa-dev] [PATCH 12/22] i965/vs: generalize brw_vs_binding_table in preparation for GS.
--- src/mesa/drivers/dri/i965/brw_state.h| 6 src/mesa/drivers/dri/i965/brw_vs_surface_state.c | 42 2 files changed, 35 insertions(+), 13 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_state.h b/src/mesa/drivers/dri/i965/brw_state.h index e7a1b40..3a2f54f 100644 --- a/src/mesa/drivers/dri/i965/brw_state.h +++ b/src/mesa/drivers/dri/i965/brw_state.h @@ -122,6 +122,7 @@ extern const struct brw_tracked_state gen7_vs_state; extern const struct brw_tracked_state gen7_wm_state; extern const struct brw_tracked_state haswell_cut_index; + /* brw_misc_state.c */ void brw_upload_invariant_state(struct brw_context *brw); uint32_t @@ -228,6 +229,11 @@ brw_upload_vec4_pull_constants(struct brw_context *brw, const struct gl_program *prog, struct brw_vec4_context_base *vec4_ctx, const struct brw_vec4_prog_data *prog_data); +void +brw_vec4_upload_binding_table(struct brw_context *brw, + GLbitfield64 brw_new_binding_table, + struct brw_vec4_context_base *vec4_ctx, + const struct brw_vec4_prog_data *prog_data); #ifdef __cplusplus } diff --git a/src/mesa/drivers/dri/i965/brw_vs_surface_state.c b/src/mesa/drivers/dri/i965/brw_vs_surface_state.c index 48124bf..ac612b4 100644 --- a/src/mesa/drivers/dri/i965/brw_vs_surface_state.c +++ b/src/mesa/drivers/dri/i965/brw_vs_surface_state.c @@ -150,14 +150,13 @@ const struct brw_tracked_state brw_vs_ubo_surfaces = { .emit = brw_upload_vs_ubo_surfaces, }; -/** - * Constructs the binding table for the WM surface state, which maps unit - * numbers to surface state objects. - */ -static void -brw_vs_upload_binding_table(struct brw_context *brw) + +void +brw_vec4_upload_binding_table(struct brw_context *brw, + GLbitfield64 brw_new_binding_table, + struct brw_vec4_context_base *vec4_ctx, + const struct brw_vec4_prog_data *prog_data) { - struct brw_vec4_context_base *vec4_ctx = brw-vs.base; uint32_t *bind; int i; @@ -165,13 +164,13 @@ brw_vs_upload_binding_table(struct brw_context *brw) gen7_create_shader_time_surface(brw, vec4_ctx-surf_offset[SURF_INDEX_VEC4_SHADER_TIME]); } - /* CACHE_NEW_VS_PROG: Skip making a binding table if we don't use textures or -* pull constants. + /* Skip making a binding table if we don't use textures or pull +* constants. */ - const unsigned entries = brw-vs.prog_data-base.binding_table_size; + const unsigned entries = prog_data-binding_table_size; if (entries == 0) { if (vec4_ctx-bind_bo_offset != 0) { -brw-state.dirty.brw |= BRW_NEW_VS_BINDING_TABLE; +brw-state.dirty.brw |= brw_new_binding_table; vec4_ctx-bind_bo_offset = 0; } return; @@ -184,12 +183,29 @@ brw_vs_upload_binding_table(struct brw_context *brw) sizeof(uint32_t) * entries, 32, vec4_ctx-bind_bo_offset); - /* BRW_NEW_SURFACES and BRW_NEW_VS_CONSTBUF */ + /* BRW_NEW_SURFACES and BRW_NEW_*_CONSTBUF */ for (i = 0; i entries; i++) { bind[i] = vec4_ctx-surf_offset[i]; } - brw-state.dirty.brw |= BRW_NEW_VS_BINDING_TABLE; + brw-state.dirty.brw |= brw_new_binding_table; +} + + +/** + * Constructs the binding table for the WM surface state, which maps unit + * numbers to surface state objects. + */ +static void +brw_vs_upload_binding_table(struct brw_context *brw) +{ + struct brw_vec4_context_base *vec4_ctx = brw-vs.base; + /* CACHE_NEW_VS_PROG */ + const struct brw_vec4_prog_data *prog_data = brw-vs.prog_data-base; + + /* BRW_NEW_SURFACES and BRW_NEW_VS_CONSTBUF */ + brw_vec4_upload_binding_table(brw, BRW_NEW_VS_BINDING_TABLE, vec4_ctx, + prog_data); } const struct brw_tracked_state brw_vs_binding_table = { -- 1.8.4 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 13/22] i965/gs: Implement support for geometry shader surfaces.
This patch implements pull constant upload, binding table upload, and surface setup for geometry shaders, by re-using vertex shader code that was generalized in previous patches. Based on work by Eric Anholt e...@anholt.net. --- src/mesa/drivers/dri/i965/Makefile.sources | 1 + src/mesa/drivers/dri/i965/brw_context.h | 2 + src/mesa/drivers/dri/i965/brw_gs_surface_state.c | 123 +++ src/mesa/drivers/dri/i965/brw_state.h| 3 + src/mesa/drivers/dri/i965/brw_state_upload.c | 3 + 5 files changed, 132 insertions(+) create mode 100644 src/mesa/drivers/dri/i965/brw_gs_surface_state.c diff --git a/src/mesa/drivers/dri/i965/Makefile.sources b/src/mesa/drivers/dri/i965/Makefile.sources index 290cd93..81a16ff 100644 --- a/src/mesa/drivers/dri/i965/Makefile.sources +++ b/src/mesa/drivers/dri/i965/Makefile.sources @@ -63,6 +63,7 @@ i965_FILES = \ brw_gs.c \ brw_gs_emit.c \ brw_gs_state.c \ + brw_gs_surface_state.c \ brw_interpolation_map.c \ brw_lower_texture_gradients.cpp \ brw_misc_state.c \ diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h index 35193a6..622b5c8 100644 --- a/src/mesa/drivers/dri/i965/brw_context.h +++ b/src/mesa/drivers/dri/i965/brw_context.h @@ -148,6 +148,7 @@ enum brw_state_id { BRW_STATE_BATCH, BRW_STATE_INDEX_BUFFER, BRW_STATE_VS_CONSTBUF, + BRW_STATE_GS_CONSTBUF, BRW_STATE_PROGRAM_CACHE, BRW_STATE_STATE_BASE_ADDRESS, BRW_STATE_VUE_MAP_VS, @@ -185,6 +186,7 @@ enum brw_state_id { /** \see brw.state.depth_region */ #define BRW_NEW_INDEX_BUFFER (1 BRW_STATE_INDEX_BUFFER) #define BRW_NEW_VS_CONSTBUF(1 BRW_STATE_VS_CONSTBUF) +#define BRW_NEW_GS_CONSTBUF(1 BRW_STATE_GS_CONSTBUF) #define BRW_NEW_PROGRAM_CACHE (1 BRW_STATE_PROGRAM_CACHE) #define BRW_NEW_STATE_BASE_ADDRESS (1 BRW_STATE_STATE_BASE_ADDRESS) #define BRW_NEW_VUE_MAP_VS (1 BRW_STATE_VUE_MAP_VS) diff --git a/src/mesa/drivers/dri/i965/brw_gs_surface_state.c b/src/mesa/drivers/dri/i965/brw_gs_surface_state.c new file mode 100644 index 000..d3d48ff --- /dev/null +++ b/src/mesa/drivers/dri/i965/brw_gs_surface_state.c @@ -0,0 +1,123 @@ +/* + * Copyright © 2013 Intel Corporation + * + * 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 main/mtypes.h +#include program/prog_parameter.h + +#include brw_context.h +#include brw_state.h + + +/* Creates a new GS constant buffer reflecting the current GS program's + * constants, if needed by the GS program. + * + * Otherwise, constants go through the CURBEs using the brw_constant_buffer + * state atom. + */ +static void +brw_upload_gs_pull_constants(struct brw_context *brw) +{ + struct brw_vec4_context_base *vec4_ctx = brw-gs.base; + + /* BRW_NEW_GEOMETRY_PROGRAM */ + struct brw_geometry_program *gp = + (struct brw_geometry_program *) brw-geometry_program; + + if (!gp) + return; + + /* CACHE_NEW_GS_PROG */ + const struct brw_vec4_prog_data *prog_data = brw-gs.prog_data-base; + + /* _NEW_PROGRAM_CONSTANTS */ + brw_upload_vec4_pull_constants(brw, BRW_NEW_GS_CONSTBUF, gp-program.Base, + vec4_ctx, prog_data); +} + +const struct brw_tracked_state brw_gs_pull_constants = { + .dirty = { + .mesa = (_NEW_PROGRAM_CONSTANTS), + .brw = (BRW_NEW_BATCH | BRW_NEW_GEOMETRY_PROGRAM), + .cache = CACHE_NEW_GS_PROG, + }, + .emit = brw_upload_gs_pull_constants, +}; + +static void +brw_upload_gs_ubo_surfaces(struct brw_context *brw) +{ + struct gl_context *ctx = brw-ctx; + struct brw_vec4_context_base *vec4_ctx = brw-gs.base; + + /* _NEW_PROGRAM */ + struct gl_shader_program *prog = ctx-Shader.CurrentGeometryProgram; + + if (!prog) + return; + + brw_upload_ubo_surfaces(brw,
[Mesa-dev] [PATCH 14/22] i965/gs: make the state atom for compiling Gen7 geometry shaders.
Reviewed-by: Kenneth Graunke kenn...@whitecape.org v2: Use unsigned rather than GLuint. --- src/mesa/drivers/dri/i965/Makefile.sources| 1 + src/mesa/drivers/dri/i965/brw_defines.h | 10 + src/mesa/drivers/dri/i965/brw_draw.c | 2 + src/mesa/drivers/dri/i965/brw_state.h | 1 + src/mesa/drivers/dri/i965/brw_state_cache.c | 3 + src/mesa/drivers/dri/i965/brw_state_dump.c| 3 + src/mesa/drivers/dri/i965/brw_state_upload.c | 1 + src/mesa/drivers/dri/i965/brw_vec4_gs.c | 287 ++ src/mesa/drivers/dri/i965/brw_vec4_gs.h | 41 src/mesa/drivers/dri/i965/brw_vec4_gs_visitor.cpp | 32 +++ src/mesa/drivers/dri/i965/brw_vec4_gs_visitor.h | 13 + src/mesa/drivers/dri/i965/brw_vs.c| 13 +- 12 files changed, 401 insertions(+), 6 deletions(-) create mode 100644 src/mesa/drivers/dri/i965/brw_vec4_gs.c create mode 100644 src/mesa/drivers/dri/i965/brw_vec4_gs.h diff --git a/src/mesa/drivers/dri/i965/Makefile.sources b/src/mesa/drivers/dri/i965/Makefile.sources index 81a16ff..1f3abac 100644 --- a/src/mesa/drivers/dri/i965/Makefile.sources +++ b/src/mesa/drivers/dri/i965/Makefile.sources @@ -88,6 +88,7 @@ i965_FILES = \ brw_vec4.cpp \ brw_vec4_copy_propagation.cpp \ brw_vec4_emit.cpp \ + brw_vec4_gs.c \ brw_vec4_gs_visitor.cpp \ brw_vec4_live_variables.cpp \ brw_vec4_reg_allocate.cpp \ diff --git a/src/mesa/drivers/dri/i965/brw_defines.h b/src/mesa/drivers/dri/i965/brw_defines.h index 8d9a824..ec6c854 100644 --- a/src/mesa/drivers/dri/i965/brw_defines.h +++ b/src/mesa/drivers/dri/i965/brw_defines.h @@ -1283,6 +1283,11 @@ enum brw_message_target { # define GEN7_URB_ENTRY_SIZE_SHIFT 16 # define GEN7_URB_STARTING_ADDRESS_SHIFT25 +/* GS URB Entry Allocation Size is a U9-1 field, so the maximum gs_size + * is 2^9, or 512. It's counted in multiples of 64 bytes. + */ +#define GEN7_MAX_GS_URB_ENTRY_SIZE_BYTES (512*64) + #define _3DSTATE_PUSH_CONSTANT_ALLOC_VS 0x7912 /* GEN7+ */ #define _3DSTATE_PUSH_CONSTANT_ALLOC_GS 0x7915 /* GEN7+ */ #define _3DSTATE_PUSH_CONSTANT_ALLOC_PS 0x7916 /* GEN7+ */ @@ -1348,6 +1353,11 @@ enum brw_message_target { # define BRW_GS_EDGE_INDICATOR_0 (1 8) # define BRW_GS_EDGE_INDICATOR_1 (1 9) +/* 3DSTATE_GS Output Vertex Size has an effective maximum of 62. It's + * counted in multiples of 16 bytes. + */ +#define GEN7_MAX_GS_OUTPUT_VERTEX_SIZE_BYTES (62*16) + #define _3DSTATE_HS 0x781B /* GEN7+ */ #define _3DSTATE_TE 0x781C /* GEN7+ */ #define _3DSTATE_DS 0x781D /* GEN7+ */ diff --git a/src/mesa/drivers/dri/i965/brw_draw.c b/src/mesa/drivers/dri/i965/brw_draw.c index 96ba817..5c17ce6 100644 --- a/src/mesa/drivers/dri/i965/brw_draw.c +++ b/src/mesa/drivers/dri/i965/brw_draw.c @@ -376,6 +376,8 @@ static bool brw_try_draw_prims( struct gl_context *ctx, * index. */ brw-wm.sampler_count = _mesa_fls(ctx-FragmentProgram._Current-Base.SamplersUsed); + brw-gs.base.sampler_count = ctx-GeometryProgram._Current ? + _mesa_fls(ctx-GeometryProgram._Current-Base.SamplersUsed) : 0; brw-vs.base.sampler_count = _mesa_fls(ctx-VertexProgram._Current-Base.SamplersUsed); diff --git a/src/mesa/drivers/dri/i965/brw_state.h b/src/mesa/drivers/dri/i965/brw_state.h index 72ac84c..d43ec0d 100644 --- a/src/mesa/drivers/dri/i965/brw_state.h +++ b/src/mesa/drivers/dri/i965/brw_state.h @@ -72,6 +72,7 @@ extern const struct brw_tracked_state brw_vs_samplers; extern const struct brw_tracked_state brw_vs_ubo_surfaces; extern const struct brw_tracked_state brw_gs_ubo_surfaces; extern const struct brw_tracked_state brw_vs_unit; +extern const struct brw_tracked_state brw_gs_prog; extern const struct brw_tracked_state brw_wm_prog; extern const struct brw_tracked_state brw_renderbuffer_surfaces; extern const struct brw_tracked_state brw_texture_surfaces; diff --git a/src/mesa/drivers/dri/i965/brw_state_cache.c b/src/mesa/drivers/dri/i965/brw_state_cache.c index ddb275f..ef32840 100644 --- a/src/mesa/drivers/dri/i965/brw_state_cache.c +++ b/src/mesa/drivers/dri/i965/brw_state_cache.c @@ -50,6 +50,7 @@ #include brw_vs.h #include brw_wm.h #include brw_vs.h +#include brw_vec4_gs.h #define FILE_DEBUG_FLAG DEBUG_STATE @@ -341,8 +342,10 @@ brw_init_caches(struct brw_context *brw) 4096, 64); cache-aux_compare[BRW_VS_PROG] = brw_vs_prog_data_compare; + cache-aux_compare[BRW_GS_PROG] = brw_gs_prog_data_compare; cache-aux_compare[BRW_WM_PROG] = brw_wm_prog_data_compare; cache-aux_free[BRW_VS_PROG] = brw_vs_prog_data_free; + cache-aux_free[BRW_GS_PROG] = brw_gs_prog_data_free; cache-aux_free[BRW_WM_PROG] = brw_wm_prog_data_free;
[Mesa-dev] [PATCH 15/22] i965/vs: generalize gen6_vs_push_constants in preparation for GS.
--- src/mesa/drivers/dri/i965/brw_context.h | 7 + src/mesa/drivers/dri/i965/gen6_vs_state.c | 45 --- 2 files changed, 36 insertions(+), 16 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h index 622b5c8..28943e2 100644 --- a/src/mesa/drivers/dri/i965/brw_context.h +++ b/src/mesa/drivers/dri/i965/brw_context.h @@ -1628,6 +1628,13 @@ brw_setup_vec4_key_clip_info(struct brw_context *brw, struct brw_vec4_prog_key *key, bool program_uses_clip_distance); +void +gen6_upload_vec4_push_constants(struct brw_context *brw, +const struct gl_program *prog, +const struct brw_vec4_prog_data *prog_data, +struct brw_vec4_context_base *vec4_ctx, +enum state_struct_type type); + #ifdef __cplusplus } #endif diff --git a/src/mesa/drivers/dri/i965/gen6_vs_state.c b/src/mesa/drivers/dri/i965/gen6_vs_state.c index 9f99db8..f59b353 100644 --- a/src/mesa/drivers/dri/i965/gen6_vs_state.c +++ b/src/mesa/drivers/dri/i965/gen6_vs_state.c @@ -33,32 +33,30 @@ #include program/prog_statevars.h #include intel_batchbuffer.h -static void -gen6_upload_vs_push_constants(struct brw_context *brw) +void +gen6_upload_vec4_push_constants(struct brw_context *brw, +const struct gl_program *prog, +const struct brw_vec4_prog_data *prog_data, +struct brw_vec4_context_base *vec4_ctx, +enum state_struct_type type) { struct gl_context *ctx = brw-ctx; - struct brw_vec4_context_base *vec4_ctx = brw-vs.base; - - /* _BRW_NEW_VERTEX_PROGRAM */ - const struct brw_vertex_program *vp = - brw_vertex_program_const(brw-vertex_program); /* Updates the ParamaterValues[i] pointers for all parameters of the * basic type of PROGRAM_STATE_VAR. */ /* XXX: Should this happen somewhere before to get our state flag set? */ - _mesa_load_state_parameters(ctx, vp-program.Base.Parameters); + _mesa_load_state_parameters(ctx, prog-Parameters); - /* CACHE_NEW_VS_PROG */ - if (brw-vs.prog_data-base.nr_params == 0) { + if (prog_data-nr_params == 0) { vec4_ctx-push_const_size = 0; } else { int params_uploaded; float *param; int i; - param = brw_state_batch(brw, AUB_TRACE_VS_CONSTANTS, - brw-vs.prog_data-base.nr_params * sizeof(float), + param = brw_state_batch(brw, type, + prog_data-nr_params * sizeof(float), 32, vec4_ctx-push_const_offset); /* _NEW_PROGRAM_CONSTANTS @@ -67,13 +65,13 @@ gen6_upload_vs_push_constants(struct brw_context *brw) * side effect of dereferencing uniforms, so _NEW_PROGRAM_CONSTANTS * wouldn't be set for them. */ - for (i = 0; i brw-vs.prog_data-base.nr_params; i++) { - param[i] = *brw-vs.prog_data-base.param[i]; + for (i = 0; i prog_data-nr_params; i++) { + param[i] = *prog_data-param[i]; } - params_uploaded = brw-vs.prog_data-base.nr_params / 4; + params_uploaded = prog_data-nr_params / 4; if (0) { -printf(VS constant buffer:\n); +printf(Constant buffer:\n); for (i = 0; i params_uploaded; i++) { float *buf = param + i * 4; printf(%d: %f %f %f %f\n, @@ -87,6 +85,21 @@ gen6_upload_vs_push_constants(struct brw_context *brw) } } +static void +gen6_upload_vs_push_constants(struct brw_context *brw) +{ + struct brw_vec4_context_base *vec4_ctx = brw-vs.base; + + /* _BRW_NEW_VERTEX_PROGRAM */ + const struct brw_vertex_program *vp = + brw_vertex_program_const(brw-vertex_program); + /* CACHE_NEW_VS_PROG */ + const struct brw_vec4_prog_data *prog_data = brw-vs.prog_data-base; + + gen6_upload_vec4_push_constants(brw, vp-program.Base, prog_data, + vec4_ctx, AUB_TRACE_VS_CONSTANTS); +} + const struct brw_tracked_state gen6_vs_push_constants = { .dirty = { .mesa = _NEW_TRANSFORM | _NEW_PROGRAM_CONSTANTS, -- 1.8.4 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 16/22] i965: Modify signature to update_texture_surface functions.
Previously these functions would accept a pointer to the binding table and an index indicating which entry in the binding table should be updated. Now they merely take a pointer to the binding table entry to be updated. This will make it easier to generalize brw_texture_surfaces to support geometry shaders. --- src/mesa/drivers/dri/i965/brw_context.h | 3 +-- src/mesa/drivers/dri/i965/brw_wm_surface_state.c | 20 +--- src/mesa/drivers/dri/i965/gen7_wm_surface_state.c | 16 +++- 3 files changed, 17 insertions(+), 22 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h index 28943e2..487680e 100644 --- a/src/mesa/drivers/dri/i965/brw_context.h +++ b/src/mesa/drivers/dri/i965/brw_context.h @@ -864,8 +864,7 @@ struct brw_context void (*update_texture_surface)(struct gl_context *ctx, unsigned unit, - uint32_t *binding_table, - unsigned surf_index); + uint32_t *surf_offset); void (*update_renderbuffer_surface)(struct brw_context *brw, struct gl_renderbuffer *rb, bool layered, diff --git a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c index e08a127..3fecc68 100644 --- a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c +++ b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c @@ -194,8 +194,7 @@ brw_get_texture_swizzle(const struct gl_context *ctx, static void brw_update_buffer_texture_surface(struct gl_context *ctx, unsigned unit, - uint32_t *binding_table, - unsigned surf_index) + uint32_t *surf_offset) { struct brw_context *brw = brw_context(ctx); struct gl_texture_object *tObj = ctx-Texture.Unit[unit]._Current; @@ -213,7 +212,7 @@ brw_update_buffer_texture_surface(struct gl_context *ctx, } surf = brw_state_batch(brw, AUB_TRACE_SURFACE_STATE, - 6 * 4, 32, binding_table[surf_index]); + 6 * 4, 32, surf_offset); surf[0] = (BRW_SURFACE_BUFFER BRW_SURFACE_TYPE_SHIFT | (brw_format_for_mesa_format(format) BRW_SURFACE_FORMAT_SHIFT)); @@ -226,7 +225,7 @@ brw_update_buffer_texture_surface(struct gl_context *ctx, /* Emit relocation to surface contents. */ drm_intel_bo_emit_reloc(brw-batch.bo, - binding_table[surf_index] + 4, + *surf_offset + 4, bo, 0, I915_GEM_DOMAIN_SAMPLER, 0); int w = intel_obj-Base.Size / texel_size; @@ -247,8 +246,7 @@ brw_update_buffer_texture_surface(struct gl_context *ctx, static void brw_update_texture_surface(struct gl_context *ctx, unsigned unit, - uint32_t *binding_table, - unsigned surf_index) + uint32_t *surf_offset) { struct brw_context *brw = brw_context(ctx); struct gl_texture_object *tObj = ctx-Texture.Unit[unit]._Current; @@ -260,12 +258,12 @@ brw_update_texture_surface(struct gl_context *ctx, uint32_t tile_x, tile_y; if (tObj-Target == GL_TEXTURE_BUFFER) { - brw_update_buffer_texture_surface(ctx, unit, binding_table, surf_index); + brw_update_buffer_texture_surface(ctx, unit, surf_offset); return; } surf = brw_state_batch(brw, AUB_TRACE_SURFACE_STATE, - 6 * 4, 32, binding_table[surf_index]); + 6 * 4, 32, surf_offset); surf[0] = (translate_tex_target(tObj-Target) BRW_SURFACE_TYPE_SHIFT | BRW_SURFACE_MIPMAPLAYOUT_BELOW BRW_SURFACE_MIPLAYOUT_SHIFT | @@ -303,7 +301,7 @@ brw_update_texture_surface(struct gl_context *ctx, /* Emit relocation to surface contents */ drm_intel_bo_emit_reloc(brw-batch.bo, - binding_table[surf_index] + 4, + *surf_offset + 4, intelObj-mt-region-bo, surf[1] - intelObj-mt-region-bo-offset, I915_GEM_DOMAIN_SAMPLER, 0); @@ -773,7 +771,7 @@ brw_update_texture_surfaces(struct brw_context *brw) /* _NEW_TEXTURE */ if (ctx-Texture.Unit[unit]._ReallyEnabled) { brw-vtbl.update_texture_surface(ctx, unit, - brw-vs.base.surf_offset, + brw-vs.base.surf_offset + SURF_INDEX_VEC4_TEXTURE(s)); } } @@ -784,7 +782,7 @@ brw_update_texture_surfaces(struct brw_context *brw) /* _NEW_TEXTURE */ if
[Mesa-dev] [PATCH 17/22] i965/gs: generalize brw_texture_surfaces in preparation for gs.
There is a slight functionality change. Previously we would compute a common value for num_samplers for all stages, and populate that many entries in each stage's surf_offset table regardless of how many samplers each stage used. Now we only populate the number of entries in the surf_offset table corresponding to the number of samplers actually used by the stage. --- src/mesa/drivers/dri/i965/brw_wm_surface_state.c | 64 1 file changed, 33 insertions(+), 31 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c index 3fecc68..1b4388c 100644 --- a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c +++ b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c @@ -742,51 +742,53 @@ const struct brw_tracked_state gen6_renderbuffer_surfaces = { .emit = brw_update_renderbuffer_surfaces, }; -/** - * Construct SURFACE_STATE objects for enabled textures. - */ + static void -brw_update_texture_surfaces(struct brw_context *brw) +update_stage_texture_surfaces(struct brw_context *brw, + const struct gl_program *prog, + uint32_t *surf_offset) { - struct gl_context *ctx = brw-ctx; + if (!prog) + return; - /* BRW_NEW_VERTEX_PROGRAM and BRW_NEW_FRAGMENT_PROGRAM: -* Unfortunately, we're stuck using the gl_program structs until the -* ARB_fragment_program front-end gets converted to GLSL IR. These -* have the downside that SamplerUnits is split and only contains the -* mappings for samplers active in that stage. -*/ - struct gl_program *vs = (struct gl_program *) brw-vertex_program; - struct gl_program *fs = (struct gl_program *) brw-fragment_program; + struct gl_context *ctx = brw-ctx; - unsigned num_samplers = _mesa_fls(vs-SamplersUsed | fs-SamplersUsed); + unsigned num_samplers = _mesa_fls(prog-SamplersUsed); for (unsigned s = 0; s num_samplers; s++) { - brw-vs.base.surf_offset[SURF_INDEX_VEC4_TEXTURE(s)] = 0; - brw-wm.surf_offset[SURF_INDEX_TEXTURE(s)] = 0; + surf_offset[s] = 0; - if (vs-SamplersUsed (1 s)) { - const unsigned unit = vs-SamplerUnits[s]; + if (prog-SamplersUsed (1 s)) { + const unsigned unit = prog-SamplerUnits[s]; /* _NEW_TEXTURE */ if (ctx-Texture.Unit[unit]._ReallyEnabled) { -brw-vtbl.update_texture_surface(ctx, unit, - brw-vs.base.surf_offset + - SURF_INDEX_VEC4_TEXTURE(s)); +brw-vtbl.update_texture_surface(ctx, unit, surf_offset + s); } } + } +} - if (fs-SamplersUsed (1 s)) { - const unsigned unit = fs-SamplerUnits[s]; - /* _NEW_TEXTURE */ - if (ctx-Texture.Unit[unit]._ReallyEnabled) { -brw-vtbl.update_texture_surface(ctx, unit, - brw-wm.surf_offset + - SURF_INDEX_TEXTURE(s)); - } - } - } +/** + * Construct SURFACE_STATE objects for enabled textures. + */ +static void +brw_update_texture_surfaces(struct brw_context *brw) +{ + /* BRW_NEW_VERTEX_PROGRAM */ + struct gl_program *vs = (struct gl_program *) brw-vertex_program; + + /* BRW_NEW_FRAGMENT_PROGRAM */ + struct gl_program *fs = (struct gl_program *) brw-fragment_program; + + /* _NEW_TEXTURE */ + update_stage_texture_surfaces(brw, vs, + brw-vs.base.surf_offset + + SURF_INDEX_VEC4_TEXTURE(0)); + update_stage_texture_surfaces(brw, fs, + brw-wm.surf_offset + + SURF_INDEX_TEXTURE(0)); brw-state.dirty.brw |= BRW_NEW_SURFACES; } -- 1.8.4 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 18/22] i965/gs: add geometry shader support to brw_texture_surfaces.
--- src/mesa/drivers/dri/i965/brw_wm_surface_state.c | 7 +++ 1 file changed, 7 insertions(+) diff --git a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c index 1b4388c..600b564 100644 --- a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c +++ b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c @@ -779,6 +779,9 @@ brw_update_texture_surfaces(struct brw_context *brw) /* BRW_NEW_VERTEX_PROGRAM */ struct gl_program *vs = (struct gl_program *) brw-vertex_program; + /* BRW_NEW_GEOMETRY_PROGRAM */ + struct gl_program *gs = (struct gl_program *) brw-geometry_program; + /* BRW_NEW_FRAGMENT_PROGRAM */ struct gl_program *fs = (struct gl_program *) brw-fragment_program; @@ -786,6 +789,9 @@ brw_update_texture_surfaces(struct brw_context *brw) update_stage_texture_surfaces(brw, vs, brw-vs.base.surf_offset + SURF_INDEX_VEC4_TEXTURE(0)); + update_stage_texture_surfaces(brw, gs, + brw-gs.base.surf_offset + + SURF_INDEX_VEC4_TEXTURE(0)); update_stage_texture_surfaces(brw, fs, brw-wm.surf_offset + SURF_INDEX_TEXTURE(0)); @@ -798,6 +804,7 @@ const struct brw_tracked_state brw_texture_surfaces = { .mesa = _NEW_TEXTURE, .brw = BRW_NEW_BATCH | BRW_NEW_VERTEX_PROGRAM | + BRW_NEW_GEOMETRY_PROGRAM | BRW_NEW_FRAGMENT_PROGRAM, .cache = 0 }, -- 1.8.4 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 19/22] i965/gs: Implement support for geometry shader samplers.
--- src/mesa/drivers/dri/i965/brw_state.h| 1 + src/mesa/drivers/dri/i965/brw_state_upload.c | 1 + src/mesa/drivers/dri/i965/brw_wm_sampler_state.c | 28 3 files changed, 30 insertions(+) diff --git a/src/mesa/drivers/dri/i965/brw_state.h b/src/mesa/drivers/dri/i965/brw_state.h index d43ec0d..b54338a 100644 --- a/src/mesa/drivers/dri/i965/brw_state.h +++ b/src/mesa/drivers/dri/i965/brw_state.h @@ -69,6 +69,7 @@ extern const struct brw_tracked_state brw_state_base_address; extern const struct brw_tracked_state brw_urb_fence; extern const struct brw_tracked_state brw_vs_prog; extern const struct brw_tracked_state brw_vs_samplers; +extern const struct brw_tracked_state brw_gs_samplers; extern const struct brw_tracked_state brw_vs_ubo_surfaces; extern const struct brw_tracked_state brw_gs_ubo_surfaces; extern const struct brw_tracked_state brw_vs_unit; diff --git a/src/mesa/drivers/dri/i965/brw_state_upload.c b/src/mesa/drivers/dri/i965/brw_state_upload.c index 004e403..b6a6a0a 100644 --- a/src/mesa/drivers/dri/i965/brw_state_upload.c +++ b/src/mesa/drivers/dri/i965/brw_state_upload.c @@ -215,6 +215,7 @@ static const struct brw_tracked_state *gen7_atoms[] = brw_fs_samplers, brw_vs_samplers, + brw_gs_samplers, gen6_multisample_state, gen7_disable_stages, diff --git a/src/mesa/drivers/dri/i965/brw_wm_sampler_state.c b/src/mesa/drivers/dri/i965/brw_wm_sampler_state.c index 84cfe55..ffe4a62 100644 --- a/src/mesa/drivers/dri/i965/brw_wm_sampler_state.c +++ b/src/mesa/drivers/dri/i965/brw_wm_sampler_state.c @@ -444,6 +444,34 @@ const struct brw_tracked_state brw_vs_samplers = { }; +static void +brw_upload_gs_samplers(struct brw_context *brw) +{ + struct brw_vec4_context_base *vec4_ctx = brw-gs.base; + + /* BRW_NEW_GEOMETRY_PROGRAM */ + struct gl_program *gs = (struct gl_program *) brw-geometry_program; + if (!gs) + return; + + brw-vtbl.upload_sampler_state_table(brw, gs, +vec4_ctx-sampler_count, +vec4_ctx-sampler_offset, +vec4_ctx-sdc_offset); +} + + +const struct brw_tracked_state brw_gs_samplers = { + .dirty = { + .mesa = _NEW_TEXTURE, + .brw = BRW_NEW_BATCH | + BRW_NEW_GEOMETRY_PROGRAM, + .cache = 0 + }, + .emit = brw_upload_gs_samplers, +}; + + void gen4_init_vtable_sampler_functions(struct brw_context *brw) { -- 1.8.4 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 20/22] i965/gen7: merge defines for 3DSTATE{VS, GS, WM} dword 2
Dword 2 of all 3DSTATE commands is the same, so there's no need tohave separate defines for it. This will allow us to unify some of the state setup code between VS and GS. --- src/mesa/drivers/dri/i965/brw_defines.h | 30 +- src/mesa/drivers/dri/i965/gen6_blorp.cpp | 2 +- src/mesa/drivers/dri/i965/gen6_gs_state.c | 6 +++--- src/mesa/drivers/dri/i965/gen6_vs_state.c | 4 ++-- src/mesa/drivers/dri/i965/gen6_wm_state.c | 4 ++-- src/mesa/drivers/dri/i965/gen7_disable.c | 4 ++-- src/mesa/drivers/dri/i965/gen7_vs_state.c | 4 ++-- 7 files changed, 21 insertions(+), 33 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_defines.h b/src/mesa/drivers/dri/i965/brw_defines.h index ec6c854..d698757 100644 --- a/src/mesa/drivers/dri/i965/brw_defines.h +++ b/src/mesa/drivers/dri/i965/brw_defines.h @@ -1303,14 +1303,16 @@ enum brw_message_target { #define _3DSTATE_SCISSOR_STATE_POINTERS0x780f /* GEN6+ */ -#define _3DSTATE_VS0x7810 /* GEN6+ */ +/* Common to _3DSTATE_{VS,GS} */ /* DW2 */ -# define GEN6_VS_SPF_MODE (1 31) -# define GEN6_VS_VECTOR_MASK_ENABLE(1 30) -# define GEN6_VS_SAMPLER_COUNT_SHIFT 27 -# define GEN6_VS_BINDING_TABLE_ENTRY_COUNT_SHIFT 18 -# define GEN6_VS_FLOATING_POINT_MODE_IEEE_754 (0 16) -# define GEN6_VS_FLOATING_POINT_MODE_ALT (1 16) +# define GEN6_SPF_MODE (1 31) +# define GEN6_VECTOR_MASK_ENABLE (1 30) +# define GEN6_SAMPLER_COUNT_SHIFT 27 +# define GEN6_BINDING_TABLE_ENTRY_COUNT_SHIFT 18 +# define GEN6_FLOATING_POINT_MODE_IEEE_754 (0 16) +# define GEN6_FLOATING_POINT_MODE_ALT (1 16) + +#define _3DSTATE_VS0x7810 /* GEN6+ */ /* DW4 */ # define GEN6_VS_DISPATCH_START_GRF_SHIFT 20 # define GEN6_VS_URB_READ_LENGTH_SHIFT 11 @@ -1323,13 +1325,6 @@ enum brw_message_target { # define GEN6_VS_ENABLE(1 0) #define _3DSTATE_GS0x7811 /* GEN6+ */ -/* DW2 */ -# define GEN6_GS_SPF_MODE (1 31) -# define GEN6_GS_VECTOR_MASK_ENABLE(1 30) -# define GEN6_GS_SAMPLER_COUNT_SHIFT 27 -# define GEN6_GS_BINDING_TABLE_ENTRY_COUNT_SHIFT 18 -# define GEN6_GS_FLOATING_POINT_MODE_IEEE_754 (0 16) -# define GEN6_GS_FLOATING_POINT_MODE_ALT (1 16) /* DW4 */ # define GEN6_GS_URB_READ_LENGTH_SHIFT 11 # define GEN7_GS_INCLUDE_VERTEX_HANDLES(1 10) @@ -1518,13 +1513,6 @@ enum brw_wm_barycentric_interp_mode { #define _3DSTATE_WM0x7814 /* GEN6+ */ /* DW1: kernel pointer */ -/* DW2 */ -# define GEN6_WM_SPF_MODE (1 31) -# define GEN6_WM_VECTOR_MASK_ENABLE(1 30) -# define GEN6_WM_SAMPLER_COUNT_SHIFT 27 -# define GEN6_WM_BINDING_TABLE_ENTRY_COUNT_SHIFT 18 -# define GEN6_WM_FLOATING_POINT_MODE_IEEE_754 (0 16) -# define GEN6_WM_FLOATING_POINT_MODE_ALT (1 16) /* DW3: scratch space */ /* DW4 */ # define GEN6_WM_STATISTICS_ENABLE (1 31) diff --git a/src/mesa/drivers/dri/i965/gen6_blorp.cpp b/src/mesa/drivers/dri/i965/gen6_blorp.cpp index 1c85921..4b11d72 100644 --- a/src/mesa/drivers/dri/i965/gen6_blorp.cpp +++ b/src/mesa/drivers/dri/i965/gen6_blorp.cpp @@ -727,7 +727,7 @@ gen6_blorp_emit_wm_config(struct brw_context *brw, dw6 |= 0 GEN6_WM_BARYCENTRIC_INTERPOLATION_MODE_SHIFT; /* No interp */ dw6 |= 0 GEN6_WM_NUM_SF_OUTPUTS_SHIFT; /* No inputs from SF */ if (params-use_wm_prog) { - dw2 |= 1 GEN6_WM_SAMPLER_COUNT_SHIFT; /* Up to 4 samplers */ + dw2 |= 1 GEN6_SAMPLER_COUNT_SHIFT; /* Up to 4 samplers */ dw4 |= prog_data-first_curbe_grf GEN6_WM_DISPATCH_START_GRF_SHIFT_0; dw5 |= GEN6_WM_16_DISPATCH_ENABLE; dw5 |= GEN6_WM_KILL_ENABLE; /* TODO: temporarily smash on */ diff --git a/src/mesa/drivers/dri/i965/gen6_gs_state.c b/src/mesa/drivers/dri/i965/gen6_gs_state.c index 9648fb7..29f9042 100644 --- a/src/mesa/drivers/dri/i965/gen6_gs_state.c +++ b/src/mesa/drivers/dri/i965/gen6_gs_state.c @@ -46,7 +46,7 @@ upload_gs_state(struct brw_context *brw) BEGIN_BATCH(7); OUT_BATCH(_3DSTATE_GS 16 | (7 - 2)); OUT_BATCH(brw-ff_gs.prog_offset); - OUT_BATCH(GEN6_GS_SPF_MODE | GEN6_GS_VECTOR_MASK_ENABLE); + OUT_BATCH(GEN6_SPF_MODE | GEN6_VECTOR_MASK_ENABLE); OUT_BATCH(0); /* no scratch space */ OUT_BATCH((2 GEN6_GS_DISPATCH_START_GRF_SHIFT) | (brw-ff_gs.prog_data-urb_read_length GEN6_GS_URB_READ_LENGTH_SHIFT)); @@ -64,8 +64,8 @@ upload_gs_state(struct brw_context *brw) BEGIN_BATCH(7); OUT_BATCH(_3DSTATE_GS
[Mesa-dev] [PATCH 21/22] i965/gen7: Generalize gen7_vs_state in preparation for GS.
--- src/mesa/drivers/dri/i965/brw_state.h | 41 ++ src/mesa/drivers/dri/i965/gen7_vs_state.c | 123 -- 2 files changed, 122 insertions(+), 42 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_state.h b/src/mesa/drivers/dri/i965/brw_state.h index b54338a..efef994 100644 --- a/src/mesa/drivers/dri/i965/brw_state.h +++ b/src/mesa/drivers/dri/i965/brw_state.h @@ -128,6 +128,38 @@ extern const struct brw_tracked_state gen7_wm_state; extern const struct brw_tracked_state haswell_cut_index; +/** + * Parameters that differ between Gen7 VS and GS state upload commands. + */ +struct gen7_vec4_upload_params +{ + /** +* Command used to set the binding table pointers for this stage. +*/ + unsigned binding_table_pointers_cmd; + + /** +* Command used to set the sampler state pointers for this stage. +*/ + unsigned sampler_state_pointers_cmd; + + /** +* Command used to send constants for this stage. +*/ + unsigned constant_cmd; + + /** +* Command used to send state for this stage. +*/ + unsigned state_cmd; + + /** +* Size of the state command for this stage. +*/ + unsigned state_cmd_size; +}; + + /* brw_misc_state.c */ void brw_upload_invariant_state(struct brw_context *brw); uint32_t @@ -240,6 +272,15 @@ brw_vec4_upload_binding_table(struct brw_context *brw, struct brw_vec4_context_base *vec4_ctx, const struct brw_vec4_prog_data *prog_data); +/* gen7_vs_state.c */ +void +gen7_upload_vec4_state(struct brw_context *brw, + const struct gen7_vec4_upload_params *upload_params, + const struct brw_vec4_context_base *vec4_ctx, + bool active, bool alt_floating_point_mode, + const struct brw_vec4_prog_data *prog_data, + const unsigned *stage_specific_cmd_data); + #ifdef __cplusplus } #endif diff --git a/src/mesa/drivers/dri/i965/gen7_vs_state.c b/src/mesa/drivers/dri/i965/gen7_vs_state.c index 30fe802..fd81112 100644 --- a/src/mesa/drivers/dri/i965/gen7_vs_state.c +++ b/src/mesa/drivers/dri/i965/gen7_vs_state.c @@ -29,33 +29,31 @@ #include program/prog_statevars.h #include intel_batchbuffer.h -static void -upload_vs_state(struct brw_context *brw) -{ - struct gl_context *ctx = brw-ctx; - const struct brw_vec4_context_base *vec4_ctx = brw-vs.base; - uint32_t floating_point_mode = 0; - const int max_threads_shift = brw-is_haswell ? - HSW_VS_MAX_THREADS_SHIFT : GEN6_VS_MAX_THREADS_SHIFT; - gen7_emit_vs_workaround_flush(brw); - - /* BRW_NEW_VS_BINDING_TABLE */ +void +gen7_upload_vec4_state(struct brw_context *brw, + const struct gen7_vec4_upload_params *upload_params, + const struct brw_vec4_context_base *vec4_ctx, + bool active, bool alt_floating_point_mode, + const struct brw_vec4_prog_data *prog_data, + const unsigned *stage_specific_cmd_data) +{ + /* BRW_NEW_*_BINDING_TABLE */ BEGIN_BATCH(2); - OUT_BATCH(_3DSTATE_BINDING_TABLE_POINTERS_VS 16 | (2 - 2)); + OUT_BATCH(upload_params-binding_table_pointers_cmd 16 | (2 - 2)); OUT_BATCH(vec4_ctx-bind_bo_offset); ADVANCE_BATCH(); /* CACHE_NEW_SAMPLER */ BEGIN_BATCH(2); - OUT_BATCH(_3DSTATE_SAMPLER_STATE_POINTERS_VS 16 | (2 - 2)); + OUT_BATCH(upload_params-sampler_state_pointers_cmd 16 | (2 - 2)); OUT_BATCH(vec4_ctx-sampler_offset); ADVANCE_BATCH(); - if (vec4_ctx-push_const_size == 0) { + if (!active || vec4_ctx-push_const_size == 0) { /* Disable the push constant buffers. */ BEGIN_BATCH(7); - OUT_BATCH(_3DSTATE_CONSTANT_VS 16 | (7 - 2)); + OUT_BATCH(upload_params-constant_cmd 16 | (7 - 2)); OUT_BATCH(0); OUT_BATCH(0); OUT_BATCH(0); @@ -65,10 +63,10 @@ upload_vs_state(struct brw_context *brw) ADVANCE_BATCH(); } else { BEGIN_BATCH(7); - OUT_BATCH(_3DSTATE_CONSTANT_VS 16 | (7 - 2)); + OUT_BATCH(upload_params-constant_cmd 16 | (7 - 2)); OUT_BATCH(vec4_ctx-push_const_size); OUT_BATCH(0); - /* Pointer to the VS constant buffer. Covered by the set of + /* Pointer to the stage's constant buffer. Covered by the set of * state flags from gen6_prepare_wm_contants */ OUT_BATCH(vec4_ctx-push_const_offset | GEN7_MOCS_L3); @@ -78,36 +76,77 @@ upload_vs_state(struct brw_context *brw) ADVANCE_BATCH(); } + BEGIN_BATCH(upload_params-state_cmd_size); + OUT_BATCH(upload_params-state_cmd 16 | + (upload_params-state_cmd_size - 2)); + if (active) { + OUT_BATCH(vec4_ctx-prog_offset); + OUT_BATCH((alt_floating_point_mode ? GEN6_FLOATING_POINT_MODE_ALT + : GEN6_FLOATING_POINT_MODE_IEEE_754) | +((ALIGN(vec4_ctx-sampler_count, 4)/4) +
[Mesa-dev] [PATCH 22/22] i965/gs: Add a state atom to set up geometry shader state.
--- src/mesa/drivers/dri/i965/Makefile.sources | 1 + src/mesa/drivers/dri/i965/brw_defines.h | 7 ++ src/mesa/drivers/dri/i965/brw_state.h| 2 + src/mesa/drivers/dri/i965/brw_state_upload.c | 2 + src/mesa/drivers/dri/i965/gen7_disable.c | 33 --- src/mesa/drivers/dri/i965/gen7_gs_state.c| 126 +++ 6 files changed, 138 insertions(+), 33 deletions(-) create mode 100644 src/mesa/drivers/dri/i965/gen7_gs_state.c diff --git a/src/mesa/drivers/dri/i965/Makefile.sources b/src/mesa/drivers/dri/i965/Makefile.sources index 1f3abac..5651ba6 100644 --- a/src/mesa/drivers/dri/i965/Makefile.sources +++ b/src/mesa/drivers/dri/i965/Makefile.sources @@ -121,6 +121,7 @@ i965_FILES = \ gen7_blorp.cpp \ gen7_clip_state.c \ gen7_disable.c \ +gen7_gs_state.c \ gen7_misc_state.c \ gen7_sampler_state.c \ gen7_sf_state.c \ diff --git a/src/mesa/drivers/dri/i965/brw_defines.h b/src/mesa/drivers/dri/i965/brw_defines.h index d698757..696de0c 100644 --- a/src/mesa/drivers/dri/i965/brw_defines.h +++ b/src/mesa/drivers/dri/i965/brw_defines.h @@ -1326,15 +1326,22 @@ enum brw_message_target { #define _3DSTATE_GS0x7811 /* GEN6+ */ /* DW4 */ +# define GEN7_GS_OUTPUT_VERTEX_SIZE_SHIFT 23 +# define GEN7_GS_OUTPUT_TOPOLOGY_SHIFT 17 # define GEN6_GS_URB_READ_LENGTH_SHIFT 11 # define GEN7_GS_INCLUDE_VERTEX_HANDLES(1 10) # define GEN6_GS_URB_ENTRY_READ_OFFSET_SHIFT 4 # define GEN6_GS_DISPATCH_START_GRF_SHIFT 0 /* DW5 */ # define GEN6_GS_MAX_THREADS_SHIFT 25 +# define HSW_GS_MAX_THREADS_SHIFT 24 +# define GEN7_GS_DISPATCH_MODE_SINGLE (0 11) +# define GEN7_GS_DISPATCH_MODE_DUAL_INSTANCE (1 11) +# define GEN7_GS_DISPATCH_MODE_DUAL_OBJECT (2 11) # define GEN6_GS_STATISTICS_ENABLE (1 10) # define GEN6_GS_SO_STATISTICS_ENABLE (1 9) # define GEN6_GS_RENDERING_ENABLE (1 8) +# define GEN7_GS_INCLUDE_PRIMITIVE_ID (1 4) # define GEN7_GS_ENABLE(1 0) /* DW6 */ # define GEN6_GS_REORDER (1 30) diff --git a/src/mesa/drivers/dri/i965/brw_state.h b/src/mesa/drivers/dri/i965/brw_state.h index efef994..0205a9e 100644 --- a/src/mesa/drivers/dri/i965/brw_state.h +++ b/src/mesa/drivers/dri/i965/brw_state.h @@ -116,6 +116,8 @@ extern const struct brw_tracked_state gen7_depthbuffer; extern const struct brw_tracked_state gen7_cc_viewport_state_pointer; extern const struct brw_tracked_state gen7_clip_state; extern const struct brw_tracked_state gen7_disable_stages; +extern const struct brw_tracked_state gen7_gs_push_constants; +extern const struct brw_tracked_state gen7_gs_state; extern const struct brw_tracked_state gen7_ps_state; extern const struct brw_tracked_state gen7_push_constant_space; extern const struct brw_tracked_state gen7_sbe_state; diff --git a/src/mesa/drivers/dri/i965/brw_state_upload.c b/src/mesa/drivers/dri/i965/brw_state_upload.c index b6a6a0a..8f21f06 100644 --- a/src/mesa/drivers/dri/i965/brw_state_upload.c +++ b/src/mesa/drivers/dri/i965/brw_state_upload.c @@ -196,6 +196,7 @@ static const struct brw_tracked_state *gen7_atoms[] = gen6_depth_stencil_state, /* must do before cc unit */ gen6_vs_push_constants, /* Before vs_state */ + gen7_gs_push_constants, /* Before gs_state */ gen6_wm_push_constants, /* Before wm_surfaces and constant_buffer */ /* Surface state setup. Must come before the VS/WM unit. The binding @@ -220,6 +221,7 @@ static const struct brw_tracked_state *gen7_atoms[] = gen7_disable_stages, gen7_vs_state, + gen7_gs_state, gen7_sol_state, gen7_clip_state, gen7_sbe_state, diff --git a/src/mesa/drivers/dri/i965/gen7_disable.c b/src/mesa/drivers/dri/i965/gen7_disable.c index d7f9405..98d115b 100644 --- a/src/mesa/drivers/dri/i965/gen7_disable.c +++ b/src/mesa/drivers/dri/i965/gen7_disable.c @@ -29,39 +29,6 @@ static void disable_stages(struct brw_context *brw) { - assert(!brw-ff_gs.prog_active); - - /* Disable the Geometry Shader (GS) Unit */ - BEGIN_BATCH(7); - OUT_BATCH(_3DSTATE_CONSTANT_GS 16 | (7 - 2)); - OUT_BATCH(0); - OUT_BATCH(0); - OUT_BATCH(0); - OUT_BATCH(0); - OUT_BATCH(0); - OUT_BATCH(0); - ADVANCE_BATCH(); - - BEGIN_BATCH(7); - OUT_BATCH(_3DSTATE_GS 16 | (7 - 2)); - OUT_BATCH(0); /* prog_bo */ - OUT_BATCH((0 GEN6_SAMPLER_COUNT_SHIFT) | -(0 GEN6_BINDING_TABLE_ENTRY_COUNT_SHIFT)); - OUT_BATCH(0); /* scratch space base offset */ - OUT_BATCH((1 GEN6_GS_DISPATCH_START_GRF_SHIFT) | -(0 GEN6_GS_URB_READ_LENGTH_SHIFT) | -GEN7_GS_INCLUDE_VERTEX_HANDLES | -(0 GEN6_GS_URB_ENTRY_READ_OFFSET_SHIFT)); -
Re: [Mesa-dev] [PATCH] clover: work around altivec build failure with GNU C++ and -std=c++
Chí-Thanh Christopher Nguyễn chith...@gentoo.org writes: Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=68504 Bugzilla: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58241 CC: mesa-sta...@lists.freedesktop.org --- configure.ac | 11 +++ src/gallium/state_trackers/clover/Makefile.am | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 40e052c..15831fd 100644 --- a/configure.ac +++ b/configure.ac @@ -1390,6 +1390,17 @@ if test x$enable_opencl = xyes; then AC_MSG_ERROR([pkg-config cannot use libclc.pc which is required to build clover]) fi +dnl +dnl Workaround for altivec failure with GNU C++ and -std=c++0x, PR58241 +dnl + +if test x${ac_cv_cxx_compiler_gnu} = xyes ; then +CLOVER_CXX_STD=gnu++0x +else +CLOVER_CXX_STD=c++0x +fi +AC_SUBST([CLOVER_CXX_STD]) + GALLIUM_STATE_TRACKERS_DIRS=$GALLIUM_STATE_TRACKERS_DIRS clover GALLIUM_TARGET_DIRS=$GALLIUM_TARGET_DIRS opencl enable_gallium_loader=yes diff --git a/src/gallium/state_trackers/clover/Makefile.am b/src/gallium/state_trackers/clover/Makefile.am index b4c197a..e339c1f 100644 --- a/src/gallium/state_trackers/clover/Makefile.am +++ b/src/gallium/state_trackers/clover/Makefile.am @@ -30,7 +30,7 @@ libclllvm_la_SOURCES = \ llvm/invocation.cpp libclover_la_CXXFLAGS = \ - -std=c++0x + -std=$(CLOVER_CXX_STD) libclover_la_LIBADD = \ libcltgsi.la libclllvm.la How about disabling AltiVec code generation by adding -mno-altivec to CXXFLAGS? AFAICT what's going on is that the -maltivec option (which is implied by your -mcpu=7450) enables a number of language extensions as a side effect that collide with the C++ standard, which is exacerbated by GCC's seemingly broken implementation. I wonder if they could have any undesirable side effects on components other than clover: not including altivec.h doesn't seem to guarantee that the problematic preprocessor definitions (bool and vector) aren't going to be present. Switching the dialect we're compiling with to GNU C++ isn't especially reassuring, clover doesn't need GNU's C++ extensions and we don't want to start using any of them by accident -- we don't use the AltiVec extensions either so disabling the latter seems like the most reasonable solution to me. Thank you. pgpi8kq41txBW.pgp Description: PGP signature ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] configure.ac: Fix order of and/or for AM_CONDITIONAL
Sorry, I missed that the author already sent his patch to the list. Please disregard. ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] clover: work around altivec build failure with GNU C++ and -std=c++
Chí-Thanh Christopher Nguyễn schrieb: How about disabling AltiVec code generation by adding -mno-altivec to CXXFLAGS? AFAICT what's going on is that the -maltivec option (which is implied by your -mcpu=7450) enables a number of language extensions as a side effect that collide with the C++ standard, which is exacerbated by GCC's seemingly broken implementation. Ah, and one potential issue I didn't think of yet is that -mno-altivec also implies -mabi=no-altivec and I am unsure if this can lead to problems if altivec ABI is enabled for the rest of the build. Best regards, Chí-Thanh Christopher Nguyễn ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] clover: work around altivec build failure with GNU C++ and -std=c++
Chí-Thanh Christopher Nguyễn chith...@gentoo.org writes: Francisco Jerez schrieb: [...] How about disabling AltiVec code generation by adding -mno-altivec to CXXFLAGS? AFAICT what's going on is that the -maltivec option (which is implied by your -mcpu=7450) enables a number of language extensions as a side effect that collide with the C++ standard, which is exacerbated by GCC's seemingly broken implementation. Then what is the purpose of the altivec code in cl_platform.h? cl_platform.h is part of the standard CL headers provided by Khronos, they're meant to be distributed along with mesa for OpenCL applications to use, but the AltiVec code is not useful for the implementation itself. pgphRMxmrflNb.pgp Description: PGP signature ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] clover: work around altivec build failure with GNU C++ and -std=c++
Chí-Thanh Christopher Nguyễn chith...@gentoo.org writes: Chí-Thanh Christopher Nguyễn schrieb: How about disabling AltiVec code generation by adding -mno-altivec to CXXFLAGS? AFAICT what's going on is that the -maltivec option (which is implied by your -mcpu=7450) enables a number of language extensions as a side effect that collide with the C++ standard, which is exacerbated by GCC's seemingly broken implementation. Ah, and one potential issue I didn't think of yet is that -mno-altivec also implies -mabi=no-altivec and I am unsure if this can lead to problems if altivec ABI is enabled for the rest of the build. Aren't both options orthogonal? It seems like you can enable the AltiVec ABI without getting the annoying language extensions by doing -mno-altivec -mabi=altivec. Best regards, Chí-Thanh Christopher Nguyễn pgpShpfDnoGvp.pgp Description: PGP signature ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] clover: work around altivec build failure with GNU C++ and -std=c++
Francisco Jerez schrieb: Chí-Thanh Christopher Nguyễn chith...@gentoo.org writes: Chí-Thanh Christopher Nguyễn schrieb: How about disabling AltiVec code generation by adding -mno-altivec to CXXFLAGS? AFAICT what's going on is that the -maltivec option (which is implied by your -mcpu=7450) enables a number of language extensions as a side effect that collide with the C++ standard, which is exacerbated by GCC's seemingly broken implementation. Ah, and one potential issue I didn't think of yet is that -mno-altivec also implies -mabi=no-altivec and I am unsure if this can lead to problems if altivec ABI is enabled for the rest of the build. Aren't both options orthogonal? It seems like you can enable the AltiVec ABI without getting the annoying language extensions by doing -mno-altivec -mabi=altivec. Yes, but how are we going to find out whether we need to pass -mabi=altivec or not? Certain values for -mcpu imply -maltivec and -mabi=altivec, while others don't. (That is assuming mixing -mabi=altivec and -mabi=no-altivec can cause problems, which I have no idea at all about.) Best regards, Chí-Thanh Christopher Nguyễn ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] glsl: Disallow uniform block layout qualifiers on non-uniform block vars.
On 08/26/2013 02:16 PM, Matt Turner wrote: Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=68460 Cc: 9.2 mesa-sta...@lists.freedesktop.org --- src/glsl/ast_to_hir.cpp | 17 + 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp index feff586..bb25d81 100644 --- a/src/glsl/ast_to_hir.cpp +++ b/src/glsl/ast_to_hir.cpp @@ -1849,9 +1849,18 @@ is_varying_var(ir_variable *var, _mesa_glsl_parser_targets target) static void validate_matrix_layout_for_type(struct _mesa_glsl_parse_state *state, YYLTYPE *loc, - const glsl_type *type) +const glsl_type *type, +ir_variable *var) { - if (!type-is_matrix()) { + if (var !var-is_in_uniform_block()) { + /* Layout qualifiers may only apply to interface blocks and fields in + * them. + */ + _mesa_glsl_error(loc, state, + uniform block layout qualifiers row_major and + column_major may not be applied to variables + outside of uniform blocks); + } else if (!type-is_matrix()) { /* The OpenGL ES 3.0 conformance tests did not originally allow * matrix layout qualifiers on non-matrices. However, the OpenGL * 4.4 and OpenGL ES 3.0 (revision TBD) specifications were @@ -2302,7 +2311,7 @@ apply_type_qualifier_to_variable(const struct ast_type_qualifier *qual, } if (qual-flags.q.row_major || qual-flags.q.column_major) { - validate_matrix_layout_for_type(state, loc, var-type); + validate_matrix_layout_for_type(state, loc, var-type, var); } } @@ -4476,7 +4485,7 @@ ast_process_structure_or_interface_block(exec_list *instructions, row_major and column_major can only be applied to uniform interface blocks); } else - validate_matrix_layout_for_type(state, loc, field_type); + validate_matrix_layout_for_type(state, loc, field_type, NULL); I think this will allow things like: struct foo { layout(row_major) mat4 bar; }; Yeah? } if (qual-flags.q.uniform qual-has_interpolation()) { ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] glsl: Disallow uniform block layout qualifiers on non-uniform block vars.
On Mon, Aug 26, 2013 at 4:35 PM, Ian Romanick i...@freedesktop.org wrote: I think this will allow things like: struct foo { layout(row_major) mat4 bar; }; Yeah? Don't think so: error: syntax error, unexpected LAYOUT_TOK ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [RFC PATCH] i965: Allow C++ type safety in the use of enum brw_urb_write_flags.
On 08/26/2013 01:10 PM, Francisco Jerez wrote: Ian Romanick i...@freedesktop.org writes: [...] Disadvantage (b) can be made painless with the macro I discuss below. IMHO it would be nicer to define generic templates implementing overloads for all bitwise operators. They would have to reference the bitmask_enumeration_traits structure so they would be discarded for non-bitmask types. [...] Second, we could arrange for the expression 'FOO op BAR' (with 'FOO' and 'BAR' enumerants from different incompatible bitmask types) to be rejected by the compiler by means of a static assertion in the definition of 'T op S'. If we use the macro solution below the compiler will accept that expression by downgrading both T and S to integers and then applying the built-in definition of 'op'. Though it would still refuse to assign the result to a variable of any of both types *if* the user is doing that. As a non-C++ programmer, that explanation gave me a headache. I don't think this project is ready yet for its developers to need that level of knowledge of the C++ type system. I can immediately understand Chad's macro, and I can also (nearly immediately) understand that it's probably not the C++ way. My explanation is exactly as relevant if we stick to Chad's solution or not, using macros doesn't save you from getting the unexpected effect I was trying to describe -- quite the opposite, I can't think of any simple way to work around that problem without using templates. The thing is that defining bitwise operators separately for each enum type, as this patch and the macro solution do, doesn't stop the compiler From using the corresponding built-in integer operators when it doesn't find a match among the user-defined ones. That means that if we have two bitfield enumerants from two different disjoint types e.g. SEASON_OF_THE_YEAR_SUMMER and a CPU_ARCHITECTURE_I386, the compiler is still going to accept expressions like SEASON_OF_THE_YEAR_SUMMER | CPU_ARCHITECTURE_I386, which might not be what had been expected if the BRW_CXX_ENUM_OPS macro was used in an attempt to improve the code's type safety. This sounds insane. If there are no operator overloads, the compiler rejects: enum foo f(enum foo a, enum foo b) { return a | b; } Then we add operloads: enum foo operator|(enum foo, enum foo); enum bar operator|(enum bar, enum bar); And now the compiler will accept: unsigned f(enum foo a, enum bar b) { return a | b; } That can't be right. Am I missing something? Or am I reinforcing my point about not being ready for this level of C++ ninjitsu... The template-based solution might seem somewhat obscure to the inexperienced C++ programmer, but unlike the macro-based one it would be semantically sound, and this is just one of many reasons why it's a good idea for anyone dealing with C++ code to have at least some basic knowledge on using templates -- it's the cleanest way to do static polymorphism and generic programming in C++. That said, I agree that it would be a bad idea to make a sudden transition to template metaprogramming in components of our tree where the majority of maintainers have a strong preference towards old-school C programming, but that's no reason to reject a small, non-intrusive and potentially useful change in the good direction a priori before having seen any of the code... [...] ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] glsl: Disallow uniform block layout qualifiers on non-uniform block vars.
On 08/26/2013 04:49 PM, Matt Turner wrote: On Mon, Aug 26, 2013 at 4:35 PM, Ian Romanick i...@freedesktop.org wrote: I think this will allow things like: struct foo { layout(row_major) mat4 bar; }; Yeah? Don't think so: error: syntax error, unexpected LAYOUT_TOK Right... because the grammar doesn't allow it. Assuming it fixes the broken cases (and doesn't regress anything in a full piglit / gles3conform run), Reviewed-by: Ian Romanick ian.d.roman...@intel.com ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev