From mareko at kemper.freedesktop.org Mon Mar 2 11:49:12 2015 From: mareko at kemper.freedesktop.org (Marek Olšák) Date: Mon, 2 Mar 2015 03:49:12 -0800 (PST) Subject: Mesa (master): draw: fix division-by-zero for empty geometry shaders Message-ID: <20150302114912.42F1776338@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 27a34f62baa991eadd040302748c48b31ec21a0c URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=27a34f62baa991eadd040302748c48b31ec21a0c Author: Marek Ol??k Date: Sun Mar 1 11:18:42 2015 +0100 draw: fix division-by-zero for empty geometry shaders Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=89372 Reviewed-by: Dave Airlie --- src/gallium/auxiliary/draw/draw_pt_emit.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/gallium/auxiliary/draw/draw_pt_emit.c b/src/gallium/auxiliary/draw/draw_pt_emit.c index b215c5f..d1eafd8 100644 --- a/src/gallium/auxiliary/draw/draw_pt_emit.c +++ b/src/gallium/auxiliary/draw/draw_pt_emit.c @@ -113,8 +113,11 @@ draw_pt_emit_prepare(struct pt_emit *emit, emit->translate = translate_cache_find(emit->cache, &hw_key); } - *max_vertices = (draw->render->max_vertex_buffer_bytes / - (vinfo->size * 4)); + if (!vinfo->size) + *max_vertices = 0; + else + *max_vertices = (draw->render->max_vertex_buffer_bytes / + (vinfo->size * 4)); } From nroberts at kemper.freedesktop.org Mon Mar 2 12:08:07 2015 From: nroberts at kemper.freedesktop.org (Neil Roberts) Date: Mon, 2 Mar 2015 04:08:07 -0800 (PST) Subject: Mesa (master): i965/skl: Fix the maximum thread count format for the PS Message-ID: <20150302120807.89AEF76338@kemper.freedesktop.org> Module: Mesa Branch: master Commit: aef8a4897937c0c06c7b01e39de23117a6e81d3e URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=aef8a4897937c0c06c7b01e39de23117a6e81d3e Author: Neil Roberts Date: Fri Feb 27 16:57:22 2015 +0000 i965/skl: Fix the maximum thread count format for the PS According to the bspec for some reason the format of the maximum number of threads field has changed from U8-2 to U8-1 for the PS. Reviewed-by: Anuj Phogat --- src/mesa/drivers/dri/i965/gen8_ps_state.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/mesa/drivers/dri/i965/gen8_ps_state.c b/src/mesa/drivers/dri/i965/gen8_ps_state.c index d4a58e4..5f39e12 100644 --- a/src/mesa/drivers/dri/i965/gen8_ps_state.c +++ b/src/mesa/drivers/dri/i965/gen8_ps_state.c @@ -146,8 +146,13 @@ upload_ps_state(struct brw_context *brw) /* 3DSTATE_PS expects the number of threads per PSD, which is always 64; * it implicitly scales for different GT levels (which have some # of PSDs). + * + * In Gen8 the format is U8-2 whereas in Gen9 it is U8-1. */ - dw6 |= (64 - 2) << HSW_PS_MAX_THREADS_SHIFT; + if (brw->gen >= 9) + dw6 |= (64 - 1) << HSW_PS_MAX_THREADS_SHIFT; + else + dw6 |= (64 - 2) << HSW_PS_MAX_THREADS_SHIFT; if (prog_data->base.nr_params > 0) dw6 |= GEN7_PS_PUSH_CONSTANT_ENABLE; From nroberts at kemper.freedesktop.org Mon Mar 2 12:08:07 2015 From: nroberts at kemper.freedesktop.org (Neil Roberts) Date: Mon, 2 Mar 2015 04:08:07 -0800 (PST) Subject: Mesa (master): i965/skl: Lay out a 1D miptree horizontally Message-ID: <20150302120807.9F731763B8@kemper.freedesktop.org> Module: Mesa Branch: master Commit: cf67ca9ffa92a6324ed4c3df0bffd18fd967bc8d URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=cf67ca9ffa92a6324ed4c3df0bffd18fd967bc8d Author: Neil Roberts Date: Thu Feb 12 14:39:07 2015 +0000 i965/skl: Lay out a 1D miptree horizontally On Gen9+ the 1D miptree is laid out with all of the mipmap levels in a horizontal line. Reviewed-by: Ben Widawsky --- src/mesa/drivers/dri/i965/brw_tex_layout.c | 62 +++++++++++++++++++++++++++- 1 file changed, 60 insertions(+), 2 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_tex_layout.c b/src/mesa/drivers/dri/i965/brw_tex_layout.c index 6923a8f..5e70cd2 100644 --- a/src/mesa/drivers/dri/i965/brw_tex_layout.c +++ b/src/mesa/drivers/dri/i965/brw_tex_layout.c @@ -161,6 +161,36 @@ intel_vertical_texture_alignment_unit(struct brw_context *brw, } static void +gen9_miptree_layout_1d(struct intel_mipmap_tree *mt) +{ + unsigned x = 0; + unsigned width = mt->physical_width0; + unsigned depth = mt->physical_depth0; /* number of array layers. */ + + /* When this layout is used the horizontal alignment is fixed at 64 and the + * hardware ignores the value given in the surface state + */ + const unsigned int align_w = 64; + + mt->total_height = mt->physical_height0; + mt->total_width = 0; + + for (unsigned level = mt->first_level; level <= mt->last_level; level++) { + unsigned img_width; + + intel_miptree_set_level_info(mt, level, x, 0, depth); + + img_width = ALIGN(width, align_w); + + mt->total_width = MAX2(mt->total_width, x + img_width); + + x += img_width; + + width = minify(width, 1); + } +} + +static void brw_miptree_layout_2d(struct intel_mipmap_tree *mt) { unsigned x = 0; @@ -245,12 +275,34 @@ align_cube(struct intel_mipmap_tree *mt) mt->total_height += 2; } +static bool +use_linear_1d_layout(struct brw_context *brw, + struct intel_mipmap_tree *mt) +{ + /* On Gen9+ the mipmap levels of a 1D surface are all laid out in a + * horizontal line. This isn't done for depth/stencil buffers however + * because those will be using a tiled layout + */ + if (brw->gen >= 9 && + (mt->target == GL_TEXTURE_1D || + mt->target == GL_TEXTURE_1D_ARRAY)) { + GLenum base_format = _mesa_get_format_base_format(mt->format); + + if (base_format != GL_DEPTH_COMPONENT && + base_format != GL_DEPTH_STENCIL) + return true; + } + + return false; +} + static void brw_miptree_layout_texture_array(struct brw_context *brw, struct intel_mipmap_tree *mt) { int h0, h1; unsigned height = mt->physical_height0; + bool layout_1d = use_linear_1d_layout(brw, mt); h0 = ALIGN(mt->physical_height0, mt->align_h); h1 = ALIGN(minify(mt->physical_height0, 1), mt->align_h); @@ -261,7 +313,10 @@ brw_miptree_layout_texture_array(struct brw_context *brw, int physical_qpitch = mt->compressed ? mt->qpitch / 4 : mt->qpitch; - brw_miptree_layout_2d(mt); + if (layout_1d) + gen9_miptree_layout_1d(mt); + else + brw_miptree_layout_2d(mt); for (unsigned level = mt->first_level; level <= mt->last_level; level++) { unsigned img_height; @@ -395,7 +450,10 @@ brw_miptree_layout(struct brw_context *brw, struct intel_mipmap_tree *mt) break; case INTEL_MSAA_LAYOUT_NONE: case INTEL_MSAA_LAYOUT_IMS: - brw_miptree_layout_2d(mt); + if (use_linear_1d_layout(brw, mt)) + gen9_miptree_layout_1d(mt); + else + brw_miptree_layout_2d(mt); break; } break; From nroberts at kemper.freedesktop.org Mon Mar 2 12:08:07 2015 From: nroberts at kemper.freedesktop.org (Neil Roberts) Date: Mon, 2 Mar 2015 04:08:07 -0800 (PST) Subject: Mesa (master): i965/skl: Lay out 3D textures the same as array textures Message-ID: <20150302120807.94CAE763B7@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 0f1e86afd65952df00b82e55c4b7371645cf6fbc URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=0f1e86afd65952df00b82e55c4b7371645cf6fbc Author: Neil Roberts Date: Wed Feb 18 18:27:45 2015 +0000 i965/skl: Lay out 3D textures the same as array textures On Gen9+ the 3D textures use the same mipmap layout as 2D array textures. Reviewed-by: Ben Widawsky --- src/mesa/drivers/dri/i965/brw_tex_layout.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_tex_layout.c b/src/mesa/drivers/dri/i965/brw_tex_layout.c index 66d1b4f..6923a8f 100644 --- a/src/mesa/drivers/dri/i965/brw_tex_layout.c +++ b/src/mesa/drivers/dri/i965/brw_tex_layout.c @@ -227,6 +227,9 @@ brw_miptree_layout_2d(struct intel_mipmap_tree *mt) width = minify(width, 1); height = minify(height, 1); + + if (mt->target == GL_TEXTURE_3D) + depth = minify(depth, 1); } } @@ -266,7 +269,7 @@ brw_miptree_layout_texture_array(struct brw_context *brw, if (mt->compressed) img_height /= mt->align_h; - for (int q = 0; q < mt->physical_depth0; q++) { + for (int q = 0; q < mt->level[level].depth; q++) { if (mt->array_layout == ALL_SLICES_AT_EACH_LOD) { intel_miptree_set_image_offset(mt, level, q, 0, q * img_height); } else { @@ -371,7 +374,10 @@ brw_miptree_layout(struct brw_context *brw, struct intel_mipmap_tree *mt) break; case GL_TEXTURE_3D: - brw_miptree_layout_texture_3d(brw, mt); + if (brw->gen >= 9) + brw_miptree_layout_texture_array(brw, mt); + else + brw_miptree_layout_texture_3d(brw, mt); break; case GL_TEXTURE_1D_ARRAY: From currojerez at kemper.freedesktop.org Mon Mar 2 12:32:43 2015 From: currojerez at kemper.freedesktop.org (Francisco Jerez) Date: Mon, 2 Mar 2015 04:32:43 -0800 (PST) Subject: Mesa (master): i965: Add missing defines for render cache messages. Message-ID: <20150302123243.9F4DF76338@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 65f9b83e05d790ddb3846b7a0e2b02241c61ab02 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=65f9b83e05d790ddb3846b7a0e2b02241c61ab02 Author: Francisco Jerez Date: Fri Nov 22 16:18:43 2013 -0800 i965: Add missing defines for render cache messages. And remove duplicated definition of OWORD_DUAL_BLOCK_WRITE. Reviewed-by: Paul Berry --- src/mesa/drivers/dri/i965/brw_defines.h | 8 +++++++- src/mesa/drivers/dri/i965/brw_vec4_generator.cpp | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_defines.h b/src/mesa/drivers/dri/i965/brw_defines.h index 17c27dd..da6ed5b 100644 --- a/src/mesa/drivers/dri/i965/brw_defines.h +++ b/src/mesa/drivers/dri/i965/brw_defines.h @@ -1440,7 +1440,13 @@ enum brw_message_target { #define GEN6_DATAPORT_WRITE_MESSAGE_RENDER_TARGET_UNORM_WRITE 14 /* GEN7 */ -#define GEN7_DATAPORT_WRITE_MESSAGE_OWORD_DUAL_BLOCK_WRITE 10 +#define GEN7_DATAPORT_RC_MEDIA_BLOCK_READ 4 +#define GEN7_DATAPORT_RC_TYPED_SURFACE_READ 5 +#define GEN7_DATAPORT_RC_TYPED_ATOMIC_OP 6 +#define GEN7_DATAPORT_RC_MEMORY_FENCE 7 +#define GEN7_DATAPORT_RC_MEDIA_BLOCK_WRITE 10 +#define GEN7_DATAPORT_RC_RENDER_TARGET_WRITE 12 +#define GEN7_DATAPORT_RC_TYPED_SURFACE_WRITE 13 #define GEN7_DATAPORT_DC_OWORD_BLOCK_READ 0 #define GEN7_DATAPORT_DC_UNALIGNED_OWORD_BLOCK_READ 1 #define GEN7_DATAPORT_DC_OWORD_DUAL_BLOCK_READ 2 diff --git a/src/mesa/drivers/dri/i965/brw_vec4_generator.cpp b/src/mesa/drivers/dri/i965/brw_vec4_generator.cpp index 67c8285..010a5c4 100644 --- a/src/mesa/drivers/dri/i965/brw_vec4_generator.cpp +++ b/src/mesa/drivers/dri/i965/brw_vec4_generator.cpp @@ -948,7 +948,7 @@ vec4_generator::generate_scratch_write(vec4_instruction *inst, uint32_t msg_type; if (brw->gen >= 7) - msg_type = GEN7_DATAPORT_WRITE_MESSAGE_OWORD_DUAL_BLOCK_WRITE; + msg_type = GEN7_DATAPORT_DC_OWORD_DUAL_BLOCK_WRITE; else if (brw->gen == 6) msg_type = GEN6_DATAPORT_WRITE_MESSAGE_OWORD_DUAL_BLOCK_WRITE; else From currojerez at kemper.freedesktop.org Mon Mar 2 12:32:43 2015 From: currojerez at kemper.freedesktop.org (Francisco Jerez) Date: Mon, 2 Mar 2015 04:32:43 -0800 (PST) Subject: Mesa (master): i965: Remove the create_raw_surface vtbl hook. Message-ID: <20150302123243.AB60C76338@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 7bfbaf4a5ab580a8661ea99059cb48c64a016ab6 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=7bfbaf4a5ab580a8661ea99059cb48c64a016ab6 Author: Francisco Jerez Date: Tue Feb 10 15:54:55 2015 +0200 i965: Remove the create_raw_surface vtbl hook. It's a wrapper around emit_buffer_surface_state with format=RAW, pitch=1, rw=true and the remaining arguments ordered differently. There's no point in having a separate vtbl pointer for that. Reviewed-by: Kristian H?gsberg --- src/mesa/drivers/dri/i965/brw_binding_tables.c | 8 +++++--- src/mesa/drivers/dri/i965/brw_context.h | 6 ------ src/mesa/drivers/dri/i965/brw_wm_surface_state.c | 6 +++--- src/mesa/drivers/dri/i965/gen7_wm_surface_state.c | 19 ------------------- src/mesa/drivers/dri/i965/gen8_surface_state.c | 16 ---------------- 5 files changed, 8 insertions(+), 47 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_binding_tables.c b/src/mesa/drivers/dri/i965/brw_binding_tables.c index ea82e71..08e4191 100644 --- a/src/mesa/drivers/dri/i965/brw_binding_tables.c +++ b/src/mesa/drivers/dri/i965/brw_binding_tables.c @@ -68,9 +68,11 @@ brw_upload_binding_table(struct brw_context *brw, } else { /* Upload a new binding table. */ if (INTEL_DEBUG & DEBUG_SHADER_TIME) { - brw->vtbl.create_raw_surface( - brw, brw->shader_time.bo, 0, brw->shader_time.bo->size, - &stage_state->surf_offset[prog_data->binding_table.shader_time_start], true); + brw->vtbl.emit_buffer_surface_state( + brw, &stage_state->surf_offset[ + prog_data->binding_table.shader_time_start], + brw->shader_time.bo, 0, BRW_SURFACEFORMAT_RAW, + brw->shader_time.bo->size, 1, true); } uint32_t *bind = brw_state_batch(brw, AUB_TRACE_BINDING_TABLE, diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h index 197ed3e..c89e90e 100644 --- a/src/mesa/drivers/dri/i965/brw_context.h +++ b/src/mesa/drivers/dri/i965/brw_context.h @@ -964,12 +964,6 @@ struct brw_context bool layered, unsigned unit); - void (*create_raw_surface)(struct brw_context *brw, - drm_intel_bo *bo, - uint32_t offset, - uint32_t size, - uint32_t *out_offset, - bool rw); void (*emit_buffer_surface_state)(struct brw_context *brw, uint32_t *out_offset, drm_intel_bo *bo, 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 f479f44..828893b 100644 --- a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c +++ b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c @@ -953,9 +953,9 @@ brw_upload_abo_surfaces(struct brw_context *brw, drm_intel_bo *bo = intel_bufferobj_buffer( brw, intel_bo, binding->Offset, intel_bo->Base.Size - binding->Offset); - brw->vtbl.create_raw_surface(brw, bo, binding->Offset, - bo->size - binding->Offset, - &surf_offsets[i], true); + brw->vtbl.emit_buffer_surface_state(brw, &surf_offsets[i], bo, + binding->Offset, BRW_SURFACEFORMAT_RAW, + bo->size - binding->Offset, 1, true); } if (prog->NumAtomicBuffers) diff --git a/src/mesa/drivers/dri/i965/gen7_wm_surface_state.c b/src/mesa/drivers/dri/i965/gen7_wm_surface_state.c index 12b588f..7d78515 100644 --- a/src/mesa/drivers/dri/i965/gen7_wm_surface_state.c +++ b/src/mesa/drivers/dri/i965/gen7_wm_surface_state.c @@ -373,24 +373,6 @@ gen7_update_texture_surface(struct gl_context *ctx, } /** - * Create a raw surface for untyped R/W access. - */ -static void -gen7_create_raw_surface(struct brw_context *brw, drm_intel_bo *bo, - uint32_t offset, uint32_t size, - uint32_t *out_offset, bool rw) -{ - gen7_emit_buffer_surface_state(brw, - out_offset, - bo, - offset, - BRW_SURFACEFORMAT_RAW, - size, - 1, - true /* rw */); -} - -/** * Creates a null surface. * * This is used when the shader doesn't write to any color output. An FB @@ -563,6 +545,5 @@ gen7_init_vtable_surface_functions(struct brw_context *brw) brw->vtbl.update_texture_surface = gen7_update_texture_surface; brw->vtbl.update_renderbuffer_surface = gen7_update_renderbuffer_surface; brw->vtbl.emit_null_surface_state = gen7_emit_null_surface_state; - brw->vtbl.create_raw_surface = gen7_create_raw_surface; brw->vtbl.emit_buffer_surface_state = gen7_emit_buffer_surface_state; } diff --git a/src/mesa/drivers/dri/i965/gen8_surface_state.c b/src/mesa/drivers/dri/i965/gen8_surface_state.c index d6b870e..7f82f53 100644 --- a/src/mesa/drivers/dri/i965/gen8_surface_state.c +++ b/src/mesa/drivers/dri/i965/gen8_surface_state.c @@ -274,21 +274,6 @@ gen8_update_texture_surface(struct gl_context *ctx, I915_GEM_DOMAIN_SAMPLER, 0); } -static void -gen8_create_raw_surface(struct brw_context *brw, drm_intel_bo *bo, - uint32_t offset, uint32_t size, - uint32_t *out_offset, bool rw) -{ - gen8_emit_buffer_surface_state(brw, - out_offset, - bo, - offset, - BRW_SURFACEFORMAT_RAW, - size, - 1, - true /* rw */); -} - /** * Creates a null surface. * @@ -456,6 +441,5 @@ gen8_init_vtable_surface_functions(struct brw_context *brw) brw->vtbl.update_texture_surface = gen8_update_texture_surface; brw->vtbl.update_renderbuffer_surface = gen8_update_renderbuffer_surface; brw->vtbl.emit_null_surface_state = gen8_emit_null_surface_state; - brw->vtbl.create_raw_surface = gen8_create_raw_surface; brw->vtbl.emit_buffer_surface_state = gen8_emit_buffer_surface_state; } From jrfonseca at kemper.freedesktop.org Mon Mar 2 14:52:20 2015 From: jrfonseca at kemper.freedesktop.org (Jose Fonseca) Date: Mon, 2 Mar 2015 06:52:20 -0800 (PST) Subject: Mesa (master): identity: Remove. Message-ID: <20150302145220.C9DCA761DF@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 9a07435ff885277aba670eb59c039a748175c702 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=9a07435ff885277aba670eb59c039a748175c702 Author: Jose Fonseca Date: Fri Feb 27 14:43:51 2015 +0000 identity: Remove. It's unmaintained, and most likely broken: I use trace driver every now and then, and everytime I do I need to fix it up. It's also unused: identity_screen_create is never called. Above all, it's dead weight: if identity driver had the infrastructure for other pass-through drivers (like trace and rbug), then it would make sense on its own right. But as it is implemmented, it's just another driver to (forget) to update whenever there is a gallium interface change. Reviewed-by: Marek Ol??k --- configure.ac | 1 - src/gallium/Makefile.am | 1 - src/gallium/SConscript | 1 - src/gallium/drivers/identity/Makefile.am | 11 - src/gallium/drivers/identity/Makefile.sources | 8 - src/gallium/drivers/identity/SConscript | 12 - src/gallium/drivers/identity/id_context.c | 883 ------------------------- src/gallium/drivers/identity/id_context.h | 52 -- src/gallium/drivers/identity/id_objects.c | 189 ------ src/gallium/drivers/identity/id_objects.h | 177 ----- src/gallium/drivers/identity/id_public.h | 37 -- src/gallium/drivers/identity/id_screen.c | 286 -------- src/gallium/drivers/identity/id_screen.h | 48 -- src/gallium/targets/egl-static/Makefile.am | 1 - 14 files changed, 1707 deletions(-) Diff: http://cgit.freedesktop.org/mesa/mesa/diff/?id=9a07435ff885277aba670eb59c039a748175c702 From jrfonseca at kemper.freedesktop.org Mon Mar 2 14:52:20 2015 From: jrfonseca at kemper.freedesktop.org (Jose Fonseca) Date: Mon, 2 Mar 2015 06:52:20 -0800 (PST) Subject: Mesa (master): scons: Fix HAVE___* definition. Message-ID: <20150302145220.D3013763B7@kemper.freedesktop.org> Module: Mesa Branch: master Commit: fa5140bb18422da570958a58a4bd0cec718402e7 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=fa5140bb18422da570958a58a4bd0cec718402e7 Author: Jose Fonseca Date: Fri Feb 27 15:42:23 2015 +0000 scons: Fix HAVE___* definition. These definitions must be moved before `cppdefines` is used to have effect. Trivial. --- scons/gallium.py | 47 +++++++++++++++++++++++------------------------ 1 file changed, 23 insertions(+), 24 deletions(-) diff --git a/scons/gallium.py b/scons/gallium.py index 5195508..711aa3b 100755 --- a/scons/gallium.py +++ b/scons/gallium.py @@ -342,6 +342,29 @@ def generate(env): print 'warning: Floating-point textures enabled.' print 'warning: Please consult docs/patents.txt with your lawyer before building Mesa.' cppdefines += ['TEXTURE_FLOAT_ENABLED'] + if gcc_compat: + ccversion = env['CCVERSION'] + cppdefines += [ + 'HAVE___BUILTIN_EXPECT', + 'HAVE___BUILTIN_FFS', + 'HAVE___BUILTIN_FFSLL', + 'HAVE_FUNC_ATTRIBUTE_FLATTEN', + ] + if distutils.version.LooseVersion(ccversion) >= distutils.version.LooseVersion('3'): + cppdefines += [ + 'HAVE_FUNC_ATTRIBUTE_FORMAT', + 'HAVE_FUNC_ATTRIBUTE_PACKED', + ] + if distutils.version.LooseVersion(ccversion) >= distutils.version.LooseVersion('3.4'): + cppdefines += [ + 'HAVE___BUILTIN_CTZ', + 'HAVE___BUILTIN_POPCOUNT', + 'HAVE___BUILTIN_POPCOUNTLL', + 'HAVE___BUILTIN_CLZ', + 'HAVE___BUILTIN_CLZLL', + ] + if distutils.version.LooseVersion(ccversion) >= distutils.version.LooseVersion('4.5'): + cppdefines += ['HAVE___BUILTIN_UNREACHABLE'] env.Append(CPPDEFINES = cppdefines) # C compiler options @@ -584,30 +607,6 @@ def generate(env): env.Append(CCFLAGS = ['-fopenmp']) env.Append(LIBS = ['gomp']) - if gcc_compat: - ccversion = env['CCVERSION'] - cppdefines += [ - 'HAVE___BUILTIN_EXPECT', - 'HAVE___BUILTIN_FFS', - 'HAVE___BUILTIN_FFSLL', - 'HAVE_FUNC_ATTRIBUTE_FLATTEN', - ] - if distutils.version.LooseVersion(ccversion) >= distutils.version.LooseVersion('3'): - cppdefines += [ - 'HAVE_FUNC_ATTRIBUTE_FORMAT', - 'HAVE_FUNC_ATTRIBUTE_PACKED', - ] - if distutils.version.LooseVersion(ccversion) >= distutils.version.LooseVersion('3.4'): - cppdefines += [ - 'HAVE___BUILTIN_CTZ', - 'HAVE___BUILTIN_POPCOUNT', - 'HAVE___BUILTIN_POPCOUNTLL', - 'HAVE___BUILTIN_CLZ', - 'HAVE___BUILTIN_CLZLL', - ] - if distutils.version.LooseVersion(ccversion) >= distutils.version.LooseVersion('4.5'): - cppdefines += ['HAVE___BUILTIN_UNREACHABLE'] - # Load tools env.Tool('lex') env.Tool('yacc') From brianp at kemper.freedesktop.org Mon Mar 2 16:02:50 2015 From: brianp at kemper.freedesktop.org (Brian Paul) Date: Mon, 2 Mar 2015 08:02:50 -0800 (PST) Subject: Mesa (master): mesa: trim down includes of compiler.h Message-ID: <20150302160250.2C09C761DF@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 775049b6adb3f83b7c00cfc06088c443aef0b514 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=775049b6adb3f83b7c00cfc06088c443aef0b514 Author: Brian Paul Date: Thu Feb 26 13:03:05 2015 -0700 mesa: trim down includes of compiler.h In some cases, glheader.h is the right #include. Also remove some instances of struct _glapi_table declarations. Acked-by: Matt Turner --- src/mesa/main/api_loopback.h | 1 - src/mesa/main/atifragshader.h | 3 +-- src/mesa/main/attrib.h | 1 - src/mesa/main/blit.h | 1 - src/mesa/main/colortab.h | 2 -- src/mesa/main/convolve.h | 2 +- src/mesa/main/drawpix.h | 4 +--- src/mesa/main/histogram.h | 3 +-- src/mesa/main/pixel.h | 2 -- src/mesa/main/rastpos.h | 3 ++- src/mesa/main/remap.h | 2 -- src/mesa/main/texcompress_s3tc.h | 1 - src/mesa/main/texgen.h | 1 - src/mesa/main/vtxfmt.h | 1 - src/mesa/math/m_translate.h | 1 - src/mesa/program/sampler.cpp | 1 - 16 files changed, 6 insertions(+), 23 deletions(-) diff --git a/src/mesa/main/api_loopback.h b/src/mesa/main/api_loopback.h index 2195e01..eb3d54b 100644 --- a/src/mesa/main/api_loopback.h +++ b/src/mesa/main/api_loopback.h @@ -27,7 +27,6 @@ #ifndef API_LOOPBACK_H #define API_LOOPBACK_H -#include "main/compiler.h" #include "main/glheader.h" // ? #include "main/macros.h" // ? #include "main/mtypes.h" // ? diff --git a/src/mesa/main/atifragshader.h b/src/mesa/main/atifragshader.h index afaea00..5901134 100644 --- a/src/mesa/main/atifragshader.h +++ b/src/mesa/main/atifragshader.h @@ -8,10 +8,9 @@ #ifndef ATIFRAGSHADER_H #define ATIFRAGSHADER_H -#include "compiler.h" #include "glheader.h" -struct _glapi_table; + struct gl_context; #define MAX_NUM_INSTRUCTIONS_PER_PASS_ATI 8 diff --git a/src/mesa/main/attrib.h b/src/mesa/main/attrib.h index 44413a6..f4fd492 100644 --- a/src/mesa/main/attrib.h +++ b/src/mesa/main/attrib.h @@ -26,7 +26,6 @@ #define ATTRIB_H -#include "compiler.h" #include "glheader.h" struct _glapi_table; diff --git a/src/mesa/main/blit.h b/src/mesa/main/blit.h index 533d6e5..01a958a 100644 --- a/src/mesa/main/blit.h +++ b/src/mesa/main/blit.h @@ -26,7 +26,6 @@ #ifndef BLIT_H #define BLIT_H -#include "compiler.h" #include "glheader.h" diff --git a/src/mesa/main/colortab.h b/src/mesa/main/colortab.h index 55c3b59..e1165d7 100644 --- a/src/mesa/main/colortab.h +++ b/src/mesa/main/colortab.h @@ -26,8 +26,6 @@ #ifndef COLORTAB_H #define COLORTAB_H - -#include "compiler.h" #include "glheader.h" struct _glapi_table; diff --git a/src/mesa/main/convolve.h b/src/mesa/main/convolve.h index 0c0a9dd..e696ce4 100644 --- a/src/mesa/main/convolve.h +++ b/src/mesa/main/convolve.h @@ -28,7 +28,7 @@ #define CONVOLVE_H -#include "compiler.h" +#include "glheader.h" struct _glapi_table; diff --git a/src/mesa/main/drawpix.h b/src/mesa/main/drawpix.h index eb2cb89..181c05c 100644 --- a/src/mesa/main/drawpix.h +++ b/src/mesa/main/drawpix.h @@ -26,9 +26,7 @@ #define DRAWPIX_H -#include "compiler.h" - -struct _glapi_table; +#include "glheader.h" void GLAPIENTRY diff --git a/src/mesa/main/histogram.h b/src/mesa/main/histogram.h index 1d145a0..47a2bf0 100644 --- a/src/mesa/main/histogram.h +++ b/src/mesa/main/histogram.h @@ -36,9 +36,8 @@ #ifndef HISTOGRAM_H #define HISTOGRAM_H -#include "compiler.h" +#include "glheader.h" -struct _glapi_table; void GLAPIENTRY _mesa_GetnMinmaxARB(GLenum target, GLboolean reset, GLenum format, diff --git a/src/mesa/main/pixel.h b/src/mesa/main/pixel.h index c12ef97..fd1782e 100644 --- a/src/mesa/main/pixel.h +++ b/src/mesa/main/pixel.h @@ -33,10 +33,8 @@ #define PIXEL_H -#include "compiler.h" #include "glheader.h" -struct _glapi_table; struct gl_context; diff --git a/src/mesa/main/rastpos.h b/src/mesa/main/rastpos.h index 2d36936..dc28c68 100644 --- a/src/mesa/main/rastpos.h +++ b/src/mesa/main/rastpos.h @@ -32,7 +32,8 @@ #define RASTPOS_H -#include "compiler.h" +#include "glheader.h" + struct _glapi_table; struct gl_context; diff --git a/src/mesa/main/remap.h b/src/mesa/main/remap.h index 7199169..9d91b83 100644 --- a/src/mesa/main/remap.h +++ b/src/mesa/main/remap.h @@ -27,8 +27,6 @@ #define REMAP_H -#include "main/compiler.h" - struct gl_function_pool_remap { int pool_index; int remap_index; diff --git a/src/mesa/main/texcompress_s3tc.h b/src/mesa/main/texcompress_s3tc.h index 2734210..438b71f 100644 --- a/src/mesa/main/texcompress_s3tc.h +++ b/src/mesa/main/texcompress_s3tc.h @@ -25,7 +25,6 @@ #ifndef TEXCOMPRESS_S3TC_H #define TEXCOMPRESS_S3TC_H -#include "compiler.h" #include "glheader.h" #include "texstore.h" #include "texcompress.h" diff --git a/src/mesa/main/texgen.h b/src/mesa/main/texgen.h index aad5d2e..84adfc0 100644 --- a/src/mesa/main/texgen.h +++ b/src/mesa/main/texgen.h @@ -27,7 +27,6 @@ #define TEXGEN_H -#include "compiler.h" #include "glheader.h" struct _glapi_table; diff --git a/src/mesa/main/vtxfmt.h b/src/mesa/main/vtxfmt.h index 34ade89..efccd90 100644 --- a/src/mesa/main/vtxfmt.h +++ b/src/mesa/main/vtxfmt.h @@ -33,7 +33,6 @@ #ifndef _VTXFMT_H_ #define _VTXFMT_H_ -#include "compiler.h" #include "mtypes.h" extern void _mesa_install_exec_vtxfmt( struct gl_context *ctx, const GLvertexformat *vfmt ); diff --git a/src/mesa/math/m_translate.h b/src/mesa/math/m_translate.h index bdfa4c7..62f676c 100644 --- a/src/mesa/math/m_translate.h +++ b/src/mesa/math/m_translate.h @@ -26,7 +26,6 @@ #ifndef _M_TRANSLATE_H_ #define _M_TRANSLATE_H_ -#include "main/compiler.h" #include "main/glheader.h" /** diff --git a/src/mesa/program/sampler.cpp b/src/mesa/program/sampler.cpp index f8584c9..ea3024d 100644 --- a/src/mesa/program/sampler.cpp +++ b/src/mesa/program/sampler.cpp @@ -29,7 +29,6 @@ #include "../glsl/program.h" #include "ir_uniform.h" -#include "main/compiler.h" #include "main/mtypes.h" #include "program/hash_table.h" #include "program/prog_parameter.h" From brianp at kemper.freedesktop.org Mon Mar 2 16:02:50 2015 From: brianp at kemper.freedesktop.org (Brian Paul) Date: Mon, 2 Mar 2015 08:02:50 -0800 (PST) Subject: Mesa (master): mesa/vbo: replace Elements() with ARRAY_SIZE() Message-ID: <20150302160250.5C904761DF@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 766f5cf8f88c08a7673beb492095ad8ca878bc22 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=766f5cf8f88c08a7673beb492095ad8ca878bc22 Author: Brian Paul Date: Sat Feb 28 08:57:15 2015 -0700 mesa/vbo: replace Elements() with ARRAY_SIZE() Acked-by: Ilia Mirkin --- src/mesa/vbo/vbo_context.c | 4 ++-- src/mesa/vbo/vbo_exec_api.c | 12 ++++++------ src/mesa/vbo/vbo_exec_array.c | 4 ++-- src/mesa/vbo/vbo_exec_draw.c | 8 ++++---- src/mesa/vbo/vbo_exec_eval.c | 8 ++++---- 5 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/mesa/vbo/vbo_context.c b/src/mesa/vbo/vbo_context.c index 696a6fa..fd1ffe2 100644 --- a/src/mesa/vbo/vbo_context.c +++ b/src/mesa/vbo/vbo_context.c @@ -172,14 +172,14 @@ GLboolean _vbo_CreateContext( struct gl_context *ctx ) GLuint i; /* identity mapping */ - for (i = 0; i < Elements(vbo->map_vp_none); i++) + for (i = 0; i < ARRAY_SIZE(vbo->map_vp_none); i++) vbo->map_vp_none[i] = i; /* map material attribs to generic slots */ for (i = 0; i < NR_MAT_ATTRIBS; i++) vbo->map_vp_none[VERT_ATTRIB_GENERIC(i)] = VBO_ATTRIB_MAT_FRONT_AMBIENT + i; - for (i = 0; i < Elements(vbo->map_vp_arb); i++) + for (i = 0; i < ARRAY_SIZE(vbo->map_vp_arb); i++) vbo->map_vp_arb[i] = i; } diff --git a/src/mesa/vbo/vbo_exec_api.c b/src/mesa/vbo/vbo_exec_api.c index 2a17ff5..9669abe 100644 --- a/src/mesa/vbo/vbo_exec_api.c +++ b/src/mesa/vbo/vbo_exec_api.c @@ -1044,16 +1044,16 @@ void vbo_exec_vtx_init( struct vbo_exec_context *exec ) _mesa_noop_vtxfmt_init(&exec->vtxfmt_noop); for (i = 0 ; i < VBO_ATTRIB_MAX ; i++) { - assert(i < Elements(exec->vtx.attrsz)); + assert(i < ARRAY_SIZE(exec->vtx.attrsz)); exec->vtx.attrsz[i] = 0; - assert(i < Elements(exec->vtx.attrtype)); + assert(i < ARRAY_SIZE(exec->vtx.attrtype)); exec->vtx.attrtype[i] = GL_FLOAT; - assert(i < Elements(exec->vtx.active_sz)); + assert(i < ARRAY_SIZE(exec->vtx.active_sz)); exec->vtx.active_sz[i] = 0; } for (i = 0 ; i < VERT_ATTRIB_MAX; i++) { - assert(i < Elements(exec->vtx.inputs)); - assert(i < Elements(exec->vtx.arrays)); + assert(i < ARRAY_SIZE(exec->vtx.inputs)); + assert(i < ARRAY_SIZE(exec->vtx.arrays)); exec->vtx.inputs[i] = &exec->vtx.arrays[i]; } @@ -1110,7 +1110,7 @@ void vbo_exec_vtx_destroy( struct vbo_exec_context *exec ) /* Drop any outstanding reference to the vertex buffer */ - for (i = 0; i < Elements(exec->vtx.arrays); i++) { + for (i = 0; i < ARRAY_SIZE(exec->vtx.arrays); i++) { _mesa_reference_buffer_object(ctx, &exec->vtx.arrays[i].BufferObj, NULL); diff --git a/src/mesa/vbo/vbo_exec_array.c b/src/mesa/vbo/vbo_exec_array.c index b547e4e..8a36618 100644 --- a/src/mesa/vbo/vbo_exec_array.c +++ b/src/mesa/vbo/vbo_exec_array.c @@ -330,7 +330,7 @@ check_draw_elements_data(struct gl_context *ctx, GLsizei count, GLenum elemType, } /* check element j of each enabled array */ - for (k = 0; k < Elements(vao->_VertexAttrib); k++) { + for (k = 0; k < ARRAY_SIZE(vao->_VertexAttrib); k++) { check_array_data(ctx, &vao->_VertexAttrib[k], k, j); } } @@ -340,7 +340,7 @@ check_draw_elements_data(struct gl_context *ctx, GLsizei count, GLenum elemType, MAP_INTERNAL); } - for (k = 0; k < Elements(vao->_VertexAttrib); k++) { + for (k = 0; k < ARRAY_SIZE(vao->_VertexAttrib); k++) { unmap_array_buffer(ctx, &vao->_VertexAttrib[k]); } } diff --git a/src/mesa/vbo/vbo_exec_draw.c b/src/mesa/vbo/vbo_exec_draw.c index ec44fdb..fa5eba9 100644 --- a/src/mesa/vbo/vbo_exec_draw.c +++ b/src/mesa/vbo/vbo_exec_draw.c @@ -172,7 +172,7 @@ vbo_exec_bind_arrays( struct gl_context *ctx ) exec->vtx.inputs[attr] = &vbo->currval[VBO_ATTRIB_POS+attr]; } for (attr = 0; attr < MAT_ATTRIB_MAX; attr++) { - assert(VERT_ATTRIB_GENERIC(attr) < Elements(exec->vtx.inputs)); + assert(VERT_ATTRIB_GENERIC(attr) < ARRAY_SIZE(exec->vtx.inputs)); exec->vtx.inputs[VERT_ATTRIB_GENERIC(attr)] = &vbo->currval[VBO_ATTRIB_MAT_FRONT_AMBIENT+attr]; } @@ -183,7 +183,7 @@ vbo_exec_bind_arrays( struct gl_context *ctx ) exec->vtx.inputs[attr] = &vbo->currval[VBO_ATTRIB_POS+attr]; } for (attr = 0; attr < VERT_ATTRIB_GENERIC_MAX; attr++) { - assert(VERT_ATTRIB_GENERIC(attr) < Elements(exec->vtx.inputs)); + assert(VERT_ATTRIB_GENERIC(attr) < ARRAY_SIZE(exec->vtx.inputs)); exec->vtx.inputs[VERT_ATTRIB_GENERIC(attr)] = &vbo->currval[VBO_ATTRIB_GENERIC0+attr]; } @@ -213,8 +213,8 @@ vbo_exec_bind_arrays( struct gl_context *ctx ) (GLbyte *)exec->vtx.vertex; /* override the default array set above */ - assert(attr < Elements(exec->vtx.inputs)); - assert(attr < Elements(exec->vtx.arrays)); /* arrays[] */ + assert(attr < ARRAY_SIZE(exec->vtx.inputs)); + assert(attr < ARRAY_SIZE(exec->vtx.arrays)); /* arrays[] */ exec->vtx.inputs[attr] = &arrays[attr]; if (_mesa_is_bufferobj(exec->vtx.bufferobj)) { diff --git a/src/mesa/vbo/vbo_exec_eval.c b/src/mesa/vbo/vbo_exec_eval.c index 409f31a..b26655b 100644 --- a/src/mesa/vbo/vbo_exec_eval.c +++ b/src/mesa/vbo/vbo_exec_eval.c @@ -35,20 +35,20 @@ static void clear_active_eval1( struct vbo_exec_context *exec, GLuint attr ) { - assert(attr < Elements(exec->eval.map1)); + assert(attr < ARRAY_SIZE(exec->eval.map1)); exec->eval.map1[attr].map = NULL; } static void clear_active_eval2( struct vbo_exec_context *exec, GLuint attr ) { - assert(attr < Elements(exec->eval.map2)); + assert(attr < ARRAY_SIZE(exec->eval.map2)); exec->eval.map2[attr].map = NULL; } static void set_active_eval1( struct vbo_exec_context *exec, GLuint attr, GLuint dim, struct gl_1d_map *map ) { - assert(attr < Elements(exec->eval.map1)); + assert(attr < ARRAY_SIZE(exec->eval.map1)); if (!exec->eval.map1[attr].map) { exec->eval.map1[attr].map = map; exec->eval.map1[attr].sz = dim; @@ -58,7 +58,7 @@ static void set_active_eval1( struct vbo_exec_context *exec, GLuint attr, GLuint static void set_active_eval2( struct vbo_exec_context *exec, GLuint attr, GLuint dim, struct gl_2d_map *map ) { - assert(attr < Elements(exec->eval.map2)); + assert(attr < ARRAY_SIZE(exec->eval.map2)); if (!exec->eval.map2[attr].map) { exec->eval.map2[attr].map = map; exec->eval.map2[attr].sz = dim; From brianp at kemper.freedesktop.org Mon Mar 2 16:02:50 2015 From: brianp at kemper.freedesktop.org (Brian Paul) Date: Mon, 2 Mar 2015 08:02:50 -0800 (PST) Subject: Mesa (master): mesa/swrast: replace Elements() with ARRAY_SIZE() Message-ID: <20150302160250.68446761DF@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 16f7b7727569758a4df9c2bae3ca3a0de683960d URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=16f7b7727569758a4df9c2bae3ca3a0de683960d Author: Brian Paul Date: Sat Feb 28 08:57:20 2015 -0700 mesa/swrast: replace Elements() with ARRAY_SIZE() Acked-by: Ilia Mirkin --- src/mesa/swrast/s_points.c | 2 +- src/mesa/swrast/s_texfetch.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mesa/swrast/s_points.c b/src/mesa/swrast/s_points.c index 52a7222..8180483 100644 --- a/src/mesa/swrast/s_points.c +++ b/src/mesa/swrast/s_points.c @@ -140,7 +140,7 @@ sprite_point(struct gl_context *ctx, const SWvertex *vert) if (attr >= VARYING_SLOT_TEX0 && attr <= VARYING_SLOT_TEX7) { /* a texcoord attribute */ const GLuint u = attr - VARYING_SLOT_TEX0; - assert(u < Elements(ctx->Point.CoordReplace)); + assert(u < ARRAY_SIZE(ctx->Point.CoordReplace)); if (ctx->Point.CoordReplace[u]) { tCoords[numTcoords++] = attr; diff --git a/src/mesa/swrast/s_texfetch.c b/src/mesa/swrast/s_texfetch.c index 242f8a4..3c4ee15 100644 --- a/src/mesa/swrast/s_texfetch.c +++ b/src/mesa/swrast/s_texfetch.c @@ -573,7 +573,7 @@ set_fetch_functions(const struct gl_sampler_object *samp, } #endif - STATIC_ASSERT(Elements(texfetch_funcs) == MESA_FORMAT_COUNT); + STATIC_ASSERT(ARRAY_SIZE(texfetch_funcs) == MESA_FORMAT_COUNT); if (samp->sRGBDecode == GL_SKIP_DECODE_EXT && _mesa_get_format_color_encoding(format) == GL_SRGB) { From brianp at kemper.freedesktop.org Mon Mar 2 16:02:50 2015 From: brianp at kemper.freedesktop.org (Brian Paul) Date: Mon, 2 Mar 2015 08:02:50 -0800 (PST) Subject: Mesa (master): mesa: trim down #includes in api_loopback.h Message-ID: <20150302160250.345A2763B7@kemper.freedesktop.org> Module: Mesa Branch: master Commit: cd6db1989ad98b3e848d3ab132de98dc06274385 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=cd6db1989ad98b3e848d3ab132de98dc06274385 Author: Brian Paul Date: Thu Feb 26 13:06:57 2015 -0700 mesa: trim down #includes in api_loopback.h Acked-by: Matt Turner --- src/mesa/main/api_loopback.h | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/mesa/main/api_loopback.h b/src/mesa/main/api_loopback.h index eb3d54b..4451440 100644 --- a/src/mesa/main/api_loopback.h +++ b/src/mesa/main/api_loopback.h @@ -27,12 +27,7 @@ #ifndef API_LOOPBACK_H #define API_LOOPBACK_H -#include "main/glheader.h" // ? -#include "main/macros.h" // ? -#include "main/mtypes.h" // ? -#include "glapi/glapi.h" // ? -#include "main/dispatch.h" // ? -#include "main/context.h" // ? +#include "main/glheader.h" struct _glapi_table; struct gl_context; From brianp at kemper.freedesktop.org Mon Mar 2 16:02:50 2015 From: brianp at kemper.freedesktop.org (Brian Paul) Date: Mon, 2 Mar 2015 08:02:50 -0800 (PST) Subject: Mesa (master): mesa/main: replace Elements() with ARRAY_SIZE() Message-ID: <20150302160250.50324761DF@kemper.freedesktop.org> Module: Mesa Branch: master Commit: c2e130f8201239f836f429cab3beddb4d66a3357 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=c2e130f8201239f836f429cab3beddb4d66a3357 Author: Brian Paul Date: Sat Feb 28 08:57:11 2015 -0700 mesa/main: replace Elements() with ARRAY_SIZE() We've been using a mix of these two macros for a while now. Let's just use the later everywhere. It seems to be the convention used by other open-source projects. Acked-by: Ilia Mirkin --- src/mesa/main/arrayobj.c | 6 +++--- src/mesa/main/attrib.c | 2 +- src/mesa/main/blend.c | 2 +- src/mesa/main/blit.c | 2 +- src/mesa/main/bufferobj.c | 2 +- src/mesa/main/context.c | 2 +- src/mesa/main/debug.c | 8 ++++---- src/mesa/main/errors.c | 6 +++--- src/mesa/main/es1_conversion.c | 16 ++++++++-------- src/mesa/main/formats.c | 2 +- src/mesa/main/get.c | 14 +++++++------- src/mesa/main/matrix.c | 10 +++++----- src/mesa/main/points.c | 2 +- src/mesa/main/rastpos.c | 4 ++-- src/mesa/main/remap.c | 2 +- src/mesa/main/shared.c | 2 +- src/mesa/main/teximage.c | 4 ++-- src/mesa/main/texstate.c | 16 ++++++++-------- src/mesa/main/texstate.h | 2 +- src/mesa/main/texstorage.c | 2 +- src/mesa/main/transformfeedback.c | 2 +- src/mesa/main/uniform_query.cpp | 2 +- src/mesa/main/uniforms.c | 2 +- src/mesa/main/varray.c | 14 +++++++------- 24 files changed, 63 insertions(+), 63 deletions(-) diff --git a/src/mesa/main/arrayobj.c b/src/mesa/main/arrayobj.c index bdbd169..3c8ffb5 100644 --- a/src/mesa/main/arrayobj.c +++ b/src/mesa/main/arrayobj.c @@ -84,10 +84,10 @@ unbind_array_object_vbos(struct gl_context *ctx, struct gl_vertex_array_object * { GLuint i; - for (i = 0; i < Elements(obj->VertexBinding); i++) + for (i = 0; i < ARRAY_SIZE(obj->VertexBinding); i++) _mesa_reference_buffer_object(ctx, &obj->VertexBinding[i].BufferObj, NULL); - for (i = 0; i < Elements(obj->_VertexAttrib); i++) + for (i = 0; i < ARRAY_SIZE(obj->_VertexAttrib); i++) _mesa_reference_buffer_object(ctx, &obj->_VertexAttrib[i].BufferObj, NULL); } @@ -230,7 +230,7 @@ _mesa_initialize_vao(struct gl_context *ctx, obj->RefCount = 1; /* Init the individual arrays */ - for (i = 0; i < Elements(obj->VertexAttrib); i++) { + for (i = 0; i < ARRAY_SIZE(obj->VertexAttrib); i++) { switch (i) { case VERT_ATTRIB_WEIGHT: init_array(ctx, obj, VERT_ATTRIB_WEIGHT, 1, GL_FLOAT); diff --git a/src/mesa/main/attrib.c b/src/mesa/main/attrib.c index 07934b9..20216a8 100644 --- a/src/mesa/main/attrib.c +++ b/src/mesa/main/attrib.c @@ -1453,7 +1453,7 @@ copy_array_object(struct gl_context *ctx, /* In theory must be the same anyway, but on recreate make sure it matches */ dest->ARBsemantics = src->ARBsemantics; - for (i = 0; i < Elements(src->VertexAttrib); i++) { + for (i = 0; i < ARRAY_SIZE(src->VertexAttrib); i++) { _mesa_copy_client_array(ctx, &dest->_VertexAttrib[i], &src->_VertexAttrib[i]); _mesa_copy_vertex_attrib_array(ctx, &dest->VertexAttrib[i], &src->VertexAttrib[i]); _mesa_copy_vertex_buffer_binding(ctx, &dest->VertexBinding[i], &src->VertexBinding[i]); diff --git a/src/mesa/main/blend.c b/src/mesa/main/blend.c index b941937..774fc88 100644 --- a/src/mesa/main/blend.c +++ b/src/mesa/main/blend.c @@ -896,7 +896,7 @@ void _mesa_init_color( struct gl_context * ctx ) ctx->Color.AlphaFunc = GL_ALWAYS; ctx->Color.AlphaRef = 0; ctx->Color.BlendEnabled = 0x0; - for (i = 0; i < Elements(ctx->Color.Blend); i++) { + for (i = 0; i < ARRAY_SIZE(ctx->Color.Blend); i++) { ctx->Color.Blend[i].SrcRGB = GL_ONE; ctx->Color.Blend[i].DstRGB = GL_ZERO; ctx->Color.Blend[i].SrcA = GL_ONE; diff --git a/src/mesa/main/blit.c b/src/mesa/main/blit.c index b244c8d..2898723 100644 --- a/src/mesa/main/blit.c +++ b/src/mesa/main/blit.c @@ -48,7 +48,7 @@ find_attachment(const struct gl_framebuffer *fb, const struct gl_renderbuffer *rb) { GLuint i; - for (i = 0; i < Elements(fb->Attachment); i++) { + for (i = 0; i < ARRAY_SIZE(fb->Attachment); i++) { if (fb->Attachment[i].Renderbuffer == rb) return &fb->Attachment[i]; } diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c index f026fc3..e1c5877 100644 --- a/src/mesa/main/bufferobj.c +++ b/src/mesa/main/bufferobj.c @@ -1179,7 +1179,7 @@ _mesa_DeleteBuffers(GLsizei n, const GLuint *ids) _mesa_buffer_unmap_all_mappings(ctx, bufObj); /* unbind any vertex pointers bound to this buffer */ - for (j = 0; j < Elements(vao->VertexBinding); j++) { + for (j = 0; j < ARRAY_SIZE(vao->VertexBinding); j++) { unbind(ctx, &vao->VertexBinding[j].BufferObj, bufObj); } diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c index d6c1368..22c2341 100644 --- a/src/mesa/main/context.c +++ b/src/mesa/main/context.c @@ -447,7 +447,7 @@ _mesa_init_current(struct gl_context *ctx) GLuint i; /* Init all to (0,0,0,1) */ - for (i = 0; i < Elements(ctx->Current.Attrib); i++) { + for (i = 0; i < ARRAY_SIZE(ctx->Current.Attrib); i++) { ASSIGN_4V( ctx->Current.Attrib[i], 0.0, 0.0, 0.0, 1.0 ); } diff --git a/src/mesa/main/debug.c b/src/mesa/main/debug.c index 089ce89..4522114 100644 --- a/src/mesa/main/debug.c +++ b/src/mesa/main/debug.c @@ -58,8 +58,8 @@ tex_target_name(GLenum tgt) { GL_TEXTURE_EXTERNAL_OES, "GL_TEXTURE_EXTERNAL_OES" } }; GLuint i; - STATIC_ASSERT(Elements(tex_targets) == NUM_TEXTURE_TARGETS); - for (i = 0; i < Elements(tex_targets); i++) { + STATIC_ASSERT(ARRAY_SIZE(tex_targets) == NUM_TEXTURE_TARGETS); + for (i = 0; i < ARRAY_SIZE(tex_targets); i++) { if (tex_targets[i].target == tgt) return tex_targets[i].name; } @@ -168,7 +168,7 @@ set_verbose_flags(const char *str) return; MESA_VERBOSE = 0x0; - for (i = 0; i < Elements(opts); i++) { + for (i = 0; i < ARRAY_SIZE(opts); i++) { if (strstr(str, opts[i].name) || strcmp(str, "all") == 0) MESA_VERBOSE |= opts[i].flag; } @@ -201,7 +201,7 @@ set_debug_flags(const char *str) return; MESA_DEBUG_FLAGS = 0x0; - for (i = 0; i < Elements(opts); i++) { + for (i = 0; i < ARRAY_SIZE(opts); i++) { if (strstr(str, opts[i].name)) MESA_DEBUG_FLAGS |= opts[i].flag; } diff --git a/src/mesa/main/errors.c b/src/mesa/main/errors.c index 43e8adf..33c1730 100644 --- a/src/mesa/main/errors.c +++ b/src/mesa/main/errors.c @@ -137,7 +137,7 @@ gl_enum_to_debug_source(GLenum e) { unsigned i; - for (i = 0; i < Elements(debug_source_enums); i++) { + for (i = 0; i < ARRAY_SIZE(debug_source_enums); i++) { if (debug_source_enums[i] == e) break; } @@ -149,7 +149,7 @@ gl_enum_to_debug_type(GLenum e) { unsigned i; - for (i = 0; i < Elements(debug_type_enums); i++) { + for (i = 0; i < ARRAY_SIZE(debug_type_enums); i++) { if (debug_type_enums[i] == e) break; } @@ -161,7 +161,7 @@ gl_enum_to_debug_severity(GLenum e) { unsigned i; - for (i = 0; i < Elements(debug_severity_enums); i++) { + for (i = 0; i < ARRAY_SIZE(debug_severity_enums); i++) { if (debug_severity_enums[i] == e) break; } diff --git a/src/mesa/main/es1_conversion.c b/src/mesa/main/es1_conversion.c index 60a60e2..b254a6e 100644 --- a/src/mesa/main/es1_conversion.c +++ b/src/mesa/main/es1_conversion.c @@ -55,7 +55,7 @@ _mesa_ClipPlanef(GLenum plane, const GLfloat *equation) unsigned int i; GLdouble converted_equation[4]; - for (i = 0; i < Elements(converted_equation); i++) { + for (i = 0; i < ARRAY_SIZE(converted_equation); i++) { converted_equation[i] = (GLdouble) (equation[i]); } @@ -68,7 +68,7 @@ _mesa_ClipPlanex(GLenum plane, const GLfixed *equation) unsigned int i; GLdouble converted_equation[4]; - for (i = 0; i < Elements(converted_equation); i++) { + for (i = 0; i < ARRAY_SIZE(converted_equation); i++) { converted_equation[i] = (GLdouble) (equation[i] / 65536.0); } @@ -117,7 +117,7 @@ _mesa_DrawTexxvOES(const GLfixed *coords) unsigned int i; GLfloat converted_coords[5]; - for (i = 0; i < Elements(converted_coords); i++) { + for (i = 0; i < ARRAY_SIZE(converted_coords); i++) { converted_coords[i] = (GLfloat) (coords[i] / 65536.0f); } @@ -206,7 +206,7 @@ _mesa_GetClipPlanef(GLenum plane, GLfloat *equation) GLdouble converted_equation[4]; _mesa_GetClipPlane(plane, converted_equation); - for (i = 0; i < Elements(converted_equation); i++) { + for (i = 0; i < ARRAY_SIZE(converted_equation); i++) { equation[i] = (GLfloat) (converted_equation[i]); } } @@ -218,7 +218,7 @@ _mesa_GetClipPlanex(GLenum plane, GLfixed *equation) GLdouble converted_equation[4]; _mesa_GetClipPlane(plane, converted_equation); - for (i = 0; i < Elements(converted_equation); i++) { + for (i = 0; i < ARRAY_SIZE(converted_equation); i++) { equation[i] = (GLfixed) (converted_equation[i] * 65536); } } @@ -549,7 +549,7 @@ _mesa_LoadMatrixx(const GLfixed *m) unsigned int i; GLfloat converted_m[16]; - for (i = 0; i < Elements(converted_m); i++) { + for (i = 0; i < ARRAY_SIZE(converted_m); i++) { converted_m[i] = (GLfloat) (m[i] / 65536.0f); } @@ -617,7 +617,7 @@ _mesa_MultMatrixx(const GLfixed *m) unsigned int i; GLfloat converted_m[16]; - for (i = 0; i < Elements(converted_m); i++) { + for (i = 0; i < ARRAY_SIZE(converted_m); i++) { converted_m[i] = (GLfloat) (m[i] / 65536.0f); } @@ -825,7 +825,7 @@ _mesa_TexEnvxv(GLenum target, GLenum pname, const GLfixed *params) unsigned int i; GLfloat converted_params[4]; - for (i = 0; i < Elements(converted_params); i++) { + for (i = 0; i < ARRAY_SIZE(converted_params); i++) { converted_params[i] = (GLfloat) (params[i] / 65536.0f); } diff --git a/src/mesa/main/formats.c b/src/mesa/main/formats.c index df852f3..a6f5cde 100644 --- a/src/mesa/main/formats.c +++ b/src/mesa/main/formats.c @@ -887,7 +887,7 @@ _mesa_test_formats(void) { GLuint i; - STATIC_ASSERT(Elements(format_info) == MESA_FORMAT_COUNT); + STATIC_ASSERT(ARRAY_SIZE(format_info) == MESA_FORMAT_COUNT); for (i = 0; i < MESA_FORMAT_COUNT; i++) { const struct gl_format_info *info = _mesa_get_format_info(i); diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c index 2f4693a..a881bc5 100644 --- a/src/mesa/main/get.c +++ b/src/mesa/main/get.c @@ -497,12 +497,12 @@ print_table_stats(int api) }; const char *api_name; - api_name = api < Elements(api_names) ? api_names[api] : "N/A"; + api_name = api < ARRAY_SIZE(api_names) ? api_names[api] : "N/A"; count = 0; - mask = Elements(table(api)) - 1; + mask = ARRAY_SIZE(table(api)) - 1; memset(collisions, 0, sizeof collisions); - for (i = 0; i < Elements(table(api)); i++) { + for (i = 0; i < ARRAY_SIZE(table(api)); i++) { if (!table(api)[i]) continue; count++; @@ -523,8 +523,8 @@ print_table_stats(int api) } printf("number of enums for %s: %d (total %ld)\n", - api_name, count, Elements(values)); - for (i = 0; i < Elements(collisions) - 1; i++) + api_name, count, ARRAY_SIZE(values)); + for (i = 0; i < ARRAY_SIZE(collisions) - 1; i++) if (collisions[i] > 0) printf(" %d enums with %d %scollisions\n", collisions[i], i, i == 10 ? "or more " : ""); @@ -1195,11 +1195,11 @@ find_value(const char *func, GLenum pname, void **p, union value *v) * value since it's compatible with GLES2 its entry in table_set[] is at the * end. */ - STATIC_ASSERT(Elements(table_set) == API_OPENGL_LAST + 2); + STATIC_ASSERT(ARRAY_SIZE(table_set) == API_OPENGL_LAST + 2); if (_mesa_is_gles3(ctx)) { api = API_OPENGL_LAST + 1; } - mask = Elements(table(api)) - 1; + mask = ARRAY_SIZE(table(api)) - 1; hash = (pname * prime_factor); while (1) { int idx = table(api)[hash & mask]; diff --git a/src/mesa/main/matrix.c b/src/mesa/main/matrix.c index 4a2ce75..80c8a24 100644 --- a/src/mesa/main/matrix.c +++ b/src/mesa/main/matrix.c @@ -176,7 +176,7 @@ _mesa_MatrixMode( GLenum mode ) return; } #endif - assert(ctx->Texture.CurrentUnit < Elements(ctx->TextureMatrixStack)); + assert(ctx->Texture.CurrentUnit < ARRAY_SIZE(ctx->TextureMatrixStack)); ctx->CurrentStack = &ctx->TextureMatrixStack[ctx->Texture.CurrentUnit]; break; case GL_MATRIX0_ARB: @@ -697,10 +697,10 @@ void _mesa_init_matrix( struct gl_context * ctx ) _NEW_MODELVIEW); init_matrix_stack(&ctx->ProjectionMatrixStack, MAX_PROJECTION_STACK_DEPTH, _NEW_PROJECTION); - for (i = 0; i < Elements(ctx->TextureMatrixStack); i++) + for (i = 0; i < ARRAY_SIZE(ctx->TextureMatrixStack); i++) init_matrix_stack(&ctx->TextureMatrixStack[i], MAX_TEXTURE_STACK_DEPTH, _NEW_TEXTURE_MATRIX); - for (i = 0; i < Elements(ctx->ProgramMatrixStack); i++) + for (i = 0; i < ARRAY_SIZE(ctx->ProgramMatrixStack); i++) init_matrix_stack(&ctx->ProgramMatrixStack[i], MAX_PROGRAM_MATRIX_STACK_DEPTH, _NEW_TRACK_MATRIX); ctx->CurrentStack = &ctx->ModelviewMatrixStack; @@ -724,9 +724,9 @@ void _mesa_free_matrix_data( struct gl_context *ctx ) free_matrix_stack(&ctx->ModelviewMatrixStack); free_matrix_stack(&ctx->ProjectionMatrixStack); - for (i = 0; i < Elements(ctx->TextureMatrixStack); i++) + for (i = 0; i < ARRAY_SIZE(ctx->TextureMatrixStack); i++) free_matrix_stack(&ctx->TextureMatrixStack[i]); - for (i = 0; i < Elements(ctx->ProgramMatrixStack); i++) + for (i = 0; i < ARRAY_SIZE(ctx->ProgramMatrixStack); i++) free_matrix_stack(&ctx->ProgramMatrixStack[i]); /* combined Modelview*Projection matrix */ _math_matrix_dtr( &ctx->_ModelProjectMatrix ); diff --git a/src/mesa/main/points.c b/src/mesa/main/points.c index 0a7807d..5ad1f38 100644 --- a/src/mesa/main/points.c +++ b/src/mesa/main/points.c @@ -253,7 +253,7 @@ _mesa_init_point(struct gl_context *ctx) ctx->Point.SpriteRMode = GL_ZERO; /* GL_NV_point_sprite (only!) */ ctx->Point.SpriteOrigin = GL_UPPER_LEFT; /* GL_ARB_point_sprite */ - for (i = 0; i < Elements(ctx->Point.CoordReplace); i++) { + for (i = 0; i < ARRAY_SIZE(ctx->Point.CoordReplace); i++) { ctx->Point.CoordReplace[i] = GL_FALSE; /* GL_ARB/NV_point_sprite */ } } diff --git a/src/mesa/main/rastpos.c b/src/mesa/main/rastpos.c index 2027a9b..54b2125 100644 --- a/src/mesa/main/rastpos.c +++ b/src/mesa/main/rastpos.c @@ -266,7 +266,7 @@ window_pos3f(GLfloat x, GLfloat y, GLfloat z) { GLuint texSet; for (texSet = 0; texSet < ctx->Const.MaxTextureCoordUnits; texSet++) { - assert(texSet < Elements(ctx->Current.RasterTexCoords)); + assert(texSet < ARRAY_SIZE(ctx->Current.RasterTexCoords)); COPY_4FV( ctx->Current.RasterTexCoords[texSet], ctx->Current.Attrib[VERT_ATTRIB_TEX0 + texSet] ); } @@ -496,7 +496,7 @@ void _mesa_init_rastpos( struct gl_context * ctx ) ctx->Current.RasterDistance = 0.0; ASSIGN_4V( ctx->Current.RasterColor, 1.0, 1.0, 1.0, 1.0 ); ASSIGN_4V( ctx->Current.RasterSecondaryColor, 0.0, 0.0, 0.0, 1.0 ); - for (i = 0; i < Elements(ctx->Current.RasterTexCoords); i++) + for (i = 0; i < ARRAY_SIZE(ctx->Current.RasterTexCoords); i++) ASSIGN_4V( ctx->Current.RasterTexCoords[i], 0.0, 0.0, 0.0, 1.0 ); ctx->Current.RasterPosValid = GL_TRUE; } diff --git a/src/mesa/main/remap.c b/src/mesa/main/remap.c index 01f7594..5a95387 100644 --- a/src/mesa/main/remap.c +++ b/src/mesa/main/remap.c @@ -60,7 +60,7 @@ int driDispatchRemapTable[driDispatchRemapTable_size]; const char * _mesa_get_function_spec(GLint func_index) { - if (func_index < Elements(_mesa_function_pool)) + if (func_index < ARRAY_SIZE(_mesa_function_pool)) return _mesa_function_pool + func_index; else return NULL; diff --git a/src/mesa/main/shared.c b/src/mesa/main/shared.c index 7162bbc..0b76cc0 100644 --- a/src/mesa/main/shared.c +++ b/src/mesa/main/shared.c @@ -105,7 +105,7 @@ _mesa_alloc_shared_state(struct gl_context *ctx) GL_TEXTURE_2D, GL_TEXTURE_1D }; - STATIC_ASSERT(Elements(targets) == NUM_TEXTURE_TARGETS); + STATIC_ASSERT(ARRAY_SIZE(targets) == NUM_TEXTURE_TARGETS); shared->DefaultTex[i] = ctx->Driver.NewTextureObject(ctx, 0, targets[i]); } diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c index 6e45cc9..5ea48c5 100644 --- a/src/mesa/main/teximage.c +++ b/src/mesa/main/teximage.c @@ -729,9 +729,9 @@ _mesa_is_proxy_texture(GLenum target) * NUM_TEXTURE_TARGETS should match number of terms above, except there's no * proxy for GL_TEXTURE_BUFFER and GL_TEXTURE_EXTERNAL_OES. */ - STATIC_ASSERT(NUM_TEXTURE_TARGETS == Elements(targets) + 2); + STATIC_ASSERT(NUM_TEXTURE_TARGETS == ARRAY_SIZE(targets) + 2); - for (i = 0; i < Elements(targets); ++i) + for (i = 0; i < ARRAY_SIZE(targets); ++i) if (target == targets[i]) return GL_TRUE; return GL_FALSE; diff --git a/src/mesa/main/texstate.c b/src/mesa/main/texstate.c index 8b5853d..78ae7d2 100644 --- a/src/mesa/main/texstate.c +++ b/src/mesa/main/texstate.c @@ -292,7 +292,7 @@ _mesa_ActiveTexture(GLenum texture) k = _mesa_max_tex_unit(ctx); - assert(k <= Elements(ctx->Texture.Unit)); + assert(k <= ARRAY_SIZE(ctx->Texture.Unit)); if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE)) _mesa_debug(ctx, "glActiveTexture %s\n", @@ -363,7 +363,7 @@ update_texture_matrices( struct gl_context *ctx ) ctx->Texture._TexMatEnabled = 0x0; for (u = 0; u < ctx->Const.MaxTextureCoordUnits; u++) { - assert(u < Elements(ctx->TextureMatrixStack)); + assert(u < ARRAY_SIZE(ctx->TextureMatrixStack)); if (_math_matrix_is_dirty(ctx->TextureMatrixStack[u].Top)) { _math_matrix_analyse( ctx->TextureMatrixStack[u].Top ); @@ -501,7 +501,7 @@ update_texgen(struct gl_context *ctx) ctx->Texture._GenFlags |= texUnit->_GenFlags; } - assert(unit < Elements(ctx->TextureMatrixStack)); + assert(unit < ARRAY_SIZE(ctx->TextureMatrixStack)); if (ctx->TextureMatrixStack[unit].Top->type != MATRIX_IDENTITY) ctx->Texture._TexMatEnabled |= ENABLE_TEXMAT(unit); } @@ -797,7 +797,7 @@ alloc_proxy_textures( struct gl_context *ctx ) }; GLint tgt; - STATIC_ASSERT(Elements(targets) == NUM_TEXTURE_TARGETS); + STATIC_ASSERT(ARRAY_SIZE(targets) == NUM_TEXTURE_TARGETS); assert(targets[TEXTURE_2D_INDEX] == GL_TEXTURE_2D); assert(targets[TEXTURE_CUBE_INDEX] == GL_TEXTURE_CUBE_MAP); @@ -894,7 +894,7 @@ _mesa_init_texture(struct gl_context *ctx) */ ctx->Texture.CubeMapSeamless = ctx->API == API_OPENGLES2; - for (u = 0; u < Elements(ctx->Texture.Unit); u++) + for (u = 0; u < ARRAY_SIZE(ctx->Texture.Unit); u++) init_texture_unit(ctx, u); /* After we're done initializing the context's texture state the default @@ -927,7 +927,7 @@ _mesa_free_texture_data(struct gl_context *ctx) GLuint u, tgt; /* unreference current textures */ - for (u = 0; u < Elements(ctx->Texture.Unit); u++) { + for (u = 0; u < ARRAY_SIZE(ctx->Texture.Unit); u++) { /* The _Current texture could account for another reference */ _mesa_reference_texobj(&ctx->Texture.Unit[u]._Current, NULL); @@ -943,7 +943,7 @@ _mesa_free_texture_data(struct gl_context *ctx) /* GL_ARB_texture_buffer_object */ _mesa_reference_buffer_object(ctx, &ctx->Texture.BufferObject, NULL); - for (u = 0; u < Elements(ctx->Texture.Unit); u++) { + for (u = 0; u < ARRAY_SIZE(ctx->Texture.Unit); u++) { _mesa_reference_sampler_object(ctx, &ctx->Texture.Unit[u].Sampler, NULL); } } @@ -959,7 +959,7 @@ _mesa_update_default_objects_texture(struct gl_context *ctx) { GLuint u, tex; - for (u = 0; u < Elements(ctx->Texture.Unit); u++) { + for (u = 0; u < ARRAY_SIZE(ctx->Texture.Unit); u++) { struct gl_texture_unit *texUnit = &ctx->Texture.Unit[u]; for (tex = 0; tex < NUM_TEXTURE_TARGETS; tex++) { _mesa_reference_texobj(&texUnit->CurrentTex[tex], diff --git a/src/mesa/main/texstate.h b/src/mesa/main/texstate.h index ce7b5d7..662435b 100644 --- a/src/mesa/main/texstate.h +++ b/src/mesa/main/texstate.h @@ -41,7 +41,7 @@ static inline struct gl_texture_unit * _mesa_get_tex_unit(struct gl_context *ctx, GLuint unit) { - assert(unit < Elements(ctx->Texture.Unit)); + assert(unit < ARRAY_SIZE(ctx->Texture.Unit)); return &(ctx->Texture.Unit[unit]); } diff --git a/src/mesa/main/texstorage.c b/src/mesa/main/texstorage.c index 3ace5e8..53cb2c0 100644 --- a/src/mesa/main/texstorage.c +++ b/src/mesa/main/texstorage.c @@ -171,7 +171,7 @@ clear_texture_fields(struct gl_context *ctx, GLint level; GLuint face; - for (level = 0; level < Elements(texObj->Image[0]); level++) { + for (level = 0; level < ARRAY_SIZE(texObj->Image[0]); level++) { for (face = 0; face < numFaces; face++) { struct gl_texture_image *texImage = get_tex_image(ctx, texObj, face, level); diff --git a/src/mesa/main/transformfeedback.c b/src/mesa/main/transformfeedback.c index 1e23e8f..a3e23ce 100644 --- a/src/mesa/main/transformfeedback.c +++ b/src/mesa/main/transformfeedback.c @@ -235,7 +235,7 @@ delete_transform_feedback(struct gl_context *ctx, { GLuint i; - for (i = 0; i < Elements(obj->Buffers); i++) { + for (i = 0; i < ARRAY_SIZE(obj->Buffers); i++) { _mesa_reference_buffer_object(ctx, &obj->Buffers[i], NULL); } diff --git a/src/mesa/main/uniform_query.cpp b/src/mesa/main/uniform_query.cpp index 40327fb..9f82de9 100644 --- a/src/mesa/main/uniform_query.cpp +++ b/src/mesa/main/uniform_query.cpp @@ -762,7 +762,7 @@ _mesa_uniform(struct gl_context *ctx, struct gl_shader_program *shProg, * been modified. */ bool changed = false; - for (unsigned j = 0; j < Elements(prog->SamplerUnits); j++) { + for (unsigned j = 0; j < ARRAY_SIZE(prog->SamplerUnits); j++) { if ((sh->active_samplers & (1U << j)) != 0 && (prog->SamplerUnits[j] != sh->SamplerUnits[j])) { changed = true; diff --git a/src/mesa/main/uniforms.c b/src/mesa/main/uniforms.c index 4bb3dfb..fb1482f 100644 --- a/src/mesa/main/uniforms.c +++ b/src/mesa/main/uniforms.c @@ -81,7 +81,7 @@ _mesa_update_shader_textures_used(struct gl_shader_program *shProg, if (prog->SamplersUsed & (1 << s)) { GLuint unit = shader->SamplerUnits[s]; GLuint tgt = shader->SamplerTargets[s]; - assert(unit < Elements(prog->TexturesUsed)); + assert(unit < ARRAY_SIZE(prog->TexturesUsed)); assert(tgt < NUM_TEXTURE_TARGETS); /* The types of the samplers associated with a particular texture diff --git a/src/mesa/main/varray.c b/src/mesa/main/varray.c index 6df50de..3db9e06 100644 --- a/src/mesa/main/varray.c +++ b/src/mesa/main/varray.c @@ -714,7 +714,7 @@ _mesa_EnableVertexAttribArray(GLuint index) vao = ctx->Array.VAO; - assert(VERT_ATTRIB_GENERIC(index) < Elements(vao->VertexAttrib)); + assert(VERT_ATTRIB_GENERIC(index) < ARRAY_SIZE(vao->VertexAttrib)); if (!vao->VertexAttrib[VERT_ATTRIB_GENERIC(index)].Enabled) { /* was disabled, now being enabled */ @@ -740,7 +740,7 @@ _mesa_DisableVertexAttribArray(GLuint index) vao = ctx->Array.VAO; - assert(VERT_ATTRIB_GENERIC(index) < Elements(vao->VertexAttrib)); + assert(VERT_ATTRIB_GENERIC(index) < ARRAY_SIZE(vao->VertexAttrib)); if (vao->VertexAttrib[VERT_ATTRIB_GENERIC(index)].Enabled) { /* was enabled, now being disabled */ @@ -769,7 +769,7 @@ get_vertex_array_attrib(struct gl_context *ctx, GLuint index, GLenum pname, return 0; } - assert(VERT_ATTRIB_GENERIC(index) < Elements(vao->VertexAttrib)); + assert(VERT_ATTRIB_GENERIC(index) < ARRAY_SIZE(vao->VertexAttrib)); array = &vao->VertexAttrib[VERT_ATTRIB_GENERIC(index)]; @@ -834,7 +834,7 @@ get_current_attrib(struct gl_context *ctx, GLuint index, const char *function) return NULL; } - assert(VERT_ATTRIB_GENERIC(index) < Elements(ctx->Array.VAO->VertexAttrib)); + assert(VERT_ATTRIB_GENERIC(index) < ARRAY_SIZE(ctx->Array.VAO->VertexAttrib)); FLUSH_CURRENT(ctx, 0); return ctx->Current.Attrib[VERT_ATTRIB_GENERIC(index)]; @@ -956,7 +956,7 @@ _mesa_GetVertexAttribPointerv(GLuint index, GLenum pname, GLvoid **pointer) return; } - assert(VERT_ATTRIB_GENERIC(index) < Elements(ctx->Array.VAO->VertexAttrib)); + assert(VERT_ATTRIB_GENERIC(index) < ARRAY_SIZE(ctx->Array.VAO->VertexAttrib)); *pointer = (GLvoid *) ctx->Array.VAO->VertexAttrib[VERT_ATTRIB_GENERIC(index)].Ptr; } @@ -1348,7 +1348,7 @@ _mesa_VertexAttribDivisor(GLuint index, GLuint divisor) return; } - assert(genericIndex < Elements(ctx->Array.VAO->VertexAttrib)); + assert(genericIndex < ARRAY_SIZE(ctx->Array.VAO->VertexAttrib)); /* The ARB_vertex_attrib_binding spec says: * @@ -1803,7 +1803,7 @@ _mesa_VertexAttribBinding(GLuint attribIndex, GLuint bindingIndex) } assert(VERT_ATTRIB_GENERIC(attribIndex) < - Elements(ctx->Array.VAO->VertexAttrib)); + ARRAY_SIZE(ctx->Array.VAO->VertexAttrib)); vertex_attrib_binding(ctx, VERT_ATTRIB_GENERIC(attribIndex), VERT_ATTRIB_GENERIC(bindingIndex)); From brianp at kemper.freedesktop.org Mon Mar 2 16:02:50 2015 From: brianp at kemper.freedesktop.org (Brian Paul) Date: Mon, 2 Mar 2015 08:02:50 -0800 (PST) Subject: Mesa (master): mesa/program: replace Elements() with ARRAY_SIZE() Message-ID: <20150302160250.7B1BD761DF@kemper.freedesktop.org> Module: Mesa Branch: master Commit: c7136ff64691efec1bf58b34019e5283a751f67b URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=c7136ff64691efec1bf58b34019e5283a751f67b Author: Brian Paul Date: Sat Feb 28 08:57:27 2015 -0700 mesa/program: replace Elements() with ARRAY_SIZE() Acked-by: Ilia Mirkin --- src/mesa/program/ir_to_mesa.cpp | 2 +- src/mesa/program/prog_execute.c | 2 +- src/mesa/program/prog_print.c | 16 ++++++++-------- src/mesa/program/prog_statevars.c | 4 ++-- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp index b2776da..39790ec 100644 --- a/src/mesa/program/ir_to_mesa.cpp +++ b/src/mesa/program/ir_to_mesa.cpp @@ -1018,7 +1018,7 @@ void ir_to_mesa_visitor::visit(ir_expression *ir) { unsigned int operand; - src_reg op[Elements(ir->operands)]; + src_reg op[ARRAY_SIZE(ir->operands)]; src_reg result_src; dst_reg result_dst; diff --git a/src/mesa/program/prog_execute.c b/src/mesa/program/prog_execute.c index ac81332..dc4919a 100644 --- a/src/mesa/program/prog_execute.c +++ b/src/mesa/program/prog_execute.c @@ -124,7 +124,7 @@ get_src_register_pointer(const struct prog_src_register *source, return (GLfloat *) prog->Parameters->ParameterValues[reg]; case PROGRAM_SYSTEM_VALUE: - assert(reg < (GLint) Elements(machine->SystemValues)); + assert(reg < (GLint) ARRAY_SIZE(machine->SystemValues)); return machine->SystemValues[reg]; default: diff --git a/src/mesa/program/prog_print.c b/src/mesa/program/prog_print.c index 3f499749..d588d07 100644 --- a/src/mesa/program/prog_print.c +++ b/src/mesa/program/prog_print.c @@ -182,20 +182,20 @@ arb_input_attrib_string(GLuint index, GLenum progType) }; /* sanity checks */ - STATIC_ASSERT(Elements(vertAttribs) == VERT_ATTRIB_MAX); - STATIC_ASSERT(Elements(fragAttribs) == VARYING_SLOT_MAX); + STATIC_ASSERT(ARRAY_SIZE(vertAttribs) == VERT_ATTRIB_MAX); + STATIC_ASSERT(ARRAY_SIZE(fragAttribs) == VARYING_SLOT_MAX); assert(strcmp(vertAttribs[VERT_ATTRIB_TEX0], "vertex.texcoord[0]") == 0); assert(strcmp(vertAttribs[VERT_ATTRIB_GENERIC15], "vertex.attrib[15]") == 0); assert(strcmp(fragAttribs[VARYING_SLOT_TEX0], "fragment.texcoord[0]") == 0); assert(strcmp(fragAttribs[VARYING_SLOT_VAR0+15], "fragment.varying[15]") == 0); if (progType == GL_VERTEX_PROGRAM_ARB) { - assert(index < Elements(vertAttribs)); + assert(index < ARRAY_SIZE(vertAttribs)); return vertAttribs[index]; } else { assert(progType == GL_FRAGMENT_PROGRAM_ARB); - assert(index < Elements(fragAttribs)); + assert(index < ARRAY_SIZE(fragAttribs)); return fragAttribs[index]; } } @@ -321,19 +321,19 @@ arb_output_attrib_string(GLuint index, GLenum progType) }; /* sanity checks */ - STATIC_ASSERT(Elements(vertResults) == VARYING_SLOT_MAX); - STATIC_ASSERT(Elements(fragResults) == FRAG_RESULT_MAX); + STATIC_ASSERT(ARRAY_SIZE(vertResults) == VARYING_SLOT_MAX); + STATIC_ASSERT(ARRAY_SIZE(fragResults) == FRAG_RESULT_MAX); assert(strcmp(vertResults[VARYING_SLOT_POS], "result.position") == 0); assert(strcmp(vertResults[VARYING_SLOT_VAR0], "result.varying[0]") == 0); assert(strcmp(fragResults[FRAG_RESULT_DATA0], "result.color[0]") == 0); if (progType == GL_VERTEX_PROGRAM_ARB) { - assert(index < Elements(vertResults)); + assert(index < ARRAY_SIZE(vertResults)); return vertResults[index]; } else { assert(progType == GL_FRAGMENT_PROGRAM_ARB); - assert(index < Elements(fragResults)); + assert(index < ARRAY_SIZE(fragResults)); return fragResults[index]; } } diff --git a/src/mesa/program/prog_statevars.c b/src/mesa/program/prog_statevars.c index 7e55371..4cde744 100644 --- a/src/mesa/program/prog_statevars.c +++ b/src/mesa/program/prog_statevars.c @@ -310,11 +310,11 @@ _mesa_fetch_state(struct gl_context *ctx, const gl_state_index state[], matrix = &ctx->_ModelProjectMatrix; } else if (mat == STATE_TEXTURE_MATRIX) { - assert(index < Elements(ctx->TextureMatrixStack)); + assert(index < ARRAY_SIZE(ctx->TextureMatrixStack)); matrix = ctx->TextureMatrixStack[index].Top; } else if (mat == STATE_PROGRAM_MATRIX) { - assert(index < Elements(ctx->ProgramMatrixStack)); + assert(index < ARRAY_SIZE(ctx->ProgramMatrixStack)); matrix = ctx->ProgramMatrixStack[index].Top; } else { From brianp at kemper.freedesktop.org Mon Mar 2 16:02:50 2015 From: brianp at kemper.freedesktop.org (Brian Paul) Date: Mon, 2 Mar 2015 08:02:50 -0800 (PST) Subject: Mesa (master): st/mesa: replace Elements() with ARRAY_SIZE() Message-ID: <20150302160250.8E4F0761DF@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 2f0143ca968d739e8b9cefb213ac61402a7f6587 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=2f0143ca968d739e8b9cefb213ac61402a7f6587 Author: Brian Paul Date: Sat Feb 28 09:01:33 2015 -0700 st/mesa: replace Elements() with ARRAY_SIZE() Acked-by: Ilia Mirkin --- src/mesa/state_tracker/st_atom.c | 4 ++-- src/mesa/state_tracker/st_cb_drawpixels.c | 4 ++-- src/mesa/state_tracker/st_cb_rasterpos.c | 2 +- src/mesa/state_tracker/st_cb_xformfb.c | 8 ++++---- src/mesa/state_tracker/st_context.c | 6 +++--- src/mesa/state_tracker/st_extensions.c | 24 ++++++++++++------------ src/mesa/state_tracker/st_format.c | 2 +- src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 22 +++++++++++----------- src/mesa/state_tracker/st_mesa_to_tgsi.c | 14 +++++++------- src/mesa/state_tracker/st_program.c | 4 ++-- 10 files changed, 45 insertions(+), 45 deletions(-) diff --git a/src/mesa/state_tracker/st_atom.c b/src/mesa/state_tracker/st_atom.c index 625ea29..8cc6af2 100644 --- a/src/mesa/state_tracker/st_atom.c +++ b/src/mesa/state_tracker/st_atom.c @@ -197,7 +197,7 @@ void st_validate_state( struct st_context *st ) memset(&examined, 0, sizeof(examined)); prev = *state; - for (i = 0; i < Elements(atoms); i++) { + for (i = 0; i < ARRAY_SIZE(atoms); i++) { const struct st_tracked_state *atom = atoms[i]; struct st_state_flags generated; @@ -228,7 +228,7 @@ void st_validate_state( struct st_context *st ) } else { - for (i = 0; i < Elements(atoms); i++) { + for (i = 0; i < ARRAY_SIZE(atoms); i++) { if (check_state(state, &atoms[i]->dirty)) atoms[i]->update( st ); } diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c index 14fc139..3edf31b 100644 --- a/src/mesa/state_tracker/st_cb_drawpixels.c +++ b/src/mesa/state_tracker/st_cb_drawpixels.c @@ -201,7 +201,7 @@ st_make_drawpix_z_stencil_program(struct st_context *st, GLuint ic = 0; const GLuint shaderIndex = write_depth * 2 + write_stencil; - assert(shaderIndex < Elements(st->drawpix.shaders)); + assert(shaderIndex < ARRAY_SIZE(st->drawpix.shaders)); if (st->drawpix.shaders[shaderIndex]) { /* already have the proper shader */ @@ -1684,7 +1684,7 @@ st_destroy_drawpix(struct st_context *st) { GLuint i; - for (i = 0; i < Elements(st->drawpix.shaders); i++) { + for (i = 0; i < ARRAY_SIZE(st->drawpix.shaders); i++) { if (st->drawpix.shaders[i]) _mesa_reference_fragprog(st->ctx, &st->drawpix.shaders[i], NULL); } diff --git a/src/mesa/state_tracker/st_cb_rasterpos.c b/src/mesa/state_tracker/st_cb_rasterpos.c index b051aed..272cbb9 100644 --- a/src/mesa/state_tracker/st_cb_rasterpos.c +++ b/src/mesa/state_tracker/st_cb_rasterpos.c @@ -191,7 +191,7 @@ new_draw_rastpos_stage(struct gl_context *ctx, struct draw_context *draw) rs->stage.destroy = rastpos_destroy; rs->ctx = ctx; - for (i = 0; i < Elements(rs->array); i++) { + for (i = 0; i < ARRAY_SIZE(rs->array); i++) { rs->array[i].Size = 4; rs->array[i].Type = GL_FLOAT; rs->array[i].Format = GL_RGBA; diff --git a/src/mesa/state_tracker/st_cb_xformfb.c b/src/mesa/state_tracker/st_cb_xformfb.c index 39d0b61..07c118e 100644 --- a/src/mesa/state_tracker/st_cb_xformfb.c +++ b/src/mesa/state_tracker/st_cb_xformfb.c @@ -95,7 +95,7 @@ st_delete_transform_feedback(struct gl_context *ctx, pipe_so_target_reference(&sobj->targets[i], NULL); } - for (i = 0; i < Elements(sobj->base.Buffers); i++) { + for (i = 0; i < ARRAY_SIZE(sobj->base.Buffers); i++) { _mesa_reference_buffer_object(ctx, &sobj->base.Buffers[i], NULL); } @@ -115,8 +115,8 @@ st_begin_transform_feedback(struct gl_context *ctx, GLenum mode, unsigned i, max_num_targets; unsigned offsets[PIPE_MAX_SO_BUFFERS] = {0}; - max_num_targets = MIN2(Elements(sobj->base.Buffers), - Elements(sobj->targets)); + max_num_targets = MIN2(ARRAY_SIZE(sobj->base.Buffers), + ARRAY_SIZE(sobj->targets)); /* Convert the transform feedback state into the gallium representation. */ for (i = 0; i < max_num_targets; i++) { @@ -185,7 +185,7 @@ st_transform_feedback_get_draw_target(struct gl_transform_feedback_object *obj) st_transform_feedback_object(obj); unsigned i; - for (i = 0; i < Elements(sobj->targets); i++) { + for (i = 0; i < ARRAY_SIZE(sobj->targets); i++) { if (sobj->targets[i]) { return sobj->targets[i]; } diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c index 5834eba..5fe132a 100644 --- a/src/mesa/state_tracker/st_context.c +++ b/src/mesa/state_tracker/st_context.c @@ -117,8 +117,8 @@ st_destroy_context_priv(struct st_context *st) st_destroy_drawpix(st); st_destroy_drawtex(st); - for (shader = 0; shader < Elements(st->state.sampler_views); shader++) { - for (i = 0; i < Elements(st->state.sampler_views[0]); i++) { + for (shader = 0; shader < ARRAY_SIZE(st->state.sampler_views); shader++) { + for (i = 0; i < ARRAY_SIZE(st->state.sampler_views[0]); i++) { pipe_sampler_view_release(st->pipe, &st->state.sampler_views[shader][i]); } @@ -200,7 +200,7 @@ st_create_context_priv( struct gl_context *ctx, struct pipe_context *pipe, /* Vertex element objects used for drawing rectangles for glBitmap, * glDrawPixels, glClear, etc. */ - for (i = 0; i < Elements(st->velems_util_draw); i++) { + for (i = 0; i < ARRAY_SIZE(st->velems_util_draw); i++) { memset(&st->velems_util_draw[i], 0, sizeof(struct pipe_vertex_element)); st->velems_util_draw[i].src_offset = i * 4 * sizeof(float); st->velems_util_draw[i].instance_divisor = 0; diff --git a/src/mesa/state_tracker/st_extensions.c b/src/mesa/state_tracker/st_extensions.c index ce29d07..bc20f73 100644 --- a/src/mesa/state_tracker/st_extensions.c +++ b/src/mesa/state_tracker/st_extensions.c @@ -347,8 +347,8 @@ init_format_extensions(struct pipe_screen *screen, GLboolean *extension_table = (GLboolean *) extensions; unsigned i; int j; - int num_formats = Elements(mapping->format); - int num_ext = Elements(mapping->extension_offset); + int num_formats = ARRAY_SIZE(mapping->format); + int num_ext = ARRAY_SIZE(mapping->extension_offset); for (i = 0; i < num_mappings; i++) { int num_supported = 0; @@ -630,7 +630,7 @@ void st_init_extensions(struct pipe_screen *screen, extensions->OES_draw_texture = GL_TRUE; /* Expose the extensions which directly correspond to gallium caps. */ - for (i = 0; i < Elements(cap_mapping); i++) { + for (i = 0; i < ARRAY_SIZE(cap_mapping); i++) { if (screen->get_param(screen, cap_mapping[i].cap)) { extension_table[cap_mapping[i].extension_offset] = GL_TRUE; } @@ -638,16 +638,16 @@ void st_init_extensions(struct pipe_screen *screen, /* Expose the extensions which directly correspond to gallium formats. */ init_format_extensions(screen, extensions, rendertarget_mapping, - Elements(rendertarget_mapping), PIPE_TEXTURE_2D, + ARRAY_SIZE(rendertarget_mapping), PIPE_TEXTURE_2D, PIPE_BIND_RENDER_TARGET | PIPE_BIND_SAMPLER_VIEW); init_format_extensions(screen, extensions, depthstencil_mapping, - Elements(depthstencil_mapping), PIPE_TEXTURE_2D, + ARRAY_SIZE(depthstencil_mapping), PIPE_TEXTURE_2D, PIPE_BIND_DEPTH_STENCIL | PIPE_BIND_SAMPLER_VIEW); init_format_extensions(screen, extensions, texture_mapping, - Elements(texture_mapping), PIPE_TEXTURE_2D, + ARRAY_SIZE(texture_mapping), PIPE_TEXTURE_2D, PIPE_BIND_SAMPLER_VIEW); init_format_extensions(screen, extensions, vertex_mapping, - Elements(vertex_mapping), PIPE_BUFFER, + ARRAY_SIZE(vertex_mapping), PIPE_BUFFER, PIPE_BIND_VERTEX_BUFFER); /* Figure out GLSL support. */ @@ -758,22 +758,22 @@ void st_init_extensions(struct pipe_screen *screen, }; consts->MaxSamples = - get_max_samples_for_formats(screen, Elements(color_formats), + get_max_samples_for_formats(screen, ARRAY_SIZE(color_formats), color_formats, 16, PIPE_BIND_RENDER_TARGET); consts->MaxColorTextureSamples = - get_max_samples_for_formats(screen, Elements(color_formats), + get_max_samples_for_formats(screen, ARRAY_SIZE(color_formats), color_formats, consts->MaxSamples, PIPE_BIND_SAMPLER_VIEW); consts->MaxDepthTextureSamples = - get_max_samples_for_formats(screen, Elements(depth_formats), + get_max_samples_for_formats(screen, ARRAY_SIZE(depth_formats), depth_formats, consts->MaxSamples, PIPE_BIND_SAMPLER_VIEW); consts->MaxIntegerSamples = - get_max_samples_for_formats(screen, Elements(int_formats), + get_max_samples_for_formats(screen, ARRAY_SIZE(int_formats), int_formats, consts->MaxSamples, PIPE_BIND_SAMPLER_VIEW); } @@ -831,7 +831,7 @@ void st_init_extensions(struct pipe_screen *screen, extensions->ARB_texture_buffer_range = GL_TRUE; init_format_extensions(screen, extensions, tbo_rgb32, - Elements(tbo_rgb32), PIPE_BUFFER, + ARRAY_SIZE(tbo_rgb32), PIPE_BUFFER, PIPE_BIND_SAMPLER_VIEW); } diff --git a/src/mesa/state_tracker/st_format.c b/src/mesa/state_tracker/st_format.c index 7868bb5..72dbf3b 100644 --- a/src/mesa/state_tracker/st_format.c +++ b/src/mesa/state_tracker/st_format.c @@ -1855,7 +1855,7 @@ st_choose_format(struct st_context *st, GLenum internalFormat, return pf; /* search table for internalFormat */ - for (i = 0; i < Elements(format_map); i++) { + for (i = 0; i < ARRAY_SIZE(format_map); i++) { const struct format_mapping *mapping = &format_map[i]; for (j = 0; mapping->glFormats[j]; j++) { if (mapping->glFormats[j] == internalFormat) { diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp index b305507..bd191d8 100644 --- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp +++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp @@ -1497,7 +1497,7 @@ void glsl_to_tgsi_visitor::visit(ir_expression *ir) { unsigned int operand; - st_src_reg op[Elements(ir->operands)]; + st_src_reg op[ARRAY_SIZE(ir->operands)]; st_src_reg result_src; st_dst_reg result_dst; @@ -4022,7 +4022,7 @@ glsl_to_tgsi_visitor::eliminate_dead_code(void) /* Continuing the block, clear any channels from the write array that * are read by this instruction. */ - for (unsigned i = 0; i < Elements(inst->src); i++) { + for (unsigned i = 0; i < ARRAY_SIZE(inst->src); i++) { if (inst->src[i].file == PROGRAM_TEMPORARY && inst->src[i].reladdr){ /* Any temporary might be read, so no dead code elimination * across this instruction. @@ -4067,7 +4067,7 @@ glsl_to_tgsi_visitor::eliminate_dead_code(void) * If there is already an instruction in the write array for one or more * of the channels, flag that channel write as dead. */ - for (unsigned i = 0; i < Elements(inst->dst); i++) { + for (unsigned i = 0; i < ARRAY_SIZE(inst->dst); i++) { if (inst->dst[i].file == PROGRAM_TEMPORARY && !inst->dst[i].reladdr && !inst->saturate) { @@ -4625,7 +4625,7 @@ dst_register(struct st_translate *t, case PROGRAM_ARRAY: array = index >> 16; - assert(array < Elements(t->arrays)); + assert(array < ARRAY_SIZE(t->arrays)); if (ureg_dst_is_undef(t->arrays[array])) t->arrays[array] = ureg_DECL_array_temporary( @@ -4642,7 +4642,7 @@ dst_register(struct st_translate *t, else assert(index < VARYING_SLOT_MAX); - assert(t->outputMapping[index] < Elements(t->outputs)); + assert(t->outputMapping[index] < ARRAY_SIZE(t->outputs)); return t->outputs[t->outputMapping[index]]; @@ -4685,18 +4685,18 @@ src_register(struct st_translate *t, const st_src_reg *reg) return t->immediates[reg->index]; case PROGRAM_INPUT: - assert(t->inputMapping[reg->index] < Elements(t->inputs)); + assert(t->inputMapping[reg->index] < ARRAY_SIZE(t->inputs)); return t->inputs[t->inputMapping[reg->index]]; case PROGRAM_OUTPUT: - assert(t->outputMapping[reg->index] < Elements(t->outputs)); + assert(t->outputMapping[reg->index] < ARRAY_SIZE(t->outputs)); return ureg_src(t->outputs[t->outputMapping[reg->index]]); /* not needed? */ case PROGRAM_ADDRESS: return ureg_src(t->address[reg->index]); case PROGRAM_SYSTEM_VALUE: - assert(reg->index < (int) Elements(t->systemValues)); + assert(reg->index < (int) ARRAY_SIZE(t->systemValues)); return t->systemValues[reg->index]; default: @@ -4824,7 +4824,7 @@ translate_tex_offset(struct st_translate *t, array = in_offset->index >> 16; assert(array >= 0); - assert(array < (int) Elements(t->arrays)); + assert(array < (int) ARRAY_SIZE(t->arrays)); dst = t->arrays[array]; offset.File = dst.File; @@ -5200,8 +5200,8 @@ st_translate_program( unsigned i; enum pipe_error ret = PIPE_OK; - assert(numInputs <= Elements(t->inputs)); - assert(numOutputs <= Elements(t->outputs)); + assert(numInputs <= ARRAY_SIZE(t->inputs)); + assert(numOutputs <= ARRAY_SIZE(t->outputs)); assert(_mesa_sysval_to_semantic[SYSTEM_VALUE_FRONT_FACE] == TGSI_SEMANTIC_FACE); diff --git a/src/mesa/state_tracker/st_mesa_to_tgsi.c b/src/mesa/state_tracker/st_mesa_to_tgsi.c index 4684421..2f10161 100644 --- a/src/mesa/state_tracker/st_mesa_to_tgsi.c +++ b/src/mesa/state_tracker/st_mesa_to_tgsi.c @@ -172,7 +172,7 @@ dst_register( struct st_translate *t, else assert(index < VARYING_SLOT_MAX); - assert(t->outputMapping[index] < Elements(t->outputs)); + assert(t->outputMapping[index] < ARRAY_SIZE(t->outputs)); return t->outputs[t->outputMapping[index]]; @@ -200,7 +200,7 @@ src_register( struct st_translate *t, case PROGRAM_TEMPORARY: assert(index >= 0); - assert(index < Elements(t->temps)); + assert(index < ARRAY_SIZE(t->temps)); if (ureg_dst_is_undef(t->temps[index])) t->temps[index] = ureg_DECL_temporary( t->ureg ); return ureg_src(t->temps[index]); @@ -216,18 +216,18 @@ src_register( struct st_translate *t, return t->constants[index]; case PROGRAM_INPUT: - assert(t->inputMapping[index] < Elements(t->inputs)); + assert(t->inputMapping[index] < ARRAY_SIZE(t->inputs)); return t->inputs[t->inputMapping[index]]; case PROGRAM_OUTPUT: - assert(t->outputMapping[index] < Elements(t->outputs)); + assert(t->outputMapping[index] < ARRAY_SIZE(t->outputs)); return ureg_src(t->outputs[t->outputMapping[index]]); /* not needed? */ case PROGRAM_ADDRESS: return ureg_src(t->address[index]); case PROGRAM_SYSTEM_VALUE: - assert(index < Elements(t->systemValues)); + assert(index < ARRAY_SIZE(t->systemValues)); return t->systemValues[index]; default: @@ -1027,8 +1027,8 @@ st_translate_mesa_program( unsigned i; enum pipe_error ret = PIPE_OK; - assert(numInputs <= Elements(t->inputs)); - assert(numOutputs <= Elements(t->outputs)); + assert(numInputs <= ARRAY_SIZE(t->inputs)); + assert(numOutputs <= ARRAY_SIZE(t->outputs)); t = &translate; memset(t, 0, sizeof *t); diff --git a/src/mesa/state_tracker/st_program.c b/src/mesa/state_tracker/st_program.c index 8ce461e..4cfd817 100644 --- a/src/mesa/state_tracker/st_program.c +++ b/src/mesa/state_tracker/st_program.c @@ -1054,7 +1054,7 @@ st_translate_geometry_program(struct st_context *st, /* fall through */ case VARYING_SLOT_VAR0: default: - assert(slot < Elements(gs_output_semantic_name)); + assert(slot < ARRAY_SIZE(gs_output_semantic_name)); assert(attr >= VARYING_SLOT_VAR0); gs_output_semantic_name[slot] = TGSI_SEMANTIC_GENERIC; gs_output_semantic_index[slot] = @@ -1247,7 +1247,7 @@ destroy_shader_program_variants_cb(GLuint key, void *data, void *userData) destroy_program_variants(st, shProg->Shaders[i]->Program); } - for (i = 0; i < Elements(shProg->_LinkedShaders); i++) { + for (i = 0; i < ARRAY_SIZE(shProg->_LinkedShaders); i++) { if (shProg->_LinkedShaders[i]) destroy_program_variants(st, shProg->_LinkedShaders[i]->Program); } From brianp at kemper.freedesktop.org Mon Mar 2 16:02:50 2015 From: brianp at kemper.freedesktop.org (Brian Paul) Date: Mon, 2 Mar 2015 08:02:50 -0800 (PST) Subject: Mesa (master): st/dri: replace Elements() with ARRAY_SIZE() Message-ID: <20150302160250.9E438761DF@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 70b401029cf800f22e6c4318cfd2ab9bf118bb6c URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=70b401029cf800f22e6c4318cfd2ab9bf118bb6c Author: Brian Paul Date: Sat Feb 28 09:11:13 2015 -0700 st/dri: replace Elements() with ARRAY_SIZE() Acked-by: Ilia Mirkin --- src/gallium/state_trackers/dri/dri_screen.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/gallium/state_trackers/dri/dri_screen.c b/src/gallium/state_trackers/dri/dri_screen.c index 9cdebf8..1b14ab1 100644 --- a/src/gallium/state_trackers/dri/dri_screen.c +++ b/src/gallium/state_trackers/dri/dri_screen.c @@ -178,10 +178,10 @@ dri_fill_in_modes(struct dri_screen *screen) stencil_bits_array[depth_buffer_factor++] = 0; } - assert(Elements(mesa_formats) == Elements(pipe_formats)); + assert(ARRAY_SIZE(mesa_formats) == ARRAY_SIZE(pipe_formats)); /* Add configs. */ - for (format = 0; format < Elements(mesa_formats); format++) { + for (format = 0; format < ARRAY_SIZE(mesa_formats); format++) { __DRIconfig **new_configs = NULL; unsigned num_msaa_modes = 0; /* includes a single-sample mode */ uint8_t msaa_modes[MSAA_VISUAL_MAX_SAMPLES]; @@ -201,7 +201,7 @@ dri_fill_in_modes(struct dri_screen *screen) new_configs = driCreateConfigs(mesa_formats[format], depth_bits_array, stencil_bits_array, depth_buffer_factor, back_buffer_modes, - Elements(back_buffer_modes), + ARRAY_SIZE(back_buffer_modes), msaa_modes, 1, GL_TRUE); configs = driConcatConfigs(configs, new_configs); @@ -211,7 +211,7 @@ dri_fill_in_modes(struct dri_screen *screen) new_configs = driCreateConfigs(mesa_formats[format], depth_bits_array, stencil_bits_array, depth_buffer_factor, back_buffer_modes, - Elements(back_buffer_modes), + ARRAY_SIZE(back_buffer_modes), msaa_modes+1, num_msaa_modes-1, GL_FALSE); configs = driConcatConfigs(configs, new_configs); From brianp at kemper.freedesktop.org Mon Mar 2 16:02:50 2015 From: brianp at kemper.freedesktop.org (Brian Paul) Date: Mon, 2 Mar 2015 08:02:50 -0800 (PST) Subject: Mesa (master): glsl: replace Elements() with ARRAY_SIZE() Message-ID: <20150302160250.B14BC761DF@kemper.freedesktop.org> Module: Mesa Branch: master Commit: c16c719647664abf7531896770c31eda1dbe7a58 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=c16c719647664abf7531896770c31eda1dbe7a58 Author: Brian Paul Date: Sat Feb 28 09:11:23 2015 -0700 glsl: replace Elements() with ARRAY_SIZE() Acked-by: Ilia Mirkin --- src/glsl/builtin_functions.cpp | 2 +- src/glsl/builtin_variables.cpp | 2 +- src/glsl/glsl_parser.yy | 4 ++-- src/glsl/glsl_parser_extras.cpp | 8 ++++---- src/glsl/ir.cpp | 6 +++--- src/glsl/ir_clone.cpp | 2 +- src/glsl/ir_constant_expression.cpp | 2 +- src/glsl/loop_controls.cpp | 2 +- src/glsl/s_expression.h | 4 ++-- src/glsl/tests/copy_constant_to_storage_tests.cpp | 10 +++++----- src/glsl/tests/uniform_initializer_utils.cpp | 2 +- 11 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/glsl/builtin_functions.cpp b/src/glsl/builtin_functions.cpp index b643927..84bbdc2 100644 --- a/src/glsl/builtin_functions.cpp +++ b/src/glsl/builtin_functions.cpp @@ -2549,7 +2549,7 @@ builtin_builder::add_image_function(const char *name, }; ir_function *f = new(mem_ctx) ir_function(name); - for (unsigned i = 0; i < Elements(types); ++i) { + for (unsigned i = 0; i < ARRAY_SIZE(types); ++i) { if (types[i]->sampler_type != GLSL_TYPE_FLOAT || (flags & IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE)) f->add_signature(_image(types[i], intrinsic_name, diff --git a/src/glsl/builtin_variables.cpp b/src/glsl/builtin_variables.cpp index 65e32ad..21e7331 100644 --- a/src/glsl/builtin_variables.cpp +++ b/src/glsl/builtin_variables.cpp @@ -227,7 +227,7 @@ static const struct gl_builtin_uniform_element gl_NormalMatrix_elements[] = { #undef MATRIX -#define STATEVAR(name) {#name, name ## _elements, Elements(name ## _elements)} +#define STATEVAR(name) {#name, name ## _elements, ARRAY_SIZE(name ## _elements)} static const struct gl_builtin_uniform_desc _mesa_builtin_uniform_desc[] = { STATEVAR(gl_NumSamples), diff --git a/src/glsl/glsl_parser.yy b/src/glsl/glsl_parser.yy index ea3bd8a..90c216e 100644 --- a/src/glsl/glsl_parser.yy +++ b/src/glsl/glsl_parser.yy @@ -1280,7 +1280,7 @@ layout_qualifier_id: { "triangles_adjacency", GL_TRIANGLES_ADJACENCY }, { "triangle_strip", GL_TRIANGLE_STRIP }, }; - for (unsigned i = 0; i < Elements(map); i++) { + for (unsigned i = 0; i < ARRAY_SIZE(map); i++) { if (match_layout_qualifier($1, map[i].s, state) == 0) { $$.flags.q.prim_type = 1; $$.prim_type = map[i].e; @@ -1344,7 +1344,7 @@ layout_qualifier_id: { "r8_snorm", GL_R8_SNORM, GLSL_TYPE_FLOAT } }; - for (unsigned i = 0; i < Elements(map); i++) { + for (unsigned i = 0; i < ARRAY_SIZE(map); i++) { if (match_layout_qualifier($1, map[i].name, state) == 0) { $$.flags.q.explicit_image_format = 1; $$.image_format = map[i].format; diff --git a/src/glsl/glsl_parser_extras.cpp b/src/glsl/glsl_parser_extras.cpp index f19804b..79624bc 100644 --- a/src/glsl/glsl_parser_extras.cpp +++ b/src/glsl/glsl_parser_extras.cpp @@ -119,9 +119,9 @@ _mesa_glsl_parse_state::_mesa_glsl_parse_state(struct gl_context *_ctx, this->Const.MaxAtomicBufferBindings = ctx->Const.MaxAtomicBufferBindings; /* Compute shader constants */ - for (unsigned i = 0; i < Elements(this->Const.MaxComputeWorkGroupCount); i++) + for (unsigned i = 0; i < ARRAY_SIZE(this->Const.MaxComputeWorkGroupCount); i++) this->Const.MaxComputeWorkGroupCount[i] = ctx->Const.MaxComputeWorkGroupCount[i]; - for (unsigned i = 0; i < Elements(this->Const.MaxComputeWorkGroupSize); i++) + for (unsigned i = 0; i < ARRAY_SIZE(this->Const.MaxComputeWorkGroupSize); i++) this->Const.MaxComputeWorkGroupSize[i] = ctx->Const.MaxComputeWorkGroupSize[i]; this->Const.MaxImageUnits = ctx->Const.MaxImageUnits; @@ -636,7 +636,7 @@ void _mesa_glsl_extension::set_flags(_mesa_glsl_parse_state *state, */ static const _mesa_glsl_extension *find_extension(const char *name) { - for (unsigned i = 0; i < Elements(_mesa_glsl_supported_extensions); ++i) { + for (unsigned i = 0; i < ARRAY_SIZE(_mesa_glsl_supported_extensions); ++i) { if (strcmp(name, _mesa_glsl_supported_extensions[i].name) == 0) { return &_mesa_glsl_supported_extensions[i]; } @@ -674,7 +674,7 @@ _mesa_glsl_process_extension(const char *name, YYLTYPE *name_locp, return false; } else { for (unsigned i = 0; - i < Elements(_mesa_glsl_supported_extensions); ++i) { + i < ARRAY_SIZE(_mesa_glsl_supported_extensions); ++i) { const _mesa_glsl_extension *extension = &_mesa_glsl_supported_extensions[i]; if (extension->compatible_with_state(state)) { diff --git a/src/glsl/ir.cpp b/src/glsl/ir.cpp index f4f92e9..54656f8 100644 --- a/src/glsl/ir.cpp +++ b/src/glsl/ir.cpp @@ -618,8 +618,8 @@ static const char *const operator_strs[] = { const char *ir_expression::operator_string(ir_expression_operation op) { - assert((unsigned int) op < Elements(operator_strs)); - assert(Elements(operator_strs) == (ir_quadop_vector + 1)); + assert((unsigned int) op < ARRAY_SIZE(operator_strs)); + assert(ARRAY_SIZE(operator_strs) == (ir_quadop_vector + 1)); return operator_strs[op]; } @@ -1707,7 +1707,7 @@ const char *const ir_variable::warn_extension_table[] = { void ir_variable::enable_extension_warning(const char *extension) { - for (unsigned i = 0; i < Elements(warn_extension_table); i++) { + for (unsigned i = 0; i < ARRAY_SIZE(warn_extension_table); i++) { if (strcmp(warn_extension_table[i], extension) == 0) { this->data.warn_extension_index = i; return; diff --git a/src/glsl/ir_clone.cpp b/src/glsl/ir_clone.cpp index 5c7279c..914e0e4 100644 --- a/src/glsl/ir_clone.cpp +++ b/src/glsl/ir_clone.cpp @@ -158,7 +158,7 @@ ir_call::clone(void *mem_ctx, struct hash_table *ht) const ir_expression * ir_expression::clone(void *mem_ctx, struct hash_table *ht) const { - ir_rvalue *op[Elements(this->operands)] = { NULL, }; + ir_rvalue *op[ARRAY_SIZE(this->operands)] = { NULL, }; unsigned int i; for (i = 0; i < get_num_operands(); i++) { diff --git a/src/glsl/ir_constant_expression.cpp b/src/glsl/ir_constant_expression.cpp index 07dd439..388c4c2 100644 --- a/src/glsl/ir_constant_expression.cpp +++ b/src/glsl/ir_constant_expression.cpp @@ -506,7 +506,7 @@ ir_expression::constant_expression_value(struct hash_table *variable_context) if (this->type->is_error()) return NULL; - ir_constant *op[Elements(this->operands)] = { NULL, }; + ir_constant *op[ARRAY_SIZE(this->operands)] = { NULL, }; ir_constant_data data; memset(&data, 0, sizeof(data)); diff --git a/src/glsl/loop_controls.cpp b/src/glsl/loop_controls.cpp index 2459fc1..d7f0b28 100644 --- a/src/glsl/loop_controls.cpp +++ b/src/glsl/loop_controls.cpp @@ -123,7 +123,7 @@ calculate_iterations(ir_rvalue *from, ir_rvalue *to, ir_rvalue *increment, const int bias[] = { -1, 0, 1 }; bool valid_loop = false; - for (unsigned i = 0; i < Elements(bias); i++) { + for (unsigned i = 0; i < ARRAY_SIZE(bias); i++) { /* Increment may be of type int, uint or float. */ switch (increment->type->base_type) { case GLSL_TYPE_INT: diff --git a/src/glsl/s_expression.h b/src/glsl/s_expression.h index 1d47535..f0dffb1 100644 --- a/src/glsl/s_expression.h +++ b/src/glsl/s_expression.h @@ -39,8 +39,8 @@ #define SX_AS_INT(x) SX_AS_(int, x) /* Pattern matching macros */ -#define MATCH(list, pat) s_match(list, Elements(pat), pat, false) -#define PARTIAL_MATCH(list, pat) s_match(list, Elements(pat), pat, true) +#define MATCH(list, pat) s_match(list, ARRAY_SIZE(pat), pat, false) +#define PARTIAL_MATCH(list, pat) s_match(list, ARRAY_SIZE(pat), pat, true) /* For our purposes, S-Expressions are: * - diff --git a/src/glsl/tests/copy_constant_to_storage_tests.cpp b/src/glsl/tests/copy_constant_to_storage_tests.cpp index acf2789..cd48bc5 100644 --- a/src/glsl/tests/copy_constant_to_storage_tests.cpp +++ b/src/glsl/tests/copy_constant_to_storage_tests.cpp @@ -70,7 +70,7 @@ copy_constant_to_storage::int_test(unsigned rows) ir_constant *val; generate_data(mem_ctx, GLSL_TYPE_INT, 1, rows, val); - const unsigned red_zone_size = Elements(storage) - val->type->components(); + const unsigned red_zone_size = ARRAY_SIZE(storage) - val->type->components(); fill_storage_array_with_sentinels(storage, val->type->components(), red_zone_size); @@ -90,7 +90,7 @@ copy_constant_to_storage::uint_test(unsigned rows) ir_constant *val; generate_data(mem_ctx, GLSL_TYPE_UINT, 1, rows, val); - const unsigned red_zone_size = Elements(storage) - val->type->components(); + const unsigned red_zone_size = ARRAY_SIZE(storage) - val->type->components(); fill_storage_array_with_sentinels(storage, val->type->components(), red_zone_size); @@ -110,7 +110,7 @@ copy_constant_to_storage::float_test(unsigned columns, unsigned rows) ir_constant *val; generate_data(mem_ctx, GLSL_TYPE_FLOAT, columns, rows, val); - const unsigned red_zone_size = Elements(storage) - val->type->components(); + const unsigned red_zone_size = ARRAY_SIZE(storage) - val->type->components(); fill_storage_array_with_sentinels(storage, val->type->components(), red_zone_size); @@ -130,7 +130,7 @@ copy_constant_to_storage::bool_test(unsigned rows) ir_constant *val; generate_data(mem_ctx, GLSL_TYPE_BOOL, 1, rows, val); - const unsigned red_zone_size = Elements(storage) - val->type->components(); + const unsigned red_zone_size = ARRAY_SIZE(storage) - val->type->components(); fill_storage_array_with_sentinels(storage, val->type->components(), red_zone_size); @@ -155,7 +155,7 @@ copy_constant_to_storage::sampler_test(void) ir_constant *val; generate_data(mem_ctx, GLSL_TYPE_INT, 1, 1, val); - const unsigned red_zone_size = Elements(storage) - val->type->components(); + const unsigned red_zone_size = ARRAY_SIZE(storage) - val->type->components(); fill_storage_array_with_sentinels(storage, val->type->components(), red_zone_size); diff --git a/src/glsl/tests/uniform_initializer_utils.cpp b/src/glsl/tests/uniform_initializer_utils.cpp index 297f342..b90bdca 100644 --- a/src/glsl/tests/uniform_initializer_utils.cpp +++ b/src/glsl/tests/uniform_initializer_utils.cpp @@ -79,7 +79,7 @@ generate_data_element(void *mem_ctx, const glsl_type *type, ir_constant_data data; memset(&data, 0, sizeof(data)); for (unsigned i = 0; i < type->components(); i++) { - const unsigned idx = (i + data_index_base) % Elements(values); + const unsigned idx = (i + data_index_base) % ARRAY_SIZE(values); switch (type->base_type) { case GLSL_TYPE_UINT: case GLSL_TYPE_INT: From brianp at kemper.freedesktop.org Mon Mar 2 16:02:50 2015 From: brianp at kemper.freedesktop.org (Brian Paul) Date: Mon, 2 Mar 2015 08:02:50 -0800 (PST) Subject: Mesa (master): mapi: replace Elements() with ARRAY_SIZE() Message-ID: <20150302160250.BC2CC761DF@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 0a77ffcd5a22cffdbf3b70d5aa105b9b1019e704 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=0a77ffcd5a22cffdbf3b70d5aa105b9b1019e704 Author: Brian Paul Date: Sat Feb 28 09:11:29 2015 -0700 mapi: replace Elements() with ARRAY_SIZE() Acked-by: Ilia Mirkin --- src/mapi/glapi/gen/gl_enums.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mapi/glapi/gen/gl_enums.py b/src/mapi/glapi/gen/gl_enums.py index 35919d6..d61618f 100644 --- a/src/mapi/glapi/gen/gl_enums.py +++ b/src/mapi/glapi/gen/gl_enums.py @@ -83,7 +83,7 @@ const char *_mesa_lookup_enum_by_nr( int nr ) STATIC_ASSERT(sizeof(enum_string_table) < (1 << 16)); elt = bsearch(& nr, enum_string_table_offsets, - Elements(enum_string_table_offsets), + ARRAY_SIZE(enum_string_table_offsets), sizeof(enum_string_table_offsets[0]), (cfunc) compar_nr); @@ -127,7 +127,7 @@ static const char *prim_names[PRIM_MAX+3] = { const char * _mesa_lookup_prim_by_nr(GLuint nr) { - if (nr < Elements(prim_names)) + if (nr < ARRAY_SIZE(prim_names)) return prim_names[nr]; else return "invalid mode"; From brianp at kemper.freedesktop.org Mon Mar 2 16:02:50 2015 From: brianp at kemper.freedesktop.org (Brian Paul) Date: Mon, 2 Mar 2015 08:02:50 -0800 (PST) Subject: Mesa (master): i915: replace Elements() with ARRAY_SIZE() Message-ID: <20150302160250.C7596761DF@kemper.freedesktop.org> Module: Mesa Branch: master Commit: b565771003fc416e6ccccda8b10efa2423ae7e5a URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=b565771003fc416e6ccccda8b10efa2423ae7e5a Author: Brian Paul Date: Sat Feb 28 09:05:24 2015 -0700 i915: replace Elements() with ARRAY_SIZE() Acked-by: Ilia Mirkin --- src/mesa/drivers/dri/i915/intel_fbo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesa/drivers/dri/i915/intel_fbo.c b/src/mesa/drivers/dri/i915/intel_fbo.c index 2a34385..1e1397d 100644 --- a/src/mesa/drivers/dri/i915/intel_fbo.c +++ b/src/mesa/drivers/dri/i915/intel_fbo.c @@ -599,7 +599,7 @@ intel_validate_framebuffer(struct gl_context *ctx, struct gl_framebuffer *fb) } } - for (i = 0; i < Elements(fb->Attachment); i++) { + for (i = 0; i < ARRAY_SIZE(fb->Attachment); i++) { struct gl_renderbuffer *rb; struct intel_renderbuffer *irb; From brianp at kemper.freedesktop.org Mon Mar 2 16:02:50 2015 From: brianp at kemper.freedesktop.org (Brian Paul) Date: Mon, 2 Mar 2015 08:02:50 -0800 (PST) Subject: Mesa (master): i965: replace Elements() with ARRAY_SIZE() Message-ID: <20150302160250.DE63B761DF@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 49a7f8c919d23fec977116f218780a35896cc1dd URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=49a7f8c919d23fec977116f218780a35896cc1dd Author: Brian Paul Date: Sat Feb 28 09:05:29 2015 -0700 i965: replace Elements() with ARRAY_SIZE() Acked-by: Ilia Mirkin --- src/mesa/drivers/dri/i965/brw_eu_emit.c | 8 ++++---- src/mesa/drivers/dri/i965/brw_fs.cpp | 2 +- src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp | 2 +- src/mesa/drivers/dri/i965/gen6_sol.c | 2 +- src/mesa/drivers/dri/i965/intel_fbo.c | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_eu_emit.c b/src/mesa/drivers/dri/i965/brw_eu_emit.c index 1d6fd67..6f29468 100644 --- a/src/mesa/drivers/dri/i965/brw_eu_emit.c +++ b/src/mesa/drivers/dri/i965/brw_eu_emit.c @@ -249,21 +249,21 @@ validate_reg(const struct brw_context *brw, brw_inst *inst, struct brw_reg reg) reg.file == BRW_ARF_NULL) return; - assert(reg.hstride >= 0 && reg.hstride < Elements(hstride_for_reg)); + assert(reg.hstride >= 0 && reg.hstride < ARRAY_SIZE(hstride_for_reg)); hstride = hstride_for_reg[reg.hstride]; if (reg.vstride == 0xf) { vstride = -1; } else { - assert(reg.vstride >= 0 && reg.vstride < Elements(vstride_for_reg)); + assert(reg.vstride >= 0 && reg.vstride < ARRAY_SIZE(vstride_for_reg)); vstride = vstride_for_reg[reg.vstride]; } - assert(reg.width >= 0 && reg.width < Elements(width_for_reg)); + assert(reg.width >= 0 && reg.width < ARRAY_SIZE(width_for_reg)); width = width_for_reg[reg.width]; assert(brw_inst_exec_size(brw, inst) >= 0 && - brw_inst_exec_size(brw, inst) < Elements(execsize_for_reg)); + brw_inst_exec_size(brw, inst) < ARRAY_SIZE(execsize_for_reg)); execsize = execsize_for_reg[brw_inst_exec_size(brw, inst)]; /* Restrictions from 3.3.10: Register Region Restrictions. */ diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp index 0354f56..1a09ea3 100644 --- a/src/mesa/drivers/dri/i965/brw_fs.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs.cpp @@ -2852,7 +2852,7 @@ fs_visitor::remove_duplicate_mrf_writes() /* Clear out any MRF move records whose sources got overwritten. */ if (inst->dst.file == GRF) { - for (unsigned int i = 0; i < Elements(last_mrf_move); i++) { + for (unsigned int i = 0; i < ARRAY_SIZE(last_mrf_move); i++) { if (last_mrf_move[i] && last_mrf_move[i]->src[0].reg == inst->dst.reg) { last_mrf_move[i] = NULL; diff --git a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp index c174fdb..5bf9e1b 100644 --- a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp +++ b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp @@ -1305,7 +1305,7 @@ void vec4_visitor::visit(ir_expression *ir) { unsigned int operand; - src_reg op[Elements(ir->operands)]; + src_reg op[ARRAY_SIZE(ir->operands)]; vec4_instruction *inst; if (ir->operation == ir_binop_add) { diff --git a/src/mesa/drivers/dri/i965/gen6_sol.c b/src/mesa/drivers/dri/i965/gen6_sol.c index 511b699..0a66b1b 100644 --- a/src/mesa/drivers/dri/i965/gen6_sol.c +++ b/src/mesa/drivers/dri/i965/gen6_sol.c @@ -219,7 +219,7 @@ brw_delete_transform_feedback(struct gl_context *ctx, struct brw_transform_feedback_object *brw_obj = (struct brw_transform_feedback_object *) obj; - for (unsigned i = 0; i < Elements(obj->Buffers); i++) { + for (unsigned i = 0; i < ARRAY_SIZE(obj->Buffers); i++) { _mesa_reference_buffer_object(ctx, &obj->Buffers[i], NULL); } diff --git a/src/mesa/drivers/dri/i965/intel_fbo.c b/src/mesa/drivers/dri/i965/intel_fbo.c index 63ed7ad..04e5030 100644 --- a/src/mesa/drivers/dri/i965/intel_fbo.c +++ b/src/mesa/drivers/dri/i965/intel_fbo.c @@ -729,7 +729,7 @@ intel_validate_framebuffer(struct gl_context *ctx, struct gl_framebuffer *fb) } } - for (i = 0; i < Elements(fb->Attachment); i++) { + for (i = 0; i < ARRAY_SIZE(fb->Attachment); i++) { struct gl_renderbuffer *rb; struct intel_renderbuffer *irb; From brianp at kemper.freedesktop.org Mon Mar 2 16:02:50 2015 From: brianp at kemper.freedesktop.org (Brian Paul) Date: Mon, 2 Mar 2015 08:02:50 -0800 (PST) Subject: Mesa (master): nouveau: replace Elements() with ARRAY_SIZE() Message-ID: <20150302160250.E877D761DF@kemper.freedesktop.org> Module: Mesa Branch: master Commit: ea760c20902b92f83e324e2dd601d5f8e254ae74 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=ea760c20902b92f83e324e2dd601d5f8e254ae74 Author: Brian Paul Date: Sat Feb 28 09:05:40 2015 -0700 nouveau: replace Elements() with ARRAY_SIZE() Acked-by: Ilia Mirkin --- src/mesa/drivers/dri/nouveau/nouveau_screen.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/mesa/drivers/dri/nouveau/nouveau_screen.c b/src/mesa/drivers/dri/nouveau/nouveau_screen.c index 150dd8e..b9ae959 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_screen.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_screen.c @@ -64,16 +64,16 @@ nouveau_get_configs(void) GLX_NONE, GLX_SWAP_UNDEFINED_OML }; - for (i = 0; i < Elements(formats); i++) { + for (i = 0; i < ARRAY_SIZE(formats); i++) { __DRIconfig **config; config = driCreateConfigs(formats[i], depth_bits, stencil_bits, - Elements(depth_bits), + ARRAY_SIZE(depth_bits), back_buffer_modes, - Elements(back_buffer_modes), + ARRAY_SIZE(back_buffer_modes), msaa_samples, - Elements(msaa_samples), + ARRAY_SIZE(msaa_samples), GL_TRUE); assert(config); From brianp at kemper.freedesktop.org Mon Mar 2 16:02:50 2015 From: brianp at kemper.freedesktop.org (Brian Paul) Date: Mon, 2 Mar 2015 08:02:50 -0800 (PST) Subject: Mesa (master): r200: replace Elements() with ARRAY_SIZE() Message-ID: <20150302160250.F34A1761DF@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 9775dbc33505e486f9e6e11587a38bd09285a10c URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=9775dbc33505e486f9e6e11587a38bd09285a10c Author: Brian Paul Date: Sat Feb 28 09:05:48 2015 -0700 r200: replace Elements() with ARRAY_SIZE() Acked-by: Ilia Mirkin --- src/mesa/drivers/dri/r200/r200_sanity.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/mesa/drivers/dri/r200/r200_sanity.c b/src/mesa/drivers/dri/r200/r200_sanity.c index 8f7c0fe..ab922e5 100644 --- a/src/mesa/drivers/dri/r200/r200_sanity.c +++ b/src/mesa/drivers/dri/r200/r200_sanity.c @@ -609,7 +609,7 @@ struct reg { }; -static struct reg regs[Elements(reg_names)+1]; +static struct reg regs[ARRAY_SIZE(reg_names)+1]; static struct reg scalars[512+1]; static struct reg vectors[512*4+1]; @@ -620,29 +620,29 @@ static void init_regs( void ) struct reg_names *tmp; int i; - for (i = 0 ; i < Elements(reg_names) ; i++) { + for (i = 0 ; i < ARRAY_SIZE(reg_names) ; i++) { regs[i].idx = reg_names[i].idx; regs[i].closest = ®_names[i]; regs[i].flags = 0; } - for (i = 0, tmp = scalar_names ; i < Elements(scalars) ; i++) { + for (i = 0, tmp = scalar_names ; i < ARRAY_SIZE(scalars) ; i++) { if (tmp[1].idx == i) tmp++; scalars[i].idx = i; scalars[i].closest = tmp; scalars[i].flags = ISFLOAT; } - for (i = 0, tmp = vector_names ; i < Elements(vectors) ; i++) { + for (i = 0, tmp = vector_names ; i < ARRAY_SIZE(vectors) ; i++) { if (tmp[1].idx*4 == i) tmp++; vectors[i].idx = i; vectors[i].closest = tmp; vectors[i].flags = ISFLOAT|ISVEC; } - regs[Elements(regs)-1].idx = -1; - scalars[Elements(scalars)-1].idx = -1; - vectors[Elements(vectors)-1].idx = -1; + regs[ARRAY_SIZE(regs)-1].idx = -1; + scalars[ARRAY_SIZE(scalars)-1].idx = -1; + vectors[ARRAY_SIZE(vectors)-1].idx = -1; } static int find_or_add_value( struct reg *reg, int val ) @@ -786,13 +786,13 @@ static void dump_state( void ) { int i; - for (i = 0 ; i < Elements(regs) ; i++) + for (i = 0 ; i < ARRAY_SIZE(regs) ; i++) print_reg( ®s[i] ); - for (i = 0 ; i < Elements(scalars) ; i++) + for (i = 0 ; i < ARRAY_SIZE(scalars) ; i++) print_reg( &scalars[i] ); - for (i = 0 ; i < Elements(vectors) ; i++) + for (i = 0 ; i < ARRAY_SIZE(vectors) ; i++) print_reg( &vectors[i] ); } From brianp at kemper.freedesktop.org Mon Mar 2 16:02:51 2015 From: brianp at kemper.freedesktop.org (Brian Paul) Date: Mon, 2 Mar 2015 08:02:51 -0800 (PST) Subject: Mesa (master): radeon: replace Elements() with ARRAY_SIZE() Message-ID: <20150302160251.0CD55761DF@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 6633271159f99bc86d29a86d7e3802f0b60c7a11 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=6633271159f99bc86d29a86d7e3802f0b60c7a11 Author: Brian Paul Date: Sat Feb 28 09:05:54 2015 -0700 radeon: replace Elements() with ARRAY_SIZE() Acked-by: Ilia Mirkin --- src/mesa/drivers/dri/radeon/radeon_sanity.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/mesa/drivers/dri/radeon/radeon_sanity.c b/src/mesa/drivers/dri/radeon/radeon_sanity.c index bb2a3bf..ca10fc3 100644 --- a/src/mesa/drivers/dri/radeon/radeon_sanity.c +++ b/src/mesa/drivers/dri/radeon/radeon_sanity.c @@ -331,7 +331,7 @@ struct reg { }; -static struct reg regs[Elements(reg_names)+1]; +static struct reg regs[ARRAY_SIZE(reg_names)+1]; static struct reg scalars[512+1]; static struct reg vectors[512*4+1]; @@ -342,29 +342,29 @@ static void init_regs( void ) struct reg_names *tmp; int i; - for (i = 0 ; i < Elements(regs)-1 ; i++) { + for (i = 0 ; i < ARRAY_SIZE(regs)-1 ; i++) { regs[i].idx = reg_names[i].idx; regs[i].closest = ®_names[i]; regs[i].flags = 0; } - for (i = 0, tmp = scalar_names ; i < Elements(scalars) ; i++) { + for (i = 0, tmp = scalar_names ; i < ARRAY_SIZE(scalars) ; i++) { if (tmp[1].idx == i) tmp++; scalars[i].idx = i; scalars[i].closest = tmp; scalars[i].flags = ISFLOAT; } - for (i = 0, tmp = vector_names ; i < Elements(vectors) ; i++) { + for (i = 0, tmp = vector_names ; i < ARRAY_SIZE(vectors) ; i++) { if (tmp[1].idx*4 == i) tmp++; vectors[i].idx = i; vectors[i].closest = tmp; vectors[i].flags = ISFLOAT|ISVEC; } - regs[Elements(regs)-1].idx = -1; - scalars[Elements(scalars)-1].idx = -1; - vectors[Elements(vectors)-1].idx = -1; + regs[ARRAY_SIZE(regs)-1].idx = -1; + scalars[ARRAY_SIZE(scalars)-1].idx = -1; + vectors[ARRAY_SIZE(vectors)-1].idx = -1; } static int find_or_add_value( struct reg *reg, int val ) @@ -508,13 +508,13 @@ static void dump_state( void ) { int i; - for (i = 0 ; i < Elements(regs) ; i++) + for (i = 0 ; i < ARRAY_SIZE(regs) ; i++) print_reg( ®s[i] ); - for (i = 0 ; i < Elements(scalars) ; i++) + for (i = 0 ; i < ARRAY_SIZE(scalars) ; i++) print_reg( &scalars[i] ); - for (i = 0 ; i < Elements(vectors) ; i++) + for (i = 0 ; i < ARRAY_SIZE(vectors) ; i++) print_reg( &vectors[i] ); } From brianp at kemper.freedesktop.org Mon Mar 2 16:02:51 2015 From: brianp at kemper.freedesktop.org (Brian Paul) Date: Mon, 2 Mar 2015 08:02:51 -0800 (PST) Subject: Mesa (master): mesa: remove the Elements() macro definition Message-ID: <20150302160251.20D71761DF@kemper.freedesktop.org> Module: Mesa Branch: master Commit: e1437d6c0a88906191b7531f4e941fc6b06e2e4a URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=e1437d6c0a88906191b7531f4e941fc6b06e2e4a Author: Brian Paul Date: Sat Feb 28 09:11:43 2015 -0700 mesa: remove the Elements() macro definition No longer used. Acked-by: Ilia Mirkin --- src/mesa/main/compiler.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/mesa/main/compiler.h b/src/mesa/main/compiler.h index a0ef75a..7f2d732 100644 --- a/src/mesa/main/compiler.h +++ b/src/mesa/main/compiler.h @@ -175,9 +175,6 @@ static inline GLuint CPU_TO_LE32(GLuint x) #define IEEE_ONE 0x3f800000 -#ifndef Elements -#define Elements(x) (sizeof(x)/sizeof(*(x))) -#endif #ifdef __cplusplus } From brianp at kemper.freedesktop.org Mon Mar 2 16:02:51 2015 From: brianp at kemper.freedesktop.org (Brian Paul) Date: Mon, 2 Mar 2015 08:02:51 -0800 (PST) Subject: Mesa (master): mesa: remove extra definition of ARRAY_SIZE in src/mesa/ main/macros.h Message-ID: <20150302160251.2CC6A761DF@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 6f0e9c2e393ba17829e1338dc035c25f22a2718c URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=6f0e9c2e393ba17829e1338dc035c25f22a2718c Author: Brian Paul Date: Sat Feb 28 13:33:11 2015 -0700 mesa: remove extra definition of ARRAY_SIZE in src/mesa/main/macros.h Already defined in src/util/macros.h Reviewed-by: Matt Turner --- src/mesa/main/macros.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/mesa/main/macros.h b/src/mesa/main/macros.h index da5e8e8..2d7a6a1 100644 --- a/src/mesa/main/macros.h +++ b/src/mesa/main/macros.h @@ -803,10 +803,6 @@ DIFFERENT_SIGNS(GLfloat x, GLfloat y) #define ENUM_TO_DOUBLE(E) ((GLdouble)(GLint)(E)) #define ENUM_TO_BOOLEAN(E) ((E) ? GL_TRUE : GL_FALSE) -/* Compute the size of an array */ -#ifndef ARRAY_SIZE -# define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0])) -#endif /* Stringify */ #define STRINGIFY(x) #x From brianp at kemper.freedesktop.org Mon Mar 2 16:02:51 2015 From: brianp at kemper.freedesktop.org (Brian Paul) Date: Mon, 2 Mar 2015 08:02:51 -0800 (PST) Subject: Mesa (master): util: replace Elements() with ARRAY_SIZE() Message-ID: <20150302160251.16AAE761DF@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 692bd4a1ab9ae00a4771746626d4f33ceb8bcc9b URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=692bd4a1ab9ae00a4771746626d4f33ceb8bcc9b Author: Brian Paul Date: Sat Feb 28 13:28:06 2015 -0700 util: replace Elements() with ARRAY_SIZE() Reviewed-by: Matt Turner --- src/util/bitset.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/bitset.h b/src/util/bitset.h index 17c5d5d..febcdde 100644 --- a/src/util/bitset.h +++ b/src/util/bitset.h @@ -94,6 +94,6 @@ __bitset_ffs(const BITSET_WORD *x, int n) return 0; } -#define BITSET_FFS(x) __bitset_ffs(x, Elements(x)) +#define BITSET_FFS(x) __bitset_ffs(x, ARRAY_SIZE(x)) #endif From brianp at kemper.freedesktop.org Mon Mar 2 16:26:28 2015 From: brianp at kemper.freedesktop.org (Brian Paul) Date: Mon, 2 Mar 2015 08:26:28 -0800 (PST) Subject: Mesa (master): c99_alloca.h: Include stdlib.h on all non-Windows. Message-ID: <20150302162628.394D7761DF@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 3de01d2fe46652471362bcb8a527f59e0bb81cfc URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=3de01d2fe46652471362bcb8a527f59e0bb81cfc Author: Vinson Lee Date: Sun Mar 1 13:52:00 2015 -0700 c99_alloca.h: Include stdlib.h on all non-Windows. Fix build on FreeBSD. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=89364 Signed-off-by: Vinson Lee Tested-by: Brian Paul --- include/c99_alloca.h | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/include/c99_alloca.h b/include/c99_alloca.h index 7a81c50..575f719 100644 --- a/include/c99_alloca.h +++ b/include/c99_alloca.h @@ -35,13 +35,9 @@ # define alloca _alloca -#elif defined(__MINGW32__) - -# include - #else /* !defined(_MSC_VER) */ -# include +# include #endif /* !defined(_MSC_VER) */ From mattst88 at kemper.freedesktop.org Mon Mar 2 18:28:43 2015 From: mattst88 at kemper.freedesktop.org (Matt Turner) Date: Mon, 2 Mar 2015 10:28:43 -0800 (PST) Subject: Mesa (master): mesa: Free memory allocated for luminance in readpixels. Message-ID: <20150302182843.8E3E7763B7@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 87109acbed9c9b52f33d58ca06d9048d0ac7a215 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=87109acbed9c9b52f33d58ca06d9048d0ac7a215 Author: Matt Turner Date: Sat Feb 28 11:08:17 2015 -0800 mesa: Free memory allocated for luminance in readpixels. Cc: "10.4, 10.5" Reviewed-by: Brian Paul Reviewed-by: Iago Toral Quiroga --- src/mesa/main/readpix.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/mesa/main/readpix.c b/src/mesa/main/readpix.c index 2e4a460..ed0104c 100644 --- a/src/mesa/main/readpix.c +++ b/src/mesa/main/readpix.c @@ -594,6 +594,7 @@ read_rgba_pixels( struct gl_context *ctx, _mesa_format_convert(dst, dst_format, dst_stride, luminance, luminance_format, luminance_stride, width, height, NULL); + free(luminance); } else { _mesa_pack_luminance_from_rgba_integer(width * height, src, !src_is_uint, dst, format, type); From mattst88 at kemper.freedesktop.org Mon Mar 2 18:28:43 2015 From: mattst88 at kemper.freedesktop.org (Matt Turner) Date: Mon, 2 Mar 2015 10:28:43 -0800 (PST) Subject: Mesa (master): mesa: Indent break statements and add a missing one. Message-ID: <20150302182843.84EE6761DF@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 2b2fa1865248c6e3b7baec81c4f92774759b201f URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=2b2fa1865248c6e3b7baec81c4f92774759b201f Author: Matt Turner Date: Sat Feb 28 11:00:51 2015 -0800 mesa: Indent break statements and add a missing one. Always indenting break statements makes spotting missing ones easier. Cc: "10.4, 10.5" Reviewed-by: Brian Paul Reviewed-by: Iago Toral Quiroga --- src/mesa/main/pack.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/mesa/main/pack.c b/src/mesa/main/pack.c index 3b77c49..f723608 100644 --- a/src/mesa/main/pack.c +++ b/src/mesa/main/pack.c @@ -1487,20 +1487,20 @@ _mesa_pack_luminance_from_rgba_integer(GLuint n, case GL_UNSIGNED_BYTE: { GLbyte *dst = (GLbyte *) dstAddr; dst[i] = lum32; + break; } - break; case GL_SHORT: case GL_UNSIGNED_SHORT: { GLshort *dst = (GLshort *) dstAddr; dst[i] = lum32; + break; } - break; case GL_INT: case GL_UNSIGNED_INT: { GLint *dst = (GLint *) dstAddr; dst[i] = lum32; + break; } - break; } } return; @@ -1525,21 +1525,22 @@ _mesa_pack_luminance_from_rgba_integer(GLuint n, GLbyte *dst = (GLbyte *) dstAddr; dst[2*i] = lum32; dst[2*i+1] = alpha; + break; } case GL_SHORT: case GL_UNSIGNED_SHORT: { GLshort *dst = (GLshort *) dstAddr; dst[i] = lum32; dst[2*i+1] = alpha; + break; } - break; case GL_INT: case GL_UNSIGNED_INT: { GLint *dst = (GLint *) dstAddr; dst[i] = lum32; dst[2*i+1] = alpha; + break; } - break; } } return; From mattst88 at kemper.freedesktop.org Mon Mar 2 18:28:43 2015 From: mattst88 at kemper.freedesktop.org (Matt Turner) Date: Mon, 2 Mar 2015 10:28:43 -0800 (PST) Subject: Mesa (master): mesa: Correct backwards NULL check. Message-ID: <20150302182843.9B2FE763B8@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 491d42135ad0e5670756216154f2ba9fc79d4ba7 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=491d42135ad0e5670756216154f2ba9fc79d4ba7 Author: Matt Turner Date: Sat Feb 28 11:14:02 2015 -0800 mesa: Correct backwards NULL check. Cc: "10.4, 10.5" Reviewed-by: Emil Velikov Reviewed-by: Ian Romanick --- src/mesa/main/shaderapi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c index dd536cd..5731d58 100644 --- a/src/mesa/main/shaderapi.c +++ b/src/mesa/main/shaderapi.c @@ -1739,7 +1739,7 @@ _mesa_GetProgramBinary(GLuint program, GLsizei bufSize, GLsizei *length, * Ensure that length always points to valid storage to avoid multiple NULL * pointer checks below. */ - if (length != NULL) + if (length == NULL) length = &length_dummy; From mattst88 at kemper.freedesktop.org Mon Mar 2 18:28:43 2015 From: mattst88 at kemper.freedesktop.org (Matt Turner) Date: Mon, 2 Mar 2015 10:28:43 -0800 (PST) Subject: Mesa (master): i965: Consider scratch writes to have side effects. Message-ID: <20150302182843.A4F30761DF@kemper.freedesktop.org> Module: Mesa Branch: master Commit: da20bf068ef0f816968d9bc4dfea81facf0fd680 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=da20bf068ef0f816968d9bc4dfea81facf0fd680 Author: Matt Turner Date: Sat Feb 28 13:36:21 2015 -0800 i965: Consider scratch writes to have side effects. We could do better by tracking scratch reads and writes. Cc: 10.5 Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=88793 Reviewed-by: Jason Ekstrand --- src/mesa/drivers/dri/i965/brw_shader.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/mesa/drivers/dri/i965/brw_shader.cpp b/src/mesa/drivers/dri/i965/brw_shader.cpp index fbb20bc..ec3cfcb 100644 --- a/src/mesa/drivers/dri/i965/brw_shader.cpp +++ b/src/mesa/drivers/dri/i965/brw_shader.cpp @@ -963,6 +963,7 @@ backend_instruction::has_side_effects() const { switch (opcode) { case SHADER_OPCODE_UNTYPED_ATOMIC: + case SHADER_OPCODE_GEN4_SCRATCH_WRITE: case SHADER_OPCODE_URB_WRITE_SIMD8: case FS_OPCODE_FB_WRITE: return true; From mattst88 at kemper.freedesktop.org Mon Mar 2 18:39:07 2015 From: mattst88 at kemper.freedesktop.org (Matt Turner) Date: Mon, 2 Mar 2015 10:39:07 -0800 (PST) Subject: Mesa (master): i965: Remove hand-rolled memcpy implementation. Message-ID: <20150302183907.BD451761DF@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 54d7925012c639e7ff93eb2ae65404df290a5f91 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=54d7925012c639e7ff93eb2ae65404df290a5f91 Author: Matt Turner Date: Fri Feb 20 20:28:52 2015 -0800 i965: Remove hand-rolled memcpy implementation. Reviewed-by: Eric Anholt --- src/mesa/drivers/dri/i965/brw_context.h | 27 ------------------------- src/mesa/drivers/dri/i965/intel_batchbuffer.c | 2 +- 2 files changed, 1 insertion(+), 28 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h index c89e90e..682fbe9 100644 --- a/src/mesa/drivers/dri/i965/brw_context.h +++ b/src/mesa/drivers/dri/i965/brw_context.h @@ -1914,33 +1914,6 @@ gen6_upload_push_constants(struct brw_context *brw, struct brw_stage_state *stage_state, enum aub_state_struct_type type); -/* ================================================================ - * From linux kernel i386 header files, copes with odd sizes better - * than COPY_DWORDS would: - * XXX Put this in src/mesa/main/imports.h ??? - */ -#if defined(i386) || defined(__i386__) -static inline void * __memcpy(void * to, const void * from, size_t n) -{ - int d0, d1, d2; - __asm__ __volatile__( - "rep ; movsl\n\t" - "testb $2,%b4\n\t" - "je 1f\n\t" - "movsw\n" - "1:\ttestb $1,%b4\n\t" - "je 2f\n\t" - "movsb\n" - "2:" - : "=&c" (d0), "=&D" (d1), "=&S" (d2) - :"0" (n/4), "q" (n),"1" ((long) to),"2" ((long) from) - : "memory"); - return (to); -} -#else -#define __memcpy(a,b,c) memcpy(a,b,c) -#endif - #ifdef __cplusplus } #endif diff --git a/src/mesa/drivers/dri/i965/intel_batchbuffer.c b/src/mesa/drivers/dri/i965/intel_batchbuffer.c index 7b96005..45c7493 100644 --- a/src/mesa/drivers/dri/i965/intel_batchbuffer.c +++ b/src/mesa/drivers/dri/i965/intel_batchbuffer.c @@ -390,7 +390,7 @@ intel_batchbuffer_data(struct brw_context *brw, { assert((bytes & 3) == 0); intel_batchbuffer_require_space(brw, bytes, ring); - __memcpy(brw->batch.map + brw->batch.used, data, bytes); + memcpy(brw->batch.map + brw->batch.used, data, bytes); brw->batch.used += bytes >> 2; } From mattst88 at kemper.freedesktop.org Mon Mar 2 18:39:07 2015 From: mattst88 at kemper.freedesktop.org (Matt Turner) Date: Mon, 2 Mar 2015 10:39:07 -0800 (PST) Subject: Mesa (master): i915: Remove hand-rolled memcpy implementation. Message-ID: <20150302183907.CB0A9761DF@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 93a8c702a6582049d2f49c752fdaab1df625cc0c URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=93a8c702a6582049d2f49c752fdaab1df625cc0c Author: Matt Turner Date: Fri Feb 20 20:32:14 2015 -0800 i915: Remove hand-rolled memcpy implementation. Reviewed-by: Eric Anholt --- src/mesa/drivers/dri/i915/intel_batchbuffer.c | 2 +- src/mesa/drivers/dri/i915/intel_context.h | 28 ------------------------- 2 files changed, 1 insertion(+), 29 deletions(-) diff --git a/src/mesa/drivers/dri/i915/intel_batchbuffer.c b/src/mesa/drivers/dri/i915/intel_batchbuffer.c index 3d4e365..e0f14a4 100644 --- a/src/mesa/drivers/dri/i915/intel_batchbuffer.c +++ b/src/mesa/drivers/dri/i915/intel_batchbuffer.c @@ -246,7 +246,7 @@ intel_batchbuffer_data(struct intel_context *intel, { assert((bytes & 3) == 0); intel_batchbuffer_require_space(intel, bytes); - __memcpy(intel->batch.map + intel->batch.used, data, bytes); + memcpy(intel->batch.map + intel->batch.used, data, bytes); intel->batch.used += bytes >> 2; } diff --git a/src/mesa/drivers/dri/i915/intel_context.h b/src/mesa/drivers/dri/i915/intel_context.h index a2819a1..1bbd58f 100644 --- a/src/mesa/drivers/dri/i915/intel_context.h +++ b/src/mesa/drivers/dri/i915/intel_context.h @@ -297,34 +297,6 @@ do { \ } while (0) /* ================================================================ - * From linux kernel i386 header files, copes with odd sizes better - * than COPY_DWORDS would: - * XXX Put this in src/mesa/main/imports.h ??? - */ -#if defined(i386) || defined(__i386__) -static inline void * __memcpy(void * to, const void * from, size_t n) -{ - int d0, d1, d2; - __asm__ __volatile__( - "rep ; movsl\n\t" - "testb $2,%b4\n\t" - "je 1f\n\t" - "movsw\n" - "1:\ttestb $1,%b4\n\t" - "je 2f\n\t" - "movsb\n" - "2:" - : "=&c" (d0), "=&D" (d1), "=&S" (d2) - :"0" (n/4), "q" (n),"1" ((long) to),"2" ((long) from) - : "memory"); - return (to); -} -#else -#define __memcpy(a,b,c) memcpy(a,b,c) -#endif - - -/* ================================================================ * Debugging: */ extern int INTEL_DEBUG; From jekstrand at kemper.freedesktop.org Mon Mar 2 19:09:25 2015 From: jekstrand at kemper.freedesktop.org (Jason Ekstrand) Date: Mon, 2 Mar 2015 11:09:25 -0800 (PST) Subject: Mesa (master): main/base_tex_format: Properly handle STENCIL_INDEX1/4/16 Message-ID: <20150302190925.90B07763B7@kemper.freedesktop.org> Module: Mesa Branch: master Commit: c4925d7f3b66d63fbdd7b7607cd809db1e58bee9 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=c4925d7f3b66d63fbdd7b7607cd809db1e58bee9 Author: Jason Ekstrand Date: Fri Feb 27 18:53:11 2015 -0500 main/base_tex_format: Properly handle STENCIL_INDEX1/4/16 This takes "fbo-stencil blit GL_STENCIL_INDEX1/4/16" from crash to pass on BDW. Cc: 10.5 Reviewed-by: Matt Turner --- src/mesa/main/teximage.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c index 5ea48c5..611d664 100644 --- a/src/mesa/main/teximage.c +++ b/src/mesa/main/teximage.c @@ -224,7 +224,10 @@ _mesa_base_tex_format( struct gl_context *ctx, GLint internalFormat ) if (ctx->Extensions.ARB_stencil_texturing) { switch (internalFormat) { case GL_STENCIL_INDEX: + case GL_STENCIL_INDEX1: + case GL_STENCIL_INDEX4: case GL_STENCIL_INDEX8: + case GL_STENCIL_INDEX16: return GL_STENCIL_INDEX; default: ; /* fallthrough */ From jekstrand at kemper.freedesktop.org Mon Mar 2 19:09:25 2015 From: jekstrand at kemper.freedesktop.org (Jason Ekstrand) Date: Mon, 2 Mar 2015 11:09:25 -0800 (PST) Subject: Mesa (master): meta/TexSubImage: Stash everything other than PIXEL_TRANSFER/store in meta_begin Message-ID: <20150302190925.85312761DF@kemper.freedesktop.org> Module: Mesa Branch: master Commit: b1ab02d9c0cc11ba8ef4efaba9452d644b6a0811 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=b1ab02d9c0cc11ba8ef4efaba9452d644b6a0811 Author: Jason Ekstrand Date: Fri Feb 27 12:29:03 2015 -0800 meta/TexSubImage: Stash everything other than PIXEL_TRANSFER/store in meta_begin Previously, there were bugs where if the app set a scissor it could affect the area of the texture that was downloaded. There was also potential that the framebuffer SRGB state could affect downloads. This ensures that those will get saved/restored and can't affect the texture download. Cc: 10.5 Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=89292 Reviewed-by: Neil Roberts --- src/mesa/drivers/common/meta_tex_subimage.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/mesa/drivers/common/meta_tex_subimage.c b/src/mesa/drivers/common/meta_tex_subimage.c index bba2b4f..971ed59 100644 --- a/src/mesa/drivers/common/meta_tex_subimage.c +++ b/src/mesa/drivers/common/meta_tex_subimage.c @@ -193,8 +193,8 @@ _mesa_meta_pbo_TexSubImage(struct gl_context *ctx, GLuint dims, if (allocate_storage) ctx->Driver.AllocTextureImageBuffer(ctx, tex_image); - /* Only stash the current FBO */ - _mesa_meta_begin(ctx, 0); + _mesa_meta_begin(ctx, ~(MESA_META_PIXEL_TRANSFER | + MESA_META_PIXEL_STORE)); _mesa_GenFramebuffers(2, fbos); _mesa_BindFramebuffer(GL_READ_FRAMEBUFFER, fbos[0]); @@ -312,8 +312,8 @@ _mesa_meta_pbo_GetTexSubImage(struct gl_context *ctx, GLuint dims, if (!pbo_tex_image) return false; - /* Only stash the current FBO */ - _mesa_meta_begin(ctx, 0); + _mesa_meta_begin(ctx, ~(MESA_META_PIXEL_TRANSFER | + MESA_META_PIXEL_STORE)); _mesa_GenFramebuffers(2, fbos); From mattst88 at kemper.freedesktop.org Tue Mar 3 02:13:36 2015 From: mattst88 at kemper.freedesktop.org (Matt Turner) Date: Mon, 2 Mar 2015 18:13:36 -0800 (PST) Subject: Mesa (master): i965/fs: Don't use backend_visitor:: instructions after creating the CFG. Message-ID: <20150303021336.A2DC5761DF@kemper.freedesktop.org> Module: Mesa Branch: master Commit: e214000f258ae564e64d839cccee9418526f226b URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=e214000f258ae564e64d839cccee9418526f226b Author: Matt Turner Date: Tue Jan 13 15:35:57 2015 -0800 i965/fs: Don't use backend_visitor::instructions after creating the CFG. This is a fix for a regression introduced in commit a9f8296d ("i965/fs: Preserve the CFG in a few more places."). The errata this code works around is described in a comment before the function: "[DevBW, DevCL] Errata: A destination register from a send can not be used as a destination register until after it has been sourced by an instruction with a different destination register. The framebuffer write's sources must be in message registers, which SEND instructions cannot have as a destination. There's no way for this errata to affect anything at the end of the program. Just remove the code. Cc: 10.4, 10.5 Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=84613 Reviewed-by: Kenneth Graunke --- src/mesa/drivers/dri/i965/brw_fs.cpp | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp index 1a09ea3..533feb4 100644 --- a/src/mesa/drivers/dri/i965/brw_fs.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs.cpp @@ -3037,16 +3037,6 @@ fs_visitor::insert_gen4_post_send_dependency_workarounds(bblock_t *block, fs_ins if (i == write_len) return; } - - /* If we hit the end of the program, resolve all remaining dependencies out - * of paranoia. - */ - fs_inst *last_inst = (fs_inst *)this->instructions.get_tail(); - assert(last_inst->eot); - for (int i = 0; i < write_len; i++) { - if (needs_dep[i]) - last_inst->insert_before(block, DEP_RESOLVE_MOV(first_write_grf + i)); - } } void From bwidawsk at kemper.freedesktop.org Tue Mar 3 03:34:34 2015 From: bwidawsk at kemper.freedesktop.org (Ben Widawsky) Date: Mon, 2 Mar 2015 19:34:34 -0800 (PST) Subject: Mesa (master): i965: Rename some PIPE_CONTROL flags Message-ID: <20150303033434.1841B761DF@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 37c2687645bf44515dbd1bc1c066b02889ca46c4 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=37c2687645bf44515dbd1bc1c066b02889ca46c4 Author: Ben Widawsky Date: Thu Feb 26 23:01:33 2015 -0800 i965: Rename some PIPE_CONTROL flags I'm not really sure of the origins of the existing flag names. Modern docs have some slightly different names. Having the correct names makes it easier to determine if existing PIPE_CONTROL flag settings are correct, as well as making adding new PIPE_CONTROLs easier. This originally came up while I was trying to implement workarounds and spotted some things called, "flush" which should have been called "invalidate." Signed-off-by: Ben Widawsky Reviewed-by: Kristian H?gsberg Reviewed-by: Kenneth Graunke --- src/mesa/drivers/dri/i965/brw_program.c | 10 +++++----- src/mesa/drivers/dri/i965/gen6_vs_state.c | 2 +- src/mesa/drivers/dri/i965/gen8_depth_state.c | 2 +- src/mesa/drivers/dri/i965/intel_batchbuffer.c | 8 ++++---- src/mesa/drivers/dri/i965/intel_reg.h | 6 +++--- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_program.c b/src/mesa/drivers/dri/i965/brw_program.c index aed595e..70b5a62 100644 --- a/src/mesa/drivers/dri/i965/brw_program.c +++ b/src/mesa/drivers/dri/i965/brw_program.c @@ -195,24 +195,24 @@ brw_memory_barrier(struct gl_context *ctx, GLbitfield barriers) bits |= PIPE_CONTROL_VF_CACHE_INVALIDATE; if (barriers & GL_UNIFORM_BARRIER_BIT) - bits |= (PIPE_CONTROL_TC_FLUSH | + bits |= (PIPE_CONTROL_TEXTURE_CACHE_INVALIDATE | PIPE_CONTROL_CONST_CACHE_INVALIDATE); if (barriers & GL_TEXTURE_FETCH_BARRIER_BIT) - bits |= PIPE_CONTROL_TC_FLUSH; + bits |= PIPE_CONTROL_TEXTURE_CACHE_INVALIDATE; if (barriers & GL_TEXTURE_UPDATE_BARRIER_BIT) - bits |= PIPE_CONTROL_WRITE_FLUSH; + bits |= PIPE_CONTROL_RENDER_TARGET_FLUSH; if (barriers & GL_FRAMEBUFFER_BARRIER_BIT) bits |= (PIPE_CONTROL_DEPTH_CACHE_FLUSH | - PIPE_CONTROL_WRITE_FLUSH); + PIPE_CONTROL_RENDER_TARGET_FLUSH); /* Typed surface messages are handled by the render cache on IVB, so we * need to flush it too. */ if (brw->gen == 7 && !brw->is_haswell) - bits |= PIPE_CONTROL_WRITE_FLUSH; + bits |= PIPE_CONTROL_RENDER_TARGET_FLUSH; brw_emit_pipe_control_flush(brw, bits); } diff --git a/src/mesa/drivers/dri/i965/gen6_vs_state.c b/src/mesa/drivers/dri/i965/gen6_vs_state.c index ee68ba5..35d10ef 100644 --- a/src/mesa/drivers/dri/i965/gen6_vs_state.c +++ b/src/mesa/drivers/dri/i965/gen6_vs_state.c @@ -248,7 +248,7 @@ upload_vs_state(struct brw_context *brw) */ brw_emit_pipe_control_flush(brw, PIPE_CONTROL_DEPTH_STALL | - PIPE_CONTROL_INSTRUCTION_FLUSH | + PIPE_CONTROL_INSTRUCTION_INVALIDATE | PIPE_CONTROL_STATE_CACHE_INVALIDATE); } diff --git a/src/mesa/drivers/dri/i965/gen8_depth_state.c b/src/mesa/drivers/dri/i965/gen8_depth_state.c index b4eb6e1..5c56d51 100644 --- a/src/mesa/drivers/dri/i965/gen8_depth_state.c +++ b/src/mesa/drivers/dri/i965/gen8_depth_state.c @@ -340,7 +340,7 @@ write_pma_stall_bits(struct brw_context *brw, uint32_t pma_stall_bits) * Flush is also necessary. */ const uint32_t render_cache_flush = - ctx->Stencil._WriteEnabled ? PIPE_CONTROL_WRITE_FLUSH : 0; + ctx->Stencil._WriteEnabled ? PIPE_CONTROL_RENDER_TARGET_FLUSH : 0; brw_emit_pipe_control_flush(brw, PIPE_CONTROL_CS_STALL | PIPE_CONTROL_DEPTH_CACHE_FLUSH | diff --git a/src/mesa/drivers/dri/i965/intel_batchbuffer.c b/src/mesa/drivers/dri/i965/intel_batchbuffer.c index 45c7493..5ac4d18 100644 --- a/src/mesa/drivers/dri/i965/intel_batchbuffer.c +++ b/src/mesa/drivers/dri/i965/intel_batchbuffer.c @@ -411,7 +411,7 @@ intel_batchbuffer_data(struct brw_context *brw, static void gen8_add_cs_stall_workaround_bits(uint32_t *flags) { - uint32_t wa_bits = PIPE_CONTROL_WRITE_FLUSH | + uint32_t wa_bits = PIPE_CONTROL_RENDER_TARGET_FLUSH | PIPE_CONTROL_DEPTH_CACHE_FLUSH | PIPE_CONTROL_WRITE_IMMEDIATE | PIPE_CONTROL_WRITE_DEPTH_COUNT | @@ -665,7 +665,7 @@ intel_batchbuffer_emit_mi_flush(struct brw_context *brw) OUT_BATCH(0); ADVANCE_BATCH(); } else { - int flags = PIPE_CONTROL_NO_WRITE | PIPE_CONTROL_WRITE_FLUSH; + int flags = PIPE_CONTROL_NO_WRITE | PIPE_CONTROL_RENDER_TARGET_FLUSH; if (brw->gen >= 6) { if (brw->gen == 9) { /* Hardware workaround: SKL @@ -676,10 +676,10 @@ intel_batchbuffer_emit_mi_flush(struct brw_context *brw) brw_emit_pipe_control_flush(brw, 0); } - flags |= PIPE_CONTROL_INSTRUCTION_FLUSH | + flags |= PIPE_CONTROL_INSTRUCTION_INVALIDATE | PIPE_CONTROL_DEPTH_CACHE_FLUSH | PIPE_CONTROL_VF_CACHE_INVALIDATE | - PIPE_CONTROL_TC_FLUSH | + PIPE_CONTROL_TEXTURE_CACHE_INVALIDATE | PIPE_CONTROL_CS_STALL; if (brw->gen == 6) { diff --git a/src/mesa/drivers/dri/i965/intel_reg.h b/src/mesa/drivers/dri/i965/intel_reg.h index af1c1df..e5730e2 100644 --- a/src/mesa/drivers/dri/i965/intel_reg.h +++ b/src/mesa/drivers/dri/i965/intel_reg.h @@ -64,9 +64,9 @@ #define PIPE_CONTROL_WRITE_DEPTH_COUNT (2 << 14) #define PIPE_CONTROL_WRITE_TIMESTAMP (3 << 14) #define PIPE_CONTROL_DEPTH_STALL (1 << 13) -#define PIPE_CONTROL_WRITE_FLUSH (1 << 12) -#define PIPE_CONTROL_INSTRUCTION_FLUSH (1 << 11) -#define PIPE_CONTROL_TC_FLUSH (1 << 10) /* GM45+ only */ +#define PIPE_CONTROL_RENDER_TARGET_FLUSH (1 << 12) +#define PIPE_CONTROL_INSTRUCTION_INVALIDATE (1 << 11) +#define PIPE_CONTROL_TEXTURE_CACHE_INVALIDATE (1 << 10) /* GM45+ only */ #define PIPE_CONTROL_ISP_DIS (1 << 9) #define PIPE_CONTROL_INTERRUPT_ENABLE (1 << 8) /* GT */ From bwidawsk at kemper.freedesktop.org Tue Mar 3 03:55:44 2015 From: bwidawsk at kemper.freedesktop.org (Ben Widawsky) Date: Mon, 2 Mar 2015 19:55:44 -0800 (PST) Subject: Mesa (master): i965: Fix assertion in brw_reg_type_letters Message-ID: <20150303035544.5A5FE761DF@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 3d4d77a5dc7bc9f60d7845ff1d8d5b23f988232a URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=3d4d77a5dc7bc9f60d7845ff1d8d5b23f988232a Author: Ben Widawsky Date: Fri Nov 28 14:28:19 2014 -0800 i965: Fix assertion in brw_reg_type_letters While using various debugging features (optimization debug, instruction dumping, etc) this function is called in order to get a readable letter for the type of unit. On GEN8, two new units were added, the Qword and the Unsigned Qword (Q, and UQ respectively). The existing assertion tries to determine that the argument passed in is within the correct boundary, however, it was using UQ as the upper limit instead of Q. To my knowledge you can only hit this case with the branch I am currently working on, so it doesn't fix any known issues. Signed-off-by: Ben Widawsky Reviewed-by: Matt Turner --- src/mesa/drivers/dri/i965/brw_eu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesa/drivers/dri/i965/brw_eu.c b/src/mesa/drivers/dri/i965/brw_eu.c index a1b7fda..146202b 100644 --- a/src/mesa/drivers/dri/i965/brw_eu.c +++ b/src/mesa/drivers/dri/i965/brw_eu.c @@ -61,7 +61,7 @@ brw_reg_type_letters(unsigned type) [BRW_REGISTER_TYPE_UQ] = "UQ", [BRW_REGISTER_TYPE_Q] = "Q", }; - assert(type <= BRW_REGISTER_TYPE_UQ); + assert(type <= BRW_REGISTER_TYPE_Q); return names[type]; } From jrfonseca at kemper.freedesktop.org Tue Mar 3 11:30:53 2015 From: jrfonseca at kemper.freedesktop.org (Jose Fonseca) Date: Tue, 3 Mar 2015 03:30:53 -0800 (PST) Subject: Mesa (master): configure: Leverage gcc warn options to enable safe use of C99 features where possible. Message-ID: <20150303113053.AA449761DF@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 80c5bd7ef0319d14cd0362a763d9d15e9ba2c946 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=80c5bd7ef0319d14cd0362a763d9d15e9ba2c946 Author: Jose Fonseca Date: Thu Feb 26 16:46:48 2015 +0000 configure: Leverage gcc warn options to enable safe use of C99 features where possible. The main objective of this change is to enable Linux developers to use more of C99 throughout Mesa, with confidence that the portions that need to be built with MSVC -- and only those portions --, stay portable. This is achieved by using the appropriate -Werror= options only on the places they need to be used. Unfortunately we still need MSVC 2008 on a few portions of the code (namely llvmpipe and its dependencies). I hope to eventually eliminate this so that we can use C99 everywhere, but there are technical/logistic challenges (specifically, newer Windows SDKs no longer bundle MSVC, instead require a full installation of Visual Studio, and that has hindered adoption of newer MSVC versions on our build processes.) Thankfully we have more directy control over our OpenGL driver, which is why we're now able to migrate to MSVC 2013 for most of the tree. Reviewed-by: Brian Paul Reviewed-by: Kenneth Graunke --- configure.ac | 17 +++++++++++++++++ src/egl/main/Makefile.am | 1 + src/gallium/auxiliary/Makefile.am | 7 +++++-- src/gallium/drivers/llvmpipe/Makefile.am | 6 ++++-- src/gallium/state_trackers/egl/Makefile.am | 3 ++- src/gallium/targets/egl-static/Makefile.am | 3 ++- src/glsl/Makefile.am | 8 ++++++-- src/loader/Makefile.am | 1 + src/mapi/Makefile.am | 4 +++- src/mesa/Makefile.am | 10 ++++++++-- src/util/Makefile.am | 3 ++- 11 files changed, 51 insertions(+), 12 deletions(-) diff --git a/configure.ac b/configure.ac index 2ba79ef..c5abbfd 100644 --- a/configure.ac +++ b/configure.ac @@ -263,6 +263,18 @@ if test "x$GCC" = xyes; then # gcc's builtin memcmp is slower than glibc's # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43052 CFLAGS="$CFLAGS -fno-builtin-memcmp" + + # Flags to help ensure that certain portions of the code -- and only those + # portions -- can be built with MSVC: + # - src/util, src/gallium/auxiliary, and src/gallium/drivers/llvmpipe needs + # to build with Windows SDK 7.0.7600, which bundles MSVC 2008 + # - non-Linux/Posix OpenGL portions needs to build on MSVC 2013 (which + # supports most of C99) + # - the rest has no compiler compiler restrictions + MSVC2013_COMPAT_CFLAGS="-Werror=vla -Werror=pointer-arith" + MSVC2013_COMPAT_CXXFLAGS="-Werror=vla -Werror=pointer-arith" + MSVC2008_COMPAT_CFLAGS="$MSVC2013_COMPAT_CFLAGS -Werror=declaration-after-statement" + MSVC2008_COMPAT_CXXFLAGS="$MSVC2013_COMPAT_CXXFLAGS" fi if test "x$GXX" = xyes; then CXXFLAGS="$CXXFLAGS -Wall" @@ -288,6 +300,11 @@ if test "x$GXX" = xyes; then CXXFLAGS="$CXXFLAGS -fno-builtin-memcmp" fi +AC_SUBST([MSVC2013_COMPAT_CFLAGS]) +AC_SUBST([MSVC2013_COMPAT_CXXFLAGS]) +AC_SUBST([MSVC2008_COMPAT_CFLAGS]) +AC_SUBST([MSVC2008_COMPAT_CXXFLAGS]) + dnl even if the compiler appears to support it, using visibility attributes isn't dnl going to do anything useful currently on cygwin apart from emit lots of warnings case "$host_os" in diff --git a/src/egl/main/Makefile.am b/src/egl/main/Makefile.am index d21d8a9..a4db210 100644 --- a/src/egl/main/Makefile.am +++ b/src/egl/main/Makefile.am @@ -26,6 +26,7 @@ AM_CFLAGS = \ -I$(top_srcdir)/src/gbm/main \ $(DEFINES) \ $(VISIBILITY_CFLAGS) \ + $(MSVC2013_COMPAT_CFLAGS) \ $(EGL_CFLAGS) \ -D_EGL_NATIVE_PLATFORM=$(EGL_NATIVE_PLATFORM) \ -D_EGL_DRIVER_SEARCH_DIR=\"$(libdir)/egl\" \ diff --git a/src/gallium/auxiliary/Makefile.am b/src/gallium/auxiliary/Makefile.am index 4b62057..27a8b3f 100644 --- a/src/gallium/auxiliary/Makefile.am +++ b/src/gallium/auxiliary/Makefile.am @@ -12,9 +12,12 @@ noinst_LTLIBRARIES = libgallium.la AM_CFLAGS = \ -I$(top_srcdir)/src/gallium/auxiliary/util \ $(GALLIUM_CFLAGS) \ - $(VISIBILITY_CFLAGS) + $(VISIBILITY_CFLAGS) \ + $(MSVC2008_COMPAT_CXXFLAGS) -AM_CXXFLAGS = $(VISIBILITY_CXXFLAGS) +AM_CXXFLAGS = \ + $(VISIBILITY_CXXFLAGS) \ + $(MSVC2008_COMPAT_CXXFLAGS) libgallium_la_SOURCES = \ $(C_SOURCES) \ diff --git a/src/gallium/drivers/llvmpipe/Makefile.am b/src/gallium/drivers/llvmpipe/Makefile.am index 0bd4282..1d3853e 100644 --- a/src/gallium/drivers/llvmpipe/Makefile.am +++ b/src/gallium/drivers/llvmpipe/Makefile.am @@ -25,10 +25,12 @@ include $(top_srcdir)/src/gallium/Automake.inc AM_CFLAGS = \ $(GALLIUM_DRIVER_CFLAGS) \ - $(LLVM_CFLAGS) + $(LLVM_CFLAGS) \ + $(MSVC2008_COMPAT_CFLAGS) AM_CXXFLAGS= \ $(GALLIUM_DRIVER_CXXFLAGS) \ - $(LLVM_CXXFLAGS) + $(LLVM_CXXFLAGS) \ + $(MSVC2008_COMPAT_CXXFLAGS) noinst_LTLIBRARIES = libllvmpipe.la diff --git a/src/gallium/state_trackers/egl/Makefile.am b/src/gallium/state_trackers/egl/Makefile.am index 31546a7..f13fcb2 100644 --- a/src/gallium/state_trackers/egl/Makefile.am +++ b/src/gallium/state_trackers/egl/Makefile.am @@ -27,7 +27,8 @@ include $(top_srcdir)/src/gallium/Automake.inc AM_CFLAGS = \ $(GALLIUM_CFLAGS) \ - $(VISIBILITY_CFLAGS) + $(VISIBILITY_CFLAGS) \ + $(MSVC2013_COMPAT_CFLAGS) AM_CPPFLAGS = \ -I$(top_srcdir)/src/egl/main \ diff --git a/src/gallium/targets/egl-static/Makefile.am b/src/gallium/targets/egl-static/Makefile.am index 0056276..653fab1 100644 --- a/src/gallium/targets/egl-static/Makefile.am +++ b/src/gallium/targets/egl-static/Makefile.am @@ -31,7 +31,8 @@ include $(top_srcdir)/src/gallium/Automake.inc AM_CFLAGS = \ - $(GALLIUM_TARGET_CFLAGS) + $(GALLIUM_TARGET_CFLAGS) \ + $(MSVC2013_COMPAT_CFLAGS) AM_CPPFLAGS = \ -I$(top_srcdir)/src/gallium/state_trackers/egl \ diff --git a/src/glsl/Makefile.am b/src/glsl/Makefile.am index 5a0a643..b466a3b 100644 --- a/src/glsl/Makefile.am +++ b/src/glsl/Makefile.am @@ -33,8 +33,12 @@ AM_CPPFLAGS = \ -I$(top_srcdir)/src/gtest/include \ -I$(top_builddir)/src/glsl/nir \ $(DEFINES) -AM_CFLAGS = $(VISIBILITY_CFLAGS) -AM_CXXFLAGS = $(VISIBILITY_CXXFLAGS) +AM_CFLAGS = \ + $(VISIBILITY_CFLAGS) \ + $(MSVC2013_COMPAT_CFLAGS) +AM_CXXFLAGS = \ + $(VISIBILITY_CXXFLAGS) \ + $(MSVC2013_COMPAT_CXXFLAGS) EXTRA_DIST = tests glcpp/tests README TODO glcpp/README \ glsl_lexer.ll \ diff --git a/src/loader/Makefile.am b/src/loader/Makefile.am index 36ddba8..3d32279 100644 --- a/src/loader/Makefile.am +++ b/src/loader/Makefile.am @@ -30,6 +30,7 @@ libloader_la_CPPFLAGS = \ -I$(top_srcdir)/include \ -I$(top_srcdir)/src \ $(VISIBILITY_CFLAGS) \ + $(MSVC2013_COMPAT_CFLAGS) \ $(LIBUDEV_CFLAGS) libloader_la_SOURCES = $(LOADER_C_FILES) diff --git a/src/mapi/Makefile.am b/src/mapi/Makefile.am index 6794682..b0a6c8c 100644 --- a/src/mapi/Makefile.am +++ b/src/mapi/Makefile.am @@ -39,7 +39,9 @@ EXTRA_DIST = \ glapi/SConscript \ shared-glapi/SConscript -AM_CFLAGS = $(PTHREAD_CFLAGS) +AM_CFLAGS = \ + $(PTHREAD_CFLAGS) \ + $(MSVC2013_COMPAT_CFLAGS) AM_CPPFLAGS = \ $(DEFINES) \ $(SELINUX_CFLAGS) \ diff --git a/src/mesa/Makefile.am b/src/mesa/Makefile.am index b6cb8f1..5e9a820 100644 --- a/src/mesa/Makefile.am +++ b/src/mesa/Makefile.am @@ -136,8 +136,14 @@ noinst_LTLIBRARIES += libmesagallium.la endif AM_CPPFLAGS = $(DEFINES) $(INCLUDE_DIRS) -AM_CFLAGS = $(LLVM_CFLAGS) $(VISIBILITY_CFLAGS) -AM_CXXFLAGS = $(LLVM_CFLAGS) $(VISIBILITY_CXXFLAGS) +AM_CFLAGS = \ + $(LLVM_CFLAGS) \ + $(VISIBILITY_CFLAGS) \ + $(MSVC2013_COMPAT_CFLAGS) +AM_CXXFLAGS = \ + $(LLVM_CFLAGS) \ + $(VISIBILITY_CXXFLAGS) \ + $(MSVC2013_COMPAT_CXXFLAGS) ARCH_LIBS = diff --git a/src/util/Makefile.am b/src/util/Makefile.am index 9af2330..29b66e7 100644 --- a/src/util/Makefile.am +++ b/src/util/Makefile.am @@ -34,7 +34,8 @@ libmesautil_la_CPPFLAGS = \ -I$(top_srcdir)/src/gallium/include \ -I$(top_srcdir)/src/gallium/auxiliary \ $(SHA1_CFLAGS) \ - $(VISIBILITY_CFLAGS) + $(VISIBILITY_CFLAGS) \ + $(MSVC2008_COMPAT_CFLAGS) libmesautil_la_SOURCES = \ $(MESA_UTIL_FILES) \ From brianp at kemper.freedesktop.org Tue Mar 3 15:39:28 2015 From: brianp at kemper.freedesktop.org (Brian Paul) Date: Tue, 3 Mar 2015 07:39:28 -0800 (PST) Subject: Mesa (master): c99_alloca.h: add case for __sun Message-ID: <20150303153928.10BE276333@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 5ece2888769c2886b181d228ad447a8bca2ddee0 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=5ece2888769c2886b181d228ad447a8bca2ddee0 Author: Brian Paul Date: Tue Mar 3 08:09:21 2015 -0700 c99_alloca.h: add case for __sun Reviewed-by: Alan Coopersmith --- include/c99_alloca.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/c99_alloca.h b/include/c99_alloca.h index 575f719..ed66fda 100644 --- a/include/c99_alloca.h +++ b/include/c99_alloca.h @@ -35,6 +35,10 @@ # define alloca _alloca +#elif defined(__sun) + +# include + #else /* !defined(_MSC_VER) */ # include From robclark at kemper.freedesktop.org Tue Mar 3 15:41:16 2015 From: robclark at kemper.freedesktop.org (Rob Clark) Date: Tue, 3 Mar 2015 07:41:16 -0800 (PST) Subject: Mesa (master): tgsi/lowering: don't forget interp for BCOLOR inputs Message-ID: <20150303154116.703DD763B7@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 4abb789bca95e9c23b2339ea7732833203c94639 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=4abb789bca95e9c23b2339ea7732833203c94639 Author: Rob Clark Date: Fri Feb 27 09:02:48 2015 -0500 tgsi/lowering: don't forget interp for BCOLOR inputs To lower two sided color, tgsi_lowering creates additional BCOLOR inputs (matching up to the BCOLOR outputs on the vert shader). These inputs should copy the interpolation state of their matching COLOR input. Signed-off-by: Rob Clark --- src/gallium/auxiliary/tgsi/tgsi_lowering.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/gallium/auxiliary/tgsi/tgsi_lowering.c b/src/gallium/auxiliary/tgsi/tgsi_lowering.c index dee6c41..4954c11 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_lowering.c +++ b/src/gallium/auxiliary/tgsi/tgsi_lowering.c @@ -1152,7 +1152,7 @@ transform_samp(struct tgsi_transform_context *tctx, */ #define TWOSIDE_GROW(n) ( \ 2 + /* FACE */ \ - ((n) * 2) + /* IN[] BCOLOR[n] */ \ + ((n) * 3) + /* IN[], BCOLOR[n], */\ ((n) * 1) + /* TEMP[] */ \ ((n) * NINST(3)) /* CMP instr */ \ ) @@ -1172,13 +1172,17 @@ emit_twoside(struct tgsi_transform_context *tctx) /* additional inputs for BCOLOR's */ for (i = 0; i < ctx->two_side_colors; i++) { + unsigned in_idx = ctx->two_side_idx[i]; decl = tgsi_default_full_declaration(); decl.Declaration.File = TGSI_FILE_INPUT; decl.Declaration.Semantic = true; decl.Range.First = decl.Range.Last = inbase + i; decl.Semantic.Name = TGSI_SEMANTIC_BCOLOR; - decl.Semantic.Index = - info->input_semantic_index[ctx->two_side_idx[i]]; + decl.Semantic.Index = info->input_semantic_index[in_idx]; + decl.Declaration.Interpolate = true; + decl.Interp.Interpolate = info->input_interpolate[in_idx]; + decl.Interp.Location = info->input_interpolate_loc[in_idx]; + decl.Interp.CylindricalWrap = info->input_cylindrical_wrap[in_idx]; tctx->emit_declaration(tctx, &decl); } From robclark at kemper.freedesktop.org Tue Mar 3 15:41:16 2015 From: robclark at kemper.freedesktop.org (Rob Clark) Date: Tue, 3 Mar 2015 07:41:16 -0800 (PST) Subject: Mesa (master): freedreno/ir3: handle flat bypass for a4xx Message-ID: <20150303154116.9898876333@kemper.freedesktop.org> Module: Mesa Branch: master Commit: e9f2abe349886ae5423c7c31d201e7d587a3695a URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=e9f2abe349886ae5423c7c31d201e7d587a3695a Author: Rob Clark Date: Wed Feb 25 13:54:25 2015 -0500 freedreno/ir3: handle flat bypass for a4xx We may not need this for later a4xx patchlevels, but we do at least need this for patchlevel 0. Bypass bary.f for fetching varyings when flat shading is needed (rather than configure via cmdstream). This requires a special dummy bary.f w/ (ei) flag to signal to scheduler when all varyings are consumed. And requires shader variants based on rasterizer flatshade state to handle TGSI_INTERPOLATE_COLOR. Signed-off-by: Rob Clark --- src/gallium/drivers/freedreno/a4xx/fd4_draw.c | 5 ++- src/gallium/drivers/freedreno/a4xx/fd4_emit.h | 1 - src/gallium/drivers/freedreno/ir3/ir3.c | 2 + src/gallium/drivers/freedreno/ir3/ir3.h | 6 +++ src/gallium/drivers/freedreno/ir3/ir3_compiler.c | 47 +++++++++++++++++++++- src/gallium/drivers/freedreno/ir3/ir3_legalize.c | 38 ++++++++++++++++- src/gallium/drivers/freedreno/ir3/ir3_shader.c | 1 + src/gallium/drivers/freedreno/ir3/ir3_shader.h | 4 ++ 8 files changed, 99 insertions(+), 5 deletions(-) diff --git a/src/gallium/drivers/freedreno/a4xx/fd4_draw.c b/src/gallium/drivers/freedreno/a4xx/fd4_draw.c index b6bf650..57f2574 100644 --- a/src/gallium/drivers/freedreno/a4xx/fd4_draw.c +++ b/src/gallium/drivers/freedreno/a4xx/fd4_draw.c @@ -100,6 +100,9 @@ fixup_shader_state(struct fd_context *ctx, struct ir3_shader_key *key) if (last_key->alpha != key->alpha) ctx->prog.dirty |= FD_SHADER_DIRTY_FP; + if (last_key->rasterflat != key->rasterflat) + ctx->prog.dirty |= FD_SHADER_DIRTY_FP; + fd4_ctx->last_key = *key; } } @@ -118,6 +121,7 @@ fd4_draw_vbo(struct fd_context *ctx, const struct pipe_draw_info *info) .binning_pass = true, .color_two_side = ctx->rasterizer ? ctx->rasterizer->light_twoside : false, .alpha = util_format_is_alpha(pipe_surface_format(pfb->cbufs[0])), + .rasterflat = ctx->rasterizer && ctx->rasterizer->flatshade, // TODO set .half_precision based on render target format, // ie. float16 and smaller use half, float32 use full.. .half_precision = !!(fd_mesa_debug & FD_DBG_FRAGHALF), @@ -130,7 +134,6 @@ fd4_draw_vbo(struct fd_context *ctx, const struct pipe_draw_info *info) .fsaturate_r = fd4_ctx->fsaturate_r, }, .format = fd4_emit_format(pfb->cbufs[0]), - .rasterflat = ctx->rasterizer && ctx->rasterizer->flatshade, }; unsigned dirty; diff --git a/src/gallium/drivers/freedreno/a4xx/fd4_emit.h b/src/gallium/drivers/freedreno/a4xx/fd4_emit.h index cdfa0f4..5dc3db8 100644 --- a/src/gallium/drivers/freedreno/a4xx/fd4_emit.h +++ b/src/gallium/drivers/freedreno/a4xx/fd4_emit.h @@ -55,7 +55,6 @@ struct fd4_emit { struct ir3_shader_key key; enum a4xx_color_fmt format; uint32_t dirty; - bool rasterflat; /* cached to avoid repeated lookups of same variants: */ struct ir3_shader_variant *vp, *fp; diff --git a/src/gallium/drivers/freedreno/ir3/ir3.c b/src/gallium/drivers/freedreno/ir3/ir3.c index a02b06f..fe0ffc9 100644 --- a/src/gallium/drivers/freedreno/ir3/ir3.c +++ b/src/gallium/drivers/freedreno/ir3/ir3.c @@ -113,6 +113,8 @@ static uint32_t reg(struct ir3_register *reg, struct ir3_info *info, if (reg->flags & IR3_REG_CONST) { info->max_const = MAX2(info->max_const, max); + } else if (val.num == 63) { + /* ignore writes to dummy register r63.x */ } else if ((max != REG_A0) && (max != REG_P0)) { if (reg->flags & IR3_REG_HALF) { info->max_half_reg = MAX2(info->max_half_reg, max); diff --git a/src/gallium/drivers/freedreno/ir3/ir3.h b/src/gallium/drivers/freedreno/ir3/ir3.h index f90392b..18d59fa 100644 --- a/src/gallium/drivers/freedreno/ir3/ir3.h +++ b/src/gallium/drivers/freedreno/ir3/ir3.h @@ -427,6 +427,12 @@ static inline bool is_mem(struct ir3_instruction *instr) static inline bool is_input(struct ir3_instruction *instr) { + /* in some cases, ldlv is used to fetch varying without + * interpolation.. fortunately inloc is the first src + * register in either case + */ + if (is_mem(instr) && (instr->opc == OPC_LDLV)) + return true; return (instr->category == 2) && (instr->opc == OPC_BARY_F); } diff --git a/src/gallium/drivers/freedreno/ir3/ir3_compiler.c b/src/gallium/drivers/freedreno/ir3/ir3_compiler.c index 3ee9642..2084ad3 100644 --- a/src/gallium/drivers/freedreno/ir3/ir3_compiler.c +++ b/src/gallium/drivers/freedreno/ir3/ir3_compiler.c @@ -105,6 +105,11 @@ struct ir3_compile_context { /* for calculating input/output positions/linkages: */ unsigned next_inloc; + /* a4xx (at least patchlevel 0) cannot seem to flat-interpolate + * so we need to use ldlv.u32 to load the varying directly: + */ + bool flat_bypass; + unsigned num_internal_temps; struct tgsi_src_register internal_temps[8]; @@ -204,9 +209,13 @@ compile_init(struct ir3_compile_context *ctx, struct ir3_shader_variant *so, } else if (ir3_shader_gpuid(so->shader) >= 400) { /* a4xx seems to have *no* sam.p */ lconfig.lower_TXP = ~0; /* lower all txp */ + /* need special handling for "flat" */ + ctx->flat_bypass = true; } else { /* a3xx just needs to avoid sam.p for 3d tex */ lconfig.lower_TXP = (1 << TGSI_TEXTURE_3D); + /* no special handling for "flat" */ + ctx->flat_bypass = false; } ctx->tokens = tgsi_transform_lowering(&lconfig, tokens, &ctx->info); @@ -2745,11 +2754,23 @@ decl_semantic(const struct tgsi_declaration_semantic *sem) static struct ir3_instruction * decl_in_frag_bary(struct ir3_compile_context *ctx, unsigned regid, - unsigned j, unsigned inloc) + unsigned j, unsigned inloc, bool use_ldlv) { struct ir3_instruction *instr; struct ir3_register *src; + if (use_ldlv) { + /* ldlv.u32 dst, l[#inloc], 1 */ + instr = instr_create(ctx, 6, OPC_LDLV); + instr->cat6.type = TYPE_U32; + instr->cat6.iim_val = 1; + ir3_reg_create(instr, regid, 0); /* dummy dst */ + ir3_reg_create(instr, 0, IR3_REG_IMMED)->iim_val = inloc; + ir3_reg_create(instr, 0, IR3_REG_IMMED)->iim_val = 1; + + return instr; + } + /* bary.f dst, #inloc, r0.x */ instr = instr_create(ctx, 2, OPC_BARY_F); ir3_reg_create(instr, regid, 0); /* dummy dst */ @@ -2943,9 +2964,31 @@ decl_in(struct ir3_compile_context *ctx, struct tgsi_full_declaration *decl) so->frag_face = true; instr = decl_in_frag_face(ctx, r + j, j); } else { + bool use_ldlv = false; + + /* I don't believe it is valid to not have Interp + * on a normal frag shader input, and various parts + * that that handle flat/smooth shading make this + * assumption as well. + */ + compile_assert(ctx, decl->Declaration.Interpolate); + + if (ctx->flat_bypass) { + switch (decl->Interp.Interpolate) { + case TGSI_INTERPOLATE_COLOR: + if (!ctx->so->key.rasterflat) + break; + /* fallthrough */ + case TGSI_INTERPOLATE_CONSTANT: + use_ldlv = true; + break; + } + } + so->inputs[n].bary = true; + instr = decl_in_frag_bary(ctx, r + j, j, - so->inputs[n].inloc + j - 8); + so->inputs[n].inloc + j - 8, use_ldlv); } } else { instr = create_input(ctx->block, NULL, (i * 4) + j); diff --git a/src/gallium/drivers/freedreno/ir3/ir3_legalize.c b/src/gallium/drivers/freedreno/ir3/ir3_legalize.c index 11629f6..4e0b42b 100644 --- a/src/gallium/drivers/freedreno/ir3/ir3_legalize.c +++ b/src/gallium/drivers/freedreno/ir3/ir3_legalize.c @@ -187,8 +187,44 @@ static void legalize(struct ir3_legalize_ctx *ctx) last_input = n; } - if (last_input) + if (last_input) { + /* special hack.. if using ldlv to bypass interpolation, + * we need to insert a dummy bary.f on which we can set + * the (ei) flag: + */ + if (is_mem(last_input) && (last_input->opc == OPC_LDLV)) { + int i, cnt; + + /* note that ir3_instr_create() inserts into + * shader->instrs[] and increments the count.. + * so we need to bump up the cnt initially (to + * avoid it clobbering the last real instr) and + * restore it after. + */ + cnt = ++shader->instrs_count; + + /* inserting instructions would be a bit nicer if list.. */ + for (i = cnt - 2; i >= 0; i--) { + if (shader->instrs[i] == last_input) { + + /* (ss)bary.f (ei)r63.x, 0, r0.x */ + last_input = ir3_instr_create(block, 2, OPC_BARY_F); + last_input->flags |= IR3_INSTR_SS; + ir3_reg_create(last_input, regid(63, 0), 0); + ir3_reg_create(last_input, 0, IR3_REG_IMMED)->iim_val = 0; + ir3_reg_create(last_input, regid(0, 0), 0); + + shader->instrs[i + 1] = last_input; + + break; + } + shader->instrs[i + 1] = shader->instrs[i]; + } + + shader->instrs_count = cnt; + } last_input->regs[0]->flags |= IR3_REG_EI; + } if (last_rel) last_rel->flags |= IR3_INSTR_UL; diff --git a/src/gallium/drivers/freedreno/ir3/ir3_shader.c b/src/gallium/drivers/freedreno/ir3/ir3_shader.c index 5e43e28..7e7ae36 100644 --- a/src/gallium/drivers/freedreno/ir3/ir3_shader.c +++ b/src/gallium/drivers/freedreno/ir3/ir3_shader.c @@ -246,6 +246,7 @@ ir3_shader_variant(struct ir3_shader *shader, struct ir3_shader_key key) key.color_two_side = false; key.half_precision = false; key.alpha = false; + key.rasterflat = false; if (key.has_per_samp) { key.fsaturate_s = 0; key.fsaturate_t = 0; diff --git a/src/gallium/drivers/freedreno/ir3/ir3_shader.h b/src/gallium/drivers/freedreno/ir3/ir3_shader.h index e5d57af..7f38067 100644 --- a/src/gallium/drivers/freedreno/ir3/ir3_shader.h +++ b/src/gallium/drivers/freedreno/ir3/ir3_shader.h @@ -77,6 +77,10 @@ struct ir3_shader_key { * let's start with this and see how it goes: */ unsigned alpha : 1; + /* used when shader needs to handle flat varyings (a4xx), + * for TGSI_INTERPOLATE_COLOR: + */ + unsigned rasterflat : 1; }; uint32_t global; }; From robclark at kemper.freedesktop.org Tue Mar 3 15:41:16 2015 From: robclark at kemper.freedesktop.org (Rob Clark) Date: Tue, 3 Mar 2015 07:41:16 -0800 (PST) Subject: Mesa (master): freedreno/a3xx,a4xx: silence some warnings Message-ID: <20150303154116.673AD76333@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 583a8a8f65c3086d21de864c602c6aa6283bcd45 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=583a8a8f65c3086d21de864c602c6aa6283bcd45 Author: Rob Clark Date: Thu Feb 26 21:06:02 2015 -0500 freedreno/a3xx,a4xx: silence some warnings fd3_emit.c: In function ?fd3_emit_vertex_bufs?: fd3_emit.c:377:11: warning: unused variable ?semantic? [-Wunused-variable] uint8_t semantic = sem2name(vp->inputs[i].semantic); and fd4_emit.c: In function ?fd4_emit_vertex_bufs?: fd4_emit.c:304:11: warning: unused variable ?semantic? [-Wunused-variable] uint8_t semantic = sem2name(vp->inputs[i].semantic); Signed-off-by: Rob Clark --- src/gallium/drivers/freedreno/a3xx/fd3_emit.c | 3 +-- src/gallium/drivers/freedreno/a4xx/fd4_emit.c | 4 +--- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/gallium/drivers/freedreno/a3xx/fd3_emit.c b/src/gallium/drivers/freedreno/a3xx/fd3_emit.c index f1a17ec..a5874e4 100644 --- a/src/gallium/drivers/freedreno/a3xx/fd3_emit.c +++ b/src/gallium/drivers/freedreno/a3xx/fd3_emit.c @@ -374,8 +374,7 @@ fd3_emit_vertex_bufs(struct fd_ringbuffer *ring, struct fd3_emit *emit) return; for (i = 0, j = 0; i <= last; i++) { - uint8_t semantic = sem2name(vp->inputs[i].semantic); - assert(semantic == 0); + assert(sem2name(vp->inputs[i].semantic) == 0); if (vp->inputs[i].compmask) { struct pipe_vertex_element *elem = &vtx->vtx->pipe[i]; const struct pipe_vertex_buffer *vb = diff --git a/src/gallium/drivers/freedreno/a4xx/fd4_emit.c b/src/gallium/drivers/freedreno/a4xx/fd4_emit.c index 6540e1d..37552cf 100644 --- a/src/gallium/drivers/freedreno/a4xx/fd4_emit.c +++ b/src/gallium/drivers/freedreno/a4xx/fd4_emit.c @@ -301,9 +301,7 @@ fd4_emit_vertex_bufs(struct fd_ringbuffer *ring, struct fd4_emit *emit) return; for (i = 0, j = 0; i <= last; i++) { - uint8_t semantic = sem2name(vp->inputs[i].semantic); - assert(semantic != TGSI_SEMANTIC_VERTEXID); - assert(semantic != TGSI_SEMANTIC_INSTANCEID); + assert(sem2name(vp->inputs[i].semantic) == 0); if (vp->inputs[i].compmask) { struct pipe_vertex_element *elem = &vtx->vtx->pipe[i]; const struct pipe_vertex_buffer *vb = From robclark at kemper.freedesktop.org Tue Mar 3 15:41:16 2015 From: robclark at kemper.freedesktop.org (Rob Clark) Date: Tue, 3 Mar 2015 07:41:16 -0800 (PST) Subject: Mesa (master): freedreno/ir3: fix up cat6 instruction encodings Message-ID: <20150303154116.7CD3376333@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 20b50a071271e2caf8a4c3d4fd72f877af8a18d9 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=20b50a071271e2caf8a4c3d4fd72f877af8a18d9 Author: Rob Clark Date: Thu Feb 26 13:35:31 2015 -0500 freedreno/ir3: fix up cat6 instruction encodings I think there is at least one more sub-encoding, but these two should be enough to cover the common load/store instructions. Signed-off-by: Rob Clark --- src/gallium/drivers/freedreno/ir3/disasm-a3xx.c | 157 +++++++++++------------ src/gallium/drivers/freedreno/ir3/instr-a3xx.h | 41 +++--- src/gallium/drivers/freedreno/ir3/ir3.c | 62 ++++----- 3 files changed, 121 insertions(+), 139 deletions(-) diff --git a/src/gallium/drivers/freedreno/ir3/disasm-a3xx.c b/src/gallium/drivers/freedreno/ir3/disasm-a3xx.c index 602be65..bed9aca 100644 --- a/src/gallium/drivers/freedreno/ir3/disasm-a3xx.c +++ b/src/gallium/drivers/freedreno/ir3/disasm-a3xx.c @@ -448,117 +448,114 @@ static void print_instr_cat5(instr_t *instr) } } -static int32_t u2i(uint32_t val, int nbits) -{ - return ((val >> (nbits-1)) * ~((1 << nbits) - 1)) | val; -} - static void print_instr_cat6(instr_t *instr) { instr_cat6_t *cat6 = &instr->cat6; + char sd = 0, ss = 0; /* dst/src address space */ + bool full = type_size(cat6->type) == 32; + bool nodst = false; printf(".%s ", type[cat6->type]); switch (cat6->opc) { + case OPC_STG: + sd = 'g'; + break; + case OPC_STP: + sd = 'p'; + break; + case OPC_STL: + case OPC_STLW: + sd = 'l'; + break; + case OPC_LDG: + ss = 'g'; + break; case OPC_LDP: + ss = 'p'; + break; case OPC_LDL: case OPC_LDLW: case OPC_LDLV: - /* load instructions: */ - print_reg_dst((reg_t)(cat6->a.dst), type_size(cat6->type) == 32, false); - printf(","); - switch (cat6->opc) { - case OPC_LDG: - printf("g"); - break; - case OPC_LDP: - printf("p"); - break; - case OPC_LDL: - case OPC_LDLW: - case OPC_LDLV: - printf("l"); - break; - } - printf("["); - print_reg_src((reg_t)(cat6->a.src), true, - false, false, false, false, false, false); - if (cat6->a.off) - printf("%+d", cat6->a.off); - printf("]"); + ss = 'l'; break; - case OPC_PREFETCH: - /* similar to load instructions: */ - printf("g["); - print_reg_src((reg_t)(cat6->a.src), true, - false, false, false, false, false, false); - if (cat6->a.off) - printf("%+d", cat6->a.off); - printf("]"); + + case OPC_L2G: + ss = 'l'; + sd = 'g'; break; - case OPC_STG: - case OPC_STP: - case OPC_STL: - case OPC_STLW: - /* store instructions: */ - switch (cat6->opc) { - case OPC_STG: - printf("g"); - break; - case OPC_STP: - printf("p"); - break; - case OPC_STL: - case OPC_STLW: - printf("l"); - break; - } - printf("["); - print_reg_dst((reg_t)(cat6->b.dst), true, false); - if (cat6->b.off || cat6->b.off_hi) - printf("%+d", u2i((cat6->b.off_hi << 8) | cat6->b.off, 13)); - printf("]"); - printf(","); - print_reg_src((reg_t)(cat6->b.src), type_size(cat6->type) == 32, - false, false, false, false, false, false); + case OPC_G2L: + ss = 'g'; + sd = 'l'; break; + + case OPC_PREFETCH: + ss = 'g'; + nodst = true; + break; + case OPC_STI: - /* sti has same encoding as other store instructions, but - * slightly different syntax: - */ - print_reg_dst((reg_t)(cat6->b.dst), false /* XXX is it always half? */, false); - if (cat6->b.off || cat6->b.off_hi) - printf("%+d", u2i((cat6->b.off_hi << 8) | cat6->b.off, 13)); - printf(","); - print_reg_src((reg_t)(cat6->b.src), type_size(cat6->type) == 32, - false, false, false, false, false, false); + full = false; // XXX or inverts?? break; } - printf(", %d", cat6->iim_val); + if (cat6->has_off) { + if (!nodst) { + if (sd) + printf("%c[", sd); + print_reg_dst((reg_t)(cat6->a.dst), full, false); + if (sd) + printf("]"); + printf(", "); + } + if (ss) + printf("%c[", ss); + print_reg_src((reg_t)(cat6->a.src1), true, + false, false, cat6->a.src1_im, false, false, false); + printf("%+d", cat6->a.off); + if (ss) + printf("]"); + printf(", "); + print_reg_src((reg_t)(cat6->a.src2), full, + false, false, cat6->a.src2_im, false, false, false); + } else { + if (!nodst) { + if (sd) + printf("%c[", sd); + print_reg_dst((reg_t)(cat6->b.dst), full, false); + if (sd) + printf("]"); + printf(", "); + } + if (ss) + printf("%c[", ss); + print_reg_src((reg_t)(cat6->b.src1), true, + false, false, cat6->b.src1_im, false, false, false); + if (ss) + printf("]"); + printf(", "); + print_reg_src((reg_t)(cat6->b.src2), full, + false, false, cat6->b.src2_im, false, false, false); + } if (debug & PRINT_VERBOSE) { switch (cat6->opc) { case OPC_LDG: case OPC_LDP: /* load instructions: */ - if (cat6->a.dummy1|cat6->a.dummy2|cat6->a.dummy3) - printf("\t{6: %x,%x,%x}", cat6->a.dummy1, cat6->a.dummy2, cat6->a.dummy3); - if ((cat6->a.must_be_one1 != 1) || (cat6->a.must_be_one2 != 1)) - printf("{?? %d,%d ??}", cat6->a.must_be_one1, cat6->a.must_be_one2); + if (cat6->a.dummy2|cat6->a.dummy3) + printf("\t{6: %x,%x}", cat6->a.dummy2, cat6->a.dummy3); break; case OPC_STG: case OPC_STP: case OPC_STI: /* store instructions: */ - if (cat6->b.dummy1|cat6->b.dummy2) - printf("\t{6: %x,%x}", cat6->b.dummy1, cat6->b.dummy2); - if ((cat6->b.must_be_one1 != 1) || (cat6->b.must_be_one2 != 1) || - (cat6->b.must_be_zero1 != 0)) - printf("{?? %d,%d,%d ??}", cat6->b.must_be_one1, cat6->b.must_be_one2, - cat6->b.must_be_zero1); + if (cat6->b.dummy2|cat6->b.dummy2) + printf("\t{6: %x,%x}", cat6->b.dummy2, cat6->b.dummy3); + if (cat6->b.ignore0) + printf("\t{?? %x}", cat6->b.ignore0); break; } } diff --git a/src/gallium/drivers/freedreno/ir3/instr-a3xx.h b/src/gallium/drivers/freedreno/ir3/instr-a3xx.h index c67f103..b7e19c8 100644 --- a/src/gallium/drivers/freedreno/ir3/instr-a3xx.h +++ b/src/gallium/drivers/freedreno/ir3/instr-a3xx.h @@ -572,15 +572,15 @@ typedef struct PACKED { uint32_t opc_cat : 3; } instr_cat5_t; -/* used for load instructions: */ +/* [src1 + off], src2: */ typedef struct PACKED { /* dword0: */ - uint32_t must_be_one1 : 1; - int16_t off : 13; - uint32_t src : 8; - uint32_t dummy1 : 1; - uint32_t must_be_one2 : 1; - int32_t iim_val : 8; + uint32_t mustbe1 : 1; + int32_t off : 13; + uint32_t src1 : 8; + uint32_t src1_im : 1; + uint32_t src2_im : 1; + uint32_t src2 : 8; /* dword1: */ uint32_t dst : 8; @@ -593,35 +593,38 @@ typedef struct PACKED { uint32_t opc_cat : 3; } instr_cat6a_t; -/* used for store instructions: */ +/* [src1], src2: */ typedef struct PACKED { /* dword0: */ - uint32_t must_be_zero1 : 1; - uint32_t src : 8; - uint32_t off_hi : 5; /* high bits of 'off'... ugly! */ - uint32_t dummy1 : 9; - uint32_t must_be_one1 : 1; - int32_t iim_val : 8; + uint32_t mustbe0 : 1; + uint32_t src1 : 8; + uint32_t ignore0 : 13; + uint32_t src1_im : 1; + uint32_t src2_im : 1; + uint32_t src2 : 8; /* dword1: */ - uint16_t off : 8; - uint32_t must_be_one2 : 1; uint32_t dst : 8; + uint32_t dummy2 : 9; uint32_t type : 3; - uint32_t dummy2 : 2; + uint32_t dummy3 : 2; uint32_t opc : 5; uint32_t jmp_tgt : 1; uint32_t sync : 1; uint32_t opc_cat : 3; } instr_cat6b_t; +/* I think some of the other cat6 instructions use additional + * sub-encodings.. + */ + typedef union PACKED { instr_cat6a_t a; instr_cat6b_t b; struct PACKED { /* dword0: */ - uint32_t pad1 : 24; - int32_t iim_val : 8; + uint32_t has_off : 1; + uint32_t pad1 : 31; /* dword1: */ uint32_t pad2 : 17; diff --git a/src/gallium/drivers/freedreno/ir3/ir3.c b/src/gallium/drivers/freedreno/ir3/ir3.c index 095085a..a02b06f 100644 --- a/src/gallium/drivers/freedreno/ir3/ir3.c +++ b/src/gallium/drivers/freedreno/ir3/ir3.c @@ -474,58 +474,40 @@ static int emit_cat5(struct ir3_instruction *instr, void *ptr, static int emit_cat6(struct ir3_instruction *instr, void *ptr, struct ir3_info *info) { - struct ir3_register *dst = instr->regs[0]; - struct ir3_register *src = instr->regs[1]; + struct ir3_register *dst = instr->regs[0]; + struct ir3_register *src1 = instr->regs[1]; + struct ir3_register *src2 = (instr->regs_count >= 3) ? instr->regs[2] : NULL; instr_cat6_t *cat6 = ptr; - iassert(instr->regs_count == 2); + iassert(instr->regs_count >= 2); - switch (instr->opc) { - /* load instructions: */ - case OPC_LDG: - case OPC_LDP: - case OPC_LDL: - case OPC_LDLW: - case OPC_LDLV: - case OPC_PREFETCH: { + if (instr->cat6.offset) { instr_cat6a_t *cat6a = ptr; - iassert(!((dst->flags ^ type_flags(instr->cat6.type)) & IR3_REG_HALF)); + cat6->has_off = true; - cat6a->must_be_one1 = 1; - cat6a->must_be_one2 = 1; - cat6a->off = instr->cat6.offset; - cat6a->src = reg(src, info, instr->repeat, 0); cat6a->dst = reg(dst, info, instr->repeat, IR3_REG_R | IR3_REG_HALF); - break; - } - /* store instructions: */ - case OPC_STG: - case OPC_STP: - case OPC_STL: - case OPC_STLW: - case OPC_STI: { + cat6a->src1 = reg(src1, info, instr->repeat, IR3_REG_IMMED); + cat6a->src1_im = !!(src1->flags & IR3_REG_IMMED); + if (src2) { + cat6a->src2 = reg(src2, info, instr->repeat, IR3_REG_IMMED); + cat6a->src2_im = !!(src2->flags & IR3_REG_IMMED); + } + cat6a->off = instr->cat6.offset; + } else { instr_cat6b_t *cat6b = ptr; - uint32_t src_flags = type_flags(instr->cat6.type); - uint32_t dst_flags = (instr->opc == OPC_STI) ? IR3_REG_HALF : 0; - - iassert(!((src->flags ^ src_flags) & IR3_REG_HALF)); - cat6b->must_be_one1 = 1; - cat6b->must_be_one2 = 1; - cat6b->src = reg(src, info, instr->repeat, src_flags); - cat6b->off_hi = instr->cat6.offset >> 8; - cat6b->off = instr->cat6.offset; - cat6b->dst = reg(dst, info, instr->repeat, IR3_REG_R | dst_flags); + cat6->has_off = false; - break; - } - default: - // TODO - break; + cat6b->dst = reg(dst, info, instr->repeat, IR3_REG_R | IR3_REG_HALF); + cat6b->src1 = reg(src1, info, instr->repeat, IR3_REG_IMMED); + cat6b->src1_im = !!(src1->flags & IR3_REG_IMMED); + if (src2) { + cat6b->src2 = reg(src2, info, instr->repeat, IR3_REG_IMMED); + cat6b->src2_im = !!(src2->flags & IR3_REG_IMMED); + } } - cat6->iim_val = instr->cat6.iim_val; cat6->type = instr->cat6.type; cat6->opc = instr->opc; cat6->jmp_tgt = !!(instr->flags & IR3_INSTR_JP); From robclark at kemper.freedesktop.org Tue Mar 3 15:41:16 2015 From: robclark at kemper.freedesktop.org (Rob Clark) Date: Tue, 3 Mar 2015 07:41:16 -0800 (PST) Subject: Mesa (master): freedreno/ir3: add support for memory (cat6) instructions Message-ID: <20150303154116.87A7B76333@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 9d732d3125e1b39788a642a5723aeb54cb1983f3 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=9d732d3125e1b39788a642a5723aeb54cb1983f3 Author: Rob Clark Date: Thu Feb 26 15:13:10 2015 -0500 freedreno/ir3: add support for memory (cat6) instructions Scheduled basically the same as texture (cat5) instructions, using (sy) flag for synchronization. Signed-off-by: Rob Clark --- src/gallium/drivers/freedreno/ir3/ir3.h | 8 +++++--- src/gallium/drivers/freedreno/ir3/ir3_depth.c | 2 +- src/gallium/drivers/freedreno/ir3/ir3_legalize.c | 2 ++ 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/gallium/drivers/freedreno/ir3/ir3.h b/src/gallium/drivers/freedreno/ir3/ir3.h index a3bbba9..f90392b 100644 --- a/src/gallium/drivers/freedreno/ir3/ir3.h +++ b/src/gallium/drivers/freedreno/ir3/ir3.h @@ -420,6 +420,11 @@ static inline bool is_tex(struct ir3_instruction *instr) return (instr->category == 5); } +static inline bool is_mem(struct ir3_instruction *instr) +{ + return (instr->category == 6); +} + static inline bool is_input(struct ir3_instruction *instr) { return (instr->category == 2) && (instr->opc == OPC_BARY_F); @@ -508,9 +513,6 @@ int ir3_block_ra(struct ir3_block *block, enum shader_t type, void ir3_block_legalize(struct ir3_block *block, bool *has_samp, int *max_bary); -#ifndef ARRAY_SIZE -# define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0])) -#endif /* ************************************************************************* */ /* split this out or find some helper to use.. like main/bitset.h.. */ diff --git a/src/gallium/drivers/freedreno/ir3/ir3_depth.c b/src/gallium/drivers/freedreno/ir3/ir3_depth.c index 76413d4..8ff62ba 100644 --- a/src/gallium/drivers/freedreno/ir3/ir3_depth.c +++ b/src/gallium/drivers/freedreno/ir3/ir3_depth.c @@ -67,7 +67,7 @@ int ir3_delayslots(struct ir3_instruction *assigner, return 6; /* handled via sync flags: */ - if (is_sfu(assigner) || is_tex(assigner)) + if (is_sfu(assigner) || is_tex(assigner) || is_mem(assigner)) return 0; /* assigner must be alu: */ diff --git a/src/gallium/drivers/freedreno/ir3/ir3_legalize.c b/src/gallium/drivers/freedreno/ir3/ir3_legalize.c index 2ef11f1..11629f6 100644 --- a/src/gallium/drivers/freedreno/ir3/ir3_legalize.c +++ b/src/gallium/drivers/freedreno/ir3/ir3_legalize.c @@ -168,6 +168,8 @@ static void legalize(struct ir3_legalize_ctx *ctx) */ ctx->has_samp = true; regmask_set(&needs_sy, n->regs[0]); + } else if (is_mem(n)) { + regmask_set(&needs_sy, n->regs[0]); } /* both tex/sfu appear to not always immediately consume From robclark at kemper.freedesktop.org Tue Mar 3 15:41:16 2015 From: robclark at kemper.freedesktop.org (Rob Clark) Date: Tue, 3 Mar 2015 07:41:16 -0800 (PST) Subject: Mesa (master): freedreno/a4xx: re-enable int (conditional on glsl130) Message-ID: <20150303154116.A5F3E76333@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 8e67fd798e750fde213c6c401964e065e7dbe5e5 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=8e67fd798e750fde213c6c401964e065e7dbe5e5 Author: Rob Clark Date: Thu Feb 26 19:37:31 2015 -0500 freedreno/a4xx: re-enable int (conditional on glsl130) Re-enable integer, now that we can handle flat varyings. Still, ofc, conditional on FD_MESA_DEBUG=glsl130, until we can deprecate _old compiler.. Signed-off-by: Rob Clark --- src/gallium/drivers/freedreno/freedreno_screen.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gallium/drivers/freedreno/freedreno_screen.c b/src/gallium/drivers/freedreno/freedreno_screen.c index 2973458..3e9a3f3 100644 --- a/src/gallium/drivers/freedreno/freedreno_screen.c +++ b/src/gallium/drivers/freedreno/freedreno_screen.c @@ -372,7 +372,7 @@ fd_screen_get_shader_param(struct pipe_screen *pscreen, unsigned shader, * TODO looks like a4xx will require some additional * work for integer varying fetch.. */ - return (is_a3xx(screen) && glsl130) ? 1 : 0; + return ((is_a3xx(screen) || is_a4xx(screen)) && glsl130) ? 1 : 0; case PIPE_SHADER_CAP_MAX_TEXTURE_SAMPLERS: case PIPE_SHADER_CAP_MAX_SAMPLER_VIEWS: return 16; From chadversary at kemper.freedesktop.org Tue Mar 3 18:59:31 2015 From: chadversary at kemper.freedesktop.org (Chad Versace) Date: Tue, 3 Mar 2015 10:59:31 -0800 (PST) Subject: Mesa (master): intel: fix EGLImage renderbuffer _BaseFormat Message-ID: <20150303185931.B44BA76333@kemper.freedesktop.org> Module: Mesa Branch: master Commit: e43729943e67972e547a19123fb3afca6b77202b URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=e43729943e67972e547a19123fb3afca6b77202b Author: Frank Henigman Date: Thu Feb 19 15:09:20 2015 -0800 intel: fix EGLImage renderbuffer _BaseFormat Correctly set _BaseFormat field when creating a gl_renderbuffer with EGLImage storage. Change-Id: I8c9f7302d18b617f54fa68304d8ffee087ed8a77 Signed-off-by: Frank Henigman Reviewed-by: St?phane Marchesin Reviewed-by: Chad Versace --- src/mesa/drivers/dri/i915/intel_fbo.c | 3 +-- src/mesa/drivers/dri/i965/intel_fbo.c | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/mesa/drivers/dri/i915/intel_fbo.c b/src/mesa/drivers/dri/i915/intel_fbo.c index 1e1397d..8ce1dbf 100644 --- a/src/mesa/drivers/dri/i915/intel_fbo.c +++ b/src/mesa/drivers/dri/i915/intel_fbo.c @@ -287,8 +287,7 @@ intel_image_target_renderbuffer_storage(struct gl_context *ctx, rb->Width = image->region->width; rb->Height = image->region->height; rb->Format = image->format; - rb->_BaseFormat = _mesa_base_fbo_format(&intel->ctx, - image->internal_format); + rb->_BaseFormat = _mesa_get_format_base_format(image->format); rb->NeedsFinishRenderTexture = true; } diff --git a/src/mesa/drivers/dri/i965/intel_fbo.c b/src/mesa/drivers/dri/i965/intel_fbo.c index 04e5030..90fd064 100644 --- a/src/mesa/drivers/dri/i965/intel_fbo.c +++ b/src/mesa/drivers/dri/i965/intel_fbo.c @@ -398,7 +398,7 @@ intel_image_target_renderbuffer_storage(struct gl_context *ctx, rb->Width = image->width; rb->Height = image->height; rb->Format = image->format; - rb->_BaseFormat = _mesa_base_fbo_format(ctx, image->internal_format); + rb->_BaseFormat = _mesa_get_format_base_format(image->format); rb->NeedsFinishRenderTexture = true; irb->layer_count = 1; } From vlee at kemper.freedesktop.org Wed Mar 4 01:30:10 2015 From: vlee at kemper.freedesktop.org (Vinson Lee) Date: Tue, 3 Mar 2015 17:30:10 -0800 (PST) Subject: Mesa (master): scons: Define _DEFAULT_SOURCE. Message-ID: <20150304013010.7252476333@kemper.freedesktop.org> Module: Mesa Branch: master Commit: b77576edc1a8010e5457f82b41c335ae27cb066b URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=b77576edc1a8010e5457f82b41c335ae27cb066b Author: Vinson Lee Date: Sun Mar 1 00:41:48 2015 -0800 scons: Define _DEFAULT_SOURCE. Fix GCC cpp warnings with glibc >= 2.19. /usr/include/features.h:148:3: warning: #warning "_BSD_SOURCE and _SVID_SOURCE are deprecated, use _DEFAULT_SOURCE" [-Wcpp] # warning "_BSD_SOURCE and _SVID_SOURCE are deprecated, use _DEFAULT_SOURCE" ^ Signed-off-by: Vinson Lee Acked-by: Emil Velikov --- scons/gallium.py | 1 + 1 file changed, 1 insertion(+) diff --git a/scons/gallium.py b/scons/gallium.py index 711aa3b..c34468f 100755 --- a/scons/gallium.py +++ b/scons/gallium.py @@ -283,6 +283,7 @@ def generate(env): '_SVID_SOURCE', '_BSD_SOURCE', '_GNU_SOURCE', + '_DEFAULT_SOURCE', 'HAVE_PTHREAD', 'HAVE_POSIX_MEMALIGN', ] From evelikov at kemper.freedesktop.org Wed Mar 4 02:02:53 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Tue, 3 Mar 2015 18:02:53 -0800 (PST) Subject: Mesa (10.4): install-lib-links: don't depend on .libs directory Message-ID: <20150304020253.275C276333@kemper.freedesktop.org> Module: Mesa Branch: 10.4 Commit: deea686c71147665ccea990630180379404badce URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=deea686c71147665ccea990630180379404badce Author: Lucas Stach Date: Thu Feb 19 14:52:49 2015 +0100 install-lib-links: don't depend on .libs directory This snippet can be included in Makefiles that may, depending on the project configuration, not actually build any installable libraries. In that case we don't have anything to depend on and this part of the makefile may be executed before the .libs directory is created, so do not depend on it being there. Cc: "10.3 10.4 10.5" Reviewed-by: Matt Turner Signed-off-by: Lucas Stach (cherry picked from commit 5c1aac17adffeef9bb6171d83cc7ddd94c61c5f2) --- install-lib-links.mk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/install-lib-links.mk b/install-lib-links.mk index 5ea73853..1893457 100644 --- a/install-lib-links.mk +++ b/install-lib-links.mk @@ -3,9 +3,9 @@ if BUILD_SHARED if HAVE_COMPAT_SYMLINKS -all-local : .libs/install-mesa-links +all-local : .install-mesa-links -.libs/install-mesa-links : $(lib_LTLIBRARIES) +.install-mesa-links : $(lib_LTLIBRARIES) $(AM_V_GEN)$(MKDIR_P) $(top_builddir)/$(LIB_DIR); \ for f in $(join $(addsuffix .libs/,$(dir $(lib_LTLIBRARIES))),$(notdir $(lib_LTLIBRARIES:%.la=%.$(LIB_EXT)*))); do \ if test -h .libs/$$f; then \ From evelikov at kemper.freedesktop.org Wed Mar 4 02:02:53 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Tue, 3 Mar 2015 18:02:53 -0800 (PST) Subject: Mesa (10.4): st/mesa: fix sampler view reference counting bug in glDraw/ CopyPixels Message-ID: <20150304020253.40CE276333@kemper.freedesktop.org> Module: Mesa Branch: 10.4 Commit: 7e57411b9ab0b844292544534367d2633a8d94ec URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=7e57411b9ab0b844292544534367d2633a8d94ec Author: Brian Paul Date: Wed Feb 18 11:16:55 2015 -0700 st/mesa: fix sampler view reference counting bug in glDraw/CopyPixels Use pipe_sampler_view_reference() instead of ordinary assignment. Also add a new sanity check assertion. Fixes piglit gl-1.0-drawpixels-color-index test crash. But note that the test still fails. Cc: "10.4, 10.5" Reviewed-by: Ilia Mirkin (cherry picked from commit 62a8883f32f8a4c8c7d85390d4b17986e4018edf) --- src/mesa/state_tracker/st_cb_drawpixels.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c index 5ae092b..e82bed5 100644 --- a/src/mesa/state_tracker/st_cb_drawpixels.c +++ b/src/mesa/state_tracker/st_cb_drawpixels.c @@ -1102,7 +1102,7 @@ st_DrawPixels(struct gl_context *ctx, GLint x, GLint y, const GLfloat *color; struct pipe_context *pipe = st->pipe; GLboolean write_stencil = GL_FALSE, write_depth = GL_FALSE; - struct pipe_sampler_view *sv[2]; + struct pipe_sampler_view *sv[2] = { NULL }; int num_sampler_view = 1; struct st_fp_variant *fpv; struct gl_pixelstore_attrib clippedUnpack; @@ -1156,8 +1156,9 @@ st_DrawPixels(struct gl_context *ctx, GLint x, GLint y, color = NULL; if (st->pixel_xfer.pixelmap_enabled) { - sv[1] = st->pixel_xfer.pixelmap_sampler_view; - num_sampler_view++; + pipe_sampler_view_reference(&sv[1], + st->pixel_xfer.pixelmap_sampler_view); + num_sampler_view++; } } @@ -1178,7 +1179,8 @@ st_DrawPixels(struct gl_context *ctx, GLint x, GLint y, if (write_stencil) { enum pipe_format stencil_format = util_format_stencil_only(pt->format); - + /* we should not be doing pixel map/transfer (see above) */ + assert(num_sampler_view == 1); sv[1] = st_create_texture_sampler_view_format(st->pipe, pt, stencil_format); num_sampler_view++; @@ -1469,7 +1471,7 @@ st_CopyPixels(struct gl_context *ctx, GLint srcx, GLint srcy, struct st_renderbuffer *rbRead; void *driver_vp, *driver_fp; struct pipe_resource *pt; - struct pipe_sampler_view *sv[2]; + struct pipe_sampler_view *sv[2] = { NULL }; int num_sampler_view = 1; GLfloat *color; enum pipe_format srcFormat; @@ -1518,7 +1520,8 @@ st_CopyPixels(struct gl_context *ctx, GLint srcx, GLint srcy, driver_vp = make_passthrough_vertex_shader(st, GL_FALSE); if (st->pixel_xfer.pixelmap_enabled) { - sv[1] = st->pixel_xfer.pixelmap_sampler_view; + pipe_sampler_view_reference(&sv[1], + st->pixel_xfer.pixelmap_sampler_view); num_sampler_view++; } } From evelikov at kemper.freedesktop.org Wed Mar 4 02:02:53 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Tue, 3 Mar 2015 18:02:53 -0800 (PST) Subject: Mesa (10.4): swrast: fix multiple color buffer writing Message-ID: <20150304020253.341F176333@kemper.freedesktop.org> Module: Mesa Branch: 10.4 Commit: 1e6735ead144ce7ddfeb37e3df7b7f8526eb1577 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=1e6735ead144ce7ddfeb37e3df7b7f8526eb1577 Author: Brian Paul Date: Mon Feb 16 11:23:06 2015 -0700 swrast: fix multiple color buffer writing If a fragment program wrote to more than one color buffer, the first fragment color got replicated to all dest buffers. This fixes 5 piglit FBO tests, including fbo-drawbuffers-arbfp. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=45348 Cc: "10.4, 10.5" Reviewed-by: Eric Anholt (cherry picked from commit 89c96afe3c0acf8f2fccaf02da02945afe8ba5f3) --- src/mesa/swrast/s_span.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/src/mesa/swrast/s_span.c b/src/mesa/swrast/s_span.c index 10aa33c..95cf5a6 100644 --- a/src/mesa/swrast/s_span.c +++ b/src/mesa/swrast/s_span.c @@ -932,19 +932,19 @@ clamp_colors(SWspan *span) * \param output which fragment program color output is being processed */ static inline void -convert_color_type(SWspan *span, GLenum newType, GLuint output) +convert_color_type(SWspan *span, GLenum srcType, GLenum newType, GLuint output) { GLvoid *src, *dst; - if (output > 0 || span->array->ChanType == GL_FLOAT) { + if (output > 0 || srcType == GL_FLOAT) { src = span->array->attribs[VARYING_SLOT_COL0 + output]; span->array->ChanType = GL_FLOAT; } - else if (span->array->ChanType == GL_UNSIGNED_BYTE) { + else if (srcType == GL_UNSIGNED_BYTE) { src = span->array->rgba8; } else { - ASSERT(span->array->ChanType == GL_UNSIGNED_SHORT); + ASSERT(srcType == GL_UNSIGNED_SHORT); src = span->array->rgba16; } @@ -978,7 +978,7 @@ shade_texture_span(struct gl_context *ctx, SWspan *span) ctx->ATIFragmentShader._Enabled) { /* programmable shading */ if (span->primitive == GL_BITMAP && span->array->ChanType != GL_FLOAT) { - convert_color_type(span, GL_FLOAT, 0); + convert_color_type(span, span->array->ChanType, GL_FLOAT, 0); } else { span->array->rgba = (void *) span->array->attribs[VARYING_SLOT_COL0]; @@ -1313,6 +1313,8 @@ _swrast_write_rgba_span( struct gl_context *ctx, SWspan *span) const GLboolean multiFragOutputs = _swrast_use_fragment_program(ctx) && fp->Base.OutputsWritten >= (1 << FRAG_RESULT_DATA0); + /* Save srcColorType because convert_color_type() can change it */ + const GLenum srcColorType = span->array->ChanType; GLuint buf; for (buf = 0; buf < numBuffers; buf++) { @@ -1324,17 +1326,18 @@ _swrast_write_rgba_span( struct gl_context *ctx, SWspan *span) /* re-use one of the attribute array buffers for rgbaSave */ GLchan (*rgbaSave)[4] = (GLchan (*)[4]) span->array->attribs[0]; struct swrast_renderbuffer *srb = swrast_renderbuffer(rb); - GLenum colorType = srb->ColorType; + const GLenum dstColorType = srb->ColorType; - assert(colorType == GL_UNSIGNED_BYTE || - colorType == GL_FLOAT); + assert(dstColorType == GL_UNSIGNED_BYTE || + dstColorType == GL_FLOAT); /* set span->array->rgba to colors for renderbuffer's datatype */ - if (span->array->ChanType != colorType) { - convert_color_type(span, colorType, 0); + if (srcColorType != dstColorType) { + convert_color_type(span, srcColorType, dstColorType, + multiFragOutputs ? buf : 0); } else { - if (span->array->ChanType == GL_UNSIGNED_BYTE) { + if (srcColorType == GL_UNSIGNED_BYTE) { span->array->rgba = span->array->rgba8; } else { From evelikov at kemper.freedesktop.org Wed Mar 4 02:02:53 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Tue, 3 Mar 2015 18:02:53 -0800 (PST) Subject: Mesa (10.4): mesa: Fix error validating args for TexSubImage3D Message-ID: <20150304020253.6451476333@kemper.freedesktop.org> Module: Mesa Branch: 10.4 Commit: 39ae85732d29906ea2a16dfdfc77f8e5dbed5853 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=39ae85732d29906ea2a16dfdfc77f8e5dbed5853 Author: Eduardo Lima Mitev Date: Mon Feb 2 18:14:47 2015 +0100 mesa: Fix error validating args for TexSubImage3D The zoffset and depth values were not being considered when calling error_check_subtexture_dimensions(). Fixes 2 dEQP tests: * dEQP-GLES3.functional.negative_api.texture.texsubimage3d_neg_offset * dEQP-GLES3.functional.negative_api.texture.texsubimage3d_invalid_offset Reviewed-by: Brian Paul Reviewed-by: Ian Romanick Cc: "10.4 10.5" (cherry picked from commit 2aa71e9485a5a062b1bd2dd8bdc081a8fa4c873d) [Emil Velikov: Resolve trivial conflicts] Signed-off-by: Emil Velikov Conflicts: src/mesa/main/teximage.c --- src/mesa/main/teximage.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c index 7766904..3c494be 100644 --- a/src/mesa/main/teximage.c +++ b/src/mesa/main/teximage.c @@ -2497,7 +2497,7 @@ texsubimage_error_check(struct gl_context *ctx, GLuint dimensions, } if (error_check_subtexture_dimensions(ctx, "glTexSubImage", dimensions, - texImage, xoffset, yoffset, 0, + texImage, xoffset, yoffset, zoffset, width, height, 1)) { return GL_TRUE; } From evelikov at kemper.freedesktop.org Wed Mar 4 02:02:53 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Tue, 3 Mar 2015 18:02:53 -0800 (PST) Subject: Mesa (10.4): install-lib-links: remove the .install-lib-links file Message-ID: <20150304020253.6EAB476333@kemper.freedesktop.org> Module: Mesa Branch: 10.4 Commit: 120792fa04e67da1042583cb4dfbe901bad618d9 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=120792fa04e67da1042583cb4dfbe901bad618d9 Author: Emil Velikov Date: Tue Feb 24 14:05:15 2015 +0000 install-lib-links: remove the .install-lib-links file With earlier commit (install-lib-links: don't depend on .libs directory) we moved the location of the file from .libs/ to the current dir. Although we did not attribute that in the former case autotools was doing us a favour and removing the file. Explicitly remove the file at clean-local time, otherwise we'll end up with dangling files. Cc: "10.3 10.4 10.5" Cc: Matt Turner Cc: Lucas Stach Signed-off-by: Emil Velikov (cherry picked from commit fece147be53880ac8e8e5e2863f91cdd01d98b5c) --- install-lib-links.mk | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/install-lib-links.mk b/install-lib-links.mk index 1893457..860f93c 100644 --- a/install-lib-links.mk +++ b/install-lib-links.mk @@ -14,5 +14,9 @@ all-local : .install-mesa-links ln -f $$f $(top_builddir)/$(LIB_DIR); \ fi; \ done && touch $@ + +clean-local: + $(RM) .install-mesa-links + endif endif From evelikov at kemper.freedesktop.org Wed Mar 4 02:02:53 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Tue, 3 Mar 2015 18:02:53 -0800 (PST) Subject: Mesa (10.4): st/omx/dec/h264: fix picture out-of-order with poc type 0 v2 Message-ID: <20150304020253.7A1B276333@kemper.freedesktop.org> Module: Mesa Branch: 10.4 Commit: 2a9e9b5aeb378f218b147fc6303351ba1d9208f5 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=2a9e9b5aeb378f218b147fc6303351ba1d9208f5 Author: Leo Liu Date: Mon Feb 23 13:50:06 2015 -0500 st/omx/dec/h264: fix picture out-of-order with poc type 0 v2 poc counter should be reset with IDR frame, otherwise there would be a re-order issue with frames before and after IDR v2: add commit message Signed-off-by: Leo Liu Reviewed-by: Christian K?nig Cc: "10.4 10.5" (cherry picked from commit 9c7b343bc0a6aa6065055cbc1c0a891ccc445984) --- src/gallium/state_trackers/omx/vid_dec_h264.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/gallium/state_trackers/omx/vid_dec_h264.c b/src/gallium/state_trackers/omx/vid_dec_h264.c index 7b57785..e01e873 100644 --- a/src/gallium/state_trackers/omx/vid_dec_h264.c +++ b/src/gallium/state_trackers/omx/vid_dec_h264.c @@ -706,6 +706,11 @@ static void slice_header(vid_dec_PrivateType *priv, struct vl_rbsp *rbsp, if (pic_order_cnt_lsb != priv->codec_data.h264.pic_order_cnt_lsb) vid_dec_h264_EndFrame(priv); + if (IdrPicFlag) { + priv->codec_data.h264.pic_order_cnt_msb = 0; + priv->codec_data.h264.pic_order_cnt_lsb = 0; + } + if ((pic_order_cnt_lsb < priv->codec_data.h264.pic_order_cnt_lsb) && (priv->codec_data.h264.pic_order_cnt_lsb - pic_order_cnt_lsb) >= (max_pic_order_cnt_lsb / 2)) pic_order_cnt_msb = priv->codec_data.h264.pic_order_cnt_msb + max_pic_order_cnt_lsb; From evelikov at kemper.freedesktop.org Wed Mar 4 02:02:53 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Tue, 3 Mar 2015 18:02:53 -0800 (PST) Subject: Mesa (10.4): glsl: Rewrite and fix min/max to saturate optimization. Message-ID: <20150304020253.8F7BC76333@kemper.freedesktop.org> Module: Mesa Branch: 10.4 Commit: 7e723c98cedd5446f5481077925ef2346d5ab47e URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=7e723c98cedd5446f5481077925ef2346d5ab47e Author: Matt Turner Date: Tue Feb 24 10:41:52 2015 -0800 glsl: Rewrite and fix min/max to saturate optimization. There were some bugs, and the code was really difficult to follow. We would optimize min(max(x, b), 1.0) into max(sat(x), b) but not pay attention to the order of min/max and also do max(min(x, b), 1.0) into max(sat(x), b) Corrects four shaders from Champions of Regnum that do min(max(x, 1), 10) and corrects rendering of Mass Effect under VMware Workstation. Cc: "10.4 10.5" Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=89180 Reviewed-by: Abdiel Janulgue Reviewed-by: Ian Romanick (cherry picked from commit cb25087c7bd5f1ad2515647278b32d3f07803f77) --- src/glsl/opt_algebraic.cpp | 75 +++++++++++++++++++++++++++----------------- 1 file changed, 46 insertions(+), 29 deletions(-) diff --git a/src/glsl/opt_algebraic.cpp b/src/glsl/opt_algebraic.cpp index 430f5cb..33e94c4 100644 --- a/src/glsl/opt_algebraic.cpp +++ b/src/glsl/opt_algebraic.cpp @@ -686,48 +686,65 @@ ir_algebraic_visitor::handle_expression(ir_expression *ir) * a saturate operation */ for (int op = 0; op < 2; op++) { - ir_expression *minmax = op_expr[op]; + ir_expression *inner_expr = op_expr[op]; ir_constant *outer_const = op_const[1 - op]; ir_expression_operation op_cond = (ir->operation == ir_binop_max) ? ir_binop_min : ir_binop_max; - if (!minmax || !outer_const || (minmax->operation != op_cond)) + if (!inner_expr || !outer_const || (inner_expr->operation != op_cond)) continue; + /* One of these has to be a constant */ + if (!inner_expr->operands[0]->as_constant() && + !inner_expr->operands[1]->as_constant()) + break; + /* Found a min(max) combination. Now try to see if its operands * meet our conditions that we can do just a single saturate operation */ for (int minmax_op = 0; minmax_op < 2; minmax_op++) { - ir_rvalue *inner_val_a = minmax->operands[minmax_op]; - ir_rvalue *inner_val_b = minmax->operands[1 - minmax_op]; + ir_rvalue *x = inner_expr->operands[minmax_op]; + ir_rvalue *y = inner_expr->operands[1 - minmax_op]; - if (!inner_val_a || !inner_val_b) + ir_constant *inner_const = y->as_constant(); + if (!inner_const) continue; - /* Found a {min|max} ({max|min} (x, 0.0), 1.0) operation and its variations */ - if ((outer_const->is_one() && inner_val_a->is_zero()) || - (inner_val_a->is_one() && outer_const->is_zero())) - return saturate(inner_val_b); - - /* Found a {min|max} ({max|min} (x, 0.0), b) where b < 1.0 - * and its variations - */ - if (is_less_than_one(outer_const) && inner_val_b->is_zero()) - return expr(ir_binop_min, saturate(inner_val_a), outer_const); - - if (!inner_val_b->as_constant()) - continue; - - if (is_less_than_one(inner_val_b->as_constant()) && outer_const->is_zero()) - return expr(ir_binop_min, saturate(inner_val_a), inner_val_b); - - /* Found a {min|max} ({max|min} (x, b), 1.0), where b > 0.0 - * and its variations - */ - if (outer_const->is_one() && is_greater_than_zero(inner_val_b->as_constant())) - return expr(ir_binop_max, saturate(inner_val_a), inner_val_b); - if (inner_val_b->as_constant()->is_one() && is_greater_than_zero(outer_const)) - return expr(ir_binop_max, saturate(inner_val_a), outer_const); + /* min(max(x, 0.0), 1.0) is sat(x) */ + if (ir->operation == ir_binop_min && + inner_const->is_zero() && + outer_const->is_one()) + return saturate(x); + + /* max(min(x, 1.0), 0.0) is sat(x) */ + if (ir->operation == ir_binop_max && + inner_const->is_one() && + outer_const->is_zero()) + return saturate(x); + + /* min(max(x, 0.0), b) where b < 1.0 is sat(min(x, b)) */ + if (ir->operation == ir_binop_min && + inner_const->is_zero() && + is_less_than_one(outer_const)) + return saturate(expr(ir_binop_min, x, outer_const)); + + /* max(min(x, b), 0.0) where b < 1.0 is sat(min(x, b)) */ + if (ir->operation == ir_binop_max && + is_less_than_one(inner_const) && + outer_const->is_zero()) + return saturate(expr(ir_binop_min, x, inner_const)); + + /* max(min(x, 1.0), b) where b > 0.0 is sat(max(x, b)) */ + if (ir->operation == ir_binop_max && + inner_const->is_one() && + is_greater_than_zero(outer_const)) + return saturate(expr(ir_binop_max, x, outer_const)); + + /* min(max(x, b), 1.0) where b > 0.0 is sat(max(x, b)) */ + if (ir->operation == ir_binop_min && + is_greater_than_zero(inner_const) && + outer_const->is_one()) + return saturate(expr(ir_binop_max, x, inner_const)); } } From evelikov at kemper.freedesktop.org Wed Mar 4 02:02:53 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Tue, 3 Mar 2015 18:02:53 -0800 (PST) Subject: Mesa (10.4): auxilary/os: correct sysctl use in os_get_total_physical_memory() Message-ID: <20150304020253.998D876333@kemper.freedesktop.org> Module: Mesa Branch: 10.4 Commit: da46b1b160cc56e908f058b0e11c129aa3a66704 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=da46b1b160cc56e908f058b0e11c129aa3a66704 Author: Jonathan Gray Date: Sun Feb 22 19:19:25 2015 +1100 auxilary/os: correct sysctl use in os_get_total_physical_memory() The length argument passed to sysctl was the size of the pointer not the type. The result of this is sysctl calls would fail on 32 bit BSD/Mac OS X. Additionally the wrong pointer was passed as an argument to store the result of the sysctl call. Cc: "10.4, 10.5" Signed-off-by: Jonathan Gray Reviewed-by: Emil Velikov (cherry picked from commit 7983a3d2e06b0bc16c1a16bddccc7f14fe1f132c) --- src/gallium/auxiliary/os/os_misc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gallium/auxiliary/os/os_misc.c b/src/gallium/auxiliary/os/os_misc.c index ebf033c..c46078b 100644 --- a/src/gallium/auxiliary/os/os_misc.c +++ b/src/gallium/auxiliary/os/os_misc.c @@ -118,7 +118,7 @@ os_get_total_physical_memory(uint64_t *size) *size = phys_pages * page_size; return (phys_pages > 0 && page_size > 0); #elif defined(PIPE_OS_APPLE) || defined(PIPE_OS_BSD) - size_t len = sizeof(size); + size_t len = sizeof(*size); int mib[2]; mib[0] = CTL_HW; @@ -134,7 +134,7 @@ os_get_total_physical_memory(uint64_t *size) #error Unsupported *BSD #endif - return (sysctl(mib, 2, &size, &len, NULL, 0) == 0); + return (sysctl(mib, 2, size, &len, NULL, 0) == 0); #elif defined(PIPE_OS_HAIKU) system_info info; status_t ret; From evelikov at kemper.freedesktop.org Wed Mar 4 02:02:53 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Tue, 3 Mar 2015 18:02:53 -0800 (PST) Subject: Mesa (10.4): i965/fs: Don't use backend_visitor:: instructions after creating the CFG. Message-ID: <20150304020253.BC9DC76333@kemper.freedesktop.org> Module: Mesa Branch: 10.4 Commit: 741aeba26f618d9df04da4fed8a3123174a81e2e URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=741aeba26f618d9df04da4fed8a3123174a81e2e Author: Matt Turner Date: Tue Jan 13 15:35:57 2015 -0800 i965/fs: Don't use backend_visitor::instructions after creating the CFG. This is a fix for a regression introduced in commit a9f8296d ("i965/fs: Preserve the CFG in a few more places."). The errata this code works around is described in a comment before the function: "[DevBW, DevCL] Errata: A destination register from a send can not be used as a destination register until after it has been sourced by an instruction with a different destination register. The framebuffer write's sources must be in message registers, which SEND instructions cannot have as a destination. There's no way for this errata to affect anything at the end of the program. Just remove the code. Cc: 10.4, 10.5 Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=84613 Reviewed-by: Kenneth Graunke (cherry picked from commit e214000f258ae564e64d839cccee9418526f226b) --- src/mesa/drivers/dri/i965/brw_fs.cpp | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp index ef6e6e7..57ca39d 100644 --- a/src/mesa/drivers/dri/i965/brw_fs.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs.cpp @@ -2842,16 +2842,6 @@ fs_visitor::insert_gen4_post_send_dependency_workarounds(bblock_t *block, fs_ins if (i == write_len) return; } - - /* If we hit the end of the program, resolve all remaining dependencies out - * of paranoia. - */ - fs_inst *last_inst = (fs_inst *)this->instructions.get_tail(); - assert(last_inst->eot); - for (int i = 0; i < write_len; i++) { - if (needs_dep[i]) - last_inst->insert_before(block, DEP_RESOLVE_MOV(first_write_grf + i)); - } } void From evelikov at kemper.freedesktop.org Wed Mar 4 02:02:53 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Tue, 3 Mar 2015 18:02:53 -0800 (PST) Subject: Mesa (10.4): vbo: fix an unitialized-variable warning Message-ID: <20150304020253.4C5C076333@kemper.freedesktop.org> Module: Mesa Branch: 10.4 Commit: 6da4e66d4e1785d37ed06007a8804d955ddab9f6 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=6da4e66d4e1785d37ed06007a8804d955ddab9f6 Author: Marek Ol??k Date: Fri Feb 20 20:17:39 2015 +0100 vbo: fix an unitialized-variable warning It looks like a bug to me. Cc: 10.5 10.4 10.3 Reviewed-by: Brian Paul (cherry picked from commit 0feb0b73731cebd1513dd7f4e6cdf6de81edb802) --- src/mesa/vbo/vbo_attrib_tmp.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/mesa/vbo/vbo_attrib_tmp.h b/src/mesa/vbo/vbo_attrib_tmp.h index ec66934..0c44540 100644 --- a/src/mesa/vbo/vbo_attrib_tmp.h +++ b/src/mesa/vbo/vbo_attrib_tmp.h @@ -210,6 +210,7 @@ static inline float conv_i2_to_norm_float(const struct gl_context *ctx, int i2) } \ } else if ((type) == GL_UNSIGNED_INT_10F_11F_11F_REV) { \ float res[4]; \ + res[3] = 1; \ r11g11b10f_to_float3((arg), res); \ ATTR##val##FV((attr), res); \ } else \ From evelikov at kemper.freedesktop.org Wed Mar 4 02:02:53 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Tue, 3 Mar 2015 18:02:53 -0800 (PST) Subject: Mesa (10.4): radeonsi: fix point sprites Message-ID: <20150304020253.5783276333@kemper.freedesktop.org> Module: Mesa Branch: 10.4 Commit: 61c1aabb9f25a6e0710ab6a49a9fb889c4fa7752 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=61c1aabb9f25a6e0710ab6a49a9fb889c4fa7752 Author: Marek Ol??k Date: Mon Feb 23 11:39:53 2015 +0100 radeonsi: fix point sprites Broken by a27b74819ad375e8c0bc88e13f42c951d2b5cd6a. This fix is critical and should be ported to stable ASAP. Cc: 10.5 10.4 (cherry picked from commit 7820a11e3dea2aca8e2b9b4ed9faf94ff5696990) Squashed with commit radeonsi: fix a warning caused by previous commit Cc: 10.5 10.4 (cherry picked from commit 050bf75c8bbaa7cad537aabaf8612129edfee3a4) [Emil Velikov: The file was renamed si_state_{shaders,draw}.c] Signed-off-by: Emil Velikov Conflicts: src/gallium/drivers/radeonsi/si_state_shader.c --- src/gallium/drivers/radeonsi/si_state_draw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gallium/drivers/radeonsi/si_state_draw.c b/src/gallium/drivers/radeonsi/si_state_draw.c index c85b1cc..137394f 100644 --- a/src/gallium/drivers/radeonsi/si_state_draw.c +++ b/src/gallium/drivers/radeonsi/si_state_draw.c @@ -544,7 +544,7 @@ bcolor: } } - if (j == vsinfo->num_outputs) { + if (j == vsinfo->num_outputs && !G_028644_PT_SPRITE_TEX(tmp)) { /* No corresponding output found, load defaults into input. * Don't set any other bits. * (FLAT_SHADE=1 completely changes behavior) */ From evelikov at kemper.freedesktop.org Wed Mar 4 02:02:53 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Tue, 3 Mar 2015 18:02:53 -0800 (PST) Subject: Mesa (10.4): glx: Fix returned values of GLX_RENDERER_PREFERRED_PROFILE_MESA Message-ID: <20150304020253.8420F76333@kemper.freedesktop.org> Module: Mesa Branch: 10.4 Commit: 0a51529a2880947f0e954b0fe20d854734782d22 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=0a51529a2880947f0e954b0fe20d854734782d22 Author: Andreas Boll Date: Tue Feb 24 20:01:30 2015 +0100 glx: Fix returned values of GLX_RENDERER_PREFERRED_PROFILE_MESA If the renderer supports the core profile the query returned incorrectly 0x8 as value, because it was using (1U << __DRI_API_OPENGL_CORE) for the returned value. The same happened with the compatibility profile. It returned 0x1 (1U << __DRI_API_OPENGL) instead of 0x2. Internal DRI defines: dri_interface.h: #define __DRI_API_OPENGL 0 dri_interface.h: #define __DRI_API_OPENGL_CORE 3 Those two bits are supposed for internal usage only and should be translated to GLX_CONTEXT_CORE_PROFILE_BIT_ARB (0x1) for a preferred core context profile and GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB (0x2) for a preferred compatibility context profile. This patch implements the above translation in the glx module. v2: Fix the incorrect behavior in the glx module Cc: "10.3 10.4 10.5" Signed-off-by: Andreas Boll Reviewed-by: Ian Romanick (cherry picked from commit 6d164f65c5a794164d07bc66c1f8f87280514e8c) --- src/glx/dri_common_query_renderer.c | 36 +++++++++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/src/glx/dri_common_query_renderer.c b/src/glx/dri_common_query_renderer.c index d598b12..b3e107d 100644 --- a/src/glx/dri_common_query_renderer.c +++ b/src/glx/dri_common_query_renderer.c @@ -65,10 +65,23 @@ dri2_convert_glx_query_renderer_attribs(int attribute) return -1; } +/* Convert internal dri context profile bits into GLX context profile bits */ +static inline void +dri_convert_context_profile_bits(int attribute, unsigned int *value) +{ + if (attribute == GLX_RENDERER_PREFERRED_PROFILE_MESA) { + if (value[0] == (1U << __DRI_API_OPENGL_CORE)) + value[0] = GLX_CONTEXT_CORE_PROFILE_BIT_ARB; + else if (value[0] == (1U << __DRI_API_OPENGL)) + value[0] = GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB; + } +} + _X_HIDDEN int dri2_query_renderer_integer(struct glx_screen *base, int attribute, unsigned int *value) { + int ret; struct dri2_screen *const psc = (struct dri2_screen *) base; /* Even though there are invalid values (and @@ -81,8 +94,11 @@ dri2_query_renderer_integer(struct glx_screen *base, int attribute, if (psc->rendererQuery == NULL) return -1; - return psc->rendererQuery->queryInteger(psc->driScreen, dri_attribute, - value); + ret = psc->rendererQuery->queryInteger(psc->driScreen, dri_attribute, + value); + dri_convert_context_profile_bits(attribute, value); + + return ret; } _X_HIDDEN int @@ -108,6 +124,7 @@ _X_HIDDEN int dri3_query_renderer_integer(struct glx_screen *base, int attribute, unsigned int *value) { + int ret; struct dri3_screen *const psc = (struct dri3_screen *) base; /* Even though there are invalid values (and @@ -120,8 +137,11 @@ dri3_query_renderer_integer(struct glx_screen *base, int attribute, if (psc->rendererQuery == NULL) return -1; - return psc->rendererQuery->queryInteger(psc->driScreen, dri_attribute, - value); + ret = psc->rendererQuery->queryInteger(psc->driScreen, dri_attribute, + value); + dri_convert_context_profile_bits(attribute, value); + + return ret; } _X_HIDDEN int @@ -147,6 +167,7 @@ _X_HIDDEN int drisw_query_renderer_integer(struct glx_screen *base, int attribute, unsigned int *value) { + int ret; struct drisw_screen *const psc = (struct drisw_screen *) base; /* Even though there are invalid values (and @@ -159,8 +180,11 @@ drisw_query_renderer_integer(struct glx_screen *base, int attribute, if (psc->rendererQuery == NULL) return -1; - return psc->rendererQuery->queryInteger(psc->driScreen, dri_attribute, - value); + ret = psc->rendererQuery->queryInteger(psc->driScreen, dri_attribute, + value); + dri_convert_context_profile_bits(attribute, value); + + return ret; } _X_HIDDEN int From evelikov at kemper.freedesktop.org Wed Mar 4 02:02:53 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Tue, 3 Mar 2015 18:02:53 -0800 (PST) Subject: Mesa (10.4): i965/gs: Check newly-generated GS-out VUE map against correct stage Message-ID: <20150304020253.A42C776333@kemper.freedesktop.org> Module: Mesa Branch: 10.4 Commit: 0c46d850d9f154c69258782f219e1705bb90a68c URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=0c46d850d9f154c69258782f219e1705bb90a68c Author: Chris Forbes Date: Sat Feb 28 19:57:20 2015 +1300 i965/gs: Check newly-generated GS-out VUE map against correct stage Previously, we compared our new GS-out VUE map to the existing *VS*-out VUE map, which is bogus. This would mostly manifest as redundant dirty flagging where the GS is in use but the VS and GS output layouts differ; but there is a scary case where we would fail to flag a GS-out layout change if it happened to match the VS-out layout. Signed-off-by: Chris Forbes Cc: "10.5, 10.4" Reviewed-by: Matt Turner Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=88885 (cherry picked from commit b51ff50a767cc78d678ed3d2c25995f5c4194fea) --- src/mesa/drivers/dri/i965/brw_gs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesa/drivers/dri/i965/brw_gs.c b/src/mesa/drivers/dri/i965/brw_gs.c index f44ac26..fb968cf 100644 --- a/src/mesa/drivers/dri/i965/brw_gs.c +++ b/src/mesa/drivers/dri/i965/brw_gs.c @@ -354,7 +354,7 @@ brw_upload_gs_prog(struct brw_context *brw) } brw->gs.base.prog_data = &brw->gs.prog_data->base.base; - if (memcmp(&brw->vs.prog_data->base.vue_map, &brw->vue_map_geom_out, + if (memcmp(&brw->gs.prog_data->base.vue_map, &brw->vue_map_geom_out, sizeof(brw->vue_map_geom_out)) != 0) { brw->vue_map_geom_out = brw->gs.prog_data->base.vue_map; brw->state.dirty.brw |= BRW_NEW_VUE_MAP_GEOM_OUT; From evelikov at kemper.freedesktop.org Wed Mar 4 02:02:53 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Tue, 3 Mar 2015 18:02:53 -0800 (PST) Subject: Mesa (10.4): mesa: Correct backwards NULL check. Message-ID: <20150304020253.AFEE676333@kemper.freedesktop.org> Module: Mesa Branch: 10.4 Commit: a598a9bdfe9f5d0ed35ca89a55cf74a2b678e8e1 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=a598a9bdfe9f5d0ed35ca89a55cf74a2b678e8e1 Author: Matt Turner Date: Sat Feb 28 11:14:02 2015 -0800 mesa: Correct backwards NULL check. Cc: "10.4, 10.5" Reviewed-by: Emil Velikov Reviewed-by: Ian Romanick (cherry picked from commit 491d42135ad0e5670756216154f2ba9fc79d4ba7) [Emil Velikov: the patch hunk has a different offset.] Signed-off-by: Emil Velikov Conflicts: src/mesa/main/shaderapi.c --- src/mesa/main/shaderapi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c index 6657820..94f6b76 100644 --- a/src/mesa/main/shaderapi.c +++ b/src/mesa/main/shaderapi.c @@ -1704,7 +1704,7 @@ _mesa_GetProgramBinary(GLuint program, GLsizei bufSize, GLsizei *length, * * "If is NULL, then no length is returned." */ - if (length != NULL) + if (length == NULL) *length = 0; (void) binaryFormat; From evelikov at kemper.freedesktop.org Wed Mar 4 02:02:53 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Tue, 3 Mar 2015 18:02:53 -0800 (PST) Subject: Mesa (10.4): glsl: Don't optimize min/ max into saturate when EmitNoSat is set Message-ID: <20150304020253.CA5E476333@kemper.freedesktop.org> Module: Mesa Branch: 10.4 Commit: d880aa573ce4d39cd6c2b7445b757414360a432c URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=d880aa573ce4d39cd6c2b7445b757414360a432c Author: Abdiel Janulgue Date: Mon Dec 8 13:31:29 2014 +0200 glsl: Don't optimize min/max into saturate when EmitNoSat is set v3: Fix multi-line comment format (Ian) Reviewed-by: Matt Turner Signed-off-by: Abdiel Janulgue (cherry picked from commit 4ea8c8d56ca8d6b4af36e7750186821b4973355a) --- src/glsl/opt_algebraic.cpp | 2 +- src/mesa/main/mtypes.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/glsl/opt_algebraic.cpp b/src/glsl/opt_algebraic.cpp index 33e94c4..87bb875 100644 --- a/src/glsl/opt_algebraic.cpp +++ b/src/glsl/opt_algebraic.cpp @@ -679,7 +679,7 @@ ir_algebraic_visitor::handle_expression(ir_expression *ir) case ir_binop_min: case ir_binop_max: - if (ir->type->base_type != GLSL_TYPE_FLOAT) + if (ir->type->base_type != GLSL_TYPE_FLOAT || options->EmitNoSat) break; /* Replace min(max) operations and its commutative combinations with diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 7389baa..cee11a3 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -2990,6 +2990,7 @@ struct gl_shader_compiler_options GLboolean EmitNoMainReturn; /**< Emit CONT/RET opcodes? */ GLboolean EmitNoNoise; /**< Emit NOISE opcodes? */ GLboolean EmitNoPow; /**< Emit POW opcodes? */ + GLboolean EmitNoSat; /**< Emit SAT opcodes? */ GLboolean LowerClipDistance; /**< Lower gl_ClipDistance from float[8] to vec4[2]? */ /** From evelikov at kemper.freedesktop.org Wed Mar 4 02:02:53 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Tue, 3 Mar 2015 18:02:53 -0800 (PST) Subject: Mesa (10.4): st/mesa: For vertex shaders, don' t emit saturate when SM 3.0 is unsupported Message-ID: <20150304020253.D80AA76333@kemper.freedesktop.org> Module: Mesa Branch: 10.4 Commit: afa7a851da07126349ab9c5b3e8c16cddc74d818 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=afa7a851da07126349ab9c5b3e8c16cddc74d818 Author: Abdiel Janulgue Date: Mon Dec 1 14:59:08 2014 +0200 st/mesa: For vertex shaders, don't emit saturate when SM 3.0 is unsupported There is a bug in the current lowering pass implementation where we lower saturate to clamp only for vertex shaders on drivers supporting SM 3.0. The correct behavior is to actually lower to clamp only when we don't support saturate which happens on drivers that don't support SM 3.0 Reviewed-by: Marek Ol??k Reviewed-by: Matt Turner Signed-off-by: Abdiel Janulgue (cherry picked from commit 49e04312116e4f7bbb9ebcc59247a0bcb89c3064) Nominated-by: Matt Turner --- src/mesa/state_tracker/st_context.c | 2 ++ src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 5 +---- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c index 1723513..9da0c77 100644 --- a/src/mesa/state_tracker/st_context.c +++ b/src/mesa/state_tracker/st_context.c @@ -271,6 +271,8 @@ st_create_context_priv( struct gl_context *ctx, struct pipe_context *pipe, */ st->ctx->Point.MaxSize = MAX2(ctx->Const.MaxPointSize, ctx->Const.MaxPointSizeAA); + /* For vertex shaders, make sure not to emit saturate when SM 3.0 is not supported */ + ctx->Const.ShaderCompilerOptions[MESA_SHADER_VERTEX].EmitNoSat = !st->has_shader_model3; _mesa_compute_version(ctx); diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp index ed7746c..86b31d4 100644 --- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp +++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp @@ -5388,9 +5388,6 @@ st_link_shader(struct gl_context *ctx, struct gl_shader_program *prog) if (!pscreen->get_param(pscreen, PIPE_CAP_TEXTURE_GATHER_OFFSETS)) lower_offset_arrays(ir); do_mat_op_to_vec(ir); - /* Emit saturates in the vertex shader only if SM 3.0 is supported. */ - bool vs_sm3 = (_mesa_shader_stage_to_program(prog->_LinkedShaders[i]->Stage) == - GL_VERTEX_PROGRAM_ARB) && st_context(ctx)->has_shader_model3; lower_instructions(ir, MOD_TO_FRACT | DIV_TO_MUL_RCP | @@ -5401,7 +5398,7 @@ st_link_shader(struct gl_context *ctx, struct gl_shader_program *prog) BORROW_TO_ARITH | (options->EmitNoPow ? POW_TO_EXP2 : 0) | (!ctx->Const.NativeIntegers ? INT_DIV_TO_MUL_RCP : 0) | - (vs_sm3 ? SAT_TO_CLAMP : 0)); + (options->EmitNoSat ? SAT_TO_CLAMP : 0)); lower_ubo_reference(prog->_LinkedShaders[i], ir); do_vec_index_to_cond_assign(ir); From evelikov at kemper.freedesktop.org Wed Mar 4 02:02:53 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Tue, 3 Mar 2015 18:02:53 -0800 (PST) Subject: Mesa (10.4): gallivm: Update for RTDyldMemoryManager becoming an unique_ptr. Message-ID: <20150304020253.E394076333@kemper.freedesktop.org> Module: Mesa Branch: 10.4 Commit: 66a3f104a5b29dd4c4d5f1652dde994bf5b8878c URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=66a3f104a5b29dd4c4d5f1652dde994bf5b8878c Author: Jos? Fonseca Date: Wed Dec 3 07:48:26 2014 +0000 gallivm: Update for RTDyldMemoryManager becoming an unique_ptr. Trivial. Fixes https://bugs.freedesktop.org/show_bug.cgi?id=86958 (cherry picked from commit ef7e0b39a24966526b102643523feac765771842) Nominated-by: Sedat Dilek --- src/gallium/auxiliary/gallivm/lp_bld_misc.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp b/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp index fe3c754..5210acc 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp +++ b/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp @@ -500,8 +500,12 @@ lp_build_create_jit_compiler_for_module(LLVMExecutionEngineRef *OutJIT, MM = new ShaderMemoryManager(JMM); *OutCode = MM->getGeneratedCode(); +#if HAVE_LLVM >= 0x0306 + builder.setMCJITMemoryManager(std::unique_ptr(MM)); +#else builder.setMCJITMemoryManager(MM); #endif +#endif } else { #if HAVE_LLVM < 0x0306 BaseMemoryManager* JMM = reinterpret_cast(CMM); From imirkin at kemper.freedesktop.org Wed Mar 4 05:17:34 2015 From: imirkin at kemper.freedesktop.org (Ilia Mirkin) Date: Tue, 3 Mar 2015 21:17:34 -0800 (PST) Subject: Mesa (master): gallium/auxiliary/indices: fix start param Message-ID: <20150304051734.608D476333@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 073a5d2e84ac9d95f0d037aeb04889822e76aa4e URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=073a5d2e84ac9d95f0d037aeb04889822e76aa4e Author: Marc-Andre Lureau Date: Fri Feb 27 19:40:19 2015 +0100 gallium/auxiliary/indices: fix start param Since commit 28f3f8d, indices generator take a start parameter. However, some index values have been left to start at 0. This fixes the glean/fbo test with the virgl driver, and copytexsubimage with freedreno. Reviewed-by: Ilia Mirkin Cc: "10.4 10.5" --- src/gallium/auxiliary/indices/u_indices_gen.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/gallium/auxiliary/indices/u_indices_gen.py b/src/gallium/auxiliary/indices/u_indices_gen.py index 2714df8..f05b70a 100644 --- a/src/gallium/auxiliary/indices/u_indices_gen.py +++ b/src/gallium/auxiliary/indices/u_indices_gen.py @@ -193,7 +193,7 @@ def lineloop(intype, outtype, inpv, outpv): print ' for (i = start, j = 0; j < nr - 2; j+=2, i++) { ' do_line( intype, outtype, 'out+j', 'i', 'i+1', inpv, outpv ); print ' }' - do_line( intype, outtype, 'out+j', 'i', '0', inpv, outpv ); + do_line( intype, outtype, 'out+j', 'i', 'start', inpv, outpv ); postamble() def tris(intype, outtype, inpv, outpv): @@ -218,7 +218,7 @@ def tristrip(intype, outtype, inpv, outpv): def trifan(intype, outtype, inpv, outpv): preamble(intype, outtype, inpv, outpv, prim='trifan') print ' for (i = start, j = 0; j < nr; j+=3, i++) { ' - do_tri( intype, outtype, 'out+j', '0', 'i+1', 'i+2', inpv, outpv ); + do_tri( intype, outtype, 'out+j', 'start', 'i+1', 'i+2', inpv, outpv ); print ' }' postamble() @@ -228,9 +228,9 @@ def polygon(intype, outtype, inpv, outpv): preamble(intype, outtype, inpv, outpv, prim='polygon') print ' for (i = start, j = 0; j < nr; j+=3, i++) { ' if inpv == FIRST: - do_tri( intype, outtype, 'out+j', '0', 'i+1', 'i+2', inpv, outpv ); + do_tri( intype, outtype, 'out+j', 'start', 'i+1', 'i+2', inpv, outpv ); else: - do_tri( intype, outtype, 'out+j', 'i+1', 'i+2', '0', inpv, outpv ); + do_tri( intype, outtype, 'out+j', 'i+1', 'i+2', 'start', inpv, outpv ); print ' }' postamble() From jrfonseca at kemper.freedesktop.org Wed Mar 4 11:02:04 2015 From: jrfonseca at kemper.freedesktop.org (Jose Fonseca) Date: Wed, 4 Mar 2015 03:02:04 -0800 (PST) Subject: Mesa (master): nir: Use helper macros for dealing with VLAs. Message-ID: <20150304110204.B035276333@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 40a4797384d89c4ae225e1999ebe502cd50b2500 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=40a4797384d89c4ae225e1999ebe502cd50b2500 Author: Jose Fonseca Date: Fri Feb 27 15:32:24 2015 +0000 nir: Use helper macros for dealing with VLAs. v2: - Single statement, by using memset return value as suggested by Ian Romanick. - No internal declaration, as suggested by Jason Ekstrand. - Move macros to a header. Reviewed-by: Jason Ekstrand --- src/glsl/nir/nir_from_ssa.c | 23 ++++++--------- src/glsl/nir/nir_live_variables.c | 4 +-- src/glsl/nir/nir_lower_vars_to_ssa.c | 12 +++----- src/glsl/nir/nir_vla.h | 54 ++++++++++++++++++++++++++++++++++ 4 files changed, 69 insertions(+), 24 deletions(-) diff --git a/src/glsl/nir/nir_from_ssa.c b/src/glsl/nir/nir_from_ssa.c index 66339f3..c3090fb 100644 --- a/src/glsl/nir/nir_from_ssa.c +++ b/src/glsl/nir/nir_from_ssa.c @@ -26,7 +26,7 @@ */ #include "nir.h" -#include "c99_alloca.h" +#include "nir_vla.h" /* * This file implements an out-of-SSA pass as described in "Revisiting @@ -182,7 +182,7 @@ merge_merge_sets(merge_set *a, merge_set *b) static bool merge_sets_interfere(merge_set *a, merge_set *b) { - merge_node **dom = alloca((a->size + b->size) * sizeof *dom); + NIR_VLA(merge_node *, dom, a->size + b->size); int dom_idx = -1; struct exec_node *an = exec_list_get_head(&a->nodes); @@ -674,21 +674,16 @@ resolve_parallel_copy(nir_parallel_copy_instr *pcopy, } /* The register/source corresponding to the given index */ - nir_src *values = alloca(num_copies * 2 * sizeof *values); - memset(values, 0, num_copies * 2 * sizeof *values); + NIR_VLA_ZERO(nir_src, values, num_copies * 2); - /* The current location of a given piece of data */ - int *loc = alloca(num_copies * 2 * sizeof *loc); + /* The current location of a given piece of data. We will use -1 for "null" */ + NIR_VLA_FILL(int, loc, num_copies * 2, -1); - /* The piece of data that the given piece of data is to be copied from */ - int *pred = alloca(num_copies * 2 * sizeof *pred); - - /* Initialize loc and pred. We will use -1 for "null" */ - memset(loc, -1, num_copies * 2 * sizeof *loc); - memset(pred, -1, num_copies * 2 * sizeof *pred); + /* The piece of data that the given piece of data is to be copied from. We will use -1 for "null" */ + NIR_VLA_FILL(int, pred, num_copies * 2, -1); /* The destinations we have yet to properly fill */ - int *to_do = alloca(num_copies * 2 * sizeof *to_do); + NIR_VLA(int, to_do, num_copies * 2); int to_do_idx = -1; /* Now we set everything up: @@ -738,7 +733,7 @@ resolve_parallel_copy(nir_parallel_copy_instr *pcopy, } /* Currently empty destinations we can go ahead and fill */ - int *ready = alloca(num_copies * 2 * sizeof *ready); + NIR_VLA(int, ready, num_copies * 2); int ready_idx = -1; /* Mark the ones that are ready for copying. We know an index is a diff --git a/src/glsl/nir/nir_live_variables.c b/src/glsl/nir/nir_live_variables.c index b57ca3a..1c96dcf 100644 --- a/src/glsl/nir/nir_live_variables.c +++ b/src/glsl/nir/nir_live_variables.c @@ -26,7 +26,7 @@ #include "nir.h" #include "nir_worklist.h" -#include "c99_alloca.h" +#include "nir_vla.h" /* * Basic liveness analysis. This works only in SSA form. @@ -131,7 +131,7 @@ static bool propagate_across_edge(nir_block *pred, nir_block *succ, struct live_variables_state *state) { - BITSET_WORD *live = alloca(state->bitset_words * sizeof *live); + NIR_VLA(BITSET_WORD, live, state->bitset_words); memcpy(live, succ->live_in, state->bitset_words * sizeof *live); nir_foreach_instr(succ, instr) { diff --git a/src/glsl/nir/nir_lower_vars_to_ssa.c b/src/glsl/nir/nir_lower_vars_to_ssa.c index f54d1b7..9e9a418 100644 --- a/src/glsl/nir/nir_lower_vars_to_ssa.c +++ b/src/glsl/nir/nir_lower_vars_to_ssa.c @@ -26,8 +26,7 @@ */ #include "nir.h" - -#include "c99_alloca.h" +#include "nir_vla.h" struct deref_node { @@ -902,8 +901,8 @@ rename_variables_block(nir_block *block, struct lower_variables_state *state) static void insert_phi_nodes(struct lower_variables_state *state) { - unsigned *work = alloca(state->impl->num_blocks * sizeof *work); - unsigned *has_already = alloca(state->impl->num_blocks * sizeof *has_already); + NIR_VLA_ZERO(unsigned, work, state->impl->num_blocks); + NIR_VLA_ZERO(unsigned, has_already, state->impl->num_blocks); /* * Since the work flags already prevent us from inserting a node that has @@ -913,10 +912,7 @@ insert_phi_nodes(struct lower_variables_state *state) * function. So all we need to handle W is an array and a pointer to the * next element to be inserted and the next element to be removed. */ - nir_block **W = alloca(state->impl->num_blocks * sizeof *W); - - memset(work, 0, state->impl->num_blocks * sizeof *work); - memset(has_already, 0, state->impl->num_blocks * sizeof *has_already); + NIR_VLA(nir_block *, W, state->impl->num_blocks); unsigned w_start, w_end; unsigned iter_count = 0; diff --git a/src/glsl/nir/nir_vla.h b/src/glsl/nir/nir_vla.h new file mode 100644 index 0000000..7537833 --- /dev/null +++ b/src/glsl/nir/nir_vla.h @@ -0,0 +1,54 @@ +/************************************************************************** + * + * Copyright 2015 VMware, 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 VMWARE 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. + * + **************************************************************************/ + +#pragma once + + +#include "c99_alloca.h" + + +/* Declare a variable length array, with no initialization */ +#define NIR_VLA(_type, _name, _length) \ + _type *_name = alloca((_length) * sizeof *_name) + + +/* Declare a variable length array, and initialize it with the given byte. + * + * _length is evaluated twice, so expressions with side-effects must be + * avoided. + */ +#define NIR_VLA_FILL(_type, _name, _length, _byte) \ + _type *_name = memset(alloca((_length) * sizeof *_name), _byte, (_length) * sizeof *_name) + + +/* Declare a variable length array, and zero it. + * + * Just like NIR_VLA_FILL, _length is evaluated twice, so expressions with + * side-effects must be avoided. + */ +#define NIR_VLA_ZERO(_type, _name, _length) \ + NIR_VLA_FILL(_type, _name, _length, 0) From jrfonseca at kemper.freedesktop.org Wed Mar 4 11:02:04 2015 From: jrfonseca at kemper.freedesktop.org (Jose Fonseca) Date: Wed, 4 Mar 2015 03:02:04 -0800 (PST) Subject: Mesa (master): windows/gdi: Remove. Message-ID: <20150304110204.BBCAC76333@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 17b2825d760fb6a7b643e5f9c067d249a582cfdb URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=17b2825d760fb6a7b643e5f9c067d249a582cfdb Author: Jose Fonseca Date: Tue Mar 3 14:52:15 2015 +0000 windows/gdi: Remove. This classic driver is so far behind Gallium softpipe/llvmpipe based one, that's hard to imagine ever being useful. v2: Drop drivers/windows from src/mesa/Makefile.am:EXTRA_DIST per Emil Velikov. Reviewed-by: Emil Velikov v3: Update release notes. --- docs/README.WIN32 | 4 +- docs/install.html | 5 +- docs/relnotes/10.6.0.html | 4 +- include/GL/wmesa.h | 140 ------ src/mesa/Makefile.am | 1 - src/mesa/drivers/SConscript | 3 - src/mesa/drivers/windows/gdi/SConscript | 40 -- src/mesa/drivers/windows/gdi/colors.h | 29 -- src/mesa/drivers/windows/gdi/mesa.def | 385 --------------- src/mesa/drivers/windows/gdi/wgl.c | 689 --------------------------- src/mesa/drivers/windows/gdi/wmesa.c | 791 ------------------------------- src/mesa/drivers/windows/gdi/wmesadef.h | 43 -- 12 files changed, 7 insertions(+), 2127 deletions(-) Diff: http://cgit.freedesktop.org/mesa/mesa/diff/?id=17b2825d760fb6a7b643e5f9c067d249a582cfdb From jrfonseca at kemper.freedesktop.org Wed Mar 4 11:02:04 2015 From: jrfonseca at kemper.freedesktop.org (Jose Fonseca) Date: Wed, 4 Mar 2015 03:02:04 -0800 (PST) Subject: Mesa (master): st/egl: Remove. Message-ID: <20150304110204.D12B376333@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 5564c361b5cc1f5ec4be3622d7f9be601e3c268a URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=5564c361b5cc1f5ec4be3622d7f9be601e3c268a Author: Jose Fonseca Date: Tue Mar 3 16:01:22 2015 +0000 st/egl: Remove. Largely superseeded by src/egl, and WGL/GLX_EXT_create_context_es_profile extensions. Note this will break Android.mk with gallium drivers -- somebody familiar with that build infrastructure will need to update it to use gallium drivers through egl_dri2. v2: Remove the _EGL_BUILT_IN_DRIVER_GALLIUM define from src/egl/main/Android.mk; and update the src/egl/main/Sconscript to create a SharedLibrary, add versioning, create symlink - copy the bits from egl-static, per Emil Velikov. Reviewed-by: Emil Velikov v3: Disallow undefined symbols in libEGL.so. Update release notes --- docs/egl.html | 29 +- docs/relnotes/10.6.0.html | 1 + docs/sourcetree.html | 1 - src/egl/main/Android.mk | 2 - src/egl/main/SConscript | 12 +- src/egl/main/egldriver.c | 3 - src/gallium/Android.mk | 5 - src/gallium/Makefile.am | 2 - src/gallium/SConscript | 5 - src/gallium/state_trackers/egl/Android.mk | 55 -- src/gallium/state_trackers/egl/Makefile.am | 111 --- src/gallium/state_trackers/egl/Makefile.sources | 57 -- src/gallium/state_trackers/egl/SConscript | 62 -- .../state_trackers/egl/android/native_android.cpp | 892 ------------------ src/gallium/state_trackers/egl/common/egl_g3d.c | 674 -------------- src/gallium/state_trackers/egl/common/egl_g3d.h | 132 --- .../state_trackers/egl/common/egl_g3d_api.c | 952 -------------------- .../state_trackers/egl/common/egl_g3d_api.h | 33 - .../state_trackers/egl/common/egl_g3d_image.c | 372 -------- .../state_trackers/egl/common/egl_g3d_image.h | 49 - .../state_trackers/egl/common/egl_g3d_loader.h | 51 -- src/gallium/state_trackers/egl/common/egl_g3d_st.c | 321 ------- src/gallium/state_trackers/egl/common/egl_g3d_st.h | 47 - .../state_trackers/egl/common/egl_g3d_sync.c | 278 ------ .../state_trackers/egl/common/egl_g3d_sync.h | 48 - src/gallium/state_trackers/egl/common/native.h | 342 ------- .../state_trackers/egl/common/native_buffer.h | 75 -- .../state_trackers/egl/common/native_helper.c | 501 ---------- .../state_trackers/egl/common/native_helper.h | 125 --- .../state_trackers/egl/common/native_modeset.h | 87 -- .../egl/common/native_wayland_bufmgr.h | 49 - .../egl/common/native_wayland_drm_bufmgr.c | 228 ----- .../egl/common/native_wayland_drm_bufmgr.h | 37 - src/gallium/state_trackers/egl/drm/modeset.c | 707 --------------- src/gallium/state_trackers/egl/drm/native_drm.c | 273 ------ src/gallium/state_trackers/egl/drm/native_drm.h | 160 ---- .../state_trackers/egl/fbdev/native_fbdev.c | 552 ------------ src/gallium/state_trackers/egl/gdi/native_gdi.c | 428 --------- src/gallium/state_trackers/egl/null/native_null.c | 189 ---- .../state_trackers/egl/wayland/native_drm.c | 286 ------ .../state_trackers/egl/wayland/native_shm.c | 209 ----- .../state_trackers/egl/wayland/native_wayland.c | 465 ---------- .../state_trackers/egl/wayland/native_wayland.h | 124 --- src/gallium/state_trackers/egl/x11/dri2.c | 1 - src/gallium/state_trackers/egl/x11/glcore.h | 179 ---- src/gallium/state_trackers/egl/x11/glxinit.c | 656 -------------- src/gallium/state_trackers/egl/x11/glxinit.h | 22 - src/gallium/state_trackers/egl/x11/native_dri2.c | 925 ------------------- src/gallium/state_trackers/egl/x11/native_x11.c | 63 -- src/gallium/state_trackers/egl/x11/native_x11.h | 39 - src/gallium/state_trackers/egl/x11/native_ximage.c | 587 ------------ src/gallium/state_trackers/egl/x11/x11_screen.c | 488 ---------- src/gallium/state_trackers/egl/x11/x11_screen.h | 133 --- src/gallium/targets/egl-static/Android.mk | 81 -- src/gallium/targets/egl-static/Makefile.am | 210 ----- src/gallium/targets/egl-static/SConscript | 114 --- src/gallium/targets/egl-static/egl.c | 122 --- src/gallium/targets/egl-static/egl.sym | 6 - src/gallium/targets/egl-static/egl_pipe.c | 41 - src/gallium/targets/egl-static/egl_pipe.h | 36 - src/gallium/targets/egl-static/egl_st.c | 167 ---- src/gallium/targets/egl-static/egl_st.h | 39 - src/gallium/targets/egl-static/st_GL.c | 37 - 63 files changed, 12 insertions(+), 12965 deletions(-) Diff: http://cgit.freedesktop.org/mesa/mesa/diff/?id=5564c361b5cc1f5ec4be3622d7f9be601e3c268a From jrfonseca at kemper.freedesktop.org Wed Mar 4 11:02:04 2015 From: jrfonseca at kemper.freedesktop.org (Jose Fonseca) Date: Wed, 4 Mar 2015 03:02:04 -0800 (PST) Subject: Mesa (master): st/vega: Remove. Message-ID: <20150304110204.E9D5276333@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 3acd7a34ab05b87521b74f626ec637e7fdcc6595 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=3acd7a34ab05b87521b74f626ec637e7fdcc6595 Author: Jose Fonseca Date: Tue Mar 3 16:58:21 2015 +0000 st/vega: Remove. OpenVG API seems to have dwindled away. The code would still be interesting if we wanted to implement NV_path_rendering but given the trend of the next gen graphics APIs, it seems unlikely that this becomes ARB or core. v2: Remove a few "openvg" references left, per Emil Velikov. Reviewed-by: Emil Velikov v3: Update release notes. --- configure.ac | 31 - docs/contents.html | 1 - docs/egl.html | 7 - docs/openvg.html | 59 - docs/relnotes/10.6.0.html | 1 + docs/relnotes/7.6.html | 2 +- docs/sourcetree.html | 1 - include/VG/openvg.h | 746 -------- include/VG/vgext.h | 233 --- include/VG/vgplatform.h | 92 - include/VG/vgu.h | 131 -- src/SConscript | 2 - src/gallium/Makefile.am | 5 - src/gallium/SConscript | 2 - src/gallium/docs/source/distro.rst | 13 - src/gallium/state_trackers/vega/.gitignore | 1 - src/gallium/state_trackers/vega/Makefile.am | 42 - src/gallium/state_trackers/vega/Makefile.sources | 56 - src/gallium/state_trackers/vega/SConscript | 30 - src/gallium/state_trackers/vega/api.c | 74 - src/gallium/state_trackers/vega/api.h | 47 - src/gallium/state_trackers/vega/api_consts.h | 56 - src/gallium/state_trackers/vega/api_context.c | 81 - src/gallium/state_trackers/vega/api_filters.c | 705 -------- src/gallium/state_trackers/vega/api_images.c | 492 ----- src/gallium/state_trackers/vega/api_masks.c | 246 --- src/gallium/state_trackers/vega/api_misc.c | 84 - src/gallium/state_trackers/vega/api_paint.c | 172 -- src/gallium/state_trackers/vega/api_params.c | 1679 ----------------- src/gallium/state_trackers/vega/api_path.c | 487 ----- src/gallium/state_trackers/vega/api_text.c | 209 --- src/gallium/state_trackers/vega/api_transform.c | 129 -- src/gallium/state_trackers/vega/arc.c | 709 -------- src/gallium/state_trackers/vega/arc.h | 80 - src/gallium/state_trackers/vega/asm_fill.h | 693 -------- src/gallium/state_trackers/vega/asm_filters.h | 117 -- src/gallium/state_trackers/vega/asm_util.h | 85 - src/gallium/state_trackers/vega/bezier.c | 706 -------- src/gallium/state_trackers/vega/bezier.h | 81 - src/gallium/state_trackers/vega/handle.c | 93 - src/gallium/state_trackers/vega/handle.h | 172 -- src/gallium/state_trackers/vega/image.c | 653 ------- src/gallium/state_trackers/vega/image.h | 104 -- src/gallium/state_trackers/vega/mask.c | 523 ------ src/gallium/state_trackers/vega/mask.h | 68 - src/gallium/state_trackers/vega/matrix.h | 462 ----- src/gallium/state_trackers/vega/paint.c | 759 -------- src/gallium/state_trackers/vega/paint.h | 123 -- src/gallium/state_trackers/vega/path.c | 2077 ---------------------- src/gallium/state_trackers/vega/path.h | 126 -- src/gallium/state_trackers/vega/path_utils.h | 109 -- src/gallium/state_trackers/vega/polygon.c | 351 ---- src/gallium/state_trackers/vega/polygon.h | 75 - src/gallium/state_trackers/vega/renderer.c | 1558 ---------------- src/gallium/state_trackers/vega/renderer.h | 159 -- src/gallium/state_trackers/vega/shader.c | 414 ----- src/gallium/state_trackers/vega/shader.h | 63 - src/gallium/state_trackers/vega/shaders_cache.c | 462 ----- src/gallium/state_trackers/vega/shaders_cache.h | 120 -- src/gallium/state_trackers/vega/stroker.c | 1351 -------------- src/gallium/state_trackers/vega/stroker.h | 89 - src/gallium/state_trackers/vega/text.c | 250 --- src/gallium/state_trackers/vega/text.h | 71 - src/gallium/state_trackers/vega/util_array.h | 122 -- src/gallium/state_trackers/vega/vg_api.h | 36 - src/gallium/state_trackers/vega/vg_context.c | 537 ------ src/gallium/state_trackers/vega/vg_context.h | 280 --- src/gallium/state_trackers/vega/vg_manager.c | 399 ----- src/gallium/state_trackers/vega/vg_manager.h | 40 - src/gallium/state_trackers/vega/vg_state.c | 124 -- src/gallium/state_trackers/vega/vg_state.h | 109 -- src/gallium/state_trackers/vega/vg_translate.c | 1097 ------------ src/gallium/state_trackers/vega/vg_translate.h | 49 - src/gallium/state_trackers/vega/vgu.c | 441 ----- src/mapi/Makefile.am | 6 - src/mapi/mapi_abi.py | 20 +- src/mapi/vgapi/.gitignore | 1 - src/mapi/vgapi/Makefile.am | 61 - src/mapi/vgapi/SConscript | 61 - src/mapi/vgapi/vg.pc.in | 12 - src/mapi/vgapi/vgapi.csv | 93 - 81 files changed, 3 insertions(+), 22104 deletions(-) Diff: http://cgit.freedesktop.org/mesa/mesa/diff/?id=3acd7a34ab05b87521b74f626ec637e7fdcc6595 From jrfonseca at kemper.freedesktop.org Wed Mar 4 15:15:49 2015 From: jrfonseca at kemper.freedesktop.org (Jose Fonseca) Date: Wed, 4 Mar 2015 07:15:49 -0800 (PST) Subject: Mesa (master): scons: Use -Werror MSVC compatibility flags per-directory. Message-ID: <20150304151549.AE87F761D4@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 00faf9f00059370bc20ebeaf00884c2d8ef15a74 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=00faf9f00059370bc20ebeaf00884c2d8ef15a74 Author: Jose Fonseca Date: Wed Mar 4 14:23:52 2015 +0000 scons: Use -Werror MSVC compatibility flags per-directory. Matching what we already do with autotools builds. Reviewed-by: Brian Paul --- scons/gallium.py | 27 ++++++++++++++++++++------- src/egl/main/SConscript | 2 ++ src/gallium/auxiliary/SConscript | 4 ++++ src/gallium/drivers/llvmpipe/SConscript | 2 ++ src/glsl/SConscript | 2 ++ src/loader/SConscript | 2 ++ src/mapi/glapi/SConscript | 2 ++ src/mesa/SConscript | 2 ++ src/util/SConscript | 2 ++ 9 files changed, 38 insertions(+), 7 deletions(-) diff --git a/scons/gallium.py b/scons/gallium.py index c34468f..f839758 100755 --- a/scons/gallium.py +++ b/scons/gallium.py @@ -87,6 +87,25 @@ def createInstallMethods(env): env.AddMethod(install_shared_library, 'InstallSharedLibrary') +def msvc2013_compat(env): + if env['gcc']: + env.Append(CCFLAGS = [ + '-Werror=vla', + '-Werror=pointer-arith', + ]) + +def msvc2008_compat(env): + msvc2013_compat(env) + if env['gcc']: + env.Append(CFLAGS = [ + '-Werror=declaration-after-statement', + ]) + +def createMSVCCompatMethods(env): + env.AddMethod(msvc2013_compat, 'MSVC2013Compat') + env.AddMethod(msvc2008_compat, 'MSVC2008Compat') + + def num_jobs(): try: return int(os.environ['NUMBER_OF_PROCESSORS']) @@ -443,13 +462,6 @@ def generate(env): '-Wmissing-prototypes', '-std=gnu99', ] - if distutils.version.LooseVersion(ccversion) >= distutils.version.LooseVersion('4.2'): - ccflags += [ - '-Wpointer-arith', - ] - cflags += [ - '-Wdeclaration-after-statement', - ] if icc: cflags += [ '-std=gnu99', @@ -617,6 +629,7 @@ def generate(env): # Custom builders and methods env.Tool('custom') createInstallMethods(env) + createMSVCCompatMethods(env) env.PkgCheckModules('X11', ['x11', 'xext', 'xdamage', 'xfixes', 'glproto >= 1.4.13']) env.PkgCheckModules('XCB', ['x11-xcb', 'xcb-glx >= 1.8.1', 'xcb-dri2 >= 1.8']) diff --git a/src/egl/main/SConscript b/src/egl/main/SConscript index 399c020..b4e9b67 100644 --- a/src/egl/main/SConscript +++ b/src/egl/main/SConscript @@ -6,6 +6,8 @@ Import('*') env = env.Clone() +env.MSVC2013Compat() + env.Append(CPPDEFINES = [ '_EGL_DRIVER_SEARCH_DIR=\\"\\"', ]) diff --git a/src/gallium/auxiliary/SConscript b/src/gallium/auxiliary/SConscript index 6cb6b8c..d5fa880 100644 --- a/src/gallium/auxiliary/SConscript +++ b/src/gallium/auxiliary/SConscript @@ -8,6 +8,10 @@ env.Append(CPPPATH = [ 'util', ]) +env = env.Clone() + +env.MSVC2008Compat() + env.CodeGenerate( target = 'indices/u_indices_gen.c', script = 'indices/u_indices_gen.py', diff --git a/src/gallium/drivers/llvmpipe/SConscript b/src/gallium/drivers/llvmpipe/SConscript index 1bea611..3a51efc 100644 --- a/src/gallium/drivers/llvmpipe/SConscript +++ b/src/gallium/drivers/llvmpipe/SConscript @@ -9,6 +9,8 @@ if not env['llvm']: env = env.Clone() +env.MSVC2008Compat() + llvmpipe = env.ConvenienceLibrary( target = 'llvmpipe', source = env.ParseSourceList('Makefile.sources', 'C_SOURCES') diff --git a/src/glsl/SConscript b/src/glsl/SConscript index 21c8266..26de455 100644 --- a/src/glsl/SConscript +++ b/src/glsl/SConscript @@ -6,6 +6,8 @@ from sys import executable as python_cmd env = env.Clone() +env.MSVC2013Compat() + env.Prepend(CPPPATH = [ '#include', '#src', diff --git a/src/loader/SConscript b/src/loader/SConscript index 359fc18..16d1053 100644 --- a/src/loader/SConscript +++ b/src/loader/SConscript @@ -2,6 +2,8 @@ Import('*') env = env.Clone() +env.MSVC2013Compat() + env.Prepend(CPPPATH = [ '#include' ]) diff --git a/src/mapi/glapi/SConscript b/src/mapi/glapi/SConscript index 97ebfe6..84a5068 100644 --- a/src/mapi/glapi/SConscript +++ b/src/mapi/glapi/SConscript @@ -8,6 +8,8 @@ Import('*') env = env.Clone() +env.MSVC2013Compat() + env.Append(CPPDEFINES = [ 'MAPI_MODE_UTIL', ]) diff --git a/src/mesa/SConscript b/src/mesa/SConscript index 62e81ce..d6ff083 100644 --- a/src/mesa/SConscript +++ b/src/mesa/SConscript @@ -10,6 +10,8 @@ from sys import executable as python_cmd env = env.Clone() +env.MSVC2013Compat() + env.Append(CPPPATH = [ '#/src', '#/src/mapi', diff --git a/src/util/SConscript b/src/util/SConscript index 84bd7a1..9e4d481 100644 --- a/src/util/SConscript +++ b/src/util/SConscript @@ -6,6 +6,8 @@ from sys import executable as python_cmd env = env.Clone() +env.MSVC2008Compat() + env.Prepend(CPPPATH = [ '#include', '#src', From jrfonseca at kemper.freedesktop.org Wed Mar 4 15:15:49 2015 From: jrfonseca at kemper.freedesktop.org (Jose Fonseca) Date: Wed, 4 Mar 2015 07:15:49 -0800 (PST) Subject: Mesa (master): scons: Update for the fact that we require GCC 4.2 Message-ID: <20150304151549.CF998761D4@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 6e836d2c8643dff127c0aef22dcabed763d7ea3e URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=6e836d2c8643dff127c0aef22dcabed763d7ea3e Author: Jose Fonseca Date: Wed Mar 4 13:56:35 2015 +0000 scons: Update for the fact that we require GCC 4.2 Reviewed-by: Brian Paul --- scons/gallium.py | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/scons/gallium.py b/scons/gallium.py index f839758..7533f06 100755 --- a/scons/gallium.py +++ b/scons/gallium.py @@ -369,20 +369,16 @@ def generate(env): 'HAVE___BUILTIN_FFS', 'HAVE___BUILTIN_FFSLL', 'HAVE_FUNC_ATTRIBUTE_FLATTEN', + # GCC 3.0 + 'HAVE_FUNC_ATTRIBUTE_FORMAT', + 'HAVE_FUNC_ATTRIBUTE_PACKED', + # GCC 3.4 + 'HAVE___BUILTIN_CTZ', + 'HAVE___BUILTIN_POPCOUNT', + 'HAVE___BUILTIN_POPCOUNTLL', + 'HAVE___BUILTIN_CLZ', + 'HAVE___BUILTIN_CLZLL', ] - if distutils.version.LooseVersion(ccversion) >= distutils.version.LooseVersion('3'): - cppdefines += [ - 'HAVE_FUNC_ATTRIBUTE_FORMAT', - 'HAVE_FUNC_ATTRIBUTE_PACKED', - ] - if distutils.version.LooseVersion(ccversion) >= distutils.version.LooseVersion('3.4'): - cppdefines += [ - 'HAVE___BUILTIN_CTZ', - 'HAVE___BUILTIN_POPCOUNT', - 'HAVE___BUILTIN_POPCOUNTLL', - 'HAVE___BUILTIN_CLZ', - 'HAVE___BUILTIN_CLZLL', - ] if distutils.version.LooseVersion(ccversion) >= distutils.version.LooseVersion('4.5'): cppdefines += ['HAVE___BUILTIN_UNREACHABLE'] env.Append(CPPDEFINES = cppdefines) @@ -420,8 +416,7 @@ def generate(env): '-m32', #'-march=pentium4', ] - if distutils.version.LooseVersion(ccversion) >= distutils.version.LooseVersion('4.2') \ - and platform != 'haiku': + if platform != 'haiku': # NOTE: We need to ensure stack is realigned given that we # produce shared objects, and have no control over the stack # alignment policy of the application. Therefore we need From jrfonseca at kemper.freedesktop.org Wed Mar 4 15:15:49 2015 From: jrfonseca at kemper.freedesktop.org (Jose Fonseca) Date: Wed, 4 Mar 2015 07:15:49 -0800 (PST) Subject: Mesa (master): softpipe,trace: Set MSVC 2008 compat flags. Message-ID: <20150304151549.B7A27763B7@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 2c25008e8e37a41fa61988b7fb65b524cbb7e64f URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=2c25008e8e37a41fa61988b7fb65b524cbb7e64f Author: Jose Fonseca Date: Wed Mar 4 14:25:39 2015 +0000 softpipe,trace: Set MSVC 2008 compat flags. Although we don't deploy these, we need to use them for debugging. Reviewed-by: Brian Paul --- src/gallium/drivers/softpipe/Makefile.am | 3 ++- src/gallium/drivers/softpipe/SConscript | 1 + src/gallium/drivers/trace/Makefile.am | 3 ++- src/gallium/drivers/trace/SConscript | 2 ++ 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/gallium/drivers/softpipe/Makefile.am b/src/gallium/drivers/softpipe/Makefile.am index 20f11f8..05126a5 100644 --- a/src/gallium/drivers/softpipe/Makefile.am +++ b/src/gallium/drivers/softpipe/Makefile.am @@ -24,7 +24,8 @@ include Makefile.sources include $(top_srcdir)/src/gallium/Automake.inc AM_CFLAGS = \ - $(GALLIUM_DRIVER_CFLAGS) + $(GALLIUM_DRIVER_CFLAGS) \ + $(MSVC2008_COMPAT_CFLAGS) noinst_LTLIBRARIES = libsoftpipe.la diff --git a/src/gallium/drivers/softpipe/SConscript b/src/gallium/drivers/softpipe/SConscript index 6768cbb..dc3542c 100644 --- a/src/gallium/drivers/softpipe/SConscript +++ b/src/gallium/drivers/softpipe/SConscript @@ -2,6 +2,7 @@ Import('*') env = env.Clone() +env.MSVC2008Compat() softpipe = env.ConvenienceLibrary( target = 'softpipe', diff --git a/src/gallium/drivers/trace/Makefile.am b/src/gallium/drivers/trace/Makefile.am index db7b449..6a8a74a 100644 --- a/src/gallium/drivers/trace/Makefile.am +++ b/src/gallium/drivers/trace/Makefile.am @@ -2,7 +2,8 @@ include Makefile.sources include $(top_srcdir)/src/gallium/Automake.inc AM_CFLAGS = \ - $(GALLIUM_DRIVER_CFLAGS) + $(GALLIUM_DRIVER_CFLAGS) \ + $(MSVC2008_COMPAT_CFLAGS) noinst_LTLIBRARIES = libtrace.la diff --git a/src/gallium/drivers/trace/SConscript b/src/gallium/drivers/trace/SConscript index 7341d1c..1bbed73 100644 --- a/src/gallium/drivers/trace/SConscript +++ b/src/gallium/drivers/trace/SConscript @@ -2,6 +2,8 @@ Import('*') env = env.Clone() +env.MSVC2008Compat() + trace = env.ConvenienceLibrary( target = 'trace', source = env.ParseSourceList('Makefile.sources', 'C_SOURCES') From jrfonseca at kemper.freedesktop.org Wed Mar 4 15:15:49 2015 From: jrfonseca at kemper.freedesktop.org (Jose Fonseca) Date: Wed, 4 Mar 2015 07:15:49 -0800 (PST) Subject: Mesa (master): svga: Set MSVC2013 compat flags. Message-ID: <20150304151549.C2204763B8@kemper.freedesktop.org> Module: Mesa Branch: master Commit: d0b1c74b73ddc7590e81bdfd837f540d75b172ce URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=d0b1c74b73ddc7590e81bdfd837f540d75b172ce Author: Jose Fonseca Date: Wed Mar 4 14:25:54 2015 +0000 svga: Set MSVC2013 compat flags. Reviewed-by: Brian Paul --- src/gallium/drivers/svga/Makefile.am | 3 ++- src/gallium/drivers/svga/SConscript | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/gallium/drivers/svga/Makefile.am b/src/gallium/drivers/svga/Makefile.am index 50d44cf..e0a8cad 100644 --- a/src/gallium/drivers/svga/Makefile.am +++ b/src/gallium/drivers/svga/Makefile.am @@ -26,7 +26,8 @@ include Makefile.sources include $(top_srcdir)/src/gallium/Automake.inc AM_CFLAGS = \ - $(GALLIUM_DRIVER_CFLAGS) + $(GALLIUM_DRIVER_CFLAGS) \ + $(MSVC2013_COMPAT_CFLAGS) #On some systems -std= must be added to CFLAGS to be the last -std= CFLAGS += -std=gnu99 diff --git a/src/gallium/drivers/svga/SConscript b/src/gallium/drivers/svga/SConscript index 2051a3e..bb4d034 100644 --- a/src/gallium/drivers/svga/SConscript +++ b/src/gallium/drivers/svga/SConscript @@ -2,6 +2,8 @@ Import('*') env = env.Clone() +env.MSVC2013Compat() + if env['suncc']: print 'warning: not building svga' Return() From brianp at kemper.freedesktop.org Wed Mar 4 16:23:56 2015 From: brianp at kemper.freedesktop.org (Brian Paul) Date: Wed, 4 Mar 2015 08:23:56 -0800 (PST) Subject: Mesa (master): mesa: consolidate PUBLIC macro definition Message-ID: <20150304162356.B01BB761D4@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 5bebd7099ab22c6f1498cd928170561718d6ff36 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=5bebd7099ab22c6f1498cd928170561718d6ff36 Author: Brian Paul Date: Tue Mar 3 09:01:03 2015 -0700 mesa: consolidate PUBLIC macro definition Define the macro in src/util/macros.h rather than in two different places. Note that USED isn't actually used anywhere at this time. Reviewed-by: Jose Fonseca --- src/gallium/include/pipe/p_compiler.h | 12 ------------ src/mesa/main/compiler.h | 20 -------------------- src/util/macros.h | 23 +++++++++++++++++++++++ 3 files changed, 23 insertions(+), 32 deletions(-) diff --git a/src/gallium/include/pipe/p_compiler.h b/src/gallium/include/pipe/p_compiler.h index cc4f444..0e95369 100644 --- a/src/gallium/include/pipe/p_compiler.h +++ b/src/gallium/include/pipe/p_compiler.h @@ -111,18 +111,6 @@ typedef unsigned char boolean; #endif -/* Function visibility */ -#ifndef PUBLIC -# if defined(__GNUC__) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)) -# define PUBLIC __attribute__((visibility("default"))) -# elif defined(_MSC_VER) -# define PUBLIC __declspec(dllexport) -# else -# define PUBLIC -# endif -#endif - - /* XXX: Use standard `__func__` instead */ #ifndef __FUNCTION__ # define __FUNCTION__ __func__ diff --git a/src/mesa/main/compiler.h b/src/mesa/main/compiler.h index 7f2d732..95581fb 100644 --- a/src/mesa/main/compiler.h +++ b/src/mesa/main/compiler.h @@ -83,26 +83,6 @@ extern "C" { #endif -/** - * PUBLIC/USED macros - * - * If we build the library with gcc's -fvisibility=hidden flag, we'll - * use the PUBLIC macro to mark functions that are to be exported. - * - * We also need to define a USED attribute, so the optimizer doesn't - * inline a static function that we later use in an alias. - ajax - */ -#ifndef PUBLIC -# if defined(__GNUC__) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)) -# define PUBLIC __attribute__((visibility("default"))) -# define USED __attribute__((used)) -# else -# define PUBLIC -# define USED -# endif -#endif - - /* XXX: Use standard `__func__` instead */ #ifndef __FUNCTION__ # define __FUNCTION__ __func__ diff --git a/src/util/macros.h b/src/util/macros.h index eec8b93..b862bfd 100644 --- a/src/util/macros.h +++ b/src/util/macros.h @@ -156,4 +156,27 @@ do { \ # endif #endif +/** + * PUBLIC/USED macros + * + * If we build the library with gcc's -fvisibility=hidden flag, we'll + * use the PUBLIC macro to mark functions that are to be exported. + * + * We also need to define a USED attribute, so the optimizer doesn't + * inline a static function that we later use in an alias. - ajax + */ +#ifndef PUBLIC +# if defined(__GNUC__) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)) +# define PUBLIC __attribute__((visibility("default"))) +# define USED __attribute__((used)) +# elif defined(_MSC_VER) +# define PUBLIC __declspec(dllexport) +# define USED +# else +# define PUBLIC +# define USED +# endif +#endif + + #endif /* UTIL_MACROS_H */ From brianp at kemper.freedesktop.org Wed Mar 4 16:23:56 2015 From: brianp at kemper.freedesktop.org (Brian Paul) Date: Wed, 4 Mar 2015 08:23:56 -0800 (PST) Subject: Mesa (master): glx: use ARRAY_SIZE from macros.h Message-ID: <20150304162356.84687761D4@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 0339e7dbdab2ee3a4776e50461bc4697a23b57b6 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=0339e7dbdab2ee3a4776e50461bc4697a23b57b6 Author: Brian Paul Date: Tue Mar 3 09:51:19 2015 -0700 glx: use ARRAY_SIZE from macros.h Reviewed-by: Jose Fonseca --- src/glx/Makefile.am | 1 + src/glx/SConscript | 1 + src/glx/glxclient.h | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/glx/Makefile.am b/src/glx/Makefile.am index 3ea1b30..6e50e09 100644 --- a/src/glx/Makefile.am +++ b/src/glx/Makefile.am @@ -35,6 +35,7 @@ endif AM_CFLAGS = \ -I$(top_srcdir)/include \ -I$(top_srcdir)/include/GL/internal \ + -I$(top_srcdir)/src \ -I$(top_srcdir)/src/loader \ -I$(top_srcdir)/src/mapi \ -I$(top_srcdir)/src/mapi/glapi \ diff --git a/src/glx/SConscript b/src/glx/SConscript index 473c5ab..b91c0bd 100644 --- a/src/glx/SConscript +++ b/src/glx/SConscript @@ -11,6 +11,7 @@ env.Prepend(CPPPATH = [ '.', # the build//glx/ directory '#include', '#include/GL/internal', + '#src/', '#src/loader', '#src/mesa', '#src/mapi', diff --git a/src/glx/glxclient.h b/src/glx/glxclient.h index aaca989..a140c87 100644 --- a/src/glx/glxclient.h +++ b/src/glx/glxclient.h @@ -56,10 +56,10 @@ #if defined( HAVE_PTHREAD ) # include #endif +#include "util/macros.h" #include "glxextensions.h" -#define ARRAY_SIZE(a) (sizeof (a) / sizeof ((a)[0])) #define GLX_MAJOR_VERSION 1 /* current version numbers */ #define GLX_MINOR_VERSION 4 From brianp at kemper.freedesktop.org Wed Mar 4 16:23:56 2015 From: brianp at kemper.freedesktop.org (Brian Paul) Date: Wed, 4 Mar 2015 08:23:56 -0800 (PST) Subject: Mesa (master): st/xlib: include p_compiler.h to get PUBLIC definition Message-ID: <20150304162356.9F945761D4@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 25656753d765680ea4a592ff812deac132e2262d URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=25656753d765680ea4a592ff812deac132e2262d Author: Brian Paul Date: Tue Mar 3 09:18:36 2015 -0700 st/xlib: include p_compiler.h to get PUBLIC definition To prevent build break with following changes. Reviewed-by: Jose Fonseca --- src/gallium/state_trackers/glx/xlib/glx_getproc.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gallium/state_trackers/glx/xlib/glx_getproc.c b/src/gallium/state_trackers/glx/xlib/glx_getproc.c index af7afdb..e7564ad 100644 --- a/src/gallium/state_trackers/glx/xlib/glx_getproc.c +++ b/src/gallium/state_trackers/glx/xlib/glx_getproc.c @@ -32,6 +32,7 @@ #define GLX_GLXEXT_PROTOTYPES #include +#include "pipe/p_compiler.h" #include "GL/glx.h" #include "glapi/glapi.h" From brianp at kemper.freedesktop.org Wed Mar 4 16:23:56 2015 From: brianp at kemper.freedesktop.org (Brian Paul) Date: Wed, 4 Mar 2015 08:23:56 -0800 (PST) Subject: Mesa (master): mapi: replace INLINE with inline Message-ID: <20150304162356.B9CFD761D4@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 41c87cc5666de7ec5cfdea2c035c671048c06ca5 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=41c87cc5666de7ec5cfdea2c035c671048c06ca5 Author: Brian Paul Date: Tue Mar 3 09:08:22 2015 -0700 mapi: replace INLINE with inline Reviewed-by: Jose Fonseca --- src/mapi/entry.c | 2 +- src/mapi/table.h | 6 +++--- src/mapi/u_compiler.h | 6 ------ src/mapi/u_current.h | 4 ++-- src/mapi/u_thread.h | 10 +++++----- 5 files changed, 11 insertions(+), 17 deletions(-) diff --git a/src/mapi/entry.c b/src/mapi/entry.c index b6e8db2..f0287a0 100644 --- a/src/mapi/entry.c +++ b/src/mapi/entry.c @@ -51,7 +51,7 @@ #include -static INLINE const struct mapi_table * +static inline const struct mapi_table * entry_current_get(void) { #ifdef MAPI_MODE_BRIDGE diff --git a/src/mapi/table.h b/src/mapi/table.h index df59aed..8180db9 100644 --- a/src/mapi/table.h +++ b/src/mapi/table.h @@ -42,7 +42,7 @@ extern const mapi_func table_noop_array[]; /** * Get the no-op dispatch table. */ -static INLINE const struct mapi_table * +static inline const struct mapi_table * table_get_noop(void) { return (const struct mapi_table *) table_noop_array; @@ -51,7 +51,7 @@ table_get_noop(void) /** * Set the function of a slot. */ -static INLINE void +static inline void table_set_func(struct mapi_table *tbl, int slot, mapi_func func) { mapi_func *funcs = (mapi_func *) tbl; @@ -61,7 +61,7 @@ table_set_func(struct mapi_table *tbl, int slot, mapi_func func) /** * Return the function of a slot. */ -static INLINE mapi_func +static inline mapi_func table_get_func(const struct mapi_table *tbl, int slot) { const mapi_func *funcs = (const mapi_func *) tbl; diff --git a/src/mapi/u_compiler.h b/src/mapi/u_compiler.h index f376e97..8ed0f71 100644 --- a/src/mapi/u_compiler.h +++ b/src/mapi/u_compiler.h @@ -3,12 +3,6 @@ #include "c99_compat.h" /* inline, __func__, etc. */ - -/* XXX: Use standard `inline` keyword instead */ -#ifndef INLINE -# define INLINE inline -#endif - /* Function visibility */ #ifndef PUBLIC # if defined(__GNUC__) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)) diff --git a/src/mapi/u_current.h b/src/mapi/u_current.h index 72708d4..252e696 100644 --- a/src/mapi/u_current.h +++ b/src/mapi/u_current.h @@ -63,7 +63,7 @@ u_current_set_context(const void *ptr); void * u_current_get_context_internal(void); -static INLINE const struct mapi_table * +static inline const struct mapi_table * u_current_get_table(void) { #ifdef GLX_USE_TLS @@ -74,7 +74,7 @@ u_current_get_table(void) #endif } -static INLINE const void * +static inline const void * u_current_get_context(void) { #ifdef GLX_USE_TLS diff --git a/src/mapi/u_thread.h b/src/mapi/u_thread.h index 57c3b07..3cd07b5 100644 --- a/src/mapi/u_thread.h +++ b/src/mapi/u_thread.h @@ -80,7 +80,7 @@ struct u_tsd { }; -static INLINE unsigned long +static inline unsigned long u_thread_self(void) { /* @@ -104,7 +104,7 @@ u_thread_self(void) } -static INLINE void +static inline void u_tsd_init(struct u_tsd *tsd) { if (tss_create(&tsd->key, NULL/*free*/) != 0) { @@ -115,7 +115,7 @@ u_tsd_init(struct u_tsd *tsd) } -static INLINE void * +static inline void * u_tsd_get(struct u_tsd *tsd) { if (tsd->initMagic != INIT_MAGIC) { @@ -125,7 +125,7 @@ u_tsd_get(struct u_tsd *tsd) } -static INLINE void +static inline void u_tsd_set(struct u_tsd *tsd, void *ptr) { if (tsd->initMagic != INIT_MAGIC) { @@ -138,7 +138,7 @@ u_tsd_set(struct u_tsd *tsd, void *ptr) } -static INLINE void +static inline void u_tsd_destroy(struct u_tsd *tsd) { if (tsd->initMagic != INIT_MAGIC) { From brianp at kemper.freedesktop.org Wed Mar 4 16:23:56 2015 From: brianp at kemper.freedesktop.org (Brian Paul) Date: Wed, 4 Mar 2015 08:23:56 -0800 (PST) Subject: Mesa (master): mapi: use util/macros.h instead of locally defined macros Message-ID: <20150304162356.C3CAC761D4@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 4ab713423ffbdb885910f0c0efcabb594e55d227 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=4ab713423ffbdb885910f0c0efcabb594e55d227 Author: Brian Paul Date: Tue Mar 3 09:11:35 2015 -0700 mapi: use util/macros.h instead of locally defined macros The next step is to get rid of u_compiler.h completely. Reviewed-by: Jose Fonseca --- src/mapi/glapi/SConscript | 1 + src/mapi/u_compiler.h | 22 +--------------------- 2 files changed, 2 insertions(+), 21 deletions(-) diff --git a/src/mapi/glapi/SConscript b/src/mapi/glapi/SConscript index 84a5068..8ded46f 100644 --- a/src/mapi/glapi/SConscript +++ b/src/mapi/glapi/SConscript @@ -27,6 +27,7 @@ if env['platform'] == 'windows': env.Append(CPPDEFINES = ['_GLAPI_NO_EXPORTS']) env.Append(CPPPATH = [ + '#/src', '#/src/mapi', '#/src/mesa', Dir('..'), # src/mapi build path diff --git a/src/mapi/u_compiler.h b/src/mapi/u_compiler.h index 8ed0f71..cd80f68 100644 --- a/src/mapi/u_compiler.h +++ b/src/mapi/u_compiler.h @@ -2,26 +2,6 @@ #define _U_COMPILER_H_ #include "c99_compat.h" /* inline, __func__, etc. */ - -/* Function visibility */ -#ifndef PUBLIC -# if defined(__GNUC__) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)) -# define PUBLIC __attribute__((visibility("default"))) -# elif defined(_MSC_VER) -# define PUBLIC __declspec(dllexport) -# else -# define PUBLIC -# endif -#endif - -#ifndef likely -# if defined(__GNUC__) -# define likely(x) __builtin_expect(!!(x), 1) -# define unlikely(x) __builtin_expect(!!(x), 0) -# else -# define likely(x) (x) -# define unlikely(x) (x) -# endif -#endif +#include "util/macros.h" #endif /* _U_COMPILER_H_ */ From brianp at kemper.freedesktop.org Wed Mar 4 16:23:56 2015 From: brianp at kemper.freedesktop.org (Brian Paul) Date: Wed, 4 Mar 2015 08:23:56 -0800 (PST) Subject: Mesa (master): mapi: remove u_compiler.h Message-ID: <20150304162356.CE7C8761D4@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 8aa9191878a5608fc6e4e8c72bea1d25cd821dec URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=8aa9191878a5608fc6e4e8c72bea1d25cd821dec Author: Brian Paul Date: Tue Mar 3 17:15:05 2015 -0700 mapi: remove u_compiler.h Just include c99_compat.h or util/macros.h where needed. Reviewed-by: Jose Fonseca --- src/mapi/Makefile.sources | 1 - src/mapi/entry.h | 1 - src/mapi/glapi/glapi.h | 1 + src/mapi/mapi.h | 2 -- src/mapi/table.h | 4 +++- src/mapi/u_compiler.h | 7 ------- src/mapi/u_current.h | 6 ++++-- src/mapi/u_execmem.c | 2 +- src/mapi/u_thread.h | 2 +- 9 files changed, 10 insertions(+), 16 deletions(-) diff --git a/src/mapi/Makefile.sources b/src/mapi/Makefile.sources index 41dbb24..a179662 100644 --- a/src/mapi/Makefile.sources +++ b/src/mapi/Makefile.sources @@ -15,7 +15,6 @@ # this mode, compile MAPI_BRIDGE_FILES with MAPI_MODE_BRIDGE defined. MAPI_UTIL_FILES = \ - u_compiler.h \ u_current.c \ u_current.h \ u_execmem.c \ diff --git a/src/mapi/entry.h b/src/mapi/entry.h index dba1c06..7c8137c 100644 --- a/src/mapi/entry.h +++ b/src/mapi/entry.h @@ -28,7 +28,6 @@ #ifndef _ENTRY_H_ #define _ENTRY_H_ -#include "u_compiler.h" typedef void (*mapi_func)(void); diff --git a/src/mapi/glapi/glapi.h b/src/mapi/glapi/glapi.h index e2fa925..e3f76b4 100644 --- a/src/mapi/glapi/glapi.h +++ b/src/mapi/glapi/glapi.h @@ -44,6 +44,7 @@ #ifndef _GLAPI_H #define _GLAPI_H +#include "util/macros.h" #include "u_thread.h" diff --git a/src/mapi/mapi.h b/src/mapi/mapi.h index 2aa8d9f..9adf8b5 100644 --- a/src/mapi/mapi.h +++ b/src/mapi/mapi.h @@ -28,8 +28,6 @@ #ifndef _MAPI_H_ #define _MAPI_H_ -#include "u_compiler.h" - #ifdef _WIN32 #ifdef MAPI_DLL_EXPORTS #define MAPI_EXPORT __declspec(dllexport) diff --git a/src/mapi/table.h b/src/mapi/table.h index 8180db9..e2d6ef0 100644 --- a/src/mapi/table.h +++ b/src/mapi/table.h @@ -28,7 +28,7 @@ #ifndef _TABLE_H_ #define _TABLE_H_ -#include "u_compiler.h" +#include "c99_compat.h" #include "entry.h" #define MAPI_TMP_TABLE @@ -37,6 +37,8 @@ #define MAPI_TABLE_NUM_SLOTS (MAPI_TABLE_NUM_STATIC + MAPI_TABLE_NUM_DYNAMIC) #define MAPI_TABLE_SIZE (MAPI_TABLE_NUM_SLOTS * sizeof(mapi_func)) +struct mapi_table; + extern const mapi_func table_noop_array[]; /** diff --git a/src/mapi/u_compiler.h b/src/mapi/u_compiler.h deleted file mode 100644 index cd80f68..0000000 --- a/src/mapi/u_compiler.h +++ /dev/null @@ -1,7 +0,0 @@ -#ifndef _U_COMPILER_H_ -#define _U_COMPILER_H_ - -#include "c99_compat.h" /* inline, __func__, etc. */ -#include "util/macros.h" - -#endif /* _U_COMPILER_H_ */ diff --git a/src/mapi/u_current.h b/src/mapi/u_current.h index 252e696..ea4f817 100644 --- a/src/mapi/u_current.h +++ b/src/mapi/u_current.h @@ -1,6 +1,10 @@ #ifndef _U_CURRENT_H_ #define _U_CURRENT_H_ +#include "c99_compat.h" +#include "util/macros.h" + + #if defined(MAPI_MODE_UTIL) || defined(MAPI_MODE_GLAPI) || \ defined(MAPI_MODE_BRIDGE) @@ -24,8 +28,6 @@ #else /* MAPI_MODE_UTIL || MAPI_MODE_GLAPI || MAPI_MODE_BRIDGE */ -#include "u_compiler.h" - struct mapi_table; #ifdef GLX_USE_TLS diff --git a/src/mapi/u_execmem.c b/src/mapi/u_execmem.c index ac1cae0..ad6427b 100644 --- a/src/mapi/u_execmem.c +++ b/src/mapi/u_execmem.c @@ -32,7 +32,7 @@ */ -#include "u_compiler.h" +#include "c99_compat.h" #include "u_thread.h" #include "u_execmem.h" diff --git a/src/mapi/u_thread.h b/src/mapi/u_thread.h index 3cd07b5..4dd9515 100644 --- a/src/mapi/u_thread.h +++ b/src/mapi/u_thread.h @@ -44,7 +44,7 @@ #include #include -#include "u_compiler.h" +#include "c99_compat.h" #include "c11/threads.h" From brianp at kemper.freedesktop.org Wed Mar 4 16:23:56 2015 From: brianp at kemper.freedesktop.org (Brian Paul) Date: Wed, 4 Mar 2015 08:23:56 -0800 (PST) Subject: Mesa (master): gallivm: init MM = NULL to silence warning Message-ID: <20150304162356.DB3CB761D4@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 34ff9bc6696f3bb84406850d9bc59dfda4bcf8d6 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=34ff9bc6696f3bb84406850d9bc59dfda4bcf8d6 Author: Brian Paul Date: Tue Mar 3 13:20:56 2015 -0700 gallivm: init MM = NULL to silence warning Reviewed-by: Jose Fonseca --- src/gallium/auxiliary/gallivm/lp_bld_misc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp b/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp index 5210acc..e2578cf 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp +++ b/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp @@ -493,7 +493,7 @@ lp_build_create_jit_compiler_for_module(LLVMExecutionEngineRef *OutJIT, builder.setMCPU(MCPU); #endif - ShaderMemoryManager *MM; + ShaderMemoryManager *MM = NULL; if (useMCJIT) { #if HAVE_LLVM > 0x0303 BaseMemoryManager* JMM = reinterpret_cast(CMM); From brianp at kemper.freedesktop.org Wed Mar 4 16:23:56 2015 From: brianp at kemper.freedesktop.org (Brian Paul) Date: Wed, 4 Mar 2015 08:23:56 -0800 (PST) Subject: Mesa (master): mapi: remove unneeded ARRAY_SIZE #define Message-ID: <20150304162356.91D63761D4@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 25a847d9cc046584aa43894f70da1bf11ba48f09 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=25a847d9cc046584aa43894f70da1bf11ba48f09 Author: Brian Paul Date: Tue Mar 3 09:40:40 2015 -0700 mapi: remove unneeded ARRAY_SIZE #define include util/macros.h instead. Reviewed-by: Jose Fonseca --- src/mapi/Makefile.am | 1 + src/mapi/shared-glapi/SConscript | 1 + src/mapi/stub.c | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/mapi/Makefile.am b/src/mapi/Makefile.am index 90ba571..ef6f5ee 100644 --- a/src/mapi/Makefile.am +++ b/src/mapi/Makefile.am @@ -46,6 +46,7 @@ AM_CPPFLAGS = \ $(DEFINES) \ $(SELINUX_CFLAGS) \ -I$(top_srcdir)/include \ + -I$(top_srcdir)/src \ -I$(top_srcdir)/src/mapi \ -I$(top_builddir)/src/mapi diff --git a/src/mapi/shared-glapi/SConscript b/src/mapi/shared-glapi/SConscript index 07b3eff..26bfe7e 100644 --- a/src/mapi/shared-glapi/SConscript +++ b/src/mapi/shared-glapi/SConscript @@ -37,6 +37,7 @@ def mapi_objects(env, printer, mode): cpppath = [ header[0].dir, '#/include', + '#/src', '#/src/mapi', ] diff --git a/src/mapi/stub.c b/src/mapi/stub.c index dfadbe1..953b6c7 100644 --- a/src/mapi/stub.c +++ b/src/mapi/stub.c @@ -29,13 +29,13 @@ #include #include +#include "util/macros.h" #include "u_current.h" #include "u_thread.h" #include "entry.h" #include "stub.h" #include "table.h" -#define ARRAY_SIZE(x) (sizeof(x)/sizeof((x)[0])) struct mapi_stub { const void *name; From robclark at kemper.freedesktop.org Wed Mar 4 16:39:28 2015 From: robclark at kemper.freedesktop.org (Rob Clark) Date: Wed, 4 Mar 2015 08:39:28 -0800 (PST) Subject: Mesa (master): freedreno/ir3: fix old compiler after f6b2e8af742 Message-ID: <20150304163928.77C9E761D4@kemper.freedesktop.org> Module: Mesa Branch: master Commit: b709adf7cca24412a6c1bb813856ca701e534ffd URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=b709adf7cca24412a6c1bb813856ca701e534ffd Author: Rob Clark Date: Wed Mar 4 11:36:32 2015 -0500 freedreno/ir3: fix old compiler after f6b2e8af742 If first_driver_param is left as zero (calloc'd struct), the result is c0 getting clobbered. Signed-off-by: Rob Clark --- src/gallium/drivers/freedreno/ir3/ir3_compiler_old.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gallium/drivers/freedreno/ir3/ir3_compiler_old.c b/src/gallium/drivers/freedreno/ir3/ir3_compiler_old.c index 3353156..44a629f 100644 --- a/src/gallium/drivers/freedreno/ir3/ir3_compiler_old.c +++ b/src/gallium/drivers/freedreno/ir3/ir3_compiler_old.c @@ -195,6 +195,7 @@ compile_init(struct ir3_compile_context *ctx, struct ir3_shader_variant *so, info->file_max[TGSI_FILE_INPUT] + 1 + info->file_max[TGSI_FILE_OUTPUT] + 1; + so->first_driver_param = ~0; so->first_immediate = ctx->base_reg[TGSI_FILE_IMMEDIATE]; ctx->immediate_idx = 4 * (ctx->info.file_max[TGSI_FILE_IMMEDIATE] + 1); From tstellar at kemper.freedesktop.org Wed Mar 4 17:24:03 2015 From: tstellar at kemper.freedesktop.org (Tom Stellard) Date: Wed, 4 Mar 2015 09:24:03 -0800 (PST) Subject: Mesa (master): egl: Take alpha bits into account when selecting GBM formats Message-ID: <20150304172404.02B8A761D4@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 65c8965d033cf9ade5e6f3c88bda6d247d46af9d URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=65c8965d033cf9ade5e6f3c88bda6d247d46af9d Author: Daniel Stone Date: Mon Mar 2 13:52:59 2015 +0000 egl: Take alpha bits into account when selecting GBM formats This fixes piglit when using PIGLIT_PLATFORM=gbm Tom Stellard: - Fix ARGB2101010 format Cc: "10.4 10.5" Reviewed-by: Alex Deucher Reviewed-by: Chad Versace --- src/egl/drivers/dri2/platform_drm.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/egl/drivers/dri2/platform_drm.c b/src/egl/drivers/dri2/platform_drm.c index 02e87f7..bf205be 100644 --- a/src/egl/drivers/dri2/platform_drm.c +++ b/src/egl/drivers/dri2/platform_drm.c @@ -668,15 +668,21 @@ dri2_initialize_drm(_EGLDriver *drv, _EGLDisplay *disp) for (i = 0; dri2_dpy->driver_configs[i]; i++) { EGLint format, attr_list[3]; - unsigned int mask; + unsigned int red, alpha; dri2_dpy->core->getConfigAttrib(dri2_dpy->driver_configs[i], - __DRI_ATTRIB_RED_MASK, &mask); - if (mask == 0x3ff00000) + __DRI_ATTRIB_RED_MASK, &red); + dri2_dpy->core->getConfigAttrib(dri2_dpy->driver_configs[i], + __DRI_ATTRIB_ALPHA_MASK, &alpha); + if (red == 0x3ff00000 && alpha == 0x00000000) format = GBM_FORMAT_XRGB2101010; - else if (mask == 0x00ff0000) + else if (red == 0x3ff00000 && alpha == 0xc0000000) + format = GBM_FORMAT_ARGB2101010; + else if (red == 0x00ff0000 && alpha == 0x00000000) format = GBM_FORMAT_XRGB8888; - else if (mask == 0xf800) + else if (red == 0x00ff0000 && alpha == 0xff000000) + format = GBM_FORMAT_ARGB8888; + else if (red == 0xf800) format = GBM_FORMAT_RGB565; else continue; From krh at kemper.freedesktop.org Wed Mar 4 17:55:46 2015 From: krh at kemper.freedesktop.org (Kristian Høgsberg) Date: Wed, 4 Mar 2015 09:55:46 -0800 (PST) Subject: Mesa (master): i965: Fix uint64_t overflow in intel_client_wait_sync() Message-ID: <20150304175546.AEEC7761D4@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 10c82c6c5fc415d323a5e9c6acdc6a4c85d6b712 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=10c82c6c5fc415d323a5e9c6acdc6a4c85d6b712 Author: Kristian H?gsberg Date: Mon Mar 2 16:19:52 2015 -0800 i965: Fix uint64_t overflow in intel_client_wait_sync() DRM_IOCTL_I915_GEM_WAIT takes an int64_t for the timeout value but GL_ARB_sync takes an uint64_t. Further, the ioctl used to wait indefinitely when passed a negative timeout, but it's been broken and now returns immediately in that case. Thus, if an application passes UINT64_MAX to wait forever, we overflow to -1LL and return immediately. Work around this mess by clamping the wait timeout to INT64_MAX. Signed-off-by: Kristian H?gsberg Reviewed-by: Chad Versace --- src/mesa/drivers/dri/i965/intel_syncobj.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/mesa/drivers/dri/i965/intel_syncobj.c b/src/mesa/drivers/dri/i965/intel_syncobj.c index 9cde152..e500fa0 100644 --- a/src/mesa/drivers/dri/i965/intel_syncobj.c +++ b/src/mesa/drivers/dri/i965/intel_syncobj.c @@ -84,6 +84,14 @@ static void intel_client_wait_sync(struct gl_context *ctx, struct gl_sync_object { struct intel_sync_object *sync = (struct intel_sync_object *)s; + /* DRM_IOCTL_I915_GEM_WAIT uses a signed 64 bit timeout and returns + * immediately for timeouts <= 0. The best we can do is to clamp the + * timeout to INT64_MAX. This limits the maximum timeout from 584 years to + * 292 years - likely not a big deal. + */ + if (timeout > INT64_MAX) + timeout = INT64_MAX; + if (sync->bo && drm_intel_gem_bo_wait(sync->bo, timeout) == 0) { s->StatusFlag = 1; drm_intel_bo_unreference(sync->bo); From brianp at kemper.freedesktop.org Wed Mar 4 18:14:15 2015 From: brianp at kemper.freedesktop.org (Brian Paul) Date: Wed, 4 Mar 2015 10:14:15 -0800 (PST) Subject: Mesa (master): glx/tests: add -I src/ to fix make check Message-ID: <20150304181415.38F51761D4@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 67e0a4f6e8a6c6d03cf3f9d15797bc14c373711e URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=67e0a4f6e8a6c6d03cf3f9d15797bc14c373711e Author: Brian Paul Date: Wed Mar 4 10:03:09 2015 -0700 glx/tests: add -I src/ to fix make check Reviewed-by: Ian Romanick --- src/glx/tests/Makefile.am | 1 + 1 file changed, 1 insertion(+) diff --git a/src/glx/tests/Makefile.am b/src/glx/tests/Makefile.am index dd82449..b02a9e3 100644 --- a/src/glx/tests/Makefile.am +++ b/src/glx/tests/Makefile.am @@ -2,6 +2,7 @@ if HAVE_SHARED_GLAPI AM_CFLAGS = $(PTHREAD_CFLAGS) AM_CPPFLAGS = \ -I$(top_srcdir)/src/gtest/include \ + -I$(top_srcdir)/src \ -I$(top_srcdir)/src/mapi \ -I$(top_srcdir)/src/mesa \ -I$(top_srcdir)/src/glx \ From mattst88 at kemper.freedesktop.org Wed Mar 4 19:15:14 2015 From: mattst88 at kemper.freedesktop.org (Matt Turner) Date: Wed, 4 Mar 2015 11:15:14 -0800 (PST) Subject: Mesa (master): r300g: Check return value of snprintf(). Message-ID: <20150304191514.EACAF763B7@kemper.freedesktop.org> Module: Mesa Branch: master Commit: ade0b580e75bdea227eec5345f6681b678d0811b URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=ade0b580e75bdea227eec5345f6681b678d0811b Author: Matt Turner Date: Tue Mar 3 16:09:58 2015 -0800 r300g: Check return value of snprintf(). Would have at least prevented the crash the previous patch fixed. Cc: 10.4, 10.5 Bugzilla: https://bugs.gentoo.org/show_bug.cgi?id=540970 Reviewed-by: Tom Stellard --- src/gallium/drivers/r300/compiler/tests/rc_test_helpers.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/gallium/drivers/r300/compiler/tests/rc_test_helpers.c b/src/gallium/drivers/r300/compiler/tests/rc_test_helpers.c index 422bdb0..04c01f1 100644 --- a/src/gallium/drivers/r300/compiler/tests/rc_test_helpers.c +++ b/src/gallium/drivers/r300/compiler/tests/rc_test_helpers.c @@ -541,9 +541,14 @@ unsigned load_program( unsigned *count; char **string_store; unsigned i = 0; + int n; memset(line, 0, sizeof(line)); - snprintf(path, PATH_MAX, TEST_PATH "/%s", filename); + n = snprintf(path, PATH_MAX, TEST_PATH "/%s", filename); + if (n < 0 || n >= PATH_MAX) { + return 0; + } + file = fopen(path, "r"); if (!file) { return 0; From mattst88 at kemper.freedesktop.org Wed Mar 4 19:15:14 2015 From: mattst88 at kemper.freedesktop.org (Matt Turner) Date: Wed, 4 Mar 2015 11:15:14 -0800 (PST) Subject: Mesa (master): r300g: Use PATH_MAX instead of limiting ourselves to 100 chars. Message-ID: <20150304191514.DEFAA761D4@kemper.freedesktop.org> Module: Mesa Branch: master Commit: f5e2aa1324dd6a9666bb21834097d2fbc3cb99b6 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=f5e2aa1324dd6a9666bb21834097d2fbc3cb99b6 Author: Matt Turner Date: Tue Mar 3 16:02:40 2015 -0800 r300g: Use PATH_MAX instead of limiting ourselves to 100 chars. When built with Gentoo's package manager, the Mesa source directory exists seven directories deep. The path to the .test file is too long and is silently truncated, leading to a crash. Just use PATH_MAX. Cc: 10.4, 10.5 Bugzilla: https://bugs.gentoo.org/show_bug.cgi?id=540970 Reviewed-by: Tom Stellard --- src/gallium/drivers/r300/compiler/tests/rc_test_helpers.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/gallium/drivers/r300/compiler/tests/rc_test_helpers.c b/src/gallium/drivers/r300/compiler/tests/rc_test_helpers.c index 7c9d177..422bdb0 100644 --- a/src/gallium/drivers/r300/compiler/tests/rc_test_helpers.c +++ b/src/gallium/drivers/r300/compiler/tests/rc_test_helpers.c @@ -28,6 +28,7 @@ */ #include +#include #include #include #include @@ -528,7 +529,6 @@ void init_compiler( } #define MAX_LINE_LENGTH 100 -#define MAX_PATH_LENGTH 100 unsigned load_program( struct radeon_compiler *c, @@ -536,14 +536,14 @@ unsigned load_program( const char *filename) { char line[MAX_LINE_LENGTH]; - char path[MAX_PATH_LENGTH]; + char path[PATH_MAX]; FILE *file; unsigned *count; char **string_store; unsigned i = 0; memset(line, 0, sizeof(line)); - snprintf(path, MAX_PATH_LENGTH, TEST_PATH "/%s", filename); + snprintf(path, PATH_MAX, TEST_PATH "/%s", filename); file = fopen(path, "r"); if (!file) { return 0; From mattst88 at kemper.freedesktop.org Wed Mar 4 20:33:35 2015 From: mattst88 at kemper.freedesktop.org (Matt Turner) Date: Wed, 4 Mar 2015 12:33:35 -0800 (PST) Subject: Mesa (master): i965/fs: Consider cmod when propagating to inst with different type. Message-ID: <20150304203335.110F6761D4@kemper.freedesktop.org> Module: Mesa Branch: master Commit: bd5e193eae5ba429b20597f814e0b201c73b6d68 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=bd5e193eae5ba429b20597f814e0b201c73b6d68 Author: Matt Turner Date: Fri Feb 27 10:22:21 2015 -0800 i965/fs: Consider cmod when propagating to inst with different type. We can safely propagate the conditional mod to an instruction with a different type if the conditional mod does not involve comparing for equality with zero (or probably NaN, but ignore that for now). This is because -0.0 and +0.0 are both test equal to zero, but their integer representations do not. Cc: 10.5 Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=89317 Reviewed-by: Kenneth Graunke --- .../drivers/dri/i965/brw_fs_cmod_propagation.cpp | 4 ++ .../drivers/dri/i965/test_fs_cmod_propagation.cpp | 67 ++++++++++++++++++++ 2 files changed, 71 insertions(+) diff --git a/src/mesa/drivers/dri/i965/brw_fs_cmod_propagation.cpp b/src/mesa/drivers/dri/i965/brw_fs_cmod_propagation.cpp index c6384ab..58890ee 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_cmod_propagation.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_cmod_propagation.cpp @@ -80,6 +80,10 @@ opt_cmod_propagation_local(fs_visitor *v, bblock_t *block) scan_inst->dst.reg_offset != inst->src[0].reg_offset) break; + /* Comparisons operate differently for ints and floats */ + if (scan_inst->dst.type != inst->dst.type) + break; + /* If the instruction generating inst's source also wrote the * flag, and inst is doing a simple .nz comparison, then inst * is redundant - the appropriate value is already in the flag diff --git a/src/mesa/drivers/dri/i965/test_fs_cmod_propagation.cpp b/src/mesa/drivers/dri/i965/test_fs_cmod_propagation.cpp index fbe4fd9..0287161 100644 --- a/src/mesa/drivers/dri/i965/test_fs_cmod_propagation.cpp +++ b/src/mesa/drivers/dri/i965/test_fs_cmod_propagation.cpp @@ -415,3 +415,70 @@ TEST_F(cmod_propagation_test, movnz) EXPECT_EQ(BRW_OPCODE_CMP, instruction(block0, 0)->opcode); EXPECT_EQ(BRW_CONDITIONAL_GE, instruction(block0, 0)->conditional_mod); } + +TEST_F(cmod_propagation_test, different_types) +{ + fs_reg dest = v->vgrf(glsl_type::int_type); + fs_reg src0 = v->vgrf(glsl_type::int_type); + fs_reg src1 = v->vgrf(glsl_type::int_type); + fs_reg zero(0.0f); + v->emit(BRW_OPCODE_ADD, dest, src0, src1); + v->emit(BRW_OPCODE_CMP, v->reg_null_f, retype(dest, BRW_REGISTER_TYPE_F), + zero) + ->conditional_mod = BRW_CONDITIONAL_G; + + /* = Before = + * + * 0: add(8) dest:D src0:D src1:D + * 1: cmp.g.f0(8) null:F dest:F 0.0f + * + * = After = + * 0: add.g.f0(8) dest:D src0:D src1:D + */ + + v->calculate_cfg(); + bblock_t *block0 = v->cfg->blocks[0]; + + EXPECT_EQ(0, block0->start_ip); + EXPECT_EQ(1, block0->end_ip); + + EXPECT_TRUE(cmod_propagation(v)); + EXPECT_EQ(0, block0->start_ip); + EXPECT_EQ(0, block0->end_ip); + EXPECT_EQ(BRW_OPCODE_ADD, instruction(block0, 0)->opcode); + EXPECT_EQ(BRW_CONDITIONAL_G, instruction(block0, 0)->conditional_mod); +} + +TEST_F(cmod_propagation_test, different_types_cmod_with_zero) +{ + fs_reg dest = v->vgrf(glsl_type::int_type); + fs_reg src0 = v->vgrf(glsl_type::int_type); + fs_reg src1 = v->vgrf(glsl_type::int_type); + fs_reg zero(0.0f); + v->emit(BRW_OPCODE_ADD, dest, src0, src1); + v->emit(BRW_OPCODE_CMP, v->reg_null_f, retype(dest, BRW_REGISTER_TYPE_F), + zero) + ->conditional_mod = BRW_CONDITIONAL_GE; + + /* = Before = + * + * 0: add(8) dest:D src0:D src1:D + * 1: cmp.ge.f0(8) null:F dest:F 0.0f + * + * = After = + * (no changes) + */ + + v->calculate_cfg(); + bblock_t *block0 = v->cfg->blocks[0]; + + EXPECT_EQ(0, block0->start_ip); + EXPECT_EQ(1, block0->end_ip); + + EXPECT_FALSE(cmod_propagation(v)); + EXPECT_EQ(0, block0->start_ip); + EXPECT_EQ(1, block0->end_ip); + EXPECT_EQ(BRW_OPCODE_ADD, instruction(block0, 0)->opcode); + EXPECT_EQ(BRW_OPCODE_CMP, instruction(block0, 1)->opcode); + EXPECT_EQ(BRW_CONDITIONAL_GE, instruction(block0, 1)->conditional_mod); +} From mattst88 at kemper.freedesktop.org Wed Mar 4 20:36:52 2015 From: mattst88 at kemper.freedesktop.org (Matt Turner) Date: Wed, 4 Mar 2015 12:36:52 -0800 (PST) Subject: Mesa (master): i965/fs: Don' t propagate cmod when to inst with different type. Message-ID: <20150304203652.5F7AB761D4@kemper.freedesktop.org> Module: Mesa Branch: master Commit: fc180f436630116ba8811a2b393ce1e7dfcc6c93 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=fc180f436630116ba8811a2b393ce1e7dfcc6c93 Author: Matt Turner Date: Fri Feb 27 10:22:21 2015 -0800 i965/fs: Don't propagate cmod when to inst with different type. Cc: 10.5 Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=89317 Reviewed-by: Kenneth Graunke --- .../drivers/dri/i965/brw_fs_cmod_propagation.cpp | 4 +++ .../drivers/dri/i965/test_fs_cmod_propagation.cpp | 34 ++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/src/mesa/drivers/dri/i965/brw_fs_cmod_propagation.cpp b/src/mesa/drivers/dri/i965/brw_fs_cmod_propagation.cpp index c6384ab..58890ee 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_cmod_propagation.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_cmod_propagation.cpp @@ -80,6 +80,10 @@ opt_cmod_propagation_local(fs_visitor *v, bblock_t *block) scan_inst->dst.reg_offset != inst->src[0].reg_offset) break; + /* Comparisons operate differently for ints and floats */ + if (scan_inst->dst.type != inst->dst.type) + break; + /* If the instruction generating inst's source also wrote the * flag, and inst is doing a simple .nz comparison, then inst * is redundant - the appropriate value is already in the flag diff --git a/src/mesa/drivers/dri/i965/test_fs_cmod_propagation.cpp b/src/mesa/drivers/dri/i965/test_fs_cmod_propagation.cpp index fbe4fd9..cb92abf 100644 --- a/src/mesa/drivers/dri/i965/test_fs_cmod_propagation.cpp +++ b/src/mesa/drivers/dri/i965/test_fs_cmod_propagation.cpp @@ -415,3 +415,37 @@ TEST_F(cmod_propagation_test, movnz) EXPECT_EQ(BRW_OPCODE_CMP, instruction(block0, 0)->opcode); EXPECT_EQ(BRW_CONDITIONAL_GE, instruction(block0, 0)->conditional_mod); } + +TEST_F(cmod_propagation_test, different_types_cmod_with_zero) +{ + fs_reg dest = v->vgrf(glsl_type::int_type); + fs_reg src0 = v->vgrf(glsl_type::int_type); + fs_reg src1 = v->vgrf(glsl_type::int_type); + fs_reg zero(0.0f); + v->emit(BRW_OPCODE_ADD, dest, src0, src1); + v->emit(BRW_OPCODE_CMP, v->reg_null_f, retype(dest, BRW_REGISTER_TYPE_F), + zero) + ->conditional_mod = BRW_CONDITIONAL_GE; + + /* = Before = + * + * 0: add(8) dest:D src0:D src1:D + * 1: cmp.ge.f0(8) null:F dest:F 0.0f + * + * = After = + * (no changes) + */ + + v->calculate_cfg(); + bblock_t *block0 = v->cfg->blocks[0]; + + EXPECT_EQ(0, block0->start_ip); + EXPECT_EQ(1, block0->end_ip); + + EXPECT_FALSE(cmod_propagation(v)); + EXPECT_EQ(0, block0->start_ip); + EXPECT_EQ(1, block0->end_ip); + EXPECT_EQ(BRW_OPCODE_ADD, instruction(block0, 0)->opcode); + EXPECT_EQ(BRW_OPCODE_CMP, instruction(block0, 1)->opcode); + EXPECT_EQ(BRW_CONDITIONAL_GE, instruction(block0, 1)->conditional_mod); +} From mattst88 at kemper.freedesktop.org Wed Mar 4 20:37:46 2015 From: mattst88 at kemper.freedesktop.org (Matt Turner) Date: Wed, 4 Mar 2015 12:37:46 -0800 (PST) Subject: Mesa (master): i965/fs: Don't propagate cmod to inst with different type. Message-ID: <20150304203746.DC9CB761D4@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 1e128e9b69c6336762a2b6ee5d356c763b9ae3b0 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=1e128e9b69c6336762a2b6ee5d356c763b9ae3b0 Author: Matt Turner Date: Fri Feb 27 10:22:21 2015 -0800 i965/fs: Don't propagate cmod to inst with different type. Cc: 10.5 Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=89317 Reviewed-by: Kenneth Graunke --- .../drivers/dri/i965/brw_fs_cmod_propagation.cpp | 4 +++ .../drivers/dri/i965/test_fs_cmod_propagation.cpp | 34 ++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/src/mesa/drivers/dri/i965/brw_fs_cmod_propagation.cpp b/src/mesa/drivers/dri/i965/brw_fs_cmod_propagation.cpp index c6384ab..58890ee 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_cmod_propagation.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_cmod_propagation.cpp @@ -80,6 +80,10 @@ opt_cmod_propagation_local(fs_visitor *v, bblock_t *block) scan_inst->dst.reg_offset != inst->src[0].reg_offset) break; + /* Comparisons operate differently for ints and floats */ + if (scan_inst->dst.type != inst->dst.type) + break; + /* If the instruction generating inst's source also wrote the * flag, and inst is doing a simple .nz comparison, then inst * is redundant - the appropriate value is already in the flag diff --git a/src/mesa/drivers/dri/i965/test_fs_cmod_propagation.cpp b/src/mesa/drivers/dri/i965/test_fs_cmod_propagation.cpp index fbe4fd9..cb92abf 100644 --- a/src/mesa/drivers/dri/i965/test_fs_cmod_propagation.cpp +++ b/src/mesa/drivers/dri/i965/test_fs_cmod_propagation.cpp @@ -415,3 +415,37 @@ TEST_F(cmod_propagation_test, movnz) EXPECT_EQ(BRW_OPCODE_CMP, instruction(block0, 0)->opcode); EXPECT_EQ(BRW_CONDITIONAL_GE, instruction(block0, 0)->conditional_mod); } + +TEST_F(cmod_propagation_test, different_types_cmod_with_zero) +{ + fs_reg dest = v->vgrf(glsl_type::int_type); + fs_reg src0 = v->vgrf(glsl_type::int_type); + fs_reg src1 = v->vgrf(glsl_type::int_type); + fs_reg zero(0.0f); + v->emit(BRW_OPCODE_ADD, dest, src0, src1); + v->emit(BRW_OPCODE_CMP, v->reg_null_f, retype(dest, BRW_REGISTER_TYPE_F), + zero) + ->conditional_mod = BRW_CONDITIONAL_GE; + + /* = Before = + * + * 0: add(8) dest:D src0:D src1:D + * 1: cmp.ge.f0(8) null:F dest:F 0.0f + * + * = After = + * (no changes) + */ + + v->calculate_cfg(); + bblock_t *block0 = v->cfg->blocks[0]; + + EXPECT_EQ(0, block0->start_ip); + EXPECT_EQ(1, block0->end_ip); + + EXPECT_FALSE(cmod_propagation(v)); + EXPECT_EQ(0, block0->start_ip); + EXPECT_EQ(1, block0->end_ip); + EXPECT_EQ(BRW_OPCODE_ADD, instruction(block0, 0)->opcode); + EXPECT_EQ(BRW_OPCODE_CMP, instruction(block0, 1)->opcode); + EXPECT_EQ(BRW_CONDITIONAL_GE, instruction(block0, 1)->conditional_mod); +} From olv at kemper.freedesktop.org Wed Mar 4 20:55:44 2015 From: olv at kemper.freedesktop.org (Chia-I Wu) Date: Wed, 4 Mar 2015 12:55:44 -0800 (PST) Subject: Mesa (master): ilo: add some more winsys functions Message-ID: <20150304205544.9B7AF761D4@kemper.freedesktop.org> Module: Mesa Branch: master Commit: af4cff5d6f74460d34bc10f9dc3a9f91e4e11f2d URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=af4cff5d6f74460d34bc10f9dc3a9f91e4e11f2d Author: Chia-I Wu Date: Wed Mar 4 12:02:12 2015 -0700 ilo: add some more winsys functions Add intel_winsys_get_reset_stats(), intel_winsys_import_userptr(), and intel_bo_map_async(). The latter two are stubs, but we are not going to use them immediately either. --- src/gallium/drivers/ilo/intel_winsys.h | 30 +++++++++++++++++- src/gallium/winsys/intel/drm/intel_drm_winsys.c | 38 ++++++++++++++++++++++- 2 files changed, 66 insertions(+), 2 deletions(-) diff --git a/src/gallium/drivers/ilo/intel_winsys.h b/src/gallium/drivers/ilo/intel_winsys.h index 4ee35d7..5a199e2 100644 --- a/src/gallium/drivers/ilo/intel_winsys.h +++ b/src/gallium/drivers/ilo/intel_winsys.h @@ -112,6 +112,17 @@ intel_winsys_read_reg(struct intel_winsys *winsys, uint32_t reg, uint64_t *val); /** + * Return the numbers of submissions lost due to GPU reset. + * + * \param active_lost Number of lost active/guilty submissions + * \param pending_lost Number of lost pending/innocent submissions + */ +int +intel_winsys_get_reset_stats(struct intel_winsys *winsys, + struct intel_context *ctx, + uint32_t *active_lost, + uint32_t *pending_lost); +/** * Allocate a buffer object. * * \param name Informative description of the bo. @@ -142,6 +153,19 @@ intel_winsys_alloc_buffer(struct intel_winsys *winsys, } /** + * Create a bo from a user memory pointer. Both \p userptr and (\p pitch * \p + * height) must be page aligned. + */ +struct intel_bo * +intel_winsys_import_userptr(struct intel_winsys *winsys, + const char *name, + void *userptr, + enum intel_tiling_mode tiling, + unsigned long pitch, + unsigned long height, + unsigned long flags); + +/** * Create a bo from a winsys handle. */ struct intel_bo * @@ -223,12 +247,16 @@ intel_bo_unreference(struct intel_bo *bo); * sequential writes, but reads would be very slow. Callers always have a * linear view of the bo. * - * map_gtt_async() is similar to map_gtt(), except that it does not block. + * map_async() and map_gtt_async() work similar to map() and map_gtt() + * respectively, except that they do not block. */ void * intel_bo_map(struct intel_bo *bo, bool write_enable); void * +intel_bo_map_async(struct intel_bo *bo); + +void * intel_bo_map_gtt(struct intel_bo *bo); void * diff --git a/src/gallium/winsys/intel/drm/intel_drm_winsys.c b/src/gallium/winsys/intel/drm/intel_drm_winsys.c index 9b94ac6..a41cbb0 100644 --- a/src/gallium/winsys/intel/drm/intel_drm_winsys.c +++ b/src/gallium/winsys/intel/drm/intel_drm_winsys.c @@ -55,6 +55,12 @@ struct intel_winsys { struct drm_intel_decode *decode; }; +static drm_intel_context * +gem_ctx(const struct intel_context *ctx) +{ + return (drm_intel_context *) ctx; +} + static drm_intel_bo * gem_bo(const struct intel_bo *bo) { @@ -244,7 +250,7 @@ void intel_winsys_destroy_context(struct intel_winsys *winsys, struct intel_context *ctx) { - drm_intel_gem_context_destroy((drm_intel_context *) ctx); + drm_intel_gem_context_destroy(gem_ctx(ctx)); } int @@ -254,6 +260,18 @@ intel_winsys_read_reg(struct intel_winsys *winsys, return drm_intel_reg_read(winsys->bufmgr, reg, val); } +int +intel_winsys_get_reset_stats(struct intel_winsys *winsys, + struct intel_context *ctx, + uint32_t *active_lost, + uint32_t *pending_lost) +{ + uint32_t reset_count; + + return drm_intel_get_reset_stats(gem_ctx(ctx), + &reset_count, active_lost, pending_lost); +} + struct intel_bo * intel_winsys_alloc_bo(struct intel_winsys *winsys, const char *name, @@ -308,6 +326,18 @@ intel_winsys_alloc_bo(struct intel_winsys *winsys, } struct intel_bo * +intel_winsys_import_userptr(struct intel_winsys *winsys, + const char *name, + void *userptr, + enum intel_tiling_mode tiling, + unsigned long pitch, + unsigned long height, + unsigned long flags) +{ + return NULL; +} + +struct intel_bo * intel_winsys_import_handle(struct intel_winsys *winsys, const char *name, const struct winsys_handle *handle, @@ -497,6 +527,12 @@ intel_bo_map(struct intel_bo *bo, bool write_enable) } void * +intel_bo_map_async(struct intel_bo *bo) +{ + return NULL; +} + +void * intel_bo_map_gtt(struct intel_bo *bo) { int err; From olv at kemper.freedesktop.org Wed Mar 4 20:55:44 2015 From: olv at kemper.freedesktop.org (Chia-I Wu) Date: Wed, 4 Mar 2015 12:55:44 -0800 (PST) Subject: Mesa (master): ilo: add ILO_DEBUG=hang Message-ID: <20150304205544.A7731763B7@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 68d2e395d9e18898ef74a635a93dfc4501c1c507 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=68d2e395d9e18898ef74a635a93dfc4501c1c507 Author: Chia-I Wu Date: Wed Mar 4 13:07:55 2015 -0700 ilo: add ILO_DEBUG=hang When set, detect and dump the hanging batch bufffer. --- src/gallium/drivers/ilo/ilo_builder.h | 2 +- src/gallium/drivers/ilo/ilo_common.h | 3 ++- src/gallium/drivers/ilo/ilo_cp.c | 38 ++++++++++++++++++++++++++++++++- src/gallium/drivers/ilo/ilo_cp.h | 3 +++ src/gallium/drivers/ilo/ilo_screen.c | 3 ++- 5 files changed, 45 insertions(+), 4 deletions(-) diff --git a/src/gallium/drivers/ilo/ilo_builder.h b/src/gallium/drivers/ilo/ilo_builder.h index 0de7b5d..c902a8f 100644 --- a/src/gallium/drivers/ilo/ilo_builder.h +++ b/src/gallium/drivers/ilo/ilo_builder.h @@ -171,7 +171,7 @@ ilo_builder_writer_checked_record(struct ilo_builder *builder, enum ilo_builder_item_type item, unsigned offset, unsigned size) { - if (unlikely(ilo_debug & ILO_DEBUG_BATCH)) { + if (unlikely(ilo_debug & (ILO_DEBUG_BATCH | ILO_DEBUG_HANG))) { if (!ilo_builder_writer_record(builder, which, item, offset, size)) { builder->unrecoverable_error = true; builder->writers[which].item_used = 0; diff --git a/src/gallium/drivers/ilo/ilo_common.h b/src/gallium/drivers/ilo/ilo_common.h index 23a7080..1ed964f 100644 --- a/src/gallium/drivers/ilo/ilo_common.h +++ b/src/gallium/drivers/ilo/ilo_common.h @@ -63,6 +63,7 @@ enum ilo_debug { ILO_DEBUG_CS = 1 << 4, ILO_DEBUG_DRAW = ILO_DEBUG_HOT << 5, ILO_DEBUG_SUBMIT = 1 << 6, + ILO_DEBUG_HANG = 1 << 7, /* flags that affect the behaviors of the driver */ ILO_DEBUG_NOHW = 1 << 20, @@ -82,7 +83,7 @@ struct ilo_dev_info { bool has_timestamp; bool has_gen7_sol_reset; - /* use ilo_dev_gen() */ + /* use ilo_dev_gen() to access */ int gen_opaque; int gt; diff --git a/src/gallium/drivers/ilo/ilo_cp.c b/src/gallium/drivers/ilo/ilo_cp.c index 67de95b..f78fd1f 100644 --- a/src/gallium/drivers/ilo/ilo_cp.c +++ b/src/gallium/drivers/ilo/ilo_cp.c @@ -105,6 +105,35 @@ ilo_cp_end_batch(struct ilo_cp *cp, unsigned *used) return bo; } +static bool +ilo_cp_detect_hang(struct ilo_cp *cp) +{ + uint32_t active_lost, pending_lost; + bool guilty = false; + + if (likely(!(ilo_debug & ILO_DEBUG_HANG))) + return false; + + /* wait and get reset stats */ + if (intel_bo_wait(cp->last_submitted_bo, -1) || + intel_winsys_get_reset_stats(cp->winsys, cp->render_ctx, + &active_lost, &pending_lost)) + return false; + + if (cp->active_lost != active_lost) { + ilo_err("GPU hang caused by bo %p\n", cp->last_submitted_bo); + cp->active_lost = active_lost; + guilty = true; + } + + if (cp->pending_lost != pending_lost) { + ilo_err("GPU hang detected\n"); + cp->pending_lost = pending_lost; + } + + return guilty; +} + /** * Flush the command parser and execute the commands. When the parser buffer * is empty, the callback is not invoked. @@ -132,13 +161,20 @@ ilo_cp_submit_internal(struct ilo_cp *cp) cp->one_off_flags = 0; if (!err) { + bool guilty; + if (cp->last_submitted_bo) intel_bo_unreference(cp->last_submitted_bo); cp->last_submitted_bo = bo; intel_bo_reference(cp->last_submitted_bo); - if (ilo_debug & ILO_DEBUG_BATCH) + guilty = ilo_cp_detect_hang(cp); + + if (unlikely((ilo_debug & ILO_DEBUG_BATCH) || guilty)) { ilo_builder_decode(&cp->builder); + if (guilty) + abort(); + } if (cp->submit_callback) cp->submit_callback(cp, cp->submit_callback_data); diff --git a/src/gallium/drivers/ilo/ilo_cp.h b/src/gallium/drivers/ilo/ilo_cp.h index 04b3ad5..dcab55b 100644 --- a/src/gallium/drivers/ilo/ilo_cp.h +++ b/src/gallium/drivers/ilo/ilo_cp.h @@ -72,6 +72,9 @@ struct ilo_cp { struct ilo_builder builder; struct intel_bo *last_submitted_bo; + + uint32_t active_lost; + uint32_t pending_lost; }; struct ilo_cp * diff --git a/src/gallium/drivers/ilo/ilo_screen.c b/src/gallium/drivers/ilo/ilo_screen.c index 95e34d3..c9577c8 100644 --- a/src/gallium/drivers/ilo/ilo_screen.c +++ b/src/gallium/drivers/ilo/ilo_screen.c @@ -48,13 +48,14 @@ struct ilo_fence { int ilo_debug; static const struct debug_named_value ilo_debug_flags[] = { - { "batch", ILO_DEBUG_BATCH, "Dump batch/state/surface/instruction buffers" }, + { "batch", ILO_DEBUG_BATCH, "Dump batch/dynamic/surface/instruction buffers" }, { "vs", ILO_DEBUG_VS, "Dump vertex shaders" }, { "gs", ILO_DEBUG_GS, "Dump geometry shaders" }, { "fs", ILO_DEBUG_FS, "Dump fragment shaders" }, { "cs", ILO_DEBUG_CS, "Dump compute shaders" }, { "draw", ILO_DEBUG_DRAW, "Show draw information" }, { "submit", ILO_DEBUG_SUBMIT, "Show batch buffer submissions" }, + { "hang", ILO_DEBUG_HANG, "Detect GPU hangs" }, { "nohw", ILO_DEBUG_NOHW, "Do not send commands to HW" }, { "nocache", ILO_DEBUG_NOCACHE, "Always invalidate HW caches" }, { "nohiz", ILO_DEBUG_NOHIZ, "Disable HiZ" }, From tstellar at kemper.freedesktop.org Wed Mar 4 21:29:04 2015 From: tstellar at kemper.freedesktop.org (Tom Stellard) Date: Wed, 4 Mar 2015 13:29:04 -0800 (PST) Subject: Mesa (master): clover: Fix build since llvm r231270 Message-ID: <20150304212904.E2E8A761D4@kemper.freedesktop.org> Module: Mesa Branch: master Commit: a398168f7238b42c2fbecf940e09fc5ebef71f62 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=a398168f7238b42c2fbecf940e09fc5ebef71f62 Author: Tom Stellard Date: Wed Mar 4 13:09:50 2015 -0800 clover: Fix build since llvm r231270 --- src/gallium/state_trackers/clover/llvm/invocation.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gallium/state_trackers/clover/llvm/invocation.cpp b/src/gallium/state_trackers/clover/llvm/invocation.cpp index 9354812..4da62b9 100644 --- a/src/gallium/state_trackers/clover/llvm/invocation.cpp +++ b/src/gallium/state_trackers/clover/llvm/invocation.cpp @@ -332,7 +332,7 @@ namespace { PM.add(new llvm::DataLayout(mod)); #elif HAVE_LLVM < 0x0306 PM.add(new llvm::DataLayoutPass(mod)); -#else +#elif HAVE_LLVM < 0x0307 PM.add(new llvm::DataLayoutPass()); #endif PM.add(llvm::createInternalizePass(export_list)); From olv at kemper.freedesktop.org Wed Mar 4 22:35:51 2015 From: olv at kemper.freedesktop.org (Chia-I Wu) Date: Wed, 4 Mar 2015 14:35:51 -0800 (PST) Subject: Mesa (master): ilo: clean up Gen7.5 WAs Message-ID: <20150304223551.D811F761D4@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 1424bdd61bce26f0853e974fc3b87c4c275e6ef0 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=1424bdd61bce26f0853e974fc3b87c4c275e6ef0 Author: Chia-I Wu Date: Wed Mar 4 14:09:26 2015 -0700 ilo: clean up Gen7.5 WAs These WAs gen7_wa_post_3dstate_push_constant_alloc_ps() gen7_wa_pre_vs() gen7_wa_pre_3dstate_sf_depth_bias() first half of gen7_wa_pre_depth() gen7_wa_post_ps_and_later() are Gen7-specific. Update copy-and-pasted gen8_wa_pre_depth() also. --- src/gallium/drivers/ilo/ilo_render_gen7.c | 80 ++++++++++++++++------------- src/gallium/drivers/ilo/ilo_render_gen8.c | 14 ----- 2 files changed, 43 insertions(+), 51 deletions(-) diff --git a/src/gallium/drivers/ilo/ilo_render_gen7.c b/src/gallium/drivers/ilo/ilo_render_gen7.c index e76db79..cfb9e2e 100644 --- a/src/gallium/drivers/ilo/ilo_render_gen7.c +++ b/src/gallium/drivers/ilo/ilo_render_gen7.c @@ -59,7 +59,6 @@ gen7_pipe_control(struct ilo_render *r, uint32_t dw1) gen6_PIPE_CONTROL(r->builder, dw1, bo, 0, 0); - r->state.current_pipe_control_dw1 |= dw1; r->state.deferred_pipe_control_dw1 &= ~dw1; } @@ -76,7 +75,7 @@ gen7_wa_post_3dstate_push_constant_alloc_ps(struct ilo_render *r) */ const uint32_t dw1 = GEN6_PIPE_CONTROL_CS_STALL; - ILO_DEV_ASSERT(r->dev, 7, 7.5); + ILO_DEV_ASSERT(r->dev, 7, 7); r->state.deferred_pipe_control_dw1 |= dw1; } @@ -96,7 +95,7 @@ gen7_wa_pre_vs(struct ilo_render *r) const uint32_t dw1 = GEN6_PIPE_CONTROL_DEPTH_STALL | GEN6_PIPE_CONTROL_WRITE_IMM; - ILO_DEV_ASSERT(r->dev, 7, 7.5); + ILO_DEV_ASSERT(r->dev, 7, 7); if ((r->state.current_pipe_control_dw1 & dw1) != dw1) gen7_pipe_control(r, dw1); @@ -114,7 +113,7 @@ gen7_wa_pre_3dstate_sf_depth_bias(struct ilo_render *r) */ const uint32_t dw1 = GEN6_PIPE_CONTROL_CS_STALL; - ILO_DEV_ASSERT(r->dev, 7, 7.5); + ILO_DEV_ASSERT(r->dev, 7, 7); if ((r->state.current_pipe_control_dw1 & dw1) != dw1) gen7_pipe_control(r, dw1); @@ -143,21 +142,23 @@ gen7_wa_pre_3dstate_multisample(struct ilo_render *r) static void gen7_wa_pre_depth(struct ilo_render *r) { - /* - * From the Ivy Bridge PRM, volume 2 part 1, page 315: - * - * "Driver must send a least one PIPE_CONTROL command with CS Stall and - * a post sync operation prior to the group of depth - * commands(3DSTATE_DEPTH_BUFFER, 3DSTATE_CLEAR_PARAMS, - * 3DSTATE_STENCIL_BUFFER, and 3DSTATE_HIER_DEPTH_BUFFER)." - */ - const uint32_t dw1 = GEN6_PIPE_CONTROL_CS_STALL | - GEN6_PIPE_CONTROL_WRITE_IMM; - ILO_DEV_ASSERT(r->dev, 7, 7.5); - if ((r->state.current_pipe_control_dw1 & dw1) != dw1) - gen7_pipe_control(r, dw1); + if (ilo_dev_gen(r->dev) == ILO_GEN(7)) { + /* + * From the Ivy Bridge PRM, volume 2 part 1, page 315: + * + * "Driver must send a least one PIPE_CONTROL command with CS Stall + * and a post sync operation prior to the group of depth + * commands(3DSTATE_DEPTH_BUFFER, 3DSTATE_CLEAR_PARAMS, + * 3DSTATE_STENCIL_BUFFER, and 3DSTATE_HIER_DEPTH_BUFFER)." + */ + const uint32_t dw1 = GEN6_PIPE_CONTROL_CS_STALL | + GEN6_PIPE_CONTROL_WRITE_IMM; + + if ((r->state.current_pipe_control_dw1 & dw1) != dw1) + gen7_pipe_control(r, dw1); + } /* * From the Ivy Bridge PRM, volume 2 part 1, page 315: @@ -215,7 +216,7 @@ gen7_wa_post_ps_and_later(struct ilo_render *r) */ const uint32_t dw1 = GEN6_PIPE_CONTROL_DEPTH_STALL; - ILO_DEV_ASSERT(r->dev, 7, 7.5); + ILO_DEV_ASSERT(r->dev, 7, 7); r->state.deferred_pipe_control_dw1 |= dw1; } @@ -253,7 +254,7 @@ gen7_draw_common_urb(struct ilo_render *r, vs_entry_size *= sizeof(float) * 4; vs_total_size = r->dev->urb_size - offset; - if (ilo_dev_gen(r->dev) < ILO_GEN(8)) + if (ilo_dev_gen(r->dev) == ILO_GEN(7)) gen7_wa_pre_vs(r); gen7_3DSTATE_URB_VS(r->builder, @@ -344,7 +345,7 @@ gen7_draw_vs(struct ilo_render *r, const bool emit_3dstate_vs = (DIRTY(VS) || r->instruction_bo_changed); /* emit depth stall before any of the VS commands */ - if (ilo_dev_gen(r->dev) < ILO_GEN(8)) { + if (ilo_dev_gen(r->dev) == ILO_GEN(7)) { if (emit_3dstate_binding_table || emit_3dstate_sampler_state || emit_3dstate_constant_vs || emit_3dstate_vs) gen7_wa_pre_vs(r); @@ -513,7 +514,9 @@ gen7_draw_sf(struct ilo_render *r, if (DIRTY(RASTERIZER) || DIRTY(FB)) { struct pipe_surface *zs = vec->fb.state.zsbuf; - gen7_wa_pre_3dstate_sf_depth_bias(r); + if (ilo_dev_gen(r->dev) == ILO_GEN(7)) + gen7_wa_pre_3dstate_sf_depth_bias(r); + gen7_3DSTATE_SF(r->builder, (vec->rasterizer) ? &vec->rasterizer->sf : NULL, (zs) ? zs->format : PIPE_FORMAT_NONE, @@ -558,9 +561,7 @@ gen7_draw_wm(struct ilo_render *r, if (DIRTY(FS) || DIRTY(BLEND) || r->instruction_bo_changed) { const bool dual_blend = vec->blend->dual_blend; - if ((ilo_dev_gen(r->dev) == ILO_GEN(7) || - ilo_dev_gen(r->dev) == ILO_GEN(7.5)) && - r->hw_ctx_changed) + if (r->hw_ctx_changed) gen7_wa_pre_3dstate_ps_max_threads(r); gen7_3DSTATE_PS(r->builder, vec->fs, dual_blend); @@ -572,21 +573,23 @@ gen7_draw_wm(struct ilo_render *r, r->state.SCISSOR_RECT); } - /* XXX what is the best way to know if this workaround is needed? */ { const bool emit_3dstate_ps = (DIRTY(FS) || DIRTY(BLEND)); const bool emit_3dstate_depth_buffer = (DIRTY(FB) || DIRTY(DSA) || r->state_bo_changed); - if (emit_3dstate_ps || - session->pcb_fs_changed || - session->viewport_changed || - session->binding_table_fs_changed || - session->sampler_fs_changed || - session->cc_changed || - session->blend_changed || - session->dsa_changed) - gen7_wa_post_ps_and_later(r); + if (ilo_dev_gen(r->dev) == ILO_GEN(7)) { + /* XXX what is the best way to know if this workaround is needed? */ + if (emit_3dstate_ps || + session->pcb_fs_changed || + session->viewport_changed || + session->binding_table_fs_changed || + session->sampler_fs_changed || + session->cc_changed || + session->blend_changed || + session->dsa_changed) + gen7_wa_post_ps_and_later(r); + } if (emit_3dstate_depth_buffer) gen7_wa_pre_depth(r); @@ -716,7 +719,8 @@ gen7_rectlist_pcb_alloc(struct ilo_render *r, gen7_3DSTATE_PUSH_CONSTANT_ALLOC_PS(r->builder, offset, size); - gen7_wa_post_3dstate_push_constant_alloc_ps(r); + if (ilo_dev_gen(r->dev) == ILO_GEN(7)) + gen7_wa_post_3dstate_push_constant_alloc_ps(r); } static void @@ -760,7 +764,8 @@ gen7_rectlist_vs_to_sf(struct ilo_render *r, gen6_disable_3DSTATE_CLIP(r->builder); - gen7_wa_pre_3dstate_sf_depth_bias(r); + if (ilo_dev_gen(r->dev) == ILO_GEN(7)) + gen7_wa_pre_3dstate_sf_depth_bias(r); gen7_3DSTATE_SF(r->builder, NULL, blitter->fb.dst.base.format, blitter->fb.num_samples); @@ -860,7 +865,8 @@ ilo_render_emit_rectlist_commands_gen7(struct ilo_render *r, gen7_rectlist_pcb_alloc(r, blitter); /* needed for any VS-related commands */ - gen7_wa_pre_vs(r); + if (ilo_dev_gen(r->dev) == ILO_GEN(7)) + gen7_wa_pre_vs(r); gen7_rectlist_urb(r, blitter); diff --git a/src/gallium/drivers/ilo/ilo_render_gen8.c b/src/gallium/drivers/ilo/ilo_render_gen8.c index 6b14373..b858041 100644 --- a/src/gallium/drivers/ilo/ilo_render_gen8.c +++ b/src/gallium/drivers/ilo/ilo_render_gen8.c @@ -67,22 +67,8 @@ gen8_pipe_control(struct ilo_render *r, uint32_t dw1) static void gen8_wa_pre_depth(struct ilo_render *r) { - /* - * From the Ivy Bridge PRM, volume 2 part 1, page 315: - * - * "Driver must send a least one PIPE_CONTROL command with CS Stall and - * a post sync operation prior to the group of depth - * commands(3DSTATE_DEPTH_BUFFER, 3DSTATE_CLEAR_PARAMS, - * 3DSTATE_STENCIL_BUFFER, and 3DSTATE_HIER_DEPTH_BUFFER)." - */ - const uint32_t dw1 = GEN6_PIPE_CONTROL_CS_STALL | - GEN6_PIPE_CONTROL_WRITE_IMM; - ILO_DEV_ASSERT(r->dev, 8, 8); - if ((r->state.current_pipe_control_dw1 & dw1) != dw1) - gen8_pipe_control(r, dw1); - /* * From the Ivy Bridge PRM, volume 2 part 1, page 315: * From olv at kemper.freedesktop.org Wed Mar 4 22:35:51 2015 From: olv at kemper.freedesktop.org (Chia-I Wu) Date: Wed, 4 Mar 2015 14:35:51 -0800 (PST) Subject: Mesa (master): ilo: improve WA handling in rectlist path Message-ID: <20150304223551.E4725761D4@kemper.freedesktop.org> Module: Mesa Branch: master Commit: b5eb6f769db71557c86c72c3352db149379fdade URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=b5eb6f769db71557c86c72c3352db149379fdade Author: Chia-I Wu Date: Wed Mar 4 14:38:50 2015 -0700 ilo: improve WA handling in rectlist path Add wrappers for 3DPRIMITIVE to make sure we clear current_pipe_control_dw1 and deferred_pipe_control_dw1 after it. Add missing gen7_wa_post_ps_and_later(). --- src/gallium/drivers/ilo/ilo_render_gen.h | 5 ---- src/gallium/drivers/ilo/ilo_render_gen6.c | 33 +++++++++++++----------- src/gallium/drivers/ilo/ilo_render_gen7.c | 40 +++++++++++++++++------------ src/gallium/drivers/ilo/ilo_render_gen8.c | 20 ++++++++++++++- 4 files changed, 60 insertions(+), 38 deletions(-) diff --git a/src/gallium/drivers/ilo/ilo_render_gen.h b/src/gallium/drivers/ilo/ilo_render_gen.h index 012c3d7..583265f 100644 --- a/src/gallium/drivers/ilo/ilo_render_gen.h +++ b/src/gallium/drivers/ilo/ilo_render_gen.h @@ -439,9 +439,4 @@ gen7_draw_sol(struct ilo_render *r, const struct ilo_state_vector *vec, struct ilo_render_draw_session *session); -void -gen7_draw_vf_draw(struct ilo_render *r, - const struct ilo_state_vector *vec, - struct ilo_render_draw_session *session); - #endif /* ILO_RENDER_GEN_H */ diff --git a/src/gallium/drivers/ilo/ilo_render_gen6.c b/src/gallium/drivers/ilo/ilo_render_gen6.c index 0221acd..7232882 100644 --- a/src/gallium/drivers/ilo/ilo_render_gen6.c +++ b/src/gallium/drivers/ilo/ilo_render_gen6.c @@ -41,7 +41,7 @@ /** * A wrapper for gen6_PIPE_CONTROL(). */ -static inline void +static void gen6_pipe_control(struct ilo_render *r, uint32_t dw1) { struct intel_bo *bo = (dw1 & GEN6_PIPE_CONTROL_WRITE__MASK) ? @@ -56,6 +56,20 @@ gen6_pipe_control(struct ilo_render *r, uint32_t dw1) assert(!r->state.deferred_pipe_control_dw1); } +static void +gen6_3dprimitive(struct ilo_render *r, + const struct pipe_draw_info *info, + const struct ilo_ib_state *ib) +{ + ILO_DEV_ASSERT(r->dev, 6, 6); + + /* 3DPRIMITIVE */ + gen6_3DPRIMITIVE(r->builder, info, ib); + + r->state.current_pipe_control_dw1 = 0; + assert(!r->state.deferred_pipe_control_dw1); +} + /** * This should be called before PIPE_CONTROL. */ @@ -482,18 +496,6 @@ gen6_draw_vf_statistics(struct ilo_render *r, gen6_3DSTATE_VF_STATISTICS(r->builder, false); } -static void -gen6_draw_vf_draw(struct ilo_render *r, - const struct ilo_state_vector *vec, - struct ilo_render_draw_session *session) -{ - /* 3DPRIMITIVE */ - gen6_3DPRIMITIVE(r->builder, vec->draw, &vec->ib); - - r->state.current_pipe_control_dw1 = 0; - assert(!r->state.deferred_pipe_control_dw1); -} - void gen6_draw_vs(struct ilo_render *r, const struct ilo_state_vector *vec, @@ -850,7 +852,8 @@ ilo_render_emit_draw_commands_gen6(struct ilo_render *render, gen6_draw_wm_raster(render, vec, session); gen6_draw_sf_rect(render, vec, session); gen6_draw_vf(render, vec, session); - gen6_draw_vf_draw(render, vec, session); + + gen6_3dprimitive(render, vec->draw, &vec->ib); } static void @@ -995,7 +998,7 @@ ilo_render_emit_rectlist_commands_gen6(struct ilo_render *r, gen6_3DSTATE_DRAWING_RECTANGLE(r->builder, 0, 0, blitter->fb.width, blitter->fb.height); - gen6_3DPRIMITIVE(r->builder, &blitter->draw, NULL); + gen6_3dprimitive(r, &blitter->draw, NULL); } int diff --git a/src/gallium/drivers/ilo/ilo_render_gen7.c b/src/gallium/drivers/ilo/ilo_render_gen7.c index cfb9e2e..2d3f6cf 100644 --- a/src/gallium/drivers/ilo/ilo_render_gen7.c +++ b/src/gallium/drivers/ilo/ilo_render_gen7.c @@ -64,6 +64,23 @@ gen7_pipe_control(struct ilo_render *r, uint32_t dw1) } static void +gen7_3dprimitive(struct ilo_render *r, + const struct pipe_draw_info *info, + const struct ilo_ib_state *ib) +{ + ILO_DEV_ASSERT(r->dev, 7, 7.5); + + if (r->state.deferred_pipe_control_dw1) + gen7_pipe_control(r, r->state.deferred_pipe_control_dw1); + + /* 3DPRIMITIVE */ + gen7_3DPRIMITIVE(r->builder, info, ib); + + r->state.current_pipe_control_dw1 = 0; + r->state.deferred_pipe_control_dw1 = 0; +} + +static void gen7_wa_post_3dstate_push_constant_alloc_ps(struct ilo_render *r) { /* @@ -649,21 +666,6 @@ gen7_draw_wm_multisample(struct ilo_render *r, } void -gen7_draw_vf_draw(struct ilo_render *r, - const struct ilo_state_vector *vec, - struct ilo_render_draw_session *session) -{ - if (r->state.deferred_pipe_control_dw1) - gen7_pipe_control(r, r->state.deferred_pipe_control_dw1); - - /* 3DPRIMITIVE */ - gen7_3DPRIMITIVE(r->builder, vec->draw, &vec->ib); - - r->state.current_pipe_control_dw1 = 0; - r->state.deferred_pipe_control_dw1 = 0; -} - -void ilo_render_emit_draw_commands_gen7(struct ilo_render *render, const struct ilo_state_vector *vec, struct ilo_render_draw_session *session) @@ -696,7 +698,8 @@ ilo_render_emit_draw_commands_gen7(struct ilo_render *render, gen6_draw_wm_raster(render, vec, session); gen6_draw_sf_rect(render, vec, session); gen6_draw_vf(render, vec, session); - gen7_draw_vf_draw(render, vec, session); + + gen7_3dprimitive(render, vec->draw, &vec->ib); } static void @@ -893,7 +896,10 @@ ilo_render_emit_rectlist_commands_gen7(struct ilo_render *r, gen6_3DSTATE_DRAWING_RECTANGLE(r->builder, 0, 0, blitter->fb.width, blitter->fb.height); - gen7_3DPRIMITIVE(r->builder, &blitter->draw, NULL); + if (ilo_dev_gen(r->dev) == ILO_GEN(7)) + gen7_wa_post_ps_and_later(r); + + gen7_3dprimitive(r, &blitter->draw, NULL); } int diff --git a/src/gallium/drivers/ilo/ilo_render_gen8.c b/src/gallium/drivers/ilo/ilo_render_gen8.c index b858041..36fc129 100644 --- a/src/gallium/drivers/ilo/ilo_render_gen8.c +++ b/src/gallium/drivers/ilo/ilo_render_gen8.c @@ -65,6 +65,23 @@ gen8_pipe_control(struct ilo_render *r, uint32_t dw1) } static void +gen8_3dprimitive(struct ilo_render *r, + const struct pipe_draw_info *info, + const struct ilo_ib_state *ib) +{ + ILO_DEV_ASSERT(r->dev, 8, 8); + + if (r->state.deferred_pipe_control_dw1) + gen8_pipe_control(r, r->state.deferred_pipe_control_dw1); + + /* 3DPRIMITIVE */ + gen7_3DPRIMITIVE(r->builder, info, ib); + + r->state.current_pipe_control_dw1 = 0; + r->state.deferred_pipe_control_dw1 = 0; +} + +static void gen8_wa_pre_depth(struct ilo_render *r) { ILO_DEV_ASSERT(r->dev, 8, 8); @@ -309,7 +326,8 @@ ilo_render_emit_draw_commands_gen8(struct ilo_render *render, gen6_draw_wm_raster(render, vec, session); gen6_draw_sf_rect(render, vec, session); gen8_draw_vf(render, vec, session); - gen7_draw_vf_draw(render, vec, session); + + gen8_3dprimitive(render, vec->draw, &vec->ib); } int From vlee at kemper.freedesktop.org Thu Mar 5 01:20:52 2015 From: vlee at kemper.freedesktop.org (Vinson Lee) Date: Wed, 4 Mar 2015 17:20:52 -0800 (PST) Subject: Mesa (master): glsl: Fix GCC unused-variable warning in release build. Message-ID: <20150305012052.D513B761D4@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 29c23644cc8cfe9a1cdd75f79a96a1c9b49d26fa URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=29c23644cc8cfe9a1cdd75f79a96a1c9b49d26fa Author: Vinson Lee Date: Tue Mar 3 18:46:13 2015 -0800 glsl: Fix GCC unused-variable warning in release build. CXX ast_array_index.lo ast_array_index.cpp: In function ?void update_max_array_access(ir_rvalue*, int, YYLTYPE*, _mesa_glsl_parse_state*)?: ast_array_index.cpp:86:30: warning: unused variable ?interface_type? [-Wunused-variable] const glsl_type *interface_type = ^ Signed-off-by: Vinson Lee Reviewed-by: Timothy Arceri --- src/glsl/ast_array_index.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/glsl/ast_array_index.cpp b/src/glsl/ast_array_index.cpp index ff0c757..ecef651 100644 --- a/src/glsl/ast_array_index.cpp +++ b/src/glsl/ast_array_index.cpp @@ -83,11 +83,9 @@ update_max_array_access(ir_rvalue *ir, int idx, YYLTYPE *loc, if (deref_var != NULL) { if (deref_var->var->is_interface_instance()) { - const glsl_type *interface_type = - deref_var->var->get_interface_type(); unsigned field_index = deref_record->record->type->field_index(deref_record->field); - assert(field_index < interface_type->length); + assert(field_index < deref_var->var->get_interface_type()->length); unsigned *const max_ifc_array_access = deref_var->var->get_max_ifc_array_access(); From nroberts at kemper.freedesktop.org Thu Mar 5 13:30:52 2015 From: nroberts at kemper.freedesktop.org (Neil Roberts) Date: Thu, 5 Mar 2015 05:30:52 -0800 (PST) Subject: Mesa (master): Revert "common: Fix PBOs for 1D_ARRAY." Message-ID: <20150305133053.02D21761D4@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 7d10d2feee381739eef97f4720cbadbd65bb4fc6 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=7d10d2feee381739eef97f4720cbadbd65bb4fc6 Author: Neil Roberts Date: Thu Feb 26 12:12:15 2015 +0000 Revert "common: Fix PBOs for 1D_ARRAY." This reverts commit 546aba143d13ba3f993ead4cc30b2404abfc0202. I think the changes to the calls to glBlitFramebuffer from this patch are no different to what it was doing previously because it used to set height to 1 before doing the blits. However it was introducing some problems with the blit for layer 0 because this was no longer special cased. It didn't fix problems with the yoffset which needs to be interpreted as a slice offset. I think a better solution would be to modify the original if statement to cope with the yoffset. Conflicts: src/mesa/drivers/common/meta_tex_subimage.c Cc: "10.5" Reviewed-by: Jason Ekstrand --- src/mesa/drivers/common/meta_tex_subimage.c | 62 +++++++++++---------------- 1 file changed, 26 insertions(+), 36 deletions(-) diff --git a/src/mesa/drivers/common/meta_tex_subimage.c b/src/mesa/drivers/common/meta_tex_subimage.c index 971ed59..1fef79d 100644 --- a/src/mesa/drivers/common/meta_tex_subimage.c +++ b/src/mesa/drivers/common/meta_tex_subimage.c @@ -147,7 +147,7 @@ _mesa_meta_pbo_TexSubImage(struct gl_context *ctx, GLuint dims, struct gl_texture_image *pbo_tex_image; GLenum status; bool success = false; - int z, iters; + int z; /* XXX: This should probably be passed in from somewhere */ const char *where = "_mesa_meta_pbo_TexSubImage"; @@ -200,6 +200,12 @@ _mesa_meta_pbo_TexSubImage(struct gl_context *ctx, GLuint dims, _mesa_BindFramebuffer(GL_READ_FRAMEBUFFER, fbos[0]); _mesa_BindFramebuffer(GL_DRAW_FRAMEBUFFER, fbos[1]); + if (tex_image->TexObject->Target == GL_TEXTURE_1D_ARRAY) { + assert(depth == 1); + depth = height; + height = 1; + } + _mesa_meta_bind_fbo_image(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, pbo_tex_image, 0); /* If this passes on the first layer it should pass on the others */ @@ -223,27 +229,17 @@ _mesa_meta_pbo_TexSubImage(struct gl_context *ctx, GLuint dims, GL_COLOR_BUFFER_BIT, GL_NEAREST)) goto fail; - iters = tex_image->TexObject->Target == GL_TEXTURE_1D_ARRAY ? - height : depth; - - for (z = 1; z < iters; z++) { + for (z = 1; z < depth; z++) { _mesa_meta_bind_fbo_image(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, tex_image, zoffset + z); _mesa_update_state(ctx); - if (tex_image->TexObject->Target == GL_TEXTURE_1D_ARRAY) - _mesa_meta_BlitFramebuffer(ctx, ctx->ReadBuffer, ctx->DrawBuffer, - 0, z, width, z + 1, - xoffset, yoffset, - xoffset + width, yoffset + 1, - GL_COLOR_BUFFER_BIT, GL_NEAREST); - else - _mesa_meta_BlitFramebuffer(ctx, ctx->ReadBuffer, ctx->DrawBuffer, - 0, z * height, width, (z + 1) * height, - xoffset, yoffset, - xoffset + width, yoffset + height, - GL_COLOR_BUFFER_BIT, GL_NEAREST); + _mesa_meta_BlitFramebuffer(ctx, ctx->ReadBuffer, ctx->DrawBuffer, + 0, z * height, width, (z + 1) * height, + xoffset, yoffset, + xoffset + width, yoffset + height, + GL_COLOR_BUFFER_BIT, GL_NEAREST); } success = true; @@ -270,7 +266,7 @@ _mesa_meta_pbo_GetTexSubImage(struct gl_context *ctx, GLuint dims, struct gl_texture_image *pbo_tex_image; GLenum status; bool success = false; - int z, iters; + int z; /* XXX: This should probably be passed in from somewhere */ const char *where = "_mesa_meta_pbo_GetTexSubImage"; @@ -317,6 +313,12 @@ _mesa_meta_pbo_GetTexSubImage(struct gl_context *ctx, GLuint dims, _mesa_GenFramebuffers(2, fbos); + if (tex_image && tex_image->TexObject->Target == GL_TEXTURE_1D_ARRAY) { + assert(depth == 1); + depth = height; + height = 1; + } + /* If we were given a texture, bind it to the read framebuffer. If not, * we're doing a ReadPixels and we should just use whatever framebuffer * the client has bound. @@ -350,29 +352,17 @@ _mesa_meta_pbo_GetTexSubImage(struct gl_context *ctx, GLuint dims, GL_COLOR_BUFFER_BIT, GL_NEAREST)) goto fail; - if (tex_image && tex_image->TexObject->Target == GL_TEXTURE_1D_ARRAY) - iters = height; - else - iters = depth; - - for (z = 1; z < iters; z++) { + for (z = 1; z < depth; z++) { _mesa_meta_bind_fbo_image(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, tex_image, zoffset + z); _mesa_update_state(ctx); - if (tex_image->TexObject->Target == GL_TEXTURE_1D_ARRAY) - _mesa_meta_BlitFramebuffer(ctx, ctx->ReadBuffer, ctx->DrawBuffer, - xoffset, yoffset, - xoffset + width, yoffset + 1, - 0, z, width, z + 1, - GL_COLOR_BUFFER_BIT, GL_NEAREST); - else - _mesa_meta_BlitFramebuffer(ctx, ctx->ReadBuffer, ctx->DrawBuffer, - xoffset, yoffset, - xoffset + width, yoffset + height, - 0, z * height, width, (z + 1) * height, - GL_COLOR_BUFFER_BIT, GL_NEAREST); + _mesa_meta_BlitFramebuffer(ctx, ctx->ReadBuffer, ctx->DrawBuffer, + xoffset, yoffset, + xoffset + width, yoffset + height, + 0, z * height, width, (z + 1) * height, + GL_COLOR_BUFFER_BIT, GL_NEAREST); } success = true; From nroberts at kemper.freedesktop.org Thu Mar 5 13:30:53 2015 From: nroberts at kemper.freedesktop.org (Neil Roberts) Date: Thu, 5 Mar 2015 05:30:53 -0800 (PST) Subject: Mesa (master): meta: Fix the y offset for 1D_ARRAY in _mesa_meta_pbo_TexSubImage Message-ID: <20150305133053.1AAD5761D4@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 7286a6899176a8b26aa794097288eff941f5178c URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=7286a6899176a8b26aa794097288eff941f5178c Author: Neil Roberts Date: Wed Feb 25 15:33:08 2015 +0000 meta: Fix the y offset for 1D_ARRAY in _mesa_meta_pbo_TexSubImage The yoffset needs to be interpreted as a slice offset for 1D array textures. This patch implements that by moving the yoffset into zoffset similar to how it moves the height into depth. Reviewed-by: Jason Ekstrand Cc: "10.5" --- src/mesa/drivers/common/meta_tex_subimage.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/mesa/drivers/common/meta_tex_subimage.c b/src/mesa/drivers/common/meta_tex_subimage.c index f360d64..e29addb 100644 --- a/src/mesa/drivers/common/meta_tex_subimage.c +++ b/src/mesa/drivers/common/meta_tex_subimage.c @@ -205,8 +205,12 @@ _mesa_meta_pbo_TexSubImage(struct gl_context *ctx, GLuint dims, if (tex_image->TexObject->Target == GL_TEXTURE_1D_ARRAY) { assert(depth == 1); + assert(zoffset == 0); depth = height; height = 1; + image_height = 1; + zoffset = yoffset; + yoffset = 0; } _mesa_meta_bind_fbo_image(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, @@ -322,8 +326,12 @@ _mesa_meta_pbo_GetTexSubImage(struct gl_context *ctx, GLuint dims, if (tex_image && tex_image->TexObject->Target == GL_TEXTURE_1D_ARRAY) { assert(depth == 1); + assert(zoffset == 0); depth = height; height = 1; + image_height = 1; + zoffset = yoffset; + yoffset = 0; } /* If we were given a texture, bind it to the read framebuffer. If not, From nroberts at kemper.freedesktop.org Thu Mar 5 13:30:53 2015 From: nroberts at kemper.freedesktop.org (Neil Roberts) Date: Thu, 5 Mar 2015 05:30:53 -0800 (PST) Subject: Mesa (master): meta: Allow GL_UN/PACK_IMAGE_HEIGHT in _mesa_meta_pbo_Get/ TexSubImage Message-ID: <20150305133053.0F1A4761D4@kemper.freedesktop.org> Module: Mesa Branch: master Commit: a08bff1e98b8e630f8bdf341af1491cd99e7d104 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=a08bff1e98b8e630f8bdf341af1491cd99e7d104 Author: Neil Roberts Date: Thu Feb 26 12:53:50 2015 +0000 meta: Allow GL_UN/PACK_IMAGE_HEIGHT in _mesa_meta_pbo_Get/TexSubImage Now that a layered source PBO is interpreted as a single tall 2D image it's quite easy to accept the image height packing option by just creating an image that is tall enough to include the image padding. I'm not sure whether the image height property should affect 1D_ARRAY textures. My intuition and interpretation of the GL spec (which is a bit vague) would be that it shouldn't. However the software fallback path in Mesa uses the property for packing but not for unpacking. The binary NVidia driver uses it for both. This patch doesn't use it for either case so it is different from the software fallback. There is some discussion about this here: http://lists.freedesktop.org/archives/mesa-dev/2015-February/077925.html This is tested by the texsubimage Piglit test with the array and pbo arguments. Previously this test was skipping this code path because it always sets the image height. I've also tested it by modifying the getteximage-targets test. It wasn't using this code path before because it was using the default texture object so this code couldn't successfully create a frame buffer. I also modified it to add some image padding with the image height in the PBO. Reviewed-by: Jason Ekstrand Cc: "10.5" --- src/mesa/drivers/common/meta_tex_subimage.c | 32 +++++++++++++++++---------- 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/src/mesa/drivers/common/meta_tex_subimage.c b/src/mesa/drivers/common/meta_tex_subimage.c index 1fef79d..f360d64 100644 --- a/src/mesa/drivers/common/meta_tex_subimage.c +++ b/src/mesa/drivers/common/meta_tex_subimage.c @@ -144,6 +144,7 @@ _mesa_meta_pbo_TexSubImage(struct gl_context *ctx, GLuint dims, const struct gl_pixelstore_attrib *packing) { GLuint pbo = 0, pbo_tex = 0, fbos[2] = { 0, 0 }; + int full_height, image_height; struct gl_texture_image *pbo_tex_image; GLenum status; bool success = false; @@ -177,14 +178,16 @@ _mesa_meta_pbo_TexSubImage(struct gl_context *ctx, GLuint dims, return true; } - /* Only accept tightly packed pixels from the user. */ - if (packing->ImageHeight != 0 && packing->ImageHeight != height) - return false; + /* For arrays, use a tall (height * depth) 2D texture but taking into + * account the inter-image padding specified with the image height packing + * property. + */ + image_height = packing->ImageHeight == 0 ? height : packing->ImageHeight; + full_height = image_height * (depth - 1) + height; - /* For arrays, use a tall (height * depth) 2D texture. */ pbo_tex_image = create_texture_for_pbo(ctx, create_pbo, GL_PIXEL_UNPACK_BUFFER, - width, height * depth, + width, full_height, format, type, pixels, packing, &pbo, &pbo_tex); if (!pbo_tex_image) @@ -236,7 +239,8 @@ _mesa_meta_pbo_TexSubImage(struct gl_context *ctx, GLuint dims, _mesa_update_state(ctx); _mesa_meta_BlitFramebuffer(ctx, ctx->ReadBuffer, ctx->DrawBuffer, - 0, z * height, width, (z + 1) * height, + 0, z * image_height, + width, z * image_height + height, xoffset, yoffset, xoffset + width, yoffset + height, GL_COLOR_BUFFER_BIT, GL_NEAREST); @@ -263,6 +267,7 @@ _mesa_meta_pbo_GetTexSubImage(struct gl_context *ctx, GLuint dims, const struct gl_pixelstore_attrib *packing) { GLuint pbo = 0, pbo_tex = 0, fbos[2] = { 0, 0 }; + int full_height, image_height; struct gl_texture_image *pbo_tex_image; GLenum status; bool success = false; @@ -296,13 +301,15 @@ _mesa_meta_pbo_GetTexSubImage(struct gl_context *ctx, GLuint dims, return true; } - /* Only accept tightly packed pixels from the user. */ - if (packing->ImageHeight != 0 && packing->ImageHeight != height) - return false; + /* For arrays, use a tall (height * depth) 2D texture but taking into + * account the inter-image padding specified with the image height packing + * property. + */ + image_height = packing->ImageHeight == 0 ? height : packing->ImageHeight; + full_height = image_height * (depth - 1) + height; - /* For arrays, use a tall (height * depth) 2D texture. */ pbo_tex_image = create_texture_for_pbo(ctx, false, GL_PIXEL_PACK_BUFFER, - width, height * depth, + width, full_height * depth, format, type, pixels, packing, &pbo, &pbo_tex); if (!pbo_tex_image) @@ -361,7 +368,8 @@ _mesa_meta_pbo_GetTexSubImage(struct gl_context *ctx, GLuint dims, _mesa_meta_BlitFramebuffer(ctx, ctx->ReadBuffer, ctx->DrawBuffer, xoffset, yoffset, xoffset + width, yoffset + height, - 0, z * height, width, (z + 1) * height, + 0, z * image_height, + width, z * image_height + height, GL_COLOR_BUFFER_BIT, GL_NEAREST); } From brianp at kemper.freedesktop.org Thu Mar 5 14:19:31 2015 From: brianp at kemper.freedesktop.org (Brian Paul) Date: Thu, 5 Mar 2015 06:19:31 -0800 (PST) Subject: Mesa (master): mesa: include c11/threads.h in mtypes.h Message-ID: <20150305141932.00E83761D4@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 028968a3ce317cead6aec29890308f8242d547dd URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=028968a3ce317cead6aec29890308f8242d547dd Author: Brian Paul Date: Wed Mar 4 19:17:56 2015 -0700 mesa: include c11/threads.h in mtypes.h Let's directly include c11/threads.h instead of relying on glapi.h to provide it. Reviewed-by: Matt Turner Reviewed-by: Jos? Fonseca --- src/mesa/main/mtypes.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 6e99773..efeee8b 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -36,6 +36,7 @@ #include /* uint32_t */ #include +#include "c11/threads.h" #include "main/glheader.h" #include "main/config.h" From brianp at kemper.freedesktop.org Thu Mar 5 14:19:32 2015 From: brianp at kemper.freedesktop.org (Brian Paul) Date: Thu, 5 Mar 2015 06:19:32 -0800 (PST) Subject: Mesa (master): mesa: include stdio.h where needed Message-ID: <20150305141932.1636B761D4@kemper.freedesktop.org> Module: Mesa Branch: master Commit: db29869205ecc2d7254698daac3e9027f6c92619 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=db29869205ecc2d7254698daac3e9027f6c92619 Author: Brian Paul Date: Wed Mar 4 19:17:57 2015 -0700 mesa: include stdio.h where needed Instead of relying on glapi.h or some other header to provide it. Acked-by: Matt Turner Reviewed-by: Jos? Fonseca --- src/mesa/main/blit.c | 1 + src/mesa/main/debug.c | 1 + src/mesa/main/dlist.h | 2 +- src/mesa/main/errors.c | 1 + src/mesa/main/execmem.c | 1 + src/mesa/main/framebuffer.c | 2 +- src/mesa/main/imports.c | 1 + src/mesa/main/texobj.c | 1 + src/mesa/main/texstate.c | 1 + src/mesa/main/varray.c | 1 + src/mesa/main/version.c | 1 + src/mesa/math/m_vector.c | 1 + src/mesa/program/prog_statevars.c | 1 + src/mesa/tnl/t_draw.c | 2 ++ src/mesa/tnl/t_vb_render.c | 1 + src/mesa/tnl/t_vertex.c | 1 + src/mesa/vbo/vbo_exec_array.c | 1 + src/mesa/vbo/vbo_exec_draw.c | 1 + src/mesa/vbo/vbo_rebase.c | 1 + src/mesa/vbo/vbo_save_loopback.c | 1 + src/mesa/vbo/vbo_split_copy.c | 2 ++ src/mesa/x86/gen_matypes.c | 2 ++ 22 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/mesa/main/blit.c b/src/mesa/main/blit.c index 2898723..0694466 100644 --- a/src/mesa/main/blit.c +++ b/src/mesa/main/blit.c @@ -28,6 +28,7 @@ */ #include +#include #include "context.h" #include "enums.h" diff --git a/src/mesa/main/debug.c b/src/mesa/main/debug.c index 4522114..eda4937 100644 --- a/src/mesa/main/debug.c +++ b/src/mesa/main/debug.c @@ -23,6 +23,7 @@ * OTHER DEALINGS IN THE SOFTWARE. */ +#include #include "mtypes.h" #include "attrib.h" #include "colormac.h" diff --git a/src/mesa/main/dlist.h b/src/mesa/main/dlist.h index 6189632..a121467 100644 --- a/src/mesa/main/dlist.h +++ b/src/mesa/main/dlist.h @@ -32,7 +32,7 @@ #ifndef DLIST_H #define DLIST_H - +#include #include "main/mtypes.h" diff --git a/src/mesa/main/errors.c b/src/mesa/main/errors.c index 33c1730..8ffbf41 100644 --- a/src/mesa/main/errors.c +++ b/src/mesa/main/errors.c @@ -29,6 +29,7 @@ #include +#include #include "errors.h" #include "enums.h" #include "imports.h" diff --git a/src/mesa/main/execmem.c b/src/mesa/main/execmem.c index 7267cf8..3a13385 100644 --- a/src/mesa/main/execmem.c +++ b/src/mesa/main/execmem.c @@ -31,6 +31,7 @@ */ +#include #include "imports.h" diff --git a/src/mesa/main/framebuffer.c b/src/mesa/main/framebuffer.c index 5df1ecc..4f7736a 100644 --- a/src/mesa/main/framebuffer.c +++ b/src/mesa/main/framebuffer.c @@ -29,7 +29,7 @@ * ushorts, uints, etc. */ - +#include #include "glheader.h" #include "imports.h" #include "blend.h" diff --git a/src/mesa/main/imports.c b/src/mesa/main/imports.c index 752cf5a..a7ffe22 100644 --- a/src/mesa/main/imports.c +++ b/src/mesa/main/imports.c @@ -42,6 +42,7 @@ * OTHER DEALINGS IN THE SOFTWARE. */ +#include #include #include "c99_math.h" #include "imports.h" diff --git a/src/mesa/main/texobj.c b/src/mesa/main/texobj.c index d5aa620..e018ab9 100644 --- a/src/mesa/main/texobj.c +++ b/src/mesa/main/texobj.c @@ -28,6 +28,7 @@ */ +#include #include "bufferobj.h" #include "colortab.h" #include "context.h" diff --git a/src/mesa/main/texstate.c b/src/mesa/main/texstate.c index 78ae7d2..0a7f983 100644 --- a/src/mesa/main/texstate.c +++ b/src/mesa/main/texstate.c @@ -28,6 +28,7 @@ * Texture state handling. */ +#include #include "glheader.h" #include "bufferobj.h" #include "colormac.h" diff --git a/src/mesa/main/varray.c b/src/mesa/main/varray.c index 3db9e06..42e7f89 100644 --- a/src/mesa/main/varray.c +++ b/src/mesa/main/varray.c @@ -24,6 +24,7 @@ */ +#include #include /* for PRId64 macro */ #include "glheader.h" diff --git a/src/mesa/main/version.c b/src/mesa/main/version.c index 4951891..8e0c3ef 100644 --- a/src/mesa/main/version.c +++ b/src/mesa/main/version.c @@ -23,6 +23,7 @@ */ +#include #include "imports.h" #include "mtypes.h" #include "version.h" diff --git a/src/mesa/math/m_vector.c b/src/mesa/math/m_vector.c index ff42396..831f953 100644 --- a/src/mesa/math/m_vector.c +++ b/src/mesa/math/m_vector.c @@ -26,6 +26,7 @@ * New (3.1) transformation code written by Keith Whitwell. */ +#include #include "main/glheader.h" #include "main/imports.h" diff --git a/src/mesa/program/prog_statevars.c b/src/mesa/program/prog_statevars.c index 4cde744..57b25a7 100644 --- a/src/mesa/program/prog_statevars.c +++ b/src/mesa/program/prog_statevars.c @@ -29,6 +29,7 @@ */ +#include #include "main/glheader.h" #include "main/context.h" #include "main/blend.h" diff --git a/src/mesa/tnl/t_draw.c b/src/mesa/tnl/t_draw.c index be3f059..60265d6 100644 --- a/src/mesa/tnl/t_draw.c +++ b/src/mesa/tnl/t_draw.c @@ -25,6 +25,8 @@ * Keith Whitwell */ +#include + #include "main/glheader.h" #include "main/bufferobj.h" #include "main/condrender.h" diff --git a/src/mesa/tnl/t_vb_render.c b/src/mesa/tnl/t_vb_render.c index a090c48..4960ac0 100644 --- a/src/mesa/tnl/t_vb_render.c +++ b/src/mesa/tnl/t_vb_render.c @@ -38,6 +38,7 @@ */ +#include #include "main/glheader.h" #include "main/context.h" #include "main/enums.h" diff --git a/src/mesa/tnl/t_vertex.c b/src/mesa/tnl/t_vertex.c index 90b97a0..369d6d9 100644 --- a/src/mesa/tnl/t_vertex.c +++ b/src/mesa/tnl/t_vertex.c @@ -25,6 +25,7 @@ * Keith Whitwell */ +#include #include "main/glheader.h" #include "main/context.h" #include "main/colormac.h" diff --git a/src/mesa/vbo/vbo_exec_array.c b/src/mesa/vbo/vbo_exec_array.c index 8a36618..3ea775c 100644 --- a/src/mesa/vbo/vbo_exec_array.c +++ b/src/mesa/vbo/vbo_exec_array.c @@ -26,6 +26,7 @@ * **************************************************************************/ +#include #include "main/glheader.h" #include "main/context.h" #include "main/state.h" diff --git a/src/mesa/vbo/vbo_exec_draw.c b/src/mesa/vbo/vbo_exec_draw.c index fa5eba9..91f2ca4 100644 --- a/src/mesa/vbo/vbo_exec_draw.c +++ b/src/mesa/vbo/vbo_exec_draw.c @@ -25,6 +25,7 @@ * Keith Whitwell */ +#include #include "main/glheader.h" #include "main/bufferobj.h" #include "main/compiler.h" diff --git a/src/mesa/vbo/vbo_rebase.c b/src/mesa/vbo/vbo_rebase.c index 82a0b8e..b06df4a 100644 --- a/src/mesa/vbo/vbo_rebase.c +++ b/src/mesa/vbo/vbo_rebase.c @@ -46,6 +46,7 @@ * of zero. */ +#include #include "main/glheader.h" #include "main/imports.h" #include "main/mtypes.h" diff --git a/src/mesa/vbo/vbo_save_loopback.c b/src/mesa/vbo/vbo_save_loopback.c index 8c93ae8..7410f18 100644 --- a/src/mesa/vbo/vbo_save_loopback.c +++ b/src/mesa/vbo/vbo_save_loopback.c @@ -25,6 +25,7 @@ * **************************************************************************/ +#include #include "main/context.h" #include "main/glheader.h" #include "main/enums.h" diff --git a/src/mesa/vbo/vbo_split_copy.c b/src/mesa/vbo/vbo_split_copy.c index ca752e8..d1107dd 100644 --- a/src/mesa/vbo/vbo_split_copy.c +++ b/src/mesa/vbo/vbo_split_copy.c @@ -29,6 +29,8 @@ /* Split indexed primitives with per-vertex copying. */ +#include + #include "main/glheader.h" #include "main/bufferobj.h" #include "main/imports.h" diff --git a/src/mesa/x86/gen_matypes.c b/src/mesa/x86/gen_matypes.c index 1e904aa..18ffb72 100644 --- a/src/mesa/x86/gen_matypes.c +++ b/src/mesa/x86/gen_matypes.c @@ -35,6 +35,8 @@ #ifndef __STDC_FORMAT_MACROS #define __STDC_FORMAT_MACROS #endif + +#include #include #include "main/glheader.h" From brianp at kemper.freedesktop.org Thu Mar 5 14:19:32 2015 From: brianp at kemper.freedesktop.org (Brian Paul) Date: Thu, 5 Mar 2015 06:19:32 -0800 (PST) Subject: Mesa (master): nouveau: include stdio.h where needed Message-ID: <20150305141932.3FCB3761D4@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 78ee6fdb2303a630925405bf12af2b61f20383d7 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=78ee6fdb2303a630925405bf12af2b61f20383d7 Author: Brian Paul Date: Wed Mar 4 19:17:57 2015 -0700 nouveau: include stdio.h where needed Acked-by: Matt Turner Reviewed-by: Jos? Fonseca --- src/mesa/drivers/dri/nouveau/nouveau_context.c | 1 + src/mesa/drivers/dri/nouveau/nouveau_driver.c | 1 + src/mesa/drivers/dri/nouveau/nouveau_screen.c | 1 + 3 files changed, 3 insertions(+) diff --git a/src/mesa/drivers/dri/nouveau/nouveau_context.c b/src/mesa/drivers/dri/nouveau/nouveau_context.c index e1bb7e8..a049d9b 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_context.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_context.c @@ -25,6 +25,7 @@ */ #include +#include #include "nouveau_driver.h" #include "nouveau_context.h" #include "nouveau_bufferobj.h" diff --git a/src/mesa/drivers/dri/nouveau/nouveau_driver.c b/src/mesa/drivers/dri/nouveau/nouveau_driver.c index c1f8672..7f31b28 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_driver.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_driver.c @@ -24,6 +24,7 @@ * */ +#include #include "main/mtypes.h" #include "main/fbobject.h" diff --git a/src/mesa/drivers/dri/nouveau/nouveau_screen.c b/src/mesa/drivers/dri/nouveau/nouveau_screen.c index b9ae959..153f18e 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_screen.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_screen.c @@ -24,6 +24,7 @@ * */ +#include #include #include #include "nouveau_driver.h" From brianp at kemper.freedesktop.org Thu Mar 5 14:19:32 2015 From: brianp at kemper.freedesktop.org (Brian Paul) Date: Thu, 5 Mar 2015 06:19:32 -0800 (PST) Subject: Mesa (master): st/mesa: include stdio.h where needed Message-ID: <20150305141932.5B155761D4@kemper.freedesktop.org> Module: Mesa Branch: master Commit: fe976ceb76d71189eff866ede2538572af09c4bf URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=fe976ceb76d71189eff866ede2538572af09c4bf Author: Brian Paul Date: Wed Mar 4 19:17:57 2015 -0700 st/mesa: include stdio.h where needed Acked-by: Matt Turner Reviewed-by: Jos? Fonseca --- src/mesa/state_tracker/st_atom.c | 1 + src/mesa/state_tracker/st_cb_texture.c | 1 + 2 files changed, 2 insertions(+) diff --git a/src/mesa/state_tracker/st_atom.c b/src/mesa/state_tracker/st_atom.c index 8cc6af2..f0fe11f 100644 --- a/src/mesa/state_tracker/st_atom.c +++ b/src/mesa/state_tracker/st_atom.c @@ -26,6 +26,7 @@ **************************************************************************/ +#include #include "main/glheader.h" #include "main/context.h" diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c index 0525e87..a8b19a1 100644 --- a/src/mesa/state_tracker/st_cb_texture.c +++ b/src/mesa/state_tracker/st_cb_texture.c @@ -25,6 +25,7 @@ * **************************************************************************/ +#include #include "main/bufferobj.h" #include "main/enums.h" #include "main/fbobject.h" From brianp at kemper.freedesktop.org Thu Mar 5 14:19:32 2015 From: brianp at kemper.freedesktop.org (Brian Paul) Date: Thu, 5 Mar 2015 06:19:32 -0800 (PST) Subject: Mesa (master): st/xlib: include stdio.h Message-ID: <20150305141932.681D8761D4@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 68579c4a5c43bf946b6a1301d360468761d46644 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=68579c4a5c43bf946b6a1301d360468761d46644 Author: Brian Paul Date: Wed Mar 4 19:17:57 2015 -0700 st/xlib: include stdio.h Acked-by: Matt Turner Reviewed-by: Jos? Fonseca --- src/gallium/state_trackers/glx/xlib/glx_api.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gallium/state_trackers/glx/xlib/glx_api.c b/src/gallium/state_trackers/glx/xlib/glx_api.c index f59b0ba..d1bd760 100644 --- a/src/gallium/state_trackers/glx/xlib/glx_api.c +++ b/src/gallium/state_trackers/glx/xlib/glx_api.c @@ -33,6 +33,7 @@ #define GLX_GLXEXT_PROTOTYPES #include "GL/glx.h" +#include #include #include From brianp at kemper.freedesktop.org Thu Mar 5 14:19:32 2015 From: brianp at kemper.freedesktop.org (Brian Paul) Date: Thu, 5 Mar 2015 06:19:32 -0800 (PST) Subject: Mesa (master): st/xlib: include stdio.h Message-ID: <20150305141932.7323C761D4@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 8c68987d0962f0a6c0b5157ccc2d8ab074fbadfd URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=8c68987d0962f0a6c0b5157ccc2d8ab074fbadfd Author: Brian Paul Date: Wed Mar 4 19:17:57 2015 -0700 st/xlib: include stdio.h Acked-by: Matt Turner Reviewed-by: Jos? Fonseca --- src/gallium/state_trackers/glx/xlib/glx_usefont.c | 1 + src/gallium/state_trackers/glx/xlib/xm_api.c | 1 + 2 files changed, 2 insertions(+) diff --git a/src/gallium/state_trackers/glx/xlib/glx_usefont.c b/src/gallium/state_trackers/glx/xlib/glx_usefont.c index f7ee68b..b3e9c79 100644 --- a/src/gallium/state_trackers/glx/xlib/glx_usefont.c +++ b/src/gallium/state_trackers/glx/xlib/glx_usefont.c @@ -30,6 +30,7 @@ */ +#include #include "main/core.h" #include diff --git a/src/gallium/state_trackers/glx/xlib/xm_api.c b/src/gallium/state_trackers/glx/xlib/xm_api.c index e6f40c3..a0ee59c 100644 --- a/src/gallium/state_trackers/glx/xlib/xm_api.c +++ b/src/gallium/state_trackers/glx/xlib/xm_api.c @@ -53,6 +53,7 @@ #undef __WIN32__ #endif +#include #include "xm_api.h" #include "xm_st.h" From brianp at kemper.freedesktop.org Thu Mar 5 14:19:32 2015 From: brianp at kemper.freedesktop.org (Brian Paul) Date: Thu, 5 Mar 2015 06:19:32 -0800 (PST) Subject: Mesa (master): st/osmesa: include stdio.h Message-ID: <20150305141932.7D490761D4@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 8f1a11bfc4a48abff77f80dd3c2b043efc9787d4 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=8f1a11bfc4a48abff77f80dd3c2b043efc9787d4 Author: Brian Paul Date: Wed Mar 4 19:17:57 2015 -0700 st/osmesa: include stdio.h Acked-by: Matt Turner Reviewed-by: Jos? Fonseca --- src/gallium/state_trackers/osmesa/osmesa.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gallium/state_trackers/osmesa/osmesa.c b/src/gallium/state_trackers/osmesa/osmesa.c index 4e2b2e0..2d5d096 100644 --- a/src/gallium/state_trackers/osmesa/osmesa.c +++ b/src/gallium/state_trackers/osmesa/osmesa.c @@ -49,6 +49,7 @@ */ +#include #include "GL/osmesa.h" #include "glapi/glapi.h" /* for OSMesaGetProcAddress below */ From brianp at kemper.freedesktop.org Thu Mar 5 14:19:32 2015 From: brianp at kemper.freedesktop.org (Brian Paul) Date: Thu, 5 Mar 2015 06:19:32 -0800 (PST) Subject: Mesa (master): xlib: include stdio.h Message-ID: <20150305141932.8C743761D4@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 80524549f06cc98cb77d18715a79c0fc989c0bff URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=80524549f06cc98cb77d18715a79c0fc989c0bff Author: Brian Paul Date: Wed Mar 4 19:17:57 2015 -0700 xlib: include stdio.h Acked-by: Matt Turner Reviewed-by: Jos? Fonseca --- src/mesa/drivers/x11/fakeglx.c | 2 +- src/mesa/drivers/x11/xfonts.c | 1 + src/mesa/drivers/x11/xm_api.c | 1 + src/mesa/drivers/x11/xm_tri.c | 1 + 4 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/mesa/drivers/x11/fakeglx.c b/src/mesa/drivers/x11/fakeglx.c index 00c583f..3869e94 100644 --- a/src/mesa/drivers/x11/fakeglx.c +++ b/src/mesa/drivers/x11/fakeglx.c @@ -40,7 +40,7 @@ */ - +#include #include "glxheader.h" #include "glxapi.h" #include "main/context.h" diff --git a/src/mesa/drivers/x11/xfonts.c b/src/mesa/drivers/x11/xfonts.c index e9a38ba..8405013 100644 --- a/src/mesa/drivers/x11/xfonts.c +++ b/src/mesa/drivers/x11/xfonts.c @@ -28,6 +28,7 @@ * Copyright (C) 1995 Thorsten.Ohl @ Physik.TH-Darmstadt.de */ +#include #include "glxheader.h" #include "main/context.h" #include "main/imports.h" diff --git a/src/mesa/drivers/x11/xm_api.c b/src/mesa/drivers/x11/xm_api.c index 89c219e..681b81a 100644 --- a/src/mesa/drivers/x11/xm_api.c +++ b/src/mesa/drivers/x11/xm_api.c @@ -62,6 +62,7 @@ #undef __WIN32__ #endif +#include #include "glxheader.h" #include "xmesaP.h" #include "main/api_exec.h" diff --git a/src/mesa/drivers/x11/xm_tri.c b/src/mesa/drivers/x11/xm_tri.c index 528d10b..da26235 100644 --- a/src/mesa/drivers/x11/xm_tri.c +++ b/src/mesa/drivers/x11/xm_tri.c @@ -30,6 +30,7 @@ */ +#include #include "c99_math.h" #include "main/imports.h" #include "main/mtypes.h" From brianp at kemper.freedesktop.org Thu Mar 5 14:19:32 2015 From: brianp at kemper.freedesktop.org (Brian Paul) Date: Thu, 5 Mar 2015 06:19:32 -0800 (PST) Subject: Mesa (master): osmesa: include stdio.h Message-ID: <20150305141932.97260761D4@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 83926b8193cfbb3ad259760567babb4eab7c5fe7 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=83926b8193cfbb3ad259760567babb4eab7c5fe7 Author: Brian Paul Date: Wed Mar 4 19:17:57 2015 -0700 osmesa: include stdio.h Acked-by: Matt Turner Reviewed-by: Jos? Fonseca --- src/mesa/drivers/osmesa/osmesa.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/mesa/drivers/osmesa/osmesa.c b/src/mesa/drivers/osmesa/osmesa.c index 9f1a5a8..022523e 100644 --- a/src/mesa/drivers/osmesa/osmesa.c +++ b/src/mesa/drivers/osmesa/osmesa.c @@ -33,6 +33,7 @@ */ +#include #include "main/glheader.h" #include "GL/osmesa.h" #include "main/api_exec.h" From brianp at kemper.freedesktop.org Thu Mar 5 14:19:32 2015 From: brianp at kemper.freedesktop.org (Brian Paul) Date: Thu, 5 Mar 2015 06:19:32 -0800 (PST) Subject: Mesa (master): mapi: fix preprocessor check in u_current_destroy() Message-ID: <20150305141932.ABA72761D4@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 6b5eb7bce6ac5351b0c96252a1c8738f51834e1d URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=6b5eb7bce6ac5351b0c96252a1c8738f51834e1d Author: Brian Paul Date: Wed Mar 4 19:17:57 2015 -0700 mapi: fix preprocessor check in u_current_destroy() So it matches the preprocessor check around the u_current_init_tsd() code. Reviewed-by: Matt Turner Reviewed-by: Jos? Fonseca --- src/mapi/u_current.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mapi/u_current.c b/src/mapi/u_current.c index afa887e..eb77cc7 100644 --- a/src/mapi/u_current.c +++ b/src/mapi/u_current.c @@ -125,7 +125,7 @@ static int ThreadSafe; void u_current_destroy(void) { -#if defined(THREADS) && defined(_WIN32) +#if defined(THREADS) && !defined(GLX_USE_TLS) u_tsd_destroy(&u_current_table_tsd); u_tsd_destroy(&u_current_context_tsd); #endif From brianp at kemper.freedesktop.org Thu Mar 5 14:19:32 2015 From: brianp at kemper.freedesktop.org (Brian Paul) Date: Thu, 5 Mar 2015 06:19:32 -0800 (PST) Subject: Mesa (master): mapi: rewrite u_current_init() function without u_thread_self() Message-ID: <20150305141932.B6630761D4@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 458c7490c29ef2960a33a089f65490e044da5d27 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=458c7490c29ef2960a33a089f65490e044da5d27 Author: Brian Paul Date: Wed Mar 4 19:17:57 2015 -0700 mapi: rewrite u_current_init() function without u_thread_self() Remove u_thread_self() since u_thread.h is going away soon. Create a simple thread ID abstraction which wraps WIN32 or c11 threads. This also gets rid of the questionable casting of thrd_t to an unsigned long. Reviewed-by: Matt Turner Reviewed-by: Jos? Fonseca --- src/mapi/u_current.c | 43 ++++++++++++++++++++++++++++++++++++++++--- src/mapi/u_thread.h | 24 ------------------------ 2 files changed, 40 insertions(+), 27 deletions(-) diff --git a/src/mapi/u_current.c b/src/mapi/u_current.c index eb77cc7..c1a486b 100644 --- a/src/mapi/u_current.c +++ b/src/mapi/u_current.c @@ -146,6 +146,43 @@ u_current_init_tsd(void) */ static mtx_t ThreadCheckMutex = _MTX_INITIALIZER_NP; + +#ifdef _WIN32 +typedef DWORD thread_id; +#else +typedef thrd_t thread_id; +#endif + + +static inline thread_id +get_thread_id(void) +{ + /* + * XXX: Callers of of this function assume it is a lightweight function. + * But unfortunately C11's thrd_current() gives no such guarantees. In + * fact, it's pretty hard to have a compliant implementation of + * thrd_current() on Windows with such characteristics. So for now, we + * side-step this mess and use Windows thread primitives directly here. + */ +#ifdef _WIN32 + return GetCurrentThreadId(); +#else + return thrd_current(); +#endif +} + + +static inline int +thread_id_equal(thread_id t1, thread_id t2) +{ +#ifdef _WIN32 + return t1 == t2; +#else + return thrd_equal(t1, t2); +#endif +} + + /** * We should call this periodically from a function such as glXMakeCurrent * in order to test if multiple threads are being used. @@ -153,7 +190,7 @@ static mtx_t ThreadCheckMutex = _MTX_INITIALIZER_NP; void u_current_init(void) { - static unsigned long knownID; + static thread_id knownID; static int firstCall = 1; if (ThreadSafe) @@ -163,10 +200,10 @@ u_current_init(void) if (firstCall) { u_current_init_tsd(); - knownID = u_thread_self(); + knownID = get_thread_id(); firstCall = 0; } - else if (knownID != u_thread_self()) { + else if (!thread_id_equal(knownID, get_thread_id())) { ThreadSafe = 1; u_current_set_table(NULL); u_current_set_context(NULL); diff --git a/src/mapi/u_thread.h b/src/mapi/u_thread.h index 4dd9515..e57c69a 100644 --- a/src/mapi/u_thread.h +++ b/src/mapi/u_thread.h @@ -80,30 +80,6 @@ struct u_tsd { }; -static inline unsigned long -u_thread_self(void) -{ - /* - * XXX: Callers of u_thread_self assume it is a lightweight function, - * returning a numeric value. But unfortunately C11's thrd_current() gives - * no such guarantees. In fact, it's pretty hard to have a compliant - * implementation of thrd_current() on Windows with such characteristics. - * So for now, we side-step this mess and use Windows thread primitives - * directly here. - * - * FIXME: On the other hand, u_thread_self() is a bad - * abstraction. Even with pthreads, there is no guarantee that - * pthread_self() will return numeric IDs -- we should be using - * pthread_equal() instead of assuming we can compare thread ids... - */ -#ifdef _WIN32 - return GetCurrentThreadId(); -#else - return (unsigned long) (uintptr_t) thrd_current(); -#endif -} - - static inline void u_tsd_init(struct u_tsd *tsd) { From brianp at kemper.freedesktop.org Thu Mar 5 14:19:32 2015 From: brianp at kemper.freedesktop.org (Brian Paul) Date: Thu, 5 Mar 2015 06:19:32 -0800 (PST) Subject: Mesa (master): mesa: remove THREADS check, printf calls in debug.c Message-ID: <20150305141932.C0AE2761D4@kemper.freedesktop.org> Module: Mesa Branch: master Commit: fac77912b5faa2394e0c0a88f3862eae9d87967a URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=fac77912b5faa2394e0c0a88f3862eae9d87967a Author: Brian Paul Date: Wed Mar 4 19:17:57 2015 -0700 mesa: remove THREADS check, printf calls in debug.c THREADS is going away in the next commit. Reviewed-by: Matt Turner Reviewed-by: Jos? Fonseca --- src/mesa/main/debug.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/mesa/main/debug.c b/src/mesa/main/debug.c index eda4937..b50d79e 100644 --- a/src/mesa/main/debug.c +++ b/src/mesa/main/debug.c @@ -118,11 +118,6 @@ void _mesa_print_info( struct gl_context *ctx ) */ _mesa_debug(NULL, "Mesa GL_EXTENSIONS = %s\n", ctx->Extensions.String); -#if defined(THREADS) - _mesa_debug(NULL, "Mesa thread-safe: YES\n"); -#else - _mesa_debug(NULL, "Mesa thread-safe: NO\n"); -#endif #if defined(USE_X86_ASM) _mesa_debug(NULL, "Mesa x86-optimized: YES\n"); #else From brianp at kemper.freedesktop.org Thu Mar 5 14:19:32 2015 From: brianp at kemper.freedesktop.org (Brian Paul) Date: Thu, 5 Mar 2015 06:19:32 -0800 (PST) Subject: Mesa (master): mapi: use c11 call_once() instead of pthread_once() Message-ID: <20150305141932.DC519761D4@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 262cd683e22ec64645a50b558f91001b75ea2000 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=262cd683e22ec64645a50b558f91001b75ea2000 Author: Brian Paul Date: Wed Mar 4 19:17:57 2015 -0700 mapi: use c11 call_once() instead of pthread_once() Reviewed-by: Matt Turner Reviewed-by: Jos? Fonseca --- src/mapi/glapi/glapi_entrypoint.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/mapi/glapi/glapi_entrypoint.c b/src/mapi/glapi/glapi_entrypoint.c index 53104ce..7facd8a 100644 --- a/src/mapi/glapi/glapi_entrypoint.c +++ b/src/mapi/glapi/glapi_entrypoint.c @@ -29,6 +29,7 @@ */ +#include "c11/threads.h" #include "glapi/glapi_priv.h" #include "u_execmem.h" @@ -336,7 +337,7 @@ void init_glapi_relocs_once( void ) { #if defined(HAVE_PTHREAD) || defined(GLX_USE_TLS) - static pthread_once_t once_control = PTHREAD_ONCE_INIT; - pthread_once( & once_control, init_glapi_relocs ); + static once_flag flag = ONCE_FLAG_INIT; + call_once(&flag, init_glapi_relocs); #endif } From brianp at kemper.freedesktop.org Thu Mar 5 14:19:32 2015 From: brianp at kemper.freedesktop.org (Brian Paul) Date: Thu, 5 Mar 2015 06:19:32 -0800 (PST) Subject: Mesa (master): glsl: include stdio.h where needed Message-ID: <20150305141932.20BA3761D4@kemper.freedesktop.org> Module: Mesa Branch: master Commit: db9a088d329453bcdc770e5caf7578c1eaf67aa7 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=db9a088d329453bcdc770e5caf7578c1eaf67aa7 Author: Brian Paul Date: Wed Mar 4 19:17:57 2015 -0700 glsl: include stdio.h where needed Acked-by: Matt Turner Reviewed-by: Jos? Fonseca --- src/glsl/s_expression.cpp | 1 + src/glsl/standalone_scaffolding.cpp | 1 + 2 files changed, 2 insertions(+) diff --git a/src/glsl/s_expression.cpp b/src/glsl/s_expression.cpp index 2928a4d..7eaa491 100644 --- a/src/glsl/s_expression.cpp +++ b/src/glsl/s_expression.cpp @@ -24,6 +24,7 @@ #include #include +#include #include "s_expression.h" s_symbol::s_symbol(const char *str, size_t n) diff --git a/src/glsl/standalone_scaffolding.cpp b/src/glsl/standalone_scaffolding.cpp index ad0d75b..6f5a27f 100644 --- a/src/glsl/standalone_scaffolding.cpp +++ b/src/glsl/standalone_scaffolding.cpp @@ -30,6 +30,7 @@ #include "standalone_scaffolding.h" #include +#include #include #include "util/ralloc.h" From brianp at kemper.freedesktop.org Thu Mar 5 14:19:32 2015 From: brianp at kemper.freedesktop.org (Brian Paul) Date: Thu, 5 Mar 2015 06:19:32 -0800 (PST) Subject: Mesa (master): mapi: remove u_thread.h Message-ID: <20150305141932.E479E761D4@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 9385c592c68e7304cd9084fe17f27ec17319cdcf URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=9385c592c68e7304cd9084fe17f27ec17319cdcf Author: Brian Paul Date: Wed Mar 4 19:17:57 2015 -0700 mapi: remove u_thread.h Just use c11 threads directly. Reviewed-by: Matt Turner Reviewed-by: Jos? Fonseca --- src/mapi/Makefile.sources | 3 +-- src/mapi/glapi/glapi.h | 1 - src/mapi/mapi.c | 1 - src/mapi/stub.c | 14 +++----------- src/mapi/u_current.c | 28 ++++++++++++++-------------- src/mapi/u_execmem.c | 2 +- 6 files changed, 19 insertions(+), 30 deletions(-) diff --git a/src/mapi/Makefile.sources b/src/mapi/Makefile.sources index 4e92f5e..07063f3 100644 --- a/src/mapi/Makefile.sources +++ b/src/mapi/Makefile.sources @@ -18,8 +18,7 @@ MAPI_UTIL_FILES = \ u_current.c \ u_current.h \ u_execmem.c \ - u_execmem.h \ - u_thread.h + u_execmem.h MAPI_BRIDGE_FILES = \ entry.c \ diff --git a/src/mapi/glapi/glapi.h b/src/mapi/glapi/glapi.h index b2d6632..8d991fb 100644 --- a/src/mapi/glapi/glapi.h +++ b/src/mapi/glapi/glapi.h @@ -45,7 +45,6 @@ #define _GLAPI_H #include "util/macros.h" -#include "u_thread.h" #ifdef __cplusplus diff --git a/src/mapi/mapi.c b/src/mapi/mapi.c index aa6b91b..c235adc 100644 --- a/src/mapi/mapi.c +++ b/src/mapi/mapi.c @@ -29,7 +29,6 @@ #include #include "u_current.h" -#include "u_thread.h" #include "mapi.h" #include "stub.h" #include "table.h" diff --git a/src/mapi/stub.c b/src/mapi/stub.c index 953b6c7..05436ba 100644 --- a/src/mapi/stub.c +++ b/src/mapi/stub.c @@ -28,10 +28,10 @@ #include #include #include +#include "c11/threads.h" #include "util/macros.h" #include "u_current.h" -#include "u_thread.h" #include "entry.h" #include "stub.h" #include "table.h" @@ -54,16 +54,8 @@ static int next_dynamic_slot = MAPI_TABLE_NUM_STATIC; void stub_init_once(void) { -#ifdef HAVE_PTHREAD - static pthread_once_t once = PTHREAD_ONCE_INIT; - pthread_once(&once, entry_patch_public); -#else - static int first = 1; - if (first) { - first = 0; - entry_patch_public(); - } -#endif + static once_flag flag = ONCE_FLAG_INIT; + call_once(&flag, entry_patch_public); } static int diff --git a/src/mapi/u_current.c b/src/mapi/u_current.c index 0365724..7e7e275 100644 --- a/src/mapi/u_current.c +++ b/src/mapi/u_current.c @@ -48,8 +48,8 @@ * drivers! No changes to the public glapi interface. */ +#include "c11/threads.h" #include "u_current.h" -#include "u_thread.h" #ifndef MAPI_MODE_UTIL @@ -112,8 +112,8 @@ struct mapi_table *u_current_table = (struct mapi_table *) table_noop_array; void *u_current_context; -struct u_tsd u_current_table_tsd; -static struct u_tsd u_current_context_tsd; +tss_t u_current_table_tsd; +static tss_t u_current_context_tsd; static int ThreadSafe; #endif /* defined(GLX_USE_TLS) */ @@ -124,8 +124,8 @@ void u_current_destroy(void) { #if !defined(GLX_USE_TLS) - u_tsd_destroy(&u_current_table_tsd); - u_tsd_destroy(&u_current_context_tsd); + tss_delete(u_current_table_tsd); + tss_delete(u_current_context_tsd); #endif } @@ -135,8 +135,8 @@ u_current_destroy(void) static void u_current_init_tsd(void) { - u_tsd_init(&u_current_table_tsd); - u_tsd_init(&u_current_context_tsd); + tss_create(&u_current_table_tsd, NULL); + tss_create(&u_current_context_tsd, NULL); } /** @@ -233,7 +233,7 @@ u_current_set_context(const void *ptr) #if defined(GLX_USE_TLS) u_current_context = (void *) ptr; #else - u_tsd_set(&u_current_context_tsd, (void *) ptr); + tss_set(u_current_context_tsd, (void *) ptr); u_current_context = (ThreadSafe) ? NULL : (void *) ptr; #endif } @@ -249,9 +249,7 @@ u_current_get_context_internal(void) #if defined(GLX_USE_TLS) return u_current_context; #else - return (ThreadSafe) - ? u_tsd_get(&u_current_context_tsd) - : u_current_context; + return ThreadSafe ? tss_get(u_current_context_tsd) : u_current_context; #endif } @@ -273,7 +271,7 @@ u_current_set_table(const struct mapi_table *tbl) #if defined(GLX_USE_TLS) u_current_table = (struct mapi_table *) tbl; #else - u_tsd_set(&u_current_table_tsd, (void *) tbl); + tss_set(u_current_table_tsd, (void *) tbl); u_current_table = (ThreadSafe) ? NULL : (void *) tbl; #endif } @@ -287,7 +285,9 @@ u_current_get_table_internal(void) #if defined(GLX_USE_TLS) return u_current_table; #else - return (struct mapi_table *) ((ThreadSafe) ? - u_tsd_get(&u_current_table_tsd) : (void *) u_current_table); + if (ThreadSafe) + return (struct mapi_table *) tss_get(u_current_table_tsd); + else + return (struct mapi_table *) u_current_table; #endif } diff --git a/src/mapi/u_execmem.c b/src/mapi/u_execmem.c index ad6427b..89d5c1d 100644 --- a/src/mapi/u_execmem.c +++ b/src/mapi/u_execmem.c @@ -33,7 +33,7 @@ #include "c99_compat.h" -#include "u_thread.h" +#include "c11/threads.h" #include "u_execmem.h" From brianp at kemper.freedesktop.org Thu Mar 5 14:19:32 2015 From: brianp at kemper.freedesktop.org (Brian Paul) Date: Thu, 5 Mar 2015 06:19:32 -0800 (PST) Subject: Mesa (master): swrast: include stdio.h where needed Message-ID: <20150305141932.4B122761D4@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 2655afc7e68a0c7dacbd7cf653f11105790b50a6 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=2655afc7e68a0c7dacbd7cf653f11105790b50a6 Author: Brian Paul Date: Wed Mar 4 19:17:57 2015 -0700 swrast: include stdio.h where needed Acked-by: Matt Turner Reviewed-by: Jos? Fonseca --- src/mesa/drivers/dri/swrast/swrast.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/mesa/drivers/dri/swrast/swrast.c b/src/mesa/drivers/dri/swrast/swrast.c index b801476..fb29078 100644 --- a/src/mesa/drivers/dri/swrast/swrast.c +++ b/src/mesa/drivers/dri/swrast/swrast.c @@ -32,6 +32,7 @@ * The back-buffer is allocated by the driver and is private. */ +#include #include "main/api_exec.h" #include "main/context.h" #include "main/extensions.h" From brianp at kemper.freedesktop.org Thu Mar 5 14:19:32 2015 From: brianp at kemper.freedesktop.org (Brian Paul) Date: Thu, 5 Mar 2015 06:19:32 -0800 (PST) Subject: Mesa (master): mapi: THREADS was always defined, remove it Message-ID: <20150305141932.CDDEC761D4@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 18db13f586509f4fc196839886efcfd0715d8db0 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=18db13f586509f4fc196839886efcfd0715d8db0 Author: Brian Paul Date: Wed Mar 4 19:17:57 2015 -0700 mapi: THREADS was always defined, remove it THREADS was defined if HAVE_PTHREADS or _WIN32 was defined. That's always the case. The build would die in c11/threads.h otherwise. Reviewed-by: Matt Turner Reviewed-by: Jos? Fonseca --- src/mapi/glapi/gen/gl_x86-64_asm.py | 6 +----- src/mapi/glapi/gen/gl_x86_asm.py | 14 ++------------ src/mapi/glapi/glapi.h | 13 ++----------- src/mapi/glapi/glapi_entrypoint.c | 4 +--- src/mapi/glapi/glapi_priv.h | 4 +--- src/mapi/u_current.c | 22 ++++++---------------- src/mapi/u_thread.h | 6 ------ 7 files changed, 13 insertions(+), 56 deletions(-) diff --git a/src/mapi/glapi/gen/gl_x86-64_asm.py b/src/mapi/glapi/gen/gl_x86-64_asm.py index 19e0e15..5a69e034 100644 --- a/src/mapi/glapi/gen/gl_x86-64_asm.py +++ b/src/mapi/glapi/gen/gl_x86-64_asm.py @@ -138,10 +138,6 @@ class PrintGenericStubs(gl_XML.gl_print_base): print '# define GL_PREFIX(n) GLNAME(CONCAT(gl,n))' print '# endif' print '' - print '#if defined(HAVE_PTHREAD) || defined(_WIN32)' - print '# define THREADS' - print '#endif' - print '' print '\t.text' print '' print '#ifdef GLX_USE_TLS' @@ -170,7 +166,7 @@ class PrintGenericStubs(gl_XML.gl_print_base): print '\tmovl\t(%rax), %edi' print '\tjmp\tpthread_getspecific at PLT' print '' - print '#elif defined(THREADS)' + print '#else' print '' print '\t.extern\t_glapi_get_dispatch' print '' diff --git a/src/mapi/glapi/gen/gl_x86_asm.py b/src/mapi/glapi/gen/gl_x86_asm.py index d87d0bd..f855dba 100644 --- a/src/mapi/glapi/gen/gl_x86_asm.py +++ b/src/mapi/glapi/gen/gl_x86_asm.py @@ -78,9 +78,6 @@ class PrintGenericStubs(gl_XML.gl_print_base): print '#define GLOBL_FN(x) GLOBL x' print '#endif' print '' - print '#if defined(HAVE_PTHREAD) || defined(_WIN32)' - print '# define THREADS' - print '#endif' print '' print '#ifdef GLX_USE_TLS' print '' @@ -109,7 +106,7 @@ class PrintGenericStubs(gl_XML.gl_print_base): print '\tJMP(GL_OFFSET(off)) ;\t\t\t\t\\' print '1:\tCALL(_x86_get_dispatch) ;\t\t\t\\' print '\tJMP(GL_OFFSET(off))' - print '#elif defined(THREADS)' + print '#else' print '# define GL_STUB(fn,off,fn_alt)\t\t\t\\' print 'ALIGNTEXT16;\t\t\t\t\t\t\\' print 'GLOBL_FN(GL_PREFIX(fn, fn_alt));\t\t\t\\' @@ -120,13 +117,6 @@ class PrintGenericStubs(gl_XML.gl_print_base): print '\tJMP(GL_OFFSET(off)) ;\t\t\t\t\\' print '1:\tCALL(_glapi_get_dispatch) ;\t\t\t\\' print '\tJMP(GL_OFFSET(off))' - print '#else /* Non-threaded version. */' - print '# define GL_STUB(fn,off,fn_alt)\t\t\t\\' - print 'ALIGNTEXT16;\t\t\t\t\t\t\\' - print 'GLOBL_FN(GL_PREFIX(fn, fn_alt));\t\t\t\\' - print 'GL_PREFIX(fn, fn_alt):\t\t\t\t\t\\' - print '\tMOV_L(CONTENT(GLNAME(_glapi_Dispatch)), EAX) ;\t\\' - print '\tJMP(GL_OFFSET(off))' print '#endif' print '' print '#ifdef HAVE_ALIAS' @@ -164,7 +154,7 @@ class PrintGenericStubs(gl_XML.gl_print_base): print '\tCALL(GLNAME(pthread_getspecific))' print '\tADD_L(CONST(28), ESP)' print '\tRET' - print '#elif defined(THREADS)' + print '#else' print 'EXTERN GLNAME(_glapi_get_dispatch)' print '#endif' print '' diff --git a/src/mapi/glapi/glapi.h b/src/mapi/glapi/glapi.h index e3f76b4..b2d6632 100644 --- a/src/mapi/glapi/glapi.h +++ b/src/mapi/glapi/glapi.h @@ -103,21 +103,12 @@ _GLAPI_EXPORT extern const void *_glapi_Context; _GLAPI_EXPORT extern struct _glapi_table *_glapi_Dispatch; _GLAPI_EXPORT extern void *_glapi_Context; -# ifdef THREADS - -# define GET_DISPATCH() \ +#define GET_DISPATCH() \ (likely(_glapi_Dispatch) ? _glapi_Dispatch : _glapi_get_dispatch()) -# define GET_CURRENT_CONTEXT(C) struct gl_context *C = (struct gl_context *) \ +#define GET_CURRENT_CONTEXT(C) struct gl_context *C = (struct gl_context *) \ (likely(_glapi_Context) ? _glapi_Context : _glapi_get_context()) -# else - -# define GET_DISPATCH() _glapi_Dispatch -# define GET_CURRENT_CONTEXT(C) struct gl_context *C = (struct gl_context *) _glapi_Context - -# endif - #endif /* defined (GLX_USE_TLS) */ diff --git a/src/mapi/glapi/glapi_entrypoint.c b/src/mapi/glapi/glapi_entrypoint.c index 362a8f1..53104ce 100644 --- a/src/mapi/glapi/glapi_entrypoint.c +++ b/src/mapi/glapi/glapi_entrypoint.c @@ -120,11 +120,9 @@ fill_in_entrypoint_offset(_glapi_proc entrypoint, unsigned int offset) #if defined(GLX_USE_TLS) *((unsigned int *)(code + 8)) = 4 * offset; -#elif defined(THREADS) +#else *((unsigned int *)(code + 11)) = 4 * offset; *((unsigned int *)(code + 22)) = 4 * offset; -#else - *((unsigned int *)(code + 7)) = 4 * offset; #endif } diff --git a/src/mapi/glapi/glapi_priv.h b/src/mapi/glapi/glapi_priv.h index 92925fa..d368260 100644 --- a/src/mapi/glapi/glapi_priv.h +++ b/src/mapi/glapi/glapi_priv.h @@ -86,10 +86,8 @@ get_entrypoint_address(unsigned int functionOffset); #if defined(USE_X86_ASM) # if defined(GLX_USE_TLS) # define DISPATCH_FUNCTION_SIZE 16 -# elif defined(THREADS) -# define DISPATCH_FUNCTION_SIZE 32 # else -# define DISPATCH_FUNCTION_SIZE 16 +# define DISPATCH_FUNCTION_SIZE 32 # endif #endif diff --git a/src/mapi/u_current.c b/src/mapi/u_current.c index c1a486b..0365724 100644 --- a/src/mapi/u_current.c +++ b/src/mapi/u_current.c @@ -112,11 +112,9 @@ struct mapi_table *u_current_table = (struct mapi_table *) table_noop_array; void *u_current_context; -#ifdef THREADS struct u_tsd u_current_table_tsd; static struct u_tsd u_current_context_tsd; static int ThreadSafe; -#endif /* THREADS */ #endif /* defined(GLX_USE_TLS) */ /*@}*/ @@ -125,14 +123,14 @@ static int ThreadSafe; void u_current_destroy(void) { -#if defined(THREADS) && !defined(GLX_USE_TLS) +#if !defined(GLX_USE_TLS) u_tsd_destroy(&u_current_table_tsd); u_tsd_destroy(&u_current_context_tsd); #endif } -#if defined(THREADS) && !defined(GLX_USE_TLS) +#if !defined(GLX_USE_TLS) static void u_current_init_tsd(void) @@ -234,11 +232,9 @@ u_current_set_context(const void *ptr) #if defined(GLX_USE_TLS) u_current_context = (void *) ptr; -#elif defined(THREADS) +#else u_tsd_set(&u_current_context_tsd, (void *) ptr); u_current_context = (ThreadSafe) ? NULL : (void *) ptr; -#else - u_current_context = (void *) ptr; #endif } @@ -252,12 +248,10 @@ u_current_get_context_internal(void) { #if defined(GLX_USE_TLS) return u_current_context; -#elif defined(THREADS) +#else return (ThreadSafe) ? u_tsd_get(&u_current_context_tsd) : u_current_context; -#else - return u_current_context; #endif } @@ -278,11 +272,9 @@ u_current_set_table(const struct mapi_table *tbl) #if defined(GLX_USE_TLS) u_current_table = (struct mapi_table *) tbl; -#elif defined(THREADS) +#else u_tsd_set(&u_current_table_tsd, (void *) tbl); u_current_table = (ThreadSafe) ? NULL : (void *) tbl; -#else - u_current_table = (struct mapi_table *) tbl; #endif } @@ -294,10 +286,8 @@ u_current_get_table_internal(void) { #if defined(GLX_USE_TLS) return u_current_table; -#elif defined(THREADS) +#else return (struct mapi_table *) ((ThreadSafe) ? u_tsd_get(&u_current_table_tsd) : (void *) u_current_table); -#else - return u_current_table; #endif } diff --git a/src/mapi/u_thread.h b/src/mapi/u_thread.h index e57c69a..a3a65c3 100644 --- a/src/mapi/u_thread.h +++ b/src/mapi/u_thread.h @@ -48,12 +48,6 @@ #include "c11/threads.h" -#if defined(HAVE_PTHREAD) || defined(_WIN32) -#ifndef THREADS -#define THREADS -#endif -#endif - /* * Error messages */ From brianp at kemper.freedesktop.org Thu Mar 5 14:19:32 2015 From: brianp at kemper.freedesktop.org (Brian Paul) Date: Thu, 5 Mar 2015 06:19:32 -0800 (PST) Subject: Mesa (master): dri/common: include stdio.h where needed Message-ID: <20150305141932.30189761D4@kemper.freedesktop.org> Module: Mesa Branch: master Commit: f330ab93835c98e778dc22a50f8a018eb01d2ec3 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=f330ab93835c98e778dc22a50f8a018eb01d2ec3 Author: Brian Paul Date: Wed Mar 4 19:17:57 2015 -0700 dri/common: include stdio.h where needed Acked-by: Matt Turner Reviewed-by: Jos? Fonseca --- src/mesa/drivers/dri/common/utils.c | 1 + src/mesa/drivers/dri/common/xmlconfig.c | 1 + 2 files changed, 2 insertions(+) diff --git a/src/mesa/drivers/dri/common/utils.c b/src/mesa/drivers/dri/common/utils.c index ccdc971..bb22107 100644 --- a/src/mesa/drivers/dri/common/utils.c +++ b/src/mesa/drivers/dri/common/utils.c @@ -30,6 +30,7 @@ */ #include +#include #include #include #include diff --git a/src/mesa/drivers/dri/common/xmlconfig.c b/src/mesa/drivers/dri/common/xmlconfig.c index 6357e92..2b284cc 100644 --- a/src/mesa/drivers/dri/common/xmlconfig.c +++ b/src/mesa/drivers/dri/common/xmlconfig.c @@ -28,6 +28,7 @@ */ #include +#include #include #include #include From brianp at kemper.freedesktop.org Thu Mar 5 14:19:32 2015 From: brianp at kemper.freedesktop.org (Brian Paul) Date: Thu, 5 Mar 2015 06:19:32 -0800 (PST) Subject: Mesa (master): mapi: remove u_macros.h Message-ID: <20150305141932.A1DE0761D4@kemper.freedesktop.org> Module: Mesa Branch: master Commit: c3f352e8367f03cc416968d780f5dc6a6812a496 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=c3f352e8367f03cc416968d780f5dc6a6812a496 Author: Brian Paul Date: Wed Mar 4 19:17:57 2015 -0700 mapi: remove u_macros.h Only U_STRINGIFY() is used in entry.c Reviewed-by: Matt Turner Reviewed-by: Jos? Fonseca --- src/mapi/Makefile.sources | 1 - src/mapi/entry.c | 4 +++- src/mapi/entry_x86-64_tls.h | 1 - src/mapi/entry_x86_tls.h | 1 - src/mapi/entry_x86_tsd.h | 1 - src/mapi/u_macros.h | 12 ------------ 6 files changed, 3 insertions(+), 17 deletions(-) diff --git a/src/mapi/Makefile.sources b/src/mapi/Makefile.sources index a179662..4e92f5e 100644 --- a/src/mapi/Makefile.sources +++ b/src/mapi/Makefile.sources @@ -19,7 +19,6 @@ MAPI_UTIL_FILES = \ u_current.h \ u_execmem.c \ u_execmem.h \ - u_macros.h \ u_thread.h MAPI_BRIDGE_FILES = \ diff --git a/src/mapi/entry.c b/src/mapi/entry.c index f0287a0..27d0db4 100644 --- a/src/mapi/entry.c +++ b/src/mapi/entry.c @@ -27,7 +27,9 @@ #include "entry.h" #include "u_current.h" -#include "u_macros.h" + +#define _U_STRINGIFY(x) #x +#define U_STRINGIFY(x) _U_STRINGIFY(x) /* define macros for use by assembly dispatchers */ #define ENTRY_CURRENT_TABLE U_STRINGIFY(u_current_table) diff --git a/src/mapi/entry_x86-64_tls.h b/src/mapi/entry_x86-64_tls.h index d571df9..5c03b04 100644 --- a/src/mapi/entry_x86-64_tls.h +++ b/src/mapi/entry_x86-64_tls.h @@ -25,7 +25,6 @@ * Chia-I Wu */ -#include "u_macros.h" __asm__(".text\n" ".balign 32\n" diff --git a/src/mapi/entry_x86_tls.h b/src/mapi/entry_x86_tls.h index df31dce..46d2ece 100644 --- a/src/mapi/entry_x86_tls.h +++ b/src/mapi/entry_x86_tls.h @@ -26,7 +26,6 @@ */ #include -#include "u_macros.h" __asm__(".text"); diff --git a/src/mapi/entry_x86_tsd.h b/src/mapi/entry_x86_tsd.h index ece00fa..ea7bacb 100644 --- a/src/mapi/entry_x86_tsd.h +++ b/src/mapi/entry_x86_tsd.h @@ -25,7 +25,6 @@ * Chia-I Wu */ -#include "u_macros.h" #define X86_ENTRY_SIZE 32 diff --git a/src/mapi/u_macros.h b/src/mapi/u_macros.h deleted file mode 100644 index 72345b5..0000000 --- a/src/mapi/u_macros.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef _U_MACROS_ -#define _U_MACROS_ - -#define _U_STRINGIFY(x) #x -#define _U_CONCAT(x, y) x ## y -#define _U_CONCAT_STR(x, y) #x#y - -#define U_STRINGIFY(x) _U_STRINGIFY(x) -#define U_CONCAT(x, y) _U_CONCAT(x, y) -#define U_CONCAT_STR(x, y) _U_CONCAT_STR(x, y) - -#endif /* _U_MACROS_ */ From evelikov at kemper.freedesktop.org Thu Mar 5 14:51:51 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Thu, 5 Mar 2015 06:51:51 -0800 (PST) Subject: Mesa (master): egl/main: replace INLINE with inline Message-ID: <20150305145151.3D06F7617A@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 7bd1693877e4de9aaf8f6776649fc48db54ec82b URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=7bd1693877e4de9aaf8f6776649fc48db54ec82b Author: Emil Velikov Date: Sat Feb 28 16:35:22 2015 +0000 egl/main: replace INLINE with inline Drop the custom keyword in favour of the C99 one. All the places using it now directly include c99_compat.h which should handle things on platforms which lack it. Signed-off-by: Emil Velikov Reviewed-by: Matt Turner Reviewed-by: Brian Paul --- src/egl/main/eglapi.c | 19 ++++++++++--------- src/egl/main/eglarray.h | 3 ++- src/egl/main/eglcompiler.h | 8 +------- src/egl/main/eglconfig.c | 6 ++++-- src/egl/main/eglconfig.h | 10 ++++++---- src/egl/main/eglcontext.h | 13 +++++++------ src/egl/main/eglcurrent.c | 20 +++++++++++--------- src/egl/main/eglcurrent.h | 7 ++++--- src/egl/main/egldisplay.h | 7 ++++--- src/egl/main/egldriver.h | 4 +++- src/egl/main/eglimage.h | 13 +++++++------ src/egl/main/eglmutex.h | 10 ++++++---- src/egl/main/eglscreen.h | 3 ++- src/egl/main/eglsurface.h | 13 +++++++------ src/egl/main/eglsync.h | 14 ++++++++------ 15 files changed, 82 insertions(+), 68 deletions(-) diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c index db44a26..cc74b1a 100644 --- a/src/egl/main/eglapi.c +++ b/src/egl/main/eglapi.c @@ -86,6 +86,7 @@ #include #include #include +#include "c99_compat.h" #include "eglglobals.h" #include "eglcontext.h" @@ -161,7 +162,7 @@ _EGL_CHECK_OBJECT(disp, Sync, s, ret, drv) -static INLINE _EGLDriver * +static inline _EGLDriver * _eglCheckDisplay(_EGLDisplay *disp, const char *msg) { if (!disp) { @@ -176,7 +177,7 @@ _eglCheckDisplay(_EGLDisplay *disp, const char *msg) } -static INLINE _EGLDriver * +static inline _EGLDriver * _eglCheckSurface(_EGLDisplay *disp, _EGLSurface *surf, const char *msg) { _EGLDriver *drv = _eglCheckDisplay(disp, msg); @@ -190,7 +191,7 @@ _eglCheckSurface(_EGLDisplay *disp, _EGLSurface *surf, const char *msg) } -static INLINE _EGLDriver * +static inline _EGLDriver * _eglCheckContext(_EGLDisplay *disp, _EGLContext *context, const char *msg) { _EGLDriver *drv = _eglCheckDisplay(disp, msg); @@ -204,7 +205,7 @@ _eglCheckContext(_EGLDisplay *disp, _EGLContext *context, const char *msg) } -static INLINE _EGLDriver * +static inline _EGLDriver * _eglCheckConfig(_EGLDisplay *disp, _EGLConfig *conf, const char *msg) { _EGLDriver *drv = _eglCheckDisplay(disp, msg); @@ -218,7 +219,7 @@ _eglCheckConfig(_EGLDisplay *disp, _EGLConfig *conf, const char *msg) } -static INLINE _EGLDriver * +static inline _EGLDriver * _eglCheckSync(_EGLDisplay *disp, _EGLSync *s, const char *msg) { _EGLDriver *drv = _eglCheckDisplay(disp, msg); @@ -235,7 +236,7 @@ _eglCheckSync(_EGLDisplay *disp, _EGLSync *s, const char *msg) #ifdef EGL_MESA_screen_surface -static INLINE _EGLDriver * +static inline _EGLDriver * _eglCheckScreen(_EGLDisplay *disp, _EGLScreen *scrn, const char *msg) { _EGLDriver *drv = _eglCheckDisplay(disp, msg); @@ -249,7 +250,7 @@ _eglCheckScreen(_EGLDisplay *disp, _EGLScreen *scrn, const char *msg) } -static INLINE _EGLDriver * +static inline _EGLDriver * _eglCheckMode(_EGLDisplay *disp, _EGLMode *m, const char *msg) { _EGLDriver *drv = _eglCheckDisplay(disp, msg); @@ -269,7 +270,7 @@ _eglCheckMode(_EGLDisplay *disp, _EGLMode *m, const char *msg) /** * Lookup and lock a display. */ -static INLINE _EGLDisplay * +static inline _EGLDisplay * _eglLockDisplay(EGLDisplay display) { _EGLDisplay *dpy = _eglLookupDisplay(display); @@ -282,7 +283,7 @@ _eglLockDisplay(EGLDisplay display) /** * Unlock a display. */ -static INLINE void +static inline void _eglUnlockDisplay(_EGLDisplay *dpy) { _eglUnlockMutex(&dpy->Mutex); diff --git a/src/egl/main/eglarray.h b/src/egl/main/eglarray.h index d07f301..bde5ba5 100644 --- a/src/egl/main/eglarray.h +++ b/src/egl/main/eglarray.h @@ -29,6 +29,7 @@ #ifndef EGLARRAY_INCLUDED #define EGLARRAY_INCLUDED +#include "c99_compat.h" #include "egltypedefs.h" @@ -75,7 +76,7 @@ _eglFlattenArray(_EGLArray *array, void *buffer, EGLint elem_size, EGLint size, _EGLArrayForEach flatten); -static INLINE EGLint +static inline EGLint _eglGetArraySize(_EGLArray *array) { return (array) ? array->Size : 0; diff --git a/src/egl/main/eglcompiler.h b/src/egl/main/eglcompiler.h index 5ea83d6..2e1c8b9 100644 --- a/src/egl/main/eglcompiler.h +++ b/src/egl/main/eglcompiler.h @@ -31,7 +31,7 @@ #define EGLCOMPILER_INCLUDED -#include "c99_compat.h" /* inline, __func__, etc. */ +#include "c99_compat.h" /* __func__, etc. */ /** @@ -66,12 +66,6 @@ #endif -/* XXX: Use standard `inline` keyword instead */ -#ifndef INLINE -# define INLINE inline -#endif - - /** * Function visibility */ diff --git a/src/egl/main/eglconfig.c b/src/egl/main/eglconfig.c index 1ac716c..50fcbb0 100644 --- a/src/egl/main/eglconfig.c +++ b/src/egl/main/eglconfig.c @@ -36,6 +36,8 @@ #include #include #include +#include "c99_compat.h" + #include "eglconfig.h" #include "egldisplay.h" #include "eglcurrent.h" @@ -481,7 +483,7 @@ _eglMatchConfig(const _EGLConfig *conf, const _EGLConfig *criteria) return matched; } -static INLINE EGLBoolean +static inline EGLBoolean _eglIsConfigAttribValid(_EGLConfig *conf, EGLint attr) { if (_eglOffsetOfConfig(attr) < 0) @@ -651,7 +653,7 @@ _eglCompareConfigs(const _EGLConfig *conf1, const _EGLConfig *conf2, } -static INLINE +static inline void _eglSwapConfigs(const _EGLConfig **conf1, const _EGLConfig **conf2) { const _EGLConfig *tmp = *conf1; diff --git a/src/egl/main/eglconfig.h b/src/egl/main/eglconfig.h index b00f872..5fa8f33 100644 --- a/src/egl/main/eglconfig.h +++ b/src/egl/main/eglconfig.h @@ -34,6 +34,8 @@ #include #include +#include "c99_compat.h" + #include "egltypedefs.h" @@ -86,7 +88,7 @@ struct _egl_config /** * Map an EGL attribute enum to the offset of the member in _EGLConfig. */ -static INLINE EGLint +static inline EGLint _eglOffsetOfConfig(EGLint attr) { switch (attr) { @@ -141,7 +143,7 @@ _eglOffsetOfConfig(EGLint attr) * in the attribute enums. The separation is to catch application errors. * Drivers should never set a key that is an invalid attribute. */ -static INLINE void +static inline void _eglSetConfigKey(_EGLConfig *conf, EGLint key, EGLint val) { EGLint offset = _eglOffsetOfConfig(key); @@ -153,7 +155,7 @@ _eglSetConfigKey(_EGLConfig *conf, EGLint key, EGLint val) /** * Return the value for a given key. */ -static INLINE EGLint +static inline EGLint _eglGetConfigKey(const _EGLConfig *conf, EGLint key) { EGLint offset = _eglOffsetOfConfig(key); @@ -177,7 +179,7 @@ _eglLookupConfig(EGLConfig config, _EGLDisplay *dpy); /** * Return the handle of a linked config. */ -static INLINE EGLConfig +static inline EGLConfig _eglGetConfigHandle(_EGLConfig *conf) { return (EGLConfig) conf; diff --git a/src/egl/main/eglcontext.h b/src/egl/main/eglcontext.h index 73badc5..5b574b5 100644 --- a/src/egl/main/eglcontext.h +++ b/src/egl/main/eglcontext.h @@ -31,6 +31,7 @@ #ifndef EGLCONTEXT_INCLUDED #define EGLCONTEXT_INCLUDED +#include "c99_compat.h" #include "egltypedefs.h" #include "egldisplay.h" @@ -81,7 +82,7 @@ _eglBindContext(_EGLContext *ctx, _EGLSurface *draw, _EGLSurface *read, /** * Increment reference count for the context. */ -static INLINE _EGLContext * +static inline _EGLContext * _eglGetContext(_EGLContext *ctx) { if (ctx) @@ -93,7 +94,7 @@ _eglGetContext(_EGLContext *ctx) /** * Decrement reference count for the context. */ -static INLINE EGLBoolean +static inline EGLBoolean _eglPutContext(_EGLContext *ctx) { return (ctx) ? _eglPutResource(&ctx->Resource) : EGL_FALSE; @@ -104,7 +105,7 @@ _eglPutContext(_EGLContext *ctx) * Link a context to its display and return the handle of the link. * The handle can be passed to client directly. */ -static INLINE EGLContext +static inline EGLContext _eglLinkContext(_EGLContext *ctx) { _eglLinkResource(&ctx->Resource, _EGL_RESOURCE_CONTEXT); @@ -116,7 +117,7 @@ _eglLinkContext(_EGLContext *ctx) * Unlink a linked context from its display. * Accessing an unlinked context should generate EGL_BAD_CONTEXT error. */ -static INLINE void +static inline void _eglUnlinkContext(_EGLContext *ctx) { _eglUnlinkResource(&ctx->Resource, _EGL_RESOURCE_CONTEXT); @@ -127,7 +128,7 @@ _eglUnlinkContext(_EGLContext *ctx) * Lookup a handle to find the linked context. * Return NULL if the handle has no corresponding linked context. */ -static INLINE _EGLContext * +static inline _EGLContext * _eglLookupContext(EGLContext context, _EGLDisplay *dpy) { _EGLContext *ctx = (_EGLContext *) context; @@ -140,7 +141,7 @@ _eglLookupContext(EGLContext context, _EGLDisplay *dpy) /** * Return the handle of a linked context, or EGL_NO_CONTEXT. */ -static INLINE EGLContext +static inline EGLContext _eglGetContextHandle(_EGLContext *ctx) { _EGLResource *res = (_EGLResource *) ctx; diff --git a/src/egl/main/eglcurrent.c b/src/egl/main/eglcurrent.c index fcb732d..d358fea 100644 --- a/src/egl/main/eglcurrent.c +++ b/src/egl/main/eglcurrent.c @@ -28,6 +28,8 @@ #include #include +#include "c99_compat.h" + #include "egllog.h" #include "eglmutex.h" #include "eglcurrent.h" @@ -55,7 +57,7 @@ static __thread const _EGLThreadInfo *_egl_TLS __attribute__ ((tls_model("initial-exec"))); #endif -static INLINE void _eglSetTSD(const _EGLThreadInfo *t) +static inline void _eglSetTSD(const _EGLThreadInfo *t) { pthread_setspecific(_egl_TSD, (const void *) t); #ifdef GLX_USE_TLS @@ -63,7 +65,7 @@ static INLINE void _eglSetTSD(const _EGLThreadInfo *t) #endif } -static INLINE _EGLThreadInfo *_eglGetTSD(void) +static inline _EGLThreadInfo *_eglGetTSD(void) { #ifdef GLX_USE_TLS return (_EGLThreadInfo *) _egl_TLS; @@ -72,7 +74,7 @@ static INLINE _EGLThreadInfo *_eglGetTSD(void) #endif } -static INLINE void _eglFiniTSD(void) +static inline void _eglFiniTSD(void) { _eglLockMutex(&_egl_TSDMutex); if (_egl_TSDInitialized) { @@ -86,7 +88,7 @@ static INLINE void _eglFiniTSD(void) _eglUnlockMutex(&_egl_TSDMutex); } -static INLINE EGLBoolean _eglInitTSD(void (*dtor)(_EGLThreadInfo *)) +static inline EGLBoolean _eglInitTSD(void (*dtor)(_EGLThreadInfo *)) { if (!_egl_TSDInitialized) { _eglLockMutex(&_egl_TSDMutex); @@ -112,23 +114,23 @@ static INLINE EGLBoolean _eglInitTSD(void (*dtor)(_EGLThreadInfo *)) static const _EGLThreadInfo *_egl_TSD; static void (*_egl_FreeTSD)(_EGLThreadInfo *); -static INLINE void _eglSetTSD(const _EGLThreadInfo *t) +static inline void _eglSetTSD(const _EGLThreadInfo *t) { _egl_TSD = t; } -static INLINE _EGLThreadInfo *_eglGetTSD(void) +static inline _EGLThreadInfo *_eglGetTSD(void) { return (_EGLThreadInfo *) _egl_TSD; } -static INLINE void _eglFiniTSD(void) +static inline void _eglFiniTSD(void) { if (_egl_FreeTSD && _egl_TSD) _egl_FreeTSD((_EGLThreadInfo *) _egl_TSD); } -static INLINE EGLBoolean _eglInitTSD(void (*dtor)(_EGLThreadInfo *)) +static inline EGLBoolean _eglInitTSD(void (*dtor)(_EGLThreadInfo *)) { if (!_egl_FreeTSD && dtor) { _egl_FreeTSD = dtor; @@ -179,7 +181,7 @@ _eglDestroyThreadInfo(_EGLThreadInfo *t) /** * Make sure TSD is initialized and return current value. */ -static INLINE _EGLThreadInfo * +static inline _EGLThreadInfo * _eglCheckedGetTSD(void) { if (_eglInitTSD(&_eglDestroyThreadInfo) != EGL_TRUE) { diff --git a/src/egl/main/eglcurrent.h b/src/egl/main/eglcurrent.h index 45fcc64..a2856d2 100644 --- a/src/egl/main/eglcurrent.h +++ b/src/egl/main/eglcurrent.h @@ -29,6 +29,7 @@ #ifndef EGLCURRENT_INCLUDED #define EGLCURRENT_INCLUDED +#include "c99_compat.h" #include "egltypedefs.h" @@ -61,7 +62,7 @@ struct _egl_thread_info /** * Return true if a client API enum is recognized. */ -static INLINE EGLBoolean +static inline EGLBoolean _eglIsApiValid(EGLenum api) { return (api >= _EGL_API_FIRST_API && api <= _EGL_API_LAST_API); @@ -72,7 +73,7 @@ _eglIsApiValid(EGLenum api) * Convert a client API enum to an index, for use by thread info. * The client API enum is assumed to be valid. */ -static INLINE EGLint +static inline EGLint _eglConvertApiToIndex(EGLenum api) { return api - _EGL_API_FIRST_API; @@ -83,7 +84,7 @@ _eglConvertApiToIndex(EGLenum api) * Convert an index, used by thread info, to a client API enum. * The index is assumed to be valid. */ -static INLINE EGLenum +static inline EGLenum _eglConvertApiFromIndex(EGLint idx) { return _EGL_API_FIRST_API + idx; diff --git a/src/egl/main/egldisplay.h b/src/egl/main/egldisplay.h index bcdc2b2..213b96a 100644 --- a/src/egl/main/egldisplay.h +++ b/src/egl/main/egldisplay.h @@ -31,6 +31,7 @@ #ifndef EGLDISPLAY_INCLUDED #define EGLDISPLAY_INCLUDED +#include "c99_compat.h" #include "egltypedefs.h" #include "egldefines.h" @@ -197,7 +198,7 @@ _eglCheckResource(void *res, _EGLResourceType type, _EGLDisplay *dpy); * Lookup a handle to find the linked display. * Return NULL if the handle has no corresponding linked display. */ -static INLINE _EGLDisplay * +static inline _EGLDisplay * _eglLookupDisplay(EGLDisplay display) { _EGLDisplay *dpy = (_EGLDisplay *) display; @@ -210,7 +211,7 @@ _eglLookupDisplay(EGLDisplay display) /** * Return the handle of a linked display, or EGL_NO_DISPLAY. */ -static INLINE EGLDisplay +static inline EGLDisplay _eglGetDisplayHandle(_EGLDisplay *dpy) { return (EGLDisplay) ((dpy) ? dpy : EGL_NO_DISPLAY); @@ -240,7 +241,7 @@ _eglUnlinkResource(_EGLResource *res, _EGLResourceType type); /** * Return true if the resource is linked. */ -static INLINE EGLBoolean +static inline EGLBoolean _eglIsResourceLinked(_EGLResource *res) { return res->IsLinked; diff --git a/src/egl/main/egldriver.h b/src/egl/main/egldriver.h index e34f19f..ccb70ac 100644 --- a/src/egl/main/egldriver.h +++ b/src/egl/main/egldriver.h @@ -32,6 +32,8 @@ #define EGLDRIVER_INCLUDED +#include "c99_compat.h" + #include "egltypedefs.h" #include "eglapi.h" #include @@ -43,7 +45,7 @@ * semicolon when used. */ #define _EGL_DRIVER_TYPECAST(drvtype, egltype, code) \ - static INLINE struct drvtype *drvtype(const egltype *obj) \ + static inline struct drvtype *drvtype(const egltype *obj) \ { return (struct drvtype *) code; } diff --git a/src/egl/main/eglimage.h b/src/egl/main/eglimage.h index 1b4d6cd..71c52ca 100644 --- a/src/egl/main/eglimage.h +++ b/src/egl/main/eglimage.h @@ -30,6 +30,7 @@ #ifndef EGLIMAGE_INCLUDED #define EGLIMAGE_INCLUDED +#include "c99_compat.h" #include "egltypedefs.h" #include "egldisplay.h" @@ -92,7 +93,7 @@ _eglInitImage(_EGLImage *img, _EGLDisplay *dpy); /** * Increment reference count for the image. */ -static INLINE _EGLImage * +static inline _EGLImage * _eglGetImage(_EGLImage *img) { if (img) @@ -104,7 +105,7 @@ _eglGetImage(_EGLImage *img) /** * Decrement reference count for the image. */ -static INLINE EGLBoolean +static inline EGLBoolean _eglPutImage(_EGLImage *img) { return (img) ? _eglPutResource(&img->Resource) : EGL_FALSE; @@ -115,7 +116,7 @@ _eglPutImage(_EGLImage *img) * Link an image to its display and return the handle of the link. * The handle can be passed to client directly. */ -static INLINE EGLImageKHR +static inline EGLImageKHR _eglLinkImage(_EGLImage *img) { _eglLinkResource(&img->Resource, _EGL_RESOURCE_IMAGE); @@ -127,7 +128,7 @@ _eglLinkImage(_EGLImage *img) * Unlink a linked image from its display. * Accessing an unlinked image should generate EGL_BAD_PARAMETER error. */ -static INLINE void +static inline void _eglUnlinkImage(_EGLImage *img) { _eglUnlinkResource(&img->Resource, _EGL_RESOURCE_IMAGE); @@ -138,7 +139,7 @@ _eglUnlinkImage(_EGLImage *img) * Lookup a handle to find the linked image. * Return NULL if the handle has no corresponding linked image. */ -static INLINE _EGLImage * +static inline _EGLImage * _eglLookupImage(EGLImageKHR image, _EGLDisplay *dpy) { _EGLImage *img = (_EGLImage *) image; @@ -151,7 +152,7 @@ _eglLookupImage(EGLImageKHR image, _EGLDisplay *dpy) /** * Return the handle of a linked image, or EGL_NO_IMAGE_KHR. */ -static INLINE EGLImageKHR +static inline EGLImageKHR _eglGetImageHandle(_EGLImage *img) { _EGLResource *res = (_EGLResource *) img; diff --git a/src/egl/main/eglmutex.h b/src/egl/main/eglmutex.h index 2ec965c..b58f0e3 100644 --- a/src/egl/main/eglmutex.h +++ b/src/egl/main/eglmutex.h @@ -29,30 +29,32 @@ #ifndef EGLMUTEX_INCLUDED #define EGLMUTEX_INCLUDED +#include "c99_compat.h" + #include "eglcompiler.h" #include "c11/threads.h" typedef mtx_t _EGLMutex; -static INLINE void _eglInitMutex(_EGLMutex *m) +static inline void _eglInitMutex(_EGLMutex *m) { mtx_init(m, mtx_plain); } -static INLINE void +static inline void _eglDestroyMutex(_EGLMutex *m) { mtx_destroy(m); } -static INLINE void +static inline void _eglLockMutex(_EGLMutex *m) { mtx_lock(m); } -static INLINE void +static inline void _eglUnlockMutex(_EGLMutex *m) { mtx_unlock(m); diff --git a/src/egl/main/eglscreen.h b/src/egl/main/eglscreen.h index 1cede44..542f2de 100644 --- a/src/egl/main/eglscreen.h +++ b/src/egl/main/eglscreen.h @@ -31,6 +31,7 @@ #ifndef EGLSCREEN_INCLUDED #define EGLSCREEN_INCLUDED +#include "c99_compat.h" #include "egltypedefs.h" @@ -82,7 +83,7 @@ _eglLookupScreen(EGLScreenMESA screen, _EGLDisplay *dpy); /** * Return the handle of a linked screen. */ -static INLINE EGLScreenMESA +static inline EGLScreenMESA _eglGetScreenHandle(_EGLScreen *screen) { return (screen) ? screen->Handle : (EGLScreenMESA) 0; diff --git a/src/egl/main/eglsurface.h b/src/egl/main/eglsurface.h index d13d301..898f3a4 100644 --- a/src/egl/main/eglsurface.h +++ b/src/egl/main/eglsurface.h @@ -31,6 +31,7 @@ #ifndef EGLSURFACE_INCLUDED #define EGLSURFACE_INCLUDED +#include "c99_compat.h" #include "egltypedefs.h" #include "egldisplay.h" @@ -105,7 +106,7 @@ _eglSwapInterval(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf, EGLint in /** * Increment reference count for the surface. */ -static INLINE _EGLSurface * +static inline _EGLSurface * _eglGetSurface(_EGLSurface *surf) { if (surf) @@ -117,7 +118,7 @@ _eglGetSurface(_EGLSurface *surf) /** * Decrement reference count for the surface. */ -static INLINE EGLBoolean +static inline EGLBoolean _eglPutSurface(_EGLSurface *surf) { return (surf) ? _eglPutResource(&surf->Resource) : EGL_FALSE; @@ -128,7 +129,7 @@ _eglPutSurface(_EGLSurface *surf) * Link a surface to its display and return the handle of the link. * The handle can be passed to client directly. */ -static INLINE EGLSurface +static inline EGLSurface _eglLinkSurface(_EGLSurface *surf) { _eglLinkResource(&surf->Resource, _EGL_RESOURCE_SURFACE); @@ -140,7 +141,7 @@ _eglLinkSurface(_EGLSurface *surf) * Unlink a linked surface from its display. * Accessing an unlinked surface should generate EGL_BAD_SURFACE error. */ -static INLINE void +static inline void _eglUnlinkSurface(_EGLSurface *surf) { _eglUnlinkResource(&surf->Resource, _EGL_RESOURCE_SURFACE); @@ -151,7 +152,7 @@ _eglUnlinkSurface(_EGLSurface *surf) * Lookup a handle to find the linked surface. * Return NULL if the handle has no corresponding linked surface. */ -static INLINE _EGLSurface * +static inline _EGLSurface * _eglLookupSurface(EGLSurface surface, _EGLDisplay *dpy) { _EGLSurface *surf = (_EGLSurface *) surface; @@ -164,7 +165,7 @@ _eglLookupSurface(EGLSurface surface, _EGLDisplay *dpy) /** * Return the handle of a linked surface, or EGL_NO_SURFACE. */ -static INLINE EGLSurface +static inline EGLSurface _eglGetSurfaceHandle(_EGLSurface *surf) { _EGLResource *res = (_EGLResource *) surf; diff --git a/src/egl/main/eglsync.h b/src/egl/main/eglsync.h index 9708d09..cd2d783 100644 --- a/src/egl/main/eglsync.h +++ b/src/egl/main/eglsync.h @@ -30,6 +30,8 @@ #define EGLSYNC_INCLUDED +#include "c99_compat.h" + #include "egltypedefs.h" #include "egldisplay.h" @@ -61,7 +63,7 @@ _eglGetSyncAttribKHR(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSync *sync, /** * Increment reference count for the sync. */ -static INLINE _EGLSync * +static inline _EGLSync * _eglGetSync(_EGLSync *sync) { if (sync) @@ -73,7 +75,7 @@ _eglGetSync(_EGLSync *sync) /** * Decrement reference count for the sync. */ -static INLINE EGLBoolean +static inline EGLBoolean _eglPutSync(_EGLSync *sync) { return (sync) ? _eglPutResource(&sync->Resource) : EGL_FALSE; @@ -84,7 +86,7 @@ _eglPutSync(_EGLSync *sync) * Link a sync to its display and return the handle of the link. * The handle can be passed to client directly. */ -static INLINE EGLSyncKHR +static inline EGLSyncKHR _eglLinkSync(_EGLSync *sync) { _eglLinkResource(&sync->Resource, _EGL_RESOURCE_SYNC); @@ -95,7 +97,7 @@ _eglLinkSync(_EGLSync *sync) /** * Unlink a linked sync from its display. */ -static INLINE void +static inline void _eglUnlinkSync(_EGLSync *sync) { _eglUnlinkResource(&sync->Resource, _EGL_RESOURCE_SYNC); @@ -106,7 +108,7 @@ _eglUnlinkSync(_EGLSync *sync) * Lookup a handle to find the linked sync. * Return NULL if the handle has no corresponding linked sync. */ -static INLINE _EGLSync * +static inline _EGLSync * _eglLookupSync(EGLSyncKHR handle, _EGLDisplay *dpy) { _EGLSync *sync = (_EGLSync *) handle; @@ -119,7 +121,7 @@ _eglLookupSync(EGLSyncKHR handle, _EGLDisplay *dpy) /** * Return the handle of a linked sync, or EGL_NO_SYNC_KHR. */ -static INLINE EGLSyncKHR +static inline EGLSyncKHR _eglGetSyncHandle(_EGLSync *sync) { _EGLResource *res = (_EGLResource *) sync; From evelikov at kemper.freedesktop.org Thu Mar 5 14:51:51 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Thu, 5 Mar 2015 06:51:51 -0800 (PST) Subject: Mesa (master): egl/main: no longer export internal function Message-ID: <20150305145151.4FB9A7617A@kemper.freedesktop.org> Module: Mesa Branch: master Commit: dd438ae34bdbaa6651cdd226d5fec15a892923bf URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=dd438ae34bdbaa6651cdd226d5fec15a892923bf Author: Emil Velikov Date: Sat Feb 28 17:20:01 2015 +0000 egl/main: no longer export internal function With the split of the gallium egl module we had previously it required access to some of the internal functions. As the only build (automake) that did this no longer builds it we can now appropriately hide those functions. Cc: 10.5 Signed-off-by: Emil Velikov Reviewed-by: Matt Turner Reviewed-by: Brian Paul --- src/egl/main/eglarray.h | 4 ++-- src/egl/main/eglconfig.c | 2 +- src/egl/main/eglconfig.h | 14 +++++++------- src/egl/main/eglcontext.h | 4 ++-- src/egl/main/eglcurrent.c | 2 +- src/egl/main/eglcurrent.h | 8 ++++---- src/egl/main/egldisplay.h | 10 +++++----- src/egl/main/egldriver.h | 6 +++--- src/egl/main/eglimage.h | 4 ++-- src/egl/main/egllog.h | 6 +++--- src/egl/main/eglscreen.h | 4 ++-- src/egl/main/eglsurface.h | 6 +++--- src/egl/main/eglsync.h | 2 +- 13 files changed, 36 insertions(+), 36 deletions(-) diff --git a/src/egl/main/eglarray.h b/src/egl/main/eglarray.h index bde5ba5..228f6c3 100644 --- a/src/egl/main/eglarray.h +++ b/src/egl/main/eglarray.h @@ -50,7 +50,7 @@ extern _EGLArray * _eglCreateArray(const char *name, EGLint init_size); -PUBLIC void +extern void _eglDestroyArray(_EGLArray *array, void (*free_cb)(void *)); @@ -66,7 +66,7 @@ void * _eglFindArray(_EGLArray *array, void *elem); -PUBLIC EGLint +extern EGLint _eglFilterArray(_EGLArray *array, void **data, EGLint size, _EGLArrayForEach filter, void *filter_data); diff --git a/src/egl/main/eglconfig.c b/src/egl/main/eglconfig.c index 50fcbb0..db42e95 100644 --- a/src/egl/main/eglconfig.c +++ b/src/egl/main/eglconfig.c @@ -77,7 +77,7 @@ _eglInitConfig(_EGLConfig *conf, _EGLDisplay *dpy, EGLint id) * * Note that we just save the ptr to the config (we don't copy the config). */ -PUBLIC EGLConfig +EGLConfig _eglLinkConfig(_EGLConfig *conf) { _EGLDisplay *dpy = conf->Display; diff --git a/src/egl/main/eglconfig.h b/src/egl/main/eglconfig.h index 5fa8f33..dc59ea3 100644 --- a/src/egl/main/eglconfig.h +++ b/src/egl/main/eglconfig.h @@ -164,11 +164,11 @@ _eglGetConfigKey(const _EGLConfig *conf, EGLint key) } -PUBLIC void +extern void _eglInitConfig(_EGLConfig *config, _EGLDisplay *dpy, EGLint id); -PUBLIC EGLConfig +extern EGLConfig _eglLinkConfig(_EGLConfig *conf); @@ -186,25 +186,25 @@ _eglGetConfigHandle(_EGLConfig *conf) } -PUBLIC EGLBoolean +extern EGLBoolean _eglValidateConfig(const _EGLConfig *conf, EGLBoolean for_matching); -PUBLIC EGLBoolean +extern EGLBoolean _eglMatchConfig(const _EGLConfig *conf, const _EGLConfig *criteria); -PUBLIC EGLBoolean +extern EGLBoolean _eglParseConfigAttribList(_EGLConfig *conf, _EGLDisplay *dpy, const EGLint *attrib_list); -PUBLIC EGLint +extern EGLint _eglCompareConfigs(const _EGLConfig *conf1, const _EGLConfig *conf2, const _EGLConfig *criteria, EGLBoolean compare_id); -PUBLIC EGLBoolean +extern EGLBoolean _eglFilterConfigArray(_EGLArray *array, EGLConfig *configs, EGLint config_size, EGLint *num_configs, EGLBoolean (*match)(const _EGLConfig *, void *), diff --git a/src/egl/main/eglcontext.h b/src/egl/main/eglcontext.h index 5b574b5..241917f 100644 --- a/src/egl/main/eglcontext.h +++ b/src/egl/main/eglcontext.h @@ -64,7 +64,7 @@ struct _egl_context }; -PUBLIC EGLBoolean +extern EGLBoolean _eglInitContext(_EGLContext *ctx, _EGLDisplay *dpy, _EGLConfig *config, const EGLint *attrib_list); @@ -73,7 +73,7 @@ extern EGLBoolean _eglQueryContext(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *ctx, EGLint attribute, EGLint *value); -PUBLIC EGLBoolean +extern EGLBoolean _eglBindContext(_EGLContext *ctx, _EGLSurface *draw, _EGLSurface *read, _EGLContext **old_ctx, _EGLSurface **old_draw, _EGLSurface **old_read); diff --git a/src/egl/main/eglcurrent.c b/src/egl/main/eglcurrent.c index d358fea..3d49641 100644 --- a/src/egl/main/eglcurrent.c +++ b/src/egl/main/eglcurrent.c @@ -244,7 +244,7 @@ _eglIsCurrentThreadDummy(void) /** * Return the currently bound context of the given API, or NULL. */ -PUBLIC _EGLContext * +_EGLContext * _eglGetAPIContext(EGLenum api) { _EGLThreadInfo *t = _eglGetCurrentThread(); diff --git a/src/egl/main/eglcurrent.h b/src/egl/main/eglcurrent.h index a2856d2..3343755 100644 --- a/src/egl/main/eglcurrent.h +++ b/src/egl/main/eglcurrent.h @@ -91,7 +91,7 @@ _eglConvertApiFromIndex(EGLint idx) } -PUBLIC _EGLThreadInfo * +extern _EGLThreadInfo * _eglGetCurrentThread(void); @@ -103,15 +103,15 @@ extern EGLBoolean _eglIsCurrentThreadDummy(void); -PUBLIC _EGLContext * +extern _EGLContext * _eglGetAPIContext(EGLenum api); -PUBLIC _EGLContext * +extern _EGLContext * _eglGetCurrentContext(void); -PUBLIC EGLBoolean +extern EGLBoolean _eglError(EGLint errCode, const char *msg); diff --git a/src/egl/main/egldisplay.h b/src/egl/main/egldisplay.h index 213b96a..9c3c8c7 100644 --- a/src/egl/main/egldisplay.h +++ b/src/egl/main/egldisplay.h @@ -178,11 +178,11 @@ extern _EGLDisplay * _eglFindDisplay(_EGLPlatformType plat, void *plat_dpy); -PUBLIC void +extern void _eglReleaseDisplayResources(_EGLDriver *drv, _EGLDisplay *dpy); -PUBLIC void +extern void _eglCleanupDisplay(_EGLDisplay *disp); @@ -190,7 +190,7 @@ extern EGLBoolean _eglCheckDisplayHandle(EGLDisplay dpy); -PUBLIC EGLBoolean +extern EGLBoolean _eglCheckResource(void *res, _EGLResourceType type, _EGLDisplay *dpy); @@ -222,11 +222,11 @@ extern void _eglInitResource(_EGLResource *res, EGLint size, _EGLDisplay *dpy); -PUBLIC void +extern void _eglGetResource(_EGLResource *res); -PUBLIC EGLBoolean +extern EGLBoolean _eglPutResource(_EGLResource *res); diff --git a/src/egl/main/egldriver.h b/src/egl/main/egldriver.h index ccb70ac..11300ce 100644 --- a/src/egl/main/egldriver.h +++ b/src/egl/main/egldriver.h @@ -98,7 +98,7 @@ extern _EGLDriver * _eglBuiltInDriverGLX(const char *args); -PUBLIC _EGLDriver * +extern _EGLDriver * _eglMain(const char *args); @@ -115,11 +115,11 @@ _eglUnloadDrivers(void); /* defined in eglfallbacks.c */ -PUBLIC void +extern void _eglInitDriverFallbacks(_EGLDriver *drv); -PUBLIC void +extern void _eglSearchPathForEach(EGLBoolean (*callback)(const char *, size_t, void *), void *callback_data); diff --git a/src/egl/main/eglimage.h b/src/egl/main/eglimage.h index 71c52ca..50a87a1 100644 --- a/src/egl/main/eglimage.h +++ b/src/egl/main/eglimage.h @@ -81,12 +81,12 @@ struct _egl_image }; -PUBLIC EGLint +extern EGLint _eglParseImageAttribList(_EGLImageAttribs *attrs, _EGLDisplay *dpy, const EGLint *attrib_list); -PUBLIC EGLBoolean +extern EGLBoolean _eglInitImage(_EGLImage *img, _EGLDisplay *dpy); diff --git a/src/egl/main/egllog.h b/src/egl/main/egllog.h index bac5720..12a477e 100644 --- a/src/egl/main/egllog.h +++ b/src/egl/main/egllog.h @@ -43,15 +43,15 @@ typedef void (*_EGLLogProc)(EGLint level, const char *msg); -PUBLIC void +extern void _eglSetLogProc(_EGLLogProc logger); -PUBLIC void +extern void _eglSetLogLevel(EGLint level); -PUBLIC void +extern void _eglLog(EGLint level, const char *fmtStr, ...); diff --git a/src/egl/main/eglscreen.h b/src/egl/main/eglscreen.h index 542f2de..c554e1d 100644 --- a/src/egl/main/eglscreen.h +++ b/src/egl/main/eglscreen.h @@ -68,11 +68,11 @@ struct _egl_screen }; -PUBLIC void +extern void _eglInitScreen(_EGLScreen *screen, _EGLDisplay *dpy, EGLint num_modes); -PUBLIC EGLScreenMESA +extern EGLScreenMESA _eglLinkScreen(_EGLScreen *screen); diff --git a/src/egl/main/eglsurface.h b/src/egl/main/eglsurface.h index 898f3a4..438e27c 100644 --- a/src/egl/main/eglsurface.h +++ b/src/egl/main/eglsurface.h @@ -79,7 +79,7 @@ struct _egl_surface }; -PUBLIC EGLBoolean +extern EGLBoolean _eglInitSurface(_EGLSurface *surf, _EGLDisplay *dpy, EGLint type, _EGLConfig *config, const EGLint *attrib_list); @@ -92,10 +92,10 @@ extern EGLBoolean _eglSurfaceAttrib(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf, EGLint attribute, EGLint value); -PUBLIC extern EGLBoolean +extern EGLBoolean _eglBindTexImage(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf, EGLint buffer); -PUBLIC extern EGLBoolean +extern EGLBoolean _eglReleaseTexImage(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf, EGLint buffer); diff --git a/src/egl/main/eglsync.h b/src/egl/main/eglsync.h index cd2d783..c6cf8c6 100644 --- a/src/egl/main/eglsync.h +++ b/src/egl/main/eglsync.h @@ -50,7 +50,7 @@ struct _egl_sync }; -PUBLIC EGLBoolean +extern EGLBoolean _eglInitSync(_EGLSync *sync, _EGLDisplay *dpy, EGLenum type, const EGLint *attrib_list); From evelikov at kemper.freedesktop.org Thu Mar 5 14:51:51 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Thu, 5 Mar 2015 06:51:51 -0800 (PST) Subject: Mesa (master): egl/drivers: include stdint.h where needed Message-ID: <20150305145151.63EC17617A@kemper.freedesktop.org> Module: Mesa Branch: master Commit: bf0e4d219a8cf396402b46c265eb35afd22a676d URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=bf0e4d219a8cf396402b46c265eb35afd22a676d Author: Emil Velikov Date: Sat Feb 28 17:12:40 2015 +0000 egl/drivers: include stdint.h where needed Currently these files are including it indirectly via eglcompiler.h The latter of which will be removed with follow up commits. Signed-off-by: Emil Velikov Reviewed-by: Matt Turner Reviewed-by: Brian Paul --- src/egl/drivers/dri2/egl_dri2.c | 1 + src/egl/drivers/dri2/egl_dri2.h | 2 ++ src/egl/drivers/dri2/platform_drm.c | 1 + src/egl/drivers/dri2/platform_wayland.c | 1 + src/egl/drivers/dri2/platform_x11.c | 1 + src/egl/drivers/haiku/egl_haiku.cpp | 1 + 6 files changed, 7 insertions(+) diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c index 6306483..d503196 100644 --- a/src/egl/drivers/dri2/egl_dri2.c +++ b/src/egl/drivers/dri2/egl_dri2.c @@ -27,6 +27,7 @@ #define WL_HIDE_DEPRECATED +#include #include #include #include diff --git a/src/egl/drivers/dri2/egl_dri2.h b/src/egl/drivers/dri2/egl_dri2.h index 9efe1f7..167b3b1 100644 --- a/src/egl/drivers/dri2/egl_dri2.h +++ b/src/egl/drivers/dri2/egl_dri2.h @@ -28,6 +28,8 @@ #ifndef EGL_DRI2_INCLUDED #define EGL_DRI2_INCLUDED +#include + #ifdef HAVE_X11_PLATFORM #include #include diff --git a/src/egl/drivers/dri2/platform_drm.c b/src/egl/drivers/dri2/platform_drm.c index bf205be..486b003 100644 --- a/src/egl/drivers/dri2/platform_drm.c +++ b/src/egl/drivers/dri2/platform_drm.c @@ -25,6 +25,7 @@ * Kristian H?gsberg */ +#include #include #include #include diff --git a/src/egl/drivers/dri2/platform_wayland.c b/src/egl/drivers/dri2/platform_wayland.c index 07f68a2..e226005 100644 --- a/src/egl/drivers/dri2/platform_wayland.c +++ b/src/egl/drivers/dri2/platform_wayland.c @@ -26,6 +26,7 @@ * Benjamin Franzke */ +#include #include #include #include diff --git a/src/egl/drivers/dri2/platform_x11.c b/src/egl/drivers/dri2/platform_x11.c index cbcf6a7..ddb3b54 100644 --- a/src/egl/drivers/dri2/platform_x11.c +++ b/src/egl/drivers/dri2/platform_x11.c @@ -26,6 +26,7 @@ */ #include +#include #include #include #include diff --git a/src/egl/drivers/haiku/egl_haiku.cpp b/src/egl/drivers/haiku/egl_haiku.cpp index f94a34b..4cf2ccb 100644 --- a/src/egl/drivers/haiku/egl_haiku.cpp +++ b/src/egl/drivers/haiku/egl_haiku.cpp @@ -24,6 +24,7 @@ #include #include +#include #include extern "C" { From evelikov at kemper.freedesktop.org Thu Mar 5 14:51:51 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Thu, 5 Mar 2015 06:51:51 -0800 (PST) Subject: Mesa (master): egl/main: remove no-longer needed definition of stdint types Message-ID: <20150305145151.6C9AC763B7@kemper.freedesktop.org> Module: Mesa Branch: master Commit: d1fbea038b29579a578ff4e1babbce8c39365d36 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=d1fbea038b29579a578ff4e1babbce8c39365d36 Author: Emil Velikov Date: Sat Feb 28 17:14:31 2015 +0000 egl/main: remove no-longer needed definition of stdint types All the users directly include the header, plus we have a in-tree replacements for non C99 compilers which we already use. Signed-off-by: Emil Velikov Reviewed-by: Matt Turner Reviewed-by: Brian Paul --- src/egl/main/eglcompiler.h | 32 -------------------------------- 1 file changed, 32 deletions(-) diff --git a/src/egl/main/eglcompiler.h b/src/egl/main/eglcompiler.h index ffd327a..b457a40 100644 --- a/src/egl/main/eglcompiler.h +++ b/src/egl/main/eglcompiler.h @@ -30,38 +30,6 @@ #ifndef EGLCOMPILER_INCLUDED #define EGLCOMPILER_INCLUDED - -/** - * Get standard integer types - */ -#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || \ - (defined(_MSC_VER) && _MSC_VER >= 1600) -# include -#elif defined(_MSC_VER) - typedef __int8 int8_t; - typedef unsigned __int8 uint8_t; - typedef __int16 int16_t; - typedef unsigned __int16 uint16_t; - typedef __int32 int32_t; - typedef unsigned __int32 uint32_t; - typedef __int64 int64_t; - typedef unsigned __int64 uint64_t; - -# if defined(_WIN64) - typedef __int64 intptr_t; - typedef unsigned __int64 uintptr_t; -# else - typedef __int32 intptr_t; - typedef unsigned __int32 uintptr_t; -# endif - -# define INT64_C(__val) __val##i64 -# define UINT64_C(__val) __val##ui64 -#else -/* hope the best instead of adding a bunch of ifdef's */ -# include -#endif - #define STATIC_ASSERT(COND) \ do { \ (void) sizeof(char [1 - 2*!(COND)]); \ From evelikov at kemper.freedesktop.org Thu Mar 5 14:51:51 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Thu, 5 Mar 2015 06:51:51 -0800 (PST) Subject: Mesa (master): mesa/main: update .gitignore Message-ID: <20150305145151.7524B7617A@kemper.freedesktop.org> Module: Mesa Branch: master Commit: abae3434c42ce55d0aa26443e52fea98cc7cfe32 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=abae3434c42ce55d0aa26443e52fea98cc7cfe32 Author: Emil Velikov Date: Mon Mar 2 15:58:16 2015 +0000 mesa/main: update .gitignore Drop the no longer present get_es{1,2}.c from the list. v2: Keep the format_info.c rename hunk out of this patch. Signed-off-by: Emil Velikov Reviewed-by: Matt Turner --- src/mesa/main/.gitignore | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/mesa/main/.gitignore b/src/mesa/main/.gitignore index e65472d..98e645e 100644 --- a/src/mesa/main/.gitignore +++ b/src/mesa/main/.gitignore @@ -1,8 +1,6 @@ api_exec.c dispatch.h enums.c -get_es1.c -get_es2.c git_sha1.h git_sha1.h.tmp remap_helper.h From evelikov at kemper.freedesktop.org Thu Mar 5 14:51:51 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Thu, 5 Mar 2015 06:51:51 -0800 (PST) Subject: Mesa (master): mesa: rename format_info.c to format_info.h Message-ID: <20150305145151.7ECDB7617A@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 3f6c28f2a976e35128b7a4a513cfa60af00301e1 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=3f6c28f2a976e35128b7a4a513cfa60af00301e1 Author: Emil Velikov Date: Mon Mar 2 15:58:17 2015 +0000 mesa: rename format_info.c to format_info.h The file is auto-generated, and #included by formats.c. Let's rename it to reflect the latter. This will also help up fix the dependency tracking by adding it to the _SOURCES variable, without the side effect of it being compiled (twice). v2: Update .gitignore to reflect the rename. Cc: "10.4, 10.5" Signed-off-by: Emil Velikov Reviewed-by: Matt Turner --- src/mesa/Android.gen.mk | 2 +- src/mesa/Makefile.am | 6 +++--- src/mesa/SConscript | 2 +- src/mesa/main/.gitignore | 2 +- src/mesa/main/formats.c | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/mesa/Android.gen.mk b/src/mesa/Android.gen.mk index c7b7f7e..caae2c1 100644 --- a/src/mesa/Android.gen.mk +++ b/src/mesa/Android.gen.mk @@ -122,5 +122,5 @@ format_info_deps := \ $(LOCAL_PATH)/main/format_parser.py \ $(FORMAT_INFO) -$(intermediates)/main/format_info.c: $(format_info_deps) +$(intermediates)/main/format_info.h: $(format_info_deps) @$(MESA_PYTHON2) $(FORMAT_INFO) $< > $@ diff --git a/src/mesa/Makefile.am b/src/mesa/Makefile.am index 467492f..5f9ee1e 100644 --- a/src/mesa/Makefile.am +++ b/src/mesa/Makefile.am @@ -79,7 +79,7 @@ EXTRA_DIST = \ BUILT_SOURCES = \ main/get_hash.h \ - main/format_info.c \ + main/format_info.h \ main/git_sha1.h \ main/format_pack.c \ main/format_unpack.c \ @@ -99,7 +99,7 @@ main/get_hash.h: ../mapi/glapi/gen/gl_and_es_API.xml main/get_hash_params.py \ -f $< > $@.tmp; \ mv $@.tmp $@; -main/format_info.c: main/formats.csv \ +main/format_info.h: main/formats.csv \ main/format_parser.py main/format_info.py $(AM_V_GEN)set -e; \ $(PYTHON2) $(PYTHON_FLAGS) $(srcdir)/main/format_info.py \ @@ -122,7 +122,7 @@ main/format_unpack.c: main/format_unpack.py main/formats.csv \ $(srcdir)/main/formats.csv \ | $(INDENT) $(INDENT_FLAGS) > $@; -main/formats.c: main/format_info.c +main/formats.c: main/format_info.h noinst_LTLIBRARIES = $(ARCH_LIBS) if NEED_LIBMESA diff --git a/src/mesa/SConscript b/src/mesa/SConscript index d6ff083..81939f9 100644 --- a/src/mesa/SConscript +++ b/src/mesa/SConscript @@ -64,7 +64,7 @@ get_hash_header = env.CodeGenerate( ) format_info = env.CodeGenerate( - target = 'main/format_info.c', + target = 'main/format_info.h', script = 'main/format_info.py', source = 'main/formats.csv', command = python_cmd + ' $SCRIPT ' + ' $SOURCE > $TARGET' diff --git a/src/mesa/main/.gitignore b/src/mesa/main/.gitignore index 98e645e..8256ad7 100644 --- a/src/mesa/main/.gitignore +++ b/src/mesa/main/.gitignore @@ -6,6 +6,6 @@ git_sha1.h.tmp remap_helper.h get_hash.h get_hash.h.tmp -format_info.c +format_info.h format_pack.c format_unpack.c diff --git a/src/mesa/main/formats.c b/src/mesa/main/formats.c index a6f5cde..422c9dc 100644 --- a/src/mesa/main/formats.c +++ b/src/mesa/main/formats.c @@ -75,7 +75,7 @@ struct gl_format_info mesa_array_format ArrayFormat; }; -#include "format_info.c" +#include "format_info.h" static const struct gl_format_info * _mesa_get_format_info(mesa_format format) From evelikov at kemper.freedesktop.org Thu Mar 5 14:51:51 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Thu, 5 Mar 2015 06:51:51 -0800 (PST) Subject: Mesa (master): mesa: fix dependency tracking of generated sources Message-ID: <20150305145151.878857617A@kemper.freedesktop.org> Module: Mesa Branch: master Commit: d22391cb165af4ed2f9a9e5d6233072a432cc969 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=d22391cb165af4ed2f9a9e5d6233072a432cc969 Author: Emil Velikov Date: Mon Mar 2 15:58:18 2015 +0000 mesa: fix dependency tracking of generated sources Some of the files generated were not in the SOURCES variable, thus although generated prior to compilation the dependency tracking was incomplete. The latter of which resulted in the files missing from the distribution tarball. Cc: "10.5" Signed-off-by: Emil Velikov Reviewed-by: Matt Turner --- src/mesa/Makefile.sources | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/mesa/Makefile.sources b/src/mesa/Makefile.sources index 5b4e712..217be9a 100644 --- a/src/mesa/Makefile.sources +++ b/src/mesa/Makefile.sources @@ -86,6 +86,7 @@ MAIN_FILES = \ main/ffvertex_prog.h \ main/fog.c \ main/fog.h \ + main/format_info.h \ main/format_pack.h \ main/format_pack.c \ main/format_unpack.h \ @@ -100,6 +101,7 @@ MAIN_FILES = \ main/framebuffer.h \ main/get.c \ main/get.h \ + main/get_hash.h \ main/genmipmap.c \ main/genmipmap.h \ main/getstring.c \ From evelikov at kemper.freedesktop.org Thu Mar 5 14:51:51 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Thu, 5 Mar 2015 06:51:51 -0800 (PST) Subject: Mesa (master): xmlpool: make sure we ship options.h Message-ID: <20150305145151.A34D97617A@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 8d8ca64c28170ec7e9ffa01638bcf8fd30a96088 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=8d8ca64c28170ec7e9ffa01638bcf8fd30a96088 Author: Emil Velikov Date: Mon Mar 2 15:58:21 2015 +0000 xmlpool: make sure we ship options.h The header is included in ../xmlpool.h. With the latter of which used directly in a number of places in mesa. Note that we can also add it (alongside t_option.h) to noinst_HEADERS, but neither solution fixes the issue that brough us here - namely: Do not regenerate the headers, if it already exists. Cc: "10.5" Signed-off-by: Emil Velikov Reviewed-by: Matt Turner --- src/mesa/drivers/dri/common/xmlpool/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesa/drivers/dri/common/xmlpool/Makefile.am b/src/mesa/drivers/dri/common/xmlpool/Makefile.am index da7d034..5557716 100644 --- a/src/mesa/drivers/dri/common/xmlpool/Makefile.am +++ b/src/mesa/drivers/dri/common/xmlpool/Makefile.am @@ -52,7 +52,7 @@ POT=xmlpool.pot .PHONY: all clean pot po mo -EXTRA_DIST = gen_xmlpool.py t_options.h $(POS) SConscript +EXTRA_DIST = gen_xmlpool.py options.h t_options.h $(POS) SConscript BUILT_SOURCES = options.h CLEANFILES = $(MOS) options.h From evelikov at kemper.freedesktop.org Thu Mar 5 14:51:51 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Thu, 5 Mar 2015 06:51:51 -0800 (PST) Subject: Mesa (master): mapi: fix *glapi dependency tracking Message-ID: <20150305145151.99C617617A@kemper.freedesktop.org> Module: Mesa Branch: master Commit: fe5fddd7e2df74233a2a02ae021418485f39d11c URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=fe5fddd7e2df74233a2a02ae021418485f39d11c Author: Emil Velikov Date: Mon Mar 2 15:58:20 2015 +0000 mapi: fix *glapi dependency tracking I.e. add {shared-,}glapi/glapi_mapi_tmp.h to the SOURCES list. Otherwise there will be no knowledge that the file is required by others for the build. Thus autotools won't pick it up for the distribution tarball. v2: Don't forget about the static glapi. Spotted by Matt. Cc: "10.5" Signed-off-by: Emil Velikov Reviewed-by: Matt Turner --- src/mapi/Makefile.am | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mapi/Makefile.am b/src/mapi/Makefile.am index ef6f5ee..50c5b2e 100644 --- a/src/mapi/Makefile.am +++ b/src/mapi/Makefile.am @@ -69,7 +69,7 @@ if HAVE_SHARED_GLAPI BUILT_SOURCES += shared-glapi/glapi_mapi_tmp.h lib_LTLIBRARIES += shared-glapi/libglapi.la -shared_glapi_libglapi_la_SOURCES = $(MAPI_GLAPI_FILES) +shared_glapi_libglapi_la_SOURCES = $(MAPI_GLAPI_FILES) shared-glapi/glapi_mapi_tmp.h shared_glapi_libglapi_la_CPPFLAGS = \ $(AM_CPPFLAGS) \ -DMAPI_MODE_GLAPI \ @@ -118,7 +118,7 @@ glapi_libglapi_la_CPPFLAGS = \ -I$(top_srcdir)/src/mesa if HAVE_SHARED_GLAPI -glapi_libglapi_la_SOURCES += $(MAPI_BRIDGE_FILES) +glapi_libglapi_la_SOURCES += $(MAPI_BRIDGE_FILES) glapi/glapi_mapi_tmp.h glapi_libglapi_la_CPPFLAGS += \ -DMAPI_MODE_BRIDGE \ -DMAPI_ABI_HEADER=\"glapi/glapi_mapi_tmp.h\" From evelikov at kemper.freedesktop.org Thu Mar 5 14:51:51 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Thu, 5 Mar 2015 06:51:51 -0800 (PST) Subject: Mesa (master): mesa: drop Makefile from get_hash.h dependency list Message-ID: <20150305145151.90DD37617A@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 2c0f72d5389a9838cc4fbf4cc4f4291aa56c7845 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=2c0f72d5389a9838cc4fbf4cc4f4291aa56c7845 Author: Emil Velikov Date: Mon Mar 2 15:58:19 2015 +0000 mesa: drop Makefile from get_hash.h dependency list Not required. Additionally this had the side effect of generating the file, despite it's existence. Cc: "10.5" Signed-off-by: Emil Velikov Reviewed-by: Matt Turner --- src/mesa/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesa/Makefile.am b/src/mesa/Makefile.am index 5f9ee1e..3dab8f0 100644 --- a/src/mesa/Makefile.am +++ b/src/mesa/Makefile.am @@ -93,7 +93,7 @@ CLEANFILES = \ GET_HASH_GEN = main/get_hash_generator.py main/get_hash.h: ../mapi/glapi/gen/gl_and_es_API.xml main/get_hash_params.py \ - $(GET_HASH_GEN) Makefile + $(GET_HASH_GEN) $(AM_V_GEN)set -e; \ $(PYTHON2) $(PYTHON_FLAGS) $(srcdir)/$(GET_HASH_GEN) \ -f $< > $@.tmp; \ From evelikov at kemper.freedesktop.org Thu Mar 5 14:51:51 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Thu, 5 Mar 2015 06:51:51 -0800 (PST) Subject: Mesa (master): egl/main: replace __FUNCTION__ with __func__ Message-ID: <20150305145151.44FCF763B7@kemper.freedesktop.org> Module: Mesa Branch: master Commit: d780012cd75c24394b043b107d17eb8199ae2dc7 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=d780012cd75c24394b043b107d17eb8199ae2dc7 Author: Emil Velikov Date: Sat Feb 28 16:39:10 2015 +0000 egl/main: replace __FUNCTION__ with __func__ The latter is a C99 standard, and our current wrapper c99_compat.h should handle non-compliant compilers. Drop the c99_compat.h inclusion from eglcompiler.h altogether, as it's no longer required. Signed-off-by: Emil Velikov Reviewed-by: Matt Turner Reviewed-by: Brian Paul --- src/egl/main/eglapi.c | 6 +++--- src/egl/main/eglcompiler.h | 8 -------- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c index cc74b1a..2258830 100644 --- a/src/egl/main/eglapi.c +++ b/src/egl/main/eglapi.c @@ -113,7 +113,7 @@ _eglUnlockDisplay(disp); \ /* EGL error codes are non-zero */ \ if (err) \ - _eglError(err, __FUNCTION__); \ + _eglError(err, __func__); \ return ret; \ } while (0) @@ -131,14 +131,14 @@ #define _EGL_CHECK_DISPLAY(disp, ret, drv) \ do { \ - drv = _eglCheckDisplay(disp, __FUNCTION__); \ + drv = _eglCheckDisplay(disp, __func__); \ if (!drv) \ RETURN_EGL_ERROR(disp, 0, ret); \ } while (0) #define _EGL_CHECK_OBJECT(disp, type, obj, ret, drv) \ do { \ - drv = _eglCheck ## type(disp, obj, __FUNCTION__); \ + drv = _eglCheck ## type(disp, obj, __func__); \ if (!drv) \ RETURN_EGL_ERROR(disp, 0, ret); \ } while (0) diff --git a/src/egl/main/eglcompiler.h b/src/egl/main/eglcompiler.h index 2e1c8b9..f5fb869 100644 --- a/src/egl/main/eglcompiler.h +++ b/src/egl/main/eglcompiler.h @@ -31,9 +31,6 @@ #define EGLCOMPILER_INCLUDED -#include "c99_compat.h" /* __func__, etc. */ - - /** * Get standard integer types */ @@ -79,11 +76,6 @@ # endif #endif -/* XXX: Use standard `__func__` instead */ -#ifndef __FUNCTION__ -# define __FUNCTION__ __func__ -#endif - #define STATIC_ASSERT(COND) \ do { \ (void) sizeof(char [1 - 2*!(COND)]); \ From evelikov at kemper.freedesktop.org Thu Mar 5 14:51:51 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Thu, 5 Mar 2015 06:51:51 -0800 (PST) Subject: Mesa (master): egl/main: drop the declaration of PUBLIC keyword. Message-ID: <20150305145151.5853A7617A@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 74c40b9b5676c836b3d6ea2ff32e3d1913a0e559 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=74c40b9b5676c836b3d6ea2ff32e3d1913a0e559 Author: Emil Velikov Date: Sat Feb 28 16:51:21 2015 +0000 egl/main: drop the declaration of PUBLIC keyword. Should no longer be used. As many places indirectly include eglcompiler.h keep this change separate, so that it can be easily reverted, if needed. Signed-off-by: Emil Velikov Reviewed-by: Matt Turner Reviewed-by: Brian Paul --- src/egl/main/eglcompiler.h | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/src/egl/main/eglcompiler.h b/src/egl/main/eglcompiler.h index f5fb869..ffd327a 100644 --- a/src/egl/main/eglcompiler.h +++ b/src/egl/main/eglcompiler.h @@ -62,20 +62,6 @@ # include #endif - -/** - * Function visibility - */ -#ifndef PUBLIC -# if defined(__GNUC__) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)) -# define PUBLIC __attribute__((visibility("default"))) -# elif defined(_MSC_VER) -# define PUBLIC __declspec(dllexport) -# else -# define PUBLIC -# endif -#endif - #define STATIC_ASSERT(COND) \ do { \ (void) sizeof(char [1 - 2*!(COND)]); \ From tstellar at kemper.freedesktop.org Thu Mar 5 15:15:30 2015 From: tstellar at kemper.freedesktop.org (Tom Stellard) Date: Thu, 5 Mar 2015 07:15:30 -0800 (PST) Subject: Mesa (master): clover: Enable cl_khr_fp64 for devices that support doubles v4 Message-ID: <20150305151530.679BC7617A@kemper.freedesktop.org> Module: Mesa Branch: master Commit: c97e902a1a69892147e7649581951747f03afaee URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=c97e902a1a69892147e7649581951747f03afaee Author: Tom Stellard Date: Wed Jul 2 15:42:43 2014 -0400 clover: Enable cl_khr_fp64 for devices that support doubles v4 v2: - Report correct values for CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE and CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE. - Only define cl_khr_fp64 if the extension is supported. - Remove trailing space from extension string. - Rename device query function from cl_khr_fp64() to has_doubles(). v3: - Return 0 for device::doubled_fp_confg() when doubles aren't supported. v4: - Remove device query for double fp_config. Reviewed-by: Francisco Jerez --- src/gallium/state_trackers/clover/api/device.cpp | 21 ++++++++++++++++++--- src/gallium/state_trackers/clover/core/device.cpp | 6 ++++++ src/gallium/state_trackers/clover/core/device.hpp | 1 + 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/src/gallium/state_trackers/clover/api/device.cpp b/src/gallium/state_trackers/clover/api/device.cpp index e825468..b1f556f 100644 --- a/src/gallium/state_trackers/clover/api/device.cpp +++ b/src/gallium/state_trackers/clover/api/device.cpp @@ -145,7 +145,7 @@ clGetDeviceInfo(cl_device_id d_dev, cl_device_info param, break; case CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE: - buf.as_scalar() = 2; + buf.as_scalar() = dev.has_doubles() ? 2 : 0; break; case CL_DEVICE_PREFERRED_VECTOR_WIDTH_HALF: @@ -205,6 +205,21 @@ clGetDeviceInfo(cl_device_id d_dev, cl_device_info param, CL_FP_DENORM | CL_FP_INF_NAN | CL_FP_ROUND_TO_NEAREST; break; + case CL_DEVICE_DOUBLE_FP_CONFIG: + if (dev.has_doubles()) + // This is the "mandated minimum double precision floating-point + // capability" + buf.as_scalar() = + CL_FP_FMA + | CL_FP_ROUND_TO_NEAREST + | CL_FP_ROUND_TO_ZERO + | CL_FP_ROUND_TO_INF + | CL_FP_INF_NAN + | CL_FP_DENORM; + else + buf.as_scalar() = 0; + break; + case CL_DEVICE_GLOBAL_MEM_CACHE_TYPE: buf.as_scalar() = CL_NONE; break; @@ -283,7 +298,7 @@ clGetDeviceInfo(cl_device_id d_dev, cl_device_info param, break; case CL_DEVICE_EXTENSIONS: - buf.as_string() = ""; + buf.as_string() = dev.has_doubles() ? "cl_khr_fp64" : ""; break; case CL_DEVICE_PLATFORM: @@ -315,7 +330,7 @@ clGetDeviceInfo(cl_device_id d_dev, cl_device_info param, break; case CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE: - buf.as_scalar() = 2; + buf.as_scalar() = dev.has_doubles() ? 2 : 0; break; case CL_DEVICE_NATIVE_VECTOR_WIDTH_HALF: diff --git a/src/gallium/state_trackers/clover/core/device.cpp b/src/gallium/state_trackers/clover/core/device.cpp index 688a7dd..c3f3b4e 100644 --- a/src/gallium/state_trackers/clover/core/device.cpp +++ b/src/gallium/state_trackers/clover/core/device.cpp @@ -173,6 +173,12 @@ device::image_support() const { PIPE_COMPUTE_CAP_IMAGES_SUPPORTED)[0]; } +bool +device::has_doubles() const { + return pipe->get_shader_param(pipe, PIPE_SHADER_COMPUTE, + PIPE_SHADER_CAP_DOUBLES); +} + std::vector device::max_block_size() const { auto v = get_compute_param(pipe, PIPE_COMPUTE_CAP_MAX_BLOCK_SIZE); diff --git a/src/gallium/state_trackers/clover/core/device.hpp b/src/gallium/state_trackers/clover/core/device.hpp index 2201700..de5fc6b 100644 --- a/src/gallium/state_trackers/clover/core/device.hpp +++ b/src/gallium/state_trackers/clover/core/device.hpp @@ -64,6 +64,7 @@ namespace clover { cl_uint max_clock_frequency() const; cl_uint max_compute_units() const; bool image_support() const; + bool has_doubles() const; std::vector max_block_size() const; std::string device_name() const; From mattst88 at kemper.freedesktop.org Thu Mar 5 18:17:04 2015 From: mattst88 at kemper.freedesktop.org (Matt Turner) Date: Thu, 5 Mar 2015 10:17:04 -0800 (PST) Subject: Mesa (master): mesa/x86: missing stdio inclusions Message-ID: <20150305181704.4129E7617A@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 5f9ee6a02f54864df166e5dcc7303771d4eac9b3 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=5f9ee6a02f54864df166e5dcc7303771d4eac9b3 Author: Mark Janes Date: Thu Mar 5 10:14:16 2015 -0800 mesa/x86: missing stdio inclusions Several patches added include statements where required by the m64 build. Some files are only compiled for m32, and require similar changes. Reviewed-by: Matt Turner --- src/mesa/tnl/t_vertex_sse.c | 2 ++ src/mesa/x86/rtasm/x86sse.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/mesa/tnl/t_vertex_sse.c b/src/mesa/tnl/t_vertex_sse.c index 93128fb..963432c 100644 --- a/src/mesa/tnl/t_vertex_sse.c +++ b/src/mesa/tnl/t_vertex_sse.c @@ -25,6 +25,8 @@ * Keith Whitwell */ +#include + #include "main/glheader.h" #include "main/context.h" #include "main/colormac.h" diff --git a/src/mesa/x86/rtasm/x86sse.c b/src/mesa/x86/rtasm/x86sse.c index c93faba..c9f52a4 100644 --- a/src/mesa/x86/rtasm/x86sse.c +++ b/src/mesa/x86/rtasm/x86sse.c @@ -1,6 +1,8 @@ #ifdef USE_X86_ASM #if defined(__i386__) || defined(__386__) +#include + #include "main/imports.h" #include "x86sse.h" From mattst88 at kemper.freedesktop.org Thu Mar 5 18:18:37 2015 From: mattst88 at kemper.freedesktop.org (Matt Turner) Date: Thu, 5 Mar 2015 10:18:37 -0800 (PST) Subject: Mesa (master): i965: Tell intel_get_memcpy() which direction the memcpy() is going. Message-ID: <20150305181837.694487617A@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 2e4c95dfe2cb205c327ceaa12b44a9273bdb20dc URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=2e4c95dfe2cb205c327ceaa12b44a9273bdb20dc Author: Matt Turner Date: Wed Mar 4 15:21:53 2015 -0800 i965: Tell intel_get_memcpy() which direction the memcpy() is going. The SSSE3 swizzling code was written for fast uploads to the GPU and assumed the destination was always 16-byte aligned. When we began using this code for fast downloads as well we didn't do anything to account for the fact that the destination pointer given by glReadPixels() or glGetTexImage() is not guaranteed to be suitably aligned. With SSSE3 enabled (at compile-time), some applications would crash when an SSE aligned-store instruction tried to store to an unaligned destination (or an assertion that the destination is aligned would trigger). To remedy this, tell intel_get_memcpy() whether we're uploading or downloading so that it can select whether to assume the destination or source is aligned, respectively. Cc: 10.5 Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=89416 Tested-by: Uriy Zhuravlev Reviewed-by: Jason Ekstrand --- src/mesa/drivers/dri/i965/intel_pixel_read.c | 3 +- src/mesa/drivers/dri/i965/intel_tex_image.c | 3 +- src/mesa/drivers/dri/i965/intel_tex_subimage.c | 3 +- src/mesa/drivers/dri/i965/intel_tiled_memcpy.c | 124 ++++++++++++++++-------- src/mesa/drivers/dri/i965/intel_tiled_memcpy.h | 15 ++- 5 files changed, 106 insertions(+), 42 deletions(-) diff --git a/src/mesa/drivers/dri/i965/intel_pixel_read.c b/src/mesa/drivers/dri/i965/intel_pixel_read.c index df22a63..0972121 100644 --- a/src/mesa/drivers/dri/i965/intel_pixel_read.c +++ b/src/mesa/drivers/dri/i965/intel_pixel_read.c @@ -139,7 +139,8 @@ intel_readpixels_tiled_memcpy(struct gl_context * ctx, rb->Format == MESA_FORMAT_R8G8B8X8_UNORM) return false; - if (!intel_get_memcpy(rb->Format, format, type, &mem_copy, &cpp)) + if (!intel_get_memcpy(rb->Format, format, type, &mem_copy, &cpp, + INTEL_DOWNLOAD)) return false; if (!irb->mt || diff --git a/src/mesa/drivers/dri/i965/intel_tex_image.c b/src/mesa/drivers/dri/i965/intel_tex_image.c index da42fdd..00bf9ce 100644 --- a/src/mesa/drivers/dri/i965/intel_tex_image.c +++ b/src/mesa/drivers/dri/i965/intel_tex_image.c @@ -408,7 +408,8 @@ intel_gettexsubimage_tiled_memcpy(struct gl_context *ctx, texImage->TexFormat == MESA_FORMAT_R8G8B8X8_UNORM) return false; - if (!intel_get_memcpy(texImage->TexFormat, format, type, &mem_copy, &cpp)) + if (!intel_get_memcpy(texImage->TexFormat, format, type, &mem_copy, &cpp, + INTEL_DOWNLOAD)) return false; /* If this is a nontrivial texture view, let another path handle it instead. */ diff --git a/src/mesa/drivers/dri/i965/intel_tex_subimage.c b/src/mesa/drivers/dri/i965/intel_tex_subimage.c index 4262f71..909ff25 100644 --- a/src/mesa/drivers/dri/i965/intel_tex_subimage.c +++ b/src/mesa/drivers/dri/i965/intel_tex_subimage.c @@ -118,7 +118,8 @@ intel_texsubimage_tiled_memcpy(struct gl_context * ctx, packing->Invert) return false; - if (!intel_get_memcpy(texImage->TexFormat, format, type, &mem_copy, &cpp)) + if (!intel_get_memcpy(texImage->TexFormat, format, type, &mem_copy, &cpp, + INTEL_UPLOAD)) return false; /* If this is a nontrivial texture view, let another path handle it instead. */ diff --git a/src/mesa/drivers/dri/i965/intel_tiled_memcpy.c b/src/mesa/drivers/dri/i965/intel_tiled_memcpy.c index f2b35cb..2097aaa 100644 --- a/src/mesa/drivers/dri/i965/intel_tiled_memcpy.c +++ b/src/mesa/drivers/dri/i965/intel_tiled_memcpy.c @@ -60,42 +60,79 @@ static const uint32_t ytile_span = 16; static const uint8_t rgba8_permutation[16] = { 2,1,0,3, 6,5,4,7, 10,9,8,11, 14,13,12,15 }; -/* NOTE: dst must be 16 byte aligned */ -#define rgba8_copy_16(dst, src) \ - *(__m128i *)(dst) = _mm_shuffle_epi8( \ - (__m128i) _mm_loadu_ps((float *)(src)), \ - *(__m128i *) rgba8_permutation \ - ) +/* NOTE: dst must be 16-byte aligned. src may be unaligned. */ +#define rgba8_copy_16_aligned_dst(dst, src) \ + _mm_store_si128((__m128i *)(dst), \ + _mm_shuffle_epi8(_mm_loadu_si128((__m128i *)(src)), \ + *(__m128i *) rgba8_permutation)) + +/* NOTE: src must be 16-byte aligned. dst may be unaligned. */ +#define rgba8_copy_16_aligned_src(dst, src) \ + _mm_storeu_si128((__m128i *)(dst), \ + _mm_shuffle_epi8(_mm_load_si128((__m128i *)(src)), \ + *(__m128i *) rgba8_permutation)) #endif /** - * Copy RGBA to BGRA - swap R and B. + * Copy RGBA to BGRA - swap R and B, with the destination 16-byte aligned. */ static inline void * -rgba8_copy(void *dst, const void *src, size_t bytes) +rgba8_copy_aligned_dst(void *dst, const void *src, size_t bytes) { uint8_t *d = dst; uint8_t const *s = src; #ifdef __SSSE3__ - /* Fast copying for tile spans. - * - * As long as the destination texture is 16 aligned, - * any 16 or 64 spans we get here should also be 16 aligned. - */ - if (bytes == 16) { assert(!(((uintptr_t)dst) & 0xf)); - rgba8_copy_16(d+ 0, s+ 0); + rgba8_copy_16_aligned_dst(d+ 0, s+ 0); return dst; } if (bytes == 64) { assert(!(((uintptr_t)dst) & 0xf)); - rgba8_copy_16(d+ 0, s+ 0); - rgba8_copy_16(d+16, s+16); - rgba8_copy_16(d+32, s+32); - rgba8_copy_16(d+48, s+48); + rgba8_copy_16_aligned_dst(d+ 0, s+ 0); + rgba8_copy_16_aligned_dst(d+16, s+16); + rgba8_copy_16_aligned_dst(d+32, s+32); + rgba8_copy_16_aligned_dst(d+48, s+48); + return dst; + } +#endif + + while (bytes >= 4) { + d[0] = s[2]; + d[1] = s[1]; + d[2] = s[0]; + d[3] = s[3]; + d += 4; + s += 4; + bytes -= 4; + } + return dst; +} + +/** + * Copy RGBA to BGRA - swap R and B, with the source 16-byte aligned. + */ +static inline void * +rgba8_copy_aligned_src(void *dst, const void *src, size_t bytes) +{ + uint8_t *d = dst; + uint8_t const *s = src; + +#ifdef __SSSE3__ + if (bytes == 16) { + assert(!(((uintptr_t)src) & 0xf)); + rgba8_copy_16_aligned_src(d+ 0, s+ 0); + return dst; + } + + if (bytes == 64) { + assert(!(((uintptr_t)src) & 0xf)); + rgba8_copy_16_aligned_src(d+ 0, s+ 0); + rgba8_copy_16_aligned_src(d+16, s+16); + rgba8_copy_16_aligned_src(d+32, s+32); + rgba8_copy_16_aligned_src(d+48, s+48); return dst; } #endif @@ -357,16 +394,18 @@ linear_to_xtiled_faster(uint32_t x0, uint32_t x1, uint32_t x2, uint32_t x3, if (mem_copy == memcpy) return linear_to_xtiled(0, 0, xtile_width, xtile_width, 0, xtile_height, dst, src, src_pitch, swizzle_bit, memcpy); - else if (mem_copy == rgba8_copy) + else if (mem_copy == rgba8_copy_aligned_dst) return linear_to_xtiled(0, 0, xtile_width, xtile_width, 0, xtile_height, - dst, src, src_pitch, swizzle_bit, rgba8_copy); + dst, src, src_pitch, swizzle_bit, + rgba8_copy_aligned_dst); } else { if (mem_copy == memcpy) return linear_to_xtiled(x0, x1, x2, x3, y0, y1, dst, src, src_pitch, swizzle_bit, memcpy); - else if (mem_copy == rgba8_copy) + else if (mem_copy == rgba8_copy_aligned_dst) return linear_to_xtiled(x0, x1, x2, x3, y0, y1, - dst, src, src_pitch, swizzle_bit, rgba8_copy); + dst, src, src_pitch, swizzle_bit, + rgba8_copy_aligned_dst); } linear_to_xtiled(x0, x1, x2, x3, y0, y1, dst, src, src_pitch, swizzle_bit, mem_copy); @@ -393,16 +432,18 @@ linear_to_ytiled_faster(uint32_t x0, uint32_t x1, uint32_t x2, uint32_t x3, if (mem_copy == memcpy) return linear_to_ytiled(0, 0, ytile_width, ytile_width, 0, ytile_height, dst, src, src_pitch, swizzle_bit, memcpy); - else if (mem_copy == rgba8_copy) + else if (mem_copy == rgba8_copy_aligned_dst) return linear_to_ytiled(0, 0, ytile_width, ytile_width, 0, ytile_height, - dst, src, src_pitch, swizzle_bit, rgba8_copy); + dst, src, src_pitch, swizzle_bit, + rgba8_copy_aligned_dst); } else { if (mem_copy == memcpy) return linear_to_ytiled(x0, x1, x2, x3, y0, y1, dst, src, src_pitch, swizzle_bit, memcpy); - else if (mem_copy == rgba8_copy) + else if (mem_copy == rgba8_copy_aligned_dst) return linear_to_ytiled(x0, x1, x2, x3, y0, y1, - dst, src, src_pitch, swizzle_bit, rgba8_copy); + dst, src, src_pitch, swizzle_bit, + rgba8_copy_aligned_dst); } linear_to_ytiled(x0, x1, x2, x3, y0, y1, dst, src, src_pitch, swizzle_bit, mem_copy); @@ -429,16 +470,18 @@ xtiled_to_linear_faster(uint32_t x0, uint32_t x1, uint32_t x2, uint32_t x3, if (mem_copy == memcpy) return xtiled_to_linear(0, 0, xtile_width, xtile_width, 0, xtile_height, dst, src, dst_pitch, swizzle_bit, memcpy); - else if (mem_copy == rgba8_copy) + else if (mem_copy == rgba8_copy_aligned_src) return xtiled_to_linear(0, 0, xtile_width, xtile_width, 0, xtile_height, - dst, src, dst_pitch, swizzle_bit, rgba8_copy); + dst, src, dst_pitch, swizzle_bit, + rgba8_copy_aligned_src); } else { if (mem_copy == memcpy) return xtiled_to_linear(x0, x1, x2, x3, y0, y1, dst, src, dst_pitch, swizzle_bit, memcpy); - else if (mem_copy == rgba8_copy) + else if (mem_copy == rgba8_copy_aligned_src) return xtiled_to_linear(x0, x1, x2, x3, y0, y1, - dst, src, dst_pitch, swizzle_bit, rgba8_copy); + dst, src, dst_pitch, swizzle_bit, + rgba8_copy_aligned_src); } xtiled_to_linear(x0, x1, x2, x3, y0, y1, dst, src, dst_pitch, swizzle_bit, mem_copy); @@ -465,16 +508,18 @@ ytiled_to_linear_faster(uint32_t x0, uint32_t x1, uint32_t x2, uint32_t x3, if (mem_copy == memcpy) return ytiled_to_linear(0, 0, ytile_width, ytile_width, 0, ytile_height, dst, src, dst_pitch, swizzle_bit, memcpy); - else if (mem_copy == rgba8_copy) + else if (mem_copy == rgba8_copy_aligned_src) return ytiled_to_linear(0, 0, ytile_width, ytile_width, 0, ytile_height, - dst, src, dst_pitch, swizzle_bit, rgba8_copy); + dst, src, dst_pitch, swizzle_bit, + rgba8_copy_aligned_src); } else { if (mem_copy == memcpy) return ytiled_to_linear(x0, x1, x2, x3, y0, y1, dst, src, dst_pitch, swizzle_bit, memcpy); - else if (mem_copy == rgba8_copy) + else if (mem_copy == rgba8_copy_aligned_src) return ytiled_to_linear(x0, x1, x2, x3, y0, y1, - dst, src, dst_pitch, swizzle_bit, rgba8_copy); + dst, src, dst_pitch, swizzle_bit, + rgba8_copy_aligned_src); } ytiled_to_linear(x0, x1, x2, x3, y0, y1, dst, src, dst_pitch, swizzle_bit, mem_copy); @@ -684,7 +729,8 @@ tiled_to_linear(uint32_t xt1, uint32_t xt2, * \return true if the format and type combination are valid */ bool intel_get_memcpy(mesa_format tiledFormat, GLenum format, - GLenum type, mem_copy_fn* mem_copy, uint32_t* cpp) + GLenum type, mem_copy_fn *mem_copy, uint32_t *cpp, + enum intel_memcpy_direction direction) { if (type == GL_UNSIGNED_INT_8_8_8_8_REV && !(format == GL_RGBA || format == GL_BGRA)) @@ -700,7 +746,8 @@ bool intel_get_memcpy(mesa_format tiledFormat, GLenum format, if (format == GL_BGRA) { *mem_copy = memcpy; } else if (format == GL_RGBA) { - *mem_copy = rgba8_copy; + *mem_copy = direction == INTEL_UPLOAD ? rgba8_copy_aligned_dst + : rgba8_copy_aligned_src; } } else if ((tiledFormat == MESA_FORMAT_R8G8B8A8_UNORM) || (tiledFormat == MESA_FORMAT_R8G8B8X8_UNORM)) { @@ -709,7 +756,8 @@ bool intel_get_memcpy(mesa_format tiledFormat, GLenum format, /* Copying from RGBA to BGRA is the same as BGRA to RGBA so we can * use the same function. */ - *mem_copy = rgba8_copy; + *mem_copy = direction == INTEL_UPLOAD ? rgba8_copy_aligned_dst + : rgba8_copy_aligned_src; } else if (format == GL_RGBA) { *mem_copy = memcpy; } diff --git a/src/mesa/drivers/dri/i965/intel_tiled_memcpy.h b/src/mesa/drivers/dri/i965/intel_tiled_memcpy.h index 3ff0d71..9dc1088 100644 --- a/src/mesa/drivers/dri/i965/intel_tiled_memcpy.h +++ b/src/mesa/drivers/dri/i965/intel_tiled_memcpy.h @@ -55,7 +55,20 @@ tiled_to_linear(uint32_t xt1, uint32_t xt2, uint32_t tiling, mem_copy_fn mem_copy); +/* Tells intel_get_memcpy() whether the memcpy() is + * + * - an upload to the GPU with an aligned destination and a potentially + * unaligned source; or + * - a download from the GPU with an aligned source and a potentially + * unaligned destination. + */ +enum intel_memcpy_direction { + INTEL_UPLOAD, + INTEL_DOWNLOAD +}; + bool intel_get_memcpy(mesa_format tiledFormat, GLenum format, - GLenum type, mem_copy_fn* mem_copy, uint32_t* cpp); + GLenum type, mem_copy_fn *mem_copy, uint32_t *cpp, + enum intel_memcpy_direction direction); #endif /* INTEL_TILED_MEMCPY */ From mattst88 at kemper.freedesktop.org Thu Mar 5 18:23:39 2015 From: mattst88 at kemper.freedesktop.org (Matt Turner) Date: Thu, 5 Mar 2015 10:23:39 -0800 (PST) Subject: Mesa (master): Fix invalid extern "C" around header inclusion. Message-ID: <20150305182339.3DFE37617A@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 237dcb4aa7c39c59bfd225ae3d73caf709be216d URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=237dcb4aa7c39c59bfd225ae3d73caf709be216d Author: Mark Janes Date: Wed Mar 4 16:37:29 2015 -0800 Fix invalid extern "C" around header inclusion. System headers may contain C++ declarations, which cannot be given C linkage. For this reason, include statements should never occur inside extern "C". This patch moves the C linkage statements to enclose only the declarations within a single header. Reviewed-by: Jose Fonseca --- src/gallium/auxiliary/util/u_math.h | 11 +++++------ src/gallium/drivers/r600/r600_shader.h | 12 ++++++++++++ src/gallium/drivers/r600/sb/sb_bc.h | 2 -- src/gallium/drivers/r600/sb/sb_bc_parser.cpp | 2 -- src/gallium/drivers/r600/sb/sb_core.cpp | 2 -- src/gallium/drivers/r600/sb/sb_public.h | 12 ++++++++++++ src/glx/indirect_init.h | 8 ++++++++ src/glx/tests/indirect_api.cpp | 2 -- src/mapi/shared-glapi/tests/check_table.cpp | 2 -- src/mesa/drivers/common/driverfuncs.h | 7 +++++++ src/mesa/drivers/dri/i965/brw_fs.cpp | 3 --- src/mesa/drivers/dri/i965/brw_fs_channel_expressions.cpp | 2 -- src/mesa/drivers/dri/i965/brw_fs_generator.cpp | 3 --- src/mesa/drivers/dri/i965/brw_fs_vector_splitting.cpp | 2 -- src/mesa/drivers/dri/i965/brw_fs_visitor.cpp | 3 --- src/mesa/drivers/dri/i965/brw_shader.cpp | 2 -- src/mesa/drivers/dri/i965/brw_vec4_reg_allocate.cpp | 3 --- src/mesa/drivers/dri/i965/brw_wm.h | 8 ++++++++ src/mesa/main/api_exec.h | 7 +++++++ src/mesa/main/tests/dispatch_sanity.cpp | 2 -- src/mesa/main/tests/program_state_string.cpp | 2 -- src/mesa/main/vtxfmt.h | 8 ++++++++ src/mesa/vbo/vbo.h | 8 ++++++++ src/mesa/vbo/vbo_context.h | 8 ++++++++ src/util/Makefile.am | 3 +++ src/util/register_allocate.h | 10 ++++++++++ 26 files changed, 96 insertions(+), 38 deletions(-) diff --git a/src/gallium/auxiliary/util/u_math.h b/src/gallium/auxiliary/util/u_math.h index 5400fce..8f62cac 100644 --- a/src/gallium/auxiliary/util/u_math.h +++ b/src/gallium/auxiliary/util/u_math.h @@ -41,12 +41,6 @@ #include "pipe/p_compiler.h" - -#ifdef __cplusplus -extern "C" { -#endif - - #include "c99_math.h" #include #include @@ -56,6 +50,11 @@ extern "C" { #endif +#ifdef __cplusplus +extern "C" { +#endif + + #ifndef M_SQRT2 #define M_SQRT2 1.41421356237309504880 #endif diff --git a/src/gallium/drivers/r600/r600_shader.h b/src/gallium/drivers/r600/r600_shader.h index b2559e9..dd359d7 100644 --- a/src/gallium/drivers/r600/r600_shader.h +++ b/src/gallium/drivers/r600/r600_shader.h @@ -25,6 +25,12 @@ #include "r600_asm.h" + +#ifdef __cplusplus +extern "C" { +#endif + + struct r600_shader_io { unsigned name; unsigned gpr; @@ -125,4 +131,10 @@ struct r600_pipe_shader { TGSI_INTERPOLATE_LOC_CENTER/SAMPLE/COUNT. Other input values return -1. */ int eg_get_interpolator_index(unsigned interpolate, unsigned location); + +#ifdef __cplusplus +} // extern "C" +#endif + + #endif diff --git a/src/gallium/drivers/r600/sb/sb_bc.h b/src/gallium/drivers/r600/sb/sb_bc.h index 072d8f8..ab988f8 100644 --- a/src/gallium/drivers/r600/sb/sb_bc.h +++ b/src/gallium/drivers/r600/sb/sb_bc.h @@ -27,10 +27,8 @@ #ifndef SB_BC_H_ #define SB_BC_H_ -extern "C" { #include #include "r600_isa.h" -} #include #include diff --git a/src/gallium/drivers/r600/sb/sb_bc_parser.cpp b/src/gallium/drivers/r600/sb/sb_bc_parser.cpp index 403f938..08e7f5c 100644 --- a/src/gallium/drivers/r600/sb/sb_bc_parser.cpp +++ b/src/gallium/drivers/r600/sb/sb_bc_parser.cpp @@ -32,10 +32,8 @@ #define BCP_DUMP(q) #endif -extern "C" { #include "r600_pipe.h" #include "r600_shader.h" -} #include diff --git a/src/gallium/drivers/r600/sb/sb_core.cpp b/src/gallium/drivers/r600/sb/sb_core.cpp index 9fd9d9a..7db8008 100644 --- a/src/gallium/drivers/r600/sb/sb_core.cpp +++ b/src/gallium/drivers/r600/sb/sb_core.cpp @@ -26,13 +26,11 @@ #define SB_RA_SCHED_CHECK DEBUG -extern "C" { #include "os/os_time.h" #include "r600_pipe.h" #include "r600_shader.h" #include "sb_public.h" -} #include #include diff --git a/src/gallium/drivers/r600/sb/sb_public.h b/src/gallium/drivers/r600/sb/sb_public.h index c9f5f97..a90771f 100644 --- a/src/gallium/drivers/r600/sb/sb_public.h +++ b/src/gallium/drivers/r600/sb/sb_public.h @@ -27,6 +27,12 @@ #ifndef R600_SB_H_ #define R600_SB_H_ + +#ifdef __cplusplus +extern "C" { +#endif + + struct r600_shader; void r600_sb_context_destroy(void *sctx); @@ -37,4 +43,10 @@ int r600_sb_bytecode_process(struct r600_context *rctx, int dump_source_bytecode, int optimize); + +#ifdef __cplusplus +} // extern "C" +#endif + + #endif //R600_SB_H_ diff --git a/src/glx/indirect_init.h b/src/glx/indirect_init.h index 2ba01f5..7fe9a96 100644 --- a/src/glx/indirect_init.h +++ b/src/glx/indirect_init.h @@ -36,6 +36,14 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "glxclient.h" +#ifdef __cplusplus +extern "C" { +#endif + extern struct _glapi_table *__glXNewIndirectAPI(void); +#ifdef __cplusplus +} // extern "C" +#endif + #endif /* _INDIRECT_INIT_H_ */ diff --git a/src/glx/tests/indirect_api.cpp b/src/glx/tests/indirect_api.cpp index 52469a7..34304a1 100644 --- a/src/glx/tests/indirect_api.cpp +++ b/src/glx/tests/indirect_api.cpp @@ -45,11 +45,9 @@ #include #include "main/glheader.h" -extern "C" { #include "../indirect_init.h" #include "glapi/glapi.h" #include "../../mesa/main/dispatch.h" -} static const void *nil = 0; diff --git a/src/mapi/shared-glapi/tests/check_table.cpp b/src/mapi/shared-glapi/tests/check_table.cpp index 47c0b27..02d313c 100644 --- a/src/mapi/shared-glapi/tests/check_table.cpp +++ b/src/mapi/shared-glapi/tests/check_table.cpp @@ -24,10 +24,8 @@ #include #include "../../../mesa/main/glheader.h" -extern "C" { #include "glapi/glapi.h" #include "glapi/glapitable.h" -} struct name_offset { const char *name; diff --git a/src/mesa/drivers/common/driverfuncs.h b/src/mesa/drivers/common/driverfuncs.h index 6b9a900..385ccb8 100644 --- a/src/mesa/drivers/common/driverfuncs.h +++ b/src/mesa/drivers/common/driverfuncs.h @@ -26,6 +26,10 @@ #ifndef DRIVERFUNCS_H #define DRIVERFUNCS_H +#ifdef __cplusplus +extern "C" { +#endif + extern void _mesa_init_driver_functions(struct dd_function_table *driver); @@ -33,5 +37,8 @@ _mesa_init_driver_functions(struct dd_function_table *driver); extern void _mesa_init_driver_state(struct gl_context *ctx); +#ifdef __cplusplus +} // extern "C" +#endif #endif diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp index 533feb4..d6acc23 100644 --- a/src/mesa/drivers/dri/i965/brw_fs.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs.cpp @@ -28,8 +28,6 @@ * from the LIR. */ -extern "C" { - #include #include "util/hash_table.h" @@ -43,7 +41,6 @@ extern "C" { #include "brw_context.h" #include "brw_eu.h" #include "brw_wm.h" -} #include "brw_fs.h" #include "brw_cfg.h" #include "brw_dead_control_flow.h" 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 c64742c..933fdde 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_channel_expressions.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_channel_expressions.cpp @@ -41,10 +41,8 @@ * we do retain the vector types in that case. */ -extern "C" { #include "main/core.h" #include "brw_wm.h" -} #include "glsl/ir.h" #include "glsl/ir_expression_flattening.h" #include "glsl/glsl_types.h" diff --git a/src/mesa/drivers/dri/i965/brw_fs_generator.cpp b/src/mesa/drivers/dri/i965/brw_fs_generator.cpp index cbe6191..02ea3b6 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_generator.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_generator.cpp @@ -27,12 +27,9 @@ * native instructions. */ -extern "C" { #include "main/macros.h" #include "brw_context.h" #include "brw_eu.h" -} /* extern "C" */ - #include "brw_fs.h" #include "brw_cfg.h" diff --git a/src/mesa/drivers/dri/i965/brw_fs_vector_splitting.cpp b/src/mesa/drivers/dri/i965/brw_fs_vector_splitting.cpp index 03e5fdb..01d3a56 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_vector_splitting.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_vector_splitting.cpp @@ -37,10 +37,8 @@ * behavior we want for the results of texture lookups, but probably not for */ -extern "C" { #include "main/core.h" #include "brw_context.h" -} #include "glsl/ir.h" #include "glsl/ir_visitor.h" #include "glsl/ir_rvalue_visitor.h" diff --git a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp index 57c4d66..6b48f70 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp @@ -27,8 +27,6 @@ * makes it easier to do backend-specific optimizations than doing so * in the GLSL IR or in the native code. */ -extern "C" { - #include #include "main/macros.h" @@ -41,7 +39,6 @@ extern "C" { #include "brw_context.h" #include "brw_eu.h" #include "brw_wm.h" -} #include "brw_vec4.h" #include "brw_fs.h" #include "main/uniforms.h" diff --git a/src/mesa/drivers/dri/i965/brw_shader.cpp b/src/mesa/drivers/dri/i965/brw_shader.cpp index ec3cfcb..f2b4d82 100644 --- a/src/mesa/drivers/dri/i965/brw_shader.cpp +++ b/src/mesa/drivers/dri/i965/brw_shader.cpp @@ -21,10 +21,8 @@ * IN THE SOFTWARE. */ -extern "C" { #include "main/macros.h" #include "brw_context.h" -} #include "brw_vs.h" #include "brw_gs.h" #include "brw_fs.h" 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 a286f8a..3186824 100644 --- a/src/mesa/drivers/dri/i965/brw_vec4_reg_allocate.cpp +++ b/src/mesa/drivers/dri/i965/brw_vec4_reg_allocate.cpp @@ -21,11 +21,8 @@ * IN THE SOFTWARE. */ -extern "C" { #include "main/macros.h" #include "util/register_allocate.h" -} /* extern "C" */ - #include "brw_vec4.h" #include "brw_vs.h" #include "brw_cfg.h" diff --git a/src/mesa/drivers/dri/i965/brw_wm.h b/src/mesa/drivers/dri/i965/brw_wm.h index f54530f..32d1ce3 100644 --- a/src/mesa/drivers/dri/i965/brw_wm.h +++ b/src/mesa/drivers/dri/i965/brw_wm.h @@ -57,6 +57,10 @@ #define AA_SOMETIMES 1 #define AA_ALWAYS 2 +#ifdef __cplusplus +extern "C" { +#endif + /** * Compile a fragment shader. * @@ -86,4 +90,8 @@ bool brw_wm_prog_data_compare(const void *a, const void *b); void brw_upload_wm_prog(struct brw_context *brw); +#ifdef __cplusplus +} // extern "C" +#endif + #endif diff --git a/src/mesa/main/api_exec.h b/src/mesa/main/api_exec.h index ff35b78..1e4a9d6 100644 --- a/src/mesa/main/api_exec.h +++ b/src/mesa/main/api_exec.h @@ -26,6 +26,9 @@ #ifndef API_EXEC_H #define API_EXEC_H +#ifdef __cplusplus +extern "C" { +#endif struct _glapi_table; struct gl_context; @@ -39,4 +42,8 @@ _mesa_initialize_exec_table(struct gl_context *ctx); extern void _mesa_initialize_dispatch_tables(struct gl_context *ctx); +#ifdef __cplusplus +} // extern "C" +#endif + #endif diff --git a/src/mesa/main/tests/dispatch_sanity.cpp b/src/mesa/main/tests/dispatch_sanity.cpp index c14ad32..d25143f 100644 --- a/src/mesa/main/tests/dispatch_sanity.cpp +++ b/src/mesa/main/tests/dispatch_sanity.cpp @@ -41,7 +41,6 @@ #include -extern "C" { #include "GL/gl.h" #include "GL/glext.h" #include "main/compiler.h" @@ -62,7 +61,6 @@ extern "C" { #endif #include "main/dispatch.h" -} struct function { const char *name; diff --git a/src/mesa/main/tests/program_state_string.cpp b/src/mesa/main/tests/program_state_string.cpp index 418c39c..ddfdb49 100644 --- a/src/mesa/main/tests/program_state_string.cpp +++ b/src/mesa/main/tests/program_state_string.cpp @@ -23,11 +23,9 @@ #include -extern "C" { #include "GL/gl.h" #include "GL/glext.h" #include "main/compiler.h" -} #include "program/prog_statevars.h" diff --git a/src/mesa/main/vtxfmt.h b/src/mesa/main/vtxfmt.h index efccd90..4f8bc9c 100644 --- a/src/mesa/main/vtxfmt.h +++ b/src/mesa/main/vtxfmt.h @@ -35,8 +35,16 @@ #include "mtypes.h" +#ifdef __cplusplus +extern "C" { +#endif + extern void _mesa_install_exec_vtxfmt( struct gl_context *ctx, const GLvertexformat *vfmt ); extern void _mesa_install_save_vtxfmt( struct gl_context *ctx, const GLvertexformat *vfmt ); extern void _mesa_initialize_vbo_vtxfmt(struct gl_context *ctx); +#ifdef __cplusplus +} // extern "C" +#endif + #endif /* _VTXFMT_H_ */ diff --git a/src/mesa/vbo/vbo.h b/src/mesa/vbo/vbo.h index 6e1a4aa..54dee6c 100644 --- a/src/mesa/vbo/vbo.h +++ b/src/mesa/vbo/vbo.h @@ -35,6 +35,10 @@ #include #include "main/glheader.h" +#ifdef __cplusplus +extern "C" { +#endif + struct gl_client_array; struct gl_context; struct gl_transform_feedback_object; @@ -228,4 +232,8 @@ _es_VertexAttrib3fv(GLuint indx, const GLfloat* values); void GLAPIENTRY _es_VertexAttrib4fv(GLuint indx, const GLfloat* values); +#ifdef __cplusplus +} // extern "C" +#endif + #endif diff --git a/src/mesa/vbo/vbo_context.h b/src/mesa/vbo/vbo_context.h index 3b454be..6099b56 100644 --- a/src/mesa/vbo/vbo_context.h +++ b/src/mesa/vbo/vbo_context.h @@ -58,6 +58,10 @@ #include "main/macros.h" +#ifdef __cplusplus +extern "C" { +#endif + struct vbo_context { struct gl_client_array currval[VBO_ATTRIB_MAX]; @@ -175,4 +179,8 @@ vbo_get_default_vals_as_union(GLenum format) } } +#ifdef __cplusplus +} // extern "C" +#endif + #endif diff --git a/src/util/Makefile.am b/src/util/Makefile.am index 29b66e7..ec49dc6 100644 --- a/src/util/Makefile.am +++ b/src/util/Makefile.am @@ -25,6 +25,9 @@ include Makefile.sources noinst_LTLIBRARIES = libmesautil.la +AM_CPPFLAGS = \ + -I$(top_srcdir)/include + libmesautil_la_CPPFLAGS = \ $(DEFINES) \ -I$(top_srcdir)/include \ diff --git a/src/util/register_allocate.h b/src/util/register_allocate.h index dc68744..61f182e 100644 --- a/src/util/register_allocate.h +++ b/src/util/register_allocate.h @@ -27,6 +27,12 @@ #include + +#ifdef __cplusplus +extern "C" { +#endif + + struct ra_class; struct ra_regs; @@ -77,3 +83,7 @@ void ra_set_node_spill_cost(struct ra_graph *g, unsigned int n, float cost); int ra_get_best_spill_node(struct ra_graph *g); /** @} */ + +#ifdef __cplusplus +} // extern "C" +#endif From olv at kemper.freedesktop.org Thu Mar 5 18:25:49 2015 From: olv at kemper.freedesktop.org (Chia-I Wu) Date: Thu, 5 Mar 2015 10:25:49 -0800 (PST) Subject: Mesa (master): ilo: replace intel_tiling_mode by gen_surface_tiling Message-ID: <20150305182549.684627617A@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 0ac706535a07d003b9a40f8bad5445dd50f6c35b URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=0ac706535a07d003b9a40f8bad5445dd50f6c35b Author: Chia-I Wu Date: Thu Mar 5 23:53:16 2015 +0800 ilo: replace intel_tiling_mode by gen_surface_tiling The former is used by the kernel driver to set up fence registers and to pass tiling info across processes. It lacks INTEL_TILING_W, which made our code less expressive. --- src/gallium/drivers/ilo/ilo_blitter_blt.c | 32 +++++---- src/gallium/drivers/ilo/ilo_builder_blt.h | 17 +++-- src/gallium/drivers/ilo/ilo_layout.c | 86 ++++++++++++------------- src/gallium/drivers/ilo/ilo_layout.h | 26 ++++---- src/gallium/drivers/ilo/ilo_resource.c | 66 +++++++++++++++---- src/gallium/drivers/ilo/ilo_state.c | 2 +- src/gallium/drivers/ilo/ilo_state_3d.h | 19 ------ src/gallium/drivers/ilo/ilo_state_3d_bottom.c | 6 +- src/gallium/drivers/ilo/ilo_state_3d_top.c | 14 ++-- src/gallium/drivers/ilo/ilo_transfer.c | 35 +++++----- 10 files changed, 167 insertions(+), 136 deletions(-) diff --git a/src/gallium/drivers/ilo/ilo_blitter_blt.c b/src/gallium/drivers/ilo/ilo_blitter_blt.c index 86ca1e9..7667d4e 100644 --- a/src/gallium/drivers/ilo/ilo_blitter_blt.c +++ b/src/gallium/drivers/ilo/ilo_blitter_blt.c @@ -38,8 +38,10 @@ static uint32_t ilo_blitter_blt_begin(struct ilo_blitter *blitter, int max_cmd_size, - struct intel_bo *dst, enum intel_tiling_mode dst_tiling, - struct intel_bo *src, enum intel_tiling_mode src_tiling) + struct intel_bo *dst, + enum gen_surface_tiling dst_tiling, + struct intel_bo *src, + enum gen_surface_tiling src_tiling) { struct ilo_cp *cp = blitter->ilo->cp; struct intel_bo *aper_check[2]; @@ -64,12 +66,19 @@ ilo_blitter_blt_begin(struct ilo_blitter *blitter, int max_cmd_size, /* set BCS_SWCTRL */ swctrl = 0x0; - if (dst_tiling == INTEL_TILING_Y) { + assert(dst_tiling == GEN6_TILING_NONE || + dst_tiling == GEN6_TILING_X || + dst_tiling == GEN6_TILING_Y); + assert(src_tiling == GEN6_TILING_NONE || + src_tiling == GEN6_TILING_X || + src_tiling == GEN6_TILING_Y); + + if (dst_tiling == GEN6_TILING_Y) { swctrl |= GEN6_REG_BCS_SWCTRL_DST_TILING_Y << 16 | GEN6_REG_BCS_SWCTRL_DST_TILING_Y; } - if (src && src_tiling == INTEL_TILING_Y) { + if (src && src_tiling == GEN6_TILING_Y) { swctrl |= GEN6_REG_BCS_SWCTRL_SRC_TILING_Y << 16 | GEN6_REG_BCS_SWCTRL_SRC_TILING_Y; } @@ -136,7 +145,7 @@ buf_clear_region(struct ilo_blitter *blitter, ilo_blitter_blt_begin(blitter, GEN6_COLOR_BLT__SIZE * (1 + size / 32764 / gen6_blt_max_scanlines), - dst.bo, INTEL_TILING_NONE, NULL, INTEL_TILING_NONE); + dst.bo, GEN6_TILING_NONE, NULL, GEN6_TILING_NONE); while (size) { unsigned width, height; @@ -188,7 +197,7 @@ buf_copy_region(struct ilo_blitter *blitter, ilo_blitter_blt_begin(blitter, GEN6_SRC_COPY_BLT__SIZE * (1 + size / 32764 / gen6_blt_max_scanlines), - dst_buf->bo, INTEL_TILING_NONE, src_buf->bo, INTEL_TILING_NONE); + dst_buf->bo, GEN6_TILING_NONE, src_buf->bo, GEN6_TILING_NONE); while (size) { unsigned width, height; @@ -239,8 +248,8 @@ tex_clear_region(struct ilo_blitter *blitter, uint32_t swctrl; int slice; - /* no W-tiling support */ - if (dst_tex->separate_s8) + /* no W-tiling nor separate stencil support */ + if (dst_tex->layout.tiling == GEN8_TILING_W || dst_tex->separate_s8) return false; if (dst_tex->layout.bo_stride > max_extent) @@ -256,7 +265,7 @@ tex_clear_region(struct ilo_blitter *blitter, swctrl = ilo_blitter_blt_begin(blitter, GEN6_XY_COLOR_BLT__SIZE * dst_box->depth, - dst_tex->bo, dst_tex->layout.tiling, NULL, INTEL_TILING_NONE); + dst_tex->bo, dst_tex->layout.tiling, NULL, GEN6_TILING_NONE); for (slice = 0; slice < dst_box->depth; slice++) { unsigned x, y; @@ -299,8 +308,9 @@ tex_copy_region(struct ilo_blitter *blitter, uint32_t swctrl; int cpp, xscale, slice; - /* no W-tiling support */ - if (dst_tex->separate_s8 || src_tex->separate_s8) + /* no W-tiling nor separate stencil support */ + if (dst_tex->layout.tiling == GEN8_TILING_W || dst_tex->separate_s8 || + src_tex->layout.tiling == GEN8_TILING_W || src_tex->separate_s8) return false; if (dst_tex->layout.bo_stride > max_extent || diff --git a/src/gallium/drivers/ilo/ilo_builder_blt.h b/src/gallium/drivers/ilo/ilo_builder_blt.h index 1da3cd8..327f698 100644 --- a/src/gallium/drivers/ilo/ilo_builder_blt.h +++ b/src/gallium/drivers/ilo/ilo_builder_blt.h @@ -53,7 +53,7 @@ struct gen6_blt_xy_bo { uint32_t offset; int16_t pitch; - enum intel_tiling_mode tiling; + enum gen_surface_tiling tiling; int16_t x, y; }; @@ -170,10 +170,11 @@ gen6_XY_COLOR_BLT(struct ilo_builder *builder, gen6_blt_translate_write_mask(write_mask) | (cmd_len - 2); - if (dst->tiling != INTEL_TILING_NONE) { + if (dst->tiling != GEN6_TILING_NONE) { dw[0] |= GEN6_BLITTER_BR00_DST_TILED; - dst_align = (dst->tiling == INTEL_TILING_Y) ? 128 : 512; + assert(dst->tiling == GEN6_TILING_X || dst->tiling == GEN6_TILING_Y); + dst_align = (dst->tiling == GEN6_TILING_Y) ? 128 : 512; /* in dwords when tiled */ dst_pitch_shift = 2; } @@ -273,18 +274,20 @@ gen6_XY_SRC_COPY_BLT(struct ilo_builder *builder, gen6_blt_translate_write_mask(write_mask) | (cmd_len - 2); - if (dst->tiling != INTEL_TILING_NONE) { + if (dst->tiling != GEN6_TILING_NONE) { dw[0] |= GEN6_BLITTER_BR00_DST_TILED; - dst_align = (dst->tiling == INTEL_TILING_Y) ? 128 : 512; + assert(dst->tiling == GEN6_TILING_X || dst->tiling == GEN6_TILING_Y); + dst_align = (dst->tiling == GEN6_TILING_Y) ? 128 : 512; /* in dwords when tiled */ dst_pitch_shift = 2; } - if (src->tiling != INTEL_TILING_NONE) { + if (src->tiling != GEN6_TILING_NONE) { dw[0] |= GEN6_BLITTER_BR00_SRC_TILED; - src_align = (src->tiling == INTEL_TILING_Y) ? 128 : 512; + assert(src->tiling == GEN6_TILING_X || src->tiling == GEN6_TILING_Y); + src_align = (src->tiling == GEN6_TILING_Y) ? 128 : 512; /* in dwords when tiled */ src_pitch_shift = 2; } diff --git a/src/gallium/drivers/ilo/ilo_layout.c b/src/gallium/drivers/ilo/ilo_layout.c index 0b639b2..8f83ccb 100644 --- a/src/gallium/drivers/ilo/ilo_layout.c +++ b/src/gallium/drivers/ilo/ilo_layout.c @@ -28,10 +28,10 @@ #include "ilo_layout.h" enum { - LAYOUT_TILING_NONE = 1 << INTEL_TILING_NONE, - LAYOUT_TILING_X = 1 << INTEL_TILING_X, - LAYOUT_TILING_Y = 1 << INTEL_TILING_Y, - LAYOUT_TILING_W = 1 << (INTEL_TILING_Y + 1), + LAYOUT_TILING_NONE = 1 << GEN6_TILING_NONE, + LAYOUT_TILING_X = 1 << GEN6_TILING_X, + LAYOUT_TILING_Y = 1 << GEN6_TILING_Y, + LAYOUT_TILING_W = 1 << GEN8_TILING_W, LAYOUT_TILING_ALL = (LAYOUT_TILING_NONE | LAYOUT_TILING_X | @@ -427,7 +427,7 @@ layout_init_alignments(struct ilo_layout *layout, (templ->nr_samples > 1) || (ilo_dev_gen(params->dev) >= ILO_GEN(8)) || (ilo_dev_gen(params->dev) >= ILO_GEN(7) && - layout->tiling == INTEL_TILING_Y && + layout->tiling == GEN6_TILING_Y && (templ->bind & PIPE_BIND_RENDER_TARGET)); if (ilo_dev_gen(params->dev) >= ILO_GEN(7) && @@ -460,7 +460,8 @@ layout_get_valid_tilings(const struct ilo_layout *layout, { const struct pipe_resource *templ = params->templ; const enum pipe_format format = layout->format; - unsigned valid_tilings = LAYOUT_TILING_ALL; + /* W-tiling is too restrictive */ + unsigned valid_tilings = LAYOUT_TILING_ALL & ~LAYOUT_TILING_W; /* * From the Sandy Bridge PRM, volume 1 part 2, page 32: @@ -495,7 +496,8 @@ layout_get_valid_tilings(const struct ilo_layout *layout, if (templ->bind & PIPE_BIND_DEPTH_STENCIL) { switch (format) { case PIPE_FORMAT_S8_UINT: - valid_tilings &= LAYOUT_TILING_W; + /* this is the only case LAYOUT_TILING_W is valid */ + valid_tilings = LAYOUT_TILING_W; break; default: valid_tilings &= LAYOUT_TILING_Y; @@ -545,10 +547,6 @@ layout_init_tiling(struct ilo_layout *layout, const struct pipe_resource *templ = params->templ; unsigned valid_tilings = layout_get_valid_tilings(layout, params); - /* no hardware support for W-tile */ - if (valid_tilings & LAYOUT_TILING_W) - valid_tilings = (valid_tilings & ~LAYOUT_TILING_W) | LAYOUT_TILING_NONE; - layout->valid_tilings = valid_tilings; if (templ->bind & (PIPE_BIND_RENDER_TARGET | PIPE_BIND_SAMPLER_VIEW)) { @@ -570,11 +568,13 @@ layout_init_tiling(struct ilo_layout *layout, /* prefer tiled over linear */ if (valid_tilings & LAYOUT_TILING_Y) - layout->tiling = INTEL_TILING_Y; + layout->tiling = GEN6_TILING_Y; else if (valid_tilings & LAYOUT_TILING_X) - layout->tiling = INTEL_TILING_X; + layout->tiling = GEN6_TILING_X; + else if (valid_tilings & LAYOUT_TILING_W) + layout->tiling = GEN8_TILING_W; else - layout->tiling = INTEL_TILING_NONE; + layout->tiling = GEN6_TILING_NONE; } static void @@ -755,7 +755,7 @@ layout_want_mcs(struct ilo_layout *layout, * 32bpp, 64bpp and 128bpp. * ..." */ - if (layout->tiling != INTEL_TILING_NONE && + if (layout->tiling != GEN6_TILING_NONE && templ->last_level == 0 && templ->array_size == 1) { switch (layout->block_size) { case 4: @@ -909,7 +909,7 @@ layout_calculate_bo_size(struct ilo_layout *layout, */ if (ilo_dev_gen(params->dev) >= ILO_GEN(7.5) && (params->templ->bind & PIPE_BIND_SAMPLER_VIEW) && - layout->tiling == INTEL_TILING_NONE) { + layout->tiling == GEN6_TILING_NONE) { layout->bo_height += (64 + layout->bo_stride - 1) / layout->bo_stride; } @@ -931,33 +931,30 @@ layout_calculate_bo_size(struct ilo_layout *layout, * need to check layout->templ->bind. */ switch (layout->tiling) { - case INTEL_TILING_X: + case GEN6_TILING_X: align_w = 512; align_h = 8; break; - case INTEL_TILING_Y: + case GEN6_TILING_Y: align_w = 128; align_h = 32; break; + case GEN8_TILING_W: + /* + * From the Sandy Bridge PRM, volume 1 part 2, page 22: + * + * "A 4KB tile is subdivided into 8-high by 8-wide array of + * Blocks for W-Major Tiles (W Tiles). Each Block is 8 rows by 8 + * bytes." + */ + align_w = 64; + align_h = 64; + break; default: - if (layout->format == PIPE_FORMAT_S8_UINT) { - /* - * From the Sandy Bridge PRM, volume 1 part 2, page 22: - * - * "A 4KB tile is subdivided into 8-high by 8-wide array of - * Blocks for W-Major Tiles (W Tiles). Each Block is 8 rows by 8 - * bytes." - * - * Since we asked for INTEL_TILING_NONE instead of the non-existent - * INTEL_TILING_W, we want to align to W tiles here. - */ - align_w = 64; - align_h = 64; - } else { - /* some good enough values */ - align_w = 64; - align_h = 2; - } + assert(layout->tiling == GEN6_TILING_NONE); + /* some good enough values */ + align_w = 64; + align_h = 2; break; } @@ -965,7 +962,7 @@ layout_calculate_bo_size(struct ilo_layout *layout, h = align(h, align_h); /* make sure the bo is mappable */ - if (layout->tiling != INTEL_TILING_NONE) { + if (layout->tiling != GEN6_TILING_NONE) { /* * Usually only the first 256MB of the GTT is mappable. * @@ -979,7 +976,7 @@ layout_calculate_bo_size(struct ilo_layout *layout, */ if (mappable_gtt_size / w / 4 < h) { if (layout->valid_tilings & LAYOUT_TILING_NONE) { - layout->tiling = INTEL_TILING_NONE; + layout->tiling = GEN6_TILING_NONE; /* MCS support for non-MSRTs is limited to tiled RTs */ if (layout->aux == ILO_LAYOUT_AUX_MCS && params->templ->nr_samples <= 1) @@ -1251,11 +1248,11 @@ layout_calculate_mcs_size(struct ilo_layout *layout, * hit out-of-bound access. */ switch (layout->tiling) { - case INTEL_TILING_X: + case GEN6_TILING_X: downscale_x = 64 / layout->block_size; downscale_y = 2; break; - case INTEL_TILING_Y: + case GEN6_TILING_Y: downscale_x = 32 / layout->block_size; downscale_y = 4; break; @@ -1315,7 +1312,7 @@ layout_init_for_transfer(struct ilo_layout *layout, layout->walk = ILO_LAYOUT_WALK_LOD; layout->valid_tilings = LAYOUT_TILING_NONE; - layout->tiling = INTEL_TILING_NONE; + layout->tiling = GEN6_TILING_NONE; layout->align_i = layout->block_width; layout->align_j = layout->block_height; @@ -1387,14 +1384,15 @@ void ilo_layout_init(struct ilo_layout *layout, */ bool ilo_layout_update_for_imported_bo(struct ilo_layout *layout, - enum intel_tiling_mode tiling, + enum gen_surface_tiling tiling, unsigned bo_stride) { if (!(layout->valid_tilings & (1 << tiling))) return false; - if ((tiling == INTEL_TILING_X && bo_stride % 512) || - (tiling == INTEL_TILING_Y && bo_stride % 128)) + if ((tiling == GEN6_TILING_X && bo_stride % 512) || + (tiling == GEN6_TILING_Y && bo_stride % 128) || + (tiling == GEN8_TILING_W && bo_stride % 64)) return false; layout->tiling = tiling; diff --git a/src/gallium/drivers/ilo/ilo_layout.h b/src/gallium/drivers/ilo/ilo_layout.h index 54ba2d8..1ecf87d 100644 --- a/src/gallium/drivers/ilo/ilo_layout.h +++ b/src/gallium/drivers/ilo/ilo_layout.h @@ -28,7 +28,7 @@ #ifndef ILO_LAYOUT_H #define ILO_LAYOUT_H -#include "intel_winsys.h" +#include "genhw/genhw.h" #include "ilo_common.h" @@ -99,7 +99,7 @@ struct ilo_layout { /* bitmask of valid tiling modes */ unsigned valid_tilings; - enum intel_tiling_mode tiling; + enum gen_surface_tiling tiling; /* mipmap alignments */ unsigned align_i; @@ -129,7 +129,7 @@ void ilo_layout_init(struct ilo_layout *layout, bool ilo_layout_update_for_imported_bo(struct ilo_layout *layout, - enum intel_tiling_mode tiling, + enum gen_surface_tiling tiling, unsigned bo_stride); /** @@ -167,24 +167,22 @@ ilo_layout_mem_to_raw(const struct ilo_layout *layout, unsigned tile_w, tile_h; switch (layout->tiling) { - case INTEL_TILING_NONE: - if (layout->format == PIPE_FORMAT_S8_UINT) { - /* W-tile */ - tile_w = 64; - tile_h = 64; - } else { - tile_w = 1; - tile_h = 1; - } + case GEN6_TILING_NONE: + tile_w = 1; + tile_h = 1; break; - case INTEL_TILING_X: + case GEN6_TILING_X: tile_w = 512; tile_h = 8; break; - case INTEL_TILING_Y: + case GEN6_TILING_Y: tile_w = 128; tile_h = 32; break; + case GEN8_TILING_W: + tile_w = 64; + tile_h = 64; + break; default: assert(!"unknown tiling"); tile_w = 1; diff --git a/src/gallium/drivers/ilo/ilo_resource.c b/src/gallium/drivers/ilo/ilo_resource.c index c6eadc3..6dfc580 100644 --- a/src/gallium/drivers/ilo/ilo_resource.c +++ b/src/gallium/drivers/ilo/ilo_resource.c @@ -84,6 +84,38 @@ resource_get_cpu_init(const struct pipe_resource *templ) PIPE_BIND_STREAM_OUTPUT)) ? false : true; } +static enum gen_surface_tiling +winsys_to_surface_tiling(enum intel_tiling_mode tiling) +{ + switch (tiling) { + case INTEL_TILING_NONE: + return GEN6_TILING_NONE; + case INTEL_TILING_X: + return GEN6_TILING_X; + case INTEL_TILING_Y: + return GEN6_TILING_Y; + default: + assert(!"unknown tiling"); + return GEN6_TILING_NONE; + } +} + +static inline enum intel_tiling_mode +surface_to_winsys_tiling(enum gen_surface_tiling tiling) +{ + switch (tiling) { + case GEN6_TILING_NONE: + return INTEL_TILING_NONE; + case GEN6_TILING_X: + return INTEL_TILING_X; + case GEN6_TILING_Y: + return INTEL_TILING_Y; + default: + assert(!"unknown tiling"); + return GEN6_TILING_NONE; + } +} + static void tex_free_slices(struct ilo_texture *tex) { @@ -136,7 +168,8 @@ tex_import_handle(struct ilo_texture *tex, if (!tex->bo) return false; - if (!ilo_layout_update_for_imported_bo(&tex->layout, tiling, pitch)) { + if (!ilo_layout_update_for_imported_bo(&tex->layout, + winsys_to_surface_tiling(tiling), pitch)) { ilo_err("imported handle has incompatible tiling/pitch\n"); intel_bo_unreference(tex->bo); tex->bo = NULL; @@ -152,8 +185,15 @@ tex_create_bo(struct ilo_texture *tex) struct ilo_screen *is = ilo_screen(tex->base.screen); const char *name = resource_get_bo_name(&tex->base); const bool cpu_init = resource_get_cpu_init(&tex->base); + enum intel_tiling_mode tiling; + + /* no native support */ + if (tex->layout.tiling == GEN8_TILING_W) + tiling = INTEL_TILING_NONE; + else + tiling = surface_to_winsys_tiling(tex->layout.tiling); - tex->bo = intel_winsys_alloc_bo(is->winsys, name, tex->layout.tiling, + tex->bo = intel_winsys_alloc_bo(is->winsys, name, tiling, tex->layout.bo_stride, tex->layout.bo_height, cpu_init); return (tex->bo != NULL); @@ -190,9 +230,8 @@ tex_create_hiz(struct ilo_texture *tex) struct ilo_screen *is = ilo_screen(tex->base.screen); unsigned lv; - tex->aux_bo = intel_winsys_alloc_bo(is->winsys, "hiz texture", - INTEL_TILING_Y, tex->layout.aux_stride, tex->layout.aux_height, - false); + tex->aux_bo = intel_winsys_alloc_buffer(is->winsys, "hiz texture", + tex->layout.aux_stride * tex->layout.aux_height, false); if (!tex->aux_bo) return false; @@ -220,9 +259,8 @@ tex_create_mcs(struct ilo_texture *tex) assert(tex->layout.aux_enables == (1 << (tex->base.last_level + 1)) - 1); - tex->aux_bo = intel_winsys_alloc_bo(is->winsys, "mcs texture", - INTEL_TILING_Y, tex->layout.aux_stride, tex->layout.aux_height, - false); + tex->aux_bo = intel_winsys_alloc_buffer(is->winsys, "mcs texture", + tex->layout.aux_stride * tex->layout.aux_height, false); if (!tex->aux_bo) return false; @@ -297,8 +335,7 @@ tex_init_layout(struct ilo_texture *tex) if (templ->flags & PIPE_RESOURCE_FLAG_MAP_PERSISTENT) { /* require on-the-fly tiling/untiling or format conversion */ - if (layout->separate_stencil || - layout->format == PIPE_FORMAT_S8_UINT || + if (layout->tiling == GEN8_TILING_W || layout->separate_stencil || layout->format != templ->format) return false; } @@ -343,9 +380,16 @@ static bool tex_get_handle(struct ilo_texture *tex, struct winsys_handle *handle) { struct ilo_screen *is = ilo_screen(tex->base.screen); + enum intel_tiling_mode tiling; int err; - err = intel_winsys_export_handle(is->winsys, tex->bo, tex->layout.tiling, + /* no native support */ + if (tex->layout.tiling == GEN8_TILING_W) + tiling = INTEL_TILING_NONE; + else + tiling = surface_to_winsys_tiling(tex->layout.tiling); + + err = intel_winsys_export_handle(is->winsys, tex->bo, tiling, tex->layout.bo_stride, tex->layout.bo_height, handle); return !err; diff --git a/src/gallium/drivers/ilo/ilo_state.c b/src/gallium/drivers/ilo/ilo_state.c index b852f9f..197a49e 100644 --- a/src/gallium/drivers/ilo/ilo_state.c +++ b/src/gallium/drivers/ilo/ilo_state.c @@ -1013,7 +1013,7 @@ ilo_create_sampler_view(struct pipe_context *pipe, struct ilo_texture *tex = ilo_texture(res); /* warn about degraded performance because of a missing binding flag */ - if (tex->layout.tiling == INTEL_TILING_NONE && + if (tex->layout.tiling == GEN6_TILING_NONE && !(tex->base.bind & PIPE_BIND_SAMPLER_VIEW)) { ilo_warn("creating sampler view for a resource " "not created for sampling\n"); diff --git a/src/gallium/drivers/ilo/ilo_state_3d.h b/src/gallium/drivers/ilo/ilo_state_3d.h index b83322b..cb4b89a 100644 --- a/src/gallium/drivers/ilo/ilo_state_3d.h +++ b/src/gallium/drivers/ilo/ilo_state_3d.h @@ -35,25 +35,6 @@ #include "ilo_state.h" /** - * Translate winsys tiling to hardware tiling. - */ -static inline int -ilo_gpe_gen6_translate_winsys_tiling(enum intel_tiling_mode tiling) -{ - switch (tiling) { - case INTEL_TILING_NONE: - return GEN6_TILING_NONE; - case INTEL_TILING_X: - return GEN6_TILING_X; - case INTEL_TILING_Y: - return GEN6_TILING_Y; - default: - assert(!"unknown tiling"); - return GEN6_TILING_NONE; - } -} - -/** * Translate a pipe texture target to the matching hardware surface type. */ static inline int diff --git a/src/gallium/drivers/ilo/ilo_state_3d_bottom.c b/src/gallium/drivers/ilo/ilo_state_3d_bottom.c index 96b1b22..4c74ef4 100644 --- a/src/gallium/drivers/ilo/ilo_state_3d_bottom.c +++ b/src/gallium/drivers/ilo/ilo_state_3d_bottom.c @@ -910,7 +910,7 @@ struct ilo_zs_surface_info { struct intel_bo *bo; unsigned stride; unsigned qpitch; - enum intel_tiling_mode tiling; + enum gen_surface_tiling tiling; uint32_t offset; } zs, stencil, hiz; @@ -1082,7 +1082,7 @@ zs_init_info(const struct ilo_dev_info *dev, assert(tex->layout.aux_layer_height % 4 == 0); info->hiz.qpitch = tex->layout.aux_layer_height / 4; - info->hiz.tiling = INTEL_TILING_Y; + info->hiz.tiling = GEN6_TILING_Y; /* offset to the level */ if (ilo_dev_gen(dev) == ILO_GEN(6)) @@ -1175,7 +1175,7 @@ ilo_gpe_init_zs_surface(const struct ilo_dev_info *dev, if (info.zs.bo) { /* required for GEN6+ */ - assert(info.zs.tiling == INTEL_TILING_Y); + assert(info.zs.tiling == GEN6_TILING_Y); assert(info.zs.stride > 0 && info.zs.stride < 128 * 1024 && info.zs.stride % 128 == 0); assert(info.width <= info.zs.stride); diff --git a/src/gallium/drivers/ilo/ilo_state_3d_top.c b/src/gallium/drivers/ilo/ilo_state_3d_top.c index 40e5e9d..ffa9ed8 100644 --- a/src/gallium/drivers/ilo/ilo_state_3d_top.c +++ b/src/gallium/drivers/ilo/ilo_state_3d_top.c @@ -678,7 +678,7 @@ view_init_for_texture_gen6(const struct ilo_dev_info *dev, * * "For linear surfaces, this field (X Offset) must be zero" */ - if (tex->layout.tiling == INTEL_TILING_NONE) { + if (tex->layout.tiling == GEN6_TILING_NONE) { if (is_rt) { const int elem_size = util_format_get_blocksize(format); assert(pitch % elem_size == 0); @@ -706,9 +706,10 @@ view_init_for_texture_gen6(const struct ilo_dev_info *dev, (width - 1) << GEN6_SURFACE_DW2_WIDTH__SHIFT | lod << GEN6_SURFACE_DW2_MIP_COUNT_LOD__SHIFT; + assert(tex->layout.tiling != GEN8_TILING_W); dw[3] = (depth - 1) << GEN6_SURFACE_DW3_DEPTH__SHIFT | (pitch - 1) << GEN6_SURFACE_DW3_PITCH__SHIFT | - ilo_gpe_gen6_translate_winsys_tiling(tex->layout.tiling); + tex->layout.tiling; dw[4] = first_level << GEN6_SURFACE_DW4_MIN_LOD__SHIFT | first_layer << 17 | @@ -1042,7 +1043,7 @@ view_init_for_texture_gen7(const struct ilo_dev_info *dev, * * "For linear surfaces, this field (X Offset) must be zero." */ - if (tex->layout.tiling == INTEL_TILING_NONE) { + if (tex->layout.tiling == GEN6_TILING_NONE) { if (is_rt) { const int elem_size = util_format_get_blocksize(format); assert(pitch % elem_size == 0); @@ -1104,8 +1105,7 @@ view_init_for_texture_gen7(const struct ilo_dev_info *dev, break; } - dw[0] |= ilo_gpe_gen6_translate_winsys_tiling(tex->layout.tiling) << - GEN8_SURFACE_DW0_TILING__SHIFT; + dw[0] |= tex->layout.tiling << GEN8_SURFACE_DW0_TILING__SHIFT; } else { assert(tex->layout.align_i == 4 || tex->layout.align_i == 8); assert(tex->layout.align_j == 2 || tex->layout.align_j == 4); @@ -1116,8 +1116,8 @@ view_init_for_texture_gen7(const struct ilo_dev_info *dev, if (tex->layout.align_i == 8) dw[0] |= GEN7_SURFACE_DW0_HALIGN_8; - dw[0] |= ilo_gpe_gen6_translate_winsys_tiling(tex->layout.tiling) << - GEN7_SURFACE_DW0_TILING__SHIFT; + assert(tex->layout.tiling != GEN8_TILING_W); + dw[0] |= tex->layout.tiling << GEN7_SURFACE_DW0_TILING__SHIFT; if (tex->layout.walk == ILO_LAYOUT_WALK_LOD) dw[0] |= GEN7_SURFACE_DW0_ARYSPC_LOD0; diff --git a/src/gallium/drivers/ilo/ilo_transfer.c b/src/gallium/drivers/ilo/ilo_transfer.c index 34a94f2..f0d47de 100644 --- a/src/gallium/drivers/ilo/ilo_transfer.c +++ b/src/gallium/drivers/ilo/ilo_transfer.c @@ -88,13 +88,12 @@ resource_get_transfer_method(struct pipe_resource *res, if (res->target == PIPE_BUFFER) { tiled = false; - } - else { + } else { struct ilo_texture *tex = ilo_texture(res); bool need_convert = false; /* we may need to convert on the fly */ - if (tex->separate_s8 || tex->layout.format == PIPE_FORMAT_S8_UINT) { + if (tex->layout.tiling == GEN8_TILING_W || tex->separate_s8) { /* on GEN6, separate stencil is enabled only when HiZ is */ if (ilo_dev_gen(&is->dev) >= ILO_GEN(7) || ilo_texture_can_enable_hiz(tex, transfer->level, @@ -115,7 +114,7 @@ resource_get_transfer_method(struct pipe_resource *res, return true; } - tiled = (tex->layout.tiling != INTEL_TILING_NONE); + tiled = (tex->layout.tiling != GEN6_TILING_NONE); } if (tiled) @@ -204,7 +203,7 @@ xfer_alloc_staging_res(struct ilo_transfer *xfer) if (xfer->staging.res && xfer->staging.res->target != PIPE_BUFFER) { assert(ilo_texture(xfer->staging.res)->layout.tiling == - INTEL_TILING_NONE); + GEN6_TILING_NONE); } return (xfer->staging.res != NULL); @@ -525,23 +524,21 @@ tex_tile_choose_offset_func(const struct ilo_texture *tex, unsigned *tiles_per_row) { switch (tex->layout.tiling) { - case INTEL_TILING_X: + default: + assert(!"unknown tiling"); + /* fall through */ + case GEN6_TILING_NONE: + *tiles_per_row = tex->layout.bo_stride; + return tex_tile_none_offset; + case GEN6_TILING_X: *tiles_per_row = tex->layout.bo_stride / 512; return tex_tile_x_offset; - case INTEL_TILING_Y: + case GEN6_TILING_Y: *tiles_per_row = tex->layout.bo_stride / 128; return tex_tile_y_offset; - case INTEL_TILING_NONE: - default: - /* W-tiling */ - if (tex->layout.format == PIPE_FORMAT_S8_UINT) { - *tiles_per_row = tex->layout.bo_stride / 64; - return tex_tile_w_offset; - } - else { - *tiles_per_row = tex->layout.bo_stride; - return tex_tile_none_offset; - } + case GEN8_TILING_W: + *tiles_per_row = tex->layout.bo_stride / 64; + return tex_tile_w_offset; } } @@ -554,7 +551,7 @@ tex_staging_sys_map_bo(struct ilo_texture *tex, const bool prefer_cpu = (is->dev.has_llc || for_read_back); void *ptr; - if (prefer_cpu && (tex->layout.tiling == INTEL_TILING_NONE || + if (prefer_cpu && (tex->layout.tiling == GEN6_TILING_NONE || !linear_view)) ptr = intel_bo_map(tex->bo, !for_read_back); else From olv at kemper.freedesktop.org Thu Mar 5 18:25:49 2015 From: olv at kemper.freedesktop.org (Chia-I Wu) Date: Thu, 5 Mar 2015 10:25:49 -0800 (PST) Subject: Mesa (master): ilo: update genhw headers Message-ID: <20150305182549.586C17617A@kemper.freedesktop.org> Module: Mesa Branch: master Commit: eb32ac19569b5f05fc3fa2621b52f2c9fa85556a URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=eb32ac19569b5f05fc3fa2621b52f2c9fa85556a Author: Chia-I Wu Date: Thu Mar 5 15:25:43 2015 +0800 ilo: update genhw headers The main change is non-inline s are now generated as C enums. --- src/gallium/drivers/ilo/genhw/gen_eu_isa.xml.h | 457 ++++++++++-------- src/gallium/drivers/ilo/genhw/gen_eu_message.xml.h | 283 +++++------ src/gallium/drivers/ilo/genhw/gen_mi.xml.h | 72 +-- src/gallium/drivers/ilo/genhw/gen_render.xml.h | 36 +- src/gallium/drivers/ilo/genhw/gen_render_3d.xml.h | 176 +++---- .../drivers/ilo/genhw/gen_render_dynamic.xml.h | 249 ++++++---- .../drivers/ilo/genhw/gen_render_surface.xml.h | 495 ++++++++++---------- 7 files changed, 986 insertions(+), 782 deletions(-) Diff: http://cgit.freedesktop.org/mesa/mesa/diff/?id=eb32ac19569b5f05fc3fa2621b52f2c9fa85556a From olv at kemper.freedesktop.org Thu Mar 5 18:25:49 2015 From: olv at kemper.freedesktop.org (Chia-I Wu) Date: Thu, 5 Mar 2015 10:25:49 -0800 (PST) Subject: Mesa (master): ilo: add intel_bo_set_tiling() Message-ID: <20150305182549.75D9D7617A@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 70ef171e91582f60a010a4f0ea9f7ff5ba971ab4 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=70ef171e91582f60a010a4f0ea9f7ff5ba971ab4 Author: Chia-I Wu Date: Fri Mar 6 01:36:01 2015 +0800 ilo: add intel_bo_set_tiling() Make intel_winsys_alloc_bo() always allocate a linear bo, and add intel_bo_set_tiling() to set the tiling. Document the purpose of tiling. --- src/gallium/drivers/ilo/ilo_builder.c | 2 +- src/gallium/drivers/ilo/ilo_draw.c | 2 +- src/gallium/drivers/ilo/ilo_render.c | 2 +- src/gallium/drivers/ilo/ilo_resource.c | 33 +++++++---- src/gallium/drivers/ilo/intel_winsys.h | 40 +++++-------- src/gallium/winsys/intel/drm/intel_drm_winsys.c | 72 +++++++++++------------ 6 files changed, 71 insertions(+), 80 deletions(-) diff --git a/src/gallium/drivers/ilo/ilo_builder.c b/src/gallium/drivers/ilo/ilo_builder.c index 92a1290..52c4b21 100644 --- a/src/gallium/drivers/ilo/ilo_builder.c +++ b/src/gallium/drivers/ilo/ilo_builder.c @@ -139,7 +139,7 @@ alloc_writer_bo(struct intel_winsys *winsys, [ILO_BUILDER_WRITER_INSTRUCTION] = "instruction", }; - return intel_winsys_alloc_buffer(winsys, writer_names[which], size, true); + return intel_winsys_alloc_bo(winsys, writer_names[which], size, true); } static void * diff --git a/src/gallium/drivers/ilo/ilo_draw.c b/src/gallium/drivers/ilo/ilo_draw.c index 9d1c419..02e5225 100644 --- a/src/gallium/drivers/ilo/ilo_draw.c +++ b/src/gallium/drivers/ilo/ilo_draw.c @@ -183,7 +183,7 @@ ilo_init_draw_query(struct ilo_context *ilo, struct ilo_query *q) q->stride <<= q->in_pairs; bo_size = (q->stride > 4096) ? q->stride : 4096; - q->bo = intel_winsys_alloc_buffer(ilo->winsys, "query", bo_size, false); + q->bo = intel_winsys_alloc_bo(ilo->winsys, "query", bo_size, false); if (!q->bo) return false; diff --git a/src/gallium/drivers/ilo/ilo_render.c b/src/gallium/drivers/ilo/ilo_render.c index c1ed2c3..c549256 100644 --- a/src/gallium/drivers/ilo/ilo_render.c +++ b/src/gallium/drivers/ilo/ilo_render.c @@ -113,7 +113,7 @@ ilo_render_create(struct ilo_builder *builder) render->dev = builder->dev; render->builder = builder; - render->workaround_bo = intel_winsys_alloc_buffer(builder->winsys, + render->workaround_bo = intel_winsys_alloc_bo(builder->winsys, "PIPE_CONTROL workaround", 4096, false); if (!render->workaround_bo) { ilo_warn("failed to allocate PIPE_CONTROL workaround bo\n"); diff --git a/src/gallium/drivers/ilo/ilo_resource.c b/src/gallium/drivers/ilo/ilo_resource.c index 6dfc580..9f4ee40 100644 --- a/src/gallium/drivers/ilo/ilo_resource.c +++ b/src/gallium/drivers/ilo/ilo_resource.c @@ -185,16 +185,24 @@ tex_create_bo(struct ilo_texture *tex) struct ilo_screen *is = ilo_screen(tex->base.screen); const char *name = resource_get_bo_name(&tex->base); const bool cpu_init = resource_get_cpu_init(&tex->base); - enum intel_tiling_mode tiling; + struct intel_bo *bo; - /* no native support */ - if (tex->layout.tiling == GEN8_TILING_W) - tiling = INTEL_TILING_NONE; - else - tiling = surface_to_winsys_tiling(tex->layout.tiling); + bo = intel_winsys_alloc_bo(is->winsys, name, + tex->layout.bo_stride * tex->layout.bo_height, cpu_init); + + /* set the tiling for transfer and export */ + if (bo && (tex->layout.tiling == GEN6_TILING_X || + tex->layout.tiling == GEN6_TILING_Y)) { + const enum intel_tiling_mode tiling = + surface_to_winsys_tiling(tex->layout.tiling); + + if (intel_bo_set_tiling(bo, tiling, tex->layout.bo_stride)) { + intel_bo_unreference(bo); + bo = NULL; + } + } - tex->bo = intel_winsys_alloc_bo(is->winsys, name, tiling, - tex->layout.bo_stride, tex->layout.bo_height, cpu_init); + tex->bo = bo; return (tex->bo != NULL); } @@ -230,7 +238,7 @@ tex_create_hiz(struct ilo_texture *tex) struct ilo_screen *is = ilo_screen(tex->base.screen); unsigned lv; - tex->aux_bo = intel_winsys_alloc_buffer(is->winsys, "hiz texture", + tex->aux_bo = intel_winsys_alloc_bo(is->winsys, "hiz texture", tex->layout.aux_stride * tex->layout.aux_height, false); if (!tex->aux_bo) return false; @@ -259,7 +267,7 @@ tex_create_mcs(struct ilo_texture *tex) assert(tex->layout.aux_enables == (1 << (tex->base.last_level + 1)) - 1); - tex->aux_bo = intel_winsys_alloc_buffer(is->winsys, "mcs texture", + tex->aux_bo = intel_winsys_alloc_bo(is->winsys, "mcs texture", tex->layout.aux_stride * tex->layout.aux_height, false); if (!tex->aux_bo) return false; @@ -383,7 +391,7 @@ tex_get_handle(struct ilo_texture *tex, struct winsys_handle *handle) enum intel_tiling_mode tiling; int err; - /* no native support */ + /* must match what tex_create_bo() sets */ if (tex->layout.tiling == GEN8_TILING_W) tiling = INTEL_TILING_NONE; else @@ -402,8 +410,7 @@ buf_create_bo(struct ilo_buffer *buf) const char *name = resource_get_bo_name(&buf->base); const bool cpu_init = resource_get_cpu_init(&buf->base); - buf->bo = intel_winsys_alloc_buffer(is->winsys, name, - buf->bo_size, cpu_init); + buf->bo = intel_winsys_alloc_bo(is->winsys, name, buf->bo_size, cpu_init); return (buf->bo != NULL); } diff --git a/src/gallium/drivers/ilo/intel_winsys.h b/src/gallium/drivers/ilo/intel_winsys.h index 5a199e2..77eb030 100644 --- a/src/gallium/drivers/ilo/intel_winsys.h +++ b/src/gallium/drivers/ilo/intel_winsys.h @@ -126,43 +126,24 @@ intel_winsys_get_reset_stats(struct intel_winsys *winsys, * Allocate a buffer object. * * \param name Informative description of the bo. - * \param tiling Tiling mode. - * \param pitch Pitch of the bo. - * \param height Height of the bo. + * \param size Size of the bo. * \param cpu_init Will be initialized by CPU. */ struct intel_bo * intel_winsys_alloc_bo(struct intel_winsys *winsys, const char *name, - enum intel_tiling_mode tiling, - unsigned long pitch, - unsigned long height, + unsigned long size, bool cpu_init); /** - * Allocate a linear buffer object. - */ -static inline struct intel_bo * -intel_winsys_alloc_buffer(struct intel_winsys *winsys, - const char *name, - unsigned long size, - bool cpu_init) -{ - return intel_winsys_alloc_bo(winsys, name, - INTEL_TILING_NONE, size, 1, cpu_init); -} - -/** - * Create a bo from a user memory pointer. Both \p userptr and (\p pitch * \p - * height) must be page aligned. + * Create a bo from a user memory pointer. Both \p userptr and \p size must + * be page aligned. */ struct intel_bo * intel_winsys_import_userptr(struct intel_winsys *winsys, const char *name, void *userptr, - enum intel_tiling_mode tiling, - unsigned long pitch, - unsigned long height, + unsigned long size, unsigned long flags); /** @@ -177,7 +158,8 @@ intel_winsys_import_handle(struct intel_winsys *winsys, unsigned long *pitch); /** - * Export \p bo as a winsys handle for inter-process sharing. + * Export \p bo as a winsys handle for inter-process sharing. \p tiling and + * \p pitch must match those set by \p intel_bo_set_tiling(). */ int intel_winsys_export_handle(struct intel_winsys *winsys, @@ -234,6 +216,14 @@ void intel_bo_unreference(struct intel_bo *bo); /** + * Set the tiling of \p bo. The info is used by GTT mapping and bo export. + */ +int +intel_bo_set_tiling(struct intel_bo *bo, + enum intel_tiling_mode tiling, + unsigned long pitch); + +/** * Map \p bo for CPU access. Recursive mapping is allowed. * * map() maps the backing store into CPU address space, cached. It will block diff --git a/src/gallium/winsys/intel/drm/intel_drm_winsys.c b/src/gallium/winsys/intel/drm/intel_drm_winsys.c index a41cbb0..d05e036 100644 --- a/src/gallium/winsys/intel/drm/intel_drm_winsys.c +++ b/src/gallium/winsys/intel/drm/intel_drm_winsys.c @@ -275,53 +275,19 @@ intel_winsys_get_reset_stats(struct intel_winsys *winsys, struct intel_bo * intel_winsys_alloc_bo(struct intel_winsys *winsys, const char *name, - enum intel_tiling_mode tiling, - unsigned long pitch, - unsigned long height, + unsigned long size, bool cpu_init) { const unsigned int alignment = 4096; /* always page-aligned */ - unsigned long size; drm_intel_bo *bo; - switch (tiling) { - case INTEL_TILING_X: - if (pitch % 512) - return NULL; - break; - case INTEL_TILING_Y: - if (pitch % 128) - return NULL; - break; - default: - break; - } - - if (pitch > ULONG_MAX / height) - return NULL; - - size = pitch * height; - if (cpu_init) { bo = drm_intel_bo_alloc(winsys->bufmgr, name, size, alignment); - } - else { + } else { bo = drm_intel_bo_alloc_for_render(winsys->bufmgr, name, size, alignment); } - if (bo && tiling != INTEL_TILING_NONE) { - uint32_t real_tiling = tiling; - int err; - - err = drm_intel_bo_set_tiling(bo, &real_tiling, pitch); - if (err || real_tiling != tiling) { - assert(!"tiling mismatch"); - drm_intel_bo_unreference(bo); - return NULL; - } - } - return (struct intel_bo *) bo; } @@ -329,9 +295,7 @@ struct intel_bo * intel_winsys_import_userptr(struct intel_winsys *winsys, const char *name, void *userptr, - enum intel_tiling_mode tiling, - unsigned long pitch, - unsigned long height, + unsigned long size, unsigned long flags) { return NULL; @@ -512,6 +476,36 @@ intel_bo_unreference(struct intel_bo *bo) drm_intel_bo_unreference(gem_bo(bo)); } +int +intel_bo_set_tiling(struct intel_bo *bo, + enum intel_tiling_mode tiling, + unsigned long pitch) +{ + uint32_t real_tiling = tiling; + int err; + + switch (tiling) { + case INTEL_TILING_X: + if (pitch % 512) + return -1; + break; + case INTEL_TILING_Y: + if (pitch % 128) + return -1; + break; + default: + break; + } + + err = drm_intel_bo_set_tiling(gem_bo(bo), &real_tiling, pitch); + if (err || real_tiling != tiling) { + assert(!"tiling mismatch"); + return -1; + } + + return 0; +} + void * intel_bo_map(struct intel_bo *bo, bool write_enable) { From olv at kemper.freedesktop.org Thu Mar 5 18:25:49 2015 From: olv at kemper.freedesktop.org (Chia-I Wu) Date: Thu, 5 Mar 2015 10:25:49 -0800 (PST) Subject: Mesa (master): ilo: add more convenient intel_bo_{ref,unref}() Message-ID: <20150305182549.84FA27617A@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 4ddd981e407f9e97fcbb862c241f1ce165616fd4 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=4ddd981e407f9e97fcbb862c241f1ce165616fd4 Author: Chia-I Wu Date: Fri Mar 6 02:03:10 2015 +0800 ilo: add more convenient intel_bo_{ref,unref}() They both check for NULL and intel_bo_ref() returns the referenced bo. They replace intel_bo_{reference,unreference}(). --- src/gallium/drivers/ilo/ilo_builder.c | 13 +++++-------- src/gallium/drivers/ilo/ilo_cp.c | 6 ++---- src/gallium/drivers/ilo/ilo_query.c | 4 +--- src/gallium/drivers/ilo/ilo_render.c | 4 +--- src/gallium/drivers/ilo/ilo_resource.c | 17 +++++++---------- src/gallium/drivers/ilo/ilo_screen.c | 14 +++++--------- src/gallium/drivers/ilo/intel_winsys.h | 10 +++++----- src/gallium/winsys/intel/drm/intel_drm_winsys.c | 14 +++++++++----- 8 files changed, 35 insertions(+), 47 deletions(-) diff --git a/src/gallium/drivers/ilo/ilo_builder.c b/src/gallium/drivers/ilo/ilo_builder.c index 52c4b21..56920e5 100644 --- a/src/gallium/drivers/ilo/ilo_builder.c +++ b/src/gallium/drivers/ilo/ilo_builder.c @@ -99,10 +99,8 @@ ilo_builder_writer_reset(struct ilo_builder *builder, writer->ptr = NULL; } - if (writer->bo) { - intel_bo_unreference(writer->bo); - writer->bo = NULL; - } + intel_bo_unref(writer->bo); + writer->bo = NULL; writer->used = 0; writer->stolen = 0; @@ -168,8 +166,7 @@ ilo_builder_writer_alloc_and_map(struct ilo_builder *builder, bo = alloc_writer_bo(builder->winsys, which, writer->size); if (bo) { - if (writer->bo) - intel_bo_unreference(writer->bo); + intel_bo_unref(writer->bo); writer->bo = bo; } else if (writer->bo) { /* reuse the old bo */ @@ -273,7 +270,7 @@ ilo_builder_writer_grow(struct ilo_builder *builder, } if (!new_ptr) { - intel_bo_unreference(new_bo); + intel_bo_unref(new_bo); return false; } @@ -282,7 +279,7 @@ ilo_builder_writer_grow(struct ilo_builder *builder, else if (!preserve) FREE(writer->ptr); - intel_bo_unreference(writer->bo); + intel_bo_unref(writer->bo); writer->size = new_size; writer->bo = new_bo; diff --git a/src/gallium/drivers/ilo/ilo_cp.c b/src/gallium/drivers/ilo/ilo_cp.c index f78fd1f..9d2dffd 100644 --- a/src/gallium/drivers/ilo/ilo_cp.c +++ b/src/gallium/drivers/ilo/ilo_cp.c @@ -163,10 +163,8 @@ ilo_cp_submit_internal(struct ilo_cp *cp) if (!err) { bool guilty; - if (cp->last_submitted_bo) - intel_bo_unreference(cp->last_submitted_bo); - cp->last_submitted_bo = bo; - intel_bo_reference(cp->last_submitted_bo); + intel_bo_unref(cp->last_submitted_bo); + cp->last_submitted_bo = intel_bo_ref(bo); guilty = ilo_cp_detect_hang(cp); diff --git a/src/gallium/drivers/ilo/ilo_query.c b/src/gallium/drivers/ilo/ilo_query.c index 942df2d..7a2e503 100644 --- a/src/gallium/drivers/ilo/ilo_query.c +++ b/src/gallium/drivers/ilo/ilo_query.c @@ -107,9 +107,7 @@ ilo_destroy_query(struct pipe_context *pipe, struct pipe_query *query) { struct ilo_query *q = ilo_query(query); - if (q->bo) - intel_bo_unreference(q->bo); - + intel_bo_unref(q->bo); FREE(q); } diff --git a/src/gallium/drivers/ilo/ilo_render.c b/src/gallium/drivers/ilo/ilo_render.c index c549256..a6614f1 100644 --- a/src/gallium/drivers/ilo/ilo_render.c +++ b/src/gallium/drivers/ilo/ilo_render.c @@ -154,9 +154,7 @@ ilo_render_create(struct ilo_builder *builder) void ilo_render_destroy(struct ilo_render *render) { - if (render->workaround_bo) - intel_bo_unreference(render->workaround_bo); - + intel_bo_unref(render->workaround_bo); FREE(render); } diff --git a/src/gallium/drivers/ilo/ilo_resource.c b/src/gallium/drivers/ilo/ilo_resource.c index 9f4ee40..7815354 100644 --- a/src/gallium/drivers/ilo/ilo_resource.c +++ b/src/gallium/drivers/ilo/ilo_resource.c @@ -171,7 +171,7 @@ tex_import_handle(struct ilo_texture *tex, if (!ilo_layout_update_for_imported_bo(&tex->layout, winsys_to_surface_tiling(tiling), pitch)) { ilo_err("imported handle has incompatible tiling/pitch\n"); - intel_bo_unreference(tex->bo); + intel_bo_unref(tex->bo); tex->bo = NULL; return false; } @@ -197,7 +197,7 @@ tex_create_bo(struct ilo_texture *tex) surface_to_winsys_tiling(tex->layout.tiling); if (intel_bo_set_tiling(bo, tiling, tex->layout.bo_stride)) { - intel_bo_unreference(bo); + intel_bo_unref(bo); bo = NULL; } } @@ -278,14 +278,11 @@ tex_create_mcs(struct ilo_texture *tex) static void tex_destroy(struct ilo_texture *tex) { - if (tex->aux_bo) - intel_bo_unreference(tex->aux_bo); - if (tex->separate_s8) tex_destroy(tex->separate_s8); - if (tex->bo) - intel_bo_unreference(tex->bo); + intel_bo_unref(tex->aux_bo); + intel_bo_unref(tex->bo); tex_free_slices(tex); FREE(tex); @@ -418,7 +415,7 @@ buf_create_bo(struct ilo_buffer *buf) static void buf_destroy(struct ilo_buffer *buf) { - intel_bo_unreference(buf->bo); + intel_bo_unref(buf->bo); FREE(buf); } @@ -554,7 +551,7 @@ ilo_buffer_rename_bo(struct ilo_buffer *buf) struct intel_bo *old_bo = buf->bo; if (buf_create_bo(buf)) { - intel_bo_unreference(old_bo); + intel_bo_unref(old_bo); return true; } else { @@ -573,7 +570,7 @@ ilo_texture_rename_bo(struct ilo_texture *tex) return false; if (tex_create_bo(tex)) { - intel_bo_unreference(old_bo); + intel_bo_unref(old_bo); return true; } else { diff --git a/src/gallium/drivers/ilo/ilo_screen.c b/src/gallium/drivers/ilo/ilo_screen.c index c9577c8..bf0a84a 100644 --- a/src/gallium/drivers/ilo/ilo_screen.c +++ b/src/gallium/drivers/ilo/ilo_screen.c @@ -600,15 +600,13 @@ ilo_fence_reference(struct pipe_screen *screen, if (likely(p)) { old = ilo_fence(*p); *p = f; - } - else { + } else { old = NULL; } STATIC_ASSERT(&((struct ilo_fence *) NULL)->reference == NULL); if (pipe_reference(&old->reference, &fence->reference)) { - if (old->bo) - intel_bo_unreference(old->bo); + intel_bo_unref(old->bo); FREE(old); } } @@ -621,7 +619,7 @@ ilo_fence_signalled(struct pipe_screen *screen, /* mark signalled if the bo is idle */ if (fence->bo && !intel_bo_is_busy(fence->bo)) { - intel_bo_unreference(fence->bo); + intel_bo_unref(fence->bo); fence->bo = NULL; } @@ -645,7 +643,7 @@ ilo_fence_finish(struct pipe_screen *screen, return false; /* mark signalled */ - intel_bo_unreference(fence->bo); + intel_bo_unref(fence->bo); fence->bo = NULL; return true; @@ -666,9 +664,7 @@ ilo_fence_create(struct pipe_screen *screen, struct intel_bo *bo) pipe_reference_init(&fence->reference, 1); - if (bo) - intel_bo_reference(bo); - fence->bo = bo; + fence->bo = intel_bo_ref(bo); return fence; } diff --git a/src/gallium/drivers/ilo/intel_winsys.h b/src/gallium/drivers/ilo/intel_winsys.h index 77eb030..afd038c 100644 --- a/src/gallium/drivers/ilo/intel_winsys.h +++ b/src/gallium/drivers/ilo/intel_winsys.h @@ -203,17 +203,17 @@ intel_winsys_decode_bo(struct intel_winsys *winsys, struct intel_bo *bo, int used); /** - * Increase the reference count of \p bo. + * Increase the reference count of \p bo. No-op when \p bo is NULL. */ -void -intel_bo_reference(struct intel_bo *bo); +struct intel_bo * +intel_bo_ref(struct intel_bo *bo); /** * Decrease the reference count of \p bo. When the reference count reaches - * zero, \p bo is destroyed. + * zero, \p bo is destroyed. No-op when \p bo is NULL. */ void -intel_bo_unreference(struct intel_bo *bo); +intel_bo_unref(struct intel_bo *bo); /** * Set the tiling of \p bo. The info is used by GTT mapping and bo export. diff --git a/src/gallium/winsys/intel/drm/intel_drm_winsys.c b/src/gallium/winsys/intel/drm/intel_drm_winsys.c index d05e036..b5ffceb 100644 --- a/src/gallium/winsys/intel/drm/intel_drm_winsys.c +++ b/src/gallium/winsys/intel/drm/intel_drm_winsys.c @@ -464,16 +464,20 @@ intel_winsys_decode_bo(struct intel_winsys *winsys, intel_bo_unmap(bo); } -void -intel_bo_reference(struct intel_bo *bo) +struct intel_bo * +intel_bo_ref(struct intel_bo *bo) { - drm_intel_bo_reference(gem_bo(bo)); + if (bo) + drm_intel_bo_reference(gem_bo(bo)); + + return bo; } void -intel_bo_unreference(struct intel_bo *bo) +intel_bo_unref(struct intel_bo *bo) { - drm_intel_bo_unreference(gem_bo(bo)); + if (bo) + drm_intel_bo_unreference(gem_bo(bo)); } int From kwg at kemper.freedesktop.org Thu Mar 5 18:50:09 2015 From: kwg at kemper.freedesktop.org (Kenneth Graunke) Date: Thu, 5 Mar 2015 10:50:09 -0800 (PST) Subject: Mesa (master): i965: Split Gen4-5 BlitFramebuffer code; prefer BLT over Meta. Message-ID: <20150305185009.874517617A@kemper.freedesktop.org> Module: Mesa Branch: master Commit: aa0705c06c03d2b882ac7b185ed123bc8a10d716 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=aa0705c06c03d2b882ac7b185ed123bc8a10d716 Author: Kenneth Graunke Date: Wed Mar 4 18:14:31 2015 -0800 i965: Split Gen4-5 BlitFramebuffer code; prefer BLT over Meta. A while back I switched intel_blit_framebuffer to prefer Meta over the BLT. This meant that Gen8 platforms would start using the 3D engine for blits, just like we do on Gen6-7.5. However, I hadn't considered Gen4-5 when making that change. The BLT engine appears to be substantially faster on 965GM than using Meta to drive the 3D engine. This isn't too surprising: original Gen4 doesn't support tile offsets (that came on G45), and the level/layer fields don't work for cubemap rendering, so for inconvenient miplevel alignments, we end up blitting or copying data to/from temporaries in order to render to it. We may as well just use the blitter. I chose to use the BLT on Gen4-5 because they use the same ring for both 3D and BLT; Gen6+ splits it out. Fixes regressions on 965GM due to botched tile offset code (we should fix those properly as well, but they're longstanding bugs - for now, put things back to the status quo). Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=89430 Signed-off-by: Kenneth Graunke Reviewed-by: Topi Pohjolainen Reviewed-by: Jordan Justen Cc: "10.5" --- src/mesa/drivers/dri/i965/intel_fbo.c | 50 ++++++++++++++++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) diff --git a/src/mesa/drivers/dri/i965/intel_fbo.c b/src/mesa/drivers/dri/i965/intel_fbo.c index 90fd064..57cf583 100644 --- a/src/mesa/drivers/dri/i965/intel_fbo.c +++ b/src/mesa/drivers/dri/i965/intel_fbo.c @@ -916,6 +916,51 @@ intel_blit_framebuffer(struct gl_context *ctx, } /** + * Gen4-5 implementation of glBlitFrameBuffer(). + * + * Tries BLT, Meta, then swrast. + * + * Gen4-5 have a single ring for both 3D and BLT operations, so there's no + * inter-ring synchronization issues like on Gen6+. It is apparently faster + * than using the 3D pipeline. Original Gen4 also has to rebase and copy + * miptree slices in order to render to unaligned locations. + */ +static void +gen4_blit_framebuffer(struct gl_context *ctx, + struct gl_framebuffer *readFb, + struct gl_framebuffer *drawFb, + GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, + GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, + GLbitfield mask, GLenum filter) +{ + /* Page 679 of OpenGL 4.4 spec says: + * "Added BlitFramebuffer to commands affected by conditional rendering in + * section 10.10 (Bug 9562)." + */ + if (!_mesa_check_conditional_render(ctx)) + return; + + mask = intel_blit_framebuffer_with_blitter(ctx, readFb, drawFb, + srcX0, srcY0, srcX1, srcY1, + dstX0, dstY0, dstX1, dstY1, + mask, filter); + if (mask == 0x0) + return; + + mask = _mesa_meta_BlitFramebuffer(ctx, readFb, drawFb, + srcX0, srcY0, srcX1, srcY1, + dstX0, dstY0, dstX1, dstY1, + mask, filter); + if (mask == 0x0) + return; + + _swrast_BlitFramebuffer(ctx, readFb, drawFb, + srcX0, srcY0, srcX1, srcY1, + dstX0, dstY0, dstX1, dstY1, + mask, filter); +} + +/** * Does the renderbuffer have hiz enabled? */ bool @@ -1049,7 +1094,10 @@ intel_fbo_init(struct brw_context *brw) dd->UnmapRenderbuffer = intel_unmap_renderbuffer; dd->RenderTexture = intel_render_texture; dd->ValidateFramebuffer = intel_validate_framebuffer; - dd->BlitFramebuffer = intel_blit_framebuffer; + if (brw->gen >= 6) + dd->BlitFramebuffer = intel_blit_framebuffer; + else + dd->BlitFramebuffer = gen4_blit_framebuffer; dd->EGLImageTargetRenderbufferStorage = intel_image_target_renderbuffer_storage; From tarceri at kemper.freedesktop.org Thu Mar 5 20:36:26 2015 From: tarceri at kemper.freedesktop.org (Timothy Arceri) Date: Thu, 5 Mar 2015 12:36:26 -0800 (PST) Subject: Mesa (master): glsl: move array validation into its own function Message-ID: <20150305203627.031477617A@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 50859c688c15bd0e98ce20fb1563e61e90aca169 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=50859c688c15bd0e98ce20fb1563e61e90aca169 Author: Timothy Arceri Date: Sat Feb 21 21:47:14 2015 +1100 glsl: move array validation into its own function V2: return true when var->type is unsized but max access is within valid range Reviewed-by: Mark Janes --- src/glsl/linker.cpp | 89 +++++++++++++++++++++++++++++---------------------- src/glsl/linker.h | 5 +++ 2 files changed, 55 insertions(+), 39 deletions(-) diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp index e11b6fa..590f364 100644 --- a/src/glsl/linker.cpp +++ b/src/glsl/linker.cpp @@ -681,6 +681,45 @@ validate_geometry_shader_emissions(struct gl_context *ctx, } } +bool +validate_intrastage_arrays(struct gl_shader_program *prog, + ir_variable *const var, + ir_variable *const existing) +{ + /* Consider the types to be "the same" if both types are arrays + * of the same type and one of the arrays is implicitly sized. + * In addition, set the type of the linked variable to the + * explicitly sized array. + */ + if (var->type->is_array() && existing->type->is_array() && + (var->type->fields.array == existing->type->fields.array) && + ((var->type->length == 0)|| (existing->type->length == 0))) { + if (var->type->length != 0) { + if (var->type->length <= existing->data.max_array_access) { + linker_error(prog, "%s `%s' declared as type " + "`%s' but outermost dimension has an index" + " of `%i'\n", + mode_string(var), + var->name, var->type->name, + existing->data.max_array_access); + } + existing->type = var->type; + return true; + } else if (existing->type->length != 0) { + if(existing->type->length <= var->data.max_array_access) { + linker_error(prog, "%s `%s' declared as type " + "`%s' but outermost dimension has an index" + " of `%i'\n", + mode_string(var), + var->name, existing->type->name, + var->data.max_array_access); + } + return true; + } + } + return false; +} + /** * Perform validation of global variables used across multiple shaders @@ -720,50 +759,22 @@ cross_validate_globals(struct gl_shader_program *prog, */ ir_variable *const existing = variables.get_variable(var->name); if (existing != NULL) { + /* Check if types match. Interface blocks have some special + * rules so we handle those elsewhere. + */ if (var->type != existing->type) { - /* Consider the types to be "the same" if both types are arrays - * of the same type and one of the arrays is implicitly sized. - * In addition, set the type of the linked variable to the - * explicitly sized array. - */ - if (var->type->is_array() - && existing->type->is_array() - && (var->type->fields.array == existing->type->fields.array) - && ((var->type->length == 0) - || (existing->type->length == 0))) { - if (var->type->length != 0) { - if (var->type->length <= existing->data.max_array_access) { - linker_error(prog, "%s `%s' declared as type " - "`%s' but outermost dimension has an index" - " of `%i'\n", - mode_string(var), - var->name, var->type->name, - existing->data.max_array_access); - return; - } - existing->type = var->type; - } else if (existing->type->length != 0 - && existing->type->length <= - var->data.max_array_access) { + if (!validate_intrastage_arrays(prog, var, existing)) { + if (var->type->is_record() && existing->type->is_record() + && existing->type->record_compare(var->type)) { + existing->type = var->type; + } else { linker_error(prog, "%s `%s' declared as type " - "`%s' but outermost dimension has an index" - " of `%i'\n", + "`%s' and type `%s'\n", mode_string(var), - var->name, existing->type->name, - var->data.max_array_access); + var->name, var->type->name, + existing->type->name); return; } - } else if (var->type->is_record() - && existing->type->is_record() - && existing->type->record_compare(var->type)) { - existing->type = var->type; - } else { - linker_error(prog, "%s `%s' declared as type " - "`%s' and type `%s'\n", - mode_string(var), - var->name, var->type->name, - existing->type->name); - return; } } diff --git a/src/glsl/linker.h b/src/glsl/linker.h index be4da5e..ce3dc32 100644 --- a/src/glsl/linker.h +++ b/src/glsl/linker.h @@ -61,6 +61,11 @@ link_uniform_blocks(void *mem_ctx, unsigned num_shaders, struct gl_uniform_block **blocks_ret); +bool +validate_intrastage_arrays(struct gl_shader_program *prog, + ir_variable *const var, + ir_variable *const existing); + void validate_intrastage_interface_blocks(struct gl_shader_program *prog, const gl_shader **shader_list, From tarceri at kemper.freedesktop.org Thu Mar 5 20:36:27 2015 From: tarceri at kemper.freedesktop.org (Timothy Arceri) Date: Thu, 5 Mar 2015 12:36:27 -0800 (PST) Subject: Mesa (master): glsl: use common intrastage array validation Message-ID: <20150305203627.0AA94763B7@kemper.freedesktop.org> Module: Mesa Branch: master Commit: c5a56a63f9fe94eaddea358b2fd67a1b7abe9ab0 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=c5a56a63f9fe94eaddea358b2fd67a1b7abe9ab0 Author: Timothy Arceri Date: Sun Feb 22 22:52:48 2015 +1100 glsl: use common intrastage array validation Use common intrastage array validation for interface blocks. This change also allows us to support interface blocks that are arrays of arrays. V2: Reinsert unsized array asserts in interstage_match() Reviewed-by: Mark Janes --- src/glsl/link_interface_blocks.cpp | 74 ++++++++++++++++++------------------ 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/src/glsl/link_interface_blocks.cpp b/src/glsl/link_interface_blocks.cpp index 0ce502d..07f5b42 100644 --- a/src/glsl/link_interface_blocks.cpp +++ b/src/glsl/link_interface_blocks.cpp @@ -50,18 +50,20 @@ struct interface_block_definition * represents either the interface instance (for named interfaces), or a * member of the interface (for unnamed interfaces). */ - explicit interface_block_definition(const ir_variable *var) - : type(var->get_interface_type()), - instance_name(NULL), - array_size(-1) + explicit interface_block_definition(ir_variable *var) + : var(var), + type(var->get_interface_type()), + instance_name(NULL) { if (var->is_interface_instance()) { instance_name = var->name; - if (var->type->is_array()) - array_size = var->type->length; } explicitly_declared = (var->data.how_declared != ir_var_declared_implicitly); } + /** + * Interface block ir_variable + */ + ir_variable *var; /** * Interface block type @@ -74,12 +76,6 @@ struct interface_block_definition const char *instance_name; /** - * For an interface block array, the array size (or 0 if unsized). - * Otherwise -1. - */ - int array_size; - - /** * True if this interface block was explicitly declared in the shader; * false if it was an implicitly declared built-in interface block. */ @@ -95,7 +91,8 @@ struct interface_block_definition bool intrastage_match(interface_block_definition *a, const interface_block_definition *b, - ir_variable_mode mode) + ir_variable_mode mode, + struct gl_shader_program *prog) { /* Types must match. */ if (a->type != b->type) { @@ -120,18 +117,13 @@ intrastage_match(interface_block_definition *a, return false; } - /* Array vs. nonarray must be consistent, and sizes must be - * consistent, with the exception that unsized arrays match sized - * arrays. + /* If a block is an array then it must match across the shader. + * Unsized arrays are also processed and matched agaist sized arrays. */ - if ((a->array_size == -1) != (b->array_size == -1)) + if (b->var->type != a->var->type && + (b->instance_name != NULL || a->instance_name != NULL) && + !validate_intrastage_arrays(prog, b->var, a->var)) return false; - if (b->array_size != 0) { - if (a->array_size == 0) - a->array_size = b->array_size; - else if (a->array_size != b->array_size) - return false; - } return true; } @@ -153,8 +145,8 @@ interstage_match(const interface_block_definition *producer, /* Unsized arrays should not occur during interstage linking. They * should have all been assigned a size by link_intrastage_shaders. */ - assert(consumer->array_size != 0); - assert(producer->array_size != 0); + assert(!consumer->var->type->is_unsized_array()); + assert(!producer->var->type->is_unsized_array()); /* Types must match. */ if (consumer->type != producer->type) { @@ -165,20 +157,27 @@ interstage_match(const interface_block_definition *producer, if (consumer->explicitly_declared || producer->explicitly_declared) return false; } + + /* Ignore outermost array if geom shader */ + const glsl_type *consumer_instance_type; if (extra_array_level) { - /* Consumer must be an array, and producer must not. */ - if (consumer->array_size == -1) - return false; - if (producer->array_size != -1) - return false; + consumer_instance_type = consumer->var->type->fields.array; } else { - /* Array vs. nonarray must be consistent, and sizes must be consistent. - * Since unsized arrays have been ruled out, we can check this by just - * making sure the sizes are equal. - */ - if (consumer->array_size != producer->array_size) + consumer_instance_type = consumer->var->type; + } + + /* If a block is an array then it must match across shaders. + * Since unsized arrays have been ruled out, we can check this by just + * making sure the types are equal. + */ + if ((consumer->instance_name != NULL && + consumer_instance_type->is_array()) || + (producer->instance_name != NULL && + producer->var->type->is_array())) { + if (consumer_instance_type != producer->var->type) return false; } + return true; } @@ -298,7 +297,8 @@ validate_intrastage_interface_blocks(struct gl_shader_program *prog, */ definitions->store(def); } else if (!intrastage_match(prev_def, &def, - (ir_variable_mode) var->data.mode)) { + (ir_variable_mode) var->data.mode, + prog)) { linker_error(prog, "definitions of interface block `%s' do not" " match\n", iface_type->name); return; @@ -374,7 +374,7 @@ validate_interstage_uniform_blocks(struct gl_shader_program *prog, * uniform matchin rules (for uniforms, it is as though all * shaders are in the same shader stage). */ - if (!intrastage_match(old_def, &new_def, ir_var_uniform)) { + if (!intrastage_match(old_def, &new_def, ir_var_uniform, prog)) { linker_error(prog, "definitions of interface block `%s' do not " "match\n", var->get_interface_type()->name); return; From tarceri at kemper.freedesktop.org Thu Mar 5 20:36:27 2015 From: tarceri at kemper.freedesktop.org (Timothy Arceri) Date: Thu, 5 Mar 2015 12:36:27 -0800 (PST) Subject: Mesa (master): glsl: let interface linking code validate its arrays Message-ID: <20150305203627.15FCE7617A@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 1a96d9ef1c2821df7e49f6bf685d26c264167933 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=1a96d9ef1c2821df7e49f6bf685d26c264167933 Author: Timothy Arceri Date: Tue Feb 24 17:28:51 2015 +1100 glsl: let interface linking code validate its arrays Currently intrastage arrays are validated twice for interface blocks. Reviewed-by: Mark Janes --- src/glsl/linker.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp index 590f364..0c44677 100644 --- a/src/glsl/linker.cpp +++ b/src/glsl/linker.cpp @@ -762,7 +762,8 @@ cross_validate_globals(struct gl_shader_program *prog, /* Check if types match. Interface blocks have some special * rules so we handle those elsewhere. */ - if (var->type != existing->type) { + if (var->type != existing->type && + !var->is_interface_instance()) { if (!validate_intrastage_arrays(prog, var, existing)) { if (var->type->is_record() && existing->type->is_record() && existing->type->record_compare(var->type)) { From robclark at kemper.freedesktop.org Thu Mar 5 20:36:52 2015 From: robclark at kemper.freedesktop.org (Rob Clark) Date: Thu, 5 Mar 2015 12:36:52 -0800 (PST) Subject: Mesa (master): freedreno/ir3: fix silly typo for binning pass shaders Message-ID: <20150305203652.60D787617A@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 60096ed906e5ebfdce41024c7af69f03b96dbe82 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=60096ed906e5ebfdce41024c7af69f03b96dbe82 Author: Rob Clark Date: Thu Mar 5 15:27:27 2015 -0500 freedreno/ir3: fix silly typo for binning pass shaders Was resulting in gl_PointSize write being optimized out, causing particle system type shaders to hang if hw binning enabled. Fixes neverball, OGLES2ParticleSystem, etc. Signed-off-by: Rob Clark --- src/gallium/drivers/freedreno/ir3/ir3_compiler.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gallium/drivers/freedreno/ir3/ir3_compiler.c b/src/gallium/drivers/freedreno/ir3/ir3_compiler.c index 2084ad3..fb51cde 100644 --- a/src/gallium/drivers/freedreno/ir3/ir3_compiler.c +++ b/src/gallium/drivers/freedreno/ir3/ir3_compiler.c @@ -3337,7 +3337,7 @@ ir3_compile_shader(struct ir3_shader_variant *so, if (key.binning_pass) { for (i = 0, j = 0; i < so->outputs_count; i++) { unsigned name = sem2name(so->outputs[i].semantic); - unsigned idx = sem2name(so->outputs[i].semantic); + unsigned idx = sem2idx(so->outputs[i].semantic); /* throw away everything but first position/psize */ if ((idx == 0) && ((name == TGSI_SEMANTIC_POSITION) || From brianp at kemper.freedesktop.org Thu Mar 5 20:38:39 2015 From: brianp at kemper.freedesktop.org (Brian Paul) Date: Thu, 5 Mar 2015 12:38:39 -0800 (PST) Subject: Mesa (master): mapi: actually remove unused u_thread.h Message-ID: <20150305203839.591557617A@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 8b2c845ea0227cf51f51eec90ec51447ae642d5b URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=8b2c845ea0227cf51f51eec90ec51447ae642d5b Author: Brian Paul Date: Thu Mar 5 07:22:40 2015 -0700 mapi: actually remove unused u_thread.h I thought this was in the previous commit in the series. Reviewed-by: Emil Velikov --- src/mapi/u_thread.h | 126 --------------------------------------------------- 1 file changed, 126 deletions(-) diff --git a/src/mapi/u_thread.h b/src/mapi/u_thread.h deleted file mode 100644 index a3a65c3..0000000 --- a/src/mapi/u_thread.h +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Mesa 3-D graphics library - * - * Copyright (C) 1999-2006 Brian Paul 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. - */ - - -/* - * Thread support for gl dispatch. - * - * Initial version by John Stone (j.stone at acm.org) (johns at cs.umr.edu) - * and Christoph Poliwoda (poliwoda at volumegraphics.com) - * Revised by Keith Whitwell - * Adapted for new gl dispatcher by Brian Paul - * Modified for use in mapi by Chia-I Wu - */ - -/* - * If this file is accidentally included by a non-threaded build, - * it should not cause the build to fail, or otherwise cause problems. - * In general, it should only be included when needed however. - */ - -#ifndef _U_THREAD_H_ -#define _U_THREAD_H_ - -#include -#include -#include "c99_compat.h" - -#include "c11/threads.h" - -/* - * Error messages - */ -#define INIT_TSD_ERROR "Mesa: failed to allocate key for thread specific data" -#define GET_TSD_ERROR "Mesa: failed to get thread specific data" -#define SET_TSD_ERROR "Mesa: thread failed to set thread specific data" - - -/* - * Magic number to determine if a TSD object has been initialized. - * Kind of a hack but there doesn't appear to be a better cross-platform - * solution. - */ -#define INIT_MAGIC 0xff8adc98 - -#ifdef __cplusplus -extern "C" { -#endif - - -struct u_tsd { - tss_t key; - unsigned initMagic; -}; - - -static inline void -u_tsd_init(struct u_tsd *tsd) -{ - if (tss_create(&tsd->key, NULL/*free*/) != 0) { - perror(INIT_TSD_ERROR); - exit(-1); - } - tsd->initMagic = INIT_MAGIC; -} - - -static inline void * -u_tsd_get(struct u_tsd *tsd) -{ - if (tsd->initMagic != INIT_MAGIC) { - u_tsd_init(tsd); - } - return tss_get(tsd->key); -} - - -static inline void -u_tsd_set(struct u_tsd *tsd, void *ptr) -{ - if (tsd->initMagic != INIT_MAGIC) { - u_tsd_init(tsd); - } - if (tss_set(tsd->key, ptr) != 0) { - perror(SET_TSD_ERROR); - exit(-1); - } -} - - -static inline void -u_tsd_destroy(struct u_tsd *tsd) -{ - if (tsd->initMagic != INIT_MAGIC) { - return; - } - tss_delete(tsd->key); - tsd->initMagic = 0x0; -} - - -#ifdef __cplusplus -} -#endif - -#endif /* _U_THREAD_H_ */ From olv at kemper.freedesktop.org Thu Mar 5 21:01:06 2015 From: olv at kemper.freedesktop.org (Chia-I Wu) Date: Thu, 5 Mar 2015 13:01:06 -0800 (PST) Subject: Mesa (master): ilo: track if a ilo_view_surface is a scanout Message-ID: <20150305210106.62023763B7@kemper.freedesktop.org> Module: Mesa Branch: master Commit: c7d17f8a80e99014743c0efbdb434c0bb281eb6c URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=c7d17f8a80e99014743c0efbdb434c0bb281eb6c Author: Chia-I Wu Date: Fri Mar 6 04:24:34 2015 +0800 ilo: track if a ilo_view_surface is a scanout Scanouts require a different cache type. --- src/gallium/drivers/ilo/ilo_state.h | 2 ++ src/gallium/drivers/ilo/ilo_state_3d_top.c | 30 +++++++++++++--------------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/gallium/drivers/ilo/ilo_state.h b/src/gallium/drivers/ilo/ilo_state.h index 0155595..5374d51 100644 --- a/src/gallium/drivers/ilo/ilo_state.h +++ b/src/gallium/drivers/ilo/ilo_state.h @@ -302,6 +302,8 @@ struct ilo_view_surface { /* SURFACE_STATE */ uint32_t payload[13]; struct intel_bo *bo; + + uint32_t scanout; }; struct ilo_view_cso { diff --git a/src/gallium/drivers/ilo/ilo_state_3d_top.c b/src/gallium/drivers/ilo/ilo_state_3d_top.c index ffa9ed8..067e735 100644 --- a/src/gallium/drivers/ilo/ilo_state_3d_top.c +++ b/src/gallium/drivers/ilo/ilo_state_3d_top.c @@ -462,8 +462,6 @@ view_init_null_gen6(const struct ilo_dev_info *dev, dw[4] = 0; dw[5] = 0; - - surf->bo = NULL; } static void @@ -555,9 +553,6 @@ view_init_for_buffer_gen6(const struct ilo_dev_info *dev, dw[4] = 0; dw[5] = 0; - - /* do not increment reference count */ - surf->bo = buf->bo; } static void @@ -722,9 +717,6 @@ view_init_for_texture_gen6(const struct ilo_dev_info *dev, assert(tex->layout.align_j == 2 || tex->layout.align_j == 4); if (tex->layout.align_j == 4) dw[5] |= GEN6_SURFACE_DW5_VALIGN_4; - - /* do not increment reference count */ - surf->bo = tex->bo; } static void @@ -796,8 +788,6 @@ view_init_null_gen7(const struct ilo_dev_info *dev, if (ilo_dev_gen(dev) >= ILO_GEN(8)) memset(&dw[8], 0, sizeof(*dw) * (13 - 8)); - - surf->bo = NULL; } static void @@ -925,9 +915,6 @@ view_init_for_buffer_gen7(const struct ilo_dev_info *dev, GEN_SHIFT32(GEN75_SCS_BLUE, GEN75_SURFACE_DW7_SCS_B) | GEN_SHIFT32(GEN75_SCS_ALPHA, GEN75_SURFACE_DW7_SCS_A); } - - /* do not increment reference count */ - surf->bo = buf->bo; } static void @@ -1195,9 +1182,6 @@ view_init_for_texture_gen7(const struct ilo_dev_info *dev, if (ilo_dev_gen(dev) >= ILO_GEN(8)) memset(&dw[8], 0, sizeof(*dw) * (13 - 8)); - - /* do not increment reference count */ - surf->bo = tex->bo; } void @@ -1213,6 +1197,9 @@ ilo_gpe_init_view_surface_null(const struct ilo_dev_info *dev, view_init_null_gen6(dev, width, height, depth, level, surf); } + + surf->bo = NULL; + surf->scanout = false; } void @@ -1231,6 +1218,10 @@ ilo_gpe_init_view_surface_for_buffer(const struct ilo_dev_info *dev, view_init_for_buffer_gen6(dev, buf, offset, size, struct_size, elem_format, is_rt, render_cache_rw, surf); } + + /* do not increment reference count */ + surf->bo = buf->bo; + surf->scanout = false; } void @@ -1253,6 +1244,13 @@ ilo_gpe_init_view_surface_for_texture(const struct ilo_dev_info *dev, first_level, num_levels, first_layer, num_layers, is_rt, surf); } + + /* do not increment reference count */ + surf->bo = tex->bo; + + /* assume imported RTs are scanouts */ + surf->scanout = ((tex->base.bind & PIPE_BIND_SCANOUT) || + (tex->imported && (tex->base.bind & PIPE_BIND_RENDER_TARGET))); } static void From olv at kemper.freedesktop.org Thu Mar 5 21:01:06 2015 From: olv at kemper.freedesktop.org (Chia-I Wu) Date: Thu, 5 Mar 2015 13:01:06 -0800 (PST) Subject: Mesa (master): ilo: clean up SURFACE_STATE and BINDING_TABLE_STATE Message-ID: <20150305210106.548927617A@kemper.freedesktop.org> Module: Mesa Branch: master Commit: e7c74ef43d7dc9c8e6791e8a4083b0776abdcfc6 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=e7c74ef43d7dc9c8e6791e8a4083b0776abdcfc6 Author: Chia-I Wu Date: Fri Mar 6 04:27:16 2015 +0800 ilo: clean up SURFACE_STATE and BINDING_TABLE_STATE Add ilo_builder_surface_pointer() to replace ilo_builder_surface_write(). Make Gen8+ take a different path in gen6_SURFACE_STATE(). --- src/gallium/drivers/ilo/ilo_builder.h | 15 +++++----- src/gallium/drivers/ilo/ilo_builder_3d_top.h | 41 +++++++++++++++++--------- 2 files changed, 35 insertions(+), 21 deletions(-) diff --git a/src/gallium/drivers/ilo/ilo_builder.h b/src/gallium/drivers/ilo/ilo_builder.h index c902a8f..cb639d1 100644 --- a/src/gallium/drivers/ilo/ilo_builder.h +++ b/src/gallium/drivers/ilo/ilo_builder.h @@ -350,21 +350,22 @@ ilo_builder_dynamic_used(const struct ilo_builder *builder) } /** - * Write a surface state to the surface buffer. The offset, in bytes, of the - * state is returned. + * Reserve a region from the surface buffer. Both the offset, in bytes, and + * the pointer to the reserved region are returned. The pointer is only valid + * until the next reserve call. * * Note that \p alignment is in bytes and \p len is in DWords. */ static inline uint32_t -ilo_builder_surface_write(struct ilo_builder *builder, - enum ilo_builder_item_type item, - unsigned alignment, unsigned len, - const uint32_t *dw) +ilo_builder_surface_pointer(struct ilo_builder *builder, + enum ilo_builder_item_type item, + unsigned alignment, unsigned len, + uint32_t **dw) { assert(item == ILO_BUILDER_ITEM_SURFACE || item == ILO_BUILDER_ITEM_BINDING_TABLE); - return ilo_builder_dynamic_write(builder, item, alignment, len, dw); + return ilo_builder_dynamic_pointer(builder, item, alignment, len, dw); } /** diff --git a/src/gallium/drivers/ilo/ilo_builder_3d_top.h b/src/gallium/drivers/ilo/ilo_builder_3d_top.h index d359252..ab1374a 100644 --- a/src/gallium/drivers/ilo/ilo_builder_3d_top.h +++ b/src/gallium/drivers/ilo/ilo_builder_3d_top.h @@ -1585,11 +1585,12 @@ gen7_3DSTATE_CONSTANT_GS(struct ilo_builder *builder, static inline uint32_t gen6_BINDING_TABLE_STATE(struct ilo_builder *builder, - uint32_t *surface_states, + const uint32_t *surface_states, int num_surface_states) { const int state_align = 32; const int state_len = num_surface_states; + uint32_t state_offset, *dw; ILO_DEV_ASSERT(builder->dev, 6, 8); @@ -1603,8 +1604,11 @@ gen6_BINDING_TABLE_STATE(struct ilo_builder *builder, if (!num_surface_states) return 0; - return ilo_builder_surface_write(builder, ILO_BUILDER_ITEM_BINDING_TABLE, - state_align, state_len, surface_states); + state_offset = ilo_builder_surface_pointer(builder, + ILO_BUILDER_ITEM_BINDING_TABLE, state_align, state_len, &dw); + memcpy(dw, surface_states, state_len << 2); + + return state_offset; } static inline uint32_t @@ -1612,23 +1616,32 @@ gen6_SURFACE_STATE(struct ilo_builder *builder, const struct ilo_view_surface *surf, bool for_render) { - const int state_align = - (ilo_dev_gen(builder->dev) >= ILO_GEN(8)) ? 64 : 32; - const int state_len = - (ilo_dev_gen(builder->dev) >= ILO_GEN(8)) ? 13 : - (ilo_dev_gen(builder->dev) >= ILO_GEN(7)) ? 8 : 6; - uint32_t state_offset; + int state_align, state_len; + uint32_t state_offset, *dw; ILO_DEV_ASSERT(builder->dev, 6, 8); - state_offset = ilo_builder_surface_write(builder, ILO_BUILDER_ITEM_SURFACE, - state_align, state_len, surf->payload); + if (ilo_dev_gen(builder->dev) >= ILO_GEN(8)) { + state_align = 64; + state_len = 13; - if (surf->bo) { - if (ilo_dev_gen(builder->dev) >= ILO_GEN(8)) { + state_offset = ilo_builder_surface_pointer(builder, + ILO_BUILDER_ITEM_SURFACE, state_align, state_len, &dw); + memcpy(dw, surf->payload, state_len << 2); + + if (surf->bo) { ilo_builder_surface_reloc64(builder, state_offset, 8, surf->bo, surf->payload[8], (for_render) ? INTEL_RELOC_WRITE : 0); - } else { + } + } else { + state_align = 32; + state_len = (ilo_dev_gen(builder->dev) >= ILO_GEN(7)) ? 8 : 6; + + state_offset = ilo_builder_surface_pointer(builder, + ILO_BUILDER_ITEM_SURFACE, state_align, state_len, &dw); + memcpy(dw, surf->payload, state_len << 2); + + if (surf->bo) { ilo_builder_surface_reloc(builder, state_offset, 1, surf->bo, surf->payload[1], (for_render) ? INTEL_RELOC_WRITE : 0); } From olv at kemper.freedesktop.org Thu Mar 5 21:01:06 2015 From: olv at kemper.freedesktop.org (Chia-I Wu) Date: Thu, 5 Mar 2015 13:01:06 -0800 (PST) Subject: Mesa (master): ilo: enable L3 cache in MOCS Message-ID: <20150305210106.733197617A@kemper.freedesktop.org> Module: Mesa Branch: master Commit: ebad062e9abbc070645dbfd18cf57c24daf7da6c URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=ebad062e9abbc070645dbfd18cf57c24daf7da6c Author: Chia-I Wu Date: Fri Mar 6 04:30:07 2015 +0800 ilo: enable L3 cache in MOCS This enables L3 cache in MOCS almost everywhere. --- src/gallium/drivers/ilo/ilo_builder.c | 14 +++++++++ src/gallium/drivers/ilo/ilo_builder.h | 1 + src/gallium/drivers/ilo/ilo_builder_3d_bottom.h | 15 +++++++++ src/gallium/drivers/ilo/ilo_builder_3d_top.h | 35 ++++++++++++++++++--- src/gallium/drivers/ilo/ilo_builder_render.h | 37 +++++++++++++++-------- 5 files changed, 85 insertions(+), 17 deletions(-) diff --git a/src/gallium/drivers/ilo/ilo_builder.c b/src/gallium/drivers/ilo/ilo_builder.c index 56920e5..d068e5b 100644 --- a/src/gallium/drivers/ilo/ilo_builder.c +++ b/src/gallium/drivers/ilo/ilo_builder.c @@ -338,6 +338,20 @@ ilo_builder_init(struct ilo_builder *builder, builder->dev = dev; builder->winsys = winsys; + /* gen6_SURFACE_STATE() may override this */ + switch (ilo_dev_gen(dev)) { + case ILO_GEN(8): + builder->mocs = GEN8_MOCS_MT_WB | GEN8_MOCS_CT_L3; + break; + case ILO_GEN(7.5): + case ILO_GEN(7): + builder->mocs = GEN7_MOCS_L3_WB; + break; + default: + builder->mocs = 0; + break; + } + for (i = 0; i < ILO_BUILDER_WRITER_COUNT; i++) ilo_builder_writer_init(builder, i); } diff --git a/src/gallium/drivers/ilo/ilo_builder.h b/src/gallium/drivers/ilo/ilo_builder.h index cb639d1..e0e9f53 100644 --- a/src/gallium/drivers/ilo/ilo_builder.h +++ b/src/gallium/drivers/ilo/ilo_builder.h @@ -100,6 +100,7 @@ struct ilo_builder_snapshot { struct ilo_builder { const struct ilo_dev_info *dev; struct intel_winsys *winsys; + uint32_t mocs; struct ilo_builder_writer writers[ILO_BUILDER_WRITER_COUNT]; bool unrecoverable_error; diff --git a/src/gallium/drivers/ilo/ilo_builder_3d_bottom.h b/src/gallium/drivers/ilo/ilo_builder_3d_bottom.h index ece1423..4f203d1 100644 --- a/src/gallium/drivers/ilo/ilo_builder_3d_bottom.h +++ b/src/gallium/drivers/ilo/ilo_builder_3d_bottom.h @@ -1182,6 +1182,8 @@ gen6_3DSTATE_DEPTH_BUFFER(struct ilo_builder *builder, dw[6] = zs->payload[4]; dw[7] = zs->payload[5]; + dw[5] |= builder->mocs << GEN8_DEPTH_DW5_MOCS__SHIFT; + if (zs->bo) { ilo_builder_batch_reloc64(builder, pos + 2, zs->bo, zs->payload[1], INTEL_RELOC_WRITE); @@ -1192,6 +1194,11 @@ gen6_3DSTATE_DEPTH_BUFFER(struct ilo_builder *builder, dw[5] = zs->payload[4]; dw[6] = zs->payload[5]; + if (ilo_dev_gen(builder->dev) >= ILO_GEN(7)) + dw[4] |= builder->mocs << GEN7_DEPTH_DW4_MOCS__SHIFT; + else + dw[6] |= builder->mocs << GEN6_DEPTH_DW6_MOCS__SHIFT; + if (zs->bo) { ilo_builder_batch_reloc(builder, pos + 2, zs->bo, zs->payload[1], INTEL_RELOC_WRITE); @@ -1220,6 +1227,8 @@ gen6_3DSTATE_STENCIL_BUFFER(struct ilo_builder *builder, dw[2] = 0; if (ilo_dev_gen(builder->dev) >= ILO_GEN(8)) { + dw[1] |= builder->mocs << GEN8_STENCIL_DW1_MOCS__SHIFT; + dw[3] = 0; dw[4] = zs->payload[8]; @@ -1228,6 +1237,8 @@ gen6_3DSTATE_STENCIL_BUFFER(struct ilo_builder *builder, zs->separate_s8_bo, zs->payload[7], INTEL_RELOC_WRITE); } } else { + dw[1] |= builder->mocs << GEN6_STENCIL_DW1_MOCS__SHIFT; + if (zs->separate_s8_bo) { ilo_builder_batch_reloc(builder, pos + 2, zs->separate_s8_bo, zs->payload[7], INTEL_RELOC_WRITE); @@ -1256,6 +1267,8 @@ gen6_3DSTATE_HIER_DEPTH_BUFFER(struct ilo_builder *builder, dw[2] = 0; if (ilo_dev_gen(builder->dev) >= ILO_GEN(8)) { + dw[1] |= builder->mocs << GEN8_HIZ_DW1_MOCS__SHIFT; + dw[3] = 0; dw[4] = zs->payload[11]; @@ -1264,6 +1277,8 @@ gen6_3DSTATE_HIER_DEPTH_BUFFER(struct ilo_builder *builder, zs->hiz_bo, zs->payload[10], INTEL_RELOC_WRITE); } } else { + dw[1] |= builder->mocs << GEN6_HIZ_DW1_MOCS__SHIFT; + if (zs->hiz_bo) { ilo_builder_batch_reloc(builder, pos + 2, zs->hiz_bo, zs->payload[10], INTEL_RELOC_WRITE); diff --git a/src/gallium/drivers/ilo/ilo_builder_3d_top.h b/src/gallium/drivers/ilo/ilo_builder_3d_top.h index ab1374a..b968beb 100644 --- a/src/gallium/drivers/ilo/ilo_builder_3d_top.h +++ b/src/gallium/drivers/ilo/ilo_builder_3d_top.h @@ -479,6 +479,11 @@ gen6_3DSTATE_VERTEX_BUFFERS(struct ilo_builder *builder, dw[0] = hw_idx << GEN6_VB_DW0_INDEX__SHIFT; + if (ilo_dev_gen(builder->dev) >= ILO_GEN(8)) + dw[0] |= builder->mocs << GEN8_VB_DW0_MOCS__SHIFT; + else + dw[0] |= builder->mocs << GEN6_VB_DW0_MOCS__SHIFT; + if (ilo_dev_gen(builder->dev) >= ILO_GEN(7)) dw[0] |= GEN7_VB_DW0_ADDR_MODIFIED; @@ -650,9 +655,9 @@ gen6_3DSTATE_INDEX_BUFFER(struct ilo_builder *builder, pos = ilo_builder_batch_pointer(builder, cmd_len, &dw); - dw[0] = GEN6_RENDER_CMD(3D, 3DSTATE_INDEX_BUFFER) | - format | - (cmd_len - 2); + dw[0] = GEN6_RENDER_CMD(3D, 3DSTATE_INDEX_BUFFER) | (cmd_len - 2) | + builder->mocs << GEN6_IB_DW0_MOCS__SHIFT | + format; if (enable_cut_index) dw[0] |= GEN6_IB_DW0_CUT_INDEX_ENABLE; @@ -694,7 +699,8 @@ gen8_3DSTATE_INDEX_BUFFER(struct ilo_builder *builder, pos = ilo_builder_batch_pointer(builder, cmd_len, &dw); dw[0] = GEN6_RENDER_CMD(3D, 3DSTATE_INDEX_BUFFER) | (cmd_len - 2); - dw[1] = format; + dw[1] = format | + builder->mocs << GEN8_IB_DW1_MOCS__SHIFT; dw[4] = buf->bo_size; /* ignore ib->offset here in favor of adjusting 3DPRIMITIVE */ @@ -1193,6 +1199,8 @@ gen7_3DSTATE_SO_BUFFER(struct ilo_builder *builder, int index, int stride, stride; if (ilo_dev_gen(builder->dev) >= ILO_GEN(8)) { + dw[1] |= builder->mocs << GEN8_SO_BUF_DW1_MOCS__SHIFT; + dw[4] = end - start; dw[5] = 0; dw[6] = 0; @@ -1201,6 +1209,8 @@ gen7_3DSTATE_SO_BUFFER(struct ilo_builder *builder, int index, int stride, ilo_builder_batch_reloc64(builder, pos + 2, buf->bo, start, INTEL_RELOC_WRITE); } else { + dw[1] |= builder->mocs << GEN7_SO_BUF_DW1_MOCS__SHIFT; + ilo_builder_batch_reloc(builder, pos + 2, buf->bo, start, INTEL_RELOC_WRITE); ilo_builder_batch_reloc(builder, pos + 3, @@ -1441,7 +1451,9 @@ gen6_3dstate_constant(struct ilo_builder *builder, int subop, ilo_builder_batch_pointer(builder, cmd_len, &dw); dw[0] = cmd | (cmd_len - 2) | - buf_enabled << 12; + buf_enabled << GEN6_CONSTANT_DW0_BUFFER_ENABLES__SHIFT | + builder->mocs << GEN6_CONSTANT_DW0_MOCS__SHIFT; + memcpy(&dw[1], buf_dw, sizeof(buf_dw)); } @@ -1543,6 +1555,8 @@ gen7_3dstate_constant(struct ilo_builder *builder, dw[9] = payload[5]; dw[10] = 0; } else { + payload[2] |= builder->mocs << GEN7_CONSTANT_DW_ADDR_MOCS__SHIFT; + memcpy(&dw[1], payload, sizeof(payload)); } } @@ -1630,6 +1644,11 @@ gen6_SURFACE_STATE(struct ilo_builder *builder, memcpy(dw, surf->payload, state_len << 2); if (surf->bo) { + const uint32_t mocs = (surf->scanout) ? + (GEN8_MOCS_MT_PTE | GEN8_MOCS_CT_L3) : builder->mocs; + + dw[1] |= mocs << GEN8_SURFACE_DW1_MOCS__SHIFT; + ilo_builder_surface_reloc64(builder, state_offset, 8, surf->bo, surf->payload[8], (for_render) ? INTEL_RELOC_WRITE : 0); } @@ -1642,6 +1661,12 @@ gen6_SURFACE_STATE(struct ilo_builder *builder, memcpy(dw, surf->payload, state_len << 2); if (surf->bo) { + /* + * For scanouts, we should not enable caching in LLC. Since we only + * enable that on Gen8+, we are fine here. + */ + dw[5] |= builder->mocs << GEN6_SURFACE_DW5_MOCS__SHIFT; + ilo_builder_surface_reloc(builder, state_offset, 1, surf->bo, surf->payload[1], (for_render) ? INTEL_RELOC_WRITE : 0); } diff --git a/src/gallium/drivers/ilo/ilo_builder_render.h b/src/gallium/drivers/ilo/ilo_builder_render.h index 0008040..34a2e2c 100644 --- a/src/gallium/drivers/ilo/ilo_builder_render.h +++ b/src/gallium/drivers/ilo/ilo_builder_render.h @@ -201,10 +201,13 @@ ilo_builder_batch_patch_sba(struct ilo_builder *builder) if (ilo_dev_gen(builder->dev) >= ILO_GEN(8)) { ilo_builder_batch_reloc64(builder, builder->sba_instruction_pos, - inst->bo, 1, 0); + inst->bo, + builder->mocs << GEN8_SBA_MOCS__SHIFT | GEN6_SBA_ADDR_MODIFIED, + 0); } else { - ilo_builder_batch_reloc(builder, builder->sba_instruction_pos, - inst->bo, 1, 0); + ilo_builder_batch_reloc(builder, builder->sba_instruction_pos, inst->bo, + builder->mocs << GEN6_SBA_MOCS__SHIFT | GEN6_SBA_ADDR_MODIFIED, + 0); } } @@ -227,12 +230,18 @@ gen6_state_base_address(struct ilo_builder *builder, bool init_all) pos = ilo_builder_batch_pointer(builder, cmd_len, &dw); dw[0] = GEN6_RENDER_CMD(COMMON, STATE_BASE_ADDRESS) | (cmd_len - 2); - dw[1] = init_all; + dw[1] = builder->mocs << GEN6_SBA_MOCS__SHIFT | + builder->mocs << GEN6_SBA_DW1_GENERAL_STATELESS_MOCS__SHIFT | + init_all; - ilo_builder_batch_reloc(builder, pos + 2, bat->bo, 1, 0); - ilo_builder_batch_reloc(builder, pos + 3, bat->bo, 1, 0); + ilo_builder_batch_reloc(builder, pos + 2, bat->bo, + builder->mocs << GEN6_SBA_MOCS__SHIFT | GEN6_SBA_ADDR_MODIFIED, + 0); + ilo_builder_batch_reloc(builder, pos + 3, bat->bo, + builder->mocs << GEN6_SBA_MOCS__SHIFT | GEN6_SBA_ADDR_MODIFIED, + 0); - dw[4] = init_all; + dw[4] = builder->mocs << GEN6_SBA_MOCS__SHIFT | init_all; /* * Since the instruction writer has WRITER_FLAG_APPEND set, it is tempting @@ -268,12 +277,16 @@ gen8_state_base_address(struct ilo_builder *builder, bool init_all) pos = ilo_builder_batch_pointer(builder, cmd_len, &dw); dw[0] = GEN6_RENDER_CMD(COMMON, STATE_BASE_ADDRESS) | (cmd_len - 2); - dw[1] = init_all; + dw[1] = builder->mocs << GEN8_SBA_MOCS__SHIFT | init_all; dw[2] = 0; - dw[3] = 0; - ilo_builder_batch_reloc64(builder, pos + 4, bat->bo, 1, 0); - ilo_builder_batch_reloc64(builder, pos + 6, bat->bo, 1, 0); - dw[8] = init_all; + dw[3] = builder->mocs << GEN8_SBA_DW3_STATELESS_MOCS__SHIFT; + ilo_builder_batch_reloc64(builder, pos + 4, bat->bo, + builder->mocs << GEN8_SBA_MOCS__SHIFT | GEN6_SBA_ADDR_MODIFIED, + 0); + ilo_builder_batch_reloc64(builder, pos + 6, bat->bo, + builder->mocs << GEN8_SBA_MOCS__SHIFT | GEN6_SBA_ADDR_MODIFIED, + 0); + dw[8] = builder->mocs << GEN8_SBA_MOCS__SHIFT | init_all; dw[9] = 0; ilo_builder_batch_patch_sba(builder); From mattst88 at kemper.freedesktop.org Thu Mar 5 23:47:57 2015 From: mattst88 at kemper.freedesktop.org (Matt Turner) Date: Thu, 5 Mar 2015 15:47:57 -0800 (PST) Subject: Mesa (master): i965/vec4: Handle saturate in dump_instruction(). Message-ID: <20150305234757.A89227617A@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 78df9d5e30fbca8b0795594448a3bcae05d5f5f2 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=78df9d5e30fbca8b0795594448a3bcae05d5f5f2 Author: Matt Turner Date: Thu Mar 5 11:16:07 2015 -0800 i965/vec4: Handle saturate in dump_instruction(). Reviewed-by: Ian Romanick --- src/mesa/drivers/dri/i965/brw_vec4.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/mesa/drivers/dri/i965/brw_vec4.cpp b/src/mesa/drivers/dri/i965/brw_vec4.cpp index 0a68413..8edb4d0 100644 --- a/src/mesa/drivers/dri/i965/brw_vec4.cpp +++ b/src/mesa/drivers/dri/i965/brw_vec4.cpp @@ -1334,6 +1334,8 @@ vec4_visitor::dump_instruction(backend_instruction *be_inst, FILE *file) } fprintf(file, "%s", brw_instruction_name(inst->opcode)); + if (inst->saturate) + fprintf(file, ".sat"); if (inst->conditional_mod) { fprintf(file, "%s", conditional_modifier[inst->conditional_mod]); if (!inst->predicate && From mattst88 at kemper.freedesktop.org Thu Mar 5 23:47:57 2015 From: mattst88 at kemper.freedesktop.org (Matt Turner) Date: Thu, 5 Mar 2015 15:47:57 -0800 (PST) Subject: Mesa (master): i965/vec4: Don' t lose the saturate modifier in copy propagation. Message-ID: <20150305234757.B4079763B7@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 0dfec59a2785cf7a87ee5128889ecebe810b611b URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=0dfec59a2785cf7a87ee5128889ecebe810b611b Author: Andrey Sudnik Date: Thu Mar 5 11:16:49 2015 -0800 i965/vec4: Don't lose the saturate modifier in copy propagation. Cc: 10.4, 10.5 Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=89224 Reviewed-by: Matt Turner Reviewed-by: Ian Romanick --- src/mesa/drivers/dri/i965/brw_vec4_copy_propagation.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesa/drivers/dri/i965/brw_vec4_copy_propagation.cpp b/src/mesa/drivers/dri/i965/brw_vec4_copy_propagation.cpp index 679867c..1f5e4f7 100644 --- a/src/mesa/drivers/dri/i965/brw_vec4_copy_propagation.cpp +++ b/src/mesa/drivers/dri/i965/brw_vec4_copy_propagation.cpp @@ -440,7 +440,7 @@ vec4_visitor::opt_copy_propagation(bool do_constant_prop) entries[reg].saturatemask = 0x0; for (int i = 0; i < 4; i++) { if (inst->dst.writemask & (1 << i)) { - entries[reg].value[i] = direct_copy ? &inst->src[0] : NULL; + entries[reg].value[i] = (!inst->saturate && direct_copy) ? &inst->src[0] : NULL; entries[reg].saturatemask |= (((inst->saturate && direct_copy) ? 1 : 0) << i); } } From samuelig at kemper.freedesktop.org Fri Mar 6 08:59:50 2015 From: samuelig at kemper.freedesktop.org (Samuel Iglesias Gonsálvez) Date: Fri, 6 Mar 2015 00:59:50 -0800 (PST) Subject: Mesa (master): configure: Introduce new output variable to ax_check_python_mako_module.m4 Message-ID: <20150306085951.0B81A76332@kemper.freedesktop.org> Module: Mesa Branch: master Commit: ced9425327be6cb557a4a1217a1dac29b18d1a09 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=ced9425327be6cb557a4a1217a1dac29b18d1a09 Author: Samuel Iglesias Gonsalvez Date: Mon Mar 2 10:49:31 2015 +0100 configure: Introduce new output variable to ax_check_python_mako_module.m4 This output variables gives more flexibility for future changes in autoconf to detect if it is needed to auto-generate files and check for the auto-generation dependencies. It is still returning error when Python is not installed. Signed-off-by: Samuel Iglesias Gonsalvez Reviewed-by: Kai Wasserb?ch --- configure.ac | 8 +++++++- m4/ax_check_python_mako_module.m4 | 4 ++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index ad64df0..90c7737 100644 --- a/configure.ac +++ b/configure.ac @@ -79,6 +79,7 @@ XCBDRI2_REQUIRED=1.8 XCBGLX_REQUIRED=1.8.1 XSHMFENCE_REQUIRED=1.1 XVMC_REQUIRED=1.0.6 +PYTHON_MAKO_REQUIRED=0.3.4 dnl Check for progs AC_PROG_CPP @@ -114,7 +115,12 @@ if test "x$INDENT" != "xcat"; then fi fi -AX_CHECK_PYTHON_MAKO_MODULE(0.3.4) +AX_CHECK_PYTHON_MAKO_MODULE($PYTHON_MAKO_REQUIRED) +if test -n "$PYTHON2" -a "x$acv_mako_found" = "xyes"; then + AC_MSG_RESULT(yes) +else + AC_MSG_ERROR([Python mako module v$PYTHON_MAKO_REQUIRED or higher not found]) +fi AC_PROG_INSTALL diff --git a/m4/ax_check_python_mako_module.m4 b/m4/ax_check_python_mako_module.m4 index 2fc029b..ee68a7c 100644 --- a/m4/ax_check_python_mako_module.m4 +++ b/m4/ax_check_python_mako_module.m4 @@ -54,8 +54,8 @@ else: " | $PYTHON2 - if test $? -ne 0 ; then - AC_MSG_ERROR(mako $1 or later is required.) + AC_SUBST(acv_mako_found, 'no') else - AC_MSG_RESULT(yes) + AC_SUBST(acv_mako_found, 'yes') fi ]) From vsyrjala at kemper.freedesktop.org Fri Mar 6 09:53:19 2015 From: vsyrjala at kemper.freedesktop.org (Ville Syrjala) Date: Fri, 6 Mar 2015 01:53:19 -0800 (PST) Subject: Mesa (master): i965: Fix URB size for CHV Message-ID: <20150306095319.6A6CD76332@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 970dc2360372a7859691d690bd2f1976c3c97fb0 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=970dc2360372a7859691d690bd2f1976c3c97fb0 Author: Ville Syrj?l? Date: Mon Jan 19 16:08:31 2015 +0200 i965: Fix URB size for CHV Increase the device info .urb.size for CHV to match the default URB size (192kB). Reviewed-by: Kenneth Graunke Signed-off-by: Ville Syrj?l? --- src/mesa/drivers/dri/i965/brw_device_info.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesa/drivers/dri/i965/brw_device_info.c b/src/mesa/drivers/dri/i965/brw_device_info.c index ec4e22e..c4350b4 100644 --- a/src/mesa/drivers/dri/i965/brw_device_info.c +++ b/src/mesa/drivers/dri/i965/brw_device_info.c @@ -275,7 +275,7 @@ static const struct brw_device_info brw_device_info_chv = { .max_gs_threads = 80, .max_wm_threads = 128, .urb = { - .size = 128, + .size = 192, .min_vs_entries = 34, .max_vs_entries = 640, .max_hs_entries = 80, From itoral at kemper.freedesktop.org Fri Mar 6 12:18:01 2015 From: itoral at kemper.freedesktop.org (Iago Toral Quiroga) Date: Fri, 6 Mar 2015 04:18:01 -0800 (PST) Subject: Mesa (master): i965: free scratch buffers when destroying the context Message-ID: <20150306121801.A4E6876332@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 7f10e1678e4ff72791a544cbb9da669f373dc78d URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=7f10e1678e4ff72791a544cbb9da669f373dc78d Author: Iago Toral Quiroga Date: Wed Oct 1 13:55:32 2014 +0200 i965: free scratch buffers when destroying the context If scratch space is needed for a shader stage we try to reuse the last scratch buffer bound to that stage. If we can't, we free the old scratch buffer and allocate a new one. This means we always keep the last scratch buffer for a particular shader stage around for the entire life span of the context. These buffers are being reported by Valgrind as definitely lost after destroying the OpenGL context. For example, for the geometry shader stage: ==18350== 248 bytes in 1 blocks are definitely lost in loss record 85 of 150 ==18350== at 0x4C2CC70: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==18350== by 0xA1B35D6: drm_intel_gem_bo_alloc_internal (intel_bufmgr_gem.c:724) ==18350== by 0xA1B383F: drm_intel_gem_bo_alloc (intel_bufmgr_gem.c:794) ==18350== by 0xA1AEFA3: drm_intel_bo_alloc (intel_bufmgr.c:52) ==18350== by 0x9D08E31: brw_get_scratch_bo (brw_program.c:226) ==18350== by 0x9D2A0F2: do_gs_prog (brw_vec4_gs.c:280) ==18350== by 0x9D2A635: brw_gs_precompile (brw_vec4_gs.c:401) ==18350== by 0x9D14F68: brw_shader_precompile(gl_context*, gl_shader_program*) (brw_shader.cpp:76) ==18350== by 0x9D157B8: brw_link_shader (brw_shader.cpp:269) ==18350== by 0x9B0941E: _mesa_glsl_link_shader (ir_to_mesa.cpp:3038) ==18350== by 0x99AE4ED: link_program (shaderapi.c:917) ==18350== by 0x99AF365: _mesa_LinkProgram (shaderapi.c:1385) So make sure that by the time we destroy the context we check if we have live scratch buffers for the various stages and release them if that is the case. Reviewed-by: Jordan Justen --- src/mesa/drivers/dri/i965/brw_context.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c index 786e6f5..972e458 100644 --- a/src/mesa/drivers/dri/i965/brw_context.c +++ b/src/mesa/drivers/dri/i965/brw_context.c @@ -908,6 +908,12 @@ intelDestroyContext(__DRIcontext * driContextPriv) brw_draw_destroy(brw); drm_intel_bo_unreference(brw->curbe.curbe_bo); + if (brw->vs.base.scratch_bo) + drm_intel_bo_unreference(brw->vs.base.scratch_bo); + if (brw->gs.base.scratch_bo) + drm_intel_bo_unreference(brw->gs.base.scratch_bo); + if (brw->wm.base.scratch_bo) + drm_intel_bo_unreference(brw->wm.base.scratch_bo); drm_intel_gem_context_destroy(brw->hw_ctx); From jrfonseca at kemper.freedesktop.org Fri Mar 6 12:39:25 2015 From: jrfonseca at kemper.freedesktop.org (Jose Fonseca) Date: Fri, 6 Mar 2015 04:39:25 -0800 (PST) Subject: Mesa (master): include: Add helper header to help trap includes inside extern C. Message-ID: <20150306123925.3D76C76332@kemper.freedesktop.org> Module: Mesa Branch: master Commit: bfb4db83b618d57fcc5f0c9e9fdb3a7ff33d07f3 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=bfb4db83b618d57fcc5f0c9e9fdb3a7ff33d07f3 Author: Jos? Fonseca Date: Thu Dec 11 22:14:14 2014 +0000 include: Add helper header to help trap includes inside extern C. This is just to help repro and fixing these issues with any C++ compiler -- Commiting this will of course wait until all issues are addressed. $ scons src/glsl/ scons: Reading SConscript files ... Checking for GCC ... yes Checking for Clang ... no Checking for X11 (x11 xext xdamage xfixes glproto >= 1.4.13)... yes Checking for XCB (x11-xcb xcb-glx >= 1.8.1 xcb-dri2 >= 1.8)... yes Checking for XF86VIDMODE (xxf86vm)... yes Checking for DRM (libdrm >= 2.4.38)... yes Checking for UDEV (libudev >= 151)... yes warning: LLVM disabled: not building llvmpipe scons: done reading SConscript files. scons: Building targets ... scons: building associated VariantDir targets: build/linux-x86_64-debug/glsl Compiling src/glsl/ast_array_index.cpp ... Compiling src/glsl/ast_expr.cpp ... Compiling src/glsl/ast_function.cpp ... Compiling src/glsl/ast_to_hir.cpp ... Compiling src/glsl/ast_type.cpp ... Compiling src/glsl/builtin_functions.cpp ... In file included from include/c99_compat.h:28:0, from src/mapi/u_compiler.h:4, from src/mapi/u_thread.h:47, from src/mapi/glapi/glapi.h:47, from src/mesa/main/mtypes.h:42, from src/mesa/main/errors.h:47, from src/mesa/main/imports.h:41, from src/mesa/main/core.h:44, from src/glsl/builtin_functions.cpp:58: include/no_extern_c.h:48:1: error: template with C linkage template class _IncludeInsideExternCNotPortable; ^ In file included from include/c99_compat.h:28:0, from include/c11/threads.h:38, from src/mapi/u_thread.h:49, from src/mapi/glapi/glapi.h:47, from src/mesa/main/mtypes.h:42, from src/mesa/main/errors.h:47, from src/mesa/main/imports.h:41, from src/mesa/main/core.h:44, from src/glsl/builtin_functions.cpp:58: include/no_extern_c.h:48:1: error: template with C linkage template class _IncludeInsideExternCNotPortable; ^ Compiling src/glsl/builtin_types.cpp ... Compiling src/glsl/builtin_variables.cpp ... scons: *** [build/linux-x86_64-debug/glsl/builtin_functions.os] Error 1 scons: building terminated because of errors. Reviewed-by: Mark Janes --- include/c99_compat.h | 2 ++ include/no_extern_c.h | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ src/util/u_atomic.h | 2 ++ 3 files changed, 52 insertions(+) diff --git a/include/c99_compat.h b/include/c99_compat.h index f56f6f3..4fc91bc 100644 --- a/include/c99_compat.h +++ b/include/c99_compat.h @@ -25,6 +25,8 @@ * **************************************************************************/ +#include "no_extern_c.h" + #ifndef _C99_COMPAT_H_ #define _C99_COMPAT_H_ diff --git a/include/no_extern_c.h b/include/no_extern_c.h new file mode 100644 index 0000000..f79602c --- /dev/null +++ b/include/no_extern_c.h @@ -0,0 +1,48 @@ +/************************************************************************** + * + * Copyright 2014 VMware, 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, 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. + * + **************************************************************************/ + + +/* + * Including system's headers inside `extern "C" { ... }` is not safe, as system + * headers may have C++ code in them, and C++ code inside extern "C" + * leads to syntatically incorrect code. + * + * This is because putting code inside extern "C" won't make __cplusplus define + * go away, that is, the system header being included thinks is free to use C++ + * as it sees fits. + * + * Including non-system headers inside extern "C" is not safe either, because + * non-system headers end up including system headers, hence fall in the above + * case too. + * + * Conclusion, includes inside extern "C" is simply not portable. + * + * + * This header helps surface these issues. + */ + +#ifdef __cplusplus +template class _IncludeInsideExternCNotPortable; +#endif diff --git a/src/util/u_atomic.h b/src/util/u_atomic.h index d15398e..e38395a 100644 --- a/src/util/u_atomic.h +++ b/src/util/u_atomic.h @@ -6,6 +6,8 @@ * */ +#include "no_extern_c.h" + #ifndef U_ATOMIC_H #define U_ATOMIC_H From evelikov at kemper.freedesktop.org Fri Mar 6 16:58:33 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Fri, 6 Mar 2015 08:58:33 -0800 (PST) Subject: Mesa (master): egl/main: convert thread management to use c11 threads Message-ID: <20150306165833.5CFC77633A@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 33eff853363d7eba5e61b00431b95f7aa0d7b0a5 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=33eff853363d7eba5e61b00431b95f7aa0d7b0a5 Author: Emil Velikov Date: Thu Mar 5 15:30:12 2015 +0000 egl/main: convert thread management to use c11 threads Convert the code to use the C11 threads implementation, and nuke the Windows non-pthreads code-path. The c11/threads_win32.h abstraction should be better than the current code. Signed-off-by: Emil Velikov --- src/egl/main/eglcurrent.c | 48 ++++++--------------------------------------- 1 file changed, 6 insertions(+), 42 deletions(-) diff --git a/src/egl/main/eglcurrent.c b/src/egl/main/eglcurrent.c index dc32ed4..5d8cae4 100644 --- a/src/egl/main/eglcurrent.c +++ b/src/egl/main/eglcurrent.c @@ -29,6 +29,7 @@ #include #include #include "c99_compat.h" +#include "c11/threads.h" #include "egllog.h" #include "eglcurrent.h" @@ -41,14 +42,9 @@ /* a fallback thread info to guarantee that every thread always has one */ static _EGLThreadInfo dummy_thread = _EGL_THREAD_INFO_INITIALIZER; - - -#if HAVE_PTHREAD -#include - static mtx_t _egl_TSDMutex = _MTX_INITIALIZER_NP; static EGLBoolean _egl_TSDInitialized; -static pthread_key_t _egl_TSD; +static tss_t _egl_TSD; static void (*_egl_FreeTSD)(_EGLThreadInfo *); #ifdef GLX_USE_TLS @@ -58,7 +54,7 @@ static __thread const _EGLThreadInfo *_egl_TLS static inline void _eglSetTSD(const _EGLThreadInfo *t) { - pthread_setspecific(_egl_TSD, (const void *) t); + tss_set(_egl_TSD, (const void *) t); #ifdef GLX_USE_TLS _egl_TLS = t; #endif @@ -69,7 +65,7 @@ static inline _EGLThreadInfo *_eglGetTSD(void) #ifdef GLX_USE_TLS return (_EGLThreadInfo *) _egl_TLS; #else - return (_EGLThreadInfo *) pthread_getspecific(_egl_TSD); + return (_EGLThreadInfo *) tss_get(_egl_TSD); #endif } @@ -82,7 +78,7 @@ static inline void _eglFiniTSD(void) _egl_TSDInitialized = EGL_FALSE; if (t && _egl_FreeTSD) _egl_FreeTSD((void *) t); - pthread_key_delete(_egl_TSD); + tss_delete(_egl_TSD); } mtx_unlock(&_egl_TSDMutex); } @@ -94,7 +90,7 @@ static inline EGLBoolean _eglInitTSD(void (*dtor)(_EGLThreadInfo *)) /* check again after acquiring lock */ if (!_egl_TSDInitialized) { - if (pthread_key_create(&_egl_TSD, (void (*)(void *)) dtor) != 0) { + if (tss_create(&_egl_TSD, (void (*)(void *)) dtor) != thrd_success) { mtx_unlock(&_egl_TSDMutex); return EGL_FALSE; } @@ -109,38 +105,6 @@ static inline EGLBoolean _eglInitTSD(void (*dtor)(_EGLThreadInfo *)) return EGL_TRUE; } -#else /* HAVE_PTHREAD */ -static const _EGLThreadInfo *_egl_TSD; -static void (*_egl_FreeTSD)(_EGLThreadInfo *); - -static inline void _eglSetTSD(const _EGLThreadInfo *t) -{ - _egl_TSD = t; -} - -static inline _EGLThreadInfo *_eglGetTSD(void) -{ - return (_EGLThreadInfo *) _egl_TSD; -} - -static inline void _eglFiniTSD(void) -{ - if (_egl_FreeTSD && _egl_TSD) - _egl_FreeTSD((_EGLThreadInfo *) _egl_TSD); -} - -static inline EGLBoolean _eglInitTSD(void (*dtor)(_EGLThreadInfo *)) -{ - if (!_egl_FreeTSD && dtor) { - _egl_FreeTSD = dtor; - _eglAddAtExitCall(_eglFiniTSD); - } - return EGL_TRUE; -} - -#endif /* !HAVE_PTHREAD */ - - static void _eglInitThreadInfo(_EGLThreadInfo *t) { From evelikov at kemper.freedesktop.org Fri Mar 6 16:58:33 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Fri, 6 Mar 2015 08:58:33 -0800 (PST) Subject: Mesa (master): egl/main: use c11/threads' mutex directly Message-ID: <20150306165833.5427B76336@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 6cee785c69a5c8d2d32b6807f9c502117f5a74b0 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=6cee785c69a5c8d2d32b6807f9c502117f5a74b0 Author: Emil Velikov Date: Thu Mar 5 15:07:51 2015 +0000 egl/main: use c11/threads' mutex directly Remove the inline wrappers/abstraction layer. Signed-off-by: Emil Velikov --- src/egl/main/Makefile.sources | 1 - src/egl/main/eglapi.c | 14 +++++---- src/egl/main/eglcurrent.c | 13 ++++---- src/egl/main/egldisplay.c | 13 ++++---- src/egl/main/egldisplay.h | 4 +-- src/egl/main/egldriver.c | 8 ++--- src/egl/main/eglglobals.c | 9 +++--- src/egl/main/eglglobals.h | 4 +-- src/egl/main/egllog.c | 18 +++++------ src/egl/main/eglmutex.h | 66 ----------------------------------------- src/egl/main/eglscreen.c | 8 ++--- 11 files changed, 47 insertions(+), 111 deletions(-) diff --git a/src/egl/main/Makefile.sources b/src/egl/main/Makefile.sources index 6a917e2..75f060a 100644 --- a/src/egl/main/Makefile.sources +++ b/src/egl/main/Makefile.sources @@ -26,7 +26,6 @@ LIBEGL_C_FILES := \ eglmisc.h \ eglmode.c \ eglmode.h \ - eglmutex.h \ eglscreen.c \ eglscreen.h \ eglstring.c \ diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c index 2258830..a74efcd 100644 --- a/src/egl/main/eglapi.c +++ b/src/egl/main/eglapi.c @@ -87,6 +87,8 @@ #include #include #include "c99_compat.h" +#include "c11/threads.h" +#include "eglcompiler.h" #include "eglglobals.h" #include "eglcontext.h" @@ -275,7 +277,7 @@ _eglLockDisplay(EGLDisplay display) { _EGLDisplay *dpy = _eglLookupDisplay(display); if (dpy) - _eglLockMutex(&dpy->Mutex); + mtx_lock(&dpy->Mutex); return dpy; } @@ -286,7 +288,7 @@ _eglLockDisplay(EGLDisplay display) static inline void _eglUnlockDisplay(_EGLDisplay *dpy) { - _eglUnlockMutex(&dpy->Mutex); + mtx_unlock(&dpy->Mutex); } @@ -896,7 +898,7 @@ eglWaitClient(void) RETURN_EGL_SUCCESS(NULL, EGL_TRUE); disp = ctx->Resource.Display; - _eglLockMutex(&disp->Mutex); + mtx_lock(&disp->Mutex); /* let bad current context imply bad current surface */ if (_eglGetContextHandle(ctx) == EGL_NO_CONTEXT || @@ -942,7 +944,7 @@ eglWaitNative(EGLint engine) RETURN_EGL_SUCCESS(NULL, EGL_TRUE); disp = ctx->Resource.Display; - _eglLockMutex(&disp->Mutex); + mtx_lock(&disp->Mutex); /* let bad current context imply bad current surface */ if (_eglGetContextHandle(ctx) == EGL_NO_CONTEXT || @@ -1457,10 +1459,10 @@ eglReleaseThread(void) t->CurrentAPIIndex = i; - _eglLockMutex(&disp->Mutex); + mtx_lock(&disp->Mutex); drv = disp->Driver; (void) drv->API.MakeCurrent(drv, disp, NULL, NULL, NULL); - _eglUnlockMutex(&disp->Mutex); + mtx_unlock(&disp->Mutex); } } diff --git a/src/egl/main/eglcurrent.c b/src/egl/main/eglcurrent.c index 3d49641..dc32ed4 100644 --- a/src/egl/main/eglcurrent.c +++ b/src/egl/main/eglcurrent.c @@ -31,7 +31,6 @@ #include "c99_compat.h" #include "egllog.h" -#include "eglmutex.h" #include "eglcurrent.h" #include "eglglobals.h" @@ -47,7 +46,7 @@ static _EGLThreadInfo dummy_thread = _EGL_THREAD_INFO_INITIALIZER; #if HAVE_PTHREAD #include -static _EGLMutex _egl_TSDMutex = _EGL_MUTEX_INITIALIZER; +static mtx_t _egl_TSDMutex = _MTX_INITIALIZER_NP; static EGLBoolean _egl_TSDInitialized; static pthread_key_t _egl_TSD; static void (*_egl_FreeTSD)(_EGLThreadInfo *); @@ -76,7 +75,7 @@ static inline _EGLThreadInfo *_eglGetTSD(void) static inline void _eglFiniTSD(void) { - _eglLockMutex(&_egl_TSDMutex); + mtx_lock(&_egl_TSDMutex); if (_egl_TSDInitialized) { _EGLThreadInfo *t = _eglGetTSD(); @@ -85,18 +84,18 @@ static inline void _eglFiniTSD(void) _egl_FreeTSD((void *) t); pthread_key_delete(_egl_TSD); } - _eglUnlockMutex(&_egl_TSDMutex); + mtx_unlock(&_egl_TSDMutex); } static inline EGLBoolean _eglInitTSD(void (*dtor)(_EGLThreadInfo *)) { if (!_egl_TSDInitialized) { - _eglLockMutex(&_egl_TSDMutex); + mtx_lock(&_egl_TSDMutex); /* check again after acquiring lock */ if (!_egl_TSDInitialized) { if (pthread_key_create(&_egl_TSD, (void (*)(void *)) dtor) != 0) { - _eglUnlockMutex(&_egl_TSDMutex); + mtx_unlock(&_egl_TSDMutex); return EGL_FALSE; } _egl_FreeTSD = dtor; @@ -104,7 +103,7 @@ static inline EGLBoolean _eglInitTSD(void (*dtor)(_EGLThreadInfo *)) _egl_TSDInitialized = EGL_TRUE; } - _eglUnlockMutex(&_egl_TSDMutex); + mtx_unlock(&_egl_TSDMutex); } return EGL_TRUE; diff --git a/src/egl/main/egldisplay.c b/src/egl/main/egldisplay.c index a167ae5..b7a5b8f 100644 --- a/src/egl/main/egldisplay.c +++ b/src/egl/main/egldisplay.c @@ -35,13 +35,14 @@ #include #include #include +#include "c11/threads.h" + #include "eglcontext.h" #include "eglcurrent.h" #include "eglsurface.h" #include "egldisplay.h" #include "egldriver.h" #include "eglglobals.h" -#include "eglmutex.h" #include "egllog.h" /* Includes for _eglNativePlatformDetectNativeDisplay */ @@ -260,7 +261,7 @@ _eglFindDisplay(_EGLPlatformType plat, void *plat_dpy) if (plat == _EGL_INVALID_PLATFORM) return NULL; - _eglLockMutex(_eglGlobal.Mutex); + mtx_lock(_eglGlobal.Mutex); /* search the display list first */ dpy = _eglGlobal.DisplayList; @@ -274,7 +275,7 @@ _eglFindDisplay(_EGLPlatformType plat, void *plat_dpy) if (!dpy) { dpy = calloc(1, sizeof(_EGLDisplay)); if (dpy) { - _eglInitMutex(&dpy->Mutex); + mtx_init(&dpy->Mutex, mtx_plain); dpy->Platform = plat; dpy->PlatformDisplay = plat_dpy; @@ -284,7 +285,7 @@ _eglFindDisplay(_EGLPlatformType plat, void *plat_dpy) } } - _eglUnlockMutex(_eglGlobal.Mutex); + mtx_unlock(_eglGlobal.Mutex); return dpy; } @@ -344,14 +345,14 @@ _eglCheckDisplayHandle(EGLDisplay dpy) { _EGLDisplay *cur; - _eglLockMutex(_eglGlobal.Mutex); + mtx_lock(_eglGlobal.Mutex); cur = _eglGlobal.DisplayList; while (cur) { if (cur == (_EGLDisplay *) dpy) break; cur = cur->Next; } - _eglUnlockMutex(_eglGlobal.Mutex); + mtx_unlock(_eglGlobal.Mutex); return (cur != NULL); } diff --git a/src/egl/main/egldisplay.h b/src/egl/main/egldisplay.h index 9c3c8c7..5a845d8 100644 --- a/src/egl/main/egldisplay.h +++ b/src/egl/main/egldisplay.h @@ -32,10 +32,10 @@ #define EGLDISPLAY_INCLUDED #include "c99_compat.h" +#include "c11/threads.h" #include "egltypedefs.h" #include "egldefines.h" -#include "eglmutex.h" #include "eglarray.h" @@ -132,7 +132,7 @@ struct _egl_display /* used to link displays */ _EGLDisplay *Next; - _EGLMutex Mutex; + mtx_t Mutex; _EGLPlatformType Platform; /**< The type of the platform display */ void *PlatformDisplay; /**< A pointer to the platform display */ diff --git a/src/egl/main/egldriver.c b/src/egl/main/egldriver.c index e6a61f3..6983af9 100644 --- a/src/egl/main/egldriver.c +++ b/src/egl/main/egldriver.c @@ -37,13 +37,13 @@ #include #include #include +#include "c11/threads.h" #include "eglstring.h" #include "egldefines.h" #include "egldisplay.h" #include "egldriver.h" #include "egllog.h" -#include "eglmutex.h" #if defined(_EGL_OS_UNIX) #include @@ -63,7 +63,7 @@ typedef struct _egl_module { _EGLDriver *Driver; } _EGLModule; -static _EGLMutex _eglModuleMutex = _EGL_MUTEX_INITIALIZER; +static mtx_t _eglModuleMutex = _MTX_INITIALIZER_NP; static _EGLArray *_eglModules; const struct { @@ -616,7 +616,7 @@ _eglMatchDriver(_EGLDisplay *dpy, EGLBoolean test_only) assert(!dpy->Initialized); - _eglLockMutex(&_eglModuleMutex); + mtx_lock(&_eglModuleMutex); /* set options */ dpy->Options.TestOnly = test_only; @@ -628,7 +628,7 @@ _eglMatchDriver(_EGLDisplay *dpy, EGLBoolean test_only) best_drv = _eglMatchAndInitialize(dpy); } - _eglUnlockMutex(&_eglModuleMutex); + mtx_unlock(&_eglModuleMutex); if (best_drv) { _eglLog(_EGL_DEBUG, "the best driver is %s%s", diff --git a/src/egl/main/eglglobals.c b/src/egl/main/eglglobals.c index 56fe9e2..129bf29 100644 --- a/src/egl/main/eglglobals.c +++ b/src/egl/main/eglglobals.c @@ -30,13 +30,14 @@ #include #include +#include "c11/threads.h" + #include "eglglobals.h" #include "egldisplay.h" #include "egldriver.h" -#include "eglmutex.h" -static _EGLMutex _eglGlobalMutex = _EGL_MUTEX_INITIALIZER; +static mtx_t _eglGlobalMutex = _MTX_INITIALIZER_NP; struct _egl_global _eglGlobal = { @@ -84,7 +85,7 @@ _eglAddAtExitCall(void (*func)(void)) if (func) { static EGLBoolean registered = EGL_FALSE; - _eglLockMutex(_eglGlobal.Mutex); + mtx_lock(_eglGlobal.Mutex); if (!registered) { atexit(_eglAtExit); @@ -94,6 +95,6 @@ _eglAddAtExitCall(void (*func)(void)) assert(_eglGlobal.NumAtExitCalls < ARRAY_SIZE(_eglGlobal.AtExitCalls)); _eglGlobal.AtExitCalls[_eglGlobal.NumAtExitCalls++] = func; - _eglUnlockMutex(_eglGlobal.Mutex); + mtx_unlock(_eglGlobal.Mutex); } } diff --git a/src/egl/main/eglglobals.h b/src/egl/main/eglglobals.h index a8cf6d6..04b9609 100644 --- a/src/egl/main/eglglobals.h +++ b/src/egl/main/eglglobals.h @@ -32,9 +32,9 @@ #define EGLGLOBALS_INCLUDED #include +#include "c11/threads.h" #include "egltypedefs.h" -#include "eglmutex.h" /** @@ -42,7 +42,7 @@ */ struct _egl_global { - _EGLMutex *Mutex; + mtx_t *Mutex; /* the list of all displays */ _EGLDisplay *DisplayList; diff --git a/src/egl/main/egllog.c b/src/egl/main/egllog.c index babab07..1877d8b 100644 --- a/src/egl/main/egllog.c +++ b/src/egl/main/egllog.c @@ -38,24 +38,24 @@ #include #include #include +#include "c11/threads.h" #include "egllog.h" #include "eglstring.h" -#include "eglmutex.h" #define MAXSTRING 1000 #define FALLBACK_LOG_LEVEL _EGL_WARNING static struct { - _EGLMutex mutex; + mtx_t mutex; EGLBoolean initialized; EGLint level; _EGLLogProc logger; EGLint num_messages; } logging = { - _EGL_MUTEX_INITIALIZER, + _MTX_INITIALIZER_NP, EGL_FALSE, FALLBACK_LOG_LEVEL, NULL, @@ -82,7 +82,7 @@ _eglSetLogProc(_EGLLogProc logger) { EGLint num_messages = 0; - _eglLockMutex(&logging.mutex); + mtx_lock(&logging.mutex); if (logging.logger != logger) { logging.logger = logger; @@ -91,7 +91,7 @@ _eglSetLogProc(_EGLLogProc logger) logging.num_messages = 0; } - _eglUnlockMutex(&logging.mutex); + mtx_unlock(&logging.mutex); if (num_messages) _eglLog(_EGL_DEBUG, @@ -111,9 +111,9 @@ _eglSetLogLevel(EGLint level) case _EGL_WARNING: case _EGL_INFO: case _EGL_DEBUG: - _eglLockMutex(&logging.mutex); + mtx_lock(&logging.mutex); logging.level = level; - _eglUnlockMutex(&logging.mutex); + mtx_unlock(&logging.mutex); break; default: break; @@ -188,7 +188,7 @@ _eglLog(EGLint level, const char *fmtStr, ...) if (level > logging.level || level < 0) return; - _eglLockMutex(&logging.mutex); + mtx_lock(&logging.mutex); if (logging.logger) { va_start(args, fmtStr); @@ -201,7 +201,7 @@ _eglLog(EGLint level, const char *fmtStr, ...) logging.num_messages++; } - _eglUnlockMutex(&logging.mutex); + mtx_unlock(&logging.mutex); if (level == _EGL_FATAL) exit(1); /* or abort()? */ diff --git a/src/egl/main/eglmutex.h b/src/egl/main/eglmutex.h deleted file mode 100644 index b58f0e3..0000000 --- a/src/egl/main/eglmutex.h +++ /dev/null @@ -1,66 +0,0 @@ -/************************************************************************** - * - * Copyright 2009 Chia-I Wu - * 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 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. - * - **************************************************************************/ - - -#ifndef EGLMUTEX_INCLUDED -#define EGLMUTEX_INCLUDED - -#include "c99_compat.h" - -#include "eglcompiler.h" - -#include "c11/threads.h" - -typedef mtx_t _EGLMutex; - -static inline void _eglInitMutex(_EGLMutex *m) -{ - mtx_init(m, mtx_plain); -} - -static inline void -_eglDestroyMutex(_EGLMutex *m) -{ - mtx_destroy(m); -} - -static inline void -_eglLockMutex(_EGLMutex *m) -{ - mtx_lock(m); -} - -static inline void -_eglUnlockMutex(_EGLMutex *m) -{ - mtx_unlock(m); -} - -#define _EGL_MUTEX_INITIALIZER _MTX_INITIALIZER_NP - - -#endif /* EGLMUTEX_INCLUDED */ diff --git a/src/egl/main/eglscreen.c b/src/egl/main/eglscreen.c index b8f2b39..42ac621 100644 --- a/src/egl/main/eglscreen.c +++ b/src/egl/main/eglscreen.c @@ -44,20 +44,20 @@ #include #include #include +#include "c11/threads.h" #include "egldisplay.h" #include "eglcurrent.h" #include "eglmode.h" #include "eglsurface.h" #include "eglscreen.h" -#include "eglmutex.h" #ifdef EGL_MESA_screen_surface /* ugh, no atomic op? */ -static _EGLMutex _eglNextScreenHandleMutex = _EGL_MUTEX_INITIALIZER; +static mtx_t _eglNextScreenHandleMutex = _MTX_INITIALIZER_NP; static EGLScreenMESA _eglNextScreenHandle = 1; @@ -70,10 +70,10 @@ _eglAllocScreenHandle(void) { EGLScreenMESA s; - _eglLockMutex(&_eglNextScreenHandleMutex); + mtx_lock(&_eglNextScreenHandleMutex); s = _eglNextScreenHandle; _eglNextScreenHandle += _EGL_SCREEN_MAX_MODES; - _eglUnlockMutex(&_eglNextScreenHandleMutex); + mtx_unlock(&_eglNextScreenHandleMutex); return s; } From evelikov at kemper.freedesktop.org Fri Mar 6 16:58:33 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Fri, 6 Mar 2015 08:58:33 -0800 (PST) Subject: Mesa (master): glx: remove final reference to THREADS Message-ID: <20150306165833.720FE76359@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 8b15a883e0ba72c9156d7192a798bb272e0bc528 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=8b15a883e0ba72c9156d7192a798bb272e0bc528 Author: Emil Velikov Date: Thu Mar 5 22:06:06 2015 +0000 glx: remove final reference to THREADS Left over from commit 18db13f5865(mapi: THREADS was always defined, remove it) Signed-off-by: Emil Velikov --- src/glx/glxcurrent.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/glx/glxcurrent.c b/src/glx/glxcurrent.c index dc2acd5..86fb658 100644 --- a/src/glx/glxcurrent.c +++ b/src/glx/glxcurrent.c @@ -138,10 +138,6 @@ __glXGetCurrentContext(void) # endif /* defined( GLX_USE_TLS ) */ -#elif defined( THREADS ) - -#error Unknown threading method specified. - #else /* not thread safe */ From evelikov at kemper.freedesktop.org Fri Mar 6 16:58:33 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Fri, 6 Mar 2015 08:58:33 -0800 (PST) Subject: Mesa (master): glx: remove support for non-multithreaded platforms Message-ID: <20150306165833.7CF8976336@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 38591295cd4b68f89f257b20f476f98de3772a47 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=38591295cd4b68f89f257b20f476f98de3772a47 Author: Emil Velikov Date: Thu Mar 5 23:06:42 2015 +0000 glx: remove support for non-multithreaded platforms Implicitly required for a while, although commit 9385c592c68 (mapi: remove u_thread.h) was the one that put the final nail on the coffin. Signed-off-by: Emil Velikov --- docs/dispatch.html | 7 ++----- src/glx/glxclient.h | 18 +----------------- src/glx/glxcurrent.c | 11 ----------- src/glx/tests/fake_glx_screen.cpp | 2 +- 4 files changed, 4 insertions(+), 34 deletions(-) diff --git a/docs/dispatch.html b/docs/dispatch.html index aacd01e..77cfba3 100644 --- a/docs/dispatch.html +++ b/docs/dispatch.html @@ -185,8 +185,6 @@ ways that the dispatch table pointer can be accessed. There are four different methods that can be used:

    -
  1. Using _glapi_Dispatch directly in builds for non-multithreaded -environments.
  2. Using _glapi_Dispatch and _glapi_get_dispatch in multithreaded environments.
  3. Using _glapi_Dispatch and pthread_getspecific in @@ -204,9 +202,8 @@ terribly relevant.

    few preprocessor defines.

      -
    • If GLX_USE_TLS is defined, method #4 is used.
    • -
    • If HAVE_PTHREAD is defined, method #3 is used.
    • -
    • If WIN32_THREADS is defined, method #2 is used.
    • +
    • If GLX_USE_TLS is defined, method #3 is used.
    • +
    • If HAVE_PTHREAD is defined, method #2 is used.
    • If none of the preceding are defined, method #1 is used.
    diff --git a/src/glx/glxclient.h b/src/glx/glxclient.h index a140c87..4211d31 100644 --- a/src/glx/glxclient.h +++ b/src/glx/glxclient.h @@ -47,15 +47,13 @@ #include #include #include +#include #ifdef _WIN32 #include #endif #include "GL/glxproto.h" #include "glxconfig.h" #include "glxhash.h" -#if defined( HAVE_PTHREAD ) -# include -#endif #include "util/macros.h" #include "glxextensions.h" @@ -631,7 +629,6 @@ extern void __glXPreferEGL(int state); extern int __glXDebug; /* This is per-thread storage in an MT environment */ -#if defined( HAVE_PTHREAD ) extern void __glXSetCurrentContext(struct glx_context * c); @@ -648,14 +645,6 @@ extern struct glx_context *__glXGetCurrentContext(void); # endif /* defined( GLX_USE_TLS ) */ -#else - -extern struct glx_context *__glXcurrentContext; -#define __glXGetCurrentContext() __glXcurrentContext -#define __glXSetCurrentContext(gc) __glXcurrentContext = gc - -#endif /* defined( HAVE_PTHREAD ) */ - extern void __glXSetCurrentContextNull(void); @@ -663,14 +652,9 @@ extern void __glXSetCurrentContextNull(void); ** Global lock for all threads in this address space using the GLX ** extension */ -#if defined( HAVE_PTHREAD ) extern pthread_mutex_t __glXmutex; #define __glXLock() pthread_mutex_lock(&__glXmutex) #define __glXUnlock() pthread_mutex_unlock(&__glXmutex) -#else -#define __glXLock() -#define __glXUnlock() -#endif /* ** Setup for a command. Initialize the extension for dpy if necessary. diff --git a/src/glx/glxcurrent.c b/src/glx/glxcurrent.c index 86fb658..7f47a42 100644 --- a/src/glx/glxcurrent.c +++ b/src/glx/glxcurrent.c @@ -33,9 +33,7 @@ * Client-side GLX interface for current context management. */ -#ifdef HAVE_PTHREAD #include -#endif #include "glxclient.h" @@ -67,8 +65,6 @@ struct glx_context dummyContext = { * Current context management and locking */ -#if defined( HAVE_PTHREAD ) - _X_HIDDEN pthread_mutex_t __glXmutex = PTHREAD_MUTEX_INITIALIZER; # if defined( GLX_USE_TLS ) @@ -138,13 +134,6 @@ __glXGetCurrentContext(void) # endif /* defined( GLX_USE_TLS ) */ -#else - -/* not thread safe */ -_X_HIDDEN struct glx_context *__glXcurrentContext = &dummyContext; - -#endif - _X_HIDDEN void __glXSetCurrentContextNull(void) diff --git a/src/glx/tests/fake_glx_screen.cpp b/src/glx/tests/fake_glx_screen.cpp index ccb1afa..db20749 100644 --- a/src/glx/tests/fake_glx_screen.cpp +++ b/src/glx/tests/fake_glx_screen.cpp @@ -77,7 +77,7 @@ indirect_create_context_attribs(struct glx_screen *base, __thread void *__glX_tls_Context = NULL; -#if defined(HAVE_PTHREAD) && !defined(GLX_USE_TLS) +#if !defined(GLX_USE_TLS) extern "C" struct glx_context * __glXGetCurrentContext() { From evelikov at kemper.freedesktop.org Fri Mar 6 16:58:33 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Fri, 6 Mar 2015 08:58:33 -0800 (PST) Subject: Mesa (master): glx: remove unneeded ifdef _WIN32 guard Message-ID: <20150306165833.909E476336@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 1c1fd82b4b50fae4644e442b0c2a017f1e428610 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=1c1fd82b4b50fae4644e442b0c2a017f1e428610 Author: Emil Velikov Date: Thu Mar 5 23:48:29 2015 +0000 glx: remove unneeded ifdef _WIN32 guard The C99 header exists on other platforms as well. Signed-off-by: Emil Velikov Reviewed-by: Brian Paul --- src/glx/glxclient.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/glx/glxclient.h b/src/glx/glxclient.h index 4211d31..30c9e52 100644 --- a/src/glx/glxclient.h +++ b/src/glx/glxclient.h @@ -48,9 +48,7 @@ #include #include #include -#ifdef _WIN32 #include -#endif #include "GL/glxproto.h" #include "glxconfig.h" #include "glxhash.h" From evelikov at kemper.freedesktop.org Fri Mar 6 16:58:33 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Fri, 6 Mar 2015 08:58:33 -0800 (PST) Subject: Mesa (master): configure: require pthreads for POSIX builds Message-ID: <20150306165833.67FE97633D@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 50714cec2b50c7836841c09f04bfe875de00ae1d URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=50714cec2b50c7836841c09f04bfe875de00ae1d Author: Emil Velikov Date: Thu Mar 5 22:36:41 2015 +0000 configure: require pthreads for POSIX builds This has been an implicit rule for building mesa for a long time. Let's make it official and just bail out at configure time. This way we can cleaning up some of our glx code. Signed-off-by: Emil Velikov --- configure.ac | 3 +++ 1 file changed, 3 insertions(+) diff --git a/configure.ac b/configure.ac index 90c7737..4989444 100644 --- a/configure.ac +++ b/configure.ac @@ -657,6 +657,9 @@ mingw*) ;; *) AX_PTHREAD + if test "x$ax_pthread_ok" = xno; then + AC_MSG_ERROR([Building mesa on this platform requires pthreads]) + fi ;; esac dnl AX_PTHREADS leaves PTHREAD_LIBS empty for gcc and sets PTHREAD_CFLAGS From evelikov at kemper.freedesktop.org Fri Mar 6 16:58:33 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Fri, 6 Mar 2015 08:58:33 -0800 (PST) Subject: Mesa (master): util: rework _MSC_VER >= 1200 checks Message-ID: <20150306165833.868CA76336@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 3f167516399c8e20478bb0081a24ab7ac155b093 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=3f167516399c8e20478bb0081a24ab7ac155b093 Author: Emil Velikov Date: Thu Mar 5 23:40:10 2015 +0000 util: rework _MSC_VER >= 1200 checks Replace the _MSC_VER >= 1200 with defined (_MSC_VER) and compact if/else statements. We require MSVC 2008 or later with commit 46110c5d564. Signed-off-by: Emil Velikov Reviewed-by: Brian Paul Reviewed-by: Jose Fonseca --- src/util/macros.h | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/util/macros.h b/src/util/macros.h index b862bfd..63daba3 100644 --- a/src/util/macros.h +++ b/src/util/macros.h @@ -73,15 +73,13 @@ do { \ assert(!str); \ __builtin_unreachable(); \ } while (0) -#elif _MSC_VER >= 1200 +#elif defined (_MSC_VER) #define unreachable(str) \ do { \ assert(!str); \ __assume(0); \ } while (0) -#endif - -#ifndef unreachable +#else #define unreachable(str) assert(!str) #endif @@ -99,7 +97,7 @@ do { \ #define assume(expr) ((expr) ? ((void) 0) \ : (assert(!"assumption failed"), \ __builtin_unreachable())) -#elif _MSC_VER >= 1200 +#elif defined (_MSC_VER) #define assume(expr) __assume(expr) #else #define assume(expr) assert(expr) From evelikov at kemper.freedesktop.org Fri Mar 6 17:12:46 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Fri, 6 Mar 2015 09:12:46 -0800 (PST) Subject: Mesa (master): Revert "egl/main: use c11/threads' mutex directly" Message-ID: <20150306171246.34AE476336@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 56ede80940751bfcdaf26e9c23e439d37ef0e96b URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=56ede80940751bfcdaf26e9c23e439d37ef0e96b Author: Emil Velikov Date: Fri Mar 6 17:07:40 2015 +0000 Revert "egl/main: use c11/threads' mutex directly" This reverts commit 6cee785c69a5c8d2d32b6807f9c502117f5a74b0. Not meant to go in yet. Lacking review. --- src/egl/main/Makefile.sources | 1 + src/egl/main/eglapi.c | 14 ++++----- src/egl/main/eglcurrent.c | 13 ++++---- src/egl/main/egldisplay.c | 13 ++++---- src/egl/main/egldisplay.h | 4 +-- src/egl/main/egldriver.c | 8 ++--- src/egl/main/eglglobals.c | 9 +++--- src/egl/main/eglglobals.h | 4 +-- src/egl/main/egllog.c | 18 +++++------ src/egl/main/eglmutex.h | 66 +++++++++++++++++++++++++++++++++++++++++ src/egl/main/eglscreen.c | 8 ++--- 11 files changed, 111 insertions(+), 47 deletions(-) diff --git a/src/egl/main/Makefile.sources b/src/egl/main/Makefile.sources index 75f060a..6a917e2 100644 --- a/src/egl/main/Makefile.sources +++ b/src/egl/main/Makefile.sources @@ -26,6 +26,7 @@ LIBEGL_C_FILES := \ eglmisc.h \ eglmode.c \ eglmode.h \ + eglmutex.h \ eglscreen.c \ eglscreen.h \ eglstring.c \ diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c index a74efcd..2258830 100644 --- a/src/egl/main/eglapi.c +++ b/src/egl/main/eglapi.c @@ -87,8 +87,6 @@ #include #include #include "c99_compat.h" -#include "c11/threads.h" -#include "eglcompiler.h" #include "eglglobals.h" #include "eglcontext.h" @@ -277,7 +275,7 @@ _eglLockDisplay(EGLDisplay display) { _EGLDisplay *dpy = _eglLookupDisplay(display); if (dpy) - mtx_lock(&dpy->Mutex); + _eglLockMutex(&dpy->Mutex); return dpy; } @@ -288,7 +286,7 @@ _eglLockDisplay(EGLDisplay display) static inline void _eglUnlockDisplay(_EGLDisplay *dpy) { - mtx_unlock(&dpy->Mutex); + _eglUnlockMutex(&dpy->Mutex); } @@ -898,7 +896,7 @@ eglWaitClient(void) RETURN_EGL_SUCCESS(NULL, EGL_TRUE); disp = ctx->Resource.Display; - mtx_lock(&disp->Mutex); + _eglLockMutex(&disp->Mutex); /* let bad current context imply bad current surface */ if (_eglGetContextHandle(ctx) == EGL_NO_CONTEXT || @@ -944,7 +942,7 @@ eglWaitNative(EGLint engine) RETURN_EGL_SUCCESS(NULL, EGL_TRUE); disp = ctx->Resource.Display; - mtx_lock(&disp->Mutex); + _eglLockMutex(&disp->Mutex); /* let bad current context imply bad current surface */ if (_eglGetContextHandle(ctx) == EGL_NO_CONTEXT || @@ -1459,10 +1457,10 @@ eglReleaseThread(void) t->CurrentAPIIndex = i; - mtx_lock(&disp->Mutex); + _eglLockMutex(&disp->Mutex); drv = disp->Driver; (void) drv->API.MakeCurrent(drv, disp, NULL, NULL, NULL); - mtx_unlock(&disp->Mutex); + _eglUnlockMutex(&disp->Mutex); } } diff --git a/src/egl/main/eglcurrent.c b/src/egl/main/eglcurrent.c index dc32ed4..3d49641 100644 --- a/src/egl/main/eglcurrent.c +++ b/src/egl/main/eglcurrent.c @@ -31,6 +31,7 @@ #include "c99_compat.h" #include "egllog.h" +#include "eglmutex.h" #include "eglcurrent.h" #include "eglglobals.h" @@ -46,7 +47,7 @@ static _EGLThreadInfo dummy_thread = _EGL_THREAD_INFO_INITIALIZER; #if HAVE_PTHREAD #include -static mtx_t _egl_TSDMutex = _MTX_INITIALIZER_NP; +static _EGLMutex _egl_TSDMutex = _EGL_MUTEX_INITIALIZER; static EGLBoolean _egl_TSDInitialized; static pthread_key_t _egl_TSD; static void (*_egl_FreeTSD)(_EGLThreadInfo *); @@ -75,7 +76,7 @@ static inline _EGLThreadInfo *_eglGetTSD(void) static inline void _eglFiniTSD(void) { - mtx_lock(&_egl_TSDMutex); + _eglLockMutex(&_egl_TSDMutex); if (_egl_TSDInitialized) { _EGLThreadInfo *t = _eglGetTSD(); @@ -84,18 +85,18 @@ static inline void _eglFiniTSD(void) _egl_FreeTSD((void *) t); pthread_key_delete(_egl_TSD); } - mtx_unlock(&_egl_TSDMutex); + _eglUnlockMutex(&_egl_TSDMutex); } static inline EGLBoolean _eglInitTSD(void (*dtor)(_EGLThreadInfo *)) { if (!_egl_TSDInitialized) { - mtx_lock(&_egl_TSDMutex); + _eglLockMutex(&_egl_TSDMutex); /* check again after acquiring lock */ if (!_egl_TSDInitialized) { if (pthread_key_create(&_egl_TSD, (void (*)(void *)) dtor) != 0) { - mtx_unlock(&_egl_TSDMutex); + _eglUnlockMutex(&_egl_TSDMutex); return EGL_FALSE; } _egl_FreeTSD = dtor; @@ -103,7 +104,7 @@ static inline EGLBoolean _eglInitTSD(void (*dtor)(_EGLThreadInfo *)) _egl_TSDInitialized = EGL_TRUE; } - mtx_unlock(&_egl_TSDMutex); + _eglUnlockMutex(&_egl_TSDMutex); } return EGL_TRUE; diff --git a/src/egl/main/egldisplay.c b/src/egl/main/egldisplay.c index b7a5b8f..a167ae5 100644 --- a/src/egl/main/egldisplay.c +++ b/src/egl/main/egldisplay.c @@ -35,14 +35,13 @@ #include #include #include -#include "c11/threads.h" - #include "eglcontext.h" #include "eglcurrent.h" #include "eglsurface.h" #include "egldisplay.h" #include "egldriver.h" #include "eglglobals.h" +#include "eglmutex.h" #include "egllog.h" /* Includes for _eglNativePlatformDetectNativeDisplay */ @@ -261,7 +260,7 @@ _eglFindDisplay(_EGLPlatformType plat, void *plat_dpy) if (plat == _EGL_INVALID_PLATFORM) return NULL; - mtx_lock(_eglGlobal.Mutex); + _eglLockMutex(_eglGlobal.Mutex); /* search the display list first */ dpy = _eglGlobal.DisplayList; @@ -275,7 +274,7 @@ _eglFindDisplay(_EGLPlatformType plat, void *plat_dpy) if (!dpy) { dpy = calloc(1, sizeof(_EGLDisplay)); if (dpy) { - mtx_init(&dpy->Mutex, mtx_plain); + _eglInitMutex(&dpy->Mutex); dpy->Platform = plat; dpy->PlatformDisplay = plat_dpy; @@ -285,7 +284,7 @@ _eglFindDisplay(_EGLPlatformType plat, void *plat_dpy) } } - mtx_unlock(_eglGlobal.Mutex); + _eglUnlockMutex(_eglGlobal.Mutex); return dpy; } @@ -345,14 +344,14 @@ _eglCheckDisplayHandle(EGLDisplay dpy) { _EGLDisplay *cur; - mtx_lock(_eglGlobal.Mutex); + _eglLockMutex(_eglGlobal.Mutex); cur = _eglGlobal.DisplayList; while (cur) { if (cur == (_EGLDisplay *) dpy) break; cur = cur->Next; } - mtx_unlock(_eglGlobal.Mutex); + _eglUnlockMutex(_eglGlobal.Mutex); return (cur != NULL); } diff --git a/src/egl/main/egldisplay.h b/src/egl/main/egldisplay.h index 5a845d8..9c3c8c7 100644 --- a/src/egl/main/egldisplay.h +++ b/src/egl/main/egldisplay.h @@ -32,10 +32,10 @@ #define EGLDISPLAY_INCLUDED #include "c99_compat.h" -#include "c11/threads.h" #include "egltypedefs.h" #include "egldefines.h" +#include "eglmutex.h" #include "eglarray.h" @@ -132,7 +132,7 @@ struct _egl_display /* used to link displays */ _EGLDisplay *Next; - mtx_t Mutex; + _EGLMutex Mutex; _EGLPlatformType Platform; /**< The type of the platform display */ void *PlatformDisplay; /**< A pointer to the platform display */ diff --git a/src/egl/main/egldriver.c b/src/egl/main/egldriver.c index 6983af9..e6a61f3 100644 --- a/src/egl/main/egldriver.c +++ b/src/egl/main/egldriver.c @@ -37,13 +37,13 @@ #include #include #include -#include "c11/threads.h" #include "eglstring.h" #include "egldefines.h" #include "egldisplay.h" #include "egldriver.h" #include "egllog.h" +#include "eglmutex.h" #if defined(_EGL_OS_UNIX) #include @@ -63,7 +63,7 @@ typedef struct _egl_module { _EGLDriver *Driver; } _EGLModule; -static mtx_t _eglModuleMutex = _MTX_INITIALIZER_NP; +static _EGLMutex _eglModuleMutex = _EGL_MUTEX_INITIALIZER; static _EGLArray *_eglModules; const struct { @@ -616,7 +616,7 @@ _eglMatchDriver(_EGLDisplay *dpy, EGLBoolean test_only) assert(!dpy->Initialized); - mtx_lock(&_eglModuleMutex); + _eglLockMutex(&_eglModuleMutex); /* set options */ dpy->Options.TestOnly = test_only; @@ -628,7 +628,7 @@ _eglMatchDriver(_EGLDisplay *dpy, EGLBoolean test_only) best_drv = _eglMatchAndInitialize(dpy); } - mtx_unlock(&_eglModuleMutex); + _eglUnlockMutex(&_eglModuleMutex); if (best_drv) { _eglLog(_EGL_DEBUG, "the best driver is %s%s", diff --git a/src/egl/main/eglglobals.c b/src/egl/main/eglglobals.c index 129bf29..56fe9e2 100644 --- a/src/egl/main/eglglobals.c +++ b/src/egl/main/eglglobals.c @@ -30,14 +30,13 @@ #include #include -#include "c11/threads.h" - #include "eglglobals.h" #include "egldisplay.h" #include "egldriver.h" +#include "eglmutex.h" -static mtx_t _eglGlobalMutex = _MTX_INITIALIZER_NP; +static _EGLMutex _eglGlobalMutex = _EGL_MUTEX_INITIALIZER; struct _egl_global _eglGlobal = { @@ -85,7 +84,7 @@ _eglAddAtExitCall(void (*func)(void)) if (func) { static EGLBoolean registered = EGL_FALSE; - mtx_lock(_eglGlobal.Mutex); + _eglLockMutex(_eglGlobal.Mutex); if (!registered) { atexit(_eglAtExit); @@ -95,6 +94,6 @@ _eglAddAtExitCall(void (*func)(void)) assert(_eglGlobal.NumAtExitCalls < ARRAY_SIZE(_eglGlobal.AtExitCalls)); _eglGlobal.AtExitCalls[_eglGlobal.NumAtExitCalls++] = func; - mtx_unlock(_eglGlobal.Mutex); + _eglUnlockMutex(_eglGlobal.Mutex); } } diff --git a/src/egl/main/eglglobals.h b/src/egl/main/eglglobals.h index 04b9609..a8cf6d6 100644 --- a/src/egl/main/eglglobals.h +++ b/src/egl/main/eglglobals.h @@ -32,9 +32,9 @@ #define EGLGLOBALS_INCLUDED #include -#include "c11/threads.h" #include "egltypedefs.h" +#include "eglmutex.h" /** @@ -42,7 +42,7 @@ */ struct _egl_global { - mtx_t *Mutex; + _EGLMutex *Mutex; /* the list of all displays */ _EGLDisplay *DisplayList; diff --git a/src/egl/main/egllog.c b/src/egl/main/egllog.c index 1877d8b..babab07 100644 --- a/src/egl/main/egllog.c +++ b/src/egl/main/egllog.c @@ -38,24 +38,24 @@ #include #include #include -#include "c11/threads.h" #include "egllog.h" #include "eglstring.h" +#include "eglmutex.h" #define MAXSTRING 1000 #define FALLBACK_LOG_LEVEL _EGL_WARNING static struct { - mtx_t mutex; + _EGLMutex mutex; EGLBoolean initialized; EGLint level; _EGLLogProc logger; EGLint num_messages; } logging = { - _MTX_INITIALIZER_NP, + _EGL_MUTEX_INITIALIZER, EGL_FALSE, FALLBACK_LOG_LEVEL, NULL, @@ -82,7 +82,7 @@ _eglSetLogProc(_EGLLogProc logger) { EGLint num_messages = 0; - mtx_lock(&logging.mutex); + _eglLockMutex(&logging.mutex); if (logging.logger != logger) { logging.logger = logger; @@ -91,7 +91,7 @@ _eglSetLogProc(_EGLLogProc logger) logging.num_messages = 0; } - mtx_unlock(&logging.mutex); + _eglUnlockMutex(&logging.mutex); if (num_messages) _eglLog(_EGL_DEBUG, @@ -111,9 +111,9 @@ _eglSetLogLevel(EGLint level) case _EGL_WARNING: case _EGL_INFO: case _EGL_DEBUG: - mtx_lock(&logging.mutex); + _eglLockMutex(&logging.mutex); logging.level = level; - mtx_unlock(&logging.mutex); + _eglUnlockMutex(&logging.mutex); break; default: break; @@ -188,7 +188,7 @@ _eglLog(EGLint level, const char *fmtStr, ...) if (level > logging.level || level < 0) return; - mtx_lock(&logging.mutex); + _eglLockMutex(&logging.mutex); if (logging.logger) { va_start(args, fmtStr); @@ -201,7 +201,7 @@ _eglLog(EGLint level, const char *fmtStr, ...) logging.num_messages++; } - mtx_unlock(&logging.mutex); + _eglUnlockMutex(&logging.mutex); if (level == _EGL_FATAL) exit(1); /* or abort()? */ diff --git a/src/egl/main/eglmutex.h b/src/egl/main/eglmutex.h new file mode 100644 index 0000000..b58f0e3 --- /dev/null +++ b/src/egl/main/eglmutex.h @@ -0,0 +1,66 @@ +/************************************************************************** + * + * Copyright 2009 Chia-I Wu + * 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 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. + * + **************************************************************************/ + + +#ifndef EGLMUTEX_INCLUDED +#define EGLMUTEX_INCLUDED + +#include "c99_compat.h" + +#include "eglcompiler.h" + +#include "c11/threads.h" + +typedef mtx_t _EGLMutex; + +static inline void _eglInitMutex(_EGLMutex *m) +{ + mtx_init(m, mtx_plain); +} + +static inline void +_eglDestroyMutex(_EGLMutex *m) +{ + mtx_destroy(m); +} + +static inline void +_eglLockMutex(_EGLMutex *m) +{ + mtx_lock(m); +} + +static inline void +_eglUnlockMutex(_EGLMutex *m) +{ + mtx_unlock(m); +} + +#define _EGL_MUTEX_INITIALIZER _MTX_INITIALIZER_NP + + +#endif /* EGLMUTEX_INCLUDED */ diff --git a/src/egl/main/eglscreen.c b/src/egl/main/eglscreen.c index 42ac621..b8f2b39 100644 --- a/src/egl/main/eglscreen.c +++ b/src/egl/main/eglscreen.c @@ -44,20 +44,20 @@ #include #include #include -#include "c11/threads.h" #include "egldisplay.h" #include "eglcurrent.h" #include "eglmode.h" #include "eglsurface.h" #include "eglscreen.h" +#include "eglmutex.h" #ifdef EGL_MESA_screen_surface /* ugh, no atomic op? */ -static mtx_t _eglNextScreenHandleMutex = _MTX_INITIALIZER_NP; +static _EGLMutex _eglNextScreenHandleMutex = _EGL_MUTEX_INITIALIZER; static EGLScreenMESA _eglNextScreenHandle = 1; @@ -70,10 +70,10 @@ _eglAllocScreenHandle(void) { EGLScreenMESA s; - mtx_lock(&_eglNextScreenHandleMutex); + _eglLockMutex(&_eglNextScreenHandleMutex); s = _eglNextScreenHandle; _eglNextScreenHandle += _EGL_SCREEN_MAX_MODES; - mtx_unlock(&_eglNextScreenHandleMutex); + _eglUnlockMutex(&_eglNextScreenHandleMutex); return s; } From evelikov at kemper.freedesktop.org Fri Mar 6 17:12:46 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Fri, 6 Mar 2015 09:12:46 -0800 (PST) Subject: Mesa (master): Revert "glx: remove final reference to THREADS" Message-ID: <20150306171246.1B9CD7633A@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 8f2eaae10c199ed8347e96a9057a580b768c62df URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=8f2eaae10c199ed8347e96a9057a580b768c62df Author: Emil Velikov Date: Fri Mar 6 17:07:23 2015 +0000 Revert "glx: remove final reference to THREADS" This reverts commit 8b15a883e0ba72c9156d7192a798bb272e0bc528. Not meant to go in yet. Lacking review. --- src/glx/glxcurrent.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/glx/glxcurrent.c b/src/glx/glxcurrent.c index 86fb658..dc2acd5 100644 --- a/src/glx/glxcurrent.c +++ b/src/glx/glxcurrent.c @@ -138,6 +138,10 @@ __glXGetCurrentContext(void) # endif /* defined( GLX_USE_TLS ) */ +#elif defined( THREADS ) + +#error Unknown threading method specified. + #else /* not thread safe */ From evelikov at kemper.freedesktop.org Fri Mar 6 17:12:46 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Fri, 6 Mar 2015 09:12:46 -0800 (PST) Subject: Mesa (master): Revert "configure: require pthreads for POSIX builds" Message-ID: <20150306171246.23D237633D@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 3b1d69910dcee3f53e827f1a10adb93992b10a05 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=3b1d69910dcee3f53e827f1a10adb93992b10a05 Author: Emil Velikov Date: Fri Mar 6 17:07:29 2015 +0000 Revert "configure: require pthreads for POSIX builds" This reverts commit 50714cec2b50c7836841c09f04bfe875de00ae1d. Not meant to go in yet. Lacking review. --- configure.ac | 3 --- 1 file changed, 3 deletions(-) diff --git a/configure.ac b/configure.ac index 4989444..90c7737 100644 --- a/configure.ac +++ b/configure.ac @@ -657,9 +657,6 @@ mingw*) ;; *) AX_PTHREAD - if test "x$ax_pthread_ok" = xno; then - AC_MSG_ERROR([Building mesa on this platform requires pthreads]) - fi ;; esac dnl AX_PTHREADS leaves PTHREAD_LIBS empty for gcc and sets PTHREAD_CFLAGS From evelikov at kemper.freedesktop.org Fri Mar 6 17:12:46 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Fri, 6 Mar 2015 09:12:46 -0800 (PST) Subject: Mesa (master): Revert "glx: remove support for non-multithreaded platforms " Message-ID: <20150306171246.1576776336@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 5e3276f5c7bf1a363de710709737624634389858 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=5e3276f5c7bf1a363de710709737624634389858 Author: Emil Velikov Date: Fri Mar 6 17:07:11 2015 +0000 Revert "glx: remove support for non-multithreaded platforms" This reverts commit 38591295cd4b68f89f257b20f476f98de3772a47. Not meant to go in yet. Lacking review. --- docs/dispatch.html | 7 +++++-- src/glx/glxclient.h | 18 +++++++++++++++++- src/glx/glxcurrent.c | 11 +++++++++++ src/glx/tests/fake_glx_screen.cpp | 2 +- 4 files changed, 34 insertions(+), 4 deletions(-) diff --git a/docs/dispatch.html b/docs/dispatch.html index 77cfba3..aacd01e 100644 --- a/docs/dispatch.html +++ b/docs/dispatch.html @@ -185,6 +185,8 @@ ways that the dispatch table pointer can be accessed. There are four different methods that can be used:

      +
    1. Using _glapi_Dispatch directly in builds for non-multithreaded +environments.
    2. Using _glapi_Dispatch and _glapi_get_dispatch in multithreaded environments.
    3. Using _glapi_Dispatch and pthread_getspecific in @@ -202,8 +204,9 @@ terribly relevant.

      few preprocessor defines.

        -
      • If GLX_USE_TLS is defined, method #3 is used.
      • -
      • If HAVE_PTHREAD is defined, method #2 is used.
      • +
      • If GLX_USE_TLS is defined, method #4 is used.
      • +
      • If HAVE_PTHREAD is defined, method #3 is used.
      • +
      • If WIN32_THREADS is defined, method #2 is used.
      • If none of the preceding are defined, method #1 is used.
      diff --git a/src/glx/glxclient.h b/src/glx/glxclient.h index 30c9e52..122ae5d 100644 --- a/src/glx/glxclient.h +++ b/src/glx/glxclient.h @@ -47,11 +47,13 @@ #include #include #include -#include #include #include "GL/glxproto.h" #include "glxconfig.h" #include "glxhash.h" +#if defined( HAVE_PTHREAD ) +# include +#endif #include "util/macros.h" #include "glxextensions.h" @@ -627,6 +629,7 @@ extern void __glXPreferEGL(int state); extern int __glXDebug; /* This is per-thread storage in an MT environment */ +#if defined( HAVE_PTHREAD ) extern void __glXSetCurrentContext(struct glx_context * c); @@ -643,6 +646,14 @@ extern struct glx_context *__glXGetCurrentContext(void); # endif /* defined( GLX_USE_TLS ) */ +#else + +extern struct glx_context *__glXcurrentContext; +#define __glXGetCurrentContext() __glXcurrentContext +#define __glXSetCurrentContext(gc) __glXcurrentContext = gc + +#endif /* defined( HAVE_PTHREAD ) */ + extern void __glXSetCurrentContextNull(void); @@ -650,9 +661,14 @@ extern void __glXSetCurrentContextNull(void); ** Global lock for all threads in this address space using the GLX ** extension */ +#if defined( HAVE_PTHREAD ) extern pthread_mutex_t __glXmutex; #define __glXLock() pthread_mutex_lock(&__glXmutex) #define __glXUnlock() pthread_mutex_unlock(&__glXmutex) +#else +#define __glXLock() +#define __glXUnlock() +#endif /* ** Setup for a command. Initialize the extension for dpy if necessary. diff --git a/src/glx/glxcurrent.c b/src/glx/glxcurrent.c index 7f47a42..86fb658 100644 --- a/src/glx/glxcurrent.c +++ b/src/glx/glxcurrent.c @@ -33,7 +33,9 @@ * Client-side GLX interface for current context management. */ +#ifdef HAVE_PTHREAD #include +#endif #include "glxclient.h" @@ -65,6 +67,8 @@ struct glx_context dummyContext = { * Current context management and locking */ +#if defined( HAVE_PTHREAD ) + _X_HIDDEN pthread_mutex_t __glXmutex = PTHREAD_MUTEX_INITIALIZER; # if defined( GLX_USE_TLS ) @@ -134,6 +138,13 @@ __glXGetCurrentContext(void) # endif /* defined( GLX_USE_TLS ) */ +#else + +/* not thread safe */ +_X_HIDDEN struct glx_context *__glXcurrentContext = &dummyContext; + +#endif + _X_HIDDEN void __glXSetCurrentContextNull(void) diff --git a/src/glx/tests/fake_glx_screen.cpp b/src/glx/tests/fake_glx_screen.cpp index db20749..ccb1afa 100644 --- a/src/glx/tests/fake_glx_screen.cpp +++ b/src/glx/tests/fake_glx_screen.cpp @@ -77,7 +77,7 @@ indirect_create_context_attribs(struct glx_screen *base, __thread void *__glX_tls_Context = NULL; -#if !defined(GLX_USE_TLS) +#if defined(HAVE_PTHREAD) && !defined(GLX_USE_TLS) extern "C" struct glx_context * __glXGetCurrentContext() { From evelikov at kemper.freedesktop.org Fri Mar 6 17:12:46 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Fri, 6 Mar 2015 09:12:46 -0800 (PST) Subject: Mesa (master): Revert "egl/main: convert thread management to use c11 threads" Message-ID: <20150306171246.2B09676336@kemper.freedesktop.org> Module: Mesa Branch: master Commit: eb14d28e6db25eeecc89faf51837c92cc3dafbed URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=eb14d28e6db25eeecc89faf51837c92cc3dafbed Author: Emil Velikov Date: Fri Mar 6 17:07:34 2015 +0000 Revert "egl/main: convert thread management to use c11 threads" This reverts commit 33eff853363d7eba5e61b00431b95f7aa0d7b0a5. Not meant to go in yet. Lacking review. --- src/egl/main/eglcurrent.c | 48 +++++++++++++++++++++++++++++++++++++++------ 1 file changed, 42 insertions(+), 6 deletions(-) diff --git a/src/egl/main/eglcurrent.c b/src/egl/main/eglcurrent.c index 5d8cae4..dc32ed4 100644 --- a/src/egl/main/eglcurrent.c +++ b/src/egl/main/eglcurrent.c @@ -29,7 +29,6 @@ #include #include #include "c99_compat.h" -#include "c11/threads.h" #include "egllog.h" #include "eglcurrent.h" @@ -42,9 +41,14 @@ /* a fallback thread info to guarantee that every thread always has one */ static _EGLThreadInfo dummy_thread = _EGL_THREAD_INFO_INITIALIZER; + + +#if HAVE_PTHREAD +#include + static mtx_t _egl_TSDMutex = _MTX_INITIALIZER_NP; static EGLBoolean _egl_TSDInitialized; -static tss_t _egl_TSD; +static pthread_key_t _egl_TSD; static void (*_egl_FreeTSD)(_EGLThreadInfo *); #ifdef GLX_USE_TLS @@ -54,7 +58,7 @@ static __thread const _EGLThreadInfo *_egl_TLS static inline void _eglSetTSD(const _EGLThreadInfo *t) { - tss_set(_egl_TSD, (const void *) t); + pthread_setspecific(_egl_TSD, (const void *) t); #ifdef GLX_USE_TLS _egl_TLS = t; #endif @@ -65,7 +69,7 @@ static inline _EGLThreadInfo *_eglGetTSD(void) #ifdef GLX_USE_TLS return (_EGLThreadInfo *) _egl_TLS; #else - return (_EGLThreadInfo *) tss_get(_egl_TSD); + return (_EGLThreadInfo *) pthread_getspecific(_egl_TSD); #endif } @@ -78,7 +82,7 @@ static inline void _eglFiniTSD(void) _egl_TSDInitialized = EGL_FALSE; if (t && _egl_FreeTSD) _egl_FreeTSD((void *) t); - tss_delete(_egl_TSD); + pthread_key_delete(_egl_TSD); } mtx_unlock(&_egl_TSDMutex); } @@ -90,7 +94,7 @@ static inline EGLBoolean _eglInitTSD(void (*dtor)(_EGLThreadInfo *)) /* check again after acquiring lock */ if (!_egl_TSDInitialized) { - if (tss_create(&_egl_TSD, (void (*)(void *)) dtor) != thrd_success) { + if (pthread_key_create(&_egl_TSD, (void (*)(void *)) dtor) != 0) { mtx_unlock(&_egl_TSDMutex); return EGL_FALSE; } @@ -105,6 +109,38 @@ static inline EGLBoolean _eglInitTSD(void (*dtor)(_EGLThreadInfo *)) return EGL_TRUE; } +#else /* HAVE_PTHREAD */ +static const _EGLThreadInfo *_egl_TSD; +static void (*_egl_FreeTSD)(_EGLThreadInfo *); + +static inline void _eglSetTSD(const _EGLThreadInfo *t) +{ + _egl_TSD = t; +} + +static inline _EGLThreadInfo *_eglGetTSD(void) +{ + return (_EGLThreadInfo *) _egl_TSD; +} + +static inline void _eglFiniTSD(void) +{ + if (_egl_FreeTSD && _egl_TSD) + _egl_FreeTSD((_EGLThreadInfo *) _egl_TSD); +} + +static inline EGLBoolean _eglInitTSD(void (*dtor)(_EGLThreadInfo *)) +{ + if (!_egl_FreeTSD && dtor) { + _egl_FreeTSD = dtor; + _eglAddAtExitCall(_eglFiniTSD); + } + return EGL_TRUE; +} + +#endif /* !HAVE_PTHREAD */ + + static void _eglInitThreadInfo(_EGLThreadInfo *t) { From olv at kemper.freedesktop.org Fri Mar 6 19:29:20 2015 From: olv at kemper.freedesktop.org (Chia-I Wu) Date: Fri, 6 Mar 2015 11:29:20 -0800 (PST) Subject: Mesa (master): ilo: do not check for interleaved_samples Message-ID: <20150306192920.EF4C476336@kemper.freedesktop.org> Module: Mesa Branch: master Commit: dda482384446dae9b48077a2e1bd51b3c1fce8fc URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=dda482384446dae9b48077a2e1bd51b3c1fce8fc Author: Chia-I Wu Date: Fri Mar 6 15:04:47 2015 +0800 ilo: do not check for interleaved_samples interleaved_samples is only zero-initialized when layout_want_mcs() is called. We should not check for it. There is also no need to. --- src/gallium/drivers/ilo/ilo_layout.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/gallium/drivers/ilo/ilo_layout.c b/src/gallium/drivers/ilo/ilo_layout.c index 8f83ccb..a99e445 100644 --- a/src/gallium/drivers/ilo/ilo_layout.c +++ b/src/gallium/drivers/ilo/ilo_layout.c @@ -737,8 +737,7 @@ layout_want_mcs(struct ilo_layout *layout, * "This field must be set to 0 for all SINT MSRTs when all RT channels * are not written" */ - if (templ->nr_samples > 1 && !layout->interleaved_samples && - !util_format_is_pure_sint(templ->format)) { + if (templ->nr_samples > 1 && !util_format_is_pure_sint(templ->format)) { want_mcs = true; } else if (templ->nr_samples <= 1) { /* From olv at kemper.freedesktop.org Fri Mar 6 19:29:21 2015 From: olv at kemper.freedesktop.org (Chia-I Wu) Date: Fri, 6 Mar 2015 11:29:21 -0800 (PST) Subject: Mesa (master): ilo: fix padding of linear sampler views Message-ID: <20150306192921.0B7427633A@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 35b713ad75c9d6be4ad357244b59b39d80dcc77f URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=35b713ad75c9d6be4ad357244b59b39d80dcc77f Author: Chia-I Wu Date: Fri Mar 6 15:10:45 2015 +0800 ilo: fix padding of linear sampler views Should use the temporary variable in the loop instead of layout->bo_height. --- src/gallium/drivers/ilo/ilo_layout.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/gallium/drivers/ilo/ilo_layout.c b/src/gallium/drivers/ilo/ilo_layout.c index a99e445..2c78dc6 100644 --- a/src/gallium/drivers/ilo/ilo_layout.c +++ b/src/gallium/drivers/ilo/ilo_layout.c @@ -908,10 +908,8 @@ layout_calculate_bo_size(struct ilo_layout *layout, */ if (ilo_dev_gen(params->dev) >= ILO_GEN(7.5) && (params->templ->bind & PIPE_BIND_SAMPLER_VIEW) && - layout->tiling == GEN6_TILING_NONE) { - layout->bo_height += - (64 + layout->bo_stride - 1) / layout->bo_stride; - } + layout->tiling == GEN6_TILING_NONE) + h += (64 + layout->bo_stride - 1) / layout->bo_stride; /* * From the Sandy Bridge PRM, volume 4 part 1, page 81: From olv at kemper.freedesktop.org Fri Mar 6 19:29:21 2015 From: olv at kemper.freedesktop.org (Chia-I Wu) Date: Fri, 6 Mar 2015 11:29:21 -0800 (PST) Subject: Mesa (master): ilo: add generic ilo_render_3dprimitive() Message-ID: <20150306192921.28CC176336@kemper.freedesktop.org> Module: Mesa Branch: master Commit: ba5670fc500cce59a76e241ab384caaf5502e391 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=ba5670fc500cce59a76e241ab384caaf5502e391 Author: Chia-I Wu Date: Sat Mar 7 01:44:33 2015 +0800 ilo: add generic ilo_render_3dprimitive() It replaces gen[6-8]_3dprimitive(). --- src/gallium/drivers/ilo/ilo_render_gen.h | 24 ++++++++++++++++++++++++ src/gallium/drivers/ilo/ilo_render_gen6.c | 18 ++---------------- src/gallium/drivers/ilo/ilo_render_gen7.c | 21 ++------------------- src/gallium/drivers/ilo/ilo_render_gen8.c | 19 +------------------ 4 files changed, 29 insertions(+), 53 deletions(-) diff --git a/src/gallium/drivers/ilo/ilo_render_gen.h b/src/gallium/drivers/ilo/ilo_render_gen.h index 9657798..f2bcf7a 100644 --- a/src/gallium/drivers/ilo/ilo_render_gen.h +++ b/src/gallium/drivers/ilo/ilo_render_gen.h @@ -30,6 +30,7 @@ #include "ilo_common.h" #include "ilo_builder.h" +#include "ilo_builder_3d.h" #include "ilo_builder_render.h" #include "ilo_state.h" #include "ilo_render.h" @@ -374,6 +375,29 @@ ilo_render_pipe_control(struct ilo_render *r, uint32_t dw1) r->state.deferred_pipe_control_dw1 &= ~dw1; } +/** + * A convenient wrapper for gen{6,7}_3DPRIMITIVE(). + */ +static inline void +ilo_render_3dprimitive(struct ilo_render *r, + const struct pipe_draw_info *info, + const struct ilo_ib_state *ib) +{ + ILO_DEV_ASSERT(r->dev, 6, 8); + + if (r->state.deferred_pipe_control_dw1) + ilo_render_pipe_control(r, r->state.deferred_pipe_control_dw1); + + /* 3DPRIMITIVE */ + if (ilo_dev_gen(r->dev) >= ILO_GEN(7)) + gen7_3DPRIMITIVE(r->builder, info, ib); + else + gen6_3DPRIMITIVE(r->builder, info, ib); + + r->state.current_pipe_control_dw1 = 0; + assert(!r->state.deferred_pipe_control_dw1); +} + void gen6_wa_pre_pipe_control(struct ilo_render *r, uint32_t dw1); diff --git a/src/gallium/drivers/ilo/ilo_render_gen6.c b/src/gallium/drivers/ilo/ilo_render_gen6.c index 898b98a..902d398 100644 --- a/src/gallium/drivers/ilo/ilo_render_gen6.c +++ b/src/gallium/drivers/ilo/ilo_render_gen6.c @@ -38,20 +38,6 @@ #include "ilo_state.h" #include "ilo_render_gen.h" -static void -gen6_3dprimitive(struct ilo_render *r, - const struct pipe_draw_info *info, - const struct ilo_ib_state *ib) -{ - ILO_DEV_ASSERT(r->dev, 6, 6); - - /* 3DPRIMITIVE */ - gen6_3DPRIMITIVE(r->builder, info, ib); - - r->state.current_pipe_control_dw1 = 0; - assert(!r->state.deferred_pipe_control_dw1); -} - /** * This should be called before PIPE_CONTROL. */ @@ -835,7 +821,7 @@ ilo_render_emit_draw_commands_gen6(struct ilo_render *render, gen6_draw_sf_rect(render, vec, session); gen6_draw_vf(render, vec, session); - gen6_3dprimitive(render, vec->draw, &vec->ib); + ilo_render_3dprimitive(render, vec->draw, &vec->ib); } static void @@ -980,7 +966,7 @@ ilo_render_emit_rectlist_commands_gen6(struct ilo_render *r, gen6_3DSTATE_DRAWING_RECTANGLE(r->builder, 0, 0, blitter->fb.width, blitter->fb.height); - gen6_3dprimitive(r, &blitter->draw, NULL); + ilo_render_3dprimitive(r, &blitter->draw, NULL); } int diff --git a/src/gallium/drivers/ilo/ilo_render_gen7.c b/src/gallium/drivers/ilo/ilo_render_gen7.c index a8a222d..8801d14 100644 --- a/src/gallium/drivers/ilo/ilo_render_gen7.c +++ b/src/gallium/drivers/ilo/ilo_render_gen7.c @@ -36,23 +36,6 @@ #include "ilo_render_gen.h" static void -gen7_3dprimitive(struct ilo_render *r, - const struct pipe_draw_info *info, - const struct ilo_ib_state *ib) -{ - ILO_DEV_ASSERT(r->dev, 7, 7.5); - - if (r->state.deferred_pipe_control_dw1) - ilo_render_pipe_control(r, r->state.deferred_pipe_control_dw1); - - /* 3DPRIMITIVE */ - gen7_3DPRIMITIVE(r->builder, info, ib); - - r->state.current_pipe_control_dw1 = 0; - r->state.deferred_pipe_control_dw1 = 0; -} - -static void gen7_wa_post_3dstate_push_constant_alloc_ps(struct ilo_render *r) { /* @@ -671,7 +654,7 @@ ilo_render_emit_draw_commands_gen7(struct ilo_render *render, gen6_draw_sf_rect(render, vec, session); gen6_draw_vf(render, vec, session); - gen7_3dprimitive(render, vec->draw, &vec->ib); + ilo_render_3dprimitive(render, vec->draw, &vec->ib); } static void @@ -871,7 +854,7 @@ ilo_render_emit_rectlist_commands_gen7(struct ilo_render *r, if (ilo_dev_gen(r->dev) == ILO_GEN(7)) gen7_wa_post_ps_and_later(r); - gen7_3dprimitive(r, &blitter->draw, NULL); + ilo_render_3dprimitive(r, &blitter->draw, NULL); } int diff --git a/src/gallium/drivers/ilo/ilo_render_gen8.c b/src/gallium/drivers/ilo/ilo_render_gen8.c index 49c5e7a..f6d8d66 100644 --- a/src/gallium/drivers/ilo/ilo_render_gen8.c +++ b/src/gallium/drivers/ilo/ilo_render_gen8.c @@ -36,23 +36,6 @@ #include "ilo_render_gen.h" static void -gen8_3dprimitive(struct ilo_render *r, - const struct pipe_draw_info *info, - const struct ilo_ib_state *ib) -{ - ILO_DEV_ASSERT(r->dev, 8, 8); - - if (r->state.deferred_pipe_control_dw1) - ilo_render_pipe_control(r, r->state.deferred_pipe_control_dw1); - - /* 3DPRIMITIVE */ - gen7_3DPRIMITIVE(r->builder, info, ib); - - r->state.current_pipe_control_dw1 = 0; - r->state.deferred_pipe_control_dw1 = 0; -} - -static void gen8_wa_pre_depth(struct ilo_render *r) { ILO_DEV_ASSERT(r->dev, 8, 8); @@ -298,7 +281,7 @@ ilo_render_emit_draw_commands_gen8(struct ilo_render *render, gen6_draw_sf_rect(render, vec, session); gen8_draw_vf(render, vec, session); - gen8_3dprimitive(render, vec->draw, &vec->ib); + ilo_render_3dprimitive(render, vec->draw, &vec->ib); } int From olv at kemper.freedesktop.org Fri Mar 6 19:29:21 2015 From: olv at kemper.freedesktop.org (Chia-I Wu) Date: Fri, 6 Mar 2015 11:29:21 -0800 (PST) Subject: Mesa (master): ilo: clean up Gen6 WAs Message-ID: <20150306192921.335B876336@kemper.freedesktop.org> Module: Mesa Branch: master Commit: bf061a3d2ec00aa486cda0fb4af04e50e8522868 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=bf061a3d2ec00aa486cda0fb4af04e50e8522868 Author: Chia-I Wu Date: Sat Mar 7 01:55:15 2015 +0800 ilo: clean up Gen6 WAs Add a help function for each WA and make PIPE_CONTROL flags match the WA descriptions. Call gen6_wa_pre_pipe_contro() only before PIPE_CONTROLs. Fix missing gen6_wa_pre_3dstate_vs_toggle() in the rectlist path. --- src/gallium/drivers/ilo/ilo_render_gen6.c | 96 +++++++++++++++++++---------- 1 file changed, 62 insertions(+), 34 deletions(-) diff --git a/src/gallium/drivers/ilo/ilo_render_gen6.c b/src/gallium/drivers/ilo/ilo_render_gen6.c index 902d398..1c101ac 100644 --- a/src/gallium/drivers/ilo/ilo_render_gen6.c +++ b/src/gallium/drivers/ilo/ilo_render_gen6.c @@ -112,6 +112,26 @@ gen6_wa_pre_non_pipelined(struct ilo_render *r) } static void +gen6_wa_post_3dstate_urb_no_gs(struct ilo_render *r) +{ + /* + * From the Sandy Bridge PRM, volume 2 part 1, page 27: + * + * "Because of a urb corruption caused by allocating a previous + * gsunit's urb entry to vsunit software is required to send a + * "GS NULL Fence" (Send URB fence with VS URB size == 1 and GS URB + * size == 0) plus a dummy DRAW call before any case where VS will + * be taking over GS URB space." + */ + const uint32_t dw1 = GEN6_PIPE_CONTROL_CS_STALL; + + if ((r->state.current_pipe_control_dw1 & dw1) != dw1) + gen6_wa_pre_pipe_control(r, dw1); + if ((r->state.current_pipe_control_dw1 & dw1) != dw1) + ilo_render_pipe_control(r, dw1); +} + +static void gen6_wa_post_3dstate_constant_vs(struct ilo_render *r) { /* @@ -123,9 +143,32 @@ gen6_wa_post_3dstate_constant_vs(struct ilo_render *r) GEN6_PIPE_CONTROL_INSTRUCTION_CACHE_INVALIDATE | GEN6_PIPE_CONTROL_STATE_CACHE_INVALIDATE; - gen6_wa_pre_pipe_control(r, dw1); + if ((r->state.current_pipe_control_dw1 & dw1) != dw1) + gen6_wa_pre_pipe_control(r, dw1); + if ((r->state.current_pipe_control_dw1 & dw1) != dw1) + ilo_render_pipe_control(r, dw1); +} + +static void +gen6_wa_pre_3dstate_vs_toggle(struct ilo_render *r) +{ + /* + * The classic driver has this undocumented WA: + * + * From the BSpec, 3D Pipeline > Geometry > Vertex Shader > State, + * 3DSTATE_VS, Dword 5.0 "VS Function Enable": + * + * [DevSNB] A pipeline flush must be programmed prior to a 3DSTATE_VS + * command that causes the VS Function Enable to toggle. Pipeline + * flush can be executed by sending a PIPE_CONTROL command with CS + * stall bit set and a post sync operation. + */ + const uint32_t dw1 = GEN6_PIPE_CONTROL_WRITE_IMM | + GEN6_PIPE_CONTROL_CS_STALL; if ((r->state.current_pipe_control_dw1 & dw1) != dw1) + gen6_wa_pre_pipe_control(r, dw1); + if ((r->state.current_pipe_control_dw1 & dw1) != dw1) ilo_render_pipe_control(r, dw1); } @@ -143,8 +186,8 @@ gen6_wa_pre_3dstate_wm_max_threads(struct ilo_render *r) ILO_DEV_ASSERT(r->dev, 6, 6); - gen6_wa_pre_pipe_control(r, dw1); - + if ((r->state.current_pipe_control_dw1 & dw1) != dw1) + gen6_wa_pre_pipe_control(r, dw1); if ((r->state.current_pipe_control_dw1 & dw1) != dw1) ilo_render_pipe_control(r, dw1); } @@ -165,8 +208,8 @@ gen6_wa_pre_3dstate_multisample(struct ilo_render *r) ILO_DEV_ASSERT(r->dev, 6, 6); - gen6_wa_pre_pipe_control(r, dw1); - + if ((r->state.current_pipe_control_dw1 & dw1) != dw1) + gen6_wa_pre_pipe_control(r, dw1); if ((r->state.current_pipe_control_dw1 & dw1) != dw1) ilo_render_pipe_control(r, dw1); } @@ -340,17 +383,8 @@ gen6_draw_common_urb(struct ilo_render *r, gen6_3DSTATE_URB(r->builder, vs_total_size, gs_total_size, vs_entry_size, gs_entry_size); - /* - * From the Sandy Bridge PRM, volume 2 part 1, page 27: - * - * "Because of a urb corruption caused by allocating a previous - * gsunit's urb entry to vsunit software is required to send a - * "GS NULL Fence" (Send URB fence with VS URB size == 1 and GS URB - * size == 0) plus a dummy DRAW call before any case where VS will - * be taking over GS URB space." - */ if (r->state.gs.active && !gs_active) - ilo_render_emit_flush(r); + gen6_wa_post_3dstate_urb_no_gs(r); r->state.gs.active = gs_active; } @@ -469,30 +503,24 @@ gen6_draw_vs(struct ilo_render *r, const struct ilo_state_vector *vec, struct ilo_render_draw_session *session) { - const bool emit_3dstate_vs = (DIRTY(VS) || r->instruction_bo_changed); - const bool emit_3dstate_constant_vs = session->pcb_vs_changed; - - /* - * the classic i965 does this in upload_vs_state(), citing a spec that I - * cannot find - */ - if (emit_3dstate_vs && ilo_dev_gen(r->dev) == ILO_GEN(6)) - gen6_wa_pre_non_pipelined(r); - /* 3DSTATE_CONSTANT_VS */ - if (emit_3dstate_constant_vs) { + if (session->pcb_vs_changed) { gen6_3DSTATE_CONSTANT_VS(r->builder, &r->state.vs.PUSH_CONSTANT_BUFFER, &r->state.vs.PUSH_CONSTANT_BUFFER_size, 1); + + if (ilo_dev_gen(r->dev) == ILO_GEN(6)) + gen6_wa_post_3dstate_constant_vs(r); } /* 3DSTATE_VS */ - if (emit_3dstate_vs) - gen6_3DSTATE_VS(r->builder, vec->vs); + if (DIRTY(VS) || r->instruction_bo_changed) { + if (ilo_dev_gen(r->dev) == ILO_GEN(6)) + gen6_wa_pre_3dstate_vs_toggle(r); - if (emit_3dstate_constant_vs && ilo_dev_gen(r->dev) == ILO_GEN(6)) - gen6_wa_post_3dstate_constant_vs(r); + gen6_3DSTATE_VS(r->builder, vec->vs); + } } static void @@ -829,10 +857,11 @@ gen6_rectlist_vs_to_sf(struct ilo_render *r, const struct ilo_blitter *blitter) { gen6_3DSTATE_CONSTANT_VS(r->builder, NULL, NULL, 0); - gen6_disable_3DSTATE_VS(r->builder); - gen6_wa_post_3dstate_constant_vs(r); + gen6_wa_pre_3dstate_vs_toggle(r); + gen6_disable_3DSTATE_VS(r->builder); + gen6_3DSTATE_CONSTANT_GS(r->builder, NULL, NULL, 0); gen6_disable_3DSTATE_GS(r->builder); @@ -941,9 +970,8 @@ ilo_render_emit_rectlist_commands_gen6(struct ilo_render *r, (blitter->ve.count + blitter->ve.prepend_nosrc_cso) * 4 * sizeof(float), 0); - /* 3DSTATE_URB workaround */ if (r->state.gs.active) { - ilo_render_emit_flush(r); + gen6_wa_post_3dstate_urb_no_gs(r); r->state.gs.active = false; } From olv at kemper.freedesktop.org Fri Mar 6 19:29:21 2015 From: olv at kemper.freedesktop.org (Chia-I Wu) Date: Fri, 6 Mar 2015 11:29:21 -0800 (PST) Subject: Mesa (master): ilo: add generic ilo_render_pipe_control() Message-ID: <20150306192921.19EB77633D@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 8b2eecfbf8def8ef343529f7b0378dc1b8a36ff9 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=8b2eecfbf8def8ef343529f7b0378dc1b8a36ff9 Author: Chia-I Wu Date: Sat Mar 7 01:16:47 2015 +0800 ilo: add generic ilo_render_pipe_control() It replaces gen[6-8]_pipe_control() and a direct gen6_PIPE_CONTROL() call in ilo_render_emit_flush(). --- src/gallium/drivers/ilo/ilo_render.c | 5 +--- src/gallium/drivers/ilo/ilo_render_gen.h | 33 +++++++++++++++++++++ src/gallium/drivers/ilo/ilo_render_gen6.c | 34 +++++---------------- src/gallium/drivers/ilo/ilo_render_gen7.c | 46 ++++++----------------------- src/gallium/drivers/ilo/ilo_render_gen8.c | 39 ++++-------------------- 5 files changed, 56 insertions(+), 101 deletions(-) diff --git a/src/gallium/drivers/ilo/ilo_render.c b/src/gallium/drivers/ilo/ilo_render.c index a6614f1..af18e89 100644 --- a/src/gallium/drivers/ilo/ilo_render.c +++ b/src/gallium/drivers/ilo/ilo_render.c @@ -253,10 +253,7 @@ ilo_render_emit_flush(struct ilo_render *render) if (ilo_dev_gen(render->dev) == ILO_GEN(6)) gen6_wa_pre_pipe_control(render, dw1); - gen6_PIPE_CONTROL(render->builder, dw1, NULL, 0, 0); - - render->state.current_pipe_control_dw1 |= dw1; - render->state.deferred_pipe_control_dw1 &= ~dw1; + ilo_render_pipe_control(render, dw1); assert(ilo_builder_batch_used(render->builder) <= batch_used + ilo_render_get_flush_len(render)); diff --git a/src/gallium/drivers/ilo/ilo_render_gen.h b/src/gallium/drivers/ilo/ilo_render_gen.h index 583265f..9657798 100644 --- a/src/gallium/drivers/ilo/ilo_render_gen.h +++ b/src/gallium/drivers/ilo/ilo_render_gen.h @@ -30,6 +30,7 @@ #include "ilo_common.h" #include "ilo_builder.h" +#include "ilo_builder_render.h" #include "ilo_state.h" #include "ilo_render.h" @@ -341,6 +342,38 @@ ilo_render_emit_launch_grid_surface_states(struct ilo_render *render, const struct ilo_state_vector *vec, struct ilo_render_launch_grid_session *session); +/** + * A convenient wrapper for gen6_PIPE_CONTROL(). This should be enough for + * our needs everywhere except for queries. + */ +static inline void +ilo_render_pipe_control(struct ilo_render *r, uint32_t dw1) +{ + const uint32_t write_mask = (dw1 & GEN6_PIPE_CONTROL_WRITE__MASK); + struct intel_bo *bo = (write_mask) ? r->workaround_bo : NULL; + + ILO_DEV_ASSERT(r->dev, 6, 8); + + if (write_mask) + assert(write_mask == GEN6_PIPE_CONTROL_WRITE_IMM); + + if (dw1 & GEN6_PIPE_CONTROL_CS_STALL) { + /* CS stall cannot be set alone */ + const uint32_t mask = GEN6_PIPE_CONTROL_RENDER_CACHE_FLUSH | + GEN6_PIPE_CONTROL_DEPTH_CACHE_FLUSH | + GEN6_PIPE_CONTROL_PIXEL_SCOREBOARD_STALL | + GEN6_PIPE_CONTROL_DEPTH_STALL | + GEN6_PIPE_CONTROL_WRITE__MASK; + if (!(dw1 & mask)) + dw1 |= GEN6_PIPE_CONTROL_PIXEL_SCOREBOARD_STALL; + } + + gen6_PIPE_CONTROL(r->builder, dw1, bo, 0, 0); + + r->state.current_pipe_control_dw1 |= dw1; + r->state.deferred_pipe_control_dw1 &= ~dw1; +} + void gen6_wa_pre_pipe_control(struct ilo_render *r, uint32_t dw1); diff --git a/src/gallium/drivers/ilo/ilo_render_gen6.c b/src/gallium/drivers/ilo/ilo_render_gen6.c index 7232882..898b98a 100644 --- a/src/gallium/drivers/ilo/ilo_render_gen6.c +++ b/src/gallium/drivers/ilo/ilo_render_gen6.c @@ -38,24 +38,6 @@ #include "ilo_state.h" #include "ilo_render_gen.h" -/** - * A wrapper for gen6_PIPE_CONTROL(). - */ -static void -gen6_pipe_control(struct ilo_render *r, uint32_t dw1) -{ - struct intel_bo *bo = (dw1 & GEN6_PIPE_CONTROL_WRITE__MASK) ? - r->workaround_bo : NULL; - - ILO_DEV_ASSERT(r->dev, 6, 6); - - gen6_PIPE_CONTROL(r->builder, dw1, bo, 0, 0); - - r->state.current_pipe_control_dw1 |= dw1; - - assert(!r->state.deferred_pipe_control_dw1); -} - static void gen6_3dprimitive(struct ilo_render *r, const struct pipe_draw_info *info, @@ -120,14 +102,14 @@ gen6_wa_pre_pipe_control(struct ilo_render *r, uint32_t dw1) const uint32_t direct_wa = GEN6_PIPE_CONTROL_CS_STALL | GEN6_PIPE_CONTROL_PIXEL_SCOREBOARD_STALL; - gen6_pipe_control(r, direct_wa); + ilo_render_pipe_control(r, direct_wa); } if (indirect_wa_cond && !(r->state.current_pipe_control_dw1 & GEN6_PIPE_CONTROL_WRITE__MASK)) { const uint32_t indirect_wa = GEN6_PIPE_CONTROL_WRITE_IMM; - gen6_pipe_control(r, indirect_wa); + ilo_render_pipe_control(r, indirect_wa); } } @@ -158,7 +140,7 @@ gen6_wa_post_3dstate_constant_vs(struct ilo_render *r) gen6_wa_pre_pipe_control(r, dw1); if ((r->state.current_pipe_control_dw1 & dw1) != dw1) - gen6_pipe_control(r, dw1); + ilo_render_pipe_control(r, dw1); } static void @@ -178,7 +160,7 @@ gen6_wa_pre_3dstate_wm_max_threads(struct ilo_render *r) gen6_wa_pre_pipe_control(r, dw1); if ((r->state.current_pipe_control_dw1 & dw1) != dw1) - gen6_pipe_control(r, dw1); + ilo_render_pipe_control(r, dw1); } static void @@ -200,7 +182,7 @@ gen6_wa_pre_3dstate_multisample(struct ilo_render *r) gen6_wa_pre_pipe_control(r, dw1); if ((r->state.current_pipe_control_dw1 & dw1) != dw1) - gen6_pipe_control(r, dw1); + ilo_render_pipe_control(r, dw1); } static void @@ -226,9 +208,9 @@ gen6_wa_pre_depth(struct ilo_render *r) gen6_wa_pre_pipe_control(r, GEN6_PIPE_CONTROL_DEPTH_STALL | GEN6_PIPE_CONTROL_DEPTH_CACHE_FLUSH); - gen6_pipe_control(r, GEN6_PIPE_CONTROL_DEPTH_STALL); - gen6_pipe_control(r, GEN6_PIPE_CONTROL_DEPTH_CACHE_FLUSH); - gen6_pipe_control(r, GEN6_PIPE_CONTROL_DEPTH_STALL); + ilo_render_pipe_control(r, GEN6_PIPE_CONTROL_DEPTH_STALL); + ilo_render_pipe_control(r, GEN6_PIPE_CONTROL_DEPTH_CACHE_FLUSH); + ilo_render_pipe_control(r, GEN6_PIPE_CONTROL_DEPTH_STALL); } #define DIRTY(state) (session->pipe_dirty & ILO_DIRTY_ ## state) diff --git a/src/gallium/drivers/ilo/ilo_render_gen7.c b/src/gallium/drivers/ilo/ilo_render_gen7.c index 2d3f6cf..a8a222d 100644 --- a/src/gallium/drivers/ilo/ilo_render_gen7.c +++ b/src/gallium/drivers/ilo/ilo_render_gen7.c @@ -35,34 +35,6 @@ #include "ilo_state.h" #include "ilo_render_gen.h" -/** - * A wrapper for gen6_PIPE_CONTROL(). - */ -static void -gen7_pipe_control(struct ilo_render *r, uint32_t dw1) -{ - struct intel_bo *bo = (dw1 & GEN6_PIPE_CONTROL_WRITE__MASK) ? - r->workaround_bo : NULL; - - ILO_DEV_ASSERT(r->dev, 7, 7.5); - - if (dw1 & GEN6_PIPE_CONTROL_CS_STALL) { - /* CS stall cannot be set alone */ - const uint32_t mask = GEN6_PIPE_CONTROL_RENDER_CACHE_FLUSH | - GEN6_PIPE_CONTROL_DEPTH_CACHE_FLUSH | - GEN6_PIPE_CONTROL_PIXEL_SCOREBOARD_STALL | - GEN6_PIPE_CONTROL_DEPTH_STALL | - GEN6_PIPE_CONTROL_WRITE__MASK; - if (!(dw1 & mask)) - dw1 |= GEN6_PIPE_CONTROL_PIXEL_SCOREBOARD_STALL; - } - - gen6_PIPE_CONTROL(r->builder, dw1, bo, 0, 0); - - r->state.current_pipe_control_dw1 |= dw1; - r->state.deferred_pipe_control_dw1 &= ~dw1; -} - static void gen7_3dprimitive(struct ilo_render *r, const struct pipe_draw_info *info, @@ -71,7 +43,7 @@ gen7_3dprimitive(struct ilo_render *r, ILO_DEV_ASSERT(r->dev, 7, 7.5); if (r->state.deferred_pipe_control_dw1) - gen7_pipe_control(r, r->state.deferred_pipe_control_dw1); + ilo_render_pipe_control(r, r->state.deferred_pipe_control_dw1); /* 3DPRIMITIVE */ gen7_3DPRIMITIVE(r->builder, info, ib); @@ -115,7 +87,7 @@ gen7_wa_pre_vs(struct ilo_render *r) ILO_DEV_ASSERT(r->dev, 7, 7); if ((r->state.current_pipe_control_dw1 & dw1) != dw1) - gen7_pipe_control(r, dw1); + ilo_render_pipe_control(r, dw1); } static void @@ -133,7 +105,7 @@ gen7_wa_pre_3dstate_sf_depth_bias(struct ilo_render *r) ILO_DEV_ASSERT(r->dev, 7, 7); if ((r->state.current_pipe_control_dw1 & dw1) != dw1) - gen7_pipe_control(r, dw1); + ilo_render_pipe_control(r, dw1); } static void @@ -153,7 +125,7 @@ gen7_wa_pre_3dstate_multisample(struct ilo_render *r) ILO_DEV_ASSERT(r->dev, 7, 7.5); if ((r->state.current_pipe_control_dw1 & dw1) != dw1) - gen7_pipe_control(r, dw1); + ilo_render_pipe_control(r, dw1); } static void @@ -174,7 +146,7 @@ gen7_wa_pre_depth(struct ilo_render *r) GEN6_PIPE_CONTROL_WRITE_IMM; if ((r->state.current_pipe_control_dw1 & dw1) != dw1) - gen7_pipe_control(r, dw1); + ilo_render_pipe_control(r, dw1); } /* @@ -190,9 +162,9 @@ gen7_wa_pre_depth(struct ilo_render *r) * guarantee that the pipeline from WM onwards is already flushed * (e.g., via a preceding MI_FLUSH)." */ - gen7_pipe_control(r, GEN6_PIPE_CONTROL_DEPTH_STALL); - gen7_pipe_control(r, GEN6_PIPE_CONTROL_DEPTH_CACHE_FLUSH); - gen7_pipe_control(r, GEN6_PIPE_CONTROL_DEPTH_STALL); + ilo_render_pipe_control(r, GEN6_PIPE_CONTROL_DEPTH_STALL); + ilo_render_pipe_control(r, GEN6_PIPE_CONTROL_DEPTH_CACHE_FLUSH); + ilo_render_pipe_control(r, GEN6_PIPE_CONTROL_DEPTH_STALL); } static void @@ -210,7 +182,7 @@ gen7_wa_pre_3dstate_ps_max_threads(struct ilo_render *r) ILO_DEV_ASSERT(r->dev, 7, 7.5); if ((r->state.current_pipe_control_dw1 & dw1) != dw1) - gen7_pipe_control(r, dw1); + ilo_render_pipe_control(r, dw1); } static void diff --git a/src/gallium/drivers/ilo/ilo_render_gen8.c b/src/gallium/drivers/ilo/ilo_render_gen8.c index 36fc129..49c5e7a 100644 --- a/src/gallium/drivers/ilo/ilo_render_gen8.c +++ b/src/gallium/drivers/ilo/ilo_render_gen8.c @@ -35,35 +35,6 @@ #include "ilo_state.h" #include "ilo_render_gen.h" -/** - * A wrapper for gen6_PIPE_CONTROL(). - */ -static void -gen8_pipe_control(struct ilo_render *r, uint32_t dw1) -{ - struct intel_bo *bo = (dw1 & GEN6_PIPE_CONTROL_WRITE__MASK) ? - r->workaround_bo : NULL; - - ILO_DEV_ASSERT(r->dev, 8, 8); - - if (dw1 & GEN6_PIPE_CONTROL_CS_STALL) { - /* CS stall cannot be set alone */ - const uint32_t mask = GEN6_PIPE_CONTROL_RENDER_CACHE_FLUSH | - GEN6_PIPE_CONTROL_DEPTH_CACHE_FLUSH | - GEN6_PIPE_CONTROL_PIXEL_SCOREBOARD_STALL | - GEN6_PIPE_CONTROL_DEPTH_STALL | - GEN6_PIPE_CONTROL_WRITE__MASK; - if (!(dw1 & mask)) - dw1 |= GEN6_PIPE_CONTROL_PIXEL_SCOREBOARD_STALL; - } - - gen6_PIPE_CONTROL(r->builder, dw1, bo, 0, 0); - - - r->state.current_pipe_control_dw1 |= dw1; - r->state.deferred_pipe_control_dw1 &= ~dw1; -} - static void gen8_3dprimitive(struct ilo_render *r, const struct pipe_draw_info *info, @@ -72,7 +43,7 @@ gen8_3dprimitive(struct ilo_render *r, ILO_DEV_ASSERT(r->dev, 8, 8); if (r->state.deferred_pipe_control_dw1) - gen8_pipe_control(r, r->state.deferred_pipe_control_dw1); + ilo_render_pipe_control(r, r->state.deferred_pipe_control_dw1); /* 3DPRIMITIVE */ gen7_3DPRIMITIVE(r->builder, info, ib); @@ -99,9 +70,9 @@ gen8_wa_pre_depth(struct ilo_render *r) * guarantee that the pipeline from WM onwards is already flushed * (e.g., via a preceding MI_FLUSH)." */ - gen8_pipe_control(r, GEN6_PIPE_CONTROL_DEPTH_STALL); - gen8_pipe_control(r, GEN6_PIPE_CONTROL_DEPTH_CACHE_FLUSH); - gen8_pipe_control(r, GEN6_PIPE_CONTROL_DEPTH_STALL); + ilo_render_pipe_control(r, GEN6_PIPE_CONTROL_DEPTH_STALL); + ilo_render_pipe_control(r, GEN6_PIPE_CONTROL_DEPTH_CACHE_FLUSH); + ilo_render_pipe_control(r, GEN6_PIPE_CONTROL_DEPTH_STALL); } #define DIRTY(state) (session->pipe_dirty & ILO_DIRTY_ ## state) @@ -461,7 +432,7 @@ ilo_render_emit_rectlist_commands_gen8(struct ilo_render *r, gen8_3DSTATE_WM_HZ_OP(r->builder, op, blitter->fb.width, blitter->fb.height, blitter->fb.num_samples); - gen8_pipe_control(r, GEN6_PIPE_CONTROL_WRITE_IMM); + ilo_render_pipe_control(r, GEN6_PIPE_CONTROL_WRITE_IMM); gen8_disable_3DSTATE_WM_HZ_OP(r->builder); } From evelikov at kemper.freedesktop.org Fri Mar 6 19:42:33 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Fri, 6 Mar 2015 11:42:33 -0800 (PST) Subject: Mesa (10.4): Revert "mesa: Correct backwards NULL check." Message-ID: <20150306194233.CE1AA76336@kemper.freedesktop.org> Module: Mesa Branch: 10.4 Commit: 93edf3e7dc4740e97ef42e2911ed5b9d165e6c2c URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=93edf3e7dc4740e97ef42e2911ed5b9d165e6c2c Author: Emil Velikov Date: Fri Mar 6 18:40:09 2015 +0000 Revert "mesa: Correct backwards NULL check." This reverts commit a598a9bdfe9f5d0ed35ca89a55cf74a2b678e8e1. The patch was applied without the required dependencies. --- src/mesa/main/shaderapi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c index 94f6b76..6657820 100644 --- a/src/mesa/main/shaderapi.c +++ b/src/mesa/main/shaderapi.c @@ -1704,7 +1704,7 @@ _mesa_GetProgramBinary(GLuint program, GLsizei bufSize, GLsizei *length, * * "If is NULL, then no length is returned." */ - if (length == NULL) + if (length != NULL) *length = 0; (void) binaryFormat; From evelikov at kemper.freedesktop.org Fri Mar 6 19:42:33 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Fri, 6 Mar 2015 11:42:33 -0800 (PST) Subject: Mesa (10.4): mesa: Always generate GL_INVALID_OPERATION in _mesa_GetProgramBinary Message-ID: <20150306194233.EA91776336@kemper.freedesktop.org> Module: Mesa Branch: 10.4 Commit: a369361f9e0b9d781e77a05c85462479b6db9d04 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=a369361f9e0b9d781e77a05c85462479b6db9d04 Author: Ian Romanick Date: Sun Dec 21 12:06:23 2014 -0800 mesa: Always generate GL_INVALID_OPERATION in _mesa_GetProgramBinary There are no binary formats supported, so what are you doing? At least this gives the application developer some feedback about what's going on. The spec gives no guidance about what to do in this scenario. Signed-off-by: Ian Romanick Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=87516 Reviewed-by: Kenneth Graunke Acked-by: Leight Bade (cherry picked from commit f591712efeb9a757379d1e89907e2147749aaf6c) --- src/mesa/main/shaderapi.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c index 1fec416..0ca4f58 100644 --- a/src/mesa/main/shaderapi.c +++ b/src/mesa/main/shaderapi.c @@ -1720,6 +1720,8 @@ _mesa_GetProgramBinary(GLuint program, GLsizei bufSize, GLsizei *length, } *length = 0; + _mesa_error(ctx, GL_INVALID_OPERATION, + "glGetProgramBinary(driver supports zero binary formats)"); (void) binaryFormat; (void) binary; From evelikov at kemper.freedesktop.org Fri Mar 6 19:42:34 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Fri, 6 Mar 2015 11:42:34 -0800 (PST) Subject: Mesa (10.4): mesa: cherry-pick the second half of commit 2aa71e9485a Message-ID: <20150306194234.07D9976336@kemper.freedesktop.org> Module: Mesa Branch: 10.4 Commit: 9508ca24f15e61eb7266a4358dde2f76bce17c10 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=9508ca24f15e61eb7266a4358dde2f76bce17c10 Author: Emil Velikov Date: Fri Mar 6 18:52:38 2015 +0000 mesa: cherry-pick the second half of commit 2aa71e9485a Missed out by commit 39ae85732d2(mesa: Fix error validating args for TexSubImage3D) Reported-by: Matt Turner Signed-off-by: Emil Velikov --- src/mesa/main/teximage.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c index 3c494be..a85bb94 100644 --- a/src/mesa/main/teximage.c +++ b/src/mesa/main/teximage.c @@ -2498,7 +2498,7 @@ texsubimage_error_check(struct gl_context *ctx, GLuint dimensions, if (error_check_subtexture_dimensions(ctx, "glTexSubImage", dimensions, texImage, xoffset, yoffset, zoffset, - width, height, 1)) { + width, height, depth)) { return GL_TRUE; } From evelikov at kemper.freedesktop.org Fri Mar 6 19:42:34 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Fri, 6 Mar 2015 11:42:34 -0800 (PST) Subject: Mesa (10.4): Update version to 10.4.6 Message-ID: <20150306194234.1596276336@kemper.freedesktop.org> Module: Mesa Branch: 10.4 Commit: e559d126f97efc9ce89fdc9dbac6a62d0e0d217b URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=e559d126f97efc9ce89fdc9dbac6a62d0e0d217b Author: Emil Velikov Date: Fri Mar 6 19:16:58 2015 +0000 Update version to 10.4.6 Signed-off-by: Emil Velikov --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index aa725fb..9a9af46 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -10.4.5 +10.4.6 From evelikov at kemper.freedesktop.org Fri Mar 6 19:42:33 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Fri, 6 Mar 2015 11:42:33 -0800 (PST) Subject: Mesa (10.4): mesa: Correct backwards NULL check. Message-ID: <20150306194233.F356E76336@kemper.freedesktop.org> Module: Mesa Branch: 10.4 Commit: 644bbf88ec8fe876efda7aa6615f8a89d0101bd0 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=644bbf88ec8fe876efda7aa6615f8a89d0101bd0 Author: Matt Turner Date: Sat Feb 28 11:14:02 2015 -0800 mesa: Correct backwards NULL check. Cc: "10.4, 10.5" Reviewed-by: Emil Velikov Reviewed-by: Ian Romanick (cherry picked from commit 491d42135ad0e5670756216154f2ba9fc79d4ba7) --- src/mesa/main/shaderapi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c index 0ca4f58..3e2f883 100644 --- a/src/mesa/main/shaderapi.c +++ b/src/mesa/main/shaderapi.c @@ -1696,7 +1696,7 @@ _mesa_GetProgramBinary(GLuint program, GLsizei bufSize, GLsizei *length, * Ensure that length always points to valid storage to avoid multiple NULL * pointer checks below. */ - if (length != NULL) + if (length == NULL) length = &length_dummy; From evelikov at kemper.freedesktop.org Fri Mar 6 19:42:34 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Fri, 6 Mar 2015 11:42:34 -0800 (PST) Subject: Mesa (10.4): Add release notes for the 10.4.6 release Message-ID: <20150306194234.1E63276336@kemper.freedesktop.org> Module: Mesa Branch: 10.4 Commit: 542a754524a2b149c178a2f70c05b292c7228fc2 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=542a754524a2b149c178a2f70c05b292c7228fc2 Author: Emil Velikov Date: Fri Mar 6 19:23:34 2015 +0000 Add release notes for the 10.4.6 release Signed-off-by: Emil Velikov --- docs/relnotes/10.4.6.html | 141 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 141 insertions(+) diff --git a/docs/relnotes/10.4.6.html b/docs/relnotes/10.4.6.html new file mode 100644 index 0000000..26398e7 --- /dev/null +++ b/docs/relnotes/10.4.6.html @@ -0,0 +1,141 @@ + + + + + Mesa Release Notes + + + + +
      +

      The Mesa 3D Graphics Library

      +
      + + +
      + +

      Mesa 10.4.6 Release Notes / March 06, 2015

      + +

      +Mesa 10.4.6 is a bug fix release which fixes bugs found since the 10.4.5 release. +

      +

      +Mesa 10.4.6 implements the OpenGL 3.3 API, but the version reported by +glGetString(GL_VERSION) or glGetIntegerv(GL_MAJOR_VERSION) / +glGetIntegerv(GL_MINOR_VERSION) depends on the particular driver being used. +Some drivers don't support all the features required in OpenGL 3.3. OpenGL +3.3 is only available if requested at context creation +because compatibility contexts are not supported. +

      + +

      SHA256 checksums

      +
      +TBD
      +
      + +

      New features

      +

      None

      + +

      Bug fixes

      + +

      This list is likely incomplete.

      + +
        + +
      • Bug 45348 - [swrast] piglit fbo-drawbuffers-arbfp regression
      • + +
      • Bug 84613 - [G965, bisected] piglit regressions : glslparsertest.glsl2
      • + +
      • Bug 87516 - glProgramBinary violates spec
      • + +
      • Bug 88885 - Transform feedback uses incorrect interleaving if a previous draw did not write gl_Position
      • + +
      • Bug 89180 - [IVB regression] Rendering issues in Mass Effect through VMware Workstation
      • + +
      + + +

      Changes

      + +

      Abdiel Janulgue (2):

      +
        +
      • glsl: Don't optimize min/max into saturate when EmitNoSat is set
      • +
      • st/mesa: For vertex shaders, don't emit saturate when SM 3.0 is unsupported
      • +
      + +

      Andreas Boll (1):

      +
        +
      • glx: Fix returned values of GLX_RENDERER_PREFERRED_PROFILE_MESA
      • +
      + +

      Brian Paul (2):

      +
        +
      • swrast: fix multiple color buffer writing
      • +
      • st/mesa: fix sampler view reference counting bug in glDraw/CopyPixels
      • +
      + +

      Chris Forbes (1):

      +
        +
      • i965/gs: Check newly-generated GS-out VUE map against correct stage
      • +
      + +

      Eduardo Lima Mitev (1):

      +
        +
      • mesa: Fix error validating args for TexSubImage3D
      • +
      + +

      Emil Velikov (6):

      +
        +
      • docs: Add sha256 sums for the 10.4.5 release
      • +
      • install-lib-links: remove the .install-lib-links file
      • +
      • Revert "mesa: Correct backwards NULL check."
      • +
      • mesa: cherry-pick the second half of commit 2aa71e9485a
      • +
      • Revert "gallivm: Update for RTDyldMemoryManager becoming an unique_ptr."
      • +
      • Update version to 10.4.6
      • +
      + +

      Ian Romanick (3):

      +
        +
      • mesa: Add missing error checks in _mesa_ProgramBinary
      • +
      • mesa: Ensure that length is set to zero in _mesa_GetProgramBinary
      • +
      • mesa: Always generate GL_INVALID_OPERATION in _mesa_GetProgramBinary
      • +
      + +

      Jonathan Gray (1):

      +
        +
      • auxilary/os: correct sysctl use in os_get_total_physical_memory()
      • +
      + +

      Jos? Fonseca (1):

      +
        +
      • gallivm: Update for RTDyldMemoryManager becoming an unique_ptr.
      • +
      + +

      Leo Liu (1):

      +
        +
      • st/omx/dec/h264: fix picture out-of-order with poc type 0 v2
      • +
      + +

      Lucas Stach (1):

      +
        +
      • install-lib-links: don't depend on .libs directory
      • +
      + +

      Marek Ol??k (2):

      +
        +
      • vbo: fix an unitialized-variable warning
      • +
      • radeonsi: fix point sprites
      • +
      + +

      Matt Turner (4):

      +
        +
      • glsl: Rewrite and fix min/max to saturate optimization.
      • +
      • mesa: Correct backwards NULL check.
      • +
      • i965/fs: Don't use backend_visitor::instructions after creating the CFG.
      • +
      • mesa: Correct backwards NULL check.
      • +
      + + +
      + + From evelikov at kemper.freedesktop.org Fri Mar 6 19:42:34 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Fri, 6 Mar 2015 11:42:34 -0800 (PST) Subject: Mesa: tag mesa-10.4.6: Mesa 10.4.6 Release Message-ID: <20150306194234.35D4176336@kemper.freedesktop.org> Module: Mesa Branch: refs/tags/mesa-10.4.6 Tag: 8fcc210d73472769838fc9f03609112a6ee85295 URL: http://cgit.freedesktop.org/mesa/mesa/tag/?id=8fcc210d73472769838fc9f03609112a6ee85295 Tagger: Emil Velikov Date: Fri Mar 6 19:24:38 2015 +0000 Mesa 10.4.6 Release From evelikov at kemper.freedesktop.org Fri Mar 6 19:42:33 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Fri, 6 Mar 2015 11:42:33 -0800 (PST) Subject: Mesa (10.4): mesa: Add missing error checks in _mesa_ProgramBinary Message-ID: <20150306194233.D6FED7633A@kemper.freedesktop.org> Module: Mesa Branch: 10.4 Commit: e1b5bc9330fb1cc76e643fd6968dcee39d0d9d83 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=e1b5bc9330fb1cc76e643fd6968dcee39d0d9d83 Author: Ian Romanick Date: Sun Dec 21 12:03:09 2014 -0800 mesa: Add missing error checks in _mesa_ProgramBinary Signed-off-by: Ian Romanick Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=87516 Reviewed-by: Kenneth Graunke Acked-by: Leight Bade (cherry picked from commit 201b9c181825551559f6d995007de8ff12d1a54c) Conflicts: src/mesa/main/shaderapi.c --- src/mesa/main/shaderapi.c | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c index 6657820..3451ea2 100644 --- a/src/mesa/main/shaderapi.c +++ b/src/mesa/main/shaderapi.c @@ -1724,8 +1724,31 @@ _mesa_ProgramBinary(GLuint program, GLenum binaryFormat, (void) binaryFormat; (void) binary; - (void) length; - _mesa_error(ctx, GL_INVALID_OPERATION, __FUNCTION__); + + /* Section 2.3.1 (Errors) of the OpenGL 4.5 spec says: + * + * "If a negative number is provided where an argument of type sizei or + * sizeiptr is specified, an INVALID_VALUE error is generated." + */ + if (length < 0) { + _mesa_error(ctx, GL_INVALID_VALUE, "glProgramBinary(length < 0)"); + return; + } + + /* The ARB_get_program_binary spec says: + * + * " and must be those returned by a previous + * call to GetProgramBinary, and must be the length of the + * program binary as returned by GetProgramBinary or GetProgramiv with + * PROGRAM_BINARY_LENGTH. Loading the program binary will fail, + * setting the LINK_STATUS of to FALSE, if these conditions + * are not met." + * + * Since any value of binaryFormat passed "is not one of those specified as + * allowable for [this] command, an INVALID_ENUM error is generated." + */ + shProg->LinkStatus = GL_FALSE; + _mesa_error(ctx, GL_INVALID_ENUM, "glProgramBinary"); } From evelikov at kemper.freedesktop.org Fri Mar 6 19:42:33 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Fri, 6 Mar 2015 11:42:33 -0800 (PST) Subject: Mesa (10.4): mesa: Ensure that length is set to zero in _mesa_GetProgramBinary Message-ID: <20150306194233.DF8147633D@kemper.freedesktop.org> Module: Mesa Branch: 10.4 Commit: f1663a5236db78217f735bca73c6796a2fa11e51 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=f1663a5236db78217f735bca73c6796a2fa11e51 Author: Ian Romanick Date: Sun Dec 21 12:03:57 2014 -0800 mesa: Ensure that length is set to zero in _mesa_GetProgramBinary v2: Fix assignment of length. Noticed by Julien Cristau. Signed-off-by: Ian Romanick Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=87516 Reviewed-by: Kenneth Graunke Acked-by: Leight Bade (cherry picked from commit 4fd8b3012371a5795a0d272928266c6237e57466) --- src/mesa/main/shaderapi.c | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c index 3451ea2..1fec416 100644 --- a/src/mesa/main/shaderapi.c +++ b/src/mesa/main/shaderapi.c @@ -1682,16 +1682,35 @@ _mesa_GetProgramBinary(GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, GLvoid *binary) { struct gl_shader_program *shProg; + GLsizei length_dummy; GET_CURRENT_CONTEXT(ctx); shProg = _mesa_lookup_shader_program_err(ctx, program, "glGetProgramBinary"); if (!shProg) return; + /* The ARB_get_program_binary spec says: + * + * "If is NULL, then no length is returned." + * + * Ensure that length always points to valid storage to avoid multiple NULL + * pointer checks below. + */ + if (length != NULL) + length = &length_dummy; + + + /* The ARB_get_program_binary spec says: + * + * "When a program object's LINK_STATUS is FALSE, its program binary + * length is zero, and a call to GetProgramBinary will generate an + * INVALID_OPERATION error. + */ if (!shProg->LinkStatus) { _mesa_error(ctx, GL_INVALID_OPERATION, "glGetProgramBinary(program %u not linked)", shProg->Name); + *length = 0; return; } @@ -1700,12 +1719,7 @@ _mesa_GetProgramBinary(GLuint program, GLsizei bufSize, GLsizei *length, return; } - /* The ARB_get_program_binary spec says: - * - * "If is NULL, then no length is returned." - */ - if (length != NULL) - *length = 0; + *length = 0; (void) binaryFormat; (void) binary; From evelikov at kemper.freedesktop.org Fri Mar 6 19:42:34 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Fri, 6 Mar 2015 11:42:34 -0800 (PST) Subject: Mesa (10.4): docs: Add sha256 sums for the 10.4.6 release Message-ID: <20150306194234.279E276336@kemper.freedesktop.org> Module: Mesa Branch: 10.4 Commit: fc9dd495b2adbd329d6b58cd611d2acd8ac3070a URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=fc9dd495b2adbd329d6b58cd611d2acd8ac3070a Author: Emil Velikov Date: Fri Mar 6 19:44:55 2015 +0000 docs: Add sha256 sums for the 10.4.6 release Signed-off-by: Emil Velikov --- docs/relnotes/10.4.6.html | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/relnotes/10.4.6.html b/docs/relnotes/10.4.6.html index 26398e7..22647f6 100644 --- a/docs/relnotes/10.4.6.html +++ b/docs/relnotes/10.4.6.html @@ -30,7 +30,9 @@ because compatibility contexts are not supported.

      SHA256 checksums

      -TBD
      +46c9082142e811c01e49a2c332a9ac0a1eb98f2908985fb9df216539d7eaeaf4  MesaLib-10.4.6.tar.gz
      +d8baedd20e79ccd98a5a7b05e23d59a30892e68de1fcc057ca6873dafca02735  MesaLib-10.4.6.tar.bz2
      +6aded6eac7f0d4d55117b8b581d8424710bbb4c768fc90f7b881f29311a751aa  MesaLib-10.4.6.zip
       

      New features

      From evelikov at kemper.freedesktop.org Fri Mar 6 19:42:34 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Fri, 6 Mar 2015 11:42:34 -0800 (PST) Subject: Mesa (10.4): Revert "gallivm: Update for RTDyldMemoryManager becoming an unique_ptr." Message-ID: <20150306194234.0EE6C76336@kemper.freedesktop.org> Module: Mesa Branch: 10.4 Commit: fc5881ad73561860ad8006685f9abe49141428db URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=fc5881ad73561860ad8006685f9abe49141428db Author: Emil Velikov Date: Fri Mar 6 19:09:41 2015 +0000 Revert "gallivm: Update for RTDyldMemoryManager becoming an unique_ptr." This reverts commit 66a3f104a5b29dd4c4d5f1652dde994bf5b8878c. The commit is likely insufficient for normal work with LLVM 3.6. The full discussion and reason can be found at http://lists.freedesktop.org/archives/mesa-dev/2015-March/078795.html --- src/gallium/auxiliary/gallivm/lp_bld_misc.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp b/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp index 5210acc..fe3c754 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp +++ b/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp @@ -500,12 +500,8 @@ lp_build_create_jit_compiler_for_module(LLVMExecutionEngineRef *OutJIT, MM = new ShaderMemoryManager(JMM); *OutCode = MM->getGeneratedCode(); -#if HAVE_LLVM >= 0x0306 - builder.setMCJITMemoryManager(std::unique_ptr(MM)); -#else builder.setMCJITMemoryManager(MM); #endif -#endif } else { #if HAVE_LLVM < 0x0306 BaseMemoryManager* JMM = reinterpret_cast(CMM); From olv at kemper.freedesktop.org Fri Mar 6 21:22:21 2015 From: olv at kemper.freedesktop.org (Chia-I Wu) Date: Fri, 6 Mar 2015 13:22:21 -0800 (PST) Subject: Mesa (master): ilo: clarify valid and preferred tilings Message-ID: <20150306212221.8B93076336@kemper.freedesktop.org> Module: Mesa Branch: master Commit: bca6c8572f68a21e43982ffec057b30f35465965 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=bca6c8572f68a21e43982ffec057b30f35465965 Author: Chia-I Wu Date: Fri Mar 6 12:41:55 2015 -0700 ilo: clarify valid and preferred tilings We did it right until the switch to gen_surface_tiling, which has GEN8_TILING_W. Generally, GEN8_TILING_W may be valid but not preferred. --- src/gallium/drivers/ilo/ilo_layout.c | 41 ++++++++++++++++++++------------ src/gallium/drivers/ilo/ilo_resource.c | 3 +++ 2 files changed, 29 insertions(+), 15 deletions(-) diff --git a/src/gallium/drivers/ilo/ilo_layout.c b/src/gallium/drivers/ilo/ilo_layout.c index 2c78dc6..0444c5d 100644 --- a/src/gallium/drivers/ilo/ilo_layout.c +++ b/src/gallium/drivers/ilo/ilo_layout.c @@ -460,8 +460,7 @@ layout_get_valid_tilings(const struct ilo_layout *layout, { const struct pipe_resource *templ = params->templ; const enum pipe_format format = layout->format; - /* W-tiling is too restrictive */ - unsigned valid_tilings = LAYOUT_TILING_ALL & ~LAYOUT_TILING_W; + unsigned valid_tilings = LAYOUT_TILING_ALL; /* * From the Sandy Bridge PRM, volume 1 part 2, page 32: @@ -496,8 +495,7 @@ layout_get_valid_tilings(const struct ilo_layout *layout, if (templ->bind & PIPE_BIND_DEPTH_STENCIL) { switch (format) { case PIPE_FORMAT_S8_UINT: - /* this is the only case LAYOUT_TILING_W is valid */ - valid_tilings = LAYOUT_TILING_W; + valid_tilings &= LAYOUT_TILING_W; break; default: valid_tilings &= LAYOUT_TILING_Y; @@ -532,6 +530,13 @@ layout_get_valid_tilings(const struct ilo_layout *layout, ilo_dev_gen(params->dev) <= ILO_GEN(7.5) && layout->format == PIPE_FORMAT_R32G32B32_FLOAT) valid_tilings &= ~LAYOUT_TILING_Y; + + valid_tilings &= ~LAYOUT_TILING_W; + } + + if (templ->bind & PIPE_BIND_SAMPLER_VIEW) { + if (ilo_dev_gen(params->dev) < ILO_GEN(8)) + valid_tilings &= ~LAYOUT_TILING_W; } /* no conflicting binding flags */ @@ -545,33 +550,39 @@ layout_init_tiling(struct ilo_layout *layout, struct ilo_layout_params *params) { const struct pipe_resource *templ = params->templ; - unsigned valid_tilings = layout_get_valid_tilings(layout, params); + unsigned preferred_tilings; - layout->valid_tilings = valid_tilings; + layout->valid_tilings = layout_get_valid_tilings(layout, params); + + preferred_tilings = layout->valid_tilings; + + /* no fencing nor BLT support */ + if (preferred_tilings & ~LAYOUT_TILING_W) + preferred_tilings &= ~LAYOUT_TILING_W; if (templ->bind & (PIPE_BIND_RENDER_TARGET | PIPE_BIND_SAMPLER_VIEW)) { /* * heuristically set a minimum width/height for enabling tiling */ - if (layout->width0 < 64 && (valid_tilings & ~LAYOUT_TILING_X)) - valid_tilings &= ~LAYOUT_TILING_X; + if (layout->width0 < 64 && (preferred_tilings & ~LAYOUT_TILING_X)) + preferred_tilings &= ~LAYOUT_TILING_X; if ((layout->width0 < 32 || layout->height0 < 16) && (layout->width0 < 16 || layout->height0 < 32) && - (valid_tilings & ~LAYOUT_TILING_Y)) - valid_tilings &= ~LAYOUT_TILING_Y; + (preferred_tilings & ~LAYOUT_TILING_Y)) + preferred_tilings &= ~LAYOUT_TILING_Y; } else { /* force linear if we are not sure where the texture is bound to */ - if (valid_tilings & LAYOUT_TILING_NONE) - valid_tilings &= LAYOUT_TILING_NONE; + if (preferred_tilings & LAYOUT_TILING_NONE) + preferred_tilings &= LAYOUT_TILING_NONE; } /* prefer tiled over linear */ - if (valid_tilings & LAYOUT_TILING_Y) + if (preferred_tilings & LAYOUT_TILING_Y) layout->tiling = GEN6_TILING_Y; - else if (valid_tilings & LAYOUT_TILING_X) + else if (preferred_tilings & LAYOUT_TILING_X) layout->tiling = GEN6_TILING_X; - else if (valid_tilings & LAYOUT_TILING_W) + else if (preferred_tilings & LAYOUT_TILING_W) layout->tiling = GEN8_TILING_W; else layout->tiling = GEN6_TILING_NONE; diff --git a/src/gallium/drivers/ilo/ilo_resource.c b/src/gallium/drivers/ilo/ilo_resource.c index 7815354..18062d7 100644 --- a/src/gallium/drivers/ilo/ilo_resource.c +++ b/src/gallium/drivers/ilo/ilo_resource.c @@ -220,6 +220,9 @@ tex_create_separate_stencil(struct ilo_texture *tex) */ templ.format = PIPE_FORMAT_S8_UINT; + /* no stencil texturing */ + templ.bind &= ~PIPE_BIND_SAMPLER_VIEW; + s8 = tex->base.screen->resource_create(tex->base.screen, &templ); if (!s8) return false; From evelikov at kemper.freedesktop.org Fri Mar 6 23:57:47 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Fri, 6 Mar 2015 15:57:47 -0800 (PST) Subject: Mesa (10.5): mesa: fix dependency tracking of generated sources Message-ID: <20150306235747.107CD7633D@kemper.freedesktop.org> Module: Mesa Branch: 10.5 Commit: 1b00847bb2393285be514c0844e7e15a70fba284 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=1b00847bb2393285be514c0844e7e15a70fba284 Author: Emil Velikov Date: Mon Mar 2 13:10:15 2015 +0000 mesa: fix dependency tracking of generated sources Some of the files generated were not in the SOURCES variable, thus although generated prior to compilation the dependency tracking was incomplete. The latter of which resulted in the files missing from the distribution tarball. Cc: "10.5" Signed-off-by: Emil Velikov --- src/mesa/Makefile.sources | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/mesa/Makefile.sources b/src/mesa/Makefile.sources index b5912b7..629f4a6 100644 --- a/src/mesa/Makefile.sources +++ b/src/mesa/Makefile.sources @@ -87,6 +87,7 @@ MAIN_FILES = \ main/ffvertex_prog.h \ main/fog.c \ main/fog.h \ + main/format_info.h \ main/format_pack.h \ main/format_pack.c \ main/format_unpack.h \ @@ -101,6 +102,7 @@ MAIN_FILES = \ main/framebuffer.h \ main/get.c \ main/get.h \ + main/get_hash.h \ main/genmipmap.c \ main/genmipmap.h \ main/getstring.c \ From evelikov at kemper.freedesktop.org Fri Mar 6 23:57:46 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Fri, 6 Mar 2015 15:57:46 -0800 (PST) Subject: Mesa (10.5): mesa/main: update .gitignore Message-ID: <20150306235747.005CD76336@kemper.freedesktop.org> Module: Mesa Branch: 10.5 Commit: c7d49878972ec4666d7287f7f8781bfdf2a65dd4 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=c7d49878972ec4666d7287f7f8781bfdf2a65dd4 Author: Emil Velikov Date: Mon Mar 2 13:00:55 2015 +0000 mesa/main: update .gitignore Drop the no longer present get_es{1,2}.c from the list. Signed-off-by: Emil Velikov --- src/mesa/main/.gitignore | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/mesa/main/.gitignore b/src/mesa/main/.gitignore index e65472d..8256ad7 100644 --- a/src/mesa/main/.gitignore +++ b/src/mesa/main/.gitignore @@ -1,13 +1,11 @@ api_exec.c dispatch.h enums.c -get_es1.c -get_es2.c git_sha1.h git_sha1.h.tmp remap_helper.h get_hash.h get_hash.h.tmp -format_info.c +format_info.h format_pack.c format_unpack.c From evelikov at kemper.freedesktop.org Fri Mar 6 23:57:47 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Fri, 6 Mar 2015 15:57:47 -0800 (PST) Subject: Mesa (10.5): mesa: drop Makefile from get_hash.h dependency list Message-ID: <20150306235747.17A2F76359@kemper.freedesktop.org> Module: Mesa Branch: 10.5 Commit: 19422e433c5d1b72f2b72ea9a74cf991fd6cada9 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=19422e433c5d1b72f2b72ea9a74cf991fd6cada9 Author: Emil Velikov Date: Mon Mar 2 14:28:41 2015 +0000 mesa: drop Makefile from get_hash.h dependency list Not required. Additionally this had the side effect of generating the file, despite it's existence. Cc: "10.5" Signed-off-by: Emil Velikov --- src/mesa/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesa/Makefile.am b/src/mesa/Makefile.am index 17697bf..c1c466a 100644 --- a/src/mesa/Makefile.am +++ b/src/mesa/Makefile.am @@ -94,7 +94,7 @@ CLEANFILES = \ GET_HASH_GEN = main/get_hash_generator.py main/get_hash.h: ../mapi/glapi/gen/gl_and_es_API.xml main/get_hash_params.py \ - $(GET_HASH_GEN) Makefile + $(GET_HASH_GEN) $(AM_V_GEN)set -e; \ $(PYTHON2) $(PYTHON_FLAGS) $(srcdir)/$(GET_HASH_GEN) \ -f $< > $@.tmp; \ From evelikov at kemper.freedesktop.org Fri Mar 6 23:57:47 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Fri, 6 Mar 2015 15:57:47 -0800 (PST) Subject: Mesa (10.5): mapi: fix shared-glapi dependency tracking Message-ID: <20150306235747.1F82676336@kemper.freedesktop.org> Module: Mesa Branch: 10.5 Commit: 90411b56f6bc817e229d8801ac0adad6d4e3fb7a URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=90411b56f6bc817e229d8801ac0adad6d4e3fb7a Author: Emil Velikov Date: Mon Mar 2 14:33:50 2015 +0000 mapi: fix shared-glapi dependency tracking I.e. add shared-glapi/glapi_mapi_tmp.h to the SOURCES list. Otherwise there will be no knowledge that the file is required by others for the build. Thus autotools won't pick it up for the distribution tarball. Cc: "10.5" Signed-off-by: Emil Velikov --- src/mapi/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mapi/Makefile.am b/src/mapi/Makefile.am index 6794682..ab82e00 100644 --- a/src/mapi/Makefile.am +++ b/src/mapi/Makefile.am @@ -66,7 +66,7 @@ if HAVE_SHARED_GLAPI BUILT_SOURCES += shared-glapi/glapi_mapi_tmp.h lib_LTLIBRARIES += shared-glapi/libglapi.la -shared_glapi_libglapi_la_SOURCES = $(MAPI_GLAPI_FILES) +shared_glapi_libglapi_la_SOURCES = $(MAPI_GLAPI_FILES) shared-glapi/glapi_mapi_tmp.h shared_glapi_libglapi_la_CPPFLAGS = \ $(AM_CPPFLAGS) \ -DMAPI_MODE_GLAPI \ From evelikov at kemper.freedesktop.org Fri Mar 6 23:57:47 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Fri, 6 Mar 2015 15:57:47 -0800 (PST) Subject: Mesa (10.5): xmlpool: make sure we ship options.h Message-ID: <20150306235747.2682A76336@kemper.freedesktop.org> Module: Mesa Branch: 10.5 Commit: b973acc0937a5fc10cdff6429757a55ad3b4f13a URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=b973acc0937a5fc10cdff6429757a55ad3b4f13a Author: Emil Velikov Date: Mon Mar 2 13:24:55 2015 +0000 xmlpool: make sure we ship options.h The header is included in ../xmlpool.h. With the latter of which used directly in a number of places in mesa. Note that we can also add it (alongside t_option.h) to noinst_HEADERS, but neither solution fixes the issue that brough us here - namely: Do not regenerate the headers, if it already exists. Cc: "10.5" Signed-off-by: Emil Velikov --- src/mesa/drivers/dri/common/xmlpool/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesa/drivers/dri/common/xmlpool/Makefile.am b/src/mesa/drivers/dri/common/xmlpool/Makefile.am index da7d034..5557716 100644 --- a/src/mesa/drivers/dri/common/xmlpool/Makefile.am +++ b/src/mesa/drivers/dri/common/xmlpool/Makefile.am @@ -52,7 +52,7 @@ POT=xmlpool.pot .PHONY: all clean pot po mo -EXTRA_DIST = gen_xmlpool.py t_options.h $(POS) SConscript +EXTRA_DIST = gen_xmlpool.py options.h t_options.h $(POS) SConscript BUILT_SOURCES = options.h CLEANFILES = $(MOS) options.h From evelikov at kemper.freedesktop.org Fri Mar 6 23:57:47 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Fri, 6 Mar 2015 15:57:47 -0800 (PST) Subject: Mesa (10.5): docs: Add sha256 sums for the 10.5.0 release Message-ID: <20150306235747.3CB527633A@kemper.freedesktop.org> Module: Mesa Branch: 10.5 Commit: 0d3e4ed1349565dea8e6c5139400d7441b8ffdca URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=0d3e4ed1349565dea8e6c5139400d7441b8ffdca Author: Emil Velikov Date: Fri Mar 6 23:58:47 2015 +0000 docs: Add sha256 sums for the 10.5.0 release Signed-off-by: Emil Velikov --- docs/relnotes/10.5.0.html | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/relnotes/10.5.0.html b/docs/relnotes/10.5.0.html index cde8f3d..1d3dd88 100644 --- a/docs/relnotes/10.5.0.html +++ b/docs/relnotes/10.5.0.html @@ -31,9 +31,10 @@ because compatibility contexts are not supported.

      -

      MD5 checksums

      +

      SHA256 checksums

      -TBD.
      +2bb6e2e982ee4d8264d52d638c2a4e3f8a164190336d72d4e34ae1304d87ed91  mesa-10.5.0.tar.gz
      +d7ca9f9044bbdd674377e3eebceef1fae339c8817b9aa435c2053e4fea44e5d3  mesa-10.5.0.tar.xz
       
      From evelikov at kemper.freedesktop.org Fri Mar 6 23:57:47 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Fri, 6 Mar 2015 15:57:47 -0800 (PST) Subject: Mesa (10.5): docs: Update 10.5.0 release notes Message-ID: <20150306235747.35A1F76336@kemper.freedesktop.org> Module: Mesa Branch: 10.5 Commit: 97357d475fc8cbb5dbe7bf17ca41f535827fb253 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=97357d475fc8cbb5dbe7bf17ca41f535827fb253 Author: Emil Velikov Date: Fri Mar 6 22:55:59 2015 +0000 docs: Update 10.5.0 release notes Signed-off-by: Emil Velikov --- docs/relnotes/10.5.0.html | 147 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 145 insertions(+), 2 deletions(-) diff --git a/docs/relnotes/10.5.0.html b/docs/relnotes/10.5.0.html index 578db4f..cde8f3d 100644 --- a/docs/relnotes/10.5.0.html +++ b/docs/relnotes/10.5.0.html @@ -14,7 +14,7 @@
      -

      Mesa 10.5.0 Release Notes / TBD

      +

      Mesa 10.5.0 Release Notes / March 06, 2015

      Mesa 10.5.0 is a new development release. @@ -55,7 +55,150 @@ Note: some of the new features are only available with certain drivers.

      Bug fixes

      -TBD. +

      This list is likely incomplete.

      + +
        + +
      • Bug 10370 - Incorrect pixels read back if draw bitmap texture through Display list
      • + +
      • Bug 45348 - [swrast] piglit fbo-drawbuffers-arbfp regression
      • + +
      • Bug 60879 - [radeonsi] X11 can't start with acceleration enabled
      • + +
      • Bug 67672 - [llvmpipe] lp_test_arit fails on old CPUs
      • + +
      • Bug 77544 - i965: Try to use LINE instructions to perform MAD with immediate arguments
      • + +
      • Bug 78770 - [SNB bisected]Webglc conformance/textures/texture-size-limit.html fails
      • + +
      • Bug 80568 - [gen4] GPU Crash During Google Chrome Operation
      • + +
      • Bug 82477 - [softpipe] piglit fp-long-alu regression
      • + +
      • Bug 82585 - geometry shader with optional out variable segfaults
      • + +
      • Bug 82991 - Inverted bumpmap in webgl applications
      • + +
      • Bug 83463 - [swrast] piglit glsl-vs-clamp-1 regression
      • + +
      • Bug 83500 - si_dma_copy_tile causes GPU hangs
      • + +
      • Bug 83510 - Graphical glitches in Unreal Engine 4
      • + +
      • Bug 83908 - [i965] Incorrect icon colors in Steam Big Picture
      • + +
      • Bug 84212 - [BSW]ES3-CTS.shaders.loops.do_while_dynamic_iterations.vector_counter_vertex fails and causes GPU hang
      • + +
      • Bug 84651 - Distorted graphics or black window when running Battle.net app on Intel hardware via wine
      • + +
      • Bug 84777 - [BSW]Piglit spec_glsl-1.50_execution_geometry-basic fails
      • + +
      • Bug 85367 - [gen4] GPU hang in glmark-es2
      • + +
      • Bug 85467 - [llvmpipe] piglit gl-1.0-dlist-beginend failure with llvm-3.6.0svn
      • + +
      • Bug 85529 - Surfaces not drawn in Unvanquished
      • + +
      • Bug 85647 - Random radeonsi crashes with mesa 10.3.x
      • + +
      • Bug 85696 - r600g+nine: Bioshock shader failure after 7b1c0cbc90d456384b0950ad21faa3c61a6b43ff
      • + +
      • Bug 86089 - [r600g][mesa 10.4.0-dev] shader failure - r600_sb::bc_finalizer::cf_peephole() when starting Second Life
      • + +
      • Bug 86618 - [NV96] neg modifiers not working in MIN and MAX operations
      • + +
      • Bug 86760 - mesa doesn't build: recipe for target 'r600_llvm.lo' failed
      • + +
      • Bug 86764 - [SNB+ Bisected]Piglit glean/pointSprite fails
      • + +
      • Bug 86788 - (bisected) 32bit UrbanTerror 4.1 timedemo sse4.1 segfault...
      • + +
      • Bug 86811 - [BDW/BSW Bisected]Piglit spec_arb_shading_language_packing_execution_built-in-functions_vs-unpackSnorm4x8 fails
      • + +
      • Bug 86837 - kodi segfault since auxiliary/vl: rework the build of the VL code
      • + +
      • Bug 86939 - test_vf_float_conversions.cpp:63:12: error: expected primary-expression before ?union?
      • + +
      • Bug 86944 - glsl_parser_extras.cpp", line 1455: Error: Badly formed expression. (Oracle Studio)
      • + +
      • Bug 86958 - lp_bld_misc.cpp:503:40: error: no matching function for call to ?llvm::EngineBuilder::setMCJITMemoryManager(ShaderMemoryManager*&)?
      • + +
      • Bug 86969 - _drm_intel_gem_bo_references() function takes half the CPU with Witcher2 game
      • + +
      • Bug 87076 - Dead Island needs allow_glsl_extension_directive_midshader
      • + +
      • Bug 87516 - glProgramBinary violates spec
      • + +
      • Bug 87619 - Changes to state such as render targets change fragment shader without marking it dirty.
      • + +
      • Bug 87658 - [llvmpipe] SEGV in sse2_has_daz on ancient Pentium4-M
      • + +
      • Bug 87694 - [SNB] Crash in brw_begin_transform_feedback
      • + +
      • Bug 87886 - constant fps drops with Intel and Radeon
      • + +
      • Bug 87887 - [i965 Bisected]ES2-CTS.gtf.GL.cos.cos_float_vert_xvary fails
      • + +
      • Bug 87913 - CPU cacheline size of 0 can be returned by CPUID leaf 0x80000006 in some virtual machines
      • + +
      • Bug 88079 - dEQP-GLES3.functional.fbo.completeness.renderable.renderbuffer.color0 tests fail due to enabling of GL_RGB and GL_RGBA
      • + +
      • Bug 88170 - 32 bits opengl apps crash with latest llvm 3.6 git / mesa git / radeonsi
      • + +
      • Bug 88219 - include/c11/threads_posix.h:197: undefined reference to `pthread_mutex_lock'
      • + +
      • Bug 88227 - Radeonsi: High GTT usage in Prison Architect large map
      • + +
      • Bug 88248 - Calling glClear while there is an occlusion query in progress messes up the results
      • + +
      • Bug 88335 - format_pack.c:9567:22: error: expected ')'
      • + +
      • Bug 88385 - [SNB+ Bisected]Ogles3conform ES3-CTS.gtf.GL3Tests.packed_pixels.packed_pixels core dumped
      • + +
      • Bug 88467 - nir.c:140: error: ?nir_src? has no member named ?ssa?
      • + +
      • Bug 88478 - #error "<malloc.h> has been replaced by <stdlib.h>"
      • + +
      • Bug 88519 - sha1.c:210:22: error: 'grcy_md_hd_t' undeclared (first use in this function)
      • + +
      • Bug 88523 - sha1.c:37: error: 'SHA1_CTX' undeclared (first use in this function)
      • + +
      • Bug 88561 - [radeonsi][regression,bisected] Depth test/buffer issues in Portal
      • + +
      • Bug 88658 - (bisected) Slow video playback on Kabini
      • + +
      • Bug 88662 - unaligned access to gl_dlist_node
      • + +
      • Bug 88783 - FTBFS: Clover: src/gallium/state_trackers/clover/llvm/invocation.cpp:335:49: error: no matching function for call to 'llvm::TargetLibraryInfo::TargetLibraryInfo(llvm::Triple)
      • + +
      • Bug 88792 - [BDW/BSW Bisected]Piglit spec_ARB_pixel_buffer_object_pbo-read-argb8888 fails
      • + +
      • Bug 88806 - nir/nir_constant_expressions.c:2754:15: error: controlling expression type 'unsigned int' not compatible with any generic association type
      • + +
      • Bug 88841 - [SNB/IVB/HSW/BDW Bisected]Piglit spec_EGL_NOK_texture_from_pixmap_basic fails
      • + +
      • Bug 88852 - macros.h(181) : error C2143: syntax error : missing '{' before 'enum [tag]'
      • + +
      • Bug 88905 - [SNB+ Bisected]Ogles3conform ES3-CTS.gtf.GL3Tests.packed_pixels.packed_pixels fails
      • + +
      • Bug 88930 - [osmesa] osbuffer->textures should be indexed by attachment type
      • + +
      • Bug 88962 - [osmesa] Crash on postprocessing if z buffer is NULL
      • + +
      • Bug 89032 - [BDW/BSW/SKL Bisected]Piglit spec_OpenGL_1.1_infinite-spot-light fails
      • + +
      • Bug 89037 - [SKL]Piglit spec_EXT_texture_array_copyteximage_1D_ARRAY_samples=2 sporadically causes GPU hang
      • + +
      • Bug 89068 - glTexImage2D regression by texstore_rgba switch to _mesa_format_convert
      • + +
      • Bug 89069 - Lack of grass in The Talos Principle on radeonsi (native\wine\nine)
      • + +
      • Bug 89180 - [IVB regression] Rendering issues in Mass Effect through VMware Workstation
      • + +
      • Bug 86330 - lp_bld_debug.cpp:112: multiple definition of `raw_debug_ostream::write_impl(char const*, unsigned long)'
      • + +
      +

      Changes

      From evelikov at kemper.freedesktop.org Fri Mar 6 23:57:47 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Fri, 6 Mar 2015 15:57:47 -0800 (PST) Subject: Mesa: tag mesa-10.5.0: Mesa 10.5.0 release Message-ID: <20150306235747.4C4E876336@kemper.freedesktop.org> Module: Mesa Branch: refs/tags/mesa-10.5.0 Tag: 3bf84d4791390229b015f1ef7e49fbc26300e20b URL: http://cgit.freedesktop.org/mesa/mesa/tag/?id=3bf84d4791390229b015f1ef7e49fbc26300e20b Tagger: Emil Velikov Date: Fri Mar 6 22:57:00 2015 +0000 Mesa 10.5.0 release From evelikov at kemper.freedesktop.org Fri Mar 6 23:57:47 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Fri, 6 Mar 2015 15:57:47 -0800 (PST) Subject: Mesa (10.5): mesa: rename format_info.c to format_info.h Message-ID: <20150306235747.090167633A@kemper.freedesktop.org> Module: Mesa Branch: 10.5 Commit: a0264d4076a12380320adfda3b5172de7b314e27 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=a0264d4076a12380320adfda3b5172de7b314e27 Author: Emil Velikov Date: Mon Mar 2 13:04:37 2015 +0000 mesa: rename format_info.c to format_info.h The file is auto-generated, and #included by formats.c. Let's rename it to reflect the latter. This will also help up fix the dependency tracking by adding it to the _SOURCES variable, without the side effect of it being compiled (twice). Cc: "10.4, 10.5" Signed-off-by: Emil Velikov --- src/mesa/Android.gen.mk | 2 +- src/mesa/Makefile.am | 6 +++--- src/mesa/SConscript | 2 +- src/mesa/main/formats.c | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/mesa/Android.gen.mk b/src/mesa/Android.gen.mk index c7b7f7e..caae2c1 100644 --- a/src/mesa/Android.gen.mk +++ b/src/mesa/Android.gen.mk @@ -122,5 +122,5 @@ format_info_deps := \ $(LOCAL_PATH)/main/format_parser.py \ $(FORMAT_INFO) -$(intermediates)/main/format_info.c: $(format_info_deps) +$(intermediates)/main/format_info.h: $(format_info_deps) @$(MESA_PYTHON2) $(FORMAT_INFO) $< > $@ diff --git a/src/mesa/Makefile.am b/src/mesa/Makefile.am index b6cb8f1..17697bf 100644 --- a/src/mesa/Makefile.am +++ b/src/mesa/Makefile.am @@ -80,7 +80,7 @@ EXTRA_DIST = \ BUILT_SOURCES = \ main/get_hash.h \ - main/format_info.c \ + main/format_info.h \ main/git_sha1.h \ main/format_pack.c \ main/format_unpack.c \ @@ -100,7 +100,7 @@ main/get_hash.h: ../mapi/glapi/gen/gl_and_es_API.xml main/get_hash_params.py \ -f $< > $@.tmp; \ mv $@.tmp $@; -main/format_info.c: main/formats.csv \ +main/format_info.h: main/formats.csv \ main/format_parser.py main/format_info.py $(AM_V_GEN)set -e; \ $(PYTHON2) $(PYTHON_FLAGS) $(srcdir)/main/format_info.py \ @@ -123,7 +123,7 @@ main/format_unpack.c: main/format_unpack.py main/formats.csv \ $(srcdir)/main/formats.csv \ | $(INDENT) $(INDENT_FLAGS) > $@; -main/formats.c: main/format_info.c +main/formats.c: main/format_info.h noinst_LTLIBRARIES = $(ARCH_LIBS) if NEED_LIBMESA diff --git a/src/mesa/SConscript b/src/mesa/SConscript index 1ad5f26..4d2ed62 100644 --- a/src/mesa/SConscript +++ b/src/mesa/SConscript @@ -60,7 +60,7 @@ get_hash_header = env.CodeGenerate( ) format_info = env.CodeGenerate( - target = 'main/format_info.c', + target = 'main/format_info.h', script = 'main/format_info.py', source = 'main/formats.csv', command = python_cmd + ' $SCRIPT ' + ' $SOURCE > $TARGET' diff --git a/src/mesa/main/formats.c b/src/mesa/main/formats.c index 958d6f2..a5aa793 100644 --- a/src/mesa/main/formats.c +++ b/src/mesa/main/formats.c @@ -75,7 +75,7 @@ struct gl_format_info mesa_array_format ArrayFormat; }; -#include "format_info.c" +#include "format_info.h" static const struct gl_format_info * _mesa_get_format_info(mesa_format format) From evelikov at kemper.freedesktop.org Fri Mar 6 23:57:47 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Fri, 6 Mar 2015 15:57:47 -0800 (PST) Subject: Mesa (10.5): Bump version to 10.5.0 (final) Message-ID: <20150306235747.2D76576336@kemper.freedesktop.org> Module: Mesa Branch: 10.5 Commit: c899144da6fddd97e4f865600cd8ebfda8112664 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=c899144da6fddd97e4f865600cd8ebfda8112664 Author: Emil Velikov Date: Fri Mar 6 22:46:49 2015 +0000 Bump version to 10.5.0 (final) Signed-off-by: Emil Velikov --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index a42f4fc..2cf514e 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -10.5.0-rc3 +10.5.0 From evelikov at kemper.freedesktop.org Sat Mar 7 00:33:59 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Fri, 6 Mar 2015 16:33:59 -0800 (PST) Subject: Mesa (master): docs: Add sha256 sums for the 10.4.6 release Message-ID: <20150307003359.256A47633A@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 19c5bee10165d7918dcf4456ce0e546d554d7d21 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=19c5bee10165d7918dcf4456ce0e546d554d7d21 Author: Emil Velikov Date: Fri Mar 6 19:44:55 2015 +0000 docs: Add sha256 sums for the 10.4.6 release Signed-off-by: Emil Velikov (cherry picked from commit fc9dd495b2adbd329d6b58cd611d2acd8ac3070a) --- docs/relnotes/10.4.6.html | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/relnotes/10.4.6.html b/docs/relnotes/10.4.6.html index 26398e7..22647f6 100644 --- a/docs/relnotes/10.4.6.html +++ b/docs/relnotes/10.4.6.html @@ -30,7 +30,9 @@ because compatibility contexts are not supported.

      SHA256 checksums

      -TBD
      +46c9082142e811c01e49a2c332a9ac0a1eb98f2908985fb9df216539d7eaeaf4  MesaLib-10.4.6.tar.gz
      +d8baedd20e79ccd98a5a7b05e23d59a30892e68de1fcc057ca6873dafca02735  MesaLib-10.4.6.tar.bz2
      +6aded6eac7f0d4d55117b8b581d8424710bbb4c768fc90f7b881f29311a751aa  MesaLib-10.4.6.zip
       

      New features

      From evelikov at kemper.freedesktop.org Sat Mar 7 00:33:59 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Fri, 6 Mar 2015 16:33:59 -0800 (PST) Subject: Mesa (master): Add release notes for the 10.4.6 release Message-ID: <20150307003359.1CE5E76336@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 9fe27c7b9987fd3fa353cc355dce1a9364dc27e6 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=9fe27c7b9987fd3fa353cc355dce1a9364dc27e6 Author: Emil Velikov Date: Fri Mar 6 19:23:34 2015 +0000 Add release notes for the 10.4.6 release Signed-off-by: Emil Velikov (cherry picked from commit 542a754524a2b149c178a2f70c05b292c7228fc2) --- docs/relnotes/10.4.6.html | 141 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 141 insertions(+) diff --git a/docs/relnotes/10.4.6.html b/docs/relnotes/10.4.6.html new file mode 100644 index 0000000..26398e7 --- /dev/null +++ b/docs/relnotes/10.4.6.html @@ -0,0 +1,141 @@ + + + + + Mesa Release Notes + + + + +
      +

      The Mesa 3D Graphics Library

      +
      + + +
      + +

      Mesa 10.4.6 Release Notes / March 06, 2015

      + +

      +Mesa 10.4.6 is a bug fix release which fixes bugs found since the 10.4.5 release. +

      +

      +Mesa 10.4.6 implements the OpenGL 3.3 API, but the version reported by +glGetString(GL_VERSION) or glGetIntegerv(GL_MAJOR_VERSION) / +glGetIntegerv(GL_MINOR_VERSION) depends on the particular driver being used. +Some drivers don't support all the features required in OpenGL 3.3. OpenGL +3.3 is only available if requested at context creation +because compatibility contexts are not supported. +

      + +

      SHA256 checksums

      +
      +TBD
      +
      + +

      New features

      +

      None

      + +

      Bug fixes

      + +

      This list is likely incomplete.

      + +
        + +
      • Bug 45348 - [swrast] piglit fbo-drawbuffers-arbfp regression
      • + +
      • Bug 84613 - [G965, bisected] piglit regressions : glslparsertest.glsl2
      • + +
      • Bug 87516 - glProgramBinary violates spec
      • + +
      • Bug 88885 - Transform feedback uses incorrect interleaving if a previous draw did not write gl_Position
      • + +
      • Bug 89180 - [IVB regression] Rendering issues in Mass Effect through VMware Workstation
      • + +
      + + +

      Changes

      + +

      Abdiel Janulgue (2):

      +
        +
      • glsl: Don't optimize min/max into saturate when EmitNoSat is set
      • +
      • st/mesa: For vertex shaders, don't emit saturate when SM 3.0 is unsupported
      • +
      + +

      Andreas Boll (1):

      +
        +
      • glx: Fix returned values of GLX_RENDERER_PREFERRED_PROFILE_MESA
      • +
      + +

      Brian Paul (2):

      +
        +
      • swrast: fix multiple color buffer writing
      • +
      • st/mesa: fix sampler view reference counting bug in glDraw/CopyPixels
      • +
      + +

      Chris Forbes (1):

      +
        +
      • i965/gs: Check newly-generated GS-out VUE map against correct stage
      • +
      + +

      Eduardo Lima Mitev (1):

      +
        +
      • mesa: Fix error validating args for TexSubImage3D
      • +
      + +

      Emil Velikov (6):

      +
        +
      • docs: Add sha256 sums for the 10.4.5 release
      • +
      • install-lib-links: remove the .install-lib-links file
      • +
      • Revert "mesa: Correct backwards NULL check."
      • +
      • mesa: cherry-pick the second half of commit 2aa71e9485a
      • +
      • Revert "gallivm: Update for RTDyldMemoryManager becoming an unique_ptr."
      • +
      • Update version to 10.4.6
      • +
      + +

      Ian Romanick (3):

      +
        +
      • mesa: Add missing error checks in _mesa_ProgramBinary
      • +
      • mesa: Ensure that length is set to zero in _mesa_GetProgramBinary
      • +
      • mesa: Always generate GL_INVALID_OPERATION in _mesa_GetProgramBinary
      • +
      + +

      Jonathan Gray (1):

      +
        +
      • auxilary/os: correct sysctl use in os_get_total_physical_memory()
      • +
      + +

      Jos? Fonseca (1):

      +
        +
      • gallivm: Update for RTDyldMemoryManager becoming an unique_ptr.
      • +
      + +

      Leo Liu (1):

      +
        +
      • st/omx/dec/h264: fix picture out-of-order with poc type 0 v2
      • +
      + +

      Lucas Stach (1):

      +
        +
      • install-lib-links: don't depend on .libs directory
      • +
      + +

      Marek Ol??k (2):

      +
        +
      • vbo: fix an unitialized-variable warning
      • +
      • radeonsi: fix point sprites
      • +
      + +

      Matt Turner (4):

      +
        +
      • glsl: Rewrite and fix min/max to saturate optimization.
      • +
      • mesa: Correct backwards NULL check.
      • +
      • i965/fs: Don't use backend_visitor::instructions after creating the CFG.
      • +
      • mesa: Correct backwards NULL check.
      • +
      + + +
      + + From evelikov at kemper.freedesktop.org Sat Mar 7 00:33:59 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Fri, 6 Mar 2015 16:33:59 -0800 (PST) Subject: Mesa (master): docs: Add sha256 sums for the 10.5.0 release Message-ID: <20150307003359.3A9F376359@kemper.freedesktop.org> Module: Mesa Branch: master Commit: ac9679b1c5ed533bbb419a4ea94d8cdd0c7a935f URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=ac9679b1c5ed533bbb419a4ea94d8cdd0c7a935f Author: Emil Velikov Date: Fri Mar 6 23:58:47 2015 +0000 docs: Add sha256 sums for the 10.5.0 release Signed-off-by: Emil Velikov (cherry picked from commit 0d3e4ed1349565dea8e6c5139400d7441b8ffdca) --- docs/relnotes/10.5.0.html | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/relnotes/10.5.0.html b/docs/relnotes/10.5.0.html index cde8f3d..1d3dd88 100644 --- a/docs/relnotes/10.5.0.html +++ b/docs/relnotes/10.5.0.html @@ -31,9 +31,10 @@ because compatibility contexts are not supported.

      -

      MD5 checksums

      +

      SHA256 checksums

      -TBD.
      +2bb6e2e982ee4d8264d52d638c2a4e3f8a164190336d72d4e34ae1304d87ed91  mesa-10.5.0.tar.gz
      +d7ca9f9044bbdd674377e3eebceef1fae339c8817b9aa435c2053e4fea44e5d3  mesa-10.5.0.tar.xz
       
      From evelikov at kemper.freedesktop.org Sat Mar 7 00:33:59 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Fri, 6 Mar 2015 16:33:59 -0800 (PST) Subject: Mesa (master): docs: add news item and link release notes for mesa 10.4.6/ 10.5.0 Message-ID: <20150307003359.474B576336@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 1e5f833a0d94943e0fe13be245261757e6c73a2e URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=1e5f833a0d94943e0fe13be245261757e6c73a2e Author: Emil Velikov Date: Sat Mar 7 00:33:06 2015 +0000 docs: add news item and link release notes for mesa 10.4.6/10.5.0 Signed-off-by: Emil Velikov --- docs/index.html | 13 +++++++++++++ docs/relnotes.html | 2 ++ 2 files changed, 15 insertions(+) diff --git a/docs/index.html b/docs/index.html index 9b72bc1..e52dc44 100644 --- a/docs/index.html +++ b/docs/index.html @@ -16,6 +16,19 @@

      News

      +

      March 06, 2015

      +

      +Mesa 10.5.0 is released. This is a new +development release. See the release notes for more information about +the release. +

      + +

      March 06, 2015

      +

      +Mesa 10.4.6 is released. +This is a bug-fix release. +

      +

      February 21, 2015

      Mesa 10.4.5 is released. diff --git a/docs/relnotes.html b/docs/relnotes.html index d4ba110..eea1064 100644 --- a/docs/relnotes.html +++ b/docs/relnotes.html @@ -21,6 +21,8 @@ The release notes summarize what's new or changed in each Mesa release.

        +
      • 10.5.0 release notes +
      • 10.4.6 release notes
      • 10.4.5 release notes
      • 10.4.4 release notes
      • 10.4.3 release notes From evelikov at kemper.freedesktop.org Sat Mar 7 00:33:59 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Fri, 6 Mar 2015 16:33:59 -0800 (PST) Subject: Mesa (master): docs: Update 10.5.0 release notes Message-ID: <20150307003359.3011C7633D@kemper.freedesktop.org> Module: Mesa Branch: master Commit: b48774e7d8b402497ffccf25b7372bdb7ff49350 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=b48774e7d8b402497ffccf25b7372bdb7ff49350 Author: Emil Velikov Date: Fri Mar 6 22:55:59 2015 +0000 docs: Update 10.5.0 release notes Signed-off-by: Emil Velikov (cherry picked from commit 97357d475fc8cbb5dbe7bf17ca41f535827fb253) --- docs/relnotes/10.5.0.html | 147 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 145 insertions(+), 2 deletions(-) diff --git a/docs/relnotes/10.5.0.html b/docs/relnotes/10.5.0.html index 578db4f..cde8f3d 100644 --- a/docs/relnotes/10.5.0.html +++ b/docs/relnotes/10.5.0.html @@ -14,7 +14,7 @@
        -

        Mesa 10.5.0 Release Notes / TBD

        +

        Mesa 10.5.0 Release Notes / March 06, 2015

        Mesa 10.5.0 is a new development release. @@ -55,7 +55,150 @@ Note: some of the new features are only available with certain drivers.

        Bug fixes

        -TBD. +

        This list is likely incomplete.

        + +
          + +
        • Bug 10370 - Incorrect pixels read back if draw bitmap texture through Display list
        • + +
        • Bug 45348 - [swrast] piglit fbo-drawbuffers-arbfp regression
        • + +
        • Bug 60879 - [radeonsi] X11 can't start with acceleration enabled
        • + +
        • Bug 67672 - [llvmpipe] lp_test_arit fails on old CPUs
        • + +
        • Bug 77544 - i965: Try to use LINE instructions to perform MAD with immediate arguments
        • + +
        • Bug 78770 - [SNB bisected]Webglc conformance/textures/texture-size-limit.html fails
        • + +
        • Bug 80568 - [gen4] GPU Crash During Google Chrome Operation
        • + +
        • Bug 82477 - [softpipe] piglit fp-long-alu regression
        • + +
        • Bug 82585 - geometry shader with optional out variable segfaults
        • + +
        • Bug 82991 - Inverted bumpmap in webgl applications
        • + +
        • Bug 83463 - [swrast] piglit glsl-vs-clamp-1 regression
        • + +
        • Bug 83500 - si_dma_copy_tile causes GPU hangs
        • + +
        • Bug 83510 - Graphical glitches in Unreal Engine 4
        • + +
        • Bug 83908 - [i965] Incorrect icon colors in Steam Big Picture
        • + +
        • Bug 84212 - [BSW]ES3-CTS.shaders.loops.do_while_dynamic_iterations.vector_counter_vertex fails and causes GPU hang
        • + +
        • Bug 84651 - Distorted graphics or black window when running Battle.net app on Intel hardware via wine
        • + +
        • Bug 84777 - [BSW]Piglit spec_glsl-1.50_execution_geometry-basic fails
        • + +
        • Bug 85367 - [gen4] GPU hang in glmark-es2
        • + +
        • Bug 85467 - [llvmpipe] piglit gl-1.0-dlist-beginend failure with llvm-3.6.0svn
        • + +
        • Bug 85529 - Surfaces not drawn in Unvanquished
        • + +
        • Bug 85647 - Random radeonsi crashes with mesa 10.3.x
        • + +
        • Bug 85696 - r600g+nine: Bioshock shader failure after 7b1c0cbc90d456384b0950ad21faa3c61a6b43ff
        • + +
        • Bug 86089 - [r600g][mesa 10.4.0-dev] shader failure - r600_sb::bc_finalizer::cf_peephole() when starting Second Life
        • + +
        • Bug 86618 - [NV96] neg modifiers not working in MIN and MAX operations
        • + +
        • Bug 86760 - mesa doesn't build: recipe for target 'r600_llvm.lo' failed
        • + +
        • Bug 86764 - [SNB+ Bisected]Piglit glean/pointSprite fails
        • + +
        • Bug 86788 - (bisected) 32bit UrbanTerror 4.1 timedemo sse4.1 segfault...
        • + +
        • Bug 86811 - [BDW/BSW Bisected]Piglit spec_arb_shading_language_packing_execution_built-in-functions_vs-unpackSnorm4x8 fails
        • + +
        • Bug 86837 - kodi segfault since auxiliary/vl: rework the build of the VL code
        • + +
        • Bug 86939 - test_vf_float_conversions.cpp:63:12: error: expected primary-expression before ?union?
        • + +
        • Bug 86944 - glsl_parser_extras.cpp", line 1455: Error: Badly formed expression. (Oracle Studio)
        • + +
        • Bug 86958 - lp_bld_misc.cpp:503:40: error: no matching function for call to ?llvm::EngineBuilder::setMCJITMemoryManager(ShaderMemoryManager*&)?
        • + +
        • Bug 86969 - _drm_intel_gem_bo_references() function takes half the CPU with Witcher2 game
        • + +
        • Bug 87076 - Dead Island needs allow_glsl_extension_directive_midshader
        • + +
        • Bug 87516 - glProgramBinary violates spec
        • + +
        • Bug 87619 - Changes to state such as render targets change fragment shader without marking it dirty.
        • + +
        • Bug 87658 - [llvmpipe] SEGV in sse2_has_daz on ancient Pentium4-M
        • + +
        • Bug 87694 - [SNB] Crash in brw_begin_transform_feedback
        • + +
        • Bug 87886 - constant fps drops with Intel and Radeon
        • + +
        • Bug 87887 - [i965 Bisected]ES2-CTS.gtf.GL.cos.cos_float_vert_xvary fails
        • + +
        • Bug 87913 - CPU cacheline size of 0 can be returned by CPUID leaf 0x80000006 in some virtual machines
        • + +
        • Bug 88079 - dEQP-GLES3.functional.fbo.completeness.renderable.renderbuffer.color0 tests fail due to enabling of GL_RGB and GL_RGBA
        • + +
        • Bug 88170 - 32 bits opengl apps crash with latest llvm 3.6 git / mesa git / radeonsi
        • + +
        • Bug 88219 - include/c11/threads_posix.h:197: undefined reference to `pthread_mutex_lock'
        • + +
        • Bug 88227 - Radeonsi: High GTT usage in Prison Architect large map
        • + +
        • Bug 88248 - Calling glClear while there is an occlusion query in progress messes up the results
        • + +
        • Bug 88335 - format_pack.c:9567:22: error: expected ')'
        • + +
        • Bug 88385 - [SNB+ Bisected]Ogles3conform ES3-CTS.gtf.GL3Tests.packed_pixels.packed_pixels core dumped
        • + +
        • Bug 88467 - nir.c:140: error: ?nir_src? has no member named ?ssa?
        • + +
        • Bug 88478 - #error "<malloc.h> has been replaced by <stdlib.h>"
        • + +
        • Bug 88519 - sha1.c:210:22: error: 'grcy_md_hd_t' undeclared (first use in this function)
        • + +
        • Bug 88523 - sha1.c:37: error: 'SHA1_CTX' undeclared (first use in this function)
        • + +
        • Bug 88561 - [radeonsi][regression,bisected] Depth test/buffer issues in Portal
        • + +
        • Bug 88658 - (bisected) Slow video playback on Kabini
        • + +
        • Bug 88662 - unaligned access to gl_dlist_node
        • + +
        • Bug 88783 - FTBFS: Clover: src/gallium/state_trackers/clover/llvm/invocation.cpp:335:49: error: no matching function for call to 'llvm::TargetLibraryInfo::TargetLibraryInfo(llvm::Triple)
        • + +
        • Bug 88792 - [BDW/BSW Bisected]Piglit spec_ARB_pixel_buffer_object_pbo-read-argb8888 fails
        • + +
        • Bug 88806 - nir/nir_constant_expressions.c:2754:15: error: controlling expression type 'unsigned int' not compatible with any generic association type
        • + +
        • Bug 88841 - [SNB/IVB/HSW/BDW Bisected]Piglit spec_EGL_NOK_texture_from_pixmap_basic fails
        • + +
        • Bug 88852 - macros.h(181) : error C2143: syntax error : missing '{' before 'enum [tag]'
        • + +
        • Bug 88905 - [SNB+ Bisected]Ogles3conform ES3-CTS.gtf.GL3Tests.packed_pixels.packed_pixels fails
        • + +
        • Bug 88930 - [osmesa] osbuffer->textures should be indexed by attachment type
        • + +
        • Bug 88962 - [osmesa] Crash on postprocessing if z buffer is NULL
        • + +
        • Bug 89032 - [BDW/BSW/SKL Bisected]Piglit spec_OpenGL_1.1_infinite-spot-light fails
        • + +
        • Bug 89037 - [SKL]Piglit spec_EXT_texture_array_copyteximage_1D_ARRAY_samples=2 sporadically causes GPU hang
        • + +
        • Bug 89068 - glTexImage2D regression by texstore_rgba switch to _mesa_format_convert
        • + +
        • Bug 89069 - Lack of grass in The Talos Principle on radeonsi (native\wine\nine)
        • + +
        • Bug 89180 - [IVB regression] Rendering issues in Mass Effect through VMware Workstation
        • + +
        • Bug 86330 - lp_bld_debug.cpp:112: multiple definition of `raw_debug_ostream::write_impl(char const*, unsigned long)'
        • + +
        +

        Changes

        From imirkin at kemper.freedesktop.org Sat Mar 7 03:20:51 2015 From: imirkin at kemper.freedesktop.org (Ilia Mirkin) Date: Fri, 6 Mar 2015 19:20:51 -0800 (PST) Subject: Mesa (master): nv50,nvc0: remove bogus 64_FLOAT formats Message-ID: <20150307032051.3D7CC76336@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 20346808cf4f1ee4f320afaf18f94043fb146f2e URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=20346808cf4f1ee4f320afaf18f94043fb146f2e Author: Ilia Mirkin Date: Thu Mar 5 12:09:21 2015 -0500 nv50,nvc0: remove bogus 64_FLOAT formats There is no HW support for these and the VBO pusher doesn't know about them. No need to, either, since the st will be lowering them to 2x32. Signed-off-by: Ilia Mirkin --- src/gallium/drivers/nouveau/nv50/nv50_formats.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/gallium/drivers/nouveau/nv50/nv50_formats.c b/src/gallium/drivers/nouveau/nv50/nv50_formats.c index 0f86ba1..6a1b11c 100644 --- a/src/gallium/drivers/nouveau/nv50/nv50_formats.c +++ b/src/gallium/drivers/nouveau/nv50/nv50_formats.c @@ -436,9 +436,4 @@ const struct nv50_format nv50_format_table[PIPE_FORMAT_COUNT] = F3B(R32G32B32_FIXED, NONE, C0, C1, C2, xx, FLOAT, 32_32_32, V), F2B(R32G32_FIXED, NONE, C0, C1, xx, xx, FLOAT, 32_32, V), F1B(R32_FIXED, NONE, C0, xx, xx, xx, FLOAT, 32, V), - - C4B(R64G64B64A64_FLOAT, NONE, C0, C1, C2, C3, FLOAT, 32_32_32_32, V), - F3B(R64G64B64_FLOAT, NONE, C0, C1, C2, xx, FLOAT, 32_32_32, V), - F2B(R64G64_FLOAT, NONE, C0, C1, xx, xx, FLOAT, 32_32, V), - F1B(R64_FLOAT, NONE, C0, xx, xx, xx, FLOAT, 32, V), }; From imirkin at kemper.freedesktop.org Sat Mar 7 03:20:51 2015 From: imirkin at kemper.freedesktop.org (Ilia Mirkin) Date: Fri, 6 Mar 2015 19:20:51 -0800 (PST) Subject: Mesa (master): nouveau: Fix build, invalid extern "C" around header inclusion. Message-ID: <20150307032051.4A1547633A@kemper.freedesktop.org> Module: Mesa Branch: master Commit: c4b91a1f5c7ef667708a6b8d734707bbba851437 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=c4b91a1f5c7ef667708a6b8d734707bbba851437 Author: Mark Janes Date: Fri Mar 6 13:36:54 2015 -0800 nouveau: Fix build, invalid extern "C" around header inclusion. A previous patch to fix header inclusion within extern "C" neglected to fix the occurences of this pattern in nouveau files. When the helper to detect this issue was pushed to master, it broke the build for the nouveau driver. This patch fixes the nouveau build. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=89477 Reviewed-by: Ilia Mirkin Reviewed-by: Jose Fonseca --- src/gallium/auxiliary/tgsi/tgsi_scan.h | 7 +++++++ src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp | 2 -- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/gallium/auxiliary/tgsi/tgsi_scan.h b/src/gallium/auxiliary/tgsi/tgsi_scan.h index 5dc9267..0ea0e88 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_scan.h +++ b/src/gallium/auxiliary/tgsi/tgsi_scan.h @@ -33,6 +33,10 @@ #include "pipe/p_state.h" #include "pipe/p_shader_tokens.h" +#ifdef __cplusplus +extern "C" { +#endif + /** * Shader summary info */ @@ -114,5 +118,8 @@ tgsi_scan_shader(const struct tgsi_token *tokens, extern boolean tgsi_is_passthrough_shader(const struct tgsi_token *tokens); +#ifdef __cplusplus +} // extern "C" +#endif #endif /* TGSI_SCAN_H */ diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp b/src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp index 6e75730..1e0a695 100644 --- a/src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp +++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp @@ -20,11 +20,9 @@ * OTHER DEALINGS IN THE SOFTWARE. */ -extern "C" { #include "tgsi/tgsi_dump.h" #include "tgsi/tgsi_scan.h" #include "tgsi/tgsi_util.h" -} #include From imirkin at kemper.freedesktop.org Sat Mar 7 03:20:51 2015 From: imirkin at kemper.freedesktop.org (Ilia Mirkin) Date: Fri, 6 Mar 2015 19:20:51 -0800 (PST) Subject: Mesa (master): r300g: Fix build, invalid extern "C" around header inclusion. Message-ID: <20150307032051.5323E7633D@kemper.freedesktop.org> Module: Mesa Branch: master Commit: b28c037d64ac7cee7e2c7d9d33b128d62aa4df8a URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=b28c037d64ac7cee7e2c7d9d33b128d62aa4df8a Author: Mark Janes Date: Fri Mar 6 13:36:55 2015 -0800 r300g: Fix build, invalid extern "C" around header inclusion. A previous patch to fix header inclusion within extern "C" neglected to fix the occurences of this pattern in r300 files. When the helper to detect this issue was pushed to master, it broke the build for the r300 driver. This patch fixes the r300 build. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=89477 Reviewed-by: Ilia Mirkin Reviewed-by: Jose Fonseca --- src/gallium/drivers/r300/r300_public.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/gallium/drivers/r300/r300_public.h b/src/gallium/drivers/r300/r300_public.h index b605920..57a69cb 100644 --- a/src/gallium/drivers/r300/r300_public.h +++ b/src/gallium/drivers/r300/r300_public.h @@ -2,8 +2,16 @@ #ifndef R300_PUBLIC_H #define R300_PUBLIC_H +#ifdef __cplusplus +extern "C" { +#endif + struct radeon_winsys; struct pipe_screen* r300_screen_create(struct radeon_winsys *rws); +#ifdef __cplusplus +} // extern "C" +#endif + #endif From vlee at kemper.freedesktop.org Sat Mar 7 05:42:52 2015 From: vlee at kemper.freedesktop.org (Vinson Lee) Date: Fri, 6 Mar 2015 21:42:52 -0800 (PST) Subject: Mesa (master): i915: Fix GCC unused-variable warning in release build. Message-ID: <20150307054252.1423076336@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 1ca39ec03cfba9c032f6e3b8b6c1f24e69bf96ac URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=1ca39ec03cfba9c032f6e3b8b6c1f24e69bf96ac Author: Vinson Lee Date: Tue Mar 3 18:54:48 2015 -0800 i915: Fix GCC unused-variable warning in release build. i915_debug_fp.c: In function ?i915_disassemble_program?: i915_debug_fp.c:302:11: warning: unused variable ?size? [-Wunused-variable] GLuint size = program[0] & 0x1ff; ^ Signed-off-by: Vinson Lee Reviewed-by: Timothy Arceri --- src/mesa/drivers/dri/i915/i915_debug_fp.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/mesa/drivers/dri/i915/i915_debug_fp.c b/src/mesa/drivers/dri/i915/i915_debug_fp.c index 9b4bc76..3f09902 100644 --- a/src/mesa/drivers/dri/i915/i915_debug_fp.c +++ b/src/mesa/drivers/dri/i915/i915_debug_fp.c @@ -299,12 +299,11 @@ print_dcl_op(GLuint opcode, const GLuint * program) void i915_disassemble_program(const GLuint * program, GLuint sz) { - GLuint size = program[0] & 0x1ff; GLint i; printf("\t\tBEGIN\n"); - assert(size + 2 == sz); + assert(program[0] & 0x1ff + 2 == sz); program++; for (i = 1; i < sz; i += 3, program += 3) { From evelikov at kemper.freedesktop.org Sat Mar 7 16:52:54 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Sat, 7 Mar 2015 08:52:54 -0800 (PST) Subject: Mesa (10.4): gallium/auxiliary/indices: fix start param Message-ID: <20150307165254.4DD1F7633D@kemper.freedesktop.org> Module: Mesa Branch: 10.4 Commit: 3a625d0b3f7d5e693b83a84bfd22ecca08d9de6e URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=3a625d0b3f7d5e693b83a84bfd22ecca08d9de6e Author: Marc-Andre Lureau Date: Fri Feb 27 19:40:19 2015 +0100 gallium/auxiliary/indices: fix start param Since commit 28f3f8d, indices generator take a start parameter. However, some index values have been left to start at 0. This fixes the glean/fbo test with the virgl driver, and copytexsubimage with freedreno. Reviewed-by: Ilia Mirkin Cc: "10.4 10.5" (cherry picked from commit 073a5d2e84ac9d95f0d037aeb04889822e76aa4e) --- src/gallium/auxiliary/indices/u_indices_gen.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/gallium/auxiliary/indices/u_indices_gen.py b/src/gallium/auxiliary/indices/u_indices_gen.py index 2714df8..f05b70a 100644 --- a/src/gallium/auxiliary/indices/u_indices_gen.py +++ b/src/gallium/auxiliary/indices/u_indices_gen.py @@ -193,7 +193,7 @@ def lineloop(intype, outtype, inpv, outpv): print ' for (i = start, j = 0; j < nr - 2; j+=2, i++) { ' do_line( intype, outtype, 'out+j', 'i', 'i+1', inpv, outpv ); print ' }' - do_line( intype, outtype, 'out+j', 'i', '0', inpv, outpv ); + do_line( intype, outtype, 'out+j', 'i', 'start', inpv, outpv ); postamble() def tris(intype, outtype, inpv, outpv): @@ -218,7 +218,7 @@ def tristrip(intype, outtype, inpv, outpv): def trifan(intype, outtype, inpv, outpv): preamble(intype, outtype, inpv, outpv, prim='trifan') print ' for (i = start, j = 0; j < nr; j+=3, i++) { ' - do_tri( intype, outtype, 'out+j', '0', 'i+1', 'i+2', inpv, outpv ); + do_tri( intype, outtype, 'out+j', 'start', 'i+1', 'i+2', inpv, outpv ); print ' }' postamble() @@ -228,9 +228,9 @@ def polygon(intype, outtype, inpv, outpv): preamble(intype, outtype, inpv, outpv, prim='polygon') print ' for (i = start, j = 0; j < nr; j+=3, i++) { ' if inpv == FIRST: - do_tri( intype, outtype, 'out+j', '0', 'i+1', 'i+2', inpv, outpv ); + do_tri( intype, outtype, 'out+j', 'start', 'i+1', 'i+2', inpv, outpv ); else: - do_tri( intype, outtype, 'out+j', 'i+1', 'i+2', '0', inpv, outpv ); + do_tri( intype, outtype, 'out+j', 'i+1', 'i+2', 'start', inpv, outpv ); print ' }' postamble() From evelikov at kemper.freedesktop.org Sat Mar 7 16:52:54 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Sat, 7 Mar 2015 08:52:54 -0800 (PST) Subject: Mesa (10.4): cherry-ignore: add not applicable/rejected commits Message-ID: <20150307165254.482F67633A@kemper.freedesktop.org> Module: Mesa Branch: 10.4 Commit: 944ef59b2f2b4ff12716ee6a1b55535acb58cbfa URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=944ef59b2f2b4ff12716ee6a1b55535acb58cbfa Author: Emil Velikov Date: Sat Mar 7 16:36:03 2015 +0000 cherry-ignore: add not applicable/rejected commits Signed-off-by: Emil Velikov --- bin/.cherry-ignore | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/bin/.cherry-ignore b/bin/.cherry-ignore index 7e8fff0..923fc36 100644 --- a/bin/.cherry-ignore +++ b/bin/.cherry-ignore @@ -1,2 +1,18 @@ # No whitespace commits in stable. -a10bf5c10caf27232d4df8da74d5c35c23eb883d \ No newline at end of file +a10bf5c10caf27232d4df8da74d5c35c23eb883d + +# The following patches address code which is missing in 10.4 +# http://lists.freedesktop.org/archives/mesa-dev/2015-March/078515.html +06084652fefe49c3d6bf1b476ff74ff602fdc22a common: Correct texture init for meta pbo uploads and downloads. + +# http://lists.freedesktop.org/archives/mesa-dev/2015-March/078547.html +ccc5ce6f72c1ec86be4dfcef96c0b51fba0faa6d common: Correct PBO 2D_ARRAY handling. + +# http://lists.freedesktop.org/archives/mesa-dev/2015-March/078549.html +546aba143d13ba3f993ead4cc30b2404abfc0202 common: Fix PBOs for 1D_ARRAY. + +# http://lists.freedesktop.org/archives/mesa-dev/2015-March/078501.html +2b2fa1865248c6e3b7baec81c4f92774759b201f mesa: Indent break statements and add a missing one. + +# http://lists.freedesktop.org/archives/mesa-dev/2015-March/078502.html +87109acbed9c9b52f33d58ca06d9048d0ac7a215 mesa: Free memory allocated for luminance in readpixels. From evelikov at kemper.freedesktop.org Sat Mar 7 16:52:54 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Sat, 7 Mar 2015 08:52:54 -0800 (PST) Subject: Mesa (10.4): r300g: Use PATH_MAX instead of limiting ourselves to 100 chars. Message-ID: <20150307165254.5C5547633A@kemper.freedesktop.org> Module: Mesa Branch: 10.4 Commit: 8e8d215cae22238125e99166115400ce281d72e9 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=8e8d215cae22238125e99166115400ce281d72e9 Author: Matt Turner Date: Tue Mar 3 16:02:40 2015 -0800 r300g: Use PATH_MAX instead of limiting ourselves to 100 chars. When built with Gentoo's package manager, the Mesa source directory exists seven directories deep. The path to the .test file is too long and is silently truncated, leading to a crash. Just use PATH_MAX. Cc: 10.4, 10.5 Bugzilla: https://bugs.gentoo.org/show_bug.cgi?id=540970 Reviewed-by: Tom Stellard (cherry picked from commit f5e2aa1324dd6a9666bb21834097d2fbc3cb99b6) --- src/gallium/drivers/r300/compiler/tests/rc_test_helpers.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/gallium/drivers/r300/compiler/tests/rc_test_helpers.c b/src/gallium/drivers/r300/compiler/tests/rc_test_helpers.c index 7c9d177..422bdb0 100644 --- a/src/gallium/drivers/r300/compiler/tests/rc_test_helpers.c +++ b/src/gallium/drivers/r300/compiler/tests/rc_test_helpers.c @@ -28,6 +28,7 @@ */ #include +#include #include #include #include @@ -528,7 +529,6 @@ void init_compiler( } #define MAX_LINE_LENGTH 100 -#define MAX_PATH_LENGTH 100 unsigned load_program( struct radeon_compiler *c, @@ -536,14 +536,14 @@ unsigned load_program( const char *filename) { char line[MAX_LINE_LENGTH]; - char path[MAX_PATH_LENGTH]; + char path[PATH_MAX]; FILE *file; unsigned *count; char **string_store; unsigned i = 0; memset(line, 0, sizeof(line)); - snprintf(path, MAX_PATH_LENGTH, TEST_PATH "/%s", filename); + snprintf(path, PATH_MAX, TEST_PATH "/%s", filename); file = fopen(path, "r"); if (!file) { return 0; From evelikov at kemper.freedesktop.org Sat Mar 7 16:52:54 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Sat, 7 Mar 2015 08:52:54 -0800 (PST) Subject: Mesa (10.4): egl: Take alpha bits into account when selecting GBM formats Message-ID: <20150307165254.54E407633E@kemper.freedesktop.org> Module: Mesa Branch: 10.4 Commit: 1a929baa0b27373265a4a7d9f04d9925b7b6ac17 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=1a929baa0b27373265a4a7d9f04d9925b7b6ac17 Author: Daniel Stone Date: Mon Mar 2 13:52:59 2015 +0000 egl: Take alpha bits into account when selecting GBM formats This fixes piglit when using PIGLIT_PLATFORM=gbm Tom Stellard: - Fix ARGB2101010 format Cc: "10.4 10.5" Reviewed-by: Alex Deucher Reviewed-by: Chad Versace (cherry picked from commit 65c8965d033cf9ade5e6f3c88bda6d247d46af9d) --- src/egl/drivers/dri2/platform_drm.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/egl/drivers/dri2/platform_drm.c b/src/egl/drivers/dri2/platform_drm.c index 753c60f..affb807 100644 --- a/src/egl/drivers/dri2/platform_drm.c +++ b/src/egl/drivers/dri2/platform_drm.c @@ -668,15 +668,21 @@ dri2_initialize_drm(_EGLDriver *drv, _EGLDisplay *disp) for (i = 0; dri2_dpy->driver_configs[i]; i++) { EGLint format, attr_list[3]; - unsigned int mask; + unsigned int red, alpha; dri2_dpy->core->getConfigAttrib(dri2_dpy->driver_configs[i], - __DRI_ATTRIB_RED_MASK, &mask); - if (mask == 0x3ff00000) + __DRI_ATTRIB_RED_MASK, &red); + dri2_dpy->core->getConfigAttrib(dri2_dpy->driver_configs[i], + __DRI_ATTRIB_ALPHA_MASK, &alpha); + if (red == 0x3ff00000 && alpha == 0x00000000) format = GBM_FORMAT_XRGB2101010; - else if (mask == 0x00ff0000) + else if (red == 0x3ff00000 && alpha == 0xc0000000) + format = GBM_FORMAT_ARGB2101010; + else if (red == 0x00ff0000 && alpha == 0x00000000) format = GBM_FORMAT_XRGB8888; - else if (mask == 0xf800) + else if (red == 0x00ff0000 && alpha == 0xff000000) + format = GBM_FORMAT_ARGB8888; + else if (red == 0xf800) format = GBM_FORMAT_RGB565; else continue; From evelikov at kemper.freedesktop.org Sat Mar 7 16:52:54 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Sat, 7 Mar 2015 08:52:54 -0800 (PST) Subject: Mesa (10.4): mesa: rename format_info.c to format_info.h Message-ID: <20150307165254.6F64A7633A@kemper.freedesktop.org> Module: Mesa Branch: 10.4 Commit: 97b0219ed5a61b4935794e76c40ccea9250ebadf URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=97b0219ed5a61b4935794e76c40ccea9250ebadf Author: Emil Velikov Date: Mon Mar 2 15:58:17 2015 +0000 mesa: rename format_info.c to format_info.h The file is auto-generated, and #included by formats.c. Let's rename it to reflect the latter. This will also help up fix the dependency tracking by adding it to the _SOURCES variable, without the side effect of it being compiled (twice). v2: Update .gitignore to reflect the rename. Cc: "10.4, 10.5" Signed-off-by: Emil Velikov Reviewed-by: Matt Turner (cherry picked from commit 3f6c28f2a976e35128b7a4a513cfa60af00301e1) Conflicts: src/mesa/Makefile.am src/mesa/main/.gitignore --- src/mesa/Android.gen.mk | 2 +- src/mesa/Makefile.am | 6 +++--- src/mesa/SConscript | 2 +- src/mesa/main/.gitignore | 2 +- src/mesa/main/formats.c | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/mesa/Android.gen.mk b/src/mesa/Android.gen.mk index c7b7f7e..caae2c1 100644 --- a/src/mesa/Android.gen.mk +++ b/src/mesa/Android.gen.mk @@ -122,5 +122,5 @@ format_info_deps := \ $(LOCAL_PATH)/main/format_parser.py \ $(FORMAT_INFO) -$(intermediates)/main/format_info.c: $(format_info_deps) +$(intermediates)/main/format_info.h: $(format_info_deps) @$(MESA_PYTHON2) $(FORMAT_INFO) $< > $@ diff --git a/src/mesa/Makefile.am b/src/mesa/Makefile.am index 3b68573..90b7c94 100644 --- a/src/mesa/Makefile.am +++ b/src/mesa/Makefile.am @@ -64,7 +64,7 @@ include Makefile.sources BUILT_SOURCES = \ main/get_hash.h \ - main/format_info.c \ + main/format_info.h \ $(BUILDDIR)main/git_sha1.h \ $(BUILDDIR)program/program_parse.tab.c \ $(BUILDDIR)program/lex.yy.c @@ -82,14 +82,14 @@ main/get_hash.h: $(GLAPI)/gl_and_es_API.xml main/get_hash_params.py \ -f $< > $@.tmp; \ mv $@.tmp $@; -main/format_info.c: main/formats.csv \ +main/format_info.h: main/formats.csv \ main/format_parser.py main/format_info.py $(AM_V_GEN)set -e; \ $(PYTHON2) $(PYTHON_FLAGS) $(srcdir)/main/format_info.py \ $< > $@.tmp; \ mv $@.tmp $@; -main/formats.c: main/format_info.c +main/formats.c: main/format_info.h noinst_LTLIBRARIES = $(ARCH_LIBS) if NEED_LIBMESA diff --git a/src/mesa/SConscript b/src/mesa/SConscript index e7c4f5c..1017034 100644 --- a/src/mesa/SConscript +++ b/src/mesa/SConscript @@ -60,7 +60,7 @@ get_hash_header = env.CodeGenerate( ) format_info = env.CodeGenerate( - target = 'main/format_info.c', + target = 'main/format_info.h', script = 'main/format_info.py', source = 'main/formats.csv', command = python_cmd + ' $SCRIPT ' + ' $SOURCE > $TARGET' diff --git a/src/mesa/main/.gitignore b/src/mesa/main/.gitignore index fec0629..c74f58a 100644 --- a/src/mesa/main/.gitignore +++ b/src/mesa/main/.gitignore @@ -8,4 +8,4 @@ git_sha1.h.tmp remap_helper.h get_hash.h get_hash.h.tmp -format_info.c +format_info.h diff --git a/src/mesa/main/formats.c b/src/mesa/main/formats.c index 58c32e2..c6c5680 100644 --- a/src/mesa/main/formats.c +++ b/src/mesa/main/formats.c @@ -73,7 +73,7 @@ struct gl_format_info uint8_t Swizzle[4]; }; -#include "format_info.c" +#include "format_info.h" static const struct gl_format_info * _mesa_get_format_info(mesa_format format) From evelikov at kemper.freedesktop.org Sat Mar 7 16:52:54 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Sat, 7 Mar 2015 08:52:54 -0800 (PST) Subject: Mesa (10.4): r300g: Check return value of snprintf(). Message-ID: <20150307165254.661FC7633A@kemper.freedesktop.org> Module: Mesa Branch: 10.4 Commit: 93273f16afd4be9bf4ff364a21217994837b28bb URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=93273f16afd4be9bf4ff364a21217994837b28bb Author: Matt Turner Date: Tue Mar 3 16:09:58 2015 -0800 r300g: Check return value of snprintf(). Would have at least prevented the crash the previous patch fixed. Cc: 10.4, 10.5 Bugzilla: https://bugs.gentoo.org/show_bug.cgi?id=540970 Reviewed-by: Tom Stellard (cherry picked from commit ade0b580e75bdea227eec5345f6681b678d0811b) --- src/gallium/drivers/r300/compiler/tests/rc_test_helpers.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/gallium/drivers/r300/compiler/tests/rc_test_helpers.c b/src/gallium/drivers/r300/compiler/tests/rc_test_helpers.c index 422bdb0..04c01f1 100644 --- a/src/gallium/drivers/r300/compiler/tests/rc_test_helpers.c +++ b/src/gallium/drivers/r300/compiler/tests/rc_test_helpers.c @@ -541,9 +541,14 @@ unsigned load_program( unsigned *count; char **string_store; unsigned i = 0; + int n; memset(line, 0, sizeof(line)); - snprintf(path, PATH_MAX, TEST_PATH "/%s", filename); + n = snprintf(path, PATH_MAX, TEST_PATH "/%s", filename); + if (n < 0 || n >= PATH_MAX) { + return 0; + } + file = fopen(path, "r"); if (!file) { return 0; From evelikov at kemper.freedesktop.org Sat Mar 7 16:52:54 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Sat, 7 Mar 2015 08:52:54 -0800 (PST) Subject: Mesa (10.4): i965/vec4: Don' t lose the saturate modifier in copy propagation. Message-ID: <20150307165254.78D167633A@kemper.freedesktop.org> Module: Mesa Branch: 10.4 Commit: d4a95ffcdae7f99a08f45c651bcc1fee35f496bf URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=d4a95ffcdae7f99a08f45c651bcc1fee35f496bf Author: Andrey Sudnik Date: Thu Mar 5 11:16:49 2015 -0800 i965/vec4: Don't lose the saturate modifier in copy propagation. Cc: 10.4, 10.5 Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=89224 Reviewed-by: Matt Turner Reviewed-by: Ian Romanick (cherry picked from commit 0dfec59a2785cf7a87ee5128889ecebe810b611b) --- src/mesa/drivers/dri/i965/brw_vec4_copy_propagation.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesa/drivers/dri/i965/brw_vec4_copy_propagation.cpp b/src/mesa/drivers/dri/i965/brw_vec4_copy_propagation.cpp index 65564c9..1df90cc 100644 --- a/src/mesa/drivers/dri/i965/brw_vec4_copy_propagation.cpp +++ b/src/mesa/drivers/dri/i965/brw_vec4_copy_propagation.cpp @@ -415,7 +415,7 @@ vec4_visitor::opt_copy_propagation() entries[reg].saturatemask = 0x0; for (int i = 0; i < 4; i++) { if (inst->dst.writemask & (1 << i)) { - entries[reg].value[i] = direct_copy ? &inst->src[0] : NULL; + entries[reg].value[i] = (!inst->saturate && direct_copy) ? &inst->src[0] : NULL; entries[reg].saturatemask |= (((inst->saturate && direct_copy) ? 1 : 0) << i); } } From jturney at kemper.freedesktop.org Sat Mar 7 18:19:47 2015 From: jturney at kemper.freedesktop.org (Jon TURNEY) Date: Sat, 7 Mar 2015 10:19:47 -0800 (PST) Subject: Mesa (master): c99_alloca.h: Also use for cygwin Message-ID: <20150307181947.342637633A@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 72d4f6c67f8a96956a1a8eeb90449231ba8e0940 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=72d4f6c67f8a96956a1a8eeb90449231ba8e0940 Author: Jon TURNEY Date: Thu Mar 5 15:29:32 2015 +0000 c99_alloca.h: Also use for cygwin Signed-off-by: Jon TURNEY Reviewed-by: Brian Paul --- include/c99_alloca.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/c99_alloca.h b/include/c99_alloca.h index ed66fda..5a3b8c1 100644 --- a/include/c99_alloca.h +++ b/include/c99_alloca.h @@ -35,7 +35,7 @@ # define alloca _alloca -#elif defined(__sun) +#elif defined(__sun) || defined(__CYGWIN__) # include From evelikov at kemper.freedesktop.org Sat Mar 7 19:19:11 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Sat, 7 Mar 2015 11:19:11 -0800 (PST) Subject: Mesa (10.5): 26 new commits Message-ID: <20150307191911.CE29C7633A@kemper.freedesktop.org> URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=31fcb21ef523434a254c0bbff515345c2c6d8152 Author: Matt Turner Date: Fri Feb 27 10:59:17 2015 -0800 i965: Avoid applying negate to wrong MAD source. For some given GLSL IR like (+ (neg x) (* 1.2 x)), the try_emit_mad function would see that one of the +'s sources was a negate expression and set mul_negate = true without confirming that it was actually a multiply. Cc: 10.5 Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=89315 Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=89095 Reviewed-by: Ian Romanick (cherry picked from commit d528907fd2950c7bb968fff66dd79863cd128890) [Emil Velikov: drop the changes in brw_vec4_visitor.cpp] Signed-off-by: Emil Velikov Conflicts: src/mesa/drivers/dri/i965/brw_fs_visitor.cpp src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=0cd8e357e323f39603bfb178108d94f83d6a3c37 Author: Laura Ekstrand Date: Wed Feb 25 15:45:47 2015 -0800 main: Fix target checking for CopyTexSubImage*D. This fixes a dEQP test failure. In the test, glCopyTexSubImage2D was called with target = 0 and failed to throw INVALID ENUM. This failure was caused by _mesa_get_current_tex_object(ctx, target) being called before the target checking. To remedy this, target checking was separated from the main error-checking function and called prior to _mesa_get_current_tex_object. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=89312 Reviewed-by: Anuj Phogat (cherry picked from commit ca65764d6042d2ea220a1e3952490f79c226f3e0) URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=8b4db9c6877fab9ed37a7377fe6592ff76828555 Author: Laura Ekstrand Date: Wed Feb 25 10:34:03 2015 -0800 main: Fix target checking for CompressedTexSubImage*D. This fixes a dEQP test failure. In the test, glCompressedTexSubImage2D was called with target = 0 and failed to throw INVALID ENUM. This failure was caused by _mesa_get_current_tex_object(ctx, target) being called before the target checking. To remedy this, target checking was made into its own function and called prior to _mesa_get_current_tex_object. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=89311 Reviewed-by: Anuj Phogat (cherry picked from commit 549078cb5a95e0ee381d036b8c36bc41506f21bc) URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=b0400a58dbbfba8dce7427cf489361a8db2c9312 Author: Frank Henigman Date: Thu Feb 19 15:09:20 2015 -0800 intel: fix EGLImage renderbuffer _BaseFormat Correctly set _BaseFormat field when creating a gl_renderbuffer with EGLImage storage. Change-Id: I8c9f7302d18b617f54fa68304d8ffee087ed8a77 Signed-off-by: Frank Henigman Reviewed-by: St?phane Marchesin Reviewed-by: Chad Versace (cherry picked from commit e43729943e67972e547a19123fb3afca6b77202b) Nominated-by: Chad Versace URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=ef1c87ba09d34e4985fa9cbdc4e32b2945314dc6 Author: Matt Turner Date: Sat Feb 28 12:12:22 2015 -0800 Revert SHA1 additions. The shader-cache isn't finished, so the configure checks are a bit premature and will only stand to confuse users of Mesa 10.5.0. This is a squash of the follow four reverts: Revert "Rename sha1.c and sha1.h to mesa-sha1.c and mesa-sha1.h" Revert "configure: Add machinery for --enable-shader-cache (and --disable-shader-cache)" Revert "sha1: Fix gcry_md_hd_t typo." Revert "mesa: Add mesa SHA-1 functions" Reviewed-by: Carl Worth URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=a71223eb594cee382cde633b318fc43a6e85c1dd Author: Andrey Sudnik Date: Thu Mar 5 11:16:49 2015 -0800 i965/vec4: Don't lose the saturate modifier in copy propagation. Cc: 10.4, 10.5 Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=89224 Reviewed-by: Matt Turner Reviewed-by: Ian Romanick (cherry picked from commit 0dfec59a2785cf7a87ee5128889ecebe810b611b) URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=47a3ae1f20a5e936c2f4bed864dd2d9427ed651d Author: Kenneth Graunke Date: Wed Mar 4 18:14:31 2015 -0800 i965: Split Gen4-5 BlitFramebuffer code; prefer BLT over Meta. A while back I switched intel_blit_framebuffer to prefer Meta over the BLT. This meant that Gen8 platforms would start using the 3D engine for blits, just like we do on Gen6-7.5. However, I hadn't considered Gen4-5 when making that change. The BLT engine appears to be substantially faster on 965GM than using Meta to drive the 3D engine. This isn't too surprising: original Gen4 doesn't support tile offsets (that came on G45), and the level/layer fields don't work for cubemap rendering, so for inconvenient miplevel alignments, we end up blitting or copying data to/from temporaries in order to render to it. We may as well just use the blitter. I chose to use the BLT on Gen4-5 because they use the same ring for both 3D and BLT; Gen6+ splits it out. Fixes regressions on 965GM due to botched tile offset code (we should fix those properly as well, but they're longstanding bugs - for now, put things back to the status quo). Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=89430 Signed-off-by: Kenneth Graunke Reviewed-by: Topi Pohjolainen Reviewed-by: Jordan Justen Cc: "10.5" (cherry picked from commit aa0705c06c03d2b882ac7b185ed123bc8a10d716) URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=dbf974636af53d15cd9b0924262a1f29d21dcfb1 Author: Matt Turner Date: Wed Mar 4 15:21:53 2015 -0800 i965: Tell intel_get_memcpy() which direction the memcpy() is going. The SSSE3 swizzling code was written for fast uploads to the GPU and assumed the destination was always 16-byte aligned. When we began using this code for fast downloads as well we didn't do anything to account for the fact that the destination pointer given by glReadPixels() or glGetTexImage() is not guaranteed to be suitably aligned. With SSSE3 enabled (at compile-time), some applications would crash when an SSE aligned-store instruction tried to store to an unaligned destination (or an assertion that the destination is aligned would trigger). To remedy this, tell intel_get_memcpy() whether we're uploading or downloading so that it can select whether to assume the destination or source is aligned, respectively. Cc: 10.5 Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=89416 Tested-by: Uriy Zhuravlev Reviewed-by: Jason Ekstrand (cherry picked from commit 2e4c95dfe2cb205c327ceaa12b44a9273bdb20dc) URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=35909f0e12fcb726e5f25fff7ff9a11293e054fd Author: Emil Velikov Date: Sat Mar 7 17:52:02 2015 +0000 mapi: fix commit 90411b56f6bc817e229d8801ac0adad6d4e3fb7a Handle static glapi as well. Signed-off-by: Emil Velikov URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=b83333ac5b9eeae24739d47902e3fd75e9cfeaeb Author: Emil Velikov Date: Sat Mar 7 17:50:29 2015 +0000 cherry-ignore: ignore a few more commits picked without -x Signed-off-by: Emil Velikov URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=30079d6846124e9580335393f75464f8b65149fe Author: Emil Velikov Date: Sat Feb 28 17:20:01 2015 +0000 egl/main: no longer export internal function With the split of the gallium egl module we had previously it required access to some of the internal functions. As the only build (automake) that did this no longer builds it we can now appropriately hide those functions. Cc: 10.5 Signed-off-by: Emil Velikov Reviewed-by: Matt Turner Reviewed-by: Brian Paul (cherry picked from commit dd438ae34bdbaa6651cdd226d5fec15a892923bf) URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=e5eab59b576fd7c1c2bcb78dcca899331fb3f5e9 Author: Matt Turner Date: Fri Feb 27 10:22:21 2015 -0800 i965/fs: Don't propagate cmod to inst with different type. Cc: 10.5 Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=89317 Reviewed-by: Kenneth Graunke (cherry picked from commit 1e128e9b69c6336762a2b6ee5d356c763b9ae3b0) URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=57f54b067b5c6d4fbf3ceb2bc1138aed8c913c8a Author: Matt Turner Date: Tue Mar 3 16:09:58 2015 -0800 r300g: Check return value of snprintf(). Would have at least prevented the crash the previous patch fixed. Cc: 10.4, 10.5 Bugzilla: https://bugs.gentoo.org/show_bug.cgi?id=540970 Reviewed-by: Tom Stellard (cherry picked from commit ade0b580e75bdea227eec5345f6681b678d0811b) URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=e0670715bc511bb814ab42b10d9608a93d6ba439 Author: Matt Turner Date: Tue Mar 3 16:02:40 2015 -0800 r300g: Use PATH_MAX instead of limiting ourselves to 100 chars. When built with Gentoo's package manager, the Mesa source directory exists seven directories deep. The path to the .test file is too long and is silently truncated, leading to a crash. Just use PATH_MAX. Cc: 10.4, 10.5 Bugzilla: https://bugs.gentoo.org/show_bug.cgi?id=540970 Reviewed-by: Tom Stellard (cherry picked from commit f5e2aa1324dd6a9666bb21834097d2fbc3cb99b6) URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=8357abf4c3a7ea7f2c4e2dcc4381333a979a0758 Author: Daniel Stone Date: Mon Mar 2 13:52:59 2015 +0000 egl: Take alpha bits into account when selecting GBM formats This fixes piglit when using PIGLIT_PLATFORM=gbm Tom Stellard: - Fix ARGB2101010 format Cc: "10.4 10.5" Reviewed-by: Alex Deucher Reviewed-by: Chad Versace (cherry picked from commit 65c8965d033cf9ade5e6f3c88bda6d247d46af9d) URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=b0f60c891aed6340a4c4e4d1dbf594b97c404d4f Author: Marc-Andre Lureau Date: Fri Feb 27 19:40:19 2015 +0100 gallium/auxiliary/indices: fix start param Since commit 28f3f8d, indices generator take a start parameter. However, some index values have been left to start at 0. This fixes the glean/fbo test with the virgl driver, and copytexsubimage with freedreno. Reviewed-by: Ilia Mirkin Cc: "10.4 10.5" (cherry picked from commit 073a5d2e84ac9d95f0d037aeb04889822e76aa4e) URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=73efd2891f9e044c89e9d24ac4b93931c02ea2fc Author: Matt Turner Date: Tue Jan 13 15:35:57 2015 -0800 i965/fs: Don't use backend_visitor::instructions after creating the CFG. This is a fix for a regression introduced in commit a9f8296d ("i965/fs: Preserve the CFG in a few more places."). The errata this code works around is described in a comment before the function: "[DevBW, DevCL] Errata: A destination register from a send can not be used as a destination register until after it has been sourced by an instruction with a different destination register. The framebuffer write's sources must be in message registers, which SEND instructions cannot have as a destination. There's no way for this errata to affect anything at the end of the program. Just remove the code. Cc: 10.4, 10.5 Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=84613 Reviewed-by: Kenneth Graunke (cherry picked from commit e214000f258ae564e64d839cccee9418526f226b) URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=73f8e342a7d33e296eb7a92b3dffae55a66f8f9f Author: Jason Ekstrand Date: Fri Feb 27 18:53:11 2015 -0500 main/base_tex_format: Properly handle STENCIL_INDEX1/4/16 This takes "fbo-stencil blit GL_STENCIL_INDEX1/4/16" from crash to pass on BDW. Cc: 10.5 Reviewed-by: Matt Turner (cherry picked from commit c4925d7f3b66d63fbdd7b7607cd809db1e58bee9) URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=53d66c0c7c39fbe2a587a849e0714d6f9a01f476 Author: Jason Ekstrand Date: Fri Feb 27 12:29:03 2015 -0800 meta/TexSubImage: Stash everything other than PIXEL_TRANSFER/store in meta_begin Previously, there were bugs where if the app set a scissor it could affect the area of the texture that was downloaded. There was also potential that the framebuffer SRGB state could affect downloads. This ensures that those will get saved/restored and can't affect the texture download. Cc: 10.5 Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=89292 Reviewed-by: Neil Roberts (cherry picked from commit b1ab02d9c0cc11ba8ef4efaba9452d644b6a0811) URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=560fb4ee450659ed603338301f8d0af827d56f16 Author: Matt Turner Date: Sat Feb 28 13:36:21 2015 -0800 i965: Consider scratch writes to have side effects. We could do better by tracking scratch reads and writes. Cc: 10.5 Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=88793 Reviewed-by: Jason Ekstrand (cherry picked from commit da20bf068ef0f816968d9bc4dfea81facf0fd680) URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=446aa309e18e0c5a6335d7dd9688a4e521d29043 Author: Matt Turner Date: Sat Feb 28 11:14:02 2015 -0800 mesa: Correct backwards NULL check. Cc: "10.4, 10.5" Reviewed-by: Emil Velikov Reviewed-by: Ian Romanick (cherry picked from commit 491d42135ad0e5670756216154f2ba9fc79d4ba7) URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=4c45e239385473da58d79100b0af25bd0b9edf9c Author: Matt Turner Date: Sat Feb 28 11:08:17 2015 -0800 mesa: Free memory allocated for luminance in readpixels. Cc: "10.4, 10.5" Reviewed-by: Brian Paul Reviewed-by: Iago Toral Quiroga (cherry picked from commit 87109acbed9c9b52f33d58ca06d9048d0ac7a215) URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=9267820be63fedade5ab4087c00e2239c0129cbe Author: Matt Turner Date: Sat Feb 28 11:00:51 2015 -0800 mesa: Indent break statements and add a missing one. Always indenting break statements makes spotting missing ones easier. Cc: "10.4, 10.5" Reviewed-by: Brian Paul Reviewed-by: Iago Toral Quiroga (cherry picked from commit 2b2fa1865248c6e3b7baec81c4f92774759b201f) URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=b730f6e18eb290962474aade3bfb2eea3105063b Author: Chris Forbes Date: Sat Feb 28 19:57:20 2015 +1300 i965/gs: Check newly-generated GS-out VUE map against correct stage Previously, we compared our new GS-out VUE map to the existing *VS*-out VUE map, which is bogus. This would mostly manifest as redundant dirty flagging where the GS is in use but the VS and GS output layouts differ; but there is a scary case where we would fail to flag a GS-out layout change if it happened to match the VS-out layout. Signed-off-by: Chris Forbes Cc: "10.5, 10.4" Reviewed-by: Matt Turner Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=88885 (cherry picked from commit b51ff50a767cc78d678ed3d2c25995f5c4194fea) URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=f5fbed4831767b086a904281cdb7fe9fb9e9ae62 Author: Matt Turner Date: Thu Feb 26 22:49:47 2015 -0800 i965/vec4: Fix implementation of i2b. I broke this in commit 2881b123d. I must have misread i2b as b2i. Cc: 10.5 Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=88246 Reviewed-by: Ian Romanick (cherry picked from commit 43ef2657a08f850c5756f28520f2cbe506807f24) URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=f7cc5fb2cbe42924655f8d41f9464e943a94b9ac Author: Ian Romanick Date: Fri Feb 27 14:17:50 2015 -0800 i965/fs/nir: Use emit_math for nir_op_fpow It appears that all the other instructions that need it already use it. This one just got missed. Signed-off-by: Ian Romanick Reviewed-by: Jason Ekstrand Cc: "10.5" (cherry picked from commit b8a1637119249c1d5e76c27d0053360bbb7f4e77) From robclark at kemper.freedesktop.org Sun Mar 8 21:57:11 2015 From: robclark at kemper.freedesktop.org (Rob Clark) Date: Sun, 8 Mar 2015 14:57:11 -0700 (PDT) Subject: Mesa (master): freedreno/ir3: fix failed assert in grouping Message-ID: <20150308215711.7A63476331@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 27648efa2070e8db111908314d8b924d3717dbb0 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=27648efa2070e8db111908314d8b924d3717dbb0 Author: Rob Clark Date: Tue Feb 10 04:42:32 2015 -0500 freedreno/ir3: fix failed assert in grouping Turns out there are scenarios where we need to insert mov's in "front" of an input. Triggered by shaders like: VERT DCL IN[0] DCL IN[1] DCL OUT[0], POSITION DCL OUT[1], GENERIC[9] DCL SAMP[0] DCL TEMP[0], LOCAL 0: MOV TEMP[0].xy, IN[1].xyyy 1: MOV TEMP[0].w, IN[1].wwww 2: TXF TEMP[0], TEMP[0], SAMP[0], 1D_ARRAY 3: MOV OUT[1], TEMP[0] 4: MOV OUT[0], IN[0] 5: END Signed-off-by: Rob Clark --- src/gallium/drivers/freedreno/ir3/ir3_group.c | 71 +++++++++++++++---------- 1 file changed, 44 insertions(+), 27 deletions(-) diff --git a/src/gallium/drivers/freedreno/ir3/ir3_group.c b/src/gallium/drivers/freedreno/ir3/ir3_group.c index da2142e..a571e2e 100644 --- a/src/gallium/drivers/freedreno/ir3/ir3_group.c +++ b/src/gallium/drivers/freedreno/ir3/ir3_group.c @@ -50,40 +50,72 @@ static bool check_stop(struct ir3_instruction *instr) return false; } +static struct ir3_instruction * create_mov(struct ir3_instruction *instr) +{ + struct ir3_instruction *mov; + + mov = ir3_instr_create(instr->block, 1, 0); + mov->cat1.src_type = TYPE_F32; + mov->cat1.dst_type = TYPE_F32; + ir3_reg_create(mov, 0, 0); /* dst */ + ir3_reg_create(mov, 0, IR3_REG_SSA)->instr = instr; + + return mov; +} + /* bleh.. we need to do the same group_n() thing for both inputs/outputs * (where we have a simple instr[] array), and fanin nodes (where we have * an extra indirection via reg->instr). */ struct group_ops { struct ir3_instruction *(*get)(void *arr, int idx); - void (*set)(void *arr, int idx, struct ir3_instruction *instr); + void (*insert_mov)(void *arr, int idx, struct ir3_instruction *instr); }; static struct ir3_instruction *arr_get(void *arr, int idx) { return ((struct ir3_instruction **)arr)[idx]; } -static void arr_set_out(void *arr, int idx, struct ir3_instruction *instr) +static void arr_insert_mov_out(void *arr, int idx, struct ir3_instruction *instr) { - ((struct ir3_instruction **)arr)[idx] = instr; + ((struct ir3_instruction **)arr)[idx] = create_mov(instr); } -static void arr_set_in(void *arr, int idx, struct ir3_instruction *instr) +static void arr_insert_mov_in(void *arr, int idx, struct ir3_instruction *instr) { - debug_printf("cannot insert mov before input!\n"); - debug_assert(0); + /* so, we can't insert a mov in front of a meta:in.. and the downstream + * instruction already has a pointer to 'instr'. So we cheat a bit and + * morph the meta:in instruction into a mov and insert a new meta:in + * in front. + */ + struct ir3_instruction *in; + + debug_assert(instr->regs_count == 1); + + in = ir3_instr_create(instr->block, -1, OPC_META_INPUT); + in->inout.block = instr->block; + ir3_reg_create(in, instr->regs[0]->num, 0); + + /* create src reg for meta:in and fixup to now be a mov: */ + ir3_reg_create(instr, 0, IR3_REG_SSA)->instr = in; + instr->category = 1; + instr->opc = 0; + instr->cat1.src_type = TYPE_F32; + instr->cat1.dst_type = TYPE_F32; + + ((struct ir3_instruction **)arr)[idx] = in; } -static struct group_ops arr_ops_out = { arr_get, arr_set_out }; -static struct group_ops arr_ops_in = { arr_get, arr_set_in }; +static struct group_ops arr_ops_out = { arr_get, arr_insert_mov_out }; +static struct group_ops arr_ops_in = { arr_get, arr_insert_mov_in }; static struct ir3_instruction *instr_get(void *arr, int idx) { return ssa(((struct ir3_instruction *)arr)->regs[idx+1]); } -static void instr_set(void *arr, int idx, struct ir3_instruction *instr) +static void instr_insert_mov(void *arr, int idx, struct ir3_instruction *instr) { - ((struct ir3_instruction *)arr)->regs[idx+1]->instr = instr; + ((struct ir3_instruction *)arr)->regs[idx+1]->instr = create_mov(instr); } -static struct group_ops instr_ops = { instr_get, instr_set }; +static struct group_ops instr_ops = { instr_get, instr_insert_mov }; @@ -92,20 +124,6 @@ static bool conflicts(struct ir3_instruction *a, struct ir3_instruction *b) return (a && b) && (a != b); } -static struct ir3_instruction * -create_mov(struct ir3_instruction *instr) -{ - struct ir3_instruction *mov; - - mov = ir3_instr_create(instr->block, 1, 0); - mov->cat1.src_type = TYPE_F32; - mov->cat1.dst_type = TYPE_F32; - ir3_reg_create(mov, 0, 0); /* dst */ - ir3_reg_create(mov, 0, IR3_REG_SSA)->instr = instr; - - return mov; -} - static void group_n(struct group_ops *ops, void *arr, unsigned n) { unsigned i, j; @@ -135,8 +153,7 @@ restart: conflict = true; if (conflict) { - instr = create_mov(instr); - ops->set(arr, i, instr); + ops->insert_mov(arr, i, instr); /* inserting the mov may have caused a conflict * against the previous: */ From robclark at kemper.freedesktop.org Sun Mar 8 21:57:11 2015 From: robclark at kemper.freedesktop.org (Rob Clark) Date: Sun, 8 Mar 2015 14:57:11 -0700 (PDT) Subject: Mesa (master): freedreno/ir3: couple tweaks for cmdline compiler Message-ID: <20150308215711.8CDF276331@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 3ecc834e752a452bfc445a46ea14d06dc24d7b9b URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=3ecc834e752a452bfc445a46ea14d06dc24d7b9b Author: Rob Clark Date: Tue Feb 3 15:53:35 2015 -0500 freedreno/ir3: couple tweaks for cmdline compiler Signed-off-by: Rob Clark --- src/gallium/drivers/freedreno/ir3/ir3_cmdline.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/gallium/drivers/freedreno/ir3/ir3_cmdline.c b/src/gallium/drivers/freedreno/ir3/ir3_cmdline.c index 4b60802..afad792 100644 --- a/src/gallium/drivers/freedreno/ir3/ir3_cmdline.c +++ b/src/gallium/drivers/freedreno/ir3/ir3_cmdline.c @@ -210,7 +210,7 @@ read_file(const char *filename, void **ptr, size_t *size) static void reset_variant(struct ir3_shader_variant *v, const char *msg) { - debug_error(msg); + printf("; %s\n", msg); v->inputs_count = 0; v->outputs_count = 0; v->total_in = 0; @@ -336,6 +336,9 @@ int main(int argc, char **argv) return ret; } + if (fd_mesa_debug & FD_DBG_OPTMSGS) + debug_printf("%s\n", (char *)ptr); + if (!tgsi_text_translate(ptr, toks, Elements(toks))) errx(1, "could not parse `%s'", filename); From robclark at kemper.freedesktop.org Sun Mar 8 21:57:11 2015 From: robclark at kemper.freedesktop.org (Rob Clark) Date: Sun, 8 Mar 2015 14:57:11 -0700 (PDT) Subject: Mesa (master): freedreno/ir3: fix register usage calculations Message-ID: <20150308215711.9676076331@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 26b79ac3e40624726bff5101dfe892d3ee2ba607 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=26b79ac3e40624726bff5101dfe892d3ee2ba607 Author: Rob Clark Date: Sun Feb 1 13:04:09 2015 -0500 freedreno/ir3: fix register usage calculations For cat1 instructions, use reg() as well for relative src, to ensure proper accounting of register usage. Also, for relative instructions, use reg->size rather than reg->wrmask to determine the number of components read/written. Signed-off-by: Rob Clark --- src/gallium/drivers/freedreno/ir3/ir3.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/gallium/drivers/freedreno/ir3/ir3.c b/src/gallium/drivers/freedreno/ir3/ir3.c index fe0ffc9..01cdd8a 100644 --- a/src/gallium/drivers/freedreno/ir3/ir3.c +++ b/src/gallium/drivers/freedreno/ir3/ir3.c @@ -105,11 +105,18 @@ static uint32_t reg(struct ir3_register *reg, struct ir3_info *info, if (reg->flags & IR3_REG_IMMED) { val.iim_val = reg->iim_val; } else { - int8_t components = util_last_bit(reg->wrmask); - int16_t max = (reg->num + repeat + components - 1) >> 2; + unsigned components; - val.comp = reg->num & 0x3; - val.num = reg->num >> 2; + if (reg->flags & IR3_REG_RELATIV) { + components = reg->size; + val.dummy10 = reg->offset; + } else { + components = util_last_bit(reg->wrmask); + val.comp = reg->num & 0x3; + val.num = reg->num >> 2; + } + + int16_t max = (reg->num + repeat + components - 1) >> 2; if (reg->flags & IR3_REG_CONST) { info->max_const = MAX2(info->max_const, max); @@ -166,13 +173,13 @@ static int emit_cat1(struct ir3_instruction *instr, void *ptr, cat1->iim_val = src->iim_val; cat1->src_im = 1; } else if (src->flags & IR3_REG_RELATIV) { - cat1->off = src->offset; + cat1->off = reg(src, info, instr->repeat, + IR3_REG_R | IR3_REG_CONST | IR3_REG_HALF | IR3_REG_RELATIV); cat1->src_rel = 1; cat1->src_rel_c = !!(src->flags & IR3_REG_CONST); } else { cat1->src = reg(src, info, instr->repeat, - IR3_REG_IMMED | IR3_REG_R | - IR3_REG_CONST | IR3_REG_HALF); + IR3_REG_R | IR3_REG_CONST | IR3_REG_HALF); cat1->src_c = !!(src->flags & IR3_REG_CONST); } From robclark at kemper.freedesktop.org Sun Mar 8 21:57:11 2015 From: robclark at kemper.freedesktop.org (Rob Clark) Date: Sun, 8 Mar 2015 14:57:11 -0700 (PDT) Subject: Mesa (master): freedreno/ir3: helpful iterator macros Message-ID: <20150308215711.A230876331@kemper.freedesktop.org> Module: Mesa Branch: master Commit: f8f7548f466509bf881db1826ef6dd23ffe2acdf URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=f8f7548f466509bf881db1826ef6dd23ffe2acdf Author: Rob Clark Date: Mon Feb 2 12:54:25 2015 -0500 freedreno/ir3: helpful iterator macros I remembered that we are using c99.. which makes some sugary iterator macros easier. So introduce iterator macros to iterate all src registers and all SSA src instructions. The _n variants also return the src #, since there are a handful of places that need this. Signed-off-by: Rob Clark --- src/gallium/drivers/freedreno/ir3/ir3.h | 34 +++++++++++ src/gallium/drivers/freedreno/ir3/ir3_cp.c | 22 +++----- src/gallium/drivers/freedreno/ir3/ir3_depth.c | 18 +++--- src/gallium/drivers/freedreno/ir3/ir3_dump.c | 41 ++++++-------- src/gallium/drivers/freedreno/ir3/ir3_flatten.c | 9 +-- src/gallium/drivers/freedreno/ir3/ir3_group.c | 9 +-- src/gallium/drivers/freedreno/ir3/ir3_legalize.c | 3 +- src/gallium/drivers/freedreno/ir3/ir3_ra.c | 19 ++++--- src/gallium/drivers/freedreno/ir3/ir3_sched.c | 65 +++++++++------------- 9 files changed, 109 insertions(+), 111 deletions(-) diff --git a/src/gallium/drivers/freedreno/ir3/ir3.h b/src/gallium/drivers/freedreno/ir3/ir3.h index 18d59fa..3d3ad07 100644 --- a/src/gallium/drivers/freedreno/ir3/ir3.h +++ b/src/gallium/drivers/freedreno/ir3/ir3.h @@ -486,6 +486,40 @@ static inline bool reg_gpr(struct ir3_register *r) return true; } + +/* iterator for an instructions's sources (reg), also returns src #: */ +#define foreach_src_n(__srcreg, __n, __instr) \ + if ((__instr)->regs_count) \ + for (unsigned __cnt = (__instr)->regs_count - 1, __n = 0; __n < __cnt; __n++) \ + if ((__srcreg = (__instr)->regs[__n + 1])) + +/* iterator for an instructions's sources (reg): */ +#define foreach_src(__srcreg, __instr) \ + foreach_src_n(__srcreg, __i, __instr) + +static inline unsigned __ssa_src_cnt(struct ir3_instruction *instr) +{ + return instr->regs_count; +} + +static inline struct ir3_instruction * __ssa_src_n(struct ir3_instruction *instr, unsigned n) +{ + return ssa(instr->regs[n]); +} + +#define __src_cnt(__instr) ((__instr)->address ? (__instr)->regs_count : (__instr)->regs_count - 1) + +/* iterator for an instruction's SSA sources (instr), also returns src #: */ +#define foreach_ssa_src_n(__srcinst, __n, __instr) \ + if ((__instr)->regs_count) \ + for (unsigned __cnt = __ssa_src_cnt(__instr) - 1, __n = 0; __n < __cnt; __n++) \ + if ((__srcinst = __ssa_src_n(__instr, __n + 1))) + +/* iterator for an instruction's SSA sources (instr): */ +#define foreach_ssa_src(__srcinst, __instr) \ + foreach_ssa_src_n(__srcinst, __i, __instr) + + /* dump: */ #include void ir3_dump(struct ir3 *shader, const char *name, diff --git a/src/gallium/drivers/freedreno/ir3/ir3_cp.c b/src/gallium/drivers/freedreno/ir3/ir3_cp.c index c55425d..b70aba9 100644 --- a/src/gallium/drivers/freedreno/ir3/ir3_cp.c +++ b/src/gallium/drivers/freedreno/ir3/ir3_cp.c @@ -64,18 +64,6 @@ static bool is_eligible_mov(struct ir3_instruction *instr) return false; } -static void walk_children(struct ir3_instruction *instr) -{ - unsigned i; - - /* walk down the graph from each src: */ - for (i = 1; i < instr->regs_count; i++) { - struct ir3_register *src = instr->regs[i]; - if (src->flags & IR3_REG_SSA) - src->instr = instr_cp(src->instr); - } -} - static struct ir3_instruction * instr_cp(struct ir3_instruction *instr) @@ -100,8 +88,14 @@ instr_cp(struct ir3_instruction *instr) * up as a src, we only need to recursively walk the children * once.) */ - if (!ir3_instr_check_mark(instr)) - walk_children(instr); + if (!ir3_instr_check_mark(instr)) { + struct ir3_register *reg; + + /* walk down the graph from each src: */ + foreach_src(reg, instr) + if (reg->flags & IR3_REG_SSA) + reg->instr = instr_cp(reg->instr); + } return instr; } diff --git a/src/gallium/drivers/freedreno/ir3/ir3_depth.c b/src/gallium/drivers/freedreno/ir3/ir3_depth.c index 8ff62ba..0cda62b 100644 --- a/src/gallium/drivers/freedreno/ir3/ir3_depth.c +++ b/src/gallium/drivers/freedreno/ir3/ir3_depth.c @@ -102,7 +102,7 @@ static void insert_by_depth(struct ir3_instruction *instr) static void ir3_instr_depth(struct ir3_instruction *instr) { - unsigned i; + struct ir3_instruction *src; /* if we've already visited this instruction, bail now: */ if (ir3_instr_check_mark(instr)) @@ -110,19 +110,15 @@ static void ir3_instr_depth(struct ir3_instruction *instr) instr->depth = 0; - for (i = 1; i < instr->regs_count; i++) { - struct ir3_register *src = instr->regs[i]; - if (src->flags & IR3_REG_SSA) { - unsigned sd; + foreach_ssa_src_n(src, i, instr) { + unsigned sd; - /* visit child to compute it's depth: */ - ir3_instr_depth(src->instr); + /* visit child to compute it's depth: */ + ir3_instr_depth(src); - sd = ir3_delayslots(src->instr, instr, i-1) + - src->instr->depth; + sd = ir3_delayslots(src, instr, i) + src->depth; - instr->depth = MAX2(instr->depth, sd); - } + instr->depth = MAX2(instr->depth, sd); } /* meta-instructions don't add cycles, other than PHI.. which diff --git a/src/gallium/drivers/freedreno/ir3/ir3_dump.c b/src/gallium/drivers/freedreno/ir3/ir3_dump.c index e4a13f9..42a38d7 100644 --- a/src/gallium/drivers/freedreno/ir3/ir3_dump.c +++ b/src/gallium/drivers/freedreno/ir3/ir3_dump.c @@ -161,12 +161,9 @@ static void dump_instr(struct ir3_dump_ctx *ctx, if (is_meta(instr)) { if ((instr->opc == OPC_META_FO) || (instr->opc == OPC_META_FI)) { - unsigned i; - for (i = 1; i < instr->regs_count; i++) { - struct ir3_register *reg = instr->regs[i]; - if (reg->flags & IR3_REG_SSA) - dump_instr(ctx, reg->instr); - } + struct ir3_instruction *src; + foreach_ssa_src(src, instr) + dump_instr(ctx, src); } else if (instr->opc == OPC_META_FLOW) { struct ir3_register *reg = instr->regs[1]; ir3_block_dump(ctx, instr->flow.if_block, "if"); @@ -226,16 +223,12 @@ static void dump_link2(struct ir3_dump_ctx *ctx, printdef(ctx, defer, "[label=\".%c\"]", "xyzw"[instr->fo.off & 0x3]); } else if (instr->opc == OPC_META_FI) { - unsigned i; - - /* recursively dump all parents and links */ - for (i = 1; i < instr->regs_count; i++) { - struct ir3_register *reg = instr->regs[i]; - if (reg->flags & IR3_REG_SSA) { - dump_link2(ctx, reg->instr, target, defer); - printdef(ctx, defer, "[label=\".%c\"]", - "xyzw"[(i - 1) & 0x3]); - } + struct ir3_instruction *src; + + foreach_ssa_src_n(src, i, instr) { + dump_link2(ctx, src, target, defer); + printdef(ctx, defer, "[label=\".%c\"]", + "xyzw"[i & 0x3]); } } else if (instr->opc == OPC_META_OUTPUT) { printdef(ctx, defer, "output%lx::w -> %s", @@ -274,7 +267,7 @@ static struct ir3_register *follow_flow(struct ir3_register *reg) static void ir3_instr_dump(struct ir3_dump_ctx *ctx, struct ir3_instruction *instr) { - unsigned i; + struct ir3_register *src; fprintf(ctx->f, "instr%lx [shape=record,style=filled,fillcolor=lightgrey,label=\"{", PTRID(instr)); @@ -284,13 +277,13 @@ static void ir3_instr_dump(struct ir3_dump_ctx *ctx, fprintf(ctx->f, "|"); /* source register(s): */ - for (i = 1; i < instr->regs_count; i++) { - struct ir3_register *reg = follow_flow(instr->regs[i]); + foreach_src_n(src, i, instr) { + struct ir3_register *reg = follow_flow(src); fprintf(ctx->f, "|"); if (reg->flags & IR3_REG_SSA) - fprintf(ctx->f, " ", (i - 1)); + fprintf(ctx->f, " ", i); dump_reg_name(ctx, reg, true); } @@ -298,18 +291,18 @@ static void ir3_instr_dump(struct ir3_dump_ctx *ctx, fprintf(ctx->f, "}\"];\n"); /* and recursively dump dependent instructions: */ - for (i = 1; i < instr->regs_count; i++) { - struct ir3_register *reg = instr->regs[i]; + foreach_src_n(src, i, instr) { + struct ir3_register *reg = follow_flow(src); char target[32]; /* link target */ if (!(reg->flags & IR3_REG_SSA)) continue; snprintf(target, sizeof(target), "instr%lx:", - PTRID(instr), (i - 1)); + PTRID(instr), i); dump_instr(ctx, reg->instr); - dump_link(ctx, follow_flow(reg)->instr, instr->block, target); + dump_link(ctx, reg->instr, instr->block, target); } } diff --git a/src/gallium/drivers/freedreno/ir3/ir3_flatten.c b/src/gallium/drivers/freedreno/ir3/ir3_flatten.c index 9389227..419cd9d 100644 --- a/src/gallium/drivers/freedreno/ir3/ir3_flatten.c +++ b/src/gallium/drivers/freedreno/ir3/ir3_flatten.c @@ -65,7 +65,7 @@ static struct ir3_register *unwrap(struct ir3_register *reg) static void ir3_instr_flatten(struct ir3_flatten_ctx *ctx, struct ir3_instruction *instr) { - unsigned i; + struct ir3_instruction *src; /* if we've already visited this instruction, bail now: */ if (ir3_instr_check_mark(instr)) @@ -131,11 +131,8 @@ static void ir3_instr_flatten(struct ir3_flatten_ctx *ctx, } /* recursively visit children: */ - for (i = 1; i < instr->regs_count; i++) { - struct ir3_register *src = instr->regs[i]; - if (src->flags & IR3_REG_SSA) - ir3_instr_flatten(ctx, src->instr); - } + foreach_ssa_src(src, instr) + ir3_instr_flatten(ctx, src); } /* return >= 0 is # of phi's flattened, < 0 is error */ diff --git a/src/gallium/drivers/freedreno/ir3/ir3_group.c b/src/gallium/drivers/freedreno/ir3/ir3_group.c index a571e2e..d48ecc3 100644 --- a/src/gallium/drivers/freedreno/ir3/ir3_group.c +++ b/src/gallium/drivers/freedreno/ir3/ir3_group.c @@ -189,7 +189,7 @@ restart: static void instr_find_neighbors(struct ir3_instruction *instr) { - unsigned i; + struct ir3_instruction *src; if (check_stop(instr)) return; @@ -197,11 +197,8 @@ static void instr_find_neighbors(struct ir3_instruction *instr) if (is_meta(instr) && (instr->opc == OPC_META_FI)) group_n(&instr_ops, instr, instr->regs_count - 1); - for (i = 1; i < instr->regs_count; i++) { - struct ir3_instruction *src_instr = ssa(instr->regs[i]); - if (src_instr) - instr_find_neighbors(src_instr); - } + foreach_ssa_src(src, instr) + instr_find_neighbors(src); } /* a bit of sadness.. we can't have "holes" in inputs from PoV of diff --git a/src/gallium/drivers/freedreno/ir3/ir3_legalize.c b/src/gallium/drivers/freedreno/ir3/ir3_legalize.c index 4e0b42b..db501e7 100644 --- a/src/gallium/drivers/freedreno/ir3/ir3_legalize.c +++ b/src/gallium/drivers/freedreno/ir3/ir3_legalize.c @@ -176,8 +176,7 @@ static void legalize(struct ir3_legalize_ctx *ctx) * their src register(s): */ if (is_tex(n) || is_sfu(n)) { - for (i = 1; i < n->regs_count; i++) { - reg = n->regs[i]; + foreach_src(reg, n) { if (reg_gpr(reg)) regmask_set(&needs_ss_war, reg); } diff --git a/src/gallium/drivers/freedreno/ir3/ir3_ra.c b/src/gallium/drivers/freedreno/ir3/ir3_ra.c index 75ea4d6..03180b1 100644 --- a/src/gallium/drivers/freedreno/ir3/ir3_ra.c +++ b/src/gallium/drivers/freedreno/ir3/ir3_ra.c @@ -389,7 +389,7 @@ static void instr_assign_src(struct ir3_ra_ctx *ctx, static void instr_assign(struct ir3_ra_ctx *ctx, struct ir3_instruction *instr, unsigned name) { - struct ir3_instruction *n; + struct ir3_instruction *n, *src; struct ir3_register *reg = instr->regs[0]; /* check if already assigned: */ @@ -404,12 +404,15 @@ static void instr_assign(struct ir3_ra_ctx *ctx, /* and rename any subsequent use of result of this instr: */ for (n = instr->next; n && !ctx->error; n = n->next) { - unsigned i; + foreach_ssa_src_n(src, i, n) { + unsigned r = i + 1; - for (i = 1; i < n->regs_count; i++) { - reg = n->regs[i]; - if ((reg->flags & IR3_REG_SSA) && (reg->instr == instr)) - instr_assign_src(ctx, n, i, name); + /* skip address / etc (non real sources): */ + if (r >= n->regs_count) + continue; + + if (src == instr) + instr_assign_src(ctx, n, r, name); } } @@ -420,9 +423,9 @@ static void instr_assign(struct ir3_ra_ctx *ctx, * to the actual instruction: */ if (is_meta(instr) && (instr->opc == OPC_META_FO)) { - struct ir3_instruction *src = ssa(instr->regs[1]); debug_assert(name >= instr->fo.off); - if (src) + + foreach_ssa_src(src, instr) instr_assign(ctx, src, name - instr->fo.off); } } diff --git a/src/gallium/drivers/freedreno/ir3/ir3_sched.c b/src/gallium/drivers/freedreno/ir3/ir3_sched.c index 29689db..1288452 100644 --- a/src/gallium/drivers/freedreno/ir3/ir3_sched.c +++ b/src/gallium/drivers/freedreno/ir3/ir3_sched.c @@ -170,14 +170,10 @@ static unsigned delay_calc_srcn(struct ir3_sched_ctx *ctx, unsigned delay = 0; if (is_meta(assigner)) { - unsigned i; - for (i = 1; i < assigner->regs_count; i++) { - struct ir3_register *reg = assigner->regs[i]; - if (reg->flags & IR3_REG_SSA) { - unsigned d = delay_calc_srcn(ctx, reg->instr, - consumer, srcn); - delay = MAX2(delay, d); - } + struct ir3_instruction *src; + foreach_ssa_src(src, assigner) { + unsigned d = delay_calc_srcn(ctx, src, consumer, srcn); + delay = MAX2(delay, d); } } else { delay = ir3_delayslots(assigner, consumer, srcn); @@ -191,15 +187,12 @@ static unsigned delay_calc_srcn(struct ir3_sched_ctx *ctx, static unsigned delay_calc(struct ir3_sched_ctx *ctx, struct ir3_instruction *instr) { - unsigned i, delay = 0; + unsigned delay = 0; + struct ir3_instruction *src; - for (i = 1; i < instr->regs_count; i++) { - struct ir3_register *reg = instr->regs[i]; - if (reg->flags & IR3_REG_SSA) { - unsigned d = delay_calc_srcn(ctx, reg->instr, - instr, i - 1); - delay = MAX2(delay, d); - } + foreach_ssa_src_n(src, i, instr) { + unsigned d = delay_calc_srcn(ctx, src, instr, i); + delay = MAX2(delay, d); } return delay; @@ -213,19 +206,16 @@ static int trysched(struct ir3_sched_ctx *ctx, { struct ir3_instruction *srcs[64]; struct ir3_instruction *src; - unsigned i, delay, nsrcs = 0; + unsigned delay, nsrcs = 0; /* if already scheduled: */ if (instr->flags & IR3_INSTR_MARK) return 0; - debug_assert(instr->regs_count < ARRAY_SIZE(srcs)); - - /* figure out our src's: */ - for (i = 1; i < instr->regs_count; i++) { - struct ir3_register *reg = instr->regs[i]; - if (reg->flags & IR3_REG_SSA) - srcs[nsrcs++] = reg->instr; + /* figure out our src's, copy 'em out into an array for sorting: */ + foreach_ssa_src(src, instr) { + debug_assert(nsrcs < ARRAY_SIZE(srcs)); + srcs[nsrcs++] = src; } /* for each src register in sorted order: @@ -302,16 +292,13 @@ static struct ir3_instruction * reverse(struct ir3_instruction *instr) static bool uses_current_addr(struct ir3_sched_ctx *ctx, struct ir3_instruction *instr) { - unsigned i; - for (i = 1; i < instr->regs_count; i++) { - struct ir3_register *reg = instr->regs[i]; - if (reg->flags & IR3_REG_SSA) { - if (is_addr(reg->instr)) { - struct ir3_instruction *addr; - addr = reg->instr->regs[1]->instr; /* the mova */ - if (ctx->addr == addr) - return true; - } + struct ir3_instruction *src; + foreach_ssa_src(src, instr) { + if (is_addr(src)) { + struct ir3_instruction *addr = + src->regs[1]->instr; /* the mova */ + if (ctx->addr == addr) + return true; } } return false; @@ -320,12 +307,10 @@ static bool uses_current_addr(struct ir3_sched_ctx *ctx, static bool uses_current_pred(struct ir3_sched_ctx *ctx, struct ir3_instruction *instr) { - unsigned i; - for (i = 1; i < instr->regs_count; i++) { - struct ir3_register *reg = instr->regs[i]; - if ((reg->flags & IR3_REG_SSA) && (ctx->pred == reg->instr)) - return true; - } + struct ir3_instruction *src; + foreach_ssa_src(src, instr) + if (ctx->pred == src) + return true; return false; } From robclark at kemper.freedesktop.org Sun Mar 8 21:57:11 2015 From: robclark at kemper.freedesktop.org (Rob Clark) Date: Sun, 8 Mar 2015 14:57:11 -0700 (PDT) Subject: Mesa (master): freedreno/ir3: drop deref nodes Message-ID: <20150308215711.B487376331@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 17754b70d78649f29e25dfe938de91d64dbf5ebf URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=17754b70d78649f29e25dfe938de91d64dbf5ebf Author: Rob Clark Date: Wed Feb 4 16:07:44 2015 -0500 freedreno/ir3: drop deref nodes The meta-deref instruction doesn't really do what we need for relative destination. Instead, since each instruction can reference at most a single address value, track the dependency on the address register via instr->address. This lets us express the dependency regardless of whether it is used for dst and/or src. The foreach_ssa_src{_n} iterator macros now also iterates the address register so, at least in SSA form, the address register behaves as an additional virtual src to the instruction. Which is pretty much what we want, as far as scheduling/etc. TODO: For now, the foreach_src{_n} iterators are unchanged. We could wrap the address in an ir3_register and make the foreach_src_{_n} iterators behave the same way. But that seems unnecessary at this point, since we mainly care about the address dependency when in SSA form. Signed-off-by: Rob Clark --- src/gallium/drivers/freedreno/ir3/instr-a3xx.h | 3 -- src/gallium/drivers/freedreno/ir3/ir3.h | 35 ++++++++-------- src/gallium/drivers/freedreno/ir3/ir3_compiler.c | 46 ++++++---------------- src/gallium/drivers/freedreno/ir3/ir3_cp.c | 3 ++ src/gallium/drivers/freedreno/ir3/ir3_dump.c | 16 ++++---- src/gallium/drivers/freedreno/ir3/ir3_ra.c | 19 ++++----- src/gallium/drivers/freedreno/ir3/ir3_sched.c | 11 +----- 7 files changed, 53 insertions(+), 80 deletions(-) diff --git a/src/gallium/drivers/freedreno/ir3/instr-a3xx.h b/src/gallium/drivers/freedreno/ir3/instr-a3xx.h index b7e19c8..c685fb1 100644 --- a/src/gallium/drivers/freedreno/ir3/instr-a3xx.h +++ b/src/gallium/drivers/freedreno/ir3/instr-a3xx.h @@ -204,9 +204,6 @@ typedef enum { /* branches/flow control */ OPC_META_FLOW = 4, OPC_META_PHI = 5, - /* relative addressing */ - OPC_META_DEREF = 6, - } opc_t; diff --git a/src/gallium/drivers/freedreno/ir3/ir3.h b/src/gallium/drivers/freedreno/ir3/ir3.h index 3d3ad07..3093285 100644 --- a/src/gallium/drivers/freedreno/ir3/ir3.h +++ b/src/gallium/drivers/freedreno/ir3/ir3.h @@ -79,18 +79,19 @@ struct ir3_register { * the component is in the low two bits of the reg #, so * rN.x becomes: (N << 2) | x */ - int num; + int num; /* immediate: */ - int iim_val; - float fim_val; + int iim_val; + float fim_val; /* relative: */ - int offset; - /* for IR3_REG_SSA, src registers contain ptr back to - * assigning instruction. - */ - struct ir3_instruction *instr; + int offset; }; + /* for IR3_REG_SSA, src registers contain ptr back to + * assigning instruction. + */ + struct ir3_instruction *instr; + union { /* used for cat5 instructions, but also for internal/IR level * tracking of what registers are read/written by an instruction. @@ -209,9 +210,6 @@ struct ir3_instruction { struct { struct ir3_block *block; } inout; - struct { - int off; /* offset relative to addr reg */ - } deref; /* XXX keep this as big as all other union members! */ uint32_t info[3]; @@ -260,6 +258,12 @@ struct ir3_instruction { struct ir3_instruction *left, *right; uint16_t left_cnt, right_cnt; } cp; + + /* an instruction can reference at most one address register amongst + * it's src/dst registers. Beyond that, you need to insert mov's. + */ + struct ir3_instruction *address; + struct ir3_instruction *next; #ifdef DEBUG uint32_t serialno; @@ -445,11 +449,6 @@ static inline bool is_meta(struct ir3_instruction *instr) return (instr->category == -1); } -static inline bool is_addr(struct ir3_instruction *instr) -{ - return is_meta(instr) && (instr->opc == OPC_META_DEREF); -} - static inline bool writes_addr(struct ir3_instruction *instr) { if (instr->regs_count > 0) { @@ -499,11 +498,15 @@ static inline bool reg_gpr(struct ir3_register *r) static inline unsigned __ssa_src_cnt(struct ir3_instruction *instr) { + if (instr->address) + return instr->regs_count + 1; return instr->regs_count; } static inline struct ir3_instruction * __ssa_src_n(struct ir3_instruction *instr, unsigned n) { + if (n == (instr->regs_count + 0)) + return instr->address; return ssa(instr->regs[n]); } diff --git a/src/gallium/drivers/freedreno/ir3/ir3_compiler.c b/src/gallium/drivers/freedreno/ir3/ir3_compiler.c index 8551eeb..4b73390 100644 --- a/src/gallium/drivers/freedreno/ir3/ir3_compiler.c +++ b/src/gallium/drivers/freedreno/ir3/ir3_compiler.c @@ -624,16 +624,18 @@ ssa_src(struct ir3_compile_context *ctx, struct ir3_register *reg, * we must generate a fanin instruction to collect all possible * array elements that the instruction could address together: */ - unsigned i, j, aid = src_array_id(ctx, src); + unsigned aid = src_array_id(ctx, src); + unsigned first = ctx->array[aid].first; + unsigned last = ctx->array[aid].last; + unsigned off = src->Index - first; /* vec4 offset */ + unsigned i, j; + + reg->size = 4 * (1 + last - first); + reg->offset = regid(off, chan); if (ctx->array[aid].fanin) { instr = ctx->array[aid].fanin; } else { - unsigned first, last; - - first = ctx->array[aid].first; - last = ctx->array[aid].last; - instr = ir3_instr_create2(ctx->block, -1, OPC_META_FI, 1 + (4 * (last + 1 - first))); ir3_reg_create(instr, 0, 0); @@ -756,7 +758,6 @@ add_src_reg_wrmask(struct ir3_compile_context *ctx, { unsigned flags = 0, num = 0; struct ir3_register *reg; - struct ir3_instruction *orig = NULL; switch (src->File) { case TGSI_FILE_IMMEDIATE: @@ -815,28 +816,15 @@ add_src_reg_wrmask(struct ir3_compile_context *ctx, /* shouldn't happen, and we can't cope with it below: */ compile_assert(ctx, wrmask == 0x1); - /* wrap in a meta-deref to track both the src and address: */ - orig = instr; - - instr = ir3_instr_create(ctx->block, -1, OPC_META_DEREF); - ir3_reg_create(instr, 0, 0); - ir3_reg_create(instr, 0, IR3_REG_SSA)->instr = ctx->block->address; + compile_assert(ctx, ctx->block->address); + if (instr->address) + compile_assert(ctx, ctx->block->address == instr->address); - if (src->File != TGSI_FILE_CONSTANT) { - unsigned aid = src_array_id(ctx, src); - unsigned off = src->Index - ctx->array[aid].first; /* vec4 offset */ - instr->deref.off = regid(off, chan); - } + instr->address = ctx->block->address; } reg = ir3_reg_create(instr, regid(num, chan), flags); - - if (src->Indirect && (src->File != TGSI_FILE_CONSTANT)) { - unsigned aid = src_array_id(ctx, src); - reg->size = 4 * (1 + ctx->array[aid].last - ctx->array[aid].first); - } else { - reg->wrmask = wrmask; - } + reg->wrmask = wrmask; if (wrmask == 0x1) { /* normal case */ @@ -872,14 +860,6 @@ add_src_reg_wrmask(struct ir3_compile_context *ctx, reg->instr = collect; } - if (src->Indirect) { - unsigned size = reg->size; - - reg = ir3_reg_create(orig, 0, flags | IR3_REG_SSA); - reg->instr = instr; - reg->size = size; - } - return reg; } diff --git a/src/gallium/drivers/freedreno/ir3/ir3_cp.c b/src/gallium/drivers/freedreno/ir3/ir3_cp.c index b70aba9..898ed70 100644 --- a/src/gallium/drivers/freedreno/ir3/ir3_cp.c +++ b/src/gallium/drivers/freedreno/ir3/ir3_cp.c @@ -95,6 +95,9 @@ instr_cp(struct ir3_instruction *instr) foreach_src(reg, instr) if (reg->flags & IR3_REG_SSA) reg->instr = instr_cp(reg->instr); + + if (instr->address) + instr->address = instr_cp(instr->address); } return instr; diff --git a/src/gallium/drivers/freedreno/ir3/ir3_dump.c b/src/gallium/drivers/freedreno/ir3/ir3_dump.c index 42a38d7..a846777 100644 --- a/src/gallium/drivers/freedreno/ir3/ir3_dump.c +++ b/src/gallium/drivers/freedreno/ir3/ir3_dump.c @@ -58,9 +58,6 @@ static void dump_instr_name(struct ir3_dump_ctx *ctx, case OPC_META_PHI: fprintf(ctx->f, "Φ"); break; - case OPC_META_DEREF: - fprintf(ctx->f, "(*)"); - break; default: /* shouldn't hit here.. just for debugging: */ switch (instr->opc) { @@ -171,8 +168,7 @@ static void dump_instr(struct ir3_dump_ctx *ctx, ir3_block_dump(ctx, instr->flow.else_block, "else"); if (reg->flags & IR3_REG_SSA) dump_instr(ctx, reg->instr); - } else if ((instr->opc == OPC_META_PHI) || - (instr->opc == OPC_META_DEREF)) { + } else if (instr->opc == OPC_META_PHI) { /* treat like a normal instruction: */ ir3_instr_dump(ctx, instr); } @@ -234,8 +230,7 @@ static void dump_link2(struct ir3_dump_ctx *ctx, printdef(ctx, defer, "output%lx::w -> %s", PTRID(instr->inout.block), instr->regs[0]->num, target); - } else if ((instr->opc == OPC_META_PHI) || - (instr->opc == OPC_META_DEREF)) { + } else if (instr->opc == OPC_META_PHI) { /* treat like a normal instruction: */ printdef(ctx, defer, "instr%lx: -> %s", PTRID(instr), target); } @@ -412,6 +407,13 @@ ir3_dump_instr_single(struct ir3_instruction *instr) dump_reg_name(&ctx, reg, !!i); } + if (instr->address) { + fprintf(ctx.f, ", address=_"); + fprintf(ctx.f, "["); + dump_instr_name(&ctx, instr->address); + fprintf(ctx.f, "]"); + } + if (is_meta(instr) && (instr->opc == OPC_META_FO)) printf(", off=%d", instr->fo.off); diff --git a/src/gallium/drivers/freedreno/ir3/ir3_ra.c b/src/gallium/drivers/freedreno/ir3/ir3_ra.c index 03180b1..0f6d40f 100644 --- a/src/gallium/drivers/freedreno/ir3/ir3_ra.c +++ b/src/gallium/drivers/freedreno/ir3/ir3_ra.c @@ -357,6 +357,11 @@ static void instr_assign(struct ir3_ra_ctx *ctx, static void instr_assign_src(struct ir3_ra_ctx *ctx, struct ir3_instruction *instr, unsigned r, unsigned name) { + struct ir3_register *reg = instr->regs[r]; + + if (reg->flags & IR3_REG_RELATIV) + name += reg->offset; + reg_assign(instr, r, name); if (is_meta(instr)) { @@ -372,14 +377,6 @@ static void instr_assign_src(struct ir3_ra_ctx *ctx, case OPC_META_FI: instr_assign(ctx, instr, name - (r - 1)); return; - case OPC_META_DEREF: - /* first arg of meta:deref is the addr reg (do not - * propagate), 2nd is actual src (fanin) which does - * get propagated) - */ - if (r == 2) - instr_assign(ctx, instr, name + instr->deref.off); - break; default: break; } @@ -392,6 +389,9 @@ static void instr_assign(struct ir3_ra_ctx *ctx, struct ir3_instruction *n, *src; struct ir3_register *reg = instr->regs[0]; + if ((reg->flags & IR3_REG_RELATIV)) + name += reg->offset; + /* check if already assigned: */ if (!(reg->flags & IR3_REG_SSA)) { /* ... and if so, sanity check: */ @@ -484,9 +484,6 @@ static void instr_alloc_and_assign(struct ir3_ra_ctx *ctx, /* allocate register(s): */ if (name >= 0) { /* already partially assigned, just finish the job */ - } else if (is_addr(instr)) { - debug_assert(!instr->cp.right); - name = instr->regs[2]->num + instr->deref.off; } else if (reg_gpr(dst)) { int size; /* number of consecutive registers to assign: */ diff --git a/src/gallium/drivers/freedreno/ir3/ir3_sched.c b/src/gallium/drivers/freedreno/ir3/ir3_sched.c index 1288452..909ecc2 100644 --- a/src/gallium/drivers/freedreno/ir3/ir3_sched.c +++ b/src/gallium/drivers/freedreno/ir3/ir3_sched.c @@ -292,16 +292,7 @@ static struct ir3_instruction * reverse(struct ir3_instruction *instr) static bool uses_current_addr(struct ir3_sched_ctx *ctx, struct ir3_instruction *instr) { - struct ir3_instruction *src; - foreach_ssa_src(src, instr) { - if (is_addr(src)) { - struct ir3_instruction *addr = - src->regs[1]->instr; /* the mova */ - if (ctx->addr == addr) - return true; - } - } - return false; + return instr->address && (ctx->addr == instr->address); } static bool uses_current_pred(struct ir3_sched_ctx *ctx, From robclark at kemper.freedesktop.org Sun Mar 8 21:57:11 2015 From: robclark at kemper.freedesktop.org (Rob Clark) Date: Sun, 8 Mar 2015 14:57:11 -0700 (PDT) Subject: Mesa (master): freedreno/ir3: split out array_fanin() helper Message-ID: <20150308215711.BE8827633D@kemper.freedesktop.org> Module: Mesa Branch: master Commit: b7703212d8dc2b38407565768ac45d1a307cd810 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=b7703212d8dc2b38407565768ac45d1a307cd810 Author: Rob Clark Date: Wed Feb 4 13:41:42 2015 -0500 freedreno/ir3: split out array_fanin() helper We'll need this too for relative dst.. Signed-off-by: Rob Clark --- src/gallium/drivers/freedreno/ir3/ir3_compiler.c | 47 ++++++++++++++-------- 1 file changed, 30 insertions(+), 17 deletions(-) diff --git a/src/gallium/drivers/freedreno/ir3/ir3_compiler.c b/src/gallium/drivers/freedreno/ir3/ir3_compiler.c index 4b73390..d755bab 100644 --- a/src/gallium/drivers/freedreno/ir3/ir3_compiler.c +++ b/src/gallium/drivers/freedreno/ir3/ir3_compiler.c @@ -606,6 +606,35 @@ static int src_array_id(struct ir3_compile_context *ctx, return fsrc->Indirect.ArrayID + ctx->array_offsets[src->File]; } +static struct ir3_instruction * +array_fanin(struct ir3_compile_context *ctx, unsigned aid, unsigned file) +{ + struct ir3_instruction *instr; + + if (ctx->array[aid].fanin) { + instr = ctx->array[aid].fanin; + } else { + unsigned first = ctx->array[aid].first; + unsigned last = ctx->array[aid].last; + unsigned i, j; + + instr = ir3_instr_create2(ctx->block, -1, OPC_META_FI, + 1 + (4 * (last + 1 - first))); + ir3_reg_create(instr, 0, 0); + for (i = first; i <= last; i++) { + for (j = 0; j < 4; j++) { + unsigned n = regid(i, j); + ir3_reg_create(instr, 0, IR3_REG_SSA)->instr = + ssa_instr_get(ctx, file, n); + } + } + ctx->array[aid].fanin = instr; + ctx->array_dirty |= (1 << aid); + } + + return instr; +} + static void ssa_dst(struct ir3_compile_context *ctx, struct ir3_instruction *instr, const struct tgsi_dst_register *dst, unsigned chan) @@ -628,27 +657,11 @@ ssa_src(struct ir3_compile_context *ctx, struct ir3_register *reg, unsigned first = ctx->array[aid].first; unsigned last = ctx->array[aid].last; unsigned off = src->Index - first; /* vec4 offset */ - unsigned i, j; reg->size = 4 * (1 + last - first); reg->offset = regid(off, chan); - if (ctx->array[aid].fanin) { - instr = ctx->array[aid].fanin; - } else { - instr = ir3_instr_create2(ctx->block, -1, OPC_META_FI, - 1 + (4 * (last + 1 - first))); - ir3_reg_create(instr, 0, 0); - for (i = first; i <= last; i++) { - for (j = 0; j < 4; j++) { - unsigned n = regid(i, j); - ir3_reg_create(instr, 0, IR3_REG_SSA)->instr = - ssa_instr_get(ctx, src->File, n); - } - } - ctx->array[aid].fanin = instr; - ctx->array_dirty |= (1 << aid); - } + instr = array_fanin(ctx, aid, src->File); } else { /* normal case (not relative addressed GPR) */ instr = ssa_instr_get(ctx, src->File, regid(src->Index, chan)); From robclark at kemper.freedesktop.org Sun Mar 8 21:57:11 2015 From: robclark at kemper.freedesktop.org (Rob Clark) Date: Sun, 8 Mar 2015 14:57:11 -0700 (PDT) Subject: Mesa (master): freedreno/ir3: relative dst Message-ID: <20150308215711.CBC2E76331@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 060d3499202c339a27fbc366335f2122ed4ff7bc URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=060d3499202c339a27fbc366335f2122ed4ff7bc Author: Rob Clark Date: Fri Jan 23 15:04:46 2015 -0500 freedreno/ir3: relative dst To simplify RA, assign arrays that are written to first. Since enough dependency information is in the graph to preserve order of reads and writes of array, so all SSA names for the array collapse into one, just assign the entire thing by array-id. Signed-off-by: Rob Clark --- src/gallium/drivers/freedreno/ir3/ir3.h | 22 ++++ src/gallium/drivers/freedreno/ir3/ir3_compiler.c | 99 +++++++++++++-- src/gallium/drivers/freedreno/ir3/ir3_cp.c | 2 +- src/gallium/drivers/freedreno/ir3/ir3_dump.c | 16 ++- src/gallium/drivers/freedreno/ir3/ir3_ra.c | 147 +++++++++++++++++----- 5 files changed, 244 insertions(+), 42 deletions(-) diff --git a/src/gallium/drivers/freedreno/ir3/ir3.h b/src/gallium/drivers/freedreno/ir3/ir3.h index 3093285..430bcf2 100644 --- a/src/gallium/drivers/freedreno/ir3/ir3.h +++ b/src/gallium/drivers/freedreno/ir3/ir3.h @@ -205,6 +205,9 @@ struct ir3_instruction { int off; /* component/offset */ } fo; struct { + int aid; + } fi; + struct { struct ir3_block *if_block, *else_block; } flow; struct { @@ -264,6 +267,19 @@ struct ir3_instruction { */ struct ir3_instruction *address; + /* in case of a instruction with relative dst instruction, we need to + * capture the dependency on the fanin for the previous values of + * the array elements. Since we don't know at compile time actually + * which array elements are written, this serves to preserve the + * unconditional write to array elements prior to the conditional + * write. + * + * TODO only cat1 can do indirect write.. we could maybe move this + * into instr->cat1.fanin (but would require the frontend to insert + * the extra mov) + */ + struct ir3_instruction *fanin; + struct ir3_instruction *next; #ifdef DEBUG uint32_t serialno; @@ -373,6 +389,8 @@ static inline int ir3_instr_regno(struct ir3_instruction *instr, } +#define MAX_ARRAYS 16 + /* comp: * 0 - x * 1 - y @@ -498,6 +516,8 @@ static inline bool reg_gpr(struct ir3_register *r) static inline unsigned __ssa_src_cnt(struct ir3_instruction *instr) { + if (instr->fanin) + return instr->regs_count + 2; if (instr->address) return instr->regs_count + 1; return instr->regs_count; @@ -505,6 +525,8 @@ static inline unsigned __ssa_src_cnt(struct ir3_instruction *instr) static inline struct ir3_instruction * __ssa_src_n(struct ir3_instruction *instr, unsigned n) { + if (n == (instr->regs_count + 1)) + return instr->fanin; if (n == (instr->regs_count + 0)) return instr->address; return ssa(instr->regs[n]); diff --git a/src/gallium/drivers/freedreno/ir3/ir3_compiler.c b/src/gallium/drivers/freedreno/ir3/ir3_compiler.c index d755bab..df428eb 100644 --- a/src/gallium/drivers/freedreno/ir3/ir3_compiler.c +++ b/src/gallium/drivers/freedreno/ir3/ir3_compiler.c @@ -64,7 +64,7 @@ struct ir3_compile_context { */ struct { struct ir3_instruction *instr, **instrp; - } output_updates[16]; + } output_updates[64]; unsigned num_output_updates; /* are we in a sequence of "atomic" instructions? @@ -97,7 +97,7 @@ struct ir3_compile_context { struct { unsigned first, last; struct ir3_instruction *fanin; - } array[16]; + } array[MAX_ARRAYS]; uint32_t array_dirty; /* offset into array[], per file, of first array info */ uint8_t array_offsets[TGSI_FILE_COUNT]; @@ -247,10 +247,6 @@ compile_init(struct ir3_compile_context *ctx, struct ir3_shader_variant *so, memset(ctx->array_offsets, 0, sizeof(ctx->array_offsets)); #define FM(x) (1 << TGSI_FILE_##x) - /* optimize can't deal with relative addressing: */ - if (info->indirect_files_written & (FM(TEMPORARY) | FM(INPUT) | FM(OUTPUT))) - return TGSI_PARSE_ERROR; - /* NOTE: if relative addressing is used, we set constlen in * the compiler (to worst-case value) since we don't know in * the assembler what the max addr reg value can be: @@ -595,6 +591,16 @@ ssa_instr_get(struct ir3_compile_context *ctx, unsigned file, unsigned n) return instr; } +static int dst_array_id(struct ir3_compile_context *ctx, + const struct tgsi_dst_register *dst) +{ + // XXX complete hack to recover tgsi_full_dst_register... + // nothing that isn't wrapped in a tgsi_full_dst_register + // should be indirect + const struct tgsi_full_dst_register *fdst = (const void *)dst; + return fdst->Indirect.ArrayID + ctx->array_offsets[dst->File]; +} + static int src_array_id(struct ir3_compile_context *ctx, const struct tgsi_src_register *src) { @@ -639,7 +645,56 @@ static void ssa_dst(struct ir3_compile_context *ctx, struct ir3_instruction *instr, const struct tgsi_dst_register *dst, unsigned chan) { - ssa_instr_set(ctx, dst->File, regid(dst->Index, chan), instr); + if (dst->Indirect) { + struct ir3_register *reg = instr->regs[0]; + unsigned i, aid = dst_array_id(ctx, dst); + unsigned first = ctx->array[aid].first; + unsigned last = ctx->array[aid].last; + unsigned off = dst->Index - first; /* vec4 offset */ + + reg->size = 4 * (1 + last - first); + reg->offset = regid(off, chan); + + instr->fanin = array_fanin(ctx, aid, dst->File); + + /* annotate with the array-id, to help out the register- + * assignment stage. At least for the case of indirect + * writes, we should capture enough dependencies to + * preserve the order of reads/writes of the array, so + * the multiple "names" for the array should end up all + * assigned to the same registers. + */ + instr->fanin->fi.aid = aid; + + /* Since we are scalarizing vec4 tgsi instructions/regs, we + * run into a slight complication here. To do the naive thing + * and setup a fanout for each scalar array element would end + * up with the result that the instructions generated for each + * component of the vec4 would end up clobbering each other. + * So we take advantage here of knowing that the array index + * (after the shl.b) will be a multiple of four, and only set + * every fourth scalar component in the array. See also + * fixup_ssa_dst_array() + */ + for (i = first; i <= last; i++) { + struct ir3_instruction *split; + unsigned n = regid(i, chan); + int off = (4 * (i - first)) + chan; + + if (is_meta(instr) && (instr->opc == OPC_META_FO)) + off -= instr->fo.off; + + split = ir3_instr_create(ctx->block, -1, OPC_META_FO); + split->fo.off = off; + ir3_reg_create(split, 0, 0); + ir3_reg_create(split, 0, IR3_REG_SSA)->instr = instr; + + ssa_instr_set(ctx, dst->File, n, split); + } + } else { + /* normal case (not relative addressed GPR) */ + ssa_instr_set(ctx, dst->File, regid(dst->Index, chan), instr); + } } static void @@ -705,12 +760,22 @@ add_dst_reg_wrmask(struct ir3_compile_context *ctx, break; } - if (dst->Indirect) + if (dst->Indirect) { flags |= IR3_REG_RELATIV; - reg = ir3_reg_create(instr, regid(num, chan), flags); + /* shouldn't happen, and we can't cope with it below: */ + compile_assert(ctx, wrmask == 0x1); + + compile_assert(ctx, ctx->block->address); + if (instr->address) + compile_assert(ctx, ctx->block->address == instr->address); + + instr->address = ctx->block->address; + } + reg = ir3_reg_create(instr, regid(num, chan), flags); reg->wrmask = wrmask; + if (wrmask == 0x1) { /* normal case */ ssa_dst(ctx, instr, dst, chan); @@ -720,6 +785,8 @@ add_dst_reg_wrmask(struct ir3_compile_context *ctx, struct ir3_instruction *prev = NULL; unsigned i; + compile_assert(ctx, !dst->Indirect); + /* if instruction writes multiple, we need to create * some place-holder collect the registers: */ @@ -2539,10 +2606,16 @@ instr_cat1(const struct instr_translater *t, struct ir3_compile_context *ctx, struct tgsi_full_instruction *inst) { - struct tgsi_dst_register *dst = get_dst(ctx, inst); + struct tgsi_dst_register *dst = &inst->Dst[0].Register; struct tgsi_src_register *src = &inst->Src[0].Register; + + /* NOTE: atomic start/end, rather than in create_mov() since + * create_mov() is used already w/in atomic sequences (and + * we aren't clever enough to deal with the nesting) + */ + instr_atomic_start(ctx); create_mov(ctx, dst, src); - put_dst(ctx, inst, dst); + instr_atomic_end(ctx); } static void @@ -3322,6 +3395,10 @@ ir3_compile_shader(struct ir3_shader_variant *so, goto out; } + /* for now, until the edge cases are worked out: */ + if (ctx.info.indirect_files_written & (FM(TEMPORARY) | FM(INPUT) | FM(OUTPUT))) + cp = false; + compile_instructions(&ctx); block = ctx.block; diff --git a/src/gallium/drivers/freedreno/ir3/ir3_cp.c b/src/gallium/drivers/freedreno/ir3/ir3_cp.c index 898ed70..8ad1894 100644 --- a/src/gallium/drivers/freedreno/ir3/ir3_cp.c +++ b/src/gallium/drivers/freedreno/ir3/ir3_cp.c @@ -49,7 +49,7 @@ static bool is_eligible_mov(struct ir3_instruction *instr) struct ir3_register *dst = instr->regs[0]; struct ir3_register *src = instr->regs[1]; struct ir3_instruction *src_instr = ssa(src); - if (dst->flags & IR3_REG_ADDR) + if (dst->flags & (IR3_REG_ADDR | IR3_REG_RELATIV)) return false; /* TODO: propagate abs/neg modifiers if possible */ if (src->flags & (IR3_REG_ABS | IR3_REG_NEGATE | IR3_REG_RELATIV)) diff --git a/src/gallium/drivers/freedreno/ir3/ir3_dump.c b/src/gallium/drivers/freedreno/ir3/ir3_dump.c index a846777..dc25165 100644 --- a/src/gallium/drivers/freedreno/ir3/ir3_dump.c +++ b/src/gallium/drivers/freedreno/ir3/ir3_dump.c @@ -414,8 +414,20 @@ ir3_dump_instr_single(struct ir3_instruction *instr) fprintf(ctx.f, "]"); } - if (is_meta(instr) && (instr->opc == OPC_META_FO)) - printf(", off=%d", instr->fo.off); + if (instr->fanin) { + fprintf(ctx.f, ", fanin=_"); + fprintf(ctx.f, "["); + dump_instr_name(&ctx, instr->fanin); + fprintf(ctx.f, "]"); + } + + if (is_meta(instr)) { + if (instr->opc == OPC_META_FO) { + printf(", off=%d", instr->fo.off); + } else if ((instr->opc == OPC_META_FI) && instr->fi.aid) { + printf(", aid=%d", instr->fi.aid); + } + } printf("\n"); } diff --git a/src/gallium/drivers/freedreno/ir3/ir3_ra.c b/src/gallium/drivers/freedreno/ir3/ir3_ra.c index 0f6d40f..a4235a7 100644 --- a/src/gallium/drivers/freedreno/ir3/ir3_ra.c +++ b/src/gallium/drivers/freedreno/ir3/ir3_ra.c @@ -47,6 +47,12 @@ * I'm not really sure a sane way for the CP stage to realize when it * cannot remove a mov due to multi-register constraints.. * + * NOTE: http://scopesconf.org/scopes-01/paper/session1_2.ps.gz has + * some ideas to handle array allocation with a more conventional + * graph coloring algorithm for register assignment, which might be + * a good alternative to the current algo. However afaict it cannot + * handle overlapping arrays, which is a scenario that we have to + * deal with */ struct ir3_ra_ctx { @@ -56,6 +62,10 @@ struct ir3_ra_ctx { bool frag_face; int cnt; bool error; + struct { + unsigned base; + unsigned size; + } arrays[MAX_ARRAYS]; }; #ifdef DEBUG @@ -141,6 +151,26 @@ static bool instr_is_output(struct ir3_instruction *instr) return false; } +static void mark_sources(struct ir3_instruction *instr, + struct ir3_instruction *n, regmask_t *liveregs, regmask_t *written) +{ + unsigned i; + + for (i = 1; i < n->regs_count; i++) { + struct ir3_register *r = reg_check(n, i); + if (r) + regmask_set_if_not(liveregs, r, written); + + /* if any src points back to the instruction(s) in + * the block of neighbors that we are assigning then + * mark any written (clobbered) registers as live: + */ + if (instr_used_by(instr, n->regs[i])) + regmask_or(liveregs, liveregs, written); + } + +} + /* live means read before written */ static void compute_liveregs(struct ir3_ra_ctx *ctx, struct ir3_instruction *instr, regmask_t *liveregs) @@ -159,18 +189,13 @@ static void compute_liveregs(struct ir3_ra_ctx *ctx, continue; /* check first src's read: */ - for (i = 1; i < n->regs_count; i++) { - r = reg_check(n, i); - if (r) - regmask_set_if_not(liveregs, r, &written); - - /* if any src points back to the instruction(s) in - * the block of neighbors that we are assigning then - * mark any written (clobbered) registers as live: - */ - if (instr_used_by(instr, n->regs[i])) - regmask_or(liveregs, liveregs, &written); - } + mark_sources(instr, n, liveregs, &written); + + /* for instructions that write to an array, we need to + * capture the dependency on the array elements: + */ + if (n->fanin) + mark_sources(instr, n->fanin, liveregs, &written); /* meta-instructions don't actually get scheduled, * so don't let it's write confuse us.. what we @@ -383,14 +408,32 @@ static void instr_assign_src(struct ir3_ra_ctx *ctx, } } -static void instr_assign(struct ir3_ra_ctx *ctx, +static void instr_assign_srcs(struct ir3_ra_ctx *ctx, struct ir3_instruction *instr, unsigned name) { struct ir3_instruction *n, *src; + + for (n = instr->next; n && !ctx->error; n = n->next) { + foreach_ssa_src_n(src, i, n) { + unsigned r = i + 1; + + /* skip address / etc (non real sources): */ + if (r >= n->regs_count) + continue; + + if (src == instr) + instr_assign_src(ctx, n, r, name); + } + } +} + +static void instr_assign(struct ir3_ra_ctx *ctx, + struct ir3_instruction *instr, unsigned name) +{ struct ir3_register *reg = instr->regs[0]; - if ((reg->flags & IR3_REG_RELATIV)) - name += reg->offset; + if (reg->flags & IR3_REG_RELATIV) + return; /* check if already assigned: */ if (!(reg->flags & IR3_REG_SSA)) { @@ -403,18 +446,7 @@ static void instr_assign(struct ir3_ra_ctx *ctx, reg_assign(instr, 0, name); /* and rename any subsequent use of result of this instr: */ - for (n = instr->next; n && !ctx->error; n = n->next) { - foreach_ssa_src_n(src, i, n) { - unsigned r = i + 1; - - /* skip address / etc (non real sources): */ - if (r >= n->regs_count) - continue; - - if (src == instr) - instr_assign_src(ctx, n, r, name); - } - } + instr_assign_srcs(ctx, instr, name); /* To simplify the neighbor logic, and to "avoid" dealing with * instructions which write more than one output, we actually @@ -423,6 +455,8 @@ static void instr_assign(struct ir3_ra_ctx *ctx, * to the actual instruction: */ if (is_meta(instr) && (instr->opc == OPC_META_FO)) { + struct ir3_instruction *src; + debug_assert(name >= instr->fo.off); foreach_ssa_src(src, instr) @@ -444,7 +478,8 @@ static int check_partial_assignment(struct ir3_ra_ctx *ctx, for (n = instr; n; n = n->cp.right) { struct ir3_register *dst = n->regs[0]; - if (!(dst->flags & IR3_REG_SSA)) { + if ((n->depth != DEPTH_UNUSED) && + !(dst->flags & IR3_REG_SSA)) { int name = dst->num - off; debug_assert(name >= 0); return name; @@ -472,6 +507,23 @@ static void instr_alloc_and_assign(struct ir3_ra_ctx *ctx, dst = instr->regs[0]; + /* For indirect dst, take the register assignment from the + * fanin and propagate it forward. + */ + if (dst->flags & IR3_REG_RELATIV) { + /* NOTE can be grouped, if for example outputs: + * for now disable cp if indirect writes + */ + instr_alloc_and_assign(ctx, instr->fanin); + + dst->num += instr->fanin->regs[0]->num; + dst->flags &= ~IR3_REG_SSA; + + instr_assign_srcs(ctx, instr, instr->fanin->regs[0]->num); + + return; + } + /* for instructions w/ fanouts, do the actual register assignment * on the group of fanout neighbor nodes and propagate the reg * name back up to the texture instruction. @@ -510,6 +562,33 @@ static void instr_alloc_and_assign(struct ir3_ra_ctx *ctx, } } +static void instr_assign_array(struct ir3_ra_ctx *ctx, + struct ir3_instruction *instr) +{ + struct ir3_instruction *src; + int name, aid = instr->fi.aid; + + if (ctx->arrays[aid].base == ~0) { + int size = instr->regs_count - 1; + ctx->arrays[aid].base = alloc_block(ctx, instr, size); + ctx->arrays[aid].size = size; + } + + name = ctx->arrays[aid].base; + + foreach_ssa_src_n(src, i, instr) { + unsigned r = i + 1; + + /* skip address / etc (non real sources): */ + if (r >= instr->regs_count) + break; + + instr_assign(ctx, src, name); + name++; + } + +} + static int block_ra(struct ir3_ra_ctx *ctx, struct ir3_block *block) { struct ir3_instruction *n; @@ -531,6 +610,16 @@ static int block_ra(struct ir3_ra_ctx *ctx, struct ir3_block *block) ra_dump_list("-------\n", block->head); + /* first pass, assign arrays: */ + for (n = block->head; n && !ctx->error; n = n->next) { + if (is_meta(n) && (n->opc == OPC_META_FI) && n->fi.aid) { + debug_assert(!n->cp.left); /* don't think this should happen */ + ra_dump_instr("ASSIGN ARRAY: ", n); + instr_assign_array(ctx, n); + ra_dump_list("-------\n", block->head); + } + } + for (n = block->head; n && !ctx->error; n = n->next) { ra_dump_instr("ASSIGN: ", n); instr_alloc_and_assign(ctx, ir3_neighbor_first(n)); @@ -552,6 +641,8 @@ int ir3_block_ra(struct ir3_block *block, enum shader_t type, }; int ret; + memset(&ctx.arrays, ~0, sizeof(ctx.arrays)); + /* mark dst registers w/ SSA flag so we can see which * have been assigned so far: * NOTE: we really should set SSA flag consistently on From robclark at kemper.freedesktop.org Sun Mar 8 21:57:11 2015 From: robclark at kemper.freedesktop.org (Rob Clark) Date: Sun, 8 Mar 2015 14:57:11 -0700 (PDT) Subject: Mesa (master): freedreno: replace glsl130 debug flag with glsl120 Message-ID: <20150308215711.E0B4976331@kemper.freedesktop.org> Module: Mesa Branch: master Commit: fd17db6fe51da8878472582329553cbae663f1db URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=fd17db6fe51da8878472582329553cbae663f1db Author: Rob Clark Date: Sun Mar 8 13:38:51 2015 -0400 freedreno: replace glsl130 debug flag with glsl120 Now that relative-dst works, we should never fall back to the old compiler. (Which is almost true, other than a couple edge case sched fails in piglit). So replace glsl130 flag to force GLSL 130 and integers on a3xx/a4xx with a glsl120 flag to force GLSL 120 and !integers. If this commit breaks any game/app/etc use FD_MESA_DEBUG=glsl120 as a workaround and please let me know. Signed-off-by: Rob Clark --- src/gallium/drivers/freedreno/freedreno_screen.c | 20 +++++++++----------- src/gallium/drivers/freedreno/freedreno_util.h | 2 +- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/src/gallium/drivers/freedreno/freedreno_screen.c b/src/gallium/drivers/freedreno/freedreno_screen.c index 3e9a3f3..31f596c 100644 --- a/src/gallium/drivers/freedreno/freedreno_screen.c +++ b/src/gallium/drivers/freedreno/freedreno_screen.c @@ -70,7 +70,7 @@ static const struct debug_named_value debug_options[] = { {"noopt", FD_DBG_NOOPT , "Disable optimization passes in compiler"}, {"optmsgs", FD_DBG_OPTMSGS,"Enable optimizater debug messages"}, {"optdump", FD_DBG_OPTDUMP,"Dump shader DAG to .dot files"}, - {"glsl130", FD_DBG_GLSL130,"Temporary flag to enable GLSL 130 on a3xx+"}, + {"glsl120", FD_DBG_GLSL120,"Temporary flag to force GLSL 120 (rather than 130) on a3xx+"}, {"nocp", FD_DBG_NOCP, "Disable copy-propagation"}, DEBUG_NAMED_VALUE_END }; @@ -79,7 +79,7 @@ DEBUG_GET_ONCE_FLAGS_OPTION(fd_mesa_debug, "FD_MESA_DEBUG", debug_options, 0) int fd_mesa_debug = 0; bool fd_binning_enabled = true; -static bool glsl130 = false; +static bool glsl120 = false; static const char * fd_screen_get_name(struct pipe_screen *pscreen) @@ -177,7 +177,9 @@ fd_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param) return 256; case PIPE_CAP_GLSL_FEATURE_LEVEL: - return ((is_a3xx(screen) || is_a4xx(screen)) && glsl130) ? 130 : 120; + if (glsl120) + return 120; + return (is_a3xx(screen) || is_a4xx(screen)) ? 130 : 120; /* Unsupported features. */ case PIPE_CAP_INDEP_BLEND_ENABLE: @@ -366,13 +368,9 @@ fd_screen_get_shader_param(struct pipe_screen *pscreen, unsigned shader, case PIPE_SHADER_CAP_TGSI_SQRT_SUPPORTED: return 1; case PIPE_SHADER_CAP_INTEGERS: - /* we should be able to support this on a3xx, but not - * implemented yet: - * - * TODO looks like a4xx will require some additional - * work for integer varying fetch.. - */ - return ((is_a3xx(screen) || is_a4xx(screen)) && glsl130) ? 1 : 0; + if (glsl120) + return 0; + return (is_a3xx(screen) || is_a4xx(screen)) ? 1 : 0; case PIPE_SHADER_CAP_MAX_TEXTURE_SAMPLERS: case PIPE_SHADER_CAP_MAX_SAMPLER_VIEWS: return 16; @@ -445,7 +443,7 @@ fd_screen_create(struct fd_device *dev) if (fd_mesa_debug & FD_DBG_NOBIN) fd_binning_enabled = false; - glsl130 = !!(fd_mesa_debug & FD_DBG_GLSL130); + glsl120 = !!(fd_mesa_debug & FD_DBG_GLSL120); if (!screen) return NULL; diff --git a/src/gallium/drivers/freedreno/freedreno_util.h b/src/gallium/drivers/freedreno/freedreno_util.h index 929715c..f9c959e 100644 --- a/src/gallium/drivers/freedreno/freedreno_util.h +++ b/src/gallium/drivers/freedreno/freedreno_util.h @@ -65,7 +65,7 @@ enum adreno_stencil_op fd_stencil_op(unsigned op); #define FD_DBG_NOOPT 0x0200 #define FD_DBG_OPTMSGS 0x0400 #define FD_DBG_OPTDUMP 0x0800 -#define FD_DBG_GLSL130 0x1000 +#define FD_DBG_GLSL120 0x1000 #define FD_DBG_NOCP 0x2000 extern int fd_mesa_debug; From robclark at kemper.freedesktop.org Sun Mar 8 21:57:11 2015 From: robclark at kemper.freedesktop.org (Rob Clark) Date: Sun, 8 Mar 2015 14:57:11 -0700 (PDT) Subject: Mesa (master): freedreno/ir3: split up ssa_dst Message-ID: <20150308215711.83E7D76331@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 0f797f7b7dd84f0bbb6efc68f230ce99eea00488 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=0f797f7b7dd84f0bbb6efc68f230ce99eea00488 Author: Rob Clark Date: Fri Jan 23 15:03:51 2015 -0500 freedreno/ir3: split up ssa_dst And a couple other trivial renames, to prepare for relative dst. Signed-off-by: Rob Clark --- src/gallium/drivers/freedreno/ir3/ir3_compiler.c | 42 +++++++++++++--------- 1 file changed, 25 insertions(+), 17 deletions(-) diff --git a/src/gallium/drivers/freedreno/ir3/ir3_compiler.c b/src/gallium/drivers/freedreno/ir3/ir3_compiler.c index fb51cde..8551eeb 100644 --- a/src/gallium/drivers/freedreno/ir3/ir3_compiler.c +++ b/src/gallium/drivers/freedreno/ir3/ir3_compiler.c @@ -498,10 +498,10 @@ create_immed(struct ir3_compile_context *ctx, float val) } static void -ssa_dst(struct ir3_compile_context *ctx, struct ir3_instruction *instr, - const struct tgsi_dst_register *dst, unsigned chan) +ssa_instr_set(struct ir3_compile_context *ctx, unsigned file, unsigned n, + struct ir3_instruction *instr) { - unsigned n = regid(dst->Index, chan); + struct ir3_block *block = ctx->block; unsigned idx = ctx->num_output_updates; compile_assert(ctx, idx < ARRAY_SIZE(ctx->output_updates)); @@ -516,22 +516,22 @@ ssa_dst(struct ir3_compile_context *ctx, struct ir3_instruction *instr, * file.. */ - switch (dst->File) { + switch (file) { case TGSI_FILE_OUTPUT: - compile_assert(ctx, n < ctx->block->noutputs); - ctx->output_updates[idx].instrp = &ctx->block->outputs[n]; + compile_assert(ctx, n < block->noutputs); + ctx->output_updates[idx].instrp = &block->outputs[n]; ctx->output_updates[idx].instr = instr; ctx->num_output_updates++; break; case TGSI_FILE_TEMPORARY: - compile_assert(ctx, n < ctx->block->ntemporaries); - ctx->output_updates[idx].instrp = &ctx->block->temporaries[n]; + compile_assert(ctx, n < block->ntemporaries); + ctx->output_updates[idx].instrp = &block->temporaries[n]; ctx->output_updates[idx].instr = instr; ctx->num_output_updates++; break; case TGSI_FILE_ADDRESS: compile_assert(ctx, n < 1); - ctx->output_updates[idx].instrp = &ctx->block->address; + ctx->output_updates[idx].instrp = &block->address; ctx->output_updates[idx].instr = instr; ctx->num_output_updates++; break; @@ -539,7 +539,7 @@ ssa_dst(struct ir3_compile_context *ctx, struct ir3_instruction *instr, } static struct ir3_instruction * -ssa_instr(struct ir3_compile_context *ctx, unsigned file, unsigned n) +ssa_instr_get(struct ir3_compile_context *ctx, unsigned file, unsigned n) { struct ir3_block *block = ctx->block; struct ir3_instruction *instr = NULL; @@ -595,7 +595,7 @@ ssa_instr(struct ir3_compile_context *ctx, unsigned file, unsigned n) return instr; } -static int array_id(struct ir3_compile_context *ctx, +static int src_array_id(struct ir3_compile_context *ctx, const struct tgsi_src_register *src) { // XXX complete hack to recover tgsi_full_src_register... @@ -607,6 +607,13 @@ static int array_id(struct ir3_compile_context *ctx, } static void +ssa_dst(struct ir3_compile_context *ctx, struct ir3_instruction *instr, + const struct tgsi_dst_register *dst, unsigned chan) +{ + ssa_instr_set(ctx, dst->File, regid(dst->Index, chan), instr); +} + +static void ssa_src(struct ir3_compile_context *ctx, struct ir3_register *reg, const struct tgsi_src_register *src, unsigned chan) { @@ -617,7 +624,7 @@ ssa_src(struct ir3_compile_context *ctx, struct ir3_register *reg, * we must generate a fanin instruction to collect all possible * array elements that the instruction could address together: */ - unsigned i, j, aid = array_id(ctx, src); + unsigned i, j, aid = src_array_id(ctx, src); if (ctx->array[aid].fanin) { instr = ctx->array[aid].fanin; @@ -632,9 +639,9 @@ ssa_src(struct ir3_compile_context *ctx, struct ir3_register *reg, ir3_reg_create(instr, 0, 0); for (i = first; i <= last; i++) { for (j = 0; j < 4; j++) { - unsigned n = (i * 4) + j; + unsigned n = regid(i, j); ir3_reg_create(instr, 0, IR3_REG_SSA)->instr = - ssa_instr(ctx, src->File, n); + ssa_instr_get(ctx, src->File, n); } } ctx->array[aid].fanin = instr; @@ -642,7 +649,7 @@ ssa_src(struct ir3_compile_context *ctx, struct ir3_register *reg, } } else { /* normal case (not relative addressed GPR) */ - instr = ssa_instr(ctx, src->File, regid(src->Index, chan)); + instr = ssa_instr_get(ctx, src->File, regid(src->Index, chan)); } if (instr) { @@ -816,7 +823,7 @@ add_src_reg_wrmask(struct ir3_compile_context *ctx, ir3_reg_create(instr, 0, IR3_REG_SSA)->instr = ctx->block->address; if (src->File != TGSI_FILE_CONSTANT) { - unsigned aid = array_id(ctx, src); + unsigned aid = src_array_id(ctx, src); unsigned off = src->Index - ctx->array[aid].first; /* vec4 offset */ instr->deref.off = regid(off, chan); } @@ -825,7 +832,7 @@ add_src_reg_wrmask(struct ir3_compile_context *ctx, reg = ir3_reg_create(instr, regid(num, chan), flags); if (src->Indirect && (src->File != TGSI_FILE_CONSTANT)) { - unsigned aid = array_id(ctx, src); + unsigned aid = src_array_id(ctx, src); reg->size = 4 * (1 + ctx->array[aid].last - ctx->array[aid].first); } else { reg->wrmask = wrmask; @@ -872,6 +879,7 @@ add_src_reg_wrmask(struct ir3_compile_context *ctx, reg->instr = instr; reg->size = size; } + return reg; } From robclark at kemper.freedesktop.org Sun Mar 8 21:57:11 2015 From: robclark at kemper.freedesktop.org (Rob Clark) Date: Sun, 8 Mar 2015 14:57:11 -0700 (PDT) Subject: Mesa (master): gallium/docs: add some freedreno compiler docs Message-ID: <20150308215711.D60E876331@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 0e8d58b80a0799728bcb8b65a79ce2d27b32170a URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=0e8d58b80a0799728bcb8b65a79ce2d27b32170a Author: Rob Clark Date: Thu Jan 29 15:55:41 2015 -0500 gallium/docs: add some freedreno compiler docs Enable the 'sphinx.ext.graphviz' extension, and add in a section for driver specific docs, with freedreno compiler docs beneath. The goal is for more complete compiler docs, and hopefully some docs about other parts of the driver (such as how tiling works, etc). Note that there is also a Distribution -> Drivers section. Although that appears to be simply just a list of drivers. Not sure if that should move under the 'Drivers' section or left alone. I did add a one-line section for freedreno in the existing Distribution -> Drivers section. Signed-off-by: Rob Clark --- src/gallium/docs/source/conf.py | 2 +- src/gallium/docs/source/distro.rst | 5 + src/gallium/docs/source/drivers.rst | 9 + src/gallium/docs/source/drivers/freedreno.rst | 9 + .../docs/source/drivers/freedreno/ir3-notes.rst | 432 ++++++++++++++++++++ src/gallium/docs/source/index.rst | 1 + 6 files changed, 457 insertions(+), 1 deletion(-) diff --git a/src/gallium/docs/source/conf.py b/src/gallium/docs/source/conf.py index 1288666..5e8173d 100644 --- a/src/gallium/docs/source/conf.py +++ b/src/gallium/docs/source/conf.py @@ -22,7 +22,7 @@ sys.path.append(os.path.abspath('exts')) # Add any Sphinx extension module names here, as strings. They can be extensions # coming with Sphinx (named 'sphinx.ext.*') or your custom ones. -extensions = ['sphinx.ext.pngmath', 'formatting'] +extensions = ['sphinx.ext.pngmath', 'sphinx.ext.graphviz', 'formatting'] # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] diff --git a/src/gallium/docs/source/distro.rst b/src/gallium/docs/source/distro.rst index d8e9d4f..000b031 100644 --- a/src/gallium/docs/source/distro.rst +++ b/src/gallium/docs/source/distro.rst @@ -60,6 +60,11 @@ AMD radeonsi Driver for the AMD Southern Islands family of GPUs. +freedreno +^^^^^^^^^ + +Driver for Qualcomm Adreno a2xx, a3xx, and a4xx series of GPUs. + .. _softpipe: Softpipe diff --git a/src/gallium/docs/source/drivers.rst b/src/gallium/docs/source/drivers.rst new file mode 100644 index 0000000..469197c --- /dev/null +++ b/src/gallium/docs/source/drivers.rst @@ -0,0 +1,9 @@ +Drivers +======= + +Driver specific documentation. + +.. toctree:: + :glob: + + drivers/* diff --git a/src/gallium/docs/source/drivers/freedreno.rst b/src/gallium/docs/source/drivers/freedreno.rst new file mode 100644 index 0000000..723ffdd --- /dev/null +++ b/src/gallium/docs/source/drivers/freedreno.rst @@ -0,0 +1,9 @@ +Freedreno +========= + +Freedreno driver specific docs. + +.. toctree:: + :glob: + + freedreno/* diff --git a/src/gallium/docs/source/drivers/freedreno/ir3-notes.rst b/src/gallium/docs/source/drivers/freedreno/ir3-notes.rst new file mode 100644 index 0000000..182508f --- /dev/null +++ b/src/gallium/docs/source/drivers/freedreno/ir3-notes.rst @@ -0,0 +1,432 @@ +IR3 NOTES +========= + +Some notes about ir3, the compiler and machine-specific IR for the shader ISA introduced with adreno a3xx. The same shader ISA is present, with some small differences, in adreno a4xx. + +Compared to the previous generation a2xx ISA (ir2), the a3xx ISA is a "simple" scalar instruction set. However, the compiler is responsible, in most cases, to schedule the instructions. The hardware does not try to hide the shader core pipeline stages. For a common example, a common (cat2) ALU instruction takes four cycles, so a subsequent cat2 instruction which uses the result must have three intervening instructions (or nops). When operating on vec4's, typically the corresponding scalar instructions for operating on the remaining three components could typically fit. Although that results in a lot of edge cases where things fall over, like: + +:: + + ADD TEMP[0], TEMP[1], TEMP[2] + MUL TEMP[0], TEMP[1], TEMP[0].wzyx + +Here, the second instruction needs the output of the first group of scalar instructions in the wrong order, resulting in not enough instruction spots between the ``add r0.w, r1.w, r2.w`` and ``mul r0.x, r1.x, r0.w``. Which is why the original (old) compiler which merely translated nearly literally from TGSI to ir3, had a strong tendency to fall over. + +So the current compiler instead, in the frontend, generates a directed-acyclic-graph of instructions and basic blocks, which go through various additional passes to eventually schedule and do register assignment. + +For additional documentation about the hardware, see wiki: `a3xx ISA +`_. + +External Structure +------------------ + +``ir3_shader`` + A single vertex/fragment/etc shader from gallium perspective (ie. + maps to a single TGSI shader), and manages a set of shader variants + which are generated on demand based on the shader key. + +``ir3_shader_key`` + The configuration key that identifies a shader variant. Ie. based + on other GL state (two-sided-color, render-to-alpha, etc) or render + stages (binning-pass vertex shader) different shader variants are + generated. + +``ir3_shader_variant`` + The actual hw shader generated based on input TGSI and shader key. + +``ir3_compiler`` + Compiler frontend which generates ir3 and runs the various backend + stages to schedule and do register assignment. + +The IR +------ + +The ir3 IR maps quite directly to the hardware, in that instruction opcodes map directly to hardware opcodes, and that dst/src register(s) map directly to the hardware dst/src register(s). But there are a few extensions, in the form of meta_ instructions. And additionally, for normal (non-const, etc) src registers, the ``IR3_REG_SSA`` flag is set and ``reg->instr`` points to the source instruction which produced that value. So, for example, the following TGSI shader: + +:: + + VERT + DCL IN[0] + DCL IN[1] + DCL OUT[0], POSITION + DCL TEMP[0], LOCAL + 1: DP3 TEMP[0].x, IN[0].xyzz, IN[1].xyzz + 2: MOV OUT[0], TEMP[0].xxxx + 3: END + +eventually generates: + +.. graphviz:: + + digraph G { + rankdir=RL; + nodesep=0.25; + ranksep=1.5; + subgraph clusterdce198 { + label="vert"; + inputdce198 [shape=record,label="inputs| i0.x| i0.y| i0.z| i1.x| i1.y| i1.z"]; + instrdcf348 [shape=record,style=filled,fillcolor=lightgrey,label="{mov.f32f32|| }"]; + instrdcedd0 [shape=record,style=filled,fillcolor=lightgrey,label="{mad.f32|| | | }"]; + inputdce198::w -> instrdcedd0: + inputdce198::w -> instrdcedd0: + instrdcec30 [shape=record,style=filled,fillcolor=lightgrey,label="{mad.f32|| | | }"]; + inputdce198::w -> instrdcec30: + inputdce198::w -> instrdcec30: + instrdceb60 [shape=record,style=filled,fillcolor=lightgrey,label="{mul.f|| | }"]; + inputdce198::w -> instrdceb60: + inputdce198::w -> instrdceb60: + instrdceb60: -> instrdcec30: + instrdcec30: -> instrdcedd0: + instrdcedd0: -> instrdcf348: + instrdcf400 [shape=record,style=filled,fillcolor=lightgrey,label="{mov.f32f32|| }"]; + instrdcedd0: -> instrdcf400: + instrdcf4b8 [shape=record,style=filled,fillcolor=lightgrey,label="{mov.f32f32|| }"]; + instrdcedd0: -> instrdcf4b8: + outputdce198 [shape=record,label="outputs| o0.x| o0.y| o0.z| o0.w"]; + instrdcf348: -> outputdce198::e + instrdcf400: -> outputdce198::e + instrdcf4b8: -> outputdce198::e + instrdcedd0: -> outputdce198::e + } + } + +(after scheduling, etc, but before register assignment). + +Internal Structure +~~~~~~~~~~~~~~~~~~ + +``ir3_block`` + Represents a basic block. + + TODO: currently blocks are nested, but I think I need to change that + to a more conventional arrangement before implementing proper flow + control. Currently the only flow control handles is if/else which + gets flattened out and results chosen with ``sel`` instructions. + +``ir3_instruction`` + Represents a machine instruction or meta_ instruction. Has pointers + to dst register (``regs[0]``) and src register(s) (``regs[1..n]``), + as needed. + +``ir3_register`` + Represents a src or dst register, flags indicate const/relative/etc. + If ``IR3_REG_SSA`` is set on a src register, the actual register + number (name) has not been assigned yet, and instead the ``instr`` + field points to src instruction. + +In addition there are various util macros/functions to simplify manipulation/traversal of the graph: + +``foreach_src(srcreg, instr)`` + Iterate each instruction's source ``ir3_register``\s + +``foreach_src_n(srcreg, n, instr)`` + Like ``foreach_src``, also setting ``n`` to the source number (starting + with ``0``). + +``foreach_ssa_src(srcinstr, instr)`` + Iterate each instruction's SSA source ``ir3_instruction``\s. This skips + non-SSA sources (consts, etc), but includes virtual sources (such as the + address register if `relative addressing`_ is used). + +``foreach_ssa_src_n(srcinstr, n, instr)`` + Like ``foreach_ssa_src``, also setting ``n`` to the source number. + +For example: + +:: + + foreach_ssa_src_n(src, i, instr) { + unsigned d = delay_calc_srcn(ctx, src, instr, i); + delay = MAX2(delay, d); + } + + +TODO probably other helper/util stuff worth mentioning here + +.. _meta: + +Meta Instructions +~~~~~~~~~~~~~~~~~ + +**input** + Used for shader inputs (registers configured in the command-stream + to hold particular input values, written by the shader core before + start of execution. Also used for connecting up values within a + basic block to an output of a previous block. + +**output** + Used to hold outputs of a basic block. + +**flow** + TODO + +**phi** + TODO + +**fanin** + Groups registers which need to be assigned to consecutive scalar + registers, for example `sam` (texture fetch) src instructions (see + `register groups`_) or array element dereference + (see `relative addressing`_). + +**fanout** + The counterpart to **fanin**, when an instruction such as `sam` + writes multiple components, splits the result into individual + scalar components to be consumed by other instructions. + + +.. _`flow control`: + +Flow Control +~~~~~~~~~~~~ + +TODO + + +.. _`register groups`: + +Register Groups +~~~~~~~~~~~~~~~ + +Certain instructions, such as texture sample instructions, consume multiple consecutive scalar registers via a single src register encoded in the instruction, and/or write multiple consecutive scalar registers. In the simplest example: + +:: + + sam (f32)(xyz)r2.x, r0.z, s#0, t#0 + +for a 2d texture, would read ``r0.zw`` to get the coordinate, and write ``r2.xyz``. + +Before register assignment, to group the two components of the texture src together: + +.. graphviz:: + + digraph G { + { rank=same; + fanin; + }; + { rank=same; + coord_x; + coord_y; + }; + sam -> fanin [label="regs[1]"]; + fanin -> coord_x [label="regs[1]"]; + fanin -> coord_y [label="regs[2]"]; + coord_x -> coord_y [label="right",style=dotted]; + coord_y -> coord_x [label="left",style=dotted]; + coord_x [label="coord.x"]; + coord_y [label="coord.y"]; + } + +The frontend sets up the SSA ptrs from ``sam`` source register to the ``fanin`` meta instruction, which in turn points to the instructions producing the ``coord.x`` and ``coord.y`` values. And the grouping_ pass sets up the ``left`` and ``right`` neighbor pointers to the ``fanin``\'s sources, used later by the `register assignment`_ pass to assign blocks of scalar registers. + +And likewise, for the consecutive scalar registers for the destination: + +.. graphviz:: + + digraph { + { rank=same; + A; + B; + C; + }; + { rank=same; + fanout_0; + fanout_1; + fanout_2; + }; + A -> fanout_0; + B -> fanout_1; + C -> fanout_2; + fanout_0 [label="fanout\noff=0"]; + fanout_0 -> sam; + fanout_1 [label="fanout\noff=1"]; + fanout_1 -> sam; + fanout_2 [label="fanout\noff=2"]; + fanout_2 -> sam; + fanout_0 -> fanout_1 [label="right",style=dotted]; + fanout_1 -> fanout_0 [label="left",style=dotted]; + fanout_1 -> fanout_2 [label="right",style=dotted]; + fanout_2 -> fanout_1 [label="left",style=dotted]; + sam; + } + +.. _`relative addressing`: + +Relative Addressing +~~~~~~~~~~~~~~~~~~~ + +Most instructions support addressing indirectly (relative to address register) into const or gpr register file in some or all of their src/dst registers. In this case the register accessed is taken from ``r`` or ``c``, ie. address register (``a0.x``) value plus ``n``, where ``n`` is encoded in the instruction (rather than the absolute register number). + + Note that cat5 (texture sample) instructions are the notable exception, not + supporting relative addressing of src or dst. + +Relative addressing of the const file (for example, a uniform array) is relatively simple. We don't do register assignment of the const file, so all that is required is to schedule things properly. Ie. the instruction that writes the address register must be scheduled first, and we cannot have two different address register values live at one time. + +But relative addressing of gpr file (which can be as src or dst) has additional restrictions on register assignment (ie. the array elements must be assigned to consecutive scalar registers). And in the case of relative dst, subsequent instructions now depend on both the relative write, as well as the previous instruction which wrote that register, since we do not know at compile time which actual register was written. + +Each instruction has an optional ``address`` pointer, to capture the dependency on the address register value when relative addressing is used for any of the src/dst register(s). This behaves as an additional virtual src register, ie. ``foreach_ssa_src()`` will also iterate the address register (last). + + Note that ``nop``\'s for timing constraints, type specifiers (ie. + ``add.f`` vs ``add.u``), etc, omitted for brevity in examples + +:: + + mova a0.x, hr1.y + sub r1.y, r2.x, r3.x + add r0.x, r1.y, c + +results in: + +.. graphviz:: + + digraph { + rankdir=LR; + sub; + const [label="const file"]; + add; + mova; + add -> mova; + add -> sub; + add -> const [label="off=2"]; + } + +The scheduling pass has some smarts to schedule things such that only a single ``a0.x`` value is used at any one time. + +To implement variable arrays, values are stored in consecutive scalar registers. This has some overlap with `register groups`_, in that ``fanin`` and ``fanout`` are used to help group things for the `register assignment`_ pass. + +To use a variable array as a src register, a slight variation of what is done for const array src. The instruction src is a `fanin` instruction that groups all the array members: + +:: + + mova a0.x, hr1.y + sub r1.y, r2.x, r3.x + add r0.x, r1.y, r + +results in: + +.. graphviz:: + + digraph { + a0 [label="r0.z"]; + a1 [label="r0.w"]; + a2 [label="r1.x"]; + a3 [label="r1.y"]; + sub; + fanin; + mova; + add; + add -> sub; + add -> fanin [label="off=2"]; + add -> mova; + fanin -> a0; + fanin -> a1; + fanin -> a2; + fanin -> a3; + } + +TODO better describe how actual deref offset is derived, ie. based on array base register. + +To do an indirect write to a variable array, a ``fanout`` is used. Say the array was assigned to registers ``r0.z`` through ``r1.y`` (hence the constant offset of 2): + + Note that only cat1 (mov) can do indirect write. + +:: + + mova a0.x, hr1.y + min r2.x, r2.x, c0.x + mov r, r2.x + mul r0.x, r0.z, c0.z + + +In this case, the ``mov`` instruction does not write all elements of the array (compared to usage of ``fanout`` for ``sam`` instructions in grouping_). But the ``mov`` instruction does need an additional dependency (via ``fanin``) on instructions that last wrote the array element members, to ensure that they get scheduled before the ``mov`` in scheduling_ stage (which also serves to group the array elements for the `register assignment`_ stage). + +.. graphviz:: + + digraph { + a0 [label="r0.z"]; + a1 [label="r0.w"]; + a2 [label="r1.x"]; + a3 [label="r1.y"]; + min; + mova; + mov; + mul; + fanout [label="fanout\noff=0"]; + mul -> fanout; + fanout -> mov; + fanin; + fanin -> a0; + fanin -> a1; + fanin -> a2; + fanin -> a3; + mov -> min; + mov -> mova; + mov -> fanin; + } + +Note that there would in fact be ``fanout`` nodes generated for each array element (although only the reachable ones will be scheduled, etc). + + + +Shader Passes +------------- + +After the frontend has generated the use-def graph of instructions, they are run through various passes which include scheduling_ and `register assignment`_. Because inserting ``mov`` instructions after scheduling would also require inserting additional ``nop`` instructions (since it is too late to reschedule to try and fill the bubbles), the earlier stages try to ensure that (at least given an infinite supply of registers) that `register assignment`_ after scheduling_ cannot fail. + + Note that we essentially have ~256 scalar registers in the + architecture (although larger register usage will at some thresholds + limit the number of threads which can run in parallel). And at some + point we will have to deal with spilling. + +.. _flatten: + +Flatten +~~~~~~~ + +In this stage, simple if/else blocks are flattened into a single block with ``phi`` nodes converted into ``sel`` instructions. The a3xx ISA has very few predicated instructions, and we would prefer not to use branches for simple if/else. + + +.. _`copy propagation`: + +Copy Propagation +~~~~~~~~~~~~~~~~ + +Currently the frontend inserts ``mov``\s in various cases, because certain categories of instructions have limitations about const regs as sources. And the CP pass simply removes all simple ``mov``\s (ie. src-type is same as dst-type, no abs/neg flags, etc). + +The eventual plan is to invert that, with the front-end inserting no ``mov``\s and CP legalize things. + + +.. _grouping: + +Grouping +~~~~~~~~ + +In the grouping pass, instructions which need to be grouped (for ``fanin``\s, etc) have their ``left`` / ``right`` neighbor pointers setup. In cases where there is a conflict (ie. one instruction cannot have two unique left or right neighbors), an additional ``mov`` instruction is inserted. This ensures that there is some possible valid `register assignment`_ at the later stages. + + +.. _depth: + +Depth +~~~~~ + +In the depth pass, a depth is calculated for each instruction node within it's basic block. The depth is the sum of the required cycles (delay slots needed between two instructions plus one) of each instruction plus the max depth of any of it's source instructions. (meta_ instructions don't add to the depth). As an instruction's depth is calculated, it is inserted into a per block list sorted by deepest instruction. Unreachable instructions and inputs are marked. + + TODO: we should probably calculate both hard and soft depths (?) to + try to coax additional instructions to fit in places where we need + to use sync bits, such as after a texture fetch or SFU. + +.. _scheduling: + +Scheduling +~~~~~~~~~~ + +After the grouping_ pass, there are no more instructions to insert or remove. Start scheduling each basic block from the deepest node in the depth sorted list created by the depth_ pass, recursively trying to schedule each instruction after it's source instructions plus delay slots. Insert ``nop``\s as required. + +.. _`register assignment`: + +Register Assignment +~~~~~~~~~~~~~~~~~~~ + +TODO + + diff --git a/src/gallium/docs/source/index.rst b/src/gallium/docs/source/index.rst index c6cf3704..dcf8399 100644 --- a/src/gallium/docs/source/index.rst +++ b/src/gallium/docs/source/index.rst @@ -20,6 +20,7 @@ Contents: context cso distro + drivers glossary Indices and tables From airlied at kemper.freedesktop.org Sun Mar 8 23:49:12 2015 From: airlied at kemper.freedesktop.org (Dave Airlie) Date: Sun, 8 Mar 2015 16:49:12 -0700 (PDT) Subject: Mesa (master): mesa/st: remove unused TexData Message-ID: <20150308234912.7572076331@kemper.freedesktop.org> Module: Mesa Branch: master Commit: c5e69409d7f04312b5a928b952b4e97f6b78be1f URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=c5e69409d7f04312b5a928b952b4e97f6b78be1f Author: Dave Airlie Date: Thu Mar 5 08:19:23 2015 +1000 mesa/st: remove unused TexData this isn't hooked up to anything at all from what I can see. Seems like a left over from commit 5d67d4fbebb(st/mesa: remove st_TexImage(), use core Mesa code instead). Reviewed-by: Emil Velikov Signed-off-by: Dave Airlie --- src/mesa/state_tracker/st_cb_texture.c | 21 --------------------- src/mesa/state_tracker/st_texture.h | 6 ------ 2 files changed, 27 deletions(-) diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c index a8b19a1..5c520b4 100644 --- a/src/mesa/state_tracker/st_cb_texture.c +++ b/src/mesa/state_tracker/st_cb_texture.c @@ -178,9 +178,6 @@ st_FreeTextureImageBuffer(struct gl_context *ctx, pipe_resource_reference(&stImage->pt, NULL); } - _mesa_align_free(stImage->TexData); - stImage->TexData = NULL; - free(stImage->transfer); stImage->transfer = NULL; stImage->num_transfers = 0; @@ -501,7 +498,6 @@ st_AllocTextureImageBuffer(struct gl_context *ctx, DBG("%s\n", __FUNCTION__); - assert(!stImage->TexData); assert(!stImage->pt); /* xxx this might be wrong */ /* Look if the parent texture object has space for this image */ @@ -1521,23 +1517,6 @@ copy_image_data_to_texture(struct st_context *st, pipe_resource_reference(&stImage->pt, NULL); } - else if (stImage->TexData) { - /* Copy from malloc'd memory */ - /* XXX this should be re-examined/tested with a compressed format */ - GLuint blockSize = util_format_get_blocksize(stObj->pt->format); - GLuint srcRowStride = stImage->base.Width * blockSize; - GLuint srcSliceStride = stImage->base.Height * srcRowStride; - st_texture_image_data(st, - stObj->pt, - stImage->base.Face, - dstLevel, - stImage->TexData, - srcRowStride, - srcSliceStride); - _mesa_align_free(stImage->TexData); - stImage->TexData = NULL; - } - pipe_resource_reference(&stImage->pt, stObj->pt); } diff --git a/src/mesa/state_tracker/st_texture.h b/src/mesa/state_tracker/st_texture.h index 6b7f8c7..3fa55ae 100644 --- a/src/mesa/state_tracker/st_texture.h +++ b/src/mesa/state_tracker/st_texture.h @@ -55,13 +55,7 @@ struct st_texture_image { struct gl_texture_image base; - /** Used to store texture data that doesn't fit in the parent - * object's mipmap buffer. - */ - GLubyte *TexData; - /* If stImage->pt != NULL, image data is stored here. - * Else if stImage->TexData != NULL, image is stored there. * Else there is no image data. */ struct pipe_resource *pt; From airlied at kemper.freedesktop.org Mon Mar 9 00:43:43 2015 From: airlied at kemper.freedesktop.org (Dave Airlie) Date: Sun, 8 Mar 2015 17:43:43 -0700 (PDT) Subject: Mesa (master): st/mesa: drop unused texture function Message-ID: <20150309004343.BD5BB76331@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 7c25a4a84d01557945ff0273fb481c24cf509837 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=7c25a4a84d01557945ff0273fb481c24cf509837 Author: Dave Airlie Date: Mon Mar 9 09:51:27 2015 +1000 st/mesa: drop unused texture function This has no users. Reviewed-by: Ilia Mirkin Signed-off-by: Dave Airlie --- src/mesa/state_tracker/st_texture.c | 40 ----------------------------------- src/mesa/state_tracker/st_texture.h | 10 --------- 2 files changed, 50 deletions(-) diff --git a/src/mesa/state_tracker/st_texture.c b/src/mesa/state_tracker/st_texture.c index ada9841..ca7c83c 100644 --- a/src/mesa/state_tracker/st_texture.c +++ b/src/mesa/state_tracker/st_texture.c @@ -310,46 +310,6 @@ st_texture_image_unmap(struct st_context *st, *transfer = NULL; } - -/* Upload data for a particular image. - */ -void -st_texture_image_data(struct st_context *st, - struct pipe_resource *dst, - GLuint face, - GLuint level, - void *src, - GLuint src_row_stride, GLuint src_image_stride) -{ - struct pipe_context *pipe = st->pipe; - GLuint i; - const GLubyte *srcUB = src; - GLuint layers; - - if (dst->target == PIPE_TEXTURE_1D_ARRAY || - dst->target == PIPE_TEXTURE_2D_ARRAY || - dst->target == PIPE_TEXTURE_CUBE_ARRAY) - layers = dst->array_size; - else - layers = u_minify(dst->depth0, level); - - DBG("%s\n", __FUNCTION__); - - for (i = 0; i < layers; i++) { - struct pipe_box box; - u_box_2d_zslice(0, 0, face + i, - u_minify(dst->width0, level), - u_minify(dst->height0, level), - &box); - - pipe->transfer_inline_write(pipe, dst, level, PIPE_TRANSFER_WRITE, - &box, srcUB, src_row_stride, 0); - - srcUB += src_image_stride; - } -} - - /** * For debug only: get/print center pixel in the src resource. */ diff --git a/src/mesa/state_tracker/st_texture.h b/src/mesa/state_tracker/st_texture.h index 3fa55ae..d8cd7c7 100644 --- a/src/mesa/state_tracker/st_texture.h +++ b/src/mesa/state_tracker/st_texture.h @@ -224,16 +224,6 @@ st_texture_image_unmap(struct st_context *st, extern const GLuint * st_texture_depth_offsets(struct pipe_resource *pt, GLuint level); - -/* Upload an image into a texture - */ -extern void -st_texture_image_data(struct st_context *st, - struct pipe_resource *dst, - GLuint face, GLuint level, void *src, - GLuint src_row_pitch, GLuint src_image_pitch); - - /* Copy an image between two textures */ extern void From kwg at kemper.freedesktop.org Mon Mar 9 05:37:23 2015 From: kwg at kemper.freedesktop.org (Kenneth Graunke) Date: Sun, 8 Mar 2015 22:37:23 -0700 (PDT) Subject: Mesa (master): i965/nir: Resolve source modifiers on Gen8+ logic operations. Message-ID: <20150309053723.7008E76331@kemper.freedesktop.org> Module: Mesa Branch: master Commit: a84f66a9b6cf46bb19ca71faca5b1d6d81209caf URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=a84f66a9b6cf46bb19ca71faca5b1d6d81209caf Author: Kenneth Graunke Date: Thu Mar 5 20:39:49 2015 -0800 i965/nir: Resolve source modifiers on Gen8+ logic operations. On Gen8+, AND/OR/XOR/NOT don't support the abs() source modifier, and negate changes meaning to bitwise-not (~, not -). This isn't what NIR expects, so we should resolve the source modifers via a MOV. +30 Piglits (fs-op-bit{and,or,xor}-not-abs-*). Signed-off-by: Kenneth Graunke Reviewed-by: Topi Pohjolainen --- src/mesa/drivers/dri/i965/brw_fs.cpp | 11 +++++++++++ src/mesa/drivers/dri/i965/brw_fs.h | 1 + src/mesa/drivers/dri/i965/brw_fs_nir.cpp | 15 +++++++++++++++ 3 files changed, 27 insertions(+) diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp index d6acc23..428234f 100644 --- a/src/mesa/drivers/dri/i965/brw_fs.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs.cpp @@ -1561,6 +1561,17 @@ fs_visitor::emit_sampleid_setup() return reg; } +void +fs_visitor::resolve_source_modifiers(fs_reg *src) +{ + if (!src->abs && !src->negate) + return; + + fs_reg temp = retype(vgrf(1), src->type); + emit(MOV(temp, *src)); + *src = temp; +} + fs_reg fs_visitor::fix_math_operand(fs_reg src) { diff --git a/src/mesa/drivers/dri/i965/brw_fs.h b/src/mesa/drivers/dri/i965/brw_fs.h index 70098d8..ec77962 100644 --- a/src/mesa/drivers/dri/i965/brw_fs.h +++ b/src/mesa/drivers/dri/i965/brw_fs.h @@ -299,6 +299,7 @@ public: int texunit); fs_reg emit_mcs_fetch(fs_reg coordinate, int components, fs_reg sampler); void emit_gen6_gather_wa(uint8_t wa, fs_reg dst); + void resolve_source_modifiers(fs_reg *src); fs_reg fix_math_operand(fs_reg src); fs_inst *emit_math(enum opcode op, fs_reg dst, fs_reg src0); fs_inst *emit_math(enum opcode op, fs_reg dst, fs_reg src0, fs_reg src1); diff --git a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp index 66f7918..a0300aa 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp @@ -935,15 +935,30 @@ fs_visitor::nir_emit_alu(nir_alu_instr *instr) break; case nir_op_inot: + if (brw->gen >= 8) { + resolve_source_modifiers(&op[0]); + } emit(NOT(result, op[0])); break; case nir_op_ixor: + if (brw->gen >= 8) { + resolve_source_modifiers(&op[0]); + resolve_source_modifiers(&op[1]); + } emit(XOR(result, op[0], op[1])); break; case nir_op_ior: + if (brw->gen >= 8) { + resolve_source_modifiers(&op[0]); + resolve_source_modifiers(&op[1]); + } emit(OR(result, op[0], op[1])); break; case nir_op_iand: + if (brw->gen >= 8) { + resolve_source_modifiers(&op[0]); + resolve_source_modifiers(&op[1]); + } emit(AND(result, op[0], op[1])); break; From kwg at kemper.freedesktop.org Mon Mar 9 05:37:23 2015 From: kwg at kemper.freedesktop.org (Kenneth Graunke) Date: Sun, 8 Mar 2015 22:37:23 -0700 (PDT) Subject: Mesa (master): glsl: Mark array access when copying to a temporary for the ?: operator. Message-ID: <20150309053723.7B5827633D@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 9f1e250e77ebd9255bbd9a83bd68c9e4068c2aab URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=9f1e250e77ebd9255bbd9a83bd68c9e4068c2aab Author: Kenneth Graunke Date: Thu Mar 5 23:18:36 2015 -0800 glsl: Mark array access when copying to a temporary for the ?: operator. Piglit's spec/glsl-1.20/compiler/structure-and-array-operations/ array-selection.vert test contains the following code: gl_Position = (pick_from_a_or_b ? a : b)[i]; where "a" and "b" are uniform vec4[2] variables. ast_to_hir creates a temporary vec4[2] variable, conditional_tmp, and generates an if-block to copy one or the other: (declare (temporary) (array vec4 2) conditional_tmp) (if (var_ref pick_from_a_or_b) ((assign () (var_ref conditional_tmp) (var_ref a))) ((assign () (var_ref conditional_tmp) (var_ref b)))) However, we failed to update max_array_access for "a" and "b", so it remained 0 - here, the whole array is being accessed. At link time, update_array_sizes() used this bogus information to change the types of "a" and "b" to vec4[1]. We then had assignments from a vec4[1] to a vec4[2], which is highly illegal. This tripped assertions in nir_split_var_copies with scalar VS. Signed-off-by: Kenneth Graunke Reviewed-by: Jason Ekstrand Cc: mesa-stable at lists.freedesktop.org --- src/glsl/ast_to_hir.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp index acb5c76..d387b2e 100644 --- a/src/glsl/ast_to_hir.cpp +++ b/src/glsl/ast_to_hir.cpp @@ -1617,6 +1617,12 @@ ast_expression::do_hir(exec_list *instructions, && cond_val != NULL) { result = cond_val->value.b[0] ? op[1] : op[2]; } else { + /* The copy to conditional_tmp reads the whole array. */ + if (type->is_array()) { + mark_whole_array_access(op[1]); + mark_whole_array_access(op[2]); + } + ir_variable *const tmp = new(ctx) ir_variable(type, "conditional_tmp", ir_var_temporary); instructions->push_tail(tmp); From kwg at kemper.freedesktop.org Mon Mar 9 05:37:23 2015 From: kwg at kemper.freedesktop.org (Kenneth Graunke) Date: Sun, 8 Mar 2015 22:37:23 -0700 (PDT) Subject: Mesa (master): nir: Delete nir_shader:: user_structures and num_user_structures. Message-ID: <20150309053723.8A78C7633E@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 2561aea6b306c4438defeb4ec96be05f6aadd12e URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=2561aea6b306c4438defeb4ec96be05f6aadd12e Author: Kenneth Graunke Date: Fri Mar 6 00:26:25 2015 -0800 nir: Delete nir_shader::user_structures and num_user_structures. Nothing actually uses these, and the only caller of glsl_to_nir() (brw_fs_nir.cpp) always passes NULL for the _mesa_glsl_parse_state pointer, meaning they'll always be NULL and 0, respectively. Just delete them. Signed-off-by: Kenneth Graunke Reviewed-by: Jason Ekstrand --- src/glsl/nir/glsl_to_nir.cpp | 11 ----------- src/glsl/nir/nir.c | 3 --- src/glsl/nir/nir.h | 4 ---- src/glsl/nir/nir_print.c | 4 ---- 4 files changed, 22 deletions(-) diff --git a/src/glsl/nir/glsl_to_nir.cpp b/src/glsl/nir/glsl_to_nir.cpp index adef19c..b82e5c7 100644 --- a/src/glsl/nir/glsl_to_nir.cpp +++ b/src/glsl/nir/glsl_to_nir.cpp @@ -154,17 +154,6 @@ glsl_to_nir(exec_list *ir, _mesa_glsl_parse_state *state, nir_shader *shader = nir_shader_create(NULL, options); - if (state) { - shader->num_user_structures = state->num_user_structures; - shader->user_structures = ralloc_array(shader, glsl_type *, - shader->num_user_structures); - memcpy(shader->user_structures, state->user_structures, - shader->num_user_structures * sizeof(glsl_type *)); - } else { - shader->num_user_structures = 0; - shader->user_structures = NULL; - } - nir_visitor v1(shader, native_integers); nir_function_visitor v2(&v1); v2.run(ir); diff --git a/src/glsl/nir/nir.c b/src/glsl/nir/nir.c index ab57fd4..abad3f8 100644 --- a/src/glsl/nir/nir.c +++ b/src/glsl/nir/nir.c @@ -42,9 +42,6 @@ nir_shader_create(void *mem_ctx, const nir_shader_compiler_options *options) shader->options = options; - shader->num_user_structures = 0; - shader->user_structures = NULL; - exec_list_make_empty(&shader->functions); exec_list_make_empty(&shader->registers); exec_list_make_empty(&shader->globals); diff --git a/src/glsl/nir/nir.h b/src/glsl/nir/nir.h index d5df596..b935354 100644 --- a/src/glsl/nir/nir.h +++ b/src/glsl/nir/nir.h @@ -1400,10 +1400,6 @@ typedef struct nir_shader { /** list of global register in the shader */ struct exec_list registers; - /** structures used in this shader */ - unsigned num_user_structures; - struct glsl_type **user_structures; - /** next available global register index */ unsigned reg_alloc; diff --git a/src/glsl/nir/nir_print.c b/src/glsl/nir/nir_print.c index 6a3c6a0..21d5dde 100644 --- a/src/glsl/nir/nir_print.c +++ b/src/glsl/nir/nir_print.c @@ -844,10 +844,6 @@ nir_print_shader(nir_shader *shader, FILE *fp) print_var_state state; init_print_state(&state); - for (unsigned i = 0; i < shader->num_user_structures; i++) { - glsl_print_struct(shader->user_structures[i], fp); - } - struct hash_entry *entry; hash_table_foreach(shader->uniforms, entry) { From kwg at kemper.freedesktop.org Mon Mar 9 05:37:23 2015 From: kwg at kemper.freedesktop.org (Kenneth Graunke) Date: Sun, 8 Mar 2015 22:37:23 -0700 (PDT) Subject: Mesa (master): nir: Try to make sense of the nir_shader_compiler_options code. Message-ID: <20150309053723.9B92C76331@kemper.freedesktop.org> Module: Mesa Branch: master Commit: a55da73be46b4576015417b2dff71a719bc8b797 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=a55da73be46b4576015417b2dff71a719bc8b797 Author: Kenneth Graunke Date: Fri Mar 6 00:43:28 2015 -0800 nir: Try to make sense of the nir_shader_compiler_options code. The code in glsl_to_nir is entirely dead, as we translate from GLSL to NIR at link time, when there isn't a _mesa_glsl_parse_state to pass, so every caller passes NULL. glsl_to_nir seems like the wrong place to try and create the shader compiler options structure anyway - tgsi_to_nir, prog_to_nir, and other translators all would have to duplicate that code. The driver should set this up once with whatever settings it wants, and pass it in. Eric also added a NirOptions field to ctx->Const.ShaderCompilerOptions[] and left a comment saying: "The memory for the options is expected to be kept in a single static copy by the driver." This suggests the plan was to do exactly that. That pointer was not marked const, however, and the dead code used a mix of static structures and ralloced ones. This patch deletes the dead code in glsl_to_nir, instead making it take the shader compiler options as a mandatory argument. It creates an (empty) options struct in the i965 driver, and makes NirOptions point to that. It marks the pointer const so that we can actually do so without generating "discards const qualifier" compiler warnings. Signed-off-by: Kenneth Graunke Acked-by: Jason Ekstrand Reviewed-by: Eric Anholt --- src/glsl/nir/glsl_to_nir.cpp | 28 ++-------------------------- src/glsl/nir/glsl_to_nir.h | 4 ++-- src/mesa/drivers/dri/i965/brw_context.c | 5 +++++ src/mesa/drivers/dri/i965/brw_fs_nir.cpp | 5 ++++- src/mesa/main/mtypes.h | 2 +- 5 files changed, 14 insertions(+), 30 deletions(-) diff --git a/src/glsl/nir/glsl_to_nir.cpp b/src/glsl/nir/glsl_to_nir.cpp index b82e5c7..7e40ef4 100644 --- a/src/glsl/nir/glsl_to_nir.cpp +++ b/src/glsl/nir/glsl_to_nir.cpp @@ -124,34 +124,10 @@ private: }; /* end of anonymous namespace */ -static const nir_shader_compiler_options default_options = { -}; - nir_shader * -glsl_to_nir(exec_list *ir, _mesa_glsl_parse_state *state, - bool native_integers) +glsl_to_nir(exec_list *ir, bool native_integers, + const nir_shader_compiler_options *options) { - const nir_shader_compiler_options *options; - - if (state) { - struct gl_context *ctx = state->ctx; - struct gl_shader_compiler_options *gl_options = - &ctx->Const.ShaderCompilerOptions[state->stage]; - - if (!gl_options->NirOptions) { - nir_shader_compiler_options *new_options = - rzalloc(ctx, nir_shader_compiler_options); - options = gl_options->NirOptions = new_options; - - if (gl_options->EmitNoPow) - new_options->lower_fpow = true; - } else { - options = gl_options->NirOptions; - } - } else { - options = &default_options; - } - nir_shader *shader = nir_shader_create(NULL, options); nir_visitor v1(shader, native_integers); diff --git a/src/glsl/nir/glsl_to_nir.h b/src/glsl/nir/glsl_to_nir.h index 58b2cee..7300945 100644 --- a/src/glsl/nir/glsl_to_nir.h +++ b/src/glsl/nir/glsl_to_nir.h @@ -32,8 +32,8 @@ extern "C" { #endif -nir_shader *glsl_to_nir(exec_list * ir, _mesa_glsl_parse_state *state, - bool native_integers); +nir_shader *glsl_to_nir(exec_list *ir, bool native_integers, + const nir_shader_compiler_options *options); #ifdef __cplusplus } diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c index 972e458..8141b45 100644 --- a/src/mesa/drivers/dri/i965/brw_context.c +++ b/src/mesa/drivers/dri/i965/brw_context.c @@ -68,6 +68,8 @@ #include "tnl/t_pipeline.h" #include "util/ralloc.h" +#include "glsl/nir/nir.h" + /*************************************** * Mesa's Driver Functions ***************************************/ @@ -549,6 +551,8 @@ brw_initialize_context_constants(struct brw_context *brw) ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxInputComponents = 128; } + static const nir_shader_compiler_options nir_options = {}; + /* We want the GLSL compiler to emit code that uses condition codes */ for (int i = 0; i < MESA_SHADER_STAGES; i++) { ctx->Const.ShaderCompilerOptions[i].MaxIfDepth = brw->gen < 6 ? 16 : UINT_MAX; @@ -562,6 +566,7 @@ brw_initialize_context_constants(struct brw_context *brw) (i == MESA_SHADER_FRAGMENT); ctx->Const.ShaderCompilerOptions[i].EmitNoIndirectUniform = false; ctx->Const.ShaderCompilerOptions[i].LowerClipDistance = true; + ctx->Const.ShaderCompilerOptions[i].NirOptions = &nir_options; } ctx->Const.ShaderCompilerOptions[MESA_SHADER_VERTEX].OptimizeForAOS = true; diff --git a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp index a0300aa..e24bf92 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp @@ -82,9 +82,12 @@ count_nir_instrs(nir_shader *nir) void fs_visitor::emit_nir_code() { + const nir_shader_compiler_options *options = + ctx->Const.ShaderCompilerOptions[stage].NirOptions; + /* first, lower the GLSL IR shader to NIR */ lower_output_reads(shader->base.ir); - nir_shader *nir = glsl_to_nir(shader->base.ir, NULL, true); + nir_shader *nir = glsl_to_nir(shader->base.ir, true, options); nir_validate_shader(nir); nir_lower_global_vars_to_local(nir); diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index efeee8b..c43c6ac 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -3036,7 +3036,7 @@ struct gl_shader_compiler_options struct gl_sl_pragmas DefaultPragmas; /**< Default #pragma settings */ - struct nir_shader_compiler_options *NirOptions; + const struct nir_shader_compiler_options *NirOptions; }; From kwg at kemper.freedesktop.org Mon Mar 9 05:37:23 2015 From: kwg at kemper.freedesktop.org (Kenneth Graunke) Date: Sun, 8 Mar 2015 22:37:23 -0700 (PDT) Subject: Mesa (master): nir: Add native_integers to nir_shader_compiler_options. Message-ID: <20150309053723.AA3C776331@kemper.freedesktop.org> Module: Mesa Branch: master Commit: b200cbb0a41aaebb007668f870a483f0b9ecd898 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=b200cbb0a41aaebb007668f870a483f0b9ecd898 Author: Kenneth Graunke Date: Fri Mar 6 01:17:22 2015 -0800 nir: Add native_integers to nir_shader_compiler_options. glsl_to_nir, tgsi_to_nir, and prog_to_nir all want to know whether the driver supports native integers. Presumably other passes may as well. Adding this to nir_shader_compiler_options is an easy way to provide that information, as it's accessible via nir_shader::options. Signed-off-by: Kenneth Graunke Reviewed-by: Jason Ekstrand --- src/glsl/nir/glsl_to_nir.cpp | 11 +++++------ src/glsl/nir/glsl_to_nir.h | 2 +- src/glsl/nir/nir.h | 6 ++++++ src/mesa/drivers/dri/i965/brw_context.c | 4 +++- src/mesa/drivers/dri/i965/brw_fs_nir.cpp | 2 +- 5 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/glsl/nir/glsl_to_nir.cpp b/src/glsl/nir/glsl_to_nir.cpp index 7e40ef4..0d96e03 100644 --- a/src/glsl/nir/glsl_to_nir.cpp +++ b/src/glsl/nir/glsl_to_nir.cpp @@ -43,7 +43,7 @@ namespace { class nir_visitor : public ir_visitor { public: - nir_visitor(nir_shader *shader, bool supports_ints); + nir_visitor(nir_shader *shader); ~nir_visitor(); virtual void visit(ir_variable *); @@ -125,12 +125,11 @@ private: }; /* end of anonymous namespace */ nir_shader * -glsl_to_nir(exec_list *ir, bool native_integers, - const nir_shader_compiler_options *options) +glsl_to_nir(exec_list *ir, const nir_shader_compiler_options *options) { nir_shader *shader = nir_shader_create(NULL, options); - nir_visitor v1(shader, native_integers); + nir_visitor v1(shader); nir_function_visitor v2(&v1); v2.run(ir); visit_exec_list(ir, &v1); @@ -138,9 +137,9 @@ glsl_to_nir(exec_list *ir, bool native_integers, return shader; } -nir_visitor::nir_visitor(nir_shader *shader, bool supports_ints) +nir_visitor::nir_visitor(nir_shader *shader) { - this->supports_ints = supports_ints; + this->supports_ints = shader->options->native_integers; this->shader = shader; this->is_global = true; this->var_table = _mesa_hash_table_create(NULL, _mesa_hash_pointer, diff --git a/src/glsl/nir/glsl_to_nir.h b/src/glsl/nir/glsl_to_nir.h index 7300945..dd62793 100644 --- a/src/glsl/nir/glsl_to_nir.h +++ b/src/glsl/nir/glsl_to_nir.h @@ -32,7 +32,7 @@ extern "C" { #endif -nir_shader *glsl_to_nir(exec_list *ir, bool native_integers, +nir_shader *glsl_to_nir(exec_list *ir, const nir_shader_compiler_options *options); #ifdef __cplusplus diff --git a/src/glsl/nir/nir.h b/src/glsl/nir/nir.h index b935354..669a26e 100644 --- a/src/glsl/nir/nir.h +++ b/src/glsl/nir/nir.h @@ -1370,6 +1370,12 @@ typedef struct nir_shader_compiler_options { bool lower_fsqrt; /** lowers fneg and ineg to fsub and isub. */ bool lower_negate; + + /** + * Does the driver support real 32-bit integers? (Otherwise, integers + * are simulated by floats.) + */ + bool native_integers; } nir_shader_compiler_options; typedef struct nir_shader { diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c index 8141b45..0881e48 100644 --- a/src/mesa/drivers/dri/i965/brw_context.c +++ b/src/mesa/drivers/dri/i965/brw_context.c @@ -551,7 +551,9 @@ brw_initialize_context_constants(struct brw_context *brw) ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxInputComponents = 128; } - static const nir_shader_compiler_options nir_options = {}; + static const nir_shader_compiler_options nir_options = { + .native_integers = true, + }; /* We want the GLSL compiler to emit code that uses condition codes */ for (int i = 0; i < MESA_SHADER_STAGES; i++) { diff --git a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp index e24bf92..ccb5cea 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp @@ -87,7 +87,7 @@ fs_visitor::emit_nir_code() /* first, lower the GLSL IR shader to NIR */ lower_output_reads(shader->base.ir); - nir_shader *nir = glsl_to_nir(shader->base.ir, true, options); + nir_shader *nir = glsl_to_nir(shader->base.ir, options); nir_validate_shader(nir); nir_lower_global_vars_to_local(nir); From kwg at kemper.freedesktop.org Mon Mar 9 05:37:23 2015 From: kwg at kemper.freedesktop.org (Kenneth Graunke) Date: Sun, 8 Mar 2015 22:37:23 -0700 (PDT) Subject: Mesa (master): nir: Plumb the shader stage into glsl_to_nir(). Message-ID: <20150309053723.B587976331@kemper.freedesktop.org> Module: Mesa Branch: master Commit: c6f2abe67e38c52361a1d342dca6ec5ed7747913 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=c6f2abe67e38c52361a1d342dca6ec5ed7747913 Author: Kenneth Graunke Date: Fri Mar 6 01:22:49 2015 -0800 nir: Plumb the shader stage into glsl_to_nir(). The next commit needs to know the shader stage in glsl_to_nir(). To facilitate that, we pass the gl_shader rather than the raw exec_list of instructions. This has both the exec_list and the stage. Signed-off-by: Kenneth Graunke Reviewed-by: Jason Ekstrand --- src/glsl/nir/glsl_to_nir.cpp | 14 ++++++++------ src/glsl/nir/glsl_to_nir.h | 2 +- src/mesa/drivers/dri/i965/brw_fs_nir.cpp | 2 +- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/glsl/nir/glsl_to_nir.cpp b/src/glsl/nir/glsl_to_nir.cpp index 0d96e03..ddad207 100644 --- a/src/glsl/nir/glsl_to_nir.cpp +++ b/src/glsl/nir/glsl_to_nir.cpp @@ -43,7 +43,7 @@ namespace { class nir_visitor : public ir_visitor { public: - nir_visitor(nir_shader *shader); + nir_visitor(nir_shader *shader, gl_shader_stage stage); ~nir_visitor(); virtual void visit(ir_variable *); @@ -83,6 +83,7 @@ private: bool supports_ints; nir_shader *shader; + gl_shader_stage stage; nir_function_impl *impl; exec_list *cf_node_list; nir_instr *result; /* result of the expression tree last visited */ @@ -125,22 +126,23 @@ private: }; /* end of anonymous namespace */ nir_shader * -glsl_to_nir(exec_list *ir, const nir_shader_compiler_options *options) +glsl_to_nir(struct gl_shader *sh, const nir_shader_compiler_options *options) { nir_shader *shader = nir_shader_create(NULL, options); - nir_visitor v1(shader); + nir_visitor v1(shader, sh->Stage); nir_function_visitor v2(&v1); - v2.run(ir); - visit_exec_list(ir, &v1); + v2.run(sh->ir); + visit_exec_list(sh->ir, &v1); return shader; } -nir_visitor::nir_visitor(nir_shader *shader) +nir_visitor::nir_visitor(nir_shader *shader, gl_shader_stage stage) { this->supports_ints = shader->options->native_integers; this->shader = shader; + this->stage = stage; this->is_global = true; this->var_table = _mesa_hash_table_create(NULL, _mesa_hash_pointer, _mesa_key_pointer_equal); diff --git a/src/glsl/nir/glsl_to_nir.h b/src/glsl/nir/glsl_to_nir.h index dd62793..3801e8c 100644 --- a/src/glsl/nir/glsl_to_nir.h +++ b/src/glsl/nir/glsl_to_nir.h @@ -32,7 +32,7 @@ extern "C" { #endif -nir_shader *glsl_to_nir(exec_list *ir, +nir_shader *glsl_to_nir(struct gl_shader *sh, const nir_shader_compiler_options *options); #ifdef __cplusplus diff --git a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp index ccb5cea..3bb6806 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp @@ -87,7 +87,7 @@ fs_visitor::emit_nir_code() /* first, lower the GLSL IR shader to NIR */ lower_output_reads(shader->base.ir); - nir_shader *nir = glsl_to_nir(shader->base.ir, options); + nir_shader *nir = glsl_to_nir(&shader->base, options); nir_validate_shader(nir); nir_lower_global_vars_to_local(nir); From kwg at kemper.freedesktop.org Mon Mar 9 05:37:23 2015 From: kwg at kemper.freedesktop.org (Kenneth Graunke) Date: Sun, 8 Mar 2015 22:37:23 -0700 (PDT) Subject: Mesa (master): nir: Only do gl_FrontFacing workaround in glsl_to_nir for the FS. Message-ID: <20150309053723.C087D76331@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 8dcc1f2c10b3dc6ded38e7a6c302f60061ba587c URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=8dcc1f2c10b3dc6ded38e7a6c302f60061ba587c Author: Kenneth Graunke Date: Fri Mar 6 01:24:30 2015 -0800 nir: Only do gl_FrontFacing workaround in glsl_to_nir for the FS. Vertex shaders can have shader inputs where location happens to be VARYING_SLOT_FACE. Without predicating this on the shader stage, we suddenly end up with load_front_face intrinsics in vertex shaders, which is nonsensical. Fixes spec/arb_vertex_buffer_object/pos-array when using NIR for VS. Signed-off-by: Kenneth Graunke Reviewed-by: Jason Ekstrand --- src/glsl/nir/glsl_to_nir.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/glsl/nir/glsl_to_nir.cpp b/src/glsl/nir/glsl_to_nir.cpp index ddad207..047cb51 100644 --- a/src/glsl/nir/glsl_to_nir.cpp +++ b/src/glsl/nir/glsl_to_nir.cpp @@ -251,7 +251,8 @@ nir_visitor::visit(ir_variable *ir) break; case ir_var_shader_in: - if (ir->data.location == VARYING_SLOT_FACE) { + if (stage == MESA_SHADER_FRAGMENT && + ir->data.location == VARYING_SLOT_FACE) { /* For whatever reason, GLSL IR makes gl_FrontFacing an input */ var->data.location = SYSTEM_VALUE_FRONT_FACE; var->data.mode = nir_var_system_value; From itoral at kemper.freedesktop.org Mon Mar 9 07:31:36 2015 From: itoral at kemper.freedesktop.org (Iago Toral Quiroga) Date: Mon, 9 Mar 2015 00:31:36 -0700 (PDT) Subject: Mesa (master): i965/fs: Implement SIMD16 dual source blending. Message-ID: <20150309073136.DA72B76331@kemper.freedesktop.org> Module: Mesa Branch: master Commit: a72fb69604711d4f0e0fe49241d2da0311503f6a URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=a72fb69604711d4f0e0fe49241d2da0311503f6a Author: Iago Toral Quiroga Date: Thu Mar 5 09:43:38 2015 +0100 i965/fs: Implement SIMD16 dual source blending. >From the SNB PRM, volume 4, part 1, page 193: "The dual source render target messages only have SIMD8 forms due to maximum message length limitations. SIMD16 pixel shaders must send two of these messages to cover all of the pixels. Each message contains two colors (4 channels each) for each pixel in the message payload." Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=82831 Reviewed-by: Jason Ekstrand --- src/mesa/drivers/dri/i965/brw_eu.h | 1 + src/mesa/drivers/dri/i965/brw_eu_emit.c | 3 +- src/mesa/drivers/dri/i965/brw_fs.h | 6 +- src/mesa/drivers/dri/i965/brw_fs_generator.cpp | 15 ++++- src/mesa/drivers/dri/i965/brw_fs_visitor.cpp | 77 ++++++++++++++++++++---- 5 files changed, 83 insertions(+), 19 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_eu.h b/src/mesa/drivers/dri/i965/brw_eu.h index 736c54b..d9ad5bd 100644 --- a/src/mesa/drivers/dri/i965/brw_eu.h +++ b/src/mesa/drivers/dri/i965/brw_eu.h @@ -266,6 +266,7 @@ void brw_fb_WRITE(struct brw_compile *p, unsigned msg_length, unsigned response_length, bool eot, + bool last_render_target, bool header_present); void brw_SAMPLE(struct brw_compile *p, diff --git a/src/mesa/drivers/dri/i965/brw_eu_emit.c b/src/mesa/drivers/dri/i965/brw_eu_emit.c index 6f29468..43e5783 100644 --- a/src/mesa/drivers/dri/i965/brw_eu_emit.c +++ b/src/mesa/drivers/dri/i965/brw_eu_emit.c @@ -2292,6 +2292,7 @@ void brw_fb_WRITE(struct brw_compile *p, unsigned msg_length, unsigned response_length, bool eot, + bool last_render_target, bool header_present) { struct brw_context *brw = p->brw; @@ -2333,7 +2334,7 @@ void brw_fb_WRITE(struct brw_compile *p, msg_type, msg_length, header_present, - eot, /* last render target write */ + last_render_target, response_length, eot, 0 /* send_commit_msg */); diff --git a/src/mesa/drivers/dri/i965/brw_fs.h b/src/mesa/drivers/dri/i965/brw_fs.h index ec77962..ee6ba98 100644 --- a/src/mesa/drivers/dri/i965/brw_fs.h +++ b/src/mesa/drivers/dri/i965/brw_fs.h @@ -370,10 +370,12 @@ public: bool optimize_frontfacing_ternary(nir_alu_instr *instr, const fs_reg &result); - int setup_color_payload(fs_reg *dst, fs_reg color, unsigned components); + int setup_color_payload(fs_reg *dst, fs_reg color, unsigned components, + bool use_2nd_half); void emit_alpha_test(); fs_inst *emit_single_fb_write(fs_reg color1, fs_reg color2, - fs_reg src0_alpha, unsigned components); + fs_reg src0_alpha, unsigned components, + bool use_2nd_half = false); void emit_fb_writes(); void emit_urb_writes(); diff --git a/src/mesa/drivers/dri/i965/brw_fs_generator.cpp b/src/mesa/drivers/dri/i965/brw_fs_generator.cpp index 02ea3b6..e086266 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_generator.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_generator.cpp @@ -214,9 +214,12 @@ fs_generator::fire_fb_write(fs_inst *inst, if (inst->opcode == FS_OPCODE_REP_FB_WRITE) msg_control = BRW_DATAPORT_RENDER_TARGET_WRITE_SIMD16_SINGLE_SOURCE_REPLICATED; - else if (prog_data->dual_src_blend) - msg_control = BRW_DATAPORT_RENDER_TARGET_WRITE_SIMD8_DUAL_SOURCE_SUBSPAN01; - else if (dispatch_width == 16) + else if (prog_data->dual_src_blend) { + if (dispatch_width == 8 || !inst->eot) + msg_control = BRW_DATAPORT_RENDER_TARGET_WRITE_SIMD8_DUAL_SOURCE_SUBSPAN01; + else + msg_control = BRW_DATAPORT_RENDER_TARGET_WRITE_SIMD8_DUAL_SOURCE_SUBSPAN23; + } else if (dispatch_width == 16) msg_control = BRW_DATAPORT_RENDER_TARGET_WRITE_SIMD16_SINGLE_SOURCE; else msg_control = BRW_DATAPORT_RENDER_TARGET_WRITE_SIMD8_SINGLE_SOURCE_SUBSPAN01; @@ -224,6 +227,10 @@ fs_generator::fire_fb_write(fs_inst *inst, uint32_t surf_index = prog_data->binding_table.render_target_start + inst->target; + bool last_render_target = inst->eot || + (prog_data->dual_src_blend && dispatch_width == 16); + + brw_fb_WRITE(p, dispatch_width, payload, @@ -233,6 +240,7 @@ fs_generator::fire_fb_write(fs_inst *inst, nr, 0, inst->eot, + last_render_target, inst->header_present); brw_mark_surface_used(&prog_data->base, surf_index); @@ -370,6 +378,7 @@ fs_generator::generate_blorp_fb_write(fs_inst *inst) inst->mlen, 0, true, + true, inst->header_present); } diff --git a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp index 6b48f70..e413ae3 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp @@ -3363,7 +3363,8 @@ fs_visitor::emit_interpolation_setup_gen6() } int -fs_visitor::setup_color_payload(fs_reg *dst, fs_reg color, unsigned components) +fs_visitor::setup_color_payload(fs_reg *dst, fs_reg color, unsigned components, + bool use_2nd_half) { brw_wm_prog_key *key = (brw_wm_prog_key*) this->key; fs_inst *inst; @@ -3381,7 +3382,7 @@ fs_visitor::setup_color_payload(fs_reg *dst, fs_reg color, unsigned components) colors_enabled = (1 << components) - 1; } - if (dispatch_width == 8 || brw->gen >= 6) { + if (dispatch_width == 8 || (brw->gen >= 6 && !do_dual_src)) { /* SIMD8 write looks like: * m + 0: r0 * m + 1: r1 @@ -3412,6 +3413,33 @@ fs_visitor::setup_color_payload(fs_reg *dst, fs_reg color, unsigned components) len++; } return len; + } else if (brw->gen >= 6 && do_dual_src) { + /* SIMD16 dual source blending for gen6+. + * + * From the SNB PRM, volume 4, part 1, page 193: + * + * "The dual source render target messages only have SIMD8 forms due to + * maximum message length limitations. SIMD16 pixel shaders must send two + * of these messages to cover all of the pixels. Each message contains + * two colors (4 channels each) for each pixel in the message payload." + * + * So in SIMD16 dual source blending we will send 2 SIMD8 messages, + * each one will call this function twice (one for each color involved), + * so in each pass we only write 4 registers. Notice that the second + * SIMD8 message needs to read color data from the 2nd half of the color + * registers, so it needs to call this with use_2nd_half = true. + */ + for (unsigned i = 0; i < 4; ++i) { + if (colors_enabled & (1 << i)) { + dst[i] = fs_reg(GRF, alloc.allocate(1), color.type); + inst = emit(MOV(dst[i], half(offset(color, i), + use_2nd_half ? 1 : 0))); + inst->saturate = key->clamp_fragment_color; + if (use_2nd_half) + inst->force_sechalf = true; + } + } + return 4; } else { /* pre-gen6 SIMD16 single source DP write looks like: * m + 0: r0 @@ -3495,7 +3523,8 @@ fs_visitor::emit_alpha_test() fs_inst * fs_visitor::emit_single_fb_write(fs_reg color0, fs_reg color1, - fs_reg src0_alpha, unsigned components) + fs_reg src0_alpha, unsigned components, + bool use_2nd_half) { assert(stage == MESA_SHADER_FRAGMENT); brw_wm_prog_data *prog_data = (brw_wm_prog_data*) this->prog_data; @@ -3555,7 +3584,8 @@ fs_visitor::emit_single_fb_write(fs_reg color0, fs_reg color1, * alpha out the pipeline to our null renderbuffer to support * alpha-testing, alpha-to-coverage, and so on. */ - length += setup_color_payload(sources + length, this->outputs[0], 0); + length += setup_color_payload(sources + length, this->outputs[0], 0, + false); } else if (color1.file == BAD_FILE) { if (src0_alpha.file != BAD_FILE) { sources[length] = fs_reg(GRF, alloc.allocate(reg_size), @@ -3565,10 +3595,13 @@ fs_visitor::emit_single_fb_write(fs_reg color0, fs_reg color1, length++; } - length += setup_color_payload(sources + length, color0, components); + length += setup_color_payload(sources + length, color0, components, + false); } else { - length += setup_color_payload(sources + length, color0, components); - length += setup_color_payload(sources + length, color1, components); + length += setup_color_payload(sources + length, color0, components, + use_2nd_half); + length += setup_color_payload(sources + length, color1, components, + use_2nd_half); } if (source_depth_to_render_target) { @@ -3637,12 +3670,6 @@ fs_visitor::emit_fb_writes() brw_wm_prog_data *prog_data = (brw_wm_prog_data*) this->prog_data; brw_wm_prog_key *key = (brw_wm_prog_key*) this->key; - if (do_dual_src) { - no16("GL_ARB_blend_func_extended not yet supported in SIMD16."); - if (dispatch_width == 16) - do_dual_src = false; - } - fs_inst *inst; if (do_dual_src) { if (INTEL_DEBUG & DEBUG_SHADER_TIME) @@ -3653,6 +3680,30 @@ fs_visitor::emit_fb_writes() inst = emit_single_fb_write(this->outputs[0], this->dual_src_output, reg_undef, 4); inst->target = 0; + + /* SIMD16 dual source blending requires to send two SIMD8 dual source + * messages, where each message contains color data for 8 pixels. Color + * data for the first group of pixels is stored in the "lower" half of + * the color registers, so in SIMD16, the previous message did: + * m + 0: r0 + * m + 1: g0 + * m + 2: b0 + * m + 3: a0 + * + * Here goes the second message, which packs color data for the + * remaining 8 pixels. Color data for these pixels is stored in the + * "upper" half of the color registers, so we need to do: + * m + 0: r1 + * m + 1: g1 + * m + 2: b1 + * m + 3: a1 + */ + if (dispatch_width == 16) { + inst = emit_single_fb_write(this->outputs[0], this->dual_src_output, + reg_undef, 4, true); + inst->target = 0; + } + prog_data->dual_src_blend = true; } else if (key->nr_color_regions > 0) { for (int target = 0; target < key->nr_color_regions; target++) { From kwg at kemper.freedesktop.org Mon Mar 9 08:35:42 2015 From: kwg at kemper.freedesktop.org (Kenneth Graunke) Date: Mon, 9 Mar 2015 01:35:42 -0700 (PDT) Subject: Mesa (master): nir: Make the printer include nir_variable::location too. Message-ID: <20150309083542.D8CDA76331@kemper.freedesktop.org> Module: Mesa Branch: master Commit: b9c2fa15e31c4904d4a2526b79ef3f70596c1074 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=b9c2fa15e31c4904d4a2526b79ef3f70596c1074 Author: Kenneth Graunke Date: Thu Feb 19 01:19:13 2015 -0800 nir: Make the printer include nir_variable::location too. Being able to see both location and driver_location can be useful when debugging IO mistakes. Signed-off-by: Kenneth Graunke Reviewed-by: Jason Ekstrand Reviewed-by: Connor Abbott --- src/glsl/nir/nir_print.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/glsl/nir/nir_print.c b/src/glsl/nir/nir_print.c index 21d5dde..f8b14a1 100644 --- a/src/glsl/nir/nir_print.c +++ b/src/glsl/nir/nir_print.c @@ -228,7 +228,7 @@ print_var_decl(nir_variable *var, print_var_state *state, FILE *fp) if (var->data.mode == nir_var_shader_in || var->data.mode == nir_var_shader_out || var->data.mode == nir_var_uniform) { - fprintf(fp, " (%u)", var->data.driver_location); + fprintf(fp, " (%u, %u)", var->data.location, var->data.driver_location); } fprintf(fp, "\n"); From imirkin at kemper.freedesktop.org Mon Mar 9 14:53:02 2015 From: imirkin at kemper.freedesktop.org (Ilia Mirkin) Date: Mon, 9 Mar 2015 07:53:02 -0700 (PDT) Subject: Mesa (master): freedreno: move fb state copy after checking for size change Message-ID: <20150309145302.B3C0976338@kemper.freedesktop.org> Module: Mesa Branch: master Commit: f3dfe6513c26d1ce50b3b0fc830d4d8ff7f6b922 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=f3dfe6513c26d1ce50b3b0fc830d4d8ff7f6b922 Author: Ilia Mirkin Date: Mon Mar 2 21:22:27 2015 -0500 freedreno: move fb state copy after checking for size change Fixes: 1f3ca56b ("freedreno: use util_copy_framebuffer_state()") Signed-off-by: Ilia Mirkin Reviewed-by: Rob Clark Cc: "10.4 10.5" --- src/gallium/drivers/freedreno/freedreno_state.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gallium/drivers/freedreno/freedreno_state.c b/src/gallium/drivers/freedreno/freedreno_state.c index 6293f43..77aa4f2 100644 --- a/src/gallium/drivers/freedreno/freedreno_state.c +++ b/src/gallium/drivers/freedreno/freedreno_state.c @@ -123,12 +123,12 @@ fd_set_framebuffer_state(struct pipe_context *pctx, fd_context_render(pctx); - util_copy_framebuffer_state(cso, framebuffer); - if ((cso->width != framebuffer->width) || (cso->height != framebuffer->height)) ctx->needs_rb_fbd = true; + util_copy_framebuffer_state(cso, framebuffer); + ctx->dirty |= FD_DIRTY_FRAMEBUFFER; ctx->disabled_scissor.minx = 0; From imirkin at kemper.freedesktop.org Mon Mar 9 14:53:02 2015 From: imirkin at kemper.freedesktop.org (Ilia Mirkin) Date: Mon, 9 Mar 2015 07:53:02 -0700 (PDT) Subject: Mesa (master): freedreno/ir3: fix array count returned by TXQ Message-ID: <20150309145302.BED2776338@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 8ac957a51c67fc095db9539df6482b9533b1d05c URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=8ac957a51c67fc095db9539df6482b9533b1d05c Author: Ilia Mirkin Date: Sat Mar 7 17:41:47 2015 -0500 freedreno/ir3: fix array count returned by TXQ Signed-off-by: Ilia Mirkin Reviewed-by: Rob Clark Cc: "10.4 10.5" --- src/gallium/drivers/freedreno/ir3/ir3_compiler.c | 44 +++++++++++++++++++++- 1 file changed, 42 insertions(+), 2 deletions(-) diff --git a/src/gallium/drivers/freedreno/ir3/ir3_compiler.c b/src/gallium/drivers/freedreno/ir3/ir3_compiler.c index df428eb..a007519 100644 --- a/src/gallium/drivers/freedreno/ir3/ir3_compiler.c +++ b/src/gallium/drivers/freedreno/ir3/ir3_compiler.c @@ -1641,6 +1641,7 @@ trans_txq(const struct instr_translater *t, struct tgsi_dst_register *dst = &inst->Dst[0].Register; struct tgsi_src_register *level = &inst->Src[0].Register; struct tgsi_src_register *samp = &inst->Src[1].Register; + const struct target_info *tgt = &tex_targets[inst->Texture.Texture]; struct tex_info tinf; memset(&tinf, 0, sizeof(tinf)); @@ -1654,8 +1655,47 @@ trans_txq(const struct instr_translater *t, instr->cat5.tex = samp->Index; instr->flags |= tinf.flags; - add_dst_reg_wrmask(ctx, instr, dst, 0, dst->WriteMask); - add_src_reg_wrmask(ctx, instr, level, level->SwizzleX, 0x1); + if (tgt->array && (dst->WriteMask & (1 << tgt->dims))) { + /* Array size actually ends up in .w rather than .z. This doesn't + * matter for miplevel 0, but for higher mips the value in z is + * minified whereas w stays. Also, the value in TEX_CONST_3_DEPTH is + * returned, which means that we have to add 1 to it for arrays. + */ + struct tgsi_dst_register tmp_dst; + struct tgsi_src_register *tmp_src; + type_t type_mov = get_utype(ctx); + + tmp_src = get_internal_temp(ctx, &tmp_dst); + add_dst_reg_wrmask(ctx, instr, &tmp_dst, 0, + dst->WriteMask | TGSI_WRITEMASK_W); + add_src_reg_wrmask(ctx, instr, level, level->SwizzleX, 0x1); + + if (dst->WriteMask & TGSI_WRITEMASK_X) { + instr = instr_create(ctx, 1, 0); + instr->cat1.src_type = type_mov; + instr->cat1.dst_type = type_mov; + add_dst_reg(ctx, instr, dst, 0); + add_src_reg(ctx, instr, tmp_src, src_swiz(tmp_src, 0)); + } + + if (tgt->dims == 2) { + if (dst->WriteMask & TGSI_WRITEMASK_Y) { + instr = instr_create(ctx, 1, 0); + instr->cat1.src_type = type_mov; + instr->cat1.dst_type = type_mov; + add_dst_reg(ctx, instr, dst, 1); + add_src_reg(ctx, instr, tmp_src, src_swiz(tmp_src, 1)); + } + } + + instr = instr_create(ctx, 2, OPC_ADD_U); + add_dst_reg(ctx, instr, dst, tgt->dims); + add_src_reg(ctx, instr, tmp_src, src_swiz(tmp_src, 3)); + ir3_reg_create(instr, 0, IR3_REG_IMMED)->iim_val = 1; + } else { + add_dst_reg_wrmask(ctx, instr, dst, 0, dst->WriteMask); + add_src_reg_wrmask(ctx, instr, level, level->SwizzleX, 0x1); + } } /* DDX/DDY */ From imirkin at kemper.freedesktop.org Mon Mar 9 14:53:02 2015 From: imirkin at kemper.freedesktop.org (Ilia Mirkin) Date: Mon, 9 Mar 2015 07:53:02 -0700 (PDT) Subject: Mesa (master): freedreno/ir3: get the # of miplevels from getinfo Message-ID: <20150309145302.CCB7276338@kemper.freedesktop.org> Module: Mesa Branch: master Commit: cb3eb43ad690a7355429ba8dcd40120646c55b9c URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=cb3eb43ad690a7355429ba8dcd40120646c55b9c Author: Ilia Mirkin Date: Sat Mar 7 18:25:54 2015 -0500 freedreno/ir3: get the # of miplevels from getinfo This fixes ARB_texture_query_levels to actually return the desired value. Signed-off-by: Ilia Mirkin Reviewed-by: Rob Clark Cc: "10.4 10.5" --- src/gallium/drivers/freedreno/ir3/ir3_compiler.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/gallium/drivers/freedreno/ir3/ir3_compiler.c b/src/gallium/drivers/freedreno/ir3/ir3_compiler.c index a007519..8ffa37c 100644 --- a/src/gallium/drivers/freedreno/ir3/ir3_compiler.c +++ b/src/gallium/drivers/freedreno/ir3/ir3_compiler.c @@ -1696,6 +1696,26 @@ trans_txq(const struct instr_translater *t, add_dst_reg_wrmask(ctx, instr, dst, 0, dst->WriteMask); add_src_reg_wrmask(ctx, instr, level, level->SwizzleX, 0x1); } + + if (dst->WriteMask & TGSI_WRITEMASK_W) { + /* The # of levels comes from getinfo.z. We need to add 1 to it, since + * the value in TEX_CONST_0 is zero-based. + */ + struct tgsi_dst_register tmp_dst; + struct tgsi_src_register *tmp_src; + + tmp_src = get_internal_temp(ctx, &tmp_dst); + instr = instr_create(ctx, 5, OPC_GETINFO); + instr->cat5.type = get_utype(ctx); + instr->cat5.samp = samp->Index; + instr->cat5.tex = samp->Index; + add_dst_reg_wrmask(ctx, instr, &tmp_dst, 0, TGSI_WRITEMASK_Z); + + instr = instr_create(ctx, 2, OPC_ADD_U); + add_dst_reg(ctx, instr, dst, 3); + add_src_reg(ctx, instr, tmp_src, src_swiz(tmp_src, 2)); + ir3_reg_create(instr, 0, IR3_REG_IMMED)->iim_val = 1; + } } /* DDX/DDY */ From tstellar at kemper.freedesktop.org Mon Mar 9 15:01:21 2015 From: tstellar at kemper.freedesktop.org (Tom Stellard) Date: Mon, 9 Mar 2015 08:01:21 -0700 (PDT) Subject: Mesa (master): clover: Return the minimum required value for CL_DEVICE_SINGLE_FP_CONFIG v2 Message-ID: <20150309150121.95FF576338@kemper.freedesktop.org> Module: Mesa Branch: master Commit: a646b00cfc42fecdf4f853a6fe3ddf12d7801881 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=a646b00cfc42fecdf4f853a6fe3ddf12d7801881 Author: Tom Stellard Date: Thu Mar 5 14:30:57 2015 +0000 clover: Return the minimum required value for CL_DEVICE_SINGLE_FP_CONFIG v2 This means dropping CL_FP_DENORM from the current return value. v2: - Add comments about minimum values for OpenCL 1.2. Reviewed-by: Francisco Jerez Reviewed-by: Jan Vesely --- src/gallium/state_trackers/clover/api/device.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/gallium/state_trackers/clover/api/device.cpp b/src/gallium/state_trackers/clover/api/device.cpp index b1f556f..5d1f4ab 100644 --- a/src/gallium/state_trackers/clover/api/device.cpp +++ b/src/gallium/state_trackers/clover/api/device.cpp @@ -201,8 +201,11 @@ clGetDeviceInfo(cl_device_id d_dev, cl_device_info param, break; case CL_DEVICE_SINGLE_FP_CONFIG: + // This is the "mandated minimum single precision floating-point + // capability" for OpenCL 1.1. In OpenCL 1.2, nothing is required for + // custom devices. buf.as_scalar() = - CL_FP_DENORM | CL_FP_INF_NAN | CL_FP_ROUND_TO_NEAREST; + CL_FP_INF_NAN | CL_FP_ROUND_TO_NEAREST; break; case CL_DEVICE_DOUBLE_FP_CONFIG: From tstellar at kemper.freedesktop.org Mon Mar 9 15:01:21 2015 From: tstellar at kemper.freedesktop.org (Tom Stellard) Date: Mon, 9 Mar 2015 08:01:21 -0700 (PDT) Subject: Mesa (master): radeonsi/compute: Use value from compiler for COMPUTE_PGM_RSRC1.FLOAT_MODE Message-ID: <20150309150121.A4A1676338@kemper.freedesktop.org> Module: Mesa Branch: master Commit: bbfa1c323917cc54162a64e7882cecaaaa9a7b70 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=bbfa1c323917cc54162a64e7882cecaaaa9a7b70 Author: Tom Stellard Date: Fri Mar 6 14:53:00 2015 +0000 radeonsi/compute: Use value from compiler for COMPUTE_PGM_RSRC1.FLOAT_MODE Reviewed-by: Marek Ol??k --- src/gallium/drivers/radeonsi/si_compute.c | 3 ++- src/gallium/drivers/radeonsi/si_shader.c | 1 + src/gallium/drivers/radeonsi/si_shader.h | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/gallium/drivers/radeonsi/si_compute.c b/src/gallium/drivers/radeonsi/si_compute.c index 5009f69..8609b89 100644 --- a/src/gallium/drivers/radeonsi/si_compute.c +++ b/src/gallium/drivers/radeonsi/si_compute.c @@ -377,7 +377,8 @@ static void si_launch_grid( * XXX: The compiler should account for this. */ | S_00B848_SGPRS(((MAX2(4 + arg_user_sgpr_count, - shader->num_sgprs)) - 1) / 8)) + shader->num_sgprs)) - 1) / 8) + | S_00B028_FLOAT_MODE(shader->float_mode)) ; lds_blocks = shader->lds_size; diff --git a/src/gallium/drivers/radeonsi/si_shader.c b/src/gallium/drivers/radeonsi/si_shader.c index b0417ed..87aef4d 100644 --- a/src/gallium/drivers/radeonsi/si_shader.c +++ b/src/gallium/drivers/radeonsi/si_shader.c @@ -2546,6 +2546,7 @@ void si_shader_binary_read_config(const struct si_screen *sscreen, case R_00B848_COMPUTE_PGM_RSRC1: shader->num_sgprs = MAX2(shader->num_sgprs, (G_00B028_SGPRS(value) + 1) * 8); shader->num_vgprs = MAX2(shader->num_vgprs, (G_00B028_VGPRS(value) + 1) * 4); + shader->float_mode = G_00B028_FLOAT_MODE(value); break; case R_00B02C_SPI_SHADER_PGM_RSRC2_PS: shader->lds_size = MAX2(shader->lds_size, G_00B02C_EXTRA_LDS_SIZE(value)); diff --git a/src/gallium/drivers/radeonsi/si_shader.h b/src/gallium/drivers/radeonsi/si_shader.h index 551c7dc..4f2bb91 100644 --- a/src/gallium/drivers/radeonsi/si_shader.h +++ b/src/gallium/drivers/radeonsi/si_shader.h @@ -149,6 +149,7 @@ struct si_shader { unsigned num_vgprs; unsigned lds_size; unsigned spi_ps_input_ena; + unsigned float_mode; unsigned scratch_bytes_per_wave; unsigned spi_shader_col_format; unsigned spi_shader_z_format; From tstellar at kemper.freedesktop.org Mon Mar 9 15:01:21 2015 From: tstellar at kemper.freedesktop.org (Tom Stellard) Date: Mon, 9 Mar 2015 08:01:21 -0700 (PDT) Subject: Mesa (master): radeonsi: Add additional information to shader dumps Message-ID: <20150309150121.B0C6376338@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 51b43c559f40eed2d02a35014c86b6a3e232c6fa URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=51b43c559f40eed2d02a35014c86b6a3e232c6fa Author: Tom Stellard Date: Thu Feb 26 21:27:27 2015 -0500 radeonsi: Add additional information to shader dumps This adds SGPR count, VGPR count, shader size, LDS size, and scratch usage to shader dumps. Reviewed-by: Marek Ol??k --- src/gallium/drivers/radeonsi/si_shader.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/gallium/drivers/radeonsi/si_shader.c b/src/gallium/drivers/radeonsi/si_shader.c index 87aef4d..0ef58a7 100644 --- a/src/gallium/drivers/radeonsi/si_shader.c +++ b/src/gallium/drivers/radeonsi/si_shader.c @@ -2605,17 +2605,23 @@ int si_shader_binary_read(struct si_screen *sscreen, bool dump = r600_can_dump_shader(&sscreen->b, shader->selector ? shader->selector->tokens : NULL); - if (dump && !binary->disassembled) { - fprintf(stderr, "SI CODE:\n"); - for (i = 0; i < binary->code_size; i+=4 ) { - fprintf(stderr, "@0x%x: %02x%02x%02x%02x\n", i, binary->code[i + 3], + si_shader_binary_read_config(sscreen, shader, 0); + + if (dump) { + if (!binary->disassembled) { + fprintf(stderr, "SI CODE:\n"); + for (i = 0; i < binary->code_size; i+=4 ) { + fprintf(stderr, "@0x%x: %02x%02x%02x%02x\n", i, binary->code[i + 3], binary->code[i + 2], binary->code[i + 1], binary->code[i]); + } } + fprintf(stderr, "SGPRS: %d\nVGPRS: %d\nCode Size: %d bytes\nLDS: %d blocks\n" + "Scratch: %d bytes per wave\n", + shader->num_sgprs, shader->num_vgprs, binary->code_size, + shader->lds_size, shader->scratch_bytes_per_wave); } - si_shader_binary_read_config(sscreen, shader, 0); - /* copy new shader */ code_size = binary->code_size + binary->rodata_size; r600_resource_reference(&shader->bo, NULL); From mareko at kemper.freedesktop.org Mon Mar 9 20:02:25 2015 From: mareko at kemper.freedesktop.org (Marek Olšák) Date: Mon, 9 Mar 2015 13:02:25 -0700 (PDT) Subject: Mesa (master): r300g: Fix the ATI1N swizzle (RGTC1 and LATC1) Message-ID: <20150309200225.EA2BC76338@kemper.freedesktop.org> Module: Mesa Branch: master Commit: f710b99071fe4e3c2ee88cdcb6bb5c10298e014e URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=f710b99071fe4e3c2ee88cdcb6bb5c10298e014e Author: Stefan D?singer Date: Mon Mar 9 16:15:13 2015 +0100 r300g: Fix the ATI1N swizzle (RGTC1 and LATC1) This fixes the GL_COMPRESSED_RED_RGTC1 part of piglit's rgtc-teximage-01 test as well as the precision part of Wine's 3dc format test (fd.o bug 89156). The Z component seems to contain a lower precision version of the result, probably a temporary value from the decompression computation. The Y and W component contain different data that depends on the input values as well, but I could not make sense of them (Not that I tried very hard). GL_COMPRESSED_SIGNED_RED_RGTC1 still seems to have precision problems in piglit, and both formats are affected by a compiler bug if they're sampled by the shader with a swizzle other than .xyzw. Wine uses .xxxx, which returns random garbage. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=89156 Signed-off-by: Marek Ol??k Cc: 10.5 10.4 --- src/gallium/drivers/r300/r300_texture.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/gallium/drivers/r300/r300_texture.c b/src/gallium/drivers/r300/r300_texture.c index ffe8c00..340b8fc 100644 --- a/src/gallium/drivers/r300/r300_texture.c +++ b/src/gallium/drivers/r300/r300_texture.c @@ -176,7 +176,9 @@ uint32_t r300_translate_texformat(enum pipe_format format, format != PIPE_FORMAT_RGTC2_UNORM && format != PIPE_FORMAT_RGTC2_SNORM && format != PIPE_FORMAT_LATC2_UNORM && - format != PIPE_FORMAT_LATC2_SNORM) { + format != PIPE_FORMAT_LATC2_SNORM && + format != PIPE_FORMAT_RGTC1_UNORM && + format != PIPE_FORMAT_LATC1_UNORM) { result |= r300_get_swizzle_combined(desc->swizzle, swizzle_view, TRUE); } else { From mareko at kemper.freedesktop.org Mon Mar 9 20:02:25 2015 From: mareko at kemper.freedesktop.org (Marek Olšák) Date: Mon, 9 Mar 2015 13:02:25 -0700 (PDT) Subject: Mesa (master): r300g: fix RGTC1 and LATC1 SNORM formats Message-ID: <20150309200225.F24D47633D@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 74a757f92f7377f59c0feb7f84c7518f9a167631 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=74a757f92f7377f59c0feb7f84c7518f9a167631 Author: Marek Ol??k Date: Mon Mar 9 20:04:04 2015 +0100 r300g: fix RGTC1 and LATC1 SNORM formats Cc: 10.5 10.4 --- src/gallium/drivers/r300/r300_fs.c | 18 ++---------------- src/gallium/drivers/r300/r300_texture.c | 30 +++++++++++++++--------------- 2 files changed, 17 insertions(+), 31 deletions(-) diff --git a/src/gallium/drivers/r300/r300_fs.c b/src/gallium/drivers/r300/r300_fs.c index c00f55f..79eee73 100644 --- a/src/gallium/drivers/r300/r300_fs.c +++ b/src/gallium/drivers/r300/r300_fs.c @@ -170,24 +170,10 @@ static void get_external_state( } state->unit[i].non_normalized_coords = !s->state.normalized_coords; - state->unit[i].convert_unorm_to_snorm = - v->base.format == PIPE_FORMAT_RGTC1_SNORM || - v->base.format == PIPE_FORMAT_LATC1_SNORM; + state->unit[i].convert_unorm_to_snorm = 0; /* Pass texture swizzling to the compiler, some lowering passes need it. */ - if (v->base.format == PIPE_FORMAT_RGTC1_SNORM || - v->base.format == PIPE_FORMAT_LATC1_SNORM) { - unsigned char swizzle[4]; - - util_format_compose_swizzles( - util_format_description(v->base.format)->swizzle, - v->swizzle, - swizzle); - - state->unit[i].texture_swizzle = - RC_MAKE_SWIZZLE(swizzle[0], swizzle[1], - swizzle[2], swizzle[3]); - } else if (state->unit[i].compare_mode_enabled) { + if (state->unit[i].compare_mode_enabled) { state->unit[i].texture_swizzle = RC_MAKE_SWIZZLE(v->swizzle[0], v->swizzle[1], v->swizzle[2], v->swizzle[3]); diff --git a/src/gallium/drivers/r300/r300_texture.c b/src/gallium/drivers/r300/r300_texture.c index 340b8fc..e85a818 100644 --- a/src/gallium/drivers/r300/r300_texture.c +++ b/src/gallium/drivers/r300/r300_texture.c @@ -169,22 +169,21 @@ uint32_t r300_translate_texformat(enum pipe_format format, /* Add swizzling. */ /* The RGTC1_SNORM and LATC1_SNORM swizzle is done in the shader. */ - if (format != PIPE_FORMAT_RGTC1_SNORM && + if (util_format_is_compressed(format) && + dxtc_swizzle && + format != PIPE_FORMAT_RGTC2_UNORM && + format != PIPE_FORMAT_RGTC2_SNORM && + format != PIPE_FORMAT_LATC2_UNORM && + format != PIPE_FORMAT_LATC2_SNORM && + format != PIPE_FORMAT_RGTC1_UNORM && + format != PIPE_FORMAT_RGTC1_SNORM && + format != PIPE_FORMAT_LATC1_UNORM && format != PIPE_FORMAT_LATC1_SNORM) { - if (util_format_is_compressed(format) && - dxtc_swizzle && - format != PIPE_FORMAT_RGTC2_UNORM && - format != PIPE_FORMAT_RGTC2_SNORM && - format != PIPE_FORMAT_LATC2_UNORM && - format != PIPE_FORMAT_LATC2_SNORM && - format != PIPE_FORMAT_RGTC1_UNORM && - format != PIPE_FORMAT_LATC1_UNORM) { - result |= r300_get_swizzle_combined(desc->swizzle, swizzle_view, - TRUE); - } else { - result |= r300_get_swizzle_combined(desc->swizzle, swizzle_view, - FALSE); - } + result |= r300_get_swizzle_combined(desc->swizzle, swizzle_view, + TRUE); + } else { + result |= r300_get_swizzle_combined(desc->swizzle, swizzle_view, + FALSE); } /* S3TC formats. */ @@ -215,6 +214,7 @@ uint32_t r300_translate_texformat(enum pipe_format format, switch (format) { case PIPE_FORMAT_RGTC1_SNORM: case PIPE_FORMAT_LATC1_SNORM: + result |= sign_bit[0]; case PIPE_FORMAT_LATC1_UNORM: case PIPE_FORMAT_RGTC1_UNORM: return R500_TX_FORMAT_ATI1N | result; From mareko at kemper.freedesktop.org Mon Mar 9 20:02:26 2015 From: mareko at kemper.freedesktop.org (Marek Olšák) Date: Mon, 9 Mar 2015 13:02:26 -0700 (PDT) Subject: Mesa (master): r300g: remove the broken SNORM->UNORM shader lowering pass Message-ID: <20150309200226.0716576338@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 4815c187b7faf48ebf38ac9efb0ed7b126f2a460 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=4815c187b7faf48ebf38ac9efb0ed7b126f2a460 Author: Marek Ol??k Date: Mon Mar 9 20:05:48 2015 +0100 r300g: remove the broken SNORM->UNORM shader lowering pass Not used anymore. --- src/gallium/drivers/r300/compiler/radeon_code.h | 6 --- .../drivers/r300/compiler/radeon_program_tex.c | 47 -------------------- src/gallium/drivers/r300/r300_fs.c | 1 - 3 files changed, 54 deletions(-) diff --git a/src/gallium/drivers/r300/compiler/radeon_code.h b/src/gallium/drivers/r300/compiler/radeon_code.h index beafc26..47f46d0 100644 --- a/src/gallium/drivers/r300/compiler/radeon_code.h +++ b/src/gallium/drivers/r300/compiler/radeon_code.h @@ -175,12 +175,6 @@ struct r300_fragment_program_external_state { * and right before texture fetch. The scaling factor is given by * RC_STATE_R300_TEXSCALE_FACTOR. */ unsigned clamp_and_scale_before_fetch : 1; - - /** - * Fetch RGTC1_SNORM or LATC1_SNORM as UNORM and convert UNORM -> SNORM - * in the shader. - */ - unsigned convert_unorm_to_snorm:1; } unit[16]; unsigned alpha_to_one:1; diff --git a/src/gallium/drivers/r300/compiler/radeon_program_tex.c b/src/gallium/drivers/r300/compiler/radeon_program_tex.c index 8dfcd54..17d6ee9 100644 --- a/src/gallium/drivers/r300/compiler/radeon_program_tex.c +++ b/src/gallium/drivers/r300/compiler/radeon_program_tex.c @@ -434,53 +434,6 @@ int radeonTransformTEX( scale_texcoords(compiler, inst, RC_STATE_R300_TEXSCALE_FACTOR); } - /* Convert SNORM-encoded ATI1N sampled as UNORM to SNORM. - * Formula: dst = tex > 0.5 ? tex*2-2 : tex*2 - */ - if (inst->U.I.Opcode != RC_OPCODE_KIL && - compiler->state.unit[inst->U.I.TexSrcUnit].convert_unorm_to_snorm) { - unsigned two, two_swizzle; - struct rc_instruction *inst_mul, *inst_mad, *inst_cnd; - - two = rc_constants_add_immediate_scalar(&c->Program.Constants, 2.35, &two_swizzle); - - inst_mul = rc_insert_new_instruction(c, inst); - inst_mul->U.I.Opcode = RC_OPCODE_MUL; - inst_mul->U.I.DstReg.File = RC_FILE_TEMPORARY; - inst_mul->U.I.DstReg.Index = rc_find_free_temporary(c); - inst_mul->U.I.SrcReg[0].File = RC_FILE_TEMPORARY; - inst_mul->U.I.SrcReg[0].Index = rc_find_free_temporary(c); /* redirected TEX output */ - inst_mul->U.I.SrcReg[1].File = RC_FILE_CONSTANT; /* 2 */ - inst_mul->U.I.SrcReg[1].Index = two; - inst_mul->U.I.SrcReg[1].Swizzle = two_swizzle; - - inst_mad = rc_insert_new_instruction(c, inst_mul); - inst_mad->U.I.Opcode = RC_OPCODE_MAD; - inst_mad->U.I.DstReg.File = RC_FILE_TEMPORARY; - inst_mad->U.I.DstReg.Index = rc_find_free_temporary(c); - inst_mad->U.I.SrcReg[0] = inst_mul->U.I.SrcReg[0]; /* redirected TEX output */ - inst_mad->U.I.SrcReg[1] = inst_mul->U.I.SrcReg[1]; /* 2 */ - inst_mad->U.I.SrcReg[2] = inst_mul->U.I.SrcReg[1]; /* 2 */ - inst_mad->U.I.SrcReg[2].Negate = RC_MASK_XYZW; - - inst_cnd = rc_insert_new_instruction(c, inst_mad); - inst_cnd->U.I.Opcode = RC_OPCODE_CND; - inst_cnd->U.I.SaturateMode = inst->U.I.SaturateMode; - inst_cnd->U.I.DstReg = inst->U.I.DstReg; - inst_cnd->U.I.SrcReg[0].File = RC_FILE_TEMPORARY; - inst_cnd->U.I.SrcReg[0].Index = inst_mad->U.I.DstReg.Index; - inst_cnd->U.I.SrcReg[0].Swizzle = compiler->state.unit[inst->U.I.TexSrcUnit].texture_swizzle; - inst_cnd->U.I.SrcReg[1].File = RC_FILE_TEMPORARY; - inst_cnd->U.I.SrcReg[1].Index = inst_mul->U.I.DstReg.Index; - inst_cnd->U.I.SrcReg[1].Swizzle = compiler->state.unit[inst->U.I.TexSrcUnit].texture_swizzle; - inst_cnd->U.I.SrcReg[2] = inst_mul->U.I.SrcReg[0]; /* redirected TEX output */ - - inst->U.I.SaturateMode = 0; - inst->U.I.DstReg.File = RC_FILE_TEMPORARY; - inst->U.I.DstReg.Index = inst_mul->U.I.SrcReg[0].Index; - inst->U.I.DstReg.WriteMask = RC_MASK_XYZW; - } - /* Cannot write texture to output registers or with saturate (all chips), * or with masks (non-r500). */ if (inst->U.I.Opcode != RC_OPCODE_KIL && diff --git a/src/gallium/drivers/r300/r300_fs.c b/src/gallium/drivers/r300/r300_fs.c index 79eee73..429543a 100644 --- a/src/gallium/drivers/r300/r300_fs.c +++ b/src/gallium/drivers/r300/r300_fs.c @@ -170,7 +170,6 @@ static void get_external_state( } state->unit[i].non_normalized_coords = !s->state.normalized_coords; - state->unit[i].convert_unorm_to_snorm = 0; /* Pass texture swizzling to the compiler, some lowering passes need it. */ if (state->unit[i].compare_mode_enabled) { From mareko at kemper.freedesktop.org Mon Mar 9 20:02:26 2015 From: mareko at kemper.freedesktop.org (Marek Olšák) Date: Mon, 9 Mar 2015 13:02:26 -0700 (PDT) Subject: Mesa (master): r300g: use memset for clearing the shader key Message-ID: <20150309200226.0E2FD76338@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 113601086d336b4ba8b378c4df6b557461a26ad6 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=113601086d336b4ba8b378c4df6b557461a26ad6 Author: Marek Ol??k Date: Mon Mar 9 20:01:26 2015 +0100 r300g: use memset for clearing the shader key --- src/gallium/drivers/r300/r300_fs.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gallium/drivers/r300/r300_fs.c b/src/gallium/drivers/r300/r300_fs.c index 429543a..6a96e67 100644 --- a/src/gallium/drivers/r300/r300_fs.c +++ b/src/gallium/drivers/r300/r300_fs.c @@ -564,9 +564,10 @@ static void r300_translate_fragment_shader( boolean r300_pick_fragment_shader(struct r300_context* r300) { struct r300_fragment_shader* fs = r300_fs(r300); - struct r300_fragment_program_external_state state = {{{ 0 }}}; + struct r300_fragment_program_external_state state; struct r300_fragment_shader_code* ptr; + memset(&state, 0, sizeof(state)); get_external_state(r300, &state); if (!fs->first) { From mareko at kemper.freedesktop.org Mon Mar 9 20:27:06 2015 From: mareko at kemper.freedesktop.org (Marek Olšák) Date: Mon, 9 Mar 2015 13:27:06 -0700 (PDT) Subject: Mesa (master): r300g: fix a crash when resolving into an sRGB texture Message-ID: <20150309202706.4D81076338@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 9953586af2254f83a610d4cd284f52f37fa18b98 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=9953586af2254f83a610d4cd284f52f37fa18b98 Author: Marek Ol??k Date: Tue Feb 24 23:15:59 2015 +0100 r300g: fix a crash when resolving into an sRGB texture Cc: 10.5 10.4 --- src/gallium/drivers/r300/r300_texture.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/gallium/drivers/r300/r300_texture.c b/src/gallium/drivers/r300/r300_texture.c index e85a818..6c01c0d 100644 --- a/src/gallium/drivers/r300/r300_texture.c +++ b/src/gallium/drivers/r300/r300_texture.c @@ -938,14 +938,16 @@ static void r300_texture_setup_fb_state(struct r300_surface *surf) surf->pitch_zmask = tex->tex.zmask_stride_in_pixels[level]; surf->pitch_hiz = tex->tex.hiz_stride_in_pixels[level]; } else { + enum pipe_format format = util_format_linear(surf->base.format); + surf->pitch = stride | - r300_translate_colorformat(surf->base.format) | + r300_translate_colorformat(format) | R300_COLOR_TILE(tex->tex.macrotile[level]) | R300_COLOR_MICROTILE(tex->tex.microtile); - surf->format = r300_translate_out_fmt(surf->base.format); + surf->format = r300_translate_out_fmt(format); surf->colormask_swizzle = - r300_translate_colormask_swizzle(surf->base.format); + r300_translate_colormask_swizzle(format); surf->pitch_cmask = tex->tex.cmask_stride_in_pixels; } } From mareko at kemper.freedesktop.org Mon Mar 9 20:27:06 2015 From: mareko at kemper.freedesktop.org (Marek Olšák) Date: Mon, 9 Mar 2015 13:27:06 -0700 (PDT) Subject: Mesa (master): r300g: fix sRGB->sRGB blits Message-ID: <20150309202706.5AD1476338@kemper.freedesktop.org> Module: Mesa Branch: master Commit: c939231e7223510408a446400ad23b8b5ce2922e URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=c939231e7223510408a446400ad23b8b5ce2922e Author: Marek Ol??k Date: Mon Mar 9 21:20:03 2015 +0100 r300g: fix sRGB->sRGB blits Cc: 10.5 10.4 --- src/gallium/drivers/r300/r300_blit.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/gallium/drivers/r300/r300_blit.c b/src/gallium/drivers/r300/r300_blit.c index 4e7efc5..baf05ce 100644 --- a/src/gallium/drivers/r300/r300_blit.c +++ b/src/gallium/drivers/r300/r300_blit.c @@ -803,6 +803,15 @@ static void r300_blit(struct pipe_context *pipe, (struct pipe_framebuffer_state*)r300->fb_state.state; struct pipe_blit_info info = *blit; + /* The driver supports sRGB textures but not framebuffers. Blitting + * from sRGB to sRGB should be the same as blitting from linear + * to linear, so use that, This avoids incorrect linearization. + */ + if (util_format_is_srgb(info.src.format)) { + info.src.format = util_format_linear(info.src.format); + info.dst.format = util_format_linear(info.dst.format); + } + /* MSAA resolve. */ if (info.src.resource->nr_samples > 1 && !util_format_is_depth_or_stencil(info.src.resource->format)) { From ldeks at kemper.freedesktop.org Mon Mar 9 20:34:45 2015 From: ldeks at kemper.freedesktop.org (Laura Ekstrand) Date: Mon, 9 Mar 2015 13:34:45 -0700 (PDT) Subject: Mesa (master): main: _mesa_cube_level_complete checks NumLayers. Message-ID: <20150309203445.17EE176338@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 1ee000a0b6737d6c140d4f07b6044908b8ebfdc7 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=1ee000a0b6737d6c140d4f07b6044908b8ebfdc7 Author: Laura Ekstrand Date: Wed Mar 4 10:49:55 2015 -0800 main: _mesa_cube_level_complete checks NumLayers. _mesa_cube_level_complete now verifies that a cube map texture object actually has six texture images before proceeding. Reviewed-by: Anuj Phogat --- src/mesa/main/texobj.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/mesa/main/texobj.c b/src/mesa/main/texobj.c index e018ab9..a99b108 100644 --- a/src/mesa/main/texobj.c +++ b/src/mesa/main/texobj.c @@ -879,6 +879,10 @@ _mesa_cube_level_complete(const struct gl_texture_object *texObj, if (texObj->Target != GL_TEXTURE_CUBE_MAP) return GL_FALSE; + /* Make sure we have enough image planes for a cube map. */ + if (texObj->NumLayers < 6) + return GL_FALSE; + if ((level < 0) || (level >= MAX_TEXTURE_LEVELS)) return GL_FALSE; From ldeks at kemper.freedesktop.org Mon Mar 9 20:34:45 2015 From: ldeks at kemper.freedesktop.org (Laura Ekstrand) Date: Mon, 9 Mar 2015 13:34:45 -0700 (PDT) Subject: Mesa (master): main: Use _mesa_lookup_bufferobj_err to simplify Tex[ture] Buffer[Range]. Message-ID: <20150309203445.793DE76338@kemper.freedesktop.org> Module: Mesa Branch: master Commit: d03337306a59ec7a9c1b4bd37856a95c40c1c801 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=d03337306a59ec7a9c1b4bd37856a95c40c1c801 Author: Laura Ekstrand Date: Wed Mar 4 14:07:50 2015 -0800 main: Use _mesa_lookup_bufferobj_err to simplify Tex[ture]Buffer[Range]. v2: Review from Anuj Phogat - Split rebase of Tex[ture]Buffer[Range] - Closing curly brace on the same line as else Reviewed-by: Anuj Phogat --- src/mesa/main/teximage.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c index 345a8ff..6374ec9 100644 --- a/src/mesa/main/teximage.c +++ b/src/mesa/main/teximage.c @@ -5303,11 +5303,12 @@ _mesa_TexBuffer(GLenum target, GLenum internalFormat, GLuint buffer) return; } - bufObj = _mesa_lookup_bufferobj(ctx, buffer); - if (!bufObj && buffer) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glTexBuffer(buffer %u)", buffer); - return; - } + if (buffer) { + bufObj = _mesa_lookup_bufferobj_err(ctx, buffer, "glTexBuffer"); + if (!bufObj) + return; + } else + bufObj = NULL; texObj = _mesa_get_current_tex_object(ctx, target); if (!texObj) @@ -5387,12 +5388,12 @@ _mesa_TextureBuffer(GLuint texture, GLenum internalFormat, GLuint buffer) return; } - bufObj = _mesa_lookup_bufferobj(ctx, buffer); - if (!bufObj && buffer) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glTextureBuffer(buffer %u)", - buffer); - return; - } + if (buffer) { + bufObj = _mesa_lookup_bufferobj_err(ctx, buffer, "glTextureBuffer"); + if (!bufObj) + return; + } else + bufObj = NULL; /* Get the texture object by Name. */ texObj = _mesa_lookup_texture_err(ctx, texture, From ldeks at kemper.freedesktop.org Mon Mar 9 20:34:45 2015 From: ldeks at kemper.freedesktop.org (Laura Ekstrand) Date: Mon, 9 Mar 2015 13:34:45 -0700 (PDT) Subject: Mesa (master): main: Refactor _mesa_texture_buffer_range. Message-ID: <20150309203445.8768F76338@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 6b78a1fb89670fd050747c79a20ecb1b2cd2dc2e URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=6b78a1fb89670fd050747c79a20ecb1b2cd2dc2e Author: Laura Ekstrand Date: Wed Mar 4 14:31:29 2015 -0800 main: Refactor _mesa_texture_buffer_range. Changes how the caller is identified in error messages, moves a check for ARB_texture_buffer_object from the entry points to the shared code in _mesa_texture_buffer_range, and removes an unused argument (GLenum target). v2: Review from Anuj Phogat - Split rebase of Tex[ture]Buffer[Range] Reviewed-by: Anuj Phogat --- src/mesa/main/teximage.c | 58 ++++++++++++++++++---------------------------- src/mesa/main/teximage.h | 6 ++--- 2 files changed, 25 insertions(+), 39 deletions(-) diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c index 6374ec9..706c76b 100644 --- a/src/mesa/main/teximage.c +++ b/src/mesa/main/teximage.c @@ -5243,24 +5243,34 @@ _mesa_validate_texbuffer_format(const struct gl_context *ctx, void _mesa_texture_buffer_range(struct gl_context *ctx, - struct gl_texture_object *texObj, GLenum target, + struct gl_texture_object *texObj, GLenum internalFormat, struct gl_buffer_object *bufObj, - GLintptr offset, GLsizeiptr size, bool range, - bool dsa) + GLintptr offset, GLsizeiptr size, + const char *caller) { mesa_format format; - FLUSH_VERTICES(ctx, 0); + /* NOTE: ARB_texture_buffer_object has interactions with + * the compatibility profile that are not implemented. + */ + if (!(ctx->API == API_OPENGL_CORE && + ctx->Extensions.ARB_texture_buffer_object)) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "%s(ARB_texture_buffer_object is not" + " implemented for the compatibility profile)", caller); + return; + } format = _mesa_validate_texbuffer_format(ctx, internalFormat); if (format == MESA_FORMAT_NONE) { _mesa_error(ctx, GL_INVALID_ENUM, - "glTex%sBuffer%s(internalFormat 0x%x)", dsa ? "ture" : "", - range ? "Range" : "", internalFormat); + "%s(internalFormat 0x%x)", caller, internalFormat); return; } + FLUSH_VERTICES(ctx, 0); + _mesa_lock_texture(ctx, texObj); { _mesa_reference_buffer_object(ctx, &texObj->BufferObject, bufObj); @@ -5294,15 +5304,6 @@ _mesa_TexBuffer(GLenum target, GLenum internalFormat, GLuint buffer) return; } - /* NOTE: ARB_texture_buffer_object has interactions with - * the compatibility profile that are not implemented. - */ - if (!(ctx->API == API_OPENGL_CORE && - ctx->Extensions.ARB_texture_buffer_object)) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glTexBuffer"); - return; - } - if (buffer) { bufObj = _mesa_lookup_bufferobj_err(ctx, buffer, "glTexBuffer"); if (!bufObj) @@ -5314,8 +5315,8 @@ _mesa_TexBuffer(GLenum target, GLenum internalFormat, GLuint buffer) if (!texObj) return; - _mesa_texture_buffer_range(ctx, texObj, target, internalFormat, bufObj, 0, - buffer ? -1 : 0, false, false); + _mesa_texture_buffer_range(ctx, texObj, internalFormat, bufObj, 0, + buffer ? -1 : 0, "glTexBuffer"); } @@ -5335,12 +5336,6 @@ _mesa_TexBufferRange(GLenum target, GLenum internalFormat, GLuint buffer, return; } - if (!(ctx->API == API_OPENGL_CORE && - ctx->Extensions.ARB_texture_buffer_range)) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glTexBufferRange"); - return; - } - bufObj = _mesa_lookup_bufferobj(ctx, buffer); if (bufObj) { if (offset < 0 || @@ -5367,8 +5362,8 @@ _mesa_TexBufferRange(GLenum target, GLenum internalFormat, GLuint buffer, if (!texObj) return; - _mesa_texture_buffer_range(ctx, texObj, target, internalFormat, bufObj, - offset, size, true, false); + _mesa_texture_buffer_range(ctx, texObj, internalFormat, bufObj, + offset, size, "glTexBufferRange"); } void GLAPIENTRY @@ -5379,15 +5374,6 @@ _mesa_TextureBuffer(GLuint texture, GLenum internalFormat, GLuint buffer) GET_CURRENT_CONTEXT(ctx); - /* NOTE: ARB_texture_buffer_object has interactions with - * the compatibility profile that are not implemented. - */ - if (!(ctx->API == API_OPENGL_CORE && - ctx->Extensions.ARB_texture_buffer_object)) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glTextureBuffer"); - return; - } - if (buffer) { bufObj = _mesa_lookup_bufferobj_err(ctx, buffer, "glTextureBuffer"); if (!bufObj) @@ -5406,8 +5392,8 @@ _mesa_TextureBuffer(GLuint texture, GLenum internalFormat, GLuint buffer) return; } - _mesa_texture_buffer_range(ctx, texObj, texObj->Target, internalFormat, - bufObj, 0, buffer ? -1 : 0, false, true); + _mesa_texture_buffer_range(ctx, texObj, internalFormat, + bufObj, 0, buffer ? -1 : 0, "glTextureBuffer"); } static GLboolean diff --git a/src/mesa/main/teximage.h b/src/mesa/main/teximage.h index 9468650..db6b648 100644 --- a/src/mesa/main/teximage.h +++ b/src/mesa/main/teximage.h @@ -209,11 +209,11 @@ _mesa_texture_image_multisample(struct gl_context *ctx, GLuint dims, extern void _mesa_texture_buffer_range(struct gl_context *ctx, - struct gl_texture_object *texObj, GLenum target, + struct gl_texture_object *texObj, GLenum internalFormat, struct gl_buffer_object *bufObj, - GLintptr offset, GLsizeiptr size, bool range, - bool dsa); + GLintptr offset, GLsizeiptr size, + const char *caller); /*@}*/ From ldeks at kemper.freedesktop.org Mon Mar 9 20:34:45 2015 From: ldeks at kemper.freedesktop.org (Laura Ekstrand) Date: Mon, 9 Mar 2015 13:34:45 -0700 (PDT) Subject: Mesa (master): main: Remove redundant copy of cube map block comment in GetTextureImage. Message-ID: <20150309203445.31A5A76338@kemper.freedesktop.org> Module: Mesa Branch: master Commit: c3e92faeb4875de47f0c83ab807b4ea298bfa079 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=c3e92faeb4875de47f0c83ab807b4ea298bfa079 Author: Laura Ekstrand Date: Wed Mar 4 11:09:17 2015 -0800 main: Remove redundant copy of cube map block comment in GetTextureImage. The comment describing why ARB_direct_state_access texture cube map functions use _mesa_cube_level_complete is very long. To save room in the files, readers are now referred to one central comment on texturesubimage in teximage.c. v2: Review from Anuj Phogat - Remove redundant copies of the cube map block comment Reviewed-by: Anuj Phogat --- src/mesa/main/texgetimage.c | 32 +++----------------------------- 1 file changed, 3 insertions(+), 29 deletions(-) diff --git a/src/mesa/main/texgetimage.c b/src/mesa/main/texgetimage.c index 42044dd..0287ebf 100644 --- a/src/mesa/main/texgetimage.c +++ b/src/mesa/main/texgetimage.c @@ -1088,35 +1088,9 @@ _mesa_GetTextureImage(GLuint texture, GLint level, GLenum format, /* Must handle special case GL_TEXTURE_CUBE_MAP. */ if (texObj->Target == GL_TEXTURE_CUBE_MAP) { - /* - * What do we do if the user created a texture with the following code - * and then called this function with its handle? - * - * GLuint tex; - * glCreateTextures(GL_TEXTURE_CUBE_MAP, 1, &tex); - * glBindTexture(GL_TEXTURE_CUBE_MAP, tex); - * glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, ...); - * glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, ...); - * glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, ...); - * // Note: GL_TEXTURE_CUBE_MAP_NEGATIVE_Y not set, or given the - * // wrong format, or given the wrong size, etc. - * glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, ...); - * glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, ...); - * - * A bug has been filed against the spec for this case. In the - * meantime, we will check for cube completeness. - * - * According to Section 8.17 Texture Completeness in the OpenGL 4.5 - * Core Profile spec (30.10.2014): - * "[A] cube map texture is cube complete if the - * following conditions all hold true: The [base level] texture - * images of each of the six cube map faces have identical, positive, - * and square dimensions. The [base level] images were each specified - * with the same internal format." - * - * It seems reasonable to check for cube completeness of an arbitrary - * level here so that the returned data has a consistent format and size - * and therefore fits in the user's buffer. + /* Make sure the texture object is a proper cube. + * (See texturesubimage in teximage.c for details on why this check is + * performed.) */ if (!_mesa_cube_level_complete(texObj, level)) { _mesa_error(ctx, GL_INVALID_OPERATION, From ldeks at kemper.freedesktop.org Mon Mar 9 20:34:45 2015 From: ldeks at kemper.freedesktop.org (Laura Ekstrand) Date: Mon, 9 Mar 2015 13:34:45 -0700 (PDT) Subject: Mesa (master): main: Checking for cube completeness in GetCompressedTextureImage. Message-ID: <20150309203445.5D6F67633D@kemper.freedesktop.org> Module: Mesa Branch: master Commit: ff011340a499d9fe5c3ead6b46b917578bfeb533 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=ff011340a499d9fe5c3ead6b46b917578bfeb533 Author: Laura Ekstrand Date: Tue Jan 6 14:05:41 2015 -0800 main: Checking for cube completeness in GetCompressedTextureImage. v2: Review from Anuj Phogat - Remove redundant copies of the cube map block comment - Replace redundant "if (!texImage) return;" statements with assert(texImage) Reviewed-by: Anuj Phogat --- src/mesa/main/texgetimage.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/mesa/main/texgetimage.c b/src/mesa/main/texgetimage.c index 9411db8..255d365 100644 --- a/src/mesa/main/texgetimage.c +++ b/src/mesa/main/texgetimage.c @@ -1303,7 +1303,16 @@ _mesa_GetCompressedTextureImage(GLuint texture, GLint level, /* Must handle special case GL_TEXTURE_CUBE_MAP. */ if (texObj->Target == GL_TEXTURE_CUBE_MAP) { - assert(texObj->NumLayers >= 6); + + /* Make sure the texture object is a proper cube. + * (See texturesubimage in teximage.c for details on why this check is + * performed.) + */ + if (!_mesa_cube_level_complete(texObj, level)) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glGetCompressedTextureImage(cube map incomplete)"); + return; + } /* Copy each face. */ for (i = 0; i < 6; ++i) { From ldeks at kemper.freedesktop.org Mon Mar 9 20:34:45 2015 From: ldeks at kemper.freedesktop.org (Laura Ekstrand) Date: Mon, 9 Mar 2015 13:34:45 -0700 (PDT) Subject: Mesa (master): main: Cosmetic changes for Texture Buffers. Message-ID: <20150309203445.9594976338@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 0f6372946b8bf52658140508d6501fe1bfd180d0 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=0f6372946b8bf52658140508d6501fe1bfd180d0 Author: Laura Ekstrand Date: Wed Mar 4 14:34:27 2015 -0800 main: Cosmetic changes for Texture Buffers. Adds a useful comment and some whitespace. Fixes an error message. v2: Review from Anuj Phogat - Split rebase of Tex[ture]Buffer[Range] Reviewed-by: Anuj Phogat --- src/mesa/main/teximage.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c index 706c76b..b4b5ac5 100644 --- a/src/mesa/main/teximage.c +++ b/src/mesa/main/teximage.c @@ -5354,6 +5354,14 @@ _mesa_TexBufferRange(GLenum target, GLenum internalFormat, GLuint buffer, buffer); return; } else { + + /* OpenGL 4.5 core spec (02.02.2015) says in Section 8.9 Buffer + * Textures (PDF page 254): + * "If buffer is zero, then any buffer object attached to the buffer + * texture is detached, the values offset and size are ignored and + * the state for offset and size for the buffer texture are reset to + * zero." + */ offset = 0; size = 0; } @@ -5382,8 +5390,7 @@ _mesa_TextureBuffer(GLuint texture, GLenum internalFormat, GLuint buffer) bufObj = NULL; /* Get the texture object by Name. */ - texObj = _mesa_lookup_texture_err(ctx, texture, - "glTextureBuffer(texture)"); + texObj = _mesa_lookup_texture_err(ctx, texture, "glTextureBuffer"); if (!texObj) return; From ldeks at kemper.freedesktop.org Mon Mar 9 20:34:45 2015 From: ldeks at kemper.freedesktop.org (Laura Ekstrand) Date: Mon, 9 Mar 2015 13:34:45 -0700 (PDT) Subject: Mesa (master): main: Add entry point for TextureBufferRange. Message-ID: <20150309203445.C514776338@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 1e552db5228e4e0acdef1d4bec4503f7116a2622 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=1e552db5228e4e0acdef1d4bec4503f7116a2622 Author: Laura Ekstrand Date: Fri Feb 27 14:54:00 2015 -0800 main: Add entry point for TextureBufferRange. v2: Review by Martin Peres - Get rid of difficult-to-follow code copied and pasted from the original TexBufferRange Reviewed-by: Anuj Phogat --- src/mapi/glapi/gen/ARB_direct_state_access.xml | 8 +++++ src/mesa/main/tests/dispatch_sanity.cpp | 1 + src/mesa/main/teximage.c | 46 ++++++++++++++++++++++++ src/mesa/main/teximage.h | 4 +++ 4 files changed, 59 insertions(+) diff --git a/src/mapi/glapi/gen/ARB_direct_state_access.xml b/src/mapi/glapi/gen/ARB_direct_state_access.xml index 2fe1638..86c00f9 100644 --- a/src/mapi/glapi/gen/ARB_direct_state_access.xml +++ b/src/mapi/glapi/gen/ARB_direct_state_access.xml @@ -21,6 +21,14 @@ + + + + + + + + diff --git a/src/mesa/main/tests/dispatch_sanity.cpp b/src/mesa/main/tests/dispatch_sanity.cpp index d25143f..8f7f69e 100644 --- a/src/mesa/main/tests/dispatch_sanity.cpp +++ b/src/mesa/main/tests/dispatch_sanity.cpp @@ -985,6 +985,7 @@ const struct function gl_core_functions_possible[] = { { "glTextureStorage2DMultisample", 45, -1 }, { "glTextureStorage3DMultisample", 45, -1 }, { "glTextureBuffer", 45, -1 }, + { "glTextureBufferRange", 45, -1 }, /* GL_EXT_polygon_offset_clamp */ { "glPolygonOffsetClampEXT", 11, -1 }, diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c index 7f11bfc..7b1a0e6 100644 --- a/src/mesa/main/teximage.c +++ b/src/mesa/main/teximage.c @@ -5463,6 +5463,52 @@ _mesa_TextureBuffer(GLuint texture, GLenum internalFormat, GLuint buffer) bufObj, 0, buffer ? -1 : 0, "glTextureBuffer"); } +void GLAPIENTRY +_mesa_TextureBufferRange(GLuint texture, GLenum internalFormat, GLuint buffer, + GLintptr offset, GLsizeiptr size) +{ + struct gl_texture_object *texObj; + struct gl_buffer_object *bufObj; + + GET_CURRENT_CONTEXT(ctx); + + if (buffer) { + bufObj = _mesa_lookup_bufferobj_err(ctx, buffer, + "glTextureBufferRange"); + if (!bufObj) + return; + + if (!check_texture_buffer_range(ctx, bufObj, offset, size, + "glTextureBufferRange")) + return; + + } else { + + /* OpenGL 4.5 core spec (02.02.2015) says in Section 8.9 Buffer + * Textures (PDF page 254): + * "If buffer is zero, then any buffer object attached to the buffer + * texture is detached, the values offset and size are ignored and + * the state for offset and size for the buffer texture are reset to + * zero." + */ + offset = 0; + size = 0; + bufObj = NULL; + } + + /* Get the texture object by Name. */ + texObj = _mesa_lookup_texture_err(ctx, texture, "glTextureBufferRange"); + if (!texObj) + return; + + if (!check_texture_buffer_target(ctx, texObj->Target, + "glTextureBufferRange")) + return; + + _mesa_texture_buffer_range(ctx, texObj, internalFormat, + bufObj, offset, size, "glTextureBufferRange"); +} + static GLboolean is_renderable_texture_format(struct gl_context *ctx, GLenum internalformat) { diff --git a/src/mesa/main/teximage.h b/src/mesa/main/teximage.h index db6b648..0ce4a30 100644 --- a/src/mesa/main/teximage.h +++ b/src/mesa/main/teximage.h @@ -409,6 +409,10 @@ _mesa_TexBufferRange(GLenum target, GLenum internalFormat, GLuint buffer, extern void GLAPIENTRY _mesa_TextureBuffer(GLuint texture, GLenum internalFormat, GLuint buffer); +extern void GLAPIENTRY +_mesa_TextureBufferRange(GLuint texture, GLenum internalFormat, GLuint buffer, + GLintptr offset, GLsizeiptr size); + extern void GLAPIENTRY _mesa_TexImage2DMultisample(GLenum target, GLsizei samples, From ldeks at kemper.freedesktop.org Mon Mar 9 20:34:45 2015 From: ldeks at kemper.freedesktop.org (Laura Ekstrand) Date: Mon, 9 Mar 2015 13:34:45 -0700 (PDT) Subject: Mesa (master): main: Remove redundant NumLayers checks. Message-ID: <20150309203445.258B976338@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 8979368f12b96c28774119aff955e7f66a57b3fc URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=8979368f12b96c28774119aff955e7f66a57b3fc Author: Laura Ekstrand Date: Wed Mar 4 11:03:18 2015 -0800 main: Remove redundant NumLayers checks. ARB_direct_state_access texture functions that operate on cube maps no longer need to verify that cube map texture objects contain six texture images because _mesa_cube_level_complete now does that for them. Reviewed-by: Anuj Phogat --- src/mesa/main/texgetimage.c | 13 ------------- src/mesa/main/teximage.c | 14 -------------- 2 files changed, 27 deletions(-) diff --git a/src/mesa/main/texgetimage.c b/src/mesa/main/texgetimage.c index f975c16..42044dd 100644 --- a/src/mesa/main/texgetimage.c +++ b/src/mesa/main/texgetimage.c @@ -1088,19 +1088,6 @@ _mesa_GetTextureImage(GLuint texture, GLint level, GLenum format, /* Must handle special case GL_TEXTURE_CUBE_MAP. */ if (texObj->Target == GL_TEXTURE_CUBE_MAP) { - /* Error checking */ - if (texObj->NumLayers < 6) { - /* Not enough image planes for a cube map. The spec does not say - * what should happen in this case because the user has always - * specified each cube face separately (using - * GL_TEXTURE_CUBE_MAP_POSITIVE_X+i) in previous GL versions. - * This is addressed in Khronos Bug 13223. - */ - _mesa_error(ctx, GL_INVALID_OPERATION, - "glGetTextureImage(insufficient cube map storage)"); - return; - } - /* * What do we do if the user created a texture with the following code * and then called this function with its handle? diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c index 611d664..cb1c81a 100644 --- a/src/mesa/main/teximage.c +++ b/src/mesa/main/teximage.c @@ -3636,20 +3636,6 @@ texturesubimage(struct gl_context *ctx, GLuint dims, if (texObj->Target == GL_TEXTURE_CUBE_MAP) { GLint rowStride; - /* Error checking */ - if (texObj->NumLayers < 6) { - /* Not enough image planes for a cube map. The spec does not say - * what should happen in this case because the user has always - * specified each cube face separately (using - * GL_TEXTURE_CUBE_MAP_POSITIVE_X+i) in previous GL versions. - * This is addressed in Khronos Bug 13223. - */ - _mesa_error(ctx, GL_INVALID_OPERATION, - "glTextureSubImage%uD(insufficient cube map storage)", - dims); - return; - } - /* * What do we do if the user created a texture with the following code * and then called this function with its handle? From ldeks at kemper.freedesktop.org Mon Mar 9 20:34:45 2015 From: ldeks at kemper.freedesktop.org (Laura Ekstrand) Date: Mon, 9 Mar 2015 13:34:45 -0700 (PDT) Subject: Mesa (master): main: assert(texImage) in ARB_DSA texture cube map functions. Message-ID: <20150309203445.41CEF76338@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 70eab80f802b26ac87fe9c3e1fa819affe903afd URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=70eab80f802b26ac87fe9c3e1fa819affe903afd Author: Laura Ekstrand Date: Wed Mar 4 11:14:48 2015 -0800 main: assert(texImage) in ARB_DSA texture cube map functions. ARB_direct_state_access functions that deal with texture cube maps need to make sure that texture images are not NULL before operating on them. In the following cases, the error check functions already throw an error if texImage == NULL, so an assert can be raised instead. v2: Review from Anuj Phogat - Replace redundant "if (!texImage) return;" statements with assert(texImage) Reviewed-by: Anuj Phogat --- src/mesa/main/texgetimage.c | 5 +++-- src/mesa/main/teximage.c | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/mesa/main/texgetimage.c b/src/mesa/main/texgetimage.c index 0287ebf..9411db8 100644 --- a/src/mesa/main/texgetimage.c +++ b/src/mesa/main/texgetimage.c @@ -1101,6 +1101,8 @@ _mesa_GetTextureImage(GLuint texture, GLint level, GLenum format, /* Copy each face. */ for (i = 0; i < 6; ++i) { texImage = texObj->Image[i][level]; + assert(texImage); + _mesa_get_texture_image(ctx, texObj, texImage, texObj->Target, level, format, type, bufSize, pixels, true); @@ -1306,8 +1308,7 @@ _mesa_GetCompressedTextureImage(GLuint texture, GLint level, /* Copy each face. */ for (i = 0; i < 6; ++i) { texImage = texObj->Image[i][level]; - if (!texImage) - return; + assert(texImage); _mesa_get_compressed_texture_image(ctx, texObj, texImage, texObj->Target, level, diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c index cb1c81a..92e2371 100644 --- a/src/mesa/main/teximage.c +++ b/src/mesa/main/teximage.c @@ -3677,6 +3677,8 @@ texturesubimage(struct gl_context *ctx, GLuint dims, /* Copy in each face. */ for (i = 0; i < 6; ++i) { texImage = texObj->Image[i][level]; + assert(texImage); + _mesa_texture_sub_image(ctx, 3, texObj, texImage, texObj->Target, level, xoffset, yoffset, zoffset, width, height, 1, format, @@ -3686,8 +3688,7 @@ texturesubimage(struct gl_context *ctx, GLuint dims, } else { texImage = _mesa_select_tex_image(texObj, texObj->Target, level); - if (!texImage) - return; + assert(texImage); _mesa_texture_sub_image(ctx, dims, texObj, texImage, texObj->Target, level, xoffset, yoffset, zoffset, From ldeks at kemper.freedesktop.org Mon Mar 9 20:34:45 2015 From: ldeks at kemper.freedesktop.org (Laura Ekstrand) Date: Mon, 9 Mar 2015 13:34:45 -0700 (PDT) Subject: Mesa (master): main: Add TEXTURE_CUBE_MAP support for glCompressedTextureSubImage3D. Message-ID: <20150309203445.50F9476338@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 4080c330fa2868017c99b059b8e5ccf8d4eaa938 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=4080c330fa2868017c99b059b8e5ccf8d4eaa938 Author: Laura Ekstrand Date: Tue Jan 6 15:27:32 2015 -0800 main: Add TEXTURE_CUBE_MAP support for glCompressedTextureSubImage3D. v2: Review from Anuj Phogat - Remove redundant copies of the cube map block comment - Replace redundant "if (!texImage) return;" statements with assert(texImage) Reviewed-by: Anuj Phogat --- src/mesa/main/teximage.c | 158 ++++++++++++++++++++++++++++++++++++++-------- src/mesa/main/teximage.h | 3 +- 2 files changed, 133 insertions(+), 28 deletions(-) diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c index 92e2371..345a8ff 100644 --- a/src/mesa/main/teximage.c +++ b/src/mesa/main/teximage.c @@ -4735,30 +4735,19 @@ _mesa_CompressedTexImage3D(GLenum target, GLint level, void _mesa_compressed_texture_sub_image(struct gl_context *ctx, GLuint dims, struct gl_texture_object *texObj, + struct gl_texture_image *texImage, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, - const GLvoid *data, bool dsa) + const GLvoid *data) { - struct gl_texture_image *texImage; - - if (compressed_subtexture_error_check(ctx, dims, texObj, target, - level, xoffset, yoffset, zoffset, - width, height, depth, - format, imageSize, dsa)) { - return; - } - FLUSH_VERTICES(ctx, 0); _mesa_lock_texture(ctx, texObj); { - texImage = _mesa_select_tex_image(texObj, target, level); - assert(texImage); - if (width > 0 && height > 0 && depth > 0) { ctx->Driver.CompressedTexSubImage(ctx, dims, texImage, xoffset, yoffset, zoffset, @@ -4782,6 +4771,8 @@ _mesa_CompressedTexSubImage1D(GLenum target, GLint level, GLint xoffset, GLsizei imageSize, const GLvoid *data) { struct gl_texture_object *texObj; + struct gl_texture_image *texImage; + GET_CURRENT_CONTEXT(ctx); if (compressed_subtexture_target_check(ctx, target, 1, format, false, @@ -4793,9 +4784,19 @@ _mesa_CompressedTexSubImage1D(GLenum target, GLint level, GLint xoffset, if (!texObj) return; - _mesa_compressed_texture_sub_image(ctx, 1, texObj, target, level, + if (compressed_subtexture_error_check(ctx, 1, texObj, target, + level, xoffset, 0, 0, + width, 1, 1, + format, imageSize, false)) { + return; + } + + texImage = _mesa_select_tex_image(texObj, target, level); + assert(texImage); + + _mesa_compressed_texture_sub_image(ctx, 1, texObj, texImage, target, level, xoffset, 0, 0, width, 1, 1, - format, imageSize, data, false); + format, imageSize, data); } void GLAPIENTRY @@ -4804,6 +4805,8 @@ _mesa_CompressedTextureSubImage1D(GLuint texture, GLint level, GLint xoffset, GLsizei imageSize, const GLvoid *data) { struct gl_texture_object *texObj; + struct gl_texture_image *texImage; + GET_CURRENT_CONTEXT(ctx); texObj = _mesa_lookup_texture_err(ctx, texture, @@ -4817,9 +4820,20 @@ _mesa_CompressedTextureSubImage1D(GLuint texture, GLint level, GLint xoffset, return; } - _mesa_compressed_texture_sub_image(ctx, 1, texObj, texObj->Target, level, + if (compressed_subtexture_error_check(ctx, 1, texObj, texObj->Target, + level, xoffset, 0, 0, + width, 1, 1, + format, imageSize, true)) { + return; + } + + texImage = _mesa_select_tex_image(texObj, texObj->Target, level); + assert(texImage); + + _mesa_compressed_texture_sub_image(ctx, 1, texObj, texImage, + texObj->Target, level, xoffset, 0, 0, width, 1, 1, - format, imageSize, data, true); + format, imageSize, data); } @@ -4830,6 +4844,8 @@ _mesa_CompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, const GLvoid *data) { struct gl_texture_object *texObj; + struct gl_texture_image *texImage; + GET_CURRENT_CONTEXT(ctx); if (compressed_subtexture_target_check(ctx, target, 2, format, false, @@ -4841,9 +4857,20 @@ _mesa_CompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, if (!texObj) return; - _mesa_compressed_texture_sub_image(ctx, 2, texObj, target, level, + if (compressed_subtexture_error_check(ctx, 2, texObj, target, + level, xoffset, yoffset, 0, + width, height, 1, + format, imageSize, false)) { + return; + } + + + texImage = _mesa_select_tex_image(texObj, target, level); + assert(texImage); + + _mesa_compressed_texture_sub_image(ctx, 2, texObj, texImage, target, level, xoffset, yoffset, 0, width, height, 1, - format, imageSize, data, false); + format, imageSize, data); } void GLAPIENTRY @@ -4854,6 +4881,8 @@ _mesa_CompressedTextureSubImage2D(GLuint texture, GLint level, GLint xoffset, const GLvoid *data) { struct gl_texture_object *texObj; + struct gl_texture_image *texImage; + GET_CURRENT_CONTEXT(ctx); texObj = _mesa_lookup_texture_err(ctx, texture, @@ -4867,9 +4896,20 @@ _mesa_CompressedTextureSubImage2D(GLuint texture, GLint level, GLint xoffset, return; } - _mesa_compressed_texture_sub_image(ctx, 2, texObj, texObj->Target, level, + if (compressed_subtexture_error_check(ctx, 2, texObj, texObj->Target, + level, xoffset, yoffset, 0, + width, height, 1, + format, imageSize, true)) { + return; + } + + texImage = _mesa_select_tex_image(texObj, texObj->Target, level); + assert(texImage); + + _mesa_compressed_texture_sub_image(ctx, 2, texObj, texImage, + texObj->Target, level, xoffset, yoffset, 0, width, height, 1, - format, imageSize, data, true); + format, imageSize, data); } void GLAPIENTRY @@ -4879,6 +4919,8 @@ _mesa_CompressedTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLsizei imageSize, const GLvoid *data) { struct gl_texture_object *texObj; + struct gl_texture_image *texImage; + GET_CURRENT_CONTEXT(ctx); if (compressed_subtexture_target_check(ctx, target, 3, format, false, @@ -4890,10 +4932,21 @@ _mesa_CompressedTexSubImage3D(GLenum target, GLint level, GLint xoffset, if (!texObj) return; - _mesa_compressed_texture_sub_image(ctx, 3, texObj, target, level, + if (compressed_subtexture_error_check(ctx, 3, texObj, target, + level, xoffset, yoffset, zoffset, + width, height, depth, + format, imageSize, false)) { + return; + } + + + texImage = _mesa_select_tex_image(texObj, target, level); + assert(texImage); + + _mesa_compressed_texture_sub_image(ctx, 3, texObj, texImage, target, level, xoffset, yoffset, zoffset, width, height, depth, - format, imageSize, data, false); + format, imageSize, data); } void GLAPIENTRY @@ -4904,6 +4957,8 @@ _mesa_CompressedTextureSubImage3D(GLuint texture, GLint level, GLint xoffset, const GLvoid *data) { struct gl_texture_object *texObj; + struct gl_texture_image *texImage; + GET_CURRENT_CONTEXT(ctx); texObj = _mesa_lookup_texture_err(ctx, texture, @@ -4917,10 +4972,59 @@ _mesa_CompressedTextureSubImage3D(GLuint texture, GLint level, GLint xoffset, return; } - _mesa_compressed_texture_sub_image(ctx, 3, texObj, texObj->Target, level, - xoffset, yoffset, zoffset, - width, height, depth, - format, imageSize, data, true); + if (compressed_subtexture_error_check(ctx, 3, texObj, texObj->Target, + level, xoffset, yoffset, zoffset, + width, height, depth, + format, imageSize, true)) { + return; + } + + /* Must handle special case GL_TEXTURE_CUBE_MAP. */ + if (texObj->Target == GL_TEXTURE_CUBE_MAP) { + const char *pixels = data; + int i; + GLint image_stride; + + /* Make sure the texture object is a proper cube. + * (See texturesubimage in teximage.c for details on why this check is + * performed.) + */ + if (!_mesa_cube_level_complete(texObj, level)) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glCompressedTextureSubImage3D(cube map incomplete)"); + return; + } + + /* Copy in each face. */ + for (i = 0; i < 6; ++i) { + texImage = texObj->Image[i][level]; + assert(texImage); + + _mesa_compressed_texture_sub_image(ctx, 3, texObj, texImage, + texObj->Target, level, + xoffset, yoffset, zoffset, + width, height, 1, + format, imageSize, pixels); + + /* Compressed images don't have a client format */ + image_stride = _mesa_format_image_size(texImage->TexFormat, + texImage->Width, + texImage->Height, 1); + + pixels += image_stride; + imageSize -= image_stride; + } + } + else { + texImage = _mesa_select_tex_image(texObj, texObj->Target, level); + assert(texImage); + + _mesa_compressed_texture_sub_image(ctx, 3, texObj, texImage, + texObj->Target, level, + xoffset, yoffset, zoffset, + width, height, depth, + format, imageSize, data); + } } static mesa_format diff --git a/src/mesa/main/teximage.h b/src/mesa/main/teximage.h index b7336bc..9468650 100644 --- a/src/mesa/main/teximage.h +++ b/src/mesa/main/teximage.h @@ -181,13 +181,14 @@ _mesa_texture_sub_image(struct gl_context *ctx, GLuint dims, extern void _mesa_compressed_texture_sub_image(struct gl_context *ctx, GLuint dims, struct gl_texture_object *texObj, + struct gl_texture_image *texImage, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, - const GLvoid *data, bool dsa); + const GLvoid *data); extern void _mesa_copy_texture_sub_image(struct gl_context *ctx, GLuint dims, From ldeks at kemper.freedesktop.org Mon Mar 9 20:34:45 2015 From: ldeks at kemper.freedesktop.org (Laura Ekstrand) Date: Mon, 9 Mar 2015 13:34:45 -0700 (PDT) Subject: Mesa (master): main: Add utility function _mesa_lookup_bufferobj_err. Message-ID: <20150309203445.6B39E76338@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 768ca8b83e45b1d23c0d3af0b79cc19c1b3b6988 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=768ca8b83e45b1d23c0d3af0b79cc19c1b3b6988 Author: Laura Ekstrand Date: Fri Jan 9 16:16:48 2015 -0800 main: Add utility function _mesa_lookup_bufferobj_err. This function is exposed to mesa driver internals so that texture buffer objects and array objects can use it. Reviewed-by: Anuj Phogat --- src/mesa/main/bufferobj.c | 19 +++++++++++++++++++ src/mesa/main/bufferobj.h | 4 ++++ 2 files changed, 23 insertions(+) diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c index e1c5877..cef284f 100644 --- a/src/mesa/main/bufferobj.c +++ b/src/mesa/main/bufferobj.c @@ -1006,6 +1006,25 @@ _mesa_lookup_bufferobj_locked(struct gl_context *ctx, GLuint buffer) _mesa_HashLookupLocked(ctx->Shared->BufferObjects, buffer); } +/** + * A convenience function for direct state access functions that throws + * GL_INVALID_OPERATION if buffer is not the name of a buffer object in the + * hash table. + */ +struct gl_buffer_object * +_mesa_lookup_bufferobj_err(struct gl_context *ctx, GLuint buffer, + const char *caller) +{ + struct gl_buffer_object *bufObj; + + bufObj = _mesa_lookup_bufferobj(ctx, buffer); + if (!bufObj) + _mesa_error(ctx, GL_INVALID_OPERATION, + "%s(non-generated buffer name %u)", caller, buffer); + + return bufObj; +} + void _mesa_begin_bufferobj_lookups(struct gl_context *ctx) diff --git a/src/mesa/main/bufferobj.h b/src/mesa/main/bufferobj.h index fe294fc..8e53bfd 100644 --- a/src/mesa/main/bufferobj.h +++ b/src/mesa/main/bufferobj.h @@ -89,6 +89,10 @@ _mesa_lookup_bufferobj(struct gl_context *ctx, GLuint buffer); extern struct gl_buffer_object * _mesa_lookup_bufferobj_locked(struct gl_context *ctx, GLuint buffer); +extern struct gl_buffer_object * +_mesa_lookup_bufferobj_err(struct gl_context *ctx, GLuint buffer, + const char *caller); + extern void _mesa_begin_bufferobj_lookups(struct gl_context *ctx); From ldeks at kemper.freedesktop.org Mon Mar 9 20:34:45 2015 From: ldeks at kemper.freedesktop.org (Laura Ekstrand) Date: Mon, 9 Mar 2015 13:34:45 -0700 (PDT) Subject: Mesa (master): main: Add check_texture_buffer_range. Message-ID: <20150309203445.A492176338@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 5f8c6eabbeb698b6dc653eda9dcf01704e53ae58 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=5f8c6eabbeb698b6dc653eda9dcf01704e53ae58 Author: Laura Ekstrand Date: Wed Mar 4 14:45:40 2015 -0800 main: Add check_texture_buffer_range. Creates a shared function that TexBufferRange and TextureBufferRange can use to check the buffer range. This cleans up TexBufferRange considerably. v2: Review from Anuj Phogat - Split rebase of Tex[ture]Buffer[Range] Reviewed-by: Anuj Phogat --- src/mesa/main/teximage.c | 73 ++++++++++++++++++++++++++++++++++++---------- 1 file changed, 58 insertions(+), 15 deletions(-) diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c index b4b5ac5..e8b5d2e 100644 --- a/src/mesa/main/teximage.c +++ b/src/mesa/main/teximage.c @@ -5289,6 +5289,56 @@ _mesa_texture_buffer_range(struct gl_context *ctx, } +/** + * Check for errors related to the texture buffer range. + * Return false if errors are found, true if none are found. + */ +static bool +check_texture_buffer_range(struct gl_context *ctx, + struct gl_buffer_object *bufObj, + GLintptr offset, GLsizeiptr size, + const char *caller) +{ + /* OpenGL 4.5 core spec (02.02.2015) says in Section 8.9 Buffer + * Textures (PDF page 245): + * "An INVALID_VALUE error is generated if offset is negative, if + * size is less than or equal to zero, or if offset + size is greater + * than the value of BUFFER_SIZE for the buffer bound to target." + */ + if (offset < 0) { + _mesa_error(ctx, GL_INVALID_VALUE, "%s(offset=%d < 0)", caller, + (int) offset); + return false; + } + + if (size <= 0) { + _mesa_error(ctx, GL_INVALID_VALUE, "%s(size=%d <= 0)", caller, + (int) size); + return false; + } + + if (offset + size > bufObj->Size) { + _mesa_error(ctx, GL_INVALID_VALUE, + "%s(offset=%d + size=%d > buffer_size=%d)", caller, + (int) offset, (int) size, (int) bufObj->Size); + return false; + } + + /* OpenGL 4.5 core spec (02.02.2015) says in Section 8.9 Buffer + * Textures (PDF page 245): + * "An INVALID_VALUE error is generated if offset is not an integer + * multiple of the value of TEXTURE_BUFFER_OFFSET_ALIGNMENT." + */ + if (offset % ctx->Const.TextureBufferOffsetAlignment) { + _mesa_error(ctx, GL_INVALID_VALUE, + "%s(invalid offset alignment)", caller); + return false; + } + + return true; +} + + /** GL_ARB_texture_buffer_object */ void GLAPIENTRY _mesa_TexBuffer(GLenum target, GLenum internalFormat, GLuint buffer) @@ -5336,23 +5386,15 @@ _mesa_TexBufferRange(GLenum target, GLenum internalFormat, GLuint buffer, return; } - bufObj = _mesa_lookup_bufferobj(ctx, buffer); - if (bufObj) { - if (offset < 0 || - size <= 0 || - (offset + size) > bufObj->Size) { - _mesa_error(ctx, GL_INVALID_VALUE, "glTexBufferRange"); + if (buffer) { + bufObj = _mesa_lookup_bufferobj_err(ctx, buffer, "glTexBufferRange"); + if (!bufObj) return; - } - if (offset % ctx->Const.TextureBufferOffsetAlignment) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glTexBufferRange(invalid offset alignment)"); + + if (!check_texture_buffer_range(ctx, bufObj, offset, size, + "glTexBufferRange")) return; - } - } else if (buffer) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glTexBufferRange(buffer %u)", - buffer); - return; + } else { /* OpenGL 4.5 core spec (02.02.2015) says in Section 8.9 Buffer @@ -5364,6 +5406,7 @@ _mesa_TexBufferRange(GLenum target, GLenum internalFormat, GLuint buffer, */ offset = 0; size = 0; + bufObj = NULL; } texObj = _mesa_get_current_tex_object(ctx, target); From ldeks at kemper.freedesktop.org Mon Mar 9 20:34:45 2015 From: ldeks at kemper.freedesktop.org (Laura Ekstrand) Date: Mon, 9 Mar 2015 13:34:45 -0700 (PDT) Subject: Mesa (master): main: Add check_texture_buffer_target. Message-ID: <20150309203445.B3E6776338@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 311b3686fe7433b1624384f7d344cc23d6363df2 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=311b3686fe7433b1624384f7d344cc23d6363df2 Author: Laura Ekstrand Date: Wed Mar 4 14:46:02 2015 -0800 main: Add check_texture_buffer_target. Creates a shared function to ensure that texture buffer target is GL_TEXTURE_BUFFER. Helps to clean up the Tex[ture]Buffer[Range] functions. v2: Review from Anuj Phogat - Split rebase of Tex[ture]Buffer[Range] Reviewed-by: Anuj Phogat --- src/mesa/main/teximage.c | 39 ++++++++++++++++++++++++++++----------- 1 file changed, 28 insertions(+), 11 deletions(-) diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c index e8b5d2e..7f11bfc 100644 --- a/src/mesa/main/teximage.c +++ b/src/mesa/main/teximage.c @@ -5290,6 +5290,25 @@ _mesa_texture_buffer_range(struct gl_context *ctx, /** + * Make sure the texture buffer target is GL_TEXTURE_BUFFER. + * Return true if it is, and return false if it is not + * (and throw INVALID ENUM as dictated in the OpenGL 4.5 + * core spec, 02.02.2015, PDF page 245). + */ +static bool +check_texture_buffer_target(struct gl_context *ctx, GLenum target, + const char *caller) +{ + if (target != GL_TEXTURE_BUFFER_ARB) { + _mesa_error(ctx, GL_INVALID_ENUM, + "%s(texture target is not GL_TEXTURE_BUFFER)", caller); + return false; + } + else + return true; +} + +/** * Check for errors related to the texture buffer range. * Return false if errors are found, true if none are found. */ @@ -5348,11 +5367,11 @@ _mesa_TexBuffer(GLenum target, GLenum internalFormat, GLuint buffer) GET_CURRENT_CONTEXT(ctx); - /* Need to catch this before it gets to _mesa_get_current_tex_object */ - if (target != GL_TEXTURE_BUFFER_ARB) { - _mesa_error(ctx, GL_INVALID_ENUM, "glTexBuffer(target)"); + /* Need to catch a bad target before it gets to + * _mesa_get_current_tex_object. + */ + if (!check_texture_buffer_target(ctx, target, "glTexBuffer")) return; - } if (buffer) { bufObj = _mesa_lookup_bufferobj_err(ctx, buffer, "glTexBuffer"); @@ -5380,11 +5399,11 @@ _mesa_TexBufferRange(GLenum target, GLenum internalFormat, GLuint buffer, GET_CURRENT_CONTEXT(ctx); - /* Need to catch this before it gets to _mesa_get_current_tex_object */ - if (target != GL_TEXTURE_BUFFER_ARB) { - _mesa_error(ctx, GL_INVALID_ENUM, "glTexBufferRange(target)"); + /* Need to catch a bad target before it gets to + * _mesa_get_current_tex_object. + */ + if (!check_texture_buffer_target(ctx, target, "glTexBufferRange")) return; - } if (buffer) { bufObj = _mesa_lookup_bufferobj_err(ctx, buffer, "glTexBufferRange"); @@ -5437,10 +5456,8 @@ _mesa_TextureBuffer(GLuint texture, GLenum internalFormat, GLuint buffer) if (!texObj) return; - if (texObj->Target != GL_TEXTURE_BUFFER_ARB) { - _mesa_error(ctx, GL_INVALID_ENUM, "glTextureBuffer(target)"); + if (!check_texture_buffer_target(ctx, texObj->Target, "glTextureBuffer")) return; - } _mesa_texture_buffer_range(ctx, texObj, internalFormat, bufObj, 0, buffer ? -1 : 0, "glTextureBuffer"); From idr at kemper.freedesktop.org Mon Mar 9 21:07:41 2015 From: idr at kemper.freedesktop.org (Ian Romanick) Date: Mon, 9 Mar 2015 14:07:41 -0700 (PDT) Subject: Mesa (master): i965/fs: Silence unused parameter warning Message-ID: <20150309210741.B2CD276338@kemper.freedesktop.org> Module: Mesa Branch: master Commit: e4f26acc08a3d852e60a27d0f0da7001944cb607 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=e4f26acc08a3d852e60a27d0f0da7001944cb607 Author: Ian Romanick Date: Fri Feb 27 16:43:13 2015 -0800 i965/fs: Silence unused parameter warning brw_fs_visitor.cpp:2162:56: warning: unused parameter 'offset_components' [-Wunused-parameter] fs_reg offset_value, unsigned offset_components, ^ Signed-off-by: Ian Romanick Reviewed-by: Jordan Justen --- src/mesa/drivers/dri/i965/brw_fs.h | 2 +- src/mesa/drivers/dri/i965/brw_fs_fp.cpp | 2 +- src/mesa/drivers/dri/i965/brw_fs_nir.cpp | 2 +- src/mesa/drivers/dri/i965/brw_fs_visitor.cpp | 6 ++---- 4 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_fs.h b/src/mesa/drivers/dri/i965/brw_fs.h index ee6ba98..70fc6fc 100644 --- a/src/mesa/drivers/dri/i965/brw_fs.h +++ b/src/mesa/drivers/dri/i965/brw_fs.h @@ -289,7 +289,7 @@ public: fs_reg shadow_c, fs_reg lod, fs_reg dpdy, int grad_components, fs_reg sample_index, - fs_reg offset, unsigned offset_components, + fs_reg offset, fs_reg mcs, int gather_component, bool is_cube_array, diff --git a/src/mesa/drivers/dri/i965/brw_fs_fp.cpp b/src/mesa/drivers/dri/i965/brw_fs_fp.cpp index d22de0e..6d08bf7 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_fp.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_fp.cpp @@ -475,7 +475,7 @@ fs_visitor::emit_fragment_program_code() emit_texture(op, glsl_type::vec4_type, coordinate, coord_components, shadow_c, lod, dpdy, 0, sample_index, - reg_undef, 0, /* offset, components */ + reg_undef, /* offset */ reg_undef, /* mcs */ 0, /* gather component */ false, /* is cube array */ diff --git a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp index 3bb6806..c23ec89 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp @@ -1760,7 +1760,7 @@ fs_visitor::nir_emit_texture(nir_tex_instr *instr) emit_texture(op, dest_type, coordinate, instr->coord_components, shadow_comparitor, lod, lod2, lod_components, sample_index, - offset, offset_components, mcs, gather_component, + offset, mcs, gather_component, is_cube_array, is_rect, sampler, sampler_reg, texunit); fs_reg dest = get_nir_dest(instr->dest); diff --git a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp index e413ae3..cdaba7f 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp @@ -2025,7 +2025,7 @@ fs_visitor::emit_texture(ir_texture_opcode op, fs_reg shadow_c, fs_reg lod, fs_reg lod2, int grad_components, fs_reg sample_index, - fs_reg offset_value, unsigned offset_components, + fs_reg offset_value, fs_reg mcs, int gather_component, bool is_cube_array, @@ -2191,7 +2191,6 @@ fs_visitor::visit(ir_texture *ir) } fs_reg offset_value; - int offset_components = 0; if (ir->offset) { ir_constant *const_offset = ir->offset->as_constant(); if (const_offset) { @@ -2206,7 +2205,6 @@ fs_visitor::visit(ir_texture *ir) ir->offset->accept(this); offset_value = this->result; } - offset_components = ir->offset->type->vector_elements; } fs_reg lod, lod2, sample_index, mcs; @@ -2263,7 +2261,7 @@ fs_visitor::visit(ir_texture *ir) emit_texture(ir->op, ir->type, coordinate, coord_components, shadow_comparitor, lod, lod2, grad_components, - sample_index, offset_value, offset_components, mcs, + sample_index, offset_value, mcs, gather_component, is_cube_array, is_rect, sampler, sampler_reg, texunit); } From idr at kemper.freedesktop.org Mon Mar 9 21:07:41 2015 From: idr at kemper.freedesktop.org (Ian Romanick) Date: Mon, 9 Mar 2015 14:07:41 -0700 (PDT) Subject: Mesa (master): i965/fs: Silence unused parameter warning Message-ID: <20150309210741.C087E76338@kemper.freedesktop.org> Module: Mesa Branch: master Commit: f9779e4a8f2ca67423cded0203adac6ad3d5c448 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=f9779e4a8f2ca67423cded0203adac6ad3d5c448 Author: Ian Romanick Date: Fri Feb 27 18:06:25 2015 -0800 i965/fs: Silence unused parameter warning Unused since b18fd23. brw_fs.cpp:2878:44: warning: unused parameter 'dispatch_width' [-Wunused-parameter] clear_deps_for_inst_src(fs_inst *inst, int dispatch_width, bool *deps, ^ Signed-off-by: Ian Romanick Reviewed-by: Jason Ekstrand Reviewed-by: Jordan Justen --- src/mesa/drivers/dri/i965/brw_fs.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp index 428234f..23876c7 100644 --- a/src/mesa/drivers/dri/i965/brw_fs.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs.cpp @@ -2883,8 +2883,7 @@ fs_visitor::remove_duplicate_mrf_writes() } static void -clear_deps_for_inst_src(fs_inst *inst, int dispatch_width, bool *deps, - int first_grf, int grf_len) +clear_deps_for_inst_src(fs_inst *inst, bool *deps, int first_grf, int grf_len) { /* Clear the flag for registers that actually got read (as expected). */ for (int i = 0; i < inst->sources; i++) { @@ -2935,8 +2934,7 @@ fs_visitor::insert_gen4_pre_send_dependency_workarounds(bblock_t *block, memset(needs_dep, false, sizeof(needs_dep)); memset(needs_dep, true, write_len); - clear_deps_for_inst_src(inst, dispatch_width, - needs_dep, first_write_grf, write_len); + clear_deps_for_inst_src(inst, needs_dep, first_write_grf, write_len); /* Walk backwards looking for writes to registers we're writing which * aren't read since being written. If we hit the start of the program, @@ -2976,8 +2974,7 @@ fs_visitor::insert_gen4_pre_send_dependency_workarounds(bblock_t *block, } /* Clear the flag for registers that actually got read (as expected). */ - clear_deps_for_inst_src(scan_inst, dispatch_width, - needs_dep, first_write_grf, write_len); + clear_deps_for_inst_src(scan_inst, needs_dep, first_write_grf, write_len); /* Continue the loop only if we haven't resolved all the dependencies */ int i; @@ -3022,8 +3019,7 @@ fs_visitor::insert_gen4_post_send_dependency_workarounds(bblock_t *block, fs_ins } /* Clear the flag for registers that actually got read (as expected). */ - clear_deps_for_inst_src(scan_inst, dispatch_width, - needs_dep, first_write_grf, write_len); + clear_deps_for_inst_src(scan_inst, needs_dep, first_write_grf, write_len); /* We insert our reads as late as possible since they're reading the * result of a SEND, which has massive latency. From idr at kemper.freedesktop.org Mon Mar 9 21:07:41 2015 From: idr at kemper.freedesktop.org (Ian Romanick) Date: Mon, 9 Mar 2015 14:07:41 -0700 (PDT) Subject: Mesa (master): i965: Silence many 'static' is not at beginning of declaration warnings Message-ID: <20150309210741.D943676338@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 3a6a732c43e6ba6d48575796907f1ed144c7722c URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=3a6a732c43e6ba6d48575796907f1ed144c7722c Author: Ian Romanick Date: Fri Feb 27 18:26:11 2015 -0800 i965: Silence many 'static' is not at beginning of declaration warnings What a useful warning. #ThanksGCC brw_performance_monitor.c:153:1: warning: 'static' is not at beginning of declaration [-Wold-style-declaration] const static struct gl_perf_monitor_counter gen5_raw_chaps_counters[] = { ^ brw_performance_monitor.c:185:1: warning: 'static' is not at beginning of declaration [-Wold-style-declaration] const static int gen5_oa_snapshot_layout[] = ^ brw_performance_monitor.c:221:1: warning: 'static' is not at beginning of declaration [-Wold-style-declaration] const static struct gl_perf_monitor_group gen5_groups[] = { ^ brw_performance_monitor.c:240:1: warning: 'static' is not at beginning of declaration [-Wold-style-declaration] const static struct gl_perf_monitor_counter gen6_raw_oa_counters[] = { ^ brw_performance_monitor.c:281:1: warning: 'static' is not at beginning of declaration [-Wold-style-declaration] const static int gen6_oa_snapshot_layout[] = ^ brw_performance_monitor.c:317:1: warning: 'static' is not at beginning of declaration [-Wold-style-declaration] const static struct gl_perf_monitor_counter gen6_statistics_counters[] = { ^ brw_performance_monitor.c:332:1: warning: 'static' is not at beginning of declaration [-Wold-style-declaration] const static int gen6_statistics_register_addresses[] = { ^ brw_performance_monitor.c:346:1: warning: 'static' is not at beginning of declaration [-Wold-style-declaration] const static struct gl_perf_monitor_group gen6_groups[] = { ^ brw_performance_monitor.c:356:1: warning: 'static' is not at beginning of declaration [-Wold-style-declaration] const static struct gl_perf_monitor_counter gen7_raw_oa_counters[] = { ^ brw_performance_monitor.c:402:1: warning: 'static' is not at beginning of declaration [-Wold-style-declaration] const static int gen7_oa_snapshot_layout[] = ^ brw_performance_monitor.c:470:1: warning: 'static' is not at beginning of declaration [-Wold-style-declaration] const static struct gl_perf_monitor_counter gen7_statistics_counters[] = { ^ brw_performance_monitor.c:493:1: warning: 'static' is not at beginning of declaration [-Wold-style-declaration] const static int gen7_statistics_register_addresses[] = { ^ brw_performance_monitor.c:515:1: warning: 'static' is not at beginning of declaration [-Wold-style-declaration] const static struct gl_perf_monitor_group gen7_groups[] = { ^ Signed-off-by: Ian Romanick Reviewed-by: Carl Worth Reviewed-by: Jordan Justen --- .../drivers/dri/i965/brw_performance_monitor.c | 26 ++++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_performance_monitor.c b/src/mesa/drivers/dri/i965/brw_performance_monitor.c index f4d4577..297150f 100644 --- a/src/mesa/drivers/dri/i965/brw_performance_monitor.c +++ b/src/mesa/drivers/dri/i965/brw_performance_monitor.c @@ -150,7 +150,7 @@ enum brw_counter_groups { * documentation, but is available by reading the source code for the * intel_perf_counters utility (shipped as part of intel-gpu-tools). */ -const static struct gl_perf_monitor_counter gen5_raw_chaps_counters[] = { +static const struct gl_perf_monitor_counter gen5_raw_chaps_counters[] = { COUNTER("cycles the CS unit is starved"), COUNTER("cycles the CS unit is stalled"), COUNTER("cycles the VF unit is starved"), @@ -182,7 +182,7 @@ const static struct gl_perf_monitor_counter gen5_raw_chaps_counters[] = { COUNTER("cycles any EU is stalled for math"), }; -const static int gen5_oa_snapshot_layout[] = +static const int gen5_oa_snapshot_layout[] = { -1, /* Report ID */ -1, /* TIMESTAMP (64-bit) */ @@ -218,7 +218,7 @@ const static int gen5_oa_snapshot_layout[] = 28, /* cycles any EU is stalled for math */ }; -const static struct gl_perf_monitor_group gen5_groups[] = { +static const struct gl_perf_monitor_group gen5_groups[] = { [OA_COUNTERS] = GROUP("CHAPS Counters", INT_MAX, gen5_raw_chaps_counters), /* Our pipeline statistics counter handling requires hardware contexts. */ }; @@ -237,7 +237,7 @@ const static struct gl_perf_monitor_group gen5_groups[] = { /** * Aggregating counters A0-A28: */ -const static struct gl_perf_monitor_counter gen6_raw_oa_counters[] = { +static const struct gl_perf_monitor_counter gen6_raw_oa_counters[] = { /* A0: 0 */ COUNTER("Aggregated Core Array Active"), /* A1: 1 */ COUNTER("Aggregated Core Array Stalled"), /* A2: 2 */ COUNTER("Vertex Shader Active Time"), @@ -278,7 +278,7 @@ const static struct gl_perf_monitor_counter gen6_raw_oa_counters[] = { * * (Yes, this is a strange order.) We also have to remap for missing counters. */ -const static int gen6_oa_snapshot_layout[] = +static const int gen6_oa_snapshot_layout[] = { -1, /* Report ID */ -1, /* TIMESTAMP (64-bit) */ @@ -314,7 +314,7 @@ const static int gen6_oa_snapshot_layout[] = 18, /* A21: Pixel Kill Count */ }; -const static struct gl_perf_monitor_counter gen6_statistics_counters[] = { +static const struct gl_perf_monitor_counter gen6_statistics_counters[] = { COUNTER64("IA_VERTICES_COUNT"), COUNTER64("IA_PRIMITIVES_COUNT"), COUNTER64("VS_INVOCATION_COUNT"), @@ -329,7 +329,7 @@ const static struct gl_perf_monitor_counter gen6_statistics_counters[] = { }; /** MMIO register addresses for each pipeline statistics counter. */ -const static int gen6_statistics_register_addresses[] = { +static const int gen6_statistics_register_addresses[] = { IA_VERTICES_COUNT, IA_PRIMITIVES_COUNT, VS_INVOCATION_COUNT, @@ -343,7 +343,7 @@ const static int gen6_statistics_register_addresses[] = { GEN6_SO_PRIM_STORAGE_NEEDED, }; -const static struct gl_perf_monitor_group gen6_groups[] = { +static const struct gl_perf_monitor_group gen6_groups[] = { GROUP("Observability Architecture Counters", INT_MAX, gen6_raw_oa_counters), GROUP("Pipeline Statistics Registers", INT_MAX, gen6_statistics_counters), }; @@ -353,7 +353,7 @@ const static struct gl_perf_monitor_group gen6_groups[] = { * Ivybridge/Baytrail/Haswell: * @{ */ -const static struct gl_perf_monitor_counter gen7_raw_oa_counters[] = { +static const struct gl_perf_monitor_counter gen7_raw_oa_counters[] = { COUNTER("Aggregated Core Array Active"), COUNTER("Aggregated Core Array Stalled"), COUNTER("Vertex Shader Active Time"), @@ -399,7 +399,7 @@ const static struct gl_perf_monitor_counter gen7_raw_oa_counters[] = { * B7 B6 B5 B4 B3 B2 B1 B0 * Rsv Rsv Rsv Rsv Rsv Rsv Rsv Rsv */ -const static int gen7_oa_snapshot_layout[] = +static const int gen7_oa_snapshot_layout[] = { -1, /* Report ID */ -1, /* TIMESTAMP (64-bit) */ @@ -467,7 +467,7 @@ const static int gen7_oa_snapshot_layout[] = -1, /* Reserved */ }; -const static struct gl_perf_monitor_counter gen7_statistics_counters[] = { +static const struct gl_perf_monitor_counter gen7_statistics_counters[] = { COUNTER64("IA_VERTICES_COUNT"), COUNTER64("IA_PRIMITIVES_COUNT"), COUNTER64("VS_INVOCATION_COUNT"), @@ -490,7 +490,7 @@ const static struct gl_perf_monitor_counter gen7_statistics_counters[] = { }; /** MMIO register addresses for each pipeline statistics counter. */ -const static int gen7_statistics_register_addresses[] = { +static const int gen7_statistics_register_addresses[] = { IA_VERTICES_COUNT, IA_PRIMITIVES_COUNT, VS_INVOCATION_COUNT, @@ -512,7 +512,7 @@ const static int gen7_statistics_register_addresses[] = { GEN7_SO_PRIM_STORAGE_NEEDED(3), }; -const static struct gl_perf_monitor_group gen7_groups[] = { +static const struct gl_perf_monitor_group gen7_groups[] = { GROUP("Observability Architecture Counters", INT_MAX, gen7_raw_oa_counters), GROUP("Pipeline Statistics Registers", INT_MAX, gen7_statistics_counters), }; From idr at kemper.freedesktop.org Mon Mar 9 21:07:41 2015 From: idr at kemper.freedesktop.org (Ian Romanick) Date: Mon, 9 Mar 2015 14:07:41 -0700 (PDT) Subject: Mesa (master): i965: Don' t write past the end of the application supplied buffer Message-ID: <20150309210741.F290676338@kemper.freedesktop.org> Module: Mesa Branch: master Commit: e7d94be1ec9c87063a21731a982ae4677cd43bdf URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=e7d94be1ec9c87063a21731a982ae4677cd43bdf Author: Ian Romanick Date: Fri Feb 27 18:43:00 2015 -0800 i965: Don't write past the end of the application supplied buffer Both the AMD and Intel APIs provide a dataSize parameter, and this function would merrily ignore it. Neither API specifies what to do when the buffer isn't big enough. I take the easy route of writing all the complete bits of data that will fit. With more complete specs, we could probably do something different. I noticed this while looking into an unused parameter warning. The warning was actually useful! brw_performance_monitor.c: In function 'brw_get_perf_monitor_result': brw_performance_monitor.c:1261:37: warning: unused parameter 'data_size' [-Wunused-parameter] GLsizei data_size, ^ v2: Fix checks to include offset in the calculation. Noticed by Jan. Signed-off-by: Ian Romanick Reviewed-by: Kenneth Graunke Reviewed-by: Jan Vesely --- src/mesa/drivers/dri/i965/brw_performance_monitor.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_performance_monitor.c b/src/mesa/drivers/dri/i965/brw_performance_monitor.c index 6c31d4c..2c8cd49 100644 --- a/src/mesa/drivers/dri/i965/brw_performance_monitor.c +++ b/src/mesa/drivers/dri/i965/brw_performance_monitor.c @@ -1264,6 +1264,7 @@ brw_get_perf_monitor_result(struct gl_context *ctx, { struct brw_context *brw = brw_context(ctx); struct brw_perf_monitor_object *monitor = brw_perf_monitor(m); + const GLuint *const data_end = (GLuint *)((uint8_t *) data + data_size); DBG("GetResult(%d)\n", m->Name); brw_dump_perf_monitors(brw); @@ -1309,9 +1310,11 @@ brw_get_perf_monitor_result(struct gl_context *ctx, if (counter < 0 || !BITSET_TEST(m->ActiveCounters[group], counter)) continue; - data[offset++] = group; - data[offset++] = counter; - data[offset++] = monitor->oa_results[i]; + if (data + offset + 3 <= data_end) { + data[offset++] = group; + data[offset++] = counter; + data[offset++] = monitor->oa_results[i]; + } } clean_bookend_bo(brw); @@ -1335,10 +1338,12 @@ brw_get_perf_monitor_result(struct gl_context *ctx, for (int i = 0; i < num_counters; i++) { if (BITSET_TEST(m->ActiveCounters[PIPELINE_STATS_COUNTERS], i)) { - data[offset++] = PIPELINE_STATS_COUNTERS; - data[offset++] = i; - *((uint64_t *) (&data[offset])) = monitor->pipeline_stats_results[i]; - offset += 2; + if (data + offset + 4 <= data_end) { + data[offset++] = PIPELINE_STATS_COUNTERS; + data[offset++] = i; + *((uint64_t *) (&data[offset])) = monitor->pipeline_stats_results[i]; + offset += 2; + } } } } From idr at kemper.freedesktop.org Mon Mar 9 21:07:41 2015 From: idr at kemper.freedesktop.org (Ian Romanick) Date: Mon, 9 Mar 2015 14:07:41 -0700 (PDT) Subject: Mesa (master): i965/fs: Silence unused parameter warning Message-ID: <20150309210741.CC4A676338@kemper.freedesktop.org> Module: Mesa Branch: master Commit: c82c8b220192bcdc6e39afd42576965b523a9ed5 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=c82c8b220192bcdc6e39afd42576965b523a9ed5 Author: Ian Romanick Date: Fri Feb 27 18:19:33 2015 -0800 i965/fs: Silence unused parameter warning I don't this opt_cmod_propagation_local ever used the fs_visitor. brw_fs_cmod_propagation.cpp:52:40: warning: unused parameter 'v' [-Wunused-parameter] opt_cmod_propagation_local(fs_visitor *v, bblock_t *block) ^ Signed-off-by: Ian Romanick Reviewed-by: Matt Turner Reviewed-by: Jordan Justen --- src/mesa/drivers/dri/i965/brw_fs_cmod_propagation.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_fs_cmod_propagation.cpp b/src/mesa/drivers/dri/i965/brw_fs_cmod_propagation.cpp index 58890ee..d0ca2f9 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_cmod_propagation.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_cmod_propagation.cpp @@ -49,7 +49,7 @@ */ static bool -opt_cmod_propagation_local(fs_visitor *v, bblock_t *block) +opt_cmod_propagation_local(bblock_t *block) { bool progress = false; int ip = block->end_ip + 1; @@ -128,7 +128,7 @@ fs_visitor::opt_cmod_propagation() bool progress = false; foreach_block_reverse(block, cfg) { - progress = opt_cmod_propagation_local(this, block) || progress; + progress = opt_cmod_propagation_local(block) || progress; } if (progress) From idr at kemper.freedesktop.org Mon Mar 9 21:07:41 2015 From: idr at kemper.freedesktop.org (Ian Romanick) Date: Mon, 9 Mar 2015 14:07:41 -0700 (PDT) Subject: Mesa (master): i965: Silence unused parameter warning Message-ID: <20150309210741.E6AFA76338@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 78a211cee5f3f5fc101e3e68b5b1c8258837a6c3 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=78a211cee5f3f5fc101e3e68b5b1c8258837a6c3 Author: Ian Romanick Date: Fri Feb 27 18:42:03 2015 -0800 i965: Silence unused parameter warning All dd functions take a gl_context as the first parameter. Instead of removing it, just silence the warning. brw_performance_monitor.c: In function 'brw_new_perf_monitor': brw_performance_monitor.c:1354:41: warning: unused parameter 'ctx' [-Wunused-parameter] brw_new_perf_monitor(struct gl_context *ctx) ^ Signed-off-by: Ian Romanick Reviewed-by: Carl Worth Reviewed-by: Jordan Justen --- src/mesa/drivers/dri/i965/brw_performance_monitor.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/mesa/drivers/dri/i965/brw_performance_monitor.c b/src/mesa/drivers/dri/i965/brw_performance_monitor.c index 297150f..6c31d4c 100644 --- a/src/mesa/drivers/dri/i965/brw_performance_monitor.c +++ b/src/mesa/drivers/dri/i965/brw_performance_monitor.c @@ -1353,6 +1353,7 @@ brw_get_perf_monitor_result(struct gl_context *ctx, static struct gl_perf_monitor_object * brw_new_perf_monitor(struct gl_context *ctx) { + (void) ctx; return calloc(1, sizeof(struct brw_perf_monitor_object)); } From idr at kemper.freedesktop.org Mon Mar 9 21:09:33 2015 From: idr at kemper.freedesktop.org (Ian Romanick) Date: Mon, 9 Mar 2015 14:09:33 -0700 (PDT) Subject: Mesa (master): i915: Remove unused IS_MOBILE macro Message-ID: <20150309210933.A018376338@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 6d41316b79cf6d67bcbd155dfb6556e2977080d5 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=6d41316b79cf6d67bcbd155dfb6556e2977080d5 Author: Ian Romanick Date: Thu Mar 5 10:24:57 2015 -0800 i915: Remove unused IS_MOBILE macro Inspired by Damien's recent libdrm changes. Signed-off-by: Ian Romanick Reviewed-by: Damien Lespiau Reviewed-by: Jordan Justen --- src/mesa/drivers/dri/i915/intel_chipset.h | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/mesa/drivers/dri/i915/intel_chipset.h b/src/mesa/drivers/dri/i915/intel_chipset.h index 3828085..d05fd08 100644 --- a/src/mesa/drivers/dri/i915/intel_chipset.h +++ b/src/mesa/drivers/dri/i915/intel_chipset.h @@ -53,16 +53,6 @@ #define IS_PNVG(devid) (devid == PCI_CHIP_PNV_G) #define IS_PNV(devid) (IS_PNVG(devid) || IS_PNVGM(devid)) -#define IS_MOBILE(devid) (devid == PCI_CHIP_I855_GM || \ - devid == PCI_CHIP_I915_GM || \ - devid == PCI_CHIP_I945_GM || \ - devid == PCI_CHIP_I945_GME || \ - devid == PCI_CHIP_I965_GM || \ - devid == PCI_CHIP_I965_GME || \ - devid == PCI_CHIP_GM45_GM || \ - IS_PNV(devid) || \ - devid == PCI_CHIP_ILM_G) - #define IS_915(devid) (devid == PCI_CHIP_I915_G || \ devid == PCI_CHIP_E7221_G || \ devid == PCI_CHIP_I915_GM) From idr at kemper.freedesktop.org Mon Mar 9 21:09:33 2015 From: idr at kemper.freedesktop.org (Ian Romanick) Date: Mon, 9 Mar 2015 14:09:33 -0700 (PDT) Subject: Mesa (master): i915: Remove (mostly) unused IS_915 macro Message-ID: <20150309210933.B65C276359@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 07a062997a3e1c12ad0e07a7d3f07340689612b8 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=07a062997a3e1c12ad0e07a7d3f07340689612b8 Author: Ian Romanick Date: Thu Mar 5 10:55:32 2015 -0800 i915: Remove (mostly) unused IS_915 macro Inspired by Damien's recent libdrm changes. Signed-off-by: Ian Romanick Reviewed-by: Damien Lespiau Reviewed-by: Jordan Justen --- src/mesa/drivers/dri/i915/intel_chipset.h | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/mesa/drivers/dri/i915/intel_chipset.h b/src/mesa/drivers/dri/i915/intel_chipset.h index cbcdb14..d33a80f 100644 --- a/src/mesa/drivers/dri/i915/intel_chipset.h +++ b/src/mesa/drivers/dri/i915/intel_chipset.h @@ -49,10 +49,6 @@ #define PCI_CHIP_PNV_GM 0xA011 #define PCI_CHIP_PNV_G 0xA001 -#define IS_915(devid) (devid == PCI_CHIP_I915_G || \ - devid == PCI_CHIP_E7221_G || \ - devid == PCI_CHIP_I915_GM) - #define IS_945(devid) (devid == PCI_CHIP_I945_G || \ devid == PCI_CHIP_I945_GM || \ devid == PCI_CHIP_I945_GME || \ @@ -62,7 +58,9 @@ devid == PCI_CHIP_PNV_G || \ devid == PCI_CHIP_PNV_GM) -#define IS_GEN3(devid) (IS_915(devid) || \ +#define IS_GEN3(devid) (devid == PCI_CHIP_I915_G || \ + devid == PCI_CHIP_E7221_G || \ + devid == PCI_CHIP_I915_GM || \ IS_945(devid)) #define IS_GEN2(devid) (devid == PCI_CHIP_I830_M || \ From idr at kemper.freedesktop.org Mon Mar 9 21:09:33 2015 From: idr at kemper.freedesktop.org (Ian Romanick) Date: Mon, 9 Mar 2015 14:09:33 -0700 (PDT) Subject: Mesa (master): i915: Remove unused IS_GEN2 macro Message-ID: <20150309210933.C0D7F76338@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 85df48b45a3bdc8c25b37b243a9f2a2398fc9e24 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=85df48b45a3bdc8c25b37b243a9f2a2398fc9e24 Author: Ian Romanick Date: Thu Mar 5 11:26:53 2015 -0800 i915: Remove unused IS_GEN2 macro Inspired by Damien's recent libdrm changes. Signed-off-by: Ian Romanick Reviewed-by: Damien Lespiau Reviewed-by: Jordan Justen --- src/mesa/drivers/dri/i915/intel_chipset.h | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/mesa/drivers/dri/i915/intel_chipset.h b/src/mesa/drivers/dri/i915/intel_chipset.h index d33a80f..7523ab7 100644 --- a/src/mesa/drivers/dri/i915/intel_chipset.h +++ b/src/mesa/drivers/dri/i915/intel_chipset.h @@ -62,8 +62,3 @@ devid == PCI_CHIP_E7221_G || \ devid == PCI_CHIP_I915_GM || \ IS_945(devid)) - -#define IS_GEN2(devid) (devid == PCI_CHIP_I830_M || \ - devid == PCI_CHIP_845_G || \ - devid == PCI_CHIP_I855_GM || \ - devid == PCI_CHIP_I865_G) From idr at kemper.freedesktop.org Mon Mar 9 21:09:33 2015 From: idr at kemper.freedesktop.org (Ian Romanick) Date: Mon, 9 Mar 2015 14:09:33 -0700 (PDT) Subject: Mesa (master): i915: Remove (mostly) unused IS_PNV, IS_PNVG, and IS_PNVGM macros Message-ID: <20150309210933.AD8C47633E@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 117288dbf305064cd57333bb05442fad0539d0fa URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=117288dbf305064cd57333bb05442fad0539d0fa Author: Ian Romanick Date: Thu Mar 5 10:47:56 2015 -0800 i915: Remove (mostly) unused IS_PNV, IS_PNVG, and IS_PNVGM macros Inspired by Damien's recent libdrm changes. Signed-off-by: Ian Romanick Reviewed-by: Damien Lespiau Reviewed-by: Jordan Justen --- src/mesa/drivers/dri/i915/intel_chipset.h | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/mesa/drivers/dri/i915/intel_chipset.h b/src/mesa/drivers/dri/i915/intel_chipset.h index f7c8b5d..cbcdb14 100644 --- a/src/mesa/drivers/dri/i915/intel_chipset.h +++ b/src/mesa/drivers/dri/i915/intel_chipset.h @@ -49,10 +49,6 @@ #define PCI_CHIP_PNV_GM 0xA011 #define PCI_CHIP_PNV_G 0xA001 -#define IS_PNVGM(devid) (devid == PCI_CHIP_PNV_GM) -#define IS_PNVG(devid) (devid == PCI_CHIP_PNV_G) -#define IS_PNV(devid) (IS_PNVG(devid) || IS_PNVGM(devid)) - #define IS_915(devid) (devid == PCI_CHIP_I915_G || \ devid == PCI_CHIP_E7221_G || \ devid == PCI_CHIP_I915_GM) @@ -62,7 +58,9 @@ devid == PCI_CHIP_I945_GME || \ devid == PCI_CHIP_G33_G || \ devid == PCI_CHIP_Q33_G || \ - devid == PCI_CHIP_Q35_G || IS_PNV(devid)) + devid == PCI_CHIP_Q35_G || \ + devid == PCI_CHIP_PNV_G || \ + devid == PCI_CHIP_PNV_GM) #define IS_GEN3(devid) (IS_915(devid) || \ IS_945(devid)) From idr at kemper.freedesktop.org Mon Mar 9 21:09:33 2015 From: idr at kemper.freedesktop.org (Ian Romanick) Date: Mon, 9 Mar 2015 14:09:33 -0700 (PDT) Subject: Mesa (master): i915: Remove IS_9XX macro Message-ID: <20150309210933.A6A167633D@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 19fda9fc8336795b9898d3773b05549238b72bd0 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=19fda9fc8336795b9898d3773b05549238b72bd0 Author: Ian Romanick Date: Thu Mar 5 10:27:04 2015 -0800 i915: Remove IS_9XX macro Since the i915 / i965 split, IS_9XX just means IS_GEN3. Inspired by Damien's recent libdrm changes. Signed-off-by: Ian Romanick Reviewed-by: Damien Lespiau Reviewed-by: Jordan Justen --- src/mesa/drivers/dri/i915/intel_chipset.h | 3 --- src/mesa/drivers/dri/i915/intel_screen.c | 4 ++-- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/mesa/drivers/dri/i915/intel_chipset.h b/src/mesa/drivers/dri/i915/intel_chipset.h index d05fd08..f7c8b5d 100644 --- a/src/mesa/drivers/dri/i915/intel_chipset.h +++ b/src/mesa/drivers/dri/i915/intel_chipset.h @@ -64,9 +64,6 @@ devid == PCI_CHIP_Q33_G || \ devid == PCI_CHIP_Q35_G || IS_PNV(devid)) -#define IS_9XX(devid) (IS_915(devid) || \ - IS_945(devid)) - #define IS_GEN3(devid) (IS_915(devid) || \ IS_945(devid)) diff --git a/src/mesa/drivers/dri/i915/intel_screen.c b/src/mesa/drivers/dri/i915/intel_screen.c index 00d8580..77af328 100644 --- a/src/mesa/drivers/dri/i915/intel_screen.c +++ b/src/mesa/drivers/dri/i915/intel_screen.c @@ -969,7 +969,7 @@ intelCreateContext(gl_api api, return false; } - if (IS_9XX(intelScreen->deviceID)) { + if (IS_GEN3(intelScreen->deviceID)) { success = i915CreateContext(api, mesaVis, driContextPriv, major_version, minor_version, flags, error, sharedContextPrivate); @@ -1177,7 +1177,7 @@ __DRIconfig **intelInitScreen2(__DRIscreen *psp) intelScreen->deviceID = drm_intel_bufmgr_gem_get_devid(intelScreen->bufmgr); - if (IS_9XX(intelScreen->deviceID)) { + if (IS_GEN3(intelScreen->deviceID)) { intelScreen->gen = 3; } else { intelScreen->gen = 2; From mareko at kemper.freedesktop.org Mon Mar 9 22:03:32 2015 From: mareko at kemper.freedesktop.org (Marek Olšák) Date: Mon, 9 Mar 2015 15:03:32 -0700 (PDT) Subject: Mesa (master): r600g: Use R600_MAX_VIEWPORTS instead of 16 Message-ID: <20150309220332.032B876338@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 7a37d5c3a48c4adec5b5db589b0cb99dc9296f0c URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=7a37d5c3a48c4adec5b5db589b0cb99dc9296f0c Author: Alexandre Demers Date: Wed Feb 25 01:50:49 2015 -0500 r600g: Use R600_MAX_VIEWPORTS instead of 16 Lets define R600_MAX_VIEWPORTS instead of using 16 here and there in the code when looping through viewports and scissors. It is easier to understand what this number represents. v2: Missed a case where R600_MAX_VIEWPORTS should have been used. Signed-off-by: Alexandre Demers Signed-off-by: Marek Ol??k --- src/gallium/drivers/r600/evergreen_state.c | 10 +++++----- src/gallium/drivers/r600/r600_hw_context.c | 2 +- src/gallium/drivers/r600/r600_pipe.c | 2 +- src/gallium/drivers/r600/r600_pipe.h | 6 ++++-- src/gallium/drivers/r600/r600_state.c | 6 +++--- 5 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/gallium/drivers/r600/evergreen_state.c b/src/gallium/drivers/r600/evergreen_state.c index 8aa8082..f0b04f0 100644 --- a/src/gallium/drivers/r600/evergreen_state.c +++ b/src/gallium/drivers/r600/evergreen_state.c @@ -2293,8 +2293,8 @@ static void cayman_init_atom_start_cs(struct r600_context *rctx) r600_store_context_reg(cb, R_028200_PA_SC_WINDOW_OFFSET, 0); r600_store_context_reg(cb, R_02820C_PA_SC_CLIPRECT_RULE, 0xFFFF); - r600_store_context_reg_seq(cb, R_0282D0_PA_SC_VPORT_ZMIN_0, 2 * 16); - for (tmp = 0; tmp < 16; tmp++) { + r600_store_context_reg_seq(cb, R_0282D0_PA_SC_VPORT_ZMIN_0, 2 * R600_MAX_VIEWPORTS); + for (tmp = 0; tmp < R600_MAX_VIEWPORTS; tmp++) { r600_store_value(cb, 0); /* R_0282D0_PA_SC_VPORT_ZMIN_0 */ r600_store_value(cb, fui(1.0)); /* R_0282D4_PA_SC_VPORT_ZMAX_0 */ } @@ -2727,8 +2727,8 @@ void evergreen_init_atom_start_cs(struct r600_context *rctx) r600_store_context_reg(cb, R_02820C_PA_SC_CLIPRECT_RULE, 0xFFFF); r600_store_context_reg(cb, R_028230_PA_SC_EDGERULE, 0xAAAAAAAA); - r600_store_context_reg_seq(cb, R_0282D0_PA_SC_VPORT_ZMIN_0, 2 * 16); - for (tmp = 0; tmp < 16; tmp++) { + r600_store_context_reg_seq(cb, R_0282D0_PA_SC_VPORT_ZMIN_0, 2 * R600_MAX_VIEWPORTS); + for (tmp = 0; tmp < R600_MAX_VIEWPORTS; tmp++) { r600_store_value(cb, 0); /* R_0282D0_PA_SC_VPORT_ZMIN_0 */ r600_store_value(cb, fui(1.0)); /* R_0282D4_PA_SC_VPORT_ZMAX_0 */ } @@ -3458,7 +3458,7 @@ void evergreen_init_state_functions(struct r600_context *rctx) r600_init_atom(rctx, &rctx->dsa_state.atom, id++, r600_emit_cso_state, 0); r600_init_atom(rctx, &rctx->poly_offset_state.atom, id++, evergreen_emit_polygon_offset, 6); r600_init_atom(rctx, &rctx->rasterizer_state.atom, id++, r600_emit_cso_state, 0); - for (i = 0; i < 16; i++) { + for (i = 0; i < R600_MAX_VIEWPORTS; i++) { r600_init_atom(rctx, &rctx->viewport[i].atom, id++, r600_emit_viewport_state, 8); r600_init_atom(rctx, &rctx->scissor[i].atom, id++, evergreen_emit_scissor_state, 4); rctx->viewport[i].idx = i; diff --git a/src/gallium/drivers/r600/r600_hw_context.c b/src/gallium/drivers/r600/r600_hw_context.c index cd57eed..7961a96 100644 --- a/src/gallium/drivers/r600/r600_hw_context.c +++ b/src/gallium/drivers/r600/r600_hw_context.c @@ -307,7 +307,7 @@ void r600_begin_new_cs(struct r600_context *ctx) ctx->poly_offset_state.atom.dirty = true; ctx->vgt_state.atom.dirty = true; ctx->sample_mask.atom.dirty = true; - for (i = 0; i < 16; i++) { + for (i = 0; i < R600_MAX_VIEWPORTS; i++) { ctx->scissor[i].atom.dirty = true; ctx->viewport[i].atom.dirty = true; } diff --git a/src/gallium/drivers/r600/r600_pipe.c b/src/gallium/drivers/r600/r600_pipe.c index c8a0e9c..24d901e 100644 --- a/src/gallium/drivers/r600/r600_pipe.c +++ b/src/gallium/drivers/r600/r600_pipe.c @@ -374,7 +374,7 @@ static int r600_get_param(struct pipe_screen* pscreen, enum pipe_cap param) return 8; case PIPE_CAP_MAX_VIEWPORTS: - return 16; + return R600_MAX_VIEWPORTS; /* Timer queries, present when the clock frequency is non zero. */ case PIPE_CAP_QUERY_TIME_ELAPSED: diff --git a/src/gallium/drivers/r600/r600_pipe.h b/src/gallium/drivers/r600/r600_pipe.h index 7237854..ac69895 100644 --- a/src/gallium/drivers/r600/r600_pipe.h +++ b/src/gallium/drivers/r600/r600_pipe.h @@ -38,6 +38,8 @@ #define R600_NUM_ATOMS 73 +#define R600_MAX_VIEWPORTS 16 + /* read caches */ #define R600_CONTEXT_INV_VERTEX_CACHE (R600_CONTEXT_PRIVATE_FLAG << 0) #define R600_CONTEXT_INV_TEX_CACHE (R600_CONTEXT_PRIVATE_FLAG << 1) @@ -443,12 +445,12 @@ struct r600_context { struct r600_poly_offset_state poly_offset_state; struct r600_cso_state rasterizer_state; struct r600_sample_mask sample_mask; - struct r600_scissor_state scissor[16]; + struct r600_scissor_state scissor[R600_MAX_VIEWPORTS]; struct r600_seamless_cube_map seamless_cube_map; struct r600_config_state config_state; struct r600_stencil_ref_state stencil_ref; struct r600_vgt_state vgt_state; - struct r600_viewport_state viewport[16]; + struct r600_viewport_state viewport[R600_MAX_VIEWPORTS]; /* Shaders and shader resources. */ struct r600_cso_state vertex_fetch_shader; struct r600_shader_state vertex_shader; diff --git a/src/gallium/drivers/r600/r600_state.c b/src/gallium/drivers/r600/r600_state.c index 26d7300..3051445 100644 --- a/src/gallium/drivers/r600/r600_state.c +++ b/src/gallium/drivers/r600/r600_state.c @@ -2387,8 +2387,8 @@ void r600_init_atom_start_cs(struct r600_context *rctx) r600_store_value(cb, fui(1.0)); /* R_028C14_PA_CL_GB_HORZ_CLIP_ADJ */ r600_store_value(cb, fui(1.0)); /* R_028C18_PA_CL_GB_HORZ_DISC_ADJ */ - r600_store_context_reg_seq(cb, R_0282D0_PA_SC_VPORT_ZMIN_0, 2 * 16); - for (tmp = 0; tmp < 16; tmp++) { + r600_store_context_reg_seq(cb, R_0282D0_PA_SC_VPORT_ZMIN_0, 2 * R600_MAX_VIEWPORTS); + for (tmp = 0; tmp < R600_MAX_VIEWPORTS; tmp++) { r600_store_value(cb, 0); /* R_0282D0_PA_SC_VPORT_ZMIN_0 */ r600_store_value(cb, fui(1.0)); /* R_0282D4_PA_SC_VPORT_ZMAX_0 */ } @@ -3065,7 +3065,7 @@ void r600_init_state_functions(struct r600_context *rctx) r600_init_atom(rctx, &rctx->dsa_state.atom, id++, r600_emit_cso_state, 0); r600_init_atom(rctx, &rctx->poly_offset_state.atom, id++, r600_emit_polygon_offset, 6); r600_init_atom(rctx, &rctx->rasterizer_state.atom, id++, r600_emit_cso_state, 0); - for (i = 0;i < 16; i++) { + for (i = 0;i < R600_MAX_VIEWPORTS; i++) { r600_init_atom(rctx, &rctx->scissor[i].atom, id++, r600_emit_scissor_state, 4); r600_init_atom(rctx, &rctx->viewport[i].atom, id++, r600_emit_viewport_state, 8); rctx->scissor[i].idx = i; From kwg at kemper.freedesktop.org Mon Mar 9 23:10:05 2015 From: kwg at kemper.freedesktop.org (Kenneth Graunke) Date: Mon, 9 Mar 2015 16:10:05 -0700 (PDT) Subject: Mesa (master): i965/fs: Set force_writemask_all on shader_time instructions. Message-ID: <20150309231005.73FF376338@kemper.freedesktop.org> Module: Mesa Branch: master Commit: ef9cc7d0c176669c03130abf576f2b700be39514 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=ef9cc7d0c176669c03130abf576f2b700be39514 Author: Kenneth Graunke Date: Sat Mar 7 23:01:07 2015 -0800 i965/fs: Set force_writemask_all on shader_time instructions. These computations don't have anything to do with the currently executing channels, so they should use force_writemask_all. This fixes assert failures. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=86974 Signed-off-by: Kenneth Graunke Reviewed-by: Matt Turner Cc: mesa-stable at lists.freedesktop.org --- src/mesa/drivers/dri/i965/brw_fs.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp index 23876c7..951cd97 100644 --- a/src/mesa/drivers/dri/i965/brw_fs.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs.cpp @@ -759,18 +759,23 @@ fs_visitor::emit_shader_time_end() reset.set_smear(2); fs_inst *test = emit(AND(reg_null_d, reset, fs_reg(1u))); test->conditional_mod = BRW_CONDITIONAL_Z; + test->force_writemask_all = true; emit(IF(BRW_PREDICATE_NORMAL)); fs_reg start = shader_start_time; start.negate = true; fs_reg diff = fs_reg(GRF, alloc.allocate(1), BRW_REGISTER_TYPE_UD, 1); - emit(ADD(diff, start, shader_end_time)); + fs_inst *add = ADD(diff, start, shader_end_time); + add->force_writemask_all = true; + emit(add); /* If there were no instructions between the two timestamp gets, the diff * is 2 cycles. Remove that overhead, so I can forget about that when * trying to determine the time taken for single instructions. */ - emit(ADD(diff, diff, fs_reg(-2u))); + add = ADD(diff, diff, fs_reg(-2u)); + add->force_writemask_all = true; + emit(add); emit_shader_time_write(type, diff); emit_shader_time_write(written_type, fs_reg(1u)); From kwg at kemper.freedesktop.org Mon Mar 9 23:10:05 2015 From: kwg at kemper.freedesktop.org (Kenneth Graunke) Date: Mon, 9 Mar 2015 16:10:05 -0700 (PDT) Subject: Mesa (master): i965/fs: Set smear on shader_time diff register. Message-ID: <20150309231005.7EEE77633D@kemper.freedesktop.org> Module: Mesa Branch: master Commit: f1adc45dbe649cdd4538fb96f6d2a27328bbfba1 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=f1adc45dbe649cdd4538fb96f6d2a27328bbfba1 Author: Kenneth Graunke Date: Sun Mar 8 00:13:41 2015 -0800 i965/fs: Set smear on shader_time diff register. The ADD(diff, diff, fs_reg(-2u)) instruction reads diff, which is a width 1 register. We need to read it as <0,1,0> with a subreg of 0, which is what smear accomplishes. Fixes assertion: brw_eu_emit.c:285: validate_reg: Assertion `hstride == 0' failed. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=86974 Signed-off-by: Kenneth Graunke Reviewed-by: Matt Turner Cc: mesa-stable at lists.freedesktop.org --- src/mesa/drivers/dri/i965/brw_fs.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp index 951cd97..71087f2 100644 --- a/src/mesa/drivers/dri/i965/brw_fs.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs.cpp @@ -765,6 +765,7 @@ fs_visitor::emit_shader_time_end() fs_reg start = shader_start_time; start.negate = true; fs_reg diff = fs_reg(GRF, alloc.allocate(1), BRW_REGISTER_TYPE_UD, 1); + diff.set_smear(0); fs_inst *add = ADD(diff, start, shader_end_time); add->force_writemask_all = true; emit(add); From kwg at kemper.freedesktop.org Mon Mar 9 23:10:05 2015 From: kwg at kemper.freedesktop.org (Kenneth Graunke) Date: Mon, 9 Mar 2015 16:10:05 -0700 (PDT) Subject: Mesa (master): i965/fs: Make emit_shader_time_end() insert before EOT. Message-ID: <20150309231005.B858276338@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 4ebeb71573ad44f7657810dc5dd2c9030e3e63db URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=4ebeb71573ad44f7657810dc5dd2c9030e3e63db Author: Kenneth Graunke Date: Thu Feb 26 22:55:54 2015 -0800 i965/fs: Make emit_shader_time_end() insert before EOT. Previously, we emitted the shader-time epilogue from emit_fb_writes(), during the middle of looping through color regions (or emit_urb_writes for the VS). This is duplicated several times and rather awkward. I need to fix a bug in our FB write handling, and it will be a lot easier if we move emit_shader_time_end() out of there. Now, we simply emit FB writes/URB writes, and subsequently have emit_shader_time_end() insert instructions before the final SEND with EOT. Not only is this simpler, it's actually a slight improvement: we now include the MOVs to set up the final FB write payload in our shader-time measurements. Note that INTEL_DEBUG=shader_time only exists on Gen7+, and uses send-from-GRF. (In the past, we might have hit trouble where both attempt to use MRFs for messages; that's not a problem now.) v2: Rebase on v3 of the previous patch and other shader_time fixes. Signed-off-by: Kenneth Graunke Reviewed-by: Topi Pohjolainen [v1] Acked-by: Matt Turner Cc: mesa-stable at lists.freedesktop.org --- src/mesa/drivers/dri/i965/brw_fs.cpp | 28 +++++++++++++++++--------- src/mesa/drivers/dri/i965/brw_fs_visitor.cpp | 13 ------------ 2 files changed, 18 insertions(+), 23 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp index ee14a7a..89754ad 100644 --- a/src/mesa/drivers/dri/i965/brw_fs.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs.cpp @@ -759,19 +759,24 @@ fs_visitor::emit_shader_time_end() unreachable("fs_visitor::emit_shader_time_end missing code"); } + /* Insert our code just before the final SEND with EOT. */ + exec_node *end = this->instructions.get_tail(); + assert(end && ((fs_inst *) end)->eot); + fs_inst *tm_read; fs_reg shader_end_time = get_timestamp(&tm_read); - emit(tm_read); + end->insert_before(tm_read); /* Check that there weren't any timestamp reset events (assuming these * were the only two timestamp reads that happened). */ fs_reg reset = shader_end_time; reset.set_smear(2); - fs_inst *test = emit(AND(reg_null_d, reset, fs_reg(1u))); + fs_inst *test = AND(reg_null_d, reset, fs_reg(1u)); test->conditional_mod = BRW_CONDITIONAL_Z; test->force_writemask_all = true; - emit(IF(BRW_PREDICATE_NORMAL)); + end->insert_before(test); + end->insert_before(IF(BRW_PREDICATE_NORMAL)); fs_reg start = shader_start_time; start.negate = true; @@ -779,7 +784,7 @@ fs_visitor::emit_shader_time_end() diff.set_smear(0); fs_inst *add = ADD(diff, start, shader_end_time); add->force_writemask_all = true; - emit(add); + end->insert_before(add); /* If there were no instructions between the two timestamp gets, the diff * is 2 cycles. Remove that overhead, so I can forget about that when @@ -787,13 +792,13 @@ fs_visitor::emit_shader_time_end() */ add = ADD(diff, diff, fs_reg(-2u)); add->force_writemask_all = true; - emit(add); + end->insert_before(add); - emit(SHADER_TIME_ADD(type, diff)); - emit(SHADER_TIME_ADD(written_type, fs_reg(1u))); - emit(BRW_OPCODE_ELSE); - emit(SHADER_TIME_ADD(reset_type, fs_reg(1u))); - emit(BRW_OPCODE_ENDIF); + end->insert_before(SHADER_TIME_ADD(type, diff)); + end->insert_before(SHADER_TIME_ADD(written_type, fs_reg(1u))); + end->insert_before(new(mem_ctx) fs_inst(BRW_OPCODE_ELSE, dispatch_width)); + end->insert_before(SHADER_TIME_ADD(reset_type, fs_reg(1u))); + end->insert_before(new(mem_ctx) fs_inst(BRW_OPCODE_ENDIF, dispatch_width)); } fs_inst * @@ -3922,6 +3927,9 @@ fs_visitor::run_fs() emit_fb_writes(); + if (INTEL_DEBUG & DEBUG_SHADER_TIME) + emit_shader_time_end(); + calculate_cfg(); optimize(); diff --git a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp index cdaba7f..5222387 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp @@ -3670,9 +3670,6 @@ fs_visitor::emit_fb_writes() fs_inst *inst; if (do_dual_src) { - if (INTEL_DEBUG & DEBUG_SHADER_TIME) - emit_shader_time_end(); - this->current_annotation = ralloc_asprintf(this->mem_ctx, "FB dual-source write"); inst = emit_single_fb_write(this->outputs[0], this->dual_src_output, @@ -3712,19 +3709,12 @@ fs_visitor::emit_fb_writes() if (brw->gen >= 6 && key->replicate_alpha && target != 0) src0_alpha = offset(outputs[0], 3); - if (target == key->nr_color_regions - 1 && - (INTEL_DEBUG & DEBUG_SHADER_TIME)) - emit_shader_time_end(); - inst = emit_single_fb_write(this->outputs[target], reg_undef, src0_alpha, this->output_components[target]); inst->target = target; } } else { - if (INTEL_DEBUG & DEBUG_SHADER_TIME) - emit_shader_time_end(); - /* Even if there's no color buffers enabled, we still need to send * alpha out the pipeline to our null renderbuffer to support * alpha-testing, alpha-to-coverage, and so on. @@ -3935,9 +3925,6 @@ fs_visitor::emit_urb_writes() if (length == 8 || last) flush = true; if (flush) { - if (last && (INTEL_DEBUG & DEBUG_SHADER_TIME)) - emit_shader_time_end(); - fs_reg *payload_sources = ralloc_array(mem_ctx, fs_reg, length + 1); fs_reg payload = fs_reg(GRF, alloc.allocate(length + 1), BRW_REGISTER_TYPE_F); From kwg at kemper.freedesktop.org Mon Mar 9 23:10:05 2015 From: kwg at kemper.freedesktop.org (Kenneth Graunke) Date: Mon, 9 Mar 2015 16:10:05 -0700 (PDT) Subject: Mesa (master): i965/fs: Don' t issue FB writes for bound but unwritten color targets. Message-ID: <20150309231005.C847376338@kemper.freedesktop.org> Module: Mesa Branch: master Commit: e95969cd9548033250ba12f2adf11740319b41e7 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=e95969cd9548033250ba12f2adf11740319b41e7 Author: Kenneth Graunke Date: Thu Feb 26 17:45:49 2015 -0800 i965/fs: Don't issue FB writes for bound but unwritten color targets. We used to loop over all color attachments, and emit FB writes for each one, even if the shader didn't write to a corresponding output variable. Those color attachments would be filled with garbage (undefined values). Football Manager binds a framebuffer with 4 color attachments, but draws to it using a shader that only writes to gl_FragData[0..2]. This meant that color attachment 3 would be filled with garbage, resulting in rendering artifacts. Now we skip writing to it, fixing rendering. Writes to gl_FragColor initialize outputs[0..nr_color_regions-1] to GRFs, while writes to gl_FragData[i] initialize outputs[i]. Thanks to Jason Ekstrand for tracking this down. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=86747 Signed-off-by: Kenneth Graunke Reviewed-by: Jason Ekstrand Cc: mesa-stable at lists.freedesktop.org --- src/mesa/drivers/dri/i965/brw_fs_visitor.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp index 5222387..7859fef 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp @@ -3668,7 +3668,7 @@ fs_visitor::emit_fb_writes() brw_wm_prog_data *prog_data = (brw_wm_prog_data*) this->prog_data; brw_wm_prog_key *key = (brw_wm_prog_key*) this->key; - fs_inst *inst; + fs_inst *inst = NULL; if (do_dual_src) { this->current_annotation = ralloc_asprintf(this->mem_ctx, "FB dual-source write"); @@ -3700,8 +3700,12 @@ fs_visitor::emit_fb_writes() } prog_data->dual_src_blend = true; - } else if (key->nr_color_regions > 0) { + } else { for (int target = 0; target < key->nr_color_regions; target++) { + /* Skip over outputs that weren't written. */ + if (this->outputs[target].file == BAD_FILE) + continue; + this->current_annotation = ralloc_asprintf(this->mem_ctx, "FB write target %d", target); @@ -3714,7 +3718,9 @@ fs_visitor::emit_fb_writes() this->output_components[target]); inst->target = target; } - } else { + } + + if (inst == NULL) { /* Even if there's no color buffers enabled, we still need to send * alpha out the pipeline to our null renderbuffer to support * alpha-testing, alpha-to-coverage, and so on. From kwg at kemper.freedesktop.org Mon Mar 9 23:10:05 2015 From: kwg at kemper.freedesktop.org (Kenneth Graunke) Date: Mon, 9 Mar 2015 16:10:05 -0700 (PDT) Subject: Mesa (master): i965/fs: Make get_timestamp() pass back the MOV rather than emitting it. Message-ID: <20150309231005.A43AB76338@kemper.freedesktop.org> Module: Mesa Branch: master Commit: e43af8d09f919d02b5ac0810c1c0f1783cbef6ef URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=e43af8d09f919d02b5ac0810c1c0f1783cbef6ef Author: Kenneth Graunke Date: Thu Feb 26 23:51:27 2015 -0800 i965/fs: Make get_timestamp() pass back the MOV rather than emitting it. This makes another part of the INTEL_DEBUG=shader_time code emittable at arbitrary locations, rather than just at the end of the instruction stream. v2: Don't lose smear! Caught by Topi Pohjolainen. v3: Don't set smear on the destination of the MOV. Thanks Topi! Signed-off-by: Kenneth Graunke Reviewed-by: Matt Turner Cc: mesa-stable at lists.freedesktop.org --- src/mesa/drivers/dri/i965/brw_fs.cpp | 19 +++++++++++++++---- src/mesa/drivers/dri/i965/brw_fs.h | 2 +- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp index 088a177..ee14a7a 100644 --- a/src/mesa/drivers/dri/i965/brw_fs.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs.cpp @@ -677,8 +677,14 @@ fs_visitor::type_size(const struct glsl_type *type) return 0; } +/** + * Create a MOV to read the timestamp register. + * + * The caller is responsible for emitting the MOV. The return value is + * the destination of the MOV, with extra parameters set. + */ fs_reg -fs_visitor::get_timestamp() +fs_visitor::get_timestamp(fs_inst **out_mov) { assert(brw->gen >= 7); @@ -689,7 +695,7 @@ fs_visitor::get_timestamp() fs_reg dst = fs_reg(GRF, alloc.allocate(1), BRW_REGISTER_TYPE_UD, 4); - fs_inst *mov = emit(MOV(dst, ts)); + fs_inst *mov = MOV(dst, ts); /* We want to read the 3 fields we care about even if it's not enabled in * the dispatch. */ @@ -707,6 +713,7 @@ fs_visitor::get_timestamp() */ dst.set_smear(0); + *out_mov = mov; return dst; } @@ -714,7 +721,9 @@ void fs_visitor::emit_shader_time_begin() { current_annotation = "shader time start"; - shader_start_time = get_timestamp(); + fs_inst *mov; + shader_start_time = get_timestamp(&mov); + emit(mov); } void @@ -750,7 +759,9 @@ fs_visitor::emit_shader_time_end() unreachable("fs_visitor::emit_shader_time_end missing code"); } - fs_reg shader_end_time = get_timestamp(); + fs_inst *tm_read; + fs_reg shader_end_time = get_timestamp(&tm_read); + emit(tm_read); /* Check that there weren't any timestamp reset events (assuming these * were the only two timestamp reads that happened). diff --git a/src/mesa/drivers/dri/i965/brw_fs.h b/src/mesa/drivers/dri/i965/brw_fs.h index e5a2d09..d9d5858 100644 --- a/src/mesa/drivers/dri/i965/brw_fs.h +++ b/src/mesa/drivers/dri/i965/brw_fs.h @@ -402,7 +402,7 @@ public: void resolve_ud_negate(fs_reg *reg); void resolve_bool_comparison(ir_rvalue *rvalue, fs_reg *reg); - fs_reg get_timestamp(); + fs_reg get_timestamp(fs_inst **out_mov); struct brw_reg interp_reg(int location, int channel); void setup_uniform_values(ir_variable *ir); From kwg at kemper.freedesktop.org Mon Mar 9 23:10:05 2015 From: kwg at kemper.freedesktop.org (Kenneth Graunke) Date: Mon, 9 Mar 2015 16:10:05 -0700 (PDT) Subject: Mesa (master): i965/fs: Make emit_shader_time_write return rather than emit. Message-ID: <20150309231005.945EE76338@kemper.freedesktop.org> Module: Mesa Branch: master Commit: bea854c7f33cc10b8292f931f114afc4f88a8dd4 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=bea854c7f33cc10b8292f931f114afc4f88a8dd4 Author: Kenneth Graunke Date: Thu Feb 26 22:49:04 2015 -0800 i965/fs: Make emit_shader_time_write return rather than emit. Instead of emit_shader_time_write, we now do emit(SHADER_TIME_ADD(...)). The advantage is that we can also insert a shader time write at an arbitrary location in the instruction stream, rather than being restricted to emitting at the end. Signed-off-by: Kenneth Graunke Reviewed-by: Topi Pohjolainen Reviewed-by: Matt Turner Cc: mesa-stable at lists.freedesktop.org --- src/mesa/drivers/dri/i965/brw_fs.cpp | 15 +++++++-------- src/mesa/drivers/dri/i965/brw_fs.h | 3 +-- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp index 71087f2..088a177 100644 --- a/src/mesa/drivers/dri/i965/brw_fs.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs.cpp @@ -778,16 +778,15 @@ fs_visitor::emit_shader_time_end() add->force_writemask_all = true; emit(add); - emit_shader_time_write(type, diff); - emit_shader_time_write(written_type, fs_reg(1u)); + emit(SHADER_TIME_ADD(type, diff)); + emit(SHADER_TIME_ADD(written_type, fs_reg(1u))); emit(BRW_OPCODE_ELSE); - emit_shader_time_write(reset_type, fs_reg(1u)); + emit(SHADER_TIME_ADD(reset_type, fs_reg(1u))); emit(BRW_OPCODE_ENDIF); } -void -fs_visitor::emit_shader_time_write(enum shader_time_shader_type type, - fs_reg value) +fs_inst * +fs_visitor::SHADER_TIME_ADD(enum shader_time_shader_type type, fs_reg value) { int shader_time_index = brw_get_shader_time_index(brw, shader_prog, prog, type); @@ -799,8 +798,8 @@ fs_visitor::emit_shader_time_write(enum shader_time_shader_type type, else payload = vgrf(glsl_type::uint_type); - emit(new(mem_ctx) fs_inst(SHADER_OPCODE_SHADER_TIME_ADD, - fs_reg(), payload, offset, value)); + return new(mem_ctx) fs_inst(SHADER_OPCODE_SHADER_TIME_ADD, + fs_reg(), payload, offset, value); } void diff --git a/src/mesa/drivers/dri/i965/brw_fs.h b/src/mesa/drivers/dri/i965/brw_fs.h index 70fc6fc..e5a2d09 100644 --- a/src/mesa/drivers/dri/i965/brw_fs.h +++ b/src/mesa/drivers/dri/i965/brw_fs.h @@ -381,8 +381,7 @@ public: void emit_shader_time_begin(); void emit_shader_time_end(); - void emit_shader_time_write(enum shader_time_shader_type type, - fs_reg value); + fs_inst *SHADER_TIME_ADD(enum shader_time_shader_type type, fs_reg value); void emit_untyped_atomic(unsigned atomic_op, unsigned surf_index, fs_reg dst, fs_reg offset, fs_reg src0, From bwidawsk at kemper.freedesktop.org Mon Mar 9 23:32:48 2015 From: bwidawsk at kemper.freedesktop.org (Ben Widawsky) Date: Mon, 9 Mar 2015 16:32:48 -0700 (PDT) Subject: Mesa (master): meta: Plug memory leak Message-ID: <20150309233248.EB5D976338@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 7aba4ab1f355ea1a5870b3deb4b295565132dfc5 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=7aba4ab1f355ea1a5870b3deb4b295565132dfc5 Author: Ben Widawsky Date: Fri Mar 6 17:31:00 2015 -0800 meta: Plug memory leak It looks like this has existed since commit f5a477ab76b6e0b268387699cd2253a43db0dfae Author: Ian Romanick Date: Mon Dec 16 11:54:08 2013 -0800 meta: Refactor shader generation code out of mipmap generation path Valgrind was complaining on fbo-generatemipmap-formats v2: Instead, do the allocation after the early return block (v2) Signed-off-by: Ben Widawsky Reviewed-by: Kenneth Graunke --- src/mesa/drivers/common/meta.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c index fdc4cf1..cf99d95 100644 --- a/src/mesa/drivers/common/meta.c +++ b/src/mesa/drivers/common/meta.c @@ -247,9 +247,9 @@ _mesa_meta_setup_blit_shader(struct gl_context *ctx, struct blit_shader_table *table) { char *vs_source, *fs_source; - void *const mem_ctx = ralloc_context(NULL); struct blit_shader *shader = choose_blit_shader(target, table); const char *vs_input, *vs_output, *fs_input, *vs_preprocess, *fs_preprocess; + void *mem_ctx; if (ctx->Const.GLSLVersion < 130) { vs_preprocess = ""; @@ -273,6 +273,8 @@ _mesa_meta_setup_blit_shader(struct gl_context *ctx, return; } + mem_ctx = ralloc_context(NULL); + vs_source = ralloc_asprintf(mem_ctx, "%s\n" "%s vec2 position;\n" From vlee at kemper.freedesktop.org Tue Mar 10 00:41:43 2015 From: vlee at kemper.freedesktop.org (Vinson Lee) Date: Mon, 9 Mar 2015 17:41:43 -0700 (PDT) Subject: Mesa (master): i915: Fix GCC unused-but-set-variable warning in release build. Message-ID: <20150310004143.810797633D@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 282f67becd072068147c95f26d9c705acf1bbe1b URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=282f67becd072068147c95f26d9c705acf1bbe1b Author: Vinson Lee Date: Fri Mar 6 21:52:31 2015 -0800 i915: Fix GCC unused-but-set-variable warning in release build. i915_fragprog.c: In function ?i915ValidateFragmentProgram?: i915_fragprog.c:1453:11: warning: variable ?k? set but not used [-Wunused-but-set-variable] int k; ^ Signed-off-by: Vinson Lee Reviewed-by: Anuj Phogat --- src/mesa/drivers/dri/i915/i915_fragprog.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/mesa/drivers/dri/i915/i915_fragprog.c b/src/mesa/drivers/dri/i915/i915_fragprog.c index d42da5a..9b00223 100644 --- a/src/mesa/drivers/dri/i915/i915_fragprog.c +++ b/src/mesa/drivers/dri/i915/i915_fragprog.c @@ -1450,8 +1450,6 @@ i915ValidateFragmentProgram(struct i915_context *i915) if (s2 != i915->state.Ctx[I915_CTXREG_LIS2] || s4 != i915->state.Ctx[I915_CTXREG_LIS4]) { - int k; - I915_STATECHANGE(i915, I915_UPLOAD_CTX); /* Must do this *after* statechange, so as not to affect @@ -1471,8 +1469,7 @@ i915ValidateFragmentProgram(struct i915_context *i915) i915->state.Ctx[I915_CTXREG_LIS2] = s2; i915->state.Ctx[I915_CTXREG_LIS4] = s4; - k = intel->vtbl.check_vertex_size(intel, intel->vertex_size); - assert(k); + assert(intel->vtbl.check_vertex_size(intel, intel->vertex_size)); } if (!p->params_uptodate) From vlee at kemper.freedesktop.org Tue Mar 10 00:41:43 2015 From: vlee at kemper.freedesktop.org (Vinson Lee) Date: Mon, 9 Mar 2015 17:41:43 -0700 (PDT) Subject: Mesa (master): Add macro for unused function attribute. Message-ID: <20150310004143.77BF576338@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 5f759836ad75360a2f4581083043a86f7a8c1e09 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=5f759836ad75360a2f4581083043a86f7a8c1e09 Author: Vinson Lee Date: Sat Mar 7 14:07:10 2015 -0800 Add macro for unused function attribute. Suggested-by: Emil Velikov Signed-off-by: Vinson Lee Reviewed-by: Emil Velikov --- configure.ac | 1 + scons/gallium.py | 1 + src/util/macros.h | 6 ++++++ 3 files changed, 8 insertions(+) diff --git a/configure.ac b/configure.ac index 90c7737..2954f80 100644 --- a/configure.ac +++ b/configure.ac @@ -195,6 +195,7 @@ AX_GCC_FUNC_ATTRIBUTE([flatten]) AX_GCC_FUNC_ATTRIBUTE([format]) AX_GCC_FUNC_ATTRIBUTE([malloc]) AX_GCC_FUNC_ATTRIBUTE([packed]) +AX_GCC_FUNC_ATTRIBUTE([unused]) AM_CONDITIONAL([GEN_ASM_OFFSETS], test "x$GEN_ASM_OFFSETS" = xyes) diff --git a/scons/gallium.py b/scons/gallium.py index 7533f06..b162089 100755 --- a/scons/gallium.py +++ b/scons/gallium.py @@ -369,6 +369,7 @@ def generate(env): 'HAVE___BUILTIN_FFS', 'HAVE___BUILTIN_FFSLL', 'HAVE_FUNC_ATTRIBUTE_FLATTEN', + 'HAVE_FUNC_ATTRIBUTE_UNUSED', # GCC 3.0 'HAVE_FUNC_ATTRIBUTE_FORMAT', 'HAVE_FUNC_ATTRIBUTE_PACKED', diff --git a/src/util/macros.h b/src/util/macros.h index 63daba3..6c7bda7 100644 --- a/src/util/macros.h +++ b/src/util/macros.h @@ -176,5 +176,11 @@ do { \ # endif #endif +#ifdef HAVE_FUNC_ATTRIBUTE_UNUSED +#define UNUSED __attribute__((unused)) +#else +#define UNUSED +#endif + #endif /* UTIL_MACROS_H */ From vlee at kemper.freedesktop.org Tue Mar 10 00:41:43 2015 From: vlee at kemper.freedesktop.org (Vinson Lee) Date: Mon, 9 Mar 2015 17:41:43 -0700 (PDT) Subject: Mesa (master): i965: Silence GCC maybe-uninitialized warning. Message-ID: <20150310004143.8B72A76338@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 13f4963ed2de90680841658af4561ef7ab238406 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=13f4963ed2de90680841658af4561ef7ab238406 Author: Vinson Lee Date: Fri Mar 6 22:08:00 2015 -0800 i965: Silence GCC maybe-uninitialized warning. brw_shader.cpp: In function ?bool brw_saturate_immediate(brw_reg_type, brw_reg*)?: brw_shader.cpp:618:31: warning: ?sat_imm.brw_saturate_immediate(brw_reg_type, brw_reg*)::::ud? may be used uninitialized in this function [-Wmaybe-uninitialized] reg->dw1.ud = sat_imm.ud; ^ Signed-off-by: Vinson Lee Reviewed-by: Anuj Phogat --- src/mesa/drivers/dri/i965/brw_shader.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesa/drivers/dri/i965/brw_shader.cpp b/src/mesa/drivers/dri/i965/brw_shader.cpp index f2b4d82..ff0ef4b 100644 --- a/src/mesa/drivers/dri/i965/brw_shader.cpp +++ b/src/mesa/drivers/dri/i965/brw_shader.cpp @@ -584,7 +584,7 @@ brw_saturate_immediate(enum brw_reg_type type, struct brw_reg *reg) unsigned ud; int d; float f; - } imm = { reg->dw1.ud }, sat_imm; + } imm = { reg->dw1.ud }, sat_imm = { 0 }; switch (type) { case BRW_REGISTER_TYPE_UD: From imirkin at kemper.freedesktop.org Tue Mar 10 00:51:05 2015 From: imirkin at kemper.freedesktop.org (Ilia Mirkin) Date: Mon, 9 Mar 2015 17:51:05 -0700 (PDT) Subject: Mesa (master): nvc0: fix wrong max value for driver queries Message-ID: <20150310005105.9D62276338@kemper.freedesktop.org> Module: Mesa Branch: master Commit: e5cd42ed9abadac8be085eea67049dc1e19ade09 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=e5cd42ed9abadac8be085eea67049dc1e19ade09 Author: Samuel Pitoiset Date: Sun Mar 8 17:18:07 2015 +0100 nvc0: fix wrong max value for driver queries The maximum value of a Gallium HUD's panel is automatically adjusted when the current value is greater than the max. If we set the pipe_query_driver_info::max_value to UINT64_MAX, the maximum value is never adjusted and this results in a flat line instead of a pretty curve which is correctly scaled. Signed-off-by: Samuel Pitoiset Reviewed-by: Ilia Mirkin --- src/gallium/drivers/nouveau/nvc0/nvc0_query.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_query.c b/src/gallium/drivers/nouveau/nvc0/nvc0_query.c index ec464b5..f21deea 100644 --- a/src/gallium/drivers/nouveau/nvc0/nvc0_query.c +++ b/src/gallium/drivers/nouveau/nvc0/nvc0_query.c @@ -1418,7 +1418,7 @@ nvc0_screen_get_driver_query_info(struct pipe_screen *pscreen, if (id < NVC0_QUERY_DRV_STAT_COUNT) { info->name = nvc0_drv_stat_names[id]; info->query_type = NVC0_QUERY_DRV_STAT(id); - info->max_value = ~0ULL; + info->max_value = 0; info->uses_byte_units = !!strstr(info->name, "bytes"); return 1; } else @@ -1427,15 +1427,14 @@ nvc0_screen_get_driver_query_info(struct pipe_screen *pscreen, if (screen->base.class_3d >= NVE4_3D_CLASS) { info->name = nve4_pm_query_names[id - NVC0_QUERY_DRV_STAT_COUNT]; info->query_type = NVE4_PM_QUERY(id - NVC0_QUERY_DRV_STAT_COUNT); - info->max_value = (id < NVE4_PM_QUERY_METRIC_MP_OCCUPANCY) ? - ~0ULL : 100; + info->max_value = (id < NVE4_PM_QUERY_METRIC_MP_OCCUPANCY) ? 0 : 100; info->uses_byte_units = FALSE; return 1; } else if (screen->compute) { info->name = nvc0_pm_query_names[id - NVC0_QUERY_DRV_STAT_COUNT]; info->query_type = NVC0_PM_QUERY(id - NVC0_QUERY_DRV_STAT_COUNT); - info->max_value = ~0ULL; + info->max_value = 0; info->uses_byte_units = FALSE; return 1; } From airlied at kemper.freedesktop.org Tue Mar 10 06:45:59 2015 From: airlied at kemper.freedesktop.org (Dave Airlie) Date: Mon, 9 Mar 2015 23:45:59 -0700 (PDT) Subject: Mesa (master): mesa/scissor: fix typos in debug names Message-ID: <20150310064559.BC93476338@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 4d318b61fc14c7ed550007cb568ff27dbeab1662 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=4d318b61fc14c7ed550007cb568ff27dbeab1662 Author: Dave Airlie Date: Tue Mar 10 16:45:18 2015 +1000 mesa/scissor: fix typos in debug names Just noticed this when working on virgl. Signed-off-by: Dave Airlie --- src/mesa/main/scissor.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mesa/main/scissor.c b/src/mesa/main/scissor.c index 83f39e2..bc8224c 100644 --- a/src/mesa/main/scissor.c +++ b/src/mesa/main/scissor.c @@ -201,13 +201,13 @@ void GLAPIENTRY _mesa_ScissorIndexed(GLuint index, GLint left, GLint bottom, GLsizei width, GLsizei height) { - ScissorIndexed(index, left, bottom, width, height, "glScissorIndexd"); + ScissorIndexed(index, left, bottom, width, height, "glScissorIndexed"); } void GLAPIENTRY _mesa_ScissorIndexedv(GLuint index, const GLint *v) { - ScissorIndexed(index, v[0], v[1], v[2], v[3], "glScissorIndexdv"); + ScissorIndexed(index, v[0], v[1], v[2], v[3], "glScissorIndexedv"); } /** From jljusten at kemper.freedesktop.org Tue Mar 10 07:34:10 2015 From: jljusten at kemper.freedesktop.org (Jordan Justen) Date: Tue, 10 Mar 2015 00:34:10 -0700 (PDT) Subject: Mesa (master): i965/hiz: Start to separate miptree out from hiz buffers Message-ID: <20150310073410.06B0B76338@kemper.freedesktop.org> Module: Mesa Branch: master Commit: aedcd466bb9d899e892f9d47f96fbca5e5647133 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=aedcd466bb9d899e892f9d47f96fbca5e5647133 Author: Jordan Justen Date: Sun Jun 29 11:55:26 2014 -0700 i965/hiz: Start to separate miptree out from hiz buffers Today we allocate a miptree's for the hiz buffer. We needed this in the past because we would point the hardware at offsets of the hiz buffer. Since the hiz format is not documented, this is not a good idea. Since moving to support layered rendering on Gen7+, we no longer point at an offset into the buffer on Gen7+. Therefore, to support hiz on Gen7+, we don't need a full miptree structure allocated. This patch starts to create a new auxiliary buffer structure (intel_miptree_aux_buffer) that can be a more simplistic miptree side-band buffer associated with a miptree. (For example, to serve the needs of the hiz buffer.) Signed-off-by: Jordan Justen Reviewed-by: Topi Pohjolainen Reviewed-by: Kenneth Graunke Reviewed-by: Ben Widawsky --- src/mesa/drivers/dri/i965/brw_misc_state.c | 4 +- src/mesa/drivers/dri/i965/gen6_blorp.cpp | 2 +- src/mesa/drivers/dri/i965/gen6_depth_state.c | 2 +- src/mesa/drivers/dri/i965/gen7_blorp.cpp | 2 +- src/mesa/drivers/dri/i965/gen7_misc_state.c | 2 +- src/mesa/drivers/dri/i965/gen8_depth_state.c | 6 +-- src/mesa/drivers/dri/i965/intel_fbo.c | 4 +- src/mesa/drivers/dri/i965/intel_mipmap_tree.c | 59 ++++++++++++++++++------- src/mesa/drivers/dri/i965/intel_mipmap_tree.h | 29 ++++++++++-- 9 files changed, 79 insertions(+), 31 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_misc_state.c b/src/mesa/drivers/dri/i965/brw_misc_state.c index 190cdf7..bc81076 100644 --- a/src/mesa/drivers/dri/i965/brw_misc_state.c +++ b/src/mesa/drivers/dri/i965/brw_misc_state.c @@ -172,7 +172,7 @@ brw_get_depthstencil_tile_masks(struct intel_mipmap_tree *depth_mt, if (intel_miptree_level_has_hiz(depth_mt, depth_level)) { uint32_t hiz_tile_mask_x, hiz_tile_mask_y; - intel_miptree_get_tile_masks(depth_mt->hiz_mt, + intel_miptree_get_tile_masks(depth_mt->hiz_buf->mt, &hiz_tile_mask_x, &hiz_tile_mask_y, false); @@ -632,7 +632,7 @@ brw_emit_depth_stencil_hiz(struct brw_context *brw, /* Emit hiz buffer. */ if (hiz) { - struct intel_mipmap_tree *hiz_mt = depth_mt->hiz_mt; + struct intel_mipmap_tree *hiz_mt = depth_mt->hiz_buf->mt; BEGIN_BATCH(3); OUT_BATCH((_3DSTATE_HIER_DEPTH_BUFFER << 16) | (3 - 2)); OUT_BATCH(hiz_mt->pitch - 1); diff --git a/src/mesa/drivers/dri/i965/gen6_blorp.cpp b/src/mesa/drivers/dri/i965/gen6_blorp.cpp index 372846b..e45705a 100644 --- a/src/mesa/drivers/dri/i965/gen6_blorp.cpp +++ b/src/mesa/drivers/dri/i965/gen6_blorp.cpp @@ -857,7 +857,7 @@ gen6_blorp_emit_depth_stencil_config(struct brw_context *brw, /* 3DSTATE_HIER_DEPTH_BUFFER */ { - struct intel_mipmap_tree *hiz_mt = params->depth.mt->hiz_mt; + struct intel_mipmap_tree *hiz_mt = params->depth.mt->hiz_buf->mt; uint32_t offset = 0; if (hiz_mt->array_layout == ALL_SLICES_AT_EACH_LOD) { diff --git a/src/mesa/drivers/dri/i965/gen6_depth_state.c b/src/mesa/drivers/dri/i965/gen6_depth_state.c index effb9c6..1df0bd4 100644 --- a/src/mesa/drivers/dri/i965/gen6_depth_state.c +++ b/src/mesa/drivers/dri/i965/gen6_depth_state.c @@ -156,7 +156,7 @@ gen6_emit_depth_stencil_hiz(struct brw_context *brw, /* Emit hiz buffer. */ if (hiz) { - struct intel_mipmap_tree *hiz_mt = depth_mt->hiz_mt; + struct intel_mipmap_tree *hiz_mt = depth_mt->hiz_buf->mt; uint32_t offset = 0; if (hiz_mt->array_layout == ALL_SLICES_AT_EACH_LOD) { diff --git a/src/mesa/drivers/dri/i965/gen7_blorp.cpp b/src/mesa/drivers/dri/i965/gen7_blorp.cpp index 206a6ff..6ba65d6 100644 --- a/src/mesa/drivers/dri/i965/gen7_blorp.cpp +++ b/src/mesa/drivers/dri/i965/gen7_blorp.cpp @@ -695,7 +695,7 @@ gen7_blorp_emit_depth_stencil_config(struct brw_context *brw, /* 3DSTATE_HIER_DEPTH_BUFFER */ { - struct intel_mipmap_tree *hiz_mt = params->depth.mt->hiz_mt; + struct intel_mipmap_tree *hiz_mt = params->depth.mt->hiz_buf->mt; BEGIN_BATCH(3); OUT_BATCH((GEN7_3DSTATE_HIER_DEPTH_BUFFER << 16) | (3 - 2)); diff --git a/src/mesa/drivers/dri/i965/gen7_misc_state.c b/src/mesa/drivers/dri/i965/gen7_misc_state.c index 33d4ade..cc74570 100644 --- a/src/mesa/drivers/dri/i965/gen7_misc_state.c +++ b/src/mesa/drivers/dri/i965/gen7_misc_state.c @@ -145,7 +145,7 @@ gen7_emit_depth_stencil_hiz(struct brw_context *brw, OUT_BATCH(0); ADVANCE_BATCH(); } else { - struct intel_mipmap_tree *hiz_mt = depth_mt->hiz_mt; + struct intel_mipmap_tree *hiz_mt = depth_mt->hiz_buf->mt; BEGIN_BATCH(3); OUT_BATCH(GEN7_3DSTATE_HIER_DEPTH_BUFFER << 16 | (3 - 2)); OUT_BATCH((mocs << 25) | diff --git a/src/mesa/drivers/dri/i965/gen8_depth_state.c b/src/mesa/drivers/dri/i965/gen8_depth_state.c index 5c56d51..9af9898 100644 --- a/src/mesa/drivers/dri/i965/gen8_depth_state.c +++ b/src/mesa/drivers/dri/i965/gen8_depth_state.c @@ -92,10 +92,10 @@ emit_depth_packets(struct brw_context *brw, } else { BEGIN_BATCH(5); OUT_BATCH(GEN7_3DSTATE_HIER_DEPTH_BUFFER << 16 | (5 - 2)); - OUT_BATCH((depth_mt->hiz_mt->pitch - 1) | mocs_wb << 25); - OUT_RELOC64(depth_mt->hiz_mt->bo, + OUT_BATCH((depth_mt->hiz_buf->mt->pitch - 1) | mocs_wb << 25); + OUT_RELOC64(depth_mt->hiz_buf->mt->bo, I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER, 0); - OUT_BATCH(depth_mt->hiz_mt->qpitch >> 2); + OUT_BATCH(depth_mt->hiz_buf->mt->qpitch >> 2); ADVANCE_BATCH(); } diff --git a/src/mesa/drivers/dri/i965/intel_fbo.c b/src/mesa/drivers/dri/i965/intel_fbo.c index 57cf583..2cf4771 100644 --- a/src/mesa/drivers/dri/i965/intel_fbo.c +++ b/src/mesa/drivers/dri/i965/intel_fbo.c @@ -561,9 +561,9 @@ intel_renderbuffer_update_wrapper(struct brw_context *brw, intel_renderbuffer_set_draw_offset(irb); - if (mt->hiz_mt == NULL && brw_is_hiz_depth_format(brw, rb->Format)) { + if (mt->hiz_buf == NULL && brw_is_hiz_depth_format(brw, rb->Format)) { intel_miptree_alloc_hiz(brw, mt); - if (!mt->hiz_mt) + if (!mt->hiz_buf) return false; } diff --git a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c index 36c3b26..6c4cc7f 100644 --- a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c +++ b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c @@ -883,7 +883,10 @@ intel_miptree_release(struct intel_mipmap_tree **mt) drm_intel_bo_unreference((*mt)->bo); intel_miptree_release(&(*mt)->stencil_mt); - intel_miptree_release(&(*mt)->hiz_mt); + if ((*mt)->hiz_buf) { + intel_miptree_release(&(*mt)->hiz_buf->mt); + free((*mt)->hiz_buf); + } intel_miptree_release(&(*mt)->mcs_mt); intel_resolve_map_clear(&(*mt)->hiz_map); @@ -1415,7 +1418,7 @@ intel_miptree_level_enable_hiz(struct brw_context *brw, struct intel_mipmap_tree *mt, uint32_t level) { - assert(mt->hiz_mt); + assert(mt->hiz_buf); if (brw->gen >= 8 || brw->is_haswell) { uint32_t width = minify(mt->physical_width0, level); @@ -1439,27 +1442,49 @@ intel_miptree_level_enable_hiz(struct brw_context *brw, } +static struct intel_miptree_aux_buffer * +intel_hiz_miptree_buf_create(struct brw_context *brw, + struct intel_mipmap_tree *mt) +{ + struct intel_miptree_aux_buffer *buf = calloc(sizeof(*buf), 1); + const bool force_all_slices_at_each_lod = brw->gen == 6; + + if (!buf) + return NULL; + + buf->mt = intel_miptree_create(brw, + mt->target, + mt->format, + mt->first_level, + mt->last_level, + mt->logical_width0, + mt->logical_height0, + mt->logical_depth0, + true, + mt->num_samples, + INTEL_MIPTREE_TILING_ANY, + force_all_slices_at_each_lod); + if (!buf->mt) { + free(buf); + return NULL; + } + + buf->bo = buf->mt->bo; + buf->pitch = buf->mt->pitch; + buf->qpitch = buf->mt->qpitch; + + return buf; +} + bool intel_miptree_alloc_hiz(struct brw_context *brw, struct intel_mipmap_tree *mt) { - assert(mt->hiz_mt == NULL); - const bool force_all_slices_at_each_lod = brw->gen == 6; - mt->hiz_mt = intel_miptree_create(brw, - mt->target, - mt->format, - mt->first_level, - mt->last_level, - mt->logical_width0, - mt->logical_height0, - mt->logical_depth0, - true, - mt->num_samples, - INTEL_MIPTREE_TILING_ANY, - force_all_slices_at_each_lod); + assert(mt->hiz_buf == NULL); + mt->hiz_buf = intel_hiz_miptree_buf_create(brw, mt); - if (!mt->hiz_mt) + if (!mt->hiz_buf) return false; /* Mark that all slices need a HiZ resolve. */ diff --git a/src/mesa/drivers/dri/i965/intel_mipmap_tree.h b/src/mesa/drivers/dri/i965/intel_mipmap_tree.h index ee9cf1e..41b6036 100644 --- a/src/mesa/drivers/dri/i965/intel_mipmap_tree.h +++ b/src/mesa/drivers/dri/i965/intel_mipmap_tree.h @@ -307,6 +307,29 @@ enum miptree_array_layout { ALL_SLICES_AT_EACH_LOD, }; +/** + * Miptree aux buffer. These buffers are associated with a miptree, but the + * format is managed by the hardware. + * + * For Gen7+, we always give the hardware the start of the buffer, and let it + * handle all accesses to the buffer. Therefore we don't need the full miptree + * layout structure for this buffer. + * + * For Gen6, we need a hiz miptree structure for this buffer so we can program + * offsets to slices & miplevels. + */ +struct intel_miptree_aux_buffer +{ + /** Buffer object containing the pixel data. */ + drm_intel_bo *bo; + + uint32_t pitch; /**< pitch in bytes. */ + + uint32_t qpitch; /**< The distance in rows between array slices. */ + + struct intel_mipmap_tree *mt; /**< hiz miptree used with Gen6 */ +}; + struct intel_mipmap_tree { /** Buffer object containing the pixel data. */ @@ -411,15 +434,15 @@ struct intel_mipmap_tree uint32_t offset; /** - * \brief HiZ miptree + * \brief HiZ aux buffer * * The hiz miptree contains the miptree's hiz buffer. To allocate the hiz - * miptree, use intel_miptree_alloc_hiz(). + * buffer, use intel_miptree_alloc_hiz(). * * To determine if hiz is enabled, do not check this pointer. Instead, use * intel_miptree_slice_has_hiz(). */ - struct intel_mipmap_tree *hiz_mt; + struct intel_miptree_aux_buffer *hiz_buf; /** * \brief Map of miptree slices to needed resolves. From jljusten at kemper.freedesktop.org Tue Mar 10 07:34:10 2015 From: jljusten at kemper.freedesktop.org (Jordan Justen) Date: Tue, 10 Mar 2015 00:34:10 -0700 (PDT) Subject: Mesa (master): i965/gen8: Don't rely directly on the hiz miptree structure Message-ID: <20150310073410.161D37633D@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 31b851dccb606090989c0400fc1899cbfe44bcf1 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=31b851dccb606090989c0400fc1899cbfe44bcf1 Author: Jordan Justen Date: Sun Jun 29 12:06:33 2014 -0700 i965/gen8: Don't rely directly on the hiz miptree structure We are still allocating a miptree for hiz, but we only use fields from intel_miptree_aux_buffer. This will allow us to switch over to not allocating a miptree. Signed-off-by: Jordan Justen Reviewed-by: Topi Pohjolainen Reviewed-by: Kenneth Graunke Reviewed-by: Ben Widawsky --- src/mesa/drivers/dri/i965/gen8_depth_state.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/mesa/drivers/dri/i965/gen8_depth_state.c b/src/mesa/drivers/dri/i965/gen8_depth_state.c index 9af9898..c6494c9 100644 --- a/src/mesa/drivers/dri/i965/gen8_depth_state.c +++ b/src/mesa/drivers/dri/i965/gen8_depth_state.c @@ -92,10 +92,10 @@ emit_depth_packets(struct brw_context *brw, } else { BEGIN_BATCH(5); OUT_BATCH(GEN7_3DSTATE_HIER_DEPTH_BUFFER << 16 | (5 - 2)); - OUT_BATCH((depth_mt->hiz_buf->mt->pitch - 1) | mocs_wb << 25); - OUT_RELOC64(depth_mt->hiz_buf->mt->bo, + OUT_BATCH((depth_mt->hiz_buf->pitch - 1) | mocs_wb << 25); + OUT_RELOC64(depth_mt->hiz_buf->bo, I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER, 0); - OUT_BATCH(depth_mt->hiz_buf->mt->qpitch >> 2); + OUT_BATCH(depth_mt->hiz_buf->qpitch >> 2); ADVANCE_BATCH(); } From jljusten at kemper.freedesktop.org Tue Mar 10 07:34:10 2015 From: jljusten at kemper.freedesktop.org (Jordan Justen) Date: Tue, 10 Mar 2015 00:34:10 -0700 (PDT) Subject: Mesa (master): i965/gen8: Don't allocate hiz miptree structure Message-ID: <20150310073410.2DF3E76338@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 6626e3548b5365dcb284504ea863d2ccdba2c7a5 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=6626e3548b5365dcb284504ea863d2ccdba2c7a5 Author: Jordan Justen Date: Sun Jun 29 12:06:33 2014 -0700 i965/gen8: Don't allocate hiz miptree structure We now skip allocating a hiz miptree for gen8. Instead, we calculate the required hiz buffer parameters and allocate a bo directly. v2: * Update hz_height calculation as suggested by Topi v3: * Bail if we failed to create the bo (Ben) v4: * CEILING => DIV_ROUND_UP * Make sure mt->logical_depth0 being 0 would not cause trouble * Fail if Y tiling is not returned Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=67564 Signed-off-by: Jordan Justen Reviewed-by: Topi Pohjolainen Reviewed-by: Ben Widawsky --- src/mesa/drivers/dri/i965/intel_mipmap_tree.c | 105 +++++++++++++++++++++++++ 1 file changed, 105 insertions(+) diff --git a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c index a1c04e0..eb226d5 100644 --- a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c +++ b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c @@ -1539,6 +1539,109 @@ intel_gen7_hiz_buf_create(struct brw_context *brw, } +/** + * Helper for intel_miptree_alloc_hiz() that determines the required hiz + * buffer dimensions and allocates a bo for the hiz buffer. + */ +static struct intel_miptree_aux_buffer * +intel_gen8_hiz_buf_create(struct brw_context *brw, + struct intel_mipmap_tree *mt) +{ + unsigned z_width = mt->logical_width0; + unsigned z_height = mt->logical_height0; + const unsigned z_depth = MAX2(mt->logical_depth0, 1); + unsigned hz_width, hz_height; + struct intel_miptree_aux_buffer *buf = calloc(sizeof(*buf), 1); + + if (!buf) + return NULL; + + /* Gen7 PRM Volume 2, Part 1, 11.5.3 "Hierarchical Depth Buffer" documents + * adjustments required for Z_Height and Z_Width based on multisampling. + */ + switch (mt->num_samples) { + case 0: + case 1: + break; + case 2: + case 4: + z_width *= 2; + z_height *= 2; + break; + case 8: + z_width *= 4; + z_height *= 2; + break; + default: + unreachable("unsupported sample count"); + } + + const unsigned vertical_align = 8; /* 'j' in the docs */ + const unsigned H0 = z_height; + const unsigned h0 = ALIGN(H0, vertical_align); + const unsigned h1 = ALIGN(minify(H0, 1), vertical_align); + const unsigned Z0 = z_depth; + + /* HZ_Width (bytes) = ceiling(Z_Width / 16) * 16 */ + hz_width = ALIGN(z_width, 16); + + unsigned H_i = H0; + unsigned Z_i = Z0; + unsigned sum_h_i = 0; + unsigned hz_height_3d_sum = 0; + for (int level = mt->first_level; level <= mt->last_level; ++level) { + unsigned i = level - mt->first_level; + unsigned h_i = ALIGN(H_i, vertical_align); + /* sum(i=2 to m; h_i) */ + if (i >= 2) { + sum_h_i += h_i; + } + /* sum(i=0 to m; h_i * max(1, floor(Z_Depth/2**i))) */ + hz_height_3d_sum += h_i * Z_i; + H_i = minify(H_i, 1); + Z_i = minify(Z_i, 1); + } + /* HZ_QPitch = h0 + max(h1, sum(i=2 to m; h_i)) */ + buf->qpitch = h0 + MAX2(h1, sum_h_i); + + if (mt->target == GL_TEXTURE_3D) { + /* (1/2) * sum(i=0 to m; h_i * max(1, floor(Z_Depth/2**i))) */ + hz_height = DIV_ROUND_UP(hz_height_3d_sum, 2); + } else { + /* HZ_Height (rows) = ceiling( (HZ_QPitch/2)/8) *8 * Z_Depth */ + hz_height = DIV_ROUND_UP(buf->qpitch, 2 * 8) * 8 * Z0; + if (mt->target == GL_TEXTURE_CUBE_MAP_ARRAY || + mt->target == GL_TEXTURE_CUBE_MAP) { + /* HZ_Height (rows) = ceiling( (HZ_QPitch/2)/8) *8 * 6 * Z_Depth + * + * We can can just take our hz_height calculation from above, and + * multiply by 6 for the cube map and cube map array types. + */ + hz_height *= 6; + } + } + + unsigned long pitch; + uint32_t tiling = I915_TILING_Y; + buf->bo = drm_intel_bo_alloc_tiled(brw->bufmgr, "hiz", + hz_width, hz_height, 1, + &tiling, &pitch, + BO_ALLOC_FOR_RENDER); + if (!buf->bo) { + free(buf); + return NULL; + } else if (tiling != I915_TILING_Y) { + drm_intel_bo_unreference(buf->bo); + free(buf); + return NULL; + } + + buf->pitch = pitch; + + return buf; +} + + static struct intel_miptree_aux_buffer * intel_hiz_miptree_buf_create(struct brw_context *brw, struct intel_mipmap_tree *mt) @@ -1582,6 +1685,8 @@ intel_miptree_alloc_hiz(struct brw_context *brw, if (brw->gen == 7) { mt->hiz_buf = intel_gen7_hiz_buf_create(brw, mt); + } else if (brw->gen >= 8) { + mt->hiz_buf = intel_gen8_hiz_buf_create(brw, mt); } else { mt->hiz_buf = intel_hiz_miptree_buf_create(brw, mt); } From jljusten at kemper.freedesktop.org Tue Mar 10 07:34:10 2015 From: jljusten at kemper.freedesktop.org (Jordan Justen) Date: Tue, 10 Mar 2015 00:34:10 -0700 (PDT) Subject: Mesa (master): i965/fs: Use unsigned for CS/ VS atomics pixel mask immediate data Message-ID: <20150310073410.37BED76338@kemper.freedesktop.org> Module: Mesa Branch: master Commit: e5269ca28e4c44fb49890b33af8b3058377d35c8 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=e5269ca28e4c44fb49890b33af8b3058377d35c8 Author: Jordan Justen Date: Sat Feb 21 15:00:28 2015 -0800 i965/fs: Use unsigned for CS/VS atomics pixel mask immediate data brw_imm_ud(0xffff) should have been converted to fs_reg(0xffffu) to make sure the uint32_t fs_reg constructor was matched. commit 49a938a265f5959c9b558995cc658f80acb6eb18 Author: Jordan Justen Date: Fri Feb 20 12:12:25 2015 -0800 i965/fs: Use fs_reg for CS/VS atomics pixel mask immediate data Signed-off-by: Jordan Justen Reviewed-by: Matt Turner --- src/mesa/drivers/dri/i965/brw_fs_visitor.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp index 7859fef..3025a9d 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp @@ -3108,7 +3108,7 @@ fs_visitor::emit_untyped_atomic(unsigned atomic_op, unsigned surf_index, */ assert(stage == MESA_SHADER_VERTEX || stage == MESA_SHADER_COMPUTE); emit(MOV(component(sources[0], 7), - fs_reg(0xffff)))->force_writemask_all = true; + fs_reg(0xffffu)))->force_writemask_all = true; } length++; @@ -3171,7 +3171,7 @@ fs_visitor::emit_untyped_surface_read(unsigned surf_index, fs_reg dst, */ assert(stage == MESA_SHADER_VERTEX || stage == MESA_SHADER_COMPUTE); emit(MOV(component(sources[0], 7), - fs_reg(0xffff)))->force_writemask_all = true; + fs_reg(0xffffu)))->force_writemask_all = true; } /* Set the surface read offset. */ From jljusten at kemper.freedesktop.org Tue Mar 10 07:34:10 2015 From: jljusten at kemper.freedesktop.org (Jordan Justen) Date: Tue, 10 Mar 2015 00:34:10 -0700 (PDT) Subject: Mesa (master): i965/gen7: Don't rely directly on the hiz miptree structure Message-ID: <20150310073410.0D0657633D@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 26eabd189d9dd1e1e1c711ee4bcc8ff73c076d11 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=26eabd189d9dd1e1e1c711ee4bcc8ff73c076d11 Author: Jordan Justen Date: Sun Jun 29 12:06:33 2014 -0700 i965/gen7: Don't rely directly on the hiz miptree structure We are still allocating a miptree for hiz, but we only use fields from intel_miptree_aux_buffer. This will allow us to switch over to not allocating a miptree. Signed-off-by: Jordan Justen Reviewed-by: Topi Pohjolainen Reviewed-by: Kenneth Graunke Reviewed-by: Ben Widawsky --- src/mesa/drivers/dri/i965/gen7_blorp.cpp | 6 +++--- src/mesa/drivers/dri/i965/gen7_misc_state.c | 7 ++++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/mesa/drivers/dri/i965/gen7_blorp.cpp b/src/mesa/drivers/dri/i965/gen7_blorp.cpp index 6ba65d6..fb6a0dd 100644 --- a/src/mesa/drivers/dri/i965/gen7_blorp.cpp +++ b/src/mesa/drivers/dri/i965/gen7_blorp.cpp @@ -695,13 +695,13 @@ gen7_blorp_emit_depth_stencil_config(struct brw_context *brw, /* 3DSTATE_HIER_DEPTH_BUFFER */ { - struct intel_mipmap_tree *hiz_mt = params->depth.mt->hiz_buf->mt; + struct intel_miptree_aux_buffer *hiz_buf = params->depth.mt->hiz_buf; BEGIN_BATCH(3); OUT_BATCH((GEN7_3DSTATE_HIER_DEPTH_BUFFER << 16) | (3 - 2)); OUT_BATCH((mocs << 25) | - (hiz_mt->pitch - 1)); - OUT_RELOC(hiz_mt->bo, + (hiz_buf->pitch - 1)); + OUT_RELOC(hiz_buf->bo, I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER, 0); ADVANCE_BATCH(); diff --git a/src/mesa/drivers/dri/i965/gen7_misc_state.c b/src/mesa/drivers/dri/i965/gen7_misc_state.c index cc74570..f4f6652 100644 --- a/src/mesa/drivers/dri/i965/gen7_misc_state.c +++ b/src/mesa/drivers/dri/i965/gen7_misc_state.c @@ -145,12 +145,13 @@ gen7_emit_depth_stencil_hiz(struct brw_context *brw, OUT_BATCH(0); ADVANCE_BATCH(); } else { - struct intel_mipmap_tree *hiz_mt = depth_mt->hiz_buf->mt; + struct intel_miptree_aux_buffer *hiz_buf = depth_mt->hiz_buf; + BEGIN_BATCH(3); OUT_BATCH(GEN7_3DSTATE_HIER_DEPTH_BUFFER << 16 | (3 - 2)); OUT_BATCH((mocs << 25) | - (hiz_mt->pitch - 1)); - OUT_RELOC(hiz_mt->bo, + (hiz_buf->pitch - 1)); + OUT_RELOC(hiz_buf->bo, I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER, 0); From jljusten at kemper.freedesktop.org Tue Mar 10 07:34:10 2015 From: jljusten at kemper.freedesktop.org (Jordan Justen) Date: Tue, 10 Mar 2015 00:34:10 -0700 (PDT) Subject: Mesa (master): i965/gen7: Don't allocate hiz miptree structure Message-ID: <20150310073410.23E3676338@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 81124aefe8a2f61d5af4257e5b9989019bfed518 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=81124aefe8a2f61d5af4257e5b9989019bfed518 Author: Jordan Justen Date: Sun Jun 29 12:06:33 2014 -0700 i965/gen7: Don't allocate hiz miptree structure We now skip allocating a hiz miptree for gen7. Instead, we calculate the required hiz buffer parameters and allocate a bo directly. v2: * Update hz_height calculation as suggested by Topi v3: * Bail if we failed to create the bo (Ben) v4: * CEILING => DIV_ROUND_UP * Make sure mt->logical_depth0 being 0 would not cause trouble * Fail if Y tiling is not returned Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=67564 Signed-off-by: Jordan Justen Reviewed-by: Topi Pohjolainen Reviewed-by: Ben Widawsky --- src/mesa/drivers/dri/i965/intel_mipmap_tree.c | 106 ++++++++++++++++++++++++- 1 file changed, 104 insertions(+), 2 deletions(-) diff --git a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c index 6c4cc7f..a1c04e0 100644 --- a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c +++ b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c @@ -884,7 +884,10 @@ intel_miptree_release(struct intel_mipmap_tree **mt) drm_intel_bo_unreference((*mt)->bo); intel_miptree_release(&(*mt)->stencil_mt); if ((*mt)->hiz_buf) { - intel_miptree_release(&(*mt)->hiz_buf->mt); + if ((*mt)->hiz_buf->mt) + intel_miptree_release(&(*mt)->hiz_buf->mt); + else + drm_intel_bo_unreference((*mt)->hiz_buf->bo); free((*mt)->hiz_buf); } intel_miptree_release(&(*mt)->mcs_mt); @@ -1442,6 +1445,100 @@ intel_miptree_level_enable_hiz(struct brw_context *brw, } +/** + * Helper for intel_miptree_alloc_hiz() that determines the required hiz + * buffer dimensions and allocates a bo for the hiz buffer. + */ +static struct intel_miptree_aux_buffer * +intel_gen7_hiz_buf_create(struct brw_context *brw, + struct intel_mipmap_tree *mt) +{ + unsigned z_width = mt->logical_width0; + unsigned z_height = mt->logical_height0; + const unsigned z_depth = MAX2(mt->logical_depth0, 1); + unsigned hz_width, hz_height; + struct intel_miptree_aux_buffer *buf = calloc(sizeof(*buf), 1); + + if (!buf) + return NULL; + + /* Gen7 PRM Volume 2, Part 1, 11.5.3 "Hierarchical Depth Buffer" documents + * adjustments required for Z_Height and Z_Width based on multisampling. + */ + switch (mt->num_samples) { + case 0: + case 1: + break; + case 2: + case 4: + z_width *= 2; + z_height *= 2; + break; + case 8: + z_width *= 4; + z_height *= 2; + break; + default: + unreachable("unsupported sample count"); + } + + const unsigned vertical_align = 8; /* 'j' in the docs */ + const unsigned H0 = z_height; + const unsigned h0 = ALIGN(H0, vertical_align); + const unsigned h1 = ALIGN(minify(H0, 1), vertical_align); + const unsigned Z0 = z_depth; + + /* HZ_Width (bytes) = ceiling(Z_Width / 16) * 16 */ + hz_width = ALIGN(z_width, 16); + + if (mt->target == GL_TEXTURE_3D) { + unsigned H_i = H0; + unsigned Z_i = Z0; + hz_height = 0; + for (int level = mt->first_level; level <= mt->last_level; ++level) { + unsigned h_i = ALIGN(H_i, vertical_align); + /* sum(i=0 to m; h_i * max(1, floor(Z_Depth/2**i))) */ + hz_height += h_i * Z_i; + H_i = minify(H_i, 1); + Z_i = minify(Z_i, 1); + } + /* HZ_Height = + * (1/2) * sum(i=0 to m; h_i * max(1, floor(Z_Depth/2**i))) + */ + hz_height = DIV_ROUND_UP(hz_height, 2); + } else { + const unsigned hz_qpitch = h0 + h1 + (12 * vertical_align); + if (mt->target == GL_TEXTURE_CUBE_MAP_ARRAY || + mt->target == GL_TEXTURE_CUBE_MAP) { + /* HZ_Height (rows) = Ceiling ( ( Q_pitch * Z_depth * 6/2) /8 ) * 8 */ + hz_height = DIV_ROUND_UP(hz_qpitch * Z0 * 6, 2 * 8) * 8; + } else { + /* HZ_Height (rows) = Ceiling ( ( Q_pitch * Z_depth/2) /8 ) * 8 */ + hz_height = DIV_ROUND_UP(hz_qpitch * Z0, 2 * 8) * 8; + } + } + + unsigned long pitch; + uint32_t tiling = I915_TILING_Y; + buf->bo = drm_intel_bo_alloc_tiled(brw->bufmgr, "hiz", + hz_width, hz_height, 1, + &tiling, &pitch, + BO_ALLOC_FOR_RENDER); + if (!buf->bo) { + free(buf); + return NULL; + } else if (tiling != I915_TILING_Y) { + drm_intel_bo_unreference(buf->bo); + free(buf); + return NULL; + } + + buf->pitch = pitch; + + return buf; +} + + static struct intel_miptree_aux_buffer * intel_hiz_miptree_buf_create(struct brw_context *brw, struct intel_mipmap_tree *mt) @@ -1482,7 +1579,12 @@ intel_miptree_alloc_hiz(struct brw_context *brw, struct intel_mipmap_tree *mt) { assert(mt->hiz_buf == NULL); - mt->hiz_buf = intel_hiz_miptree_buf_create(brw, mt); + + if (brw->gen == 7) { + mt->hiz_buf = intel_gen7_hiz_buf_create(brw, mt); + } else { + mt->hiz_buf = intel_hiz_miptree_buf_create(brw, mt); + } if (!mt->hiz_buf) return false; From jljusten at kemper.freedesktop.org Tue Mar 10 07:34:10 2015 From: jljusten at kemper.freedesktop.org (Jordan Justen) Date: Tue, 10 Mar 2015 00:34:10 -0700 (PDT) Subject: Mesa (master): i965/gen6 gs: Convert brw_imm_ud/brw_imm_d to src_reg Message-ID: <20150310073410.4025276338@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 5750595ca97b2f8f18d22af35b431a6c66dd899a URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=5750595ca97b2f8f18d22af35b431a6c66dd899a Author: Jordan Justen Date: Sat Feb 21 15:05:22 2015 -0800 i965/gen6 gs: Convert brw_imm_ud/brw_imm_d to src_reg Same idea as this patch, only for gen6_gs_visitor: commit 49a938a265f5959c9b558995cc658f80acb6eb18 Author: Jordan Justen Date: Fri Feb 20 12:12:25 2015 -0800 i965/fs: Use fs_reg for CS/VS atomics pixel mask immediate data Suggested-by: Matt Turner Signed-off-by: Jordan Justen Reviewed-by: Chris Forbes Reviewed-by: Matt Turner --- src/mesa/drivers/dri/i965/gen6_gs_visitor.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/mesa/drivers/dri/i965/gen6_gs_visitor.cpp b/src/mesa/drivers/dri/i965/gen6_gs_visitor.cpp index 564b4cb..782687a 100644 --- a/src/mesa/drivers/dri/i965/gen6_gs_visitor.cpp +++ b/src/mesa/drivers/dri/i965/gen6_gs_visitor.cpp @@ -254,7 +254,7 @@ gen6_gs_visitor::visit(ir_end_primitive *) * vertex. */ src_reg offset(this, glsl_type::uint_type); - emit(ADD(dst_reg(offset), this->vertex_output_offset, brw_imm_d(-1))); + emit(ADD(dst_reg(offset), this->vertex_output_offset, src_reg(-1))); src_reg dst(this->vertex_output); dst.reladdr = ralloc(mem_ctx, src_reg); @@ -384,7 +384,7 @@ gen6_gs_visitor::emit_thread_end() dst_reg(this->temp), this->prim_count, this->svbi); } else { inst = emit(GS_OPCODE_FF_SYNC, - dst_reg(this->temp), this->prim_count, brw_imm_ud(0u)); + dst_reg(this->temp), this->prim_count, src_reg(0u)); } inst->base_mrf = base_mrf; @@ -487,8 +487,8 @@ gen6_gs_visitor::emit_thread_end() if (c->prog_data.gen6_xfb_enabled) { /* When emitting EOT, set SONumPrimsWritten Increment Value. */ src_reg data(this, glsl_type::uint_type); - emit(AND(dst_reg(data), this->sol_prim_written, brw_imm_ud(0xffffu))); - emit(SHL(dst_reg(data), data, brw_imm_ud(16u))); + emit(AND(dst_reg(data), this->sol_prim_written, src_reg(0xffffu))); + emit(SHL(dst_reg(data), data, src_reg(16u))); emit(GS_OPCODE_SET_DWORD_2, dst_reg(MRF, base_mrf), data); } @@ -624,7 +624,7 @@ gen6_gs_visitor::xfb_write() * transform feedback is in interleaved or separate attribs mode. */ src_reg sol_temp(this, glsl_type::uvec4_type); - emit(ADD(dst_reg(sol_temp), this->svbi, brw_imm_ud(num_verts))); + emit(ADD(dst_reg(sol_temp), this->svbi, src_reg(num_verts))); /* Compare SVBI calculated number with the maximum value, which is * in R1.4 (previously saved in this->max_svbi) for gen6. @@ -671,7 +671,7 @@ gen6_gs_visitor::xfb_program(unsigned vertex, unsigned num_verts) * (all vertices). Otherwise, avoid writing any vertices for it */ emit(ADD(dst_reg(sol_temp), this->sol_prim_written, 1u)); - emit(MUL(dst_reg(sol_temp), sol_temp, brw_imm_ud(num_verts))); + emit(MUL(dst_reg(sol_temp), sol_temp, src_reg(num_verts))); emit(ADD(dst_reg(sol_temp), sol_temp, this->svbi)); emit(CMP(dst_null_d(), sol_temp, this->max_svbi, BRW_CONDITIONAL_LE)); emit(IF(BRW_PREDICATE_NORMAL)); @@ -736,7 +736,7 @@ gen6_gs_visitor::xfb_program(unsigned vertex, unsigned num_verts) */ emit(ADD(dst_reg(this->destination_indices), this->destination_indices, - brw_imm_ud(num_verts))); + src_reg(num_verts))); emit(ADD(dst_reg(this->sol_prim_written), this->sol_prim_written, 1u)); } From itoral at kemper.freedesktop.org Wed Mar 11 07:05:27 2015 From: itoral at kemper.freedesktop.org (Iago Toral Quiroga) Date: Wed, 11 Mar 2015 00:05:27 -0700 (PDT) Subject: Mesa (master): i965: Fix out-of-bounds accesses into pull_constant_loc array Message-ID: <20150311070527.3045A76246@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 6ac1bc90c4a7a6f32901a9782e14b090f6fe5270 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=6ac1bc90c4a7a6f32901a9782e14b090f6fe5270 Author: Iago Toral Quiroga Date: Tue Mar 10 11:36:43 2015 +0100 i965: Fix out-of-bounds accesses into pull_constant_loc array The piglit test glsl-fs-uniform-array-loop-unroll.shader_test was designed to do an out of bounds access into an uniform array to make sure that we handle that situation gracefully inside the driver, however, as Ken describes in bug 79202, Valgrind reports that this is leading to an out-of-bounds access in fs_visitor::demote_pull_constants(). Before accessing the pull_constant_loc array we should make sure that the uniform we are trying to access is valid. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=79202 Reviewed-by: Matt Turner --- src/mesa/drivers/dri/i965/brw_fs.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp index 89754ad..6d7cf0e 100644 --- a/src/mesa/drivers/dri/i965/brw_fs.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs.cpp @@ -2281,8 +2281,13 @@ fs_visitor::demote_pull_constants() if (inst->src[i].file != UNIFORM) continue; - int pull_index = pull_constant_loc[inst->src[i].reg + - inst->src[i].reg_offset]; + int pull_index; + unsigned location = inst->src[i].reg + inst->src[i].reg_offset; + if (location >= uniforms) /* Out of bounds access */ + pull_index = -1; + else + pull_index = pull_constant_loc[location]; + if (pull_index == -1) continue; From brianp at kemper.freedesktop.org Wed Mar 11 15:41:07 2015 From: brianp at kemper.freedesktop.org (Brian Paul) Date: Wed, 11 Mar 2015 08:41:07 -0700 (PDT) Subject: Mesa (master): vbo: improve the code style by adjust the preprocessing c code directives Message-ID: <20150311154107.CC4B076333@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 09b03254091d054800834ddee604885a1093673f URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=09b03254091d054800834ddee604885a1093673f Author: Marius Predut Date: Wed Mar 11 03:25:00 2015 -0600 vbo: improve the code style by adjust the preprocessing c code directives Brian Paul review suggestion: there's more macro use here than necessary. Removed and redefine some #define preprocessing directives. Removed the directive input parameter 'T' . No functional changes. Signed-off-by: Marius Predut Reviewed-by: Brian Paul --- src/mesa/vbo/vbo_attrib_tmp.h | 74 ++++++++++++++++++----------------------- src/mesa/vbo/vbo_exec_api.c | 2 +- 2 files changed, 34 insertions(+), 42 deletions(-) diff --git a/src/mesa/vbo/vbo_attrib_tmp.h b/src/mesa/vbo/vbo_attrib_tmp.h index b1c3d98..17e0578 100644 --- a/src/mesa/vbo/vbo_attrib_tmp.h +++ b/src/mesa/vbo/vbo_attrib_tmp.h @@ -30,35 +30,30 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. /* ATTR */ -#define ATTR( A, N, T, V0, V1, V2, V3 ) \ - ATTR_##T((A), (N), (T), (V0), (V1), (V2), (V3)) - -#define ATTR_GL_UNSIGNED_INT( A, N, T, V0, V1, V2, V3 ) \ - ATTR_UNION(A, N, T, UINT_AS_UNION(V0), UINT_AS_UNION(V1), \ - UINT_AS_UNION(V2), UINT_AS_UNION(V3)) -#define ATTR_GL_INT( A, N, T, V0, V1, V2, V3 ) \ - ATTR_UNION(A, N, T, INT_AS_UNION(V0), INT_AS_UNION(V1), \ +#define ATTRI( A, N, V0, V1, V2, V3 ) \ + ATTR_UNION(A, N, GL_INT, INT_AS_UNION(V0), INT_AS_UNION(V1), \ INT_AS_UNION(V2), INT_AS_UNION(V3)) -#define ATTR_GL_FLOAT( A, N, T, V0, V1, V2, V3 ) \ - ATTR_UNION(A, N, T, FLOAT_AS_UNION(V0), FLOAT_AS_UNION(V1),\ +#define ATTRUI( A, N, V0, V1, V2, V3 ) \ + ATTR_UNION(A, N, GL_UNSIGNED_INT, UINT_AS_UNION(V0), UINT_AS_UNION(V1), \ + UINT_AS_UNION(V2), UINT_AS_UNION(V3)) +#define ATTRF( A, N, V0, V1, V2, V3 ) \ + ATTR_UNION(A, N, GL_FLOAT, FLOAT_AS_UNION(V0), FLOAT_AS_UNION(V1),\ FLOAT_AS_UNION(V2), FLOAT_AS_UNION(V3)) /* float */ -#define ATTR1FV( A, V ) ATTR( A, 1, GL_FLOAT, (V)[0], 0, 0, 1 ) -#define ATTR2FV( A, V ) ATTR( A, 2, GL_FLOAT, (V)[0], (V)[1], 0, 1 ) -#define ATTR3FV( A, V ) ATTR( A, 3, GL_FLOAT, (V)[0], (V)[1], (V)[2], 1 ) -#define ATTR4FV( A, V ) ATTR( A, 4, GL_FLOAT, (V)[0], (V)[1], (V)[2], (V)[3] ) +#define ATTR1FV( A, V ) ATTRF( A, 1, (V)[0], 0, 0, 1 ) +#define ATTR2FV( A, V ) ATTRF( A, 2, (V)[0], (V)[1], 0, 1 ) +#define ATTR3FV( A, V ) ATTRF( A, 3, (V)[0], (V)[1], (V)[2], 1 ) +#define ATTR4FV( A, V ) ATTRF( A, 4, (V)[0], (V)[1], (V)[2], (V)[3] ) -#define ATTR1F( A, X ) ATTR( A, 1, GL_FLOAT, X, 0, 0, 1 ) -#define ATTR2F( A, X, Y ) ATTR( A, 2, GL_FLOAT, X, Y, 0, 1 ) -#define ATTR3F( A, X, Y, Z ) ATTR( A, 3, GL_FLOAT, X, Y, Z, 1 ) -#define ATTR4F( A, X, Y, Z, W ) ATTR( A, 4, GL_FLOAT, X, Y, Z, W ) +#define ATTR1F( A, X ) ATTRF( A, 1, X, 0, 0, 1 ) +#define ATTR2F( A, X, Y ) ATTRF( A, 2, X, Y, 0, 1 ) +#define ATTR3F( A, X, Y, Z ) ATTRF( A, 3, X, Y, Z, 1 ) +#define ATTR4F( A, X, Y, Z, W ) ATTRF( A, 4, X, Y, Z, W ) -/* int */ -#define ATTRI( A, N, X, Y, Z, W) ATTR( A, N, GL_INT, \ - X, Y, Z, W ) +/* int */ #define ATTR2IV( A, V ) ATTRI( A, 2, (V)[0], (V)[1], 0, 1 ) #define ATTR3IV( A, V ) ATTRI( A, 3, (V)[0], (V)[1], (V)[2], 1 ) #define ATTR4IV( A, V ) ATTRI( A, 4, (V)[0], (V)[1], (V)[2], (V)[3] ) @@ -70,9 +65,6 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. /* uint */ -#define ATTRUI( A, N, X, Y, Z, W) ATTR( A, N, GL_UNSIGNED_INT, \ - X, Y, Z, W ) - #define ATTR2UIV( A, V ) ATTRUI( A, 2, (V)[0], (V)[1], 0, 1 ) #define ATTR3UIV( A, V ) ATTRUI( A, 3, (V)[0], (V)[1], (V)[2], 1 ) #define ATTR4UIV( A, V ) ATTRUI( A, 4, (V)[0], (V)[1], (V)[2], (V)[3] ) @@ -82,7 +74,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. #define ATTR3UI( A, X, Y, Z ) ATTRUI( A, 3, X, Y, Z, 1 ) #define ATTR4UI( A, X, Y, Z, W ) ATTRUI( A, 4, X, Y, Z, W ) -#define MAT_ATTR( A, N, V ) ATTR( A, N, GL_FLOAT, (V)[0], (V)[1], (V)[2], (V)[3] ) +#define MAT_ATTR( A, N, V ) ATTRF( A, N, (V)[0], (V)[1], (V)[2], (V)[3] ) static inline float conv_ui10_to_norm_float(unsigned ui10) { @@ -94,20 +86,20 @@ static inline float conv_ui2_to_norm_float(unsigned ui2) return ui2 / 3.0f; } -#define ATTRUI10_1( A, UI ) ATTR( A, 1, GL_FLOAT, (UI) & 0x3ff, 0, 0, 1 ) -#define ATTRUI10_2( A, UI ) ATTR( A, 2, GL_FLOAT, (UI) & 0x3ff, ((UI) >> 10) & 0x3ff, 0, 1 ) -#define ATTRUI10_3( A, UI ) ATTR( A, 3, GL_FLOAT, (UI) & 0x3ff, ((UI) >> 10) & 0x3ff, ((UI) >> 20) & 0x3ff, 1 ) -#define ATTRUI10_4( A, UI ) ATTR( A, 4, GL_FLOAT, (UI) & 0x3ff, ((UI) >> 10) & 0x3ff, ((UI) >> 20) & 0x3ff, ((UI) >> 30) & 0x3 ) +#define ATTRUI10_1( A, UI ) ATTRF( A, 1, (UI) & 0x3ff, 0, 0, 1 ) +#define ATTRUI10_2( A, UI ) ATTRF( A, 2, (UI) & 0x3ff, ((UI) >> 10) & 0x3ff, 0, 1 ) +#define ATTRUI10_3( A, UI ) ATTRF( A, 3, (UI) & 0x3ff, ((UI) >> 10) & 0x3ff, ((UI) >> 20) & 0x3ff, 1 ) +#define ATTRUI10_4( A, UI ) ATTRF( A, 4, (UI) & 0x3ff, ((UI) >> 10) & 0x3ff, ((UI) >> 20) & 0x3ff, ((UI) >> 30) & 0x3 ) -#define ATTRUI10N_1( A, UI ) ATTR( A, 1, GL_FLOAT, conv_ui10_to_norm_float((UI) & 0x3ff), 0, 0, 1 ) -#define ATTRUI10N_2( A, UI ) ATTR( A, 2, GL_FLOAT, \ +#define ATTRUI10N_1( A, UI ) ATTRF( A, 1, conv_ui10_to_norm_float((UI) & 0x3ff), 0, 0, 1 ) +#define ATTRUI10N_2( A, UI ) ATTRF( A, 2, \ conv_ui10_to_norm_float((UI) & 0x3ff), \ conv_ui10_to_norm_float(((UI) >> 10) & 0x3ff), 0, 1 ) -#define ATTRUI10N_3( A, UI ) ATTR( A, 3, GL_FLOAT, \ +#define ATTRUI10N_3( A, UI ) ATTRF( A, 3, \ conv_ui10_to_norm_float((UI) & 0x3ff), \ conv_ui10_to_norm_float(((UI) >> 10) & 0x3ff), \ conv_ui10_to_norm_float(((UI) >> 20) & 0x3ff), 1 ) -#define ATTRUI10N_4( A, UI ) ATTR( A, 4, GL_FLOAT, \ +#define ATTRUI10N_4( A, UI ) ATTRF( A, 4, \ conv_ui10_to_norm_float((UI) & 0x3ff), \ conv_ui10_to_norm_float(((UI) >> 10) & 0x3ff), \ conv_ui10_to_norm_float(((UI) >> 20) & 0x3ff), \ @@ -180,30 +172,30 @@ static inline float conv_i2_to_norm_float(const struct gl_context *ctx, int i2) } } -#define ATTRI10_1( A, I10 ) ATTR( A, 1, GL_FLOAT, conv_i10_to_i((I10) & 0x3ff), 0, 0, 1 ) -#define ATTRI10_2( A, I10 ) ATTR( A, 2, GL_FLOAT, \ +#define ATTRI10_1( A, I10 ) ATTRF( A, 1, conv_i10_to_i((I10) & 0x3ff), 0, 0, 1 ) +#define ATTRI10_2( A, I10 ) ATTRF( A, 2, \ conv_i10_to_i((I10) & 0x3ff), \ conv_i10_to_i(((I10) >> 10) & 0x3ff), 0, 1 ) -#define ATTRI10_3( A, I10 ) ATTR( A, 3, GL_FLOAT, \ +#define ATTRI10_3( A, I10 ) ATTRF( A, 3, \ conv_i10_to_i((I10) & 0x3ff), \ conv_i10_to_i(((I10) >> 10) & 0x3ff), \ conv_i10_to_i(((I10) >> 20) & 0x3ff), 1 ) -#define ATTRI10_4( A, I10 ) ATTR( A, 4, GL_FLOAT, \ +#define ATTRI10_4( A, I10 ) ATTRF( A, 4, \ conv_i10_to_i((I10) & 0x3ff), \ conv_i10_to_i(((I10) >> 10) & 0x3ff), \ conv_i10_to_i(((I10) >> 20) & 0x3ff), \ conv_i2_to_i(((I10) >> 30) & 0x3)) -#define ATTRI10N_1(ctx, A, I10) ATTR(A, 1, GL_FLOAT, conv_i10_to_norm_float(ctx, (I10) & 0x3ff), 0, 0, 1 ) -#define ATTRI10N_2(ctx, A, I10) ATTR(A, 2, GL_FLOAT, \ +#define ATTRI10N_1(ctx, A, I10) ATTRF(A, 1, conv_i10_to_norm_float(ctx, (I10) & 0x3ff), 0, 0, 1 ) +#define ATTRI10N_2(ctx, A, I10) ATTRF(A, 2, \ conv_i10_to_norm_float(ctx, (I10) & 0x3ff), \ conv_i10_to_norm_float(ctx, ((I10) >> 10) & 0x3ff), 0, 1 ) -#define ATTRI10N_3(ctx, A, I10) ATTR(A, 3, GL_FLOAT, \ +#define ATTRI10N_3(ctx, A, I10) ATTRF(A, 3, \ conv_i10_to_norm_float(ctx, (I10) & 0x3ff), \ conv_i10_to_norm_float(ctx, ((I10) >> 10) & 0x3ff), \ conv_i10_to_norm_float(ctx, ((I10) >> 20) & 0x3ff), 1 ) -#define ATTRI10N_4(ctx, A, I10) ATTR(A, 4, GL_FLOAT, \ +#define ATTRI10N_4(ctx, A, I10) ATTRF(A, 4, \ conv_i10_to_norm_float(ctx, (I10) & 0x3ff), \ conv_i10_to_norm_float(ctx, ((I10) >> 10) & 0x3ff), \ conv_i10_to_norm_float(ctx, ((I10) >> 20) & 0x3ff), \ diff --git a/src/mesa/vbo/vbo_exec_api.c b/src/mesa/vbo/vbo_exec_api.c index 9669abe..02741c2 100644 --- a/src/mesa/vbo/vbo_exec_api.c +++ b/src/mesa/vbo/vbo_exec_api.c @@ -1239,7 +1239,7 @@ VertexAttrib4f_nopos(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w) { GET_CURRENT_CONTEXT(ctx); if (index < MAX_VERTEX_GENERIC_ATTRIBS) - ATTR(VBO_ATTRIB_GENERIC0 + index, 4, GL_FLOAT, x, y, z, w); + ATTRF(VBO_ATTRIB_GENERIC0 + index, 4, x, y, z, w); else ERROR(GL_INVALID_VALUE); } From brianp at kemper.freedesktop.org Wed Mar 11 15:41:07 2015 From: brianp at kemper.freedesktop.org (Brian Paul) Date: Wed, 11 Mar 2015 08:41:07 -0700 (PDT) Subject: Mesa (master): i915: add parens to silence operator precedence warning Message-ID: <20150311154107.9079976333@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 14ba6c9325229270d3f04c13253ca547f9a216ff URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=14ba6c9325229270d3f04c13253ca547f9a216ff Author: Brian Paul Date: Tue Mar 10 08:18:27 2015 -0600 i915: add parens to silence operator precedence warning Signed-off-by: Brian Paul --- src/mesa/drivers/dri/i915/i915_debug_fp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesa/drivers/dri/i915/i915_debug_fp.c b/src/mesa/drivers/dri/i915/i915_debug_fp.c index 3f09902..d107c5a 100644 --- a/src/mesa/drivers/dri/i915/i915_debug_fp.c +++ b/src/mesa/drivers/dri/i915/i915_debug_fp.c @@ -303,7 +303,7 @@ i915_disassemble_program(const GLuint * program, GLuint sz) printf("\t\tBEGIN\n"); - assert(program[0] & 0x1ff + 2 == sz); + assert((program[0] & 0x1ff) + 2 == sz); program++; for (i = 1; i < sz; i += 3, program += 3) { From brianp at kemper.freedesktop.org Wed Mar 11 15:41:07 2015 From: brianp at kemper.freedesktop.org (Brian Paul) Date: Wed, 11 Mar 2015 08:41:07 -0700 (PDT) Subject: Mesa (master): st/glx: use strdup() instead of _mesa_strdup() Message-ID: <20150311154107.A1D9576333@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 5376bc74ccfac0d1a4df6c5652e075d99e3f4fe4 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=5376bc74ccfac0d1a4df6c5652e075d99e3f4fe4 Author: Brian Paul Date: Sat Mar 7 13:15:22 2015 -0700 st/glx: use strdup() instead of _mesa_strdup() Reviewed-by: Jose Fonseca Reviewed-by: Ian Romanick --- src/gallium/state_trackers/glx/xlib/glx_api.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gallium/state_trackers/glx/xlib/glx_api.c b/src/gallium/state_trackers/glx/xlib/glx_api.c index d1bd760..f9572b7 100644 --- a/src/gallium/state_trackers/glx/xlib/glx_api.c +++ b/src/gallium/state_trackers/glx/xlib/glx_api.c @@ -34,6 +34,7 @@ #include "GL/glx.h" #include +#include #include #include @@ -644,7 +645,7 @@ register_with_display(Display *dpy) ext = dpy->ext_procs; /* new extension is at head of list */ assert(c->extension == ext->codes.extension); (void) c; - ext->name = _mesa_strdup(extName); + ext->name = strdup(extName); ext->close_display = close_display_callback; } } From brianp at kemper.freedesktop.org Wed Mar 11 15:41:07 2015 From: brianp at kemper.freedesktop.org (Brian Paul) Date: Wed, 11 Mar 2015 08:41:07 -0700 (PDT) Subject: Mesa (master): mesa: remove CPU_TO_LE32() for AIX Message-ID: <20150311154107.C28A176333@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 9816acff2ca570e248652fe05ac4ee3ce02bd2ab URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=9816acff2ca570e248652fe05ac4ee3ce02bd2ab Author: Brian Paul Date: Sun Mar 8 16:46:39 2015 -0600 mesa: remove CPU_TO_LE32() for AIX This is the only remnant of AIX-specific code in Mesa. Probably long unused. Reviewed-by: Ian Romanick --- src/mesa/main/compiler.h | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/mesa/main/compiler.h b/src/mesa/main/compiler.h index 06c4b5c..6fded88 100644 --- a/src/mesa/main/compiler.h +++ b/src/mesa/main/compiler.h @@ -98,14 +98,6 @@ extern "C" { #elif defined(__APPLE__) #include #define CPU_TO_LE32( x ) CFSwapInt32HostToLittle( x ) -#elif (defined(_AIX)) -static inline GLuint CPU_TO_LE32(GLuint x) -{ - return (((x & 0x000000ff) << 24) | - ((x & 0x0000ff00) << 8) | - ((x & 0x00ff0000) >> 8) | - ((x & 0xff000000) >> 24)); -} #elif defined(__OpenBSD__) #include #define CPU_TO_LE32( x ) htole32( x ) From brianp at kemper.freedesktop.org Wed Mar 11 15:41:07 2015 From: brianp at kemper.freedesktop.org (Brian Paul) Date: Wed, 11 Mar 2015 08:41:07 -0700 (PDT) Subject: Mesa (master): xlib: use strdup() instead of _mesa_strdup() Message-ID: <20150311154107.98BFB7633D@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 279c5965aa501e6b8f8432b1213f917298154d6c URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=279c5965aa501e6b8f8432b1213f917298154d6c Author: Brian Paul Date: Sat Mar 7 13:15:22 2015 -0700 xlib: use strdup() instead of _mesa_strdup() Reviewed-by: Jose Fonseca Reviewed-by: Ian Romanick --- src/mesa/drivers/x11/fakeglx.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/mesa/drivers/x11/fakeglx.c b/src/mesa/drivers/x11/fakeglx.c index 3869e94..4fd6d75 100644 --- a/src/mesa/drivers/x11/fakeglx.c +++ b/src/mesa/drivers/x11/fakeglx.c @@ -40,6 +40,7 @@ */ +#include #include #include "glxheader.h" #include "glxapi.h" @@ -846,7 +847,7 @@ register_with_display(Display *dpy) ext = dpy->ext_procs; /* new extension is at head of list */ assert(c->extension == ext->codes.extension); (void) c; /* silence warning */ - ext->name = _mesa_strdup(extName); + ext->name = strdup(extName); ext->close_display = close_display_callback; } } From brianp at kemper.freedesktop.org Wed Mar 11 15:41:07 2015 From: brianp at kemper.freedesktop.org (Brian Paul) Date: Wed, 11 Mar 2015 08:41:07 -0700 (PDT) Subject: Mesa (master): mesa: use strdup() instead of _mesa_strdup() Message-ID: <20150311154107.AD9A176333@kemper.freedesktop.org> Module: Mesa Branch: master Commit: d7193ce42cedc4cc7839fc4522edf5724e954c80 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=d7193ce42cedc4cc7839fc4522edf5724e954c80 Author: Brian Paul Date: Sat Mar 7 13:15:22 2015 -0700 mesa: use strdup() instead of _mesa_strdup() We were already using strdup() in various places in Mesa. Get rid of the _mesa_strdup() wrapper. All the callers pass a non-NULL argument so the NULL check isn't needed either. Reviewed-by: Jose Fonseca Reviewed-by: Ian Romanick --- src/mesa/main/imports.c | 18 ------------------ src/mesa/main/imports.h | 3 --- src/mesa/main/objectlabel.c | 2 +- src/mesa/main/shaderapi.c | 2 +- src/mesa/main/transformfeedback.c | 2 +- src/mesa/program/prog_instruction.c | 2 +- src/mesa/program/prog_parameter.c | 2 +- src/mesa/program/prog_statevars.c | 2 +- src/mesa/program/program.c | 6 +++--- 9 files changed, 9 insertions(+), 30 deletions(-) diff --git a/src/mesa/main/imports.c b/src/mesa/main/imports.c index a7ffe22..ac8deeb 100644 --- a/src/mesa/main/imports.c +++ b/src/mesa/main/imports.c @@ -481,24 +481,6 @@ _mesa_half_to_float(GLhalfARB val) /** \name String */ /*@{*/ -/** - * Implemented using malloc() and strcpy. - * Note that NULL is handled accordingly. - */ -char * -_mesa_strdup( const char *s ) -{ - if (s) { - size_t l = strlen(s); - char *s2 = malloc(l + 1); - if (s2) - strcpy(s2, s); - return s2; - } - else { - return NULL; - } -} /** Compute simple checksum/hash for a string */ unsigned int diff --git a/src/mesa/main/imports.h b/src/mesa/main/imports.h index 7921000..ee6b399 100644 --- a/src/mesa/main/imports.h +++ b/src/mesa/main/imports.h @@ -448,9 +448,6 @@ _mesa_half_is_negative(GLhalfARB h) return h & 0x8000; } -extern char * -_mesa_strdup( const char *s ); - extern unsigned int _mesa_str_checksum(const char *str); diff --git a/src/mesa/main/objectlabel.c b/src/mesa/main/objectlabel.c index 78df96b..aecb5b1 100644 --- a/src/mesa/main/objectlabel.c +++ b/src/mesa/main/objectlabel.c @@ -76,7 +76,7 @@ set_label(struct gl_context *ctx, char **labelPtr, const char *label, MAX_LABEL_LENGTH); /* null-terminated string */ - *labelPtr = _mesa_strdup(label); + *labelPtr = strdup(label); } } } diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c index 5731d58..3ea76af 100644 --- a/src/mesa/main/shaderapi.c +++ b/src/mesa/main/shaderapi.c @@ -1460,7 +1460,7 @@ read_shader(const char *fname) fclose(f); - shader = _mesa_strdup(buffer); + shader = strdup(buffer); free(buffer); return shader; diff --git a/src/mesa/main/transformfeedback.c b/src/mesa/main/transformfeedback.c index a3e23ce..ce678c8 100644 --- a/src/mesa/main/transformfeedback.c +++ b/src/mesa/main/transformfeedback.c @@ -762,7 +762,7 @@ _mesa_TransformFeedbackVaryings(GLuint program, GLsizei count, /* Save the new names and the count */ for (i = 0; i < count; i++) { - shProg->TransformFeedback.VaryingNames[i] = _mesa_strdup(varyings[i]); + shProg->TransformFeedback.VaryingNames[i] = strdup(varyings[i]); } shProg->TransformFeedback.NumVarying = count; diff --git a/src/mesa/program/prog_instruction.c b/src/mesa/program/prog_instruction.c index 6a9bcb7..f9ebe4e 100644 --- a/src/mesa/program/prog_instruction.c +++ b/src/mesa/program/prog_instruction.c @@ -89,7 +89,7 @@ _mesa_copy_instructions(struct prog_instruction *dest, memcpy(dest, src, n * sizeof(struct prog_instruction)); for (i = 0; i < n; i++) { if (src[i].Comment) - dest[i].Comment = _mesa_strdup(src[i].Comment); + dest[i].Comment = strdup(src[i].Comment); } return dest; } diff --git a/src/mesa/program/prog_parameter.c b/src/mesa/program/prog_parameter.c index 5939f6f..cdfe251 100644 --- a/src/mesa/program/prog_parameter.c +++ b/src/mesa/program/prog_parameter.c @@ -148,7 +148,7 @@ _mesa_add_parameter(struct gl_program_parameter_list *paramList, for (i = 0; i < sz4; i++) { struct gl_program_parameter *p = paramList->Parameters + oldNum + i; - p->Name = name ? _mesa_strdup(name) : NULL; + p->Name = name ? strdup(name) : NULL; p->Type = type; p->Size = size; p->DataType = datatype; diff --git a/src/mesa/program/prog_statevars.c b/src/mesa/program/prog_statevars.c index 57b25a7..0c0c87f 100644 --- a/src/mesa/program/prog_statevars.c +++ b/src/mesa/program/prog_statevars.c @@ -1045,7 +1045,7 @@ _mesa_program_state_string(const gl_state_index state[STATE_LENGTH]) break; } - return _mesa_strdup(str); + return strdup(str); } diff --git a/src/mesa/program/program.c b/src/mesa/program/program.c index 61a9e97..3c214d5 100644 --- a/src/mesa/program/program.c +++ b/src/mesa/program/program.c @@ -79,7 +79,7 @@ _mesa_init_program(struct gl_context *ctx) STATIC_ASSERT(NUM_TEXTURE_TARGETS <= (1 << 4)); ctx->Program.ErrorPos = -1; - ctx->Program.ErrorString = _mesa_strdup(""); + ctx->Program.ErrorString = strdup(""); ctx->VertexProgram.Enabled = GL_FALSE; ctx->VertexProgram.PointSizeEnabled = @@ -176,7 +176,7 @@ _mesa_set_program_error(struct gl_context *ctx, GLint pos, const char *string) free((void *) ctx->Program.ErrorString); if (!string) string = ""; - ctx->Program.ErrorString = _mesa_strdup(string); + ctx->Program.ErrorString = strdup(string); } @@ -483,7 +483,7 @@ _mesa_clone_program(struct gl_context *ctx, const struct gl_program *prog) assert(clone->Target == prog->Target); assert(clone->RefCount == 1); - clone->String = (GLubyte *) _mesa_strdup((char *) prog->String); + clone->String = (GLubyte *) strdup((char *) prog->String); clone->Format = prog->Format; clone->Instructions = _mesa_alloc_instructions(prog->NumInstructions); if (!clone->Instructions) { From brianp at kemper.freedesktop.org Wed Mar 11 15:41:07 2015 From: brianp at kemper.freedesktop.org (Brian Paul) Date: Wed, 11 Mar 2015 08:41:07 -0700 (PDT) Subject: Mesa (master): mesa: remove #define __volatile Message-ID: <20150311154107.B89CF76333@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 3158b3abb34abc9f61e4b5161411e5e83640d42d URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=3158b3abb34abc9f61e4b5161411e5e83640d42d Author: Brian Paul Date: Sun Mar 8 16:44:28 2015 -0600 mesa: remove #define __volatile Not actually used anwhere in Mesa. Reviewed-by: Ian Romanick --- src/mesa/main/compiler.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/mesa/main/compiler.h b/src/mesa/main/compiler.h index 95581fb..06c4b5c 100644 --- a/src/mesa/main/compiler.h +++ b/src/mesa/main/compiler.h @@ -57,9 +57,6 @@ extern "C" { # elif !defined(__sparc__) && defined(__sparc) # define __sparc__ # endif -# if !defined(__volatile) -# define __volatile volatile -# endif #endif From mattst88 at kemper.freedesktop.org Wed Mar 11 21:21:16 2015 From: mattst88 at kemper.freedesktop.org (Matt Turner) Date: Wed, 11 Mar 2015 14:21:16 -0700 (PDT) Subject: Mesa (master): nir: Optimize a + neg(a) Message-ID: <20150311212116.6E9A77633D@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 8fb8fe46fa565dceedacd95287c836004b0fade2 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=8fb8fe46fa565dceedacd95287c836004b0fade2 Author: Thomas Helland Date: Sat Feb 28 20:32:32 2015 +0100 nir: Optimize a + neg(a) Shader-db i965 instructions: total instructions in shared programs: 1711180 -> 1711159 (-0.00%) instructions in affected programs: 825 -> 804 (-2.55%) helped: 9 HURT: 0 GAINED: 3 LOST: 3 Shader-db NIR instructions: total instructions in shared programs: 606187 -> 606179 (-0.00%) instructions in affected programs: 298 -> 290 (-2.68%) helped: 4 HURT: 0 GAINED: 0 LOST: 0 Reviewed-by: Matt Turner Reviewed-by: Jason Ekstrand Signed-off-by: Thomas Helland --- src/glsl/nir/nir_opt_algebraic.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/glsl/nir/nir_opt_algebraic.py b/src/glsl/nir/nir_opt_algebraic.py index 688ceff..ef855aa 100644 --- a/src/glsl/nir/nir_opt_algebraic.py +++ b/src/glsl/nir/nir_opt_algebraic.py @@ -58,6 +58,8 @@ optimizations = [ (('iadd', a, 0), a), (('fadd', ('fmul', a, b), ('fmul', a, c)), ('fmul', a, ('fadd', b, c))), (('iadd', ('imul', a, b), ('imul', a, c)), ('imul', a, ('iadd', b, c))), + (('fadd', ('fneg', a), a), 0.0), + (('iadd', ('ineg', a), a), 0), (('fmul', a, 0.0), 0.0), (('imul', a, 0), 0), (('fmul', a, 1.0), a), From mattst88 at kemper.freedesktop.org Wed Mar 11 21:21:16 2015 From: mattst88 at kemper.freedesktop.org (Matt Turner) Date: Wed, 11 Mar 2015 14:21:16 -0700 (PDT) Subject: Mesa (master): nir: Optimize (a*b)+(a*c) -> a*(b+c) Message-ID: <20150311212116.6504576333@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 0525f2e851f5f6f53b5f83c8dcdfa48f9838133b URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=0525f2e851f5f6f53b5f83c8dcdfa48f9838133b Author: Thomas Helland Date: Sat Feb 28 20:32:31 2015 +0100 nir: Optimize (a*b)+(a*c) -> a*(b+c) Shader-db i965 instructions: total instructions in shared programs: 1715894 -> 1710802 (-0.30%) instructions in affected programs: 443080 -> 437988 (-1.15%) helped: 1502 HURT: 13 GAINED: 4 LOST: 4 Shader-db NIR instructions: total instructions in shared programs: 607710 -> 606187 (-0.25%) instructions in affected programs: 208285 -> 206762 (-0.73%) helped: 769 HURT: 8 GAINED: 0 LOST: 0 Reviewed-by: Matt Turner Reviewed-by: Jason Ekstrand Signed-off-by: Thomas Helland --- src/glsl/nir/nir_opt_algebraic.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/glsl/nir/nir_opt_algebraic.py b/src/glsl/nir/nir_opt_algebraic.py index 7bf6431..688ceff 100644 --- a/src/glsl/nir/nir_opt_algebraic.py +++ b/src/glsl/nir/nir_opt_algebraic.py @@ -56,6 +56,8 @@ optimizations = [ (('iabs', ('ineg', a)), ('iabs', a)), (('fadd', a, 0.0), a), (('iadd', a, 0), a), + (('fadd', ('fmul', a, b), ('fmul', a, c)), ('fmul', a, ('fadd', b, c))), + (('iadd', ('imul', a, b), ('imul', a, c)), ('imul', a, ('iadd', b, c))), (('fmul', a, 0.0), 0.0), (('imul', a, 0), 0), (('fmul', a, 1.0), a), From jekstrand at kemper.freedesktop.org Wed Mar 11 22:18:35 2015 From: jekstrand at kemper.freedesktop.org (Jason Ekstrand) Date: Wed, 11 Mar 2015 15:18:35 -0700 (PDT) Subject: Mesa (master): nir/worklist: Don' t change the start index when computing the tail index Message-ID: <20150311221836.01C7076333@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 90e50908d7f080d91f41d889cfe0dc67134971eb URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=90e50908d7f080d91f41d889cfe0dc67134971eb Author: Jason Ekstrand Date: Mon Mar 2 17:59:38 2015 -0800 nir/worklist: Don't change the start index when computing the tail index Reviewed-by: Mark Janes --- src/glsl/nir/nir_worklist.c | 10 +++++----- src/glsl/nir/nir_worklist.h | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/glsl/nir/nir_worklist.c b/src/glsl/nir/nir_worklist.c index a8baae9..3087a1d 100644 --- a/src/glsl/nir/nir_worklist.c +++ b/src/glsl/nir/nir_worklist.c @@ -82,7 +82,7 @@ nir_block_worklist_push_head(nir_block_worklist *w, nir_block *block) } nir_block * -nir_block_worklist_peek_head(nir_block_worklist *w) +nir_block_worklist_peek_head(const nir_block_worklist *w) { assert(w->count > 0); @@ -114,18 +114,18 @@ nir_block_worklist_push_tail(nir_block_worklist *w, nir_block *block) w->count++; - unsigned tail = w->start = (w->start + w->count - 1) % w->size; + unsigned tail = (w->start + w->count - 1) % w->size; w->blocks[tail] = block; BITSET_SET(w->blocks_present, block->index); } nir_block * -nir_block_worklist_peek_tail(nir_block_worklist *w) +nir_block_worklist_peek_tail(const nir_block_worklist *w) { assert(w->count > 0); - unsigned tail = w->start = (w->start + w->count - 1) % w->size; + unsigned tail = (w->start + w->count - 1) % w->size; return w->blocks[tail]; } @@ -135,7 +135,7 @@ nir_block_worklist_pop_tail(nir_block_worklist *w) { assert(w->count > 0); - unsigned tail = w->start = (w->start + w->count - 1) % w->size; + unsigned tail = (w->start + w->count - 1) % w->size; w->count--; diff --git a/src/glsl/nir/nir_worklist.h b/src/glsl/nir/nir_worklist.h index d5a8568..829bff2 100644 --- a/src/glsl/nir/nir_worklist.h +++ b/src/glsl/nir/nir_worklist.h @@ -74,13 +74,13 @@ nir_block_worklist_is_empty(const nir_block_worklist *w) void nir_block_worklist_push_head(nir_block_worklist *w, nir_block *block); -nir_block *nir_block_worklist_peek_head(nir_block_worklist *w); +nir_block *nir_block_worklist_peek_head(const nir_block_worklist *w); nir_block *nir_block_worklist_pop_head(nir_block_worklist *w); void nir_block_worklist_push_tail(nir_block_worklist *w, nir_block *block); -nir_block *nir_block_worklist_peek_tail(nir_block_worklist *w); +nir_block *nir_block_worklist_peek_tail(const nir_block_worklist *w); nir_block *nir_block_worklist_pop_tail(nir_block_worklist *w); From evelikov at kemper.freedesktop.org Wed Mar 11 23:25:28 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Wed, 11 Mar 2015 16:25:28 -0700 (PDT) Subject: Mesa (master): configure: require pthreads for POSIX builds Message-ID: <20150311232528.9FF3476333@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 39f90e6b9bb0c9c8b40abae2afde07587cd49010 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=39f90e6b9bb0c9c8b40abae2afde07587cd49010 Author: Emil Velikov Date: Fri Mar 6 16:54:57 2015 +0000 configure: require pthreads for POSIX builds This has been an implicit rule for building mesa for a long time. Let's make it official and just bail out at configure time. This way we can cleaning up some of our glx code. Signed-off-by: Emil Velikov Reviewed-by: Brian Paul --- configure.ac | 3 +++ 1 file changed, 3 insertions(+) diff --git a/configure.ac b/configure.ac index 2954f80..a3b0ebd 100644 --- a/configure.ac +++ b/configure.ac @@ -658,6 +658,9 @@ mingw*) ;; *) AX_PTHREAD + if test "x$ax_pthread_ok" = xno; then + AC_MSG_ERROR([Building mesa on this platform requires pthreads]) + fi ;; esac dnl AX_PTHREADS leaves PTHREAD_LIBS empty for gcc and sets PTHREAD_CFLAGS From evelikov at kemper.freedesktop.org Wed Mar 11 23:25:28 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Wed, 11 Mar 2015 16:25:28 -0700 (PDT) Subject: Mesa (master): egl/main: use c11/threads' mutex directly Message-ID: <20150311232528.8D21376333@kemper.freedesktop.org> Module: Mesa Branch: master Commit: efe87f1a801c61d087cd2b29a2c150453241c3d4 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=efe87f1a801c61d087cd2b29a2c150453241c3d4 Author: Emil Velikov Date: Fri Mar 6 16:54:55 2015 +0000 egl/main: use c11/threads' mutex directly Remove the inline wrappers/abstraction layer. Signed-off-by: Emil Velikov Reviewed-by: Brian Paul --- src/egl/main/Makefile.sources | 1 - src/egl/main/eglapi.c | 14 +++++---- src/egl/main/eglcurrent.c | 13 ++++---- src/egl/main/egldisplay.c | 13 ++++---- src/egl/main/egldisplay.h | 4 +-- src/egl/main/egldriver.c | 8 ++--- src/egl/main/eglglobals.c | 9 +++--- src/egl/main/eglglobals.h | 4 +-- src/egl/main/egllog.c | 18 +++++------ src/egl/main/eglmutex.h | 66 ----------------------------------------- src/egl/main/eglscreen.c | 8 ++--- 11 files changed, 47 insertions(+), 111 deletions(-) diff --git a/src/egl/main/Makefile.sources b/src/egl/main/Makefile.sources index 6a917e2..75f060a 100644 --- a/src/egl/main/Makefile.sources +++ b/src/egl/main/Makefile.sources @@ -26,7 +26,6 @@ LIBEGL_C_FILES := \ eglmisc.h \ eglmode.c \ eglmode.h \ - eglmutex.h \ eglscreen.c \ eglscreen.h \ eglstring.c \ diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c index 2258830..a74efcd 100644 --- a/src/egl/main/eglapi.c +++ b/src/egl/main/eglapi.c @@ -87,6 +87,8 @@ #include #include #include "c99_compat.h" +#include "c11/threads.h" +#include "eglcompiler.h" #include "eglglobals.h" #include "eglcontext.h" @@ -275,7 +277,7 @@ _eglLockDisplay(EGLDisplay display) { _EGLDisplay *dpy = _eglLookupDisplay(display); if (dpy) - _eglLockMutex(&dpy->Mutex); + mtx_lock(&dpy->Mutex); return dpy; } @@ -286,7 +288,7 @@ _eglLockDisplay(EGLDisplay display) static inline void _eglUnlockDisplay(_EGLDisplay *dpy) { - _eglUnlockMutex(&dpy->Mutex); + mtx_unlock(&dpy->Mutex); } @@ -896,7 +898,7 @@ eglWaitClient(void) RETURN_EGL_SUCCESS(NULL, EGL_TRUE); disp = ctx->Resource.Display; - _eglLockMutex(&disp->Mutex); + mtx_lock(&disp->Mutex); /* let bad current context imply bad current surface */ if (_eglGetContextHandle(ctx) == EGL_NO_CONTEXT || @@ -942,7 +944,7 @@ eglWaitNative(EGLint engine) RETURN_EGL_SUCCESS(NULL, EGL_TRUE); disp = ctx->Resource.Display; - _eglLockMutex(&disp->Mutex); + mtx_lock(&disp->Mutex); /* let bad current context imply bad current surface */ if (_eglGetContextHandle(ctx) == EGL_NO_CONTEXT || @@ -1457,10 +1459,10 @@ eglReleaseThread(void) t->CurrentAPIIndex = i; - _eglLockMutex(&disp->Mutex); + mtx_lock(&disp->Mutex); drv = disp->Driver; (void) drv->API.MakeCurrent(drv, disp, NULL, NULL, NULL); - _eglUnlockMutex(&disp->Mutex); + mtx_unlock(&disp->Mutex); } } diff --git a/src/egl/main/eglcurrent.c b/src/egl/main/eglcurrent.c index 3d49641..dc32ed4 100644 --- a/src/egl/main/eglcurrent.c +++ b/src/egl/main/eglcurrent.c @@ -31,7 +31,6 @@ #include "c99_compat.h" #include "egllog.h" -#include "eglmutex.h" #include "eglcurrent.h" #include "eglglobals.h" @@ -47,7 +46,7 @@ static _EGLThreadInfo dummy_thread = _EGL_THREAD_INFO_INITIALIZER; #if HAVE_PTHREAD #include -static _EGLMutex _egl_TSDMutex = _EGL_MUTEX_INITIALIZER; +static mtx_t _egl_TSDMutex = _MTX_INITIALIZER_NP; static EGLBoolean _egl_TSDInitialized; static pthread_key_t _egl_TSD; static void (*_egl_FreeTSD)(_EGLThreadInfo *); @@ -76,7 +75,7 @@ static inline _EGLThreadInfo *_eglGetTSD(void) static inline void _eglFiniTSD(void) { - _eglLockMutex(&_egl_TSDMutex); + mtx_lock(&_egl_TSDMutex); if (_egl_TSDInitialized) { _EGLThreadInfo *t = _eglGetTSD(); @@ -85,18 +84,18 @@ static inline void _eglFiniTSD(void) _egl_FreeTSD((void *) t); pthread_key_delete(_egl_TSD); } - _eglUnlockMutex(&_egl_TSDMutex); + mtx_unlock(&_egl_TSDMutex); } static inline EGLBoolean _eglInitTSD(void (*dtor)(_EGLThreadInfo *)) { if (!_egl_TSDInitialized) { - _eglLockMutex(&_egl_TSDMutex); + mtx_lock(&_egl_TSDMutex); /* check again after acquiring lock */ if (!_egl_TSDInitialized) { if (pthread_key_create(&_egl_TSD, (void (*)(void *)) dtor) != 0) { - _eglUnlockMutex(&_egl_TSDMutex); + mtx_unlock(&_egl_TSDMutex); return EGL_FALSE; } _egl_FreeTSD = dtor; @@ -104,7 +103,7 @@ static inline EGLBoolean _eglInitTSD(void (*dtor)(_EGLThreadInfo *)) _egl_TSDInitialized = EGL_TRUE; } - _eglUnlockMutex(&_egl_TSDMutex); + mtx_unlock(&_egl_TSDMutex); } return EGL_TRUE; diff --git a/src/egl/main/egldisplay.c b/src/egl/main/egldisplay.c index a167ae5..b7a5b8f 100644 --- a/src/egl/main/egldisplay.c +++ b/src/egl/main/egldisplay.c @@ -35,13 +35,14 @@ #include #include #include +#include "c11/threads.h" + #include "eglcontext.h" #include "eglcurrent.h" #include "eglsurface.h" #include "egldisplay.h" #include "egldriver.h" #include "eglglobals.h" -#include "eglmutex.h" #include "egllog.h" /* Includes for _eglNativePlatformDetectNativeDisplay */ @@ -260,7 +261,7 @@ _eglFindDisplay(_EGLPlatformType plat, void *plat_dpy) if (plat == _EGL_INVALID_PLATFORM) return NULL; - _eglLockMutex(_eglGlobal.Mutex); + mtx_lock(_eglGlobal.Mutex); /* search the display list first */ dpy = _eglGlobal.DisplayList; @@ -274,7 +275,7 @@ _eglFindDisplay(_EGLPlatformType plat, void *plat_dpy) if (!dpy) { dpy = calloc(1, sizeof(_EGLDisplay)); if (dpy) { - _eglInitMutex(&dpy->Mutex); + mtx_init(&dpy->Mutex, mtx_plain); dpy->Platform = plat; dpy->PlatformDisplay = plat_dpy; @@ -284,7 +285,7 @@ _eglFindDisplay(_EGLPlatformType plat, void *plat_dpy) } } - _eglUnlockMutex(_eglGlobal.Mutex); + mtx_unlock(_eglGlobal.Mutex); return dpy; } @@ -344,14 +345,14 @@ _eglCheckDisplayHandle(EGLDisplay dpy) { _EGLDisplay *cur; - _eglLockMutex(_eglGlobal.Mutex); + mtx_lock(_eglGlobal.Mutex); cur = _eglGlobal.DisplayList; while (cur) { if (cur == (_EGLDisplay *) dpy) break; cur = cur->Next; } - _eglUnlockMutex(_eglGlobal.Mutex); + mtx_unlock(_eglGlobal.Mutex); return (cur != NULL); } diff --git a/src/egl/main/egldisplay.h b/src/egl/main/egldisplay.h index 9c3c8c7..5a845d8 100644 --- a/src/egl/main/egldisplay.h +++ b/src/egl/main/egldisplay.h @@ -32,10 +32,10 @@ #define EGLDISPLAY_INCLUDED #include "c99_compat.h" +#include "c11/threads.h" #include "egltypedefs.h" #include "egldefines.h" -#include "eglmutex.h" #include "eglarray.h" @@ -132,7 +132,7 @@ struct _egl_display /* used to link displays */ _EGLDisplay *Next; - _EGLMutex Mutex; + mtx_t Mutex; _EGLPlatformType Platform; /**< The type of the platform display */ void *PlatformDisplay; /**< A pointer to the platform display */ diff --git a/src/egl/main/egldriver.c b/src/egl/main/egldriver.c index e6a61f3..6983af9 100644 --- a/src/egl/main/egldriver.c +++ b/src/egl/main/egldriver.c @@ -37,13 +37,13 @@ #include #include #include +#include "c11/threads.h" #include "eglstring.h" #include "egldefines.h" #include "egldisplay.h" #include "egldriver.h" #include "egllog.h" -#include "eglmutex.h" #if defined(_EGL_OS_UNIX) #include @@ -63,7 +63,7 @@ typedef struct _egl_module { _EGLDriver *Driver; } _EGLModule; -static _EGLMutex _eglModuleMutex = _EGL_MUTEX_INITIALIZER; +static mtx_t _eglModuleMutex = _MTX_INITIALIZER_NP; static _EGLArray *_eglModules; const struct { @@ -616,7 +616,7 @@ _eglMatchDriver(_EGLDisplay *dpy, EGLBoolean test_only) assert(!dpy->Initialized); - _eglLockMutex(&_eglModuleMutex); + mtx_lock(&_eglModuleMutex); /* set options */ dpy->Options.TestOnly = test_only; @@ -628,7 +628,7 @@ _eglMatchDriver(_EGLDisplay *dpy, EGLBoolean test_only) best_drv = _eglMatchAndInitialize(dpy); } - _eglUnlockMutex(&_eglModuleMutex); + mtx_unlock(&_eglModuleMutex); if (best_drv) { _eglLog(_EGL_DEBUG, "the best driver is %s%s", diff --git a/src/egl/main/eglglobals.c b/src/egl/main/eglglobals.c index 56fe9e2..129bf29 100644 --- a/src/egl/main/eglglobals.c +++ b/src/egl/main/eglglobals.c @@ -30,13 +30,14 @@ #include #include +#include "c11/threads.h" + #include "eglglobals.h" #include "egldisplay.h" #include "egldriver.h" -#include "eglmutex.h" -static _EGLMutex _eglGlobalMutex = _EGL_MUTEX_INITIALIZER; +static mtx_t _eglGlobalMutex = _MTX_INITIALIZER_NP; struct _egl_global _eglGlobal = { @@ -84,7 +85,7 @@ _eglAddAtExitCall(void (*func)(void)) if (func) { static EGLBoolean registered = EGL_FALSE; - _eglLockMutex(_eglGlobal.Mutex); + mtx_lock(_eglGlobal.Mutex); if (!registered) { atexit(_eglAtExit); @@ -94,6 +95,6 @@ _eglAddAtExitCall(void (*func)(void)) assert(_eglGlobal.NumAtExitCalls < ARRAY_SIZE(_eglGlobal.AtExitCalls)); _eglGlobal.AtExitCalls[_eglGlobal.NumAtExitCalls++] = func; - _eglUnlockMutex(_eglGlobal.Mutex); + mtx_unlock(_eglGlobal.Mutex); } } diff --git a/src/egl/main/eglglobals.h b/src/egl/main/eglglobals.h index a8cf6d6..04b9609 100644 --- a/src/egl/main/eglglobals.h +++ b/src/egl/main/eglglobals.h @@ -32,9 +32,9 @@ #define EGLGLOBALS_INCLUDED #include +#include "c11/threads.h" #include "egltypedefs.h" -#include "eglmutex.h" /** @@ -42,7 +42,7 @@ */ struct _egl_global { - _EGLMutex *Mutex; + mtx_t *Mutex; /* the list of all displays */ _EGLDisplay *DisplayList; diff --git a/src/egl/main/egllog.c b/src/egl/main/egllog.c index babab07..1877d8b 100644 --- a/src/egl/main/egllog.c +++ b/src/egl/main/egllog.c @@ -38,24 +38,24 @@ #include #include #include +#include "c11/threads.h" #include "egllog.h" #include "eglstring.h" -#include "eglmutex.h" #define MAXSTRING 1000 #define FALLBACK_LOG_LEVEL _EGL_WARNING static struct { - _EGLMutex mutex; + mtx_t mutex; EGLBoolean initialized; EGLint level; _EGLLogProc logger; EGLint num_messages; } logging = { - _EGL_MUTEX_INITIALIZER, + _MTX_INITIALIZER_NP, EGL_FALSE, FALLBACK_LOG_LEVEL, NULL, @@ -82,7 +82,7 @@ _eglSetLogProc(_EGLLogProc logger) { EGLint num_messages = 0; - _eglLockMutex(&logging.mutex); + mtx_lock(&logging.mutex); if (logging.logger != logger) { logging.logger = logger; @@ -91,7 +91,7 @@ _eglSetLogProc(_EGLLogProc logger) logging.num_messages = 0; } - _eglUnlockMutex(&logging.mutex); + mtx_unlock(&logging.mutex); if (num_messages) _eglLog(_EGL_DEBUG, @@ -111,9 +111,9 @@ _eglSetLogLevel(EGLint level) case _EGL_WARNING: case _EGL_INFO: case _EGL_DEBUG: - _eglLockMutex(&logging.mutex); + mtx_lock(&logging.mutex); logging.level = level; - _eglUnlockMutex(&logging.mutex); + mtx_unlock(&logging.mutex); break; default: break; @@ -188,7 +188,7 @@ _eglLog(EGLint level, const char *fmtStr, ...) if (level > logging.level || level < 0) return; - _eglLockMutex(&logging.mutex); + mtx_lock(&logging.mutex); if (logging.logger) { va_start(args, fmtStr); @@ -201,7 +201,7 @@ _eglLog(EGLint level, const char *fmtStr, ...) logging.num_messages++; } - _eglUnlockMutex(&logging.mutex); + mtx_unlock(&logging.mutex); if (level == _EGL_FATAL) exit(1); /* or abort()? */ diff --git a/src/egl/main/eglmutex.h b/src/egl/main/eglmutex.h deleted file mode 100644 index b58f0e3..0000000 --- a/src/egl/main/eglmutex.h +++ /dev/null @@ -1,66 +0,0 @@ -/************************************************************************** - * - * Copyright 2009 Chia-I Wu - * 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 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. - * - **************************************************************************/ - - -#ifndef EGLMUTEX_INCLUDED -#define EGLMUTEX_INCLUDED - -#include "c99_compat.h" - -#include "eglcompiler.h" - -#include "c11/threads.h" - -typedef mtx_t _EGLMutex; - -static inline void _eglInitMutex(_EGLMutex *m) -{ - mtx_init(m, mtx_plain); -} - -static inline void -_eglDestroyMutex(_EGLMutex *m) -{ - mtx_destroy(m); -} - -static inline void -_eglLockMutex(_EGLMutex *m) -{ - mtx_lock(m); -} - -static inline void -_eglUnlockMutex(_EGLMutex *m) -{ - mtx_unlock(m); -} - -#define _EGL_MUTEX_INITIALIZER _MTX_INITIALIZER_NP - - -#endif /* EGLMUTEX_INCLUDED */ diff --git a/src/egl/main/eglscreen.c b/src/egl/main/eglscreen.c index b8f2b39..42ac621 100644 --- a/src/egl/main/eglscreen.c +++ b/src/egl/main/eglscreen.c @@ -44,20 +44,20 @@ #include #include #include +#include "c11/threads.h" #include "egldisplay.h" #include "eglcurrent.h" #include "eglmode.h" #include "eglsurface.h" #include "eglscreen.h" -#include "eglmutex.h" #ifdef EGL_MESA_screen_surface /* ugh, no atomic op? */ -static _EGLMutex _eglNextScreenHandleMutex = _EGL_MUTEX_INITIALIZER; +static mtx_t _eglNextScreenHandleMutex = _MTX_INITIALIZER_NP; static EGLScreenMESA _eglNextScreenHandle = 1; @@ -70,10 +70,10 @@ _eglAllocScreenHandle(void) { EGLScreenMESA s; - _eglLockMutex(&_eglNextScreenHandleMutex); + mtx_lock(&_eglNextScreenHandleMutex); s = _eglNextScreenHandle; _eglNextScreenHandle += _EGL_SCREEN_MAX_MODES; - _eglUnlockMutex(&_eglNextScreenHandleMutex); + mtx_unlock(&_eglNextScreenHandleMutex); return s; } From evelikov at kemper.freedesktop.org Wed Mar 11 23:25:28 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Wed, 11 Mar 2015 16:25:28 -0700 (PDT) Subject: Mesa (master): egl/main: convert thread management to use c11 threads Message-ID: <20150311232528.965317633D@kemper.freedesktop.org> Module: Mesa Branch: master Commit: a806df3f23cd5fadffbfe818f8c5af7e17205426 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=a806df3f23cd5fadffbfe818f8c5af7e17205426 Author: Emil Velikov Date: Fri Mar 6 16:54:56 2015 +0000 egl/main: convert thread management to use c11 threads Convert the code to use the C11 threads implementation, and nuke the Windows non-pthreads code-path. The c11/threads_win32.h abstraction should be better than the current code. Signed-off-by: Emil Velikov Reviewed-by: Brian Paul --- src/egl/main/eglcurrent.c | 48 ++++++--------------------------------------- 1 file changed, 6 insertions(+), 42 deletions(-) diff --git a/src/egl/main/eglcurrent.c b/src/egl/main/eglcurrent.c index dc32ed4..5d8cae4 100644 --- a/src/egl/main/eglcurrent.c +++ b/src/egl/main/eglcurrent.c @@ -29,6 +29,7 @@ #include #include #include "c99_compat.h" +#include "c11/threads.h" #include "egllog.h" #include "eglcurrent.h" @@ -41,14 +42,9 @@ /* a fallback thread info to guarantee that every thread always has one */ static _EGLThreadInfo dummy_thread = _EGL_THREAD_INFO_INITIALIZER; - - -#if HAVE_PTHREAD -#include - static mtx_t _egl_TSDMutex = _MTX_INITIALIZER_NP; static EGLBoolean _egl_TSDInitialized; -static pthread_key_t _egl_TSD; +static tss_t _egl_TSD; static void (*_egl_FreeTSD)(_EGLThreadInfo *); #ifdef GLX_USE_TLS @@ -58,7 +54,7 @@ static __thread const _EGLThreadInfo *_egl_TLS static inline void _eglSetTSD(const _EGLThreadInfo *t) { - pthread_setspecific(_egl_TSD, (const void *) t); + tss_set(_egl_TSD, (const void *) t); #ifdef GLX_USE_TLS _egl_TLS = t; #endif @@ -69,7 +65,7 @@ static inline _EGLThreadInfo *_eglGetTSD(void) #ifdef GLX_USE_TLS return (_EGLThreadInfo *) _egl_TLS; #else - return (_EGLThreadInfo *) pthread_getspecific(_egl_TSD); + return (_EGLThreadInfo *) tss_get(_egl_TSD); #endif } @@ -82,7 +78,7 @@ static inline void _eglFiniTSD(void) _egl_TSDInitialized = EGL_FALSE; if (t && _egl_FreeTSD) _egl_FreeTSD((void *) t); - pthread_key_delete(_egl_TSD); + tss_delete(_egl_TSD); } mtx_unlock(&_egl_TSDMutex); } @@ -94,7 +90,7 @@ static inline EGLBoolean _eglInitTSD(void (*dtor)(_EGLThreadInfo *)) /* check again after acquiring lock */ if (!_egl_TSDInitialized) { - if (pthread_key_create(&_egl_TSD, (void (*)(void *)) dtor) != 0) { + if (tss_create(&_egl_TSD, (void (*)(void *)) dtor) != thrd_success) { mtx_unlock(&_egl_TSDMutex); return EGL_FALSE; } @@ -109,38 +105,6 @@ static inline EGLBoolean _eglInitTSD(void (*dtor)(_EGLThreadInfo *)) return EGL_TRUE; } -#else /* HAVE_PTHREAD */ -static const _EGLThreadInfo *_egl_TSD; -static void (*_egl_FreeTSD)(_EGLThreadInfo *); - -static inline void _eglSetTSD(const _EGLThreadInfo *t) -{ - _egl_TSD = t; -} - -static inline _EGLThreadInfo *_eglGetTSD(void) -{ - return (_EGLThreadInfo *) _egl_TSD; -} - -static inline void _eglFiniTSD(void) -{ - if (_egl_FreeTSD && _egl_TSD) - _egl_FreeTSD((_EGLThreadInfo *) _egl_TSD); -} - -static inline EGLBoolean _eglInitTSD(void (*dtor)(_EGLThreadInfo *)) -{ - if (!_egl_FreeTSD && dtor) { - _egl_FreeTSD = dtor; - _eglAddAtExitCall(_eglFiniTSD); - } - return EGL_TRUE; -} - -#endif /* !HAVE_PTHREAD */ - - static void _eglInitThreadInfo(_EGLThreadInfo *t) { From evelikov at kemper.freedesktop.org Wed Mar 11 23:25:28 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Wed, 11 Mar 2015 16:25:28 -0700 (PDT) Subject: Mesa (master): glx: remove final reference to THREADS Message-ID: <20150311232528.AACCD76333@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 42144170d189d2539a4fb2243200e760114af9f7 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=42144170d189d2539a4fb2243200e760114af9f7 Author: Emil Velikov Date: Fri Mar 6 16:54:58 2015 +0000 glx: remove final reference to THREADS Left over from commit 18db13f5865(mapi: THREADS was always defined, remove it) Signed-off-by: Emil Velikov Reviewed-by: Brian Paul --- src/glx/glxcurrent.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/glx/glxcurrent.c b/src/glx/glxcurrent.c index dc2acd5..86fb658 100644 --- a/src/glx/glxcurrent.c +++ b/src/glx/glxcurrent.c @@ -138,10 +138,6 @@ __glXGetCurrentContext(void) # endif /* defined( GLX_USE_TLS ) */ -#elif defined( THREADS ) - -#error Unknown threading method specified. - #else /* not thread safe */ From evelikov at kemper.freedesktop.org Wed Mar 11 23:25:28 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Wed, 11 Mar 2015 16:25:28 -0700 (PDT) Subject: Mesa (master): glx: remove support for non-multithreaded platforms Message-ID: <20150311232528.B66A376333@kemper.freedesktop.org> Module: Mesa Branch: master Commit: a385d18598b28bf935e4460b86ce3f9e095a8015 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=a385d18598b28bf935e4460b86ce3f9e095a8015 Author: Emil Velikov Date: Fri Mar 6 16:54:59 2015 +0000 glx: remove support for non-multithreaded platforms Implicitly required for a while, although commit 9385c592c68 (mapi: remove u_thread.h) was the one that put the final nail on the coffin. Signed-off-by: Emil Velikov Reviewed-by: Brian Paul --- docs/dispatch.html | 5 ++--- src/glx/glxclient.h | 18 +----------------- src/glx/glxcurrent.c | 11 ----------- src/glx/tests/fake_glx_screen.cpp | 2 +- 4 files changed, 4 insertions(+), 32 deletions(-) diff --git a/docs/dispatch.html b/docs/dispatch.html index aacd01e..c96ec2d 100644 --- a/docs/dispatch.html +++ b/docs/dispatch.html @@ -204,9 +204,8 @@ terribly relevant.

        few preprocessor defines.

          -
        • If GLX_USE_TLS is defined, method #4 is used.
        • -
        • If HAVE_PTHREAD is defined, method #3 is used.
        • -
        • If WIN32_THREADS is defined, method #2 is used.
        • +
        • If GLX_USE_TLS is defined, method #3 is used.
        • +
        • If HAVE_PTHREAD is defined, method #2 is used.
        • If none of the preceding are defined, method #1 is used.
        diff --git a/src/glx/glxclient.h b/src/glx/glxclient.h index 122ae5d..2776b44 100644 --- a/src/glx/glxclient.h +++ b/src/glx/glxclient.h @@ -48,12 +48,10 @@ #include #include #include +#include #include "GL/glxproto.h" #include "glxconfig.h" #include "glxhash.h" -#if defined( HAVE_PTHREAD ) -# include -#endif #include "util/macros.h" #include "glxextensions.h" @@ -629,7 +627,6 @@ extern void __glXPreferEGL(int state); extern int __glXDebug; /* This is per-thread storage in an MT environment */ -#if defined( HAVE_PTHREAD ) extern void __glXSetCurrentContext(struct glx_context * c); @@ -646,14 +643,6 @@ extern struct glx_context *__glXGetCurrentContext(void); # endif /* defined( GLX_USE_TLS ) */ -#else - -extern struct glx_context *__glXcurrentContext; -#define __glXGetCurrentContext() __glXcurrentContext -#define __glXSetCurrentContext(gc) __glXcurrentContext = gc - -#endif /* defined( HAVE_PTHREAD ) */ - extern void __glXSetCurrentContextNull(void); @@ -661,14 +650,9 @@ extern void __glXSetCurrentContextNull(void); ** Global lock for all threads in this address space using the GLX ** extension */ -#if defined( HAVE_PTHREAD ) extern pthread_mutex_t __glXmutex; #define __glXLock() pthread_mutex_lock(&__glXmutex) #define __glXUnlock() pthread_mutex_unlock(&__glXmutex) -#else -#define __glXLock() -#define __glXUnlock() -#endif /* ** Setup for a command. Initialize the extension for dpy if necessary. diff --git a/src/glx/glxcurrent.c b/src/glx/glxcurrent.c index 86fb658..7f47a42 100644 --- a/src/glx/glxcurrent.c +++ b/src/glx/glxcurrent.c @@ -33,9 +33,7 @@ * Client-side GLX interface for current context management. */ -#ifdef HAVE_PTHREAD #include -#endif #include "glxclient.h" @@ -67,8 +65,6 @@ struct glx_context dummyContext = { * Current context management and locking */ -#if defined( HAVE_PTHREAD ) - _X_HIDDEN pthread_mutex_t __glXmutex = PTHREAD_MUTEX_INITIALIZER; # if defined( GLX_USE_TLS ) @@ -138,13 +134,6 @@ __glXGetCurrentContext(void) # endif /* defined( GLX_USE_TLS ) */ -#else - -/* not thread safe */ -_X_HIDDEN struct glx_context *__glXcurrentContext = &dummyContext; - -#endif - _X_HIDDEN void __glXSetCurrentContextNull(void) diff --git a/src/glx/tests/fake_glx_screen.cpp b/src/glx/tests/fake_glx_screen.cpp index ccb1afa..db20749 100644 --- a/src/glx/tests/fake_glx_screen.cpp +++ b/src/glx/tests/fake_glx_screen.cpp @@ -77,7 +77,7 @@ indirect_create_context_attribs(struct glx_screen *base, __thread void *__glX_tls_Context = NULL; -#if defined(HAVE_PTHREAD) && !defined(GLX_USE_TLS) +#if !defined(GLX_USE_TLS) extern "C" struct glx_context * __glXGetCurrentContext() { From evelikov at kemper.freedesktop.org Wed Mar 11 23:25:28 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Wed, 11 Mar 2015 16:25:28 -0700 (PDT) Subject: Mesa (master): autogen.sh: pass --force to autoreconf, quote ORIGDIR Message-ID: <20150311232528.C0C0E76333@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 30916a5ef008a84e53d9821ccc11a0dee50fe77b URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=30916a5ef008a84e53d9821ccc11a0dee50fe77b Author: Emil Velikov Date: Mon Mar 9 11:46:07 2015 +0000 autogen.sh: pass --force to autoreconf, quote ORIGDIR By passing --force autoreconf will update all the aux files, which would otherwise be ignored if one updates autoconf/automake. Quote the ORIGDIR variable to prevent fall-outs, when its name contains space. Signed-off-by: Emil Velikov Reviewed-by: Matt Turner --- autogen.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/autogen.sh b/autogen.sh index 626d213..c896097 100755 --- a/autogen.sh +++ b/autogen.sh @@ -6,8 +6,8 @@ test -z "$srcdir" && srcdir=. ORIGDIR=`pwd` cd "$srcdir" -autoreconf -v --install || exit 1 -cd $ORIGDIR || exit $? +autoreconf --force --verbose --install || exit 1 +cd "$ORIGDIR" || exit $? if test -z "$NOCONFIGURE"; then "$srcdir"/configure "$@" From jrfonseca at kemper.freedesktop.org Thu Mar 12 10:02:08 2015 From: jrfonseca at kemper.freedesktop.org (Jose Fonseca) Date: Thu, 12 Mar 2015 03:02:08 -0700 (PDT) Subject: Mesa (master): gallivm: Prevent double delete on LLVM 3.6 Message-ID: <20150312100208.237C476333@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 70dc8a9930f561d7ce6db7e58b5bc9b4d940e37b URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=70dc8a9930f561d7ce6db7e58b5bc9b4d940e37b Author: Jose Fonseca Date: Thu Mar 12 09:57:43 2015 +0000 gallivm: Prevent double delete on LLVM 3.6 std::unique_ptr takes ownership of MM, and a double delete could ensure in case of an error, as pointed out by Chris Vine in https://bugs.freedesktop.org/show_bug.cgi?id=89387 Reviewed-by: Chris Vine --- src/gallium/auxiliary/gallivm/lp_bld_misc.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp b/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp index e2578cf..d60db91 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp +++ b/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp @@ -502,6 +502,7 @@ lp_build_create_jit_compiler_for_module(LLVMExecutionEngineRef *OutJIT, #if HAVE_LLVM >= 0x0306 builder.setMCJITMemoryManager(std::unique_ptr(MM)); + MM = NULL; // onwership taken by std::unique_ptr #else builder.setMCJITMemoryManager(MM); #endif From evelikov at kemper.freedesktop.org Thu Mar 12 13:10:30 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Thu, 12 Mar 2015 06:10:30 -0700 (PDT) Subject: Mesa (10.5): 30 new commits Message-ID: <20150312131030.620A476333@kemper.freedesktop.org> URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=ce13666feba564b850d326ef05b6fc05c6435c6b Author: Rob Clark Date: Tue Feb 10 04:42:32 2015 -0500 freedreno/ir3: fix failed assert in grouping Turns out there are scenarios where we need to insert mov's in "front" of an input. Triggered by shaders like: VERT DCL IN[0] DCL IN[1] DCL OUT[0], POSITION DCL OUT[1], GENERIC[9] DCL SAMP[0] DCL TEMP[0], LOCAL 0: MOV TEMP[0].xy, IN[1].xyyy 1: MOV TEMP[0].w, IN[1].wwww 2: TXF TEMP[0], TEMP[0], SAMP[0], 1D_ARRAY 3: MOV OUT[1], TEMP[0] 4: MOV OUT[0], IN[0] 5: END Signed-off-by: Rob Clark (cherry picked from commit 27648efa2070e8db111908314d8b924d3717dbb0) URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=065a24bd969b3e7d429d72ae328dbfa6affd9455 Author: Rob Clark Date: Wed Feb 25 13:54:25 2015 -0500 freedreno/ir3: handle flat bypass for a4xx We may not need this for later a4xx patchlevels, but we do at least need this for patchlevel 0. Bypass bary.f for fetching varyings when flat shading is needed (rather than configure via cmdstream). This requires a special dummy bary.f w/ (ei) flag to signal to scheduler when all varyings are consumed. And requires shader variants based on rasterizer flatshade state to handle TGSI_INTERPOLATE_COLOR. Signed-off-by: Rob Clark (cherry picked from commit e9f2abe349886ae5423c7c31d201e7d587a3695a) URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=1dec8bbb8e2971ac0cd55dee279ce10ae22242f1 Author: Rob Clark Date: Thu Feb 26 15:13:10 2015 -0500 freedreno/ir3: add support for memory (cat6) instructions Scheduled basically the same as texture (cat5) instructions, using (sy) flag for synchronization. Signed-off-by: Rob Clark (cherry picked from commit 9d732d3125e1b39788a642a5723aeb54cb1983f3) URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=af4d1096f7e82c7759692ac1b83678d3c8029f4c Author: Rob Clark Date: Thu Feb 26 13:35:31 2015 -0500 freedreno/ir3: fix up cat6 instruction encodings I think there is at least one more sub-encoding, but these two should be enough to cover the common load/store instructions. Signed-off-by: Rob Clark (cherry picked from commit 20b50a071271e2caf8a4c3d4fd72f877af8a18d9) URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=645d7f464b669f24c81fb2d78ad3f6f317e8a8c3 Author: Rob Clark Date: Tue Feb 24 11:55:28 2015 -0500 freedreno/a4xx: aniso filtering Signed-off-by: Rob Clark (cherry picked from commit dd70e786747f7e4800f4bba245373c5ffa3baeee) URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=80c4ba0c8351ceb45e99686ce4b54a3cd1c869ca Author: Rob Clark Date: Tue Feb 24 11:48:01 2015 -0500 freedreno: update generated headers Signed-off-by: Rob Clark (cherry picked from commit c70097ae8655d84a900cb27d165ca59d66411e29) URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=aca5fdae061ed5f1ebf3762f71d2f2d3beb25c39 Author: Rob Clark Date: Sat Feb 21 13:55:37 2015 -0500 freedreno/a4xx: set PC_PRIM_VTX_CNTL.VAROUT properly Fixes xonotic, some webgl stuff, and really pretty much anything with more than 4 varyings. Signed-off-by: Rob Clark (cherry picked from commit 51e335742e55d6725fd5c4558158769a32f70f22) URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=7abc57b66921186feb2e013b345b0f1b70364bf3 Author: Rob Clark Date: Sat Feb 21 13:50:52 2015 -0500 freedreno: update generated headers Signed-off-by: Rob Clark (cherry picked from commit fb1301e40abbac1de973563cacd2c7f31aa6bb4f) Conflicts: src/gallium/drivers/freedreno/a3xx/a3xx.xml.h URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=20ea65beb3ecb45419a45528dc3b7e8bd20bd0e6 Author: Rob Clark Date: Sat Feb 21 13:39:06 2015 -0500 freedreno/a4xx: bit of cleanup Signed-off-by: Rob Clark (cherry picked from commit bdf023482a6fd07adef090fb66a4aaaac22810fc) URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=38777e1345f2471f5889b1f145539e3d5d7a59c7 Author: Rob Clark Date: Tue Feb 3 15:52:53 2015 -0500 freedreno/a2xx: fix increment in assert Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=88883 Signed-off-by: Rob Clark (cherry picked from commit 68552266535747bad1eff34d856c43158398b9bf) URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=4de2f250830ec119d13153da4651a9c06079555e Author: Iago Toral Quiroga Date: Tue Mar 10 11:36:43 2015 +0100 i965: Fix out-of-bounds accesses into pull_constant_loc array The piglit test glsl-fs-uniform-array-loop-unroll.shader_test was designed to do an out of bounds access into an uniform array to make sure that we handle that situation gracefully inside the driver, however, as Ken describes in bug 79202, Valgrind reports that this is leading to an out-of-bounds access in fs_visitor::demote_pull_constants(). Before accessing the pull_constant_loc array we should make sure that the uniform we are trying to access is valid. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=79202 Reviewed-by: Matt Turner (cherry picked from commit 6ac1bc90c4a7a6f32901a9782e14b090f6fe5270) Nominated-by: Matt Turner URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=fbd06fe65c0fe57f0dea96c87d9f0eb5abc72bb7 Author: Kenneth Graunke Date: Thu Feb 26 17:45:49 2015 -0800 i965/fs: Don't issue FB writes for bound but unwritten color targets. We used to loop over all color attachments, and emit FB writes for each one, even if the shader didn't write to a corresponding output variable. Those color attachments would be filled with garbage (undefined values). Football Manager binds a framebuffer with 4 color attachments, but draws to it using a shader that only writes to gl_FragData[0..2]. This meant that color attachment 3 would be filled with garbage, resulting in rendering artifacts. Now we skip writing to it, fixing rendering. Writes to gl_FragColor initialize outputs[0..nr_color_regions-1] to GRFs, while writes to gl_FragData[i] initialize outputs[i]. Thanks to Jason Ekstrand for tracking this down. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=86747 Signed-off-by: Kenneth Graunke Reviewed-by: Jason Ekstrand Cc: mesa-stable at lists.freedesktop.org (cherry picked from commit e95969cd9548033250ba12f2adf11740319b41e7) Conflicts: src/mesa/drivers/dri/i965/brw_fs_visitor.cpp URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=c232d765affc06cc6e81ddee07656919e7f17aa5 Author: Kenneth Graunke Date: Thu Feb 26 22:55:54 2015 -0800 i965/fs: Make emit_shader_time_end() insert before EOT. Previously, we emitted the shader-time epilogue from emit_fb_writes(), during the middle of looping through color regions (or emit_urb_writes for the VS). This is duplicated several times and rather awkward. I need to fix a bug in our FB write handling, and it will be a lot easier if we move emit_shader_time_end() out of there. Now, we simply emit FB writes/URB writes, and subsequently have emit_shader_time_end() insert instructions before the final SEND with EOT. Not only is this simpler, it's actually a slight improvement: we now include the MOVs to set up the final FB write payload in our shader-time measurements. Note that INTEL_DEBUG=shader_time only exists on Gen7+, and uses send-from-GRF. (In the past, we might have hit trouble where both attempt to use MRFs for messages; that's not a problem now.) v2: Rebase on v3 of the previous patch and other shader_time fixes. Signed-off-by: Kenneth Graunke Reviewed-by: Topi Pohjolainen [v1] Acked-by: Matt Turner Cc: mesa-stable at lists.freedesktop.org (cherry picked from commit 4ebeb71573ad44f7657810dc5dd2c9030e3e63db) Conflicts: src/mesa/drivers/dri/i965/brw_fs.cpp URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=0d625e1ae7a112fee1e5068b7817e07ee1a253e1 Author: Kenneth Graunke Date: Thu Feb 26 23:51:27 2015 -0800 i965/fs: Make get_timestamp() pass back the MOV rather than emitting it. This makes another part of the INTEL_DEBUG=shader_time code emittable at arbitrary locations, rather than just at the end of the instruction stream. v2: Don't lose smear! Caught by Topi Pohjolainen. v3: Don't set smear on the destination of the MOV. Thanks Topi! Signed-off-by: Kenneth Graunke Reviewed-by: Matt Turner Cc: mesa-stable at lists.freedesktop.org (cherry picked from commit e43af8d09f919d02b5ac0810c1c0f1783cbef6ef) URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=e9e182658dbb329e6a8e5b54794d173a878c9151 Author: Kenneth Graunke Date: Thu Feb 26 22:49:04 2015 -0800 i965/fs: Make emit_shader_time_write return rather than emit. Instead of emit_shader_time_write, we now do emit(SHADER_TIME_ADD(...)). The advantage is that we can also insert a shader time write at an arbitrary location in the instruction stream, rather than being restricted to emitting at the end. Signed-off-by: Kenneth Graunke Reviewed-by: Topi Pohjolainen Reviewed-by: Matt Turner Cc: mesa-stable at lists.freedesktop.org (cherry picked from commit bea854c7f33cc10b8292f931f114afc4f88a8dd4) URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=82ef4994ddc0222241b101bcda8e729e729d93b0 Author: Kenneth Graunke Date: Sun Mar 8 00:13:41 2015 -0800 i965/fs: Set smear on shader_time diff register. The ADD(diff, diff, fs_reg(-2u)) instruction reads diff, which is a width 1 register. We need to read it as <0,1,0> with a subreg of 0, which is what smear accomplishes. Fixes assertion: brw_eu_emit.c:285: validate_reg: Assertion `hstride == 0' failed. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=86974 Signed-off-by: Kenneth Graunke Reviewed-by: Matt Turner Cc: mesa-stable at lists.freedesktop.org (cherry picked from commit f1adc45dbe649cdd4538fb96f6d2a27328bbfba1) Conflicts: src/mesa/drivers/dri/i965/brw_fs.cpp URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=c3fc8b2870668fe0313fd35b2789306dbf3b9594 Author: Kenneth Graunke Date: Sat Mar 7 23:01:07 2015 -0800 i965/fs: Set force_writemask_all on shader_time instructions. These computations don't have anything to do with the currently executing channels, so they should use force_writemask_all. This fixes assert failures. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=86974 Signed-off-by: Kenneth Graunke Reviewed-by: Matt Turner Cc: mesa-stable at lists.freedesktop.org (cherry picked from commit ef9cc7d0c176669c03130abf576f2b700be39514) Conflicts: src/mesa/drivers/dri/i965/brw_fs.cpp URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=aea510a95fab2e3c2ddeca2a3b3aae349d1ec3dc Author: Marek Ol??k Date: Mon Mar 9 21:20:03 2015 +0100 r300g: fix sRGB->sRGB blits Cc: 10.5 10.4 (cherry picked from commit c939231e7223510408a446400ad23b8b5ce2922e) URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=c898d5c931ff9a19da93f2cc700bb92e02f60cfa Author: Marek Ol??k Date: Tue Feb 24 23:15:59 2015 +0100 r300g: fix a crash when resolving into an sRGB texture Cc: 10.5 10.4 (cherry picked from commit 9953586af2254f83a610d4cd284f52f37fa18b98) URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=32a7f119dc0e65574adfc56600d68dc79ec0c840 Author: Marek Ol??k Date: Mon Mar 9 20:04:04 2015 +0100 r300g: fix RGTC1 and LATC1 SNORM formats Cc: 10.5 10.4 (cherry picked from commit 74a757f92f7377f59c0feb7f84c7518f9a167631) URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=578ac079c77abbe9c972bb95ddb57abea7eeec99 Author: Stefan D?singer Date: Mon Mar 9 16:15:13 2015 +0100 r300g: Fix the ATI1N swizzle (RGTC1 and LATC1) This fixes the GL_COMPRESSED_RED_RGTC1 part of piglit's rgtc-teximage-01 test as well as the precision part of Wine's 3dc format test (fd.o bug 89156). The Z component seems to contain a lower precision version of the result, probably a temporary value from the decompression computation. The Y and W component contain different data that depends on the input values as well, but I could not make sense of them (Not that I tried very hard). GL_COMPRESSED_SIGNED_RED_RGTC1 still seems to have precision problems in piglit, and both formats are affected by a compiler bug if they're sampled by the shader with a swizzle other than .xyzw. Wine uses .xxxx, which returns random garbage. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=89156 Signed-off-by: Marek Ol??k Cc: 10.5 10.4 (cherry picked from commit f710b99071fe4e3c2ee88cdcb6bb5c10298e014e) URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=0ea3c150cfc273e66626c8dc0958269c68d9e739 Author: Rob Clark Date: Thu Mar 5 15:27:27 2015 -0500 freedreno/ir3: fix silly typo for binning pass shaders Was resulting in gl_PointSize write being optimized out, causing particle system type shaders to hang if hw binning enabled. Fixes neverball, OGLES2ParticleSystem, etc. Signed-off-by: Rob Clark (cherry picked from commit 60096ed906e5ebfdce41024c7af69f03b96dbe82) URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=b542424ab893ecfc3dbff4176d641fc0bacba203 Author: Ilia Mirkin Date: Sat Mar 7 18:25:54 2015 -0500 freedreno/ir3: get the # of miplevels from getinfo This fixes ARB_texture_query_levels to actually return the desired value. Signed-off-by: Ilia Mirkin Reviewed-by: Rob Clark Cc: "10.4 10.5" (cherry picked from commit cb3eb43ad690a7355429ba8dcd40120646c55b9c) URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=d8ed6aa4742b37d2fda95fa7e6bea584582569e4 Author: Ilia Mirkin Date: Sat Mar 7 17:41:47 2015 -0500 freedreno/ir3: fix array count returned by TXQ Signed-off-by: Ilia Mirkin Reviewed-by: Rob Clark Cc: "10.4 10.5" (cherry picked from commit 8ac957a51c67fc095db9539df6482b9533b1d05c) URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=5b1bd4fc9e442568bacdec3a7e9697a87968158d Author: Ilia Mirkin Date: Mon Mar 2 21:22:27 2015 -0500 freedreno: move fb state copy after checking for size change Fixes: 1f3ca56b ("freedreno: use util_copy_framebuffer_state()") Signed-off-by: Ilia Mirkin Reviewed-by: Rob Clark Cc: "10.4 10.5" (cherry picked from commit f3dfe6513c26d1ce50b3b0fc830d4d8ff7f6b922) URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=cddbb3a7ba632e525b5c5a57c39e78b1a926c70f Author: Kenneth Graunke Date: Thu Mar 5 23:18:36 2015 -0800 glsl: Mark array access when copying to a temporary for the ?: operator. Piglit's spec/glsl-1.20/compiler/structure-and-array-operations/ array-selection.vert test contains the following code: gl_Position = (pick_from_a_or_b ? a : b)[i]; where "a" and "b" are uniform vec4[2] variables. ast_to_hir creates a temporary vec4[2] variable, conditional_tmp, and generates an if-block to copy one or the other: (declare (temporary) (array vec4 2) conditional_tmp) (if (var_ref pick_from_a_or_b) ((assign () (var_ref conditional_tmp) (var_ref a))) ((assign () (var_ref conditional_tmp) (var_ref b)))) However, we failed to update max_array_access for "a" and "b", so it remained 0 - here, the whole array is being accessed. At link time, update_array_sizes() used this bogus information to change the types of "a" and "b" to vec4[1]. We then had assignments from a vec4[1] to a vec4[2], which is highly illegal. This tripped assertions in nir_split_var_copies with scalar VS. Signed-off-by: Kenneth Graunke Reviewed-by: Jason Ekstrand Cc: mesa-stable at lists.freedesktop.org (cherry picked from commit 9f1e250e77ebd9255bbd9a83bd68c9e4068c2aab) URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=e4d3bd685540e59cd7fe722ad6bd3a2c32f277ec Author: Neil Roberts Date: Wed Feb 25 15:33:08 2015 +0000 meta: Fix the y offset for 1D_ARRAY in _mesa_meta_pbo_TexSubImage The yoffset needs to be interpreted as a slice offset for 1D array textures. This patch implements that by moving the yoffset into zoffset similar to how it moves the height into depth. Reviewed-by: Jason Ekstrand Cc: "10.5" (cherry picked from commit 7286a6899176a8b26aa794097288eff941f5178c) URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=614e7ebdad0ea1e0f14773db195cfcb75f74558d Author: Neil Roberts Date: Thu Feb 26 12:53:50 2015 +0000 meta: Allow GL_UN/PACK_IMAGE_HEIGHT in _mesa_meta_pbo_Get/TexSubImage Now that a layered source PBO is interpreted as a single tall 2D image it's quite easy to accept the image height packing option by just creating an image that is tall enough to include the image padding. I'm not sure whether the image height property should affect 1D_ARRAY textures. My intuition and interpretation of the GL spec (which is a bit vague) would be that it shouldn't. However the software fallback path in Mesa uses the property for packing but not for unpacking. The binary NVidia driver uses it for both. This patch doesn't use it for either case so it is different from the software fallback. There is some discussion about this here: http://lists.freedesktop.org/archives/mesa-dev/2015-February/077925.html This is tested by the texsubimage Piglit test with the array and pbo arguments. Previously this test was skipping this code path because it always sets the image height. I've also tested it by modifying the getteximage-targets test. It wasn't using this code path before because it was using the default texture object so this code couldn't successfully create a frame buffer. I also modified it to add some image padding with the image height in the PBO. Reviewed-by: Jason Ekstrand Cc: "10.5" (cherry picked from commit a08bff1e98b8e630f8bdf341af1491cd99e7d104) URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=7f32fa0dcb7dcdc9cb28521c26ec93e48c198bfa Author: Neil Roberts Date: Thu Feb 26 12:12:15 2015 +0000 Revert "common: Fix PBOs for 1D_ARRAY." This reverts commit 546aba143d13ba3f993ead4cc30b2404abfc0202. I think the changes to the calls to glBlitFramebuffer from this patch are no different to what it was doing previously because it used to set height to 1 before doing the blits. However it was introducing some problems with the blit for layer 0 because this was no longer special cased. It didn't fix problems with the yoffset which needs to be interpreted as a slice offset. I think a better solution would be to modify the original if statement to cope with the yoffset. Conflicts: src/mesa/drivers/common/meta_tex_subimage.c Cc: "10.5" Reviewed-by: Jason Ekstrand (cherry picked from commit 7d10d2feee381739eef97f4720cbadbd65bb4fc6) URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=a15de1ae1aa0a74f3caeb9f651430facefee8937 Author: Neil Roberts Date: Wed Feb 25 15:10:01 2015 +0000 meta: In pbo_{Get,}TexSubImage don't repeatedly rebind the source tex A layered PBO image is now interpreted as a single tall 2D image so the z argument in _mesa_meta_bind_fbo_image is ignored. Therefore this was just redundantly rebinding the same image repeatedly. Reviewed-by: Jason Ekstrand (cherry picked from commit a44606eb8164be2aa37eb288fd90894d74bd0935) From evelikov at kemper.freedesktop.org Thu Mar 12 13:11:38 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Thu, 12 Mar 2015 06:11:38 -0700 (PDT) Subject: Mesa (10.4): r300g: Fix the ATI1N swizzle (RGTC1 and LATC1) Message-ID: <20150312131138.3EF2276333@kemper.freedesktop.org> Module: Mesa Branch: 10.4 Commit: 80ef80d087bf48418a08cb7435ff10af2f49c4a9 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=80ef80d087bf48418a08cb7435ff10af2f49c4a9 Author: Stefan D?singer Date: Mon Mar 9 16:15:13 2015 +0100 r300g: Fix the ATI1N swizzle (RGTC1 and LATC1) This fixes the GL_COMPRESSED_RED_RGTC1 part of piglit's rgtc-teximage-01 test as well as the precision part of Wine's 3dc format test (fd.o bug 89156). The Z component seems to contain a lower precision version of the result, probably a temporary value from the decompression computation. The Y and W component contain different data that depends on the input values as well, but I could not make sense of them (Not that I tried very hard). GL_COMPRESSED_SIGNED_RED_RGTC1 still seems to have precision problems in piglit, and both formats are affected by a compiler bug if they're sampled by the shader with a swizzle other than .xyzw. Wine uses .xxxx, which returns random garbage. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=89156 Signed-off-by: Marek Ol??k Cc: 10.5 10.4 (cherry picked from commit f710b99071fe4e3c2ee88cdcb6bb5c10298e014e) --- src/gallium/drivers/r300/r300_texture.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/gallium/drivers/r300/r300_texture.c b/src/gallium/drivers/r300/r300_texture.c index ffe8c00..340b8fc 100644 --- a/src/gallium/drivers/r300/r300_texture.c +++ b/src/gallium/drivers/r300/r300_texture.c @@ -176,7 +176,9 @@ uint32_t r300_translate_texformat(enum pipe_format format, format != PIPE_FORMAT_RGTC2_UNORM && format != PIPE_FORMAT_RGTC2_SNORM && format != PIPE_FORMAT_LATC2_UNORM && - format != PIPE_FORMAT_LATC2_SNORM) { + format != PIPE_FORMAT_LATC2_SNORM && + format != PIPE_FORMAT_RGTC1_UNORM && + format != PIPE_FORMAT_LATC1_UNORM) { result |= r300_get_swizzle_combined(desc->swizzle, swizzle_view, TRUE); } else { From evelikov at kemper.freedesktop.org Thu Mar 12 13:11:38 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Thu, 12 Mar 2015 06:11:38 -0700 (PDT) Subject: Mesa (10.4): freedreno: move fb state copy after checking for size change Message-ID: <20150312131138.23B6D76333@kemper.freedesktop.org> Module: Mesa Branch: 10.4 Commit: 4db4f705467cfb7ec9c1955c1db782497a8bcf67 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=4db4f705467cfb7ec9c1955c1db782497a8bcf67 Author: Ilia Mirkin Date: Mon Mar 2 21:22:27 2015 -0500 freedreno: move fb state copy after checking for size change Fixes: 1f3ca56b ("freedreno: use util_copy_framebuffer_state()") Signed-off-by: Ilia Mirkin Reviewed-by: Rob Clark Cc: "10.4 10.5" (cherry picked from commit f3dfe6513c26d1ce50b3b0fc830d4d8ff7f6b922) --- src/gallium/drivers/freedreno/freedreno_state.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gallium/drivers/freedreno/freedreno_state.c b/src/gallium/drivers/freedreno/freedreno_state.c index 6293f43..77aa4f2 100644 --- a/src/gallium/drivers/freedreno/freedreno_state.c +++ b/src/gallium/drivers/freedreno/freedreno_state.c @@ -123,12 +123,12 @@ fd_set_framebuffer_state(struct pipe_context *pctx, fd_context_render(pctx); - util_copy_framebuffer_state(cso, framebuffer); - if ((cso->width != framebuffer->width) || (cso->height != framebuffer->height)) ctx->needs_rb_fbd = true; + util_copy_framebuffer_state(cso, framebuffer); + ctx->dirty |= FD_DIRTY_FRAMEBUFFER; ctx->disabled_scissor.minx = 0; From evelikov at kemper.freedesktop.org Thu Mar 12 13:11:38 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Thu, 12 Mar 2015 06:11:38 -0700 (PDT) Subject: Mesa (10.4): freedreno/ir3: fix array count returned by TXQ Message-ID: <20150312131138.2D7A976333@kemper.freedesktop.org> Module: Mesa Branch: 10.4 Commit: 025cf8cb3f12fab41299bedec88c9e64c5305a83 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=025cf8cb3f12fab41299bedec88c9e64c5305a83 Author: Ilia Mirkin Date: Sat Mar 7 17:41:47 2015 -0500 freedreno/ir3: fix array count returned by TXQ Signed-off-by: Ilia Mirkin Reviewed-by: Rob Clark Cc: "10.4 10.5" (cherry picked from commit 8ac957a51c67fc095db9539df6482b9533b1d05c) --- src/gallium/drivers/freedreno/ir3/ir3_compiler.c | 44 +++++++++++++++++++++- 1 file changed, 42 insertions(+), 2 deletions(-) diff --git a/src/gallium/drivers/freedreno/ir3/ir3_compiler.c b/src/gallium/drivers/freedreno/ir3/ir3_compiler.c index 2d7ea1c..fc63c10 100644 --- a/src/gallium/drivers/freedreno/ir3/ir3_compiler.c +++ b/src/gallium/drivers/freedreno/ir3/ir3_compiler.c @@ -1421,6 +1421,7 @@ trans_txq(const struct instr_translater *t, struct tgsi_dst_register *dst = &inst->Dst[0].Register; struct tgsi_src_register *level = &inst->Src[0].Register; struct tgsi_src_register *samp = &inst->Src[1].Register; + const struct target_info *tgt = &tex_targets[inst->Texture.Texture]; struct tex_info tinf; memset(&tinf, 0, sizeof(tinf)); @@ -1434,8 +1435,47 @@ trans_txq(const struct instr_translater *t, instr->cat5.tex = samp->Index; instr->flags |= tinf.flags; - add_dst_reg_wrmask(ctx, instr, dst, 0, dst->WriteMask); - add_src_reg_wrmask(ctx, instr, level, level->SwizzleX, 0x1); + if (tgt->array && (dst->WriteMask & (1 << tgt->dims))) { + /* Array size actually ends up in .w rather than .z. This doesn't + * matter for miplevel 0, but for higher mips the value in z is + * minified whereas w stays. Also, the value in TEX_CONST_3_DEPTH is + * returned, which means that we have to add 1 to it for arrays. + */ + struct tgsi_dst_register tmp_dst; + struct tgsi_src_register *tmp_src; + type_t type_mov = get_utype(ctx); + + tmp_src = get_internal_temp(ctx, &tmp_dst); + add_dst_reg_wrmask(ctx, instr, &tmp_dst, 0, + dst->WriteMask | TGSI_WRITEMASK_W); + add_src_reg_wrmask(ctx, instr, level, level->SwizzleX, 0x1); + + if (dst->WriteMask & TGSI_WRITEMASK_X) { + instr = instr_create(ctx, 1, 0); + instr->cat1.src_type = type_mov; + instr->cat1.dst_type = type_mov; + add_dst_reg(ctx, instr, dst, 0); + add_src_reg(ctx, instr, tmp_src, src_swiz(tmp_src, 0)); + } + + if (tgt->dims == 2) { + if (dst->WriteMask & TGSI_WRITEMASK_Y) { + instr = instr_create(ctx, 1, 0); + instr->cat1.src_type = type_mov; + instr->cat1.dst_type = type_mov; + add_dst_reg(ctx, instr, dst, 1); + add_src_reg(ctx, instr, tmp_src, src_swiz(tmp_src, 1)); + } + } + + instr = instr_create(ctx, 2, OPC_ADD_U); + add_dst_reg(ctx, instr, dst, tgt->dims); + add_src_reg(ctx, instr, tmp_src, src_swiz(tmp_src, 3)); + ir3_reg_create(instr, 0, IR3_REG_IMMED)->iim_val = 1; + } else { + add_dst_reg_wrmask(ctx, instr, dst, 0, dst->WriteMask); + add_src_reg_wrmask(ctx, instr, level, level->SwizzleX, 0x1); + } } /* DDX/DDY */ From evelikov at kemper.freedesktop.org Thu Mar 12 13:11:38 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Thu, 12 Mar 2015 06:11:38 -0700 (PDT) Subject: Mesa (10.4): freedreno/ir3: get the # of miplevels from getinfo Message-ID: <20150312131138.3736E76333@kemper.freedesktop.org> Module: Mesa Branch: 10.4 Commit: fa8bfb3ed17e5e08af2aba32ea25d6cb30d586e4 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=fa8bfb3ed17e5e08af2aba32ea25d6cb30d586e4 Author: Ilia Mirkin Date: Sat Mar 7 18:25:54 2015 -0500 freedreno/ir3: get the # of miplevels from getinfo This fixes ARB_texture_query_levels to actually return the desired value. Signed-off-by: Ilia Mirkin Reviewed-by: Rob Clark Cc: "10.4 10.5" (cherry picked from commit cb3eb43ad690a7355429ba8dcd40120646c55b9c) --- src/gallium/drivers/freedreno/ir3/ir3_compiler.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/gallium/drivers/freedreno/ir3/ir3_compiler.c b/src/gallium/drivers/freedreno/ir3/ir3_compiler.c index fc63c10..010ec6e 100644 --- a/src/gallium/drivers/freedreno/ir3/ir3_compiler.c +++ b/src/gallium/drivers/freedreno/ir3/ir3_compiler.c @@ -1476,6 +1476,26 @@ trans_txq(const struct instr_translater *t, add_dst_reg_wrmask(ctx, instr, dst, 0, dst->WriteMask); add_src_reg_wrmask(ctx, instr, level, level->SwizzleX, 0x1); } + + if (dst->WriteMask & TGSI_WRITEMASK_W) { + /* The # of levels comes from getinfo.z. We need to add 1 to it, since + * the value in TEX_CONST_0 is zero-based. + */ + struct tgsi_dst_register tmp_dst; + struct tgsi_src_register *tmp_src; + + tmp_src = get_internal_temp(ctx, &tmp_dst); + instr = instr_create(ctx, 5, OPC_GETINFO); + instr->cat5.type = get_utype(ctx); + instr->cat5.samp = samp->Index; + instr->cat5.tex = samp->Index; + add_dst_reg_wrmask(ctx, instr, &tmp_dst, 0, TGSI_WRITEMASK_Z); + + instr = instr_create(ctx, 2, OPC_ADD_U); + add_dst_reg(ctx, instr, dst, 3); + add_src_reg(ctx, instr, tmp_src, src_swiz(tmp_src, 2)); + ir3_reg_create(instr, 0, IR3_REG_IMMED)->iim_val = 1; + } } /* DDX/DDY */ From evelikov at kemper.freedesktop.org Thu Mar 12 13:11:38 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Thu, 12 Mar 2015 06:11:38 -0700 (PDT) Subject: Mesa (10.4): r300g: fix a crash when resolving into an sRGB texture Message-ID: <20150312131138.5F00C76333@kemper.freedesktop.org> Module: Mesa Branch: 10.4 Commit: b451a2ffbf22ee7edb93d204dc49e93093883aa7 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=b451a2ffbf22ee7edb93d204dc49e93093883aa7 Author: Marek Ol??k Date: Tue Feb 24 23:15:59 2015 +0100 r300g: fix a crash when resolving into an sRGB texture Cc: 10.5 10.4 (cherry picked from commit 9953586af2254f83a610d4cd284f52f37fa18b98) --- src/gallium/drivers/r300/r300_texture.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/gallium/drivers/r300/r300_texture.c b/src/gallium/drivers/r300/r300_texture.c index e85a818..6c01c0d 100644 --- a/src/gallium/drivers/r300/r300_texture.c +++ b/src/gallium/drivers/r300/r300_texture.c @@ -938,14 +938,16 @@ static void r300_texture_setup_fb_state(struct r300_surface *surf) surf->pitch_zmask = tex->tex.zmask_stride_in_pixels[level]; surf->pitch_hiz = tex->tex.hiz_stride_in_pixels[level]; } else { + enum pipe_format format = util_format_linear(surf->base.format); + surf->pitch = stride | - r300_translate_colorformat(surf->base.format) | + r300_translate_colorformat(format) | R300_COLOR_TILE(tex->tex.macrotile[level]) | R300_COLOR_MICROTILE(tex->tex.microtile); - surf->format = r300_translate_out_fmt(surf->base.format); + surf->format = r300_translate_out_fmt(format); surf->colormask_swizzle = - r300_translate_colormask_swizzle(surf->base.format); + r300_translate_colormask_swizzle(format); surf->pitch_cmask = tex->tex.cmask_stride_in_pixels; } } From evelikov at kemper.freedesktop.org Thu Mar 12 13:11:38 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Thu, 12 Mar 2015 06:11:38 -0700 (PDT) Subject: Mesa (10.4): r300g: fix sRGB->sRGB blits Message-ID: <20150312131138.6679D76333@kemper.freedesktop.org> Module: Mesa Branch: 10.4 Commit: 977626f10a591f46f800378563e35ae6cc655e1e URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=977626f10a591f46f800378563e35ae6cc655e1e Author: Marek Ol??k Date: Mon Mar 9 21:20:03 2015 +0100 r300g: fix sRGB->sRGB blits Cc: 10.5 10.4 (cherry picked from commit c939231e7223510408a446400ad23b8b5ce2922e) --- src/gallium/drivers/r300/r300_blit.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/gallium/drivers/r300/r300_blit.c b/src/gallium/drivers/r300/r300_blit.c index 4e7efc5..baf05ce 100644 --- a/src/gallium/drivers/r300/r300_blit.c +++ b/src/gallium/drivers/r300/r300_blit.c @@ -803,6 +803,15 @@ static void r300_blit(struct pipe_context *pipe, (struct pipe_framebuffer_state*)r300->fb_state.state; struct pipe_blit_info info = *blit; + /* The driver supports sRGB textures but not framebuffers. Blitting + * from sRGB to sRGB should be the same as blitting from linear + * to linear, so use that, This avoids incorrect linearization. + */ + if (util_format_is_srgb(info.src.format)) { + info.src.format = util_format_linear(info.src.format); + info.dst.format = util_format_linear(info.dst.format); + } + /* MSAA resolve. */ if (info.src.resource->nr_samples > 1 && !util_format_is_depth_or_stencil(info.src.resource->format)) { From evelikov at kemper.freedesktop.org Thu Mar 12 13:11:38 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Thu, 12 Mar 2015 06:11:38 -0700 (PDT) Subject: Mesa (10.4): freedreno/ir3: fix silly typo for binning pass shaders Message-ID: <20150312131138.6EF1576333@kemper.freedesktop.org> Module: Mesa Branch: 10.4 Commit: a91ee1e187d477841beadb5df1a852182ecd019b URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=a91ee1e187d477841beadb5df1a852182ecd019b Author: Rob Clark Date: Thu Mar 5 15:27:27 2015 -0500 freedreno/ir3: fix silly typo for binning pass shaders Was resulting in gl_PointSize write being optimized out, causing particle system type shaders to hang if hw binning enabled. Fixes neverball, OGLES2ParticleSystem, etc. Signed-off-by: Rob Clark (cherry picked from commit 60096ed906e5ebfdce41024c7af69f03b96dbe82) --- src/gallium/drivers/freedreno/ir3/ir3_compiler.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gallium/drivers/freedreno/ir3/ir3_compiler.c b/src/gallium/drivers/freedreno/ir3/ir3_compiler.c index 010ec6e..9d84716 100644 --- a/src/gallium/drivers/freedreno/ir3/ir3_compiler.c +++ b/src/gallium/drivers/freedreno/ir3/ir3_compiler.c @@ -3154,7 +3154,7 @@ ir3_compile_shader(struct ir3_shader_variant *so, if (key.binning_pass) { for (i = 0, j = 0; i < so->outputs_count; i++) { unsigned name = sem2name(so->outputs[i].semantic); - unsigned idx = sem2name(so->outputs[i].semantic); + unsigned idx = sem2idx(so->outputs[i].semantic); /* throw away everything but first position/psize */ if ((idx == 0) && ((name == TGSI_SEMANTIC_POSITION) || From evelikov at kemper.freedesktop.org Thu Mar 12 13:11:38 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Thu, 12 Mar 2015 06:11:38 -0700 (PDT) Subject: Mesa (10.4): i965: Fix out-of-bounds accesses into pull_constant_loc array Message-ID: <20150312131138.774BA76333@kemper.freedesktop.org> Module: Mesa Branch: 10.4 Commit: 8c25b0f2d15a03523fd731718b2f80117bc75791 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=8c25b0f2d15a03523fd731718b2f80117bc75791 Author: Iago Toral Quiroga Date: Tue Mar 10 11:36:43 2015 +0100 i965: Fix out-of-bounds accesses into pull_constant_loc array The piglit test glsl-fs-uniform-array-loop-unroll.shader_test was designed to do an out of bounds access into an uniform array to make sure that we handle that situation gracefully inside the driver, however, as Ken describes in bug 79202, Valgrind reports that this is leading to an out-of-bounds access in fs_visitor::demote_pull_constants(). Before accessing the pull_constant_loc array we should make sure that the uniform we are trying to access is valid. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=79202 Reviewed-by: Matt Turner (cherry picked from commit 6ac1bc90c4a7a6f32901a9782e14b090f6fe5270) Nominated-by: Matt Turner --- src/mesa/drivers/dri/i965/brw_fs.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp index 57ca39d..fdfd528 100644 --- a/src/mesa/drivers/dri/i965/brw_fs.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs.cpp @@ -2179,8 +2179,13 @@ fs_visitor::demote_pull_constants() if (inst->src[i].file != UNIFORM) continue; - int pull_index = pull_constant_loc[inst->src[i].reg + - inst->src[i].reg_offset]; + int pull_index; + unsigned location = inst->src[i].reg + inst->src[i].reg_offset; + if (location >= uniforms) /* Out of bounds access */ + pull_index = -1; + else + pull_index = pull_constant_loc[location]; + if (pull_index == -1) continue; From evelikov at kemper.freedesktop.org Thu Mar 12 13:11:38 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Thu, 12 Mar 2015 06:11:38 -0700 (PDT) Subject: Mesa (10.4): r300g: fix RGTC1 and LATC1 SNORM formats Message-ID: <20150312131138.47C3D76333@kemper.freedesktop.org> Module: Mesa Branch: 10.4 Commit: a561eee82c73aa8e66d18f80544607890fcf4f58 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=a561eee82c73aa8e66d18f80544607890fcf4f58 Author: Marek Ol??k Date: Mon Mar 9 20:04:04 2015 +0100 r300g: fix RGTC1 and LATC1 SNORM formats Cc: 10.5 10.4 (cherry picked from commit 74a757f92f7377f59c0feb7f84c7518f9a167631) --- src/gallium/drivers/r300/r300_fs.c | 18 ++---------------- src/gallium/drivers/r300/r300_texture.c | 30 +++++++++++++++--------------- 2 files changed, 17 insertions(+), 31 deletions(-) diff --git a/src/gallium/drivers/r300/r300_fs.c b/src/gallium/drivers/r300/r300_fs.c index c00f55f..79eee73 100644 --- a/src/gallium/drivers/r300/r300_fs.c +++ b/src/gallium/drivers/r300/r300_fs.c @@ -170,24 +170,10 @@ static void get_external_state( } state->unit[i].non_normalized_coords = !s->state.normalized_coords; - state->unit[i].convert_unorm_to_snorm = - v->base.format == PIPE_FORMAT_RGTC1_SNORM || - v->base.format == PIPE_FORMAT_LATC1_SNORM; + state->unit[i].convert_unorm_to_snorm = 0; /* Pass texture swizzling to the compiler, some lowering passes need it. */ - if (v->base.format == PIPE_FORMAT_RGTC1_SNORM || - v->base.format == PIPE_FORMAT_LATC1_SNORM) { - unsigned char swizzle[4]; - - util_format_compose_swizzles( - util_format_description(v->base.format)->swizzle, - v->swizzle, - swizzle); - - state->unit[i].texture_swizzle = - RC_MAKE_SWIZZLE(swizzle[0], swizzle[1], - swizzle[2], swizzle[3]); - } else if (state->unit[i].compare_mode_enabled) { + if (state->unit[i].compare_mode_enabled) { state->unit[i].texture_swizzle = RC_MAKE_SWIZZLE(v->swizzle[0], v->swizzle[1], v->swizzle[2], v->swizzle[3]); diff --git a/src/gallium/drivers/r300/r300_texture.c b/src/gallium/drivers/r300/r300_texture.c index 340b8fc..e85a818 100644 --- a/src/gallium/drivers/r300/r300_texture.c +++ b/src/gallium/drivers/r300/r300_texture.c @@ -169,22 +169,21 @@ uint32_t r300_translate_texformat(enum pipe_format format, /* Add swizzling. */ /* The RGTC1_SNORM and LATC1_SNORM swizzle is done in the shader. */ - if (format != PIPE_FORMAT_RGTC1_SNORM && + if (util_format_is_compressed(format) && + dxtc_swizzle && + format != PIPE_FORMAT_RGTC2_UNORM && + format != PIPE_FORMAT_RGTC2_SNORM && + format != PIPE_FORMAT_LATC2_UNORM && + format != PIPE_FORMAT_LATC2_SNORM && + format != PIPE_FORMAT_RGTC1_UNORM && + format != PIPE_FORMAT_RGTC1_SNORM && + format != PIPE_FORMAT_LATC1_UNORM && format != PIPE_FORMAT_LATC1_SNORM) { - if (util_format_is_compressed(format) && - dxtc_swizzle && - format != PIPE_FORMAT_RGTC2_UNORM && - format != PIPE_FORMAT_RGTC2_SNORM && - format != PIPE_FORMAT_LATC2_UNORM && - format != PIPE_FORMAT_LATC2_SNORM && - format != PIPE_FORMAT_RGTC1_UNORM && - format != PIPE_FORMAT_LATC1_UNORM) { - result |= r300_get_swizzle_combined(desc->swizzle, swizzle_view, - TRUE); - } else { - result |= r300_get_swizzle_combined(desc->swizzle, swizzle_view, - FALSE); - } + result |= r300_get_swizzle_combined(desc->swizzle, swizzle_view, + TRUE); + } else { + result |= r300_get_swizzle_combined(desc->swizzle, swizzle_view, + FALSE); } /* S3TC formats. */ @@ -215,6 +214,7 @@ uint32_t r300_translate_texformat(enum pipe_format format, switch (format) { case PIPE_FORMAT_RGTC1_SNORM: case PIPE_FORMAT_LATC1_SNORM: + result |= sign_bit[0]; case PIPE_FORMAT_LATC1_UNORM: case PIPE_FORMAT_RGTC1_UNORM: return R500_TX_FORMAT_ATI1N | result; From brianp at kemper.freedesktop.org Thu Mar 12 14:15:26 2015 From: brianp at kemper.freedesktop.org (Brian Paul) Date: Thu, 12 Mar 2015 07:15:26 -0700 (PDT) Subject: Mesa (master): mesa: reindent querymatrix.c Message-ID: <20150312141526.28D7D7633D@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 97f6d50f7247c40eeef33219e5cf5ccb7bf6d4ea URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=97f6d50f7247c40eeef33219e5cf5ccb7bf6d4ea Author: Brian Paul Date: Sat Mar 7 13:15:22 2015 -0700 mesa: reindent querymatrix.c Use 3-space indents, not 4. Move some comments after the case statements. Acked-by: Matt Turner --- src/mesa/main/querymatrix.c | 229 ++++++++++++++++++++++--------------------- 1 file changed, 115 insertions(+), 114 deletions(-) diff --git a/src/mesa/main/querymatrix.c b/src/mesa/main/querymatrix.c index 095817c..ca6b023 100644 --- a/src/mesa/main/querymatrix.c +++ b/src/mesa/main/querymatrix.c @@ -38,119 +38,120 @@ #define FLOAT_TO_FIXED(x) ((GLfixed) ((x) * 65536.0)) -GLbitfield GLAPIENTRY _mesa_QueryMatrixxOES(GLfixed mantissa[16], GLint exponent[16]) +GLbitfield GLAPIENTRY +_mesa_QueryMatrixxOES(GLfixed mantissa[16], GLint exponent[16]) { - GLfloat matrix[16]; - GLint tmp; - GLenum currentMode = GL_FALSE; - GLenum desiredMatrix = GL_FALSE; - /* The bitfield returns 1 for each component that is invalid (i.e. - * NaN or Inf). In case of error, everything is invalid. - */ - GLbitfield rv; - register unsigned int i; - unsigned int bit; - - /* This data structure defines the mapping between the current matrix - * mode and the desired matrix identifier. - */ - static struct { - GLenum currentMode; - GLenum desiredMatrix; - } modes[] = { - {GL_MODELVIEW, GL_MODELVIEW_MATRIX}, - {GL_PROJECTION, GL_PROJECTION_MATRIX}, - {GL_TEXTURE, GL_TEXTURE_MATRIX}, - }; - - /* Call Mesa to get the current matrix in floating-point form. First, - * we have to figure out what the current matrix mode is. - */ - _mesa_GetIntegerv(GL_MATRIX_MODE, &tmp); - currentMode = (GLenum) tmp; - - /* The mode is either GL_FALSE, if for some reason we failed to query - * the mode, or a given mode from the above table. Search for the - * returned mode to get the desired matrix; if we don't find it, - * we can return immediately, as _mesa_GetInteger() will have - * logged the necessary error already. - */ - for (i = 0; i < sizeof(modes)/sizeof(modes[0]); i++) { - if (modes[i].currentMode == currentMode) { - desiredMatrix = modes[i].desiredMatrix; - break; - } - } - if (desiredMatrix == GL_FALSE) { - /* Early error means all values are invalid. */ - return 0xffff; - } - - /* Now pull the matrix itself. */ - _mesa_GetFloatv(desiredMatrix, matrix); - - rv = 0; - for (i = 0, bit = 1; i < 16; i++, bit<<=1) { - float normalizedFraction; - int exp; - - switch (fpclassify(matrix[i])) { - /* A "subnormal" or denormalized number is too small to be - * represented in normal format; but despite that it's a - * valid floating point number. FP_ZERO and FP_NORMAL - * are both valid as well. We should be fine treating - * these three cases as legitimate floating-point numbers. - */ - case FP_SUBNORMAL: - case FP_NORMAL: - case FP_ZERO: - normalizedFraction = (GLfloat)frexp(matrix[i], &exp); - mantissa[i] = FLOAT_TO_FIXED(normalizedFraction); - exponent[i] = (GLint) exp; - break; - - /* If the entry is not-a-number or an infinity, then the - * matrix component is invalid. The invalid flag for - * the component is already set; might as well set the - * other return values to known values. We'll set - * distinct values so that a savvy end user could determine - * whether the matrix component was a NaN or an infinity, - * but this is more useful for debugging than anything else - * since the standard doesn't specify any such magic - * values to return. - */ - case FP_NAN: - mantissa[i] = INT_TO_FIXED(0); - exponent[i] = (GLint) 0; - rv |= bit; - break; - - case FP_INFINITE: - /* Return +/- 1 based on whether it's a positive or - * negative infinity. - */ - if (matrix[i] > 0) { - mantissa[i] = INT_TO_FIXED(1); - } - else { - mantissa[i] = -INT_TO_FIXED(1); - } - exponent[i] = (GLint) 0; - rv |= bit; - break; - - /* We should never get here; but here's a catching case - * in case fpclassify() is returnings something unexpected. - */ - default: - mantissa[i] = INT_TO_FIXED(2); - exponent[i] = (GLint) 0; - rv |= bit; - break; - } - - } /* for each component */ - - /* All done */ - return rv; + GLfloat matrix[16]; + GLint tmp; + GLenum currentMode = GL_FALSE; + GLenum desiredMatrix = GL_FALSE; + /* The bitfield returns 1 for each component that is invalid (i.e. + * NaN or Inf). In case of error, everything is invalid. + */ + GLbitfield rv; + register unsigned int i; + unsigned int bit; + + /* This data structure defines the mapping between the current matrix + * mode and the desired matrix identifier. + */ + static struct { + GLenum currentMode; + GLenum desiredMatrix; + } modes[] = { + {GL_MODELVIEW, GL_MODELVIEW_MATRIX}, + {GL_PROJECTION, GL_PROJECTION_MATRIX}, + {GL_TEXTURE, GL_TEXTURE_MATRIX}, + }; + + /* Call Mesa to get the current matrix in floating-point form. First, + * we have to figure out what the current matrix mode is. + */ + _mesa_GetIntegerv(GL_MATRIX_MODE, &tmp); + currentMode = (GLenum) tmp; + + /* The mode is either GL_FALSE, if for some reason we failed to query + * the mode, or a given mode from the above table. Search for the + * returned mode to get the desired matrix; if we don't find it, + * we can return immediately, as _mesa_GetInteger() will have + * logged the necessary error already. + */ + for (i = 0; i < sizeof(modes)/sizeof(modes[0]); i++) { + if (modes[i].currentMode == currentMode) { + desiredMatrix = modes[i].desiredMatrix; + break; + } + } + if (desiredMatrix == GL_FALSE) { + /* Early error means all values are invalid. */ + return 0xffff; + } + + /* Now pull the matrix itself. */ + _mesa_GetFloatv(desiredMatrix, matrix); + + rv = 0; + for (i = 0, bit = 1; i < 16; i++, bit<<=1) { + float normalizedFraction; + int exp; + + switch (fpclassify(matrix[i])) { + case FP_SUBNORMAL: + case FP_NORMAL: + case FP_ZERO: + /* A "subnormal" or denormalized number is too small to be + * represented in normal format; but despite that it's a + * valid floating point number. FP_ZERO and FP_NORMAL + * are both valid as well. We should be fine treating + * these three cases as legitimate floating-point numbers. + */ + normalizedFraction = (GLfloat)frexp(matrix[i], &exp); + mantissa[i] = FLOAT_TO_FIXED(normalizedFraction); + exponent[i] = (GLint) exp; + break; + + case FP_NAN: + /* If the entry is not-a-number or an infinity, then the + * matrix component is invalid. The invalid flag for + * the component is already set; might as well set the + * other return values to known values. We'll set + * distinct values so that a savvy end user could determine + * whether the matrix component was a NaN or an infinity, + * but this is more useful for debugging than anything else + * since the standard doesn't specify any such magic + * values to return. + */ + mantissa[i] = INT_TO_FIXED(0); + exponent[i] = (GLint) 0; + rv |= bit; + break; + + case FP_INFINITE: + /* Return +/- 1 based on whether it's a positive or + * negative infinity. + */ + if (matrix[i] > 0) { + mantissa[i] = INT_TO_FIXED(1); + } + else { + mantissa[i] = -INT_TO_FIXED(1); + } + exponent[i] = (GLint) 0; + rv |= bit; + break; + + default: + /* We should never get here; but here's a catching case + * in case fpclassify() is returnings something unexpected. + */ + mantissa[i] = INT_TO_FIXED(2); + exponent[i] = (GLint) 0; + rv |= bit; + break; + } + + } /* for each component */ + + /* All done */ + return rv; } From brianp at kemper.freedesktop.org Thu Mar 12 14:15:26 2015 From: brianp at kemper.freedesktop.org (Brian Paul) Date: Thu, 12 Mar 2015 07:15:26 -0700 (PDT) Subject: Mesa (master): mesa: move fpclassify work-arounds into c99_math.h Message-ID: <20150312141526.1F8F7761DF@kemper.freedesktop.org> Module: Mesa Branch: master Commit: be4e198be00c03e88315058eb81187a9547e3e87 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=be4e198be00c03e88315058eb81187a9547e3e87 Author: Brian Paul Date: Sat Mar 7 13:15:22 2015 -0700 mesa: move fpclassify work-arounds into c99_math.h v2: Use #error in the #else clause, per Jose. Reviewed-by: Jose Fonseca --- include/c99_math.h | 44 +++++++++++++++++++++++++++++++++++++ src/mesa/main/querymatrix.c | 51 +------------------------------------------ 2 files changed, 45 insertions(+), 50 deletions(-) diff --git a/include/c99_math.h b/include/c99_math.h index 0a49950..bd35d1b 100644 --- a/include/c99_math.h +++ b/include/c99_math.h @@ -161,4 +161,48 @@ llrintf(float f) #endif +#if defined(fpclassify) +/* ISO C99 says that fpclassify is a macro. Assume that any implementation + * of fpclassify, whether it's in a C99 compiler or not, will be a macro. + */ +#elif defined(__cplusplus) +/* For C++, fpclassify() should be defined in */ +#elif defined(_MSC_VER) +/* Not required on VS2013 and above. Oddly, the fpclassify() function + * doesn't exist in such a form on MSVC. This is an implementation using + * slightly different lower-level Windows functions. + */ +#include + +static inline enum {FP_NAN, FP_INFINITE, FP_ZERO, FP_SUBNORMAL, FP_NORMAL} +fpclassify(double x) +{ + switch(_fpclass(x)) { + case _FPCLASS_SNAN: /* signaling NaN */ + case _FPCLASS_QNAN: /* quiet NaN */ + return FP_NAN; + case _FPCLASS_NINF: /* negative infinity */ + case _FPCLASS_PINF: /* positive infinity */ + return FP_INFINITE; + case _FPCLASS_NN: /* negative normal */ + case _FPCLASS_PN: /* positive normal */ + return FP_NORMAL; + case _FPCLASS_ND: /* negative denormalized */ + case _FPCLASS_PD: /* positive denormalized */ + return FP_SUBNORMAL; + case _FPCLASS_NZ: /* negative zero */ + case _FPCLASS_PZ: /* positive zero */ + return FP_ZERO; + default: + /* Should never get here; but if we do, this will guarantee + * that the pattern is not treated like a number. + */ + return FP_NAN; + } +} +#else +#error "Need to include or define an fpclassify function" +#endif + + #endif /* #define _C99_MATH_H_ */ diff --git a/src/mesa/main/querymatrix.c b/src/mesa/main/querymatrix.c index ef85175..095817c 100644 --- a/src/mesa/main/querymatrix.c +++ b/src/mesa/main/querymatrix.c @@ -13,7 +13,7 @@ #include -#include +#include "c99_math.h" #include "glheader.h" #include "querymatrix.h" #include "main/get.h" @@ -37,55 +37,6 @@ #define INT_TO_FIXED(x) ((GLfixed) ((x) << 16)) #define FLOAT_TO_FIXED(x) ((GLfixed) ((x) * 65536.0)) -#if defined(fpclassify) -/* ISO C99 says that fpclassify is a macro. Assume that any implementation - * of fpclassify, whether it's in a C99 compiler or not, will be a macro. - */ -#elif defined(_MSC_VER) -/* Not required on VS2013 and above. */ -/* Oddly, the fpclassify() function doesn't exist in such a form - * on MSVC. This is an implementation using slightly different - * lower-level Windows functions. - */ -#include - -enum {FP_NAN, FP_INFINITE, FP_ZERO, FP_SUBNORMAL, FP_NORMAL} -fpclassify(double x) -{ - switch(_fpclass(x)) { - case _FPCLASS_SNAN: /* signaling NaN */ - case _FPCLASS_QNAN: /* quiet NaN */ - return FP_NAN; - case _FPCLASS_NINF: /* negative infinity */ - case _FPCLASS_PINF: /* positive infinity */ - return FP_INFINITE; - case _FPCLASS_NN: /* negative normal */ - case _FPCLASS_PN: /* positive normal */ - return FP_NORMAL; - case _FPCLASS_ND: /* negative denormalized */ - case _FPCLASS_PD: /* positive denormalized */ - return FP_SUBNORMAL; - case _FPCLASS_NZ: /* negative zero */ - case _FPCLASS_PZ: /* positive zero */ - return FP_ZERO; - default: - /* Should never get here; but if we do, this will guarantee - * that the pattern is not treated like a number. - */ - return FP_NAN; - } -} - -#else - -enum {FP_NAN, FP_INFINITE, FP_ZERO, FP_SUBNORMAL, FP_NORMAL} -fpclassify(double x) -{ - /* XXX do something better someday */ - return FP_NORMAL; -} - -#endif GLbitfield GLAPIENTRY _mesa_QueryMatrixxOES(GLfixed mantissa[16], GLint exponent[16]) { From brianp at kemper.freedesktop.org Thu Mar 12 14:15:26 2015 From: brianp at kemper.freedesktop.org (Brian Paul) Date: Thu, 12 Mar 2015 07:15:26 -0700 (PDT) Subject: Mesa (master): mesa: use ARRAY_SIZE in _mesa_QueryMatrixxOES() Message-ID: <20150312141526.3BD0B761DF@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 6ca5eaf49ce184009571f58fb94865cf788e8907 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=6ca5eaf49ce184009571f58fb94865cf788e8907 Author: Brian Paul Date: Sat Mar 7 13:15:22 2015 -0700 mesa: use ARRAY_SIZE in _mesa_QueryMatrixxOES() Reviewed-by: Matt Turner --- src/mesa/main/querymatrix.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesa/main/querymatrix.c b/src/mesa/main/querymatrix.c index ccd5c5e..18361c9 100644 --- a/src/mesa/main/querymatrix.c +++ b/src/mesa/main/querymatrix.c @@ -75,7 +75,7 @@ _mesa_QueryMatrixxOES(GLfixed mantissa[16], GLint exponent[16]) * we can return immediately, as _mesa_GetInteger() will have * logged the necessary error already. */ - for (i = 0; i < sizeof(modes)/sizeof(modes[0]); i++) { + for (i = 0; i < ARRAY_SIZE(modes); i++) { if (modes[i].currentMode == currentMode) { desiredMatrix = modes[i].desiredMatrix; break; From brianp at kemper.freedesktop.org Thu Mar 12 14:15:26 2015 From: brianp at kemper.freedesktop.org (Brian Paul) Date: Thu, 12 Mar 2015 07:15:26 -0700 (PDT) Subject: Mesa (master): swrast: remove _BLENDAPI Message-ID: <20150312141526.44BCD761DF@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 10035361b5c23483f236c59fe13c23153455e5c9 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=10035361b5c23483f236c59fe13c23153455e5c9 Author: Brian Paul Date: Wed Mar 11 08:29:56 2015 -0600 swrast: remove _BLENDAPI _BLENDAPI boils down to __cdecl on Windows, but __cdecl is the default calling convention so this serves no purpose. Reviewed-by: Ian Romanick --- src/mesa/swrast/s_blend.c | 21 +++++++++------------ src/mesa/swrast/s_context.h | 8 ++++---- 2 files changed, 13 insertions(+), 16 deletions(-) diff --git a/src/mesa/swrast/s_blend.c b/src/mesa/swrast/s_blend.c index 7cb1194..8479b0b 100644 --- a/src/mesa/swrast/s_blend.c +++ b/src/mesa/swrast/s_blend.c @@ -48,9 +48,6 @@ #if defined(USE_MMX_ASM) #include "x86/mmx.h" #include "x86/common_x86_asm.h" -#define _BLENDAPI _ASMAPI -#else -#define _BLENDAPI #endif @@ -69,7 +66,7 @@ * No-op means the framebuffer values remain unchanged. * Any chanType ok. */ -static void _BLENDAPI +static void blend_noop(struct gl_context *ctx, GLuint n, const GLubyte mask[], GLvoid *src, const GLvoid *dst, GLenum chanType) { @@ -97,7 +94,7 @@ blend_noop(struct gl_context *ctx, GLuint n, const GLubyte mask[], * Special case for glBlendFunc(GL_ONE, GL_ZERO) * Any chanType ok. */ -static void _BLENDAPI +static void blend_replace(struct gl_context *ctx, GLuint n, const GLubyte mask[], GLvoid *src, const GLvoid *dst, GLenum chanType) { @@ -117,7 +114,7 @@ blend_replace(struct gl_context *ctx, GLuint n, const GLubyte mask[], * Common transparency blending mode: * glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA). */ -static void _BLENDAPI +static void blend_transparency_ubyte(struct gl_context *ctx, GLuint n, const GLubyte mask[], GLvoid *src, const GLvoid *dst, GLenum chanType) { @@ -162,7 +159,7 @@ blend_transparency_ubyte(struct gl_context *ctx, GLuint n, const GLubyte mask[], } -static void _BLENDAPI +static void blend_transparency_ushort(struct gl_context *ctx, GLuint n, const GLubyte mask[], GLvoid *src, const GLvoid *dst, GLenum chanType) { @@ -200,7 +197,7 @@ blend_transparency_ushort(struct gl_context *ctx, GLuint n, const GLubyte mask[] } -static void _BLENDAPI +static void blend_transparency_float(struct gl_context *ctx, GLuint n, const GLubyte mask[], GLvoid *src, const GLvoid *dst, GLenum chanType) { @@ -242,7 +239,7 @@ blend_transparency_float(struct gl_context *ctx, GLuint n, const GLubyte mask[], * Add src and dest: glBlendFunc(GL_ONE, GL_ONE). * Any chanType ok. */ -static void _BLENDAPI +static void blend_add(struct gl_context *ctx, GLuint n, const GLubyte mask[], GLvoid *src, const GLvoid *dst, GLenum chanType) { @@ -308,7 +305,7 @@ blend_add(struct gl_context *ctx, GLuint n, const GLubyte mask[], * Blend min function. * Any chanType ok. */ -static void _BLENDAPI +static void blend_min(struct gl_context *ctx, GLuint n, const GLubyte mask[], GLvoid *src, const GLvoid *dst, GLenum chanType) { @@ -361,7 +358,7 @@ blend_min(struct gl_context *ctx, GLuint n, const GLubyte mask[], * Blend max function. * Any chanType ok. */ -static void _BLENDAPI +static void blend_max(struct gl_context *ctx, GLuint n, const GLubyte mask[], GLvoid *src, const GLvoid *dst, GLenum chanType) { @@ -415,7 +412,7 @@ blend_max(struct gl_context *ctx, GLuint n, const GLubyte mask[], * Modulate: result = src * dest * Any chanType ok. */ -static void _BLENDAPI +static void blend_modulate(struct gl_context *ctx, GLuint n, const GLubyte mask[], GLvoid *src, const GLvoid *dst, GLenum chanType) { diff --git a/src/mesa/swrast/s_context.h b/src/mesa/swrast/s_context.h index d6fbc5d5..7cf0e30 100644 --- a/src/mesa/swrast/s_context.h +++ b/src/mesa/swrast/s_context.h @@ -58,10 +58,10 @@ typedef void (*texture_sample_func)(struct gl_context *ctx, GLuint n, const GLfloat texcoords[][4], const GLfloat lambda[], GLfloat rgba[][4]); -typedef void (_ASMAPIP blend_func)( struct gl_context *ctx, GLuint n, - const GLubyte mask[], - GLvoid *src, const GLvoid *dst, - GLenum chanType); +typedef void (*blend_func)(struct gl_context *ctx, GLuint n, + const GLubyte mask[], + GLvoid *src, const GLvoid *dst, + GLenum chanType); typedef void (*swrast_point_func)( struct gl_context *ctx, const SWvertex *); From brianp at kemper.freedesktop.org Thu Mar 12 14:15:26 2015 From: brianp at kemper.freedesktop.org (Brian Paul) Date: Thu, 12 Mar 2015 07:15:26 -0700 (PDT) Subject: Mesa (master): mesa: remove _ASMAPI, ASMAPIP Message-ID: <20150312141526.5970D7633D@kemper.freedesktop.org> Module: Mesa Branch: master Commit: f8ed0bbfef7b8e8098cb3263a196689dbd280758 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=f8ed0bbfef7b8e8098cb3263a196689dbd280758 Author: Brian Paul Date: Wed Mar 11 08:38:09 2015 -0600 mesa: remove _ASMAPI, ASMAPIP Reviewed-by: Ian Romanick --- src/mesa/main/compiler.h | 19 ------------------- src/mesa/swrast/s_context.c | 2 +- src/mesa/x86/3dnow.c | 6 +++--- src/mesa/x86/common_x86.c | 12 ++++++------ src/mesa/x86/mmx.h | 10 +++++----- src/mesa/x86/sse.c | 20 ++++++++++---------- src/mesa/x86/x86_xform.c | 8 ++++---- src/mesa/x86/x86_xform.h | 30 +++++++++++++++--------------- 8 files changed, 44 insertions(+), 63 deletions(-) diff --git a/src/mesa/main/compiler.h b/src/mesa/main/compiler.h index 6fded88..b9f808e 100644 --- a/src/mesa/main/compiler.h +++ b/src/mesa/main/compiler.h @@ -113,25 +113,6 @@ extern "C" { #define LE32_TO_CPU( x ) CPU_TO_LE32( x ) - -/** - * Create a macro so that asm functions can be linked into compilers other - * than GNU C - */ -#ifndef _ASMAPI -#if defined(_WIN32) -#define _ASMAPI __cdecl -#else -#define _ASMAPI -#endif -#ifdef PTR_DECL_IN_FRONT -#define _ASMAPIP * _ASMAPI -#else -#define _ASMAPIP _ASMAPI * -#endif -#endif - - /** * LONGSTRING macro * gcc -pedantic warns about long string literals, LONGSTRING silences that. diff --git a/src/mesa/swrast/s_context.c b/src/mesa/swrast/s_context.c index 51cc227..ecde292 100644 --- a/src/mesa/swrast/s_context.c +++ b/src/mesa/swrast/s_context.c @@ -409,7 +409,7 @@ _swrast_validate_point( struct gl_context *ctx, const SWvertex *v0 ) * Called via swrast->BlendFunc. Examine GL state to choose a blending * function, then call it. */ -static void _ASMAPI +static void _swrast_validate_blend_func(struct gl_context *ctx, GLuint n, const GLubyte mask[], GLvoid *src, const GLvoid *dst, GLenum chanType ) diff --git a/src/mesa/x86/3dnow.c b/src/mesa/x86/3dnow.c index c46cfbc..df7c64f 100644 --- a/src/mesa/x86/3dnow.c +++ b/src/mesa/x86/3dnow.c @@ -47,20 +47,20 @@ DECLARE_XFORM_GROUP( 3dnow, 3 ) DECLARE_XFORM_GROUP( 3dnow, 4 ) -extern void _ASMAPI +extern void _mesa_v16_3dnow_general_xform( GLfloat *first_vert, const GLfloat *m, const GLfloat *src, GLuint src_stride, GLuint count ); -extern void _ASMAPI +extern void _mesa_3dnow_project_vertices( GLfloat *first, GLfloat *last, const GLfloat *m, GLuint stride ); -extern void _ASMAPI +extern void _mesa_3dnow_project_clipped_vertices( GLfloat *first, GLfloat *last, const GLfloat *m, diff --git a/src/mesa/x86/common_x86.c b/src/mesa/x86/common_x86.c index 14b497d..86fbca9 100644 --- a/src/mesa/x86/common_x86.c +++ b/src/mesa/x86/common_x86.c @@ -68,12 +68,12 @@ static int detection_debug = GL_FALSE; /* No reason for this to be public. */ -extern GLuint _ASMAPI _mesa_x86_has_cpuid(void); -extern void _ASMAPI _mesa_x86_cpuid(GLuint op, GLuint *reg_eax, GLuint *reg_ebx, GLuint *reg_ecx, GLuint *reg_edx); -extern GLuint _ASMAPI _mesa_x86_cpuid_eax(GLuint op); -extern GLuint _ASMAPI _mesa_x86_cpuid_ebx(GLuint op); -extern GLuint _ASMAPI _mesa_x86_cpuid_ecx(GLuint op); -extern GLuint _ASMAPI _mesa_x86_cpuid_edx(GLuint op); +extern GLuint _mesa_x86_has_cpuid(void); +extern void _mesa_x86_cpuid(GLuint op, GLuint *reg_eax, GLuint *reg_ebx, GLuint *reg_ecx, GLuint *reg_edx); +extern GLuint _mesa_x86_cpuid_eax(GLuint op); +extern GLuint _mesa_x86_cpuid_ebx(GLuint op); +extern GLuint _mesa_x86_cpuid_ecx(GLuint op); +extern GLuint _mesa_x86_cpuid_edx(GLuint op); #if defined(USE_SSE_ASM) diff --git a/src/mesa/x86/mmx.h b/src/mesa/x86/mmx.h index 8101cf8..0c35490 100644 --- a/src/mesa/x86/mmx.h +++ b/src/mesa/x86/mmx.h @@ -31,27 +31,27 @@ struct gl_context; -extern void _ASMAPI +extern void _mesa_mmx_blend_transparency( struct gl_context *ctx, GLuint n, const GLubyte mask[], GLvoid *rgba, const GLvoid *dest, GLenum chanType ); -extern void _ASMAPI +extern void _mesa_mmx_blend_add( struct gl_context *ctx, GLuint n, const GLubyte mask[], GLvoid *rgba, const GLvoid *dest, GLenum chanType ); -extern void _ASMAPI +extern void _mesa_mmx_blend_min( struct gl_context *ctx, GLuint n, const GLubyte mask[], GLvoid *rgba, const GLvoid *dest, GLenum chanType ); -extern void _ASMAPI +extern void _mesa_mmx_blend_max( struct gl_context *ctx, GLuint n, const GLubyte mask[], GLvoid *rgba, const GLvoid *dest, GLenum chanType ); -extern void _ASMAPI +extern void _mesa_mmx_blend_modulate( struct gl_context *ctx, GLuint n, const GLubyte mask[], GLvoid *rgba, const GLvoid *dest, GLenum chanType ); diff --git a/src/mesa/x86/sse.c b/src/mesa/x86/sse.c index 846184f..02fe18fa 100644 --- a/src/mesa/x86/sse.c +++ b/src/mesa/x86/sse.c @@ -46,35 +46,35 @@ DECLARE_XFORM_GROUP( sse, 3 ) #if 1 /* Some functions are not written in SSE-assembly, because the fpu ones are faster */ -extern void _ASMAPI _mesa_sse_transform_normals_no_rot( NORM_ARGS ); -extern void _ASMAPI _mesa_sse_transform_rescale_normals( NORM_ARGS ); -extern void _ASMAPI _mesa_sse_transform_rescale_normals_no_rot( NORM_ARGS ); +extern void _mesa_sse_transform_normals_no_rot( NORM_ARGS ); +extern void _mesa_sse_transform_rescale_normals( NORM_ARGS ); +extern void _mesa_sse_transform_rescale_normals_no_rot( NORM_ARGS ); -extern void _ASMAPI _mesa_sse_transform_points4_general( XFORM_ARGS ); -extern void _ASMAPI _mesa_sse_transform_points4_3d( XFORM_ARGS ); +extern void _mesa_sse_transform_points4_general( XFORM_ARGS ); +extern void _mesa_sse_transform_points4_3d( XFORM_ARGS ); /* XXX this function segfaults, see below */ -extern void _ASMAPI _mesa_sse_transform_points4_identity( XFORM_ARGS ); +extern void _mesa_sse_transform_points4_identity( XFORM_ARGS ); /* XXX this one works, see below */ -extern void _ASMAPI _mesa_x86_transform_points4_identity( XFORM_ARGS ); +extern void _mesa_x86_transform_points4_identity( XFORM_ARGS ); #else DECLARE_NORM_GROUP( sse ) #endif -extern void _ASMAPI +extern void _mesa_v16_sse_general_xform( GLfloat *first_vert, const GLfloat *m, const GLfloat *src, GLuint src_stride, GLuint count ); -extern void _ASMAPI +extern void _mesa_sse_project_vertices( GLfloat *first, GLfloat *last, const GLfloat *m, GLuint stride ); -extern void _ASMAPI +extern void _mesa_sse_project_clipped_vertices( GLfloat *first, GLfloat *last, const GLfloat *m, diff --git a/src/mesa/x86/x86_xform.c b/src/mesa/x86/x86_xform.c index 007cd70..8b5cf91 100644 --- a/src/mesa/x86/x86_xform.c +++ b/src/mesa/x86/x86_xform.c @@ -54,7 +54,7 @@ DECLARE_XFORM_GROUP( x86, 3 ) DECLARE_XFORM_GROUP( x86, 4 ) -extern GLvector4f * _ASMAPI +extern GLvector4f * _mesa_x86_cliptest_points4( GLvector4f *clip_vec, GLvector4f *proj_vec, GLubyte clipMask[], @@ -62,7 +62,7 @@ _mesa_x86_cliptest_points4( GLvector4f *clip_vec, GLubyte *andMask, GLboolean viewport_z_clip ); -extern GLvector4f * _ASMAPI +extern GLvector4f * _mesa_x86_cliptest_points4_np( GLvector4f *clip_vec, GLvector4f *proj_vec, GLubyte clipMask[], @@ -70,7 +70,7 @@ _mesa_x86_cliptest_points4_np( GLvector4f *clip_vec, GLubyte *andMask, GLboolean viewport_z_clip ); -extern void _ASMAPI +extern void _mesa_v16_x86_cliptest_points4( GLfloat *first_vert, GLfloat *last_vert, GLubyte *or_mask, @@ -78,7 +78,7 @@ _mesa_v16_x86_cliptest_points4( GLfloat *first_vert, GLubyte *clip_mask, GLboolean viewport_z_clip ); -extern void _ASMAPI +extern void _mesa_v16_x86_general_xform( GLfloat *dest, const GLfloat *m, const GLfloat *src, diff --git a/src/mesa/x86/x86_xform.h b/src/mesa/x86/x86_xform.h index 12b9fb8..e398f64 100644 --- a/src/mesa/x86/x86_xform.h +++ b/src/mesa/x86/x86_xform.h @@ -39,13 +39,13 @@ const GLvector4f *from_vec #define DECLARE_XFORM_GROUP( pfx, sz ) \ -extern void _ASMAPI _mesa_##pfx##_transform_points##sz##_general( XFORM_ARGS ); \ -extern void _ASMAPI _mesa_##pfx##_transform_points##sz##_identity( XFORM_ARGS ); \ -extern void _ASMAPI _mesa_##pfx##_transform_points##sz##_3d_no_rot( XFORM_ARGS ); \ -extern void _ASMAPI _mesa_##pfx##_transform_points##sz##_perspective( XFORM_ARGS ); \ -extern void _ASMAPI _mesa_##pfx##_transform_points##sz##_2d( XFORM_ARGS ); \ -extern void _ASMAPI _mesa_##pfx##_transform_points##sz##_2d_no_rot( XFORM_ARGS ); \ -extern void _ASMAPI _mesa_##pfx##_transform_points##sz##_3d( XFORM_ARGS ); +extern void _mesa_##pfx##_transform_points##sz##_general( XFORM_ARGS ); \ +extern void _mesa_##pfx##_transform_points##sz##_identity( XFORM_ARGS ); \ +extern void _mesa_##pfx##_transform_points##sz##_3d_no_rot( XFORM_ARGS ); \ +extern void _mesa_##pfx##_transform_points##sz##_perspective( XFORM_ARGS ); \ +extern void _mesa_##pfx##_transform_points##sz##_2d( XFORM_ARGS ); \ +extern void _mesa_##pfx##_transform_points##sz##_2d_no_rot( XFORM_ARGS ); \ +extern void _mesa_##pfx##_transform_points##sz##_3d( XFORM_ARGS ); #define ASSIGN_XFORM_GROUP( pfx, sz ) \ _mesa_transform_tab[sz][MATRIX_GENERAL] = \ @@ -75,14 +75,14 @@ extern void _ASMAPI _mesa_##pfx##_transform_points##sz##_3d( XFORM_ARGS ); GLvector4f *dest #define DECLARE_NORM_GROUP( pfx ) \ -extern void _ASMAPI _mesa_##pfx##_rescale_normals( NORM_ARGS ); \ -extern void _ASMAPI _mesa_##pfx##_normalize_normals( NORM_ARGS ); \ -extern void _ASMAPI _mesa_##pfx##_transform_normals( NORM_ARGS ); \ -extern void _ASMAPI _mesa_##pfx##_transform_normals_no_rot( NORM_ARGS ); \ -extern void _ASMAPI _mesa_##pfx##_transform_rescale_normals( NORM_ARGS ); \ -extern void _ASMAPI _mesa_##pfx##_transform_rescale_normals_no_rot( NORM_ARGS ); \ -extern void _ASMAPI _mesa_##pfx##_transform_normalize_normals( NORM_ARGS ); \ -extern void _ASMAPI _mesa_##pfx##_transform_normalize_normals_no_rot( NORM_ARGS ); +extern void _mesa_##pfx##_rescale_normals( NORM_ARGS ); \ +extern void _mesa_##pfx##_normalize_normals( NORM_ARGS ); \ +extern void _mesa_##pfx##_transform_normals( NORM_ARGS ); \ +extern void _mesa_##pfx##_transform_normals_no_rot( NORM_ARGS ); \ +extern void _mesa_##pfx##_transform_rescale_normals( NORM_ARGS ); \ +extern void _mesa_##pfx##_transform_rescale_normals_no_rot( NORM_ARGS ); \ +extern void _mesa_##pfx##_transform_normalize_normals( NORM_ARGS ); \ +extern void _mesa_##pfx##_transform_normalize_normals_no_rot( NORM_ARGS ); #define ASSIGN_NORM_GROUP( pfx ) \ _mesa_normal_tab[NORM_RESCALE] = \ From brianp at kemper.freedesktop.org Thu Mar 12 14:15:26 2015 From: brianp at kemper.freedesktop.org (Brian Paul) Date: Thu, 12 Mar 2015 07:15:26 -0700 (PDT) Subject: Mesa (master): tnl: HAVE_LE32_VERTS is never defined, remove associated code Message-ID: <20150312141526.6FC3C761DF@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 48b0a3c1c9d829a9b1d401afb2796b35df94a5d7 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=48b0a3c1c9d829a9b1d401afb2796b35df94a5d7 Author: Brian Paul Date: Wed Mar 11 17:10:53 2015 -0600 tnl: HAVE_LE32_VERTS is never defined, remove associated code Reviewed-by: Matt Turner --- src/mesa/tnl_dd/t_dd_triemit.h | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/mesa/tnl_dd/t_dd_triemit.h b/src/mesa/tnl_dd/t_dd_triemit.h index 39c9d26..082e83f 100644 --- a/src/mesa/tnl_dd/t_dd_triemit.h +++ b/src/mesa/tnl_dd/t_dd_triemit.h @@ -16,13 +16,6 @@ do { \ "D" ((long)vb), \ "S" ((long)v) ); \ } while (0) -#elif defined(HAVE_LE32_VERTS) -#define COPY_DWORDS( j, vb, vertsize, v ) \ -do { \ - for ( j = 0 ; j < vertsize ; j++ ) \ - vb[j] = CPU_TO_LE32(((GLuint *)v)[j]); \ - vb += vertsize; \ -} while (0) #else #define COPY_DWORDS( j, vb, vertsize, v ) \ do { \ From brianp at kemper.freedesktop.org Thu Mar 12 14:15:26 2015 From: brianp at kemper.freedesktop.org (Brian Paul) Date: Thu, 12 Mar 2015 07:15:26 -0700 (PDT) Subject: Mesa (master): mesa: move LONGSTRING into generated enums.c Message-ID: <20150312141526.65264761DF@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 6d3b86c3afe4ee1bfb29c322b3d36131139cbab9 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=6d3b86c3afe4ee1bfb29c322b3d36131139cbab9 Author: Brian Paul Date: Wed Mar 11 16:54:15 2015 -0600 mesa: move LONGSTRING into generated enums.c enums.c is the only place this directive is needed. Reviewed-by: Matt Turner --- src/mapi/glapi/gen/gl_enums.py | 6 ++++++ src/mesa/main/compiler.h | 9 --------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/mapi/glapi/gen/gl_enums.py b/src/mapi/glapi/gen/gl_enums.py index d61618f..f45782d 100644 --- a/src/mapi/glapi/gen/gl_enums.py +++ b/src/mapi/glapi/gen/gl_enums.py @@ -157,6 +157,12 @@ _mesa_lookup_prim_by_nr(GLuint nr) string_offsets = {} i = 0; + print '#if defined(__GNUC__)' + print '# define LONGSTRING __extension__' + print '#else' + print '# define LONGSTRING' + print '#endif' + print '' print 'LONGSTRING static const char enum_string_table[] = ' for enum, name in enum_table: print ' "%s\\0"' % (name) diff --git a/src/mesa/main/compiler.h b/src/mesa/main/compiler.h index b9f808e..5c60391 100644 --- a/src/mesa/main/compiler.h +++ b/src/mesa/main/compiler.h @@ -113,15 +113,6 @@ extern "C" { #define LE32_TO_CPU( x ) CPU_TO_LE32( x ) -/** - * LONGSTRING macro - * gcc -pedantic warns about long string literals, LONGSTRING silences that. - */ -#if !defined(__GNUC__) -# define LONGSTRING -#else -# define LONGSTRING __extension__ -#endif #define IEEE_ONE 0x3f800000 From brianp at kemper.freedesktop.org Thu Mar 12 14:15:26 2015 From: brianp at kemper.freedesktop.org (Brian Paul) Date: Thu, 12 Mar 2015 07:15:26 -0700 (PDT) Subject: Mesa (master): mesa: remove register keyword, add const in _mesa_QueryMatrixxOES() Message-ID: <20150312141526.33ED47633E@kemper.freedesktop.org> Module: Mesa Branch: master Commit: c3984c1155bc78b45001f90ed1333bbacfc32151 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=c3984c1155bc78b45001f90ed1333bbacfc32151 Author: Brian Paul Date: Sat Mar 7 13:15:22 2015 -0700 mesa: remove register keyword, add const in _mesa_QueryMatrixxOES() Reviewed-by: Matt Turner --- src/mesa/main/querymatrix.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/mesa/main/querymatrix.c b/src/mesa/main/querymatrix.c index ca6b023..ccd5c5e 100644 --- a/src/mesa/main/querymatrix.c +++ b/src/mesa/main/querymatrix.c @@ -49,13 +49,12 @@ _mesa_QueryMatrixxOES(GLfixed mantissa[16], GLint exponent[16]) * NaN or Inf). In case of error, everything is invalid. */ GLbitfield rv; - register unsigned int i; - unsigned int bit; + unsigned i, bit; /* This data structure defines the mapping between the current matrix * mode and the desired matrix identifier. */ - static struct { + static const struct { GLenum currentMode; GLenum desiredMatrix; } modes[] = { From brianp at kemper.freedesktop.org Thu Mar 12 14:15:26 2015 From: brianp at kemper.freedesktop.org (Brian Paul) Date: Thu, 12 Mar 2015 07:15:26 -0700 (PDT) Subject: Mesa (master): mesa: remove _XFORMAPI Message-ID: <20150312141526.4E831761DF@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 09ffa04cd9c560b7a8c6d8ac80e3d59c49c5ef70 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=09ffa04cd9c560b7a8c6d8ac80e3d59c49c5ef70 Author: Brian Paul Date: Wed Mar 11 08:33:21 2015 -0600 mesa: remove _XFORMAPI Reviewed-by: Ian Romanick --- src/mesa/math/m_clip_tmp.h | 8 +++--- src/mesa/math/m_norm_tmp.h | 18 +++++++------- src/mesa/math/m_xform.h | 36 +++++++++++---------------- src/mesa/math/m_xform_tmp.h | 58 +++++++++++++++++++++---------------------- 4 files changed, 56 insertions(+), 64 deletions(-) diff --git a/src/mesa/math/m_clip_tmp.h b/src/mesa/math/m_clip_tmp.h index 45dec47..e289be7 100644 --- a/src/mesa/math/m_clip_tmp.h +++ b/src/mesa/math/m_clip_tmp.h @@ -40,7 +40,7 @@ * \param andMask bitwise-AND of clipMask values * \return proj_vec pointer */ -static GLvector4f * _XFORMAPI TAG(cliptest_points4)( GLvector4f *clip_vec, +static GLvector4f * TAG(cliptest_points4)( GLvector4f *clip_vec, GLvector4f *proj_vec, GLubyte clipMask[], GLubyte *orMask, @@ -120,7 +120,7 @@ static GLvector4f * _XFORMAPI TAG(cliptest_points4)( GLvector4f *clip_vec, * \param andMask bitwise-AND of clipMask values * \return clip_vec pointer */ -static GLvector4f * _XFORMAPI TAG(cliptest_np_points4)( GLvector4f *clip_vec, +static GLvector4f * TAG(cliptest_np_points4)( GLvector4f *clip_vec, GLvector4f *proj_vec, GLubyte clipMask[], GLubyte *orMask, @@ -177,7 +177,7 @@ static GLvector4f * _XFORMAPI TAG(cliptest_np_points4)( GLvector4f *clip_vec, } -static GLvector4f * _XFORMAPI TAG(cliptest_points3)( GLvector4f *clip_vec, +static GLvector4f * TAG(cliptest_points3)( GLvector4f *clip_vec, GLvector4f *proj_vec, GLubyte clipMask[], GLubyte *orMask, @@ -213,7 +213,7 @@ static GLvector4f * _XFORMAPI TAG(cliptest_points3)( GLvector4f *clip_vec, } -static GLvector4f * _XFORMAPI TAG(cliptest_points2)( GLvector4f *clip_vec, +static GLvector4f * TAG(cliptest_points2)( GLvector4f *clip_vec, GLvector4f *proj_vec, GLubyte clipMask[], GLubyte *orMask, diff --git a/src/mesa/math/m_norm_tmp.h b/src/mesa/math/m_norm_tmp.h index c8fab0e..d3ec1c2 100644 --- a/src/mesa/math/m_norm_tmp.h +++ b/src/mesa/math/m_norm_tmp.h @@ -39,7 +39,7 @@ * optimization) * dest - the destination vector of normals */ -static void _XFORMAPI +static void TAG(transform_normalize_normals)( const GLmatrix *mat, GLfloat scale, const GLvector4f *in, @@ -106,7 +106,7 @@ TAG(transform_normalize_normals)( const GLmatrix *mat, } -static void _XFORMAPI +static void TAG(transform_normalize_normals_no_rot)( const GLmatrix *mat, GLfloat scale, const GLvector4f *in, @@ -171,7 +171,7 @@ TAG(transform_normalize_normals_no_rot)( const GLmatrix *mat, } -static void _XFORMAPI +static void TAG(transform_rescale_normals_no_rot)( const GLmatrix *mat, GLfloat scale, const GLvector4f *in, @@ -200,7 +200,7 @@ TAG(transform_rescale_normals_no_rot)( const GLmatrix *mat, } -static void _XFORMAPI +static void TAG(transform_rescale_normals)( const GLmatrix *mat, GLfloat scale, const GLvector4f *in, @@ -232,7 +232,7 @@ TAG(transform_rescale_normals)( const GLmatrix *mat, } -static void _XFORMAPI +static void TAG(transform_normals_no_rot)( const GLmatrix *mat, GLfloat scale, const GLvector4f *in, @@ -262,7 +262,7 @@ TAG(transform_normals_no_rot)( const GLmatrix *mat, } -static void _XFORMAPI +static void TAG(transform_normals)( const GLmatrix *mat, GLfloat scale, const GLvector4f *in, @@ -292,7 +292,7 @@ TAG(transform_normals)( const GLmatrix *mat, } -static void _XFORMAPI +static void TAG(normalize_normals)( const GLmatrix *mat, GLfloat scale, const GLvector4f *in, @@ -338,7 +338,7 @@ TAG(normalize_normals)( const GLmatrix *mat, } -static void _XFORMAPI +static void TAG(rescale_normals)( const GLmatrix *mat, GLfloat scale, const GLvector4f *in, @@ -361,7 +361,7 @@ TAG(rescale_normals)( const GLmatrix *mat, } -static void _XFORMAPI +static void TAG(init_c_norm_transform)( void ) { _mesa_normal_tab[NORM_TRANSFORM_NO_ROT] = diff --git a/src/mesa/math/m_xform.h b/src/mesa/math/m_xform.h index 2ed62e7..0bb8e9b 100644 --- a/src/mesa/math/m_xform.h +++ b/src/mesa/math/m_xform.h @@ -32,14 +32,6 @@ #include "math/m_matrix.h" #include "math/m_vector.h" -#ifdef USE_X86_ASM -#define _XFORMAPI _ASMAPI -#define _XFORMAPIP _ASMAPIP -#else -#define _XFORMAPI -#define _XFORMAPIP * -#endif - extern void _math_init_transformation(void); @@ -99,12 +91,12 @@ init_c_cliptest(void); #define CLIP_FRUSTUM_BITS 0x3f -typedef GLvector4f * (_XFORMAPIP clip_func)( GLvector4f *vClip, - GLvector4f *vProj, - GLubyte clipMask[], - GLubyte *orMask, - GLubyte *andMask, - GLboolean viewport_z_clip ); +typedef GLvector4f * (*clip_func)(GLvector4f *vClip, + GLvector4f *vProj, + GLubyte clipMask[], + GLubyte *orMask, + GLubyte *andMask, + GLboolean viewport_z_clip); typedef void (*dotprod_func)( GLfloat *out, GLuint out_stride, @@ -119,11 +111,11 @@ typedef void (*vec_copy_func)( GLvector4f *to, /* * Functions for transformation of normals in the VB. */ -typedef void (_XFORMAPIP normal_func)( const GLmatrix *mat, - GLfloat scale, - const GLvector4f *in, - const GLfloat lengths[], - GLvector4f *dest ); +typedef void (*normal_func)(const GLmatrix *mat, + GLfloat scale, + const GLvector4f *in, + const GLfloat lengths[], + GLvector4f *dest); /* Flags for selecting a normal transformation function. @@ -141,9 +133,9 @@ typedef void (_XFORMAPIP normal_func)( const GLmatrix *mat, * when the mask byte is zero. This is always present as a * parameter, to allow a unified interface. */ -typedef void (_XFORMAPIP transform_func)( GLvector4f *to_vec, - const GLfloat m[16], - const GLvector4f *from_vec ); +typedef void (*transform_func)(GLvector4f *to_vec, + const GLfloat m[16], + const GLvector4f *from_vec); extern dotprod_func _mesa_dotprod_tab[5]; diff --git a/src/mesa/math/m_xform_tmp.h b/src/mesa/math/m_xform_tmp.h index 8886c96..af85de3 100644 --- a/src/mesa/math/m_xform_tmp.h +++ b/src/mesa/math/m_xform_tmp.h @@ -70,7 +70,7 @@ * driver-specific vertex format. */ -static void _XFORMAPI +static void TAG(transform_points1_general)( GLvector4f *to_vec, const GLfloat m[16], const GLvector4f *from_vec ) @@ -96,7 +96,7 @@ TAG(transform_points1_general)( GLvector4f *to_vec, to_vec->count = from_vec->count; } -static void _XFORMAPI +static void TAG(transform_points1_identity)( GLvector4f *to_vec, const GLfloat m[16], const GLvector4f *from_vec ) @@ -116,7 +116,7 @@ TAG(transform_points1_identity)( GLvector4f *to_vec, to_vec->count = from_vec->count; } -static void _XFORMAPI +static void TAG(transform_points1_2d)( GLvector4f *to_vec, const GLfloat m[16], const GLvector4f *from_vec ) @@ -138,7 +138,7 @@ TAG(transform_points1_2d)( GLvector4f *to_vec, to_vec->count = from_vec->count; } -static void _XFORMAPI +static void TAG(transform_points1_2d_no_rot)( GLvector4f *to_vec, const GLfloat m[16], const GLvector4f *from_vec ) @@ -159,7 +159,7 @@ TAG(transform_points1_2d_no_rot)( GLvector4f *to_vec, to_vec->count = from_vec->count; } -static void _XFORMAPI +static void TAG(transform_points1_3d)( GLvector4f *to_vec, const GLfloat m[16], const GLvector4f *from_vec ) @@ -183,7 +183,7 @@ TAG(transform_points1_3d)( GLvector4f *to_vec, } -static void _XFORMAPI +static void TAG(transform_points1_3d_no_rot)( GLvector4f *to_vec, const GLfloat m[16], const GLvector4f *from_vec ) @@ -206,7 +206,7 @@ TAG(transform_points1_3d_no_rot)( GLvector4f *to_vec, to_vec->count = from_vec->count; } -static void _XFORMAPI +static void TAG(transform_points1_perspective)( GLvector4f *to_vec, const GLfloat m[16], const GLvector4f *from_vec ) @@ -236,7 +236,7 @@ TAG(transform_points1_perspective)( GLvector4f *to_vec, * present early in the geometry pipeline and throughout the * texture pipeline. */ -static void _XFORMAPI +static void TAG(transform_points2_general)( GLvector4f *to_vec, const GLfloat m[16], const GLvector4f *from_vec ) @@ -262,7 +262,7 @@ TAG(transform_points2_general)( GLvector4f *to_vec, to_vec->count = from_vec->count; } -static void _XFORMAPI +static void TAG(transform_points2_identity)( GLvector4f *to_vec, const GLfloat m[16], const GLvector4f *from_vec ) @@ -283,7 +283,7 @@ TAG(transform_points2_identity)( GLvector4f *to_vec, to_vec->count = from_vec->count; } -static void _XFORMAPI +static void TAG(transform_points2_2d)( GLvector4f *to_vec, const GLfloat m[16], const GLvector4f *from_vec ) @@ -305,7 +305,7 @@ TAG(transform_points2_2d)( GLvector4f *to_vec, to_vec->count = from_vec->count; } -static void _XFORMAPI +static void TAG(transform_points2_2d_no_rot)( GLvector4f *to_vec, const GLfloat m[16], const GLvector4f *from_vec ) @@ -326,7 +326,7 @@ TAG(transform_points2_2d_no_rot)( GLvector4f *to_vec, to_vec->count = from_vec->count; } -static void _XFORMAPI +static void TAG(transform_points2_3d)( GLvector4f *to_vec, const GLfloat m[16], const GLvector4f *from_vec ) @@ -353,7 +353,7 @@ TAG(transform_points2_3d)( GLvector4f *to_vec, /* I would actually say this was a fairly important function, from * a texture transformation point of view. */ -static void _XFORMAPI +static void TAG(transform_points2_3d_no_rot)( GLvector4f *to_vec, const GLfloat m[16], const GLvector4f *from_vec ) @@ -382,7 +382,7 @@ TAG(transform_points2_3d_no_rot)( GLvector4f *to_vec, } -static void _XFORMAPI +static void TAG(transform_points2_perspective)( GLvector4f *to_vec, const GLfloat m[16], const GLvector4f *from_vec ) @@ -407,7 +407,7 @@ TAG(transform_points2_perspective)( GLvector4f *to_vec, -static void _XFORMAPI +static void TAG(transform_points3_general)( GLvector4f *to_vec, const GLfloat m[16], const GLvector4f *from_vec ) @@ -433,7 +433,7 @@ TAG(transform_points3_general)( GLvector4f *to_vec, to_vec->count = from_vec->count; } -static void _XFORMAPI +static void TAG(transform_points3_identity)( GLvector4f *to_vec, const GLfloat m[16], const GLvector4f *from_vec ) @@ -455,7 +455,7 @@ TAG(transform_points3_identity)( GLvector4f *to_vec, to_vec->count = from_vec->count; } -static void _XFORMAPI +static void TAG(transform_points3_2d)( GLvector4f *to_vec, const GLfloat m[16], const GLvector4f *from_vec ) @@ -478,7 +478,7 @@ TAG(transform_points3_2d)( GLvector4f *to_vec, to_vec->count = from_vec->count; } -static void _XFORMAPI +static void TAG(transform_points3_2d_no_rot)( GLvector4f *to_vec, const GLfloat m[16], const GLvector4f *from_vec ) @@ -500,7 +500,7 @@ TAG(transform_points3_2d_no_rot)( GLvector4f *to_vec, to_vec->count = from_vec->count; } -static void _XFORMAPI +static void TAG(transform_points3_3d)( GLvector4f *to_vec, const GLfloat m[16], const GLvector4f *from_vec ) @@ -526,7 +526,7 @@ TAG(transform_points3_3d)( GLvector4f *to_vec, /* previously known as ortho... */ -static void _XFORMAPI +static void TAG(transform_points3_3d_no_rot)( GLvector4f *to_vec, const GLfloat m[16], const GLvector4f *from_vec ) @@ -549,7 +549,7 @@ TAG(transform_points3_3d_no_rot)( GLvector4f *to_vec, to_vec->count = from_vec->count; } -static void _XFORMAPI +static void TAG(transform_points3_perspective)( GLvector4f *to_vec, const GLfloat m[16], const GLvector4f *from_vec ) @@ -575,7 +575,7 @@ TAG(transform_points3_perspective)( GLvector4f *to_vec, -static void _XFORMAPI +static void TAG(transform_points4_general)( GLvector4f *to_vec, const GLfloat m[16], const GLvector4f *from_vec ) @@ -601,7 +601,7 @@ TAG(transform_points4_general)( GLvector4f *to_vec, to_vec->count = from_vec->count; } -static void _XFORMAPI +static void TAG(transform_points4_identity)( GLvector4f *to_vec, const GLfloat m[16], const GLvector4f *from_vec ) @@ -624,7 +624,7 @@ TAG(transform_points4_identity)( GLvector4f *to_vec, to_vec->count = from_vec->count; } -static void _XFORMAPI +static void TAG(transform_points4_2d)( GLvector4f *to_vec, const GLfloat m[16], const GLvector4f *from_vec ) @@ -648,7 +648,7 @@ TAG(transform_points4_2d)( GLvector4f *to_vec, to_vec->count = from_vec->count; } -static void _XFORMAPI +static void TAG(transform_points4_2d_no_rot)( GLvector4f *to_vec, const GLfloat m[16], const GLvector4f *from_vec ) @@ -671,7 +671,7 @@ TAG(transform_points4_2d_no_rot)( GLvector4f *to_vec, to_vec->count = from_vec->count; } -static void _XFORMAPI +static void TAG(transform_points4_3d)( GLvector4f *to_vec, const GLfloat m[16], const GLvector4f *from_vec ) @@ -696,7 +696,7 @@ TAG(transform_points4_3d)( GLvector4f *to_vec, to_vec->count = from_vec->count; } -static void _XFORMAPI +static void TAG(transform_points4_3d_no_rot)( GLvector4f *to_vec, const GLfloat m[16], const GLvector4f *from_vec ) @@ -720,7 +720,7 @@ TAG(transform_points4_3d_no_rot)( GLvector4f *to_vec, to_vec->count = from_vec->count; } -static void _XFORMAPI +static void TAG(transform_points4_perspective)( GLvector4f *to_vec, const GLfloat m[16], const GLvector4f *from_vec ) @@ -753,7 +753,7 @@ static transform_func TAG(transform_tab_4)[7]; * optimized routines overwriting the arrays. This only occurs during * startup. */ -static void _XFORMAPI TAG(init_c_transformations)( void ) +static void TAG(init_c_transformations)( void ) { #define TAG_TAB _mesa_transform_tab #define TAG_TAB_1 TAG(transform_tab_1) From kwg at kemper.freedesktop.org Thu Mar 12 19:20:19 2015 From: kwg at kemper.freedesktop.org (Kenneth Graunke) Date: Thu, 12 Mar 2015 12:20:19 -0700 (PDT) Subject: Mesa (master): i965/nir: Optimize after nir_lower_var_copies(). Message-ID: <20150312192019.5C4D77633D@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 1f0067811c059fb3b284a2169e94fbdec7a4b909 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=1f0067811c059fb3b284a2169e94fbdec7a4b909 Author: Kenneth Graunke Date: Mon Mar 9 01:58:52 2015 -0700 i965/nir: Optimize after nir_lower_var_copies(). Array variable copy splitting generates a bunch of stuff we want to clean up before proceeding. Signed-off-by: Kenneth Graunke Reviewed-by: Jason Ekstrand --- src/mesa/drivers/dri/i965/brw_fs_nir.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp index 28ef417..ef83693 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp @@ -102,6 +102,9 @@ fs_visitor::emit_nir_code() nir_lower_var_copies(nir); nir_validate_shader(nir); + /* Get rid of split copies */ + nir_optimize(nir); + nir_lower_io(nir); nir_validate_shader(nir); From kwg at kemper.freedesktop.org Thu Mar 12 19:20:19 2015 From: kwg at kemper.freedesktop.org (Kenneth Graunke) Date: Thu, 12 Mar 2015 12:20:19 -0700 (PDT) Subject: Mesa (master): i965/fs: Store a pointer to brw_sampler_prog_key_data in the visitor. Message-ID: <20150312192019.559A9761DF@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 1d8ef6ba606a88239de633e5abcc19471c9d3cf4 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=1d8ef6ba606a88239de633e5abcc19471c9d3cf4 Author: Kenneth Graunke Date: Mon Mar 9 01:58:51 2015 -0700 i965/fs: Store a pointer to brw_sampler_prog_key_data in the visitor. The NIR backend hardcodes brw_wm_prog_key at the moment, which won't work when we support scalar VS. We could use get_tex(), but it's a static method. I was going to promote it to fs_visitor, but then realized that both parameters (stage and key) are already members. It then occured to me that we could just set up a pointer in the constructor, and skip having a function altogether. This patch also converts all existing users to use key_tex. v2: Make key_tex a "const brw_sampler_prog_key_data *" instead of non-const; word-wrap some lines. (Review comments from Topi.) Signed-off-by: Kenneth Graunke Reviewed-by: Topi Pohjolainen Reviewed-by: Jason Ekstrand --- src/mesa/drivers/dri/i965/brw_fs.h | 2 + src/mesa/drivers/dri/i965/brw_fs_nir.cpp | 7 +-- src/mesa/drivers/dri/i965/brw_fs_visitor.cpp | 59 ++++++++++++-------------- 3 files changed, 33 insertions(+), 35 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_fs.h b/src/mesa/drivers/dri/i965/brw_fs.h index d9d5858..7716529 100644 --- a/src/mesa/drivers/dri/i965/brw_fs.h +++ b/src/mesa/drivers/dri/i965/brw_fs.h @@ -417,6 +417,8 @@ public: void visit_atomic_counter_intrinsic(ir_call *ir); const void *const key; + const struct brw_sampler_prog_key_data *key_tex; + struct brw_stage_prog_data *prog_data; unsigned int sanity_param_count; diff --git a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp index c23ec89..28ef417 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp @@ -1612,7 +1612,6 @@ fs_visitor::nir_emit_intrinsic(nir_intrinsic_instr *instr) void fs_visitor::nir_emit_texture(nir_tex_instr *instr) { - brw_wm_prog_key *key = (brw_wm_prog_key*) this->key; unsigned sampler = instr->sampler_index; fs_reg sampler_reg(sampler); @@ -1709,10 +1708,12 @@ fs_visitor::nir_emit_texture(nir_tex_instr *instr) } if (instr->op == nir_texop_txf_ms) { - if (brw->gen >= 7 && key->tex.compressed_multisample_layout_mask & (1<gen >= 7 && + key_tex->compressed_multisample_layout_mask & (1 << sampler)) { mcs = emit_mcs_fetch(coordinate, instr->coord_components, sampler_reg); - else + } else { mcs = fs_reg(0u); + } } for (unsigned i = 0; i < 3; i++) { diff --git a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp index 3025a9d..5d4b166 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp @@ -1860,19 +1860,6 @@ fs_visitor::emit_texture_gen7(ir_texture_opcode op, fs_reg dst, return inst; } -static struct brw_sampler_prog_key_data * -get_tex(gl_shader_stage stage, const void *key) -{ - switch (stage) { - case MESA_SHADER_FRAGMENT: - return &((brw_wm_prog_key*) key)->tex; - case MESA_SHADER_VERTEX: - return &((brw_vue_prog_key*) key)->tex; - default: - unreachable("unhandled shader stage"); - } -} - fs_reg fs_visitor::rescale_texcoord(fs_reg coordinate, int coord_components, bool is_rect, uint32_t sampler, int texunit) @@ -1880,7 +1867,6 @@ fs_visitor::rescale_texcoord(fs_reg coordinate, int coord_components, fs_inst *inst = NULL; bool needs_gl_clamp = true; fs_reg scale_x, scale_y; - struct brw_sampler_prog_key_data *tex = get_tex(stage, this->key); /* The 965 requires the EU to do the normalization of GL rectangle * texture coordinates. We use the program parameter state @@ -1888,8 +1874,8 @@ fs_visitor::rescale_texcoord(fs_reg coordinate, int coord_components, */ if (is_rect && (brw->gen < 6 || - (brw->gen >= 6 && (tex->gl_clamp_mask[0] & (1 << sampler) || - tex->gl_clamp_mask[1] & (1 << sampler))))) { + (brw->gen >= 6 && (key_tex->gl_clamp_mask[0] & (1 << sampler) || + key_tex->gl_clamp_mask[1] & (1 << sampler))))) { struct gl_program_parameter_list *params = prog->Parameters; int tokens[STATE_LENGTH] = { STATE_INTERNAL, @@ -1950,7 +1936,7 @@ fs_visitor::rescale_texcoord(fs_reg coordinate, int coord_components, needs_gl_clamp = false; for (int i = 0; i < 2; i++) { - if (tex->gl_clamp_mask[i] & (1 << sampler)) { + if (key_tex->gl_clamp_mask[i] & (1 << sampler)) { fs_reg chan = coordinate; chan = offset(chan, i); @@ -1975,7 +1961,7 @@ fs_visitor::rescale_texcoord(fs_reg coordinate, int coord_components, if (coord_components > 0 && needs_gl_clamp) { for (int i = 0; i < MIN2(coord_components, 3); i++) { - if (tex->gl_clamp_mask[i] & (1 << sampler)) { + if (key_tex->gl_clamp_mask[i] & (1 << sampler)) { fs_reg chan = coordinate; chan = offset(chan, i); @@ -2033,14 +2019,13 @@ fs_visitor::emit_texture(ir_texture_opcode op, uint32_t sampler, fs_reg sampler_reg, int texunit) { - struct brw_sampler_prog_key_data *tex = get_tex(stage, this->key); fs_inst *inst = NULL; if (op == ir_tg4) { /* When tg4 is used with the degenerate ZERO/ONE swizzles, don't bother * emitting anything other than setting up the constant result. */ - int swiz = GET_SWZ(tex->swizzles[sampler], gather_component); + int swiz = GET_SWZ(key_tex->swizzles[sampler], gather_component); if (swiz == SWIZZLE_ZERO || swiz == SWIZZLE_ONE) { fs_reg res = vgrf(glsl_type::vec4_type); @@ -2094,7 +2079,7 @@ fs_visitor::emit_texture(ir_texture_opcode op, gather_channel(gather_component, sampler) << 16; /* M0.2:16-17 */ if (brw->gen == 6) - emit_gen6_gather_wa(tex->gen6_gather_wa[sampler], dst); + emit_gen6_gather_wa(key_tex->gen6_gather_wa[sampler], dst); } /* fixup #layers for cube map arrays */ @@ -2121,7 +2106,6 @@ fs_visitor::emit_texture(ir_texture_opcode op, void fs_visitor::visit(ir_texture *ir) { - const struct brw_sampler_prog_key_data *tex = get_tex(stage, this->key); uint32_t sampler = _mesa_get_sampler_uniform_value(ir->sampler, shader_prog, prog); @@ -2238,11 +2222,13 @@ fs_visitor::visit(ir_texture *ir) ir->lod_info.sample_index->accept(this); sample_index = this->result; - if (brw->gen >= 7 && tex->compressed_multisample_layout_mask & (1<gen >= 7 && + key_tex->compressed_multisample_layout_mask & (1 << sampler)) { mcs = emit_mcs_fetch(coordinate, ir->coordinate->type->vector_elements, sampler_reg); - else + } else { mcs = fs_reg(0u); + } break; default: unreachable("Unrecognized texture opcode"); @@ -2302,15 +2288,14 @@ fs_visitor::emit_gen6_gather_wa(uint8_t wa, fs_reg dst) uint32_t fs_visitor::gather_channel(int orig_chan, uint32_t sampler) { - struct brw_sampler_prog_key_data *tex = get_tex(stage, this->key); - int swiz = GET_SWZ(tex->swizzles[sampler], orig_chan); + int swiz = GET_SWZ(key_tex->swizzles[sampler], orig_chan); switch (swiz) { case SWIZZLE_X: return 0; case SWIZZLE_Y: /* gather4 sampler is broken for green channel on RG32F -- * we must ask for blue instead. */ - if (tex->gather_channel_quirk_mask & (1<gather_channel_quirk_mask & (1 << sampler)) return 2; return 1; case SWIZZLE_Z: return 2; @@ -2342,16 +2327,14 @@ fs_visitor::swizzle_result(ir_texture_opcode op, int dest_components, if (op == ir_txs || op == ir_lod || op == ir_tg4) return; - struct brw_sampler_prog_key_data *tex = get_tex(stage, this->key); - if (dest_components == 1) { /* Ignore DEPTH_TEXTURE_MODE swizzling. */ - } else if (tex->swizzles[sampler] != SWIZZLE_NOOP) { + } else if (key_tex->swizzles[sampler] != SWIZZLE_NOOP) { fs_reg swizzled_result = vgrf(glsl_type::vec4_type); swizzled_result.type = orig_val.type; for (int i = 0; i < 4; i++) { - int swiz = GET_SWZ(tex->swizzles[sampler], i); + int swiz = GET_SWZ(key_tex->swizzles[sampler], i); fs_reg l = swizzled_result; l = offset(l, i); @@ -2361,7 +2344,7 @@ fs_visitor::swizzle_result(ir_texture_opcode op, int dest_components, emit(MOV(l, fs_reg(1.0f))); } else { emit(MOV(l, offset(orig_val, - GET_SWZ(tex->swizzles[sampler], i)))); + GET_SWZ(key_tex->swizzles[sampler], i)))); } } this->result = swizzled_result; @@ -4034,6 +4017,18 @@ fs_visitor::fs_visitor(struct brw_context *brw, void fs_visitor::init() { + switch (stage) { + case MESA_SHADER_FRAGMENT: + key_tex = &((const brw_wm_prog_key *) key)->tex; + break; + case MESA_SHADER_VERTEX: + case MESA_SHADER_GEOMETRY: + key_tex = &((const brw_vue_prog_key *) key)->tex; + break; + default: + unreachable("unhandled shader stage"); + } + this->failed = false; this->simd16_unsupported = false; this->no16_msg = NULL; From kwg at kemper.freedesktop.org Thu Mar 12 19:20:19 2015 From: kwg at kemper.freedesktop.org (Kenneth Graunke) Date: Thu, 12 Mar 2015 12:20:19 -0700 (PDT) Subject: Mesa (master): i965/fs: Refactor fs_visitor::nir_setup_inputs(). Message-ID: <20150312192019.7C80F761DF@kemper.freedesktop.org> Module: Mesa Branch: master Commit: a5c4e7fcf52c048c02e4ee14413a574b4ff3695e URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=a5c4e7fcf52c048c02e4ee14413a574b4ff3695e Author: Kenneth Graunke Date: Mon Mar 9 01:58:56 2015 -0700 i965/fs: Refactor fs_visitor::nir_setup_inputs(). No functional change. In preparation for supporting vertex shaders, this adds a switch statement on shader stage (since vertex attributes and fragment shader varyings will need different handling). It also renames "varying" to "input", to be more general. Signed-off-by: Kenneth Graunke Reviewed-by: Topi Pohjolainen Reviewed-by: Jason Ekstrand --- src/mesa/drivers/dri/i965/brw_fs_nir.cpp | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp index 7b83a35..9a76745 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp @@ -199,18 +199,27 @@ fs_visitor::nir_setup_inputs(nir_shader *shader) struct hash_entry *entry; hash_table_foreach(shader->inputs, entry) { nir_variable *var = (nir_variable *) entry->data; - fs_reg varying = offset(nir_inputs, var->data.driver_location); + fs_reg input = offset(nir_inputs, var->data.driver_location); fs_reg reg; - if (var->data.location == VARYING_SLOT_POS) { - reg = *emit_fragcoord_interpolation(var->data.pixel_center_integer, - var->data.origin_upper_left); - emit_percomp(MOV(varying, reg), 0xF); - } else { - emit_general_interpolation(varying, var->name, var->type, - (glsl_interp_qualifier) var->data.interpolation, - var->data.location, var->data.centroid, - var->data.sample); + switch (stage) { + case MESA_SHADER_VERTEX: + case MESA_SHADER_GEOMETRY: + case MESA_SHADER_COMPUTE: + unreachable("fs_visitor not used for these stages yet."); + break; + case MESA_SHADER_FRAGMENT: + if (var->data.location == VARYING_SLOT_POS) { + reg = *emit_fragcoord_interpolation(var->data.pixel_center_integer, + var->data.origin_upper_left); + emit_percomp(MOV(input, reg), 0xF); + } else { + emit_general_interpolation(input, var->name, var->type, + (glsl_interp_qualifier) var->data.interpolation, + var->data.location, var->data.centroid, + var->data.sample); + } + break; } } } From kwg at kemper.freedesktop.org Thu Mar 12 19:20:19 2015 From: kwg at kemper.freedesktop.org (Kenneth Graunke) Date: Thu, 12 Mar 2015 12:20:19 -0700 (PDT) Subject: Mesa (master): nir: Add intrinsics for SYSTEM_VALUE_BASE_VERTEX and VERTEX_ID_ZERO_BASE Message-ID: <20150312192019.6BCE076359@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 2c79f6f9c339448b5361f080e8f373cea5de3179 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=2c79f6f9c339448b5361f080e8f373cea5de3179 Author: Kenneth Graunke Date: Mon Mar 9 01:58:54 2015 -0700 nir: Add intrinsics for SYSTEM_VALUE_BASE_VERTEX and VERTEX_ID_ZERO_BASE Ian and I added these around the time Connor was developing NIR. Now that both exist, we should make them work together! Signed-off-by: Kenneth Graunke Reviewed-by: Ian Romanick Reviewed-by: Jason Ekstrand --- src/glsl/nir/nir_intrinsics.h | 2 ++ src/glsl/nir/nir_lower_system_values.c | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/src/glsl/nir/nir_intrinsics.h b/src/glsl/nir/nir_intrinsics.h index 3bf102f..8e28765 100644 --- a/src/glsl/nir/nir_intrinsics.h +++ b/src/glsl/nir/nir_intrinsics.h @@ -95,6 +95,8 @@ ATOMIC(read, NIR_INTRINSIC_CAN_ELIMINATE) SYSTEM_VALUE(front_face, 1) SYSTEM_VALUE(vertex_id, 1) +SYSTEM_VALUE(vertex_id_zero_base, 1) +SYSTEM_VALUE(base_vertex, 1) SYSTEM_VALUE(instance_id, 1) SYSTEM_VALUE(sample_id, 1) SYSTEM_VALUE(sample_pos, 2) diff --git a/src/glsl/nir/nir_lower_system_values.c b/src/glsl/nir/nir_lower_system_values.c index 328d4f1..a6eec65 100644 --- a/src/glsl/nir/nir_lower_system_values.c +++ b/src/glsl/nir/nir_lower_system_values.c @@ -49,6 +49,12 @@ convert_instr(nir_intrinsic_instr *instr) case SYSTEM_VALUE_VERTEX_ID: op = nir_intrinsic_load_vertex_id; break; + case SYSTEM_VALUE_VERTEX_ID_ZERO_BASE: + op = nir_intrinsic_load_vertex_id_zero_base; + break; + case SYSTEM_VALUE_BASE_VERTEX: + op = nir_intrinsic_load_base_vertex; + break; case SYSTEM_VALUE_INSTANCE_ID: op = nir_intrinsic_load_instance_id; break; From kwg at kemper.freedesktop.org Thu Mar 12 19:20:19 2015 From: kwg at kemper.freedesktop.org (Kenneth Graunke) Date: Thu, 12 Mar 2015 12:20:19 -0700 (PDT) Subject: Mesa (master): i965/nir: Lower to registers a bit later. Message-ID: <20150312192019.6481E7633E@kemper.freedesktop.org> Module: Mesa Branch: master Commit: b9dea9bc45299f19c445170a4cac27810547de00 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=b9dea9bc45299f19c445170a4cac27810547de00 Author: Kenneth Graunke Date: Mon Mar 9 01:58:53 2015 -0700 i965/nir: Lower to registers a bit later. We can't safely call nir_optimize() with register present, since several passes called in the loop can't handle registers, and will fail asserts. Notably, nir_lower_vec_alus() and nir_opt_algebraic() really don't want registers. Signed-off-by: Kenneth Graunke Reviewed-by: Jason Ekstrand --- src/mesa/drivers/dri/i965/brw_fs_nir.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp index ef83693..c225c00 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp @@ -108,9 +108,6 @@ fs_visitor::emit_nir_code() nir_lower_io(nir); nir_validate_shader(nir); - nir_lower_locals_to_regs(nir); - nir_validate_shader(nir); - nir_remove_dead_variables(nir); nir_validate_shader(nir); @@ -125,6 +122,9 @@ fs_visitor::emit_nir_code() nir_optimize(nir); + nir_lower_locals_to_regs(nir); + nir_validate_shader(nir); + nir_lower_to_source_mods(nir); nir_validate_shader(nir); nir_copy_prop(nir); From kwg at kemper.freedesktop.org Thu Mar 12 19:20:19 2015 From: kwg at kemper.freedesktop.org (Kenneth Graunke) Date: Thu, 12 Mar 2015 12:20:19 -0700 (PDT) Subject: Mesa (master): i965/fs: Handle VS inputs in the NIR backend. Message-ID: <20150312192019.873B7761DF@kemper.freedesktop.org> Module: Mesa Branch: master Commit: eb137117b7db6c78d6a1662730524d622301c708 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=eb137117b7db6c78d6a1662730524d622301c708 Author: Kenneth Graunke Date: Mon Mar 9 01:58:57 2015 -0700 i965/fs: Handle VS inputs in the NIR backend. (Jason noted that this is not a good long term solution, and we should instead improve nir_lower_io so that this extra set of MOVs is unnecessary. I tend to agree, but decided we could do that as a follow-up improvement.) Signed-off-by: Kenneth Graunke Reviewed-by: Jason Ekstrand --- src/mesa/drivers/dri/i965/brw_fs_nir.cpp | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp index 9a76745..dbfb274 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp @@ -199,11 +199,32 @@ fs_visitor::nir_setup_inputs(nir_shader *shader) struct hash_entry *entry; hash_table_foreach(shader->inputs, entry) { nir_variable *var = (nir_variable *) entry->data; + enum brw_reg_type type = brw_type_for_base_type(var->type); fs_reg input = offset(nir_inputs, var->data.driver_location); fs_reg reg; switch (stage) { - case MESA_SHADER_VERTEX: + case MESA_SHADER_VERTEX: { + /* Our ATTR file is indexed by VERT_ATTRIB_*, which is the value + * stored in nir_variable::location. + * + * However, NIR's load_input intrinsics use a different index - an + * offset into a single contiguous array containing all inputs. + * This index corresponds to the nir_variable::driver_location field. + * + * So, we need to copy from fs_reg(ATTR, var->location) to + * offset(nir_inputs, var->data.driver_location). + */ + unsigned components = var->type->without_array()->components(); + unsigned array_length = var->type->is_array() ? var->type->length : 1; + for (unsigned i = 0; i < array_length; i++) { + for (unsigned j = 0; j < components; j++) { + emit(MOV(retype(offset(input, components * i + j), type), + offset(fs_reg(ATTR, var->data.location + i, type), j))); + } + } + break; + } case MESA_SHADER_GEOMETRY: case MESA_SHADER_COMPUTE: unreachable("fs_visitor not used for these stages yet."); From kwg at kemper.freedesktop.org Thu Mar 12 19:20:19 2015 From: kwg at kemper.freedesktop.org (Kenneth Graunke) Date: Thu, 12 Mar 2015 12:20:19 -0700 (PDT) Subject: Mesa (master): i965: Implement NIR intrinsics for loading VS system values. Message-ID: <20150312192019.7453D761DF@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 34628a838aa96643be02cd23eb55af50025dd422 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=34628a838aa96643be02cd23eb55af50025dd422 Author: Kenneth Graunke Date: Mon Mar 9 01:58:55 2015 -0700 i965: Implement NIR intrinsics for loading VS system values. Signed-off-by: Kenneth Graunke Reviewed-by: Jason Ekstrand --- src/mesa/drivers/dri/i965/brw_fs_nir.cpp | 51 ++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp index c225c00..7b83a35 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp @@ -363,6 +363,30 @@ emit_system_values_block(nir_block *block, void *void_visitor) nir_intrinsic_instr *intrin = nir_instr_as_intrinsic(instr); switch (intrin->intrinsic) { + case nir_intrinsic_load_vertex_id: + unreachable("should be lowered by lower_vertex_id()."); + + case nir_intrinsic_load_vertex_id_zero_base: + assert(v->stage == MESA_SHADER_VERTEX); + reg = &v->nir_system_values[SYSTEM_VALUE_VERTEX_ID_ZERO_BASE]; + if (reg->file == BAD_FILE) + *reg = *v->emit_vs_system_value(SYSTEM_VALUE_VERTEX_ID_ZERO_BASE); + break; + + case nir_intrinsic_load_base_vertex: + assert(v->stage == MESA_SHADER_VERTEX); + reg = &v->nir_system_values[SYSTEM_VALUE_BASE_VERTEX]; + if (reg->file == BAD_FILE) + *reg = *v->emit_vs_system_value(SYSTEM_VALUE_BASE_VERTEX); + break; + + case nir_intrinsic_load_instance_id: + assert(v->stage == MESA_SHADER_VERTEX); + reg = &v->nir_system_values[SYSTEM_VALUE_INSTANCE_ID]; + if (reg->file == BAD_FILE) + *reg = *v->emit_vs_system_value(SYSTEM_VALUE_INSTANCE_ID); + break; + case nir_intrinsic_load_sample_pos: assert(v->stage == MESA_SHADER_FRAGMENT); reg = &v->nir_system_values[SYSTEM_VALUE_SAMPLE_POS]; @@ -1344,6 +1368,33 @@ fs_visitor::nir_emit_intrinsic(nir_intrinsic_instr *instr) *emit_frontfacing_interpolation())); break; + case nir_intrinsic_load_vertex_id: + unreachable("should be lowered by lower_vertex_id()"); + + case nir_intrinsic_load_vertex_id_zero_base: { + fs_reg vertex_id = nir_system_values[SYSTEM_VALUE_VERTEX_ID_ZERO_BASE]; + assert(vertex_id.file != BAD_FILE); + dest.type = vertex_id.type; + emit(MOV(dest, vertex_id)); + break; + } + + case nir_intrinsic_load_base_vertex: { + fs_reg base_vertex = nir_system_values[SYSTEM_VALUE_BASE_VERTEX]; + assert(base_vertex.file != BAD_FILE); + dest.type = base_vertex.type; + emit(MOV(dest, base_vertex)); + break; + } + + case nir_intrinsic_load_instance_id: { + fs_reg instance_id = nir_system_values[SYSTEM_VALUE_INSTANCE_ID]; + assert(instance_id.file != BAD_FILE); + dest.type = instance_id.type; + emit(MOV(dest, instance_id)); + break; + } + case nir_intrinsic_load_sample_mask_in: { fs_reg sample_mask_in = nir_system_values[SYSTEM_VALUE_SAMPLE_MASK_IN]; assert(sample_mask_in.file != BAD_FILE); From kwg at kemper.freedesktop.org Thu Mar 12 19:20:19 2015 From: kwg at kemper.freedesktop.org (Kenneth Graunke) Date: Thu, 12 Mar 2015 12:20:19 -0700 (PDT) Subject: Mesa (master): i965/fs: Add VS output support to nir_setup_outputs(). Message-ID: <20150312192019.8F64B761DF@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 7ef0b6b367f73e24e6dd47a15d439775d3dd1297 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=7ef0b6b367f73e24e6dd47a15d439775d3dd1297 Author: Kenneth Graunke Date: Mon Mar 9 01:58:58 2015 -0700 i965/fs: Add VS output support to nir_setup_outputs(). Adapted from fs_visitor::visit(ir_variable *). Signed-off-by: Kenneth Graunke Reviewed-by: Jason Ekstrand --- src/mesa/drivers/dri/i965/brw_fs_nir.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp index dbfb274..a9e75ab 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp @@ -255,7 +255,17 @@ fs_visitor::nir_setup_outputs(nir_shader *shader) nir_variable *var = (nir_variable *) entry->data; fs_reg reg = offset(nir_outputs, var->data.driver_location); - if (var->data.index > 0) { + int vector_elements = + var->type->is_array() ? var->type->fields.array->vector_elements + : var->type->vector_elements; + + if (stage == MESA_SHADER_VERTEX) { + for (int i = 0; i < ALIGN(type_size(var->type), 4) / 4; i++) { + int output = var->data.location + i; + this->outputs[output] = offset(reg, 4 * i); + this->output_components[output] = vector_elements; + } + } else if (var->data.index > 0) { assert(var->data.location == FRAG_RESULT_DATA0); assert(var->data.index == 1); this->dual_src_output = reg; @@ -275,10 +285,6 @@ fs_visitor::nir_setup_outputs(nir_shader *shader) assert(var->data.location >= FRAG_RESULT_DATA0 && var->data.location < FRAG_RESULT_DATA0 + BRW_MAX_DRAW_BUFFERS); - int vector_elements = - var->type->is_array() ? var->type->fields.array->vector_elements - : var->type->vector_elements; - /* General color output. */ for (unsigned int i = 0; i < MAX2(1, var->type->length); i++) { int output = var->data.location - FRAG_RESULT_DATA0 + i; From kwg at kemper.freedesktop.org Thu Mar 12 19:20:19 2015 From: kwg at kemper.freedesktop.org (Kenneth Graunke) Date: Thu, 12 Mar 2015 12:20:19 -0700 (PDT) Subject: Mesa (master): i965: Use NIR for scalar VS when INTEL_USE_NIR is set. Message-ID: <20150312192019.98673761DF@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 547c760964bcad23a056e5156e4fefd7487c0192 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=547c760964bcad23a056e5156e4fefd7487c0192 Author: Kenneth Graunke Date: Mon Mar 9 01:58:59 2015 -0700 i965: Use NIR for scalar VS when INTEL_USE_NIR is set. Signed-off-by: Kenneth Graunke Reviewed-by: Jason Ekstrand --- src/mesa/drivers/dri/i965/brw_fs.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp index 6d7cf0e..8702ea8 100644 --- a/src/mesa/drivers/dri/i965/brw_fs.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs.cpp @@ -3840,12 +3840,17 @@ fs_visitor::run_vs() if (INTEL_DEBUG & DEBUG_SHADER_TIME) emit_shader_time_begin(); - foreach_in_list(ir_instruction, ir, shader->base.ir) { - base_ir = ir; - this->result = reg_undef; - ir->accept(this); + if (getenv("INTEL_USE_NIR") != NULL) { + emit_nir_code(); + } else { + foreach_in_list(ir_instruction, ir, shader->base.ir) { + base_ir = ir; + this->result = reg_undef; + ir->accept(this); + } + base_ir = NULL; } - base_ir = NULL; + if (failed) return false; From jekstrand at kemper.freedesktop.org Thu Mar 12 20:27:06 2015 From: jekstrand at kemper.freedesktop.org (Jason Ekstrand) Date: Thu, 12 Mar 2015 13:27:06 -0700 (PDT) Subject: Mesa (master): util: Fix foreach_list_typed_safe when exec_node is not at offset 0. Message-ID: <20150312202706.ED738761DF@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 67388c1ef27e9ff4d7f60a496dbaea4b290dc741 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=67388c1ef27e9ff4d7f60a496dbaea4b290dc741 Author: Jason Ekstrand Date: Mon Mar 9 18:36:30 2015 -0700 util: Fix foreach_list_typed_safe when exec_node is not at offset 0. __next and __prev are pointers to the structure containing the exec_node link, not the embedded exec_node. NULL checks would fail unless the embedded exec_node happened to be at offset 0 in the parent struct. v2: Jason Ekstrand : Use "(__node)->__field.next != NULL" to check for the end of the list instead of the "&__next->__field != NULL". The former is far more obviously correct as it matches what the non-safe versions do. The original code tried to avoid any use of __next as the client code may delete it during its execution. However, since the looping condition is checked after the iteration clause but before the client code is executed, we know that __node is valid during the looping condition. Signed-off-by: Jason Ekstrand Reviewed-by: Matt Turner Reviewed-by: Connor Abbott Reviewed-by: Kenneth Graunke --- src/glsl/list.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/glsl/list.h b/src/glsl/list.h index ddb98f7..15fcd4a 100644 --- a/src/glsl/list.h +++ b/src/glsl/list.h @@ -684,7 +684,7 @@ inline void exec_node::insert_before(exec_list *before) exec_node_data(__type, (__list)->head, __field), \ * __next = \ exec_node_data(__type, (__node)->__field.next, __field); \ - __next != NULL; \ + (__node)->__field.next != NULL; \ __node = __next, __next = \ exec_node_data(__type, (__next)->__field.next, __field)) @@ -693,7 +693,7 @@ inline void exec_node::insert_before(exec_list *before) exec_node_data(__type, (__list)->tail_pred, __field), \ * __prev = \ exec_node_data(__type, (__node)->__field.prev, __field); \ - __prev != NULL; \ + (__node)->__field.prev != NULL; \ __node = __prev, __prev = \ exec_node_data(__type, (__prev)->__field.prev, __field)) From jekstrand at kemper.freedesktop.org Thu Mar 12 20:27:07 2015 From: jekstrand at kemper.freedesktop.org (Jason Ekstrand) Date: Thu, 12 Mar 2015 13:27:07 -0700 (PDT) Subject: Mesa (master): nir: Fix non-determinism in nir_lower_vars_to_ssa(). Message-ID: <20150312202707.026477633D@kemper.freedesktop.org> Module: Mesa Branch: master Commit: f3e4b2c9d2087c7f655d323cc6b4150313fc0128 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=f3e4b2c9d2087c7f655d323cc6b4150313fc0128 Author: Kenneth Graunke Date: Mon Mar 9 18:36:31 2015 -0700 nir: Fix non-determinism in nir_lower_vars_to_ssa(). Previously, we stored derefs in a hash table, using the malloc'd pointer as the key. Then, we walked through the hash table and generated code, based on the order of the hash table's elements. Memory addresses returned by malloc are pretty much random, which meant that the hash was random, and the hash table's elements would be walked in some random order. This led to successive compiles of the same shader using different variable names and slightly different orderings of phi-nodes. Code could not be diff'd, and the final assembly would sometimes change slightly too. It turns out the only point of the hash table was to avoid inserting the same node multiple times for different dereferences. We never actually searched the hash table! This patch uses an intrusive linked list instead. Since exec_list uses head and tail sentinels, checking prev or next against NULL will tell us whether the node is already in the list. Pair programming with Jason Ekstrand. Signed-off-by: Jason Ekstrand Signed-off-by: Kenneth Graunke Reviewed-by: Connor Abbott --- src/glsl/nir/nir_lower_vars_to_ssa.c | 123 +++++++--------------------------- 1 file changed, 26 insertions(+), 97 deletions(-) diff --git a/src/glsl/nir/nir_lower_vars_to_ssa.c b/src/glsl/nir/nir_lower_vars_to_ssa.c index 9e9a418..86e6ab4 100644 --- a/src/glsl/nir/nir_lower_vars_to_ssa.c +++ b/src/glsl/nir/nir_lower_vars_to_ssa.c @@ -35,6 +35,13 @@ struct deref_node { bool lower_to_ssa; + /* Only valid for things that end up in the direct list. + * Note that multiple nir_deref_vars may correspond to this node, but they + * will all be equivalent, so any is as good as the other. + */ + nir_deref_var *deref; + struct exec_node direct_derefs_link; + struct set *loads; struct set *stores; struct set *copies; @@ -69,7 +76,7 @@ struct lower_variables_state { * wildcards and no indirects, these are precisely the derefs that we * can actually consider lowering. */ - struct hash_table *direct_deref_nodes; + struct exec_list direct_deref_nodes; /* Controls whether get_deref_node will add variables to the * direct_deref_nodes table. This is turned on when we are initially @@ -83,88 +90,6 @@ struct lower_variables_state { struct hash_table *phi_table; }; -/* The following two functions implement a hash and equality check for - * variable dreferences. When the hash or equality function encounters an - * array, all indirects are treated as equal and are never equal to a - * direct dereference or a wildcard. - */ -static uint32_t -hash_deref(const void *void_deref) -{ - uint32_t hash = _mesa_fnv32_1a_offset_bias; - - const nir_deref_var *deref_var = void_deref; - hash = _mesa_fnv32_1a_accumulate(hash, deref_var->var); - - for (const nir_deref *deref = deref_var->deref.child; - deref; deref = deref->child) { - switch (deref->deref_type) { - case nir_deref_type_array: { - nir_deref_array *deref_array = nir_deref_as_array(deref); - - hash = _mesa_fnv32_1a_accumulate(hash, deref_array->deref_array_type); - - if (deref_array->deref_array_type == nir_deref_array_type_direct) - hash = _mesa_fnv32_1a_accumulate(hash, deref_array->base_offset); - break; - } - case nir_deref_type_struct: { - nir_deref_struct *deref_struct = nir_deref_as_struct(deref); - hash = _mesa_fnv32_1a_accumulate(hash, deref_struct->index); - break; - } - default: - assert("Invalid deref chain"); - } - } - - return hash; -} - -static bool -derefs_equal(const void *void_a, const void *void_b) -{ - const nir_deref_var *a_var = void_a; - const nir_deref_var *b_var = void_b; - - if (a_var->var != b_var->var) - return false; - - for (const nir_deref *a = a_var->deref.child, *b = b_var->deref.child; - a != NULL; a = a->child, b = b->child) { - if (a->deref_type != b->deref_type) - return false; - - switch (a->deref_type) { - case nir_deref_type_array: { - nir_deref_array *a_arr = nir_deref_as_array(a); - nir_deref_array *b_arr = nir_deref_as_array(b); - - if (a_arr->deref_array_type != b_arr->deref_array_type) - return false; - - if (a_arr->deref_array_type == nir_deref_array_type_direct && - a_arr->base_offset != b_arr->base_offset) - return false; - break; - } - case nir_deref_type_struct: - if (nir_deref_as_struct(a)->index != nir_deref_as_struct(b)->index) - return false; - break; - default: - assert("Invalid deref chain"); - return false; - } - - assert((a->child == NULL) == (b->child == NULL)); - if((a->child == NULL) != (b->child == NULL)) - return false; - } - - return true; -} - static int type_get_length(const struct glsl_type *type) { @@ -195,6 +120,8 @@ deref_node_create(struct deref_node *parent, struct deref_node *node = rzalloc_size(mem_ctx, size); node->type = type; node->parent = parent; + node->deref = NULL; + exec_node_init(&node->direct_derefs_link); return node; } @@ -297,8 +224,14 @@ get_deref_node(nir_deref_var *deref, struct lower_variables_state *state) assert(node); - if (is_direct && state->add_to_direct_deref_nodes) - _mesa_hash_table_insert(state->direct_deref_nodes, deref, node); + /* Only insert if it isn't already in the list. */ + if (is_direct && state->add_to_direct_deref_nodes && + node->direct_derefs_link.next == NULL) { + node->deref = deref; + assert(deref->var != NULL); + exec_list_push_tail(&state->direct_deref_nodes, + &node->direct_derefs_link); + } return node; } @@ -917,10 +850,8 @@ insert_phi_nodes(struct lower_variables_state *state) unsigned w_start, w_end; unsigned iter_count = 0; - struct hash_entry *deref_entry; - hash_table_foreach(state->direct_deref_nodes, deref_entry) { - struct deref_node *node = deref_entry->data; - + foreach_list_typed(struct deref_node, node, direct_derefs_link, + &state->direct_deref_nodes) { if (node->stores == NULL) continue; @@ -1014,8 +945,7 @@ nir_lower_vars_to_ssa_impl(nir_function_impl *impl) state.deref_var_nodes = _mesa_hash_table_create(state.dead_ctx, _mesa_hash_pointer, _mesa_key_pointer_equal); - state.direct_deref_nodes = _mesa_hash_table_create(state.dead_ctx, - hash_deref, derefs_equal); + exec_list_make_empty(&state.direct_deref_nodes); state.phi_table = _mesa_hash_table_create(state.dead_ctx, _mesa_hash_pointer, _mesa_key_pointer_equal); @@ -1035,18 +965,17 @@ nir_lower_vars_to_ssa_impl(nir_function_impl *impl) /* We're about to iterate through direct_deref_nodes. Don't modify it. */ state.add_to_direct_deref_nodes = false; - struct hash_entry *entry; - hash_table_foreach(state.direct_deref_nodes, entry) { - nir_deref_var *deref = (void *)entry->key; - struct deref_node *node = entry->data; + foreach_list_typed_safe(struct deref_node, node, direct_derefs_link, + &state.direct_deref_nodes) { + nir_deref_var *deref = node->deref; if (deref->var->data.mode != nir_var_local) { - _mesa_hash_table_remove(state.direct_deref_nodes, entry); + exec_node_remove(&node->direct_derefs_link); continue; } if (deref_may_be_aliased(deref, &state)) { - _mesa_hash_table_remove(state.direct_deref_nodes, entry); + exec_node_remove(&node->direct_derefs_link); continue; } From jekstrand at kemper.freedesktop.org Fri Mar 13 05:01:55 2015 From: jekstrand at kemper.freedesktop.org (Jason Ekstrand) Date: Thu, 12 Mar 2015 22:01:55 -0700 (PDT) Subject: Mesa (master): mesa: improve ARB_copy_image internal format compat check Message-ID: <20150313050155.55D7B761DF@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 1a469a34d517d4c24c60a613c7d1a56f77778c8e URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=1a469a34d517d4c24c60a613c7d1a56f77778c8e Author: Se?n de B?rca Date: Sat Mar 7 02:23:53 2015 -0700 mesa: improve ARB_copy_image internal format compat check The memory layout of compatible internal formats may differ in bytes per block, so TexFormat is not a reliable measure of compatibility. For example, GL_RGB8 and GL_RGB8UI are compatible formats, but GL_RGB8 may be laid out in memory as B8G8R8X8. If GL_RGB8UI has a 3 byte-per-block memory layout, the existing compatibility check will fail. Additionally, the current check allows any two compressed textures which share block size to be used, whereas the spec gives an explicit table of compatible formats. v2: Use a switch instead of array iteration for block class and show the correct GL error when internal formats are mismatched. v3: Include spec citations for new compatibility checks, rearrange check order to ensure that compressed, view-compatible formats return the correct result, and make style fixes. Original commit message amended for clarity. v4: Reformatted spec citations. Reviewed-by: Jason Ekstrand --- src/mesa/main/copyimage.c | 151 ++++++++++++++++++++++++++++++++++++++------- 1 file changed, 130 insertions(+), 21 deletions(-) diff --git a/src/mesa/main/copyimage.c b/src/mesa/main/copyimage.c index 455929d..fd22f28 100644 --- a/src/mesa/main/copyimage.c +++ b/src/mesa/main/copyimage.c @@ -33,6 +33,12 @@ #include "texobj.h" #include "fbobject.h" #include "textureview.h" +#include "glformats.h" + +enum mesa_block_class { + BLOCK_CLASS_128_BITS, + BLOCK_CLASS_64_BITS +}; static bool prepare_target(struct gl_context *ctx, GLuint name, GLenum *target, int level, @@ -253,6 +259,124 @@ check_region_bounds(struct gl_context *ctx, struct gl_texture_image *tex_image, return true; } +static bool +compressed_format_compatible(struct gl_context *ctx, + GLenum compressedFormat, GLenum otherFormat) +{ + enum mesa_block_class compressedClass, otherClass; + + /* Two view-incompatible compressed formats are never compatible. */ + if (_mesa_is_compressed_format(ctx, otherFormat)) { + return false; + } + + /* + * From ARB_copy_image spec: + * Table 4.X.1 (Compatible internal formats for copying between + * compressed and uncompressed internal formats) + * --------------------------------------------------------------------- + * | Texel / | Uncompressed | | + * | Block | internal format | Compressed internal format | + * | size | | | + * --------------------------------------------------------------------- + * | 128-bit | RGBA32UI, | COMPRESSED_RGBA_S3TC_DXT3_EXT, | + * | | RGBA32I, | COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT,| + * | | RGBA32F | COMPRESSED_RGBA_S3TC_DXT5_EXT, | + * | | | COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT,| + * | | | COMPRESSED_RG_RGTC2, | + * | | | COMPRESSED_SIGNED_RG_RGTC2, | + * | | | COMPRESSED_RGBA_BPTC_UNORM, | + * | | | COMPRESSED_SRGB_ALPHA_BPTC_UNORM, | + * | | | COMPRESSED_RGB_BPTC_SIGNED_FLOAT, | + * | | | COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT | + * --------------------------------------------------------------------- + * | 64-bit | RGBA16F, RG32F, | COMPRESSED_RGB_S3TC_DXT1_EXT, | + * | | RGBA16UI, RG32UI, | COMPRESSED_SRGB_S3TC_DXT1_EXT, | + * | | RGBA16I, RG32I, | COMPRESSED_RGBA_S3TC_DXT1_EXT, | + * | | RGBA16, | COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT,| + * | | RGBA16_SNORM | COMPRESSED_RED_RGTC1, | + * | | | COMPRESSED_SIGNED_RED_RGTC1 | + * --------------------------------------------------------------------- + */ + + switch (compressedFormat) { + case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: + case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT: + case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: + case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT: + case GL_COMPRESSED_RG_RGTC2: + case GL_COMPRESSED_SIGNED_RG_RGTC2: + case GL_COMPRESSED_RGBA_BPTC_UNORM: + case GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM: + case GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT: + case GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT: + compressedClass = BLOCK_CLASS_128_BITS; + break; + case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: + case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT: + case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: + case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT: + case GL_COMPRESSED_RED_RGTC1: + case GL_COMPRESSED_SIGNED_RED_RGTC1: + compressedClass = BLOCK_CLASS_64_BITS; + break; + default: + return false; + } + + switch (otherFormat) { + case GL_RGBA32UI: + case GL_RGBA32I: + case GL_RGBA32F: + otherClass = BLOCK_CLASS_128_BITS; + break; + case GL_RGBA16F: + case GL_RG32F: + case GL_RGBA16UI: + case GL_RG32UI: + case GL_RGBA16I: + case GL_RG32I: + case GL_RGBA16: + case GL_RGBA16_SNORM: + otherClass = BLOCK_CLASS_64_BITS; + break; + default: + return false; + } + + return compressedClass == otherClass; +} + +static bool +copy_format_compatible(struct gl_context *ctx, + GLenum srcFormat, GLenum dstFormat) +{ + /* + * From ARB_copy_image spec: + * For the purposes of CopyImageSubData, two internal formats + * are considered compatible if any of the following conditions are + * met: + * * the formats are the same, + * * the formats are considered compatible according to the + * compatibility rules used for texture views as defined in + * section 3.9.X. In particular, if both internal formats are listed + * in the same entry of Table 3.X.2, they are considered compatible, or + * * one format is compressed and the other is uncompressed and + * Table 4.X.1 lists the two formats in the same row. + */ + + if (_mesa_texture_view_compatible_format(ctx, srcFormat, dstFormat)) { + /* Also checks if formats are equal. */ + return true; + } else if (_mesa_is_compressed_format(ctx, srcFormat)) { + return compressed_format_compatible(ctx, srcFormat, dstFormat); + } else if (_mesa_is_compressed_format(ctx, dstFormat)) { + return compressed_format_compatible(ctx, dstFormat, srcFormat); + } + + return false; +} + void GLAPIENTRY _mesa_CopyImageSubData(GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, @@ -265,7 +389,7 @@ _mesa_CopyImageSubData(GLuint srcName, GLenum srcTarget, GLint srcLevel, struct gl_texture_object *srcTexObj, *dstTexObj; struct gl_texture_image *srcTexImage, *dstTexImage; GLuint src_bw, src_bh, dst_bw, dst_bh; - int i, srcNewZ, dstNewZ, Bpt; + int i, srcNewZ, dstNewZ; if (MESA_VERBOSE & VERBOSE_API) _mesa_debug(ctx, "glCopyImageSubData(%u, %s, %d, %d, %d, %d, " @@ -306,15 +430,6 @@ _mesa_CopyImageSubData(GLuint srcName, GLenum srcTarget, GLint srcLevel, goto cleanup; } - /* Very simple sanity check. This is sufficient if one of the textures - * is compressed. */ - Bpt = _mesa_get_format_bytes(srcTexImage->TexFormat); - if (_mesa_get_format_bytes(dstTexImage->TexFormat) != Bpt) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glCopyImageSubData(internalFormat mismatch)"); - goto cleanup; - } - if (!check_region_bounds(ctx, srcTexImage, srcX, srcY, srcZ, srcWidth, srcHeight, srcDepth, "src")) goto cleanup; @@ -324,17 +439,11 @@ _mesa_CopyImageSubData(GLuint srcName, GLenum srcTarget, GLint srcLevel, (srcHeight / src_bh) * dst_bh, srcDepth, "dst")) goto cleanup; - if (_mesa_is_format_compressed(srcTexImage->TexFormat)) { - /* XXX: Technically, we should probaby do some more specific checking - * here. However, this should be sufficient for all compressed - * formats that mesa supports since it is a direct memory copy. - */ - } else if (_mesa_is_format_compressed(dstTexImage->TexFormat)) { - } else if (_mesa_texture_view_compatible_format(ctx, - srcTexImage->InternalFormat, - dstTexImage->InternalFormat)) { - } else { - return; /* Error logged by _mesa_texture_view_compatible_format */ + if (!copy_format_compatible(ctx, srcTexImage->InternalFormat, + dstTexImage->InternalFormat)) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glCopyImageSubData(internalFormat mismatch)"); + goto cleanup; } for (i = 0; i < srcDepth; ++i) { From jrfonseca at kemper.freedesktop.org Fri Mar 13 13:53:13 2015 From: jrfonseca at kemper.freedesktop.org (Jose Fonseca) Date: Fri, 13 Mar 2015 06:53:13 -0700 (PDT) Subject: Mesa (master): gallivm: (trivial) Fix typo in comment introduced by 70dc8a Message-ID: <20150313135313.E0D9C76250@kemper.freedesktop.org> Module: Mesa Branch: master Commit: a38e6c4fbd6a941ec9ffb98bdf9f040cccda0247 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=a38e6c4fbd6a941ec9ffb98bdf9f040cccda0247 Author: Alexandre Demers Date: Thu Mar 12 20:50:08 2015 -0400 gallivm: (trivial) Fix typo in comment introduced by 70dc8a Fix typo in comment introduced by 70dc8a Signed-off-by: Alexandre Demers Signed-off-by: Jose Fonseca --- src/gallium/auxiliary/gallivm/lp_bld_misc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp b/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp index d60db91..4ede90b 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp +++ b/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp @@ -502,7 +502,7 @@ lp_build_create_jit_compiler_for_module(LLVMExecutionEngineRef *OutJIT, #if HAVE_LLVM >= 0x0306 builder.setMCJITMemoryManager(std::unique_ptr(MM)); - MM = NULL; // onwership taken by std::unique_ptr + MM = NULL; // ownership taken by std::unique_ptr #else builder.setMCJITMemoryManager(MM); #endif From brianp at kemper.freedesktop.org Fri Mar 13 14:03:01 2015 From: brianp at kemper.freedesktop.org (Brian Paul) Date: Fri, 13 Mar 2015 07:03:01 -0700 (PDT) Subject: Mesa (master): egl: fix cast to silence compiler warning Message-ID: <20150313140301.4233C76250@kemper.freedesktop.org> Module: Mesa Branch: master Commit: d24a20e967303e1172928937fb7f96f010d4a99c URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=d24a20e967303e1172928937fb7f96f010d4a99c Author: Brian Paul Date: Thu Mar 12 08:35:38 2015 -0600 egl: fix cast to silence compiler warning eglcurrent.c: In function '_eglSetTSD': eglcurrent.c:57:4: warning: passing argument 2 of 'tss_set' discards 'const' qualifier from pointer target type [enabled by default] tss_set(_egl_TSD, (const void *) t); ^ In file included from ../../../include/c11/threads.h:72:0, from eglcurrent.c:32: ../../../include/c11/threads_posix.h:357:1: note: expected 'void *' but argument is of type 'const void *' tss_set(tss_t key, void *val) ^ Reviewed-by: Emil Velikov --- src/egl/main/eglcurrent.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/egl/main/eglcurrent.c b/src/egl/main/eglcurrent.c index 5d8cae4..6ffc799 100644 --- a/src/egl/main/eglcurrent.c +++ b/src/egl/main/eglcurrent.c @@ -54,7 +54,7 @@ static __thread const _EGLThreadInfo *_egl_TLS static inline void _eglSetTSD(const _EGLThreadInfo *t) { - tss_set(_egl_TSD, (const void *) t); + tss_set(_egl_TSD, (void *) t); #ifdef GLX_USE_TLS _egl_TLS = t; #endif From brianp at kemper.freedesktop.org Fri Mar 13 14:03:01 2015 From: brianp at kemper.freedesktop.org (Brian Paul) Date: Fri, 13 Mar 2015 07:03:01 -0700 (PDT) Subject: Mesa (master): util: convert slab macros to inline functions Message-ID: <20150313140301.4B66876332@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 558dcd877095a27ce5de8198744f2f95ddf66b2a URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=558dcd877095a27ce5de8198744f2f95ddf66b2a Author: Brian Paul Date: Thu Mar 12 15:50:20 2015 -0600 util: convert slab macros to inline functions Reviewed-by: Jose Fonseca --- src/gallium/auxiliary/util/u_slab.h | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/gallium/auxiliary/util/u_slab.h b/src/gallium/auxiliary/util/u_slab.h index 29d0252..0df039b 100644 --- a/src/gallium/auxiliary/util/u_slab.h +++ b/src/gallium/auxiliary/util/u_slab.h @@ -81,7 +81,16 @@ void util_slab_destroy(struct util_slab_mempool *pool); void util_slab_set_thread_safety(struct util_slab_mempool *pool, enum util_slab_threading threading); -#define util_slab_alloc(pool) (pool)->alloc(pool) -#define util_slab_free(pool, ptr) (pool)->free(pool, ptr) +static inline void * +util_slab_alloc(struct util_slab_mempool *pool) +{ + return pool->alloc(pool); +} + +static inline void +util_slab_free(struct util_slab_mempool *pool, void *ptr) +{ + pool->free(pool, ptr); +} #endif From elima at kemper.freedesktop.org Fri Mar 13 15:52:42 2015 From: elima at kemper.freedesktop.org (Eduardo Lima Mitev) Date: Fri, 13 Mar 2015 08:52:42 -0700 (PDT) Subject: Mesa (master): mesa: Set the correct image size in _mesa_validate_pbo_access() Message-ID: <20150313155242.691AE76332@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 7b5bb97cefbf1d0cfef28bc974ee9a68024e3b45 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=7b5bb97cefbf1d0cfef28bc974ee9a68024e3b45 Author: Eduardo Lima Mitev Date: Thu Mar 5 09:20:11 2015 +0100 mesa: Set the correct image size in _mesa_validate_pbo_access() _mesa_validate_pbo_access() provides a generic way to check that a requested pixel transfer operation on a PBO falls within the boundaries of the buffer. It is used in various other places, and depending on the caller, some arguments are used or not. In particular, the 'clientMemSize' argument is used only by calls that are knowledgeable of the total size of the user data involved in a pixel transfer, such as the case of compressed texture image calls. Other calls don't provide 'clientMemSize' directly since it is made implicit from the size and format of the texture, and its data type. In these cases, a sufficiently big value is passed to 'clientMemSize' (INT_MAX) to avoid an incorrect constrain. The problem is that _mesa_validate_pbo_access() use uint pointers to make the calculations, which are 64 bits long in 64 bits platforms, meanwhile the dummy INT_MAX passed in 'clientMemSize' is just 32 bits. This causes a constrain that is not desired. This patch fixes that by checking that if 'clientMemSize' is MAX_INT, then UINTPTR_MAX is assumed instead. This is an ugly workaround to the fact that _mesa_validate_pbo_access() intends to be a one function fits all. The clean solution here would be to break it into different functions that provide the adequate API for each of the possible code paths and validation needs. Since there are callers relying on passing INT_MAX to 'clientMemSize', this patch is necessary to deal with the problem above while a cleaner implementation of the PBO API is not implemented. Reviewed-by: Laura Ekstrand --- src/mesa/main/pbo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesa/main/pbo.c b/src/mesa/main/pbo.c index 5c906ed..259f763 100644 --- a/src/mesa/main/pbo.c +++ b/src/mesa/main/pbo.c @@ -80,7 +80,7 @@ _mesa_validate_pbo_access(GLuint dimensions, */ if (!_mesa_is_bufferobj(pack->BufferObj)) { offset = 0; - size = clientMemSize; + size = (clientMemSize == INT_MAX) ? UINTPTR_MAX : clientMemSize; } else { offset = (uintptr_t)ptr; size = pack->BufferObj->Size; From elima at kemper.freedesktop.org Fri Mar 13 15:52:42 2015 From: elima at kemper.freedesktop.org (Eduardo Lima Mitev) Date: Fri, 13 Mar 2015 08:52:42 -0700 (PDT) Subject: Mesa (master): meta: Remove error checks for texture <-> pixel-buffer transfers that don't belong in driver code Message-ID: <20150313155242.6017976250@kemper.freedesktop.org> Module: Mesa Branch: master Commit: f6f7bfb5e1308593df9642aa8f46a17e8ce340a2 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=f6f7bfb5e1308593df9642aa8f46a17e8ce340a2 Author: Eduardo Lima Mitev Date: Tue Mar 10 19:33:30 2015 +0100 meta: Remove error checks for texture <-> pixel-buffer transfers that don't belong in driver code The implementation of texture <-> pixel-buffer transfers in drivers common layer includes certain error checks and argument validation that don't belong there, considering how the Mesa codebase is laid out. These are higher level validations that, if necessary, should be performed earlier (i.e, in GL API entry points). This patch simply removes these error checks from driver code. For more information, see discussion at http://lists.freedesktop.org/archives/mesa-dev/2015-February/077417.html. Reviewed-by: Laura Ekstrand --- src/mesa/drivers/common/meta_tex_subimage.c | 32 --------------------------- 1 file changed, 32 deletions(-) diff --git a/src/mesa/drivers/common/meta_tex_subimage.c b/src/mesa/drivers/common/meta_tex_subimage.c index e29addb..ad6e787 100644 --- a/src/mesa/drivers/common/meta_tex_subimage.c +++ b/src/mesa/drivers/common/meta_tex_subimage.c @@ -150,9 +150,6 @@ _mesa_meta_pbo_TexSubImage(struct gl_context *ctx, GLuint dims, bool success = false; int z; - /* XXX: This should probably be passed in from somewhere */ - const char *where = "_mesa_meta_pbo_TexSubImage"; - if (!_mesa_is_bufferobj(packing->BufferObj) && !create_pbo) return false; @@ -165,19 +162,6 @@ _mesa_meta_pbo_TexSubImage(struct gl_context *ctx, GLuint dims, if (ctx->_ImageTransferState) return false; - if (!_mesa_validate_pbo_access(dims, packing, width, height, depth, - format, type, INT_MAX, pixels)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "%s(out of bounds PBO access)", where); - return true; - } - - if (_mesa_check_disallowed_mapping(packing->BufferObj)) { - /* buffer is mapped - that's an error */ - _mesa_error(ctx, GL_INVALID_OPERATION, "%s(PBO is mapped)", where); - return true; - } - /* For arrays, use a tall (height * depth) 2D texture but taking into * account the inter-image padding specified with the image height packing * property. @@ -277,9 +261,6 @@ _mesa_meta_pbo_GetTexSubImage(struct gl_context *ctx, GLuint dims, bool success = false; int z; - /* XXX: This should probably be passed in from somewhere */ - const char *where = "_mesa_meta_pbo_GetTexSubImage"; - if (!_mesa_is_bufferobj(packing->BufferObj)) return false; @@ -292,19 +273,6 @@ _mesa_meta_pbo_GetTexSubImage(struct gl_context *ctx, GLuint dims, if (ctx->_ImageTransferState) return false; - if (!_mesa_validate_pbo_access(dims, packing, width, height, depth, - format, type, INT_MAX, pixels)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "%s(out of bounds PBO access)", where); - return true; - } - - if (_mesa_check_disallowed_mapping(packing->BufferObj)) { - /* buffer is mapped - that's an error */ - _mesa_error(ctx, GL_INVALID_OPERATION, "%s(PBO is mapped)", where); - return true; - } - /* For arrays, use a tall (height * depth) 2D texture but taking into * account the inter-image padding specified with the image height packing * property. From elima at kemper.freedesktop.org Fri Mar 13 15:52:42 2015 From: elima at kemper.freedesktop.org (Eduardo Lima Mitev) Date: Fri, 13 Mar 2015 08:52:42 -0700 (PDT) Subject: Mesa (master): mesa: Separate PBO validation checks from buffer mapping, to allow reuse Message-ID: <20150313155242.771DF76250@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 7c084752c612c1763212830618ee0a86f4edf8f6 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=7c084752c612c1763212830618ee0a86f4edf8f6 Author: Eduardo Lima Mitev Date: Thu Mar 12 08:14:03 2015 +0100 mesa: Separate PBO validation checks from buffer mapping, to allow reuse Internal PBO functions such as _mesa_map_validate_pbo_source() and _mesa_validate_pbo_compressed_teximage() perform validation and buffer mapping within the same call. This patch takes out the validation into separate functions to allow reuse of functionality by other code (i.e, gl(Compressed)Tex(Sub)Image). Reviewed-by: Laura Ekstrand --- src/mesa/main/pbo.c | 117 +++++++++++++++++++++++++++++++++++++-------------- src/mesa/main/pbo.h | 14 ++++++ 2 files changed, 100 insertions(+), 31 deletions(-) diff --git a/src/mesa/main/pbo.c b/src/mesa/main/pbo.c index 259f763..0c16025 100644 --- a/src/mesa/main/pbo.c +++ b/src/mesa/main/pbo.c @@ -164,23 +164,18 @@ _mesa_map_pbo_source(struct gl_context *ctx, return buf; } - /** - * Combine PBO-read validation and mapping. - * If any GL errors are detected, they'll be recorded and NULL returned. + * Perform PBO validation for read operations with uncompressed textures. + * If any GL errors are detected, false is returned, otherwise returns true. * \sa _mesa_validate_pbo_access - * \sa _mesa_map_pbo_source - * A call to this function should have a matching call to - * _mesa_unmap_pbo_source(). */ -const GLvoid * -_mesa_map_validate_pbo_source(struct gl_context *ctx, - GLuint dimensions, - const struct gl_pixelstore_attrib *unpack, - GLsizei width, GLsizei height, GLsizei depth, - GLenum format, GLenum type, - GLsizei clientMemSize, - const GLvoid *ptr, const char *where) +bool +_mesa_validate_pbo_source(struct gl_context *ctx, GLuint dimensions, + const struct gl_pixelstore_attrib *unpack, + GLsizei width, GLsizei height, GLsizei depth, + GLenum format, GLenum type, + GLsizei clientMemSize, + const GLvoid *ptr, const char *where) { assert(dimensions == 1 || dimensions == 2 || dimensions == 3); @@ -188,24 +183,85 @@ _mesa_map_validate_pbo_source(struct gl_context *ctx, format, type, clientMemSize, ptr)) { if (_mesa_is_bufferobj(unpack->BufferObj)) { _mesa_error(ctx, GL_INVALID_OPERATION, - "%s(out of bounds PBO access)", where); + "%s(out of bounds PBO access)", + where); } else { _mesa_error(ctx, GL_INVALID_OPERATION, "%s(out of bounds access: bufSize (%d) is too small)", where, clientMemSize); } - return NULL; + return false; } if (!_mesa_is_bufferobj(unpack->BufferObj)) { /* non-PBO access: no further validation to be done */ - return ptr; + return true; } if (_mesa_check_disallowed_mapping(unpack->BufferObj)) { /* buffer is already mapped - that's an error */ - _mesa_error(ctx, GL_INVALID_OPERATION, "%s(PBO is mapped)", where); - return NULL; + _mesa_error(ctx, GL_INVALID_OPERATION, "%s(PBO is mapped)", + where); + return false; + } + + return true; +} + +/** + * Perform PBO validation for read operations with compressed textures. + * If any GL errors are detected, false is returned, otherwise returns true. + */ +bool +_mesa_validate_pbo_source_compressed(struct gl_context *ctx, GLuint dimensions, + const struct gl_pixelstore_attrib *unpack, + GLsizei imageSize, const GLvoid *pixels, + const char *where) +{ + if (!_mesa_is_bufferobj(unpack->BufferObj)) { + /* not using a PBO */ + return true; + } + + if ((const GLubyte *) pixels + imageSize > + ((const GLubyte *) 0) + unpack->BufferObj->Size) { + /* out of bounds read! */ + _mesa_error(ctx, GL_INVALID_OPERATION, "%s(invalid PBO access)", + where); + return false; + } + + if (_mesa_check_disallowed_mapping(unpack->BufferObj)) { + /* buffer is already mapped - that's an error */ + _mesa_error(ctx, GL_INVALID_OPERATION, "%s(PBO is mapped)", + where); + return false; + } + + return true; +} + +/** + * Perform PBO-read mapping. + * If any GL errors are detected, they'll be recorded and NULL returned. + * \sa _mesa_validate_pbo_source + * \sa _mesa_map_pbo_source + * A call to this function should have a matching call to + * _mesa_unmap_pbo_source(). + */ +const GLvoid * +_mesa_map_validate_pbo_source(struct gl_context *ctx, + GLuint dimensions, + const struct gl_pixelstore_attrib *unpack, + GLsizei width, GLsizei height, GLsizei depth, + GLenum format, GLenum type, + GLsizei clientMemSize, + const GLvoid *ptr, const char *where) +{ + if (!_mesa_validate_pbo_source(ctx, dimensions, unpack, + width, height, depth, format, type, + clientMemSize, ptr, where)) { + return NULL; } ptr = _mesa_map_pbo_source(ctx, unpack, ptr); @@ -381,28 +437,27 @@ _mesa_validate_pbo_compressed_teximage(struct gl_context *ctx, { GLubyte *buf; + if (!_mesa_validate_pbo_source_compressed(ctx, dimensions, packing, + imageSize, pixels, funcName)) { + /* error is already set during validation */ + return NULL; + } + if (!_mesa_is_bufferobj(packing->BufferObj)) { /* not using a PBO - return pointer unchanged */ return pixels; } - if ((const GLubyte *) pixels + imageSize > - ((const GLubyte *) 0) + packing->BufferObj->Size) { - /* out of bounds read! */ - _mesa_error(ctx, GL_INVALID_OPERATION, "%s%uD(invalid PBO access)", - funcName, dimensions); - return NULL; - } buf = (GLubyte*) ctx->Driver.MapBufferRange(ctx, 0, packing->BufferObj->Size, GL_MAP_READ_BIT, packing->BufferObj, MAP_INTERNAL); - if (!buf) { - _mesa_error(ctx, GL_INVALID_OPERATION, "%s%uD(PBO is mapped)", funcName, - dimensions); - return NULL; - } + + /* Validation above already checked that PBO is not mapped, so buffer + * should not be null. + */ + assert(buf); return ADD_POINTERS(buf, pixels); } diff --git a/src/mesa/main/pbo.h b/src/mesa/main/pbo.h index 9851ef1..b3f24e6 100644 --- a/src/mesa/main/pbo.h +++ b/src/mesa/main/pbo.h @@ -92,4 +92,18 @@ _mesa_unmap_teximage_pbo(struct gl_context *ctx, const struct gl_pixelstore_attrib *unpack); +extern bool +_mesa_validate_pbo_source(struct gl_context *ctx, GLuint dimensions, + const struct gl_pixelstore_attrib *unpack, + GLsizei width, GLsizei height, GLsizei depth, + GLenum format, GLenum type, + GLsizei clientMemSize, + const GLvoid *ptr, const char *where); + +extern bool +_mesa_validate_pbo_source_compressed(struct gl_context *ctx, GLuint dimensions, + const struct gl_pixelstore_attrib *unpack, + GLsizei imageSize, const GLvoid *ptr, + const char *where); + #endif From elima at kemper.freedesktop.org Fri Mar 13 15:52:42 2015 From: elima at kemper.freedesktop.org (Eduardo Lima Mitev) Date: Fri, 13 Mar 2015 08:52:42 -0700 (PDT) Subject: Mesa (master): mesa: Check for valid PBO access in gl(Compressed)Tex(Sub) Image calls Message-ID: <20150313155242.8541776250@kemper.freedesktop.org> Module: Mesa Branch: master Commit: cf6f33ee68ca56df1650762634fa9c038359c3ec URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=cf6f33ee68ca56df1650762634fa9c038359c3ec Author: Eduardo Lima Mitev Date: Thu Mar 12 08:16:09 2015 +0100 mesa: Check for valid PBO access in gl(Compressed)Tex(Sub)Image calls This patch adds two types of checks to the gl(Compressed)Tex(Sub)Imgage family of functions when a pixel buffer object is bound to GL_PIXEL_UNPACK_BUFFER: - That the buffer is not mapped. - The total data size is within the boundaries of the buffer size. It does so by calling auxiliary validations functions from PBO API: _mesa_validate_pbo_source() for non-compressed texture calls, and _mesa_validate_pbo_source_compressed() for compressed texture calls. The first check is defined in Section 6.3.2 'Effects of Mapping Buffers on Other GL Commands' of the GLES 3.1 spec, page 57: "Any GL command which attempts to read from, write to, or change the state of a buffer object may generate an INVALID_OPERATION error if all or part of the buffer object is mapped. However, only commands which explicitly describe this error are required to do so. If an error is not generated, using such commands to perform invalid reads, writes, or state changes will have undefined results and may result in GL interruption or termination." Similar wording exists in GL 4.5 spec, page 76. In the case of gl(Compressed)Tex(Sub)Image(2,3)D, the specification doesn't force implemtations to throw an error. However since Mesa don't currently implement checks to determine when it is safe to read/write from/to a mapped PBO, we should always return the error if all or parts of it are mapped. The 2nd check is defined in Section 8.5 'Texture Image Specification' of the OpenGL 4.5 spec, page 203: "An INVALID_OPERATION error is generated if a pixel unpack buffer object is bound and storing texture data would access memory beyond the end of the pixel unpack buffer." Fixes 4 dEQP tests: * dEQP-GLES3.functional.negative_api.texture.compressedteximage2d_invalid_buffer_target * dEQP-GLES3.functional.negative_api.texture.compressedtexsubimage2d_invalid_buffer_target * dEQP-GLES3.functional.negative_api.texture.compressedteximage3d_invalid_buffer_target * dEQP-GLES3.functional.negative_api.texture.compressedtexsubimage3d_invalid_buffer_target Reviewed-by: Laura Ekstrand --- src/mesa/main/teximage.c | 180 ++++++++++++++++++++++++++-------------------- 1 file changed, 103 insertions(+), 77 deletions(-) diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c index 7b1a0e6..64e4816 100644 --- a/src/mesa/main/teximage.c +++ b/src/mesa/main/teximage.c @@ -53,6 +53,7 @@ #include "mtypes.h" #include "glformats.h" #include "texstore.h" +#include "pbo.h" /** @@ -1619,32 +1620,30 @@ error_check_subtexture_dimensions(struct gl_context *ctx, GLuint dims, /* Check size */ if (subWidth < 0) { _mesa_error(ctx, GL_INVALID_VALUE, - "%s%dD(width=%d)", func, dims, subWidth); + "%s(width=%d)", func, subWidth); return GL_TRUE; } if (dims > 1 && subHeight < 0) { _mesa_error(ctx, GL_INVALID_VALUE, - "%s%dD(height=%d)", func, dims, subHeight); + "%s(height=%d)", func, subHeight); return GL_TRUE; } if (dims > 2 && subDepth < 0) { _mesa_error(ctx, GL_INVALID_VALUE, - "%s%dD(depth=%d)", func, dims, subDepth); + "%s(depth=%d)", func, subDepth); return GL_TRUE; } /* check xoffset and width */ if (xoffset < - (GLint) destImage->Border) { - _mesa_error(ctx, GL_INVALID_VALUE, "%s%dD(xoffset)", - func, dims); + _mesa_error(ctx, GL_INVALID_VALUE, "%s(xoffset)", func); return GL_TRUE; } if (xoffset + subWidth > (GLint) destImage->Width) { - _mesa_error(ctx, GL_INVALID_VALUE, "%s%dD(xoffset+width)", - func, dims); + _mesa_error(ctx, GL_INVALID_VALUE, "%s(xoffset+width)", func); return GL_TRUE; } @@ -1652,13 +1651,11 @@ error_check_subtexture_dimensions(struct gl_context *ctx, GLuint dims, if (dims > 1) { GLint yBorder = (target == GL_TEXTURE_1D_ARRAY) ? 0 : destImage->Border; if (yoffset < -yBorder) { - _mesa_error(ctx, GL_INVALID_VALUE, "%s%dD(yoffset)", - func, dims); + _mesa_error(ctx, GL_INVALID_VALUE, "%s(yoffset)", func); return GL_TRUE; } if (yoffset + subHeight > (GLint) destImage->Height) { - _mesa_error(ctx, GL_INVALID_VALUE, "%s%dD(yoffset+height)", - func, dims); + _mesa_error(ctx, GL_INVALID_VALUE, "%s(yoffset+height)", func); return GL_TRUE; } } @@ -1671,7 +1668,7 @@ error_check_subtexture_dimensions(struct gl_context *ctx, GLuint dims, 0 : destImage->Border; if (zoffset < -zBorder) { - _mesa_error(ctx, GL_INVALID_VALUE, "%s3D(zoffset)", func); + _mesa_error(ctx, GL_INVALID_VALUE, "%s(zoffset)", func); return GL_TRUE; } @@ -1679,7 +1676,7 @@ error_check_subtexture_dimensions(struct gl_context *ctx, GLuint dims, if (target == GL_TEXTURE_CUBE_MAP) depth = 6; if (zoffset + subDepth > depth) { - _mesa_error(ctx, GL_INVALID_VALUE, "%s3D(zoffset+depth)", func); + _mesa_error(ctx, GL_INVALID_VALUE, "%s(zoffset+depth)", func); return GL_TRUE; } } @@ -1697,8 +1694,8 @@ error_check_subtexture_dimensions(struct gl_context *ctx, GLuint dims, /* offset must be multiple of block size */ if ((xoffset % bw != 0) || (yoffset % bh != 0)) { _mesa_error(ctx, GL_INVALID_OPERATION, - "%s%dD(xoffset = %d, yoffset = %d)", - func, dims, xoffset, yoffset); + "%s(xoffset = %d, yoffset = %d)", + func, xoffset, yoffset); return GL_TRUE; } @@ -1710,14 +1707,14 @@ error_check_subtexture_dimensions(struct gl_context *ctx, GLuint dims, if ((subWidth % bw != 0) && (xoffset + subWidth != (GLint) destImage->Width)) { _mesa_error(ctx, GL_INVALID_OPERATION, - "%s%dD(width = %d)", func, dims, subWidth); + "%s(width = %d)", func, subWidth); return GL_TRUE; } if ((subHeight % bh != 0) && (yoffset + subHeight != (GLint) destImage->Height)) { _mesa_error(ctx, GL_INVALID_OPERATION, - "%s%dD(height = %d)", func, dims, subHeight); + "%s(height = %d)", func, subHeight); return GL_TRUE; } } @@ -2113,7 +2110,8 @@ texture_error_check( struct gl_context *ctx, GLint level, GLint internalFormat, GLenum format, GLenum type, GLint width, GLint height, - GLint depth, GLint border ) + GLint depth, GLint border, + const GLvoid *pixels ) { GLenum err; @@ -2198,6 +2196,13 @@ texture_error_check( struct gl_context *ctx, return GL_TRUE; } + /* validate the bound PBO, if any */ + if (!_mesa_validate_pbo_source(ctx, dimensions, &ctx->Unpack, + width, height, depth, format, type, + INT_MAX, pixels, "glTexImage")) { + return GL_TRUE; + } + /* make sure internal format and format basically agree */ if (!texture_formats_agree(internalFormat, format)) { _mesa_error(ctx, GL_INVALID_OPERATION, @@ -2294,7 +2299,7 @@ compressed_texture_error_check(struct gl_context *ctx, GLint dimensions, GLenum target, GLint level, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLint border, - GLsizei imageSize) + GLsizei imageSize, const GLvoid *data) { const GLint maxLevels = _mesa_max_texture_levels(ctx, target); GLint expectedSize; @@ -2322,6 +2327,13 @@ compressed_texture_error_check(struct gl_context *ctx, GLint dimensions, return GL_TRUE; } + /* validate the bound PBO, if any */ + if (!_mesa_validate_pbo_source_compressed(ctx, dimensions, &ctx->Unpack, + imageSize, data, + "glCompressedTexImage")) { + return GL_TRUE; + } + switch (internalFormat) { case GL_PALETTE4_RGB8_OES: case GL_PALETTE4_RGBA8_OES: @@ -2454,30 +2466,28 @@ texsubimage_error_check(struct gl_context *ctx, GLuint dimensions, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint width, GLint height, GLint depth, - GLenum format, GLenum type, bool dsa) + GLenum format, GLenum type, const GLvoid *pixels, + bool dsa, const char *callerName) { struct gl_texture_image *texImage; GLenum err; - const char* suffix = dsa ? "ture" : ""; if (!texObj) { /* must be out of memory */ - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTex%sSubImage%dD()", - suffix, dimensions); + _mesa_error(ctx, GL_OUT_OF_MEMORY, "%s()", callerName); return GL_TRUE; } /* check target (proxies not allowed) */ if (!legal_texsubimage_target(ctx, dimensions, target, dsa)) { - _mesa_error(ctx, GL_INVALID_ENUM, "glTex%sSubImage%uD(target=%s)", - suffix, dimensions, _mesa_lookup_enum_by_nr(target)); + _mesa_error(ctx, GL_INVALID_ENUM, "%s(target=%s)", + callerName, _mesa_lookup_enum_by_nr(target)); return GL_TRUE; } /* level check */ if (level < 0 || level >= _mesa_max_texture_levels(ctx, target)) { - _mesa_error(ctx, GL_INVALID_VALUE, "glTex%sSubImage%uD(level=%d)", - suffix, dimensions, level); + _mesa_error(ctx, GL_INVALID_VALUE, "%s(level=%d)", callerName, level); return GL_TRUE; } @@ -2489,9 +2499,8 @@ texsubimage_error_check(struct gl_context *ctx, GLuint dimensions, if (_mesa_is_gles(ctx) && !_mesa_is_gles3(ctx)) { err = _mesa_es_error_check_format_and_type(format, type, dimensions); if (err != GL_NO_ERROR) { - _mesa_error(ctx, err, - "glTex%sSubImage%dD(format = %s, type = %s)", - suffix, dimensions, _mesa_lookup_enum_by_nr(format), + _mesa_error(ctx, err, "%s(format = %s, type = %s)", + callerName, _mesa_lookup_enum_by_nr(format), _mesa_lookup_enum_by_nr(type)); return GL_TRUE; } @@ -2500,34 +2509,37 @@ texsubimage_error_check(struct gl_context *ctx, GLuint dimensions, err = _mesa_error_check_format_and_type(ctx, format, type); if (err != GL_NO_ERROR) { _mesa_error(ctx, err, - "glTex%sSubImage%dD(incompatible format = %s, type = %s)", - suffix, dimensions, _mesa_lookup_enum_by_nr(format), + "%s(incompatible format = %s, type = %s)", + callerName, _mesa_lookup_enum_by_nr(format), _mesa_lookup_enum_by_nr(type)); return GL_TRUE; } + /* validate the bound PBO, if any */ + if (!_mesa_validate_pbo_source(ctx, dimensions, &ctx->Unpack, + width, height, depth, format, type, + INT_MAX, pixels, callerName)) { + return GL_TRUE; + } + texImage = _mesa_select_tex_image(texObj, target, level); if (!texImage) { /* non-existant texture level */ - _mesa_error(ctx, GL_INVALID_OPERATION, - "glTex%sSubImage%dD(invalid texture image)", suffix, - dimensions); + _mesa_error(ctx, GL_INVALID_OPERATION, "%s(invalid texture image)", + callerName); return GL_TRUE; } if (error_check_subtexture_dimensions(ctx, dimensions, texImage, xoffset, yoffset, zoffset, - width, height, depth, - dsa ? "glTextureSubImage" : - "glTexSubImage")) { + width, height, depth, callerName)) { return GL_TRUE; } if (_mesa_is_format_compressed(texImage->TexFormat)) { if (compressedteximage_only_format(ctx, texImage->InternalFormat)) { _mesa_error(ctx, GL_INVALID_OPERATION, - "glTex%sSubImage%dD(no compression for format)", - suffix, dimensions); + "%s(no compression for format)", callerName); return GL_TRUE; } } @@ -2537,8 +2549,7 @@ texsubimage_error_check(struct gl_context *ctx, GLuint dimensions, if (_mesa_is_format_integer_color(texImage->TexFormat) != _mesa_is_enum_format_integer(format)) { _mesa_error(ctx, GL_INVALID_OPERATION, - "glTex%sSubImage%dD(integer/non-integer format mismatch)", - suffix, dimensions); + "%s(integer/non-integer format mismatch)", callerName); return GL_TRUE; } } @@ -3218,12 +3229,13 @@ teximage(struct gl_context *ctx, GLboolean compressed, GLuint dims, if (compressed_texture_error_check(ctx, dims, target, level, internalFormat, width, height, depth, - border, imageSize)) + border, imageSize, pixels)) return; } else { if (texture_error_check(ctx, dims, target, level, internalFormat, - format, type, width, height, depth, border)) + format, type, width, height, depth, border, + pixels)) return; } @@ -3562,7 +3574,8 @@ static void texsubimage(struct gl_context *ctx, GLuint dims, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, - GLenum format, GLenum type, const GLvoid *pixels) + GLenum format, GLenum type, const GLvoid *pixels, + const char *callerName) { struct gl_texture_object *texObj; struct gl_texture_image *texImage; @@ -3573,7 +3586,8 @@ texsubimage(struct gl_context *ctx, GLuint dims, GLenum target, GLint level, if (texsubimage_error_check(ctx, dims, texObj, target, level, xoffset, yoffset, zoffset, - width, height, depth, format, type, false)) { + width, height, depth, format, type, + pixels, false, callerName)) { return; /* error was detected */ } @@ -3603,7 +3617,8 @@ texturesubimage(struct gl_context *ctx, GLuint dims, GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, - GLenum format, GLenum type, const GLvoid *pixels) + GLenum format, GLenum type, const GLvoid *pixels, + const char *callerName) { struct gl_texture_object *texObj; struct gl_texture_image *texImage; @@ -3627,7 +3642,8 @@ texturesubimage(struct gl_context *ctx, GLuint dims, if (texsubimage_error_check(ctx, dims, texObj, texObj->Target, level, xoffset, yoffset, zoffset, - width, height, depth, format, type, true)) { + width, height, depth, format, type, + pixels, true, callerName)) { return; /* error was detected */ } @@ -3708,7 +3724,7 @@ _mesa_TexSubImage1D( GLenum target, GLint level, texsubimage(ctx, 1, target, level, xoffset, 0, 0, width, 1, 1, - format, type, pixels); + format, type, pixels, "glTexSubImage1D"); } @@ -3723,7 +3739,7 @@ _mesa_TexSubImage2D( GLenum target, GLint level, texsubimage(ctx, 2, target, level, xoffset, yoffset, 0, width, height, 1, - format, type, pixels); + format, type, pixels, "glTexSubImage2D"); } @@ -3739,7 +3755,7 @@ _mesa_TexSubImage3D( GLenum target, GLint level, texsubimage(ctx, 3, target, level, xoffset, yoffset, zoffset, width, height, depth, - format, type, pixels); + format, type, pixels, "glTexSubImage3D"); } void GLAPIENTRY @@ -3752,7 +3768,7 @@ _mesa_TextureSubImage1D(GLuint texture, GLint level, texturesubimage(ctx, 1, texture, level, xoffset, 0, 0, width, 1, 1, - format, type, pixels); + format, type, pixels, "glTextureSubImage1D"); } @@ -3767,7 +3783,7 @@ _mesa_TextureSubImage2D(GLuint texture, GLint level, texturesubimage(ctx, 2, texture, level, xoffset, yoffset, 0, width, height, 1, - format, type, pixels); + format, type, pixels, "glTextureSubImage2D"); } @@ -3782,7 +3798,7 @@ _mesa_TextureSubImage3D(GLuint texture, GLint level, texturesubimage(ctx, 3, texture, level, xoffset, yoffset, zoffset, width, height, depth, - format, type, pixels); + format, type, pixels, "glTextureSubImage3D"); } @@ -4623,68 +4639,72 @@ compressed_subtexture_error_check(struct gl_context *ctx, GLint dims, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, - GLenum format, GLsizei imageSize, bool dsa) + GLenum format, GLsizei imageSize, + const GLvoid *data, const char *callerName) { struct gl_texture_image *texImage; GLint expectedSize; - const char *suffix = dsa ? "ture" : ""; /* this will catch any invalid compressed format token */ if (!_mesa_is_compressed_format(ctx, format)) { _mesa_error(ctx, GL_INVALID_ENUM, - "glCompressedTex%sSubImage%uD(format)", suffix, dims); + "%s(format)", callerName); return GL_TRUE; } if (level < 0 || level >= _mesa_max_texture_levels(ctx, target)) { _mesa_error(ctx, GL_INVALID_VALUE, - "glCompressedTex%sSubImage%uD(level=%d)", - suffix, dims, level); + "%s(level=%d)", + callerName, level); + return GL_TRUE; + } + + /* validate the bound PBO, if any */ + if (!_mesa_validate_pbo_source_compressed(ctx, dims, &ctx->Unpack, + imageSize, data, callerName)) { return GL_TRUE; } /* Check for invalid pixel storage modes */ if (!_mesa_compressed_pixel_storage_error_check(ctx, dims, - &ctx->Unpack, - dsa ? "glCompressedTextureSubImage" : - "glCompressedTexSubImage")) { + &ctx->Unpack, callerName)) { return GL_TRUE; } expectedSize = compressed_tex_size(width, height, depth, format); if (expectedSize != imageSize) { _mesa_error(ctx, GL_INVALID_VALUE, - "glCompressedTex%sSubImage%uD(size=%d)", - suffix, dims, imageSize); + "%s(size=%d)", + callerName, imageSize); return GL_TRUE; } texImage = _mesa_select_tex_image(texObj, target, level); if (!texImage) { _mesa_error(ctx, GL_INVALID_OPERATION, - "glCompressedTex%sSubImage%uD(invalid texture image)", - suffix, dims); + "%s(invalid texture image)", + callerName); return GL_TRUE; } if ((GLint) format != texImage->InternalFormat) { _mesa_error(ctx, GL_INVALID_OPERATION, - "glCompressedTex%sSubImage%uD(format=0x%x)", - suffix, dims, format); + "%s(format=0x%x)", + callerName, format); return GL_TRUE; } if (compressedteximage_only_format(ctx, format)) { _mesa_error(ctx, GL_INVALID_OPERATION, - "glCompressedTex%sSubImage%uD(format=0x%x cannot be updated)", - suffix, dims, format); + "%s(format=0x%x cannot be updated)", + callerName, format); return GL_TRUE; } if (error_check_subtexture_dimensions(ctx, dims, texImage, xoffset, yoffset, zoffset, width, height, depth, - "glCompressedTexSubImage")) { + callerName)) { return GL_TRUE; } @@ -4787,7 +4807,8 @@ _mesa_CompressedTexSubImage1D(GLenum target, GLint level, GLint xoffset, if (compressed_subtexture_error_check(ctx, 1, texObj, target, level, xoffset, 0, 0, width, 1, 1, - format, imageSize, false)) { + format, imageSize, data, + "glCompressedTexSubImage1D")) { return; } @@ -4823,7 +4844,8 @@ _mesa_CompressedTextureSubImage1D(GLuint texture, GLint level, GLint xoffset, if (compressed_subtexture_error_check(ctx, 1, texObj, texObj->Target, level, xoffset, 0, 0, width, 1, 1, - format, imageSize, true)) { + format, imageSize, data, + "glCompressedTextureSubImage1D")) { return; } @@ -4860,7 +4882,8 @@ _mesa_CompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, if (compressed_subtexture_error_check(ctx, 2, texObj, target, level, xoffset, yoffset, 0, width, height, 1, - format, imageSize, false)) { + format, imageSize, data, + "glCompressedTexSubImage2D")) { return; } @@ -4899,7 +4922,8 @@ _mesa_CompressedTextureSubImage2D(GLuint texture, GLint level, GLint xoffset, if (compressed_subtexture_error_check(ctx, 2, texObj, texObj->Target, level, xoffset, yoffset, 0, width, height, 1, - format, imageSize, true)) { + format, imageSize, data, + "glCompressedTextureSubImage2D")) { return; } @@ -4935,7 +4959,8 @@ _mesa_CompressedTexSubImage3D(GLenum target, GLint level, GLint xoffset, if (compressed_subtexture_error_check(ctx, 3, texObj, target, level, xoffset, yoffset, zoffset, width, height, depth, - format, imageSize, false)) { + format, imageSize, data, + "glCompressedTexSubImage3D")) { return; } @@ -4975,7 +5000,8 @@ _mesa_CompressedTextureSubImage3D(GLuint texture, GLint level, GLint xoffset, if (compressed_subtexture_error_check(ctx, 3, texObj, texObj->Target, level, xoffset, yoffset, zoffset, width, height, depth, - format, imageSize, true)) { + format, imageSize, data, + "glCompressedTextureSubImage3D")) { return; } From elima at kemper.freedesktop.org Fri Mar 13 15:52:42 2015 From: elima at kemper.freedesktop.org (Eduardo Lima Mitev) Date: Fri, 13 Mar 2015 08:52:42 -0700 (PDT) Subject: Mesa (master): glsl: optimize (0 cmp x + y) into (-x cmp y). Message-ID: <20150313155242.900BD76250@kemper.freedesktop.org> Module: Mesa Branch: master Commit: b43bbfa90ace596c8b2e0b3954a5f69924726c59 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=b43bbfa90ace596c8b2e0b3954a5f69924726c59 Author: Samuel Iglesias Gonsalvez Date: Tue Feb 24 19:02:57 2015 +0100 glsl: optimize (0 cmp x + y) into (-x cmp y). The optimization done by commit 34ec1a24d did not take it into account. Fixes: dEQP-GLES3.functional.shaders.random.all_features.fragment.20 Signed-off-by: Samuel Iglesias Gonsalvez Reviewed-by: Ian Romanick Reviewed-by: Matt Turner Cc: "10.4 10.5" --- src/glsl/opt_algebraic.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/glsl/opt_algebraic.cpp b/src/glsl/opt_algebraic.cpp index c6040bf..69c03ea 100644 --- a/src/glsl/opt_algebraic.cpp +++ b/src/glsl/opt_algebraic.cpp @@ -626,9 +626,18 @@ ir_algebraic_visitor::handle_expression(ir_expression *ir) if (!is_vec_zero(zero)) continue; - return new(mem_ctx) ir_expression(ir->operation, - add->operands[0], - neg(add->operands[1])); + /* Depending of the zero position we want to optimize + * (0 cmp x+y) into (-x cmp y) or (x+y cmp 0) into (x cmp -y) + */ + if (add_pos == 1) { + return new(mem_ctx) ir_expression(ir->operation, + neg(add->operands[0]), + add->operands[1]); + } else { + return new(mem_ctx) ir_expression(ir->operation, + add->operands[0], + neg(add->operands[1])); + } } break; From mattst88 at kemper.freedesktop.org Fri Mar 13 17:42:47 2015 From: mattst88 at kemper.freedesktop.org (Matt Turner) Date: Fri, 13 Mar 2015 10:42:47 -0700 (PDT) Subject: Mesa (master): docs: List ARB_shading_language_packing/ EXT_shader_integer_mix. Message-ID: <20150313174247.E499776250@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 97399fc751a0f9750c4f9585dfed14b662ebec2e URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=97399fc751a0f9750c4f9585dfed14b662ebec2e Author: Matt Turner Date: Wed Mar 11 18:43:56 2015 -0700 docs: List ARB_shading_language_packing/EXT_shader_integer_mix. Reviewed-by: Carl Worth Reviewed-by: Marek Ol??k --- docs/GL3.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/GL3.txt b/docs/GL3.txt index 43bbf85..289dd36 100644 --- a/docs/GL3.txt +++ b/docs/GL3.txt @@ -142,6 +142,7 @@ GL 4.2, GLSL 4.20: GL_ARB_shader_image_load_store in progress (curro) GL_ARB_conservative_depth DONE (all drivers that support GLSL 1.30) GL_ARB_shading_language_420pack DONE (all drivers that support GLSL 1.30) + GL_ARB_shading_language_packing DONE (all drivers) GL_ARB_internalformat_query DONE (i965, nv50, nvc0, r300, r600, radeonsi, llvmpipe, softpipe) GL_ARB_map_buffer_alignment DONE (all drivers) @@ -207,6 +208,7 @@ GL 4.5, GLSL 4.50: GL_KHR_context_flush_control DONE (all - but needs GLX/EXT extension to be useful) GL_KHR_robust_buffer_access_behavior not started GL_KHR_robustness 90% done (the ARB variant) + GL_EXT_shader_integer_mix DONE (all drivers that support GLSL) These are the extensions cherry-picked to make GLES 3.1 GLES3.1, GLSL ES 3.1 @@ -219,6 +221,7 @@ GLES3.1, GLSL ES 3.1 GL_ARB_shader_atomic_counters DONE (i965) GL_ARB_shader_image_load_store in progress (curro) GL_ARB_shader_storage_buffer_object not started + GL_ARB_shading_language_packing DONE (all drivers) GL_ARB_separate_shader_objects DONE (all drivers) GL_ARB_stencil_texturing DONE (i965/gen8+, nv50, nvc0, r600, radeonsi, llvmpipe, softpipe) GL_ARB_vertex_attrib_binding DONE (all drivers) From mattst88 at kemper.freedesktop.org Fri Mar 13 17:42:47 2015 From: mattst88 at kemper.freedesktop.org (Matt Turner) Date: Fri, 13 Mar 2015 10:42:47 -0700 (PDT) Subject: Mesa (master): egl: Create queryable strings in eglInitialize(). Message-ID: <20150313174247.CBDBF76250@kemper.freedesktop.org> Module: Mesa Branch: master Commit: dac2e7deaae2540645a6b485c7d1f47195689116 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=dac2e7deaae2540645a6b485c7d1f47195689116 Author: Matt Turner Date: Tue Mar 10 11:41:57 2015 -0700 egl: Create queryable strings in eglInitialize(). Creating/recreating the strings in eglQueryString() is extra work and isn't thread-safe, as exhibited by shader-db's run.c using libepoxy. Multiple threads in run.c call eglReleaseThread() around the same time. libepoxy calls eglQueryString() to determine whether eglReleaseThread() exists, and our EGL implementation passes a pointer to the version string to libepoxy while simultaneously overwriting the string, leading to a failure in libepoxy. Moreover, the EGL spec says (emphasis mine): "eglQueryString returns a pointer to a *static*, zero-terminated string" This patch moves some auxiliary functions from eglmisc.c to eglapi.c so that they may be used to create the extension, API, and version strings once during eglInitialize(). The auxiliary functions are renamed from _eglUpdate* to _eglCreate*, and some checks made unnecessary by calling the functions from eglInitialize() are removed. Reviewed-by: Chad Versace --- src/egl/main/eglapi.c | 112 +++++++++++++++++++++++++++++++++++++++++++ src/egl/main/eglmisc.c | 125 ------------------------------------------------ 2 files changed, 112 insertions(+), 125 deletions(-) diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c index a74efcd..bd8ffa0 100644 --- a/src/egl/main/eglapi.c +++ b/src/egl/main/eglapi.c @@ -102,6 +102,7 @@ #include "eglmode.h" #include "eglimage.h" #include "eglsync.h" +#include "eglstring.h" /** @@ -343,6 +344,111 @@ eglGetPlatformDisplayEXT(EGLenum platform, void *native_display, } /** + * Copy the extension into the string and update the string pointer. + */ +static EGLint +_eglAppendExtension(char **str, const char *ext) +{ + char *s = *str; + size_t len = strlen(ext); + + if (s) { + memcpy(s, ext, len); + s[len++] = ' '; + s[len] = '\0'; + + *str += len; + } + else { + len++; + } + + return (EGLint) len; +} + +/** + * Examine the individual extension enable/disable flags and recompute + * the driver's Extensions string. + */ +static void +_eglCreateExtensionsString(_EGLDisplay *dpy) +{ +#define _EGL_CHECK_EXTENSION(ext) \ + do { \ + if (dpy->Extensions.ext) { \ + _eglAppendExtension(&exts, "EGL_" #ext); \ + assert(exts <= dpy->ExtensionsString + _EGL_MAX_EXTENSIONS_LEN); \ + } \ + } while (0) + + char *exts = dpy->ExtensionsString; + + _EGL_CHECK_EXTENSION(MESA_screen_surface); + _EGL_CHECK_EXTENSION(MESA_copy_context); + _EGL_CHECK_EXTENSION(MESA_drm_display); + _EGL_CHECK_EXTENSION(MESA_drm_image); + _EGL_CHECK_EXTENSION(MESA_configless_context); + + _EGL_CHECK_EXTENSION(WL_bind_wayland_display); + _EGL_CHECK_EXTENSION(WL_create_wayland_buffer_from_image); + + _EGL_CHECK_EXTENSION(KHR_image_base); + _EGL_CHECK_EXTENSION(KHR_image_pixmap); + if (dpy->Extensions.KHR_image_base && dpy->Extensions.KHR_image_pixmap) + _eglAppendExtension(&exts, "EGL_KHR_image"); + + _EGL_CHECK_EXTENSION(KHR_vg_parent_image); + _EGL_CHECK_EXTENSION(KHR_get_all_proc_addresses); + _EGL_CHECK_EXTENSION(KHR_gl_texture_2D_image); + _EGL_CHECK_EXTENSION(KHR_gl_texture_cubemap_image); + _EGL_CHECK_EXTENSION(KHR_gl_texture_3D_image); + _EGL_CHECK_EXTENSION(KHR_gl_renderbuffer_image); + + _EGL_CHECK_EXTENSION(KHR_reusable_sync); + _EGL_CHECK_EXTENSION(KHR_fence_sync); + + _EGL_CHECK_EXTENSION(KHR_surfaceless_context); + _EGL_CHECK_EXTENSION(KHR_create_context); + + _EGL_CHECK_EXTENSION(NOK_swap_region); + _EGL_CHECK_EXTENSION(NOK_texture_from_pixmap); + + _EGL_CHECK_EXTENSION(ANDROID_image_native_buffer); + + _EGL_CHECK_EXTENSION(CHROMIUM_sync_control); + + _EGL_CHECK_EXTENSION(EXT_create_context_robustness); + _EGL_CHECK_EXTENSION(EXT_buffer_age); + _EGL_CHECK_EXTENSION(EXT_swap_buffers_with_damage); + _EGL_CHECK_EXTENSION(EXT_image_dma_buf_import); + + _EGL_CHECK_EXTENSION(NV_post_sub_buffer); +#undef _EGL_CHECK_EXTENSION +} + +static void +_eglCreateAPIsString(_EGLDisplay *dpy) +{ + if (dpy->ClientAPIs & EGL_OPENGL_BIT) + strcat(dpy->ClientAPIsString, "OpenGL "); + + if (dpy->ClientAPIs & EGL_OPENGL_ES_BIT) + strcat(dpy->ClientAPIsString, "OpenGL_ES "); + + if (dpy->ClientAPIs & EGL_OPENGL_ES2_BIT) + strcat(dpy->ClientAPIsString, "OpenGL_ES2 "); + + if (dpy->ClientAPIs & EGL_OPENGL_ES3_BIT_KHR) + strcat(dpy->ClientAPIsString, "OpenGL_ES3 "); + + if (dpy->ClientAPIs & EGL_OPENVG_BIT) + strcat(dpy->ClientAPIsString, "OpenVG "); + + assert(strlen(dpy->ClientAPIsString) < sizeof(dpy->ClientAPIsString)); +} + + +/** * This is typically the second EGL function that an application calls. * Here we load/initialize the actual hardware driver. */ @@ -377,6 +483,12 @@ eglInitialize(EGLDisplay dpy, EGLint *major, EGLint *minor) * EGL_KHR_get_all_proc_addresses also. */ disp->Extensions.KHR_get_all_proc_addresses = EGL_TRUE; + + _eglCreateExtensionsString(disp); + _eglCreateAPIsString(disp); + _eglsnprintf(disp->VersionString, sizeof(disp->VersionString), + "%d.%d (%s)", disp->VersionMajor, disp->VersionMinor, + disp->Driver->Name); } /* Update applications version of major and minor if not NULL */ diff --git a/src/egl/main/eglmisc.c b/src/egl/main/eglmisc.c index 2f49809..3ca3524 100644 --- a/src/egl/main/eglmisc.c +++ b/src/egl/main/eglmisc.c @@ -33,129 +33,9 @@ */ -#include -#include #include "eglcurrent.h" #include "eglmisc.h" #include "egldisplay.h" -#include "egldriver.h" -#include "eglstring.h" - - -/** - * Copy the extension into the string and update the string pointer. - */ -static EGLint -_eglAppendExtension(char **str, const char *ext) -{ - char *s = *str; - size_t len = strlen(ext); - - if (s) { - memcpy(s, ext, len); - s[len++] = ' '; - s[len] = '\0'; - - *str += len; - } - else { - len++; - } - - return (EGLint) len; -} - - -/** - * Examine the individual extension enable/disable flags and recompute - * the driver's Extensions string. - */ -static void -_eglUpdateExtensionsString(_EGLDisplay *dpy) -{ -#define _EGL_CHECK_EXTENSION(ext) \ - do { \ - if (dpy->Extensions.ext) { \ - _eglAppendExtension(&exts, "EGL_" #ext); \ - assert(exts <= dpy->ExtensionsString + _EGL_MAX_EXTENSIONS_LEN); \ - } \ - } while (0) - - char *exts = dpy->ExtensionsString; - - if (exts[0]) - return; - - _EGL_CHECK_EXTENSION(MESA_screen_surface); - _EGL_CHECK_EXTENSION(MESA_copy_context); - _EGL_CHECK_EXTENSION(MESA_drm_display); - _EGL_CHECK_EXTENSION(MESA_drm_image); - _EGL_CHECK_EXTENSION(MESA_configless_context); - - _EGL_CHECK_EXTENSION(WL_bind_wayland_display); - _EGL_CHECK_EXTENSION(WL_create_wayland_buffer_from_image); - - _EGL_CHECK_EXTENSION(KHR_image_base); - _EGL_CHECK_EXTENSION(KHR_image_pixmap); - if (dpy->Extensions.KHR_image_base && dpy->Extensions.KHR_image_pixmap) - _eglAppendExtension(&exts, "EGL_KHR_image"); - - _EGL_CHECK_EXTENSION(KHR_vg_parent_image); - _EGL_CHECK_EXTENSION(KHR_get_all_proc_addresses); - _EGL_CHECK_EXTENSION(KHR_gl_texture_2D_image); - _EGL_CHECK_EXTENSION(KHR_gl_texture_cubemap_image); - _EGL_CHECK_EXTENSION(KHR_gl_texture_3D_image); - _EGL_CHECK_EXTENSION(KHR_gl_renderbuffer_image); - - _EGL_CHECK_EXTENSION(KHR_reusable_sync); - _EGL_CHECK_EXTENSION(KHR_fence_sync); - - _EGL_CHECK_EXTENSION(KHR_surfaceless_context); - _EGL_CHECK_EXTENSION(KHR_create_context); - - _EGL_CHECK_EXTENSION(NOK_swap_region); - _EGL_CHECK_EXTENSION(NOK_texture_from_pixmap); - - _EGL_CHECK_EXTENSION(ANDROID_image_native_buffer); - - _EGL_CHECK_EXTENSION(CHROMIUM_sync_control); - - _EGL_CHECK_EXTENSION(EXT_create_context_robustness); - _EGL_CHECK_EXTENSION(EXT_buffer_age); - _EGL_CHECK_EXTENSION(EXT_swap_buffers_with_damage); - _EGL_CHECK_EXTENSION(EXT_image_dma_buf_import); - - _EGL_CHECK_EXTENSION(NV_post_sub_buffer); -#undef _EGL_CHECK_EXTENSION -} - - -static void -_eglUpdateAPIsString(_EGLDisplay *dpy) -{ - char *apis = dpy->ClientAPIsString; - - if (apis[0] || !dpy->ClientAPIs) - return; - - if (dpy->ClientAPIs & EGL_OPENGL_BIT) - strcat(apis, "OpenGL "); - - if (dpy->ClientAPIs & EGL_OPENGL_ES_BIT) - strcat(apis, "OpenGL_ES "); - - if (dpy->ClientAPIs & EGL_OPENGL_ES2_BIT) - strcat(apis, "OpenGL_ES2 "); - - if (dpy->ClientAPIs & EGL_OPENGL_ES3_BIT_KHR) - strcat(apis, "OpenGL_ES3 "); - - if (dpy->ClientAPIs & EGL_OPENVG_BIT) - strcat(apis, "OpenVG "); - - assert(strlen(apis) < sizeof(dpy->ClientAPIsString)); -} - const char * _eglQueryString(_EGLDriver *drv, _EGLDisplay *dpy, EGLint name) @@ -166,15 +46,10 @@ _eglQueryString(_EGLDriver *drv, _EGLDisplay *dpy, EGLint name) case EGL_VENDOR: return _EGL_VENDOR_STRING; case EGL_VERSION: - _eglsnprintf(dpy->VersionString, sizeof(dpy->VersionString), - "%d.%d (%s)", dpy->VersionMajor, dpy->VersionMinor, - dpy->Driver->Name); return dpy->VersionString; case EGL_EXTENSIONS: - _eglUpdateExtensionsString(dpy); return dpy->ExtensionsString; case EGL_CLIENT_APIS: - _eglUpdateAPIsString(dpy); return dpy->ClientAPIsString; default: _eglError(EGL_BAD_PARAMETER, "eglQueryString"); From mattst88 at kemper.freedesktop.org Fri Mar 13 17:42:47 2015 From: mattst88 at kemper.freedesktop.org (Matt Turner) Date: Fri, 13 Mar 2015 10:42:47 -0700 (PDT) Subject: Mesa (master): glsl: Expose built-in packing functions under GLSL 4.2. Message-ID: <20150313174247.D9E9C76250@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 8d3aa5926b73c67c7dbd4477b7177aaa00c533e5 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=8d3aa5926b73c67c7dbd4477b7177aaa00c533e5 Author: Matt Turner Date: Wed Mar 11 18:14:28 2015 -0700 glsl: Expose built-in packing functions under GLSL 4.2. ARB_shading_language_packing is part of GLSL 4.2, not 4.0 as I mistakenly believed. The following functions are available only with ARB_shading_language_packing, GLSL 4.2 (not GLSL 4.0), or ES 3.0: - packSnorm2x16 - unpackSnorm2x16 - packHalf2x16 - unpackHalf2x16 Reviewed-by: Carl Worth Reviewed-by: Marek Ol??k --- src/glsl/builtin_functions.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/glsl/builtin_functions.cpp b/src/glsl/builtin_functions.cpp index 84bbdc2..c607572 100644 --- a/src/glsl/builtin_functions.cpp +++ b/src/glsl/builtin_functions.cpp @@ -201,7 +201,7 @@ static bool shader_packing_or_es3(const _mesa_glsl_parse_state *state) { return state->ARB_shading_language_packing_enable || - state->is_version(400, 300); + state->is_version(420, 300); } static bool From chrisf at kemper.freedesktop.org Fri Mar 13 18:51:26 2015 From: chrisf at kemper.freedesktop.org (Chris Forbes) Date: Fri, 13 Mar 2015 11:51:26 -0700 (PDT) Subject: Mesa (master): i965/disasm: Mark format() as being printf-style. Message-ID: <20150313185126.116BB76250@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 7c3095d6b71c410fd625ead797c78a0f5376904d URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=7c3095d6b71c410fd625ead797c78a0f5376904d Author: Chris Forbes Date: Sat Mar 14 07:10:10 2015 +1300 i965/disasm: Mark format() as being printf-style. This allows us to get warnings from GCC when we mess up the format strings. Signed-off-by: Chris Forbes Reviewed-by: Matt Turner --- src/mesa/drivers/dri/i965/brw_disasm.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/mesa/drivers/dri/i965/brw_disasm.c b/src/mesa/drivers/dri/i965/brw_disasm.c index 863a6b3..c92c534 100644 --- a/src/mesa/drivers/dri/i965/brw_disasm.c +++ b/src/mesa/drivers/dri/i965/brw_disasm.c @@ -597,6 +597,9 @@ string(FILE *file, const char *string) } static int +format(FILE *f, const char *format, ...) PRINTFLIKE(2, 3); + +static int format(FILE *f, const char *format, ...) { char buf[1024]; From chrisf at kemper.freedesktop.org Fri Mar 13 18:51:26 2015 From: chrisf at kemper.freedesktop.org (Chris Forbes) Date: Fri, 13 Mar 2015 11:51:26 -0700 (PDT) Subject: Mesa (master): i965/disasm: Fix format strings Message-ID: <20150313185126.18F4E76332@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 21ff9bfe1cea8c0a51e9f607cc580df62baa3445 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=21ff9bfe1cea8c0a51e9f607cc580df62baa3445 Author: Chris Forbes Date: Sat Mar 14 07:10:11 2015 +1300 i965/disasm: Fix format strings Most of the brw_inst_* api returns 64bit values. This fixes disassembly of sampler messages, etc. Signed-off-by: Chris Forbes Reviewed-by: Matt Turner --- src/mesa/drivers/dri/i965/brw_disasm.c | 48 ++++++++++++++++---------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_disasm.c b/src/mesa/drivers/dri/i965/brw_disasm.c index c92c534..c41dde2 100644 --- a/src/mesa/drivers/dri/i965/brw_disasm.c +++ b/src/mesa/drivers/dri/i965/brw_disasm.c @@ -729,7 +729,7 @@ dest(FILE *file, struct brw_context *brw, brw_inst *inst) if (err == -1) return 0; if (brw_inst_dst_da1_subreg_nr(brw, inst)) - format(file, ".%d", brw_inst_dst_da1_subreg_nr(brw, inst) / + format(file, ".%ld", brw_inst_dst_da1_subreg_nr(brw, inst) / reg_type_size[brw_inst_dst_reg_type(brw, inst)]); string(file, "<"); err |= control(file, "horiz stride", horiz_stride, @@ -740,7 +740,7 @@ dest(FILE *file, struct brw_context *brw, brw_inst *inst) } else { string(file, "g[a0"); if (brw_inst_dst_ia_subreg_nr(brw, inst)) - format(file, ".%d", brw_inst_dst_ia_subreg_nr(brw, inst) / + format(file, ".%ld", brw_inst_dst_ia_subreg_nr(brw, inst) / reg_type_size[brw_inst_dst_reg_type(brw, inst)]); if (brw_inst_dst_ia1_addr_imm(brw, inst)) format(file, " %d", brw_inst_dst_ia1_addr_imm(brw, inst)); @@ -758,7 +758,7 @@ dest(FILE *file, struct brw_context *brw, brw_inst *inst) if (err == -1) return 0; if (brw_inst_dst_da16_subreg_nr(brw, inst)) - format(file, ".%d", brw_inst_dst_da16_subreg_nr(brw, inst) / + format(file, ".%ld", brw_inst_dst_da16_subreg_nr(brw, inst) / reg_type_size[brw_inst_dst_reg_type(brw, inst)]); string(file, "<1>"); err |= control(file, "writemask", writemask, @@ -789,7 +789,7 @@ dest_3src(FILE *file, struct brw_context *brw, brw_inst *inst) if (err == -1) return 0; if (brw_inst_3src_dst_subreg_nr(brw, inst)) - format(file, ".%d", brw_inst_3src_dst_subreg_nr(brw, inst)); + format(file, ".%ld", brw_inst_3src_dst_subreg_nr(brw, inst)); string(file, "<1>"); err |= control(file, "writemask", writemask, brw_inst_3src_dst_writemask(brw, inst), NULL); @@ -1225,9 +1225,9 @@ brw_disassemble_inst(FILE *file, struct brw_context *brw, brw_inst *inst, string(file, "("); err |= control(file, "predicate inverse", pred_inv, brw_inst_pred_inv(brw, inst), NULL); - format(file, "f%d", brw->gen >= 7 ? brw_inst_flag_reg_nr(brw, inst) : 0); + format(file, "f%ld", brw->gen >= 7 ? brw_inst_flag_reg_nr(brw, inst) : 0); if (brw_inst_flag_subreg_nr(brw, inst)) - format(file, ".%d", brw_inst_flag_subreg_nr(brw, inst)); + format(file, ".%ld", brw_inst_flag_subreg_nr(brw, inst)); if (brw_inst_access_mode(brw, inst) == BRW_ALIGN_1) { err |= control(file, "predicate control align1", pred_ctrl_align1, brw_inst_pred_control(brw, inst), NULL); @@ -1261,10 +1261,10 @@ brw_disassemble_inst(FILE *file, struct brw_context *brw, brw_inst *inst, (brw->gen < 6 || (opcode != BRW_OPCODE_SEL && opcode != BRW_OPCODE_IF && opcode != BRW_OPCODE_WHILE))) { - format(file, ".f%d", + format(file, ".f%ld", brw->gen >= 7 ? brw_inst_flag_reg_nr(brw, inst) : 0); if (brw_inst_flag_subreg_nr(brw, inst)) - format(file, ".%d", brw_inst_flag_subreg_nr(brw, inst)); + format(file, ".%ld", brw_inst_flag_subreg_nr(brw, inst)); } } @@ -1276,7 +1276,7 @@ brw_disassemble_inst(FILE *file, struct brw_context *brw, brw_inst *inst, } if (opcode == BRW_OPCODE_SEND && brw->gen < 6) - format(file, " %d", brw_inst_base_mrf(brw, inst)); + format(file, " %ld", brw_inst_base_mrf(brw, inst)); if (has_uip(brw, opcode)) { /* Instructions that have UIP also have JIP. */ @@ -1297,7 +1297,7 @@ brw_disassemble_inst(FILE *file, struct brw_context *brw, brw_inst *inst, pad(file, 16); format(file, "Jump: %d", brw_inst_gen4_jump_count(brw, inst)); pad(file, 32); - format(file, "Pop: %d", brw_inst_gen4_pop_count(brw, inst)); + format(file, "Pop: %ld", brw_inst_gen4_pop_count(brw, inst)); } else if (brw->gen < 6 && (opcode == BRW_OPCODE_IF || opcode == BRW_OPCODE_IFF || opcode == BRW_OPCODE_HALT)) { @@ -1305,7 +1305,7 @@ brw_disassemble_inst(FILE *file, struct brw_context *brw, brw_inst *inst, format(file, "Jump: %d", brw_inst_gen4_jump_count(brw, inst)); } else if (brw->gen < 6 && opcode == BRW_OPCODE_ENDIF) { pad(file, 16); - format(file, "Pop: %d", brw_inst_gen4_pop_count(brw, inst)); + format(file, "Pop: %ld", brw_inst_gen4_pop_count(brw, inst)); } else if (opcode == BRW_OPCODE_JMPI) { pad(file, 16); err |= src1(file, brw, inst); @@ -1374,13 +1374,13 @@ brw_disassemble_inst(FILE *file, struct brw_context *brw, brw_inst *inst, break; case BRW_SFID_SAMPLER: if (brw->gen >= 5) { - format(file, " (%d, %d, %d, %d)", + format(file, " (%ld, %ld, %ld, %ld)", brw_inst_binding_table_index(brw, inst), brw_inst_sampler(brw, inst), brw_inst_sampler_msg_type(brw, inst), brw_inst_sampler_simd_mode(brw, inst)); } else { - format(file, " (%d, %d, %d, ", + format(file, " (%ld, %ld, %ld, ", brw_inst_binding_table_index(brw, inst), brw_inst_sampler(brw, inst), brw_inst_sampler_msg_type(brw, inst)); @@ -1395,13 +1395,13 @@ brw_disassemble_inst(FILE *file, struct brw_context *brw, brw_inst *inst, case GEN6_SFID_DATAPORT_SAMPLER_CACHE: /* aka BRW_SFID_DATAPORT_READ on Gen4-5 */ if (brw->gen >= 6) { - format(file, " (%d, %d, %d, %d)", + format(file, " (%ld, %ld, %ld, %ld)", brw_inst_binding_table_index(brw, inst), brw_inst_dp_msg_control(brw, inst), brw_inst_dp_msg_type(brw, inst), brw->gen >= 7 ? 0 : brw_inst_dp_write_commit(brw, inst)); } else { - format(file, " (%d, %d, %d)", + format(file, " (%ld, %ld, %ld)", brw_inst_binding_table_index(brw, inst), brw_inst_dp_read_msg_control(brw, inst), brw_inst_dp_read_msg_type(brw, inst)); @@ -1431,16 +1431,16 @@ brw_disassemble_inst(FILE *file, struct brw_context *brw, brw_inst *inst, if (brw->gen < 7 && brw_inst_dp_write_commit(brw, inst)) string(file, " WriteCommit"); } else { - format(file, " MsgCtrl = 0x%x", + format(file, " MsgCtrl = 0x%lx", brw_inst_dp_write_msg_control(brw, inst)); } - format(file, " Surface = %d", brw_inst_binding_table_index(brw, inst)); + format(file, " Surface = %ld", brw_inst_binding_table_index(brw, inst)); break; } case BRW_SFID_URB: - format(file, " %d", brw_inst_urb_global_offset(brw, inst)); + format(file, " %ld", brw_inst_urb_global_offset(brw, inst)); space = 1; if (brw->gen >= 7) { @@ -1473,7 +1473,7 @@ brw_disassemble_inst(FILE *file, struct brw_context *brw, brw_inst *inst, dp_dc0_msg_type_gen7, brw_inst_dp_msg_type(brw, inst), &space); - format(file, ", %d, ", brw_inst_binding_table_index(brw, inst)); + format(file, ", %ld, ", brw_inst_binding_table_index(brw, inst)); switch (brw_inst_dp_msg_type(brw, inst)) { case GEN7_DATAPORT_DC_UNTYPED_ATOMIC_OP: @@ -1481,7 +1481,7 @@ brw_disassemble_inst(FILE *file, struct brw_context *brw, brw_inst *inst, brw_inst_imm_ud(brw, inst) >> 8 & 0xf, &space); break; default: - format(file, "%d", brw_inst_dp_msg_control(brw, inst)); + format(file, "%ld", brw_inst_dp_msg_control(brw, inst)); } format(file, ")"); break; @@ -1498,7 +1498,7 @@ brw_disassemble_inst(FILE *file, struct brw_context *brw, brw_inst *inst, dp_dc1_msg_type_hsw, brw_inst_dp_msg_type(brw, inst), &space); - format(file, ", Surface = %d, ", + format(file, ", Surface = %ld, ", brw_inst_binding_table_index(brw, inst)); switch (brw_inst_dp_msg_type(brw, inst)) { @@ -1532,7 +1532,7 @@ brw_disassemble_inst(FILE *file, struct brw_context *brw, brw_inst *inst, case GEN7_SFID_PIXEL_INTERPOLATOR: if (brw->gen >= 7) { - format(file, " (%s, %s, 0x%02x)", + format(file, " (%s, %s, 0x%02lx)", brw_inst_pi_nopersp(brw, inst) ? "linear" : "persp", pixel_interpolator_msg_types[brw_inst_pi_message_type(brw, inst)], brw_inst_pi_message_data(brw, inst)); @@ -1547,8 +1547,8 @@ brw_disassemble_inst(FILE *file, struct brw_context *brw, brw_inst *inst, if (space) string(file, " "); - format(file, "mlen %d", brw_inst_mlen(brw, inst)); - format(file, " rlen %d", brw_inst_rlen(brw, inst)); + format(file, "mlen %ld", brw_inst_mlen(brw, inst)); + format(file, " rlen %ld", brw_inst_rlen(brw, inst)); } } pad(file, 64); From idr at kemper.freedesktop.org Fri Mar 13 20:03:02 2015 From: idr at kemper.freedesktop.org (Ian Romanick) Date: Fri, 13 Mar 2015 13:03:02 -0700 (PDT) Subject: Mesa (master): i965/vs: Add missing resolve_bool_comparison calls on GEN4 and GEN5 Message-ID: <20150313200302.0ECA976250@kemper.freedesktop.org> Module: Mesa Branch: master Commit: e76a8dc8ed8af9ea9c99ff4f84948fa834317ee9 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=e76a8dc8ed8af9ea9c99ff4f84948fa834317ee9 Author: Ian Romanick Date: Tue Feb 24 20:57:18 2015 -0500 i965/vs: Add missing resolve_bool_comparison calls on GEN4 and GEN5 The ir_unop_any problem was discovered by some later optimization passes that generate ir_triop_csel. I was also able to reproduce it by modifying the gl-2.0-vertexattribpointer vertex shader to generate its result using color = mix(vec4(0, 1, 0, 0), vec4(1, 0, 0, 0), bvec4(any(greaterThan(diff, vec4(tolerance))))); instead of an if-statement. This also required using #version 130 and MESA_GLSL_VERSION_OVERRIDE=130. I have not nominated this for stable releases because I don't think there's any way to trigger the problem without GLSL 1.30 or optimizations that don't exist in stable. Signed-off-by: Ian Romanick Reviewed-by: Abdiel Janulgue --- src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp index 5bf9e1b..195c6f5 100644 --- a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp +++ b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp @@ -1555,6 +1555,11 @@ vec4_visitor::visit(ir_expression *ir) } case ir_binop_all_equal: + if (brw->gen <= 5) { + resolve_bool_comparison(ir->operands[0], &op[0]); + resolve_bool_comparison(ir->operands[1], &op[1]); + } + /* "==" operator producing a scalar boolean. */ if (ir->operands[0]->type->is_vector() || ir->operands[1]->type->is_vector()) { @@ -1567,6 +1572,11 @@ vec4_visitor::visit(ir_expression *ir) } break; case ir_binop_any_nequal: + if (brw->gen <= 5) { + resolve_bool_comparison(ir->operands[0], &op[0]); + resolve_bool_comparison(ir->operands[1], &op[1]); + } + /* "!=" operator producing a scalar boolean. */ if (ir->operands[0]->type->is_vector() || ir->operands[1]->type->is_vector()) { @@ -1581,6 +1591,9 @@ vec4_visitor::visit(ir_expression *ir) break; case ir_unop_any: + if (brw->gen <= 5) { + resolve_bool_comparison(ir->operands[0], &op[0]); + } emit(CMP(dst_null_d(), op[0], src_reg(0), BRW_CONDITIONAL_NZ)); emit(MOV(result_dst, src_reg(0))); From imirkin at kemper.freedesktop.org Fri Mar 13 20:06:35 2015 From: imirkin at kemper.freedesktop.org (Ilia Mirkin) Date: Fri, 13 Mar 2015 13:06:35 -0700 (PDT) Subject: Mesa (master): freedreno/a3xx: use the same layer size for all slices Message-ID: <20150313200635.C20F776250@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 89b26d5a360ebde11a69f2cdefa66e4d6a2a13fd URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=89b26d5a360ebde11a69f2cdefa66e4d6a2a13fd Author: Ilia Mirkin Date: Fri Mar 13 00:53:49 2015 -0400 freedreno/a3xx: use the same layer size for all slices We only program in one layer size per texture, so that means that all levels must share one size. This makes the piglit test bin/texelFetch fs sampler2DArray have the same breakage as its non-array version instead of being completely off, and makes bin/ext_texture_array-gen-mipmap start passing. Signed-off-by: Ilia Mirkin Cc: "10.4 10.5" Reviewed-by: Rob Clark --- src/gallium/drivers/freedreno/freedreno_resource.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/gallium/drivers/freedreno/freedreno_resource.c b/src/gallium/drivers/freedreno/freedreno_resource.c index c412407..c7b4e57 100644 --- a/src/gallium/drivers/freedreno/freedreno_resource.c +++ b/src/gallium/drivers/freedreno/freedreno_resource.c @@ -215,7 +215,14 @@ setup_slices(struct fd_resource *rsc, uint32_t alignment) slice->pitch = align(width, 32); slice->offset = size; - slice->size0 = align(slice->pitch * height * rsc->cpp, alignment); + /* 1d array, 2d array, 3d textures (but not cube!) must all have the + * same layer size for each miplevel on a3xx. These are also the + * targets that have non-1 alignment. + */ + if (level == 0 || layers_in_level == 1 || alignment == 1) + slice->size0 = align(slice->pitch * height * rsc->cpp, alignment); + else + slice->size0 = rsc->slices[0].size0; size += slice->size0 * depth * layers_in_level; From imirkin at kemper.freedesktop.org Fri Mar 13 20:06:35 2015 From: imirkin at kemper.freedesktop.org (Ilia Mirkin) Date: Fri, 13 Mar 2015 13:06:35 -0700 (PDT) Subject: Mesa (master): freedreno: fix slice pitch calculations Message-ID: <20150313200635.CC87B76250@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 620e29b74821fd75b24495ab2bfddea53fc75350 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=620e29b74821fd75b24495ab2bfddea53fc75350 Author: Ilia Mirkin Date: Fri Mar 13 01:36:57 2015 -0400 freedreno: fix slice pitch calculations For example if width were 65, the first slice would get 96 while the second would get 32. However the hardware appears to expect the second pitch to be 64, based on halving the 96 (and aligning up to 32). This fixes texelFetch piglit tests on a3xx below a certain size. Going higher they break again, but most likely due to unrelated reasons. Signed-off-by: Ilia Mirkin Cc: "10.4 10.5" Reviewed-by: Rob Clark --- src/gallium/drivers/freedreno/freedreno_resource.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gallium/drivers/freedreno/freedreno_resource.c b/src/gallium/drivers/freedreno/freedreno_resource.c index c7b4e57..69e5452 100644 --- a/src/gallium/drivers/freedreno/freedreno_resource.c +++ b/src/gallium/drivers/freedreno/freedreno_resource.c @@ -213,7 +213,7 @@ setup_slices(struct fd_resource *rsc, uint32_t alignment) for (level = 0; level <= prsc->last_level; level++) { struct fd_resource_slice *slice = fd_resource_slice(rsc, level); - slice->pitch = align(width, 32); + slice->pitch = width = align(width, 32); slice->offset = size; /* 1d array, 2d array, 3d textures (but not cube!) must all have the * same layer size for each miplevel on a3xx. These are also the From evelikov at kemper.freedesktop.org Fri Mar 13 23:30:35 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Fri, 13 Mar 2015 16:30:35 -0700 (PDT) Subject: Mesa (10.5): Add release notes for the 10.5.1 release Message-ID: <20150313233035.5904376332@kemper.freedesktop.org> Module: Mesa Branch: 10.5 Commit: 11c0ff60ef19cca84452aa989fb8bb25127473e0 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=11c0ff60ef19cca84452aa989fb8bb25127473e0 Author: Emil Velikov Date: Fri Mar 13 22:32:57 2015 +0000 Add release notes for the 10.5.1 release Signed-off-by: Emil Velikov --- docs/relnotes/10.5.1.html | 216 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 216 insertions(+) diff --git a/docs/relnotes/10.5.1.html b/docs/relnotes/10.5.1.html new file mode 100644 index 0000000..f9cadca --- /dev/null +++ b/docs/relnotes/10.5.1.html @@ -0,0 +1,216 @@ + + + + + Mesa Release Notes + + + + +
        +

        The Mesa 3D Graphics Library

        +
        + + +
        + +

        Mesa 10.5.1 Release Notes / March 13, 2015

        + +

        +Mesa 10.5.1 is a bug fix release which fixes bugs found since the 10.5.0 release. +

        +

        +Mesa 10.5.1 implements the OpenGL 3.3 API, but the version reported by +glGetString(GL_VERSION) or glGetIntegerv(GL_MAJOR_VERSION) / +glGetIntegerv(GL_MINOR_VERSION) depends on the particular driver being used. +Some drivers don't support all the features required in OpenGL 3.3. OpenGL +3.3 is only available if requested at context creation +because compatibility contexts are not supported. +

        + + +

        SHA256 checksums

        +
        +TBD
        +
        + + +

        New features

        +

        None

        + +

        Bug fixes

        + +

        This list is likely incomplete.

        + +
          + +
        • Bug 79202 - valgrind errors in glsl-fs-uniform-array-loop-unroll.shader_test; random code generation
        • + +
        • Bug 84613 - [G965, bisected] piglit regressions : glslparsertest.glsl2
        • + +
        • Bug 86747 - Noise in Football Manager 2014 textures
        • + +
        • Bug 86974 - INTEL_DEBUG=shader_time always asserts in fs_generator::generate_code() when Mesa is built with --enable-debug (= with asserts)
        • + +
        • Bug 88246 - Commit 2881b12 causes 43 DrawElements test regressions
        • + +
        • Bug 88793 - [BDW/BSW Bisected]Piglit/shaders_glsl-max-varyings fails
        • + +
        • Bug 88883 - ir-a2xx.c: variable changed in assert statement
        • + +
        • Bug 88885 - Transform feedback uses incorrect interleaving if a previous draw did not write gl_Position
        • + +
        • Bug 89095 - [SNB/IVB/BYT Bisected]Webglc conformance/glsl/functions/glsl-function-mix-float.html fails
        • + +
        • Bug 89156 - r300g: GL_COMPRESSED_RED_RGTC1 / ATI1N support broken
        • + +
        • Bug 89224 - Incorrect rendering of Unigine Valley running in VM on VMware Workstation
        • + +
        • Bug 89292 - [regression,bisected] incomplete screenshots in some cases
        • + +
        • Bug 89311 - [regression, bisected] dEQP: Added entry points for glCompressedTextureSubImage*D.
        • + +
        • Bug 89312 - [regression, bisected] main: Added entry points for CopyTextureSubImage*D. (d6b7c40cecfe01)
        • + +
        • Bug 89315 - [HSW, regression, bisected] i965/fs: Emit MAD instructions when possible.
        • + +
        • Bug 89317 - [HSW, regression, bisected] i965: Add LINTERP/CINTERP to can_do_cmod() (d91390634)
        • + +
        • Bug 89416 - UE4Editor crash after load project
        • + +
        • Bug 89430 - [g965][bisected] arb_copy_image-targets gl_texture* tests fail
        • + +
        + + +

        Changes

        + +

        Andrey Sudnik (1):

        +
          +
        • i965/vec4: Don't lose the saturate modifier in copy propagation.
        • +
        + +

        Chris Forbes (1):

        +
          +
        • i965/gs: Check newly-generated GS-out VUE map against correct stage
        • +
        + +

        Daniel Stone (1):

        +
          +
        • egl: Take alpha bits into account when selecting GBM formats
        • +
        + +

        Emil Velikov (5):

        +
          +
        • docs: Add sha256 sums for the 10.5.0 release
        • +
        • egl/main: no longer export internal function
        • +
        • cherry-ignore: ignore a few more commits picked without -x
        • +
        • mapi: fix commit 90411b56f6bc817e229d8801ac0adad6d4e3fb7a
        • +
        • Update version to 10.5.1
        • +
        + +

        Frank Henigman (1):

        +
          +
        • intel: fix EGLImage renderbuffer _BaseFormat
        • +
        + +

        Iago Toral Quiroga (1):

        +
          +
        • i965: Fix out-of-bounds accesses into pull_constant_loc array
        • +
        + +

        Ian Romanick (1):

        +
          +
        • i965/fs/nir: Use emit_math for nir_op_fpow
        • +
        + +

        Ilia Mirkin (3):

        +
          +
        • freedreno: move fb state copy after checking for size change
        • +
        • freedreno/ir3: fix array count returned by TXQ
        • +
        • freedreno/ir3: get the # of miplevels from getinfo
        • +
        + +

        Jason Ekstrand (2):

        +
          +
        • meta/TexSubImage: Stash everything other than PIXEL_TRANSFER/store in meta_begin
        • +
        • main/base_tex_format: Properly handle STENCIL_INDEX1/4/16
        • +
        + +

        Kenneth Graunke (8):

        +
          +
        • i965: Split Gen4-5 BlitFramebuffer code; prefer BLT over Meta.
        • +
        • glsl: Mark array access when copying to a temporary for the ?: operator.
        • +
        • i965/fs: Set force_writemask_all on shader_time instructions.
        • +
        • i965/fs: Set smear on shader_time diff register.
        • +
        • i965/fs: Make emit_shader_time_write return rather than emit.
        • +
        • i965/fs: Make get_timestamp() pass back the MOV rather than emitting it.
        • +
        • i965/fs: Make emit_shader_time_end() insert before EOT.
        • +
        • i965/fs: Don't issue FB writes for bound but unwritten color targets.
        • +
        + +

        Laura Ekstrand (2):

        +
          +
        • main: Fix target checking for CompressedTexSubImage*D.
        • +
        • main: Fix target checking for CopyTexSubImage*D.
        • +
        + +

        Marc-Andre Lureau (1):

        +
          +
        • gallium/auxiliary/indices: fix start param
        • +
        + +

        Marek Ol??k (3):

        +
          +
        • r300g: fix RGTC1 and LATC1 SNORM formats
        • +
        • r300g: fix a crash when resolving into an sRGB texture
        • +
        • r300g: fix sRGB->sRGB blits
        • +
        + +

        Matt Turner (12):

        +
          +
        • i965/vec4: Fix implementation of i2b.
        • +
        • mesa: Indent break statements and add a missing one.
        • +
        • mesa: Free memory allocated for luminance in readpixels.
        • +
        • mesa: Correct backwards NULL check.
        • +
        • i965: Consider scratch writes to have side effects.
        • +
        • i965/fs: Don't use backend_visitor::instructions after creating the CFG.
        • +
        • r300g: Use PATH_MAX instead of limiting ourselves to 100 chars.
        • +
        • r300g: Check return value of snprintf().
        • +
        • i965/fs: Don't propagate cmod to inst with different type.
        • +
        • i965: Tell intel_get_memcpy() which direction the memcpy() is going.
        • +
        • Revert SHA1 additions.
        • +
        • i965: Avoid applying negate to wrong MAD source.
        • +
        + +

        Neil Roberts (4):

        +
          +
        • meta: In pbo_{Get,}TexSubImage don't repeatedly rebind the source tex
        • +
        • Revert "common: Fix PBOs for 1D_ARRAY."
        • +
        • meta: Allow GL_UN/PACK_IMAGE_HEIGHT in _mesa_meta_pbo_Get/TexSubImage
        • +
        • meta: Fix the y offset for 1D_ARRAY in _mesa_meta_pbo_TexSubImage
        • +
        + +

        Rob Clark (11):

        +
          +
        • freedreno/ir3: fix silly typo for binning pass shaders
        • +
        • freedreno/a2xx: fix increment in assert
        • +
        • freedreno/a4xx: bit of cleanup
        • +
        • freedreno: update generated headers
        • +
        • freedreno/a4xx: set PC_PRIM_VTX_CNTL.VAROUT properly
        • +
        • freedreno: update generated headers
        • +
        • freedreno/a4xx: aniso filtering
        • +
        • freedreno/ir3: fix up cat6 instruction encodings
        • +
        • freedreno/ir3: add support for memory (cat6) instructions
        • +
        • freedreno/ir3: handle flat bypass for a4xx
        • +
        • freedreno/ir3: fix failed assert in grouping
        • +
        + +

        Stefan D?singer (1):

        +
          +
        • r300g: Fix the ATI1N swizzle (RGTC1 and LATC1)
        • +
        + +
        + + From evelikov at kemper.freedesktop.org Fri Mar 13 23:30:35 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Fri, 13 Mar 2015 16:30:35 -0700 (PDT) Subject: Mesa (10.5): docs: Add sha256 sums for the 10.5.1 release Message-ID: <20150313233035.6536376359@kemper.freedesktop.org> Module: Mesa Branch: 10.5 Commit: 2abba086ca84f200fae940129c0a5342c3748f00 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=2abba086ca84f200fae940129c0a5342c3748f00 Author: Emil Velikov Date: Fri Mar 13 23:32:12 2015 +0000 docs: Add sha256 sums for the 10.5.1 release Signed-off-by: Emil Velikov --- docs/relnotes/10.5.1.html | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/relnotes/10.5.1.html b/docs/relnotes/10.5.1.html index f9cadca..a9b91fa 100644 --- a/docs/relnotes/10.5.1.html +++ b/docs/relnotes/10.5.1.html @@ -31,7 +31,8 @@ because compatibility contexts are not supported.

        SHA256 checksums

        -TBD
        +b5b6256a6d46023e16a675257fd11a0f94d7b3e60a76cf112952da3d0fef8e9b  mesa-10.5.1.tar.gz
        +ffc51943d15c6812ee7611d053d8980a683fbd6a4986cff567b12cc66637d679  mesa-10.5.1.tar.xz
         
        From evelikov at kemper.freedesktop.org Fri Mar 13 23:30:35 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Fri, 13 Mar 2015 16:30:35 -0700 (PDT) Subject: Mesa: tag mesa-10.5.1: Mesa 10.5.1 release Message-ID: <20150313233035.8006976250@kemper.freedesktop.org> Module: Mesa Branch: refs/tags/mesa-10.5.1 Tag: aa7d27b4319a3376fcca08100fd517b71fe4799d URL: http://cgit.freedesktop.org/mesa/mesa/tag/?id=aa7d27b4319a3376fcca08100fd517b71fe4799d Tagger: Emil Velikov Date: Fri Mar 13 22:36:57 2015 +0000 Mesa 10.5.1 release From evelikov at kemper.freedesktop.org Fri Mar 13 23:30:35 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Fri, 13 Mar 2015 16:30:35 -0700 (PDT) Subject: Mesa (10.5): Update version to 10.5.1 Message-ID: <20150313233035.4E8C276250@kemper.freedesktop.org> Module: Mesa Branch: 10.5 Commit: 0f32ac39208f2e621e7bf838cf9a0a2bf9292960 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=0f32ac39208f2e621e7bf838cf9a0a2bf9292960 Author: Emil Velikov Date: Fri Mar 13 22:32:35 2015 +0000 Update version to 10.5.1 Signed-off-by: Emil Velikov --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 2cf514e..4a6e70e 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -10.5.0 +10.5.1 From evelikov at kemper.freedesktop.org Fri Mar 13 23:34:06 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Fri, 13 Mar 2015 16:34:06 -0700 (PDT) Subject: Mesa (master): docs: Add sha256 sums for the 10.5.1 release Message-ID: <20150313233406.B6FFF76332@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 5f72847a885518eacafc05d10e1cb52b978ba061 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=5f72847a885518eacafc05d10e1cb52b978ba061 Author: Emil Velikov Date: Fri Mar 13 23:32:12 2015 +0000 docs: Add sha256 sums for the 10.5.1 release Signed-off-by: Emil Velikov (cherry picked from commit 2abba086ca84f200fae940129c0a5342c3748f00) --- docs/relnotes/10.5.1.html | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/relnotes/10.5.1.html b/docs/relnotes/10.5.1.html index f9cadca..a9b91fa 100644 --- a/docs/relnotes/10.5.1.html +++ b/docs/relnotes/10.5.1.html @@ -31,7 +31,8 @@ because compatibility contexts are not supported.

        SHA256 checksums

        -TBD
        +b5b6256a6d46023e16a675257fd11a0f94d7b3e60a76cf112952da3d0fef8e9b  mesa-10.5.1.tar.gz
        +ffc51943d15c6812ee7611d053d8980a683fbd6a4986cff567b12cc66637d679  mesa-10.5.1.tar.xz
         
        From evelikov at kemper.freedesktop.org Fri Mar 13 23:34:06 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Fri, 13 Mar 2015 16:34:06 -0700 (PDT) Subject: Mesa (master): docs: add news item and link release notes for mesa 10.5.1 Message-ID: <20150313233406.C1A0C76250@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 8ed1b65b62665810291562b59f1e983f7a78a0fc URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=8ed1b65b62665810291562b59f1e983f7a78a0fc Author: Emil Velikov Date: Fri Mar 13 23:36:33 2015 +0000 docs: add news item and link release notes for mesa 10.5.1 Signed-off-by: Emil Velikov --- docs/index.html | 6 ++++++ docs/relnotes.html | 1 + 2 files changed, 7 insertions(+) diff --git a/docs/index.html b/docs/index.html index e52dc44..9144a43 100644 --- a/docs/index.html +++ b/docs/index.html @@ -16,6 +16,12 @@

        News

        +

        March 13, 2015

        +

        +Mesa 10.5.1 is released. +This is a bug-fix release. +

        +

        March 06, 2015

        Mesa 10.5.0 is released. This is a new diff --git a/docs/relnotes.html b/docs/relnotes.html index eea1064..9a9c0ba 100644 --- a/docs/relnotes.html +++ b/docs/relnotes.html @@ -21,6 +21,7 @@ The release notes summarize what's new or changed in each Mesa release.

          +
        • 10.5.1 release notes
        • 10.5.0 release notes
        • 10.4.6 release notes
        • 10.4.5 release notes From evelikov at kemper.freedesktop.org Fri Mar 13 23:34:06 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Fri, 13 Mar 2015 16:34:06 -0700 (PDT) Subject: Mesa (master): Add release notes for the 10.5.1 release Message-ID: <20150313233406.AEB1176250@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 6c966089374d7cb7a7778e91de182f54fc70e07c URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=6c966089374d7cb7a7778e91de182f54fc70e07c Author: Emil Velikov Date: Fri Mar 13 22:32:57 2015 +0000 Add release notes for the 10.5.1 release Signed-off-by: Emil Velikov (cherry picked from commit 11c0ff60ef19cca84452aa989fb8bb25127473e0) --- docs/relnotes/10.5.1.html | 216 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 216 insertions(+) diff --git a/docs/relnotes/10.5.1.html b/docs/relnotes/10.5.1.html new file mode 100644 index 0000000..f9cadca --- /dev/null +++ b/docs/relnotes/10.5.1.html @@ -0,0 +1,216 @@ + + + + + Mesa Release Notes + + + + +
          +

          The Mesa 3D Graphics Library

          +
          + + +
          + +

          Mesa 10.5.1 Release Notes / March 13, 2015

          + +

          +Mesa 10.5.1 is a bug fix release which fixes bugs found since the 10.5.0 release. +

          +

          +Mesa 10.5.1 implements the OpenGL 3.3 API, but the version reported by +glGetString(GL_VERSION) or glGetIntegerv(GL_MAJOR_VERSION) / +glGetIntegerv(GL_MINOR_VERSION) depends on the particular driver being used. +Some drivers don't support all the features required in OpenGL 3.3. OpenGL +3.3 is only available if requested at context creation +because compatibility contexts are not supported. +

          + + +

          SHA256 checksums

          +
          +TBD
          +
          + + +

          New features

          +

          None

          + +

          Bug fixes

          + +

          This list is likely incomplete.

          + +
            + +
          • Bug 79202 - valgrind errors in glsl-fs-uniform-array-loop-unroll.shader_test; random code generation
          • + +
          • Bug 84613 - [G965, bisected] piglit regressions : glslparsertest.glsl2
          • + +
          • Bug 86747 - Noise in Football Manager 2014 textures
          • + +
          • Bug 86974 - INTEL_DEBUG=shader_time always asserts in fs_generator::generate_code() when Mesa is built with --enable-debug (= with asserts)
          • + +
          • Bug 88246 - Commit 2881b12 causes 43 DrawElements test regressions
          • + +
          • Bug 88793 - [BDW/BSW Bisected]Piglit/shaders_glsl-max-varyings fails
          • + +
          • Bug 88883 - ir-a2xx.c: variable changed in assert statement
          • + +
          • Bug 88885 - Transform feedback uses incorrect interleaving if a previous draw did not write gl_Position
          • + +
          • Bug 89095 - [SNB/IVB/BYT Bisected]Webglc conformance/glsl/functions/glsl-function-mix-float.html fails
          • + +
          • Bug 89156 - r300g: GL_COMPRESSED_RED_RGTC1 / ATI1N support broken
          • + +
          • Bug 89224 - Incorrect rendering of Unigine Valley running in VM on VMware Workstation
          • + +
          • Bug 89292 - [regression,bisected] incomplete screenshots in some cases
          • + +
          • Bug 89311 - [regression, bisected] dEQP: Added entry points for glCompressedTextureSubImage*D.
          • + +
          • Bug 89312 - [regression, bisected] main: Added entry points for CopyTextureSubImage*D. (d6b7c40cecfe01)
          • + +
          • Bug 89315 - [HSW, regression, bisected] i965/fs: Emit MAD instructions when possible.
          • + +
          • Bug 89317 - [HSW, regression, bisected] i965: Add LINTERP/CINTERP to can_do_cmod() (d91390634)
          • + +
          • Bug 89416 - UE4Editor crash after load project
          • + +
          • Bug 89430 - [g965][bisected] arb_copy_image-targets gl_texture* tests fail
          • + +
          + + +

          Changes

          + +

          Andrey Sudnik (1):

          +
            +
          • i965/vec4: Don't lose the saturate modifier in copy propagation.
          • +
          + +

          Chris Forbes (1):

          +
            +
          • i965/gs: Check newly-generated GS-out VUE map against correct stage
          • +
          + +

          Daniel Stone (1):

          +
            +
          • egl: Take alpha bits into account when selecting GBM formats
          • +
          + +

          Emil Velikov (5):

          +
            +
          • docs: Add sha256 sums for the 10.5.0 release
          • +
          • egl/main: no longer export internal function
          • +
          • cherry-ignore: ignore a few more commits picked without -x
          • +
          • mapi: fix commit 90411b56f6bc817e229d8801ac0adad6d4e3fb7a
          • +
          • Update version to 10.5.1
          • +
          + +

          Frank Henigman (1):

          +
            +
          • intel: fix EGLImage renderbuffer _BaseFormat
          • +
          + +

          Iago Toral Quiroga (1):

          +
            +
          • i965: Fix out-of-bounds accesses into pull_constant_loc array
          • +
          + +

          Ian Romanick (1):

          +
            +
          • i965/fs/nir: Use emit_math for nir_op_fpow
          • +
          + +

          Ilia Mirkin (3):

          +
            +
          • freedreno: move fb state copy after checking for size change
          • +
          • freedreno/ir3: fix array count returned by TXQ
          • +
          • freedreno/ir3: get the # of miplevels from getinfo
          • +
          + +

          Jason Ekstrand (2):

          +
            +
          • meta/TexSubImage: Stash everything other than PIXEL_TRANSFER/store in meta_begin
          • +
          • main/base_tex_format: Properly handle STENCIL_INDEX1/4/16
          • +
          + +

          Kenneth Graunke (8):

          +
            +
          • i965: Split Gen4-5 BlitFramebuffer code; prefer BLT over Meta.
          • +
          • glsl: Mark array access when copying to a temporary for the ?: operator.
          • +
          • i965/fs: Set force_writemask_all on shader_time instructions.
          • +
          • i965/fs: Set smear on shader_time diff register.
          • +
          • i965/fs: Make emit_shader_time_write return rather than emit.
          • +
          • i965/fs: Make get_timestamp() pass back the MOV rather than emitting it.
          • +
          • i965/fs: Make emit_shader_time_end() insert before EOT.
          • +
          • i965/fs: Don't issue FB writes for bound but unwritten color targets.
          • +
          + +

          Laura Ekstrand (2):

          +
            +
          • main: Fix target checking for CompressedTexSubImage*D.
          • +
          • main: Fix target checking for CopyTexSubImage*D.
          • +
          + +

          Marc-Andre Lureau (1):

          +
            +
          • gallium/auxiliary/indices: fix start param
          • +
          + +

          Marek Ol??k (3):

          +
            +
          • r300g: fix RGTC1 and LATC1 SNORM formats
          • +
          • r300g: fix a crash when resolving into an sRGB texture
          • +
          • r300g: fix sRGB->sRGB blits
          • +
          + +

          Matt Turner (12):

          +
            +
          • i965/vec4: Fix implementation of i2b.
          • +
          • mesa: Indent break statements and add a missing one.
          • +
          • mesa: Free memory allocated for luminance in readpixels.
          • +
          • mesa: Correct backwards NULL check.
          • +
          • i965: Consider scratch writes to have side effects.
          • +
          • i965/fs: Don't use backend_visitor::instructions after creating the CFG.
          • +
          • r300g: Use PATH_MAX instead of limiting ourselves to 100 chars.
          • +
          • r300g: Check return value of snprintf().
          • +
          • i965/fs: Don't propagate cmod to inst with different type.
          • +
          • i965: Tell intel_get_memcpy() which direction the memcpy() is going.
          • +
          • Revert SHA1 additions.
          • +
          • i965: Avoid applying negate to wrong MAD source.
          • +
          + +

          Neil Roberts (4):

          +
            +
          • meta: In pbo_{Get,}TexSubImage don't repeatedly rebind the source tex
          • +
          • Revert "common: Fix PBOs for 1D_ARRAY."
          • +
          • meta: Allow GL_UN/PACK_IMAGE_HEIGHT in _mesa_meta_pbo_Get/TexSubImage
          • +
          • meta: Fix the y offset for 1D_ARRAY in _mesa_meta_pbo_TexSubImage
          • +
          + +

          Rob Clark (11):

          +
            +
          • freedreno/ir3: fix silly typo for binning pass shaders
          • +
          • freedreno/a2xx: fix increment in assert
          • +
          • freedreno/a4xx: bit of cleanup
          • +
          • freedreno: update generated headers
          • +
          • freedreno/a4xx: set PC_PRIM_VTX_CNTL.VAROUT properly
          • +
          • freedreno: update generated headers
          • +
          • freedreno/a4xx: aniso filtering
          • +
          • freedreno/ir3: fix up cat6 instruction encodings
          • +
          • freedreno/ir3: add support for memory (cat6) instructions
          • +
          • freedreno/ir3: handle flat bypass for a4xx
          • +
          • freedreno/ir3: fix failed assert in grouping
          • +
          + +

          Stefan D?singer (1):

          +
            +
          • r300g: Fix the ATI1N swizzle (RGTC1 and LATC1)
          • +
          + +
          + + From chrisf at kemper.freedesktop.org Sat Mar 14 02:56:51 2015 From: chrisf at kemper.freedesktop.org (Chris Forbes) Date: Fri, 13 Mar 2015 19:56:51 -0700 (PDT) Subject: Mesa (master): i965/gen4-5: Cope with immutable-format texture revalidation Message-ID: <20150314025651.D020476250@kemper.freedesktop.org> Module: Mesa Branch: master Commit: f68a973dfb8926ac872b0b0e3b4b5c2163389d06 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=f68a973dfb8926ac872b0b0e3b4b5c2163389d06 Author: Chris Forbes Date: Mon Dec 8 20:37:00 2014 +1300 i965/gen4-5: Cope with immutable-format texture revalidation This is unfortunately sometimes necessary due to rebasing levels when rendering into them. 16 piglits crash -> pass, when building mesa with debug enabled. Signed-off-by: Chris Forbes Reviewed-by: Kenneth Graunke --- src/mesa/drivers/dri/i965/intel_tex_validate.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/mesa/drivers/dri/i965/intel_tex_validate.c b/src/mesa/drivers/dri/i965/intel_tex_validate.c index 0bf0393..1d82768 100644 --- a/src/mesa/drivers/dri/i965/intel_tex_validate.c +++ b/src/mesa/drivers/dri/i965/intel_tex_validate.c @@ -98,10 +98,17 @@ intel_finalize_mipmap_tree(struct brw_context *brw, GLuint unit) return true; } - /* Immutable textures should not get this far -- they should have been - * created in a validated state, and nothing can invalidate them. + /* On recent generations, immutable textures should not get this far + * -- they should have been created in a validated state, and nothing + * can invalidate them. + * + * Unfortunately, this is not true on pre-Sandybridge hardware -- when + * rendering into an immutable-format depth texture we may have to rebase + * the rendered levels to meet alignment requirements. + * + * FINISHME: Avoid doing this. */ - assert(!tObj->Immutable); + assert(!tObj->Immutable || brw->gen < 6); firstImage = intel_texture_image(tObj->Image[0][tObj->BaseLevel]); From kwg at kemper.freedesktop.org Sun Mar 15 10:16:49 2015 From: kwg at kemper.freedesktop.org (Kenneth Graunke) Date: Sun, 15 Mar 2015 03:16:49 -0700 (PDT) Subject: Mesa (master): i965: De-duplicate is_expression_commutative() functions. Message-ID: <20150315101649.ADA4A76332@kemper.freedesktop.org> Module: Mesa Branch: master Commit: db095eb43bd02414e71f93e72ff61b463bef0ece URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=db095eb43bd02414e71f93e72ff61b463bef0ece Author: Kenneth Graunke Date: Fri Mar 13 14:34:06 2015 -0700 i965: De-duplicate is_expression_commutative() functions. Create a backend_inst::is_commutative() method to replace two static functions that did the exact same thing. Signed-off-by: Kenneth Graunke Reviewed-by: Topi Pohjolainen --- src/mesa/drivers/dri/i965/brw_fs_cse.cpp | 24 +----------------------- src/mesa/drivers/dri/i965/brw_shader.cpp | 22 ++++++++++++++++++++++ src/mesa/drivers/dri/i965/brw_shader.h | 1 + src/mesa/drivers/dri/i965/brw_vec4_cse.cpp | 24 +----------------------- 4 files changed, 25 insertions(+), 46 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_fs_cse.cpp b/src/mesa/drivers/dri/i965/brw_fs_cse.cpp index ae069bb..ca5b32f 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_cse.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_cse.cpp @@ -109,28 +109,6 @@ is_expression(const fs_inst *const inst) } static bool -is_expression_commutative(const fs_inst *inst) -{ - switch (inst->opcode) { - case BRW_OPCODE_AND: - case BRW_OPCODE_OR: - case BRW_OPCODE_XOR: - case BRW_OPCODE_ADD: - case BRW_OPCODE_MUL: - return true; - case BRW_OPCODE_SEL: - /* MIN and MAX are commutative. */ - if (inst->conditional_mod == BRW_CONDITIONAL_GE || - inst->conditional_mod == BRW_CONDITIONAL_L) { - return true; - } - /* fallthrough */ - default: - return false; - } -} - -static bool operands_match(const fs_inst *a, const fs_inst *b) { fs_reg *xs = a->src; @@ -140,7 +118,7 @@ operands_match(const fs_inst *a, const fs_inst *b) return xs[0].equals(ys[0]) && ((xs[1].equals(ys[1]) && xs[2].equals(ys[2])) || (xs[2].equals(ys[1]) && xs[1].equals(ys[2]))); - } else if (!is_expression_commutative(a)) { + } else if (!a->is_commutative()) { bool match = true; for (int i = 0; i < a->sources; i++) { if (!xs[i].equals(ys[i])) { diff --git a/src/mesa/drivers/dri/i965/brw_shader.cpp b/src/mesa/drivers/dri/i965/brw_shader.cpp index ff0ef4b..51c965c 100644 --- a/src/mesa/drivers/dri/i965/brw_shader.cpp +++ b/src/mesa/drivers/dri/i965/brw_shader.cpp @@ -769,6 +769,28 @@ backend_reg::is_accumulator() const } bool +backend_instruction::is_commutative() const +{ + switch (opcode) { + case BRW_OPCODE_AND: + case BRW_OPCODE_OR: + case BRW_OPCODE_XOR: + case BRW_OPCODE_ADD: + case BRW_OPCODE_MUL: + return true; + case BRW_OPCODE_SEL: + /* MIN and MAX are commutative. */ + if (conditional_mod == BRW_CONDITIONAL_GE || + conditional_mod == BRW_CONDITIONAL_L) { + return true; + } + /* fallthrough */ + default: + return false; + } +} + +bool backend_instruction::is_3src() const { return opcode < ARRAY_SIZE(opcode_descs) && opcode_descs[opcode].nsrc == 3; diff --git a/src/mesa/drivers/dri/i965/brw_shader.h b/src/mesa/drivers/dri/i965/brw_shader.h index 5c95355..f8cc98a 100644 --- a/src/mesa/drivers/dri/i965/brw_shader.h +++ b/src/mesa/drivers/dri/i965/brw_shader.h @@ -94,6 +94,7 @@ struct backend_instruction : public exec_node { bool is_tex() const; bool is_math() const; bool is_control_flow() const; + bool is_commutative() const; bool can_do_source_mods() const; bool can_do_saturate() const; bool can_do_cmod() const; diff --git a/src/mesa/drivers/dri/i965/brw_vec4_cse.cpp b/src/mesa/drivers/dri/i965/brw_vec4_cse.cpp index 5fb8f31..2c29d9f 100644 --- a/src/mesa/drivers/dri/i965/brw_vec4_cse.cpp +++ b/src/mesa/drivers/dri/i965/brw_vec4_cse.cpp @@ -89,28 +89,6 @@ is_expression(const vec4_instruction *const inst) } static bool -is_expression_commutative(const vec4_instruction *inst) -{ - switch (inst->opcode) { - case BRW_OPCODE_AND: - case BRW_OPCODE_OR: - case BRW_OPCODE_XOR: - case BRW_OPCODE_ADD: - case BRW_OPCODE_MUL: - return true; - case BRW_OPCODE_SEL: - /* MIN and MAX are commutative. */ - if (inst->conditional_mod == BRW_CONDITIONAL_GE || - inst->conditional_mod == BRW_CONDITIONAL_L) { - return true; - } - /* fallthrough */ - default: - return false; - } -} - -static bool operands_match(const vec4_instruction *a, const vec4_instruction *b) { const src_reg *xs = a->src; @@ -120,7 +98,7 @@ operands_match(const vec4_instruction *a, const vec4_instruction *b) return xs[0].equals(ys[0]) && ((xs[1].equals(ys[1]) && xs[2].equals(ys[2])) || (xs[2].equals(ys[1]) && xs[1].equals(ys[2]))); - } else if (!is_expression_commutative(a)) { + } else if (!a->is_commutative()) { return xs[0].equals(ys[0]) && xs[1].equals(ys[1]) && xs[2].equals(ys[2]); } else { return (xs[0].equals(ys[0]) && xs[1].equals(ys[1])) || From robclark at kemper.freedesktop.org Sun Mar 15 17:27:38 2015 From: robclark at kemper.freedesktop.org (Rob Clark) Date: Sun, 15 Mar 2015 10:27:38 -0700 (PDT) Subject: Mesa (master): freedreno/ir3: bit of cleanup Message-ID: <20150315172738.1D77976336@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 7208e96bb810a7a6c92fd11bb7f4df8c9b7f1a2d URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=7208e96bb810a7a6c92fd11bb7f4df8c9b7f1a2d Author: Rob Clark Date: Wed Mar 11 12:36:26 2015 -0400 freedreno/ir3: bit of cleanup Add an array_insert() macro to simplify inserting into dynamically sized arrays, add a comment, and remove unused prototype inherited from the original freedreno.git/fdre-a3xx test code, etc. Signed-off-by: Rob Clark --- src/gallium/drivers/freedreno/ir3/ir3.c | 17 +++-------------- src/gallium/drivers/freedreno/ir3/ir3.h | 17 +++++++++++++++-- src/gallium/drivers/freedreno/ir3/ir3_sched.c | 8 +++++--- 3 files changed, 23 insertions(+), 19 deletions(-) diff --git a/src/gallium/drivers/freedreno/ir3/ir3.c b/src/gallium/drivers/freedreno/ir3/ir3.c index 01cdd8a..25d7c7a 100644 --- a/src/gallium/drivers/freedreno/ir3/ir3.c +++ b/src/gallium/drivers/freedreno/ir3/ir3.c @@ -588,21 +588,10 @@ static void insert_instr(struct ir3 *shader, static uint32_t serialno = 0; instr->serialno = ++serialno; #endif - if (shader->instrs_count == shader->instrs_sz) { - shader->instrs_sz = MAX2(2 * shader->instrs_sz, 16); - shader->instrs = realloc(shader->instrs, - shader->instrs_sz * sizeof(shader->instrs[0])); - } - shader->instrs[shader->instrs_count++] = instr; + array_insert(shader->instrs, instr); - if (is_input(instr)) { - if (shader->baryfs_count == shader->baryfs_sz) { - shader->baryfs_sz = MAX2(2 * shader->baryfs_sz, 16); - shader->baryfs = realloc(shader->baryfs, - shader->baryfs_sz * sizeof(shader->baryfs[0])); - } - shader->baryfs[shader->baryfs_count++] = instr; - } + if (is_input(instr)) + array_insert(shader->baryfs, instr); } struct ir3_block * ir3_block_create(struct ir3 *shader, diff --git a/src/gallium/drivers/freedreno/ir3/ir3.h b/src/gallium/drivers/freedreno/ir3/ir3.h index 430bcf2..fa866a2 100644 --- a/src/gallium/drivers/freedreno/ir3/ir3.h +++ b/src/gallium/drivers/freedreno/ir3/ir3.h @@ -38,8 +38,6 @@ struct ir3; struct ir3_instruction; struct ir3_block; -struct ir3 * fd_asm_parse(const char *src); - struct ir3_info { uint16_t sizedwords; uint16_t instrs_count; /* expanded to account for rpt's */ @@ -313,8 +311,16 @@ struct ir3_heap_chunk; struct ir3 { unsigned instrs_count, instrs_sz; struct ir3_instruction **instrs; + + /* Track bary.f (and ldlv) instructions.. this is needed in + * scheduling to ensure that all varying fetches happen before + * any potential kill instructions. The hw gets grumpy if all + * threads in a group are killed before the last bary.f gets + * a chance to signal end of input (ei). + */ unsigned baryfs_count, baryfs_sz; struct ir3_instruction **baryfs; + struct ir3_block *block; unsigned heap_idx; struct ir3_heap_chunk *chunk; @@ -503,6 +509,13 @@ static inline bool reg_gpr(struct ir3_register *r) return true; } +#define array_insert(arr, val) do { \ + if (arr ## _count == arr ## _sz) { \ + arr ## _sz = MAX2(2 * arr ## _sz, 16); \ + arr = realloc(arr, arr ## _sz * sizeof(arr[0])); \ + } \ + arr[arr ##_count++] = val; \ + } while (0) /* iterator for an instructions's sources (reg), also returns src #: */ #define foreach_src_n(__srcreg, __n, __instr) \ diff --git a/src/gallium/drivers/freedreno/ir3/ir3_sched.c b/src/gallium/drivers/freedreno/ir3/ir3_sched.c index 909ecc2..7938c1f 100644 --- a/src/gallium/drivers/freedreno/ir3/ir3_sched.c +++ b/src/gallium/drivers/freedreno/ir3/ir3_sched.c @@ -199,7 +199,8 @@ static unsigned delay_calc(struct ir3_sched_ctx *ctx, } /* A negative return value signals that an instruction has been newly - * scheduled, return back up to the top of the stack (to block_sched()) + * SCHEDULED (or DELAYED due to address or predicate register already + * in use), return back up to the top of the stack (to block_sched()) */ static int trysched(struct ir3_sched_ctx *ctx, struct ir3_instruction *instr) @@ -252,9 +253,10 @@ static int trysched(struct ir3_sched_ctx *ctx, unsigned i; for (i = 0; i < ir->baryfs_count; i++) { - if (ir->baryfs[i]->depth == DEPTH_UNUSED) + struct ir3_instruction *baryf = ir->baryfs[i]; + if (baryf->depth == DEPTH_UNUSED) continue; - delay = trysched(ctx, ir->baryfs[i]); + delay = trysched(ctx, baryf); if (delay) return delay; } From robclark at kemper.freedesktop.org Sun Mar 15 17:27:38 2015 From: robclark at kemper.freedesktop.org (Rob Clark) Date: Sun, 15 Mar 2015 10:27:38 -0700 (PDT) Subject: Mesa (master): freedreno/ir3: avoid scheduler deadlock Message-ID: <20150315172738.298117633A@kemper.freedesktop.org> Module: Mesa Branch: master Commit: feb858b788cf27b31d12ad8a00805f015d4063cc URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=feb858b788cf27b31d12ad8a00805f015d4063cc Author: Rob Clark Date: Wed Mar 11 13:21:42 2015 -0400 freedreno/ir3: avoid scheduler deadlock Deadlock can occur if we schedule an address register write, yet some instructions which depend on that address register value also depend on other unscheduled instructions that depend on a different address register value. To solve this, before scheduling an address register write, ensure that all the other dependencies of the instructions which consume this address register are already scheduled. Signed-off-by: Rob Clark --- src/gallium/drivers/freedreno/ir3/ir3.h | 13 ++++++++++ src/gallium/drivers/freedreno/ir3/ir3_compiler.c | 2 ++ src/gallium/drivers/freedreno/ir3/ir3_sched.c | 30 ++++++++++++++++++++++ 3 files changed, 45 insertions(+) diff --git a/src/gallium/drivers/freedreno/ir3/ir3.h b/src/gallium/drivers/freedreno/ir3/ir3.h index fa866a2..14369ce 100644 --- a/src/gallium/drivers/freedreno/ir3/ir3.h +++ b/src/gallium/drivers/freedreno/ir3/ir3.h @@ -321,6 +321,19 @@ struct ir3 { unsigned baryfs_count, baryfs_sz; struct ir3_instruction **baryfs; + /* Track all indirect instructions (read and write). To avoid + * deadlock scenario where an address register gets scheduled, + * but other dependent src instructions cannot be scheduled due + * to dependency on a *different* address register value, the + * scheduler needs to ensure that all dependencies other than + * the instruction other than the address register are scheduled + * before the one that writes the address register. Having a + * convenient list of instructions that reference some address + * register simplifies this. + */ + unsigned indirects_count, indirects_sz; + struct ir3_instruction **indirects; + struct ir3_block *block; unsigned heap_idx; struct ir3_heap_chunk *chunk; diff --git a/src/gallium/drivers/freedreno/ir3/ir3_compiler.c b/src/gallium/drivers/freedreno/ir3/ir3_compiler.c index 8ffa37c..f6bdc06 100644 --- a/src/gallium/drivers/freedreno/ir3/ir3_compiler.c +++ b/src/gallium/drivers/freedreno/ir3/ir3_compiler.c @@ -771,6 +771,7 @@ add_dst_reg_wrmask(struct ir3_compile_context *ctx, compile_assert(ctx, ctx->block->address == instr->address); instr->address = ctx->block->address; + array_insert(ctx->ir->indirects, instr); } reg = ir3_reg_create(instr, regid(num, chan), flags); @@ -901,6 +902,7 @@ add_src_reg_wrmask(struct ir3_compile_context *ctx, compile_assert(ctx, ctx->block->address == instr->address); instr->address = ctx->block->address; + array_insert(ctx->ir->indirects, instr); } reg = ir3_reg_create(instr, regid(num, chan), flags); diff --git a/src/gallium/drivers/freedreno/ir3/ir3_sched.c b/src/gallium/drivers/freedreno/ir3/ir3_sched.c index 7938c1f..c1921d0 100644 --- a/src/gallium/drivers/freedreno/ir3/ir3_sched.c +++ b/src/gallium/drivers/freedreno/ir3/ir3_sched.c @@ -262,6 +262,36 @@ static int trysched(struct ir3_sched_ctx *ctx, } } + /* if instruction writes address register, we need to ensure + * that the instructions which use the address register value + * have all their other dependencies scheduled. + * TODO we may possibly need to do the same thing with predicate + * register usage, but for now we get by without since the + * predicate usage patterns are more simple + */ + if (writes_addr(instr)) { + struct ir3 *ir = instr->block->shader; + unsigned i; + + for (i = 0; i < ir->indirects_count; i++) { + struct ir3_instruction *indirect = ir->indirects[i]; + if (indirect->depth == DEPTH_UNUSED) + continue; + if (indirect->address != instr) + continue; + /* NOTE: avoid recursively scheduling the dependency + * on ourself (ie. avoid infinite recursion): + */ + foreach_ssa_src(src, indirect) { + if (src == instr) + continue; + delay = trysched(ctx, src); + if (delay) + return delay; + } + } + } + /* if this is a write to address/predicate register, and that * register is currently in use, we need to defer until it is * free: From robclark at kemper.freedesktop.org Sun Mar 15 17:27:38 2015 From: robclark at kemper.freedesktop.org (Rob Clark) Date: Sun, 15 Mar 2015 10:27:38 -0700 (PDT) Subject: Mesa (master): freedreno/ir3: remove old compiler Message-ID: <20150315172738.380C576336@kemper.freedesktop.org> Module: Mesa Branch: master Commit: d3fb949c039b80385d35c11ca86e8e7c5a84ae44 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=d3fb949c039b80385d35c11ca86e8e7c5a84ae44 Author: Rob Clark Date: Wed Mar 11 15:10:25 2015 -0400 freedreno/ir3: remove old compiler Now that piglit is no longer falling back to old compiler for any tests, we can remove it. Hurray \o/ Signed-off-by: Rob Clark --- src/gallium/drivers/freedreno/Makefile.sources | 1 - src/gallium/drivers/freedreno/freedreno_screen.c | 1 - src/gallium/drivers/freedreno/freedreno_util.h | 1 - src/gallium/drivers/freedreno/ir3/ir3_cmdline.c | 22 +- src/gallium/drivers/freedreno/ir3/ir3_compiler.h | 3 - .../drivers/freedreno/ir3/ir3_compiler_old.c | 1539 -------------------- src/gallium/drivers/freedreno/ir3/ir3_shader.c | 17 +- 7 files changed, 10 insertions(+), 1574 deletions(-) diff --git a/src/gallium/drivers/freedreno/Makefile.sources b/src/gallium/drivers/freedreno/Makefile.sources index 592f4b4..1f22ce9 100644 --- a/src/gallium/drivers/freedreno/Makefile.sources +++ b/src/gallium/drivers/freedreno/Makefile.sources @@ -122,7 +122,6 @@ ir3_SOURCES := \ ir3/ir3.c \ ir3/ir3_compiler.c \ ir3/ir3_compiler.h \ - ir3/ir3_compiler_old.c \ ir3/ir3_cp.c \ ir3/ir3_depth.c \ ir3/ir3_dump.c \ diff --git a/src/gallium/drivers/freedreno/freedreno_screen.c b/src/gallium/drivers/freedreno/freedreno_screen.c index 31f596c..a4699e4 100644 --- a/src/gallium/drivers/freedreno/freedreno_screen.c +++ b/src/gallium/drivers/freedreno/freedreno_screen.c @@ -67,7 +67,6 @@ static const struct debug_named_value debug_options[] = { {"nobypass", FD_DBG_NOBYPASS, "Disable GMEM bypass"}, {"fraghalf", FD_DBG_FRAGHALF, "Use half-precision in fragment shader"}, {"nobin", FD_DBG_NOBIN, "Disable hw binning"}, - {"noopt", FD_DBG_NOOPT , "Disable optimization passes in compiler"}, {"optmsgs", FD_DBG_OPTMSGS,"Enable optimizater debug messages"}, {"optdump", FD_DBG_OPTDUMP,"Dump shader DAG to .dot files"}, {"glsl120", FD_DBG_GLSL120,"Temporary flag to force GLSL 120 (rather than 130) on a3xx+"}, diff --git a/src/gallium/drivers/freedreno/freedreno_util.h b/src/gallium/drivers/freedreno/freedreno_util.h index f9c959e..b3076b9 100644 --- a/src/gallium/drivers/freedreno/freedreno_util.h +++ b/src/gallium/drivers/freedreno/freedreno_util.h @@ -62,7 +62,6 @@ enum adreno_stencil_op fd_stencil_op(unsigned op); #define FD_DBG_NOBYPASS 0x0040 #define FD_DBG_FRAGHALF 0x0080 #define FD_DBG_NOBIN 0x0100 -#define FD_DBG_NOOPT 0x0200 #define FD_DBG_OPTMSGS 0x0400 #define FD_DBG_OPTDUMP 0x0800 #define FD_DBG_GLSL120 0x1000 diff --git a/src/gallium/drivers/freedreno/ir3/ir3_cmdline.c b/src/gallium/drivers/freedreno/ir3/ir3_cmdline.c index afad792..bf6bcb8 100644 --- a/src/gallium/drivers/freedreno/ir3/ir3_cmdline.c +++ b/src/gallium/drivers/freedreno/ir3/ir3_cmdline.c @@ -355,27 +355,17 @@ int main(int argc, char **argv) break; } - if (!(fd_mesa_debug & FD_DBG_NOOPT)) { - /* with new compiler: */ - info = "new compiler"; - ret = ir3_compile_shader(&v, toks, key, true); - - if (ret) { - reset_variant(&v, "new compiler failed, trying without copy propagation!"); - info = "new compiler (no copy propagation)"; - ret = ir3_compile_shader(&v, toks, key, false); - if (ret) - reset_variant(&v, "new compiler failed, trying fallback!\n"); - } - } + info = "compiler"; + ret = ir3_compile_shader(&v, toks, key, true); if (ret) { - info = "old compiler"; - ret = ir3_compile_shader_old(&v, toks, key); + reset_variant(&v, "compiler failed, trying without copy propagation!"); + info = "compiler (no copy propagation)"; + ret = ir3_compile_shader(&v, toks, key, false); } if (ret) { - fprintf(stderr, "old compiler failed!\n"); + fprintf(stderr, "compiler failed!\n"); return ret; } dump_info(&v, info); diff --git a/src/gallium/drivers/freedreno/ir3/ir3_compiler.h b/src/gallium/drivers/freedreno/ir3/ir3_compiler.h index 5853297..6459482 100644 --- a/src/gallium/drivers/freedreno/ir3/ir3_compiler.h +++ b/src/gallium/drivers/freedreno/ir3/ir3_compiler.h @@ -35,8 +35,5 @@ int ir3_compile_shader(struct ir3_shader_variant *so, const struct tgsi_token *tokens, struct ir3_shader_key key, bool cp); -int ir3_compile_shader_old(struct ir3_shader_variant *so, - const struct tgsi_token *tokens, - struct ir3_shader_key key); #endif /* FD3_COMPILER_H_ */ diff --git a/src/gallium/drivers/freedreno/ir3/ir3_compiler_old.c b/src/gallium/drivers/freedreno/ir3/ir3_compiler_old.c deleted file mode 100644 index 44a629f..0000000 --- a/src/gallium/drivers/freedreno/ir3/ir3_compiler_old.c +++ /dev/null @@ -1,1539 +0,0 @@ -/* -*- mode: C; c-file-style: "k&r"; tab-width 4; indent-tabs-mode: t; -*- */ - -/* - * Copyright (C) 2013 Rob Clark - * - * 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. - * - * Authors: - * Rob Clark - */ - -#include - -#include "pipe/p_state.h" -#include "util/u_string.h" -#include "util/u_memory.h" -#include "util/u_inlines.h" -#include "tgsi/tgsi_lowering.h" -#include "tgsi/tgsi_parse.h" -#include "tgsi/tgsi_ureg.h" -#include "tgsi/tgsi_info.h" -#include "tgsi/tgsi_strings.h" -#include "tgsi/tgsi_dump.h" -#include "tgsi/tgsi_scan.h" - -#include "freedreno_util.h" - -#include "ir3_compiler.h" -#include "ir3_shader.h" - -#include "instr-a3xx.h" -#include "ir3.h" - - -struct ir3_compile_context { - const struct tgsi_token *tokens; - bool free_tokens; - struct ir3 *ir; - struct ir3_block *block; - struct ir3_shader_variant *so; - - struct tgsi_parse_context parser; - unsigned type; - - struct tgsi_shader_info info; - - /* last input dst (for setting (ei) flag): */ - struct ir3_register *last_input; - - /* last instruction with relative addressing: */ - struct ir3_instruction *last_rel; - - /* for calculating input/output positions/linkages: */ - unsigned next_inloc; - - unsigned num_internal_temps; - struct tgsi_src_register internal_temps[6]; - - /* track registers which need to synchronize w/ "complex alu" cat3 - * instruction pipeline: - */ - regmask_t needs_ss; - - /* track registers which need to synchronize with texture fetch - * pipeline: - */ - regmask_t needs_sy; - - /* inputs start at r0, temporaries start after last input, and - * outputs start after last temporary. - * - * We could be more clever, because this is not a hw restriction, - * but probably best just to implement an optimizing pass to - * reduce the # of registers used and get rid of redundant mov's - * (to output register). - */ - unsigned base_reg[TGSI_FILE_COUNT]; - - /* idx/slot for last compiler generated immediate */ - unsigned immediate_idx; - - /* stack of branch instructions that start (potentially nested) - * branch instructions, so that we can fix up the branch targets - * so that we can fix up the branch target on the corresponding - * END instruction - */ - struct ir3_instruction *branch[16]; - unsigned int branch_count; - - /* used when dst is same as one of the src, to avoid overwriting a - * src element before the remaining scalar instructions that make - * up the vector operation - */ - struct tgsi_dst_register tmp_dst; - struct tgsi_src_register *tmp_src; -}; - - -static void vectorize(struct ir3_compile_context *ctx, - struct ir3_instruction *instr, struct tgsi_dst_register *dst, - int nsrcs, ...); -static void create_mov(struct ir3_compile_context *ctx, - struct tgsi_dst_register *dst, struct tgsi_src_register *src); - -static unsigned -compile_init(struct ir3_compile_context *ctx, struct ir3_shader_variant *so, - const struct tgsi_token *tokens) -{ - unsigned ret, base = 0; - struct tgsi_shader_info *info = &ctx->info; - struct tgsi_lowering_config lconfig = { - .color_two_side = so->key.color_two_side, - .lower_DST = true, - .lower_XPD = true, - .lower_SCS = true, - .lower_LRP = true, - .lower_FRC = true, - .lower_POW = true, - .lower_LIT = true, - .lower_EXP = true, - .lower_LOG = true, - .lower_DP4 = true, - .lower_DP3 = true, - .lower_DPH = true, - .lower_DP2 = true, - .lower_DP2A = true, - }; - - switch (so->type) { - case SHADER_FRAGMENT: - case SHADER_COMPUTE: - lconfig.saturate_s = so->key.fsaturate_s; - lconfig.saturate_t = so->key.fsaturate_t; - lconfig.saturate_r = so->key.fsaturate_r; - break; - case SHADER_VERTEX: - lconfig.saturate_s = so->key.vsaturate_s; - lconfig.saturate_t = so->key.vsaturate_t; - lconfig.saturate_r = so->key.vsaturate_r; - break; - } - - ctx->tokens = tgsi_transform_lowering(&lconfig, tokens, &ctx->info); - ctx->free_tokens = !!ctx->tokens; - if (!ctx->tokens) { - /* no lowering */ - ctx->tokens = tokens; - } - ctx->ir = so->ir; - ctx->block = ir3_block_create(ctx->ir, 0, 0, 0); - ctx->so = so; - ctx->last_input = NULL; - ctx->last_rel = NULL; - ctx->next_inloc = 8; - ctx->num_internal_temps = 0; - ctx->branch_count = 0; - - regmask_init(&ctx->needs_ss); - regmask_init(&ctx->needs_sy); - memset(ctx->base_reg, 0, sizeof(ctx->base_reg)); - - /* Immediates go after constants: */ - ctx->base_reg[TGSI_FILE_CONSTANT] = 0; - ctx->base_reg[TGSI_FILE_IMMEDIATE] = - info->file_max[TGSI_FILE_CONSTANT] + 1; - - /* if full precision and fragment shader, don't clobber - * r0.x w/ bary fetch: - */ - if ((so->type == SHADER_FRAGMENT) && !so->key.half_precision) - base = 1; - - /* Temporaries after outputs after inputs: */ - ctx->base_reg[TGSI_FILE_INPUT] = base; - ctx->base_reg[TGSI_FILE_OUTPUT] = base + - info->file_max[TGSI_FILE_INPUT] + 1; - ctx->base_reg[TGSI_FILE_TEMPORARY] = base + - info->file_max[TGSI_FILE_INPUT] + 1 + - info->file_max[TGSI_FILE_OUTPUT] + 1; - - so->first_driver_param = ~0; - so->first_immediate = ctx->base_reg[TGSI_FILE_IMMEDIATE]; - ctx->immediate_idx = 4 * (ctx->info.file_max[TGSI_FILE_IMMEDIATE] + 1); - - ret = tgsi_parse_init(&ctx->parser, ctx->tokens); - if (ret != TGSI_PARSE_OK) - return ret; - - ctx->type = ctx->parser.FullHeader.Processor.Processor; - - return ret; -} - -static void -compile_error(struct ir3_compile_context *ctx, const char *format, ...) -{ - va_list ap; - va_start(ap, format); - _debug_vprintf(format, ap); - va_end(ap); - tgsi_dump(ctx->tokens, 0); - debug_assert(0); -} - -#define compile_assert(ctx, cond) do { \ - if (!(cond)) compile_error((ctx), "failed assert: "#cond"\n"); \ - } while (0) - -static void -compile_free(struct ir3_compile_context *ctx) -{ - if (ctx->free_tokens) - free((void *)ctx->tokens); - tgsi_parse_free(&ctx->parser); -} - -struct instr_translater { - void (*fxn)(const struct instr_translater *t, - struct ir3_compile_context *ctx, - struct tgsi_full_instruction *inst); - unsigned tgsi_opc; - opc_t opc; - opc_t hopc; /* opc to use for half_precision mode, if different */ - unsigned arg; -}; - -static void -handle_last_rel(struct ir3_compile_context *ctx) -{ - if (ctx->last_rel) { - ctx->last_rel->flags |= IR3_INSTR_UL; - ctx->last_rel = NULL; - } -} - -static struct ir3_instruction * -instr_create(struct ir3_compile_context *ctx, int category, opc_t opc) -{ - return ir3_instr_create(ctx->block, category, opc); -} - -static void -add_nop(struct ir3_compile_context *ctx, unsigned count) -{ - while (count-- > 0) - instr_create(ctx, 0, OPC_NOP); -} - -static unsigned -src_flags(struct ir3_compile_context *ctx, struct ir3_register *reg) -{ - unsigned flags = 0; - - if (reg->flags & (IR3_REG_CONST | IR3_REG_IMMED)) - return flags; - - if (regmask_get(&ctx->needs_ss, reg)) { - flags |= IR3_INSTR_SS; - regmask_init(&ctx->needs_ss); - } - - if (regmask_get(&ctx->needs_sy, reg)) { - flags |= IR3_INSTR_SY; - regmask_init(&ctx->needs_sy); - } - - return flags; -} - -static struct ir3_register * -add_dst_reg(struct ir3_compile_context *ctx, struct ir3_instruction *instr, - const struct tgsi_dst_register *dst, unsigned chan) -{ - unsigned flags = 0, num = 0; - struct ir3_register *reg; - - switch (dst->File) { - case TGSI_FILE_OUTPUT: - case TGSI_FILE_TEMPORARY: - num = dst->Index + ctx->base_reg[dst->File]; - break; - case TGSI_FILE_ADDRESS: - num = REG_A0; - break; - default: - compile_error(ctx, "unsupported dst register file: %s\n", - tgsi_file_name(dst->File)); - break; - } - - if (dst->Indirect) - flags |= IR3_REG_RELATIV; - if (ctx->so->key.half_precision) - flags |= IR3_REG_HALF; - - reg = ir3_reg_create(instr, regid(num, chan), flags); - - if (dst->Indirect) - ctx->last_rel = instr; - - return reg; -} - -static struct ir3_register * -add_src_reg(struct ir3_compile_context *ctx, struct ir3_instruction *instr, - const struct tgsi_src_register *src, unsigned chan) -{ - unsigned flags = 0, num = 0; - struct ir3_register *reg; - - /* TODO we need to use a mov to temp for const >= 64.. or maybe - * we could use relative addressing.. - */ - compile_assert(ctx, src->Index < 64); - - switch (src->File) { - case TGSI_FILE_IMMEDIATE: - /* TODO if possible, use actual immediate instead of const.. but - * TGSI has vec4 immediates, we can only embed scalar (of limited - * size, depending on instruction..) - */ - case TGSI_FILE_CONSTANT: - flags |= IR3_REG_CONST; - num = src->Index + ctx->base_reg[src->File]; - break; - case TGSI_FILE_OUTPUT: - /* NOTE: we should only end up w/ OUTPUT file for things like - * clamp()'ing saturated dst instructions - */ - case TGSI_FILE_INPUT: - case TGSI_FILE_TEMPORARY: - num = src->Index + ctx->base_reg[src->File]; - break; - default: - compile_error(ctx, "unsupported src register file: %s\n", - tgsi_file_name(src->File)); - break; - } - - if (src->Absolute) - flags |= IR3_REG_ABS; - if (src->Negate) - flags |= IR3_REG_NEGATE; - if (src->Indirect) - flags |= IR3_REG_RELATIV; - if (ctx->so->key.half_precision) - flags |= IR3_REG_HALF; - - reg = ir3_reg_create(instr, regid(num, chan), flags); - - if (src->Indirect) - ctx->last_rel = instr; - - instr->flags |= src_flags(ctx, reg); - - return reg; -} - -static void -src_from_dst(struct tgsi_src_register *src, struct tgsi_dst_register *dst) -{ - src->File = dst->File; - src->Indirect = dst->Indirect; - src->Dimension = dst->Dimension; - src->Index = dst->Index; - src->Absolute = 0; - src->Negate = 0; - src->SwizzleX = TGSI_SWIZZLE_X; - src->SwizzleY = TGSI_SWIZZLE_Y; - src->SwizzleZ = TGSI_SWIZZLE_Z; - src->SwizzleW = TGSI_SWIZZLE_W; -} - -/* Get internal-temp src/dst to use for a sequence of instructions - * generated by a single TGSI op. - */ -static struct tgsi_src_register * -get_internal_temp(struct ir3_compile_context *ctx, - struct tgsi_dst_register *tmp_dst) -{ - struct tgsi_src_register *tmp_src; - int n; - - tmp_dst->File = TGSI_FILE_TEMPORARY; - tmp_dst->WriteMask = TGSI_WRITEMASK_XYZW; - tmp_dst->Indirect = 0; - tmp_dst->Dimension = 0; - - /* assign next temporary: */ - n = ctx->num_internal_temps++; - compile_assert(ctx, n < ARRAY_SIZE(ctx->internal_temps)); - tmp_src = &ctx->internal_temps[n]; - - tmp_dst->Index = ctx->info.file_max[TGSI_FILE_TEMPORARY] + n + 1; - - src_from_dst(tmp_src, tmp_dst); - - return tmp_src; -} - -/* Get internal half-precision temp src/dst to use for a sequence of - * instructions generated by a single TGSI op. - */ -static struct tgsi_src_register * -get_internal_temp_hr(struct ir3_compile_context *ctx, - struct tgsi_dst_register *tmp_dst) -{ - struct tgsi_src_register *tmp_src; - int n; - - if (ctx->so->key.half_precision) - return get_internal_temp(ctx, tmp_dst); - - tmp_dst->File = TGSI_FILE_TEMPORARY; - tmp_dst->WriteMask = TGSI_WRITEMASK_XYZW; - tmp_dst->Indirect = 0; - tmp_dst->Dimension = 0; - - /* assign next temporary: */ - n = ctx->num_internal_temps++; - compile_assert(ctx, n < ARRAY_SIZE(ctx->internal_temps)); - tmp_src = &ctx->internal_temps[n]; - - /* just use hr0 because no one else should be using half- - * precision regs: - */ - tmp_dst->Index = 0; - - src_from_dst(tmp_src, tmp_dst); - - return tmp_src; -} - -static inline bool -is_const(struct tgsi_src_register *src) -{ - return (src->File == TGSI_FILE_CONSTANT) || - (src->File == TGSI_FILE_IMMEDIATE); -} - -static inline bool -is_relative(struct tgsi_src_register *src) -{ - return src->Indirect; -} - -static inline bool -is_rel_or_const(struct tgsi_src_register *src) -{ - return is_relative(src) || is_const(src); -} - -static type_t -get_ftype(struct ir3_compile_context *ctx) -{ - return ctx->so->key.half_precision ? TYPE_F16 : TYPE_F32; -} - -static type_t -get_utype(struct ir3_compile_context *ctx) -{ - return ctx->so->key.half_precision ? TYPE_U16 : TYPE_U32; -} - -static unsigned -src_swiz(struct tgsi_src_register *src, int chan) -{ - switch (chan) { - case 0: return src->SwizzleX; - case 1: return src->SwizzleY; - case 2: return src->SwizzleZ; - case 3: return src->SwizzleW; - } - assert(0); - return 0; -} - -/* for instructions that cannot take a const register as src, if needed - * generate a move to temporary gpr: - */ -static struct tgsi_src_register * -get_unconst(struct ir3_compile_context *ctx, struct tgsi_src_register *src) -{ - struct tgsi_dst_register tmp_dst; - struct tgsi_src_register *tmp_src; - - compile_assert(ctx, is_rel_or_const(src)); - - tmp_src = get_internal_temp(ctx, &tmp_dst); - - create_mov(ctx, &tmp_dst, src); - - return tmp_src; -} - -static void -get_immediate(struct ir3_compile_context *ctx, - struct tgsi_src_register *reg, uint32_t val) -{ - unsigned neg, swiz, idx, i; - /* actually maps 1:1 currently.. not sure if that is safe to rely on: */ - static const unsigned swiz2tgsi[] = { - TGSI_SWIZZLE_X, TGSI_SWIZZLE_Y, TGSI_SWIZZLE_Z, TGSI_SWIZZLE_W, - }; - - for (i = 0; i < ctx->immediate_idx; i++) { - swiz = i % 4; - idx = i / 4; - - if (ctx->so->immediates[idx].val[swiz] == val) { - neg = 0; - break; - } - - if (ctx->so->immediates[idx].val[swiz] == -val) { - neg = 1; - break; - } - } - - if (i == ctx->immediate_idx) { - /* need to generate a new immediate: */ - swiz = i % 4; - idx = i / 4; - neg = 0; - ctx->so->immediates[idx].val[swiz] = val; - ctx->so->immediates_count = idx + 1; - ctx->immediate_idx++; - } - - reg->File = TGSI_FILE_IMMEDIATE; - reg->Indirect = 0; - reg->Dimension = 0; - reg->Index = idx; - reg->Absolute = 0; - reg->Negate = neg; - reg->SwizzleX = swiz2tgsi[swiz]; - reg->SwizzleY = swiz2tgsi[swiz]; - reg->SwizzleZ = swiz2tgsi[swiz]; - reg->SwizzleW = swiz2tgsi[swiz]; -} - -static void -create_mov(struct ir3_compile_context *ctx, struct tgsi_dst_register *dst, - struct tgsi_src_register *src) -{ - type_t type_mov = get_ftype(ctx); - unsigned i; - - for (i = 0; i < 4; i++) { - /* move to destination: */ - if (dst->WriteMask & (1 << i)) { - struct ir3_instruction *instr; - - if (src->Absolute || src->Negate) { - /* can't have abs or neg on a mov instr, so use - * absneg.f instead to handle these cases: - */ - instr = instr_create(ctx, 2, OPC_ABSNEG_F); - } else { - instr = instr_create(ctx, 1, 0); - instr->cat1.src_type = type_mov; - instr->cat1.dst_type = type_mov; - } - - add_dst_reg(ctx, instr, dst, i); - add_src_reg(ctx, instr, src, src_swiz(src, i)); - } else { - add_nop(ctx, 1); - } - } -} - -static void -create_clamp(struct ir3_compile_context *ctx, - struct tgsi_dst_register *dst, struct tgsi_src_register *val, - struct tgsi_src_register *minval, struct tgsi_src_register *maxval) -{ - struct ir3_instruction *instr; - - instr = instr_create(ctx, 2, OPC_MAX_F); - vectorize(ctx, instr, dst, 2, val, 0, minval, 0); - - instr = instr_create(ctx, 2, OPC_MIN_F); - vectorize(ctx, instr, dst, 2, val, 0, maxval, 0); -} - -static void -create_clamp_imm(struct ir3_compile_context *ctx, - struct tgsi_dst_register *dst, - uint32_t minval, uint32_t maxval) -{ - struct tgsi_src_register minconst, maxconst; - struct tgsi_src_register src; - - src_from_dst(&src, dst); - - get_immediate(ctx, &minconst, minval); - get_immediate(ctx, &maxconst, maxval); - - create_clamp(ctx, dst, &src, &minconst, &maxconst); -} - -static struct tgsi_dst_register * -get_dst(struct ir3_compile_context *ctx, struct tgsi_full_instruction *inst) -{ - struct tgsi_dst_register *dst = &inst->Dst[0].Register; - unsigned i; - for (i = 0; i < inst->Instruction.NumSrcRegs; i++) { - struct tgsi_src_register *src = &inst->Src[i].Register; - if ((src->File == dst->File) && (src->Index == dst->Index)) { - if ((dst->WriteMask == TGSI_WRITEMASK_XYZW) && - (src->SwizzleX == TGSI_SWIZZLE_X) && - (src->SwizzleY == TGSI_SWIZZLE_Y) && - (src->SwizzleZ == TGSI_SWIZZLE_Z) && - (src->SwizzleW == TGSI_SWIZZLE_W)) - continue; - ctx->tmp_src = get_internal_temp(ctx, &ctx->tmp_dst); - ctx->tmp_dst.WriteMask = dst->WriteMask; - dst = &ctx->tmp_dst; - break; - } - } - return dst; -} - -static void -put_dst(struct ir3_compile_context *ctx, struct tgsi_full_instruction *inst, - struct tgsi_dst_register *dst) -{ - /* if necessary, add mov back into original dst: */ - if (dst != &inst->Dst[0].Register) { - create_mov(ctx, &inst->Dst[0].Register, ctx->tmp_src); - } -} - -/* helper to generate the necessary repeat and/or additional instructions - * to turn a scalar instruction into a vector operation: - */ -static void -vectorize(struct ir3_compile_context *ctx, struct ir3_instruction *instr, - struct tgsi_dst_register *dst, int nsrcs, ...) -{ - va_list ap; - int i, j, n = 0; - bool indirect = dst->Indirect; - - add_dst_reg(ctx, instr, dst, TGSI_SWIZZLE_X); - - va_start(ap, nsrcs); - for (j = 0; j < nsrcs; j++) { - struct tgsi_src_register *src = - va_arg(ap, struct tgsi_src_register *); - unsigned flags = va_arg(ap, unsigned); - struct ir3_register *reg; - if (flags & IR3_REG_IMMED) { - reg = ir3_reg_create(instr, 0, IR3_REG_IMMED); - /* this is an ugly cast.. should have put flags first! */ - reg->iim_val = *(int *)&src; - } else { - reg = add_src_reg(ctx, instr, src, TGSI_SWIZZLE_X); - indirect |= src->Indirect; - } - reg->flags |= flags & ~IR3_REG_NEGATE; - if (flags & IR3_REG_NEGATE) - reg->flags ^= IR3_REG_NEGATE; - } - va_end(ap); - - for (i = 0; i < 4; i++) { - if (dst->WriteMask & (1 << i)) { - struct ir3_instruction *cur; - - if (n++ == 0) { - cur = instr; - } else { - cur = ir3_instr_clone(instr); - cur->flags &= ~(IR3_INSTR_SY | IR3_INSTR_SS | IR3_INSTR_JP); - } - - /* fix-up dst register component: */ - cur->regs[0]->num = regid(cur->regs[0]->num >> 2, i); - - /* fix-up src register component: */ - va_start(ap, nsrcs); - for (j = 0; j < nsrcs; j++) { - struct tgsi_src_register *src = - va_arg(ap, struct tgsi_src_register *); - unsigned flags = va_arg(ap, unsigned); - if (!(flags & IR3_REG_IMMED)) { - cur->regs[j+1]->num = - regid(cur->regs[j+1]->num >> 2, - src_swiz(src, i)); - cur->flags |= src_flags(ctx, cur->regs[j+1]); - } - } - va_end(ap); - - if (indirect) - ctx->last_rel = cur; - } - } - - /* pad w/ nop's.. at least until we are clever enough to - * figure out if we really need to.. - */ - add_nop(ctx, 4 - n); -} - -/* - * Handlers for TGSI instructions which do not have a 1:1 mapping to - * native instructions: - */ - -static void -trans_clamp(const struct instr_translater *t, - struct ir3_compile_context *ctx, - struct tgsi_full_instruction *inst) -{ - struct tgsi_dst_register *dst = get_dst(ctx, inst); - struct tgsi_src_register *src0 = &inst->Src[0].Register; - struct tgsi_src_register *src1 = &inst->Src[1].Register; - struct tgsi_src_register *src2 = &inst->Src[2].Register; - - create_clamp(ctx, dst, src0, src1, src2); - - put_dst(ctx, inst, dst); -} - -/* ARL(x) = x, but mova from hrN.x to a0.. */ -static void -trans_arl(const struct instr_translater *t, - struct ir3_compile_context *ctx, - struct tgsi_full_instruction *inst) -{ - struct ir3_instruction *instr; - struct tgsi_dst_register tmp_dst; - struct tgsi_src_register *tmp_src; - struct tgsi_dst_register *dst = &inst->Dst[0].Register; - struct tgsi_src_register *src = &inst->Src[0].Register; - unsigned chan = src->SwizzleX; - compile_assert(ctx, dst->File == TGSI_FILE_ADDRESS); - - handle_last_rel(ctx); - - tmp_src = get_internal_temp_hr(ctx, &tmp_dst); - - /* cov.{f32,f16}s16 Rtmp, Rsrc */ - instr = instr_create(ctx, 1, 0); - instr->cat1.src_type = get_ftype(ctx); - instr->cat1.dst_type = TYPE_S16; - add_dst_reg(ctx, instr, &tmp_dst, chan)->flags |= IR3_REG_HALF; - add_src_reg(ctx, instr, src, chan); - - add_nop(ctx, 3); - - /* shl.b Rtmp, Rtmp, 2 */ - instr = instr_create(ctx, 2, OPC_SHL_B); - add_dst_reg(ctx, instr, &tmp_dst, chan)->flags |= IR3_REG_HALF; - add_src_reg(ctx, instr, tmp_src, chan)->flags |= IR3_REG_HALF; - ir3_reg_create(instr, 0, IR3_REG_IMMED)->iim_val = 2; - - add_nop(ctx, 3); - - /* mova a0, Rtmp */ - instr = instr_create(ctx, 1, 0); - instr->cat1.src_type = TYPE_S16; - instr->cat1.dst_type = TYPE_S16; - add_dst_reg(ctx, instr, dst, 0)->flags |= IR3_REG_HALF; - add_src_reg(ctx, instr, tmp_src, chan)->flags |= IR3_REG_HALF; - - /* need to ensure 5 instr slots before a0 is used: */ - add_nop(ctx, 6); -} - -/* texture fetch/sample instructions: */ -static void -trans_samp(const struct instr_translater *t, - struct ir3_compile_context *ctx, - struct tgsi_full_instruction *inst) -{ - struct ir3_register *r; - struct ir3_instruction *instr; - struct tgsi_src_register *coord = &inst->Src[0].Register; - struct tgsi_src_register *samp = &inst->Src[1].Register; - unsigned tex = inst->Texture.Texture; - int8_t *order; - unsigned i, flags = 0, src_wrmask; - bool needs_mov = false; - - switch (t->arg) { - case TGSI_OPCODE_TEX: - if (tex == TGSI_TEXTURE_2D) { - order = (int8_t[4]){ 0, 1, -1, -1 }; - src_wrmask = TGSI_WRITEMASK_XY; - } else { - order = (int8_t[4]){ 0, 1, 2, -1 }; - src_wrmask = TGSI_WRITEMASK_XYZ; - } - break; - case TGSI_OPCODE_TXP: - if (tex == TGSI_TEXTURE_2D) { - order = (int8_t[4]){ 0, 1, 3, -1 }; - src_wrmask = TGSI_WRITEMASK_XYZ; - } else { - order = (int8_t[4]){ 0, 1, 2, 3 }; - src_wrmask = TGSI_WRITEMASK_XYZW; - } - flags |= IR3_INSTR_P; - break; - default: - compile_assert(ctx, 0); - break; - } - - if ((tex == TGSI_TEXTURE_3D) || (tex == TGSI_TEXTURE_CUBE)) { - add_nop(ctx, 3); - flags |= IR3_INSTR_3D; - } - - /* cat5 instruction cannot seem to handle const or relative: */ - if (is_rel_or_const(coord)) - needs_mov = true; - - /* The texture sample instructions need to coord in successive - * registers/components (ie. src.xy but not src.yx). And TXP - * needs the .w component in .z for 2D.. so in some cases we - * might need to emit some mov instructions to shuffle things - * around: - */ - for (i = 1; (i < 4) && (order[i] >= 0) && !needs_mov; i++) - if (src_swiz(coord, i) != (src_swiz(coord, 0) + order[i])) - needs_mov = true; - - if (needs_mov) { - struct tgsi_dst_register tmp_dst; - struct tgsi_src_register *tmp_src; - unsigned j; - - type_t type_mov = get_ftype(ctx); - - /* need to move things around: */ - tmp_src = get_internal_temp(ctx, &tmp_dst); - - for (j = 0; (j < 4) && (order[j] >= 0); j++) { - instr = instr_create(ctx, 1, 0); - instr->cat1.src_type = type_mov; - instr->cat1.dst_type = type_mov; - add_dst_reg(ctx, instr, &tmp_dst, j); - add_src_reg(ctx, instr, coord, - src_swiz(coord, order[j])); - } - - coord = tmp_src; - - add_nop(ctx, 4 - j); - } - - instr = instr_create(ctx, 5, t->opc); - instr->cat5.type = get_ftype(ctx); - instr->cat5.samp = samp->Index; - instr->cat5.tex = samp->Index; - instr->flags |= flags; - - r = add_dst_reg(ctx, instr, &inst->Dst[0].Register, 0); - r->wrmask = inst->Dst[0].Register.WriteMask; - - add_src_reg(ctx, instr, coord, coord->SwizzleX)->wrmask = src_wrmask; - - /* after add_src_reg() so we don't set (sy) on sam instr itself! */ - regmask_set(&ctx->needs_sy, r); -} - -/* - * SEQ(a,b) = (a == b) ? 1.0 : 0.0 - * cmps.f.eq tmp0, b, a - * cov.u16f16 dst, tmp0 - * - * SNE(a,b) = (a != b) ? 1.0 : 0.0 - * cmps.f.eq tmp0, b, a - * add.s tmp0, tmp0, -1 - * sel.f16 dst, {0.0}, tmp0, {1.0} - * - * SGE(a,b) = (a >= b) ? 1.0 : 0.0 - * cmps.f.ge tmp0, a, b - * cov.u16f16 dst, tmp0 - * - * SLE(a,b) = (a <= b) ? 1.0 : 0.0 - * cmps.f.ge tmp0, b, a - * cov.u16f16 dst, tmp0 - * - * SGT(a,b) = (a > b) ? 1.0 : 0.0 - * cmps.f.ge tmp0, b, a - * add.s tmp0, tmp0, -1 - * sel.f16 dst, {0.0}, tmp0, {1.0} - * - * SLT(a,b) = (a < b) ? 1.0 : 0.0 - * cmps.f.ge tmp0, a, b - * add.s tmp0, tmp0, -1 - * sel.f16 dst, {0.0}, tmp0, {1.0} - * - * CMP(a,b,c) = (a < 0.0) ? b : c - * cmps.f.ge tmp0, a, {0.0} - * add.s tmp0, tmp0, -1 - * sel.f16 dst, c, tmp0, b - */ -static void -trans_cmp(const struct instr_translater *t, - struct ir3_compile_context *ctx, - struct tgsi_full_instruction *inst) -{ - struct ir3_instruction *instr; - struct tgsi_dst_register tmp_dst; - struct tgsi_src_register *tmp_src; - struct tgsi_src_register constval0, constval1; - /* final instruction for CMP() uses orig src1 and src2: */ - struct tgsi_dst_register *dst = get_dst(ctx, inst); - struct tgsi_src_register *a0, *a1; - unsigned condition; - - tmp_src = get_internal_temp(ctx, &tmp_dst); - - switch (t->tgsi_opc) { - case TGSI_OPCODE_SEQ: - case TGSI_OPCODE_SNE: - a0 = &inst->Src[1].Register; /* b */ - a1 = &inst->Src[0].Register; /* a */ - condition = IR3_COND_EQ; - break; - case TGSI_OPCODE_SGE: - case TGSI_OPCODE_SLT: - a0 = &inst->Src[0].Register; /* a */ - a1 = &inst->Src[1].Register; /* b */ - condition = IR3_COND_GE; - break; - case TGSI_OPCODE_SLE: - case TGSI_OPCODE_SGT: - a0 = &inst->Src[1].Register; /* b */ - a1 = &inst->Src[0].Register; /* a */ - condition = IR3_COND_GE; - break; - case TGSI_OPCODE_CMP: - get_immediate(ctx, &constval0, fui(0.0)); - a0 = &inst->Src[0].Register; /* a */ - a1 = &constval0; /* {0.0} */ - condition = IR3_COND_GE; - break; - default: - compile_assert(ctx, 0); - return; - } - - if (is_const(a0) && is_const(a1)) - a0 = get_unconst(ctx, a0); - - /* cmps.f.ge tmp, a0, a1 */ - instr = instr_create(ctx, 2, OPC_CMPS_F); - instr->cat2.condition = condition; - vectorize(ctx, instr, &tmp_dst, 2, a0, 0, a1, 0); - - switch (t->tgsi_opc) { - case TGSI_OPCODE_SEQ: - case TGSI_OPCODE_SGE: - case TGSI_OPCODE_SLE: - /* cov.u16f16 dst, tmp0 */ - instr = instr_create(ctx, 1, 0); - instr->cat1.src_type = get_utype(ctx); - instr->cat1.dst_type = get_ftype(ctx); - vectorize(ctx, instr, dst, 1, tmp_src, 0); - break; - case TGSI_OPCODE_SNE: - case TGSI_OPCODE_SGT: - case TGSI_OPCODE_SLT: - case TGSI_OPCODE_CMP: - /* add.s tmp, tmp, -1 */ - instr = instr_create(ctx, 2, OPC_ADD_S); - vectorize(ctx, instr, &tmp_dst, 2, tmp_src, 0, -1, IR3_REG_IMMED); - - if (t->tgsi_opc == TGSI_OPCODE_CMP) { - /* sel.{f32,f16} dst, src2, tmp, src1 */ - instr = instr_create(ctx, 3, - ctx->so->key.half_precision ? OPC_SEL_F16 : OPC_SEL_F32); - vectorize(ctx, instr, dst, 3, - &inst->Src[2].Register, 0, - tmp_src, 0, - &inst->Src[1].Register, 0); - } else { - get_immediate(ctx, &constval0, fui(0.0)); - get_immediate(ctx, &constval1, fui(1.0)); - /* sel.{f32,f16} dst, {0.0}, tmp0, {1.0} */ - instr = instr_create(ctx, 3, - ctx->so->key.half_precision ? OPC_SEL_F16 : OPC_SEL_F32); - vectorize(ctx, instr, dst, 3, - &constval0, 0, tmp_src, 0, &constval1, 0); - } - - break; - } - - put_dst(ctx, inst, dst); -} - -/* - * Conditional / Flow control - */ - -static unsigned -find_instruction(struct ir3_compile_context *ctx, struct ir3_instruction *instr) -{ - unsigned i; - for (i = 0; i < ctx->ir->instrs_count; i++) - if (ctx->ir->instrs[i] == instr) - return i; - return ~0; -} - -static void -push_branch(struct ir3_compile_context *ctx, struct ir3_instruction *instr) -{ - ctx->branch[ctx->branch_count++] = instr; -} - -static void -pop_branch(struct ir3_compile_context *ctx) -{ - struct ir3_instruction *instr; - - /* if we were clever enough, we'd patch this up after the fact, - * and set (jp) flag on whatever the next instruction was, rather - * than inserting an extra nop.. - */ - instr = instr_create(ctx, 0, OPC_NOP); - instr->flags |= IR3_INSTR_JP; - - /* pop the branch instruction from the stack and fix up branch target: */ - instr = ctx->branch[--ctx->branch_count]; - instr->cat0.immed = ctx->ir->instrs_count - find_instruction(ctx, instr) - 1; -} - -/* We probably don't really want to translate if/else/endif into branches.. - * the blob driver evaluates both legs of the if and then uses the sel - * instruction to pick which sides of the branch to "keep".. but figuring - * that out will take somewhat more compiler smarts. So hopefully branches - * don't kill performance too badly. - */ -static void -trans_if(const struct instr_translater *t, - struct ir3_compile_context *ctx, - struct tgsi_full_instruction *inst) -{ - struct ir3_instruction *instr; - struct tgsi_src_register *src = &inst->Src[0].Register; - struct tgsi_src_register constval; - - get_immediate(ctx, &constval, fui(0.0)); - - if (is_const(src)) - src = get_unconst(ctx, src); - - instr = instr_create(ctx, 2, OPC_CMPS_F); - ir3_reg_create(instr, regid(REG_P0, 0), 0); - add_src_reg(ctx, instr, src, src->SwizzleX); - add_src_reg(ctx, instr, &constval, constval.SwizzleX); - instr->cat2.condition = IR3_COND_EQ; - - instr = instr_create(ctx, 0, OPC_BR); - push_branch(ctx, instr); -} - -static void -trans_else(const struct instr_translater *t, - struct ir3_compile_context *ctx, - struct tgsi_full_instruction *inst) -{ - struct ir3_instruction *instr; - - /* for first half of if/else/endif, generate a jump past the else: */ - instr = instr_create(ctx, 0, OPC_JUMP); - - pop_branch(ctx); - push_branch(ctx, instr); -} - -static void -trans_endif(const struct instr_translater *t, - struct ir3_compile_context *ctx, - struct tgsi_full_instruction *inst) -{ - pop_branch(ctx); -} - -/* - * Handlers for TGSI instructions which do have 1:1 mapping to native - * instructions: - */ - -static void -instr_cat0(const struct instr_translater *t, - struct ir3_compile_context *ctx, - struct tgsi_full_instruction *inst) -{ - instr_create(ctx, 0, t->opc); -} - -static void -instr_cat1(const struct instr_translater *t, - struct ir3_compile_context *ctx, - struct tgsi_full_instruction *inst) -{ - struct tgsi_dst_register *dst = get_dst(ctx, inst); - struct tgsi_src_register *src = &inst->Src[0].Register; - - /* mov instructions can't handle a negate on src: */ - if (src->Negate) { - struct tgsi_src_register constval; - struct ir3_instruction *instr; - - /* since right now, we are using uniformly either TYPE_F16 or - * TYPE_F32, and we don't utilize the conversion possibilities - * of mov instructions, we can get away with substituting an - * add.f which can handle negate. Might need to revisit this - * in the future if we start supporting widening/narrowing or - * conversion to/from integer.. - */ - instr = instr_create(ctx, 2, OPC_ADD_F); - get_immediate(ctx, &constval, fui(0.0)); - vectorize(ctx, instr, dst, 2, src, 0, &constval, 0); - } else { - create_mov(ctx, dst, src); - /* create_mov() generates vector sequence, so no vectorize() */ - } - put_dst(ctx, inst, dst); -} - -static void -instr_cat2(const struct instr_translater *t, - struct ir3_compile_context *ctx, - struct tgsi_full_instruction *inst) -{ - struct tgsi_dst_register *dst = get_dst(ctx, inst); - struct tgsi_src_register *src0 = &inst->Src[0].Register; - struct tgsi_src_register *src1 = &inst->Src[1].Register; - struct ir3_instruction *instr; - unsigned src0_flags = 0, src1_flags = 0; - - switch (t->tgsi_opc) { - case TGSI_OPCODE_ABS: - src0_flags = IR3_REG_ABS; - break; - case TGSI_OPCODE_SUB: - src1_flags = IR3_REG_NEGATE; - break; - } - - switch (t->opc) { - case OPC_ABSNEG_F: - case OPC_ABSNEG_S: - case OPC_CLZ_B: - case OPC_CLZ_S: - case OPC_SIGN_F: - case OPC_FLOOR_F: - case OPC_CEIL_F: - case OPC_RNDNE_F: - case OPC_RNDAZ_F: - case OPC_TRUNC_F: - case OPC_NOT_B: - case OPC_BFREV_B: - case OPC_SETRM: - case OPC_CBITS_B: - /* these only have one src reg */ - instr = instr_create(ctx, 2, t->opc); - vectorize(ctx, instr, dst, 1, src0, src0_flags); - break; - default: - if (is_const(src0) && is_const(src1)) - src0 = get_unconst(ctx, src0); - - instr = instr_create(ctx, 2, t->opc); - vectorize(ctx, instr, dst, 2, src0, src0_flags, - src1, src1_flags); - break; - } - - put_dst(ctx, inst, dst); -} - -static void -instr_cat3(const struct instr_translater *t, - struct ir3_compile_context *ctx, - struct tgsi_full_instruction *inst) -{ - struct tgsi_dst_register *dst = get_dst(ctx, inst); - struct tgsi_src_register *src0 = &inst->Src[0].Register; - struct tgsi_src_register *src1 = &inst->Src[1].Register; - struct ir3_instruction *instr; - - /* in particular, can't handle const for src1 for cat3.. - * for mad, we can swap first two src's if needed: - */ - if (is_rel_or_const(src1)) { - if (is_mad(t->opc) && !is_rel_or_const(src0)) { - struct tgsi_src_register *tmp; - tmp = src0; - src0 = src1; - src1 = tmp; - } else { - src1 = get_unconst(ctx, src1); - } - } - - instr = instr_create(ctx, 3, - ctx->so->key.half_precision ? t->hopc : t->opc); - vectorize(ctx, instr, dst, 3, src0, 0, src1, 0, - &inst->Src[2].Register, 0); - put_dst(ctx, inst, dst); -} - -static void -instr_cat4(const struct instr_translater *t, - struct ir3_compile_context *ctx, - struct tgsi_full_instruction *inst) -{ - struct tgsi_dst_register *dst = get_dst(ctx, inst); - struct tgsi_src_register *src = &inst->Src[0].Register; - struct ir3_instruction *instr; - unsigned i, n; - - /* seems like blob compiler avoids const as src.. */ - if (is_const(src)) - src = get_unconst(ctx, src); - - /* worst case: */ - add_nop(ctx, 6); - - /* we need to replicate into each component: */ - for (i = 0, n = 0; i < 4; i++) { - if (dst->WriteMask & (1 << i)) { - if (n++) - add_nop(ctx, 1); - instr = instr_create(ctx, 4, t->opc); - add_dst_reg(ctx, instr, dst, i); - add_src_reg(ctx, instr, src, src->SwizzleX); - } - } - - regmask_set(&ctx->needs_ss, instr->regs[0]); - put_dst(ctx, inst, dst); -} - -static const struct instr_translater translaters[TGSI_OPCODE_LAST] = { -#define INSTR(n, f, ...) \ - [TGSI_OPCODE_ ## n] = { .fxn = (f), .tgsi_opc = TGSI_OPCODE_ ## n, ##__VA_ARGS__ } - - INSTR(MOV, instr_cat1), - INSTR(RCP, instr_cat4, .opc = OPC_RCP), - INSTR(RSQ, instr_cat4, .opc = OPC_RSQ), - INSTR(SQRT, instr_cat4, .opc = OPC_SQRT), - INSTR(MUL, instr_cat2, .opc = OPC_MUL_F), - INSTR(ADD, instr_cat2, .opc = OPC_ADD_F), - INSTR(SUB, instr_cat2, .opc = OPC_ADD_F), - INSTR(MIN, instr_cat2, .opc = OPC_MIN_F), - INSTR(MAX, instr_cat2, .opc = OPC_MAX_F), - INSTR(MAD, instr_cat3, .opc = OPC_MAD_F32, .hopc = OPC_MAD_F16), - INSTR(TRUNC, instr_cat2, .opc = OPC_TRUNC_F), - INSTR(CLAMP, trans_clamp), - INSTR(FLR, instr_cat2, .opc = OPC_FLOOR_F), - INSTR(ROUND, instr_cat2, .opc = OPC_RNDNE_F), - INSTR(SSG, instr_cat2, .opc = OPC_SIGN_F), - INSTR(ARL, trans_arl), - INSTR(EX2, instr_cat4, .opc = OPC_EXP2), - INSTR(LG2, instr_cat4, .opc = OPC_LOG2), - INSTR(ABS, instr_cat2, .opc = OPC_ABSNEG_F), - INSTR(COS, instr_cat4, .opc = OPC_COS), - INSTR(SIN, instr_cat4, .opc = OPC_SIN), - INSTR(TEX, trans_samp, .opc = OPC_SAM, .arg = TGSI_OPCODE_TEX), - INSTR(TXP, trans_samp, .opc = OPC_SAM, .arg = TGSI_OPCODE_TXP), - INSTR(SGT, trans_cmp), - INSTR(SLT, trans_cmp), - INSTR(SGE, trans_cmp), - INSTR(SLE, trans_cmp), - INSTR(SNE, trans_cmp), - INSTR(SEQ, trans_cmp), - INSTR(CMP, trans_cmp), - INSTR(IF, trans_if), - INSTR(ELSE, trans_else), - INSTR(ENDIF, trans_endif), - INSTR(END, instr_cat0, .opc = OPC_END), - INSTR(KILL, instr_cat0, .opc = OPC_KILL), -}; - -static ir3_semantic -decl_semantic(const struct tgsi_declaration_semantic *sem) -{ - return ir3_semantic_name(sem->Name, sem->Index); -} - -static int -decl_in(struct ir3_compile_context *ctx, struct tgsi_full_declaration *decl) -{ - struct ir3_shader_variant *so = ctx->so; - unsigned base = ctx->base_reg[TGSI_FILE_INPUT]; - unsigned i, flags = 0; - int nop = 0; - - /* I don't think we should get frag shader input without - * semantic info? Otherwise how do inputs get linked to - * vert outputs? - */ - compile_assert(ctx, (ctx->type == TGSI_PROCESSOR_VERTEX) || - decl->Declaration.Semantic); - - if (ctx->so->key.half_precision) - flags |= IR3_REG_HALF; - - for (i = decl->Range.First; i <= decl->Range.Last; i++) { - unsigned n = so->inputs_count++; - unsigned r = regid(i + base, 0); - unsigned ncomp; - - /* TODO use ctx->info.input_usage_mask[decl->Range.n] to figure out ncomp: */ - ncomp = 4; - - DBG("decl in -> r%d", i + base); // XXX - - compile_assert(ctx, n < ARRAY_SIZE(so->inputs)); - - so->inputs[n].semantic = decl_semantic(&decl->Semantic); - so->inputs[n].compmask = (1 << ncomp) - 1; - so->inputs[n].ncomp = ncomp; - so->inputs[n].regid = r; - so->inputs[n].inloc = ctx->next_inloc; - so->inputs[n].bary = true; /* all that is supported */ - ctx->next_inloc += ncomp; - - so->total_in += ncomp; - - /* for frag shaders, we need to generate the corresponding bary instr: */ - if (ctx->type == TGSI_PROCESSOR_FRAGMENT) { - unsigned j; - - for (j = 0; j < ncomp; j++) { - struct ir3_instruction *instr; - struct ir3_register *dst; - - instr = instr_create(ctx, 2, OPC_BARY_F); - - /* dst register: */ - dst = ir3_reg_create(instr, r + j, flags); - ctx->last_input = dst; - - /* input position: */ - ir3_reg_create(instr, 0, IR3_REG_IMMED)->iim_val = - so->inputs[n].inloc + j - 8; - - /* input base (always r0.xy): */ - ir3_reg_create(instr, regid(0,0), 0)->wrmask = 0x3; - } - - nop = 6; - } - } - - return nop; -} - -static void -decl_out(struct ir3_compile_context *ctx, struct tgsi_full_declaration *decl) -{ - struct ir3_shader_variant *so = ctx->so; - unsigned base = ctx->base_reg[TGSI_FILE_OUTPUT]; - unsigned comp = 0; - unsigned name = decl->Semantic.Name; - unsigned i; - - compile_assert(ctx, decl->Declaration.Semantic); // TODO is this ever not true? - - DBG("decl out[%d] -> r%d", name, decl->Range.First + base); // XXX - - if (ctx->type == TGSI_PROCESSOR_VERTEX) { - switch (name) { - case TGSI_SEMANTIC_POSITION: - so->writes_pos = true; - break; - case TGSI_SEMANTIC_PSIZE: - so->writes_psize = true; - break; - case TGSI_SEMANTIC_COLOR: - case TGSI_SEMANTIC_BCOLOR: - case TGSI_SEMANTIC_GENERIC: - case TGSI_SEMANTIC_FOG: - case TGSI_SEMANTIC_TEXCOORD: - break; - default: - compile_error(ctx, "unknown VS semantic name: %s\n", - tgsi_semantic_names[name]); - } - } else { - switch (name) { - case TGSI_SEMANTIC_POSITION: - comp = 2; /* tgsi will write to .z component */ - so->writes_pos = true; - break; - case TGSI_SEMANTIC_COLOR: - break; - default: - compile_error(ctx, "unknown FS semantic name: %s\n", - tgsi_semantic_names[name]); - } - } - - for (i = decl->Range.First; i <= decl->Range.Last; i++) { - unsigned n = so->outputs_count++; - compile_assert(ctx, n < ARRAY_SIZE(so->outputs)); - so->outputs[n].semantic = decl_semantic(&decl->Semantic); - so->outputs[n].regid = regid(i + base, comp); - } -} - -static void -decl_samp(struct ir3_compile_context *ctx, struct tgsi_full_declaration *decl) -{ - ctx->so->has_samp = true; -} - -static void -compile_instructions(struct ir3_compile_context *ctx) -{ - struct ir3 *ir = ctx->ir; - int nop = 0; - - while (!tgsi_parse_end_of_tokens(&ctx->parser)) { - tgsi_parse_token(&ctx->parser); - - switch (ctx->parser.FullToken.Token.Type) { - case TGSI_TOKEN_TYPE_DECLARATION: { - struct tgsi_full_declaration *decl = - &ctx->parser.FullToken.FullDeclaration; - if (decl->Declaration.File == TGSI_FILE_OUTPUT) { - decl_out(ctx, decl); - } else if (decl->Declaration.File == TGSI_FILE_INPUT) { - nop = decl_in(ctx, decl); - } else if (decl->Declaration.File == TGSI_FILE_SAMPLER) { - decl_samp(ctx, decl); - } - break; - } - case TGSI_TOKEN_TYPE_IMMEDIATE: { - /* TODO: if we know the immediate is small enough, and only - * used with instructions that can embed an immediate, we - * can skip this: - */ - struct tgsi_full_immediate *imm = - &ctx->parser.FullToken.FullImmediate; - unsigned n = ctx->so->immediates_count++; - memcpy(ctx->so->immediates[n].val, imm->u, 16); - break; - } - case TGSI_TOKEN_TYPE_INSTRUCTION: { - struct tgsi_full_instruction *inst = - &ctx->parser.FullToken.FullInstruction; - unsigned opc = inst->Instruction.Opcode; - const struct instr_translater *t = &translaters[opc]; - - add_nop(ctx, nop); - nop = 0; - - if (t->fxn) { - t->fxn(t, ctx, inst); - ctx->num_internal_temps = 0; - } else { - compile_error(ctx, "unknown TGSI opc: %s\n", - tgsi_get_opcode_name(opc)); - } - - switch (inst->Instruction.Saturate) { - case TGSI_SAT_ZERO_ONE: - create_clamp_imm(ctx, &inst->Dst[0].Register, - fui(0.0), fui(1.0)); - break; - case TGSI_SAT_MINUS_PLUS_ONE: - create_clamp_imm(ctx, &inst->Dst[0].Register, - fui(-1.0), fui(1.0)); - break; - } - - break; - } - default: - break; - } - } - - if (ir->instrs_count > 0) - ir->instrs[0]->flags |= IR3_INSTR_SS | IR3_INSTR_SY; - - if (ctx->last_input) - ctx->last_input->flags |= IR3_REG_EI; - - handle_last_rel(ctx); -} - -int -ir3_compile_shader_old(struct ir3_shader_variant *so, - const struct tgsi_token *tokens, struct ir3_shader_key key) -{ - struct ir3_compile_context ctx; - - assert(!so->ir); - - so->ir = ir3_create(); - - assert(so->ir); - - if (compile_init(&ctx, so, tokens) != TGSI_PARSE_OK) - return -1; - - compile_instructions(&ctx); - - compile_free(&ctx); - - return 0; -} diff --git a/src/gallium/drivers/freedreno/ir3/ir3_shader.c b/src/gallium/drivers/freedreno/ir3/ir3_shader.c index 7e7ae36..122a447 100644 --- a/src/gallium/drivers/freedreno/ir3/ir3_shader.c +++ b/src/gallium/drivers/freedreno/ir3/ir3_shader.c @@ -177,21 +177,12 @@ create_variant(struct ir3_shader *shader, struct ir3_shader_key key) tgsi_dump(tokens, 0); } - if (!(fd_mesa_debug & FD_DBG_NOOPT)) { - ret = ir3_compile_shader(v, tokens, key, true); - if (ret) { - reset_variant(v, "new compiler failed, trying without copy propagation!"); - ret = ir3_compile_shader(v, tokens, key, false); - if (ret) - reset_variant(v, "new compiler failed, trying fallback!"); - } - } else { - ret = -1; /* force fallback to old compiler */ + ret = ir3_compile_shader(v, tokens, key, true); + if (ret) { + reset_variant(v, "new compiler failed, trying without copy propagation!"); + ret = ir3_compile_shader(v, tokens, key, false); } - if (ret) - ret = ir3_compile_shader_old(v, tokens, key); - if (ret) { debug_error("compile failed!"); goto fail; From robclark at kemper.freedesktop.org Sun Mar 15 22:01:01 2015 From: robclark at kemper.freedesktop.org (Rob Clark) Date: Sun, 15 Mar 2015 15:01:01 -0700 (PDT) Subject: Mesa (master): freedreno: update generated headers Message-ID: <20150315220101.D570076336@kemper.freedesktop.org> Module: Mesa Branch: master Commit: e92bc6b38e90339a394e95a562bcce35c3ee9696 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=e92bc6b38e90339a394e95a562bcce35c3ee9696 Author: Rob Clark Date: Sun Mar 15 17:59:01 2015 -0400 freedreno: update generated headers Fix a3xx texture layer-size. Signed-off-by: Rob Clark Cc: "10.4 10.5" --- src/gallium/drivers/freedreno/a2xx/a2xx.xml.h | 2 +- src/gallium/drivers/freedreno/a3xx/a3xx.xml.h | 4 ++-- src/gallium/drivers/freedreno/a4xx/a4xx.xml.h | 2 +- src/gallium/drivers/freedreno/adreno_common.xml.h | 2 +- src/gallium/drivers/freedreno/adreno_pm4.xml.h | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/gallium/drivers/freedreno/a2xx/a2xx.xml.h b/src/gallium/drivers/freedreno/a2xx/a2xx.xml.h index de415ab..3811bc5 100644 --- a/src/gallium/drivers/freedreno/a2xx/a2xx.xml.h +++ b/src/gallium/drivers/freedreno/a2xx/a2xx.xml.h @@ -13,7 +13,7 @@ The rules-ng-ng source files this header was generated from are: - /home/robclark/src/freedreno/envytools/rnndb/adreno/a2xx.xml ( 32901 bytes, from 2014-06-02 15:21:30) - /home/robclark/src/freedreno/envytools/rnndb/adreno/adreno_common.xml ( 10551 bytes, from 2014-11-13 22:44:30) - /home/robclark/src/freedreno/envytools/rnndb/adreno/adreno_pm4.xml ( 15085 bytes, from 2014-12-20 21:49:41) -- /home/robclark/src/freedreno/envytools/rnndb/adreno/a3xx.xml ( 64848 bytes, from 2015-02-20 18:21:24) +- /home/robclark/src/freedreno/envytools/rnndb/adreno/a3xx.xml ( 64771 bytes, from 2015-03-15 21:55:57) - /home/robclark/src/freedreno/envytools/rnndb/adreno/a4xx.xml ( 51942 bytes, from 2015-02-24 17:14:02) Copyright (C) 2013-2014 by the following authors: diff --git a/src/gallium/drivers/freedreno/a3xx/a3xx.xml.h b/src/gallium/drivers/freedreno/a3xx/a3xx.xml.h index f71c249..8d15ed4 100644 --- a/src/gallium/drivers/freedreno/a3xx/a3xx.xml.h +++ b/src/gallium/drivers/freedreno/a3xx/a3xx.xml.h @@ -13,7 +13,7 @@ The rules-ng-ng source files this header was generated from are: - /home/robclark/src/freedreno/envytools/rnndb/adreno/a2xx.xml ( 32901 bytes, from 2014-06-02 15:21:30) - /home/robclark/src/freedreno/envytools/rnndb/adreno/adreno_common.xml ( 10551 bytes, from 2014-11-13 22:44:30) - /home/robclark/src/freedreno/envytools/rnndb/adreno/adreno_pm4.xml ( 15085 bytes, from 2014-12-20 21:49:41) -- /home/robclark/src/freedreno/envytools/rnndb/adreno/a3xx.xml ( 64848 bytes, from 2015-02-20 18:21:24) +- /home/robclark/src/freedreno/envytools/rnndb/adreno/a3xx.xml ( 64771 bytes, from 2015-03-15 21:55:57) - /home/robclark/src/freedreno/envytools/rnndb/adreno/a4xx.xml ( 51942 bytes, from 2015-02-24 17:14:02) Copyright (C) 2013-2015 by the following authors: @@ -2680,7 +2680,7 @@ static inline uint32_t A3XX_TEX_CONST_2_SWAP(enum a3xx_color_swap val) } #define REG_A3XX_TEX_CONST_3 0x00000003 -#define A3XX_TEX_CONST_3_LAYERSZ1__MASK 0x0000000f +#define A3XX_TEX_CONST_3_LAYERSZ1__MASK 0x00001fff #define A3XX_TEX_CONST_3_LAYERSZ1__SHIFT 0 static inline uint32_t A3XX_TEX_CONST_3_LAYERSZ1(uint32_t val) { diff --git a/src/gallium/drivers/freedreno/a4xx/a4xx.xml.h b/src/gallium/drivers/freedreno/a4xx/a4xx.xml.h index 73e9de6..0e80564 100644 --- a/src/gallium/drivers/freedreno/a4xx/a4xx.xml.h +++ b/src/gallium/drivers/freedreno/a4xx/a4xx.xml.h @@ -13,7 +13,7 @@ The rules-ng-ng source files this header was generated from are: - /home/robclark/src/freedreno/envytools/rnndb/adreno/a2xx.xml ( 32901 bytes, from 2014-06-02 15:21:30) - /home/robclark/src/freedreno/envytools/rnndb/adreno/adreno_common.xml ( 10551 bytes, from 2014-11-13 22:44:30) - /home/robclark/src/freedreno/envytools/rnndb/adreno/adreno_pm4.xml ( 15085 bytes, from 2014-12-20 21:49:41) -- /home/robclark/src/freedreno/envytools/rnndb/adreno/a3xx.xml ( 64848 bytes, from 2015-02-20 18:21:24) +- /home/robclark/src/freedreno/envytools/rnndb/adreno/a3xx.xml ( 64771 bytes, from 2015-03-15 21:55:57) - /home/robclark/src/freedreno/envytools/rnndb/adreno/a4xx.xml ( 51942 bytes, from 2015-02-24 17:14:02) Copyright (C) 2013-2015 by the following authors: diff --git a/src/gallium/drivers/freedreno/adreno_common.xml.h b/src/gallium/drivers/freedreno/adreno_common.xml.h index 868decd..163ac54 100644 --- a/src/gallium/drivers/freedreno/adreno_common.xml.h +++ b/src/gallium/drivers/freedreno/adreno_common.xml.h @@ -13,7 +13,7 @@ The rules-ng-ng source files this header was generated from are: - /home/robclark/src/freedreno/envytools/rnndb/adreno/a2xx.xml ( 32901 bytes, from 2014-06-02 15:21:30) - /home/robclark/src/freedreno/envytools/rnndb/adreno/adreno_common.xml ( 10551 bytes, from 2014-11-13 22:44:30) - /home/robclark/src/freedreno/envytools/rnndb/adreno/adreno_pm4.xml ( 15085 bytes, from 2014-12-20 21:49:41) -- /home/robclark/src/freedreno/envytools/rnndb/adreno/a3xx.xml ( 64848 bytes, from 2015-02-20 18:21:24) +- /home/robclark/src/freedreno/envytools/rnndb/adreno/a3xx.xml ( 64771 bytes, from 2015-03-15 21:55:57) - /home/robclark/src/freedreno/envytools/rnndb/adreno/a4xx.xml ( 51942 bytes, from 2015-02-24 17:14:02) Copyright (C) 2013-2014 by the following authors: diff --git a/src/gallium/drivers/freedreno/adreno_pm4.xml.h b/src/gallium/drivers/freedreno/adreno_pm4.xml.h index 19f8eb5..05afc66 100644 --- a/src/gallium/drivers/freedreno/adreno_pm4.xml.h +++ b/src/gallium/drivers/freedreno/adreno_pm4.xml.h @@ -13,7 +13,7 @@ The rules-ng-ng source files this header was generated from are: - /home/robclark/src/freedreno/envytools/rnndb/adreno/a2xx.xml ( 32901 bytes, from 2014-06-02 15:21:30) - /home/robclark/src/freedreno/envytools/rnndb/adreno/adreno_common.xml ( 10551 bytes, from 2014-11-13 22:44:30) - /home/robclark/src/freedreno/envytools/rnndb/adreno/adreno_pm4.xml ( 15085 bytes, from 2014-12-20 21:49:41) -- /home/robclark/src/freedreno/envytools/rnndb/adreno/a3xx.xml ( 64848 bytes, from 2015-02-20 18:21:24) +- /home/robclark/src/freedreno/envytools/rnndb/adreno/a3xx.xml ( 64771 bytes, from 2015-03-15 21:55:57) - /home/robclark/src/freedreno/envytools/rnndb/adreno/a4xx.xml ( 51942 bytes, from 2015-02-24 17:14:02) Copyright (C) 2013-2014 by the following authors: From mareko at kemper.freedesktop.org Mon Mar 16 11:55:49 2015 From: mareko at kemper.freedesktop.org (Marek Olšák) Date: Mon, 16 Mar 2015 04:55:49 -0700 (PDT) Subject: Mesa (master): radeonsi: add support for FMA Message-ID: <20150316115549.E3FF176336@kemper.freedesktop.org> Module: Mesa Branch: master Commit: d73c1c1304a205c8bf6d1cad1dd1d9a421ce2f32 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=d73c1c1304a205c8bf6d1cad1dd1d9a421ce2f32 Author: Marek Ol??k Date: Sat Feb 28 00:44:19 2015 +0100 radeonsi: add support for FMA Reviewed-by: Tom Stellard Reviewed-by: Glenn Kennard --- src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c | 2 ++ src/gallium/drivers/radeonsi/si_pipe.c | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c b/src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c index 94ef675..8026723 100644 --- a/src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c +++ b/src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c @@ -1314,6 +1314,8 @@ void radeon_llvm_context_init(struct radeon_llvm_context * ctx) bld_base->op_actions[TGSI_OPCODE_EX2].intr_name = "llvm.AMDIL.exp."; bld_base->op_actions[TGSI_OPCODE_FLR].emit = build_tgsi_intrinsic_nomem; bld_base->op_actions[TGSI_OPCODE_FLR].intr_name = "floor"; + bld_base->op_actions[TGSI_OPCODE_FMA].emit = build_tgsi_intrinsic_nomem; + bld_base->op_actions[TGSI_OPCODE_FMA].intr_name = "llvm.fma.f32"; bld_base->op_actions[TGSI_OPCODE_FRC].emit = build_tgsi_intrinsic_nomem; bld_base->op_actions[TGSI_OPCODE_FRC].intr_name = "llvm.AMDIL.fraction."; bld_base->op_actions[TGSI_OPCODE_F2I].emit = emit_f2i; diff --git a/src/gallium/drivers/radeonsi/si_pipe.c b/src/gallium/drivers/radeonsi/si_pipe.c index 0aacab1..87eeac6 100644 --- a/src/gallium/drivers/radeonsi/si_pipe.c +++ b/src/gallium/drivers/radeonsi/si_pipe.c @@ -425,8 +425,9 @@ static int si_get_shader_param(struct pipe_screen* pscreen, unsigned shader, enu case PIPE_SHADER_CAP_DOUBLES: case PIPE_SHADER_CAP_TGSI_DROUND_SUPPORTED: case PIPE_SHADER_CAP_TGSI_DFRACEXP_DLDEXP_SUPPORTED: - case PIPE_SHADER_CAP_TGSI_FMA_SUPPORTED: return 0; + case PIPE_SHADER_CAP_TGSI_FMA_SUPPORTED: + return 1; } return 0; } From mareko at kemper.freedesktop.org Mon Mar 16 11:55:49 2015 From: mareko at kemper.freedesktop.org (Marek Olšák) Date: Mon, 16 Mar 2015 04:55:49 -0700 (PDT) Subject: Mesa (master): radeonsi: add support for SQRT Message-ID: <20150316115549.EFBB376336@kemper.freedesktop.org> Module: Mesa Branch: master Commit: f9fd0c4a55afd97fd34d0e846000c75f5f6ecac2 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=f9fd0c4a55afd97fd34d0e846000c75f5f6ecac2 Author: Marek Ol??k Date: Mon Mar 2 02:40:57 2015 +0100 radeonsi: add support for SQRT Reviewed-by: Tom Stellard Reviewed-by: Glenn Kennard --- src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c | 2 ++ src/gallium/drivers/radeonsi/si_pipe.c | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c b/src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c index 8026723..385d3ad 100644 --- a/src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c +++ b/src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c @@ -1363,6 +1363,8 @@ void radeon_llvm_context_init(struct radeon_llvm_context * ctx) bld_base->op_actions[TGSI_OPCODE_SGT].emit = emit_cmp; bld_base->op_actions[TGSI_OPCODE_SIN].emit = build_tgsi_intrinsic_nomem; bld_base->op_actions[TGSI_OPCODE_SIN].intr_name = "llvm.sin.f32"; + bld_base->op_actions[TGSI_OPCODE_SQRT].emit = build_tgsi_intrinsic_nomem; + bld_base->op_actions[TGSI_OPCODE_SQRT].intr_name = "llvm.sqrt.f32"; bld_base->op_actions[TGSI_OPCODE_SSG].emit = emit_ssg; bld_base->op_actions[TGSI_OPCODE_TEX].fetch_args = tex_fetch_args; bld_base->op_actions[TGSI_OPCODE_TEX].intr_name = "llvm.AMDGPU.tex"; diff --git a/src/gallium/drivers/radeonsi/si_pipe.c b/src/gallium/drivers/radeonsi/si_pipe.c index 87eeac6..993b153 100644 --- a/src/gallium/drivers/radeonsi/si_pipe.c +++ b/src/gallium/drivers/radeonsi/si_pipe.c @@ -403,7 +403,7 @@ static int si_get_shader_param(struct pipe_screen* pscreen, unsigned shader, enu case PIPE_SHADER_CAP_TGSI_CONT_SUPPORTED: return 1; case PIPE_SHADER_CAP_TGSI_SQRT_SUPPORTED: - return 0; + return 1; case PIPE_SHADER_CAP_INDIRECT_INPUT_ADDR: /* Indirection of geometry shader input dimension is not * handled yet From mareko at kemper.freedesktop.org Mon Mar 16 11:55:50 2015 From: mareko at kemper.freedesktop.org (Marek Olšák) Date: Mon, 16 Mar 2015 04:55:50 -0700 (PDT) Subject: Mesa (master): radeonsi: add support for easy opcodes from ARB_gpu_shader5 Message-ID: <20150316115550.1D71376336@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 955ebf2890f18973a128ef3a6a6cfe4416fabaef URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=955ebf2890f18973a128ef3a6a6cfe4416fabaef Author: Marek Ol??k Date: Fri Mar 13 16:21:11 2015 +0100 radeonsi: add support for easy opcodes from ARB_gpu_shader5 I have to use the BFE instrinsics, because BFE is one of the most complex instructions that can't be matched easily. BFE has 3 conditional branches and one of them is quite big. In the isel DAG, lowered BFE has 27 nodes (including leafs). --- src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c b/src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c index 47c9d0c..0034b56 100644 --- a/src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c +++ b/src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c @@ -1382,6 +1382,8 @@ void radeon_llvm_context_init(struct radeon_llvm_context * ctx) bld_base->op_actions[TGSI_OPCODE_AND].emit = emit_and; bld_base->op_actions[TGSI_OPCODE_ARL].emit = emit_arl; bld_base->op_actions[TGSI_OPCODE_BGNLOOP].emit = bgnloop_emit; + bld_base->op_actions[TGSI_OPCODE_BREV].emit = build_tgsi_intrinsic_nomem; + bld_base->op_actions[TGSI_OPCODE_BREV].intr_name = "llvm.AMDGPU.brev"; bld_base->op_actions[TGSI_OPCODE_BRK].emit = brk_emit; bld_base->op_actions[TGSI_OPCODE_CEIL].emit = build_tgsi_intrinsic_nomem; bld_base->op_actions[TGSI_OPCODE_CEIL].intr_name = "ceil"; @@ -1415,6 +1417,8 @@ void radeon_llvm_context_init(struct radeon_llvm_context * ctx) bld_base->op_actions[TGSI_OPCODE_FSNE].emit = emit_fcmp; bld_base->op_actions[TGSI_OPCODE_IABS].emit = build_tgsi_intrinsic_nomem; bld_base->op_actions[TGSI_OPCODE_IABS].intr_name = "llvm.AMDIL.abs."; + bld_base->op_actions[TGSI_OPCODE_IBFE].emit = build_tgsi_intrinsic_nomem; + bld_base->op_actions[TGSI_OPCODE_IBFE].intr_name = "llvm.AMDGPU.bfe.i32"; bld_base->op_actions[TGSI_OPCODE_IDIV].emit = emit_idiv; bld_base->op_actions[TGSI_OPCODE_IF].emit = if_emit; bld_base->op_actions[TGSI_OPCODE_UIF].emit = uif_emit; @@ -1442,6 +1446,8 @@ void radeon_llvm_context_init(struct radeon_llvm_context * ctx) bld_base->op_actions[TGSI_OPCODE_UMSB].emit = emit_umsb; bld_base->op_actions[TGSI_OPCODE_NOT].emit = emit_not; bld_base->op_actions[TGSI_OPCODE_OR].emit = emit_or; + bld_base->op_actions[TGSI_OPCODE_POPC].emit = build_tgsi_intrinsic_nomem; + bld_base->op_actions[TGSI_OPCODE_POPC].intr_name = "llvm.ctpop.i32"; bld_base->op_actions[TGSI_OPCODE_POW].emit = build_tgsi_intrinsic_nomem; bld_base->op_actions[TGSI_OPCODE_POW].intr_name = "llvm.pow.f32"; bld_base->op_actions[TGSI_OPCODE_ROUND].emit = build_tgsi_intrinsic_nomem; @@ -1481,6 +1487,8 @@ void radeon_llvm_context_init(struct radeon_llvm_context * ctx) bld_base->op_actions[TGSI_OPCODE_TRUNC].emit = build_tgsi_intrinsic_nomem; bld_base->op_actions[TGSI_OPCODE_TRUNC].intr_name = "llvm.AMDGPU.trunc"; bld_base->op_actions[TGSI_OPCODE_UADD].emit = emit_uadd; + bld_base->op_actions[TGSI_OPCODE_UBFE].emit = build_tgsi_intrinsic_nomem; + bld_base->op_actions[TGSI_OPCODE_UBFE].intr_name = "llvm.AMDGPU.bfe.u32"; bld_base->op_actions[TGSI_OPCODE_UDIV].emit = emit_udiv; bld_base->op_actions[TGSI_OPCODE_UMAX].emit = build_tgsi_intrinsic_nomem; bld_base->op_actions[TGSI_OPCODE_UMAX].intr_name = "llvm.AMDGPU.umax"; From mareko at kemper.freedesktop.org Mon Mar 16 11:55:49 2015 From: mareko at kemper.freedesktop.org (Marek Olšák) Date: Mon, 16 Mar 2015 04:55:49 -0700 (PDT) Subject: Mesa (master): gallium: add FMA and DFMA opcodes (v3) Message-ID: <20150316115549.C4A9176336@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 216543ea547dd0572d9f2f0364f7a239a5aeafe1 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=216543ea547dd0572d9f2f0364f7a239a5aeafe1 Author: Marek Ol??k Date: Sat Feb 28 00:26:31 2015 +0100 gallium: add FMA and DFMA opcodes (v3) Needed by ARB_gpu_shader5. v2: select DMAD for FMA with double precision v3: add and select DFMA Reviewed-by: Ilia Mirkin --- src/gallium/auxiliary/gallivm/lp_bld_limits.h | 1 + src/gallium/auxiliary/tgsi/tgsi_exec.h | 1 + src/gallium/auxiliary/tgsi/tgsi_info.c | 4 ++-- src/gallium/auxiliary/tgsi/tgsi_util.c | 1 + src/gallium/docs/source/screen.rst | 2 ++ src/gallium/docs/source/tgsi.rst | 26 ++++++++++++++++++++++ src/gallium/drivers/freedreno/freedreno_screen.c | 1 + src/gallium/drivers/i915/i915_screen.c | 1 + src/gallium/drivers/nouveau/nv30/nv30_screen.c | 2 ++ src/gallium/drivers/nouveau/nv50/nv50_screen.c | 1 + src/gallium/drivers/nouveau/nvc0/nvc0_screen.c | 1 + src/gallium/drivers/r300/r300_screen.c | 2 ++ src/gallium/drivers/r600/r600_pipe.c | 1 + src/gallium/drivers/r600/r600_shader.c | 6 ++--- src/gallium/drivers/radeonsi/si_pipe.c | 1 + src/gallium/drivers/svga/svga_screen.c | 2 ++ src/gallium/drivers/vc4/vc4_screen.c | 1 + src/gallium/include/pipe/p_defines.h | 1 + src/gallium/include/pipe/p_shader_tokens.h | 6 ++--- src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 13 +++++++---- 20 files changed, 62 insertions(+), 12 deletions(-) diff --git a/src/gallium/auxiliary/gallivm/lp_bld_limits.h b/src/gallium/auxiliary/gallivm/lp_bld_limits.h index 2962360..c5c51c1 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_limits.h +++ b/src/gallium/auxiliary/gallivm/lp_bld_limits.h @@ -129,6 +129,7 @@ gallivm_get_shader_param(enum pipe_shader_cap param) case PIPE_SHADER_CAP_DOUBLES: case PIPE_SHADER_CAP_TGSI_DROUND_SUPPORTED: case PIPE_SHADER_CAP_TGSI_DFRACEXP_DLDEXP_SUPPORTED: + case PIPE_SHADER_CAP_TGSI_FMA_SUPPORTED: return 0; } /* if we get here, we missed a shader cap above (and should have seen diff --git a/src/gallium/auxiliary/tgsi/tgsi_exec.h b/src/gallium/auxiliary/tgsi/tgsi_exec.h index 609c81b..0e59b88 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_exec.h +++ b/src/gallium/auxiliary/tgsi/tgsi_exec.h @@ -459,6 +459,7 @@ tgsi_exec_get_shader_param(enum pipe_shader_cap param) case PIPE_SHADER_CAP_TGSI_DFRACEXP_DLDEXP_SUPPORTED: return 1; case PIPE_SHADER_CAP_TGSI_DROUND_SUPPORTED: + case PIPE_SHADER_CAP_TGSI_FMA_SUPPORTED: return 0; } /* if we get here, we missed a shader cap above (and should have seen diff --git a/src/gallium/auxiliary/tgsi/tgsi_info.c b/src/gallium/auxiliary/tgsi/tgsi_info.c index 4d838fd..1194709 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_info.c +++ b/src/gallium/auxiliary/tgsi/tgsi_info.c @@ -56,7 +56,7 @@ static const struct tgsi_opcode_info opcode_info[TGSI_OPCODE_LAST] = { 1, 3, 0, 0, 0, 0, COMP, "MAD", TGSI_OPCODE_MAD }, { 1, 2, 0, 0, 0, 0, COMP, "SUB", TGSI_OPCODE_SUB }, { 1, 3, 0, 0, 0, 0, COMP, "LRP", TGSI_OPCODE_LRP }, - { 0, 0, 0, 0, 0, 0, NONE, "", 19 }, /* removed */ + { 1, 3, 0, 0, 0, 0, COMP, "FMA", TGSI_OPCODE_FMA }, { 1, 1, 0, 0, 0, 0, REPL, "SQRT", TGSI_OPCODE_SQRT }, { 1, 3, 0, 0, 0, 0, REPL, "DP2A", TGSI_OPCODE_DP2A }, { 0, 0, 0, 0, 0, 0, NONE, "", 22 }, /* removed */ @@ -155,7 +155,7 @@ static const struct tgsi_opcode_info opcode_info[TGSI_OPCODE_LAST] = { 0, 1, 0, 0, 0, 0, NONE, "BREAKC", TGSI_OPCODE_BREAKC }, { 0, 1, 0, 0, 0, 0, NONE, "KILL_IF", TGSI_OPCODE_KILL_IF }, { 0, 0, 0, 0, 0, 0, NONE, "END", TGSI_OPCODE_END }, - { 0, 0, 0, 0, 0, 0, NONE, "", 118 }, /* removed */ + { 1, 3, 0, 0, 0, 0, COMP, "DFMA", TGSI_OPCODE_DFMA }, { 1, 1, 0, 0, 0, 0, COMP, "F2I", TGSI_OPCODE_F2I }, { 1, 2, 0, 0, 0, 0, COMP, "IDIV", TGSI_OPCODE_IDIV }, { 1, 2, 0, 0, 0, 0, COMP, "IMAX", TGSI_OPCODE_IMAX }, diff --git a/src/gallium/auxiliary/tgsi/tgsi_util.c b/src/gallium/auxiliary/tgsi/tgsi_util.c index d572ff0..e5b8427 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_util.c +++ b/src/gallium/auxiliary/tgsi/tgsi_util.c @@ -193,6 +193,7 @@ tgsi_util_get_inst_usage_mask(const struct tgsi_full_instruction *inst, case TGSI_OPCODE_MAD: case TGSI_OPCODE_SUB: case TGSI_OPCODE_LRP: + case TGSI_OPCODE_FMA: case TGSI_OPCODE_FRC: case TGSI_OPCODE_CEIL: case TGSI_OPCODE_CLAMP: diff --git a/src/gallium/docs/source/screen.rst b/src/gallium/docs/source/screen.rst index e0fd1a2..26cc9ff 100644 --- a/src/gallium/docs/source/screen.rst +++ b/src/gallium/docs/source/screen.rst @@ -336,6 +336,8 @@ to be 0. is supported. If it is, DTRUNC/DCEIL/DFLR/DROUND opcodes may be used. * ``PIPE_SHADER_CAP_TGSI_DFRACEXP_DLDEXP_SUPPORTED``: Whether DFRACEXP and DLDEXP are supported. +* ``PIPE_SHADER_CAP_TGSI_FMA_SUPPORTED``: Whether FMA and DFMA (doubles only) + are supported. .. _pipe_compute_cap: diff --git a/src/gallium/docs/source/tgsi.rst b/src/gallium/docs/source/tgsi.rst index b0a975a..7771136 100644 --- a/src/gallium/docs/source/tgsi.rst +++ b/src/gallium/docs/source/tgsi.rst @@ -272,6 +272,21 @@ This instruction replicates its result. dst.w = src0.w \times src1.w + (1 - src0.w) \times src2.w +.. opcode:: FMA - Fused Multiply-Add + +Perform a * b + c with no intermediate rounding step. + +.. math:: + + dst.x = src0.x \times src1.x + src2.x + + dst.y = src0.y \times src1.y + src2.y + + dst.z = src0.z \times src1.z + src2.z + + dst.w = src0.w \times src1.w + src2.w + + .. opcode:: DP2A - 2-component Dot Product And Add .. math:: @@ -1962,6 +1977,17 @@ source is an integer. dst.zw = src0.zw \times src1.zw + src2.zw +.. opcode:: DFMA - Fused Multiply-Add + +Perform a * b + c with no intermediate rounding step. + +.. math:: + + dst.xy = src0.xy \times src1.xy + src2.xy + + dst.zw = src0.zw \times src1.zw + src2.zw + + .. opcode:: DRCP - Reciprocal .. math:: diff --git a/src/gallium/drivers/freedreno/freedreno_screen.c b/src/gallium/drivers/freedreno/freedreno_screen.c index a4699e4..1d73513 100644 --- a/src/gallium/drivers/freedreno/freedreno_screen.c +++ b/src/gallium/drivers/freedreno/freedreno_screen.c @@ -363,6 +363,7 @@ fd_screen_get_shader_param(struct pipe_screen *pscreen, unsigned shader, case PIPE_SHADER_CAP_DOUBLES: case PIPE_SHADER_CAP_TGSI_DROUND_SUPPORTED: case PIPE_SHADER_CAP_TGSI_DFRACEXP_DLDEXP_SUPPORTED: + case PIPE_SHADER_CAP_TGSI_FMA_SUPPORTED: return 0; case PIPE_SHADER_CAP_TGSI_SQRT_SUPPORTED: return 1; diff --git a/src/gallium/drivers/i915/i915_screen.c b/src/gallium/drivers/i915/i915_screen.c index dc76464..50847e2 100644 --- a/src/gallium/drivers/i915/i915_screen.c +++ b/src/gallium/drivers/i915/i915_screen.c @@ -158,6 +158,7 @@ i915_get_shader_param(struct pipe_screen *screen, unsigned shader, enum pipe_sha case PIPE_SHADER_CAP_DOUBLES: case PIPE_SHADER_CAP_TGSI_DROUND_SUPPORTED: case PIPE_SHADER_CAP_TGSI_DFRACEXP_DLDEXP_SUPPORTED: + case PIPE_SHADER_CAP_TGSI_FMA_SUPPORTED: return 0; default: debug_printf("%s: Unknown cap %u.\n", __FUNCTION__, cap); diff --git a/src/gallium/drivers/nouveau/nv30/nv30_screen.c b/src/gallium/drivers/nouveau/nv30/nv30_screen.c index 0fca9e0..eeb7148 100644 --- a/src/gallium/drivers/nouveau/nv30/nv30_screen.c +++ b/src/gallium/drivers/nouveau/nv30/nv30_screen.c @@ -250,6 +250,7 @@ nv30_screen_get_shader_param(struct pipe_screen *pscreen, unsigned shader, case PIPE_SHADER_CAP_DOUBLES: case PIPE_SHADER_CAP_TGSI_DROUND_SUPPORTED: case PIPE_SHADER_CAP_TGSI_DFRACEXP_DLDEXP_SUPPORTED: + case PIPE_SHADER_CAP_TGSI_FMA_SUPPORTED: return 0; default: debug_printf("unknown vertex shader param %d\n", param); @@ -289,6 +290,7 @@ nv30_screen_get_shader_param(struct pipe_screen *pscreen, unsigned shader, case PIPE_SHADER_CAP_DOUBLES: case PIPE_SHADER_CAP_TGSI_DROUND_SUPPORTED: case PIPE_SHADER_CAP_TGSI_DFRACEXP_DLDEXP_SUPPORTED: + case PIPE_SHADER_CAP_TGSI_FMA_SUPPORTED: return 0; default: debug_printf("unknown fragment shader param %d\n", param); diff --git a/src/gallium/drivers/nouveau/nv50/nv50_screen.c b/src/gallium/drivers/nouveau/nv50/nv50_screen.c index ed07ba4..829dfbc 100644 --- a/src/gallium/drivers/nouveau/nv50/nv50_screen.c +++ b/src/gallium/drivers/nouveau/nv50/nv50_screen.c @@ -289,6 +289,7 @@ nv50_screen_get_shader_param(struct pipe_screen *pscreen, unsigned shader, case PIPE_SHADER_CAP_DOUBLES: case PIPE_SHADER_CAP_TGSI_DROUND_SUPPORTED: case PIPE_SHADER_CAP_TGSI_DFRACEXP_DLDEXP_SUPPORTED: + case PIPE_SHADER_CAP_TGSI_FMA_SUPPORTED: return 0; default: NOUVEAU_ERR("unknown PIPE_SHADER_CAP %d\n", param); diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c b/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c index 686d892..04c34f5 100644 --- a/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c +++ b/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c @@ -295,6 +295,7 @@ nvc0_screen_get_shader_param(struct pipe_screen *pscreen, unsigned shader, case PIPE_SHADER_CAP_TGSI_DROUND_SUPPORTED: return 1; case PIPE_SHADER_CAP_TGSI_DFRACEXP_DLDEXP_SUPPORTED: + case PIPE_SHADER_CAP_TGSI_FMA_SUPPORTED: return 0; case PIPE_SHADER_CAP_MAX_TEXTURE_SAMPLERS: return 16; /* would be 32 in linked (OpenGL-style) mode */ diff --git a/src/gallium/drivers/r300/r300_screen.c b/src/gallium/drivers/r300/r300_screen.c index fca8001..752d7e5 100644 --- a/src/gallium/drivers/r300/r300_screen.c +++ b/src/gallium/drivers/r300/r300_screen.c @@ -287,6 +287,7 @@ static int r300_get_shader_param(struct pipe_screen *pscreen, unsigned shader, e case PIPE_SHADER_CAP_DOUBLES: case PIPE_SHADER_CAP_TGSI_DROUND_SUPPORTED: case PIPE_SHADER_CAP_TGSI_DFRACEXP_DLDEXP_SUPPORTED: + case PIPE_SHADER_CAP_TGSI_FMA_SUPPORTED: return 0; case PIPE_SHADER_CAP_PREFERRED_IR: return PIPE_SHADER_IR_TGSI; @@ -341,6 +342,7 @@ static int r300_get_shader_param(struct pipe_screen *pscreen, unsigned shader, e case PIPE_SHADER_CAP_DOUBLES: case PIPE_SHADER_CAP_TGSI_DROUND_SUPPORTED: case PIPE_SHADER_CAP_TGSI_DFRACEXP_DLDEXP_SUPPORTED: + case PIPE_SHADER_CAP_TGSI_FMA_SUPPORTED: return 0; case PIPE_SHADER_CAP_PREFERRED_IR: return PIPE_SHADER_IR_TGSI; diff --git a/src/gallium/drivers/r600/r600_pipe.c b/src/gallium/drivers/r600/r600_pipe.c index 24d901e..21e5d42 100644 --- a/src/gallium/drivers/r600/r600_pipe.c +++ b/src/gallium/drivers/r600/r600_pipe.c @@ -493,6 +493,7 @@ static int r600_get_shader_param(struct pipe_screen* pscreen, unsigned shader, e return 0; case PIPE_SHADER_CAP_TGSI_DROUND_SUPPORTED: case PIPE_SHADER_CAP_TGSI_DFRACEXP_DLDEXP_SUPPORTED: + case PIPE_SHADER_CAP_TGSI_FMA_SUPPORTED: return 0; } return 0; diff --git a/src/gallium/drivers/r600/r600_shader.c b/src/gallium/drivers/r600/r600_shader.c index 2ee59c8..54540c3 100644 --- a/src/gallium/drivers/r600/r600_shader.c +++ b/src/gallium/drivers/r600/r600_shader.c @@ -7295,7 +7295,7 @@ static struct r600_shader_tgsi_instruction r600_shader_tgsi_instruction[] = { {TGSI_OPCODE_MAD, 1, ALU_OP3_MULADD, tgsi_op3}, {TGSI_OPCODE_SUB, 0, ALU_OP2_ADD, tgsi_op2}, {TGSI_OPCODE_LRP, 0, ALU_OP0_NOP, tgsi_lrp}, - {19, 0, ALU_OP0_NOP, tgsi_unsupported}, + {TGSI_OPCODE_FMA, 0, ALU_OP0_NOP, tgsi_unsupported}, {TGSI_OPCODE_SQRT, 0, ALU_OP1_SQRT_IEEE, tgsi_trans_srcx_replicate}, {TGSI_OPCODE_DP2A, 0, ALU_OP0_NOP, tgsi_unsupported}, {22, 0, ALU_OP0_NOP, tgsi_unsupported}, @@ -7494,7 +7494,7 @@ static struct r600_shader_tgsi_instruction eg_shader_tgsi_instruction[] = { {TGSI_OPCODE_MAD, 1, ALU_OP3_MULADD, tgsi_op3}, {TGSI_OPCODE_SUB, 0, ALU_OP2_ADD, tgsi_op2}, {TGSI_OPCODE_LRP, 0, ALU_OP0_NOP, tgsi_lrp}, - {19, 0, ALU_OP0_NOP, tgsi_unsupported}, + {TGSI_OPCODE_FMA, 0, ALU_OP0_NOP, tgsi_unsupported}, {TGSI_OPCODE_SQRT, 0, ALU_OP1_SQRT_IEEE, tgsi_trans_srcx_replicate}, {TGSI_OPCODE_DP2A, 0, ALU_OP0_NOP, tgsi_unsupported}, {22, 0, ALU_OP0_NOP, tgsi_unsupported}, @@ -7693,7 +7693,7 @@ static struct r600_shader_tgsi_instruction cm_shader_tgsi_instruction[] = { {TGSI_OPCODE_MAD, 1, ALU_OP3_MULADD, tgsi_op3}, {TGSI_OPCODE_SUB, 0, ALU_OP2_ADD, tgsi_op2}, {TGSI_OPCODE_LRP, 0, ALU_OP0_NOP, tgsi_lrp}, - {19, 0, ALU_OP0_NOP, tgsi_unsupported}, + {TGSI_OPCODE_FMA, 0, ALU_OP0_NOP, tgsi_unsupported}, {TGSI_OPCODE_SQRT, 0, ALU_OP1_SQRT_IEEE, cayman_emit_float_instr}, {TGSI_OPCODE_DP2A, 0, ALU_OP0_NOP, tgsi_unsupported}, {22, 0, ALU_OP0_NOP, tgsi_unsupported}, diff --git a/src/gallium/drivers/radeonsi/si_pipe.c b/src/gallium/drivers/radeonsi/si_pipe.c index f1a5388..0aacab1 100644 --- a/src/gallium/drivers/radeonsi/si_pipe.c +++ b/src/gallium/drivers/radeonsi/si_pipe.c @@ -425,6 +425,7 @@ static int si_get_shader_param(struct pipe_screen* pscreen, unsigned shader, enu case PIPE_SHADER_CAP_DOUBLES: case PIPE_SHADER_CAP_TGSI_DROUND_SUPPORTED: case PIPE_SHADER_CAP_TGSI_DFRACEXP_DLDEXP_SUPPORTED: + case PIPE_SHADER_CAP_TGSI_FMA_SUPPORTED: return 0; } return 0; diff --git a/src/gallium/drivers/svga/svga_screen.c b/src/gallium/drivers/svga/svga_screen.c index bac0dbc..7b01d35 100644 --- a/src/gallium/drivers/svga/svga_screen.c +++ b/src/gallium/drivers/svga/svga_screen.c @@ -375,6 +375,7 @@ static int svga_get_shader_param(struct pipe_screen *screen, unsigned shader, en case PIPE_SHADER_CAP_DOUBLES: case PIPE_SHADER_CAP_TGSI_DROUND_SUPPORTED: case PIPE_SHADER_CAP_TGSI_DFRACEXP_DLDEXP_SUPPORTED: + case PIPE_SHADER_CAP_TGSI_FMA_SUPPORTED: return 0; } /* If we get here, we failed to handle a cap above */ @@ -431,6 +432,7 @@ static int svga_get_shader_param(struct pipe_screen *screen, unsigned shader, en case PIPE_SHADER_CAP_DOUBLES: case PIPE_SHADER_CAP_TGSI_DROUND_SUPPORTED: case PIPE_SHADER_CAP_TGSI_DFRACEXP_DLDEXP_SUPPORTED: + case PIPE_SHADER_CAP_TGSI_FMA_SUPPORTED: return 0; } /* If we get here, we failed to handle a cap above */ diff --git a/src/gallium/drivers/vc4/vc4_screen.c b/src/gallium/drivers/vc4/vc4_screen.c index 7c62847..0be8ec2 100644 --- a/src/gallium/drivers/vc4/vc4_screen.c +++ b/src/gallium/drivers/vc4/vc4_screen.c @@ -319,6 +319,7 @@ vc4_screen_get_shader_param(struct pipe_screen *pscreen, unsigned shader, case PIPE_SHADER_CAP_DOUBLES: case PIPE_SHADER_CAP_TGSI_DROUND_SUPPORTED: case PIPE_SHADER_CAP_TGSI_DFRACEXP_DLDEXP_SUPPORTED: + case PIPE_SHADER_CAP_TGSI_FMA_SUPPORTED: return 0; case PIPE_SHADER_CAP_MAX_TEXTURE_SAMPLERS: case PIPE_SHADER_CAP_MAX_SAMPLER_VIEWS: diff --git a/src/gallium/include/pipe/p_defines.h b/src/gallium/include/pipe/p_defines.h index a8ffe9c..67f48e4 100644 --- a/src/gallium/include/pipe/p_defines.h +++ b/src/gallium/include/pipe/p_defines.h @@ -644,6 +644,7 @@ enum pipe_shader_cap PIPE_SHADER_CAP_DOUBLES, PIPE_SHADER_CAP_TGSI_DROUND_SUPPORTED, /* all rounding modes */ PIPE_SHADER_CAP_TGSI_DFRACEXP_DLDEXP_SUPPORTED, + PIPE_SHADER_CAP_TGSI_FMA_SUPPORTED, }; /** diff --git a/src/gallium/include/pipe/p_shader_tokens.h b/src/gallium/include/pipe/p_shader_tokens.h index 95ac590..c14bcbc 100644 --- a/src/gallium/include/pipe/p_shader_tokens.h +++ b/src/gallium/include/pipe/p_shader_tokens.h @@ -306,7 +306,7 @@ struct tgsi_property_data { #define TGSI_OPCODE_MAD 16 #define TGSI_OPCODE_SUB 17 #define TGSI_OPCODE_LRP 18 - /* gap */ +#define TGSI_OPCODE_FMA 19 #define TGSI_OPCODE_SQRT 20 #define TGSI_OPCODE_DP2A 21 /* gap */ @@ -404,7 +404,7 @@ struct tgsi_property_data { #define TGSI_OPCODE_BREAKC 115 #define TGSI_OPCODE_KILL_IF 116 /* conditional kill */ #define TGSI_OPCODE_END 117 /* aka HALT */ - /* gap */ +#define TGSI_OPCODE_DFMA 118 #define TGSI_OPCODE_F2I 119 #define TGSI_OPCODE_IDIV 120 #define TGSI_OPCODE_IMAX 121 @@ -510,7 +510,7 @@ struct tgsi_property_data { #define TGSI_OPCODE_DSNE 206 /* SM5 */ #define TGSI_OPCODE_DRCP 207 /* eg, cayman */ #define TGSI_OPCODE_DSQRT 208 /* eg, cayman also has DRSQ */ -#define TGSI_OPCODE_DMAD 209 /* DFMA? */ +#define TGSI_OPCODE_DMAD 209 #define TGSI_OPCODE_DFRAC 210 /* eg, cayman */ #define TGSI_OPCODE_DLDEXP 211 /* eg, cayman */ #define TGSI_OPCODE_DFRACEXP 212 /* eg, cayman */ diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp index bd191d8..efee4b2 100644 --- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp +++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp @@ -332,6 +332,7 @@ public: int glsl_version; bool native_integers; bool have_sqrt; + bool have_fma; variable_storage *find_variable_storage(ir_variable *var); @@ -836,6 +837,7 @@ glsl_to_tgsi_visitor::get_opcode(ir_instruction *ir, unsigned op, case3fid(ADD, UADD, DADD); case3fid(MUL, UMUL, DMUL); case3fid(MAD, UMAD, DMAD); + case3fid(FMA, UMAD, DFMA); case3(DIV, IDIV, UDIV); case4d(MAX, IMAX, UMAX, DMAX); case4d(MIN, IMIN, UMIN, DMIN); @@ -2222,10 +2224,11 @@ glsl_to_tgsi_visitor::visit(ir_expression *ir) emit(ir, TGSI_OPCODE_IMUL_HI, result_dst, op[0], op[1]); break; case ir_triop_fma: - /* NOTE: Perhaps there should be a special opcode that enforces fused - * mul-add. Just use MAD for now. - */ - emit(ir, TGSI_OPCODE_MAD, result_dst, op[0], op[1], op[2]); + /* In theory, MAD is incorrect here. */ + if (have_fma) + emit(ir, TGSI_OPCODE_FMA, result_dst, op[0], op[1], op[2]); + else + emit(ir, TGSI_OPCODE_MAD, result_dst, op[0], op[1], op[2]); break; case ir_unop_interpolate_at_centroid: emit(ir, TGSI_OPCODE_INTERP_CENTROID, result_dst, op[0]); @@ -5564,6 +5567,8 @@ get_mesa_program(struct gl_context *ctx, v->have_sqrt = pscreen->get_shader_param(pscreen, ptarget, PIPE_SHADER_CAP_TGSI_SQRT_SUPPORTED); + v->have_fma = pscreen->get_shader_param(pscreen, ptarget, + PIPE_SHADER_CAP_TGSI_FMA_SUPPORTED); _mesa_copy_linked_program_data(shader->Stage, shader_program, prog); _mesa_generate_parameters_list_for_uniforms(shader_program, shader, From mareko at kemper.freedesktop.org Mon Mar 16 11:55:49 2015 From: mareko at kemper.freedesktop.org (Marek Olšák) Date: Mon, 16 Mar 2015 04:55:49 -0700 (PDT) Subject: Mesa (master): tgsi: handle bitwise opcodes in tgsi_opcode_infer_type (v2) Message-ID: <20150316115549.CDABF7633A@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 9da9c8e3f4f8f06c32efa8344b0a995d34c3b592 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=9da9c8e3f4f8f06c32efa8344b0a995d34c3b592 Author: Marek Ol??k Date: Sat Feb 28 00:34:53 2015 +0100 tgsi: handle bitwise opcodes in tgsi_opcode_infer_type (v2) v2: set the same types as the destination type in tgsi_exec Reviewed-by: Ilia Mirkin --- src/gallium/auxiliary/tgsi/tgsi_info.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/gallium/auxiliary/tgsi/tgsi_info.c b/src/gallium/auxiliary/tgsi/tgsi_info.c index 1194709..3cab86e 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_info.c +++ b/src/gallium/auxiliary/tgsi/tgsi_info.c @@ -341,6 +341,12 @@ tgsi_opcode_infer_type( uint opcode ) case TGSI_OPCODE_USNE: case TGSI_OPCODE_SVIEWINFO: case TGSI_OPCODE_UMUL_HI: + case TGSI_OPCODE_UBFE: + case TGSI_OPCODE_BFI: + case TGSI_OPCODE_BREV: + case TGSI_OPCODE_POPC: + case TGSI_OPCODE_LSB: + case TGSI_OPCODE_UMSB: return TGSI_TYPE_UNSIGNED; case TGSI_OPCODE_ARL: case TGSI_OPCODE_ARR: @@ -362,6 +368,8 @@ tgsi_opcode_infer_type( uint opcode ) case TGSI_OPCODE_IABS: case TGSI_OPCODE_ISSG: case TGSI_OPCODE_IMUL_HI: + case TGSI_OPCODE_IBFE: + case TGSI_OPCODE_IMSB: return TGSI_TYPE_SIGNED; default: return TGSI_TYPE_FLOAT; From mareko at kemper.freedesktop.org Mon Mar 16 11:55:50 2015 From: mareko at kemper.freedesktop.org (Marek Olšák) Date: Mon, 16 Mar 2015 04:55:50 -0700 (PDT) Subject: Mesa (master): radeonsi: implement gl_SampleMaskIn Message-ID: <20150316115550.072DA76336@kemper.freedesktop.org> Module: Mesa Branch: master Commit: ca90cde81eb48a50286193c6bbef9ef47c70a0c6 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=ca90cde81eb48a50286193c6bbef9ef47c70a0c6 Author: Marek Ol??k Date: Sat Feb 28 00:30:26 2015 +0100 radeonsi: implement gl_SampleMaskIn Reviewed-by: Glenn Kennard --- docs/GL3.txt | 2 +- src/gallium/drivers/radeonsi/si_shader.c | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/GL3.txt b/docs/GL3.txt index 289dd36..267740a 100644 --- a/docs/GL3.txt +++ b/docs/GL3.txt @@ -106,7 +106,7 @@ GL 4.0, GLSL 4.00: - Enhanced textureGather DONE (r600, radeonsi) - Geometry shader instancing DONE (r600) - Geometry shader multiple streams DONE () - - Enhanced per-sample shading DONE (r600) + - Enhanced per-sample shading DONE (r600, radeonsi) - Interpolation functions DONE (r600) - New overload resolution rules DONE GL_ARB_gpu_shader_fp64 DONE (nvc0, softpipe) diff --git a/src/gallium/drivers/radeonsi/si_shader.c b/src/gallium/drivers/radeonsi/si_shader.c index 0ef58a7..e70a318 100644 --- a/src/gallium/drivers/radeonsi/si_shader.c +++ b/src/gallium/drivers/radeonsi/si_shader.c @@ -643,6 +643,10 @@ static void declare_system_value( break; } + case TGSI_SEMANTIC_SAMPLEMASK: + value = LLVMGetParam(radeon_bld->main_fn, SI_PARAM_SAMPLE_COVERAGE); + break; + default: assert(!"unknown system value"); return; From mareko at kemper.freedesktop.org Mon Mar 16 11:55:50 2015 From: mareko at kemper.freedesktop.org (Marek Olšák) Date: Mon, 16 Mar 2015 04:55:50 -0700 (PDT) Subject: Mesa (master): radeonsi: implement bit-finding opcodes from ARB_gpu_shader5 Message-ID: <20150316115550.1219C76336@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 755a2907a3e7f896f86861254554543d815bfad3 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=755a2907a3e7f896f86861254554543d815bfad3 Author: Marek Ol??k Date: Sat Feb 28 14:01:43 2015 +0100 radeonsi: implement bit-finding opcodes from ARB_gpu_shader5 Reviewed-by: Glenn Kennard --- .../drivers/radeon/radeon_setup_tgsi_llvm.c | 92 ++++++++++++++++++++ 1 file changed, 92 insertions(+) diff --git a/src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c b/src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c index 385d3ad..47c9d0c 100644 --- a/src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c +++ b/src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c @@ -1234,6 +1234,95 @@ build_tgsi_intrinsic_nomem( build_tgsi_intrinsic(action, bld_base, emit_data, LLVMReadNoneAttribute); } +/* this is ffs in C */ +static void emit_lsb(const struct lp_build_tgsi_action * action, + struct lp_build_tgsi_context * bld_base, + struct lp_build_emit_data * emit_data) +{ + struct gallivm_state *gallivm = bld_base->base.gallivm; + LLVMValueRef args[2] = { + emit_data->args[0], + + /* The value of 1 means that ffs(x=0) = undef, so LLVM won't + * add special code to check for x=0. The reason is that + * the LLVM behavior for x=0 is different from what we + * need here. + * + * The hardware already implements the correct behavior. + */ + lp_build_const_int32(gallivm, 1) + }; + + emit_data->output[emit_data->chan] = + build_intrinsic(gallivm->builder, "llvm.cttz.i32", + emit_data->dst_type, args, Elements(args), + LLVMReadNoneAttribute); +} + +/* Find the last bit set. */ +static void emit_umsb(const struct lp_build_tgsi_action * action, + struct lp_build_tgsi_context * bld_base, + struct lp_build_emit_data * emit_data) +{ + struct gallivm_state *gallivm = bld_base->base.gallivm; + LLVMBuilderRef builder = gallivm->builder; + LLVMValueRef args[2] = { + emit_data->args[0], + /* Don't generate code for handling zero: */ + lp_build_const_int32(gallivm, 1) + }; + + LLVMValueRef msb = + build_intrinsic(builder, "llvm.ctlz.i32", + emit_data->dst_type, args, Elements(args), + LLVMReadNoneAttribute); + + /* The HW returns the last bit index from MSB, but TGSI wants + * the index from LSB. Invert it by doing "31 - msb". */ + msb = LLVMBuildSub(builder, lp_build_const_int32(gallivm, 31), + msb, ""); + + /* Check for zero: */ + emit_data->output[emit_data->chan] = + LLVMBuildSelect(builder, + LLVMBuildICmp(builder, LLVMIntEQ, args[0], + bld_base->uint_bld.zero, ""), + lp_build_const_int32(gallivm, -1), msb, ""); +} + +/* Find the last bit opposite of the sign bit. */ +static void emit_imsb(const struct lp_build_tgsi_action * action, + struct lp_build_tgsi_context * bld_base, + struct lp_build_emit_data * emit_data) +{ + struct gallivm_state *gallivm = bld_base->base.gallivm; + LLVMBuilderRef builder = gallivm->builder; + LLVMValueRef arg = emit_data->args[0]; + + LLVMValueRef msb = + build_intrinsic(builder, "llvm.AMDGPU.flbit.i32", + emit_data->dst_type, &arg, 1, + LLVMReadNoneAttribute); + + /* The HW returns the last bit index from MSB, but TGSI wants + * the index from LSB. Invert it by doing "31 - msb". */ + msb = LLVMBuildSub(builder, lp_build_const_int32(gallivm, 31), + msb, ""); + + /* If arg == 0 || arg == -1 (0xffffffff), return -1. */ + LLVMValueRef all_ones = lp_build_const_int32(gallivm, -1); + + LLVMValueRef cond = + LLVMBuildOr(builder, + LLVMBuildICmp(builder, LLVMIntEQ, arg, + bld_base->uint_bld.zero, ""), + LLVMBuildICmp(builder, LLVMIntEQ, arg, + all_ones, ""), ""); + + emit_data->output[emit_data->chan] = + LLVMBuildSelect(builder, cond, all_ones, msb, ""); +} + void radeon_llvm_context_init(struct radeon_llvm_context * ctx) { struct lp_type type; @@ -1333,6 +1422,7 @@ void radeon_llvm_context_init(struct radeon_llvm_context * ctx) bld_base->op_actions[TGSI_OPCODE_IMAX].intr_name = "llvm.AMDGPU.imax"; bld_base->op_actions[TGSI_OPCODE_IMIN].emit = build_tgsi_intrinsic_nomem; bld_base->op_actions[TGSI_OPCODE_IMIN].intr_name = "llvm.AMDGPU.imin"; + bld_base->op_actions[TGSI_OPCODE_IMSB].emit = emit_imsb; bld_base->op_actions[TGSI_OPCODE_INEG].emit = emit_ineg; bld_base->op_actions[TGSI_OPCODE_ISHR].emit = emit_ishr; bld_base->op_actions[TGSI_OPCODE_ISGE].emit = emit_icmp; @@ -1343,11 +1433,13 @@ void radeon_llvm_context_init(struct radeon_llvm_context * ctx) bld_base->op_actions[TGSI_OPCODE_KILL_IF].intr_name = "llvm.AMDGPU.kill"; bld_base->op_actions[TGSI_OPCODE_KILL].emit = lp_build_tgsi_intrinsic; bld_base->op_actions[TGSI_OPCODE_KILL].intr_name = "llvm.AMDGPU.kilp"; + bld_base->op_actions[TGSI_OPCODE_LSB].emit = emit_lsb; bld_base->op_actions[TGSI_OPCODE_LG2].emit = build_tgsi_intrinsic_nomem; bld_base->op_actions[TGSI_OPCODE_LG2].intr_name = "llvm.log2.f32"; bld_base->op_actions[TGSI_OPCODE_LRP].emit = build_tgsi_intrinsic_nomem; bld_base->op_actions[TGSI_OPCODE_LRP].intr_name = "llvm.AMDGPU.lrp"; bld_base->op_actions[TGSI_OPCODE_MOD].emit = emit_mod; + bld_base->op_actions[TGSI_OPCODE_UMSB].emit = emit_umsb; bld_base->op_actions[TGSI_OPCODE_NOT].emit = emit_not; bld_base->op_actions[TGSI_OPCODE_OR].emit = emit_or; bld_base->op_actions[TGSI_OPCODE_POW].emit = build_tgsi_intrinsic_nomem; From mareko at kemper.freedesktop.org Mon Mar 16 11:55:50 2015 From: mareko at kemper.freedesktop.org (Marek Olšák) Date: Mon, 16 Mar 2015 04:55:50 -0700 (PDT) Subject: Mesa (master): radeonsi: simplify accessing alpha pointer in si_llvm_emit_fs_epilogue Message-ID: <20150316115550.28FB476336@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 52ff1edc5161dd7090fa55a11969c79dd4baad7d URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=52ff1edc5161dd7090fa55a11969c79dd4baad7d Author: Marek Ol??k Date: Sat Feb 28 17:16:57 2015 +0100 radeonsi: simplify accessing alpha pointer in si_llvm_emit_fs_epilogue Reviewed-by: Michel D?nzer --- src/gallium/drivers/radeonsi/si_shader.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/gallium/drivers/radeonsi/si_shader.c b/src/gallium/drivers/radeonsi/si_shader.c index e70a318..a57fdf4 100644 --- a/src/gallium/drivers/radeonsi/si_shader.c +++ b/src/gallium/drivers/radeonsi/si_shader.c @@ -794,7 +794,7 @@ static void si_llvm_init_export_args_load(struct lp_build_tgsi_context *bld_base } static void si_alpha_test(struct lp_build_tgsi_context *bld_base, - LLVMValueRef *out_ptr) + LLVMValueRef alpha_ptr) { struct si_shader_context *si_shader_ctx = si_shader_context(bld_base); struct gallivm_state *gallivm = bld_base->base.gallivm; @@ -806,7 +806,7 @@ static void si_alpha_test(struct lp_build_tgsi_context *bld_base, LLVMValueRef alpha_pass = lp_build_cmp(&bld_base->base, si_shader_ctx->shader->key.ps.alpha_func, - LLVMBuildLoad(gallivm->builder, out_ptr[3], ""), + LLVMBuildLoad(gallivm->builder, alpha_ptr, ""), alpha_ref); LLVMValueRef arg = lp_build_select(&bld_base->base, @@ -1337,6 +1337,7 @@ static void si_llvm_emit_fs_epilogue(struct lp_build_tgsi_context * bld_base) unsigned semantic_name = info->output_semantic_name[i]; unsigned semantic_index = info->output_semantic_index[i]; unsigned target; + LLVMValueRef alpha_ptr; /* Select the correct target */ switch (semantic_name) { @@ -1351,15 +1352,15 @@ static void si_llvm_emit_fs_epilogue(struct lp_build_tgsi_context * bld_base) continue; case TGSI_SEMANTIC_COLOR: target = V_008DFC_SQ_EXP_MRT + semantic_index; + alpha_ptr = si_shader_ctx->radeon_bld.soa.outputs[i][3]; + if (si_shader_ctx->shader->key.ps.alpha_to_one) - LLVMBuildStore(bld_base->base.gallivm->builder, - bld_base->base.one, - si_shader_ctx->radeon_bld.soa.outputs[i][3]); + LLVMBuildStore(base->gallivm->builder, + base->one, alpha_ptr); if (semantic_index == 0 && si_shader_ctx->shader->key.ps.alpha_func != PIPE_FUNC_ALWAYS) - si_alpha_test(bld_base, - si_shader_ctx->radeon_bld.soa.outputs[i]); + si_alpha_test(bld_base, alpha_ptr); break; default: target = 0; From mareko at kemper.freedesktop.org Mon Mar 16 11:55:50 2015 From: mareko at kemper.freedesktop.org (Marek Olšák) Date: Mon, 16 Mar 2015 04:55:50 -0700 (PDT) Subject: Mesa (master): radeonsi: small cleanup in si_shader_selector_key Message-ID: <20150316115550.3564276336@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 1921fa430452304e42059e36b654d9d446371526 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=1921fa430452304e42059e36b654d9d446371526 Author: Marek Ol??k Date: Sat Feb 28 17:22:54 2015 +0100 radeonsi: small cleanup in si_shader_selector_key Reviewed-by: Michel D?nzer --- src/gallium/drivers/radeonsi/si_state_shaders.c | 24 +++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/gallium/drivers/radeonsi/si_state_shaders.c b/src/gallium/drivers/radeonsi/si_state_shaders.c index 0a2ff2a..8c3bdc5 100644 --- a/src/gallium/drivers/radeonsi/si_state_shaders.c +++ b/src/gallium/drivers/radeonsi/si_state_shaders.c @@ -366,33 +366,33 @@ static INLINE void si_shader_selector_key(struct pipe_context *ctx, key->vs.gs_used_inputs = sctx->gs_shader->gs_used_inputs; } } else if (sel->type == PIPE_SHADER_FRAGMENT) { + struct si_state_rasterizer *rs = sctx->queued.named.rasterizer; + if (sel->info.properties[TGSI_PROPERTY_FS_COLOR0_WRITES_ALL_CBUFS]) key->ps.last_cbuf = MAX2(sctx->framebuffer.state.nr_cbufs, 1) - 1; key->ps.export_16bpc = sctx->framebuffer.export_16bpc; - if (sctx->queued.named.rasterizer) { - key->ps.color_two_side = sctx->queued.named.rasterizer->two_side; + if (rs) { + key->ps.color_two_side = rs->two_side; if (sctx->queued.named.blend) { key->ps.alpha_to_one = sctx->queued.named.blend->alpha_to_one && - sctx->queued.named.rasterizer->multisample_enable && + rs->multisample_enable && !sctx->framebuffer.cb0_is_integer; } - key->ps.poly_stipple = sctx->queued.named.rasterizer->poly_stipple_enable && + key->ps.poly_stipple = rs->poly_stipple_enable && ((sctx->current_rast_prim >= PIPE_PRIM_TRIANGLES && sctx->current_rast_prim <= PIPE_PRIM_POLYGON) || sctx->current_rast_prim >= PIPE_PRIM_TRIANGLES_ADJACENCY); } - if (sctx->queued.named.dsa) { - key->ps.alpha_func = sctx->queued.named.dsa->alpha_func; - /* Alpha-test should be disabled if colorbuffer 0 is integer. */ - if (sctx->framebuffer.cb0_is_integer) - key->ps.alpha_func = PIPE_FUNC_ALWAYS; - } else { - key->ps.alpha_func = PIPE_FUNC_ALWAYS; - } + key->ps.alpha_func = PIPE_FUNC_ALWAYS; + + /* Alpha-test should be disabled if colorbuffer 0 is integer. */ + if (sctx->queued.named.dsa && + !sctx->framebuffer.cb0_is_integer) + key->ps.alpha_func = sctx->queued.named.dsa->alpha_func; } } From mareko at kemper.freedesktop.org Mon Mar 16 11:55:50 2015 From: mareko at kemper.freedesktop.org (Marek Olšák) Date: Mon, 16 Mar 2015 04:55:50 -0700 (PDT) Subject: Mesa (master): radeonsi: add basic code for overrasterization Message-ID: <20150316115550.4477676336@kemper.freedesktop.org> Module: Mesa Branch: master Commit: f7796a966d20b04c00025bdc170883f4179a5697 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=f7796a966d20b04c00025bdc170883f4179a5697 Author: Marek Ol??k Date: Sun Mar 15 17:14:53 2015 +0100 radeonsi: add basic code for overrasterization This will be used for line and polygon smoothing. This is GCN-only even though it's in shared code. Reviewed-by: Michel D?nzer --- src/gallium/drivers/r600/evergreen_state.c | 2 +- src/gallium/drivers/radeon/cayman_msaa.c | 36 ++++++++++++++++--------- src/gallium/drivers/radeon/r600_pipe_common.h | 2 +- src/gallium/drivers/radeon/r600d_common.h | 2 ++ src/gallium/drivers/radeonsi/si_state.c | 2 +- 5 files changed, 28 insertions(+), 16 deletions(-) diff --git a/src/gallium/drivers/r600/evergreen_state.c b/src/gallium/drivers/r600/evergreen_state.c index f0b04f0..edd886b 100644 --- a/src/gallium/drivers/r600/evergreen_state.c +++ b/src/gallium/drivers/r600/evergreen_state.c @@ -1692,7 +1692,7 @@ static void evergreen_emit_framebuffer_state(struct r600_context *rctx, struct r evergreen_emit_msaa_state(rctx, rctx->framebuffer.nr_samples, rctx->ps_iter_samples); } else { cayman_emit_msaa_sample_locs(cs, rctx->framebuffer.nr_samples); - cayman_emit_msaa_config(cs, rctx->framebuffer.nr_samples, rctx->ps_iter_samples); + cayman_emit_msaa_config(cs, rctx->framebuffer.nr_samples, rctx->ps_iter_samples, 0); } } diff --git a/src/gallium/drivers/radeon/cayman_msaa.c b/src/gallium/drivers/radeon/cayman_msaa.c index 47fc5c4..12a5f60 100644 --- a/src/gallium/drivers/radeon/cayman_msaa.c +++ b/src/gallium/drivers/radeon/cayman_msaa.c @@ -195,9 +195,12 @@ void cayman_emit_msaa_sample_locs(struct radeon_winsys_cs *cs, int nr_samples) } void cayman_emit_msaa_config(struct radeon_winsys_cs *cs, int nr_samples, - int ps_iter_samples) + int ps_iter_samples, int overrast_samples) { - if (nr_samples > 1) { + int setup_samples = nr_samples > 1 ? nr_samples : + overrast_samples > 1 ? overrast_samples : 0; + + if (setup_samples > 1) { /* indexed by log2(nr_samples) */ unsigned max_dist[] = { 0, @@ -206,8 +209,7 @@ void cayman_emit_msaa_config(struct radeon_winsys_cs *cs, int nr_samples, cm_max_dist_8x, cm_max_dist_16x }; - - unsigned log_samples = util_logbase2(nr_samples); + unsigned log_samples = util_logbase2(setup_samples); unsigned log_ps_iter_samples = util_logbase2(util_next_power_of_two(ps_iter_samples)); @@ -218,15 +220,23 @@ void cayman_emit_msaa_config(struct radeon_winsys_cs *cs, int nr_samples, S_028BE0_MAX_SAMPLE_DIST(max_dist[log_samples]) | S_028BE0_MSAA_EXPOSED_SAMPLES(log_samples)); /* CM_R_028BE0_PA_SC_AA_CONFIG */ - r600_write_context_reg(cs, CM_R_028804_DB_EQAA, - S_028804_MAX_ANCHOR_SAMPLES(log_samples) | - S_028804_PS_ITER_SAMPLES(log_ps_iter_samples) | - S_028804_MASK_EXPORT_NUM_SAMPLES(log_samples) | - S_028804_ALPHA_TO_MASK_NUM_SAMPLES(log_samples) | - S_028804_HIGH_QUALITY_INTERSECTIONS(1) | - S_028804_STATIC_ANCHOR_ASSOCIATIONS(1)); - r600_write_context_reg(cs, EG_R_028A4C_PA_SC_MODE_CNTL_1, - EG_S_028A4C_PS_ITER_SAMPLE(ps_iter_samples > 1)); + if (nr_samples > 1) { + r600_write_context_reg(cs, CM_R_028804_DB_EQAA, + S_028804_MAX_ANCHOR_SAMPLES(log_samples) | + S_028804_PS_ITER_SAMPLES(log_ps_iter_samples) | + S_028804_MASK_EXPORT_NUM_SAMPLES(log_samples) | + S_028804_ALPHA_TO_MASK_NUM_SAMPLES(log_samples) | + S_028804_HIGH_QUALITY_INTERSECTIONS(1) | + S_028804_STATIC_ANCHOR_ASSOCIATIONS(1)); + r600_write_context_reg(cs, EG_R_028A4C_PA_SC_MODE_CNTL_1, + EG_S_028A4C_PS_ITER_SAMPLE(ps_iter_samples > 1)); + } else if (overrast_samples > 1) { + r600_write_context_reg(cs, CM_R_028804_DB_EQAA, + S_028804_HIGH_QUALITY_INTERSECTIONS(1) | + S_028804_STATIC_ANCHOR_ASSOCIATIONS(1) | + S_028804_OVERRASTERIZATION_AMOUNT(log_samples)); + r600_write_context_reg(cs, EG_R_028A4C_PA_SC_MODE_CNTL_1, 0); + } } else { r600_write_context_reg_seq(cs, CM_R_028BDC_PA_SC_LINE_CNTL, 2); radeon_emit(cs, S_028BDC_LAST_PIXEL(1)); /* CM_R_028BDC_PA_SC_LINE_CNTL */ diff --git a/src/gallium/drivers/radeon/r600_pipe_common.h b/src/gallium/drivers/radeon/r600_pipe_common.h index 43efaa3..a08d08c 100644 --- a/src/gallium/drivers/radeon/r600_pipe_common.h +++ b/src/gallium/drivers/radeon/r600_pipe_common.h @@ -526,7 +526,7 @@ void cayman_get_sample_position(struct pipe_context *ctx, unsigned sample_count, void cayman_init_msaa(struct pipe_context *ctx); void cayman_emit_msaa_sample_locs(struct radeon_winsys_cs *cs, int nr_samples); void cayman_emit_msaa_config(struct radeon_winsys_cs *cs, int nr_samples, - int ps_iter_samples); + int ps_iter_samples, int overrast_samples); /* Inline helpers. */ diff --git a/src/gallium/drivers/radeon/r600d_common.h b/src/gallium/drivers/radeon/r600d_common.h index ba29fd0..74c8d87 100644 --- a/src/gallium/drivers/radeon/r600d_common.h +++ b/src/gallium/drivers/radeon/r600d_common.h @@ -177,6 +177,8 @@ #define S_028804_INTERPOLATE_SRC_Z(x) (((x) & 0x1) << 19) #define S_028804_STATIC_ANCHOR_ASSOCIATIONS(x) (((x) & 0x1) << 20) #define S_028804_ALPHA_TO_MASK_EQAA_DISABLE(x) (((x) & 0x1) << 21) +#define S_028804_OVERRASTERIZATION_AMOUNT(x) (((x) & 0x7) << 24) +#define S_028804_ENABLE_POSTZ_OVERRASTERIZATION(x) (((x) & 0x1) << 27) #define CM_R_028BDC_PA_SC_LINE_CNTL 0x28bdc #define S_028BDC_EXPAND_LINE_WIDTH(x) (((x) & 0x1) << 9) #define G_028BDC_EXPAND_LINE_WIDTH(x) (((x) >> 9) & 0x1) diff --git a/src/gallium/drivers/radeonsi/si_state.c b/src/gallium/drivers/radeonsi/si_state.c index 5de31c0..b20042c 100644 --- a/src/gallium/drivers/radeonsi/si_state.c +++ b/src/gallium/drivers/radeonsi/si_state.c @@ -2206,7 +2206,7 @@ static void si_emit_msaa_config(struct r600_common_context *rctx, struct r600_at struct radeon_winsys_cs *cs = sctx->b.rings.gfx.cs; cayman_emit_msaa_config(cs, sctx->framebuffer.nr_samples, - sctx->ps_iter_samples); + sctx->ps_iter_samples, 0); } const struct r600_atom si_atom_msaa_config = { si_emit_msaa_config, 10 }; /* number of CS dwords */ From mareko at kemper.freedesktop.org Mon Mar 16 11:55:50 2015 From: mareko at kemper.freedesktop.org (Marek Olšák) Date: Mon, 16 Mar 2015 04:55:50 -0700 (PDT) Subject: Mesa (master): radeonsi: split sample locations into its own state atom Message-ID: <20150316115550.516BF76336@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 4f20a8f278aa92fb0dc6abc6998171b3ddea7dc1 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=4f20a8f278aa92fb0dc6abc6998171b3ddea7dc1 Author: Marek Ol??k Date: Sun Mar 15 17:54:29 2015 +0100 radeonsi: split sample locations into its own state atom Sample locations are not updated as often as framebuffers. Reviewed-by: Michel D?nzer --- src/gallium/drivers/radeonsi/si_hw_context.c | 1 + src/gallium/drivers/radeonsi/si_pipe.c | 3 +++ src/gallium/drivers/radeonsi/si_pipe.h | 2 ++ src/gallium/drivers/radeonsi/si_state.c | 11 +++++++++++ src/gallium/drivers/radeonsi/si_state.h | 1 + 5 files changed, 18 insertions(+) diff --git a/src/gallium/drivers/radeonsi/si_hw_context.c b/src/gallium/drivers/radeonsi/si_hw_context.c index 1cacc26..30bf41f 100644 --- a/src/gallium/drivers/radeonsi/si_hw_context.c +++ b/src/gallium/drivers/radeonsi/si_hw_context.c @@ -145,6 +145,7 @@ void si_begin_new_cs(struct si_context *ctx) ctx->clip_regs.dirty = true; ctx->framebuffer.atom.dirty = true; + ctx->msaa_sample_locs.dirty = true; ctx->msaa_config.dirty = true; ctx->db_render_state.dirty = true; ctx->b.streamout.enable_atom.dirty = true; diff --git a/src/gallium/drivers/radeonsi/si_pipe.c b/src/gallium/drivers/radeonsi/si_pipe.c index 993b153..8b4246c 100644 --- a/src/gallium/drivers/radeonsi/si_pipe.c +++ b/src/gallium/drivers/radeonsi/si_pipe.c @@ -112,6 +112,9 @@ static struct pipe_context *si_create_context(struct pipe_screen *screen, void * sctx->cache_flush = si_atom_cache_flush; sctx->atoms.s.cache_flush = &sctx->cache_flush; + sctx->msaa_sample_locs = si_atom_msaa_sample_locs; + sctx->atoms.s.msaa_sample_locs = &sctx->msaa_sample_locs; + sctx->msaa_config = si_atom_msaa_config; sctx->atoms.s.msaa_config = &sctx->msaa_config; diff --git a/src/gallium/drivers/radeonsi/si_pipe.h b/src/gallium/drivers/radeonsi/si_pipe.h index 059fe0d..1496d5f 100644 --- a/src/gallium/drivers/radeonsi/si_pipe.h +++ b/src/gallium/drivers/radeonsi/si_pipe.h @@ -151,6 +151,7 @@ struct si_context { struct r600_atom *streamout_begin; struct r600_atom *streamout_enable; /* must be after streamout_begin */ struct r600_atom *framebuffer; + struct r600_atom *msaa_sample_locs; struct r600_atom *db_render_state; struct r600_atom *msaa_config; struct r600_atom *clip_regs; @@ -181,6 +182,7 @@ struct si_context { unsigned border_color_offset; struct r600_atom clip_regs; + struct r600_atom msaa_sample_locs; struct r600_atom msaa_config; int ps_iter_samples; diff --git a/src/gallium/drivers/radeonsi/si_state.c b/src/gallium/drivers/radeonsi/si_state.c index b20042c..f844fc1 100644 --- a/src/gallium/drivers/radeonsi/si_state.c +++ b/src/gallium/drivers/radeonsi/si_state.c @@ -2093,6 +2093,8 @@ static void si_set_framebuffer_state(struct pipe_context *ctx, constbuf.buffer_size = sctx->framebuffer.nr_samples * 2 * 4; ctx->set_constant_buffer(ctx, PIPE_SHADER_FRAGMENT, SI_DRIVER_STATE_CONST_BUF, &constbuf); + + sctx->msaa_sample_locs.dirty = true; } } @@ -2196,10 +2198,19 @@ static void si_emit_framebuffer_state(struct si_context *sctx, struct r600_atom /* PA_SC_WINDOW_SCISSOR_TL is set in si_init_config() */ r600_write_context_reg(cs, R_028208_PA_SC_WINDOW_SCISSOR_BR, S_028208_BR_X(state->width) | S_028208_BR_Y(state->height)); +} + +static void si_emit_msaa_sample_locs(struct r600_common_context *rctx, + struct r600_atom *atom) +{ + struct si_context *sctx = (struct si_context *)rctx; + struct radeon_winsys_cs *cs = sctx->b.rings.gfx.cs; cayman_emit_msaa_sample_locs(cs, sctx->framebuffer.nr_samples); } +const struct r600_atom si_atom_msaa_sample_locs = { si_emit_msaa_sample_locs, 18 }; /* number of CS dwords */ + static void si_emit_msaa_config(struct r600_common_context *rctx, struct r600_atom *atom) { struct si_context *sctx = (struct si_context *)rctx; diff --git a/src/gallium/drivers/radeonsi/si_state.h b/src/gallium/drivers/radeonsi/si_state.h index d1ed530..4e6b1e2 100644 --- a/src/gallium/drivers/radeonsi/si_state.h +++ b/src/gallium/drivers/radeonsi/si_state.h @@ -269,6 +269,7 @@ void si_init_shader_functions(struct si_context *sctx); /* si_state_draw.c */ extern const struct r600_atom si_atom_cache_flush; +extern const struct r600_atom si_atom_msaa_sample_locs; extern const struct r600_atom si_atom_msaa_config; void si_emit_cache_flush(struct r600_common_context *sctx, struct r600_atom *atom); void si_draw_vbo(struct pipe_context *ctx, const struct pipe_draw_info *dinfo); From mareko at kemper.freedesktop.org Mon Mar 16 11:55:50 2015 From: mareko at kemper.freedesktop.org (Marek Olšák) Date: Mon, 16 Mar 2015 04:55:50 -0700 (PDT) Subject: Mesa (master): radeonsi: implement line and polygon smoothing Message-ID: <20150316115550.6909F76336@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 98a23982227dce29b015dcb5a867d05f2bee4388 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=98a23982227dce29b015dcb5a867d05f2bee4388 Author: Marek Ol??k Date: Sun Mar 15 18:20:19 2015 +0100 radeonsi: implement line and polygon smoothing Reviewed-by: Michel D?nzer --- src/gallium/drivers/radeonsi/si_pipe.h | 1 + src/gallium/drivers/radeonsi/si_state.c | 35 +++++++++++++++++++---- src/gallium/drivers/radeonsi/si_state.h | 2 ++ src/gallium/drivers/radeonsi/si_state_shaders.c | 21 +++++++++++--- 4 files changed, 49 insertions(+), 10 deletions(-) diff --git a/src/gallium/drivers/radeonsi/si_pipe.h b/src/gallium/drivers/radeonsi/si_pipe.h index 1bc664a..7c37a3e 100644 --- a/src/gallium/drivers/radeonsi/si_pipe.h +++ b/src/gallium/drivers/radeonsi/si_pipe.h @@ -186,6 +186,7 @@ struct si_context { struct r600_atom msaa_sample_locs; struct r600_atom msaa_config; int ps_iter_samples; + bool smoothing_enabled; /* Vertex and index buffers. */ bool vertex_buffers_dirty; diff --git a/src/gallium/drivers/radeonsi/si_state.c b/src/gallium/drivers/radeonsi/si_state.c index f844fc1..c7633dc 100644 --- a/src/gallium/drivers/radeonsi/si_state.c +++ b/src/gallium/drivers/radeonsi/si_state.c @@ -617,6 +617,8 @@ static void *si_create_rs_state(struct pipe_context *ctx, rs->clip_plane_enable = state->clip_plane_enable; rs->line_stipple_enable = state->line_stipple_enable; rs->poly_stipple_enable = state->poly_stipple_enable; + rs->line_smooth = state->line_smooth; + rs->poly_smooth = state->poly_smooth; polygon_dual_mode = (state->fill_front != PIPE_POLYGON_MODE_FILL || state->fill_back != PIPE_POLYGON_MODE_FILL); @@ -686,7 +688,9 @@ static void *si_create_rs_state(struct pipe_context *ctx, si_pm4_set_reg(pm4, R_028A08_PA_SU_LINE_CNTL, S_028A08_WIDTH(tmp)); si_pm4_set_reg(pm4, R_028A48_PA_SC_MODE_CNTL_0, S_028A48_LINE_STIPPLE_ENABLE(state->line_stipple_enable) | - S_028A48_MSAA_ENABLE(state->multisample) | + S_028A48_MSAA_ENABLE(state->multisample || + state->poly_smooth || + state->line_smooth) | S_028A48_VPORT_SCISSOR_ENABLE(state->scissor)); si_pm4_set_reg(pm4, R_028BE4_PA_SU_VTX_CNTL, @@ -945,10 +949,15 @@ static void si_emit_db_render_state(struct si_context *sctx, struct r600_atom *s r600_write_context_reg(cs, R_028010_DB_RENDER_OVERRIDE2, 0); } - db_shader_control = S_02880C_Z_ORDER(V_02880C_EARLY_Z_THEN_LATE_Z) | - S_02880C_ALPHA_TO_MASK_DISABLE(sctx->framebuffer.cb0_is_integer) | + db_shader_control = S_02880C_ALPHA_TO_MASK_DISABLE(sctx->framebuffer.cb0_is_integer) | sctx->ps_db_shader_control; + /* Bug workaround for smoothing (overrasterization) on SI. */ + if (sctx->b.chip_class == SI && sctx->smoothing_enabled) + db_shader_control |= S_02880C_Z_ORDER(V_02880C_LATE_Z); + else + db_shader_control |= S_02880C_Z_ORDER(V_02880C_EARLY_Z_THEN_LATE_Z); + /* Disable the gl_SampleMask fragment shader output if MSAA is disabled. */ if (sctx->framebuffer.nr_samples <= 1 || (rs && !rs->multisample_enable)) db_shader_control &= C_02880C_MASK_EXPORT_ENABLE; @@ -2094,7 +2103,18 @@ static void si_set_framebuffer_state(struct pipe_context *ctx, ctx->set_constant_buffer(ctx, PIPE_SHADER_FRAGMENT, SI_DRIVER_STATE_CONST_BUF, &constbuf); - sctx->msaa_sample_locs.dirty = true; + /* Smoothing (only possible with nr_samples == 1) uses the same + * sample locations as the MSAA it simulates. + * + * Therefore, don't update the sample locations when + * transitioning from no AA to smoothing-equivalent AA, and + * vice versa. + */ + if ((sctx->framebuffer.nr_samples != 1 || + old_nr_samples != SI_NUM_SMOOTH_AA_SAMPLES) && + (sctx->framebuffer.nr_samples != SI_NUM_SMOOTH_AA_SAMPLES || + old_nr_samples != 1)) + sctx->msaa_sample_locs.dirty = true; } } @@ -2205,8 +2225,10 @@ static void si_emit_msaa_sample_locs(struct r600_common_context *rctx, { struct si_context *sctx = (struct si_context *)rctx; struct radeon_winsys_cs *cs = sctx->b.rings.gfx.cs; + unsigned nr_samples = sctx->framebuffer.nr_samples; - cayman_emit_msaa_sample_locs(cs, sctx->framebuffer.nr_samples); + cayman_emit_msaa_sample_locs(cs, nr_samples > 1 ? nr_samples : + SI_NUM_SMOOTH_AA_SAMPLES); } const struct r600_atom si_atom_msaa_sample_locs = { si_emit_msaa_sample_locs, 18 }; /* number of CS dwords */ @@ -2217,7 +2239,8 @@ static void si_emit_msaa_config(struct r600_common_context *rctx, struct r600_at struct radeon_winsys_cs *cs = sctx->b.rings.gfx.cs; cayman_emit_msaa_config(cs, sctx->framebuffer.nr_samples, - sctx->ps_iter_samples, 0); + sctx->ps_iter_samples, + sctx->smoothing_enabled ? SI_NUM_SMOOTH_AA_SAMPLES : 0); } const struct r600_atom si_atom_msaa_config = { si_emit_msaa_config, 10 }; /* number of CS dwords */ diff --git a/src/gallium/drivers/radeonsi/si_state.h b/src/gallium/drivers/radeonsi/si_state.h index 4e6b1e2..27dd2c3 100644 --- a/src/gallium/drivers/radeonsi/si_state.h +++ b/src/gallium/drivers/radeonsi/si_state.h @@ -68,6 +68,8 @@ struct si_state_rasterizer { float offset_units; float offset_scale; bool poly_stipple_enable; + bool line_smooth; + bool poly_smooth; }; struct si_state_dsa { diff --git a/src/gallium/drivers/radeonsi/si_state_shaders.c b/src/gallium/drivers/radeonsi/si_state_shaders.c index 8c3bdc5..382738a 100644 --- a/src/gallium/drivers/radeonsi/si_state_shaders.c +++ b/src/gallium/drivers/radeonsi/si_state_shaders.c @@ -373,6 +373,11 @@ static INLINE void si_shader_selector_key(struct pipe_context *ctx, key->ps.export_16bpc = sctx->framebuffer.export_16bpc; if (rs) { + bool is_poly = (sctx->current_rast_prim >= PIPE_PRIM_TRIANGLES && + sctx->current_rast_prim <= PIPE_PRIM_POLYGON) || + sctx->current_rast_prim >= PIPE_PRIM_TRIANGLES_ADJACENCY; + bool is_line = !is_poly && sctx->current_rast_prim != PIPE_PRIM_POINTS; + key->ps.color_two_side = rs->two_side; if (sctx->queued.named.blend) { @@ -381,10 +386,10 @@ static INLINE void si_shader_selector_key(struct pipe_context *ctx, !sctx->framebuffer.cb0_is_integer; } - key->ps.poly_stipple = rs->poly_stipple_enable && - ((sctx->current_rast_prim >= PIPE_PRIM_TRIANGLES && - sctx->current_rast_prim <= PIPE_PRIM_POLYGON) || - sctx->current_rast_prim >= PIPE_PRIM_TRIANGLES_ADJACENCY); + key->ps.poly_stipple = rs->poly_stipple_enable && is_poly; + key->ps.poly_line_smoothing = ((is_poly && rs->poly_smooth) || + (is_line && rs->line_smooth)) && + sctx->framebuffer.nr_samples <= 1; } key->ps.alpha_func = PIPE_FUNC_ALWAYS; @@ -921,6 +926,14 @@ void si_update_shaders(struct si_context *sctx) sctx->ps_db_shader_control = sctx->ps_shader->current->db_shader_control; sctx->db_render_state.dirty = true; } + + if (sctx->smoothing_enabled != sctx->ps_shader->current->key.ps.poly_line_smoothing) { + sctx->smoothing_enabled = sctx->ps_shader->current->key.ps.poly_line_smoothing; + sctx->msaa_config.dirty = true; + + if (sctx->b.chip_class == SI) + sctx->db_render_state.dirty = true; + } } void si_init_shader_functions(struct si_context *sctx) From mareko at kemper.freedesktop.org Mon Mar 16 11:55:50 2015 From: mareko at kemper.freedesktop.org (Marek Olšák) Date: Mon, 16 Mar 2015 04:55:50 -0700 (PDT) Subject: Mesa (master): radeonsi: move PA_SU_SC_MODE_CNTL to rasterizer state Message-ID: <20150316115550.75EB576336@kemper.freedesktop.org> Module: Mesa Branch: master Commit: f5832f3f9dd0ac0b401d351acab19425fe3c1187 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=f5832f3f9dd0ac0b401d351acab19425fe3c1187 Author: Marek Ol??k Date: Sun Mar 15 18:53:50 2015 +0100 radeonsi: move PA_SU_SC_MODE_CNTL to rasterizer state This requires enabling the optional GL provoking vertex behavior for quads. + some cosmetic changes, so that the register is set exactly the same as on r600. Reviewed-by: Michel D?nzer --- src/gallium/drivers/radeonsi/si_pipe.c | 2 +- src/gallium/drivers/radeonsi/si_pipe.h | 3 +-- src/gallium/drivers/radeonsi/si_state.c | 32 ++++++++++---------------- src/gallium/drivers/radeonsi/si_state.h | 1 - src/gallium/drivers/radeonsi/si_state_draw.c | 6 ----- 5 files changed, 14 insertions(+), 30 deletions(-) diff --git a/src/gallium/drivers/radeonsi/si_pipe.c b/src/gallium/drivers/radeonsi/si_pipe.c index 8b4246c..d335bda 100644 --- a/src/gallium/drivers/radeonsi/si_pipe.c +++ b/src/gallium/drivers/radeonsi/si_pipe.c @@ -233,6 +233,7 @@ static int si_get_param(struct pipe_screen* pscreen, enum pipe_cap param) case PIPE_CAP_TGSI_VS_WINDOW_SPACE_POSITION: case PIPE_CAP_POLYGON_OFFSET_CLAMP: case PIPE_CAP_MULTISAMPLE_Z_RESOLVE: + case PIPE_CAP_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION: return 1; case PIPE_CAP_RESOURCE_FROM_USER_MEMORY: @@ -267,7 +268,6 @@ static int si_get_param(struct pipe_screen* pscreen, enum pipe_cap param) case PIPE_CAP_TGSI_CAN_COMPACT_CONSTANTS: case PIPE_CAP_FRAGMENT_COLOR_CLAMPED: case PIPE_CAP_VERTEX_COLOR_CLAMPED: - case PIPE_CAP_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION: case PIPE_CAP_USER_VERTEX_BUFFERS: case PIPE_CAP_TGSI_TEXCOORD: case PIPE_CAP_FAKE_SW_MSAA: diff --git a/src/gallium/drivers/radeonsi/si_pipe.h b/src/gallium/drivers/radeonsi/si_pipe.h index 7c37a3e..8cfaf70 100644 --- a/src/gallium/drivers/radeonsi/si_pipe.h +++ b/src/gallium/drivers/radeonsi/si_pipe.h @@ -47,7 +47,7 @@ #define SI_TRACE_CS_DWORDS 6 #define SI_MAX_DRAW_CS_DWORDS \ - (/*derived prim state:*/ 6 + /*draw regs:*/ 16 + /*draw packets:*/ 31) + (/*derived prim state:*/ 3 + /*draw regs:*/ 16 + /*draw packets:*/ 31) /* Instruction cache. */ #define SI_CONTEXT_INV_ICACHE (R600_CONTEXT_PRIVATE_FLAG << 0) @@ -163,7 +163,6 @@ struct si_context { struct si_framebuffer framebuffer; struct si_vertex_element *vertex_elements; unsigned pa_sc_line_stipple; - unsigned pa_su_sc_mode_cntl; /* for saving when using blitter */ struct pipe_stencil_ref stencil_ref; /* shaders */ diff --git a/src/gallium/drivers/radeonsi/si_state.c b/src/gallium/drivers/radeonsi/si_state.c index c7633dc..e3e6fa4 100644 --- a/src/gallium/drivers/radeonsi/si_state.c +++ b/src/gallium/drivers/radeonsi/si_state.c @@ -605,7 +605,6 @@ static void *si_create_rs_state(struct pipe_context *ctx, struct si_state_rasterizer *rs = CALLOC_STRUCT(si_state_rasterizer); struct si_pm4_state *pm4 = &rs->pm4; unsigned tmp; - unsigned prov_vtx = 1, polygon_dual_mode; float psize_min, psize_max; if (rs == NULL) { @@ -620,28 +619,11 @@ static void *si_create_rs_state(struct pipe_context *ctx, rs->line_smooth = state->line_smooth; rs->poly_smooth = state->poly_smooth; - polygon_dual_mode = (state->fill_front != PIPE_POLYGON_MODE_FILL || - state->fill_back != PIPE_POLYGON_MODE_FILL); - - if (state->flatshade_first) - prov_vtx = 0; - rs->flatshade = state->flatshade; rs->sprite_coord_enable = state->sprite_coord_enable; rs->pa_sc_line_stipple = state->line_stipple_enable ? S_028A0C_LINE_PATTERN(state->line_stipple_pattern) | S_028A0C_REPEAT_COUNT(state->line_stipple_factor) : 0; - rs->pa_su_sc_mode_cntl = - S_028814_PROVOKING_VTX_LAST(prov_vtx) | - S_028814_CULL_FRONT(state->rasterizer_discard || (state->cull_face & PIPE_FACE_FRONT) ? 1 : 0) | - S_028814_CULL_BACK(state->rasterizer_discard || (state->cull_face & PIPE_FACE_BACK) ? 1 : 0) | - S_028814_FACE(!state->front_ccw) | - S_028814_POLY_OFFSET_FRONT_ENABLE(util_get_offset(state, state->fill_front)) | - S_028814_POLY_OFFSET_BACK_ENABLE(util_get_offset(state, state->fill_back)) | - S_028814_POLY_OFFSET_PARA_ENABLE(state->offset_point || state->offset_line) | - S_028814_POLY_MODE(polygon_dual_mode) | - S_028814_POLYMODE_FRONT_PTYPE(si_translate_fill(state->fill_front)) | - S_028814_POLYMODE_BACK_PTYPE(si_translate_fill(state->fill_back)); rs->pa_cl_clip_cntl = S_028810_PS_UCP_MODE(3) | S_028810_DX_CLIP_SPACE_DEF(state->clip_halfz) | @@ -698,7 +680,18 @@ static void *si_create_rs_state(struct pipe_context *ctx, S_028BE4_QUANT_MODE(V_028BE4_X_16_8_FIXED_POINT_1_256TH)); si_pm4_set_reg(pm4, R_028B7C_PA_SU_POLY_OFFSET_CLAMP, fui(state->offset_clamp)); - + si_pm4_set_reg(pm4, R_028814_PA_SU_SC_MODE_CNTL, + S_028814_PROVOKING_VTX_LAST(!state->flatshade_first) | + S_028814_CULL_FRONT((state->cull_face & PIPE_FACE_FRONT) ? 1 : 0) | + S_028814_CULL_BACK((state->cull_face & PIPE_FACE_BACK) ? 1 : 0) | + S_028814_FACE(!state->front_ccw) | + S_028814_POLY_OFFSET_FRONT_ENABLE(util_get_offset(state, state->fill_front)) | + S_028814_POLY_OFFSET_BACK_ENABLE(util_get_offset(state, state->fill_back)) | + S_028814_POLY_OFFSET_PARA_ENABLE(state->offset_point || state->offset_line) | + S_028814_POLY_MODE(state->fill_front != PIPE_POLYGON_MODE_FILL || + state->fill_back != PIPE_POLYGON_MODE_FILL) | + S_028814_POLYMODE_FRONT_PTYPE(si_translate_fill(state->fill_front)) | + S_028814_POLYMODE_BACK_PTYPE(si_translate_fill(state->fill_back))); return rs; } @@ -714,7 +707,6 @@ static void si_bind_rs_state(struct pipe_context *ctx, void *state) // TODO sctx->pa_sc_line_stipple = rs->pa_sc_line_stipple; - sctx->pa_su_sc_mode_cntl = rs->pa_su_sc_mode_cntl; if (sctx->framebuffer.nr_samples > 1 && (!old_rs || old_rs->multisample_enable != rs->multisample_enable)) diff --git a/src/gallium/drivers/radeonsi/si_state.h b/src/gallium/drivers/radeonsi/si_state.h index 27dd2c3..2f8a943 100644 --- a/src/gallium/drivers/radeonsi/si_state.h +++ b/src/gallium/drivers/radeonsi/si_state.h @@ -62,7 +62,6 @@ struct si_state_rasterizer { bool line_stipple_enable; unsigned sprite_coord_enable; unsigned pa_sc_line_stipple; - unsigned pa_su_sc_mode_cntl; unsigned pa_cl_clip_cntl; unsigned clip_plane_enable; float offset_units; diff --git a/src/gallium/drivers/radeonsi/si_state_draw.c b/src/gallium/drivers/radeonsi/si_state_draw.c index eb2d015..b68e493 100644 --- a/src/gallium/drivers/radeonsi/si_state_draw.c +++ b/src/gallium/drivers/radeonsi/si_state_draw.c @@ -163,12 +163,6 @@ static void si_emit_rasterizer_prim_state(struct si_context *sctx) S_028A0C_AUTO_RESET_CNTL(rast_prim == PIPE_PRIM_LINES ? 1 : rast_prim == PIPE_PRIM_LINE_STRIP ? 2 : 0)); - r600_write_context_reg(cs, R_028814_PA_SU_SC_MODE_CNTL, - sctx->pa_su_sc_mode_cntl | - S_028814_PROVOKING_VTX_LAST(rast_prim == PIPE_PRIM_QUADS || - rast_prim == PIPE_PRIM_QUAD_STRIP || - rast_prim == PIPE_PRIM_POLYGON)); - sctx->last_rast_prim = rast_prim; } From mareko at kemper.freedesktop.org Mon Mar 16 11:55:50 2015 From: mareko at kemper.freedesktop.org (Marek Olšák) Date: Mon, 16 Mar 2015 04:55:50 -0700 (PDT) Subject: Mesa (master): radeonsi: don' t emit PA_SC_LINE_STIPPLE after every rasterizer state change Message-ID: <20150316115550.828D676336@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 1f4bb3826464e2ce1d3f47183c96e6e7fde9a1d7 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=1f4bb3826464e2ce1d3f47183c96e6e7fde9a1d7 Author: Marek Ol??k Date: Sun Mar 15 19:21:31 2015 +0100 radeonsi: don't emit PA_SC_LINE_STIPPLE after every rasterizer state change Do it only when the line stipple state is changed. Reviewed-by: Michel D?nzer --- src/gallium/drivers/radeonsi/si_hw_context.c | 1 + src/gallium/drivers/radeonsi/si_pipe.h | 2 +- src/gallium/drivers/radeonsi/si_state.c | 4 ---- src/gallium/drivers/radeonsi/si_state_draw.c | 7 +++++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/gallium/drivers/radeonsi/si_hw_context.c b/src/gallium/drivers/radeonsi/si_hw_context.c index 30bf41f..313ced7 100644 --- a/src/gallium/drivers/radeonsi/si_hw_context.c +++ b/src/gallium/drivers/radeonsi/si_hw_context.c @@ -161,5 +161,6 @@ void si_begin_new_cs(struct si_context *ctx) ctx->last_prim = -1; ctx->last_multi_vgt_param = -1; ctx->last_rast_prim = -1; + ctx->last_sc_line_stipple = ~0; ctx->emit_scratch_reloc = true; } diff --git a/src/gallium/drivers/radeonsi/si_pipe.h b/src/gallium/drivers/radeonsi/si_pipe.h index 8cfaf70..29f01f3 100644 --- a/src/gallium/drivers/radeonsi/si_pipe.h +++ b/src/gallium/drivers/radeonsi/si_pipe.h @@ -162,7 +162,6 @@ struct si_context { struct si_framebuffer framebuffer; struct si_vertex_element *vertex_elements; - unsigned pa_sc_line_stipple; /* for saving when using blitter */ struct pipe_stencil_ref stencil_ref; /* shaders */ @@ -227,6 +226,7 @@ struct si_context { int last_prim; int last_multi_vgt_param; int last_rast_prim; + unsigned last_sc_line_stipple; int current_rast_prim; /* primitive type after TES, GS */ /* Scratch buffer */ diff --git a/src/gallium/drivers/radeonsi/si_state.c b/src/gallium/drivers/radeonsi/si_state.c index e3e6fa4..4bb6f2b 100644 --- a/src/gallium/drivers/radeonsi/si_state.c +++ b/src/gallium/drivers/radeonsi/si_state.c @@ -705,9 +705,6 @@ static void si_bind_rs_state(struct pipe_context *ctx, void *state) if (state == NULL) return; - // TODO - sctx->pa_sc_line_stipple = rs->pa_sc_line_stipple; - if (sctx->framebuffer.nr_samples > 1 && (!old_rs || old_rs->multisample_enable != rs->multisample_enable)) sctx->db_render_state.dirty = true; @@ -716,7 +713,6 @@ static void si_bind_rs_state(struct pipe_context *ctx, void *state) si_update_fb_rs_state(sctx); sctx->clip_regs.dirty = true; - sctx->last_rast_prim = -1; /* reset this so that it gets updated */ } static void si_delete_rs_state(struct pipe_context *ctx, void *state) diff --git a/src/gallium/drivers/radeonsi/si_state_draw.c b/src/gallium/drivers/radeonsi/si_state_draw.c index b68e493..7523c2a 100644 --- a/src/gallium/drivers/radeonsi/si_state_draw.c +++ b/src/gallium/drivers/radeonsi/si_state_draw.c @@ -154,16 +154,19 @@ static void si_emit_rasterizer_prim_state(struct si_context *sctx) { struct radeon_winsys_cs *cs = sctx->b.rings.gfx.cs; unsigned rast_prim = sctx->current_rast_prim; + struct si_state_rasterizer *rs = sctx->emitted.named.rasterizer; - if (rast_prim == sctx->last_rast_prim) + if (rast_prim == sctx->last_rast_prim && + rs->pa_sc_line_stipple == sctx->last_sc_line_stipple) return; r600_write_context_reg(cs, R_028A0C_PA_SC_LINE_STIPPLE, - sctx->pa_sc_line_stipple | + rs->pa_sc_line_stipple | S_028A0C_AUTO_RESET_CNTL(rast_prim == PIPE_PRIM_LINES ? 1 : rast_prim == PIPE_PRIM_LINE_STRIP ? 2 : 0)); sctx->last_rast_prim = rast_prim; + sctx->last_sc_line_stipple = rs->pa_sc_line_stipple; } static void si_emit_draw_registers(struct si_context *sctx, From mareko at kemper.freedesktop.org Mon Mar 16 11:55:50 2015 From: mareko at kemper.freedesktop.org (Marek Olšák) Date: Mon, 16 Mar 2015 04:55:50 -0700 (PDT) Subject: Mesa (master): radeonsi: move scratch reloc state setup Message-ID: <20150316115550.986E176336@kemper.freedesktop.org> Module: Mesa Branch: master Commit: dc394136404eafec689874934db0198be6182c59 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=dc394136404eafec689874934db0198be6182c59 Author: Marek Ol??k Date: Sun Mar 15 20:13:52 2015 +0100 radeonsi: move scratch reloc state setup - move it to its own function - do it after all states are emitted - bump SI_MAX_DRAW_CS_DWORDS Reviewed-by: Michel D?nzer --- src/gallium/drivers/radeonsi/si_pipe.h | 3 ++- src/gallium/drivers/radeonsi/si_state_draw.c | 34 +++++++++++++++----------- 2 files changed, 22 insertions(+), 15 deletions(-) diff --git a/src/gallium/drivers/radeonsi/si_pipe.h b/src/gallium/drivers/radeonsi/si_pipe.h index 29f01f3..422b873 100644 --- a/src/gallium/drivers/radeonsi/si_pipe.h +++ b/src/gallium/drivers/radeonsi/si_pipe.h @@ -47,7 +47,8 @@ #define SI_TRACE_CS_DWORDS 6 #define SI_MAX_DRAW_CS_DWORDS \ - (/*derived prim state:*/ 3 + /*draw regs:*/ 16 + /*draw packets:*/ 31) + (/*scratch:*/ 3 + /*derived prim state:*/ 3 + \ + /*draw regs:*/ 16 + /*draw packets:*/ 31) /* Instruction cache. */ #define SI_CONTEXT_INV_ICACHE (R600_CONTEXT_PRIVATE_FLAG << 0) diff --git a/src/gallium/drivers/radeonsi/si_state_draw.c b/src/gallium/drivers/radeonsi/si_state_draw.c index e186694..2e77d85 100644 --- a/src/gallium/drivers/radeonsi/si_state_draw.c +++ b/src/gallium/drivers/radeonsi/si_state_draw.c @@ -149,6 +149,25 @@ static unsigned si_get_ia_multi_vgt_param(struct si_context *sctx, S_028AA8_WD_SWITCH_ON_EOP(sctx->b.chip_class >= CIK ? wd_switch_on_eop : 0); } +static void si_emit_scratch_reloc(struct si_context *sctx) +{ + struct radeon_winsys_cs *cs = sctx->b.rings.gfx.cs; + + if (!sctx->emit_scratch_reloc) + return; + + r600_write_context_reg(cs, R_0286E8_SPI_TMPRING_SIZE, + sctx->spi_tmpring_size); + + if (sctx->scratch_buffer) { + r600_context_bo_reloc(&sctx->b, &sctx->b.rings.gfx, + sctx->scratch_buffer, RADEON_USAGE_READWRITE, + RADEON_PRIO_SHADER_RESOURCE_RW); + + } + sctx->emit_scratch_reloc = false; +} + /* rast_prim is the primitive type after GS. */ static void si_emit_rasterizer_prim_state(struct si_context *sctx) { @@ -575,20 +594,6 @@ void si_draw_vbo(struct pipe_context *ctx, const struct pipe_draw_info *info) if (sctx->b.flags) sctx->atoms.s.cache_flush->dirty = true; - if (sctx->emit_scratch_reloc) { - struct radeon_winsys_cs *cs = sctx->b.rings.gfx.cs; - r600_write_context_reg(cs, R_0286E8_SPI_TMPRING_SIZE, - sctx->spi_tmpring_size); - - if (sctx->scratch_buffer) { - r600_context_bo_reloc(&sctx->b, &sctx->b.rings.gfx, - sctx->scratch_buffer, RADEON_USAGE_READWRITE, - RADEON_PRIO_SHADER_RESOURCE_RW); - - } - sctx->emit_scratch_reloc = false; - } - si_need_cs_space(sctx, 0, TRUE); /* Emit states. */ @@ -600,6 +605,7 @@ void si_draw_vbo(struct pipe_context *ctx, const struct pipe_draw_info *info) } si_pm4_emit_dirty(sctx); + si_emit_scratch_reloc(sctx); si_emit_rasterizer_prim_state(sctx); si_emit_draw_registers(sctx, info); si_emit_draw_packets(sctx, info, &ib); From mareko at kemper.freedesktop.org Mon Mar 16 11:55:49 2015 From: mareko at kemper.freedesktop.org (Marek Olšák) Date: Mon, 16 Mar 2015 04:55:49 -0700 (PDT) Subject: Mesa (master): gallium/radeon: don't use LLVMReadOnlyAttribute for ALU Message-ID: <20150316115549.D8C5376336@kemper.freedesktop.org> Module: Mesa Branch: master Commit: dfea35666e8031e9565a51eda1ee98837dbd044f URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=dfea35666e8031e9565a51eda1ee98837dbd044f Author: Marek Ol??k Date: Fri Feb 27 18:39:40 2015 +0100 gallium/radeon: don't use LLVMReadOnlyAttribute for ALU None of the instructions use a pointer argument. (+ small cosmetic changes) Reviewed-by: Tom Stellard --- .../drivers/radeon/radeon_setup_tgsi_llvm.c | 25 +++++++------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c b/src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c index dce5b55..94ef675 100644 --- a/src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c +++ b/src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c @@ -1224,6 +1224,7 @@ static void build_tgsi_intrinsic( emit_data->dst_type, emit_data->args, emit_data->arg_count, attr); } + void build_tgsi_intrinsic_nomem( const struct lp_build_tgsi_action * action, @@ -1233,14 +1234,6 @@ build_tgsi_intrinsic_nomem( build_tgsi_intrinsic(action, bld_base, emit_data, LLVMReadNoneAttribute); } -static void build_tgsi_intrinsic_readonly( - const struct lp_build_tgsi_action * action, - struct lp_build_tgsi_context * bld_base, - struct lp_build_emit_data * emit_data) -{ - build_tgsi_intrinsic(action, bld_base, emit_data, LLVMReadOnlyAttribute); -} - void radeon_llvm_context_init(struct radeon_llvm_context * ctx) { struct lp_type type; @@ -1295,20 +1288,20 @@ void radeon_llvm_context_init(struct radeon_llvm_context * ctx) lp_set_default_actions(bld_base); - bld_base->op_actions[TGSI_OPCODE_ABS].emit = build_tgsi_intrinsic_readonly; + bld_base->op_actions[TGSI_OPCODE_ABS].emit = build_tgsi_intrinsic_nomem; bld_base->op_actions[TGSI_OPCODE_ABS].intr_name = "fabs"; - bld_base->op_actions[TGSI_OPCODE_ARL].emit = emit_arl; bld_base->op_actions[TGSI_OPCODE_AND].emit = emit_and; + bld_base->op_actions[TGSI_OPCODE_ARL].emit = emit_arl; bld_base->op_actions[TGSI_OPCODE_BGNLOOP].emit = bgnloop_emit; bld_base->op_actions[TGSI_OPCODE_BRK].emit = brk_emit; - bld_base->op_actions[TGSI_OPCODE_CEIL].emit = build_tgsi_intrinsic_readonly; + bld_base->op_actions[TGSI_OPCODE_CEIL].emit = build_tgsi_intrinsic_nomem; bld_base->op_actions[TGSI_OPCODE_CEIL].intr_name = "ceil"; bld_base->op_actions[TGSI_OPCODE_CLAMP].emit = build_tgsi_intrinsic_nomem; bld_base->op_actions[TGSI_OPCODE_CLAMP].intr_name = "llvm.AMDIL.clamp."; bld_base->op_actions[TGSI_OPCODE_CMP].emit = build_tgsi_intrinsic_nomem; bld_base->op_actions[TGSI_OPCODE_CMP].intr_name = "llvm.AMDGPU.cndlt"; bld_base->op_actions[TGSI_OPCODE_CONT].emit = cont_emit; - bld_base->op_actions[TGSI_OPCODE_COS].emit = build_tgsi_intrinsic_readonly; + bld_base->op_actions[TGSI_OPCODE_COS].emit = build_tgsi_intrinsic_nomem; bld_base->op_actions[TGSI_OPCODE_COS].intr_name = "llvm.cos.f32"; bld_base->op_actions[TGSI_OPCODE_DDX].intr_name = "llvm.AMDGPU.ddx"; bld_base->op_actions[TGSI_OPCODE_DDX].fetch_args = tex_fetch_args; @@ -1319,7 +1312,7 @@ void radeon_llvm_context_init(struct radeon_llvm_context * ctx) bld_base->op_actions[TGSI_OPCODE_ENDLOOP].emit = endloop_emit; bld_base->op_actions[TGSI_OPCODE_EX2].emit = build_tgsi_intrinsic_nomem; bld_base->op_actions[TGSI_OPCODE_EX2].intr_name = "llvm.AMDIL.exp."; - bld_base->op_actions[TGSI_OPCODE_FLR].emit = build_tgsi_intrinsic_readonly; + bld_base->op_actions[TGSI_OPCODE_FLR].emit = build_tgsi_intrinsic_nomem; bld_base->op_actions[TGSI_OPCODE_FLR].intr_name = "floor"; bld_base->op_actions[TGSI_OPCODE_FRC].emit = build_tgsi_intrinsic_nomem; bld_base->op_actions[TGSI_OPCODE_FRC].intr_name = "llvm.AMDIL.fraction."; @@ -1348,14 +1341,14 @@ void radeon_llvm_context_init(struct radeon_llvm_context * ctx) bld_base->op_actions[TGSI_OPCODE_KILL_IF].intr_name = "llvm.AMDGPU.kill"; bld_base->op_actions[TGSI_OPCODE_KILL].emit = lp_build_tgsi_intrinsic; bld_base->op_actions[TGSI_OPCODE_KILL].intr_name = "llvm.AMDGPU.kilp"; - bld_base->op_actions[TGSI_OPCODE_LG2].emit = build_tgsi_intrinsic_readonly; + bld_base->op_actions[TGSI_OPCODE_LG2].emit = build_tgsi_intrinsic_nomem; bld_base->op_actions[TGSI_OPCODE_LG2].intr_name = "llvm.log2.f32"; bld_base->op_actions[TGSI_OPCODE_LRP].emit = build_tgsi_intrinsic_nomem; bld_base->op_actions[TGSI_OPCODE_LRP].intr_name = "llvm.AMDGPU.lrp"; bld_base->op_actions[TGSI_OPCODE_MOD].emit = emit_mod; bld_base->op_actions[TGSI_OPCODE_NOT].emit = emit_not; bld_base->op_actions[TGSI_OPCODE_OR].emit = emit_or; - bld_base->op_actions[TGSI_OPCODE_POW].emit = build_tgsi_intrinsic_readonly; + bld_base->op_actions[TGSI_OPCODE_POW].emit = build_tgsi_intrinsic_nomem; bld_base->op_actions[TGSI_OPCODE_POW].intr_name = "llvm.pow.f32"; bld_base->op_actions[TGSI_OPCODE_ROUND].emit = build_tgsi_intrinsic_nomem; bld_base->op_actions[TGSI_OPCODE_ROUND].intr_name = "llvm.AMDIL.round.nearest."; @@ -1366,7 +1359,7 @@ void radeon_llvm_context_init(struct radeon_llvm_context * ctx) bld_base->op_actions[TGSI_OPCODE_SLT].emit = emit_cmp; bld_base->op_actions[TGSI_OPCODE_SNE].emit = emit_cmp; bld_base->op_actions[TGSI_OPCODE_SGT].emit = emit_cmp; - bld_base->op_actions[TGSI_OPCODE_SIN].emit = build_tgsi_intrinsic_readonly; + bld_base->op_actions[TGSI_OPCODE_SIN].emit = build_tgsi_intrinsic_nomem; bld_base->op_actions[TGSI_OPCODE_SIN].intr_name = "llvm.sin.f32"; bld_base->op_actions[TGSI_OPCODE_SSG].emit = emit_ssg; bld_base->op_actions[TGSI_OPCODE_TEX].fetch_args = tex_fetch_args; From mareko at kemper.freedesktop.org Mon Mar 16 11:55:50 2015 From: mareko at kemper.freedesktop.org (Marek Olšák) Date: Mon, 16 Mar 2015 04:55:50 -0700 (PDT) Subject: Mesa (master): radeonsi: add shader code for smoothing Message-ID: <20150316115550.5D38776336@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 303d23e10d2caad69b2d122f45c78fee2906fc09 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=303d23e10d2caad69b2d122f45c78fee2906fc09 Author: Marek Ol??k Date: Sun Mar 15 18:11:19 2015 +0100 radeonsi: add shader code for smoothing The fragment shader multiplies the alpha channel with gl_SampleMaskIn. If blending is enabled, it looks like MSAA. Reviewed-by: Michel D?nzer --- src/gallium/drivers/radeonsi/si_pipe.h | 1 + src/gallium/drivers/radeonsi/si_shader.c | 38 +++++++++++++++++++++++++++++- src/gallium/drivers/radeonsi/si_shader.h | 1 + 3 files changed, 39 insertions(+), 1 deletion(-) diff --git a/src/gallium/drivers/radeonsi/si_pipe.h b/src/gallium/drivers/radeonsi/si_pipe.h index 1496d5f..1bc664a 100644 --- a/src/gallium/drivers/radeonsi/si_pipe.h +++ b/src/gallium/drivers/radeonsi/si_pipe.h @@ -41,6 +41,7 @@ * the number shouldn't be a commonly-used one. */ #define SI_BASE_VERTEX_UNKNOWN INT_MIN #define SI_RESTART_INDEX_UNKNOWN INT_MIN +#define SI_NUM_SMOOTH_AA_SAMPLES 8 #define SI_TRACE_CS 0 #define SI_TRACE_CS_DWORDS 6 diff --git a/src/gallium/drivers/radeonsi/si_shader.c b/src/gallium/drivers/radeonsi/si_shader.c index a57fdf4..2703704 100644 --- a/src/gallium/drivers/radeonsi/si_shader.c +++ b/src/gallium/drivers/radeonsi/si_shader.c @@ -644,7 +644,12 @@ static void declare_system_value( } case TGSI_SEMANTIC_SAMPLEMASK: - value = LLVMGetParam(radeon_bld->main_fn, SI_PARAM_SAMPLE_COVERAGE); + /* Smoothing isn't MSAA in GL, but it's MSAA in hardware. + * Therefore, force gl_SampleMaskIn to 1 for GL. */ + if (si_shader_ctx->shader->key.ps.poly_line_smoothing) + value = uint_bld->one; + else + value = LLVMGetParam(radeon_bld->main_fn, SI_PARAM_SAMPLE_COVERAGE); break; default: @@ -828,6 +833,34 @@ static void si_alpha_test(struct lp_build_tgsi_context *bld_base, si_shader_ctx->shader->db_shader_control |= S_02880C_KILL_ENABLE(1); } +static void si_scale_alpha_by_sample_mask(struct lp_build_tgsi_context *bld_base, + LLVMValueRef alpha_ptr) +{ + struct si_shader_context *si_shader_ctx = si_shader_context(bld_base); + struct gallivm_state *gallivm = bld_base->base.gallivm; + LLVMValueRef coverage, alpha; + + /* alpha = alpha * popcount(coverage) / SI_NUM_SMOOTH_AA_SAMPLES */ + coverage = LLVMGetParam(si_shader_ctx->radeon_bld.main_fn, + SI_PARAM_SAMPLE_COVERAGE); + coverage = bitcast(bld_base, TGSI_TYPE_SIGNED, coverage); + + coverage = build_intrinsic(gallivm->builder, "llvm.ctpop.i32", + bld_base->int_bld.elem_type, + &coverage, 1, LLVMReadNoneAttribute); + + coverage = LLVMBuildUIToFP(gallivm->builder, coverage, + bld_base->base.elem_type, ""); + + coverage = LLVMBuildFMul(gallivm->builder, coverage, + lp_build_const_float(gallivm, + 1.0 / SI_NUM_SMOOTH_AA_SAMPLES), ""); + + alpha = LLVMBuildLoad(gallivm->builder, alpha_ptr, ""); + alpha = LLVMBuildFMul(gallivm->builder, alpha, coverage, ""); + LLVMBuildStore(gallivm->builder, alpha, alpha_ptr); +} + static void si_llvm_emit_clipvertex(struct lp_build_tgsi_context * bld_base, LLVMValueRef (*pos)[9], LLVMValueRef *out_elts) { @@ -1361,6 +1394,9 @@ static void si_llvm_emit_fs_epilogue(struct lp_build_tgsi_context * bld_base) if (semantic_index == 0 && si_shader_ctx->shader->key.ps.alpha_func != PIPE_FUNC_ALWAYS) si_alpha_test(bld_base, alpha_ptr); + + if (si_shader_ctx->shader->key.ps.poly_line_smoothing) + si_scale_alpha_by_sample_mask(bld_base, alpha_ptr); break; default: target = 0; diff --git a/src/gallium/drivers/radeonsi/si_shader.h b/src/gallium/drivers/radeonsi/si_shader.h index 4f2bb91..5b602ac 100644 --- a/src/gallium/drivers/radeonsi/si_shader.h +++ b/src/gallium/drivers/radeonsi/si_shader.h @@ -126,6 +126,7 @@ union si_shader_key { unsigned alpha_func:3; unsigned alpha_to_one:1; unsigned poly_stipple:1; + unsigned poly_line_smoothing:1; } ps; struct { unsigned instance_divisors[SI_NUM_VERTEX_BUFFERS]; From mareko at kemper.freedesktop.org Mon Mar 16 11:55:50 2015 From: mareko at kemper.freedesktop.org (Marek Olšák) Date: Mon, 16 Mar 2015 04:55:50 -0700 (PDT) Subject: Mesa (master): radeonsi: don' t emit PA_SC_LINE_STIPPLE if not rendering lines Message-ID: <20150316115550.8D59076336@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 567c8d73008a672cb71a84a4724829d34e1652b2 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=567c8d73008a672cb71a84a4724829d34e1652b2 Author: Marek Ol??k Date: Sun Mar 15 19:24:13 2015 +0100 radeonsi: don't emit PA_SC_LINE_STIPPLE if not rendering lines Reviewed-by: Michel D?nzer --- src/gallium/drivers/radeonsi/si_state_draw.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/gallium/drivers/radeonsi/si_state_draw.c b/src/gallium/drivers/radeonsi/si_state_draw.c index 7523c2a..e186694 100644 --- a/src/gallium/drivers/radeonsi/si_state_draw.c +++ b/src/gallium/drivers/radeonsi/si_state_draw.c @@ -156,6 +156,14 @@ static void si_emit_rasterizer_prim_state(struct si_context *sctx) unsigned rast_prim = sctx->current_rast_prim; struct si_state_rasterizer *rs = sctx->emitted.named.rasterizer; + /* Skip this if not rendering lines. */ + if (rast_prim != PIPE_PRIM_LINES && + rast_prim != PIPE_PRIM_LINE_LOOP && + rast_prim != PIPE_PRIM_LINE_STRIP && + rast_prim != PIPE_PRIM_LINES_ADJACENCY && + rast_prim != PIPE_PRIM_LINE_STRIP_ADJACENCY) + return; + if (rast_prim == sctx->last_rast_prim && rs->pa_sc_line_stipple == sctx->last_sc_line_stipple) return; From samuelig at kemper.freedesktop.org Mon Mar 16 11:58:36 2015 From: samuelig at kemper.freedesktop.org (Samuel Iglesias Gonsálvez) Date: Mon, 16 Mar 2015 04:58:36 -0700 (PDT) Subject: Mesa (master): i965: Emit IF/ELSE/ENDIF/WHILE JIP with type W on Gen7 Message-ID: <20150316115836.D7F6C76336@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 9735a62a2c6007e7ee7baa5a769575a0adb5fda3 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=9735a62a2c6007e7ee7baa5a769575a0adb5fda3 Author: Antia Puentes Date: Thu Mar 12 13:59:17 2015 +0100 i965: Emit IF/ELSE/ENDIF/WHILE JIP with type W on Gen7 IvyBridge and Haswell PRM say that the JIP should be emitted with type W but we were using UD. The previous implementation did not show adverse effects, but IMHO it is safer to follow the specification thoroughly. Reviewed-by: Matt Turner Signed-off-by: Antia Puentes --- src/mesa/drivers/dri/i965/brw_eu_emit.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_eu_emit.c b/src/mesa/drivers/dri/i965/brw_eu_emit.c index 43e5783..1ca79a9 100644 --- a/src/mesa/drivers/dri/i965/brw_eu_emit.c +++ b/src/mesa/drivers/dri/i965/brw_eu_emit.c @@ -1332,7 +1332,7 @@ brw_IF(struct brw_compile *p, unsigned execute_size) } else if (brw->gen == 7) { brw_set_dest(p, insn, vec1(retype(brw_null_reg(), BRW_REGISTER_TYPE_D))); brw_set_src0(p, insn, vec1(retype(brw_null_reg(), BRW_REGISTER_TYPE_D))); - brw_set_src1(p, insn, brw_imm_ud(0)); + brw_set_src1(p, insn, brw_imm_w(0)); brw_inst_set_jip(brw, insn, 0); brw_inst_set_uip(brw, insn, 0); } else { @@ -1533,7 +1533,7 @@ brw_ELSE(struct brw_compile *p) } else if (brw->gen == 7) { brw_set_dest(p, insn, retype(brw_null_reg(), BRW_REGISTER_TYPE_D)); brw_set_src0(p, insn, retype(brw_null_reg(), BRW_REGISTER_TYPE_D)); - brw_set_src1(p, insn, brw_imm_ud(0)); + brw_set_src1(p, insn, brw_imm_w(0)); brw_inst_set_jip(brw, insn, 0); brw_inst_set_uip(brw, insn, 0); } else { @@ -1610,7 +1610,7 @@ brw_ENDIF(struct brw_compile *p) } else if (brw->gen == 7) { brw_set_dest(p, insn, retype(brw_null_reg(), BRW_REGISTER_TYPE_D)); brw_set_src0(p, insn, retype(brw_null_reg(), BRW_REGISTER_TYPE_D)); - brw_set_src1(p, insn, brw_imm_ud(0)); + brw_set_src1(p, insn, brw_imm_w(0)); } else { brw_set_src0(p, insn, brw_imm_d(0)); } @@ -1802,7 +1802,7 @@ brw_WHILE(struct brw_compile *p) } else if (brw->gen == 7) { brw_set_dest(p, insn, retype(brw_null_reg(), BRW_REGISTER_TYPE_D)); brw_set_src0(p, insn, retype(brw_null_reg(), BRW_REGISTER_TYPE_D)); - brw_set_src1(p, insn, brw_imm_ud(0)); + brw_set_src1(p, insn, brw_imm_w(0)); brw_inst_set_jip(brw, insn, br * (do_insn - insn)); } else { brw_set_dest(p, insn, brw_imm_w(0)); From mareko at kemper.freedesktop.org Mon Mar 16 13:58:27 2015 From: mareko at kemper.freedesktop.org (Marek Olšák) Date: Mon, 16 Mar 2015 06:58:27 -0700 (PDT) Subject: Mesa (master): radeonsi: add a helper for extracting bitfields from parameters (v2) Message-ID: <20150316135827.9EF6C76331@kemper.freedesktop.org> Module: Mesa Branch: master Commit: d3723c614fb42c22e4e87fe8151bbb36462b425a URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=d3723c614fb42c22e4e87fe8151bbb36462b425a Author: Marek Ol??k Date: Fri Feb 27 19:09:30 2015 +0100 radeonsi: add a helper for extracting bitfields from parameters (v2) This will be used a lot (especially by tessellation). v2: don't use the bfe intrinsic Reviewed-by: Tom Stellard --- src/gallium/drivers/radeonsi/si_shader.c | 43 +++++++++++++++++++----------- 1 file changed, 27 insertions(+), 16 deletions(-) diff --git a/src/gallium/drivers/radeonsi/si_shader.c b/src/gallium/drivers/radeonsi/si_shader.c index 2703704..de889ed 100644 --- a/src/gallium/drivers/radeonsi/si_shader.c +++ b/src/gallium/drivers/radeonsi/si_shader.c @@ -192,6 +192,30 @@ static int get_param_index(unsigned semantic_name, unsigned index, } /** + * Get the value of a shader input parameter and extract a bitfield. + */ +static LLVMValueRef unpack_param(struct si_shader_context *si_shader_ctx, + unsigned param, unsigned rshift, + unsigned bitwidth) +{ + struct gallivm_state *gallivm = &si_shader_ctx->radeon_bld.gallivm; + LLVMValueRef value = LLVMGetParam(si_shader_ctx->radeon_bld.main_fn, + param); + + if (rshift) + value = LLVMBuildLShr(gallivm->builder, value, + lp_build_const_int32(gallivm, rshift), ""); + + if (rshift + bitwidth < 32) { + unsigned mask = (1 << bitwidth) - 1; + value = LLVMBuildAnd(gallivm->builder, value, + lp_build_const_int32(gallivm, mask), ""); + } + + return value; +} + +/** * Build an LLVM bytecode indexed load using LLVMBuildGEP + LLVMBuildLoad. * It's equivalent to doing a load from &base_ptr[index]. * @@ -561,14 +585,8 @@ static void declare_input_fs( static LLVMValueRef get_sample_id(struct radeon_llvm_context *radeon_bld) { - struct gallivm_state *gallivm = &radeon_bld->gallivm; - LLVMValueRef value = LLVMGetParam(radeon_bld->main_fn, - SI_PARAM_ANCILLARY); - value = LLVMBuildLShr(gallivm->builder, value, - lp_build_const_int32(gallivm, 8), ""); - value = LLVMBuildAnd(gallivm->builder, value, - lp_build_const_int32(gallivm, 0xf), ""); - return value; + return unpack_param(si_shader_context(&radeon_bld->soa.bld_base), + SI_PARAM_ANCILLARY, 8, 4); } /** @@ -1013,16 +1031,9 @@ static void si_llvm_emit_streamout(struct si_shader_context *shader, LLVMTypeRef i32 = LLVMInt32TypeInContext(gallivm->context); - LLVMValueRef so_param = - LLVMGetParam(shader->radeon_bld.main_fn, - shader->param_streamout_config); - /* Get bits [22:16], i.e. (so_param >> 16) & 127; */ LLVMValueRef so_vtx_count = - LLVMBuildAnd(builder, - LLVMBuildLShr(builder, so_param, - LLVMConstInt(i32, 16, 0), ""), - LLVMConstInt(i32, 127, 0), ""); + unpack_param(shader, shader->param_streamout_config, 16, 7); LLVMValueRef tid = build_intrinsic(builder, "llvm.SI.tid", i32, NULL, 0, LLVMReadNoneAttribute); From mareko at kemper.freedesktop.org Mon Mar 16 13:58:27 2015 From: mareko at kemper.freedesktop.org (Marek Olšák) Date: Mon, 16 Mar 2015 06:58:27 -0700 (PDT) Subject: Mesa (master): radeonsi: implement TGSI_OPCODE_BFI (v2) Message-ID: <20150316135827.A90DF76331@kemper.freedesktop.org> Module: Mesa Branch: master Commit: b5f19db9766ac54d78b8087b0433011f908ebd2c URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=b5f19db9766ac54d78b8087b0433011f908ebd2c Author: Marek Ol??k Date: Sat Feb 28 14:31:45 2015 +0100 radeonsi: implement TGSI_OPCODE_BFI (v2) v2: Don't use the intrinsics, the shader backend can recognize these patterns and generates optimal code automatically. Reviewed-by: Tom Stellard --- docs/GL3.txt | 2 +- .../drivers/radeon/radeon_setup_tgsi_llvm.c | 34 ++++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/docs/GL3.txt b/docs/GL3.txt index 267740a..b295149 100644 --- a/docs/GL3.txt +++ b/docs/GL3.txt @@ -102,7 +102,7 @@ GL 4.0, GLSL 4.00: - Dynamically uniform UBO array indices DONE (r600) - Implicit signed -> unsigned conversions DONE - Fused multiply-add DONE () - - Packing/bitfield/conversion functions DONE (r600) + - Packing/bitfield/conversion functions DONE (r600, radeonsi) - Enhanced textureGather DONE (r600, radeonsi) - Geometry shader instancing DONE (r600) - Geometry shader multiple streams DONE () diff --git a/src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c b/src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c index 0034b56..d89e2b4 100644 --- a/src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c +++ b/src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c @@ -1234,6 +1234,39 @@ build_tgsi_intrinsic_nomem( build_tgsi_intrinsic(action, bld_base, emit_data, LLVMReadNoneAttribute); } +static void emit_bfi(const struct lp_build_tgsi_action * action, + struct lp_build_tgsi_context * bld_base, + struct lp_build_emit_data * emit_data) +{ + struct gallivm_state *gallivm = bld_base->base.gallivm; + LLVMBuilderRef builder = gallivm->builder; + LLVMValueRef bfi_args[3]; + + // Calculate the bitmask: (((1 << src3) - 1) << src2 + bfi_args[0] = LLVMBuildShl(builder, + LLVMBuildSub(builder, + LLVMBuildShl(builder, + bld_base->int_bld.one, + emit_data->args[3], ""), + bld_base->int_bld.one, ""), + emit_data->args[2], ""); + + bfi_args[1] = LLVMBuildShl(builder, emit_data->args[1], + emit_data->args[2], ""); + + bfi_args[2] = emit_data->args[0]; + + /* Calculate: + * (arg0 & arg1) | (~arg0 & arg2) = arg2 ^ (arg0 & (arg1 ^ arg2) + * Use the right-hand side, which the LLVM backend can convert to V_BFI. + */ + emit_data->output[emit_data->chan] = + LLVMBuildXor(builder, bfi_args[2], + LLVMBuildAnd(builder, bfi_args[0], + LLVMBuildXor(builder, bfi_args[1], bfi_args[2], + ""), ""), ""); +} + /* this is ffs in C */ static void emit_lsb(const struct lp_build_tgsi_action * action, struct lp_build_tgsi_context * bld_base, @@ -1381,6 +1414,7 @@ void radeon_llvm_context_init(struct radeon_llvm_context * ctx) bld_base->op_actions[TGSI_OPCODE_ABS].intr_name = "fabs"; bld_base->op_actions[TGSI_OPCODE_AND].emit = emit_and; bld_base->op_actions[TGSI_OPCODE_ARL].emit = emit_arl; + bld_base->op_actions[TGSI_OPCODE_BFI].emit = emit_bfi; bld_base->op_actions[TGSI_OPCODE_BGNLOOP].emit = bgnloop_emit; bld_base->op_actions[TGSI_OPCODE_BREV].emit = build_tgsi_intrinsic_nomem; bld_base->op_actions[TGSI_OPCODE_BREV].intr_name = "llvm.AMDGPU.brev"; From evelikov at kemper.freedesktop.org Mon Mar 16 21:00:53 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Mon, 16 Mar 2015 14:00:53 -0700 (PDT) Subject: Mesa (master): gallium/sw/kms: trivial cleanups Message-ID: <20150316210053.256ED76359@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 5664f57df3b7dfc5def189d1ee7a1b3df7d92bd6 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=5664f57df3b7dfc5def189d1ee7a1b3df7d92bd6 Author: Emil Velikov Date: Mon Mar 16 11:50:47 2015 +0000 gallium/sw/kms: trivial cleanups Remove the forward declaration and make use of the DEBUG_PRINT macro for debug builds. Signed-off-by: Emil Velikov Reviewed-by: Brian Paul --- src/gallium/winsys/sw/kms-dri/kms_dri_sw_winsys.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/gallium/winsys/sw/kms-dri/kms_dri_sw_winsys.c b/src/gallium/winsys/sw/kms-dri/kms_dri_sw_winsys.c index ce3de78..e61a173 100644 --- a/src/gallium/winsys/sw/kms-dri/kms_dri_sw_winsys.c +++ b/src/gallium/winsys/sw/kms-dri/kms_dri_sw_winsys.c @@ -51,16 +51,14 @@ #include "state_tracker/sw_winsys.h" #include "state_tracker/drm_driver.h" +#include "kms_dri_sw_winsys.h" -#if 0 +#ifdef DEBUG #define DEBUG_PRINT(msg, ...) fprintf(stderr, msg, __VA_ARGS__) #else #define DEBUG_PRINT(msg, ...) #endif -struct sw_winsys; - -struct sw_winsys *kms_dri_create_winsys(int fd); struct kms_sw_displaytarget { From evelikov at kemper.freedesktop.org Mon Mar 16 21:00:53 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Mon, 16 Mar 2015 14:00:53 -0700 (PDT) Subject: Mesa (master): loader: include for non-sysfs builds Message-ID: <20150316210053.1C6257633A@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 771cd266b9d00bdcf2cf7acaa3c8363c358d7478 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=771cd266b9d00bdcf2cf7acaa3c8363c358d7478 Author: Emil Velikov Date: Wed Mar 11 19:12:35 2015 +0000 loader: include for non-sysfs builds Required by fstat(), otherwise we'll error out due to implicit function declaration. Cc: "10.4 10.5" Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=89530 Signed-off-by: Emil Velikov Reported-by: Vadim Rutkovsky Tested-by: Vadim Rutkovsky --- src/loader/loader.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/loader/loader.c b/src/loader/loader.c index 9ff5115..17bf133 100644 --- a/src/loader/loader.c +++ b/src/loader/loader.c @@ -64,6 +64,7 @@ * Rob Clark */ +#include #include #include #include @@ -80,7 +81,6 @@ #endif #endif #ifdef HAVE_SYSFS -#include #include #endif #include "loader.h" From evelikov at kemper.freedesktop.org Mon Mar 16 21:00:53 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Mon, 16 Mar 2015 14:00:53 -0700 (PDT) Subject: Mesa (master): auxiliary/os: fix the android build - s/drm_munmap/ os_munmap/ Message-ID: <20150316210053.2E6357635A@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 55f0c0a29f788c5df4820e81c0cf93613ccedf5e URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=55f0c0a29f788c5df4820e81c0cf93613ccedf5e Author: Emil Velikov Date: Mon Mar 16 15:00:18 2015 +0000 auxiliary/os: fix the android build - s/drm_munmap/os_munmap/ Squash this silly typo introduced with commit c63eb5dd5ec(auxiliary/os: get the mmap/munmap wrappers working with android) Cc: "10.4 10.5" Signed-off-by: Emil Velikov Reviewed-by: Brian Paul --- src/gallium/auxiliary/os/os_mman.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gallium/auxiliary/os/os_mman.h b/src/gallium/auxiliary/os/os_mman.h index 19c9a5b..3fc8c43 100644 --- a/src/gallium/auxiliary/os/os_mman.h +++ b/src/gallium/auxiliary/os/os_mman.h @@ -70,8 +70,8 @@ static INLINE void *os_mmap(void *addr, size_t length, int prot, int flags, return __mmap2(addr, length, prot, flags, fd, (size_t) (offset >> 12)); } -# define drm_munmap(addr, length) \ - munmap(addr, length) +# define os_munmap(addr, length) \ + munmap(addr, length) #else /* assume large file support exists */ From evelikov at kemper.freedesktop.org Mon Mar 16 21:00:53 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Mon, 16 Mar 2015 14:00:53 -0700 (PDT) Subject: Mesa (master): c11/threads: Use PTHREAD_MUTEX_RECURSIVE by default Message-ID: <20150316210053.15D7F76331@kemper.freedesktop.org> Module: Mesa Branch: master Commit: aead7fe2e2b6c89258f80a25299f4ec0fece2d95 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=aead7fe2e2b6c89258f80a25299f4ec0fece2d95 Author: Felix Janda Date: Mon Feb 2 20:04:16 2015 +0100 c11/threads: Use PTHREAD_MUTEX_RECURSIVE by default Previously PTHREAD_MUTEX_RECURSIVE_NP had been used on linux for compatibility with old glibc. Since mesa defines __GNU_SOURCE__ on linux PTHREAD_MUTEX_RECURSIVE is also available since at least 1998. So we can unconditionally use the portable version PTHREAD_MUTEX_RECURSIVE. Cc: "10.5" Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=88534 Reviewed-by: Emil Velikov --- include/c11/threads_posix.h | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/include/c11/threads_posix.h b/include/c11/threads_posix.h index f9c165d..2182c28 100644 --- a/include/c11/threads_posix.h +++ b/include/c11/threads_posix.h @@ -177,13 +177,8 @@ mtx_init(mtx_t *mtx, int type) && type != (mtx_try|mtx_recursive)) return thrd_error; pthread_mutexattr_init(&attr); - if ((type & mtx_recursive) != 0) { -#if defined(__linux__) || defined(__linux) - pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE_NP); -#else + if ((type & mtx_recursive) != 0) pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE); -#endif - } pthread_mutex_init(mtx, &attr); pthread_mutexattr_destroy(&attr); return thrd_success; From evelikov at kemper.freedesktop.org Mon Mar 16 21:00:53 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Mon, 16 Mar 2015 14:00:53 -0700 (PDT) Subject: Mesa (master): st/dri: remove unused include from the automake/scons build Message-ID: <20150316210053.3BDCE76331@kemper.freedesktop.org> Module: Mesa Branch: master Commit: c066669b8df9fa5a5e87354b613988944c9a0e5c URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=c066669b8df9fa5a5e87354b613988944c9a0e5c Author: Emil Velikov Date: Mon Mar 16 15:00:19 2015 +0000 st/dri: remove unused include from the automake/scons build st/dri/common hasn't been around for a while. Signed-off-by: Emil Velikov Reviewed-by: Brian Paul --- src/gallium/state_trackers/dri/Makefile.am | 1 - src/gallium/state_trackers/dri/SConscript | 1 - 2 files changed, 2 deletions(-) diff --git a/src/gallium/state_trackers/dri/Makefile.am b/src/gallium/state_trackers/dri/Makefile.am index 5d701f7..d2c7a82 100644 --- a/src/gallium/state_trackers/dri/Makefile.am +++ b/src/gallium/state_trackers/dri/Makefile.am @@ -30,7 +30,6 @@ AM_CPPFLAGS = \ -I$(top_srcdir)/include \ -I$(top_srcdir)/src/mapi \ -I$(top_srcdir)/src/mesa \ - -I$(top_srcdir)/src/gallium/state_trackers/dri/common \ -I$(top_srcdir)/src/mesa/drivers/dri/common \ -I$(top_builddir)/src/mesa/drivers/dri/common \ $(GALLIUM_CFLAGS) \ diff --git a/src/gallium/state_trackers/dri/SConscript b/src/gallium/state_trackers/dri/SConscript index 9b0dc64..89b5e61 100644 --- a/src/gallium/state_trackers/dri/SConscript +++ b/src/gallium/state_trackers/dri/SConscript @@ -14,7 +14,6 @@ env.Append(CPPPATH = [ '#/src', '#/src/mapi', '#/src/mesa', - '#/src/gallium/state_trackers/dri/common', '#/src/mesa/drivers/dri/common', xmlpool_options.dir.dir, # Dir to generated xmlpool/options.h ]) From mareko at kemper.freedesktop.org Mon Mar 16 22:27:42 2015 From: mareko at kemper.freedesktop.org (Marek Olšák) Date: Mon, 16 Mar 2015 15:27:42 -0700 (PDT) Subject: Mesa (master): docs/GL3: also mark GLES3/GS5 for radeonsi as done Message-ID: <20150316222742.E1B1C76331@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 9d1682d619426d0a5b90a12df82390cdfa098107 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=9d1682d619426d0a5b90a12df82390cdfa098107 Author: Marek Ol??k Date: Mon Mar 16 23:24:15 2015 +0100 docs/GL3: also mark GLES3/GS5 for radeonsi as done --- docs/GL3.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/GL3.txt b/docs/GL3.txt index b295149..5d59341 100644 --- a/docs/GL3.txt +++ b/docs/GL3.txt @@ -226,7 +226,7 @@ GLES3.1, GLSL ES 3.1 GL_ARB_stencil_texturing DONE (i965/gen8+, nv50, nvc0, r600, radeonsi, llvmpipe, softpipe) GL_ARB_vertex_attrib_binding DONE (all drivers) GS5 Enhanced textureGather DONE (i965, nvc0, r600, radeonsi) - GS5 Packing/bitfield/conversion functions DONE (i965, nvc0, r600) + GS5 Packing/bitfield/conversion functions DONE (i965, nvc0, r600, radeonsi) GL_EXT_shader_integer_mix DONE (all drivers that support GLSL) From sroland at kemper.freedesktop.org Mon Mar 16 23:47:30 2015 From: sroland at kemper.freedesktop.org (Roland Scheidegger) Date: Mon, 16 Mar 2015 16:47:30 -0700 (PDT) Subject: Mesa (master): gallivm: abort properly when running out of buffer space in lp_disassembly Message-ID: <20150316234730.8C32276331@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 2372275d2fc9e4d3785b34a5aeb7b6126e8cc402 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=2372275d2fc9e4d3785b34a5aeb7b6126e8cc402 Author: Roland Scheidegger Date: Fri Mar 13 23:45:20 2015 +0100 gallivm: abort properly when running out of buffer space in lp_disassembly Before this actually ran into an infinite loop printing out "invalid"... Reviewed-by: Brian Paul Reviewed-by: Jose Fonseca --- src/gallium/auxiliary/gallivm/lp_bld_debug.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/gallium/auxiliary/gallivm/lp_bld_debug.cpp b/src/gallium/auxiliary/gallivm/lp_bld_debug.cpp index 402d29e..2c4ed21 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_debug.cpp +++ b/src/gallium/auxiliary/gallivm/lp_bld_debug.cpp @@ -399,19 +399,23 @@ disassemble(const void* func, llvm::raw_ostream & Out) break; } } + + if (pc >= extent) { + Out << "disassembly larger than " << extent << "bytes, aborting\n"; + break; + } } + Out << "\n"; + Out.flush(); + /* * Print GDB command, useful to verify output. */ - if (0) { _debug_printf("disassemble %p %p\n", bytes, bytes + pc); } - Out << "\n"; - Out.flush(); - return pc; } From vlee at kemper.freedesktop.org Tue Mar 17 05:56:16 2015 From: vlee at kemper.freedesktop.org (Vinson Lee) Date: Mon, 16 Mar 2015 22:56:16 -0700 (PDT) Subject: Mesa (master): common.py: Fix PEP 8 issues. Message-ID: <20150317055616.B6BF076331@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 60f77b22b1e3bbef7e4d1f10012acf830d81ed7b URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=60f77b22b1e3bbef7e4d1f10012acf830d81ed7b Author: Vinson Lee Date: Sat Mar 14 01:45:03 2015 -0700 common.py: Fix PEP 8 issues. Signed-off-by: Vinson Lee Reviewed-by: Brian Paul --- common.py | 97 +++++++++++++++++++++++++++++++++---------------------------- 1 file changed, 53 insertions(+), 44 deletions(-) diff --git a/common.py b/common.py index 1d2d586..7a93941 100644 --- a/common.py +++ b/common.py @@ -26,28 +26,28 @@ else: target_platform = host_platform _machine_map = { - 'x86': 'x86', - 'i386': 'x86', - 'i486': 'x86', - 'i586': 'x86', - 'i686': 'x86', - 'BePC': 'x86', - 'Intel': 'x86', - 'ppc' : 'ppc', - 'BeBox': 'ppc', - 'BeMac': 'ppc', - 'AMD64': 'x86_64', - 'x86_64': 'x86_64', - 'sparc': 'sparc', - 'sun4u': 'sparc', + 'x86': 'x86', + 'i386': 'x86', + 'i486': 'x86', + 'i586': 'x86', + 'i686': 'x86', + 'BePC': 'x86', + 'Intel': 'x86', + 'ppc': 'ppc', + 'BeBox': 'ppc', + 'BeMac': 'ppc', + 'AMD64': 'x86_64', + 'x86_64': 'x86_64', + 'sparc': 'sparc', + 'sun4u': 'sparc', } # find host_machine value if 'PROCESSOR_ARCHITECTURE' in os.environ: - host_machine = os.environ['PROCESSOR_ARCHITECTURE'] + host_machine = os.environ['PROCESSOR_ARCHITECTURE'] else: - host_machine = _platform.machine() + host_machine = _platform.machine() host_machine = _machine_map.get(host_machine, 'generic') default_machine = host_machine @@ -65,7 +65,8 @@ else: default_llvm = 'no' try: if target_platform != 'windows' and \ - subprocess.call(['llvm-config', '--version'], stdout=subprocess.PIPE) == 0: + subprocess.call(['llvm-config', '--version'], + stdout=subprocess.PIPE) == 0: default_llvm = 'yes' except: pass @@ -75,30 +76,38 @@ else: # Common options def AddOptions(opts): - try: - from SCons.Variables.BoolVariable import BoolVariable as BoolOption - except ImportError: - from SCons.Options.BoolOption import BoolOption - try: - from SCons.Variables.EnumVariable import EnumVariable as EnumOption - except ImportError: - from SCons.Options.EnumOption import EnumOption - opts.Add(EnumOption('build', 'build type', 'debug', - allowed_values=('debug', 'checked', 'profile', 'release'))) - opts.Add(BoolOption('verbose', 'verbose output', 'no')) - opts.Add(EnumOption('machine', 'use machine-specific assembly code', default_machine, - allowed_values=('generic', 'ppc', 'x86', 'x86_64'))) - opts.Add(EnumOption('platform', 'target platform', host_platform, - allowed_values=('cygwin', 'darwin', 'freebsd', 'haiku', 'linux', 'sunos', 'windows'))) - opts.Add(BoolOption('embedded', 'embedded build', 'no')) - opts.Add(BoolOption('analyze', 'enable static code analysis where available', 'no')) - opts.Add('toolchain', 'compiler toolchain', default_toolchain) - opts.Add(BoolOption('gles', 'EXPERIMENTAL: enable OpenGL ES support', 'no')) - opts.Add(BoolOption('llvm', 'use LLVM', default_llvm)) - opts.Add(BoolOption('openmp', 'EXPERIMENTAL: compile with openmp (swrast)', 'no')) - opts.Add(BoolOption('debug', 'DEPRECATED: debug build', 'yes')) - opts.Add(BoolOption('profile', 'DEPRECATED: profile build', 'no')) - opts.Add(BoolOption('quiet', 'DEPRECATED: profile build', 'yes')) - opts.Add(BoolOption('texture_float', 'enable floating-point textures and renderbuffers', 'no')) - if host_platform == 'windows': - opts.Add('MSVC_VERSION', 'Microsoft Visual C/C++ version') + try: + from SCons.Variables.BoolVariable import BoolVariable as BoolOption + except ImportError: + from SCons.Options.BoolOption import BoolOption + try: + from SCons.Variables.EnumVariable import EnumVariable as EnumOption + except ImportError: + from SCons.Options.EnumOption import EnumOption + opts.Add(EnumOption('build', 'build type', 'debug', + allowed_values=('debug', 'checked', 'profile', + 'release'))) + opts.Add(BoolOption('verbose', 'verbose output', 'no')) + opts.Add(EnumOption('machine', 'use machine-specific assembly code', + default_machine, + allowed_values=('generic', 'ppc', 'x86', 'x86_64'))) + opts.Add(EnumOption('platform', 'target platform', host_platform, + allowed_values=('cygwin', 'darwin', 'freebsd', 'haiku', + 'linux', 'sunos', 'windows'))) + opts.Add(BoolOption('embedded', 'embedded build', 'no')) + opts.Add(BoolOption('analyze', + 'enable static code analysis where available', 'no')) + opts.Add('toolchain', 'compiler toolchain', default_toolchain) + opts.Add(BoolOption('gles', 'EXPERIMENTAL: enable OpenGL ES support', + 'no')) + opts.Add(BoolOption('llvm', 'use LLVM', default_llvm)) + opts.Add(BoolOption('openmp', 'EXPERIMENTAL: compile with openmp (swrast)', + 'no')) + opts.Add(BoolOption('debug', 'DEPRECATED: debug build', 'yes')) + opts.Add(BoolOption('profile', 'DEPRECATED: profile build', 'no')) + opts.Add(BoolOption('quiet', 'DEPRECATED: profile build', 'yes')) + opts.Add(BoolOption('texture_float', + 'enable floating-point textures and renderbuffers', + 'no')) + if host_platform == 'windows': + opts.Add('MSVC_VERSION', 'Microsoft Visual C/C++ version') From tpalli at kemper.freedesktop.org Tue Mar 17 05:59:51 2015 From: tpalli at kemper.freedesktop.org (Tapani Pälli) Date: Mon, 16 Mar 2015 22:59:51 -0700 (PDT) Subject: Mesa (master): i965/fs: in MAD optimizations, switch last argument to be immediate Message-ID: <20150317055951.7796676331@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 627c68308683abbd6e563a09af6013a33938a790 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=627c68308683abbd6e563a09af6013a33938a790 Author: Tapani P?lli Date: Mon Mar 16 10:08:08 2015 +0200 i965/fs: in MAD optimizations, switch last argument to be immediate Commit bb33a31 introduced optimizations that transform cases of MAD in to simpler forms but it did not take in to account that src[0] can not be immediate and did not report progress. Patch switches src[0] and src[1] if src[0] is immediate and adds progress reporting. If both sources are immediates, this is taken care of by the same opt_algebraic pass on later run. v2: Fix for all cases, use temporary fs_reg (Matt, Kenneth) Signed-off-by: Tapani P?lli Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=89569 Reviewed-by: Francisco Jerez (v1) Reviewed-by: Kenneth Graunke Cc: "10.5" --- src/mesa/drivers/dri/i965/brw_fs.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp index 8702ea8..53ceb29 100644 --- a/src/mesa/drivers/dri/i965/brw_fs.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs.cpp @@ -2491,6 +2491,7 @@ fs_visitor::opt_algebraic() inst->opcode = BRW_OPCODE_MUL; inst->src[0] = inst->src[2]; inst->src[2] = reg_undef; + progress = true; } else if (inst->src[1].is_one()) { inst->opcode = BRW_OPCODE_ADD; inst->src[1] = inst->src[2]; @@ -2521,8 +2522,16 @@ fs_visitor::opt_algebraic() default: break; } - } + /* Swap if src[0] is immediate. */ + if (progress && inst->is_commutative()) { + if (inst->src[0].file == IMM) { + fs_reg tmp = inst->src[1]; + inst->src[1] = inst->src[0]; + inst->src[0] = tmp; + } + } + } return progress; } From nroberts at kemper.freedesktop.org Tue Mar 17 16:39:57 2015 From: nroberts at kemper.freedesktop.org (Neil Roberts) Date: Tue, 17 Mar 2015 09:39:57 -0700 (PDT) Subject: Mesa (master): i965/skl: Send a message header when doing constant loads SIMD4x2 Message-ID: <20150317163957.683CE76338@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 5a06ee7384934f8b5177b2f01bb7dff08b370145 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=5a06ee7384934f8b5177b2f01bb7dff08b370145 Author: Neil Roberts Date: Thu Mar 12 17:41:07 2015 +0000 i965/skl: Send a message header when doing constant loads SIMD4x2 Commit 0ac4c272755c7 made it add a header for the send message when using SIMD4x2 on Skylake because without this it will end up using SIMD8D. However the patch missed the case when a sampler is being used to implement constant loads from a buffer surface in a SIMD4x2 vertex shader. This fixes 29 Piglit tests, mostly related to the ARL instruction in vertex programs. Reviewed-by: Kristian H?gsberg Tested-by: Anuj Phogat --- src/mesa/drivers/dri/i965/brw_vec4_generator.cpp | 32 ++++++++++++++++++---- src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp | 18 ++++++++++++ src/mesa/drivers/dri/i965/brw_vec4_vp.cpp | 9 ++++++ 3 files changed, 53 insertions(+), 6 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_vec4_generator.cpp b/src/mesa/drivers/dri/i965/brw_vec4_generator.cpp index 010a5c4..e3a94ff 100644 --- a/src/mesa/drivers/dri/i965/brw_vec4_generator.cpp +++ b/src/mesa/drivers/dri/i965/brw_vec4_generator.cpp @@ -1049,18 +1049,38 @@ vec4_generator::generate_pull_constant_load_gen7(vec4_instruction *inst, { assert(surf_index.type == BRW_REGISTER_TYPE_UD); + struct brw_reg src = offset; + bool header_present = false; + int mlen = 1; + + if (brw->gen >= 9) { + /* Skylake requires a message header in order to use SIMD4x2 mode. */ + src = retype(brw_vec4_grf(offset.nr - 1, 0), BRW_REGISTER_TYPE_UD); + mlen = 2; + header_present = true; + + brw_push_insn_state(p); + brw_set_default_mask_control(p, BRW_MASK_DISABLE); + brw_MOV(p, src, retype(brw_vec4_grf(0, 0), BRW_REGISTER_TYPE_UD)); + brw_set_default_access_mode(p, BRW_ALIGN_1); + + brw_MOV(p, get_element_ud(src, 2), + brw_imm_ud(GEN9_SAMPLER_SIMD_MODE_EXTENSION_SIMD4X2)); + brw_pop_insn_state(p); + } + if (surf_index.file == BRW_IMMEDIATE_VALUE) { brw_inst *insn = brw_next_insn(p, BRW_OPCODE_SEND); brw_set_dest(p, insn, dst); - brw_set_src0(p, insn, offset); + brw_set_src0(p, insn, src); brw_set_sampler_message(p, insn, surf_index.dw1.ud, 0, /* LD message ignores sampler unit */ GEN5_SAMPLER_MESSAGE_SAMPLE_LD, 1, /* rlen */ - 1, /* mlen */ - false, /* no header */ + mlen, + header_present, BRW_SAMPLER_SIMD_MODE_SIMD4X2, 0); @@ -1089,8 +1109,8 @@ vec4_generator::generate_pull_constant_load_gen7(vec4_instruction *inst, 0 /* sampler */, GEN5_SAMPLER_MESSAGE_SAMPLE_LD, 1 /* rlen */, - 1 /* mlen */, - false /* header */, + mlen /* mlen */, + header_present /* header */, BRW_SAMPLER_SIMD_MODE_SIMD4X2, 0); brw_inst_set_exec_size(p->brw, insn_or, BRW_EXECUTE_1); @@ -1102,7 +1122,7 @@ vec4_generator::generate_pull_constant_load_gen7(vec4_instruction *inst, /* dst = send(offset, a0.0) */ brw_inst *insn_send = brw_next_insn(p, BRW_OPCODE_SEND); brw_set_dest(p, insn_send, dst); - brw_set_src0(p, insn_send, offset); + brw_set_src0(p, insn_send, src); brw_set_indirect_send_descriptor(p, insn_send, BRW_SFID_SAMPLER, addr); brw_pop_insn_state(p); diff --git a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp index 195c6f5..d5c6e9b 100644 --- a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp +++ b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp @@ -1783,6 +1783,15 @@ vec4_visitor::visit(ir_expression *ir) if (brw->gen >= 7) { dst_reg grf_offset = dst_reg(this, glsl_type::int_type); + + /* We have to use a message header on Skylake to get SIMD4x2 mode. + * Reserve space for the register. + */ + if (brw->gen >= 9) { + grf_offset.reg_offset++; + alloc.sizes[grf_offset.reg] = 2; + } + grf_offset.type = offset.type; emit(MOV(grf_offset, offset)); @@ -3477,6 +3486,15 @@ vec4_visitor::emit_pull_constant_load(bblock_t *block, vec4_instruction *inst, if (brw->gen >= 7) { dst_reg grf_offset = dst_reg(this, glsl_type::int_type); + + /* We have to use a message header on Skylake to get SIMD4x2 mode. + * Reserve space for the register. + */ + if (brw->gen >= 9) { + grf_offset.reg_offset++; + alloc.sizes[grf_offset.reg] = 2; + } + grf_offset.type = offset.type; emit_before(block, inst, MOV(grf_offset, offset)); diff --git a/src/mesa/drivers/dri/i965/brw_vec4_vp.cpp b/src/mesa/drivers/dri/i965/brw_vec4_vp.cpp index ba3264d..c3b0233 100644 --- a/src/mesa/drivers/dri/i965/brw_vec4_vp.cpp +++ b/src/mesa/drivers/dri/i965/brw_vec4_vp.cpp @@ -527,6 +527,15 @@ vec4_vs_visitor::get_vp_src_reg(const prog_src_register &src) /* Add the small constant index to the address register */ src_reg reladdr = src_reg(this, glsl_type::int_type); + + /* We have to use a message header on Skylake to get SIMD4x2 mode. + * Reserve space for the register. + */ + if (brw->gen >= 9) { + reladdr.reg_offset++; + alloc.sizes[reladdr.reg] = 2; + } + dst_reg dst_reladdr = dst_reg(reladdr); dst_reladdr.writemask = WRITEMASK_X; emit(ADD(dst_reladdr, this->vp_addr_reg, src_reg(src.Index))); From ldeks at kemper.freedesktop.org Tue Mar 17 17:09:11 2015 From: ldeks at kemper.freedesktop.org (Laura Ekstrand) Date: Tue, 17 Mar 2015 10:09:11 -0700 (PDT) Subject: Mesa (master): Revert "main: _mesa_cube_level_complete checks NumLayers." Message-ID: <20150317170911.6B80676338@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 44ecf0793d872e771edc448436f7a2fd7c3390f5 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=44ecf0793d872e771edc448436f7a2fd7c3390f5 Author: Laura Ekstrand Date: Tue Mar 17 09:43:52 2015 -0700 Revert "main: _mesa_cube_level_complete checks NumLayers." This reverts commit 1ee000a0b6737d6c140d4f07b6044908b8ebfdc7. Failures with the GLES3 conformance suite and Synmark2 OGLHdrBloom revealed that this commit was in error. Extensive testing with Piglit prior to patch review and upstreaming did not reveal this problem because, in the few Piglit tests that test for cube completeness, NumLayers = 6. This is because all of the existing tests use TextureStorage to initialize the texture, which sets NumLayers. A new Piglit test has been sent to the mailing list that reproduces the bug related to this patch ("texturing: Testing glGenerateMipmap(GL_TEXTURE_CUBE_MAP) without glTexStorage2D"). Reviewed-by: Jason Ekstrand --- src/mesa/main/texobj.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/mesa/main/texobj.c b/src/mesa/main/texobj.c index a99b108..e018ab9 100644 --- a/src/mesa/main/texobj.c +++ b/src/mesa/main/texobj.c @@ -879,10 +879,6 @@ _mesa_cube_level_complete(const struct gl_texture_object *texObj, if (texObj->Target != GL_TEXTURE_CUBE_MAP) return GL_FALSE; - /* Make sure we have enough image planes for a cube map. */ - if (texObj->NumLayers < 6) - return GL_FALSE; - if ((level < 0) || (level >= MAX_TEXTURE_LEVELS)) return GL_FALSE; From ldeks at kemper.freedesktop.org Tue Mar 17 17:20:05 2015 From: ldeks at kemper.freedesktop.org (Laura Ekstrand) Date: Tue, 17 Mar 2015 10:20:05 -0700 (PDT) Subject: Mesa (master): main: Add entry point for NamedBufferData. Message-ID: <20150317172005.7A88E76359@kemper.freedesktop.org> Module: Mesa Branch: master Commit: cb56835f870de01ed9c638d1470af38775bb6f72 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=cb56835f870de01ed9c638d1470af38775bb6f72 Author: Laura Ekstrand Date: Mon Feb 9 17:57:46 2015 -0800 main: Add entry point for NamedBufferData. v2: review from Ian Romanick - Fix space in ARB_direct_state_access.xml. - Remove "_mesa" from the name of buffer_data static fallback. - Restore VBO_DEBUG and BOUNDS_CHECK. - Fix beginning of comment to start on same line as /* Reviewed-by: Martin Peres --- src/mapi/glapi/gen/ARB_direct_state_access.xml | 7 +++ src/mesa/main/bufferobj.c | 69 +++++++++++++++++------- src/mesa/main/bufferobj.h | 13 ++++- src/mesa/main/tests/dispatch_sanity.cpp | 1 + 4 files changed, 68 insertions(+), 22 deletions(-) diff --git a/src/mapi/glapi/gen/ARB_direct_state_access.xml b/src/mapi/glapi/gen/ARB_direct_state_access.xml index ff81c21..7779262 100644 --- a/src/mapi/glapi/gen/ARB_direct_state_access.xml +++ b/src/mapi/glapi/gen/ARB_direct_state_access.xml @@ -21,6 +21,13 @@ + + + + + + + diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c index 73d4cb3..7d90a1f 100644 --- a/src/mesa/main/bufferobj.c +++ b/src/mesa/main/bufferobj.c @@ -561,9 +561,9 @@ _mesa_total_buffer_object_memory(struct gl_context *ctx) * \sa glBufferDataARB, dd_function_table::BufferData. */ static GLboolean -_mesa_buffer_data( struct gl_context *ctx, GLenum target, GLsizeiptrARB size, - const GLvoid * data, GLenum usage, GLenum storageFlags, - struct gl_buffer_object * bufObj ) +buffer_data_fallback(struct gl_context *ctx, GLenum target, GLsizeiptr size, + const GLvoid *data, GLenum usage, GLenum storageFlags, + struct gl_buffer_object *bufObj) { void * new_data; @@ -1117,7 +1117,7 @@ _mesa_init_buffer_object_functions(struct dd_function_table *driver) /* GL_ARB_vertex/pixel_buffer_object */ driver->NewBufferObject = _mesa_new_buffer_object; driver->DeleteBuffer = _mesa_delete_buffer_object; - driver->BufferData = _mesa_buffer_data; + driver->BufferData = buffer_data_fallback; driver->BufferSubData = _mesa_buffer_subdata; driver->GetBufferSubData = _mesa_buffer_get_subdata; driver->UnmapBuffer = _mesa_buffer_unmap; @@ -1492,23 +1492,22 @@ _mesa_NamedBufferStorage(GLuint buffer, GLsizeiptr size, const GLvoid *data, } - -void GLAPIENTRY -_mesa_BufferData(GLenum target, GLsizeiptrARB size, - const GLvoid * data, GLenum usage) +void +_mesa_buffer_data(struct gl_context *ctx, struct gl_buffer_object *bufObj, + GLenum target, GLsizeiptr size, const GLvoid *data, + GLenum usage, const char *func) { - GET_CURRENT_CONTEXT(ctx); - struct gl_buffer_object *bufObj; bool valid_usage; if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, "glBufferData(%s, %ld, %p, %s)\n", + _mesa_debug(ctx, "%s(%s, %ld, %p, %s)\n", + func, _mesa_lookup_enum_by_nr(target), (long int) size, data, _mesa_lookup_enum_by_nr(usage)); if (size < 0) { - _mesa_error(ctx, GL_INVALID_VALUE, "glBufferDataARB(size < 0)"); + _mesa_error(ctx, GL_INVALID_VALUE, "%s(size < 0)", func); return; } @@ -1537,16 +1536,13 @@ _mesa_BufferData(GLenum target, GLsizeiptrARB size, } if (!valid_usage) { - _mesa_error(ctx, GL_INVALID_ENUM, "glBufferData(usage)"); + _mesa_error(ctx, GL_INVALID_ENUM, "%s(invalid usage: %s)", func, + _mesa_lookup_enum_by_nr(usage)); return; } - bufObj = get_buffer(ctx, "glBufferDataARB", target, GL_INVALID_OPERATION); - if (!bufObj) - return; - if (bufObj->Immutable) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glBufferData(immutable)"); + _mesa_error(ctx, GL_INVALID_OPERATION, "%s(immutable)", func); return; } @@ -1579,14 +1575,47 @@ _mesa_BufferData(GLenum target, GLsizeiptrARB size, * EXTERNAL_VIRTUAL_MEMORY_BUFFER_AMD, and the store cannot be * mapped to the GPU address space. */ - _mesa_error(ctx, GL_INVALID_OPERATION, "glBufferData()"); + _mesa_error(ctx, GL_INVALID_OPERATION, "%s", func); } else { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glBufferData()"); + _mesa_error(ctx, GL_OUT_OF_MEMORY, "%s", func); } } } +void GLAPIENTRY +_mesa_BufferData(GLenum target, GLsizeiptr size, + const GLvoid *data, GLenum usage) +{ + GET_CURRENT_CONTEXT(ctx); + struct gl_buffer_object *bufObj; + + bufObj = get_buffer(ctx, "glBufferData", target, GL_INVALID_OPERATION); + if (!bufObj) + return; + + _mesa_buffer_data(ctx, bufObj, target, size, data, usage, + "glBufferData"); +} + +void GLAPIENTRY +_mesa_NamedBufferData(GLuint buffer, GLsizeiptr size, const GLvoid *data, + GLenum usage) +{ + GET_CURRENT_CONTEXT(ctx); + struct gl_buffer_object *bufObj; + + bufObj = _mesa_lookup_bufferobj_err(ctx, buffer, "glNamedBufferData"); + if (!bufObj) + return; + + /* In direct state access, buffer objects have an unspecified target since + * they are not required to be bound. + */ + _mesa_buffer_data(ctx, bufObj, GL_NONE, size, data, usage, + "glNamedBufferData"); +} + void GLAPIENTRY _mesa_BufferSubData(GLenum target, GLintptrARB offset, diff --git a/src/mesa/main/bufferobj.h b/src/mesa/main/bufferobj.h index 3c337aa..ddd240c 100644 --- a/src/mesa/main/bufferobj.h +++ b/src/mesa/main/bufferobj.h @@ -135,6 +135,11 @@ _mesa_buffer_storage(struct gl_context *ctx, struct gl_buffer_object *bufObj, GLbitfield flags, const char *func); extern void +_mesa_buffer_data(struct gl_context *ctx, struct gl_buffer_object *bufObj, + GLenum target, GLsizeiptr size, const GLvoid *data, + GLenum usage, const char *func); + +extern void _mesa_buffer_unmap_all_mappings(struct gl_context *ctx, struct gl_buffer_object *bufObj); @@ -172,8 +177,12 @@ _mesa_NamedBufferStorage(GLuint buffer, GLsizeiptr size, const GLvoid *data, GLbitfield flags); void GLAPIENTRY -_mesa_BufferData(GLenum target, GLsizeiptrARB size, - const GLvoid * data, GLenum usage); +_mesa_BufferData(GLenum target, GLsizeiptr size, + const GLvoid *data, GLenum usage); + +void GLAPIENTRY +_mesa_NamedBufferData(GLuint buffer, GLsizeiptr size, + const GLvoid *data, GLenum usage); void GLAPIENTRY _mesa_BufferSubData(GLenum target, GLintptrARB offset, diff --git a/src/mesa/main/tests/dispatch_sanity.cpp b/src/mesa/main/tests/dispatch_sanity.cpp index bc920d4..5047ca9 100644 --- a/src/mesa/main/tests/dispatch_sanity.cpp +++ b/src/mesa/main/tests/dispatch_sanity.cpp @@ -955,6 +955,7 @@ const struct function gl_core_functions_possible[] = { /* GL_ARB_direct_state_access */ { "glCreateBuffers", 45, -1 }, { "glNamedBufferStorage", 45, -1 }, + { "glNamedBufferData", 45, -1 }, { "glCreateTextures", 45, -1 }, { "glTextureStorage1D", 45, -1 }, { "glTextureStorage2D", 45, -1 }, From ldeks at kemper.freedesktop.org Tue Mar 17 17:20:05 2015 From: ldeks at kemper.freedesktop.org (Laura Ekstrand) Date: Tue, 17 Mar 2015 10:20:05 -0700 (PDT) Subject: Mesa (master): main: Improve errors and style in BufferSubData. Message-ID: <20150317172005.8EF8C76338@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 9cb732b8e9fad4a603f38ce896cd84300e2743a3 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=9cb732b8e9fad4a603f38ce896cd84300e2743a3 Author: Laura Ekstrand Date: Wed Feb 11 11:06:42 2015 -0800 main: Improve errors and style in BufferSubData. - More explicit error reporting. - Removed legacy style. Reviewed-by: Martin Peres --- src/mesa/main/bufferobj.c | 10 +++++++--- src/mesa/main/bufferobj.h | 4 ++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c index 5153679..f6bc333 100644 --- a/src/mesa/main/bufferobj.c +++ b/src/mesa/main/bufferobj.c @@ -272,13 +272,17 @@ buffer_object_subdata_range_good(struct gl_context *ctx, if (mappedRange) { if (bufferobj_range_mapped(bufObj, offset, size)) { - _mesa_error(ctx, GL_INVALID_OPERATION, "%s", caller); + _mesa_error(ctx, GL_INVALID_OPERATION, + "%s(range is mapped without persistent bit)", + caller); return false; } } else { if (_mesa_bufferobj_mapped(bufObj, MAP_USER)) { - _mesa_error(ctx, GL_INVALID_OPERATION, "%s", caller); + _mesa_error(ctx, GL_INVALID_OPERATION, + "%s(buffer is mapped without persistent bit)", + caller); return false; } } @@ -1642,7 +1646,7 @@ _mesa_buffer_sub_data(struct gl_context *ctx, struct gl_buffer_object *bufObj, bufObj->Written = GL_TRUE; assert(ctx->Driver.BufferSubData); - ctx->Driver.BufferSubData( ctx, offset, size, data, bufObj ); + ctx->Driver.BufferSubData(ctx, offset, size, data, bufObj); } void GLAPIENTRY diff --git a/src/mesa/main/bufferobj.h b/src/mesa/main/bufferobj.h index 889bbb1..d15ad00 100644 --- a/src/mesa/main/bufferobj.h +++ b/src/mesa/main/bufferobj.h @@ -190,8 +190,8 @@ _mesa_NamedBufferData(GLuint buffer, GLsizeiptr size, const GLvoid *data, GLenum usage); void GLAPIENTRY -_mesa_BufferSubData(GLenum target, GLintptrARB offset, - GLsizeiptrARB size, const GLvoid * data); +_mesa_BufferSubData(GLenum target, GLintptr offset, + GLsizeiptr size, const GLvoid *data); void GLAPIENTRY _mesa_NamedBufferSubData(GLuint buffer, GLintptr offset, From ldeks at kemper.freedesktop.org Tue Mar 17 17:20:05 2015 From: ldeks at kemper.freedesktop.org (Laura Ekstrand) Date: Tue, 17 Mar 2015 10:20:05 -0700 (PDT) Subject: Mesa (master): main: Add entry point for CopyNamedBufferSubData. Message-ID: <20150317172005.9913F76338@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 4adaad5fcc7fc959f24f807e783b6be2903e08a3 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=4adaad5fcc7fc959f24f807e783b6be2903e08a3 Author: Laura Ekstrand Date: Tue Jan 13 13:28:08 2015 -0800 main: Add entry point for CopyNamedBufferSubData. v2: remove _mesa in front of static software fallback. Reviewed-by: Martin Peres --- src/mapi/glapi/gen/ARB_direct_state_access.xml | 8 ++ src/mesa/main/bufferobj.c | 99 ++++++++++++++++-------- src/mesa/main/bufferobj.h | 12 +++ src/mesa/main/tests/dispatch_sanity.cpp | 1 + 4 files changed, 87 insertions(+), 33 deletions(-) diff --git a/src/mapi/glapi/gen/ARB_direct_state_access.xml b/src/mapi/glapi/gen/ARB_direct_state_access.xml index 6d70b8e..042b2a8 100644 --- a/src/mapi/glapi/gen/ARB_direct_state_access.xml +++ b/src/mapi/glapi/gen/ARB_direct_state_access.xml @@ -35,6 +35,14 @@ + + + + + + + + diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c index f6bc333..24ba458 100644 --- a/src/mesa/main/bufferobj.c +++ b/src/mesa/main/bufferobj.c @@ -766,11 +766,11 @@ _mesa_buffer_unmap(struct gl_context *ctx, struct gl_buffer_object *bufObj, * Called via glCopyBufferSubData(). */ static void -_mesa_copy_buffer_subdata(struct gl_context *ctx, - struct gl_buffer_object *src, - struct gl_buffer_object *dst, - GLintptr readOffset, GLintptr writeOffset, - GLsizeiptr size) +copy_buffer_sub_data_fallback(struct gl_context *ctx, + struct gl_buffer_object *src, + struct gl_buffer_object *dst, + GLintptr readOffset, GLintptr writeOffset, + GLsizeiptr size) { GLubyte *srcPtr, *dstPtr; @@ -1125,7 +1125,7 @@ _mesa_init_buffer_object_functions(struct dd_function_table *driver) driver->FlushMappedBufferRange = _mesa_buffer_flush_mapped_range; /* GL_ARB_copy_buffer */ - driver->CopyBufferSubData = _mesa_copy_buffer_subdata; + driver->CopyBufferSubData = copy_buffer_sub_data_fallback; } @@ -2130,65 +2130,54 @@ _mesa_GetBufferPointerv(GLenum target, GLenum pname, GLvoid **params) } -void GLAPIENTRY -_mesa_CopyBufferSubData(GLenum readTarget, GLenum writeTarget, - GLintptr readOffset, GLintptr writeOffset, - GLsizeiptr size) +void +_mesa_copy_buffer_sub_data(struct gl_context *ctx, + struct gl_buffer_object *src, + struct gl_buffer_object *dst, + GLintptr readOffset, GLintptr writeOffset, + GLsizeiptr size, const char *func) { - GET_CURRENT_CONTEXT(ctx); - struct gl_buffer_object *src, *dst; - - src = get_buffer(ctx, "glCopyBufferSubData", readTarget, - GL_INVALID_OPERATION); - if (!src) - return; - - dst = get_buffer(ctx, "glCopyBufferSubData", writeTarget, - GL_INVALID_OPERATION); - if (!dst) - return; - if (_mesa_check_disallowed_mapping(src)) { _mesa_error(ctx, GL_INVALID_OPERATION, - "glCopyBufferSubData(readBuffer is mapped)"); + "%s(readBuffer is mapped)", func); return; } if (_mesa_check_disallowed_mapping(dst)) { _mesa_error(ctx, GL_INVALID_OPERATION, - "glCopyBufferSubData(writeBuffer is mapped)"); + "%s(writeBuffer is mapped)", func); return; } if (readOffset < 0) { _mesa_error(ctx, GL_INVALID_VALUE, - "glCopyBufferSubData(readOffset = %d)", (int) readOffset); + "%s(readOffset %d < 0)", func, (int) readOffset); return; } if (writeOffset < 0) { _mesa_error(ctx, GL_INVALID_VALUE, - "glCopyBufferSubData(writeOffset = %d)", (int) writeOffset); + "%s(writeOffset %d < 0)", func, (int) writeOffset); return; } if (size < 0) { _mesa_error(ctx, GL_INVALID_VALUE, - "glCopyBufferSubData(writeOffset = %d)", (int) size); + "%s(size %d < 0)", func, (int) size); return; } if (readOffset + size > src->Size) { _mesa_error(ctx, GL_INVALID_VALUE, - "glCopyBufferSubData(readOffset + size = %d)", - (int) (readOffset + size)); + "%s(readOffset %d + size %d > src_buffer_size %d)", func, + (int) readOffset, (int) size, (int) src->Size); return; } if (writeOffset + size > dst->Size) { _mesa_error(ctx, GL_INVALID_VALUE, - "glCopyBufferSubData(writeOffset + size = %d)", - (int) (writeOffset + size)); + "%s(writeOffset %d + size %d > dst_buffer_size %d)", func, + (int) writeOffset, (int) size, (int) dst->Size); return; } @@ -2202,7 +2191,7 @@ _mesa_CopyBufferSubData(GLenum readTarget, GLenum writeTarget, else { /* overlapping src/dst is illegal */ _mesa_error(ctx, GL_INVALID_VALUE, - "glCopyBufferSubData(overlapping src/dst)"); + "%s(overlapping src/dst)", func); return; } } @@ -2210,6 +2199,50 @@ _mesa_CopyBufferSubData(GLenum readTarget, GLenum writeTarget, ctx->Driver.CopyBufferSubData(ctx, src, dst, readOffset, writeOffset, size); } +void GLAPIENTRY +_mesa_CopyBufferSubData(GLenum readTarget, GLenum writeTarget, + GLintptr readOffset, GLintptr writeOffset, + GLsizeiptr size) +{ + GET_CURRENT_CONTEXT(ctx); + struct gl_buffer_object *src, *dst; + + src = get_buffer(ctx, "glCopyBufferSubData", readTarget, + GL_INVALID_OPERATION); + if (!src) + return; + + dst = get_buffer(ctx, "glCopyBufferSubData", writeTarget, + GL_INVALID_OPERATION); + if (!dst) + return; + + _mesa_copy_buffer_sub_data(ctx, src, dst, readOffset, writeOffset, size, + "glCopyBufferSubData"); +} + +void GLAPIENTRY +_mesa_CopyNamedBufferSubData(GLuint readBuffer, GLuint writeBuffer, + GLintptr readOffset, GLintptr writeOffset, + GLsizeiptr size) +{ + GET_CURRENT_CONTEXT(ctx); + struct gl_buffer_object *src, *dst; + + src = _mesa_lookup_bufferobj_err(ctx, readBuffer, + "glCopyNamedBufferSubData"); + if (!src) + return; + + dst = _mesa_lookup_bufferobj_err(ctx, writeBuffer, + "glCopyNamedBufferSubData"); + if (!dst) + return; + + _mesa_copy_buffer_sub_data(ctx, src, dst, readOffset, writeOffset, size, + "glCopyNamedBufferSubData"); +} + /** * See GL_ARB_map_buffer_range spec diff --git a/src/mesa/main/bufferobj.h b/src/mesa/main/bufferobj.h index d15ad00..7db5c98 100644 --- a/src/mesa/main/bufferobj.h +++ b/src/mesa/main/bufferobj.h @@ -149,6 +149,13 @@ _mesa_buffer_unmap_all_mappings(struct gl_context *ctx, struct gl_buffer_object *bufObj); extern void +_mesa_copy_buffer_sub_data(struct gl_context *ctx, + struct gl_buffer_object *src, + struct gl_buffer_object *dst, + GLintptr readOffset, GLintptr writeOffset, + GLsizeiptr size, const char *func); + +extern void _mesa_buffer_clear_subdata(struct gl_context *ctx, GLintptr offset, GLsizeiptr size, const GLvoid *clearValue, @@ -232,6 +239,11 @@ _mesa_CopyBufferSubData(GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); +void GLAPIENTRY +_mesa_CopyNamedBufferSubData(GLuint readBuffer, GLuint writeBuffer, + GLintptr readOffset, GLintptr writeOffset, + GLsizeiptr size); + void * GLAPIENTRY _mesa_MapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); diff --git a/src/mesa/main/tests/dispatch_sanity.cpp b/src/mesa/main/tests/dispatch_sanity.cpp index 9597e06..63b9dcf 100644 --- a/src/mesa/main/tests/dispatch_sanity.cpp +++ b/src/mesa/main/tests/dispatch_sanity.cpp @@ -957,6 +957,7 @@ const struct function gl_core_functions_possible[] = { { "glNamedBufferStorage", 45, -1 }, { "glNamedBufferData", 45, -1 }, { "glNamedBufferSubData", 45, -1 }, + { "glCopyNamedBufferSubData", 45, -1 }, { "glCreateTextures", 45, -1 }, { "glTextureStorage1D", 45, -1 }, { "glTextureStorage2D", 45, -1 }, From ldeks at kemper.freedesktop.org Tue Mar 17 17:20:05 2015 From: ldeks at kemper.freedesktop.org (Laura Ekstrand) Date: Tue, 17 Mar 2015 10:20:05 -0700 (PDT) Subject: Mesa (master): main: Minor whitespace fixes in ClearNamedBuffer[Sub]Data. Message-ID: <20150317172005.BB0C876338@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 16244525fbe09ff41074eb36a435875892e316a9 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=16244525fbe09ff41074eb36a435875892e316a9 Author: Laura Ekstrand Date: Wed Feb 11 11:45:57 2015 -0800 main: Minor whitespace fixes in ClearNamedBuffer[Sub]Data. Reviewed-by: Fredrik H?glund --- src/mesa/main/bufferobj.c | 4 ++-- src/mesa/main/bufferobj.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c index ae086a6..0e77f73 100644 --- a/src/mesa/main/bufferobj.c +++ b/src/mesa/main/bufferobj.c @@ -1794,10 +1794,10 @@ void GLAPIENTRY _mesa_ClearBufferSubData(GLenum target, GLenum internalformat, GLintptr offset, GLsizeiptr size, GLenum format, GLenum type, - const GLvoid* data) + const GLvoid *data) { GET_CURRENT_CONTEXT(ctx); - struct gl_buffer_object* bufObj; + struct gl_buffer_object *bufObj; bufObj = get_buffer(ctx, "glClearBufferSubData", target, GL_INVALID_VALUE); if (!bufObj) diff --git a/src/mesa/main/bufferobj.h b/src/mesa/main/bufferobj.h index 5254727..2a66444 100644 --- a/src/mesa/main/bufferobj.h +++ b/src/mesa/main/bufferobj.h @@ -220,7 +220,7 @@ _mesa_GetBufferSubData(GLenum target, GLintptrARB offset, void GLAPIENTRY _mesa_ClearBufferData(GLenum target, GLenum internalformat, GLenum format, GLenum type, - const GLvoid * data); + const GLvoid *data); void GLAPIENTRY _mesa_ClearNamedBufferData(GLuint buffer, GLenum internalformat, @@ -231,7 +231,7 @@ void GLAPIENTRY _mesa_ClearBufferSubData(GLenum target, GLenum internalformat, GLintptr offset, GLsizeiptr size, GLenum format, GLenum type, - const GLvoid * data); + const GLvoid *data); void GLAPIENTRY _mesa_ClearNamedBufferSubData(GLuint buffer, GLenum internalformat, From ldeks at kemper.freedesktop.org Tue Mar 17 17:20:05 2015 From: ldeks at kemper.freedesktop.org (Laura Ekstrand) Date: Tue, 17 Mar 2015 10:20:05 -0700 (PDT) Subject: Mesa (master): main: Add entry points for MapNamedBuffer[Range]. Message-ID: <20150317172005.D14AE76338@kemper.freedesktop.org> Module: Mesa Branch: master Commit: a0cc03929e754692ae593df5072d144460434297 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=a0cc03929e754692ae593df5072d144460434297 Author: Laura Ekstrand Date: Wed Feb 11 14:09:52 2015 -0800 main: Add entry points for MapNamedBuffer[Range]. Reviewed-by: Fredrik H?glund --- src/mapi/glapi/gen/ARB_direct_state_access.xml | 14 ++++++++ src/mesa/main/bufferobj.c | 42 ++++++++++++++++++++++++ src/mesa/main/bufferobj.h | 14 ++++++-- src/mesa/main/tests/dispatch_sanity.cpp | 2 ++ 4 files changed, 69 insertions(+), 3 deletions(-) diff --git a/src/mapi/glapi/gen/ARB_direct_state_access.xml b/src/mapi/glapi/gen/ARB_direct_state_access.xml index ce4017b..557316a 100644 --- a/src/mapi/glapi/gen/ARB_direct_state_access.xml +++ b/src/mapi/glapi/gen/ARB_direct_state_access.xml @@ -61,6 +61,20 @@ + + + + + + + + + + + + + + diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c index d37e4a5..0d1a690 100644 --- a/src/mesa/main/bufferobj.c +++ b/src/mesa/main/bufferobj.c @@ -2346,6 +2346,28 @@ _mesa_MapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length, "glMapBufferRange"); } +void * GLAPIENTRY +_mesa_MapNamedBufferRange(GLuint buffer, GLintptr offset, GLsizeiptr length, + GLbitfield access) +{ + GET_CURRENT_CONTEXT(ctx); + struct gl_buffer_object *bufObj; + + if (!ctx->Extensions.ARB_map_buffer_range) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glMapNamedBufferRange(" + "ARB_map_buffer_range not supported)"); + return NULL; + } + + bufObj = _mesa_lookup_bufferobj_err(ctx, buffer, "glMapNamedBufferRange"); + if (!bufObj) + return NULL; + + return _mesa_map_buffer_range(ctx, bufObj, offset, length, access, + "glMapNamedBufferRange"); +} + /** * Converts GLenum access from MapBuffer and MapNamedBuffer into * flags for input to _mesa_map_buffer_range. @@ -2391,6 +2413,26 @@ _mesa_MapBuffer(GLenum target, GLenum access) "glMapBuffer"); } +void * GLAPIENTRY +_mesa_MapNamedBuffer(GLuint buffer, GLenum access) +{ + GET_CURRENT_CONTEXT(ctx); + struct gl_buffer_object *bufObj; + GLbitfield accessFlags; + + if (!get_map_buffer_access_flags(ctx, access, &accessFlags)) { + _mesa_error(ctx, GL_INVALID_ENUM, "glMapNamedBuffer(invalid access)"); + return NULL; + } + + bufObj = _mesa_lookup_bufferobj_err(ctx, buffer, "glMapNamedBuffer"); + if (!bufObj) + return NULL; + + return _mesa_map_buffer_range(ctx, bufObj, 0, bufObj->Size, accessFlags, + "glMapNamedBuffer"); +} + /** * See GL_ARB_map_buffer_range spec diff --git a/src/mesa/main/bufferobj.h b/src/mesa/main/bufferobj.h index 3584a80..6305b5c 100644 --- a/src/mesa/main/bufferobj.h +++ b/src/mesa/main/bufferobj.h @@ -245,9 +245,6 @@ _mesa_ClearNamedBufferSubData(GLuint buffer, GLenum internalformat, GLenum format, GLenum type, const GLvoid *data); -void * GLAPIENTRY -_mesa_MapBuffer(GLenum target, GLenum access); - GLboolean GLAPIENTRY _mesa_UnmapBuffer(GLenum target); @@ -274,6 +271,17 @@ void * GLAPIENTRY _mesa_MapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); +void * GLAPIENTRY +_mesa_MapNamedBufferRange(GLuint buffer, GLintptr offset, GLsizeiptr length, + GLbitfield access); + +void * GLAPIENTRY +_mesa_MapBuffer(GLenum target, GLenum access); + +void * GLAPIENTRY +_mesa_MapNamedBuffer(GLuint buffer, GLenum access); + + void GLAPIENTRY _mesa_FlushMappedBufferRange(GLenum target, GLintptr offset, GLsizeiptr length); diff --git a/src/mesa/main/tests/dispatch_sanity.cpp b/src/mesa/main/tests/dispatch_sanity.cpp index aff5cd6..bda761a 100644 --- a/src/mesa/main/tests/dispatch_sanity.cpp +++ b/src/mesa/main/tests/dispatch_sanity.cpp @@ -960,6 +960,8 @@ const struct function gl_core_functions_possible[] = { { "glCopyNamedBufferSubData", 45, -1 }, { "glClearNamedBufferData", 45, -1 }, { "glClearNamedBufferSubData", 45, -1 }, + { "glMapNamedBuffer", 45, -1 }, + { "glMapNamedBufferRange", 45, -1 }, { "glCreateTextures", 45, -1 }, { "glTextureStorage1D", 45, -1 }, { "glTextureStorage2D", 45, -1 }, From ldeks at kemper.freedesktop.org Tue Mar 17 17:20:05 2015 From: ldeks at kemper.freedesktop.org (Laura Ekstrand) Date: Tue, 17 Mar 2015 10:20:05 -0700 (PDT) Subject: Mesa (master): main: Add entry point for FlushMappedNamedBufferRange. Message-ID: <20150317172006.00CBE76338@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 1cfc18da8d3220fd6b123b6e269b3b440988027b URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=1cfc18da8d3220fd6b123b6e269b3b440988027b Author: Laura Ekstrand Date: Wed Feb 11 16:06:52 2015 -0800 main: Add entry point for FlushMappedNamedBufferRange. Reviewed-by: Fredrik H?glund --- src/mapi/glapi/gen/ARB_direct_state_access.xml | 6 ++++++ src/mesa/main/bufferobj.c | 16 ++++++++++++++++ src/mesa/main/bufferobj.h | 4 ++++ src/mesa/main/tests/dispatch_sanity.cpp | 1 + 4 files changed, 27 insertions(+) diff --git a/src/mapi/glapi/gen/ARB_direct_state_access.xml b/src/mapi/glapi/gen/ARB_direct_state_access.xml index 281646d..27938c5 100644 --- a/src/mapi/glapi/gen/ARB_direct_state_access.xml +++ b/src/mapi/glapi/gen/ARB_direct_state_access.xml @@ -80,6 +80,12 @@ + + + + + + diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c index d646617..99f1432 100644 --- a/src/mesa/main/bufferobj.c +++ b/src/mesa/main/bufferobj.c @@ -2524,6 +2524,22 @@ _mesa_FlushMappedBufferRange(GLenum target, GLintptr offset, "glFlushMappedBufferRange"); } +void GLAPIENTRY +_mesa_FlushMappedNamedBufferRange(GLuint buffer, GLintptr offset, + GLsizeiptr length) +{ + GET_CURRENT_CONTEXT(ctx); + struct gl_buffer_object *bufObj; + + bufObj = _mesa_lookup_bufferobj_err(ctx, buffer, + "glFlushMappedNamedBufferRange"); + if (!bufObj) + return; + + _mesa_flush_mapped_buffer_range(ctx, bufObj, offset, length, + "glFlushMappedNamedBufferRange"); +} + static GLenum buffer_object_purgeable(struct gl_context *ctx, GLuint name, GLenum option) diff --git a/src/mesa/main/bufferobj.h b/src/mesa/main/bufferobj.h index f51bf36..0b77bff 100644 --- a/src/mesa/main/bufferobj.h +++ b/src/mesa/main/bufferobj.h @@ -299,6 +299,10 @@ void GLAPIENTRY _mesa_FlushMappedBufferRange(GLenum target, GLintptr offset, GLsizeiptr length); +void GLAPIENTRY +_mesa_FlushMappedNamedBufferRange(GLuint buffer, GLintptr offset, + GLsizeiptr length); + GLenum GLAPIENTRY _mesa_ObjectPurgeableAPPLE(GLenum objectType, GLuint name, GLenum option); diff --git a/src/mesa/main/tests/dispatch_sanity.cpp b/src/mesa/main/tests/dispatch_sanity.cpp index fb077b3..3dd0751 100644 --- a/src/mesa/main/tests/dispatch_sanity.cpp +++ b/src/mesa/main/tests/dispatch_sanity.cpp @@ -963,6 +963,7 @@ const struct function gl_core_functions_possible[] = { { "glMapNamedBuffer", 45, -1 }, { "glMapNamedBufferRange", 45, -1 }, { "glUnmapNamedBuffer", 45, -1 }, + { "glFlushMappedNamedBufferRange", 45, -1 }, { "glCreateTextures", 45, -1 }, { "glTextureStorage1D", 45, -1 }, { "glTextureStorage2D", 45, -1 }, From ldeks at kemper.freedesktop.org Tue Mar 17 17:20:05 2015 From: ldeks at kemper.freedesktop.org (Laura Ekstrand) Date: Tue, 17 Mar 2015 10:20:05 -0700 (PDT) Subject: Mesa (master): main: Add entry point for CreateBuffers. Message-ID: <20150317172005.6030876338@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 2cf48c37c1e2946f7c0648e0a5927a90209f59a4 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=2cf48c37c1e2946f7c0648e0a5927a90209f59a4 Author: Laura Ekstrand Date: Thu Dec 18 17:10:06 2014 -0800 main: Add entry point for CreateBuffers. Reviewed-by: Martin Peres --- src/mapi/glapi/gen/ARB_direct_state_access.xml | 7 +++ src/mesa/main/bufferobj.c | 65 +++++++++++++++++++----- src/mesa/main/bufferobj.h | 5 +- src/mesa/main/tests/dispatch_sanity.cpp | 1 + 4 files changed, 64 insertions(+), 14 deletions(-) diff --git a/src/mapi/glapi/gen/ARB_direct_state_access.xml b/src/mapi/glapi/gen/ARB_direct_state_access.xml index 86c00f9..6c9d0e8 100644 --- a/src/mapi/glapi/gen/ARB_direct_state_access.xml +++ b/src/mapi/glapi/gen/ARB_direct_state_access.xml @@ -7,6 +7,13 @@ + + + + + + + diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c index cef284f..01bb131 100644 --- a/src/mesa/main/bufferobj.c +++ b/src/mesa/main/bufferobj.c @@ -1292,27 +1292,29 @@ _mesa_DeleteBuffers(GLsizei n, const GLuint *ids) /** - * Generate a set of unique buffer object IDs and store them in \c buffer. - * - * \param n Number of IDs to generate. - * \param buffer Array of \c n locations to store the IDs. + * This is the implementation for glGenBuffers and glCreateBuffers. It is not + * exposed to the rest of Mesa to encourage the use of nameless buffers in + * driver internals. */ -void GLAPIENTRY -_mesa_GenBuffers(GLsizei n, GLuint *buffer) +static void +create_buffers(GLsizei n, GLuint *buffers, bool dsa) { GET_CURRENT_CONTEXT(ctx); GLuint first; GLint i; + struct gl_buffer_object *buf; + + const char *func = dsa ? "glCreateBuffers" : "glGenBuffers"; if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, "glGenBuffers(%d)\n", n); + _mesa_debug(ctx, "%s(%d)\n", func, n); if (n < 0) { - _mesa_error(ctx, GL_INVALID_VALUE, "glGenBuffersARB"); + _mesa_error(ctx, GL_INVALID_VALUE, "%s(n %d < 0)", func, n); return; } - if (!buffer) { + if (!buffers) { return; } @@ -1323,16 +1325,53 @@ _mesa_GenBuffers(GLsizei n, GLuint *buffer) first = _mesa_HashFindFreeKeyBlock(ctx->Shared->BufferObjects, n); - /* Insert the ID and pointer to dummy buffer object into hash table */ + /* Insert the ID and pointer into the hash table. If non-DSA, insert a + * DummyBufferObject. Otherwise, create a new buffer object and insert + * it. + */ for (i = 0; i < n; i++) { - _mesa_HashInsert(ctx->Shared->BufferObjects, first + i, - &DummyBufferObject); - buffer[i] = first + i; + buffers[i] = first + i; + if (dsa) { + assert(ctx->Driver.NewBufferObject); + buf = ctx->Driver.NewBufferObject(ctx, buffers[i]); + if (!buf) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "%s", func); + return; + } + } + else + buf = &DummyBufferObject; + + _mesa_HashInsert(ctx->Shared->BufferObjects, buffers[i], buf); } mtx_unlock(&ctx->Shared->Mutex); } +/** + * Generate a set of unique buffer object IDs and store them in \c buffers. + * + * \param n Number of IDs to generate. + * \param buffers Array of \c n locations to store the IDs. + */ +void GLAPIENTRY +_mesa_GenBuffers(GLsizei n, GLuint *buffers) +{ + create_buffers(n, buffers, false); +} + +/** + * Create a set of buffer objects and store their unique IDs in \c buffers. + * + * \param n Number of IDs to generate. + * \param buffers Array of \c n locations to store the IDs. + */ +void GLAPIENTRY +_mesa_CreateBuffers(GLsizei n, GLuint *buffers) +{ + create_buffers(n, buffers, true); +} + /** * Determine if ID is the name of a buffer object. diff --git a/src/mesa/main/bufferobj.h b/src/mesa/main/bufferobj.h index 8e53bfd..48d253b 100644 --- a/src/mesa/main/bufferobj.h +++ b/src/mesa/main/bufferobj.h @@ -150,7 +150,10 @@ void GLAPIENTRY _mesa_DeleteBuffers(GLsizei n, const GLuint * buffer); void GLAPIENTRY -_mesa_GenBuffers(GLsizei n, GLuint * buffer); +_mesa_GenBuffers(GLsizei n, GLuint *buffers); + +void GLAPIENTRY +_mesa_CreateBuffers(GLsizei n, GLuint *buffers); GLboolean GLAPIENTRY _mesa_IsBuffer(GLuint buffer); diff --git a/src/mesa/main/tests/dispatch_sanity.cpp b/src/mesa/main/tests/dispatch_sanity.cpp index 8f7f69e..15a1138 100644 --- a/src/mesa/main/tests/dispatch_sanity.cpp +++ b/src/mesa/main/tests/dispatch_sanity.cpp @@ -953,6 +953,7 @@ const struct function gl_core_functions_possible[] = { { "glClipControl", 45, -1 }, /* GL_ARB_direct_state_access */ + { "glCreateBuffers", 45, -1 }, { "glCreateTextures", 45, -1 }, { "glTextureStorage1D", 45, -1 }, { "glTextureStorage2D", 45, -1 }, From ldeks at kemper.freedesktop.org Tue Mar 17 17:20:05 2015 From: ldeks at kemper.freedesktop.org (Laura Ekstrand) Date: Tue, 17 Mar 2015 10:20:05 -0700 (PDT) Subject: Mesa (master): main: Add entry point for NamedBufferSubData. Message-ID: <20150317172005.8557476338@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 566ccdf11b37363255bf5d20d7ab6639ddaf1b30 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=566ccdf11b37363255bf5d20d7ab6639ddaf1b30 Author: Laura Ekstrand Date: Tue Jan 13 11:28:17 2015 -0800 main: Add entry point for NamedBufferSubData. v2: review by Ian Romanick - Remove "_mesa" from name of static software fallback buffer_sub_data. - Remove mappedRange from _mesa_buffer_sub_data. - Removed some cosmetic changes to a separate commit. Reviewed-by: Martin Peres --- src/mapi/glapi/gen/ARB_direct_state_access.xml | 7 ++ src/mesa/main/bufferobj.c | 129 +++++++++++++++--------- src/mesa/main/bufferobj.h | 9 ++ src/mesa/main/tests/dispatch_sanity.cpp | 1 + 4 files changed, 97 insertions(+), 49 deletions(-) diff --git a/src/mapi/glapi/gen/ARB_direct_state_access.xml b/src/mapi/glapi/gen/ARB_direct_state_access.xml index 7779262..6d70b8e 100644 --- a/src/mapi/glapi/gen/ARB_direct_state_access.xml +++ b/src/mapi/glapi/gen/ARB_direct_state_access.xml @@ -28,6 +28,13 @@ + + + + + + + diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c index 7d90a1f..5153679 100644 --- a/src/mesa/main/bufferobj.c +++ b/src/mesa/main/bufferobj.c @@ -232,67 +232,58 @@ bufferobj_range_mapped(const struct gl_buffer_object *obj, * \c glClearBufferSubData. * * \param ctx GL context. - * \param target Buffer object target on which to operate. + * \param bufObj The buffer object. * \param offset Offset of the first byte of the subdata range. * \param size Size, in bytes, of the subdata range. * \param mappedRange If true, checks if an overlapping range is mapped. * If false, checks if buffer is mapped. - * \param errorNoBuffer Error code if no buffer is bound to target. * \param caller Name of calling function for recording errors. - * \return A pointer to the buffer object bound to \c target in the - * specified context or \c NULL if any of the parameter or state - * conditions are invalid. + * \return false if error, true otherwise * * \sa glBufferSubDataARB, glGetBufferSubDataARB, glClearBufferSubData */ -static struct gl_buffer_object * -buffer_object_subdata_range_good(struct gl_context * ctx, GLenum target, - GLintptrARB offset, GLsizeiptrARB size, - bool mappedRange, GLenum errorNoBuffer, - const char *caller) +static bool +buffer_object_subdata_range_good(struct gl_context *ctx, + struct gl_buffer_object *bufObj, + GLintptr offset, GLsizeiptr size, + bool mappedRange, const char *caller) { - struct gl_buffer_object *bufObj; - if (size < 0) { _mesa_error(ctx, GL_INVALID_VALUE, "%s(size < 0)", caller); - return NULL; + return false; } if (offset < 0) { _mesa_error(ctx, GL_INVALID_VALUE, "%s(offset < 0)", caller); - return NULL; + return false; } - bufObj = get_buffer(ctx, caller, target, errorNoBuffer); - if (!bufObj) - return NULL; - if (offset + size > bufObj->Size) { _mesa_error(ctx, GL_INVALID_VALUE, "%s(offset %lu + size %lu > buffer size %lu)", caller, (unsigned long) offset, (unsigned long) size, (unsigned long) bufObj->Size); - return NULL; + return false; } if (bufObj->Mappings[MAP_USER].AccessFlags & GL_MAP_PERSISTENT_BIT) - return bufObj; + return true; if (mappedRange) { if (bufferobj_range_mapped(bufObj, offset, size)) { _mesa_error(ctx, GL_INVALID_OPERATION, "%s", caller); - return NULL; + return false; } } else { if (_mesa_bufferobj_mapped(bufObj, MAP_USER)) { _mesa_error(ctx, GL_INVALID_OPERATION, "%s", caller); - return NULL; + return false; } } - return bufObj; + return true; } @@ -607,9 +598,9 @@ buffer_data_fallback(struct gl_context *ctx, GLenum target, GLsizeiptr size, * \sa glBufferSubDataARB, dd_function_table::BufferSubData. */ static void -_mesa_buffer_subdata( struct gl_context *ctx, GLintptrARB offset, - GLsizeiptrARB size, const GLvoid * data, - struct gl_buffer_object * bufObj ) +buffer_sub_data_fallback(struct gl_context *ctx, GLintptr offset, + GLsizeiptr size, const GLvoid *data, + struct gl_buffer_object *bufObj) { (void) ctx; @@ -1118,7 +1109,7 @@ _mesa_init_buffer_object_functions(struct dd_function_table *driver) driver->NewBufferObject = _mesa_new_buffer_object; driver->DeleteBuffer = _mesa_delete_buffer_object; driver->BufferData = buffer_data_fallback; - driver->BufferSubData = _mesa_buffer_subdata; + driver->BufferSubData = buffer_sub_data_fallback; driver->GetBufferSubData = _mesa_buffer_get_subdata; driver->UnmapBuffer = _mesa_buffer_unmap; @@ -1617,24 +1608,31 @@ _mesa_NamedBufferData(GLuint buffer, GLsizeiptr size, const GLvoid *data, } -void GLAPIENTRY -_mesa_BufferSubData(GLenum target, GLintptrARB offset, - GLsizeiptrARB size, const GLvoid * data) +/** + * Implementation for glBufferSubData and glNamedBufferSubData. + * + * \param ctx GL context. + * \param bufObj The buffer object. + * \param offset Offset of the first byte of the subdata range. + * \param size Size, in bytes, of the subdata range. + * \param data The data store. + * \param func Name of calling function for recording errors. + * + */ +void +_mesa_buffer_sub_data(struct gl_context *ctx, struct gl_buffer_object *bufObj, + GLintptr offset, GLsizeiptr size, const GLvoid *data, + const char *func) { - GET_CURRENT_CONTEXT(ctx); - struct gl_buffer_object *bufObj; - - bufObj = buffer_object_subdata_range_good( ctx, target, offset, size, - false, GL_INVALID_OPERATION, - "glBufferSubDataARB" ); - if (!bufObj) { + if (!buffer_object_subdata_range_good(ctx, bufObj, offset, size, + false, func)) { /* error already recorded */ return; } if (bufObj->Immutable && !(bufObj->StorageFlags & GL_DYNAMIC_STORAGE_BIT)) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glBufferSubData"); + _mesa_error(ctx, GL_INVALID_OPERATION, func); return; } @@ -1647,19 +1645,50 @@ _mesa_BufferSubData(GLenum target, GLintptrARB offset, ctx->Driver.BufferSubData( ctx, offset, size, data, bufObj ); } +void GLAPIENTRY +_mesa_BufferSubData(GLenum target, GLintptr offset, + GLsizeiptr size, const GLvoid *data) +{ + GET_CURRENT_CONTEXT(ctx); + struct gl_buffer_object *bufObj; + + bufObj = get_buffer(ctx, "glBufferSubData", target, GL_INVALID_OPERATION); + if (!bufObj) + return; + + _mesa_buffer_sub_data(ctx, bufObj, offset, size, data, "glBufferSubData"); +} void GLAPIENTRY -_mesa_GetBufferSubData(GLenum target, GLintptrARB offset, - GLsizeiptrARB size, void * data) +_mesa_NamedBufferSubData(GLuint buffer, GLintptr offset, + GLsizeiptr size, const GLvoid *data) { GET_CURRENT_CONTEXT(ctx); struct gl_buffer_object *bufObj; - bufObj = buffer_object_subdata_range_good(ctx, target, offset, size, - false, GL_INVALID_OPERATION, - "glGetBufferSubDataARB"); - if (!bufObj) { - /* error already recorded */ + bufObj = _mesa_lookup_bufferobj_err(ctx, buffer, "glNamedBufferSubData"); + if (!bufObj) + return; + + _mesa_buffer_sub_data(ctx, bufObj, offset, size, data, + "glNamedBufferSubData"); +} + + +void GLAPIENTRY +_mesa_GetBufferSubData(GLenum target, GLintptr offset, + GLsizeiptr size, GLvoid *data) +{ + GET_CURRENT_CONTEXT(ctx); + struct gl_buffer_object *bufObj; + + bufObj = get_buffer(ctx, "glGetBufferSubData", target, + GL_INVALID_OPERATION); + if (!bufObj) + return; + + if (!buffer_object_subdata_range_good(ctx, bufObj, offset, size, false, + "glGetBufferSubData")) { return; } @@ -1733,10 +1762,12 @@ _mesa_ClearBufferSubData(GLenum target, GLenum internalformat, GLubyte clearValue[MAX_PIXEL_BYTES]; GLsizeiptr clearValueSize; - bufObj = buffer_object_subdata_range_good(ctx, target, offset, size, - true, GL_INVALID_VALUE, - "glClearBufferSubData"); - if (!bufObj) { + bufObj = get_buffer(ctx, "glClearBufferSubData", target, GL_INVALID_VALUE); + if (!bufObj) + return; + + if (!buffer_object_subdata_range_good(ctx, bufObj, offset, size, + true, "glClearBufferSubData")) { return; } diff --git a/src/mesa/main/bufferobj.h b/src/mesa/main/bufferobj.h index ddd240c..889bbb1 100644 --- a/src/mesa/main/bufferobj.h +++ b/src/mesa/main/bufferobj.h @@ -140,6 +140,11 @@ _mesa_buffer_data(struct gl_context *ctx, struct gl_buffer_object *bufObj, GLenum usage, const char *func); extern void +_mesa_buffer_sub_data(struct gl_context *ctx, struct gl_buffer_object *bufObj, + GLintptr offset, GLsizeiptr size, const GLvoid *data, + const char *func); + +extern void _mesa_buffer_unmap_all_mappings(struct gl_context *ctx, struct gl_buffer_object *bufObj); @@ -189,6 +194,10 @@ _mesa_BufferSubData(GLenum target, GLintptrARB offset, GLsizeiptrARB size, const GLvoid * data); void GLAPIENTRY +_mesa_NamedBufferSubData(GLuint buffer, GLintptr offset, + GLsizeiptr size, const GLvoid *data); + +void GLAPIENTRY _mesa_GetBufferSubData(GLenum target, GLintptrARB offset, GLsizeiptrARB size, void * data); diff --git a/src/mesa/main/tests/dispatch_sanity.cpp b/src/mesa/main/tests/dispatch_sanity.cpp index 5047ca9..9597e06 100644 --- a/src/mesa/main/tests/dispatch_sanity.cpp +++ b/src/mesa/main/tests/dispatch_sanity.cpp @@ -956,6 +956,7 @@ const struct function gl_core_functions_possible[] = { { "glCreateBuffers", 45, -1 }, { "glNamedBufferStorage", 45, -1 }, { "glNamedBufferData", 45, -1 }, + { "glNamedBufferSubData", 45, -1 }, { "glCreateTextures", 45, -1 }, { "glTextureStorage1D", 45, -1 }, { "glTextureStorage2D", 45, -1 }, From ldeks at kemper.freedesktop.org Tue Mar 17 17:20:05 2015 From: ldeks at kemper.freedesktop.org (Laura Ekstrand) Date: Tue, 17 Mar 2015 10:20:05 -0700 (PDT) Subject: Mesa (master): main: Refactor ClearBuffer[Sub]Data. Message-ID: <20150317172005.A58A276338@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 9fa6c3637a53603bc92db8a97b71cf35d88e5176 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=9fa6c3637a53603bc92db8a97b71cf35d88e5176 Author: Laura Ekstrand Date: Tue Jan 13 15:20:19 2015 -0800 main: Refactor ClearBuffer[Sub]Data. v2: review by Jason Ekstrand - Split refactor of clear buffer sub data from addition of DSA entry points. Reviewed-by: Martin Peres --- src/mesa/main/bufferobj.c | 125 +++++++++++--------------- src/mesa/main/bufferobj.h | 19 ++-- src/mesa/state_tracker/st_cb_bufferobjects.c | 4 +- 3 files changed, 69 insertions(+), 79 deletions(-) diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c index 24ba458..b2d0ef9 100644 --- a/src/mesa/main/bufferobj.c +++ b/src/mesa/main/bufferobj.c @@ -665,11 +665,11 @@ _mesa_buffer_get_subdata( struct gl_context *ctx, GLintptrARB offset, * dd_function_table::ClearBufferSubData. */ void -_mesa_buffer_clear_subdata(struct gl_context *ctx, - GLintptr offset, GLsizeiptr size, - const GLvoid *clearValue, - GLsizeiptr clearValueSize, - struct gl_buffer_object *bufObj) +_mesa_ClearBufferSubData_sw(struct gl_context *ctx, + GLintptr offset, GLsizeiptr size, + const GLvoid *clearValue, + GLsizeiptr clearValueSize, + struct gl_buffer_object *bufObj) { GLsizeiptr i; GLubyte *dest; @@ -1118,7 +1118,7 @@ _mesa_init_buffer_object_functions(struct dd_function_table *driver) driver->UnmapBuffer = _mesa_buffer_unmap; /* GL_ARB_clear_buffer_object */ - driver->ClearBufferSubData = _mesa_buffer_clear_subdata; + driver->ClearBufferSubData = _mesa_ClearBufferSubData_sw; /* GL_ARB_map_buffer_range */ driver->MapBufferRange = _mesa_buffer_map_range; @@ -1700,57 +1700,77 @@ _mesa_GetBufferSubData(GLenum target, GLintptr offset, ctx->Driver.GetBufferSubData( ctx, offset, size, data, bufObj ); } - -void GLAPIENTRY -_mesa_ClearBufferData(GLenum target, GLenum internalformat, GLenum format, - GLenum type, const GLvoid* data) +/** + * \param subdata true if caller is *SubData, false if *Data + */ +void +_mesa_clear_buffer_sub_data(struct gl_context *ctx, + struct gl_buffer_object *bufObj, + GLenum internalformat, + GLintptr offset, GLsizeiptr size, + GLenum format, GLenum type, + const GLvoid *data, + const char *func, bool subdata) { - GET_CURRENT_CONTEXT(ctx); - struct gl_buffer_object* bufObj; mesa_format mesaFormat; GLubyte clearValue[MAX_PIXEL_BYTES]; GLsizeiptr clearValueSize; - bufObj = get_buffer(ctx, "glClearBufferData", target, GL_INVALID_VALUE); - if (!bufObj) { - return; - } - - if (_mesa_check_disallowed_mapping(bufObj)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glClearBufferData(buffer currently mapped)"); + /* This checks for disallowed mappings. */ + if (!buffer_object_subdata_range_good(ctx, bufObj, offset, size, + subdata, func)) { return; } mesaFormat = validate_clear_buffer_format(ctx, internalformat, - format, type, - "glClearBufferData"); + format, type, func); + if (mesaFormat == MESA_FORMAT_NONE) { return; } clearValueSize = _mesa_get_format_bytes(mesaFormat); - if (bufObj->Size % clearValueSize != 0) { + if (offset % clearValueSize != 0 || size % clearValueSize != 0) { _mesa_error(ctx, GL_INVALID_VALUE, - "glClearBufferData(size is not a multiple of " - "internalformat size)"); + "%s(offset or size is not a multiple of " + "internalformat size)", func); return; } if (data == NULL) { /* clear to zeros, per the spec */ - ctx->Driver.ClearBufferSubData(ctx, 0, bufObj->Size, - NULL, clearValueSize, bufObj); + if (size > 0) { + ctx->Driver.ClearBufferSubData(ctx, offset, size, + NULL, clearValueSize, bufObj); + } return; } if (!convert_clear_buffer_data(ctx, mesaFormat, clearValue, - format, type, data, "glClearBufferData")) { + format, type, data, func)) { return; } - ctx->Driver.ClearBufferSubData(ctx, 0, bufObj->Size, - clearValue, clearValueSize, bufObj); + if (size > 0) { + ctx->Driver.ClearBufferSubData(ctx, offset, size, + clearValue, clearValueSize, bufObj); + } +} + +void GLAPIENTRY +_mesa_ClearBufferData(GLenum target, GLenum internalformat, GLenum format, + GLenum type, const GLvoid *data) +{ + GET_CURRENT_CONTEXT(ctx); + struct gl_buffer_object *bufObj; + + bufObj = get_buffer(ctx, "glClearBufferData", target, GL_INVALID_VALUE); + if (!bufObj) + return; + + _mesa_clear_buffer_sub_data(ctx, bufObj, internalformat, 0, bufObj->Size, + format, type, data, + "glClearBufferData", false); } @@ -1762,53 +1782,14 @@ _mesa_ClearBufferSubData(GLenum target, GLenum internalformat, { GET_CURRENT_CONTEXT(ctx); struct gl_buffer_object* bufObj; - mesa_format mesaFormat; - GLubyte clearValue[MAX_PIXEL_BYTES]; - GLsizeiptr clearValueSize; bufObj = get_buffer(ctx, "glClearBufferSubData", target, GL_INVALID_VALUE); if (!bufObj) return; - if (!buffer_object_subdata_range_good(ctx, bufObj, offset, size, - true, "glClearBufferSubData")) { - return; - } - - mesaFormat = validate_clear_buffer_format(ctx, internalformat, - format, type, - "glClearBufferSubData"); - if (mesaFormat == MESA_FORMAT_NONE) { - return; - } - - clearValueSize = _mesa_get_format_bytes(mesaFormat); - if (offset % clearValueSize != 0 || size % clearValueSize != 0) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glClearBufferSubData(offset or size is not a multiple of " - "internalformat size)"); - return; - } - - if (data == NULL) { - /* clear to zeros, per the spec */ - if (size > 0) { - ctx->Driver.ClearBufferSubData(ctx, offset, size, - NULL, clearValueSize, bufObj); - } - return; - } - - if (!convert_clear_buffer_data(ctx, mesaFormat, clearValue, - format, type, data, - "glClearBufferSubData")) { - return; - } - - if (size > 0) { - ctx->Driver.ClearBufferSubData(ctx, offset, size, - clearValue, clearValueSize, bufObj); - } + _mesa_clear_buffer_sub_data(ctx, bufObj, internalformat, offset, size, + format, type, data, + "glClearBufferSubData", true); } diff --git a/src/mesa/main/bufferobj.h b/src/mesa/main/bufferobj.h index 7db5c98..5911270 100644 --- a/src/mesa/main/bufferobj.h +++ b/src/mesa/main/bufferobj.h @@ -156,11 +156,20 @@ _mesa_copy_buffer_sub_data(struct gl_context *ctx, GLsizeiptr size, const char *func); extern void -_mesa_buffer_clear_subdata(struct gl_context *ctx, - GLintptr offset, GLsizeiptr size, - const GLvoid *clearValue, - GLsizeiptr clearValueSize, - struct gl_buffer_object *bufObj); +_mesa_ClearBufferSubData_sw(struct gl_context *ctx, + GLintptr offset, GLsizeiptr size, + const GLvoid *clearValue, + GLsizeiptr clearValueSize, + struct gl_buffer_object *bufObj); + +extern void +_mesa_clear_buffer_sub_data(struct gl_context *ctx, + struct gl_buffer_object *bufObj, + GLenum internalformat, + GLintptr offset, GLsizeiptr size, + GLenum format, GLenum type, + const GLvoid *data, + const char *func, bool subdata); /* * API functions diff --git a/src/mesa/state_tracker/st_cb_bufferobjects.c b/src/mesa/state_tracker/st_cb_bufferobjects.c index 1dbc4b9..db254c2 100644 --- a/src/mesa/state_tracker/st_cb_bufferobjects.c +++ b/src/mesa/state_tracker/st_cb_bufferobjects.c @@ -485,8 +485,8 @@ st_clear_buffer_subdata(struct gl_context *ctx, static const char zeros[16] = {0}; if (!pipe->clear_buffer) { - _mesa_buffer_clear_subdata(ctx, offset, size, - clearValue, clearValueSize, bufObj); + _mesa_ClearBufferSubData_sw(ctx, offset, size, + clearValue, clearValueSize, bufObj); return; } From ldeks at kemper.freedesktop.org Tue Mar 17 17:20:05 2015 From: ldeks at kemper.freedesktop.org (Laura Ekstrand) Date: Tue, 17 Mar 2015 10:20:05 -0700 (PDT) Subject: Mesa (master): main: Refactor MapBuffer[Range]. Message-ID: <20150317172005.C65E576338@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 4f513bc330393c4615b4bad98e3e634408123960 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=4f513bc330393c4615b4bad98e3e634408123960 Author: Laura Ekstrand Date: Wed Jan 14 12:44:39 2015 -0800 main: Refactor MapBuffer[Range]. v2: review from Jason Ekstrand - Split refactor from addition of DSA entry points. review from Ian Romanick - Remove "_mesa" from static software fallback map_buffer_range - Restore VBO_DEBUG and BOUNDS_CHECK Reviewed-by: Fredrik H?glund --- src/mesa/main/bufferobj.c | 288 ++++++++++++++++++++------------------------- src/mesa/main/bufferobj.h | 6 + 2 files changed, 133 insertions(+), 161 deletions(-) diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c index 0e77f73..d37e4a5 100644 --- a/src/mesa/main/bufferobj.c +++ b/src/mesa/main/bufferobj.c @@ -706,10 +706,10 @@ _mesa_ClearBufferSubData_sw(struct gl_context *ctx, * Called via glMapBufferRange(). */ static void * -_mesa_buffer_map_range( struct gl_context *ctx, GLintptr offset, - GLsizeiptr length, GLbitfield access, - struct gl_buffer_object *bufObj, - gl_map_buffer_index index) +map_buffer_range_fallback(struct gl_context *ctx, GLintptr offset, + GLsizeiptr length, GLbitfield access, + struct gl_buffer_object *bufObj, + gl_map_buffer_index index) { (void) ctx; assert(!_mesa_bufferobj_mapped(bufObj, index)); @@ -1121,7 +1121,7 @@ _mesa_init_buffer_object_functions(struct dd_function_table *driver) driver->ClearBufferSubData = _mesa_ClearBufferSubData_sw; /* GL_ARB_map_buffer_range */ - driver->MapBufferRange = _mesa_buffer_map_range; + driver->MapBufferRange = map_buffer_range_fallback; driver->FlushMappedBufferRange = _mesa_buffer_flush_mapped_range; /* GL_ARB_copy_buffer */ @@ -1828,116 +1828,6 @@ _mesa_ClearNamedBufferSubData(GLuint buffer, GLenum internalformat, } -void * GLAPIENTRY -_mesa_MapBuffer(GLenum target, GLenum access) -{ - GET_CURRENT_CONTEXT(ctx); - struct gl_buffer_object * bufObj; - GLbitfield accessFlags; - void *map; - bool valid_access; - - ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, NULL); - - switch (access) { - case GL_READ_ONLY_ARB: - accessFlags = GL_MAP_READ_BIT; - valid_access = _mesa_is_desktop_gl(ctx); - break; - case GL_WRITE_ONLY_ARB: - accessFlags = GL_MAP_WRITE_BIT; - valid_access = true; - break; - case GL_READ_WRITE_ARB: - accessFlags = GL_MAP_READ_BIT | GL_MAP_WRITE_BIT; - valid_access = _mesa_is_desktop_gl(ctx); - break; - default: - valid_access = false; - break; - } - - if (!valid_access) { - _mesa_error(ctx, GL_INVALID_ENUM, "glMapBufferARB(access)"); - return NULL; - } - - bufObj = get_buffer(ctx, "glMapBufferARB", target, GL_INVALID_OPERATION); - if (!bufObj) - return NULL; - - if (accessFlags & GL_MAP_READ_BIT && - !(bufObj->StorageFlags & GL_MAP_READ_BIT)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glMapBuffer(invalid read flag)"); - return NULL; - } - - if (accessFlags & GL_MAP_WRITE_BIT && - !(bufObj->StorageFlags & GL_MAP_WRITE_BIT)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glMapBuffer(invalid write flag)"); - return NULL; - } - - if (_mesa_bufferobj_mapped(bufObj, MAP_USER)) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glMapBufferARB(already mapped)"); - return NULL; - } - - if (!bufObj->Size) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, - "glMapBuffer(buffer size = 0)"); - return NULL; - } - - assert(ctx->Driver.MapBufferRange); - map = ctx->Driver.MapBufferRange(ctx, 0, bufObj->Size, accessFlags, bufObj, - MAP_USER); - if (!map) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glMapBufferARB(map failed)"); - return NULL; - } - else { - /* The driver callback should have set these fields. - * This is important because other modules (like VBO) might call - * the driver function directly. - */ - assert(bufObj->Mappings[MAP_USER].Pointer == map); - assert(bufObj->Mappings[MAP_USER].Length == bufObj->Size); - assert(bufObj->Mappings[MAP_USER].Offset == 0); - bufObj->Mappings[MAP_USER].AccessFlags = accessFlags; - } - - if (access == GL_WRITE_ONLY_ARB || access == GL_READ_WRITE_ARB) - bufObj->Written = GL_TRUE; - -#ifdef VBO_DEBUG - printf("glMapBufferARB(%u, sz %ld, access 0x%x)\n", - bufObj->Name, bufObj->Size, access); - if (access == GL_WRITE_ONLY_ARB) { - GLuint i; - GLubyte *b = (GLubyte *) bufObj->Pointer; - for (i = 0; i < bufObj->Size; i++) - b[i] = i & 0xff; - } -#endif - -#ifdef BOUNDS_CHECK - { - GLubyte *buf = (GLubyte *) bufObj->Pointer; - GLuint i; - /* buffer is 100 bytes larger than requested, fill with magic value */ - for (i = 0; i < 100; i++) { - buf[bufObj->Size - i - 1] = 123; - } - } -#endif - - return bufObj->Mappings[MAP_USER].Pointer; -} - - GLboolean GLAPIENTRY _mesa_UnmapBuffer(GLenum target) { @@ -2260,35 +2150,26 @@ _mesa_CopyNamedBufferSubData(GLuint readBuffer, GLuint writeBuffer, } -/** - * See GL_ARB_map_buffer_range spec - */ -void * GLAPIENTRY -_mesa_MapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length, - GLbitfield access) +void * +_mesa_map_buffer_range(struct gl_context *ctx, + struct gl_buffer_object *bufObj, + GLintptr offset, GLsizeiptr length, + GLbitfield access, const char *func) { - GET_CURRENT_CONTEXT(ctx); - struct gl_buffer_object *bufObj; void *map; GLbitfield allowed_access; ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, NULL); - if (!ctx->Extensions.ARB_map_buffer_range) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glMapBufferRange(extension not supported)"); - return NULL; - } - if (offset < 0) { _mesa_error(ctx, GL_INVALID_VALUE, - "glMapBufferRange(offset = %ld)", (long)offset); + "%s(offset %ld < 0)", func, (long) offset); return NULL; } if (length < 0) { _mesa_error(ctx, GL_INVALID_VALUE, - "glMapBufferRange(length = %ld)", (long)length); + "%s(length %ld < 0)", func, (long) length); return NULL; } @@ -2298,10 +2179,13 @@ _mesa_MapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length, * conditions: * * * is zero." + * + * Additionally, page 94 of the PDF of the OpenGL 4.5 core spec + * (30.10.2014) also says this, so it's no longer allowed for desktop GL, + * either. */ - if (_mesa_is_gles(ctx) && length == 0) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glMapBufferRange(length = 0)"); + if (length == 0) { + _mesa_error(ctx, GL_INVALID_OPERATION, "%s(length = 0)", func); return NULL; } @@ -2318,14 +2202,15 @@ _mesa_MapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length, } if (access & ~allowed_access) { - /* generate an error if any other than allowed bit is set */ - _mesa_error(ctx, GL_INVALID_VALUE, "glMapBufferRange(access)"); + /* generate an error if any bits other than those allowed are set */ + _mesa_error(ctx, GL_INVALID_VALUE, + "%s(access has undefined bits set)", func); return NULL; } if ((access & (GL_MAP_READ_BIT | GL_MAP_WRITE_BIT)) == 0) { _mesa_error(ctx, GL_INVALID_OPERATION, - "glMapBufferRange(access indicates neither read or write)"); + "%s(access indicates neither read or write)", func); return NULL; } @@ -2334,82 +2219,69 @@ _mesa_MapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length, GL_MAP_INVALIDATE_BUFFER_BIT | GL_MAP_UNSYNCHRONIZED_BIT))) { _mesa_error(ctx, GL_INVALID_OPERATION, - "glMapBufferRange(invalid access flags)"); + "%s(read access with disallowed bits)", func); return NULL; } if ((access & GL_MAP_FLUSH_EXPLICIT_BIT) && ((access & GL_MAP_WRITE_BIT) == 0)) { _mesa_error(ctx, GL_INVALID_OPERATION, - "glMapBufferRange(invalid access flags)"); + "%s(access has flush explicit without write)", func); return NULL; } - bufObj = get_buffer(ctx, "glMapBufferRange", target, GL_INVALID_OPERATION); - if (!bufObj) - return NULL; - if (access & GL_MAP_READ_BIT && !(bufObj->StorageFlags & GL_MAP_READ_BIT)) { _mesa_error(ctx, GL_INVALID_OPERATION, - "glMapBufferRange(invalid read flag)"); + "%s(buffer does not allow read access)", func); return NULL; } if (access & GL_MAP_WRITE_BIT && !(bufObj->StorageFlags & GL_MAP_WRITE_BIT)) { _mesa_error(ctx, GL_INVALID_OPERATION, - "glMapBufferRange(invalid write flag)"); + "%s(buffer does not allow write access)", func); return NULL; } if (access & GL_MAP_COHERENT_BIT && !(bufObj->StorageFlags & GL_MAP_COHERENT_BIT)) { _mesa_error(ctx, GL_INVALID_OPERATION, - "glMapBufferRange(invalid coherent flag)"); + "%s(buffer does not allow coherent access)", func); return NULL; } if (access & GL_MAP_PERSISTENT_BIT && !(bufObj->StorageFlags & GL_MAP_PERSISTENT_BIT)) { _mesa_error(ctx, GL_INVALID_OPERATION, - "glMapBufferRange(invalid persistent flag)"); + "%s(buffer does not allow persistent access)", func); return NULL; } if (offset + length > bufObj->Size) { _mesa_error(ctx, GL_INVALID_VALUE, - "glMapBufferRange(offset + length > size)"); + "%s(offset %ld + length %ld > buffer_size %ld)", func, + offset, length, bufObj->Size); return NULL; } if (_mesa_bufferobj_mapped(bufObj, MAP_USER)) { _mesa_error(ctx, GL_INVALID_OPERATION, - "glMapBufferRange(buffer already mapped)"); + "%s(buffer already mapped)", func); return NULL; } if (!bufObj->Size) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, - "glMapBufferRange(buffer size = 0)"); + _mesa_error(ctx, GL_OUT_OF_MEMORY, "%s(buffer size = 0)", func); return NULL; } - /* Mapping zero bytes should return a non-null pointer. */ - if (!length) { - static long dummy = 0; - bufObj->Mappings[MAP_USER].Pointer = &dummy; - bufObj->Mappings[MAP_USER].Length = length; - bufObj->Mappings[MAP_USER].Offset = offset; - bufObj->Mappings[MAP_USER].AccessFlags = access; - return bufObj->Mappings[MAP_USER].Pointer; - } assert(ctx->Driver.MapBufferRange); map = ctx->Driver.MapBufferRange(ctx, offset, length, access, bufObj, MAP_USER); if (!map) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glMapBufferARB(map failed)"); + _mesa_error(ctx, GL_OUT_OF_MEMORY, "%s(map failed)", func); } else { /* The driver callback should have set all these fields. @@ -2422,9 +2294,103 @@ _mesa_MapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length, assert(bufObj->Mappings[MAP_USER].AccessFlags == access); } + if (access & GL_MAP_WRITE_BIT) + bufObj->Written = GL_TRUE; + +#ifdef VBO_DEBUG + if (strstr(func, "Range") == NULL) { /* If not MapRange */ + printf("glMapBuffer(%u, sz %ld, access 0x%x)\n", + bufObj->Name, bufObj->Size, access); + /* Access must be write only */ + if ((access & GL_MAP_WRITE_BIT) && (!(access & ~GL_MAP_WRITE_BIT))) { + GLuint i; + GLubyte *b = (GLubyte *) bufObj->Pointer; + for (i = 0; i < bufObj->Size; i++) + b[i] = i & 0xff; + } + } +#endif + +#ifdef BOUNDS_CHECK + if (strstr(func, "Range") == NULL) { /* If not MapRange */ + GLubyte *buf = (GLubyte *) bufObj->Pointer; + GLuint i; + /* buffer is 100 bytes larger than requested, fill with magic value */ + for (i = 0; i < 100; i++) { + buf[bufObj->Size - i - 1] = 123; + } + } +#endif + return map; } +void * GLAPIENTRY +_mesa_MapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length, + GLbitfield access) +{ + GET_CURRENT_CONTEXT(ctx); + struct gl_buffer_object *bufObj; + + if (!ctx->Extensions.ARB_map_buffer_range) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glMapBufferRange(ARB_map_buffer_range not supported)"); + return NULL; + } + + bufObj = get_buffer(ctx, "glMapBufferRange", target, GL_INVALID_OPERATION); + if (!bufObj) + return NULL; + + return _mesa_map_buffer_range(ctx, bufObj, offset, length, access, + "glMapBufferRange"); +} + +/** + * Converts GLenum access from MapBuffer and MapNamedBuffer into + * flags for input to _mesa_map_buffer_range. + * + * \return true if the type of requested access is permissible. + */ +static bool +get_map_buffer_access_flags(struct gl_context *ctx, GLenum access, + GLbitfield *flags) +{ + switch (access) { + case GL_READ_ONLY_ARB: + *flags = GL_MAP_READ_BIT; + return _mesa_is_desktop_gl(ctx); + case GL_WRITE_ONLY_ARB: + *flags = GL_MAP_WRITE_BIT; + return true; + case GL_READ_WRITE_ARB: + *flags = GL_MAP_READ_BIT | GL_MAP_WRITE_BIT; + return _mesa_is_desktop_gl(ctx); + default: + return false; + } +} + +void * GLAPIENTRY +_mesa_MapBuffer(GLenum target, GLenum access) +{ + GET_CURRENT_CONTEXT(ctx); + struct gl_buffer_object *bufObj; + GLbitfield accessFlags; + + if (!get_map_buffer_access_flags(ctx, access, &accessFlags)) { + _mesa_error(ctx, GL_INVALID_ENUM, "glMapBuffer(invalid access)"); + return NULL; + } + + bufObj = get_buffer(ctx, "glMapBuffer", target, GL_INVALID_OPERATION); + if (!bufObj) + return NULL; + + return _mesa_map_buffer_range(ctx, bufObj, 0, bufObj->Size, accessFlags, + "glMapBuffer"); +} + /** * See GL_ARB_map_buffer_range spec diff --git a/src/mesa/main/bufferobj.h b/src/mesa/main/bufferobj.h index 2a66444..3584a80 100644 --- a/src/mesa/main/bufferobj.h +++ b/src/mesa/main/bufferobj.h @@ -155,6 +155,12 @@ _mesa_copy_buffer_sub_data(struct gl_context *ctx, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size, const char *func); +extern void * +_mesa_map_buffer_range(struct gl_context *ctx, + struct gl_buffer_object *bufObj, + GLintptr offset, GLsizeiptr length, + GLbitfield access, const char *func); + extern void _mesa_ClearBufferSubData_sw(struct gl_context *ctx, GLintptr offset, GLsizeiptr size, From ldeks at kemper.freedesktop.org Tue Mar 17 17:20:05 2015 From: ldeks at kemper.freedesktop.org (Laura Ekstrand) Date: Tue, 17 Mar 2015 10:20:05 -0700 (PDT) Subject: Mesa (master): main: Add entry point for UnmapNamedBuffer. Message-ID: <20150317172005.DD2B276338@kemper.freedesktop.org> Module: Mesa Branch: master Commit: f7f5df99542d6492fffd803d77d5f7d2f44d08c9 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=f7f5df99542d6492fffd803d77d5f7d2f44d08c9 Author: Laura Ekstrand Date: Wed Jan 14 14:52:01 2015 -0800 main: Add entry point for UnmapNamedBuffer. v2: review from Ian Romanick - Restore VBO_DEBUG and BOUNDS_CHECK - Remove _mesa from static software fallback unmap_buffer. Reviewed-by: Fredrik H?glund --- src/mapi/glapi/gen/ARB_direct_state_access.xml | 5 +++ src/mesa/main/bufferobj.c | 47 +++++++++++++++++------- src/mesa/main/bufferobj.h | 7 ++++ src/mesa/main/tests/dispatch_sanity.cpp | 1 + 4 files changed, 47 insertions(+), 13 deletions(-) diff --git a/src/mapi/glapi/gen/ARB_direct_state_access.xml b/src/mapi/glapi/gen/ARB_direct_state_access.xml index 557316a..281646d 100644 --- a/src/mapi/glapi/gen/ARB_direct_state_access.xml +++ b/src/mapi/glapi/gen/ARB_direct_state_access.xml @@ -75,6 +75,11 @@ + + + + + diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c index 0d1a690..3b2559f 100644 --- a/src/mesa/main/bufferobj.c +++ b/src/mesa/main/bufferobj.c @@ -741,15 +741,15 @@ _mesa_buffer_flush_mapped_range( struct gl_context *ctx, /** - * Default callback for \c dd_function_table::MapBuffer(). + * Default callback for \c dd_function_table::UnmapBuffer(). * * The input parameters will have been already tested for errors. * * \sa glUnmapBufferARB, dd_function_table::UnmapBuffer */ static GLboolean -_mesa_buffer_unmap(struct gl_context *ctx, struct gl_buffer_object *bufObj, - gl_map_buffer_index index) +unmap_buffer_fallback(struct gl_context *ctx, struct gl_buffer_object *bufObj, + gl_map_buffer_index index) { (void) ctx; /* XXX we might assert here that bufObj->Pointer is non-null */ @@ -1115,7 +1115,7 @@ _mesa_init_buffer_object_functions(struct dd_function_table *driver) driver->BufferData = buffer_data_fallback; driver->BufferSubData = buffer_sub_data_fallback; driver->GetBufferSubData = _mesa_buffer_get_subdata; - driver->UnmapBuffer = _mesa_buffer_unmap; + driver->UnmapBuffer = unmap_buffer_fallback; /* GL_ARB_clear_buffer_object */ driver->ClearBufferSubData = _mesa_ClearBufferSubData_sw; @@ -1828,20 +1828,16 @@ _mesa_ClearNamedBufferSubData(GLuint buffer, GLenum internalformat, } -GLboolean GLAPIENTRY -_mesa_UnmapBuffer(GLenum target) +GLboolean +_mesa_unmap_buffer(struct gl_context *ctx, struct gl_buffer_object *bufObj, + const char *func) { - GET_CURRENT_CONTEXT(ctx); - struct gl_buffer_object *bufObj; GLboolean status = GL_TRUE; ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE); - bufObj = get_buffer(ctx, "glUnmapBufferARB", target, GL_INVALID_OPERATION); - if (!bufObj) - return GL_FALSE; - if (!_mesa_bufferobj_mapped(bufObj, MAP_USER)) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glUnmapBufferARB"); + _mesa_error(ctx, GL_INVALID_OPERATION, + "%s(buffer is not mapped)", func); return GL_FALSE; } @@ -1890,6 +1886,31 @@ _mesa_UnmapBuffer(GLenum target) return status; } +GLboolean GLAPIENTRY +_mesa_UnmapBuffer(GLenum target) +{ + GET_CURRENT_CONTEXT(ctx); + struct gl_buffer_object *bufObj; + + bufObj = get_buffer(ctx, "glUnmapBuffer", target, GL_INVALID_OPERATION); + if (!bufObj) + return GL_FALSE; + + return _mesa_unmap_buffer(ctx, bufObj, "glUnmapBuffer"); +} + +GLboolean GLAPIENTRY +_mesa_UnmapNamedBuffer(GLuint buffer) +{ + GET_CURRENT_CONTEXT(ctx); + struct gl_buffer_object *bufObj; + + bufObj = _mesa_lookup_bufferobj_err(ctx, buffer, "glUnmapNamedBuffer"); + if (!bufObj) + return GL_FALSE; + + return _mesa_unmap_buffer(ctx, bufObj, "glUnmapNamedBuffer"); +} void GLAPIENTRY _mesa_GetBufferParameteriv(GLenum target, GLenum pname, GLint *params) diff --git a/src/mesa/main/bufferobj.h b/src/mesa/main/bufferobj.h index 6305b5c..40bd9fc 100644 --- a/src/mesa/main/bufferobj.h +++ b/src/mesa/main/bufferobj.h @@ -177,6 +177,10 @@ _mesa_clear_buffer_sub_data(struct gl_context *ctx, const GLvoid *data, const char *func, bool subdata); +extern GLboolean +_mesa_unmap_buffer(struct gl_context *ctx, struct gl_buffer_object *bufObj, + const char *func); + /* * API functions */ @@ -248,6 +252,9 @@ _mesa_ClearNamedBufferSubData(GLuint buffer, GLenum internalformat, GLboolean GLAPIENTRY _mesa_UnmapBuffer(GLenum target); +GLboolean GLAPIENTRY +_mesa_UnmapNamedBuffer(GLuint buffer); + void GLAPIENTRY _mesa_GetBufferParameteriv(GLenum target, GLenum pname, GLint *params); diff --git a/src/mesa/main/tests/dispatch_sanity.cpp b/src/mesa/main/tests/dispatch_sanity.cpp index bda761a..fb077b3 100644 --- a/src/mesa/main/tests/dispatch_sanity.cpp +++ b/src/mesa/main/tests/dispatch_sanity.cpp @@ -962,6 +962,7 @@ const struct function gl_core_functions_possible[] = { { "glClearNamedBufferSubData", 45, -1 }, { "glMapNamedBuffer", 45, -1 }, { "glMapNamedBufferRange", 45, -1 }, + { "glUnmapNamedBuffer", 45, -1 }, { "glCreateTextures", 45, -1 }, { "glTextureStorage1D", 45, -1 }, { "glTextureStorage2D", 45, -1 }, From ldeks at kemper.freedesktop.org Tue Mar 17 17:20:05 2015 From: ldeks at kemper.freedesktop.org (Laura Ekstrand) Date: Tue, 17 Mar 2015 10:20:05 -0700 (PDT) Subject: Mesa (master): main: Refactor FlushMappedBufferRange. Message-ID: <20150317172005.EB73276338@kemper.freedesktop.org> Module: Mesa Branch: master Commit: ee5fae6e897a38f5104859851eb8fba84180cfa8 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=ee5fae6e897a38f5104859851eb8fba84180cfa8 Author: Laura Ekstrand Date: Wed Jan 14 17:01:20 2015 -0800 main: Refactor FlushMappedBufferRange. v2:-Remove "_mesa" from in front of static software fallback. -Split out the refactor from the addition of the DSA entry points. Reviewed-by: Fredrik H?glund --- src/mesa/main/bufferobj.c | 60 +++++++++++++++++++++++++-------------------- src/mesa/main/bufferobj.h | 6 +++++ 2 files changed, 40 insertions(+), 26 deletions(-) diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c index 3b2559f..d646617 100644 --- a/src/mesa/main/bufferobj.c +++ b/src/mesa/main/bufferobj.c @@ -727,10 +727,10 @@ map_buffer_range_fallback(struct gl_context *ctx, GLintptr offset, * Called via glFlushMappedBufferRange(). */ static void -_mesa_buffer_flush_mapped_range( struct gl_context *ctx, - GLintptr offset, GLsizeiptr length, - struct gl_buffer_object *obj, - gl_map_buffer_index index) +flush_mapped_buffer_range_fallback(struct gl_context *ctx, + GLintptr offset, GLsizeiptr length, + struct gl_buffer_object *obj, + gl_map_buffer_index index) { (void) ctx; (void) offset; @@ -1122,7 +1122,7 @@ _mesa_init_buffer_object_functions(struct dd_function_table *driver) /* GL_ARB_map_buffer_range */ driver->MapBufferRange = map_buffer_range_fallback; - driver->FlushMappedBufferRange = _mesa_buffer_flush_mapped_range; + driver->FlushMappedBufferRange = flush_mapped_buffer_range_fallback; /* GL_ARB_copy_buffer */ driver->CopyBufferSubData = copy_buffer_sub_data_fallback; @@ -2455,57 +2455,49 @@ _mesa_MapNamedBuffer(GLuint buffer, GLenum access) } -/** - * See GL_ARB_map_buffer_range spec - */ -void GLAPIENTRY -_mesa_FlushMappedBufferRange(GLenum target, GLintptr offset, GLsizeiptr length) +void +_mesa_flush_mapped_buffer_range(struct gl_context *ctx, + struct gl_buffer_object *bufObj, + GLintptr offset, GLsizeiptr length, + const char *func) { - GET_CURRENT_CONTEXT(ctx); - struct gl_buffer_object *bufObj; - if (!ctx->Extensions.ARB_map_buffer_range) { _mesa_error(ctx, GL_INVALID_OPERATION, - "glFlushMappedBufferRange(extension not supported)"); + "%s(ARB_map_buffer_range not supported)", func); return; } if (offset < 0) { _mesa_error(ctx, GL_INVALID_VALUE, - "glFlushMappedBufferRange(offset = %ld)", (long)offset); + "%s(offset %ld < 0)", func, (long) offset); return; } if (length < 0) { _mesa_error(ctx, GL_INVALID_VALUE, - "glFlushMappedBufferRange(length = %ld)", (long)length); + "%s(length %ld < 0)", func, (long) length); return; } - bufObj = get_buffer(ctx, "glFlushMappedBufferRange", target, - GL_INVALID_OPERATION); - if (!bufObj) - return; - if (!_mesa_bufferobj_mapped(bufObj, MAP_USER)) { /* buffer is not mapped */ _mesa_error(ctx, GL_INVALID_OPERATION, - "glFlushMappedBufferRange(buffer is not mapped)"); + "%s(buffer is not mapped)", func); return; } if ((bufObj->Mappings[MAP_USER].AccessFlags & GL_MAP_FLUSH_EXPLICIT_BIT) == 0) { _mesa_error(ctx, GL_INVALID_OPERATION, - "glFlushMappedBufferRange(GL_MAP_FLUSH_EXPLICIT_BIT not set)"); + "%s(GL_MAP_FLUSH_EXPLICIT_BIT not set)", func); return; } if (offset + length > bufObj->Mappings[MAP_USER].Length) { _mesa_error(ctx, GL_INVALID_VALUE, - "glFlushMappedBufferRange(offset %ld + length %ld > mapped length %ld)", - (long)offset, (long)length, - (long)bufObj->Mappings[MAP_USER].Length); + "%s(offset %ld + length %ld > mapped length %ld)", func, + (long) offset, (long) length, + (long) bufObj->Mappings[MAP_USER].Length); return; } @@ -2516,6 +2508,22 @@ _mesa_FlushMappedBufferRange(GLenum target, GLintptr offset, GLsizeiptr length) MAP_USER); } +void GLAPIENTRY +_mesa_FlushMappedBufferRange(GLenum target, GLintptr offset, + GLsizeiptr length) +{ + GET_CURRENT_CONTEXT(ctx); + struct gl_buffer_object *bufObj; + + bufObj = get_buffer(ctx, "glFlushMappedBufferRange", target, + GL_INVALID_OPERATION); + if (!bufObj) + return; + + _mesa_flush_mapped_buffer_range(ctx, bufObj, offset, length, + "glFlushMappedBufferRange"); +} + static GLenum buffer_object_purgeable(struct gl_context *ctx, GLuint name, GLenum option) diff --git a/src/mesa/main/bufferobj.h b/src/mesa/main/bufferobj.h index 40bd9fc..f51bf36 100644 --- a/src/mesa/main/bufferobj.h +++ b/src/mesa/main/bufferobj.h @@ -162,6 +162,12 @@ _mesa_map_buffer_range(struct gl_context *ctx, GLbitfield access, const char *func); extern void +_mesa_flush_mapped_buffer_range(struct gl_context *ctx, + struct gl_buffer_object *bufObj, + GLintptr offset, GLsizeiptr length, + const char *func); + +extern void _mesa_ClearBufferSubData_sw(struct gl_context *ctx, GLintptr offset, GLsizeiptr size, const GLvoid *clearValue, From ldeks at kemper.freedesktop.org Tue Mar 17 17:20:06 2015 From: ldeks at kemper.freedesktop.org (Laura Ekstrand) Date: Tue, 17 Mar 2015 10:20:06 -0700 (PDT) Subject: Mesa (master): main: Refactor GetBufferParameteri[64]v. Message-ID: <20150317172006.0D46176338@kemper.freedesktop.org> Module: Mesa Branch: master Commit: efcb830d49d601140a62a096a4ff4c215e68d89c URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=efcb830d49d601140a62a096a4ff4c215e68d89c Author: Laura Ekstrand Date: Wed Feb 11 16:07:45 2015 -0800 main: Refactor GetBufferParameteri[64]v. v2: Split into a refactor commit and an entry point commit. Reviewed-by: Fredrik H?glund --- src/mesa/main/bufferobj.c | 119 +++++++++++++++++---------------------------- 1 file changed, 45 insertions(+), 74 deletions(-) diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c index 99f1432..e39ad94 100644 --- a/src/mesa/main/bufferobj.c +++ b/src/mesa/main/bufferobj.c @@ -1912,128 +1912,99 @@ _mesa_UnmapNamedBuffer(GLuint buffer) return _mesa_unmap_buffer(ctx, bufObj, "glUnmapNamedBuffer"); } -void GLAPIENTRY -_mesa_GetBufferParameteriv(GLenum target, GLenum pname, GLint *params) -{ - GET_CURRENT_CONTEXT(ctx); - struct gl_buffer_object *bufObj; - - bufObj = get_buffer(ctx, "glGetBufferParameterivARB", target, - GL_INVALID_OPERATION); - if (!bufObj) - return; +static bool +get_buffer_parameter(struct gl_context *ctx, + struct gl_buffer_object *bufObj, GLenum pname, + GLint64 *params, const char *func) +{ switch (pname) { case GL_BUFFER_SIZE_ARB: - *params = (GLint) bufObj->Size; - return; + *params = bufObj->Size; + break; case GL_BUFFER_USAGE_ARB: *params = bufObj->Usage; - return; + break; case GL_BUFFER_ACCESS_ARB: *params = simplified_access_mode(ctx, bufObj->Mappings[MAP_USER].AccessFlags); - return; + break; case GL_BUFFER_MAPPED_ARB: *params = _mesa_bufferobj_mapped(bufObj, MAP_USER); - return; + break; case GL_BUFFER_ACCESS_FLAGS: if (!ctx->Extensions.ARB_map_buffer_range) goto invalid_pname; *params = bufObj->Mappings[MAP_USER].AccessFlags; - return; + break; case GL_BUFFER_MAP_OFFSET: if (!ctx->Extensions.ARB_map_buffer_range) goto invalid_pname; - *params = (GLint) bufObj->Mappings[MAP_USER].Offset; - return; + *params = bufObj->Mappings[MAP_USER].Offset; + break; case GL_BUFFER_MAP_LENGTH: if (!ctx->Extensions.ARB_map_buffer_range) goto invalid_pname; - *params = (GLint) bufObj->Mappings[MAP_USER].Length; - return; + *params = bufObj->Mappings[MAP_USER].Length; + break; case GL_BUFFER_IMMUTABLE_STORAGE: if (!ctx->Extensions.ARB_buffer_storage) goto invalid_pname; *params = bufObj->Immutable; - return; + break; case GL_BUFFER_STORAGE_FLAGS: if (!ctx->Extensions.ARB_buffer_storage) goto invalid_pname; *params = bufObj->StorageFlags; - return; + break; default: - ; /* fall-through */ + goto invalid_pname; } + return true; + invalid_pname: - _mesa_error(ctx, GL_INVALID_ENUM, "glGetBufferParameterivARB(pname=%s)", + _mesa_error(ctx, GL_INVALID_ENUM, "%s(invalid pname: %s)", func, _mesa_lookup_enum_by_nr(pname)); + return false; } +void GLAPIENTRY +_mesa_GetBufferParameteriv(GLenum target, GLenum pname, GLint *params) +{ + GET_CURRENT_CONTEXT(ctx); + struct gl_buffer_object *bufObj; + GLint64 parameter; + + bufObj = get_buffer(ctx, "glGetBufferParameteriv", target, + GL_INVALID_OPERATION); + if (!bufObj) + return; + + if (!get_buffer_parameter(ctx, bufObj, pname, ¶meter, + "glGetBufferParameteriv")) + return; /* Error already recorded. */ + + *params = (GLint) parameter; +} -/** - * New in GL 3.2 - * This is pretty much a duplicate of GetBufferParameteriv() but the - * GL_BUFFER_SIZE_ARB attribute will be 64-bits on a 64-bit system. - */ void GLAPIENTRY _mesa_GetBufferParameteri64v(GLenum target, GLenum pname, GLint64 *params) { GET_CURRENT_CONTEXT(ctx); struct gl_buffer_object *bufObj; + GLint64 parameter; bufObj = get_buffer(ctx, "glGetBufferParameteri64v", target, GL_INVALID_OPERATION); if (!bufObj) return; - switch (pname) { - case GL_BUFFER_SIZE_ARB: - *params = bufObj->Size; - return; - case GL_BUFFER_USAGE_ARB: - *params = bufObj->Usage; - return; - case GL_BUFFER_ACCESS_ARB: - *params = simplified_access_mode(ctx, - bufObj->Mappings[MAP_USER].AccessFlags); - return; - case GL_BUFFER_ACCESS_FLAGS: - if (!ctx->Extensions.ARB_map_buffer_range) - goto invalid_pname; - *params = bufObj->Mappings[MAP_USER].AccessFlags; - return; - case GL_BUFFER_MAPPED_ARB: - *params = _mesa_bufferobj_mapped(bufObj, MAP_USER); - return; - case GL_BUFFER_MAP_OFFSET: - if (!ctx->Extensions.ARB_map_buffer_range) - goto invalid_pname; - *params = bufObj->Mappings[MAP_USER].Offset; - return; - case GL_BUFFER_MAP_LENGTH: - if (!ctx->Extensions.ARB_map_buffer_range) - goto invalid_pname; - *params = bufObj->Mappings[MAP_USER].Length; - return; - case GL_BUFFER_IMMUTABLE_STORAGE: - if (!ctx->Extensions.ARB_buffer_storage) - goto invalid_pname; - *params = bufObj->Immutable; - return; - case GL_BUFFER_STORAGE_FLAGS: - if (!ctx->Extensions.ARB_buffer_storage) - goto invalid_pname; - *params = bufObj->StorageFlags; - return; - default: - ; /* fall-through */ - } + if (!get_buffer_parameter(ctx, bufObj, pname, ¶meter, + "glGetBufferParameteri64v")) + return; /* Error already recorded. */ -invalid_pname: - _mesa_error(ctx, GL_INVALID_ENUM, "glGetBufferParameteri64v(pname=%s)", - _mesa_lookup_enum_by_nr(pname)); + *params = parameter; } From ldeks at kemper.freedesktop.org Tue Mar 17 17:20:06 2015 From: ldeks at kemper.freedesktop.org (Laura Ekstrand) Date: Tue, 17 Mar 2015 10:20:06 -0700 (PDT) Subject: Mesa (master): main: Add entry point for GetNamedBufferSubData. Message-ID: <20150317172006.33F9D76338@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 23eab47bbe998b95d5da889b85b7b0ca6e14385b URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=23eab47bbe998b95d5da889b85b7b0ca6e14385b Author: Laura Ekstrand Date: Tue Jan 20 15:24:53 2015 -0800 main: Add entry point for GetNamedBufferSubData. Reviewed-by: Fredrik H?glund --- src/mapi/glapi/gen/ARB_direct_state_access.xml | 7 +++++++ src/mesa/main/bufferobj.c | 22 ++++++++++++++++++++++ src/mesa/main/bufferobj.h | 4 ++++ src/mesa/main/tests/dispatch_sanity.cpp | 1 + 4 files changed, 34 insertions(+) diff --git a/src/mapi/glapi/gen/ARB_direct_state_access.xml b/src/mapi/glapi/gen/ARB_direct_state_access.xml index 8bcbb08..641e68f 100644 --- a/src/mapi/glapi/gen/ARB_direct_state_access.xml +++ b/src/mapi/glapi/gen/ARB_direct_state_access.xml @@ -104,6 +104,13 @@ + + + + + + + diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c index 49d6d32..7aac1c6 100644 --- a/src/mesa/main/bufferobj.c +++ b/src/mesa/main/bufferobj.c @@ -1700,6 +1700,28 @@ _mesa_GetBufferSubData(GLenum target, GLintptr offset, ctx->Driver.GetBufferSubData( ctx, offset, size, data, bufObj ); } +void GLAPIENTRY +_mesa_GetNamedBufferSubData(GLuint buffer, GLintptr offset, + GLsizeiptr size, GLvoid *data) +{ + GET_CURRENT_CONTEXT(ctx); + struct gl_buffer_object *bufObj; + + bufObj = _mesa_lookup_bufferobj_err(ctx, buffer, + "glGetNamedBufferSubData"); + if (!bufObj) + return; + + if (!buffer_object_subdata_range_good(ctx, bufObj, offset, size, false, + "glGetNamedBufferSubData")) { + return; + } + + assert(ctx->Driver.GetBufferSubData); + ctx->Driver.GetBufferSubData(ctx, offset, size, data, bufObj); +} + + /** * \param subdata true if caller is *SubData, false if *Data */ diff --git a/src/mesa/main/bufferobj.h b/src/mesa/main/bufferobj.h index eee04fe..feeaa8b 100644 --- a/src/mesa/main/bufferobj.h +++ b/src/mesa/main/bufferobj.h @@ -234,6 +234,10 @@ _mesa_GetBufferSubData(GLenum target, GLintptrARB offset, GLsizeiptrARB size, void * data); void GLAPIENTRY +_mesa_GetNamedBufferSubData(GLuint buffer, GLintptr offset, + GLsizeiptr size, GLvoid *data); + +void GLAPIENTRY _mesa_ClearBufferData(GLenum target, GLenum internalformat, GLenum format, GLenum type, const GLvoid *data); diff --git a/src/mesa/main/tests/dispatch_sanity.cpp b/src/mesa/main/tests/dispatch_sanity.cpp index 01b73a6..5d849d4 100644 --- a/src/mesa/main/tests/dispatch_sanity.cpp +++ b/src/mesa/main/tests/dispatch_sanity.cpp @@ -967,6 +967,7 @@ const struct function gl_core_functions_possible[] = { { "glGetNamedBufferParameteriv", 45, -1 }, { "glGetNamedBufferParameteri64v", 45, -1 }, { "glGetNamedBufferPointerv", 45, -1 }, + { "glGetNamedBufferSubData", 45, -1 }, { "glCreateTextures", 45, -1 }, { "glTextureStorage1D", 45, -1 }, { "glTextureStorage2D", 45, -1 }, From ldeks at kemper.freedesktop.org Tue Mar 17 17:20:05 2015 From: ldeks at kemper.freedesktop.org (Laura Ekstrand) Date: Tue, 17 Mar 2015 10:20:05 -0700 (PDT) Subject: Mesa (master): main: Add entry point for NamedBufferStorage. Message-ID: <20150317172005.695187633A@kemper.freedesktop.org> Module: Mesa Branch: master Commit: a76808dc19580855eb39c0904f3254edd765aa50 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=a76808dc19580855eb39c0904f3254edd765aa50 Author: Laura Ekstrand Date: Fri Jan 9 16:17:10 2015 -0800 main: Add entry point for NamedBufferStorage. Reviewed-by: Martin Peres --- src/mapi/glapi/gen/ARB_direct_state_access.xml | 7 +++ src/mesa/main/bufferobj.c | 65 +++++++++++++++++------- src/mesa/main/bufferobj.h | 9 ++++ src/mesa/main/tests/dispatch_sanity.cpp | 1 + 4 files changed, 65 insertions(+), 17 deletions(-) diff --git a/src/mapi/glapi/gen/ARB_direct_state_access.xml b/src/mapi/glapi/gen/ARB_direct_state_access.xml index 6c9d0e8..ff81c21 100644 --- a/src/mapi/glapi/gen/ARB_direct_state_access.xml +++ b/src/mapi/glapi/gen/ARB_direct_state_access.xml @@ -14,6 +14,13 @@ + + + + + + + diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c index 01bb131..73d4cb3 100644 --- a/src/mesa/main/bufferobj.c +++ b/src/mesa/main/bufferobj.c @@ -1395,15 +1395,13 @@ _mesa_IsBuffer(GLuint id) } -void GLAPIENTRY -_mesa_BufferStorage(GLenum target, GLsizeiptr size, const GLvoid *data, - GLbitfield flags) +void +_mesa_buffer_storage(struct gl_context *ctx, struct gl_buffer_object *bufObj, + GLenum target, GLsizeiptr size, const GLvoid *data, + GLbitfield flags, const char *func) { - GET_CURRENT_CONTEXT(ctx); - struct gl_buffer_object *bufObj; - if (size <= 0) { - _mesa_error(ctx, GL_INVALID_VALUE, "glBufferStorage(size <= 0)"); + _mesa_error(ctx, GL_INVALID_VALUE, "%s(size <= 0)", func); return; } @@ -1413,27 +1411,25 @@ _mesa_BufferStorage(GLenum target, GLsizeiptr size, const GLvoid *data, GL_MAP_COHERENT_BIT | GL_DYNAMIC_STORAGE_BIT | GL_CLIENT_STORAGE_BIT)) { - _mesa_error(ctx, GL_INVALID_VALUE, "glBufferStorage(flags)"); + _mesa_error(ctx, GL_INVALID_VALUE, "%s(invalid flag bits set)", func); return; } if (flags & GL_MAP_PERSISTENT_BIT && !(flags & (GL_MAP_READ_BIT | GL_MAP_WRITE_BIT))) { - _mesa_error(ctx, GL_INVALID_VALUE, "glBufferStorage(flags!=READ/WRITE)"); + _mesa_error(ctx, GL_INVALID_VALUE, + "%s(PERSISTENT and flags!=READ/WRITE)", func); return; } if (flags & GL_MAP_COHERENT_BIT && !(flags & GL_MAP_PERSISTENT_BIT)) { - _mesa_error(ctx, GL_INVALID_VALUE, "glBufferStorage(flags!=PERSISTENT)"); + _mesa_error(ctx, GL_INVALID_VALUE, + "%s(COHERENT and flags!=PERSISTENT)", func); return; } - bufObj = get_buffer(ctx, "glBufferStorage", target, GL_INVALID_OPERATION); - if (!bufObj) - return; - if (bufObj->Immutable) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glBufferStorage(immutable)"); + _mesa_error(ctx, GL_INVALID_OPERATION, "%s(immutable)", func); return; } @@ -1453,14 +1449,49 @@ _mesa_BufferStorage(GLenum target, GLsizeiptr size, const GLvoid *data, * glBufferStorage is not described in the spec, Graham Sellers * said that it should behave the same as glBufferData. */ - _mesa_error(ctx, GL_INVALID_OPERATION, "glBufferStorage()"); + _mesa_error(ctx, GL_INVALID_OPERATION, "%s", func); } else { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glBufferStorage()"); + _mesa_error(ctx, GL_OUT_OF_MEMORY, "%s", func); } } } +void GLAPIENTRY +_mesa_BufferStorage(GLenum target, GLsizeiptr size, const GLvoid *data, + GLbitfield flags) +{ + GET_CURRENT_CONTEXT(ctx); + struct gl_buffer_object *bufObj; + + bufObj = get_buffer(ctx, "glBufferStorage", target, GL_INVALID_OPERATION); + if (!bufObj) + return; + + _mesa_buffer_storage(ctx, bufObj, target, size, data, flags, + "glBufferStorage"); +} + +void GLAPIENTRY +_mesa_NamedBufferStorage(GLuint buffer, GLsizeiptr size, const GLvoid *data, + GLbitfield flags) +{ + GET_CURRENT_CONTEXT(ctx); + struct gl_buffer_object *bufObj; + + bufObj = _mesa_lookup_bufferobj_err(ctx, buffer, "glNamedBufferStorage"); + if (!bufObj) + return; + + /* + * In direct state access, buffer objects have an unspecified target since + * they are not required to be bound. + */ + _mesa_buffer_storage(ctx, bufObj, GL_NONE, size, data, flags, + "glNamedBufferStorage"); +} + + void GLAPIENTRY _mesa_BufferData(GLenum target, GLsizeiptrARB size, diff --git a/src/mesa/main/bufferobj.h b/src/mesa/main/bufferobj.h index 48d253b..3c337aa 100644 --- a/src/mesa/main/bufferobj.h +++ b/src/mesa/main/bufferobj.h @@ -130,6 +130,11 @@ extern void _mesa_init_buffer_object_functions(struct dd_function_table *driver); extern void +_mesa_buffer_storage(struct gl_context *ctx, struct gl_buffer_object *bufObj, + GLenum target, GLsizeiptr size, const GLvoid *data, + GLbitfield flags, const char *func); + +extern void _mesa_buffer_unmap_all_mappings(struct gl_context *ctx, struct gl_buffer_object *bufObj); @@ -163,6 +168,10 @@ _mesa_BufferStorage(GLenum target, GLsizeiptr size, const GLvoid *data, GLbitfield flags); void GLAPIENTRY +_mesa_NamedBufferStorage(GLuint buffer, GLsizeiptr size, const GLvoid *data, + GLbitfield flags); + +void GLAPIENTRY _mesa_BufferData(GLenum target, GLsizeiptrARB size, const GLvoid * data, GLenum usage); diff --git a/src/mesa/main/tests/dispatch_sanity.cpp b/src/mesa/main/tests/dispatch_sanity.cpp index 15a1138..bc920d4 100644 --- a/src/mesa/main/tests/dispatch_sanity.cpp +++ b/src/mesa/main/tests/dispatch_sanity.cpp @@ -954,6 +954,7 @@ const struct function gl_core_functions_possible[] = { /* GL_ARB_direct_state_access */ { "glCreateBuffers", 45, -1 }, + { "glNamedBufferStorage", 45, -1 }, { "glCreateTextures", 45, -1 }, { "glTextureStorage1D", 45, -1 }, { "glTextureStorage2D", 45, -1 }, From ldeks at kemper.freedesktop.org Tue Mar 17 17:20:05 2015 From: ldeks at kemper.freedesktop.org (Laura Ekstrand) Date: Tue, 17 Mar 2015 10:20:05 -0700 (PDT) Subject: Mesa (master): main: Add entry points for ClearNamedBuffer[Sub]Data. Message-ID: <20150317172005.B13A176338@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 5030d0a4f79c3309bad04cc257beb97f74f84f61 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=5030d0a4f79c3309bad04cc257beb97f74f84f61 Author: Laura Ekstrand Date: Wed Feb 11 12:17:38 2015 -0800 main: Add entry points for ClearNamedBuffer[Sub]Data. Reviewed-by: Martin Peres --- src/mapi/glapi/gen/ARB_direct_state_access.xml | 18 ++++++++++++ src/mesa/main/bufferobj.c | 35 ++++++++++++++++++++++++ src/mesa/main/bufferobj.h | 11 ++++++++ src/mesa/main/tests/dispatch_sanity.cpp | 2 ++ 4 files changed, 66 insertions(+) diff --git a/src/mapi/glapi/gen/ARB_direct_state_access.xml b/src/mapi/glapi/gen/ARB_direct_state_access.xml index 042b2a8..ce4017b 100644 --- a/src/mapi/glapi/gen/ARB_direct_state_access.xml +++ b/src/mapi/glapi/gen/ARB_direct_state_access.xml @@ -43,6 +43,24 @@ + + + + + + + + + + + + + + + + + + diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c index b2d0ef9..ae086a6 100644 --- a/src/mesa/main/bufferobj.c +++ b/src/mesa/main/bufferobj.c @@ -1773,6 +1773,22 @@ _mesa_ClearBufferData(GLenum target, GLenum internalformat, GLenum format, "glClearBufferData", false); } +void GLAPIENTRY +_mesa_ClearNamedBufferData(GLuint buffer, GLenum internalformat, + GLenum format, GLenum type, const GLvoid *data) +{ + GET_CURRENT_CONTEXT(ctx); + struct gl_buffer_object *bufObj; + + bufObj = _mesa_lookup_bufferobj_err(ctx, buffer, "glClearNamedBufferData"); + if (!bufObj) + return; + + _mesa_clear_buffer_sub_data(ctx, bufObj, internalformat, 0, bufObj->Size, + format, type, data, + "glClearNamedBufferData", false); +} + void GLAPIENTRY _mesa_ClearBufferSubData(GLenum target, GLenum internalformat, @@ -1792,6 +1808,25 @@ _mesa_ClearBufferSubData(GLenum target, GLenum internalformat, "glClearBufferSubData", true); } +void GLAPIENTRY +_mesa_ClearNamedBufferSubData(GLuint buffer, GLenum internalformat, + GLintptr offset, GLsizeiptr size, + GLenum format, GLenum type, + const GLvoid *data) +{ + GET_CURRENT_CONTEXT(ctx); + struct gl_buffer_object *bufObj; + + bufObj = _mesa_lookup_bufferobj_err(ctx, buffer, + "glClearNamedBufferSubData"); + if (!bufObj) + return; + + _mesa_clear_buffer_sub_data(ctx, bufObj, internalformat, offset, size, + format, type, data, + "glClearNamedBufferSubData", true); +} + void * GLAPIENTRY _mesa_MapBuffer(GLenum target, GLenum access) diff --git a/src/mesa/main/bufferobj.h b/src/mesa/main/bufferobj.h index 5911270..5254727 100644 --- a/src/mesa/main/bufferobj.h +++ b/src/mesa/main/bufferobj.h @@ -223,11 +223,22 @@ _mesa_ClearBufferData(GLenum target, GLenum internalformat, const GLvoid * data); void GLAPIENTRY +_mesa_ClearNamedBufferData(GLuint buffer, GLenum internalformat, + GLenum format, GLenum type, + const GLvoid *data); + +void GLAPIENTRY _mesa_ClearBufferSubData(GLenum target, GLenum internalformat, GLintptr offset, GLsizeiptr size, GLenum format, GLenum type, const GLvoid * data); +void GLAPIENTRY +_mesa_ClearNamedBufferSubData(GLuint buffer, GLenum internalformat, + GLintptr offset, GLsizeiptr size, + GLenum format, GLenum type, + const GLvoid *data); + void * GLAPIENTRY _mesa_MapBuffer(GLenum target, GLenum access); diff --git a/src/mesa/main/tests/dispatch_sanity.cpp b/src/mesa/main/tests/dispatch_sanity.cpp index 63b9dcf..aff5cd6 100644 --- a/src/mesa/main/tests/dispatch_sanity.cpp +++ b/src/mesa/main/tests/dispatch_sanity.cpp @@ -958,6 +958,8 @@ const struct function gl_core_functions_possible[] = { { "glNamedBufferData", 45, -1 }, { "glNamedBufferSubData", 45, -1 }, { "glCopyNamedBufferSubData", 45, -1 }, + { "glClearNamedBufferData", 45, -1 }, + { "glClearNamedBufferSubData", 45, -1 }, { "glCreateTextures", 45, -1 }, { "glTextureStorage1D", 45, -1 }, { "glTextureStorage2D", 45, -1 }, From ldeks at kemper.freedesktop.org Tue Mar 17 17:20:06 2015 From: ldeks at kemper.freedesktop.org (Laura Ekstrand) Date: Tue, 17 Mar 2015 10:20:06 -0700 (PDT) Subject: Mesa (master): main: Add entry points for GetNamedBufferParameteri[64]v. Message-ID: <20150317172006.16BFB76338@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 1e45752aaf4ac7d2324d71bda4d2ac34f3abf8bd URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=1e45752aaf4ac7d2324d71bda4d2ac34f3abf8bd Author: Laura Ekstrand Date: Wed Feb 11 16:10:20 2015 -0800 main: Add entry points for GetNamedBufferParameteri[64]v. Reviewed-by: Fredrik H?glund --- src/mapi/glapi/gen/ARB_direct_state_access.xml | 12 ++++++++ src/mesa/main/bufferobj.c | 39 ++++++++++++++++++++++++ src/mesa/main/bufferobj.h | 7 +++++ src/mesa/main/tests/dispatch_sanity.cpp | 2 ++ 4 files changed, 60 insertions(+) diff --git a/src/mapi/glapi/gen/ARB_direct_state_access.xml b/src/mapi/glapi/gen/ARB_direct_state_access.xml index 27938c5..cb9f285 100644 --- a/src/mapi/glapi/gen/ARB_direct_state_access.xml +++ b/src/mapi/glapi/gen/ARB_direct_state_access.xml @@ -86,6 +86,18 @@ + + + + + + + + + + + + diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c index e39ad94..4c2cdf4 100644 --- a/src/mesa/main/bufferobj.c +++ b/src/mesa/main/bufferobj.c @@ -2007,6 +2007,45 @@ _mesa_GetBufferParameteri64v(GLenum target, GLenum pname, GLint64 *params) *params = parameter; } +void GLAPIENTRY +_mesa_GetNamedBufferParameteriv(GLuint buffer, GLenum pname, GLint *params) +{ + GET_CURRENT_CONTEXT(ctx); + struct gl_buffer_object *bufObj; + GLint64 parameter; + + bufObj = _mesa_lookup_bufferobj_err(ctx, buffer, + "glGetNamedBufferParameteriv"); + if (!bufObj) + return; + + if (!get_buffer_parameter(ctx, bufObj, pname, ¶meter, + "glGetNamedBufferParameteriv")) + return; /* Error already recorded. */ + + *params = (GLint) parameter; +} + +void GLAPIENTRY +_mesa_GetNamedBufferParameteri64v(GLuint buffer, GLenum pname, + GLint64 *params) +{ + GET_CURRENT_CONTEXT(ctx); + struct gl_buffer_object *bufObj; + GLint64 parameter; + + bufObj = _mesa_lookup_bufferobj_err(ctx, buffer, + "glGetNamedBufferParameteri64v"); + if (!bufObj) + return; + + if (!get_buffer_parameter(ctx, bufObj, pname, ¶meter, + "glGetNamedBufferParameteri64v")) + return; /* Error already recorded. */ + + *params = parameter; +} + void GLAPIENTRY _mesa_GetBufferPointerv(GLenum target, GLenum pname, GLvoid **params) diff --git a/src/mesa/main/bufferobj.h b/src/mesa/main/bufferobj.h index 0b77bff..6b29ce7 100644 --- a/src/mesa/main/bufferobj.h +++ b/src/mesa/main/bufferobj.h @@ -268,6 +268,13 @@ void GLAPIENTRY _mesa_GetBufferParameteri64v(GLenum target, GLenum pname, GLint64 *params); void GLAPIENTRY +_mesa_GetNamedBufferParameteriv(GLuint buffer, GLenum pname, GLint *params); + +void GLAPIENTRY +_mesa_GetNamedBufferParameteri64v(GLuint buffer, GLenum pname, + GLint64 *params); + +void GLAPIENTRY _mesa_GetBufferPointerv(GLenum target, GLenum pname, GLvoid **params); void GLAPIENTRY diff --git a/src/mesa/main/tests/dispatch_sanity.cpp b/src/mesa/main/tests/dispatch_sanity.cpp index 3dd0751..336c41c 100644 --- a/src/mesa/main/tests/dispatch_sanity.cpp +++ b/src/mesa/main/tests/dispatch_sanity.cpp @@ -964,6 +964,8 @@ const struct function gl_core_functions_possible[] = { { "glMapNamedBufferRange", 45, -1 }, { "glUnmapNamedBuffer", 45, -1 }, { "glFlushMappedNamedBufferRange", 45, -1 }, + { "glGetNamedBufferParameteriv", 45, -1 }, + { "glGetNamedBufferParameteri64v", 45, -1 }, { "glCreateTextures", 45, -1 }, { "glTextureStorage1D", 45, -1 }, { "glTextureStorage2D", 45, -1 }, From ldeks at kemper.freedesktop.org Tue Mar 17 17:20:06 2015 From: ldeks at kemper.freedesktop.org (Laura Ekstrand) Date: Tue, 17 Mar 2015 10:20:06 -0700 (PDT) Subject: Mesa (master): main: Add entry point for GetNamedBufferPointerv. Message-ID: <20150317172006.200E976338@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 105ddc6aea397bd5d39b8ffcd25278ed12102e3c URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=105ddc6aea397bd5d39b8ffcd25278ed12102e3c Author: Laura Ekstrand Date: Tue Jan 20 14:32:35 2015 -0800 main: Add entry point for GetNamedBufferPointerv. v3: Review from Fredrik Hoglund -Split cosmetic refactor of GetBufferPointerv out into a separate commit Reviewed-by: Fredrik H?glund --- src/mapi/glapi/gen/ARB_direct_state_access.xml | 6 ++++++ src/mesa/main/bufferobj.c | 20 ++++++++++++++++++++ src/mesa/main/bufferobj.h | 4 ++++ src/mesa/main/tests/dispatch_sanity.cpp | 1 + 4 files changed, 31 insertions(+) diff --git a/src/mapi/glapi/gen/ARB_direct_state_access.xml b/src/mapi/glapi/gen/ARB_direct_state_access.xml index cb9f285..8bcbb08 100644 --- a/src/mapi/glapi/gen/ARB_direct_state_access.xml +++ b/src/mapi/glapi/gen/ARB_direct_state_access.xml @@ -98,6 +98,12 @@ + + + + + + diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c index 4c2cdf4..2811604 100644 --- a/src/mesa/main/bufferobj.c +++ b/src/mesa/main/bufferobj.c @@ -2066,6 +2066,26 @@ _mesa_GetBufferPointerv(GLenum target, GLenum pname, GLvoid **params) *params = bufObj->Mappings[MAP_USER].Pointer; } +void GLAPIENTRY +_mesa_GetNamedBufferPointerv(GLuint buffer, GLenum pname, GLvoid **params) +{ + GET_CURRENT_CONTEXT(ctx); + struct gl_buffer_object *bufObj; + + if (pname != GL_BUFFER_MAP_POINTER) { + _mesa_error(ctx, GL_INVALID_ENUM, "glGetNamedBufferPointerv(pname != " + "GL_BUFFER_MAP_POINTER)"); + return; + } + + bufObj = _mesa_lookup_bufferobj_err(ctx, buffer, + "glGetNamedBufferPointerv"); + if (!bufObj) + return; + + *params = bufObj->Mappings[MAP_USER].Pointer; +} + void _mesa_copy_buffer_sub_data(struct gl_context *ctx, diff --git a/src/mesa/main/bufferobj.h b/src/mesa/main/bufferobj.h index 6b29ce7..eee04fe 100644 --- a/src/mesa/main/bufferobj.h +++ b/src/mesa/main/bufferobj.h @@ -278,6 +278,10 @@ void GLAPIENTRY _mesa_GetBufferPointerv(GLenum target, GLenum pname, GLvoid **params); void GLAPIENTRY +_mesa_GetNamedBufferPointerv(GLuint buffer, GLenum pname, GLvoid **params); + + +void GLAPIENTRY _mesa_CopyBufferSubData(GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); diff --git a/src/mesa/main/tests/dispatch_sanity.cpp b/src/mesa/main/tests/dispatch_sanity.cpp index 336c41c..01b73a6 100644 --- a/src/mesa/main/tests/dispatch_sanity.cpp +++ b/src/mesa/main/tests/dispatch_sanity.cpp @@ -966,6 +966,7 @@ const struct function gl_core_functions_possible[] = { { "glFlushMappedNamedBufferRange", 45, -1 }, { "glGetNamedBufferParameteriv", 45, -1 }, { "glGetNamedBufferParameteri64v", 45, -1 }, + { "glGetNamedBufferPointerv", 45, -1 }, { "glCreateTextures", 45, -1 }, { "glTextureStorage1D", 45, -1 }, { "glTextureStorage2D", 45, -1 }, From ldeks at kemper.freedesktop.org Tue Mar 17 17:20:06 2015 From: ldeks at kemper.freedesktop.org (Laura Ekstrand) Date: Tue, 17 Mar 2015 10:20:06 -0700 (PDT) Subject: Mesa (master): main: Cosmetic updates to GetBufferPointerv. Message-ID: <20150317172006.2A49176338@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 3706ace2446825b9544e45800c0ce1df261a1c30 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=3706ace2446825b9544e45800c0ce1df261a1c30 Author: Laura Ekstrand Date: Mon Mar 16 16:08:36 2015 -0700 main: Cosmetic updates to GetBufferPointerv. v3: Review from Fredrik Hoglund -Split cosmetic refactor of GetBufferPointerv out into a separate commit Reviewed-by: Fredrik H?glund --- src/mesa/main/bufferobj.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c index 2811604..49d6d32 100644 --- a/src/mesa/main/bufferobj.c +++ b/src/mesa/main/bufferobj.c @@ -2051,14 +2051,15 @@ void GLAPIENTRY _mesa_GetBufferPointerv(GLenum target, GLenum pname, GLvoid **params) { GET_CURRENT_CONTEXT(ctx); - struct gl_buffer_object * bufObj; + struct gl_buffer_object *bufObj; - if (pname != GL_BUFFER_MAP_POINTER_ARB) { - _mesa_error(ctx, GL_INVALID_ENUM, "glGetBufferPointervARB(pname)"); + if (pname != GL_BUFFER_MAP_POINTER) { + _mesa_error(ctx, GL_INVALID_ENUM, "glGetBufferPointerv(pname != " + "GL_BUFFER_MAP_POINTER)"); return; } - bufObj = get_buffer(ctx, "glGetBufferPointervARB", target, + bufObj = get_buffer(ctx, "glGetBufferPointerv", target, GL_INVALID_OPERATION); if (!bufObj) return; From ldeks at kemper.freedesktop.org Tue Mar 17 17:20:06 2015 From: ldeks at kemper.freedesktop.org (Laura Ekstrand) Date: Tue, 17 Mar 2015 10:20:06 -0700 (PDT) Subject: Mesa (master): main: Cosmetic changes to GetBufferSubData. Message-ID: <20150317172006.3CEF176338@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 579297c8bdffd92f47a8cc02100b9535822d2ae7 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=579297c8bdffd92f47a8cc02100b9535822d2ae7 Author: Laura Ekstrand Date: Wed Feb 11 16:53:46 2015 -0800 main: Cosmetic changes to GetBufferSubData. Reviewed-by: Fredrik H?glund --- src/mesa/main/bufferobj.c | 2 +- src/mesa/main/bufferobj.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c index 7aac1c6..7d2e5f8 100644 --- a/src/mesa/main/bufferobj.c +++ b/src/mesa/main/bufferobj.c @@ -1697,7 +1697,7 @@ _mesa_GetBufferSubData(GLenum target, GLintptr offset, } assert(ctx->Driver.GetBufferSubData); - ctx->Driver.GetBufferSubData( ctx, offset, size, data, bufObj ); + ctx->Driver.GetBufferSubData(ctx, offset, size, data, bufObj); } void GLAPIENTRY diff --git a/src/mesa/main/bufferobj.h b/src/mesa/main/bufferobj.h index feeaa8b..b5d73ae 100644 --- a/src/mesa/main/bufferobj.h +++ b/src/mesa/main/bufferobj.h @@ -230,8 +230,8 @@ _mesa_NamedBufferSubData(GLuint buffer, GLintptr offset, GLsizeiptr size, const GLvoid *data); void GLAPIENTRY -_mesa_GetBufferSubData(GLenum target, GLintptrARB offset, - GLsizeiptrARB size, void * data); +_mesa_GetBufferSubData(GLenum target, GLintptr offset, + GLsizeiptr size, GLvoid *data); void GLAPIENTRY _mesa_GetNamedBufferSubData(GLuint buffer, GLintptr offset, From ldeks at kemper.freedesktop.org Tue Mar 17 20:31:31 2015 From: ldeks at kemper.freedesktop.org (Laura Ekstrand) Date: Tue, 17 Mar 2015 13:31:31 -0700 (PDT) Subject: Mesa (master): main: Correct _mesa_error with no format in bufferobj.c. Message-ID: <20150317203131.C12B776338@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 827da841a1b3dbd4252c39be99965710c5085f5a URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=827da841a1b3dbd4252c39be99965710c5085f5a Author: Laura Ekstrand Date: Tue Mar 17 13:27:31 2015 -0700 main: Correct _mesa_error with no format in bufferobj.c. This fixes Bug 89616, a build failure due to line 1639 of bufferobj.c: _mesa_error(ctx, GL_INVALID_OPERATION, func); Trivial. --- src/mesa/main/bufferobj.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c index 7d2e5f8..78d3d78 100644 --- a/src/mesa/main/bufferobj.c +++ b/src/mesa/main/bufferobj.c @@ -1636,7 +1636,7 @@ _mesa_buffer_sub_data(struct gl_context *ctx, struct gl_buffer_object *bufObj, if (bufObj->Immutable && !(bufObj->StorageFlags & GL_DYNAMIC_STORAGE_BIT)) { - _mesa_error(ctx, GL_INVALID_OPERATION, func); + _mesa_error(ctx, GL_INVALID_OPERATION, "%s", func); return; } From mattst88 at kemper.freedesktop.org Tue Mar 17 21:10:17 2015 From: mattst88 at kemper.freedesktop.org (Matt Turner) Date: Tue, 17 Mar 2015 14:10:17 -0700 (PDT) Subject: Mesa (master): i965: Mark paths in linear <-> tiled functions as unreachable(). Message-ID: <20150317211017.279F27633A@kemper.freedesktop.org> Module: Mesa Branch: master Commit: d35720da9b9824d104532028775e497491f433ad URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=d35720da9b9824d104532028775e497491f433ad Author: Matt Turner Date: Wed Mar 4 17:27:21 2015 -0800 i965: Mark paths in linear <-> tiled functions as unreachable(). text data bss dec hex filename 9663 0 0 9663 25bf intel_tiled_memcpy.o before 8215 0 0 8215 2017 intel_tiled_memcpy.o after Reviewed-by: Carl Worth Reviewed-by: Jason Ekstrand --- src/mesa/drivers/dri/i965/intel_tiled_memcpy.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/mesa/drivers/dri/i965/intel_tiled_memcpy.c b/src/mesa/drivers/dri/i965/intel_tiled_memcpy.c index 2097aaa..dcf0462 100644 --- a/src/mesa/drivers/dri/i965/intel_tiled_memcpy.c +++ b/src/mesa/drivers/dri/i965/intel_tiled_memcpy.c @@ -398,6 +398,8 @@ linear_to_xtiled_faster(uint32_t x0, uint32_t x1, uint32_t x2, uint32_t x3, return linear_to_xtiled(0, 0, xtile_width, xtile_width, 0, xtile_height, dst, src, src_pitch, swizzle_bit, rgba8_copy_aligned_dst); + else + unreachable("not reached"); } else { if (mem_copy == memcpy) return linear_to_xtiled(x0, x1, x2, x3, y0, y1, @@ -406,6 +408,8 @@ linear_to_xtiled_faster(uint32_t x0, uint32_t x1, uint32_t x2, uint32_t x3, return linear_to_xtiled(x0, x1, x2, x3, y0, y1, dst, src, src_pitch, swizzle_bit, rgba8_copy_aligned_dst); + else + unreachable("not reached"); } linear_to_xtiled(x0, x1, x2, x3, y0, y1, dst, src, src_pitch, swizzle_bit, mem_copy); @@ -436,6 +440,8 @@ linear_to_ytiled_faster(uint32_t x0, uint32_t x1, uint32_t x2, uint32_t x3, return linear_to_ytiled(0, 0, ytile_width, ytile_width, 0, ytile_height, dst, src, src_pitch, swizzle_bit, rgba8_copy_aligned_dst); + else + unreachable("not reached"); } else { if (mem_copy == memcpy) return linear_to_ytiled(x0, x1, x2, x3, y0, y1, @@ -444,6 +450,8 @@ linear_to_ytiled_faster(uint32_t x0, uint32_t x1, uint32_t x2, uint32_t x3, return linear_to_ytiled(x0, x1, x2, x3, y0, y1, dst, src, src_pitch, swizzle_bit, rgba8_copy_aligned_dst); + else + unreachable("not reached"); } linear_to_ytiled(x0, x1, x2, x3, y0, y1, dst, src, src_pitch, swizzle_bit, mem_copy); @@ -474,6 +482,8 @@ xtiled_to_linear_faster(uint32_t x0, uint32_t x1, uint32_t x2, uint32_t x3, return xtiled_to_linear(0, 0, xtile_width, xtile_width, 0, xtile_height, dst, src, dst_pitch, swizzle_bit, rgba8_copy_aligned_src); + else + unreachable("not reached"); } else { if (mem_copy == memcpy) return xtiled_to_linear(x0, x1, x2, x3, y0, y1, @@ -482,6 +492,8 @@ xtiled_to_linear_faster(uint32_t x0, uint32_t x1, uint32_t x2, uint32_t x3, return xtiled_to_linear(x0, x1, x2, x3, y0, y1, dst, src, dst_pitch, swizzle_bit, rgba8_copy_aligned_src); + else + unreachable("not reached"); } xtiled_to_linear(x0, x1, x2, x3, y0, y1, dst, src, dst_pitch, swizzle_bit, mem_copy); @@ -512,6 +524,8 @@ ytiled_to_linear_faster(uint32_t x0, uint32_t x1, uint32_t x2, uint32_t x3, return ytiled_to_linear(0, 0, ytile_width, ytile_width, 0, ytile_height, dst, src, dst_pitch, swizzle_bit, rgba8_copy_aligned_src); + else + unreachable("not reached"); } else { if (mem_copy == memcpy) return ytiled_to_linear(x0, x1, x2, x3, y0, y1, @@ -520,6 +534,8 @@ ytiled_to_linear_faster(uint32_t x0, uint32_t x1, uint32_t x2, uint32_t x3, return ytiled_to_linear(x0, x1, x2, x3, y0, y1, dst, src, dst_pitch, swizzle_bit, rgba8_copy_aligned_src); + else + unreachable("not reached"); } ytiled_to_linear(x0, x1, x2, x3, y0, y1, dst, src, dst_pitch, swizzle_bit, mem_copy); From mattst88 at kemper.freedesktop.org Tue Mar 17 21:10:17 2015 From: mattst88 at kemper.freedesktop.org (Matt Turner) Date: Tue, 17 Mar 2015 14:10:17 -0700 (PDT) Subject: Mesa (master): egl: Remove eglQueryString virtual dispatch. Message-ID: <20150317211017.1DCB376338@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 6c6e2a15aa7e8c0fd9a1180a901389c1692992c3 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=6c6e2a15aa7e8c0fd9a1180a901389c1692992c3 Author: Matt Turner Date: Fri Mar 13 17:00:26 2015 -0700 egl: Remove eglQueryString virtual dispatch. Reviewed-by: Chad Versace --- src/egl/main/Makefile.sources | 2 -- src/egl/main/eglapi.c | 15 ++++++++--- src/egl/main/eglapi.h | 2 -- src/egl/main/eglfallbacks.c | 2 -- src/egl/main/eglmisc.c | 58 ----------------------------------------- src/egl/main/eglmisc.h | 42 ----------------------------- 6 files changed, 12 insertions(+), 109 deletions(-) diff --git a/src/egl/main/Makefile.sources b/src/egl/main/Makefile.sources index 75f060a..304c773 100644 --- a/src/egl/main/Makefile.sources +++ b/src/egl/main/Makefile.sources @@ -22,8 +22,6 @@ LIBEGL_C_FILES := \ eglimage.h \ egllog.c \ egllog.h \ - eglmisc.c \ - eglmisc.h \ eglmode.c \ eglmode.h \ eglscreen.c \ diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c index bd8ffa0..e224560 100644 --- a/src/egl/main/eglapi.c +++ b/src/egl/main/eglapi.c @@ -526,7 +526,6 @@ eglQueryString(EGLDisplay dpy, EGLint name) { _EGLDisplay *disp; _EGLDriver *drv; - const char *ret; if (dpy == EGL_NO_DISPLAY && name == EGL_EXTENSIONS) { RETURN_EGL_SUCCESS(NULL, _eglGlobal.ClientExtensionString); @@ -534,9 +533,19 @@ eglQueryString(EGLDisplay dpy, EGLint name) disp = _eglLockDisplay(dpy); _EGL_CHECK_DISPLAY(disp, NULL, drv); - ret = drv->API.QueryString(drv, disp, name); - RETURN_EGL_EVAL(disp, ret); + switch (name) { + case EGL_VENDOR: + RETURN_EGL_SUCCESS(disp, _EGL_VENDOR_STRING); + case EGL_VERSION: + RETURN_EGL_SUCCESS(disp, disp->VersionString); + case EGL_EXTENSIONS: + RETURN_EGL_SUCCESS(disp, disp->ExtensionsString); + case EGL_CLIENT_APIS: + RETURN_EGL_SUCCESS(disp, disp->ClientAPIsString); + default: + RETURN_EGL_ERROR(disp, EGL_BAD_PARAMETER, NULL); + } } diff --git a/src/egl/main/eglapi.h b/src/egl/main/eglapi.h index cb01cab..0626719 100644 --- a/src/egl/main/eglapi.h +++ b/src/egl/main/eglapi.h @@ -71,7 +71,6 @@ typedef EGLBoolean (*SwapBuffers_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurfa typedef EGLBoolean (*CopyBuffers_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surface, void *native_pixmap_target); /* misc funcs */ -typedef const char *(*QueryString_t)(_EGLDriver *drv, _EGLDisplay *dpy, EGLint name); typedef EGLBoolean (*WaitClient_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *ctx); typedef EGLBoolean (*WaitNative_t)(_EGLDriver *drv, _EGLDisplay *dpy, EGLint engine); @@ -170,7 +169,6 @@ struct _egl_api SwapBuffers_t SwapBuffers; CopyBuffers_t CopyBuffers; - QueryString_t QueryString; WaitClient_t WaitClient; WaitNative_t WaitNative; GetProcAddress_t GetProcAddress; diff --git a/src/egl/main/eglfallbacks.c b/src/egl/main/eglfallbacks.c index 0b70e92..be59643 100644 --- a/src/egl/main/eglfallbacks.c +++ b/src/egl/main/eglfallbacks.c @@ -32,7 +32,6 @@ #include "eglconfig.h" #include "eglcontext.h" #include "eglsurface.h" -#include "eglmisc.h" #include "eglscreen.h" #include "eglmode.h" #include "eglsync.h" @@ -85,7 +84,6 @@ _eglInitDriverFallbacks(_EGLDriver *drv) drv->API.WaitClient = (WaitClient_t) _eglReturnFalse; drv->API.WaitNative = (WaitNative_t) _eglReturnFalse; drv->API.GetProcAddress = (GetProcAddress_t) _eglReturnFalse; - drv->API.QueryString = _eglQueryString; #ifdef EGL_MESA_screen_surface drv->API.CopyContextMESA = (CopyContextMESA_t) _eglReturnFalse; diff --git a/src/egl/main/eglmisc.c b/src/egl/main/eglmisc.c deleted file mode 100644 index 3ca3524..0000000 --- a/src/egl/main/eglmisc.c +++ /dev/null @@ -1,58 +0,0 @@ -/************************************************************************** - * - * Copyright 2008 VMware, Inc. - * Copyright 2009-2010 Chia-I Wu - * Copyright 2010-2011 LunarG, 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 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. - * - **************************************************************************/ - - -/** - * Small/misc EGL functions - */ - - -#include "eglcurrent.h" -#include "eglmisc.h" -#include "egldisplay.h" - -const char * -_eglQueryString(_EGLDriver *drv, _EGLDisplay *dpy, EGLint name) -{ - (void) drv; - - switch (name) { - case EGL_VENDOR: - return _EGL_VENDOR_STRING; - case EGL_VERSION: - return dpy->VersionString; - case EGL_EXTENSIONS: - return dpy->ExtensionsString; - case EGL_CLIENT_APIS: - return dpy->ClientAPIsString; - default: - _eglError(EGL_BAD_PARAMETER, "eglQueryString"); - return NULL; - } -} diff --git a/src/egl/main/eglmisc.h b/src/egl/main/eglmisc.h deleted file mode 100644 index 068b38c..0000000 --- a/src/egl/main/eglmisc.h +++ /dev/null @@ -1,42 +0,0 @@ -/************************************************************************** - * - * Copyright 2008 VMware, Inc. - * Copyright 2009-2010 Chia-I Wu - * Copyright 2010-2011 LunarG, 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 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. - * - **************************************************************************/ - - -#ifndef EGLMISC_INCLUDED -#define EGLMISC_INCLUDED - - -#include "egltypedefs.h" - - -extern const char * -_eglQueryString(_EGLDriver *drv, _EGLDisplay *dpy, EGLint name); - - -#endif /* EGLMISC_INCLUDED */ From idr at kemper.freedesktop.org Tue Mar 17 22:04:19 2015 From: idr at kemper.freedesktop.org (Ian Romanick) Date: Tue, 17 Mar 2015 15:04:19 -0700 (PDT) Subject: Mesa (master): i965/fs: Handle CMP.nz ... 0 and AND.nz ... 1 similarly in cmod propagation Message-ID: <20150317220419.3EEA076338@kemper.freedesktop.org> Module: Mesa Branch: master Commit: ce3f46397d77141156f81dd7fcf06fb936e2b0ef URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=ce3f46397d77141156f81dd7fcf06fb936e2b0ef Author: Ian Romanick Date: Tue Feb 3 21:12:28 2015 +0200 i965/fs: Handle CMP.nz ... 0 and AND.nz ... 1 similarly in cmod propagation Espically on platforms that do not natively generate 0u and ~0u for Boolean results, we generate a lot of sequences where a CMP is followed by an AND with 1. emit_bool_to_cond_code does this, for example. On ILK, this results in a sequence like: add(8) g3<1>F g8<8,8,1>F -g4<0,1,0>F cmp.l.f0(8) g3<1>D g3<8,8,1>F 0F and.nz.f0(8) null g3<8,8,1>D 1D (+f0) iff(8) Jump: 6 The AND.nz is obviously redundant. By propagating the cmod, we can instead generate add.l.f0(8) null g8<8,8,1>F -g4<0,1,0>F (+f0) iff(8) Jump: 6 Existing code already handles the propagation from the CMP to the ADD. Shader-db results: GM45 (0x2A42): total instructions in shared programs: 3550829 -> 3550788 (-0.00%) instructions in affected programs: 10028 -> 9987 (-0.41%) helped: 24 Iron Lake (0x0046): total instructions in shared programs: 4993146 -> 4993105 (-0.00%) instructions in affected programs: 9675 -> 9634 (-0.42%) helped: 24 Ivy Bridge (0x0166): total instructions in shared programs: 6291870 -> 6291794 (-0.00%) instructions in affected programs: 17914 -> 17838 (-0.42%) helped: 48 Haswell (0x0426): total instructions in shared programs: 5779256 -> 5779180 (-0.00%) instructions in affected programs: 16694 -> 16618 (-0.46%) helped: 48 Broadwell (0x162E): total instructions in shared programs: 6823088 -> 6823014 (-0.00%) instructions in affected programs: 15824 -> 15750 (-0.47%) helped: 46 No chage on Sandy Bridge or on any platform when NIR is used. v2: Add unit tests suggested by Matt. Remove spurious writes_flag() check on scan_inst when scan_inst is known to be BRW_OPCODE_CMP (also suggested by Matt). v3: Fix some comments and remove some explicit int() casts in fs_reg constructors in the unit tests. Both suggested by Matt. Signed-off-by: Ian Romanick Reviewed-by: Matt Turner --- .../drivers/dri/i965/brw_fs_cmod_propagation.cpp | 31 +++++- .../drivers/dri/i965/test_fs_cmod_propagation.cpp | 105 ++++++++++++++++++++ 2 files changed, 135 insertions(+), 1 deletion(-) diff --git a/src/mesa/drivers/dri/i965/brw_fs_cmod_propagation.cpp b/src/mesa/drivers/dri/i965/brw_fs_cmod_propagation.cpp index d0ca2f9..1935f06 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_cmod_propagation.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_cmod_propagation.cpp @@ -57,7 +57,8 @@ opt_cmod_propagation_local(bblock_t *block) foreach_inst_in_block_reverse_safe(fs_inst, inst, block) { ip--; - if ((inst->opcode != BRW_OPCODE_CMP && + if ((inst->opcode != BRW_OPCODE_AND && + inst->opcode != BRW_OPCODE_CMP && inst->opcode != BRW_OPCODE_MOV) || inst->predicate != BRW_PREDICATE_NONE || !inst->dst.is_null() || @@ -65,6 +66,19 @@ opt_cmod_propagation_local(bblock_t *block) inst->src[0].abs) continue; + /* Only an AND.NZ can be propagated. Many AND.Z instructions are + * generated (for ir_unop_not in fs_visitor::emit_bool_to_cond_code). + * Propagating those would require inverting the condition on the CMP. + * This changes both the flag value and the register destination of the + * CMP. That result may be used elsewhere, so we can't change its value + * on a whim. + */ + if (inst->opcode == BRW_OPCODE_AND && + !(inst->src[1].is_one() && + inst->conditional_mod == BRW_CONDITIONAL_NZ && + !inst->src[0].negate)) + continue; + if (inst->opcode == BRW_OPCODE_CMP && !inst->src[1].is_zero()) continue; @@ -80,6 +94,21 @@ opt_cmod_propagation_local(bblock_t *block) scan_inst->dst.reg_offset != inst->src[0].reg_offset) break; + /* This must be done before the dst.type check because the result + * type of the AND will always be D, but the result of the CMP + * could be anything. The assumption is that the AND is just + * figuring out what the result of the previous comparison was + * instead of doing a new comparison with a different type. + */ + if (inst->opcode == BRW_OPCODE_AND) { + if (scan_inst->opcode == BRW_OPCODE_CMP) { + inst->remove(block); + progress = true; + } + + break; + } + /* Comparisons operate differently for ints and floats */ if (scan_inst->dst.type != inst->dst.type) break; diff --git a/src/mesa/drivers/dri/i965/test_fs_cmod_propagation.cpp b/src/mesa/drivers/dri/i965/test_fs_cmod_propagation.cpp index cb92abf..1ce14f8 100644 --- a/src/mesa/drivers/dri/i965/test_fs_cmod_propagation.cpp +++ b/src/mesa/drivers/dri/i965/test_fs_cmod_propagation.cpp @@ -449,3 +449,108 @@ TEST_F(cmod_propagation_test, different_types_cmod_with_zero) EXPECT_EQ(BRW_OPCODE_CMP, instruction(block0, 1)->opcode); EXPECT_EQ(BRW_CONDITIONAL_GE, instruction(block0, 1)->conditional_mod); } + +TEST_F(cmod_propagation_test, andnz_one) +{ + fs_reg dest = v->vgrf(glsl_type::int_type); + fs_reg src0 = v->vgrf(glsl_type::float_type); + fs_reg zero(0.0f); + fs_reg one(1); + + v->emit(BRW_OPCODE_CMP, retype(dest, BRW_REGISTER_TYPE_F), src0, zero) + ->conditional_mod = BRW_CONDITIONAL_L; + v->emit(BRW_OPCODE_AND, v->reg_null_f, dest, one) + ->conditional_mod = BRW_CONDITIONAL_NZ; + + /* = Before = + * 0: cmp.l.f0(8) dest:F src0:F 0F + * 1: and.nz.f0(8) null:D dest:D 1D + * + * = After = + * 0: cmp.l.f0(8) dest:F src0:F 0F + */ + + v->calculate_cfg(); + bblock_t *block0 = v->cfg->blocks[0]; + + EXPECT_EQ(0, block0->start_ip); + EXPECT_EQ(1, block0->end_ip); + + EXPECT_TRUE(cmod_propagation(v)); + EXPECT_EQ(0, block0->start_ip); + EXPECT_EQ(0, block0->end_ip); + EXPECT_EQ(BRW_OPCODE_CMP, instruction(block0, 0)->opcode); + EXPECT_EQ(BRW_CONDITIONAL_L, instruction(block0, 0)->conditional_mod); + EXPECT_TRUE(retype(dest, BRW_REGISTER_TYPE_F) + .equals(instruction(block0, 0)->dst)); +} + +TEST_F(cmod_propagation_test, andnz_non_one) +{ + fs_reg dest = v->vgrf(glsl_type::int_type); + fs_reg src0 = v->vgrf(glsl_type::float_type); + fs_reg zero(0.0f); + fs_reg nonone(38); + + v->emit(BRW_OPCODE_CMP, retype(dest, BRW_REGISTER_TYPE_F), src0, zero) + ->conditional_mod = BRW_CONDITIONAL_L; + v->emit(BRW_OPCODE_AND, v->reg_null_f, dest, nonone) + ->conditional_mod = BRW_CONDITIONAL_NZ; + + /* = Before = + * 0: cmp.l.f0(8) dest:F src0:F 0F + * 1: and.nz.f0(8) null:D dest:D 38D + * + * = After = + * (no changes) + */ + + v->calculate_cfg(); + bblock_t *block0 = v->cfg->blocks[0]; + + EXPECT_EQ(0, block0->start_ip); + EXPECT_EQ(1, block0->end_ip); + + EXPECT_FALSE(cmod_propagation(v)); + EXPECT_EQ(0, block0->start_ip); + EXPECT_EQ(1, block0->end_ip); + EXPECT_EQ(BRW_OPCODE_CMP, instruction(block0, 0)->opcode); + EXPECT_EQ(BRW_CONDITIONAL_L, instruction(block0, 0)->conditional_mod); + EXPECT_EQ(BRW_OPCODE_AND, instruction(block0, 1)->opcode); + EXPECT_EQ(BRW_CONDITIONAL_NZ, instruction(block0, 1)->conditional_mod); +} + +TEST_F(cmod_propagation_test, andz_one) +{ + fs_reg dest = v->vgrf(glsl_type::int_type); + fs_reg src0 = v->vgrf(glsl_type::float_type); + fs_reg zero(0.0f); + fs_reg one(1); + + v->emit(BRW_OPCODE_CMP, retype(dest, BRW_REGISTER_TYPE_F), src0, zero) + ->conditional_mod = BRW_CONDITIONAL_L; + v->emit(BRW_OPCODE_AND, v->reg_null_f, dest, one) + ->conditional_mod = BRW_CONDITIONAL_Z; + + /* = Before = + * 0: cmp.l.f0(8) dest:F src0:F 0F + * 1: and.z.f0(8) null:D dest:D 1D + * + * = After = + * (no changes) + */ + + v->calculate_cfg(); + bblock_t *block0 = v->cfg->blocks[0]; + + EXPECT_EQ(0, block0->start_ip); + EXPECT_EQ(1, block0->end_ip); + + EXPECT_FALSE(cmod_propagation(v)); + EXPECT_EQ(0, block0->start_ip); + EXPECT_EQ(1, block0->end_ip); + EXPECT_EQ(BRW_OPCODE_CMP, instruction(block0, 0)->opcode); + EXPECT_EQ(BRW_CONDITIONAL_L, instruction(block0, 0)->conditional_mod); + EXPECT_EQ(BRW_OPCODE_AND, instruction(block0, 1)->opcode); + EXPECT_EQ(BRW_CONDITIONAL_EQ, instruction(block0, 1)->conditional_mod); +} From idr at kemper.freedesktop.org Tue Mar 17 22:04:19 2015 From: idr at kemper.freedesktop.org (Ian Romanick) Date: Tue, 17 Mar 2015 15:04:19 -0700 (PDT) Subject: Mesa (master): i965/fs: Apply gl_FrontFacing ? -1 : 1 optimization only for floats Message-ID: <20150317220419.534D176359@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 6db5e134b627d24e3d6d42a6835e6595652c5aab URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=6db5e134b627d24e3d6d42a6835e6595652c5aab Author: Ian Romanick Date: Sat Feb 28 08:32:57 2015 -0800 i965/fs: Apply gl_FrontFacing ? -1 : 1 optimization only for floats At the very least, unreal4/sun-temple/102.shader_test uses this pattern for a signed integer result. However, that shader did not hit the optimization in the first place because it uses !gl_FrontFacing. I changed the shader to use remove the logical-not and reverse the other operands. I verified that incorrect code is generated before this change and correct code is generated after. Fixes fs-frontfacing-ternary-1-neg-1.shader_test. No shader-db changes. Signed-off-by: Ian Romanick Reviewed-by: Matt Turner --- src/mesa/drivers/dri/i965/brw_fs_visitor.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp index 91dd212..6d56115 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp @@ -2735,6 +2735,9 @@ fs_visitor::try_opt_frontfacing_ternary(ir_if *ir) if (!then_rhs || !else_rhs) return false; + if (then_rhs->type->base_type != GLSL_TYPE_FLOAT) + return false; + if ((then_rhs->is_one() && else_rhs->is_negative_one()) || (else_rhs->is_one() && then_rhs->is_negative_one())) { then_assign->lhs->accept(this); From idr at kemper.freedesktop.org Tue Mar 17 22:04:19 2015 From: idr at kemper.freedesktop.org (Ian Romanick) Date: Tue, 17 Mar 2015 15:04:19 -0700 (PDT) Subject: Mesa (master): i965/fs: Change try_opt_frontfacing_ternary to eliminate asserts Message-ID: <20150317220419.43A6F761EF@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 4a53445b0d199489b2d1ae7d8654791e42b16804 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=4a53445b0d199489b2d1ae7d8654791e42b16804 Author: Ian Romanick Date: Sat Feb 28 08:26:37 2015 -0800 i965/fs: Change try_opt_frontfacing_ternary to eliminate asserts If we check for the case that is actually necessary, the asserts become superfluous. Signed-off-by: Ian Romanick Reviewed-by: Matt Turner --- src/mesa/drivers/dri/i965/brw_fs_visitor.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp index 5d4b166..91dd212 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp @@ -2735,11 +2735,8 @@ fs_visitor::try_opt_frontfacing_ternary(ir_if *ir) if (!then_rhs || !else_rhs) return false; - if ((then_rhs->is_one() || then_rhs->is_negative_one()) && - (else_rhs->is_one() || else_rhs->is_negative_one())) { - assert(then_rhs->is_one() == else_rhs->is_negative_one()); - assert(else_rhs->is_one() == then_rhs->is_negative_one()); - + if ((then_rhs->is_one() && else_rhs->is_negative_one()) || + (else_rhs->is_one() && then_rhs->is_negative_one())) { then_assign->lhs->accept(this); fs_reg dst = this->result; dst.type = BRW_REGISTER_TYPE_D; From airlied at kemper.freedesktop.org Tue Mar 17 22:59:31 2015 From: airlied at kemper.freedesktop.org (Dave Airlie) Date: Tue, 17 Mar 2015 15:59:31 -0700 (PDT) Subject: Mesa (virgl-mesa-driver): vtest: add sending command line support Message-ID: <20150317225931.68BDB76338@kemper.freedesktop.org> Module: Mesa Branch: virgl-mesa-driver Commit: 2c45846128d497d031f8a983e65c70d93f8462e1 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=2c45846128d497d031f8a983e65c70d93f8462e1 Author: Dave Airlie Date: Wed Mar 18 08:56:56 2015 +1000 vtest: add sending command line support this adds an explicit rendering init command that passes the cmdline to the remote for debugging help it also tries to strip off shader_runner and get the test name. --- .../winsys/virgl/vtest/virgl_vtest_socket.c | 29 ++++++++++++++++++++ src/gallium/winsys/virgl/vtest/vtest_protocol.h | 2 ++ 2 files changed, 31 insertions(+) diff --git a/src/gallium/winsys/virgl/vtest/virgl_vtest_socket.c b/src/gallium/winsys/virgl/vtest/virgl_vtest_socket.c index 715b53d..b8987fe 100644 --- a/src/gallium/winsys/virgl/vtest/virgl_vtest_socket.c +++ b/src/gallium/winsys/virgl/vtest/virgl_vtest_socket.c @@ -9,6 +9,7 @@ #include #include +#include #include /* connect to remote socket */ #define VTEST_SOCKET_NAME "/tmp/.virgl_test" @@ -49,6 +50,33 @@ static int virgl_block_read(int fd, void *buf, int size) return size; } +static int virgl_vtest_send_init(struct virgl_vtest_winsys *vws) +{ + uint32_t buf[VTEST_HDR_SIZE]; + const char *nstr = "virtest"; + char cmdline[64]; + int ret; + + ret = os_get_process_name(cmdline, 63); + if (ret == FALSE) + strcpy(cmdline, nstr); +#if defined(__GLIBC__) || defined(__CYGWIN__) + if (!strcmp(cmdline, "shader_runner")) { + const char *name; + /* hack to get better testname */ + name = program_invocation_short_name; + name += strlen(name) + 1; + strncpy(cmdline, name, 63); + } +#endif + buf[VTEST_CMD_LEN] = strlen(cmdline) + 1; + buf[VTEST_CMD_ID] = VCMD_CREATE_RENDERER; + + virgl_block_write(vws->sock_fd, &buf, sizeof(buf)); + virgl_block_write(vws->sock_fd, (void *)cmdline, strlen(cmdline) + 1); + return 0; +} + int virgl_vtest_connect(struct virgl_vtest_winsys *vws) { struct sockaddr_un un; @@ -70,6 +98,7 @@ int virgl_vtest_connect(struct virgl_vtest_winsys *vws) } while (ret == -EINTR); vws->sock_fd = sock; + virgl_vtest_send_init(vws); return 0; } diff --git a/src/gallium/winsys/virgl/vtest/vtest_protocol.h b/src/gallium/winsys/virgl/vtest/vtest_protocol.h index c465339..aedc27d 100644 --- a/src/gallium/winsys/virgl/vtest/vtest_protocol.h +++ b/src/gallium/winsys/virgl/vtest/vtest_protocol.h @@ -24,6 +24,8 @@ #define VCMD_RESOURCE_BUSY_WAIT 7 +/* pass the process cmd line for debugging */ +#define VCMD_CREATE_RENDERER 8 /* get caps */ /* 0 length cmd */ /* resp VCMD_GET_CAPS + caps */ From evelikov at kemper.freedesktop.org Tue Mar 17 23:55:17 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Tue, 17 Mar 2015 16:55:17 -0700 (PDT) Subject: Mesa (master): r600g: constify r600_shader_tgsi_instruction lists. Message-ID: <20150317235517.7618676359@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 3f94a5afcbab5ebcc4229cb3c65140ad5b5dafca URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=3f94a5afcbab5ebcc4229cb3c65140ad5b5dafca Author: Emil Velikov Date: Mon Mar 16 14:47:09 2015 +0000 r600g: constify r600_shader_tgsi_instruction lists. Massive list of constant data. Annotate it as such. Signed-off-by: Emil Velikov Reviewed-by: Marek Ol??k --- src/gallium/drivers/r600/r600_shader.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/gallium/drivers/r600/r600_shader.c b/src/gallium/drivers/r600/r600_shader.c index acac89f..28b290a 100644 --- a/src/gallium/drivers/r600/r600_shader.c +++ b/src/gallium/drivers/r600/r600_shader.c @@ -283,7 +283,7 @@ struct r600_shader_ctx { unsigned type; unsigned file_offset[TGSI_FILE_COUNT]; unsigned temp_reg; - struct r600_shader_tgsi_instruction *inst_info; + const struct r600_shader_tgsi_instruction *inst_info; struct r600_bytecode *bc; struct r600_shader *shader; struct r600_shader_src src[4]; @@ -316,7 +316,7 @@ struct r600_shader_tgsi_instruction { }; static int emit_gs_ring_writes(struct r600_shader_ctx *ctx, bool ind); -static struct r600_shader_tgsi_instruction r600_shader_tgsi_instruction[], eg_shader_tgsi_instruction[], cm_shader_tgsi_instruction[]; +static const struct r600_shader_tgsi_instruction r600_shader_tgsi_instruction[], eg_shader_tgsi_instruction[], cm_shader_tgsi_instruction[]; static int tgsi_helper_tempx_replicate(struct r600_shader_ctx *ctx); static inline void callstack_push(struct r600_shader_ctx *ctx, unsigned reason); static void fc_pushlevel(struct r600_shader_ctx *ctx, int type); @@ -7270,7 +7270,7 @@ static int tgsi_umad(struct r600_shader_ctx *ctx) return 0; } -static struct r600_shader_tgsi_instruction r600_shader_tgsi_instruction[] = { +static const struct r600_shader_tgsi_instruction r600_shader_tgsi_instruction[] = { [TGSI_OPCODE_ARL] = { ALU_OP0_NOP, tgsi_r600_arl}, [TGSI_OPCODE_MOV] = { ALU_OP1_MOV, tgsi_op2}, [TGSI_OPCODE_LIT] = { ALU_OP0_NOP, tgsi_lit}, @@ -7475,7 +7475,7 @@ static struct r600_shader_tgsi_instruction r600_shader_tgsi_instruction[] = { [TGSI_OPCODE_LAST] = { ALU_OP0_NOP, tgsi_unsupported}, }; -static struct r600_shader_tgsi_instruction eg_shader_tgsi_instruction[] = { +static const struct r600_shader_tgsi_instruction eg_shader_tgsi_instruction[] = { [TGSI_OPCODE_ARL] = { ALU_OP0_NOP, tgsi_eg_arl}, [TGSI_OPCODE_MOV] = { ALU_OP1_MOV, tgsi_op2}, [TGSI_OPCODE_LIT] = { ALU_OP0_NOP, tgsi_lit}, @@ -7674,7 +7674,7 @@ static struct r600_shader_tgsi_instruction eg_shader_tgsi_instruction[] = { [TGSI_OPCODE_LAST] = { ALU_OP0_NOP, tgsi_unsupported}, }; -static struct r600_shader_tgsi_instruction cm_shader_tgsi_instruction[] = { +static const struct r600_shader_tgsi_instruction cm_shader_tgsi_instruction[] = { [TGSI_OPCODE_ARL] = { ALU_OP0_NOP, tgsi_eg_arl}, [TGSI_OPCODE_MOV] = { ALU_OP1_MOV, tgsi_op2}, [TGSI_OPCODE_LIT] = { ALU_OP0_NOP, tgsi_lit}, From evelikov at kemper.freedesktop.org Tue Mar 17 23:55:17 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Tue, 17 Mar 2015 16:55:17 -0700 (PDT) Subject: Mesa (master): r600g: use the tgsi opcode from parse.FullToken.FullInstruction Message-ID: <20150317235517.63B9376338@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 5e68c6b32284a5d8d65cf87359f321fc135bdc1c URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=5e68c6b32284a5d8d65cf87359f321fc135bdc1c Author: Emil Velikov Date: Mon Mar 16 14:47:07 2015 +0000 r600g: use the tgsi opcode from parse.FullToken.FullInstruction ... rather than the local one in inst_info->tgsi_opcode. This will allow us to simplify struct r600_shader_tgsi_instruction. Signed-off-by: Emil Velikov Reviewed-by: Marek Ol??k --- src/gallium/drivers/r600/r600_shader.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/gallium/drivers/r600/r600_shader.c b/src/gallium/drivers/r600/r600_shader.c index 54540c3..4e67447 100644 --- a/src/gallium/drivers/r600/r600_shader.c +++ b/src/gallium/drivers/r600/r600_shader.c @@ -2543,8 +2543,10 @@ out_err: static int tgsi_unsupported(struct r600_shader_ctx *ctx) { + const unsigned tgsi_opcode = + ctx->parse.FullToken.FullInstruction.Instruction.Opcode; R600_ERR("%s tgsi opcode unsupported\n", - tgsi_get_opcode_name(ctx->inst_info->tgsi_opcode)); + tgsi_get_opcode_name(tgsi_opcode)); return -EINVAL; } @@ -2639,7 +2641,7 @@ static int tgsi_op2_s(struct r600_shader_ctx *ctx, int swap, int trans_only) r600_bytecode_src(&alu.src[1], &ctx->src[0], i); } /* handle some special cases */ - switch (ctx->inst_info->tgsi_opcode) { + switch (inst->Instruction.Opcode) { case TGSI_OPCODE_SUB: r600_bytecode_src_toggle_neg(&alu.src[1]); break; @@ -2738,7 +2740,7 @@ static int cayman_emit_float_instr(struct r600_shader_ctx *ctx) r600_bytecode_src(&alu.src[j], &ctx->src[j], 0); /* RSQ should take the absolute value of src */ - if (ctx->inst_info->tgsi_opcode == TGSI_OPCODE_RSQ) { + if (inst->Instruction.Opcode == TGSI_OPCODE_RSQ) { r600_bytecode_src_set_abs(&alu.src[j]); } } @@ -3079,6 +3081,7 @@ static int tgsi_scs(struct r600_shader_ctx *ctx) static int tgsi_kill(struct r600_shader_ctx *ctx) { + const struct tgsi_full_instruction *inst = &ctx->parse.FullToken.FullInstruction; struct r600_bytecode_alu alu; int i, r; @@ -3090,7 +3093,7 @@ static int tgsi_kill(struct r600_shader_ctx *ctx) alu.src[0].sel = V_SQ_ALU_SRC_0; - if (ctx->inst_info->tgsi_opcode == TGSI_OPCODE_KILL) { + if (inst->Instruction.Opcode == TGSI_OPCODE_KILL) { alu.src[1].sel = V_SQ_ALU_SRC_1; alu.src[1].neg = 1; } else { @@ -4945,7 +4948,7 @@ static int tgsi_dp(struct r600_shader_ctx *ctx) alu.dst.chan = i; alu.dst.write = (inst->Dst[0].Register.WriteMask >> i) & 1; /* handle some special cases */ - switch (ctx->inst_info->tgsi_opcode) { + switch (inst->Instruction.Opcode) { case TGSI_OPCODE_DP2: if (i > 1) { alu.src[0].sel = alu.src[1].sel = V_SQ_ALU_SRC_0; From evelikov at kemper.freedesktop.org Tue Mar 17 23:55:17 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Tue, 17 Mar 2015 16:55:17 -0700 (PDT) Subject: Mesa (master): glx: Handle out-of-sequence swap completion events correctly. (v2) Message-ID: <20150317235517.7DD157635A@kemper.freedesktop.org> Module: Mesa Branch: master Commit: cc5ddd584d17abd422ae4d8e83805969485740d9 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=cc5ddd584d17abd422ae4d8e83805969485740d9 Author: Mario Kleiner Date: Thu Mar 12 20:34:06 2015 +0100 glx: Handle out-of-sequence swap completion events correctly. (v2) The code for emitting INTEL_swap_events swap completion events needs to translate from 32-Bit sbc on the wire to 64-Bit sbc for the events and handle wraparound accordingly. It assumed that events would be sent by the server in the order their corresponding swap requests were emitted from the client, iow. sbc count should be always increasing. This was correct for DRI2. This is not always the case under the DRI3/Present backend, where the Present extension can execute presents and send out completion events in a different order than the submission order of the present requests, due to client code specifying targetMSC target vblank counts which are not strictly monotonically increasing. This confused the wraparound handling. This patch fixes the problem by handling 32-Bit wraparound in both directions. As long as successive swap completion events real 64-Bit sbc's don't differ by more than 2^30, this should be able to do the right thing. How this is supposed to work: awire->sbc contains the low 32-Bits of the true 64-Bit sbc of the current swap event, transmitted over the wire. glxDraw->lastEventSbc contains the low 32-Bits of the 64-Bit sbc of the most recently processed swap event. glxDraw->eventSbcWrap is a 64-Bit offset which tracks the upper 32-Bits of the current sbc. The final 64-Bit output sbc aevent->sbc is computed from the sum of awire->sbc and glxDraw->eventSbcWrap. Under DRI3/Present, swap completion events can be received slightly out of order due to non-monotic targetMsc specified by client code, e.g., present request submission: Submission sbc: 1 2 3 targetMsc: 10 11 9 Reception of completion events: Completion sbc: 3 1 2 The completion sequence 3, 1, 2 would confuse the old wraparound handling made for DRI2 as 1 < 3 --> Assumes a 32-Bit wraparound has happened when it hasn't. The client can queue multiple present requests, in the case of Mesa up to n requests for n-buffered rendering, e.g., n = 2-4 in the current Mesa GLX DRI3/Present implementation. In the case of direct Pixmap presents via xcb_present_pixmap() the number n is limited by the amount of memory available. We reasonably assume that the number of outstanding requests n is much less than 2 billion due to memory contraints and common sense. Therefore while the order of received sbc's can be a bit scrambled, successive 64-Bit sbc's won't deviate by much, a given sbc may be a few counts lower or higher than the previous received sbc. Therefore any large difference between the incoming awire->sbc and the last recorded glxDraw->lastEventSbc will be due to 32-Bit wraparound and we need to adapt glxDraw->eventSbcWrap accordingly to adjust the upper 32-Bits of the sbc. Two cases, correponding to the two if-statements in the patch: a) Previous sbc event was below the last 2^32 boundary, in the previous glxDraw->eventSbcWrap epoch, the new sbc event is in the next 2^32 epoch, therefore the low 32-Bit awire->sbc wrapped around to zero, or close to zero --> awire->sbc is apparently much lower than the glxDraw->lastEventSbc recorded for the previous epoch --> We need to increment glxDraw->eventSbcWrap by 2^32 to adjust the current epoch to be one higher than the previous one. --> Case a) also handles the old DRI2 behaviour. b) Previous sbc event was above closest 2^32 boundary, but now a late event from the previous 2^32 epoch arrives, with a true sbc that belongs to the previous 2^32 segment, so the awire->sbc of this late event has a high count close to 2^32, whereas glxDraw->lastEventSbc is closer to zero --> awire->sbc is much greater than glXDraw->lastEventSbc. --> We need to decrement glxDraw->eventSbcWrap by 2^32 to adjust the current epoch back to the previous lower epoch of this late completion event. We assume such a wraparound to a higher (a) epoch or lower (b) epoch has happened if awire->sbc and glxDraw->lastEventSbc differ by more than 2^30 counts, as such a difference can only happen on wraparound, or if somehow 2^30 present requests would be pending for a given drawable inside the server, which is rather unlikely. v2: Explain the reason for this patch and the new wraparound handling much more extensive in commit message, no code change wrt. initial version. Cc: "10.3 10.4 10.5" Signed-off-by: Mario Kleiner Reviewed-by: Michel D?nzer --- src/glx/glxext.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/glx/glxext.c b/src/glx/glxext.c index 68c359e..fdc24d4 100644 --- a/src/glx/glxext.c +++ b/src/glx/glxext.c @@ -143,8 +143,13 @@ __glXWireToEvent(Display *dpy, XEvent *event, xEvent *wire) aevent->ust = ((CARD64)awire->ust_hi << 32) | awire->ust_lo; aevent->msc = ((CARD64)awire->msc_hi << 32) | awire->msc_lo; - if (awire->sbc < glxDraw->lastEventSbc) - glxDraw->eventSbcWrap += 0x100000000; + /* Handle 32-Bit wire sbc wraparound in both directions to cope with out + * of sequence 64-Bit sbc's + */ + if ((int64_t) awire->sbc < ((int64_t) glxDraw->lastEventSbc - 0x40000000)) + glxDraw->eventSbcWrap += 0x100000000; + if ((int64_t) awire->sbc > ((int64_t) glxDraw->lastEventSbc + 0x40000000)) + glxDraw->eventSbcWrap -= 0x100000000; glxDraw->lastEventSbc = awire->sbc; aevent->sbc = awire->sbc + glxDraw->eventSbcWrap; return True; From evelikov at kemper.freedesktop.org Tue Mar 17 23:55:17 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Tue, 17 Mar 2015 16:55:17 -0700 (PDT) Subject: Mesa (master): r600g: kill off r600_shader_tgsi_instruction::{tgsi_opcode, is_op3} Message-ID: <20150317235517.6C8927633A@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 63cf2b4448f96c8b69c11dac14d8c55742dc6918 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=63cf2b4448f96c8b69c11dac14d8c55742dc6918 Author: Emil Velikov Date: Mon Mar 16 14:47:08 2015 +0000 r600g: kill off r600_shader_tgsi_instruction::{tgsi_opcode,is_op3} Both of which are no longer used. Use designated initializer to make things obvious as people add/remove TGSI_OPCODEs. Signed-off-by: Emil Velikov Reviewed-by: Marek Ol??k --- src/gallium/drivers/r600/r600_shader.c | 1180 ++++++++++++++++---------------- 1 file changed, 589 insertions(+), 591 deletions(-) Diff: http://cgit.freedesktop.org/mesa/mesa/diff/?id=63cf2b4448f96c8b69c11dac14d8c55742dc6918 From jekstrand at kemper.freedesktop.org Wed Mar 18 00:15:21 2015 From: jekstrand at kemper.freedesktop.org (Jason Ekstrand) Date: Tue, 17 Mar 2015 17:15:21 -0700 (PDT) Subject: Mesa (master): nir/peephole_select: Rename are_all_move_to_phi and use a switch Message-ID: <20150318001521.3ABD076338@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 8cf40ed05dbd3a62ee817e7ebc9409cf327c10ce URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=8cf40ed05dbd3a62ee817e7ebc9409cf327c10ce Author: Jason Ekstrand Date: Mon Mar 16 14:45:54 2015 -0700 nir/peephole_select: Rename are_all_move_to_phi and use a switch Reviewed-by: Connor Abbott --- src/glsl/nir/nir_opt_peephole_select.c | 56 ++++++++++++++++++-------------- 1 file changed, 31 insertions(+), 25 deletions(-) diff --git a/src/glsl/nir/nir_opt_peephole_select.c b/src/glsl/nir/nir_opt_peephole_select.c index ab08f28..8371350 100644 --- a/src/glsl/nir/nir_opt_peephole_select.c +++ b/src/glsl/nir/nir_opt_peephole_select.c @@ -52,36 +52,41 @@ struct peephole_select_state { }; static bool -are_all_move_to_phi(nir_block *block) +block_check_for_allowed_instrs(nir_block *block) { nir_foreach_instr(block, instr) { - if (instr->type != nir_instr_type_alu) - return false; + switch (instr->type) { + case nir_instr_type_alu: { + /* It must be a move operation */ + nir_alu_instr *mov = nir_instr_as_alu(instr); + if (mov->op != nir_op_fmov && mov->op != nir_op_imov) + return false; - /* It must be a move operation */ - nir_alu_instr *mov = nir_instr_as_alu(instr); - if (mov->op != nir_op_fmov && mov->op != nir_op_imov) - return false; + /* Can't handle saturate */ + if (mov->dest.saturate) + return false; - /* Can't handle saturate */ - if (mov->dest.saturate) - return false; + /* It must be SSA */ + if (!mov->dest.dest.is_ssa) + return false; - /* It must be SSA */ - if (!mov->dest.dest.is_ssa) - return false; + /* It cannot have any if-uses */ + if (mov->dest.dest.ssa.if_uses->entries != 0) + return false; - /* It cannot have any if-uses */ - if (mov->dest.dest.ssa.if_uses->entries != 0) - return false; + /* The only uses of this definition must be phi's in the successor */ + struct set_entry *entry; + set_foreach(mov->dest.dest.ssa.uses, entry) { + const nir_instr *dest_instr = entry->key; + if (dest_instr->type != nir_instr_type_phi || + dest_instr->block != block->successors[0]) + return false; + } + break; + } - /* The only uses of this definition must be phi's in the successor */ - struct set_entry *entry; - set_foreach(mov->dest.dest.ssa.uses, entry) { - const nir_instr *dest_instr = entry->key; - if (dest_instr->type != nir_instr_type_phi || - dest_instr->block != block->successors[0]) - return false; + default: + return false; } } @@ -119,8 +124,9 @@ nir_opt_peephole_select_block(nir_block *block, void *void_state) nir_block *then_block = nir_cf_node_as_block(then_node); nir_block *else_block = nir_cf_node_as_block(else_node); - /* ... and those blocks must only contain move-to-phi. */ - if (!are_all_move_to_phi(then_block) || !are_all_move_to_phi(else_block)) + /* ... and those blocks must only contain "allowed" instructions. */ + if (!block_check_for_allowed_instrs(then_block) || + !block_check_for_allowed_instrs(else_block)) return true; /* At this point, we know that the previous CFG node is an if-then From jekstrand at kemper.freedesktop.org Wed Mar 18 00:15:21 2015 From: jekstrand at kemper.freedesktop.org (Jason Ekstrand) Date: Tue, 17 Mar 2015 17:15:21 -0700 (PDT) Subject: Mesa (master): nir/peephole_select: Copy instructions into the block before the if Message-ID: <20150318001521.4197B7633A@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 1be862c0c4965a0184908df736a30d354498ba3d URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=1be862c0c4965a0184908df736a30d354498ba3d Author: Jason Ekstrand Date: Mon Mar 16 14:55:00 2015 -0700 nir/peephole_select: Copy instructions into the block before the if Previously we tried to do poor-man's copy propagation as we created the select instructions. Instead, this commit just moves the instructions from the blocks inside the if into the block before. Copy propagation will take care of making sure we don't have any extra mov's in there for us. Reviewed-by: Connor Abbott --- src/glsl/nir/nir_opt_peephole_select.c | 33 +++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/src/glsl/nir/nir_opt_peephole_select.c b/src/glsl/nir/nir_opt_peephole_select.c index 8371350..c9512bd 100644 --- a/src/glsl/nir/nir_opt_peephole_select.c +++ b/src/glsl/nir/nir_opt_peephole_select.c @@ -135,6 +135,25 @@ nir_opt_peephole_select_block(nir_block *block, void *void_state) * selects. */ + nir_block *prev_block = nir_cf_node_as_block(nir_cf_node_prev(prev_node)); + assert(prev_block->cf_node.type == nir_cf_node_block); + + /* First, we move the remaining instructions from the blocks to the + * block before. We have already guaranteed that this is safe by + * calling block_check_for_allowed_instrs() + */ + nir_foreach_instr_safe(then_block, instr) { + exec_node_remove(&instr->node); + instr->block = prev_block; + exec_list_push_tail(&prev_block->instr_list, &instr->node); + } + + nir_foreach_instr_safe(else_block, instr) { + exec_node_remove(&instr->node); + instr->block = prev_block; + exec_list_push_tail(&prev_block->instr_list, &instr->node); + } + nir_foreach_instr_safe(block, instr) { if (instr->type != nir_instr_type_phi) break; @@ -151,19 +170,7 @@ nir_opt_peephole_select_block(nir_block *block, void *void_state) assert(src->src.is_ssa); unsigned idx = src->pred == then_block ? 1 : 2; - - if (src->src.ssa->parent_instr->block == src->pred) { - /* We already know that this instruction must be a move with - * this phi's in this block as its only users. - */ - nir_alu_instr *mov = nir_instr_as_alu(src->src.ssa->parent_instr); - assert(mov->instr.type == nir_instr_type_alu); - assert(mov->op == nir_op_fmov || mov->op == nir_op_imov); - - nir_alu_src_copy(&sel->src[idx], &mov->src[0], state->mem_ctx); - } else { - nir_src_copy(&sel->src[idx].src, &src->src, state->mem_ctx); - } + nir_src_copy(&sel->src[idx].src, &src->src, state->mem_ctx); } nir_ssa_dest_init(&sel->instr, &sel->dest.dest, From jekstrand at kemper.freedesktop.org Wed Mar 18 00:15:21 2015 From: jekstrand at kemper.freedesktop.org (Jason Ekstrand) Date: Tue, 17 Mar 2015 17:15:21 -0700 (PDT) Subject: Mesa (master): nir/peephole_select: Allow uniform/ input loads and load_const Message-ID: <20150318001521.4A06F76359@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 27bf37ba05b69ebf6f373d1637a26b4839265921 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=27bf37ba05b69ebf6f373d1637a26b4839265921 Author: Jason Ekstrand Date: Mon Mar 16 15:08:04 2015 -0700 nir/peephole_select: Allow uniform/input loads and load_const Shader-db results on HSW: total instructions in shared programs: 4174156 -> 4157291 (-0.40%) instructions in affected programs: 145397 -> 128532 (-11.60%) helped: 383 HURT: 0 GAINED: 20 LOST: 22 There are two more tests lost than gained. However, comparing this with GLSL IR vs. NIR results, the overall delta is reduced from 85/44 gained/lost on current master to 71/32 with this commit. Therefore, I think it's probably a boon since we are getting "closer" to where we were before. Reviewed-by: Connor Abbott --- src/glsl/nir/nir_opt_peephole_select.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/glsl/nir/nir_opt_peephole_select.c b/src/glsl/nir/nir_opt_peephole_select.c index c9512bd..b89451b 100644 --- a/src/glsl/nir/nir_opt_peephole_select.c +++ b/src/glsl/nir/nir_opt_peephole_select.c @@ -56,6 +56,31 @@ block_check_for_allowed_instrs(nir_block *block) { nir_foreach_instr(block, instr) { switch (instr->type) { + case nir_instr_type_intrinsic: { + nir_intrinsic_instr *intrin = nir_instr_as_intrinsic(instr); + + switch (intrin->intrinsic) { + case nir_intrinsic_load_var: + switch (intrin->variables[0]->var->data.mode) { + case nir_var_shader_in: + case nir_var_uniform: + break; + + default: + return false; + } + break; + + default: + return false; + } + + break; + } + + case nir_instr_type_load_const: + break; + case nir_instr_type_alu: { /* It must be a move operation */ nir_alu_instr *mov = nir_instr_as_alu(instr); From ickle at kemper.freedesktop.org Wed Mar 18 09:37:44 2015 From: ickle at kemper.freedesktop.org (Chris Wilson) Date: Wed, 18 Mar 2015 02:37:44 -0700 (PDT) Subject: Mesa (master): i965: Throttle rendering to an fbo Message-ID: <20150318093744.38A1176338@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 8b9bd19021c0efef33d66ae24f8871b826d66e8a URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=8b9bd19021c0efef33d66ae24f8871b826d66e8a Author: Chris Wilson Date: Thu Feb 26 11:25:18 2015 +0000 i965: Throttle rendering to an fbo When rendering to an fbo, even though it may be acting as a winsys frontbuffer or just generally, we never throttle. However, when rendering to an fbo, there is no natural frame boundary. Conventionally we use SwapBuffers and glFinish, but potential callers avoid often glFinish for being too heavy handed (waiting on all outstanding rendering to complete). The kernel provides a soft-throttling option for this case that waits for rendering older than 20ms to be complete (that's a little too lax to be used for swapbuffers, but is here a useful safety net). The remaining choice is then either never to throttle, throttle after every draw call, or at after intermediate user defined point such as glFlush and thus all the implied flushes. This patch opts for the latter as that is the current method used for flushing to front buffers. v2: Defer the throttling from inside the flush to the next intel_prepare_render() and switch non-fbo frontbuffer throttling over to use the same lax method. The issuing being that glFlush()/intel_prepare_read() is just as likely to be called inside a tight loop and not at "frame" boundaries. v3: Rename from need_front_throttle to need_flush_throttle to avoid any ambiguity between front buffer rendering and fbo rendering. (Chad) v4: Whitespace Signed-off-by: Chris Wilson Cc: Daniel Vetter Cc: Kenneth Graunke Cc: Ben Widawsky Cc: Kristian H?gsberg Cc: Chad Versace Cc: Ian Romanick Reviewed-by: Chad Versace --- src/mesa/drivers/dri/i965/brw_context.c | 16 ++++++++++++---- src/mesa/drivers/dri/i965/brw_context.h | 14 +++++++++++++- src/mesa/drivers/dri/i965/intel_screen.c | 8 ++++---- 3 files changed, 29 insertions(+), 9 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c index 0881e48..5120372 100644 --- a/src/mesa/drivers/dri/i965/brw_context.c +++ b/src/mesa/drivers/dri/i965/brw_context.c @@ -234,8 +234,8 @@ intel_glFlush(struct gl_context *ctx) intel_batchbuffer_flush(brw); intel_flush_front(ctx); - if (brw_is_front_buffer_drawing(ctx->DrawBuffer)) - brw->need_throttle = true; + + brw->need_flush_throttle = true; } static void @@ -1245,12 +1245,20 @@ intel_prepare_render(struct brw_context *brw) * the swap, and getting our hands on that doesn't seem worth it, * so we just us the first batch we emitted after the last swap. */ - if (brw->need_throttle && brw->first_post_swapbuffers_batch) { + if (brw->need_swap_throttle && brw->first_post_swapbuffers_batch) { if (!brw->disable_throttling) drm_intel_bo_wait_rendering(brw->first_post_swapbuffers_batch); drm_intel_bo_unreference(brw->first_post_swapbuffers_batch); brw->first_post_swapbuffers_batch = NULL; - brw->need_throttle = false; + brw->need_swap_throttle = false; + /* Throttling here is more precise than the throttle ioctl, so skip it */ + brw->need_flush_throttle = false; + } + + if (brw->need_flush_throttle) { + __DRIscreen *psp = brw->intelScreen->driScrnPriv; + drmCommandNone(psp->fd, DRM_I915_GEM_THROTTLE); + brw->need_flush_throttle = false; } } diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h index 682fbe9..eebd7ce 100644 --- a/src/mesa/drivers/dri/i965/brw_context.h +++ b/src/mesa/drivers/dri/i965/brw_context.h @@ -1031,7 +1031,19 @@ struct brw_context /** Framerate throttling: @{ */ drm_intel_bo *first_post_swapbuffers_batch; - bool need_throttle; + + /* Limit the number of outstanding SwapBuffers by waiting for an earlier + * frame of rendering to complete. This gives a very precise cap to the + * latency between input and output such that rendering never gets more + * than a frame behind the user. (With the caveat that we technically are + * not using the SwapBuffers itself as a barrier but the first batch + * submitted afterwards, which may be immediately prior to the next + * SwapBuffers.) + */ + bool need_swap_throttle; + + /** General throttling, not caught by throttling between SwapBuffers */ + bool need_flush_throttle; /** @} */ GLuint stats_wm; diff --git a/src/mesa/drivers/dri/i965/intel_screen.c b/src/mesa/drivers/dri/i965/intel_screen.c index cea7ddf..3640b67 100644 --- a/src/mesa/drivers/dri/i965/intel_screen.c +++ b/src/mesa/drivers/dri/i965/intel_screen.c @@ -174,10 +174,10 @@ intel_dri2_flush_with_flags(__DRIcontext *cPriv, if (flags & __DRI2_FLUSH_DRAWABLE) intel_resolve_for_dri2_flush(brw, dPriv); - if (reason == __DRI2_THROTTLE_SWAPBUFFER || - reason == __DRI2_THROTTLE_FLUSHFRONT) { - brw->need_throttle = true; - } + if (reason == __DRI2_THROTTLE_SWAPBUFFER) + brw->need_swap_throttle = true; + if (reason == __DRI2_THROTTLE_FLUSHFRONT) + brw->need_flush_throttle = true; intel_batchbuffer_flush(brw); From ickle at kemper.freedesktop.org Wed Mar 18 09:37:44 2015 From: ickle at kemper.freedesktop.org (Chris Wilson) Date: Wed, 18 Mar 2015 02:37:44 -0700 (PDT) Subject: Mesa (master): i965: Throttle to the previous frame Message-ID: <20150318093744.4216A7633A@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 64788b2e8dc2ddedc2712ed02b7e9096638b7bae URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=64788b2e8dc2ddedc2712ed02b7e9096638b7bae Author: Chris Wilson Date: Fri Sep 19 10:10:13 2014 +0100 i965: Throttle to the previous frame In order to facilitate the concurrency offered by triple buffering and to offset the latency induced by swapping via an external process, which may incur extra rendering itself, only throttle to the previous frame and not the last. The second issue that mostly affects swap benchmarks, but also can incur jitter in the throttling, is that the throttle bo is closer to the next SwapBuffers rather than immediately after the previous SwapBuffers. Throttling to the previous frame doubles the maximum possible latency at the benefit of improving throughput and reducing jitter. v2: Rename "first_post_swapbuffer" batches array to a plain throttle_batch[] as the pluralisation was contorting the name and not making it clear as to whether it was the first batch or first_post_swap batch. Not least of which was that not all throttle points are SwapBuffers. Signed-off-by: Chris Wilson Cc: Daniel Vetter Cc: Kenneth Graunke Cc: Ben Widawsky Cc: Kristian H?gsberg Cc: Chad Versace Cc: Ian Romanick Reviewed-by: Chad Versace --- src/mesa/drivers/dri/i965/brw_context.c | 19 ++++++++++++------- src/mesa/drivers/dri/i965/brw_context.h | 2 +- src/mesa/drivers/dri/i965/intel_batchbuffer.c | 7 ++++--- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c index 5120372..8257fb6 100644 --- a/src/mesa/drivers/dri/i965/brw_context.c +++ b/src/mesa/drivers/dri/i965/brw_context.c @@ -935,8 +935,10 @@ intelDestroyContext(__DRIcontext * driContextPriv) intel_batchbuffer_free(brw); - drm_intel_bo_unreference(brw->first_post_swapbuffers_batch); - brw->first_post_swapbuffers_batch = NULL; + drm_intel_bo_unreference(brw->throttle_batch[1]); + drm_intel_bo_unreference(brw->throttle_batch[0]); + brw->throttle_batch[1] = NULL; + brw->throttle_batch[0] = NULL; driDestroyOptionCache(&brw->optionCache); @@ -1245,11 +1247,14 @@ intel_prepare_render(struct brw_context *brw) * the swap, and getting our hands on that doesn't seem worth it, * so we just us the first batch we emitted after the last swap. */ - if (brw->need_swap_throttle && brw->first_post_swapbuffers_batch) { - if (!brw->disable_throttling) - drm_intel_bo_wait_rendering(brw->first_post_swapbuffers_batch); - drm_intel_bo_unreference(brw->first_post_swapbuffers_batch); - brw->first_post_swapbuffers_batch = NULL; + if (brw->need_swap_throttle && brw->throttle_batch[0]) { + if (brw->throttle_batch[1]) { + if (!brw->disable_throttling) + drm_intel_bo_wait_rendering(brw->throttle_batch[1]); + drm_intel_bo_unreference(brw->throttle_batch[1]); + } + brw->throttle_batch[1] = brw->throttle_batch[0]; + brw->throttle_batch[0] = NULL; brw->need_swap_throttle = false; /* Throttling here is more precise than the throttle ioctl, so skip it */ brw->need_flush_throttle = false; diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h index eebd7ce..8b29e2a 100644 --- a/src/mesa/drivers/dri/i965/brw_context.h +++ b/src/mesa/drivers/dri/i965/brw_context.h @@ -1030,7 +1030,7 @@ struct brw_context bool front_buffer_dirty; /** Framerate throttling: @{ */ - drm_intel_bo *first_post_swapbuffers_batch; + drm_intel_bo *throttle_batch[2]; /* Limit the number of outstanding SwapBuffers by waiting for an earlier * frame of rendering to complete. This gives a very precise cap to the diff --git a/src/mesa/drivers/dri/i965/intel_batchbuffer.c b/src/mesa/drivers/dri/i965/intel_batchbuffer.c index 5ac4d18..87862cd 100644 --- a/src/mesa/drivers/dri/i965/intel_batchbuffer.c +++ b/src/mesa/drivers/dri/i965/intel_batchbuffer.c @@ -168,6 +168,7 @@ static void brw_new_batch(struct brw_context *brw) { /* Create a new batchbuffer and reset the associated state: */ + drm_intel_gem_bo_clear_relocs(brw->batch.bo, 0); intel_batchbuffer_reset(brw); /* If the kernel supports hardware contexts, then most hardware state is @@ -289,9 +290,9 @@ _intel_batchbuffer_flush(struct brw_context *brw, if (brw->batch.used == 0) return 0; - if (brw->first_post_swapbuffers_batch == NULL) { - brw->first_post_swapbuffers_batch = brw->batch.bo; - drm_intel_bo_reference(brw->first_post_swapbuffers_batch); + if (brw->throttle_batch[0] == NULL) { + brw->throttle_batch[0] = brw->batch.bo; + drm_intel_bo_reference(brw->throttle_batch[0]); } if (unlikely(INTEL_DEBUG & DEBUG_BATCH)) { From ickle at kemper.freedesktop.org Wed Mar 18 09:37:44 2015 From: ickle at kemper.freedesktop.org (Chris Wilson) Date: Wed, 18 Mar 2015 02:37:44 -0700 (PDT) Subject: Mesa (master): i965: Defer the throttle until we submit new commands Message-ID: <20150318093744.4B3CA76359@kemper.freedesktop.org> Module: Mesa Branch: master Commit: eeb504e0ae7796e7ba475f6e9d6c26daa6b06608 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=eeb504e0ae7796e7ba475f6e9d6c26daa6b06608 Author: Chris Wilson Date: Wed Mar 11 12:21:29 2015 +0000 i965: Defer the throttle until we submit new commands Currently, we throttle before the user begins preparing commands for the next frame when we acquire the draw/read buffers. However, construction of the command buffer can itself take significant time relative to the frame time. If we move the throttle from the buffer acquire to the command submit phase we can allow the user to improve concurrency between the CPU and GPU (i.e. reduce the amount of time we waste inside the throttle). v2: Whitespace + delay throttling until after the next submission for greater parallelism Signed-off-by: Chris Wilson Cc: Daniel Vetter Cc: Kenneth Graunke Cc: Ben Widawsky Cc: Kristian H?gsberg Cc: Chad Versace Cc: Ian Romanick Reviewed-by: Chad Versace [v1] --- src/mesa/drivers/dri/i965/brw_context.c | 34 ------------------- src/mesa/drivers/dri/i965/intel_batchbuffer.c | 44 +++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 34 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c index 8257fb6..88685cd 100644 --- a/src/mesa/drivers/dri/i965/brw_context.c +++ b/src/mesa/drivers/dri/i965/brw_context.c @@ -1231,40 +1231,6 @@ intel_prepare_render(struct brw_context *brw) */ if (brw_is_front_buffer_drawing(ctx->DrawBuffer)) brw->front_buffer_dirty = true; - - /* Wait for the swapbuffers before the one we just emitted, so we - * don't get too many swaps outstanding for apps that are GPU-heavy - * but not CPU-heavy. - * - * We're using intelDRI2Flush (called from the loader before - * swapbuffer) and glFlush (for front buffer rendering) as the - * indicator that a frame is done and then throttle when we get - * here as we prepare to render the next frame. At this point for - * round trips for swap/copy and getting new buffers are done and - * we'll spend less time waiting on the GPU. - * - * Unfortunately, we don't have a handle to the batch containing - * the swap, and getting our hands on that doesn't seem worth it, - * so we just us the first batch we emitted after the last swap. - */ - if (brw->need_swap_throttle && brw->throttle_batch[0]) { - if (brw->throttle_batch[1]) { - if (!brw->disable_throttling) - drm_intel_bo_wait_rendering(brw->throttle_batch[1]); - drm_intel_bo_unreference(brw->throttle_batch[1]); - } - brw->throttle_batch[1] = brw->throttle_batch[0]; - brw->throttle_batch[0] = NULL; - brw->need_swap_throttle = false; - /* Throttling here is more precise than the throttle ioctl, so skip it */ - brw->need_flush_throttle = false; - } - - if (brw->need_flush_throttle) { - __DRIscreen *psp = brw->intelScreen->driScrnPriv; - drmCommandNone(psp->fd, DRM_I915_GEM_THROTTLE); - brw->need_flush_throttle = false; - } } /** diff --git a/src/mesa/drivers/dri/i965/intel_batchbuffer.c b/src/mesa/drivers/dri/i965/intel_batchbuffer.c index 87862cd..3cf44ad 100644 --- a/src/mesa/drivers/dri/i965/intel_batchbuffer.c +++ b/src/mesa/drivers/dri/i965/intel_batchbuffer.c @@ -33,6 +33,9 @@ #include "intel_fbo.h" #include "brw_context.h" +#include +#include + static void intel_batchbuffer_reset(struct brw_context *brw); @@ -226,6 +229,44 @@ brw_finish_batch(struct brw_context *brw) brw->cache.bo_used_by_gpu = true; } +static void +throttle(struct brw_context *brw) +{ + /* Wait for the swapbuffers before the one we just emitted, so we + * don't get too many swaps outstanding for apps that are GPU-heavy + * but not CPU-heavy. + * + * We're using intelDRI2Flush (called from the loader before + * swapbuffer) and glFlush (for front buffer rendering) as the + * indicator that a frame is done and then throttle when we get + * here as we prepare to render the next frame. At this point for + * round trips for swap/copy and getting new buffers are done and + * we'll spend less time waiting on the GPU. + * + * Unfortunately, we don't have a handle to the batch containing + * the swap, and getting our hands on that doesn't seem worth it, + * so we just use the first batch we emitted after the last swap. + */ + if (brw->need_swap_throttle && brw->throttle_batch[0]) { + if (brw->throttle_batch[1]) { + if (!brw->disable_throttling) + drm_intel_bo_wait_rendering(brw->throttle_batch[1]); + drm_intel_bo_unreference(brw->throttle_batch[1]); + } + brw->throttle_batch[1] = brw->throttle_batch[0]; + brw->throttle_batch[0] = NULL; + brw->need_swap_throttle = false; + /* Throttling here is more precise than the throttle ioctl, so skip it */ + brw->need_flush_throttle = false; + } + + if (brw->need_flush_throttle) { + __DRIscreen *psp = brw->intelScreen->driScrnPriv; + drmCommandNone(psp->fd, DRM_I915_GEM_THROTTLE); + brw->need_flush_throttle = false; + } +} + /* TODO: Push this whole function into bufmgr. */ static int @@ -260,6 +301,7 @@ do_flush_locked(struct brw_context *brw) if (ret == 0) { if (unlikely(INTEL_DEBUG & DEBUG_AUB)) brw_annotate_aub(brw); + if (brw->hw_ctx == NULL || batch->ring != RENDER_RING) { ret = drm_intel_bo_mrb_exec(batch->bo, 4 * batch->used, NULL, 0, 0, flags); @@ -268,6 +310,8 @@ do_flush_locked(struct brw_context *brw) 4 * batch->used, flags); } } + + throttle(brw); } if (unlikely(INTEL_DEBUG & DEBUG_BATCH)) From jrfonseca at kemper.freedesktop.org Wed Mar 18 10:54:45 2015 From: jrfonseca at kemper.freedesktop.org (Jose Fonseca) Date: Wed, 18 Mar 2015 03:54:45 -0700 (PDT) Subject: Mesa (master): configure: check if compiler supports -Werror=vla. Message-ID: <20150318105445.A04F176338@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 8475526a3842580f00a043bca8f821e14e9f5eb7 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=8475526a3842580f00a043bca8f821e14e9f5eb7 Author: Jonathan Gray Date: Tue Mar 17 13:16:05 2015 +1100 configure: check if compiler supports -Werror=vla. Check if the compiler supports -Werror=vla before using it. -Wvla was introduced with GCC 4.3 and is not present in 4.2. Fixes the build on OpenBSD. v2: Fix statement order, and quote $save_CFLAGS. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=89433 Signed-off-by: Jonathan Gray Signed-off-by: Jose Fonseca --- configure.ac | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index a3b0ebd..8c90b41 100644 --- a/configure.ac +++ b/configure.ac @@ -278,8 +278,20 @@ if test "x$GCC" = xyes; then # - non-Linux/Posix OpenGL portions needs to build on MSVC 2013 (which # supports most of C99) # - the rest has no compiler compiler restrictions - MSVC2013_COMPAT_CFLAGS="-Werror=vla -Werror=pointer-arith" - MSVC2013_COMPAT_CXXFLAGS="-Werror=vla -Werror=pointer-arith" + MSVC2013_COMPAT_CFLAGS="-Werror=pointer-arith" + MSVC2013_COMPAT_CXXFLAGS="-Werror=pointer-arith" + + # Enable -Werror=vla if compiler supports it + save_CFLAGS="$CFLAGS" + AC_MSG_CHECKING([whether $CC supports -Werror=vla]) + CFLAGS="$CFLAGS -Werror=vla" + AC_LINK_IFELSE([AC_LANG_PROGRAM()], + [MSVC2013_COMPAT_CFLAGS="$MSVC2013_COMPAT_CFLAGS -Werror=vla"; + MSVC2013_COMPAT_CXXFLAGS="$MSVC2013_COMPAT_CXXFLAGS -Werror=vla"; + AC_MSG_RESULT([yes])], + AC_MSG_RESULT([no])); + CFLAGS="$save_CFLAGS" + MSVC2008_COMPAT_CFLAGS="$MSVC2013_COMPAT_CFLAGS -Werror=declaration-after-statement" MSVC2008_COMPAT_CXXFLAGS="$MSVC2013_COMPAT_CXXFLAGS" fi From mareko at kemper.freedesktop.org Wed Mar 18 11:06:44 2015 From: mareko at kemper.freedesktop.org (Marek Olšák) Date: Wed, 18 Mar 2015 04:06:44 -0700 (PDT) Subject: Mesa (master): docs/GL3: don't list nv30 Message-ID: <20150318110644.B0F9C7635A@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 42715ad7932cdcfaffd8e514a200a461d6133927 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=42715ad7932cdcfaffd8e514a200a461d6133927 Author: Marek Ol??k Date: Wed Mar 18 01:50:03 2015 +0100 docs/GL3: don't list nv30 Suggested by Ilia Mirkin. --- docs/GL3.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/GL3.txt b/docs/GL3.txt index bd17743..0d37240 100644 --- a/docs/GL3.txt +++ b/docs/GL3.txt @@ -176,12 +176,12 @@ GL 4.3, GLSL 4.30: GL 4.4, GLSL 4.40: GL_MAX_VERTEX_ATTRIB_STRIDE DONE (all drivers) - GL_ARB_buffer_storage DONE (i965, nv30, nv50, nvc0, r600, radeonsi) + GL_ARB_buffer_storage DONE (i965, nv50, nvc0, r600, radeonsi) GL_ARB_clear_texture DONE (i965) GL_ARB_enhanced_layouts not started GL_ARB_multi_bind DONE (all drivers) GL_ARB_query_buffer_object not started - GL_ARB_texture_mirror_clamp_to_edge DONE (i965, nv30, nv50, nvc0, r600, radeonsi, llvmpipe, softpipe) + GL_ARB_texture_mirror_clamp_to_edge DONE (i965, nv50, nvc0, r600, radeonsi, llvmpipe, softpipe) GL_ARB_texture_stencil8 not started GL_ARB_vertex_type_10f_11f_11f_rev DONE (i965, nv50, nvc0, r600, radeonsi, llvmpipe, softpipe) From mareko at kemper.freedesktop.org Wed Mar 18 11:06:44 2015 From: mareko at kemper.freedesktop.org (Marek Olšák) Date: Wed, 18 Mar 2015 04:06:44 -0700 (PDT) Subject: Mesa (master): docs/GL3: don't list swrast Message-ID: <20150318110644.A924176359@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 4e46af0195f7f9000ee0633685756d26f745499a URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=4e46af0195f7f9000ee0633685756d26f745499a Author: Marek Ol??k Date: Mon Mar 16 23:19:17 2015 +0100 docs/GL3: don't list swrast Let's face it: This driver is unlikely to get more love. Reviewed-by: Ilia Mirkin --- docs/GL3.txt | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/docs/GL3.txt b/docs/GL3.txt index 1ca4502..bd17743 100644 --- a/docs/GL3.txt +++ b/docs/GL3.txt @@ -21,21 +21,21 @@ Feature Status GL 3.0, GLSL 1.30 --- all DONE: i965, nv50, nvc0, r600, radeonsi, llvmpipe, softpipe glBindFragDataLocation, glGetFragDataLocation DONE - Conditional rendering (GL_NV_conditional_render) DONE (swrast) - Map buffer subranges (GL_ARB_map_buffer_range) DONE (swrast) + Conditional rendering (GL_NV_conditional_render) DONE () + Map buffer subranges (GL_ARB_map_buffer_range) DONE () Clamping controls (GL_ARB_color_buffer_float) DONE () Float textures, renderbuffers (GL_ARB_texture_float) DONE () GL_EXT_packed_float DONE () - GL_EXT_texture_shared_exponent DONE (swrast) + GL_EXT_texture_shared_exponent DONE () Float depth buffers (GL_ARB_depth_buffer_float) DONE () - Framebuffer objects (GL_ARB_framebuffer_object) DONE (swrast) + Framebuffer objects (GL_ARB_framebuffer_object) DONE () GL_ARB_half_float_pixel DONE (all drivers) - GL_ARB_half_float_vertex DONE (swrast) + GL_ARB_half_float_vertex DONE () GL_EXT_texture_integer DONE () GL_EXT_texture_array DONE () - Per-buffer blend and masks (GL_EXT_draw_buffers2) DONE (swrast) - GL_EXT_texture_compression_rgtc DONE (swrast) - GL_ARB_texture_rg DONE (swrast) + Per-buffer blend and masks (GL_EXT_draw_buffers2) DONE () + GL_EXT_texture_compression_rgtc DONE () + GL_ARB_texture_rg DONE () Transform feedback (GL_EXT_transform_feedback) DONE () Vertex array objects (GL_ARB_vertex_array_object) DONE () sRGB framebuffer format (GL_EXT_framebuffer_sRGB) DONE () @@ -53,13 +53,13 @@ GL 3.0, GLSL 1.30 --- all DONE: i965, nv50, nvc0, r600, radeonsi, llvmpipe, soft GL 3.1, GLSL 1.40 --- all DONE: i965, nv50, nvc0, r600, radeonsi, llvmpipe, softpipe Forward compatible context support/deprecations DONE () - Instanced drawing (GL_ARB_draw_instanced) DONE (swrast) - Buffer copying (GL_ARB_copy_buffer) DONE (swrast) + Instanced drawing (GL_ARB_draw_instanced) DONE () + Buffer copying (GL_ARB_copy_buffer) DONE () Primitive restart (GL_NV_primitive_restart) DONE () 16 vertex texture image units DONE () Texture buffer objs (GL_ARB_texture_buffer_object) DONE for OpenGL 3.1 contexts () - Rectangular textures (GL_ARB_texture_rectangle) DONE (swrast) - Uniform buffer objs (GL_ARB_uniform_buffer_object) DONE (swrast) + Rectangular textures (GL_ARB_texture_rectangle) DONE () + Uniform buffer objs (GL_ARB_uniform_buffer_object) DONE () Signed normalized textures (GL_EXT_texture_snorm) DONE () @@ -67,14 +67,14 @@ GL 3.2, GLSL 1.50 --- all DONE: i965, nv50, nvc0, r600, radeonsi, llvmpipe, soft Core/compatibility profiles DONE Geometry shaders DONE () - BGRA vertex order (GL_ARB_vertex_array_bgra) DONE (swrast) - Base vertex offset(GL_ARB_draw_elements_base_vertex) DONE (swrast) - Frag shader coord (GL_ARB_fragment_coord_conventions) DONE (swrast) - Provoking vertex (GL_ARB_provoking_vertex) DONE (swrast) + BGRA vertex order (GL_ARB_vertex_array_bgra) DONE () + Base vertex offset(GL_ARB_draw_elements_base_vertex) DONE () + Frag shader coord (GL_ARB_fragment_coord_conventions) DONE () + Provoking vertex (GL_ARB_provoking_vertex) DONE () Seamless cubemaps (GL_ARB_seamless_cube_map) DONE () Multisample textures (GL_ARB_texture_multisample) DONE () - Frag depth clamp (GL_ARB_depth_clamp) DONE (swrast) - Fence objects (GL_ARB_sync) DONE (swrast) + Frag depth clamp (GL_ARB_depth_clamp) DONE () + Fence objects (GL_ARB_sync) DONE () GLX_ARB_create_context_profile DONE @@ -82,11 +82,11 @@ GL 3.3, GLSL 3.30 --- all DONE: i965, nv50, nvc0, r600, radeonsi, llvmpipe, soft GL_ARB_blend_func_extended DONE () GL_ARB_explicit_attrib_location DONE (all drivers that support GLSL) - GL_ARB_occlusion_query2 DONE (swrast) + GL_ARB_occlusion_query2 DONE () GL_ARB_sampler_objects DONE (all drivers) GL_ARB_shader_bit_encoding DONE () GL_ARB_texture_rgb10_a2ui DONE () - GL_ARB_texture_swizzle DONE (swrast) + GL_ARB_texture_swizzle DONE () GL_ARB_timer_query DONE () GL_ARB_instanced_arrays DONE () GL_ARB_vertex_type_2_10_10_10_rev DONE () @@ -181,7 +181,7 @@ GL 4.4, GLSL 4.40: GL_ARB_enhanced_layouts not started GL_ARB_multi_bind DONE (all drivers) GL_ARB_query_buffer_object not started - GL_ARB_texture_mirror_clamp_to_edge DONE (i965, nv30, nv50, nvc0, r600, radeonsi, swrast, llvmpipe, softpipe) + GL_ARB_texture_mirror_clamp_to_edge DONE (i965, nv30, nv50, nvc0, r600, radeonsi, llvmpipe, softpipe) GL_ARB_texture_stencil8 not started GL_ARB_vertex_type_10f_11f_11f_rev DONE (i965, nv50, nvc0, r600, radeonsi, llvmpipe, softpipe) From mareko at kemper.freedesktop.org Wed Mar 18 11:06:44 2015 From: mareko at kemper.freedesktop.org (Marek Olšák) Date: Wed, 18 Mar 2015 04:06:44 -0700 (PDT) Subject: Mesa (master): radeonsi: increase coords array size for radeon_llvm_emit_prepare_cube_coords Message-ID: <20150318110644.9DAC376338@kemper.freedesktop.org> Module: Mesa Branch: master Commit: a984abdad39df2d8ceb4c46e11f4ce1344c36c86 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=a984abdad39df2d8ceb4c46e11f4ce1344c36c86 Author: Marek Ol??k Date: Tue Mar 17 17:47:17 2015 +0100 radeonsi: increase coords array size for radeon_llvm_emit_prepare_cube_coords radeon_llvm_emit_prepare_cube_coords uses coords[4] in some cases (TXB2 etc.) Discovered by Coverity. Reported by Ilia Mirkin. Cc: 10.5 10.4 Reviewed-by: Michel D?nzer --- src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c | 2 +- src/gallium/drivers/radeonsi/si_shader.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c b/src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c index d89e2b4..1690194 100644 --- a/src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c +++ b/src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c @@ -748,7 +748,7 @@ static void txp_fetch_args( const struct tgsi_full_instruction * inst = emit_data->inst; LLVMValueRef src_w; unsigned chan; - LLVMValueRef coords[4]; + LLVMValueRef coords[5]; emit_data->dst_type = LLVMVectorType(bld_base->base.elem_type, 4); src_w = lp_build_emit_fetch(bld_base, emit_data->inst, 0, TGSI_CHAN_W); diff --git a/src/gallium/drivers/radeonsi/si_shader.c b/src/gallium/drivers/radeonsi/si_shader.c index de889ed..4dcf756 100644 --- a/src/gallium/drivers/radeonsi/si_shader.c +++ b/src/gallium/drivers/radeonsi/si_shader.c @@ -1572,7 +1572,7 @@ static void tex_fetch_args( const struct tgsi_full_instruction * inst = emit_data->inst; unsigned opcode = inst->Instruction.Opcode; unsigned target = inst->Texture.Texture; - LLVMValueRef coords[4]; + LLVMValueRef coords[5]; LLVMValueRef address[16]; int ref_pos; unsigned num_coords = tgsi_util_get_texture_coord_dim(target, &ref_pos); From mareko at kemper.freedesktop.org Wed Mar 18 11:06:44 2015 From: mareko at kemper.freedesktop.org (Marek Olšák) Date: Wed, 18 Mar 2015 04:06:44 -0700 (PDT) Subject: Mesa (master): docs/GL3: don't list r300 Message-ID: <20150318110644.A0D34761EF@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 2b5379651f0b4dca9c1187b53b8466ff265ceb80 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=2b5379651f0b4dca9c1187b53b8466ff265ceb80 Author: Marek Ol??k Date: Mon Mar 16 23:15:22 2015 +0100 docs/GL3: don't list r300 r300g already supports everything it can. There's no point in listing the driver here. Reviewed-by: Ilia Mirkin --- docs/GL3.txt | 56 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/docs/GL3.txt b/docs/GL3.txt index 5d59341..1ca4502 100644 --- a/docs/GL3.txt +++ b/docs/GL3.txt @@ -21,23 +21,23 @@ Feature Status GL 3.0, GLSL 1.30 --- all DONE: i965, nv50, nvc0, r600, radeonsi, llvmpipe, softpipe glBindFragDataLocation, glGetFragDataLocation DONE - Conditional rendering (GL_NV_conditional_render) DONE (r300, swrast) - Map buffer subranges (GL_ARB_map_buffer_range) DONE (r300, swrast) - Clamping controls (GL_ARB_color_buffer_float) DONE (r300) - Float textures, renderbuffers (GL_ARB_texture_float) DONE (r300) + Conditional rendering (GL_NV_conditional_render) DONE (swrast) + Map buffer subranges (GL_ARB_map_buffer_range) DONE (swrast) + Clamping controls (GL_ARB_color_buffer_float) DONE () + Float textures, renderbuffers (GL_ARB_texture_float) DONE () GL_EXT_packed_float DONE () GL_EXT_texture_shared_exponent DONE (swrast) Float depth buffers (GL_ARB_depth_buffer_float) DONE () - Framebuffer objects (GL_ARB_framebuffer_object) DONE (r300, swrast) + Framebuffer objects (GL_ARB_framebuffer_object) DONE (swrast) GL_ARB_half_float_pixel DONE (all drivers) - GL_ARB_half_float_vertex DONE (r300, swrast) + GL_ARB_half_float_vertex DONE (swrast) GL_EXT_texture_integer DONE () GL_EXT_texture_array DONE () Per-buffer blend and masks (GL_EXT_draw_buffers2) DONE (swrast) - GL_EXT_texture_compression_rgtc DONE (r300, swrast) - GL_ARB_texture_rg DONE (r300, swrast) + GL_EXT_texture_compression_rgtc DONE (swrast) + GL_ARB_texture_rg DONE (swrast) Transform feedback (GL_EXT_transform_feedback) DONE () - Vertex array objects (GL_ARB_vertex_array_object) DONE (all drivers) + Vertex array objects (GL_ARB_vertex_array_object) DONE () sRGB framebuffer format (GL_EXT_framebuffer_sRGB) DONE () glClearBuffer commands DONE glGetStringi command DONE @@ -45,7 +45,7 @@ GL 3.0, GLSL 1.30 --- all DONE: i965, nv50, nvc0, r600, radeonsi, llvmpipe, soft glVertexAttribI commands DONE Depth format cube textures DONE () GLX_ARB_create_context (GLX 1.4 is required) DONE - Multisample anti-aliasing DONE (llvmpipe (*), softpipe (*), r300) + Multisample anti-aliasing DONE (llvmpipe (*), softpipe (*)) (*) llvmpipe and softpipe have fake Multisample anti-aliasing support @@ -54,27 +54,27 @@ GL 3.1, GLSL 1.40 --- all DONE: i965, nv50, nvc0, r600, radeonsi, llvmpipe, soft Forward compatible context support/deprecations DONE () Instanced drawing (GL_ARB_draw_instanced) DONE (swrast) - Buffer copying (GL_ARB_copy_buffer) DONE (r300, swrast) - Primitive restart (GL_NV_primitive_restart) DONE (r300) + Buffer copying (GL_ARB_copy_buffer) DONE (swrast) + Primitive restart (GL_NV_primitive_restart) DONE () 16 vertex texture image units DONE () Texture buffer objs (GL_ARB_texture_buffer_object) DONE for OpenGL 3.1 contexts () - Rectangular textures (GL_ARB_texture_rectangle) DONE (r300, swrast) + Rectangular textures (GL_ARB_texture_rectangle) DONE (swrast) Uniform buffer objs (GL_ARB_uniform_buffer_object) DONE (swrast) - Signed normalized textures (GL_EXT_texture_snorm) DONE (r300) + Signed normalized textures (GL_EXT_texture_snorm) DONE () GL 3.2, GLSL 1.50 --- all DONE: i965, nv50, nvc0, r600, radeonsi, llvmpipe, softpipe Core/compatibility profiles DONE Geometry shaders DONE () - BGRA vertex order (GL_ARB_vertex_array_bgra) DONE (r300, swrast) - Base vertex offset(GL_ARB_draw_elements_base_vertex) DONE (r300, swrast) - Frag shader coord (GL_ARB_fragment_coord_conventions) DONE (r300, swrast) - Provoking vertex (GL_ARB_provoking_vertex) DONE (r300, swrast) + BGRA vertex order (GL_ARB_vertex_array_bgra) DONE (swrast) + Base vertex offset(GL_ARB_draw_elements_base_vertex) DONE (swrast) + Frag shader coord (GL_ARB_fragment_coord_conventions) DONE (swrast) + Provoking vertex (GL_ARB_provoking_vertex) DONE (swrast) Seamless cubemaps (GL_ARB_seamless_cube_map) DONE () Multisample textures (GL_ARB_texture_multisample) DONE () Frag depth clamp (GL_ARB_depth_clamp) DONE (swrast) - Fence objects (GL_ARB_sync) DONE (r300, swrast) + Fence objects (GL_ARB_sync) DONE (swrast) GLX_ARB_create_context_profile DONE @@ -82,13 +82,13 @@ GL 3.3, GLSL 3.30 --- all DONE: i965, nv50, nvc0, r600, radeonsi, llvmpipe, soft GL_ARB_blend_func_extended DONE () GL_ARB_explicit_attrib_location DONE (all drivers that support GLSL) - GL_ARB_occlusion_query2 DONE (r300, swrast) + GL_ARB_occlusion_query2 DONE (swrast) GL_ARB_sampler_objects DONE (all drivers) GL_ARB_shader_bit_encoding DONE () GL_ARB_texture_rgb10_a2ui DONE () - GL_ARB_texture_swizzle DONE (r300, swrast) + GL_ARB_texture_swizzle DONE (swrast) GL_ARB_timer_query DONE () - GL_ARB_instanced_arrays DONE (r300) + GL_ARB_instanced_arrays DONE () GL_ARB_vertex_type_2_10_10_10_rev DONE () @@ -123,7 +123,7 @@ GL 4.0, GLSL 4.00: GL 4.1, GLSL 4.10: - GL_ARB_ES2_compatibility DONE (i965, nv50, nvc0, r300, r600, radeonsi, llvmpipe, softpipe) + GL_ARB_ES2_compatibility DONE (i965, nv50, nvc0, r600, radeonsi, llvmpipe, softpipe) GL_ARB_get_program_binary DONE (0 binary formats) GL_ARB_separate_shader_objects DONE (all drivers) GL_ARB_shader_precision started (Micah) @@ -143,7 +143,7 @@ GL 4.2, GLSL 4.20: GL_ARB_conservative_depth DONE (all drivers that support GLSL 1.30) GL_ARB_shading_language_420pack DONE (all drivers that support GLSL 1.30) GL_ARB_shading_language_packing DONE (all drivers) - GL_ARB_internalformat_query DONE (i965, nv50, nvc0, r300, r600, radeonsi, llvmpipe, softpipe) + GL_ARB_internalformat_query DONE (i965, nv50, nvc0, r600, radeonsi, llvmpipe, softpipe) GL_ARB_map_buffer_alignment DONE (all drivers) @@ -176,19 +176,19 @@ GL 4.3, GLSL 4.30: GL 4.4, GLSL 4.40: GL_MAX_VERTEX_ATTRIB_STRIDE DONE (all drivers) - GL_ARB_buffer_storage DONE (i965, nv30, nv50, nvc0, r300, r600, radeonsi) + GL_ARB_buffer_storage DONE (i965, nv30, nv50, nvc0, r600, radeonsi) GL_ARB_clear_texture DONE (i965) GL_ARB_enhanced_layouts not started GL_ARB_multi_bind DONE (all drivers) GL_ARB_query_buffer_object not started - GL_ARB_texture_mirror_clamp_to_edge DONE (i965, nv30, nv50, nvc0, r300, r600, radeonsi, swrast, llvmpipe, softpipe) + GL_ARB_texture_mirror_clamp_to_edge DONE (i965, nv30, nv50, nvc0, r600, radeonsi, swrast, llvmpipe, softpipe) GL_ARB_texture_stencil8 not started GL_ARB_vertex_type_10f_11f_11f_rev DONE (i965, nv50, nvc0, r600, radeonsi, llvmpipe, softpipe) GL 4.5, GLSL 4.50: GL_ARB_ES3_1_compatibility not started - GL_ARB_clip_control DONE (nv50, nvc0, r300, r600, radeonsi, llvmpipe, softpipe) + GL_ARB_clip_control DONE (nv50, nvc0, r600, radeonsi, llvmpipe, softpipe) GL_ARB_conditional_render_inverted DONE (i965, nv50, nvc0, llvmpipe, softpipe) GL_ARB_cull_distance not started GL_ARB_derivative_control DONE (i965, nv50, nvc0, r600) @@ -204,7 +204,7 @@ GL 4.5, GLSL 4.50: - Query object started (Martin Peres) GL_ARB_get_texture_sub_image started (Brian Paul) GL_ARB_shader_texture_image_samples not started - GL_ARB_texture_barrier DONE (nv50, nvc0, r300, r600, radeonsi) + GL_ARB_texture_barrier DONE (nv50, nvc0, r600, radeonsi) GL_KHR_context_flush_control DONE (all - but needs GLX/EXT extension to be useful) GL_KHR_robust_buffer_access_behavior not started GL_KHR_robustness 90% done (the ARB variant) From robclark at kemper.freedesktop.org Wed Mar 18 14:48:59 2015 From: robclark at kemper.freedesktop.org (Rob Clark) Date: Wed, 18 Mar 2015 07:48:59 -0700 (PDT) Subject: Mesa (master): freedreno: fix spelling Message-ID: <20150318144859.C3D5176246@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 62cc003b7d2031c2321f4698bd5b97cc97261c07 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=62cc003b7d2031c2321f4698bd5b97cc97261c07 Author: Rob Clark Date: Wed Mar 18 09:51:27 2015 -0400 freedreno: fix spelling Signed-off-by: Rob Clark --- src/gallium/drivers/freedreno/freedreno_screen.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gallium/drivers/freedreno/freedreno_screen.c b/src/gallium/drivers/freedreno/freedreno_screen.c index 1d73513..cdcc0da 100644 --- a/src/gallium/drivers/freedreno/freedreno_screen.c +++ b/src/gallium/drivers/freedreno/freedreno_screen.c @@ -67,7 +67,7 @@ static const struct debug_named_value debug_options[] = { {"nobypass", FD_DBG_NOBYPASS, "Disable GMEM bypass"}, {"fraghalf", FD_DBG_FRAGHALF, "Use half-precision in fragment shader"}, {"nobin", FD_DBG_NOBIN, "Disable hw binning"}, - {"optmsgs", FD_DBG_OPTMSGS,"Enable optimizater debug messages"}, + {"optmsgs", FD_DBG_OPTMSGS,"Enable optimizer debug messages"}, {"optdump", FD_DBG_OPTDUMP,"Dump shader DAG to .dot files"}, {"glsl120", FD_DBG_GLSL120,"Temporary flag to force GLSL 120 (rather than 130) on a3xx+"}, {"nocp", FD_DBG_NOCP, "Disable copy-propagation"}, From robclark at kemper.freedesktop.org Wed Mar 18 14:48:59 2015 From: robclark at kemper.freedesktop.org (Rob Clark) Date: Wed, 18 Mar 2015 07:48:59 -0700 (PDT) Subject: Mesa (master): freedreno/ir3: fix infinite recursion in sched Message-ID: <20150318144859.D2F6F76246@kemper.freedesktop.org> Module: Mesa Branch: master Commit: aee26d292f165438577426f5e62a62ec2a1514c9 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=aee26d292f165438577426f5e62a62ec2a1514c9 Author: Rob Clark Date: Wed Mar 18 09:51:57 2015 -0400 freedreno/ir3: fix infinite recursion in sched One more case we need to handle. One of the src instructions for the indirect could also end up being ourself. Signed-off-by: Rob Clark --- src/gallium/drivers/freedreno/ir3/ir3_sched.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gallium/drivers/freedreno/ir3/ir3_sched.c b/src/gallium/drivers/freedreno/ir3/ir3_sched.c index c1921d0..94237c3 100644 --- a/src/gallium/drivers/freedreno/ir3/ir3_sched.c +++ b/src/gallium/drivers/freedreno/ir3/ir3_sched.c @@ -283,7 +283,7 @@ static int trysched(struct ir3_sched_ctx *ctx, * on ourself (ie. avoid infinite recursion): */ foreach_ssa_src(src, indirect) { - if (src == instr) + if ((src == instr) || (src->address == instr)) continue; delay = trysched(ctx, src); if (delay) From brianp at kemper.freedesktop.org Wed Mar 18 15:50:18 2015 From: brianp at kemper.freedesktop.org (Brian Paul) Date: Wed, 18 Mar 2015 08:50:18 -0700 (PDT) Subject: Mesa (master): mapi: move some #includes from .h file to .c files Message-ID: <20150318155018.E5C0776246@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 9fbbd60c1da4467683d93540c64164ad337ce454 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=9fbbd60c1da4467683d93540c64164ad337ce454 Author: Brian Paul Date: Fri Mar 13 13:12:12 2015 -0600 mapi: move some #includes from .h file to .c files Just include things where they're needed. Reviewed-by: Jose Fonseca --- src/mapi/glapi/glapi_getproc.c | 4 ++++ src/mapi/glapi/glapi_nop.c | 1 + src/mapi/glapi/glapi_priv.h | 3 --- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/mapi/glapi/glapi_getproc.c b/src/mapi/glapi/glapi_getproc.c index bfde92c..524a771 100644 --- a/src/mapi/glapi/glapi_getproc.c +++ b/src/mapi/glapi/glapi_getproc.c @@ -30,6 +30,9 @@ */ +#include +#include +#include #include "glapi/glapi_priv.h" #include "glapi/glapitable.h" @@ -37,6 +40,7 @@ #define FIRST_DYNAMIC_OFFSET (sizeof(struct _glapi_table) / sizeof(void *)) + /********************************************************************** * Static function management. */ diff --git a/src/mapi/glapi/glapi_nop.c b/src/mapi/glapi/glapi_nop.c index 0041ed5..13db310 100644 --- a/src/mapi/glapi/glapi_nop.c +++ b/src/mapi/glapi/glapi_nop.c @@ -44,6 +44,7 @@ */ +#include #include #include "glapi/glapi_priv.h" diff --git a/src/mapi/glapi/glapi_priv.h b/src/mapi/glapi/glapi_priv.h index d368260..50f710e 100644 --- a/src/mapi/glapi/glapi_priv.h +++ b/src/mapi/glapi/glapi_priv.h @@ -26,9 +26,6 @@ #ifndef _GLAPI_PRIV_H #define _GLAPI_PRIV_H -#include -#include -#include #ifdef HAVE_DIX_CONFIG_H #include From brianp at kemper.freedesktop.org Wed Mar 18 15:50:18 2015 From: brianp at kemper.freedesktop.org (Brian Paul) Date: Wed, 18 Mar 2015 08:50:18 -0700 (PDT) Subject: Mesa (master): mapi: add new _glapi_new_nop_table() and _glapi_set_nop_handler() Message-ID: <20150318155018.CBFEF76246@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 201e36e77d6ca616f75f14d5f1c31f0062ae4366 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=201e36e77d6ca616f75f14d5f1c31f0062ae4366 Author: Brian Paul Date: Fri Mar 13 10:20:29 2015 -0600 mapi: add new _glapi_new_nop_table() and _glapi_set_nop_handler() _glapi_new_nop_table() creates a new dispatch table populated with pointers to no-op functions. _glapi_set_nop_handler() is used to register a callback function which will be called from each of the no-op functions. Now we always generate a separate no-op function for each GL entrypoint. This allows us to do proper stack clean-up for Windows __stdcall and lets us report the actual function name in error messages. Before this change, for non-Windows release builds we used a single no-op function for all entrypoints. Reviewed-by: Jose Fonseca --- src/mapi/glapi/glapi.h | 11 ++++++ src/mapi/glapi/glapi_nop.c | 84 +++++++++++++++++++++++++------------------- src/mapi/mapi_glapi.c | 23 ++++++++++++ src/mapi/table.c | 23 +++++++++--- src/mapi/table.h | 8 +++++ 5 files changed, 108 insertions(+), 41 deletions(-) diff --git a/src/mapi/glapi/glapi.h b/src/mapi/glapi/glapi.h index 8d991fb..673295b 100644 --- a/src/mapi/glapi/glapi.h +++ b/src/mapi/glapi/glapi.h @@ -80,6 +80,9 @@ extern "C" { #endif typedef void (*_glapi_proc)(void); + +typedef void (*_glapi_nop_handler_proc)(const char *name); + struct _glapi_table; @@ -159,6 +162,14 @@ _GLAPI_EXPORT struct _glapi_table * _glapi_create_table_from_handle(void *handle, const char *symbol_prefix); +_GLAPI_EXPORT void +_glapi_set_nop_handler(_glapi_nop_handler_proc func); + +/** Return pointer to new dispatch table filled with no-op functions */ +_GLAPI_EXPORT struct _glapi_table * +_glapi_new_nop_table(unsigned num_entries); + + /** Deprecated function */ _GLAPI_EXPORT unsigned long _glthread_GetID(void); diff --git a/src/mapi/glapi/glapi_nop.c b/src/mapi/glapi/glapi_nop.c index 628276e..0041ed5 100644 --- a/src/mapi/glapi/glapi_nop.c +++ b/src/mapi/glapi/glapi_nop.c @@ -30,14 +30,21 @@ * This file defines a special dispatch table which is loaded with no-op * functions. * - * When there's no current rendering context, calling a GL function like - * glBegin() is a no-op. Apps should never normally do this. So as a - * debugging aid, each of the no-op functions will emit a warning to - * stderr if the MESA_DEBUG or LIBGL_DEBUG env var is set. + * Mesa can register a "no-op handler function" which will be called in + * the event that a no-op function is called. + * + * In the past, the dispatch table was loaded with pointers to a single + * no-op function. But that broke on Windows because the GL entrypoints + * use __stdcall convention. __stdcall means the callee cleans up the + * stack. So one no-op function can't properly clean up the stack. This + * would lead to crashes. + * + * Another benefit of unique no-op functions is we can accurately report + * the function's name in an error message. */ - +#include #include "glapi/glapi_priv.h" @@ -51,25 +58,32 @@ _glapi_set_warning_func(_glapi_proc func) { } -/* - * When GLAPIENTRY is __stdcall (i.e. Windows), the stack is popped by the - * callee making the number/type of arguments significant. + +/** + * We'll jump though this function pointer whenever a no-op function + * is called. */ -#if defined(_WIN32) || defined(DEBUG) +static _glapi_nop_handler_proc nop_handler = NULL; + + +/** + * Register the no-op handler call-back function. + */ +void +_glapi_set_nop_handler(_glapi_nop_handler_proc func) +{ + nop_handler = func; +} + /** * Called by each of the no-op GL entrypoints. */ -static int -Warn(const char *func) +static void +nop(const char *func) { -#if defined(DEBUG) - if (getenv("MESA_DEBUG") || getenv("LIBGL_DEBUG")) { - fprintf(stderr, "GL User Error: gl%s called without a rendering context\n", - func); - } -#endif - return 0; + if (nop_handler) + nop_handler(func); } @@ -79,7 +93,8 @@ Warn(const char *func) static GLint NoOpUnused(void) { - return Warn(" function"); + nop("unused GL entry point"); + return 0; } /* @@ -89,31 +104,28 @@ NoOpUnused(void) #define KEYWORD1_ALT static #define KEYWORD2 GLAPIENTRY #define NAME(func) NoOp##func -#define DISPATCH(func, args, msg) Warn(#func); -#define RETURN_DISPATCH(func, args, msg) Warn(#func); return 0 +#define DISPATCH(func, args, msg) nop(#func); +#define RETURN_DISPATCH(func, args, msg) nop(#func); return 0 /* * Defines for the table of no-op entry points. */ #define TABLE_ENTRY(name) (_glapi_proc) NoOp##name +#define DISPATCH_TABLE_NAME __glapi_noop_table +#define UNUSED_TABLE_NAME __unused_noop_functions + +#include "glapi/glapitemp.h" -#else -static int -NoOpGeneric(void) +/** Return pointer to new dispatch table filled with no-op functions */ +struct _glapi_table * +_glapi_new_nop_table(unsigned num_entries) { - if (getenv("MESA_DEBUG") || getenv("LIBGL_DEBUG")) { - fprintf(stderr, "GL User Error: calling GL function without a rendering context\n"); + struct _glapi_table *table = malloc(num_entries * sizeof(_glapi_proc)); + if (table) { + memcpy(table, __glapi_noop_table, + num_entries * sizeof(_glapi_proc)); } - return 0; + return table; } - -#define TABLE_ENTRY(name) (_glapi_proc) NoOpGeneric - -#endif - -#define DISPATCH_TABLE_NAME __glapi_noop_table -#define UNUSED_TABLE_NAME __unused_noop_functions - -#include "glapi/glapitemp.h" diff --git a/src/mapi/mapi_glapi.c b/src/mapi/mapi_glapi.c index 127dfaf..70605f3 100644 --- a/src/mapi/mapi_glapi.c +++ b/src/mapi/mapi_glapi.c @@ -27,6 +27,7 @@ */ #include +#include #include "glapi/glapi.h" #include "u_current.h" #include "table.h" /* for MAPI_TABLE_NUM_SLOTS */ @@ -222,6 +223,28 @@ _glapi_get_proc_name(unsigned int offset) return stub ? stub_get_name(stub) : NULL; } +/** Return pointer to new dispatch table filled with no-op functions */ +struct _glapi_table * +_glapi_new_nop_table(unsigned num_entries) +{ + struct _glapi_table *table; + + if (num_entries > MAPI_TABLE_NUM_SLOTS) + num_entries = MAPI_TABLE_NUM_SLOTS; + + table = malloc(num_entries * sizeof(mapi_func)); + if (table) { + memcpy(table, table_noop_array, num_entries * sizeof(mapi_func)); + } + return table; +} + +void +_glapi_set_nop_handler(_glapi_nop_handler_proc func) +{ + table_set_noop_handler(func); +} + /** * This is a deprecated function which should not be used anymore. * It's only present to satisfy linking with older versions of libGL. diff --git a/src/mapi/table.c b/src/mapi/table.c index 0d28666..7487501 100644 --- a/src/mapi/table.c +++ b/src/mapi/table.c @@ -30,16 +30,29 @@ #include "table.h" +static nop_handler_proc nop_handler = NULL; + +void +table_set_noop_handler(nop_handler_proc func) +{ + nop_handler = func; +} + static void noop_warn(const char *name) { - static int debug = -1; + if (nop_handler) { + nop_handler(name); + } + else { + static int debug = -1; - if (debug < 0) - debug = (getenv("MESA_DEBUG") || getenv("LIBGL_DEBUG")); + if (debug < 0) + debug = (getenv("MESA_DEBUG") || getenv("LIBGL_DEBUG")); - if (debug) - fprintf(stderr, "%s is no-op\n", name); + if (debug) + fprintf(stderr, "%s is no-op\n", name); + } } static int diff --git a/src/mapi/table.h b/src/mapi/table.h index e2d6ef0..a1af40c 100644 --- a/src/mapi/table.h +++ b/src/mapi/table.h @@ -41,6 +41,14 @@ struct mapi_table; extern const mapi_func table_noop_array[]; + +typedef void (*nop_handler_proc)(const char *name); + + +void +table_set_noop_handler(nop_handler_proc func); + + /** * Get the no-op dispatch table. */ From brianp at kemper.freedesktop.org Wed Mar 18 15:50:19 2015 From: brianp at kemper.freedesktop.org (Brian Paul) Date: Wed, 18 Mar 2015 08:50:19 -0700 (PDT) Subject: Mesa (master): mesa: remove MSVC warning pragmas Message-ID: <20150318155019.04BC376246@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 9263986401c90a309d167121bc98c47b24c39d3d URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=9263986401c90a309d167121bc98c47b24c39d3d Author: Brian Paul Date: Tue Mar 17 11:57:34 2015 -0600 mesa: remove MSVC warning pragmas Removing this block of pragmas doesn't seem to increase the number of warning generated by MSVC. Other than signed/unsigned comparison warnings there's very few other warnings nowadays. Acked-by: Matt Turner --- src/mesa/main/compiler.h | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/src/mesa/main/compiler.h b/src/mesa/main/compiler.h index 5c60391..55152fd 100644 --- a/src/mesa/main/compiler.h +++ b/src/mesa/main/compiler.h @@ -60,26 +60,6 @@ extern "C" { #endif -/** - * Disable assorted warnings - */ -#if defined(_WIN32) && !defined(__CYGWIN__) -# if !defined(__GNUC__) /* mingw environment */ -# pragma warning( disable : 4068 ) /* unknown pragma */ -# pragma warning( disable : 4710 ) /* function 'foo' not inlined */ -# pragma warning( disable : 4711 ) /* function 'foo' selected for automatic inline expansion */ -# pragma warning( disable : 4127 ) /* conditional expression is constant */ -# if defined(MESA_MINWARN) -# pragma warning( disable : 4244 ) /* '=' : conversion from 'const double ' to 'float ', possible loss of data */ -# pragma warning( disable : 4018 ) /* '<' : signed/unsigned mismatch */ -# pragma warning( disable : 4305 ) /* '=' : truncation from 'const double ' to 'float ' */ -# pragma warning( disable : 4550 ) /* 'function' undefined; assuming extern returning int */ -# pragma warning( disable : 4761 ) /* integral size mismatch in argument; conversion supplied */ -# endif -# endif -#endif - - /* XXX: Use standard `__func__` instead */ #ifndef __FUNCTION__ # define __FUNCTION__ __func__ From brianp at kemper.freedesktop.org Wed Mar 18 15:50:18 2015 From: brianp at kemper.freedesktop.org (Brian Paul) Date: Wed, 18 Mar 2015 08:50:18 -0700 (PDT) Subject: Mesa (master): mesa: make _mesa_alloc_dispatch_table() static Message-ID: <20150318155018.DD8FB76246@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 4009d22b61e76850b1b725f4e491da05c2406fa4 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=4009d22b61e76850b1b725f4e491da05c2406fa4 Author: Brian Paul Date: Fri Mar 13 12:05:01 2015 -0600 mesa: make _mesa_alloc_dispatch_table() static Never called from outside of context.c Reviewed-by: Jose Fonseca --- src/mesa/main/api_exec.h | 4 ---- src/mesa/main/context.c | 10 +++++----- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/mesa/main/api_exec.h b/src/mesa/main/api_exec.h index 1e4a9d6..12249fe 100644 --- a/src/mesa/main/api_exec.h +++ b/src/mesa/main/api_exec.h @@ -30,12 +30,8 @@ extern "C" { #endif -struct _glapi_table; struct gl_context; -extern struct _glapi_table * -_mesa_alloc_dispatch_table(void); - extern void _mesa_initialize_exec_table(struct gl_context *ctx); diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c index e7d1f4d..c1acda9 100644 --- a/src/mesa/main/context.c +++ b/src/mesa/main/context.c @@ -931,8 +931,8 @@ nop_glFlush(void) * populated with pointers to "no-op" functions. In turn, the no-op * functions will call nop_handler() above. */ -struct _glapi_table * -_mesa_alloc_dispatch_table(void) +static struct _glapi_table * +alloc_dispatch_table(void) { /* Find the larger of Mesa's dispatch table and libGL's dispatch table. * In practice, this'll be the same for stand-alone Mesa. But for DRI @@ -1001,7 +1001,7 @@ create_beginend_table(const struct gl_context *ctx) { struct _glapi_table *table; - table = _mesa_alloc_dispatch_table(); + table = alloc_dispatch_table(); if (!table) return NULL; @@ -1140,7 +1140,7 @@ _mesa_initialize_context(struct gl_context *ctx, goto fail; /* setup the API dispatch tables with all nop functions */ - ctx->OutsideBeginEnd = _mesa_alloc_dispatch_table(); + ctx->OutsideBeginEnd = alloc_dispatch_table(); if (!ctx->OutsideBeginEnd) goto fail; ctx->Exec = ctx->OutsideBeginEnd; @@ -1167,7 +1167,7 @@ _mesa_initialize_context(struct gl_context *ctx, switch (ctx->API) { case API_OPENGL_COMPAT: ctx->BeginEnd = create_beginend_table(ctx); - ctx->Save = _mesa_alloc_dispatch_table(); + ctx->Save = alloc_dispatch_table(); if (!ctx->BeginEnd || !ctx->Save) goto fail; From brianp at kemper.freedesktop.org Wed Mar 18 15:50:18 2015 From: brianp at kemper.freedesktop.org (Brian Paul) Date: Wed, 18 Mar 2015 08:50:18 -0700 (PDT) Subject: Mesa (master): mesa: reimplement dispatch table no-op function handling Message-ID: <20150318155018.D447F7633A@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 4bdbb588a9d385509f9168e38bfdb76952ba469c URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=4bdbb588a9d385509f9168e38bfdb76952ba469c Author: Brian Paul Date: Fri Mar 13 11:43:44 2015 -0600 mesa: reimplement dispatch table no-op function handling Use the new _glapi_new_nop_table() and _glapi_set_nop_handler() to improve how we handle calling no-op GL functions. If there's a current context for the calling thread, generate a GL_INVALID_OPERATION error. This will happen if the app calls an unimplemented extension function or it calls an illegal function between glBegin/glEnd. If there's no current context, print an error to stdout if it's a debug build. The dispatch_sanity.cpp file has some previous checks removed since the _mesa_generic_nop() function no longer exists. This fixes the piglit gl-1.0-dlist-begin-end and gl-1.0-beginend-coverage tests on Windows. Reviewed-by: Jose Fonseca --- src/mesa/main/context.c | 66 ++++++++++++++++--------------- src/mesa/main/context.h | 3 -- src/mesa/main/tests/dispatch_sanity.cpp | 35 +--------------- 3 files changed, 37 insertions(+), 67 deletions(-) diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c index 22c2341..e7d1f4d 100644 --- a/src/mesa/main/context.c +++ b/src/mesa/main/context.c @@ -882,18 +882,35 @@ update_default_objects(struct gl_context *ctx) /** - * This is the default function we plug into all dispatch table slots - * This helps prevents a segfault when someone calls a GL function without - * first checking if the extension's supported. + * This function is called by the glapi no-op functions. For each OpenGL + * function/entrypoint there's a simple no-op function. These "no-op" + * functions call this function. + * + * If there's a current OpenGL context for the calling thread, we record a + * GL_INVALID_OPERATION error. This can happen either because the app's + * calling an unsupported extension function, or calling an illegal function + * (such as glClear between glBegin/glEnd). + * + * If there's no current OpenGL context for the calling thread, we can + * print a message to stderr. + * + * \param name the name of the OpenGL function, without the "gl" prefix */ -int -_mesa_generic_nop(void) +static void +nop_handler(const char *name) { GET_CURRENT_CONTEXT(ctx); - _mesa_error(ctx, GL_INVALID_OPERATION, - "unsupported function called " - "(unsupported extension or deprecated function?)"); - return 0; + if (ctx) { + _mesa_error(ctx, GL_INVALID_OPERATION, "gl%s(invalid call)", name); + } +#if defined(DEBUG) + else if (getenv("MESA_DEBUG") || getenv("LIBGL_DEBUG")) { + fprintf(stderr, + "GL User Error: gl%s called without a rendering context\n", + name); + fflush(stderr); + } +#endif } @@ -909,13 +926,10 @@ nop_glFlush(void) #endif -extern void (*__glapi_noop_table[])(void); - - /** - * Allocate and initialize a new dispatch table. All the dispatch - * function pointers will point at the _mesa_generic_nop() function - * which raises GL_INVALID_OPERATION. + * Allocate and initialize a new dispatch table. The table will be + * populated with pointers to "no-op" functions. In turn, the no-op + * functions will call nop_handler() above. */ struct _glapi_table * _mesa_alloc_dispatch_table(void) @@ -926,23 +940,10 @@ _mesa_alloc_dispatch_table(void) * DRI drivers. */ GLint numEntries = MAX2(_glapi_get_dispatch_table_size(), _gloffset_COUNT); - struct _glapi_table *table; - - table = malloc(numEntries * sizeof(_glapi_proc)); - if (table) { - _glapi_proc *entry = (_glapi_proc *) table; - GLint i; - for (i = 0; i < numEntries; i++) { -#if defined(_WIN32) - /* FIXME: This will not generate an error, but at least it won't - * corrupt the stack like _mesa_generic_nop does. */ - entry[i] = __glapi_noop_table[i]; -#else - entry[i] = (_glapi_proc) _mesa_generic_nop; -#endif - } + struct _glapi_table *table = _glapi_new_nop_table(numEntries); #if defined(_WIN32) + if (table) { /* This is a special case for Windows in the event that * wglGetProcAddress is called between glBegin/End(). * @@ -960,8 +961,11 @@ _mesa_alloc_dispatch_table(void) * assertion passes and the test continues. */ SET_Flush(table, nop_glFlush); -#endif } +#endif + + _glapi_set_nop_handler(nop_handler); + return table; } diff --git a/src/mesa/main/context.h b/src/mesa/main/context.h index d565087..1cd89a8 100644 --- a/src/mesa/main/context.h +++ b/src/mesa/main/context.h @@ -175,9 +175,6 @@ _mesa_finish(struct gl_context *ctx); extern void _mesa_flush(struct gl_context *ctx); -extern int -_mesa_generic_nop(void); - extern void GLAPIENTRY _mesa_Finish( void ); diff --git a/src/mesa/main/tests/dispatch_sanity.cpp b/src/mesa/main/tests/dispatch_sanity.cpp index 5d849d4..59ebb21 100644 --- a/src/mesa/main/tests/dispatch_sanity.cpp +++ b/src/mesa/main/tests/dispatch_sanity.cpp @@ -119,20 +119,14 @@ offset_to_proc_name_safe(unsigned offset) } /* Scan through the dispatch table and check that all the functions in - * _glapi_proc *table exist. When found, set their pointers in the table - * to _mesa_generic_nop. */ + * _glapi_proc *table exist. + */ static void validate_functions(struct gl_context *ctx, const struct function *function_table) { _glapi_proc *table = (_glapi_proc *) ctx->Exec; for (unsigned i = 0; function_table[i].name != NULL; i++) { - /* The context version is >= the GL version where the - function was introduced. Therefore, the function cannot - be set to the nop function. - */ - bool cant_be_nop = ctx->Version >= function_table[i].Version; - const int offset = (function_table[i].offset != -1) ? function_table[i].offset : _glapi_get_proc_offset(function_table[i].name); @@ -142,27 +136,6 @@ validate_functions(struct gl_context *ctx, const struct function *function_table ASSERT_EQ(offset, _glapi_get_proc_offset(function_table[i].name)) << "Function: " << function_table[i].name; - if (cant_be_nop) { - EXPECT_NE((_glapi_proc) _mesa_generic_nop, table[offset]) - << "Function: " << function_table[i].name - << " at offset " << offset; - } - - table[offset] = (_glapi_proc) _mesa_generic_nop; - } -} - -/* Scan through the table and ensure that there is nothing except - * _mesa_generic_nop (as set by validate_functions(). */ -static void -validate_nops(struct gl_context *ctx) -{ - _glapi_proc *table = (_glapi_proc *) ctx->Exec; - - const unsigned size = _glapi_get_dispatch_table_size(); - for (unsigned i = 0; i < size; i++) { - EXPECT_EQ((_glapi_proc) _mesa_generic_nop, table[i]) - << "i = " << i << " (" << offset_to_proc_name_safe(i) << ")"; } } @@ -170,21 +143,18 @@ TEST_F(DispatchSanity_test, GL31_CORE) { SetUpCtx(API_OPENGL_CORE, 31); validate_functions(&ctx, gl_core_functions_possible); - validate_nops(&ctx); } TEST_F(DispatchSanity_test, GLES11) { SetUpCtx(API_OPENGLES, 11); validate_functions(&ctx, gles11_functions_possible); - validate_nops(&ctx); } TEST_F(DispatchSanity_test, GLES2) { SetUpCtx(API_OPENGLES2, 20); validate_functions(&ctx, gles2_functions_possible); - validate_nops(&ctx); } TEST_F(DispatchSanity_test, GLES3) @@ -192,7 +162,6 @@ TEST_F(DispatchSanity_test, GLES3) SetUpCtx(API_OPENGLES2, 30); validate_functions(&ctx, gles2_functions_possible); validate_functions(&ctx, gles3_functions_possible); - validate_nops(&ctx); } const struct function gl_core_functions_possible[] = { From brianp at kemper.freedesktop.org Wed Mar 18 15:50:18 2015 From: brianp at kemper.freedesktop.org (Brian Paul) Date: Wed, 18 Mar 2015 08:50:18 -0700 (PDT) Subject: Mesa (master): mesa: add void to format_array_format_table_init() declaration Message-ID: <20150318155018.F041176246@kemper.freedesktop.org> Module: Mesa Branch: master Commit: ea1b066a34dccd3bf1fe8bba52a586fff4158601 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=ea1b066a34dccd3bf1fe8bba52a586fff4158601 Author: Brian Paul Date: Tue Mar 17 11:50:35 2015 -0600 mesa: add void to format_array_format_table_init() declaration Silences an MSVC warning where it's called from call_once(). Reviewed-by: Matt Turner --- src/mesa/main/formats.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesa/main/formats.c b/src/mesa/main/formats.c index 422c9dc..2bc8bca 100644 --- a/src/mesa/main/formats.c +++ b/src/mesa/main/formats.c @@ -388,7 +388,7 @@ array_formats_equal(const void *a, const void *b) } static void -format_array_format_table_init() +format_array_format_table_init(void) { const struct gl_format_info *info; mesa_array_format array_format; From brianp at kemper.freedesktop.org Wed Mar 18 18:46:26 2015 From: brianp at kemper.freedesktop.org (Brian Paul) Date: Wed, 18 Mar 2015 11:46:26 -0700 (PDT) Subject: Mesa (master): dri: add _glapi_set_nop_handler(), _glapi_new_nop_table() to dri_test.c Message-ID: <20150318184626.6CC9E76246@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 627991dbf74ce5aee9ce75155fc27a429bdd0548 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=627991dbf74ce5aee9ce75155fc27a429bdd0548 Author: Brian Paul Date: Wed Mar 18 12:25:03 2015 -0600 dri: add _glapi_set_nop_handler(), _glapi_new_nop_table() to dri_test.c I wasn't aware of these _glapi_ stub functions when I committed 4bdbb588a9d385509f9168e38bfdb76952ba469c. Fixes "make check" Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=89662 Reviewed-by: Mark Janes --- src/mesa/drivers/dri/common/dri_test.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/mesa/drivers/dri/common/dri_test.c b/src/mesa/drivers/dri/common/dri_test.c index 7ab50d9..57bfa5b 100644 --- a/src/mesa/drivers/dri/common/dri_test.c +++ b/src/mesa/drivers/dri/common/dri_test.c @@ -76,6 +76,17 @@ _glapi_get_dispatch_table_size(void) return 0; } +PUBLIC void +_glapi_set_nop_handler(_glapi_nop_handler_proc func) +{ +} + +PUBLIC struct _glapi_table * +_glapi_new_nop_table(unsigned num_entries) +{ + return NULL; +} + #ifndef NO_MAIN int main(int argc, char** argv) { From ldeks at kemper.freedesktop.org Wed Mar 18 21:00:03 2015 From: ldeks at kemper.freedesktop.org (Laura Ekstrand) Date: Wed, 18 Mar 2015 14:00:03 -0700 (PDT) Subject: Mesa (master): docs: Update progress on ARB_direct_state_access. Message-ID: <20150318210003.27DB876246@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 2ccfce3f4ce72e1ae3e85c44193b3343e23572d8 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=2ccfce3f4ce72e1ae3e85c44193b3343e23572d8 Author: Laura Ekstrand Date: Wed Mar 18 13:26:31 2015 -0700 docs: Update progress on ARB_direct_state_access. Acked-by: Matt Turner --- docs/GL3.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/GL3.txt b/docs/GL3.txt index 0d37240..93fa60d 100644 --- a/docs/GL3.txt +++ b/docs/GL3.txt @@ -194,10 +194,10 @@ GL 4.5, GLSL 4.50: GL_ARB_derivative_control DONE (i965, nv50, nvc0, r600) GL_ARB_direct_state_access started - Transform Feedback object started (Martin Peres) - - Buffer object started (Laura Ekstrand) + - Buffer object DONE - Framebuffer object started (Laura Ekstrand) - Renderbuffer object started (Martin Peres) - - Texture object started (Laura Ekstrand) + - Texture object DONE - Vertex array object started (Fredrik H?glund) - Sampler object started (Martin Peres) - Program Pipeline object started (Martin Peres) From jrfonseca at kemper.freedesktop.org Wed Mar 18 21:52:04 2015 From: jrfonseca at kemper.freedesktop.org (Jose Fonseca) Date: Wed, 18 Mar 2015 14:52:04 -0700 (PDT) Subject: Mesa (master): gallivm: Use INFINITY directly. Message-ID: <20150318215204.70B8576359@kemper.freedesktop.org> Module: Mesa Branch: master Commit: a56f1a8b32a2cafdd4e46c0d48a1a252d0e3c0ae URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=a56f1a8b32a2cafdd4e46c0d48a1a252d0e3c0ae Author: Jose Fonseca Date: Wed Mar 18 14:19:10 2015 +0000 gallivm: Use INFINITY directly. Already done below. Reviewed-by: Brian Paul --- src/gallium/auxiliary/gallivm/lp_bld_arit.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/gallium/auxiliary/gallivm/lp_bld_arit.c b/src/gallium/auxiliary/gallivm/lp_bld_arit.c index cd05f11..0d4eaea 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_arit.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_arit.c @@ -2564,16 +2564,9 @@ lp_build_rsqrt(struct lp_build_context *bld, * All numbers smaller than FLT_MIN will result in +infinity * (rsqrtps treats all denormals as zero). */ - /* - * Certain non-c99 compilers don't know INFINITY and might not support - * hacks to evaluate it at compile time neither. - */ - const unsigned posinf_int = 0x7F800000; LLVMValueRef cmp; LLVMValueRef flt_min = lp_build_const_vec(bld->gallivm, type, FLT_MIN); - LLVMValueRef inf = lp_build_const_int_vec(bld->gallivm, type, posinf_int); - - inf = LLVMBuildBitCast(builder, inf, lp_build_vec_type(bld->gallivm, type), ""); + LLVMValueRef inf = lp_build_const_vec(bld->gallivm, type, INFINITY); for (i = 0; i < num_iterations; ++i) { res = lp_build_rsqrt_refine(bld, a, res); From jrfonseca at kemper.freedesktop.org Wed Mar 18 21:52:04 2015 From: jrfonseca at kemper.freedesktop.org (Jose Fonseca) Date: Wed, 18 Mar 2015 14:52:04 -0700 (PDT) Subject: Mesa (master): scons: Don't link program_lexer.l/y twice. Message-ID: <20150318215204.796EA76246@kemper.freedesktop.org> Module: Mesa Branch: master Commit: d3e9aa8d88e6684235bb0be549551d1402ef8881 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=d3e9aa8d88e6684235bb0be549551d1402ef8881 Author: Jose Fonseca Date: Wed Mar 18 14:22:41 2015 +0000 scons: Don't link program_lexer.l/y twice. program/lex.yy.c and program/program_parse.tab.c is already included in the PROGRAM_FILES variable. We still need to specify the dependency relationship though. Reviewed-by: Brian Paul --- src/mesa/SConscript | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/mesa/SConscript b/src/mesa/SConscript index 81939f9..cc5d242 100644 --- a/src/mesa/SConscript +++ b/src/mesa/SConscript @@ -40,17 +40,12 @@ else: source_lists = env.ParseSourceList('Makefile.sources') env.Append(YACCFLAGS = '-d -p "_mesa_program_"') -program_lex = env.CFile('program/lex.yy.c', 'program/program_lexer.l') -program_parse = env.CFile('program/program_parse.tab.c', - 'program/program_parse.y') -program_sources = source_lists['PROGRAM_FILES'] + [ - program_lex, - program_parse[0], -] +env.CFile('program/lex.yy.c', 'program/program_lexer.l') +env.CFile('program/program_parse.tab.c', 'program/program_parse.y') mesa_sources = ( source_lists['MESA_FILES'] + - program_sources + + source_lists['PROGRAM_FILES'] + source_lists['STATETRACKER_FILES'] ) From jrfonseca at kemper.freedesktop.org Wed Mar 18 21:52:04 2015 From: jrfonseca at kemper.freedesktop.org (Jose Fonseca) Date: Wed, 18 Mar 2015 14:52:04 -0700 (PDT) Subject: Mesa (master): scons: Silence MSVC warnings about overflows in constant arithmetic. Message-ID: <20150318215204.65334760B4@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 1d30fd85dd2a240d4ccafc9a9eca55a129306cf5 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=1d30fd85dd2a240d4ccafc9a9eca55a129306cf5 Author: Jose Fonseca Date: Wed Mar 18 14:18:28 2015 +0000 scons: Silence MSVC warnings about overflows in constant arithmetic. These get triggered even when using the standard C99 INFINITY/NAN constants. Reviewed-by: Brian Paul --- scons/gallium.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scons/gallium.py b/scons/gallium.py index 9d53848..b4018e7 100755 --- a/scons/gallium.py +++ b/scons/gallium.py @@ -495,8 +495,10 @@ def generate(env): ccflags += [ '/W3', # warning level '/wd4018', # signed/unsigned mismatch + '/wd4056', # overflow in floating-point constant arithmetic '/wd4244', # conversion from 'type1' to 'type2', possible loss of data '/wd4305', # truncation from 'type1' to 'type2' + '/wd4756', # overflow in constant arithmetic '/wd4800', # forcing value to bool 'true' or 'false' (performance warning) '/wd4996', # disable deprecated POSIX name warnings ] From jrfonseca at kemper.freedesktop.org Wed Mar 18 21:52:04 2015 From: jrfonseca at kemper.freedesktop.org (Jose Fonseca) Date: Wed, 18 Mar 2015 14:52:04 -0700 (PDT) Subject: Mesa (master): swrast: Use BITFIELD64_BIT for arrayAttribs. Message-ID: <20150318215204.837E476246@kemper.freedesktop.org> Module: Mesa Branch: master Commit: cebc62f1060c815e3b5a1bd3728c3d909db3d2b8 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=cebc62f1060c815e3b5a1bd3728c3d909db3d2b8 Author: Jose Fonseca Date: Wed Mar 18 14:25:19 2015 +0000 swrast: Use BITFIELD64_BIT for arrayAttribs. As VARYING_SLOT_MAX can be bigger than 32. I'll probably stop building swrast with MSVC in the near future, but this seems a real bug regardless. Reviewed-by: Brian Paul --- src/mesa/swrast/s_span.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesa/swrast/s_span.c b/src/mesa/swrast/s_span.c index 5d618f0..e304b6b 100644 --- a/src/mesa/swrast/s_span.c +++ b/src/mesa/swrast/s_span.c @@ -788,7 +788,7 @@ clip_span( struct gl_context *ctx, SWspan *span ) memmove(ARRAY, ARRAY + (SHIFT), (LEN) * sizeof(ARRAY[0])) for (i = 0; i < VARYING_SLOT_MAX; i++) { - if (span->arrayAttribs & (1 << i)) { + if (span->arrayAttribs & BITFIELD64_BIT(i)) { /* shift array elements left by 'leftClip' */ SHIFT_ARRAY(span->array->attribs[i], leftClip, n - leftClip); } From jrfonseca at kemper.freedesktop.org Wed Mar 18 21:52:04 2015 From: jrfonseca at kemper.freedesktop.org (Jose Fonseca) Date: Wed, 18 Mar 2015 14:52:04 -0700 (PDT) Subject: Mesa (master): scons: Disable MSVC signed/unsigned mismatch warnings. Message-ID: <20150318215204.5B4CB76246@kemper.freedesktop.org> Module: Mesa Branch: master Commit: bbac03ecca51fdbedf3c569c68322043c8e93fae URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=bbac03ecca51fdbedf3c569c68322043c8e93fae Author: Jos? Fonseca Date: Tue Nov 25 22:27:04 2014 +0000 scons: Disable MSVC signed/unsigned mismatch warnings. By default gcc ignores the issue, and as result code that mixes signed/unsigned is so widespread through the code base that it ends up being little more than noise, potentially obscuring more pertinent warnings. Maybe one day we enable the corresponding gcc warnings and cleanup, but until then, this change disables them. Reviewed-by: Brian Paul Reviewed-by: Roland Scheidegger --- scons/gallium.py | 1 + 1 file changed, 1 insertion(+) diff --git a/scons/gallium.py b/scons/gallium.py index b162089..9d53848 100755 --- a/scons/gallium.py +++ b/scons/gallium.py @@ -494,6 +494,7 @@ def generate(env): ] ccflags += [ '/W3', # warning level + '/wd4018', # signed/unsigned mismatch '/wd4244', # conversion from 'type1' to 'type2', possible loss of data '/wd4305', # truncation from 'type1' to 'type2' '/wd4800', # forcing value to bool 'true' or 'false' (performance warning) From airlied at kemper.freedesktop.org Wed Mar 18 22:29:13 2015 From: airlied at kemper.freedesktop.org (Dave Airlie) Date: Wed, 18 Mar 2015 15:29:13 -0700 (PDT) Subject: Mesa (master): egl: don't fill client apis string forever. Message-ID: <20150318222913.7A13976246@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 37e3a116f8ae09d0fa894d126d081a1af24ec14f URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=37e3a116f8ae09d0fa894d126d081a1af24ec14f Author: Dave Airlie Date: Mon Mar 16 15:21:55 2015 +1000 egl: don't fill client apis string forever. We never reset the string on eglTerminate, so it grows for ever on multiple eglInitialise. Reviewed-by: Brian Paul Reviewed-by: Matt Turner Signed-off-by: Dave Airlie --- src/egl/main/eglapi.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c index e224560..6031a7a 100644 --- a/src/egl/main/eglapi.c +++ b/src/egl/main/eglapi.c @@ -514,6 +514,7 @@ eglTerminate(EGLDisplay dpy) drv->API.Terminate(drv, disp); /* do not reset disp->Driver */ + disp->ClientAPIsString[0] = 0; disp->Initialized = EGL_FALSE; } From jekstrand at kemper.freedesktop.org Wed Mar 18 23:43:33 2015 From: jekstrand at kemper.freedesktop.org (Jason Ekstrand) Date: Wed, 18 Mar 2015 16:43:33 -0700 (PDT) Subject: Mesa (master): i965/nir: Make our environment variable checking smarter Message-ID: <20150318234333.18B4676246@kemper.freedesktop.org> Module: Mesa Branch: master Commit: e1f3ddef8c9928d9b8e845b811dc08983c541f99 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=e1f3ddef8c9928d9b8e845b811dc08983c541f99 Author: Jason Ekstrand Date: Tue Mar 17 12:10:58 2015 -0700 i965/nir: Make our environment variable checking smarter Before, we enabled NIR if you set INTEL_USE_NIR to anything which mean that INTEL_USE_NIR=false would actually turn on NIR. In preparation for turning NIR on by default, this commit makes it smarter by allowing the INTEL_USE_NIR variable to work as either a force-enable or a force-disable. Reviewed-by: Mark Janes --- src/mesa/drivers/dri/i965/brw_fs.cpp | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp index 53ceb29..3d4d31a 100644 --- a/src/mesa/drivers/dri/i965/brw_fs.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs.cpp @@ -3838,6 +3838,26 @@ fs_visitor::allocate_registers() prog_data->total_scratch = brw_get_scratch_size(last_scratch); } +static bool +env_var_as_boolean(const char *var_name, bool default_value) +{ + const char *str = getenv(var_name); + if (str == NULL) + return default_value; + + if (strcmp(str, "1") == 0 || + strcasecmp(str, "true") == 0 || + strcasecmp(str, "yes") == 0) { + return true; + } else if (strcmp(str, "0") == 0 || + strcasecmp(str, "false") == 0 || + strcasecmp(str, "no") == 0) { + return false; + } else { + return default_value; + } +} + bool fs_visitor::run_vs() { @@ -3849,7 +3869,7 @@ fs_visitor::run_vs() if (INTEL_DEBUG & DEBUG_SHADER_TIME) emit_shader_time_begin(); - if (getenv("INTEL_USE_NIR") != NULL) { + if (env_var_as_boolean("INTEL_USE_NIR", false)) { emit_nir_code(); } else { foreach_in_list(ir_instruction, ir, shader->base.ir) { @@ -3923,7 +3943,7 @@ fs_visitor::run_fs() * functions called "main"). */ if (shader) { - if (getenv("INTEL_USE_NIR") != NULL) { + if (env_var_as_boolean("INTEL_USE_NIR", false)) { emit_nir_code(); } else { foreach_in_list(ir_instruction, ir, shader->base.ir) { From evelikov at kemper.freedesktop.org Thu Mar 19 00:33:00 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Wed, 18 Mar 2015 17:33:00 -0700 (PDT) Subject: Mesa (10.4): freedreno: fix slice pitch calculations Message-ID: <20150319003300.733D276246@kemper.freedesktop.org> Module: Mesa Branch: 10.4 Commit: a563045009fe01689553c6e3db2b030cd074ce8a URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=a563045009fe01689553c6e3db2b030cd074ce8a Author: Ilia Mirkin Date: Fri Mar 13 01:36:57 2015 -0400 freedreno: fix slice pitch calculations For example if width were 65, the first slice would get 96 while the second would get 32. However the hardware appears to expect the second pitch to be 64, based on halving the 96 (and aligning up to 32). This fixes texelFetch piglit tests on a3xx below a certain size. Going higher they break again, but most likely due to unrelated reasons. Signed-off-by: Ilia Mirkin Cc: "10.4 10.5" Reviewed-by: Rob Clark (cherry picked from commit 620e29b74821fd75b24495ab2bfddea53fc75350) --- src/gallium/drivers/freedreno/freedreno_resource.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gallium/drivers/freedreno/freedreno_resource.c b/src/gallium/drivers/freedreno/freedreno_resource.c index 6b31d26..e9ec913 100644 --- a/src/gallium/drivers/freedreno/freedreno_resource.c +++ b/src/gallium/drivers/freedreno/freedreno_resource.c @@ -199,7 +199,7 @@ setup_slices(struct fd_resource *rsc) for (level = 0; level <= prsc->last_level; level++) { struct fd_resource_slice *slice = fd_resource_slice(rsc, level); - slice->pitch = align(width, 32); + slice->pitch = width = align(width, 32); slice->offset = size; slice->size0 = slice->pitch * height * rsc->cpp; From evelikov at kemper.freedesktop.org Thu Mar 19 00:33:00 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Wed, 18 Mar 2015 17:33:00 -0700 (PDT) Subject: Mesa (10.4): loader: include for non-sysfs builds Message-ID: <20150319003300.891FE76246@kemper.freedesktop.org> Module: Mesa Branch: 10.4 Commit: df2db2a55fc097d1ecb5ec48e1187542be2beee9 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=df2db2a55fc097d1ecb5ec48e1187542be2beee9 Author: Emil Velikov Date: Wed Mar 11 19:12:35 2015 +0000 loader: include for non-sysfs builds Required by fstat(), otherwise we'll error out due to implicit function declaration. Cc: "10.4 10.5" Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=89530 Signed-off-by: Emil Velikov Reported-by: Vadim Rutkovsky Tested-by: Vadim Rutkovsky (cherry picked from commit 771cd266b9d00bdcf2cf7acaa3c8363c358d7478) --- src/loader/loader.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/loader/loader.c b/src/loader/loader.c index 94c993a..638ebf2 100644 --- a/src/loader/loader.c +++ b/src/loader/loader.c @@ -64,6 +64,7 @@ * Rob Clark */ +#include #include #include #include @@ -80,7 +81,6 @@ #endif #endif #ifdef HAVE_SYSFS -#include #include #endif #include "loader.h" From evelikov at kemper.freedesktop.org Thu Mar 19 00:33:00 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Wed, 18 Mar 2015 17:33:00 -0700 (PDT) Subject: Mesa (10.4): glx: Handle out-of-sequence swap completion events correctly. (v2) Message-ID: <20150319003300.9BEF476246@kemper.freedesktop.org> Module: Mesa Branch: 10.4 Commit: 70832be2f1357edafeeafa5fe8c96792da4dfd7b URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=70832be2f1357edafeeafa5fe8c96792da4dfd7b Author: Mario Kleiner Date: Thu Mar 12 20:34:06 2015 +0100 glx: Handle out-of-sequence swap completion events correctly. (v2) The code for emitting INTEL_swap_events swap completion events needs to translate from 32-Bit sbc on the wire to 64-Bit sbc for the events and handle wraparound accordingly. It assumed that events would be sent by the server in the order their corresponding swap requests were emitted from the client, iow. sbc count should be always increasing. This was correct for DRI2. This is not always the case under the DRI3/Present backend, where the Present extension can execute presents and send out completion events in a different order than the submission order of the present requests, due to client code specifying targetMSC target vblank counts which are not strictly monotonically increasing. This confused the wraparound handling. This patch fixes the problem by handling 32-Bit wraparound in both directions. As long as successive swap completion events real 64-Bit sbc's don't differ by more than 2^30, this should be able to do the right thing. How this is supposed to work: awire->sbc contains the low 32-Bits of the true 64-Bit sbc of the current swap event, transmitted over the wire. glxDraw->lastEventSbc contains the low 32-Bits of the 64-Bit sbc of the most recently processed swap event. glxDraw->eventSbcWrap is a 64-Bit offset which tracks the upper 32-Bits of the current sbc. The final 64-Bit output sbc aevent->sbc is computed from the sum of awire->sbc and glxDraw->eventSbcWrap. Under DRI3/Present, swap completion events can be received slightly out of order due to non-monotic targetMsc specified by client code, e.g., present request submission: Submission sbc: 1 2 3 targetMsc: 10 11 9 Reception of completion events: Completion sbc: 3 1 2 The completion sequence 3, 1, 2 would confuse the old wraparound handling made for DRI2 as 1 < 3 --> Assumes a 32-Bit wraparound has happened when it hasn't. The client can queue multiple present requests, in the case of Mesa up to n requests for n-buffered rendering, e.g., n = 2-4 in the current Mesa GLX DRI3/Present implementation. In the case of direct Pixmap presents via xcb_present_pixmap() the number n is limited by the amount of memory available. We reasonably assume that the number of outstanding requests n is much less than 2 billion due to memory contraints and common sense. Therefore while the order of received sbc's can be a bit scrambled, successive 64-Bit sbc's won't deviate by much, a given sbc may be a few counts lower or higher than the previous received sbc. Therefore any large difference between the incoming awire->sbc and the last recorded glxDraw->lastEventSbc will be due to 32-Bit wraparound and we need to adapt glxDraw->eventSbcWrap accordingly to adjust the upper 32-Bits of the sbc. Two cases, correponding to the two if-statements in the patch: a) Previous sbc event was below the last 2^32 boundary, in the previous glxDraw->eventSbcWrap epoch, the new sbc event is in the next 2^32 epoch, therefore the low 32-Bit awire->sbc wrapped around to zero, or close to zero --> awire->sbc is apparently much lower than the glxDraw->lastEventSbc recorded for the previous epoch --> We need to increment glxDraw->eventSbcWrap by 2^32 to adjust the current epoch to be one higher than the previous one. --> Case a) also handles the old DRI2 behaviour. b) Previous sbc event was above closest 2^32 boundary, but now a late event from the previous 2^32 epoch arrives, with a true sbc that belongs to the previous 2^32 segment, so the awire->sbc of this late event has a high count close to 2^32, whereas glxDraw->lastEventSbc is closer to zero --> awire->sbc is much greater than glXDraw->lastEventSbc. --> We need to decrement glxDraw->eventSbcWrap by 2^32 to adjust the current epoch back to the previous lower epoch of this late completion event. We assume such a wraparound to a higher (a) epoch or lower (b) epoch has happened if awire->sbc and glxDraw->lastEventSbc differ by more than 2^30 counts, as such a difference can only happen on wraparound, or if somehow 2^30 present requests would be pending for a given drawable inside the server, which is rather unlikely. v2: Explain the reason for this patch and the new wraparound handling much more extensive in commit message, no code change wrt. initial version. Cc: "10.3 10.4 10.5" Signed-off-by: Mario Kleiner Reviewed-by: Michel D?nzer (cherry picked from commit cc5ddd584d17abd422ae4d8e83805969485740d9) --- src/glx/glxext.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/glx/glxext.c b/src/glx/glxext.c index 68c359e..fdc24d4 100644 --- a/src/glx/glxext.c +++ b/src/glx/glxext.c @@ -143,8 +143,13 @@ __glXWireToEvent(Display *dpy, XEvent *event, xEvent *wire) aevent->ust = ((CARD64)awire->ust_hi << 32) | awire->ust_lo; aevent->msc = ((CARD64)awire->msc_hi << 32) | awire->msc_lo; - if (awire->sbc < glxDraw->lastEventSbc) - glxDraw->eventSbcWrap += 0x100000000; + /* Handle 32-Bit wire sbc wraparound in both directions to cope with out + * of sequence 64-Bit sbc's + */ + if ((int64_t) awire->sbc < ((int64_t) glxDraw->lastEventSbc - 0x40000000)) + glxDraw->eventSbcWrap += 0x100000000; + if ((int64_t) awire->sbc > ((int64_t) glxDraw->lastEventSbc + 0x40000000)) + glxDraw->eventSbcWrap -= 0x100000000; glxDraw->lastEventSbc = awire->sbc; aevent->sbc = awire->sbc + glxDraw->eventSbcWrap; return True; From evelikov at kemper.freedesktop.org Thu Mar 19 00:33:00 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Wed, 18 Mar 2015 17:33:00 -0700 (PDT) Subject: Mesa (10.4): radeonsi: increase coords array size for radeon_llvm_emit_prepare_cube_coords Message-ID: <20150319003300.ACADF76246@kemper.freedesktop.org> Module: Mesa Branch: 10.4 Commit: 832c94a55c50bd3d05c17d2651ede6d3859095c2 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=832c94a55c50bd3d05c17d2651ede6d3859095c2 Author: Marek Ol??k Date: Tue Mar 17 17:47:17 2015 +0100 radeonsi: increase coords array size for radeon_llvm_emit_prepare_cube_coords radeon_llvm_emit_prepare_cube_coords uses coords[4] in some cases (TXB2 etc.) Discovered by Coverity. Reported by Ilia Mirkin. Cc: 10.5 10.4 Reviewed-by: Michel D?nzer (cherry picked from commit a984abdad39df2d8ceb4c46e11f4ce1344c36c86) --- src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c | 2 +- src/gallium/drivers/radeonsi/si_shader.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c b/src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c index c30a9d0..1f1484d 100644 --- a/src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c +++ b/src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c @@ -748,7 +748,7 @@ static void txp_fetch_args( const struct tgsi_full_instruction * inst = emit_data->inst; LLVMValueRef src_w; unsigned chan; - LLVMValueRef coords[4]; + LLVMValueRef coords[5]; emit_data->dst_type = LLVMVectorType(bld_base->base.elem_type, 4); src_w = lp_build_emit_fetch(bld_base, emit_data->inst, 0, TGSI_CHAN_W); diff --git a/src/gallium/drivers/radeonsi/si_shader.c b/src/gallium/drivers/radeonsi/si_shader.c index c15e8111..19e1781 100644 --- a/src/gallium/drivers/radeonsi/si_shader.c +++ b/src/gallium/drivers/radeonsi/si_shader.c @@ -1505,7 +1505,7 @@ static void tex_fetch_args( const struct tgsi_full_instruction * inst = emit_data->inst; unsigned opcode = inst->Instruction.Opcode; unsigned target = inst->Texture.Texture; - LLVMValueRef coords[4]; + LLVMValueRef coords[5]; LLVMValueRef address[16]; int ref_pos; unsigned num_coords = tgsi_util_get_texture_coord_dim(target, &ref_pos); From evelikov at kemper.freedesktop.org Thu Mar 19 00:33:00 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Wed, 18 Mar 2015 17:33:00 -0700 (PDT) Subject: Mesa (10.4): glsl: optimize (0 cmp x + y) into (-x cmp y). Message-ID: <20150319003300.68D7F76246@kemper.freedesktop.org> Module: Mesa Branch: 10.4 Commit: b2e243f70c5395c1002bcc6104b060b05584adbc URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=b2e243f70c5395c1002bcc6104b060b05584adbc Author: Samuel Iglesias Gonsalvez Date: Tue Feb 24 19:02:57 2015 +0100 glsl: optimize (0 cmp x + y) into (-x cmp y). The optimization done by commit 34ec1a24d did not take it into account. Fixes: dEQP-GLES3.functional.shaders.random.all_features.fragment.20 Signed-off-by: Samuel Iglesias Gonsalvez Reviewed-by: Ian Romanick Reviewed-by: Matt Turner Cc: "10.4 10.5" (cherry picked from commit b43bbfa90ace596c8b2e0b3954a5f69924726c59) --- src/glsl/opt_algebraic.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/glsl/opt_algebraic.cpp b/src/glsl/opt_algebraic.cpp index 87bb875..e94e072 100644 --- a/src/glsl/opt_algebraic.cpp +++ b/src/glsl/opt_algebraic.cpp @@ -578,9 +578,18 @@ ir_algebraic_visitor::handle_expression(ir_expression *ir) if (!is_vec_zero(zero)) continue; - return new(mem_ctx) ir_expression(ir->operation, - add->operands[0], - neg(add->operands[1])); + /* Depending of the zero position we want to optimize + * (0 cmp x+y) into (-x cmp y) or (x+y cmp 0) into (x cmp -y) + */ + if (add_pos == 1) { + return new(mem_ctx) ir_expression(ir->operation, + neg(add->operands[0]), + add->operands[1]); + } else { + return new(mem_ctx) ir_expression(ir->operation, + add->operands[0], + neg(add->operands[1])); + } } break; From evelikov at kemper.freedesktop.org Thu Mar 19 00:33:00 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Wed, 18 Mar 2015 17:33:00 -0700 (PDT) Subject: Mesa (10.4): freedreno: update generated headers Message-ID: <20150319003300.7D46776246@kemper.freedesktop.org> Module: Mesa Branch: 10.4 Commit: 0506f69f08dba612e5dc4d3334b78f3a2d4ee5ba URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=0506f69f08dba612e5dc4d3334b78f3a2d4ee5ba Author: Rob Clark Date: Sun Mar 15 17:59:01 2015 -0400 freedreno: update generated headers Fix a3xx texture layer-size. Signed-off-by: Rob Clark Cc: "10.4 10.5" (cherry picked from commit e92bc6b38e90339a394e95a562bcce35c3ee9696) [Emil Velikov: sqush trivial conflicts, drop the a4xx.xml.h changes] Signed-off-by: Emil Velikov Conflicts: src/gallium/drivers/freedreno/a2xx/a2xx.xml.h src/gallium/drivers/freedreno/a3xx/a3xx.xml.h src/gallium/drivers/freedreno/a4xx/a4xx.xml.h src/gallium/drivers/freedreno/adreno_common.xml.h src/gallium/drivers/freedreno/adreno_pm4.xml.h --- src/gallium/drivers/freedreno/a2xx/a2xx.xml.h | 2 +- src/gallium/drivers/freedreno/a3xx/a3xx.xml.h | 4 ++-- src/gallium/drivers/freedreno/adreno_common.xml.h | 2 +- src/gallium/drivers/freedreno/adreno_pm4.xml.h | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/gallium/drivers/freedreno/a2xx/a2xx.xml.h b/src/gallium/drivers/freedreno/a2xx/a2xx.xml.h index e8c54d0..e185827 100644 --- a/src/gallium/drivers/freedreno/a2xx/a2xx.xml.h +++ b/src/gallium/drivers/freedreno/a2xx/a2xx.xml.h @@ -13,7 +13,7 @@ The rules-ng-ng source files this header was generated from are: - /home/robclark/src/freedreno/envytools/rnndb/adreno/a2xx.xml ( 32901 bytes, from 2014-06-02 15:21:30) - /home/robclark/src/freedreno/envytools/rnndb/adreno/adreno_common.xml ( 10347 bytes, from 2014-10-01 18:55:57) - /home/robclark/src/freedreno/envytools/rnndb/adreno/adreno_pm4.xml ( 14960 bytes, from 2014-07-27 17:22:13) -- /home/robclark/src/freedreno/envytools/rnndb/adreno/a3xx.xml ( 60533 bytes, from 2014-10-15 18:32:43) +- /home/robclark/src/freedreno/envytools/rnndb/adreno/a3xx.xml ( 64771 bytes, from 2015-03-15 21:55:57) - /home/robclark/src/freedreno/envytools/rnndb/adreno/a4xx.xml ( 41068 bytes, from 2014-08-01 12:22:48) Copyright (C) 2013-2014 by the following authors: diff --git a/src/gallium/drivers/freedreno/a3xx/a3xx.xml.h b/src/gallium/drivers/freedreno/a3xx/a3xx.xml.h index ef3971c..8435b43 100644 --- a/src/gallium/drivers/freedreno/a3xx/a3xx.xml.h +++ b/src/gallium/drivers/freedreno/a3xx/a3xx.xml.h @@ -13,7 +13,7 @@ The rules-ng-ng source files this header was generated from are: - /home/robclark/src/freedreno/envytools/rnndb/adreno/a2xx.xml ( 32901 bytes, from 2014-06-02 15:21:30) - /home/robclark/src/freedreno/envytools/rnndb/adreno/adreno_common.xml ( 10347 bytes, from 2014-10-01 18:55:57) - /home/robclark/src/freedreno/envytools/rnndb/adreno/adreno_pm4.xml ( 14960 bytes, from 2014-07-27 17:22:13) -- /home/robclark/src/freedreno/envytools/rnndb/adreno/a3xx.xml ( 60533 bytes, from 2014-10-15 18:32:43) +- /home/robclark/src/freedreno/envytools/rnndb/adreno/a3xx.xml ( 64771 bytes, from 2015-03-15 21:55:57) - /home/robclark/src/freedreno/envytools/rnndb/adreno/a4xx.xml ( 41068 bytes, from 2014-08-01 12:22:48) Copyright (C) 2013-2014 by the following authors: @@ -2572,7 +2572,7 @@ static inline uint32_t A3XX_TEX_CONST_2_SWAP(enum a3xx_color_swap val) } #define REG_A3XX_TEX_CONST_3 0x00000003 -#define A3XX_TEX_CONST_3_LAYERSZ1__MASK 0x0000000f +#define A3XX_TEX_CONST_3_LAYERSZ1__MASK 0x00001fff #define A3XX_TEX_CONST_3_LAYERSZ1__SHIFT 0 static inline uint32_t A3XX_TEX_CONST_3_LAYERSZ1(uint32_t val) { diff --git a/src/gallium/drivers/freedreno/adreno_common.xml.h b/src/gallium/drivers/freedreno/adreno_common.xml.h index ac53281..ad77061 100644 --- a/src/gallium/drivers/freedreno/adreno_common.xml.h +++ b/src/gallium/drivers/freedreno/adreno_common.xml.h @@ -13,7 +13,7 @@ The rules-ng-ng source files this header was generated from are: - /home/robclark/src/freedreno/envytools/rnndb/adreno/a2xx.xml ( 32901 bytes, from 2014-06-02 15:21:30) - /home/robclark/src/freedreno/envytools/rnndb/adreno/adreno_common.xml ( 10347 bytes, from 2014-10-01 18:55:57) - /home/robclark/src/freedreno/envytools/rnndb/adreno/adreno_pm4.xml ( 14960 bytes, from 2014-07-27 17:22:13) -- /home/robclark/src/freedreno/envytools/rnndb/adreno/a3xx.xml ( 60533 bytes, from 2014-10-15 18:32:43) +- /home/robclark/src/freedreno/envytools/rnndb/adreno/a3xx.xml ( 64771 bytes, from 2015-03-15 21:55:57) - /home/robclark/src/freedreno/envytools/rnndb/adreno/a4xx.xml ( 41068 bytes, from 2014-08-01 12:22:48) Copyright (C) 2013-2014 by the following authors: diff --git a/src/gallium/drivers/freedreno/adreno_pm4.xml.h b/src/gallium/drivers/freedreno/adreno_pm4.xml.h index 8835601..69430bf 100644 --- a/src/gallium/drivers/freedreno/adreno_pm4.xml.h +++ b/src/gallium/drivers/freedreno/adreno_pm4.xml.h @@ -13,7 +13,7 @@ The rules-ng-ng source files this header was generated from are: - /home/robclark/src/freedreno/envytools/rnndb/adreno/a2xx.xml ( 32901 bytes, from 2014-06-02 15:21:30) - /home/robclark/src/freedreno/envytools/rnndb/adreno/adreno_common.xml ( 10347 bytes, from 2014-10-01 18:55:57) - /home/robclark/src/freedreno/envytools/rnndb/adreno/adreno_pm4.xml ( 14960 bytes, from 2014-07-27 17:22:13) -- /home/robclark/src/freedreno/envytools/rnndb/adreno/a3xx.xml ( 60533 bytes, from 2014-10-15 18:32:43) +- /home/robclark/src/freedreno/envytools/rnndb/adreno/a3xx.xml ( 64771 bytes, from 2015-03-15 21:55:57) - /home/robclark/src/freedreno/envytools/rnndb/adreno/a4xx.xml ( 41068 bytes, from 2014-08-01 12:22:48) Copyright (C) 2013-2014 by the following authors: From evelikov at kemper.freedesktop.org Thu Mar 19 00:33:00 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Wed, 18 Mar 2015 17:33:00 -0700 (PDT) Subject: Mesa (10.4): auxiliary/os: fix the android build - s/drm_munmap/os_munmap/ Message-ID: <20150319003300.923FE76246@kemper.freedesktop.org> Module: Mesa Branch: 10.4 Commit: ad259df2e0ada1ea5b3139f203c6fa6cb51bfca3 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=ad259df2e0ada1ea5b3139f203c6fa6cb51bfca3 Author: Emil Velikov Date: Mon Mar 16 15:00:18 2015 +0000 auxiliary/os: fix the android build - s/drm_munmap/os_munmap/ Squash this silly typo introduced with commit c63eb5dd5ec(auxiliary/os: get the mmap/munmap wrappers working with android) Cc: "10.4 10.5" Signed-off-by: Emil Velikov Reviewed-by: Brian Paul (cherry picked from commit 55f0c0a29f788c5df4820e81c0cf93613ccedf5e) --- src/gallium/auxiliary/os/os_mman.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gallium/auxiliary/os/os_mman.h b/src/gallium/auxiliary/os/os_mman.h index 19c9a5b..3fc8c43 100644 --- a/src/gallium/auxiliary/os/os_mman.h +++ b/src/gallium/auxiliary/os/os_mman.h @@ -70,8 +70,8 @@ static INLINE void *os_mmap(void *addr, size_t length, int prot, int flags, return __mmap2(addr, length, prot, flags, fd, (size_t) (offset >> 12)); } -# define drm_munmap(addr, length) \ - munmap(addr, length) +# define os_munmap(addr, length) \ + munmap(addr, length) #else /* assume large file support exists */ From mattst88 at kemper.freedesktop.org Thu Mar 19 04:03:48 2015 From: mattst88 at kemper.freedesktop.org (Matt Turner) Date: Wed, 18 Mar 2015 21:03:48 -0700 (PDT) Subject: Mesa (master): i965/fs: Ignore type in cmod prop if scan_inst is CMP. Message-ID: <20150319040348.91E1476246@kemper.freedesktop.org> Module: Mesa Branch: master Commit: bb22aa08e4b08c9688c5d5c6558ac01663d0163a URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=bb22aa08e4b08c9688c5d5c6558ac01663d0163a Author: Matt Turner Date: Tue Mar 17 19:17:15 2015 -0700 i965/fs: Ignore type in cmod prop if scan_inst is CMP. total instructions in shared programs: 6263270 -> 6203091 (-0.96%) instructions in affected programs: 2606529 -> 2546350 (-2.31%) helped: 14301 GAINED: 5 LOST: 3 Revewed-by: Jason Ekstrand --- .../drivers/dri/i965/brw_fs_cmod_propagation.cpp | 25 ++++++++++---------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_fs_cmod_propagation.cpp b/src/mesa/drivers/dri/i965/brw_fs_cmod_propagation.cpp index 1935f06..798fef3 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_cmod_propagation.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_cmod_propagation.cpp @@ -94,21 +94,22 @@ opt_cmod_propagation_local(bblock_t *block) scan_inst->dst.reg_offset != inst->src[0].reg_offset) break; - /* This must be done before the dst.type check because the result - * type of the AND will always be D, but the result of the CMP - * could be anything. The assumption is that the AND is just - * figuring out what the result of the previous comparison was - * instead of doing a new comparison with a different type. - */ - if (inst->opcode == BRW_OPCODE_AND) { - if (scan_inst->opcode == BRW_OPCODE_CMP) { - inst->remove(block); - progress = true; - } - + /* CMP's result is the same regardless of dest type. */ + if (inst->conditional_mod == BRW_CONDITIONAL_NZ && + scan_inst->opcode == BRW_OPCODE_CMP && + (inst->dst.type == BRW_REGISTER_TYPE_D || + inst->dst.type == BRW_REGISTER_TYPE_UD)) { + inst->remove(block); + progress = true; break; } + /* If the AND wasn't handled by the previous case, it isn't safe + * to remove it. + */ + if (inst->opcode == BRW_OPCODE_AND) + break; + /* Comparisons operate differently for ints and floats */ if (scan_inst->dst.type != inst->dst.type) break; From mattst88 at kemper.freedesktop.org Thu Mar 19 04:06:36 2015 From: mattst88 at kemper.freedesktop.org (Matt Turner) Date: Wed, 18 Mar 2015 21:06:36 -0700 (PDT) Subject: Mesa (master): util: Add a roundeven test. Message-ID: <20150319040636.9ADC67633A@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 5de86102f917d9f3a229daec8f107afb77246feb URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=5de86102f917d9f3a229daec8f107afb77246feb Author: Matt Turner Date: Thu Mar 12 11:34:05 2015 -0700 util: Add a roundeven test. Reviewed-by: Carl Worth --- src/util/Makefile.am | 4 +- src/util/roundeven_test.c | 140 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 143 insertions(+), 1 deletion(-) diff --git a/src/util/Makefile.am b/src/util/Makefile.am index ec49dc6..2e7542e 100644 --- a/src/util/Makefile.am +++ b/src/util/Makefile.am @@ -50,7 +50,9 @@ endif libmesautil_la_LIBADD = $(SHA1_LIBS) -check_PROGRAMS = u_atomic_test +roundeven_test_LDADD = -lm + +check_PROGRAMS = u_atomic_test roundeven_test TESTS = $(check_PROGRAMS) BUILT_SOURCES = $(MESA_UTIL_GENERATED_FILES) diff --git a/src/util/roundeven_test.c b/src/util/roundeven_test.c new file mode 100644 index 0000000..7526db1 --- /dev/null +++ b/src/util/roundeven_test.c @@ -0,0 +1,140 @@ +/* + * Copyright ? 2015 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 +#include +#include +#include + +#include "macros.h" +#include "rounding.h" + +int main(int argc, char *argv[]) +{ + const struct { + float input, expected; + } float_data[] = { + { 0.0, 0.0 }, + { nextafterf(0.5, 0.0), 0.0 }, + { 0.5, 0.0 }, + { nextafterf(0.5, 1.0), 1.0 }, + { 1.0, 1.0 }, + { nextafterf(1.5, 1.0), 1.0 }, + { 1.5, 2.0 }, + { nextafterf(1.5, 2.0), 2.0 }, + { 2.0, 2.0 }, + { nextafterf(2.5, 2.0), 2.0 }, + { 2.5, 2.0 }, + { nextafterf(2.5, 3.0), 3.0 }, + }; + + const struct { + double input, expected; + } double_data[] = { + { 0.0, 0.0 }, + { nextafter(0.5, 0.0), 0.0 }, + { 0.5, 0.0 }, + { nextafter(0.5, 1.0), 1.0 }, + { 1.0, 1.0 }, + { nextafter(1.5, 1.0), 1.0 }, + { 1.5, 2.0 }, + { nextafter(1.5, 2.0), 2.0 }, + { 2.0, 2.0 }, + { nextafter(2.5, 2.0), 2.0 }, + { 2.5, 2.0 }, + { nextafter(2.5, 3.0), 3.0 }, + }; + + bool failed = false; + int i; + + for (i = 0; i < ARRAY_SIZE(float_data); i++) { + float output = _mesa_roundevenf(float_data[i].input); + if (memcmp(&float_data[i].expected, &output, sizeof(float))) { + fprintf(stderr, "%d float: expected %f (%a) from " + "_mesa_roundevenf(%f (%a)) but got %f (%a)\n", + i, + float_data[i].expected, + float_data[i].expected, + float_data[i].input, + float_data[i].input, + output, + output); + failed = true; + } + } + + /* Test negated values */ + for (i = 0; i < ARRAY_SIZE(float_data); i++) { + float output = _mesa_roundevenf(-float_data[i].input); + float negated_expected = -float_data[i].expected; + if (memcmp(&negated_expected, &output, sizeof(float))) { + fprintf(stderr, "%d float: expected %f (%a) from " + "_mesa_roundevenf(%f (%a)) but got %f (%a)\n", + i, + negated_expected, + negated_expected, + -float_data[i].input, + -float_data[i].input, + output, + output); + failed = true; + } + } + + for (i = 0; i < ARRAY_SIZE(double_data); i++) { + double output = _mesa_roundeven(double_data[i].input); + if (memcmp(&double_data[i].expected, &output, sizeof(double))) { + fprintf(stderr, "%d double: expected %f (%a) from " + "_mesa_roundeven(%f (%a)) but got %f (%a)\n", + i, + double_data[i].expected, + double_data[i].expected, + double_data[i].input, + double_data[i].input, + output, + output); + failed = true; + } + } + + /* Test negated values */ + for (i = 0; i < ARRAY_SIZE(double_data); i++) { + double output = _mesa_roundeven(-double_data[i].input); + double negated_expected = -double_data[i].expected; + if (memcmp(&negated_expected, &output, sizeof(double))) { + fprintf(stderr, "%d double: expected %f (%a) from " + "_mesa_roundeven(%f (%a)) but got %f (%a)\n", + i, + negated_expected, + negated_expected, + -double_data[i].input, + -double_data[i].input, + output, + output); + failed = true; + } + } + + return failed; +} From mattst88 at kemper.freedesktop.org Thu Mar 19 04:06:36 2015 From: mattst88 at kemper.freedesktop.org (Matt Turner) Date: Wed, 18 Mar 2015 21:06:36 -0700 (PDT) Subject: Mesa (master): util: Optimize _mesa_roundeven with SSE 4.1. Message-ID: <20150319040636.A478076359@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 036e347f3c129bb547137aed955e75062fca09b8 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=036e347f3c129bb547137aed955e75062fca09b8 Author: Matt Turner Date: Wed Mar 18 14:23:41 2015 -0700 util: Optimize _mesa_roundeven with SSE 4.1. The SSE 4.1 ROUND instructions let us implement roundeven directly. Otherwise we assume that the rounding mode has not been modified (as we do in the rest of Mesa) and use rint(). glibc uses the ROUND instruction in rint() after a cpuid check. This patch just lets us inline it directly when we're already building for SSE 4.1. Reviewed-by: Carl Worth --- src/util/rounding.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/util/rounding.h b/src/util/rounding.h index c8be450..0cbe926 100644 --- a/src/util/rounding.h +++ b/src/util/rounding.h @@ -23,6 +23,10 @@ #include +#ifdef __SSE4_1__ +#include +#endif + /* The C standard library has functions round()/rint()/nearbyint() that round * their arguments according to the rounding mode set in the floating-point * control register. While there are trunc()/ceil()/floor() functions that do @@ -45,7 +49,15 @@ static inline float _mesa_roundevenf(float x) { +#ifdef __SSE4_1__ + float ret; + __m128 m = _mm_load_ss(&x); + m = _mm_round_ss(m, m, _MM_FROUND_CUR_DIRECTION | _MM_FROUND_NO_EXC); + _mm_store_ss(&ret, m); + return ret; +#else return rintf(x); +#endif } /** @@ -54,5 +66,13 @@ _mesa_roundevenf(float x) static inline double _mesa_roundeven(double x) { +#ifdef __SSE4_1__ + double ret; + __m128d m = _mm_load_sd(&x); + m = _mm_round_sd(m, m, _MM_FROUND_CUR_DIRECTION | _MM_FROUND_NO_EXC); + _mm_store_sd(&ret, m); + return ret; +#else return rint(x); +#endif } From mattst88 at kemper.freedesktop.org Thu Mar 19 04:06:36 2015 From: mattst88 at kemper.freedesktop.org (Matt Turner) Date: Wed, 18 Mar 2015 21:06:36 -0700 (PDT) Subject: Mesa (master): mesa: Replace _mesa_round_to_even() with _mesa_roundeven(). Message-ID: <20150319040636.92CE376246@kemper.freedesktop.org> Module: Mesa Branch: master Commit: dd0d3a2c0fb388745519c8a3be800720541eccfe URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=dd0d3a2c0fb388745519c8a3be800720541eccfe Author: Matt Turner Date: Tue Mar 10 17:55:21 2015 -0700 mesa: Replace _mesa_round_to_even() with _mesa_roundeven(). Eric's initial patch adding constant expression evaluation for ir_unop_round_even used nearbyint. The open-coded _mesa_round_to_even implementation came about without much explanation after a reviewer asked whether nearbyint depended on the application not modifying the rounding mode. Of course (as Eric commented) we rely on the application not changing the rounding mode from its default (round-to-nearest) in many other places, including the IROUND function used by _mesa_round_to_even! Worse, IROUND() is implemented using the trunc(x + 0.5) trick which fails for x = nextafterf(0.5, 0.0). Still worse, _mesa_round_to_even unexpectedly returns an int. I suspect that could cause problems when rounding large integral values not representable as an int in ir_constant_expression.cpp's ir_unop_round_even evaluation. Its use of _mesa_round_to_even is clearly broken for doubles (as noted during review). The constant expression evaluation code for the packing built-in functions also mistakenly assumed that _mesa_round_to_even returned a float, as can be seen by the cast through a signed integer type to an unsigned (since negative float -> unsigned conversions are undefined). rint() and nearbyint() implement the round-half-to-even behavior we want when the rounding mode is set to the default round-to-nearest. The only difference between them is that nearbyint() raises the inexact exception. This patch implements _mesa_roundeven{f,}, a function similar to the roundeven function added by a yet unimplemented technical specification (ISO/IEC TS 18661-1:2014), with a small difference in behavior -- we don't bother raising the inexact exception, which I don't think we care about anyway. At least recent Intel CPUs can quickly change a subset of the bits in the x87 floating-point control register, but the exception mask bits are not included. rint() does not need to change these bits, but nearbyint() does (twice: save old, set new, and restore old) in order to raise the inexact exception, which would incur some penalty. Reviewed-by: Carl Worth --- src/glsl/ir_constant_expression.cpp | 18 +++++----- src/glsl/nir/nir_constant_expressions.py | 15 ++++---- src/glsl/nir/nir_opcodes.py | 2 +- src/mesa/main/imports.c | 25 ++----------- src/mesa/main/imports.h | 3 -- src/util/Makefile.sources | 1 + src/util/rounding.h | 58 ++++++++++++++++++++++++++++++ 7 files changed, 82 insertions(+), 40 deletions(-) diff --git a/src/glsl/ir_constant_expression.cpp b/src/glsl/ir_constant_expression.cpp index 388c4c2..ecebc3c 100644 --- a/src/glsl/ir_constant_expression.cpp +++ b/src/glsl/ir_constant_expression.cpp @@ -35,6 +35,7 @@ #include #include "main/core.h" /* for MAX2, MIN2, CLAMP */ +#include "util/rounding.h" /* for _mesa_roundeven */ #include "ir.h" #include "glsl_types.h" #include "program/hash_table.h" @@ -245,8 +246,8 @@ pack_snorm_1x8(float x) * We must first cast the float to an int, because casting a negative * float to a uint is undefined. */ - return (uint8_t) (int8_t) - _mesa_round_to_even(CLAMP(x, -1.0f, +1.0f) * 127.0f); + return (uint8_t) (int) + _mesa_roundevenf(CLAMP(x, -1.0f, +1.0f) * 127.0f); } /** @@ -267,8 +268,8 @@ pack_snorm_1x16(float x) * We must first cast the float to an int, because casting a negative * float to a uint is undefined. */ - return (uint16_t) (int16_t) - _mesa_round_to_even(CLAMP(x, -1.0f, +1.0f) * 32767.0f); + return (uint16_t) (int) + _mesa_roundevenf(CLAMP(x, -1.0f, +1.0f) * 32767.0f); } /** @@ -322,7 +323,7 @@ pack_unorm_1x8(float x) * * packUnorm4x8: round(clamp(c, 0, +1) * 255.0) */ - return (uint8_t) _mesa_round_to_even(CLAMP(x, 0.0f, 1.0f) * 255.0f); + return (uint8_t) (int) _mesa_roundevenf(CLAMP(x, 0.0f, 1.0f) * 255.0f); } /** @@ -340,7 +341,8 @@ pack_unorm_1x16(float x) * * packUnorm2x16: round(clamp(c, 0, +1) * 65535.0) */ - return (uint16_t) _mesa_round_to_even(CLAMP(x, 0.0f, 1.0f) * 65535.0f); + return (uint16_t) (int) + _mesa_roundevenf(CLAMP(x, 0.0f, 1.0f) * 65535.0f); } /** @@ -733,9 +735,9 @@ ir_expression::constant_expression_value(struct hash_table *variable_context) case ir_unop_round_even: for (unsigned c = 0; c < op[0]->type->components(); c++) { if (op[0]->type->base_type == GLSL_TYPE_DOUBLE) - data.d[c] = _mesa_round_to_even(op[0]->value.d[c]); + data.d[c] = _mesa_roundeven(op[0]->value.d[c]); else - data.f[c] = _mesa_round_to_even(op[0]->value.f[c]); + data.f[c] = _mesa_roundevenf(op[0]->value.f[c]); } break; diff --git a/src/glsl/nir/nir_constant_expressions.py b/src/glsl/nir/nir_constant_expressions.py index 22bc4f0..bf82fe5 100644 --- a/src/glsl/nir/nir_constant_expressions.py +++ b/src/glsl/nir/nir_constant_expressions.py @@ -28,6 +28,7 @@ template = """\ #include #include "main/core.h" +#include "util/rounding.h" /* for _mesa_roundeven */ #include "nir_constant_expressions.h" #if defined(_MSC_VER) && (_MSC_VER < 1800) @@ -68,8 +69,8 @@ pack_snorm_1x8(float x) * We must first cast the float to an int, because casting a negative * float to a uint is undefined. */ - return (uint8_t) (int8_t) - _mesa_round_to_even(CLAMP(x, -1.0f, +1.0f) * 127.0f); + return (uint8_t) (int) + _mesa_roundevenf(CLAMP(x, -1.0f, +1.0f) * 127.0f); } /** @@ -90,8 +91,8 @@ pack_snorm_1x16(float x) * We must first cast the float to an int, because casting a negative * float to a uint is undefined. */ - return (uint16_t) (int16_t) - _mesa_round_to_even(CLAMP(x, -1.0f, +1.0f) * 32767.0f); + return (uint16_t) (int) + _mesa_roundevenf(CLAMP(x, -1.0f, +1.0f) * 32767.0f); } /** @@ -145,7 +146,8 @@ pack_unorm_1x8(float x) * * packUnorm4x8: round(clamp(c, 0, +1) * 255.0) */ - return (uint8_t) _mesa_round_to_even(CLAMP(x, 0.0f, 1.0f) * 255.0f); + return (uint8_t) (int) + _mesa_roundevenf(CLAMP(x, 0.0f, 1.0f) * 255.0f); } /** @@ -163,7 +165,8 @@ pack_unorm_1x16(float x) * * packUnorm2x16: round(clamp(c, 0, +1) * 65535.0) */ - return (uint16_t) _mesa_round_to_even(CLAMP(x, 0.0f, 1.0f) * 65535.0f); + return (uint16_t) (int) + _mesa_roundevenf(CLAMP(x, 0.0f, 1.0f) * 65535.0f); } /** diff --git a/src/glsl/nir/nir_opcodes.py b/src/glsl/nir/nir_opcodes.py index 77f3bb8..062cd62 100644 --- a/src/glsl/nir/nir_opcodes.py +++ b/src/glsl/nir/nir_opcodes.py @@ -183,7 +183,7 @@ unop("ftrunc", tfloat, "truncf(src0)") unop("fceil", tfloat, "ceilf(src0)") unop("ffloor", tfloat, "floorf(src0)") unop("ffract", tfloat, "src0 - floorf(src0)") -unop("fround_even", tfloat, "_mesa_round_to_even(src0)") +unop("fround_even", tfloat, "_mesa_roundevenf(src0)") # Trigonometric operations. diff --git a/src/mesa/main/imports.c b/src/mesa/main/imports.c index ac8deeb..68c7316 100644 --- a/src/mesa/main/imports.c +++ b/src/mesa/main/imports.c @@ -45,6 +45,7 @@ #include #include #include "c99_math.h" +#include "util/rounding.h" /* for _mesa_roundeven */ #include "imports.h" #include "context.h" #include "mtypes.h" @@ -307,26 +308,6 @@ _mesa_bitcount_64(uint64_t n) #endif -/* Using C99 rounding functions for roundToEven() implementation is - * difficult, because round(), rint, and nearbyint() are affected by - * fesetenv(), which the application may have done for its own - * purposes. Mesa's IROUND macro is close to what we want, but it - * rounds away from 0 on n + 0.5. - */ -int -_mesa_round_to_even(float val) -{ - int rounded = IROUND(val); - - if (val - floor(val) == 0.5) { - if (rounded % 2 != 0) - rounded += val > 0 ? -1 : 1; - } - - return rounded; -} - - /** * Convert a 4-byte float to a 2-byte half float. * @@ -388,7 +369,7 @@ _mesa_float_to_half(float val) * or normal. */ e = 0; - m = _mesa_round_to_even((1 << 24) * fabsf(fi.f)); + m = (int) _mesa_roundevenf((1 << 24) * fabsf(fi.f)); } else if (new_exp > 15) { /* map this value to infinity */ @@ -402,7 +383,7 @@ _mesa_float_to_half(float val) * either normal or infinite. */ e = new_exp + 15; - m = _mesa_round_to_even(flt_m / (float) (1 << 13)); + m = (int) _mesa_roundevenf(flt_m / (float) (1 << 13)); } } diff --git a/src/mesa/main/imports.h b/src/mesa/main/imports.h index ee6b399..29f2499 100644 --- a/src/mesa/main/imports.h +++ b/src/mesa/main/imports.h @@ -433,9 +433,6 @@ _mesa_fls(unsigned int n) #endif } -extern int -_mesa_round_to_even(float val); - extern GLhalfARB _mesa_float_to_half(float f); diff --git a/src/util/Makefile.sources b/src/util/Makefile.sources index 560ea83..3e0d02b 100644 --- a/src/util/Makefile.sources +++ b/src/util/Makefile.sources @@ -14,6 +14,7 @@ MESA_UTIL_FILES := \ register_allocate.h \ rgtc.c \ rgtc.h \ + rounding.h \ set.c \ set.h \ simple_list.h \ diff --git a/src/util/rounding.h b/src/util/rounding.h new file mode 100644 index 0000000..c8be450 --- /dev/null +++ b/src/util/rounding.h @@ -0,0 +1,58 @@ +/* + * Copyright ? 2015 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 + +/* The C standard library has functions round()/rint()/nearbyint() that round + * their arguments according to the rounding mode set in the floating-point + * control register. While there are trunc()/ceil()/floor() functions that do + * a specific operation without modifying the rounding mode, there is no + * roundeven() in any version of C. + * + * Technical Specification 18661 (ISO/IEC TS 18661-1:2014) adds roundeven(), + * but it's unfortunately not implemented by glibc. + * + * This implementation differs in that it does not raise the inexact exception. + * + * We use rint() to implement these functions, with the assumption that the + * floating-point rounding mode has not been changed from the default Round + * to Nearest. + */ + +/** + * \brief Rounds \c x to the nearest integer, with ties to the even integer. + */ +static inline float +_mesa_roundevenf(float x) +{ + return rintf(x); +} + +/** + * \brief Rounds \c x to the nearest integer, with ties to the even integer. + */ +static inline double +_mesa_roundeven(double x) +{ + return rint(x); +} From idr at kemper.freedesktop.org Thu Mar 19 17:32:00 2015 From: idr at kemper.freedesktop.org (Ian Romanick) Date: Thu, 19 Mar 2015 10:32:00 -0700 (PDT) Subject: Mesa (master): i965/fs: Emit better b2f of an expression on GEN4 and GEN5 Message-ID: <20150319173200.8B32A76333@kemper.freedesktop.org> Module: Mesa Branch: master Commit: b616164c95cb495ce43f6b61dc805ed911a85e89 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=b616164c95cb495ce43f6b61dc805ed911a85e89 Author: Ian Romanick Date: Fri Jan 23 17:31:12 2015 -0800 i965/fs: Emit better b2f of an expression on GEN4 and GEN5 On platforms that do not natively generate 0u and ~0u for Boolean results, b2f expressions that look like f = b2f(expr cmp 0) will generate better code by pretending the expression is f = ir_triop_sel(0.0, 1.0, expr cmp 0) This is because the last instruction of "expr" can generate the condition code for the "cmp 0". This avoids having to do the "-(b & 1)" trick to generate 0u or ~0u for the Boolean result. This means code like mov(16) g16<1>F 1F mul.ge.f0(16) null g6<8,8,1>F g14<8,8,1>F (+f0) sel(16) m6<1>F g16<8,8,1>F 0F will be generated instead of mul(16) g2<1>F g12<8,8,1>F g4<8,8,1>F cmp.ge.f0(16) g2<1>D g4<8,8,1>F 0F and(16) g4<1>D g2<8,8,1>D 1D and(16) m6<1>D -g4<8,8,1>D 0x3f800000UD v2: When the comparison is either == 0.0 or != 0.0 use the knowledge that the true (or false) case already results in zero would allow better code generation by possibly avoiding a load-immediate instruction. v3: Apply the optimization even when neither comparitor is zero. Shader-db results: GM45 (0x2A42): total instructions in shared programs: 3551002 -> 3550829 (-0.00%) instructions in affected programs: 33269 -> 33096 (-0.52%) helped: 121 Iron Lake (0x0046): total instructions in shared programs: 4993327 -> 4993146 (-0.00%) instructions in affected programs: 34199 -> 34018 (-0.53%) helped: 129 No change on other platforms. Signed-off-by: Ian Romanick Reviewed-by: Tapani Palli --- src/mesa/drivers/dri/i965/brw_fs.h | 2 + src/mesa/drivers/dri/i965/brw_fs_visitor.cpp | 101 +++++++++++++++++++++++++- 2 files changed, 99 insertions(+), 4 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_fs.h b/src/mesa/drivers/dri/i965/brw_fs.h index 7716529..23e7135 100644 --- a/src/mesa/drivers/dri/i965/brw_fs.h +++ b/src/mesa/drivers/dri/i965/brw_fs.h @@ -307,6 +307,7 @@ public: const fs_reg &a); void emit_minmax(enum brw_conditional_mod conditionalmod, const fs_reg &dst, const fs_reg &src0, const fs_reg &src1); + bool try_emit_b2f_of_comparison(ir_expression *ir); bool try_emit_saturate(ir_expression *ir); bool try_emit_line(ir_expression *ir); bool try_emit_mad(ir_expression *ir); @@ -317,6 +318,7 @@ public: bool opt_saturate_propagation(); bool opt_cmod_propagation(); void emit_bool_to_cond_code(ir_rvalue *condition); + void emit_bool_to_cond_code_of_reg(ir_expression *expr, fs_reg op[3]); void emit_if_gen6(ir_if *ir); void emit_unspill(bblock_t *block, fs_inst *inst, fs_reg reg, uint32_t spill_offset, int count); diff --git a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp index 6d56115..0d5252a 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp @@ -475,6 +475,87 @@ fs_visitor::try_emit_mad(ir_expression *ir) return true; } +bool +fs_visitor::try_emit_b2f_of_comparison(ir_expression *ir) +{ + /* On platforms that do not natively generate 0u and ~0u for Boolean + * results, b2f expressions that look like + * + * f = b2f(expr cmp 0) + * + * will generate better code by pretending the expression is + * + * f = ir_triop_csel(0.0, 1.0, expr cmp 0) + * + * This is because the last instruction of "expr" can generate the + * condition code for the "cmp 0". This avoids having to do the "-(b & 1)" + * trick to generate 0u or ~0u for the Boolean result. This means code like + * + * mov(16) g16<1>F 1F + * mul.ge.f0(16) null g6<8,8,1>F g14<8,8,1>F + * (+f0) sel(16) m6<1>F g16<8,8,1>F 0F + * + * will be generated instead of + * + * mul(16) g2<1>F g12<8,8,1>F g4<8,8,1>F + * cmp.ge.f0(16) g2<1>D g4<8,8,1>F 0F + * and(16) g4<1>D g2<8,8,1>D 1D + * and(16) m6<1>D -g4<8,8,1>D 0x3f800000UD + * + * When the comparison is either == 0.0 or != 0.0 using the knowledge that + * the true (or false) case already results in zero would allow better code + * generation by possibly avoiding a load-immediate instruction. + */ + ir_expression *cmp = ir->operands[0]->as_expression(); + if (cmp == NULL) + return false; + + if (cmp->operation == ir_binop_equal || cmp->operation == ir_binop_nequal) { + for (unsigned i = 0; i < 2; i++) { + ir_constant *c = cmp->operands[i]->as_constant(); + if (c == NULL || !c->is_zero()) + continue; + + ir_expression *expr = cmp->operands[i ^ 1]->as_expression(); + if (expr != NULL) { + fs_reg op[2]; + + for (unsigned j = 0; j < 2; j++) { + cmp->operands[j]->accept(this); + op[j] = this->result; + + resolve_ud_negate(&op[j]); + } + + emit_bool_to_cond_code_of_reg(cmp, op); + + /* In this case we know when the condition is true, op[i ^ 1] + * contains zero. Invert the predicate, use op[i ^ 1] as src0, + * and immediate 1.0f as src1. + */ + this->result = vgrf(ir->type); + op[i ^ 1].type = BRW_REGISTER_TYPE_F; + + fs_inst *inst = emit(SEL(this->result, op[i ^ 1], fs_reg(1.0f))); + inst->predicate = BRW_PREDICATE_NORMAL; + inst->predicate_inverse = cmp->operation == ir_binop_equal; + return true; + } + } + } + + emit_bool_to_cond_code(cmp); + + fs_reg temp = vgrf(ir->type); + emit(MOV(temp, fs_reg(1.0f))); + + this->result = vgrf(ir->type); + fs_inst *inst = emit(SEL(this->result, temp, fs_reg(0.0f))); + inst->predicate = BRW_PREDICATE_NORMAL; + + return true; +} + static int pack_pixel_offset(float x) { @@ -639,6 +720,11 @@ fs_visitor::visit(ir_expression *ir) inst->predicate = BRW_PREDICATE_NORMAL; return; + case ir_unop_b2f: + if (brw->gen <= 5 && try_emit_b2f_of_comparison(ir)) + return; + break; + case ir_unop_interpolate_at_centroid: case ir_binop_interpolate_at_offset: case ir_binop_interpolate_at_sample: @@ -2508,7 +2594,6 @@ fs_visitor::emit_bool_to_cond_code(ir_rvalue *ir) } fs_reg op[3]; - fs_inst *inst; assert(expr->get_num_operands() <= 3); for (unsigned int i = 0; i < expr->get_num_operands(); i++) { @@ -2520,6 +2605,14 @@ fs_visitor::emit_bool_to_cond_code(ir_rvalue *ir) resolve_ud_negate(&op[i]); } + emit_bool_to_cond_code_of_reg(expr, op); +} + +void +fs_visitor::emit_bool_to_cond_code_of_reg(ir_expression *expr, fs_reg op[3]) +{ + fs_inst *inst; + switch (expr->operation) { case ir_unop_logic_not: inst = emit(AND(reg_null_d, op[0], fs_reg(1))); @@ -2528,7 +2621,7 @@ fs_visitor::emit_bool_to_cond_code(ir_rvalue *ir) case ir_binop_logic_xor: if (brw->gen <= 5) { - fs_reg temp = vgrf(ir->type); + fs_reg temp = vgrf(expr->type); emit(XOR(temp, op[0], op[1])); inst = emit(AND(reg_null_d, temp, fs_reg(1))); } else { @@ -2539,7 +2632,7 @@ fs_visitor::emit_bool_to_cond_code(ir_rvalue *ir) case ir_binop_logic_or: if (brw->gen <= 5) { - fs_reg temp = vgrf(ir->type); + fs_reg temp = vgrf(expr->type); emit(OR(temp, op[0], op[1])); inst = emit(AND(reg_null_d, temp, fs_reg(1))); } else { @@ -2550,7 +2643,7 @@ fs_visitor::emit_bool_to_cond_code(ir_rvalue *ir) case ir_binop_logic_and: if (brw->gen <= 5) { - fs_reg temp = vgrf(ir->type); + fs_reg temp = vgrf(expr->type); emit(AND(temp, op[0], op[1])); inst = emit(AND(reg_null_d, temp, fs_reg(1))); } else { From mattst88 at kemper.freedesktop.org Thu Mar 19 18:16:30 2015 From: mattst88 at kemper.freedesktop.org (Matt Turner) Date: Thu, 19 Mar 2015 11:16:30 -0700 (PDT) Subject: Mesa (master): i965/fs: Print spills: fills and number of promoted constants. Message-ID: <20150319181630.B8E5B76333@kemper.freedesktop.org> Module: Mesa Branch: master Commit: b0d422cd2a99d2fd26ab11880d5d8410ebfc64b2 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=b0d422cd2a99d2fd26ab11880d5d8410ebfc64b2 Author: Matt Turner Date: Mon Mar 16 12:18:31 2015 -0700 i965/fs: Print spills:fills and number of promoted constants. Reviewed-by: Jason Ekstrand Reviewed-by: Chris Forbes --- src/mesa/drivers/dri/i965/brw_blorp_blit_eu.cpp | 2 +- src/mesa/drivers/dri/i965/brw_fs.cpp | 2 +- src/mesa/drivers/dri/i965/brw_fs.h | 4 ++++ .../drivers/dri/i965/brw_fs_combine_constants.cpp | 1 + src/mesa/drivers/dri/i965/brw_fs_generator.cpp | 22 +++++++++++++------- src/mesa/drivers/dri/i965/brw_fs_visitor.cpp | 4 ++-- src/mesa/drivers/dri/i965/brw_vec4.cpp | 3 ++- 7 files changed, 25 insertions(+), 13 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_blorp_blit_eu.cpp b/src/mesa/drivers/dri/i965/brw_blorp_blit_eu.cpp index f9b1737..32919b1 100644 --- a/src/mesa/drivers/dri/i965/brw_blorp_blit_eu.cpp +++ b/src/mesa/drivers/dri/i965/brw_blorp_blit_eu.cpp @@ -31,7 +31,7 @@ brw_blorp_eu_emitter::brw_blorp_eu_emitter(struct brw_context *brw, : mem_ctx(ralloc_context(NULL)), generator(brw, mem_ctx, (void *) rzalloc(mem_ctx, struct brw_wm_prog_key), (struct brw_stage_prog_data *) rzalloc(mem_ctx, struct brw_wm_prog_data), - NULL, false, "BLORP") + NULL, 0, false, "BLORP") { if (debug_flag) generator.enable_debug("blorp"); diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp index 3d4d31a..1008467 100644 --- a/src/mesa/drivers/dri/i965/brw_fs.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs.cpp @@ -4068,7 +4068,7 @@ brw_wm_fs_emit(struct brw_context *brw, } fs_generator g(brw, mem_ctx, (void *) key, &prog_data->base, - &fp->Base, v.runtime_check_aads_emit, "FS"); + &fp->Base, v.promoted_constants, v.runtime_check_aads_emit, "FS"); if (unlikely(INTEL_DEBUG & DEBUG_WM)) { char *name; diff --git a/src/mesa/drivers/dri/i965/brw_fs.h b/src/mesa/drivers/dri/i965/brw_fs.h index 23e7135..2f362db 100644 --- a/src/mesa/drivers/dri/i965/brw_fs.h +++ b/src/mesa/drivers/dri/i965/brw_fs.h @@ -514,6 +514,8 @@ public: bool spilled_any_registers; const unsigned dispatch_width; /**< 8 or 16 */ + + unsigned promoted_constants; }; /** @@ -529,6 +531,7 @@ public: const void *key, struct brw_stage_prog_data *prog_data, struct gl_program *fp, + unsigned promoted_constants, bool runtime_check_aads_emit, const char *stage_abbrev); ~fs_generator(); @@ -640,6 +643,7 @@ private: unsigned dispatch_width; /**< 8 or 16 */ exec_list discard_halt_patches; + unsigned promoted_constants; bool runtime_check_aads_emit; bool debug_flag; const char *shader_name; diff --git a/src/mesa/drivers/dri/i965/brw_fs_combine_constants.cpp b/src/mesa/drivers/dri/i965/brw_fs_combine_constants.cpp index 7ddb253..ebde8df 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_combine_constants.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_combine_constants.cpp @@ -286,6 +286,7 @@ fs_visitor::opt_combine_constants() reg.subreg_offset = 0; } } + promoted_constants = table.len; /* Rewrite the immediate sources to refer to the new GRFs. */ for (int i = 0; i < table.len; i++) { diff --git a/src/mesa/drivers/dri/i965/brw_fs_generator.cpp b/src/mesa/drivers/dri/i965/brw_fs_generator.cpp index e086266..05a2db4 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_generator.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_generator.cpp @@ -126,13 +126,15 @@ fs_generator::fs_generator(struct brw_context *brw, const void *key, struct brw_stage_prog_data *prog_data, struct gl_program *prog, + unsigned promoted_constants, bool runtime_check_aads_emit, const char *stage_abbrev) : brw(brw), key(key), prog_data(prog_data), - prog(prog), runtime_check_aads_emit(runtime_check_aads_emit), - debug_flag(false), stage_abbrev(stage_abbrev), mem_ctx(mem_ctx) + prog(prog), promoted_constants(promoted_constants), + runtime_check_aads_emit(runtime_check_aads_emit), debug_flag(false), + stage_abbrev(stage_abbrev), mem_ctx(mem_ctx) { ctx = &brw->ctx; @@ -1563,6 +1565,7 @@ fs_generator::generate_code(const cfg_t *cfg, int dispatch_width) brw_set_default_compression_control(p, BRW_COMPRESSION_COMPRESSED); int start_offset = p->next_insn_offset; + int spill_count = 0, fill_count = 0; int loop_count = 0; struct annotation_info annotation; @@ -1959,14 +1962,17 @@ fs_generator::generate_code(const cfg_t *cfg, int dispatch_width) case SHADER_OPCODE_GEN4_SCRATCH_WRITE: generate_scratch_write(inst, src[0]); + spill_count++; break; case SHADER_OPCODE_GEN4_SCRATCH_READ: generate_scratch_read(inst, dst); + fill_count++; break; case SHADER_OPCODE_GEN7_SCRATCH_READ: generate_scratch_read_gen7(inst, dst); + fill_count++; break; case SHADER_OPCODE_URB_WRITE_SIMD8: @@ -2111,10 +2117,10 @@ fs_generator::generate_code(const cfg_t *cfg, int dispatch_width) if (unlikely(debug_flag)) { fprintf(stderr, "Native code for %s\n" - "SIMD%d shader: %d instructions. %d loops. Compacted %d to %d" + "SIMD%d shader: %d instructions. %d loops. %d:%d spills:fills. Promoted %u constants. Compacted %d to %d" " bytes (%.0f%%)\n", - shader_name, - dispatch_width, before_size / 16, loop_count, before_size, after_size, + shader_name, dispatch_width, before_size / 16, loop_count, + spill_count, fill_count, promoted_constants, before_size, after_size, 100.0f * (before_size - after_size) / before_size); dump_assembly(p->store, annotation.ann_count, annotation.ann, brw, prog); @@ -2126,10 +2132,10 @@ fs_generator::generate_code(const cfg_t *cfg, int dispatch_width) MESA_DEBUG_SOURCE_SHADER_COMPILER, MESA_DEBUG_TYPE_OTHER, MESA_DEBUG_SEVERITY_NOTIFICATION, - "%s SIMD%d shader: %d inst, %d loops, " - "compacted %d to %d bytes.\n", + "%s SIMD%d shader: %d inst, %d loops, %d:%d spills:fills, " + "Promoted %u constants, compacted %d to %d bytes.\n", stage_abbrev, dispatch_width, before_size / 16, loop_count, - before_size, after_size); + spill_count, fill_count, promoted_constants, before_size, after_size); return start_offset; } diff --git a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp index 0d5252a..60a7a97 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp @@ -4082,7 +4082,7 @@ fs_visitor::fs_visitor(struct brw_context *brw, reg_null_d(retype(brw_null_vec(dispatch_width), BRW_REGISTER_TYPE_D)), reg_null_ud(retype(brw_null_vec(dispatch_width), BRW_REGISTER_TYPE_UD)), key(key), prog_data(&prog_data->base), - dispatch_width(dispatch_width) + dispatch_width(dispatch_width), promoted_constants(0) { this->mem_ctx = mem_ctx; init(); @@ -4101,7 +4101,7 @@ fs_visitor::fs_visitor(struct brw_context *brw, reg_null_d(retype(brw_null_vec(dispatch_width), BRW_REGISTER_TYPE_D)), reg_null_ud(retype(brw_null_vec(dispatch_width), BRW_REGISTER_TYPE_UD)), key(key), prog_data(&prog_data->base.base), - dispatch_width(dispatch_width) + dispatch_width(dispatch_width), promoted_constants(0) { this->mem_ctx = mem_ctx; init(); diff --git a/src/mesa/drivers/dri/i965/brw_vec4.cpp b/src/mesa/drivers/dri/i965/brw_vec4.cpp index 8edb4d0..b13dd58 100644 --- a/src/mesa/drivers/dri/i965/brw_vec4.cpp +++ b/src/mesa/drivers/dri/i965/brw_vec4.cpp @@ -1969,7 +1969,8 @@ brw_vs_emit(struct brw_context *brw, } fs_generator g(brw, mem_ctx, (void *) &c->key, &prog_data->base.base, - &c->vp->program.Base, v.runtime_check_aads_emit, "VS"); + &c->vp->program.Base, v.promoted_constants, + v.runtime_check_aads_emit, "VS"); if (INTEL_DEBUG & DEBUG_VS) { char *name = ralloc_asprintf(mem_ctx, "%s vertex shader %d", prog->Label ? prog->Label : "unnamed", From brianp at kemper.freedesktop.org Thu Mar 19 18:55:44 2015 From: brianp at kemper.freedesktop.org (Brian Paul) Date: Thu, 19 Mar 2015 11:55:44 -0700 (PDT) Subject: Mesa (master): mesa: use more descriptive error messages for glUniform errors Message-ID: <20150319185544.7D58F76333@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 1cd37459110402f8a5c07fe0aa0f1198b4bb1da1 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=1cd37459110402f8a5c07fe0aa0f1198b4bb1da1 Author: Brian Paul Date: Thu Mar 19 08:10:19 2015 -0600 mesa: use more descriptive error messages for glUniform errors Different errors for type mismatches, size mismatches and matrix/ non-matrix mismatches. Use a common format of "uniformName"@location in the messags. Reviewed-by: Martin Peres --- src/mesa/main/uniform_query.cpp | 69 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 65 insertions(+), 4 deletions(-) diff --git a/src/mesa/main/uniform_query.cpp b/src/mesa/main/uniform_query.cpp index 9f82de9..2ab5528 100644 --- a/src/mesa/main/uniform_query.cpp +++ b/src/mesa/main/uniform_query.cpp @@ -260,8 +260,8 @@ validate_uniform_parameters(struct gl_context *ctx, if (uni->array_elements == 0) { if (count > 1) { _mesa_error(ctx, GL_INVALID_OPERATION, - "%s(count > 1 for non-array, location=%d)", - caller, location); + "%s(count = %u for non-array \"%s\"@%d)", + caller, count, uni->name, location); return NULL; } @@ -601,6 +601,46 @@ _mesa_propagate_uniforms_to_driver_storage(struct gl_uniform_storage *uni, } } + +/** + * Return printable string for a given GLSL_TYPE_x + */ +static const char * +glsl_type_name(enum glsl_base_type type) +{ + switch (type) { + case GLSL_TYPE_UINT: + return "uint"; + case GLSL_TYPE_INT: + return "int"; + case GLSL_TYPE_FLOAT: + return "float"; + case GLSL_TYPE_DOUBLE: + return "double"; + case GLSL_TYPE_BOOL: + return "bool"; + case GLSL_TYPE_SAMPLER: + return "sampler"; + case GLSL_TYPE_IMAGE: + return "image"; + case GLSL_TYPE_ATOMIC_UINT: + return "atomic_uint"; + case GLSL_TYPE_STRUCT: + return "struct"; + case GLSL_TYPE_INTERFACE: + return "interface"; + case GLSL_TYPE_ARRAY: + return "array"; + case GLSL_TYPE_VOID: + return "void"; + case GLSL_TYPE_ERROR: + return "error"; + default: + return "other"; + } +} + + /** * Called via glUniform*() functions. */ @@ -620,11 +660,28 @@ _mesa_uniform(struct gl_context *ctx, struct gl_shader_program *shProg, if (uni == NULL) return; + if (uni->type->is_matrix()) { + /* Can't set matrix uniforms (like mat4) with glUniform */ + _mesa_error(ctx, GL_INVALID_OPERATION, + "glUniform%u(uniform \"%s\"@%d is matrix)", + src_components, uni->name, location); + return; + } + /* Verify that the types are compatible. */ const unsigned components = uni->type->is_sampler() ? 1 : uni->type->vector_elements; + if (components != src_components) { + /* glUniformN() must match float/vecN type */ + _mesa_error(ctx, GL_INVALID_OPERATION, + "glUniform%u(\"%s\"@%u has %u components, not %u)", + src_components, uni->name, location, + components, src_components); + return; + } + bool match; switch (uni->type->base_type) { case GLSL_TYPE_BOOL: @@ -639,8 +696,12 @@ _mesa_uniform(struct gl_context *ctx, struct gl_shader_program *shProg, break; } - if (uni->type->is_matrix() || components != src_components || !match) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glUniform(type mismatch)"); + if (!match) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glUniform%u(\"%s\"@%d is %s, not %s)", + src_components, uni->name, location, + glsl_type_name(uni->type->base_type), + glsl_type_name(basicType)); return; } From brianp at kemper.freedesktop.org Thu Mar 19 18:55:44 2015 From: brianp at kemper.freedesktop.org (Brian Paul) Date: Thu, 19 Mar 2015 11:55:44 -0700 (PDT) Subject: Mesa (master): gallivm: remove unused 'builder' variable Message-ID: <20150319185544.856F97633A@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 8f255f948bd5c7b8fd56c8f72f6a9a7f626fca29 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=8f255f948bd5c7b8fd56c8f72f6a9a7f626fca29 Author: Brian Paul Date: Thu Mar 19 08:48:56 2015 -0600 gallivm: remove unused 'builder' variable Reviewed-by: Roland Scheidegger Reviewed-by: Jose Fonseca --- src/gallium/auxiliary/gallivm/lp_bld_arit.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/gallium/auxiliary/gallivm/lp_bld_arit.c b/src/gallium/auxiliary/gallivm/lp_bld_arit.c index 0d4eaea..956b37a 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_arit.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_arit.c @@ -2538,7 +2538,6 @@ LLVMValueRef lp_build_rsqrt(struct lp_build_context *bld, LLVMValueRef a) { - LLVMBuilderRef builder = bld->gallivm->builder; const struct lp_type type = bld->type; assert(lp_check_value(type, a)); From jekstrand at kemper.freedesktop.org Thu Mar 19 20:25:15 2015 From: jekstrand at kemper.freedesktop.org (Jason Ekstrand) Date: Thu, 19 Mar 2015 13:25:15 -0700 (PDT) Subject: Mesa (master): nir/lower_io: Make variable location assignment a manual operation Message-ID: <20150319202515.E28B27633A@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 25db44a84597960a6aea6b252bcf2c3d7e17fc74 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=25db44a84597960a6aea6b252bcf2c3d7e17fc74 Author: Jason Ekstrand Date: Wed Mar 18 15:04:15 2015 -0700 nir/lower_io: Make variable location assignment a manual operation Previously, we just assigned variable locations in nir_lower_io. Now, we force the user to assign variable locations for us. This gives the backend a bit more control over where variables are placed. v2: Rename from _packed to _scalar Reviewed-by: Connor Abbott --- src/glsl/nir/nir.h | 3 +++ src/glsl/nir/nir_lower_io.c | 14 ++------------ src/mesa/drivers/dri/i965/brw_fs_nir.cpp | 4 ++++ 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/src/glsl/nir/nir.h b/src/glsl/nir/nir.h index 6b42df9..a2a03b2 100644 --- a/src/glsl/nir/nir.h +++ b/src/glsl/nir/nir.h @@ -1577,6 +1577,9 @@ void nir_lower_global_vars_to_local(nir_shader *shader); void nir_lower_locals_to_regs(nir_shader *shader); +void nir_assign_var_locations_scalar(struct exec_list *var_list, + unsigned *size); + void nir_lower_io(nir_shader *shader); void nir_lower_vars_to_ssa(nir_shader *shader); diff --git a/src/glsl/nir/nir_lower_io.c b/src/glsl/nir/nir_lower_io.c index 37c357e..602b8c9 100644 --- a/src/glsl/nir/nir_lower_io.c +++ b/src/glsl/nir/nir_lower_io.c @@ -76,8 +76,8 @@ type_size(const struct glsl_type *type) return 0; } -static void -assign_var_locations(struct exec_list *var_list, unsigned *size) +void +nir_assign_var_locations_scalar(struct exec_list *var_list, unsigned *size) { unsigned location = 0; @@ -96,14 +96,6 @@ assign_var_locations(struct exec_list *var_list, unsigned *size) *size = location; } -static void -assign_var_locations_shader(nir_shader *shader) -{ - assign_var_locations(&shader->inputs, &shader->num_inputs); - assign_var_locations(&shader->outputs, &shader->num_outputs); - assign_var_locations(&shader->uniforms, &shader->num_uniforms); -} - static bool deref_has_indirect(nir_deref_var *deref) { @@ -304,8 +296,6 @@ nir_lower_io_impl(nir_function_impl *impl) void nir_lower_io(nir_shader *shader) { - assign_var_locations_shader(shader); - nir_foreach_overload(shader, overload) { if (overload->impl) nir_lower_io_impl(overload->impl); diff --git a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp index 9431e5d..8ef57af 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp @@ -105,6 +105,10 @@ fs_visitor::emit_nir_code() /* Get rid of split copies */ nir_optimize(nir); + nir_assign_var_locations_scalar(&nir->uniforms, &nir->num_uniforms); + nir_assign_var_locations_scalar(&nir->inputs, &nir->num_inputs); + nir_assign_var_locations_scalar(&nir->outputs, &nir->num_outputs); + nir_lower_io(nir); nir_validate_shader(nir); From jekstrand at kemper.freedesktop.org Thu Mar 19 20:25:15 2015 From: jekstrand at kemper.freedesktop.org (Jason Ekstrand) Date: Thu, 19 Mar 2015 13:25:15 -0700 (PDT) Subject: Mesa (master): nir/lower_io: Add a assign_locations function that sorts by [in]direct use Message-ID: <20150319202515.ECFB176359@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 8a33f95b7a1128b5e46bd30306961bac72f5f12e URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=8a33f95b7a1128b5e46bd30306961bac72f5f12e Author: Jason Ekstrand Date: Wed Mar 18 15:05:28 2015 -0700 nir/lower_io: Add a assign_locations function that sorts by [in]direct use v2: Delete the set of indirectly accessed variables when we're done with it v3: Rename from _packed to _scalar Reviewed-by: Connor Abbott --- src/glsl/nir/nir.h | 4 +++ src/glsl/nir/nir_lower_io.c | 71 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 75 insertions(+) diff --git a/src/glsl/nir/nir.h b/src/glsl/nir/nir.h index a2a03b2..29fe942 100644 --- a/src/glsl/nir/nir.h +++ b/src/glsl/nir/nir.h @@ -1579,6 +1579,10 @@ void nir_lower_locals_to_regs(nir_shader *shader); void nir_assign_var_locations_scalar(struct exec_list *var_list, unsigned *size); +void nir_assign_var_locations_scalar_direct_first(nir_shader *shader, + struct exec_list *var_list, + unsigned *direct_size, + unsigned *size); void nir_lower_io(nir_shader *shader); diff --git a/src/glsl/nir/nir_lower_io.c b/src/glsl/nir/nir_lower_io.c index 602b8c9..03eed04 100644 --- a/src/glsl/nir/nir_lower_io.c +++ b/src/glsl/nir/nir_lower_io.c @@ -110,6 +110,77 @@ deref_has_indirect(nir_deref_var *deref) return false; } +static bool +mark_indirect_uses_block(nir_block *block, void *void_state) +{ + struct set *indirect_set = void_state; + + nir_foreach_instr(block, instr) { + if (instr->type != nir_instr_type_intrinsic) + continue; + + nir_intrinsic_instr *intrin = nir_instr_as_intrinsic(instr); + + for (unsigned i = 0; + i < nir_intrinsic_infos[intrin->intrinsic].num_variables; i++) { + if (deref_has_indirect(intrin->variables[i])) + _mesa_set_add(indirect_set, intrin->variables[i]->var); + } + } + + return true; +} + +/* Identical to nir_assign_var_locations_packed except that it assigns + * locations to the variables that are used 100% directly first and then + * assigns locations to variables that are used indirectly. + */ +void +nir_assign_var_locations_scalar_direct_first(nir_shader *shader, + struct exec_list *var_list, + unsigned *direct_size, + unsigned *size) +{ + struct set *indirect_set = _mesa_set_create(NULL, _mesa_hash_pointer, + _mesa_key_pointer_equal); + + nir_foreach_overload(shader, overload) { + if (overload->impl) + nir_foreach_block(overload->impl, mark_indirect_uses_block, + indirect_set); + } + + unsigned location = 0; + + foreach_list_typed(nir_variable, var, node, var_list) { + if (var->data.mode == nir_var_uniform && var->interface_type != NULL) + continue; + + if (_mesa_set_search(indirect_set, var)) + continue; + + var->data.driver_location = location; + location += type_size(var->type); + } + + *direct_size = location; + + foreach_list_typed(nir_variable, var, node, var_list) { + if (var->data.mode == nir_var_uniform && var->interface_type != NULL) + continue; + + if (!_mesa_set_search(indirect_set, var)) + continue; + + var->data.driver_location = location; + location += type_size(var->type); + } + + *size = location; + + _mesa_set_destroy(indirect_set, NULL); +} + static unsigned get_io_offset(nir_deref_var *deref, nir_instr *instr, nir_src *indirect, struct lower_io_state *state) From jekstrand at kemper.freedesktop.org Thu Mar 19 20:25:16 2015 From: jekstrand at kemper.freedesktop.org (Jason Ekstrand) Date: Thu, 19 Mar 2015 13:25:16 -0700 (PDT) Subject: Mesa (master): i965/nir: Sort uniforms direct-first and use two different uniform registers Message-ID: <20150319202516.06AC27635A@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 46c35c61e9c5c1b56fdd9fcd4eb45591dd16d21d URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=46c35c61e9c5c1b56fdd9fcd4eb45591dd16d21d Author: Jason Ekstrand Date: Wed Mar 18 15:18:54 2015 -0700 i965/nir: Sort uniforms direct-first and use two different uniform registers Previously, we put all the uniforms into one big array. The problem with this approach is that, as soon as there was one indirect array acces, the backend would decide that the entire large array should be pull constants. This commit splits the array in half: first direct-only uniforms and then potentially-indirect uniforms. This may not be optimal, but it does let the backend promote things to push constants. Shader-db results on HSW: total instructions in shared programs: 4114840 -> 4112172 (-0.06%) instructions in affected programs: 43316 -> 40648 (-6.16%) helped: 116 HURT: 0 v2: Set param_size[num_direct_uniforms] only if we have indirect uniforms. This caused a bug that, strangely enough, only showed up on Broadwell vertex shaders. Reviewed-by: Connor Abbott --- src/mesa/drivers/dri/i965/brw_fs.h | 4 +++- src/mesa/drivers/dri/i965/brw_fs_nir.cpp | 27 +++++++++++++++++++++------ 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_fs.h b/src/mesa/drivers/dri/i965/brw_fs.h index 2f362db..8317831 100644 --- a/src/mesa/drivers/dri/i965/brw_fs.h +++ b/src/mesa/drivers/dri/i965/brw_fs.h @@ -435,6 +435,9 @@ public: /** Number of uniform variable components visited. */ unsigned uniforms; + /** Total number of direct uniforms we can get from NIR */ + unsigned num_direct_uniforms; + /** Byte-offset for the next available spot in the scratch space buffer. */ unsigned last_scratch; @@ -468,7 +471,6 @@ public: fs_reg *nir_globals; fs_reg nir_inputs; fs_reg nir_outputs; - fs_reg nir_uniforms; fs_reg *nir_system_values; /** @{ debug annotation info */ diff --git a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp index 8ef57af..05506f5 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp @@ -105,7 +105,9 @@ fs_visitor::emit_nir_code() /* Get rid of split copies */ nir_optimize(nir); - nir_assign_var_locations_scalar(&nir->uniforms, &nir->num_uniforms); + nir_assign_var_locations_scalar_direct_first(nir, &nir->uniforms, + &num_direct_uniforms, + &nir->num_uniforms); nir_assign_var_locations_scalar(&nir->inputs, &nir->num_inputs); nir_assign_var_locations_scalar(&nir->outputs, &nir->num_outputs); @@ -168,7 +170,6 @@ fs_visitor::emit_nir_code() } if (nir->num_uniforms > 0) { - nir_uniforms = fs_reg(UNIFORM, 0); nir_setup_uniforms(nir); } @@ -299,7 +300,13 @@ void fs_visitor::nir_setup_uniforms(nir_shader *shader) { uniforms = shader->num_uniforms; - param_size[0] = shader->num_uniforms; + + /* We split the uniform register file in half. The first half is + * entirely direct uniforms. The second half is indirect. + */ + param_size[0] = num_direct_uniforms; + if (shader->num_uniforms > num_direct_uniforms) + param_size[num_direct_uniforms] = shader->num_uniforms - num_direct_uniforms; if (dispatch_width != 8) return; @@ -1456,11 +1463,19 @@ fs_visitor::nir_emit_intrinsic(nir_intrinsic_instr *instr) case nir_intrinsic_load_uniform_indirect: has_indirect = true; case nir_intrinsic_load_uniform: { - unsigned index = 0; + unsigned index = instr->const_index[0]; + + fs_reg uniform_reg; + if (index < num_direct_uniforms) { + uniform_reg = fs_reg(UNIFORM, 0); + } else { + uniform_reg = fs_reg(UNIFORM, num_direct_uniforms); + index -= num_direct_uniforms; + } + for (int i = 0; i < instr->const_index[1]; i++) { for (unsigned j = 0; j < instr->num_components; j++) { - fs_reg src = offset(retype(nir_uniforms, dest.type), - instr->const_index[0] + index); + fs_reg src = offset(retype(uniform_reg, dest.type), index); if (has_indirect) src.reladdr = new(mem_ctx) fs_reg(get_nir_src(instr->src[0])); index++; From jekstrand at kemper.freedesktop.org Thu Mar 19 20:25:15 2015 From: jekstrand at kemper.freedesktop.org (Jason Ekstrand) Date: Thu, 19 Mar 2015 13:25:15 -0700 (PDT) Subject: Mesa (master): nir: Use a list instead of a hash_table for inputs, outputs , and uniforms Message-ID: <20150319202515.D9C6076333@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 639115123efe7f71d432e24b1719adda7d23e97e URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=639115123efe7f71d432e24b1719adda7d23e97e Author: Jason Ekstrand Date: Wed Mar 18 12:34:09 2015 -0700 nir: Use a list instead of a hash_table for inputs, outputs, and uniforms We never did a single hash table lookup in the entire NIR code base that I found so there was no real benifit to doing it that way. I suppose that for linking, we'll probably want to be able to lookup by name but we can leave building that hash table to the linker. In the mean time this was causing problems with GLSL IR -> NIR because GLSL IR doesn't guarantee us unique names of uniforms, etc. This was causing massive rendering isues in the unreal4 Sun Temple demo. Reviewed-by: Connor Abbott --- src/glsl/nir/glsl_to_nir.cpp | 6 +++--- src/glsl/nir/nir.c | 9 +++------ src/glsl/nir/nir.h | 6 +++--- src/glsl/nir/nir_lower_io.c | 13 +++++-------- src/glsl/nir/nir_print.c | 14 ++++++-------- src/glsl/nir/nir_validate.c | 16 +++++++++------- src/mesa/drivers/dri/i965/brw_fs_nir.cpp | 13 +++---------- 7 files changed, 32 insertions(+), 45 deletions(-) diff --git a/src/glsl/nir/glsl_to_nir.cpp b/src/glsl/nir/glsl_to_nir.cpp index 047cb51..357944d 100644 --- a/src/glsl/nir/glsl_to_nir.cpp +++ b/src/glsl/nir/glsl_to_nir.cpp @@ -352,15 +352,15 @@ nir_visitor::visit(ir_variable *ir) break; case nir_var_shader_in: - _mesa_hash_table_insert(shader->inputs, var->name, var); + exec_list_push_tail(&shader->inputs, &var->node); break; case nir_var_shader_out: - _mesa_hash_table_insert(shader->outputs, var->name, var); + exec_list_push_tail(&shader->outputs, &var->node); break; case nir_var_uniform: - _mesa_hash_table_insert(shader->uniforms, var->name, var); + exec_list_push_tail(&shader->uniforms, &var->node); break; case nir_var_system_value: diff --git a/src/glsl/nir/nir.c b/src/glsl/nir/nir.c index abad3f8..6459d51 100644 --- a/src/glsl/nir/nir.c +++ b/src/glsl/nir/nir.c @@ -33,12 +33,9 @@ nir_shader_create(void *mem_ctx, const nir_shader_compiler_options *options) { nir_shader *shader = ralloc(mem_ctx, nir_shader); - shader->uniforms = _mesa_hash_table_create(shader, _mesa_key_hash_string, - _mesa_key_string_equal); - shader->inputs = _mesa_hash_table_create(shader, _mesa_key_hash_string, - _mesa_key_string_equal); - shader->outputs = _mesa_hash_table_create(shader, _mesa_key_hash_string, - _mesa_key_string_equal); + exec_list_make_empty(&shader->uniforms); + exec_list_make_empty(&shader->inputs); + exec_list_make_empty(&shader->outputs); shader->options = options; diff --git a/src/glsl/nir/nir.h b/src/glsl/nir/nir.h index 669a26e..6b42df9 100644 --- a/src/glsl/nir/nir.h +++ b/src/glsl/nir/nir.h @@ -1380,13 +1380,13 @@ typedef struct nir_shader_compiler_options { typedef struct nir_shader { /** hash table of name -> uniform nir_variable */ - struct hash_table *uniforms; + struct exec_list uniforms; /** hash table of name -> input nir_variable */ - struct hash_table *inputs; + struct exec_list inputs; /** hash table of name -> output nir_variable */ - struct hash_table *outputs; + struct exec_list outputs; /** Set of driver-specific options for the shader. * diff --git a/src/glsl/nir/nir_lower_io.c b/src/glsl/nir/nir_lower_io.c index 207f8da..37c357e 100644 --- a/src/glsl/nir/nir_lower_io.c +++ b/src/glsl/nir/nir_lower_io.c @@ -77,14 +77,11 @@ type_size(const struct glsl_type *type) } static void -assign_var_locations(struct hash_table *ht, unsigned *size) +assign_var_locations(struct exec_list *var_list, unsigned *size) { unsigned location = 0; - struct hash_entry *entry; - hash_table_foreach(ht, entry) { - nir_variable *var = (nir_variable *) entry->data; - + foreach_list_typed(nir_variable, var, node, var_list) { /* * UBO's have their own address spaces, so don't count them towards the * number of global uniforms @@ -102,9 +99,9 @@ assign_var_locations(struct hash_table *ht, unsigned *size) static void assign_var_locations_shader(nir_shader *shader) { - assign_var_locations(shader->inputs, &shader->num_inputs); - assign_var_locations(shader->outputs, &shader->num_outputs); - assign_var_locations(shader->uniforms, &shader->num_uniforms); + assign_var_locations(&shader->inputs, &shader->num_inputs); + assign_var_locations(&shader->outputs, &shader->num_outputs); + assign_var_locations(&shader->uniforms, &shader->num_uniforms); } static bool diff --git a/src/glsl/nir/nir_print.c b/src/glsl/nir/nir_print.c index f8b14a1..fa11a31 100644 --- a/src/glsl/nir/nir_print.c +++ b/src/glsl/nir/nir_print.c @@ -844,18 +844,16 @@ nir_print_shader(nir_shader *shader, FILE *fp) print_var_state state; init_print_state(&state); - struct hash_entry *entry; - - hash_table_foreach(shader->uniforms, entry) { - print_var_decl((nir_variable *) entry->data, &state, fp); + foreach_list_typed(nir_variable, var, node, &shader->uniforms) { + print_var_decl(var, &state, fp); } - hash_table_foreach(shader->inputs, entry) { - print_var_decl((nir_variable *) entry->data, &state, fp); + foreach_list_typed(nir_variable, var, node, &shader->inputs) { + print_var_decl(var, &state, fp); } - hash_table_foreach(shader->outputs, entry) { - print_var_decl((nir_variable *) entry->data, &state, fp); + foreach_list_typed(nir_variable, var, node, &shader->outputs) { + print_var_decl(var, &state, fp); } foreach_list_typed(nir_variable, var, node, &shader->globals) { diff --git a/src/glsl/nir/nir_validate.c b/src/glsl/nir/nir_validate.c index a3fe9d6..f247ae0 100644 --- a/src/glsl/nir/nir_validate.c +++ b/src/glsl/nir/nir_validate.c @@ -931,17 +931,19 @@ nir_validate_shader(nir_shader *shader) state.shader = shader; - struct hash_entry *entry; - hash_table_foreach(shader->uniforms, entry) { - validate_var_decl((nir_variable *) entry->data, true, &state); + exec_list_validate(&shader->uniforms); + foreach_list_typed(nir_variable, var, node, &shader->uniforms) { + validate_var_decl(var, true, &state); } - hash_table_foreach(shader->inputs, entry) { - validate_var_decl((nir_variable *) entry->data, true, &state); + exec_list_validate(&shader->inputs); + foreach_list_typed(nir_variable, var, node, &shader->inputs) { + validate_var_decl(var, true, &state); } - hash_table_foreach(shader->outputs, entry) { - validate_var_decl((nir_variable *) entry->data, true, &state); + exec_list_validate(&shader->outputs); + foreach_list_typed(nir_variable, var, node, &shader->outputs) { + validate_var_decl(var, true, &state); } exec_list_validate(&shader->globals); diff --git a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp index a9e75ab..9431e5d 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp @@ -196,9 +196,7 @@ fs_visitor::emit_nir_code() void fs_visitor::nir_setup_inputs(nir_shader *shader) { - struct hash_entry *entry; - hash_table_foreach(shader->inputs, entry) { - nir_variable *var = (nir_variable *) entry->data; + foreach_list_typed(nir_variable, var, node, &shader->inputs) { enum brw_reg_type type = brw_type_for_base_type(var->type); fs_reg input = offset(nir_inputs, var->data.driver_location); @@ -250,9 +248,7 @@ fs_visitor::nir_setup_outputs(nir_shader *shader) { brw_wm_prog_key *key = (brw_wm_prog_key*) this->key; - struct hash_entry *entry; - hash_table_foreach(shader->outputs, entry) { - nir_variable *var = (nir_variable *) entry->data; + foreach_list_typed(nir_variable, var, node, &shader->outputs) { fs_reg reg = offset(nir_outputs, var->data.driver_location); int vector_elements = @@ -304,10 +300,7 @@ fs_visitor::nir_setup_uniforms(nir_shader *shader) if (dispatch_width != 8) return; - struct hash_entry *entry; - hash_table_foreach(shader->uniforms, entry) { - nir_variable *var = (nir_variable *) entry->data; - + foreach_list_typed(nir_variable, var, node, &shader->uniforms) { /* UBO's and atomics don't take up space in the uniform file */ if (var->interface_type != NULL || var->type->contains_atomic()) From jljusten at kemper.freedesktop.org Thu Mar 19 20:44:39 2015 From: jljusten at kemper.freedesktop.org (Jordan Justen) Date: Thu, 19 Mar 2015 13:44:39 -0700 (PDT) Subject: Mesa (master): main: Clean up a strange construction in use_shader_program (). Message-ID: <20150319204439.2738A76333@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 57b2652322c833f9007203488526571023279cfc URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=57b2652322c833f9007203488526571023279cfc Author: Paul Berry Date: Fri Jan 10 06:35:09 2014 -0800 main: Clean up a strange construction in use_shader_program(). Reviewed-by: Jordan Justen --- src/mesa/main/shaderapi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c index 3ea76af..6e73684 100644 --- a/src/mesa/main/shaderapi.c +++ b/src/mesa/main/shaderapi.c @@ -1035,7 +1035,7 @@ use_shader_program(struct gl_context *ctx, GLenum type, gl_shader_stage stage = _mesa_shader_enum_to_shader_stage(type); target = &shTarget->CurrentProgram[stage]; - if ((shProg == NULL) || (shProg->_LinkedShaders[stage] == NULL)) + if ((shProg != NULL) && (shProg->_LinkedShaders[stage] == NULL)) shProg = NULL; if (*target != shProg) { From jljusten at kemper.freedesktop.org Thu Mar 19 20:44:39 2015 From: jljusten at kemper.freedesktop.org (Jordan Justen) Date: Thu, 19 Mar 2015 13:44:39 -0700 (PDT) Subject: Mesa (master): main: Change the type argument of use_shader_program() to gl_shader_stage. Message-ID: <20150319204439.2F58A7633A@kemper.freedesktop.org> Module: Mesa Branch: master Commit: bf9d921936305e1514d4ce7a162c4f81eba3e9f5 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=bf9d921936305e1514d4ce7a162c4f81eba3e9f5 Author: Paul Berry Date: Fri Jan 10 06:48:11 2014 -0800 main: Change the type argument of use_shader_program() to gl_shader_stage. This allows it to be called from a loop. Reviewed-by: Jordan Justen Reviewed-by: Kristian H?gsberg --- src/mesa/main/shaderapi.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c index 6e73684..30716f5 100644 --- a/src/mesa/main/shaderapi.c +++ b/src/mesa/main/shaderapi.c @@ -1027,12 +1027,11 @@ _mesa_active_program(struct gl_context *ctx, struct gl_shader_program *shProg, static void -use_shader_program(struct gl_context *ctx, GLenum type, +use_shader_program(struct gl_context *ctx, gl_shader_stage stage, struct gl_shader_program *shProg, struct gl_pipeline_object *shTarget) { struct gl_shader_program **target; - gl_shader_stage stage = _mesa_shader_enum_to_shader_stage(type); target = &shTarget->CurrentProgram[stage]; if ((shProg != NULL) && (shProg->_LinkedShaders[stage] == NULL)) @@ -1048,17 +1047,17 @@ use_shader_program(struct gl_context *ctx, GLenum type, * it from that binding point as well. This ensures that the correct * semantics of glDeleteProgram are maintained. */ - switch (type) { - case GL_VERTEX_SHADER: + switch (stage) { + case MESA_SHADER_VERTEX: /* Empty for now. */ break; - case GL_GEOMETRY_SHADER_ARB: + case MESA_SHADER_GEOMETRY: /* Empty for now. */ break; - case GL_COMPUTE_SHADER: + case MESA_SHADER_COMPUTE: /* Empty for now. */ break; - case GL_FRAGMENT_SHADER: + case MESA_SHADER_FRAGMENT: if (*target == ctx->_Shader->_CurrentFragmentProgram) { _mesa_reference_shader_program(ctx, &ctx->_Shader->_CurrentFragmentProgram, @@ -1079,10 +1078,9 @@ use_shader_program(struct gl_context *ctx, GLenum type, void _mesa_use_program(struct gl_context *ctx, struct gl_shader_program *shProg) { - use_shader_program(ctx, GL_VERTEX_SHADER, shProg, &ctx->Shader); - use_shader_program(ctx, GL_GEOMETRY_SHADER_ARB, shProg, &ctx->Shader); - use_shader_program(ctx, GL_FRAGMENT_SHADER, shProg, &ctx->Shader); - use_shader_program(ctx, GL_COMPUTE_SHADER, shProg, &ctx->Shader); + int i; + for (i = 0; i < MESA_SHADER_STAGES; i++) + use_shader_program(ctx, i, shProg, &ctx->Shader); _mesa_active_program(ctx, shProg, "glUseProgram"); if (ctx->Driver.UseProgram) @@ -1889,7 +1887,8 @@ _mesa_use_shader_program(struct gl_context *ctx, GLenum type, struct gl_shader_program *shProg, struct gl_pipeline_object *shTarget) { - use_shader_program(ctx, type, shProg, shTarget); + gl_shader_stage stage = _mesa_shader_enum_to_shader_stage(type); + use_shader_program(ctx, stage, shProg, shTarget); if (ctx->Driver.UseProgram) ctx->Driver.UseProgram(ctx, shProg); From idr at kemper.freedesktop.org Thu Mar 19 22:37:14 2015 From: idr at kemper.freedesktop.org (Ian Romanick) Date: Thu, 19 Mar 2015 15:37:14 -0700 (PDT) Subject: Mesa (master): glsl: Annotate as_foo functions that the this pointer cannot be NULL Message-ID: <20150319223714.08C9776333@kemper.freedesktop.org> Module: Mesa Branch: master Commit: a44b95cd574ecab4a4c41c6380c82db6029ad114 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=a44b95cd574ecab4a4c41c6380c82db6029ad114 Author: Ian Romanick Date: Mon Mar 16 12:14:10 2015 -0700 glsl: Annotate as_foo functions that the this pointer cannot be NULL We use the idiom ir_foo *x = y->as_foo(); if (x == NULL) return; all over the place. GCC generates some quite lovely code for this. One such example: 340a5b: 83 7d 18 04 cmpl $0x4,0x18(%rbp) 340a5f: 0f 85 06 04 00 00 jne 340e6b 340a65: 48 85 ed test %rbp,%rbp 340a68: 0f 84 fd 03 00 00 je 340e6b This case used as_expression() (ir_type_expression is 4). Note that it checks the ir_type, then checks that the pointer isn't NULL. There is some disconnect in GCC around the condition in the as_foo functions. return ir_type == ir_type_##TYPE ? (ir_##TYPE *) this : NULL; \ It believes "this" could be NULL, so it emits check outside the function just for fun. This patch uses assume() to tell GCC that it need not bother with extra NULL checking of the pointer returned by the as_foo functions. text data bss dec hex filename 4836430 158688 26248 5021366 4c9eb6 i965_dri-before.so 4836173 158688 26248 5021109 4c9db5 i965_dri-after.so v2: Replace 'if (this == NULL) unreachable("this cannot be NULL")' with assume(this != NULL). Suggested by Ilia Mirkin. Signed-off-by: Ian Romanick Reviewed-by: Matt Turner --- src/glsl/ir.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/glsl/ir.h b/src/glsl/ir.h index 25f2eca..fdc22ed 100644 --- a/src/glsl/ir.h +++ b/src/glsl/ir.h @@ -119,6 +119,7 @@ public: /*@{*/ class ir_rvalue *as_rvalue() { + assume(this != NULL); if (ir_type == ir_type_dereference_array || ir_type == ir_type_dereference_record || ir_type == ir_type_dereference_variable || @@ -132,6 +133,7 @@ public: class ir_dereference *as_dereference() { + assume(this != NULL); if (ir_type == ir_type_dereference_array || ir_type == ir_type_dereference_record || ir_type == ir_type_dereference_variable) @@ -141,6 +143,7 @@ public: class ir_jump *as_jump() { + assume(this != NULL); if (ir_type == ir_type_loop_jump || ir_type == ir_type_return || ir_type == ir_type_discard) @@ -151,6 +154,7 @@ public: #define AS_CHILD(TYPE) \ class ir_##TYPE * as_##TYPE() \ { \ + assume(this != NULL); \ return ir_type == ir_type_##TYPE ? (ir_##TYPE *) this : NULL; \ } AS_CHILD(variable) From ldeks at kemper.freedesktop.org Thu Mar 19 23:08:30 2015 From: ldeks at kemper.freedesktop.org (Laura Ekstrand) Date: Thu, 19 Mar 2015 16:08:30 -0700 (PDT) Subject: Mesa (master): main: Simplify debug messages for CopyTex*SubImage*D. Message-ID: <20150319230830.D9C6676333@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 037e36a8aad623b0e16e4d69774dbeb5bcf456d1 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=037e36a8aad623b0e16e4d69774dbeb5bcf456d1 Author: Laura Ekstrand Date: Thu Mar 19 10:43:17 2015 -0700 main: Simplify debug messages for CopyTex*SubImage*D. Reviewed-by: Martin Peres Reviewed-by: Anuj Phogat --- src/mesa/main/teximage.c | 84 ++++++++++++++++++++-------------------------- src/mesa/main/teximage.h | 3 +- 2 files changed, 38 insertions(+), 49 deletions(-) diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c index 64e4816..5516005 100644 --- a/src/mesa/main/teximage.c +++ b/src/mesa/main/teximage.c @@ -2826,10 +2826,9 @@ copytexsubimage_error_check(struct gl_context *ctx, GLuint dimensions, const struct gl_texture_object *texObj, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, - GLint width, GLint height, bool dsa) + GLint width, GLint height, const char *caller) { struct gl_texture_image *texImage; - const char *suffix = dsa ? "ture" : ""; /* Check that the source buffer is complete */ if (_mesa_is_user_fbo(ctx->ReadBuffer)) { @@ -2838,31 +2837,26 @@ copytexsubimage_error_check(struct gl_context *ctx, GLuint dimensions, } if (ctx->ReadBuffer->_Status != GL_FRAMEBUFFER_COMPLETE_EXT) { _mesa_error(ctx, GL_INVALID_FRAMEBUFFER_OPERATION_EXT, - "glCopyTex%sSubImage%dD(invalid readbuffer)", - suffix, dimensions); + "%s(invalid readbuffer)", caller); return GL_TRUE; } if (ctx->ReadBuffer->Visual.samples > 0) { _mesa_error(ctx, GL_INVALID_OPERATION, - "glCopyTex%sSubImage%dD(multisample FBO)", suffix, - dimensions); + "%s(multisample FBO)", caller); return GL_TRUE; } } /* Check level */ if (level < 0 || level >= _mesa_max_texture_levels(ctx, target)) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glCopyTex%sSubImage%dD(level=%d)", suffix, - dimensions, level); + _mesa_error(ctx, GL_INVALID_VALUE, "%s(level=%d)", caller, level); return GL_TRUE; } /* Get dest image pointers */ if (!texObj) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyTex%sSubImage%dD()", - suffix, dimensions); + _mesa_error(ctx, GL_OUT_OF_MEMORY, "%s()", caller); return GL_TRUE; } @@ -2870,37 +2864,33 @@ copytexsubimage_error_check(struct gl_context *ctx, GLuint dimensions, if (!texImage) { /* destination image does not exist */ _mesa_error(ctx, GL_INVALID_OPERATION, - "glCopyTex%sSubImage%dD(invalid texture image)", - suffix, dimensions); + "%s(invalid texture image)", caller); return GL_TRUE; } if (error_check_subtexture_dimensions(ctx, dimensions, texImage, xoffset, yoffset, zoffset, - width, height, 1, dsa ? - "glCompressedTextureSubImage" : - "glCompressedTexSubImage")) { + width, height, 1, caller)) { return GL_TRUE; } if (_mesa_is_format_compressed(texImage->TexFormat)) { if (compressedteximage_only_format(ctx, texImage->InternalFormat)) { _mesa_error(ctx, GL_INVALID_OPERATION, - "glCopyTex%sSubImage%dD(no compression for format)", - suffix, dimensions); + "%s(no compression for format)", caller); return GL_TRUE; } } if (texImage->InternalFormat == GL_YCBCR_MESA) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glCopyTex%sSubImage2D", suffix); + _mesa_error(ctx, GL_INVALID_OPERATION, "%s()", caller); return GL_TRUE; } if (!_mesa_source_buffer_exists(ctx, texImage->_BaseFormat)) { _mesa_error(ctx, GL_INVALID_OPERATION, - "glCopyTex%sSubImage%dD(missing readbuffer, format=0x%x)", - suffix, dimensions, texImage->_BaseFormat); + "%s(missing readbuffer, format=0x%x)", caller, + texImage->_BaseFormat); return GL_TRUE; } @@ -2918,8 +2908,7 @@ copytexsubimage_error_check(struct gl_context *ctx, GLuint dimensions, if (_mesa_is_format_integer_color(rb->Format) != _mesa_is_format_integer_color(texImage->TexFormat)) { _mesa_error(ctx, GL_INVALID_OPERATION, - "glCopyTex%sSubImage%dD(integer vs non-integer)", - suffix, dimensions); + "%s(integer vs non-integer)", caller); return GL_TRUE; } } @@ -4043,15 +4032,14 @@ _mesa_copy_texture_sub_image(struct gl_context *ctx, GLuint dims, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height, - bool dsa) + const char *caller) { struct gl_texture_image *texImage; FLUSH_VERTICES(ctx, 0); if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE)) - _mesa_debug(ctx, "glCopyTex%sSubImage%uD %s %d %d %d %d %d %d %d %d\n", - dsa ? "ture" : "", dims, + _mesa_debug(ctx, "%s %s %d %d %d %d %d %d %d %d\n", caller, _mesa_lookup_enum_by_nr(target), level, xoffset, yoffset, zoffset, x, y, width, height); @@ -4060,7 +4048,7 @@ _mesa_copy_texture_sub_image(struct gl_context *ctx, GLuint dims, if (copytexsubimage_error_check(ctx, dims, texObj, target, level, xoffset, yoffset, zoffset, - width, height, dsa)) { + width, height, caller)) { return; } @@ -4106,14 +4094,14 @@ _mesa_CopyTexSubImage1D( GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width ) { struct gl_texture_object* texObj; + const char *self = "glCopyTexSubImage1D"; GET_CURRENT_CONTEXT(ctx); /* Check target (proxies not allowed). Target must be checked prior to * calling _mesa_get_current_tex_object. */ if (!legal_texsubimage_target(ctx, 1, target, false)) { - _mesa_error(ctx, GL_INVALID_ENUM, - "glCopyTexSubImage1D(invalid target %s)", + _mesa_error(ctx, GL_INVALID_ENUM, "%s(invalid target %s)", self, _mesa_lookup_enum_by_nr(target)); return; } @@ -4123,7 +4111,7 @@ _mesa_CopyTexSubImage1D( GLenum target, GLint level, return; _mesa_copy_texture_sub_image(ctx, 1, texObj, target, level, xoffset, 0, 0, - x, y, width, 1, false); + x, y, width, 1, self); } @@ -4134,14 +4122,14 @@ _mesa_CopyTexSubImage2D( GLenum target, GLint level, GLint x, GLint y, GLsizei width, GLsizei height ) { struct gl_texture_object* texObj; + const char *self = "glCopyTexSubImage2D"; GET_CURRENT_CONTEXT(ctx); /* Check target (proxies not allowed). Target must be checked prior to * calling _mesa_get_current_tex_object. */ if (!legal_texsubimage_target(ctx, 2, target, false)) { - _mesa_error(ctx, GL_INVALID_ENUM, - "glCopyTexSubImage2D(invalid target %s)", + _mesa_error(ctx, GL_INVALID_ENUM, "%s(invalid target %s)", self, _mesa_lookup_enum_by_nr(target)); return; } @@ -4152,7 +4140,7 @@ _mesa_CopyTexSubImage2D( GLenum target, GLint level, _mesa_copy_texture_sub_image(ctx, 2, texObj, target, level, xoffset, yoffset, 0, - x, y, width, height, false); + x, y, width, height, self); } @@ -4163,14 +4151,14 @@ _mesa_CopyTexSubImage3D( GLenum target, GLint level, GLint x, GLint y, GLsizei width, GLsizei height ) { struct gl_texture_object* texObj; + const char *self = "glCopyTexSubImage3D"; GET_CURRENT_CONTEXT(ctx); /* Check target (proxies not allowed). Target must be checked prior to * calling _mesa_get_current_tex_object. */ if (!legal_texsubimage_target(ctx, 3, target, false)) { - _mesa_error(ctx, GL_INVALID_ENUM, - "glCopyTexSubImage3D(invalid target %s)", + _mesa_error(ctx, GL_INVALID_ENUM, "%s(invalid target %s)", self, _mesa_lookup_enum_by_nr(target)); return; } @@ -4181,7 +4169,7 @@ _mesa_CopyTexSubImage3D( GLenum target, GLint level, _mesa_copy_texture_sub_image(ctx, 3, texObj, target, level, xoffset, yoffset, zoffset, - x, y, width, height, false); + x, y, width, height, self); } void GLAPIENTRY @@ -4189,22 +4177,22 @@ _mesa_CopyTextureSubImage1D(GLuint texture, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width) { struct gl_texture_object* texObj; + const char *self = "glCopyTextureSubImage1D"; GET_CURRENT_CONTEXT(ctx); - texObj = _mesa_lookup_texture_err(ctx, texture, "glCopyTextureSubImage1D"); + texObj = _mesa_lookup_texture_err(ctx, texture, self); if (!texObj) return; /* Check target (proxies not allowed). */ if (!legal_texsubimage_target(ctx, 1, texObj->Target, true)) { - _mesa_error(ctx, GL_INVALID_ENUM, - "glCopyTextureSubImage1D(invalid target %s)", + _mesa_error(ctx, GL_INVALID_ENUM, "%s(invalid target %s)", self, _mesa_lookup_enum_by_nr(texObj->Target)); return; } _mesa_copy_texture_sub_image(ctx, 1, texObj, texObj->Target, level, - xoffset, 0, 0, x, y, width, 1, true); + xoffset, 0, 0, x, y, width, 1, self); } void GLAPIENTRY @@ -4213,23 +4201,23 @@ _mesa_CopyTextureSubImage2D(GLuint texture, GLint level, GLint x, GLint y, GLsizei width, GLsizei height) { struct gl_texture_object* texObj; + const char *self = "glCopyTextureSubImage2D"; GET_CURRENT_CONTEXT(ctx); - texObj = _mesa_lookup_texture_err(ctx, texture, "glCopyTextureSubImage2D"); + texObj = _mesa_lookup_texture_err(ctx, texture, self); if (!texObj) return; /* Check target (proxies not allowed). */ if (!legal_texsubimage_target(ctx, 2, texObj->Target, true)) { - _mesa_error(ctx, GL_INVALID_ENUM, - "glCopyTextureSubImage2D(invalid target %s)", + _mesa_error(ctx, GL_INVALID_ENUM, "%s(invalid target %s)", self, _mesa_lookup_enum_by_nr(texObj->Target)); return; } _mesa_copy_texture_sub_image(ctx, 2, texObj, texObj->Target, level, xoffset, yoffset, 0, - x, y, width, height, true); + x, y, width, height, self); } @@ -4240,23 +4228,23 @@ _mesa_CopyTextureSubImage3D(GLuint texture, GLint level, GLint x, GLint y, GLsizei width, GLsizei height) { struct gl_texture_object* texObj; + const char *self = "glCopyTextureSubImage3D"; GET_CURRENT_CONTEXT(ctx); - texObj = _mesa_lookup_texture_err(ctx, texture, "glCopyTextureSubImage3D"); + texObj = _mesa_lookup_texture_err(ctx, texture, self); if (!texObj) return; /* Check target (proxies not allowed). */ if (!legal_texsubimage_target(ctx, 3, texObj->Target, true)) { - _mesa_error(ctx, GL_INVALID_ENUM, - "glCopyTextureSubImage3D(invalid target %s)", + _mesa_error(ctx, GL_INVALID_ENUM, "%s(invalid target %s)", self, _mesa_lookup_enum_by_nr(texObj->Target)); return; } _mesa_copy_texture_sub_image(ctx, 3, texObj, texObj->Target, level, xoffset, yoffset, zoffset, - x, y, width, height, true); + x, y, width, height, self); } static bool diff --git a/src/mesa/main/teximage.h b/src/mesa/main/teximage.h index 0ce4a30..1eebaa8 100644 --- a/src/mesa/main/teximage.h +++ b/src/mesa/main/teximage.h @@ -196,7 +196,8 @@ _mesa_copy_texture_sub_image(struct gl_context *ctx, GLuint dims, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, - GLsizei width, GLsizei height, bool dsa); + GLsizei width, GLsizei height, + const char *caller); extern void _mesa_texture_image_multisample(struct gl_context *ctx, GLuint dims, From ldeks at kemper.freedesktop.org Thu Mar 19 23:08:30 2015 From: ldeks at kemper.freedesktop.org (Laura Ekstrand) Date: Thu, 19 Mar 2015 16:08:30 -0700 (PDT) Subject: Mesa (master): main: Add TEXTURE_CUBE_MAP support in CopyTextureSubImage3D. Message-ID: <20150319230830.E307A7633A@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 09bfa326a90a0ec1ddce0dc971d7d4b429884266 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=09bfa326a90a0ec1ddce0dc971d7d4b429884266 Author: Laura Ekstrand Date: Tue Mar 17 12:55:41 2015 -0700 main: Add TEXTURE_CUBE_MAP support in CopyTextureSubImage3D. So it turns out that this doesn't actually fix any bugs or add any features, stictly speaking. However, it does avoid a lot of kludginess. Previously, if you called glCopyTextureSubImage3D(texcube, 0, 0, 0, zoffset = 3, ... it would grab the texture image object for face = 0 in teximage.c instead of the desired face = 3. But Line 274 of brw_blorp_blit.cpp would correct for this by updating the slice to 3. This commit does the correct thing before calling any drivers, which should make the functionality much more robust and uniform across all drivers. Reviewed-by: Anuj Phogat --- src/mesa/main/teximage.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c index 5516005..8d9d7cf 100644 --- a/src/mesa/main/teximage.c +++ b/src/mesa/main/teximage.c @@ -4242,9 +4242,17 @@ _mesa_CopyTextureSubImage3D(GLuint texture, GLint level, return; } - _mesa_copy_texture_sub_image(ctx, 3, texObj, texObj->Target, level, - xoffset, yoffset, zoffset, - x, y, width, height, self); + if (texObj->Target == GL_TEXTURE_CUBE_MAP) { + /* Act like CopyTexSubImage2D */ + _mesa_copy_texture_sub_image(ctx, 2, texObj, + GL_TEXTURE_CUBE_MAP_POSITIVE_X + zoffset, + level, xoffset, yoffset, 0, + x, y, width, height, self); + } + else + _mesa_copy_texture_sub_image(ctx, 3, texObj, texObj->Target, level, + xoffset, yoffset, zoffset, + x, y, width, height, self); } static bool From kwg at kemper.freedesktop.org Thu Mar 19 23:15:14 2015 From: kwg at kemper.freedesktop.org (Kenneth Graunke) Date: Thu, 19 Mar 2015 16:15:14 -0700 (PDT) Subject: Mesa (master): i965/fs: Make an emit_discard_jump() function to reduce duplication. Message-ID: <20150319231514.448DF76333@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 8a0946f3b1522e5f91afe14c8c3b22ba6009ed04 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=8a0946f3b1522e5f91afe14c8c3b22ba6009ed04 Author: Kenneth Graunke Date: Thu Mar 5 15:48:39 2015 -0800 i965/fs: Make an emit_discard_jump() function to reduce duplication. This is already copied in two places, and I want to copy it to a third place. Signed-off-by: Kenneth Graunke Reviewed-by: Carl Worth Reviewed-by: Matt Turner --- src/mesa/drivers/dri/i965/brw_fs.cpp | 15 +++++++++++++++ src/mesa/drivers/dri/i965/brw_fs.h | 1 + src/mesa/drivers/dri/i965/brw_fs_nir.cpp | 12 +----------- src/mesa/drivers/dri/i965/brw_fs_visitor.cpp | 11 +---------- 4 files changed, 18 insertions(+), 21 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp index 1008467..780be80 100644 --- a/src/mesa/drivers/dri/i965/brw_fs.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs.cpp @@ -1694,6 +1694,21 @@ fs_visitor::emit_math(enum opcode opcode, fs_reg dst, fs_reg src0, fs_reg src1) } void +fs_visitor::emit_discard_jump() +{ + /* For performance, after a discard, jump to the end of the + * shader if all relevant channels have been discarded. + */ + fs_inst *discard_jump = emit(FS_OPCODE_DISCARD_JUMP); + discard_jump->flag_subreg = 1; + + discard_jump->predicate = (dispatch_width == 8) + ? BRW_PREDICATE_ALIGN1_ANY8H + : BRW_PREDICATE_ALIGN1_ANY16H; + discard_jump->predicate_inverse = true; +} + +void fs_visitor::assign_curb_setup() { if (dispatch_width == 8) { diff --git a/src/mesa/drivers/dri/i965/brw_fs.h b/src/mesa/drivers/dri/i965/brw_fs.h index 8317831..608262f 100644 --- a/src/mesa/drivers/dri/i965/brw_fs.h +++ b/src/mesa/drivers/dri/i965/brw_fs.h @@ -307,6 +307,7 @@ public: const fs_reg &a); void emit_minmax(enum brw_conditional_mod conditionalmod, const fs_reg &dst, const fs_reg &src0, const fs_reg &src1); + void emit_discard_jump(); bool try_emit_b2f_of_comparison(ir_expression *ir); bool try_emit_saturate(ir_expression *ir); bool try_emit_line(ir_expression *ir); diff --git a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp index 05506f5..5d88fe7 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp @@ -1363,18 +1363,8 @@ fs_visitor::nir_emit_intrinsic(nir_intrinsic_instr *instr) cmp->flag_subreg = 1; if (brw->gen >= 6) { - /* For performance, after a discard, jump to the end of the shader. - * Only jump if all relevant channels have been discarded. - */ - fs_inst *discard_jump = emit(FS_OPCODE_DISCARD_JUMP); - discard_jump->flag_subreg = 1; - - discard_jump->predicate = (dispatch_width == 8) - ? BRW_PREDICATE_ALIGN1_ANY8H - : BRW_PREDICATE_ALIGN1_ANY16H; - discard_jump->predicate_inverse = true; + emit_discard_jump(); } - break; } diff --git a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp index 60a7a97..2920a82 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp @@ -2497,16 +2497,7 @@ fs_visitor::visit(ir_discard *ir) cmp->flag_subreg = 1; if (brw->gen >= 6) { - /* For performance, after a discard, jump to the end of the shader. - * Only jump if all relevant channels have been discarded. - */ - fs_inst *discard_jump = emit(FS_OPCODE_DISCARD_JUMP); - discard_jump->flag_subreg = 1; - - discard_jump->predicate = (dispatch_width == 8) - ? BRW_PREDICATE_ALIGN1_ANY8H - : BRW_PREDICATE_ALIGN1_ANY16H; - discard_jump->predicate_inverse = true; + emit_discard_jump(); } } From kwg at kemper.freedesktop.org Thu Mar 19 23:15:14 2015 From: kwg at kemper.freedesktop.org (Kenneth Graunke) Date: Thu, 19 Mar 2015 16:15:14 -0700 (PDT) Subject: Mesa (master): i965/fp: Emit discard jumps. Message-ID: <20150319231514.4AE457633A@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 201aef9d1370ff524f856b725d2328c4f48199e8 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=201aef9d1370ff524f856b725d2328c4f48199e8 Author: Kenneth Graunke Date: Tue Feb 24 12:48:56 2015 -0800 i965/fp: Emit discard jumps. This should improve the performance of any shaders using the KIL instruction. I'm a bit surprised we missed this. Unfortunately, I have not been able to measure any performance improvements from this patch. It does make ARB_fragment_program behave similarly to GLSL code. Signed-off-by: Kenneth Graunke Reviewed-by: Matt Turner --- src/mesa/drivers/dri/i965/brw_fs_fp.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/mesa/drivers/dri/i965/brw_fs_fp.cpp b/src/mesa/drivers/dri/i965/brw_fs_fp.cpp index 6d08bf7..c4064da 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_fp.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_fp.cpp @@ -250,6 +250,9 @@ fs_visitor::emit_fragment_program_code() fs_reg(0.0f), BRW_CONDITIONAL_GE)); cmp->predicate = BRW_PREDICATE_NORMAL; cmp->flag_subreg = 1; + + if (brw->gen >= 6) + emit_discard_jump(); } break; } From airlied at kemper.freedesktop.org Thu Mar 19 23:46:50 2015 From: airlied at kemper.freedesktop.org (Dave Airlie) Date: Thu, 19 Mar 2015 16:46:50 -0700 (PDT) Subject: Mesa (master): u_primconvert: add primitive restart support Message-ID: <20150319234650.68A1F76333@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 9d97cd2e3e993658ebe038f4652dc59c3ae56031 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=9d97cd2e3e993658ebe038f4652dc59c3ae56031 Author: Dave Airlie Date: Wed Mar 18 11:46:45 2015 +1000 u_primconvert: add primitive restart support This add primitive restart support to the prim conversion. This involves changing the API for the translate functions as we need to pass the prim restart index and the original number of indices into the translate functions. primitive restart is support for quads, quad strips and polygons. This deal with the case where the actual number of output primitives is less than the initially calculated number, by filling the rest of the output primitives with the restart index, the other option is to reduce the output prim number, but that will make the generator code a bit messier. Reviewed-by: Brian Paul Signed-off-by: Dave Airlie --- src/gallium/auxiliary/indices/u_indices.c | 36 ++-- src/gallium/auxiliary/indices/u_indices.h | 9 +- src/gallium/auxiliary/indices/u_indices_gen.py | 198 ++++++++++++++------ src/gallium/auxiliary/indices/u_primconvert.c | 6 +- src/gallium/auxiliary/indices/u_unfilled_gen.py | 20 +- src/gallium/auxiliary/indices/u_unfilled_indices.c | 18 +- src/gallium/drivers/svga/svga_draw_elements.c | 3 +- 7 files changed, 203 insertions(+), 87 deletions(-) diff --git a/src/gallium/auxiliary/indices/u_indices.c b/src/gallium/auxiliary/indices/u_indices.c index 1b33f41..c25594b 100644 --- a/src/gallium/auxiliary/indices/u_indices.c +++ b/src/gallium/auxiliary/indices/u_indices.c @@ -27,18 +27,22 @@ static void translate_memcpy_ushort( const void *in, unsigned start, - unsigned nr, + unsigned in_nr, + unsigned out_nr, + unsigned restart_index, void *out ) { - memcpy(out, &((short *)in)[start], nr*sizeof(short)); + memcpy(out, &((short *)in)[start], out_nr*sizeof(short)); } static void translate_memcpy_uint( const void *in, unsigned start, - unsigned nr, + unsigned in_nr, + unsigned out_nr, + unsigned restart_index, void *out ) { - memcpy(out, &((int *)in)[start], nr*sizeof(int)); + memcpy(out, &((int *)in)[start], out_nr*sizeof(int)); } @@ -58,6 +62,7 @@ static void translate_memcpy_uint( const void *in, * \param nr number of incoming vertices * \param in_pv incoming provoking vertex convention (PV_FIRST or PV_LAST) * \param out_pv desired provoking vertex convention (PV_FIRST or PV_LAST) + * \param prim_restart whether primitive restart is disable or enabled * \param out_prim returns new PIPE_PRIM_x we'll translate to * \param out_index_size returns bytes per new index value (2 or 4) * \param out_nr returns number of new vertices @@ -69,6 +74,7 @@ int u_index_translator( unsigned hw_mask, unsigned nr, unsigned in_pv, unsigned out_pv, + unsigned prim_restart, unsigned *out_prim, unsigned *out_index_size, unsigned *out_nr, @@ -106,68 +112,68 @@ int u_index_translator( unsigned hw_mask, else { switch (prim) { case PIPE_PRIM_POINTS: - *out_translate = translate[in_idx][out_idx][in_pv][out_pv][prim]; + *out_translate = translate[in_idx][out_idx][in_pv][out_pv][prim_restart][prim]; *out_prim = PIPE_PRIM_POINTS; *out_nr = nr; break; case PIPE_PRIM_LINES: - *out_translate = translate[in_idx][out_idx][in_pv][out_pv][prim]; + *out_translate = translate[in_idx][out_idx][in_pv][out_pv][prim_restart][prim]; *out_prim = PIPE_PRIM_LINES; *out_nr = nr; break; case PIPE_PRIM_LINE_STRIP: - *out_translate = translate[in_idx][out_idx][in_pv][out_pv][prim]; + *out_translate = translate[in_idx][out_idx][in_pv][out_pv][prim_restart][prim]; *out_prim = PIPE_PRIM_LINES; *out_nr = (nr - 1) * 2; break; case PIPE_PRIM_LINE_LOOP: - *out_translate = translate[in_idx][out_idx][in_pv][out_pv][prim]; + *out_translate = translate[in_idx][out_idx][in_pv][out_pv][prim_restart][prim]; *out_prim = PIPE_PRIM_LINES; *out_nr = nr * 2; break; case PIPE_PRIM_TRIANGLES: - *out_translate = translate[in_idx][out_idx][in_pv][out_pv][prim]; + *out_translate = translate[in_idx][out_idx][in_pv][out_pv][prim_restart][prim]; *out_prim = PIPE_PRIM_TRIANGLES; *out_nr = nr; break; case PIPE_PRIM_TRIANGLE_STRIP: - *out_translate = translate[in_idx][out_idx][in_pv][out_pv][prim]; + *out_translate = translate[in_idx][out_idx][in_pv][out_pv][prim_restart][prim]; *out_prim = PIPE_PRIM_TRIANGLES; *out_nr = (nr - 2) * 3; break; case PIPE_PRIM_TRIANGLE_FAN: - *out_translate = translate[in_idx][out_idx][in_pv][out_pv][prim]; + *out_translate = translate[in_idx][out_idx][in_pv][out_pv][prim_restart][prim]; *out_prim = PIPE_PRIM_TRIANGLES; *out_nr = (nr - 2) * 3; break; case PIPE_PRIM_QUADS: - *out_translate = translate[in_idx][out_idx][in_pv][out_pv][prim]; + *out_translate = translate[in_idx][out_idx][in_pv][out_pv][prim_restart][prim]; *out_prim = PIPE_PRIM_TRIANGLES; *out_nr = (nr / 4) * 6; break; case PIPE_PRIM_QUAD_STRIP: - *out_translate = translate[in_idx][out_idx][in_pv][out_pv][prim]; + *out_translate = translate[in_idx][out_idx][in_pv][out_pv][prim_restart][prim]; *out_prim = PIPE_PRIM_TRIANGLES; *out_nr = (nr - 2) * 3; break; case PIPE_PRIM_POLYGON: - *out_translate = translate[in_idx][out_idx][in_pv][out_pv][prim]; + *out_translate = translate[in_idx][out_idx][in_pv][out_pv][prim_restart][prim]; *out_prim = PIPE_PRIM_TRIANGLES; *out_nr = (nr - 2) * 3; break; default: assert(0); - *out_translate = translate[in_idx][out_idx][in_pv][out_pv][prim]; + *out_translate = translate[in_idx][out_idx][in_pv][out_pv][prim_restart][prim]; *out_prim = PIPE_PRIM_POINTS; *out_nr = nr; return U_TRANSLATE_ERROR; diff --git a/src/gallium/auxiliary/indices/u_indices.h b/src/gallium/auxiliary/indices/u_indices.h index 54cd944..e01201e 100644 --- a/src/gallium/auxiliary/indices/u_indices.h +++ b/src/gallium/auxiliary/indices/u_indices.h @@ -31,6 +31,10 @@ #define PV_LAST 1 #define PV_COUNT 2 +/* primitive restart disable/enable flags */ +#define PR_DISABLE 0 +#define PR_ENABLE 1 +#define PR_COUNT 2 /** * Index translator function (for glDrawElements() case) * @@ -42,7 +46,9 @@ */ typedef void (*u_translate_func)( const void *in, unsigned start, - unsigned nr, + unsigned in_nr, + unsigned out_nr, + unsigned restart_index, void *out ); /** @@ -77,6 +83,7 @@ int u_index_translator( unsigned hw_mask, unsigned nr, unsigned in_pv, /* API */ unsigned out_pv, /* hardware */ + unsigned prim_restart, unsigned *out_prim, unsigned *out_index_size, unsigned *out_nr, diff --git a/src/gallium/auxiliary/indices/u_indices_gen.py b/src/gallium/auxiliary/indices/u_indices_gen.py index f05b70a..687a717 100644 --- a/src/gallium/auxiliary/indices/u_indices_gen.py +++ b/src/gallium/auxiliary/indices/u_indices_gen.py @@ -27,10 +27,12 @@ copyright = ''' GENERATE, UBYTE, USHORT, UINT = 'generate', 'ubyte', 'ushort', 'uint' FIRST, LAST = 'first', 'last' +PRDISABLE, PRENABLE = 'prdisable', 'prenable' INTYPES = (GENERATE, UBYTE, USHORT, UINT) OUTTYPES = (USHORT, UINT) PVS=(FIRST, LAST) +PRS=(PRDISABLE, PRENABLE) PRIMS=('points', 'lines', 'linestrip', @@ -57,7 +59,7 @@ longprim = dict(zip(PRIMS, LONGPRIMS)) intype_idx = dict(ubyte='IN_UBYTE', ushort='IN_USHORT', uint='IN_UINT') outtype_idx = dict(ushort='OUT_USHORT', uint='OUT_UINT') pv_idx = dict(first='PV_FIRST', last='PV_LAST') - +pr_idx = dict(prdisable='PR_DISABLE', prenable='PR_ENABLE') def prolog(): print '''/* File automatically generated by indices.py */''' @@ -97,7 +99,7 @@ static unsigned in_size_idx( unsigned index_size ) } -static u_translate_func translate[IN_COUNT][OUT_COUNT][PV_COUNT][PV_COUNT][PRIM_COUNT]; +static u_translate_func translate[IN_COUNT][OUT_COUNT][PV_COUNT][PV_COUNT][PR_COUNT][PRIM_COUNT]; static u_generate_func generate[OUT_COUNT][PV_COUNT][PV_COUNT][PRIM_COUNT]; @@ -143,18 +145,22 @@ def do_quad( intype, outtype, ptr, v0, v1, v2, v3, inpv, outpv ): do_tri( intype, outtype, ptr+'+0', v0, v1, v3, inpv, outpv ); do_tri( intype, outtype, ptr+'+3', v1, v2, v3, inpv, outpv ); -def name(intype, outtype, inpv, outpv, prim): +def name(intype, outtype, inpv, outpv, pr, prim): if intype == GENERATE: return 'generate_' + prim + '_' + outtype + '_' + inpv + '2' + outpv else: - return 'translate_' + prim + '_' + intype + '2' + outtype + '_' + inpv + '2' + outpv + return 'translate_' + prim + '_' + intype + '2' + outtype + '_' + inpv + '2' + outpv + '_' + pr -def preamble(intype, outtype, inpv, outpv, prim): - print 'static void ' + name( intype, outtype, inpv, outpv, prim ) + '(' +def preamble(intype, outtype, inpv, outpv, pr, prim): + print 'static void ' + name( intype, outtype, inpv, outpv, pr, prim ) + '(' if intype != GENERATE: print ' const void * _in,' print ' unsigned start,' - print ' unsigned nr,' + if intype != GENERATE: + print ' unsigned in_nr,' + print ' unsigned out_nr,' + if intype != GENERATE: + print ' unsigned restart_index,' print ' void *_out )' print '{' if intype != GENERATE: @@ -167,46 +173,46 @@ def postamble(): print '}' -def points(intype, outtype, inpv, outpv): - preamble(intype, outtype, inpv, outpv, prim='points') - print ' for (i = start; i < (nr+start); i++) { ' +def points(intype, outtype, inpv, outpv, pr): + preamble(intype, outtype, inpv, outpv, pr, prim='points') + print ' for (i = start; i < (out_nr+start); i++) { ' do_point( intype, outtype, 'out+i', 'i' ); print ' }' postamble() -def lines(intype, outtype, inpv, outpv): - preamble(intype, outtype, inpv, outpv, prim='lines') - print ' for (i = start; i < (nr+start); i+=2) { ' +def lines(intype, outtype, inpv, outpv, pr): + preamble(intype, outtype, inpv, outpv, pr, prim='lines') + print ' for (i = start; i < (out_nr+start); i+=2) { ' do_line( intype, outtype, 'out+i', 'i', 'i+1', inpv, outpv ); print ' }' postamble() -def linestrip(intype, outtype, inpv, outpv): - preamble(intype, outtype, inpv, outpv, prim='linestrip') - print ' for (i = start, j = 0; j < nr; j+=2, i++) { ' +def linestrip(intype, outtype, inpv, outpv, pr): + preamble(intype, outtype, inpv, outpv, pr, prim='linestrip') + print ' for (i = start, j = 0; j < out_nr; j+=2, i++) { ' do_line( intype, outtype, 'out+j', 'i', 'i+1', inpv, outpv ); print ' }' postamble() -def lineloop(intype, outtype, inpv, outpv): - preamble(intype, outtype, inpv, outpv, prim='lineloop') - print ' for (i = start, j = 0; j < nr - 2; j+=2, i++) { ' +def lineloop(intype, outtype, inpv, outpv, pr): + preamble(intype, outtype, inpv, outpv, pr, prim='lineloop') + print ' for (i = start, j = 0; j < out_nr - 2; j+=2, i++) { ' do_line( intype, outtype, 'out+j', 'i', 'i+1', inpv, outpv ); print ' }' do_line( intype, outtype, 'out+j', 'i', 'start', inpv, outpv ); postamble() -def tris(intype, outtype, inpv, outpv): - preamble(intype, outtype, inpv, outpv, prim='tris') - print ' for (i = start; i < (nr+start); i+=3) { ' +def tris(intype, outtype, inpv, outpv, pr): + preamble(intype, outtype, inpv, outpv, pr, prim='tris') + print ' for (i = start; i < (out_nr+start); i+=3) { ' do_tri( intype, outtype, 'out+i', 'i', 'i+1', 'i+2', inpv, outpv ); print ' }' postamble() -def tristrip(intype, outtype, inpv, outpv): - preamble(intype, outtype, inpv, outpv, prim='tristrip') - print ' for (i = start, j = 0; j < nr; j+=3, i++) { ' +def tristrip(intype, outtype, inpv, outpv, pr): + preamble(intype, outtype, inpv, outpv, pr, prim='tristrip') + print ' for (i = start, j = 0; j < out_nr; j+=3, i++) { ' if inpv == FIRST: do_tri( intype, outtype, 'out+j', 'i', 'i+1+(i&1)', 'i+2-(i&1)', inpv, outpv ); else: @@ -215,18 +221,42 @@ def tristrip(intype, outtype, inpv, outpv): postamble() -def trifan(intype, outtype, inpv, outpv): - preamble(intype, outtype, inpv, outpv, prim='trifan') - print ' for (i = start, j = 0; j < nr; j+=3, i++) { ' +def trifan(intype, outtype, inpv, outpv, pr): + preamble(intype, outtype, inpv, outpv, pr, prim='trifan') + print ' for (i = start, j = 0; j < out_nr; j+=3, i++) { ' do_tri( intype, outtype, 'out+j', 'start', 'i+1', 'i+2', inpv, outpv ); print ' }' postamble() -def polygon(intype, outtype, inpv, outpv): - preamble(intype, outtype, inpv, outpv, prim='polygon') - print ' for (i = start, j = 0; j < nr; j+=3, i++) { ' +def polygon(intype, outtype, inpv, outpv, pr): + preamble(intype, outtype, inpv, outpv, pr, prim='polygon') + print ' for (i = start, j = 0; j < out_nr; j+=3, i++) { ' + if pr == PRENABLE: + print 'restart:' + print ' if (i + 3 > in_nr) {' + print ' (out+j+0)[0] = restart_index;' + print ' (out+j+0)[1] = restart_index;' + print ' (out+j+0)[2] = restart_index;' + print ' continue;' + print ' }' + print ' if (in[i + 0] == restart_index) {' + print ' i += 1;' + print ' start = i;' + print ' goto restart;' + print ' }' + print ' if (in[i + 1] == restart_index) {' + print ' i += 2;' + print ' start = i;' + print ' goto restart;' + print ' }' + print ' if (in[i + 2] == restart_index) {' + print ' i += 3;' + print ' start = i;' + print ' goto restart;' + print ' }' + if inpv == FIRST: do_tri( intype, outtype, 'out+j', 'start', 'i+1', 'i+2', inpv, outpv ); else: @@ -235,17 +265,72 @@ def polygon(intype, outtype, inpv, outpv): postamble() -def quads(intype, outtype, inpv, outpv): - preamble(intype, outtype, inpv, outpv, prim='quads') - print ' for (i = start, j = 0; j < nr; j+=6, i+=4) { ' +def quads(intype, outtype, inpv, outpv, pr): + preamble(intype, outtype, inpv, outpv, pr, prim='quads') + print ' for (i = start, j = 0; j < out_nr; j+=6, i+=4) { ' + if pr == PRENABLE: + print 'restart:' + print ' if (i + 4 > in_nr) {' + print ' (out+j+0)[0] = restart_index;' + print ' (out+j+0)[1] = restart_index;' + print ' (out+j+0)[2] = restart_index;' + print ' (out+j+3)[0] = restart_index;' + print ' (out+j+3)[1] = restart_index;' + print ' (out+j+3)[2] = restart_index;' + print ' continue;' + print ' }' + print ' if (in[i + 0] == restart_index) {' + print ' i += 1;' + print ' goto restart;' + print ' }' + print ' if (in[i + 1] == restart_index) {' + print ' i += 2;' + print ' goto restart;' + print ' }' + print ' if (in[i + 2] == restart_index) {' + print ' i += 3;' + print ' goto restart;' + print ' }' + print ' if (in[i + 3] == restart_index) {' + print ' i += 4;' + print ' goto restart;' + print ' }' + do_quad( intype, outtype, 'out+j', 'i+0', 'i+1', 'i+2', 'i+3', inpv, outpv ); print ' }' postamble() -def quadstrip(intype, outtype, inpv, outpv): - preamble(intype, outtype, inpv, outpv, prim='quadstrip') - print ' for (i = start, j = 0; j < nr; j+=6, i+=2) { ' +def quadstrip(intype, outtype, inpv, outpv, pr): + preamble(intype, outtype, inpv, outpv, pr, prim='quadstrip') + print ' for (i = start, j = 0; j < out_nr; j+=6, i+=2) { ' + if pr == PRENABLE: + print 'restart:' + print ' if (i + 4 > in_nr) {' + print ' (out+j+0)[0] = restart_index;' + print ' (out+j+0)[1] = restart_index;' + print ' (out+j+0)[2] = restart_index;' + print ' (out+j+3)[0] = restart_index;' + print ' (out+j+3)[1] = restart_index;' + print ' (out+j+3)[2] = restart_index;' + print ' continue;' + print ' }' + print ' if (in[i + 0] == restart_index) {' + print ' i += 1;' + print ' goto restart;' + print ' }' + print ' if (in[i + 1] == restart_index) {' + print ' i += 2;' + print ' goto restart;' + print ' }' + print ' if (in[i + 2] == restart_index) {' + print ' i += 3;' + print ' goto restart;' + print ' }' + print ' if (in[i + 3] == restart_index) {' + print ' i += 4;' + print ' goto restart;' + print ' }' do_quad( intype, outtype, 'out+j', 'i+2', 'i+0', 'i+1', 'i+3', inpv, outpv ); print ' }' postamble() @@ -256,33 +341,37 @@ def emit_funcs(): for outtype in OUTTYPES: for inpv in (FIRST, LAST): for outpv in (FIRST, LAST): - points(intype, outtype, inpv, outpv) - lines(intype, outtype, inpv, outpv) - linestrip(intype, outtype, inpv, outpv) - lineloop(intype, outtype, inpv, outpv) - tris(intype, outtype, inpv, outpv) - tristrip(intype, outtype, inpv, outpv) - trifan(intype, outtype, inpv, outpv) - quads(intype, outtype, inpv, outpv) - quadstrip(intype, outtype, inpv, outpv) - polygon(intype, outtype, inpv, outpv) - -def init(intype, outtype, inpv, outpv, prim): + for pr in (PRDISABLE, PRENABLE): + if pr == PRENABLE and intype == GENERATE: + continue + points(intype, outtype, inpv, outpv, pr) + lines(intype, outtype, inpv, outpv, pr) + linestrip(intype, outtype, inpv, outpv, pr) + lineloop(intype, outtype, inpv, outpv, pr) + tris(intype, outtype, inpv, outpv, pr) + tristrip(intype, outtype, inpv, outpv, pr) + trifan(intype, outtype, inpv, outpv, pr) + quads(intype, outtype, inpv, outpv, pr) + quadstrip(intype, outtype, inpv, outpv, pr) + polygon(intype, outtype, inpv, outpv, pr) + +def init(intype, outtype, inpv, outpv, pr, prim): if intype == GENERATE: print ('generate[' + outtype_idx[outtype] + '][' + pv_idx[inpv] + '][' + pv_idx[outpv] + '][' + longprim[prim] + - '] = ' + name( intype, outtype, inpv, outpv, prim ) + ';') + '] = ' + name( intype, outtype, inpv, outpv, pr, prim ) + ';') else: print ('translate[' + intype_idx[intype] + '][' + outtype_idx[outtype] + '][' + pv_idx[inpv] + - '][' + pv_idx[outpv] + + '][' + pv_idx[outpv] + + '][' + pr_idx[pr] + '][' + longprim[prim] + - '] = ' + name( intype, outtype, inpv, outpv, prim ) + ';') + '] = ' + name( intype, outtype, inpv, outpv, pr, prim ) + ';') def emit_all_inits(): @@ -290,8 +379,9 @@ def emit_all_inits(): for outtype in OUTTYPES: for inpv in PVS: for outpv in PVS: - for prim in PRIMS: - init(intype, outtype, inpv, outpv, prim) + for pr in PRS: + for prim in PRIMS: + init(intype, outtype, inpv, outpv, pr, prim) def emit_init(): print 'void u_index_init( void )' diff --git a/src/gallium/auxiliary/indices/u_primconvert.c b/src/gallium/auxiliary/indices/u_primconvert.c index cebb818..00e65aa 100644 --- a/src/gallium/auxiliary/indices/u_primconvert.c +++ b/src/gallium/auxiliary/indices/u_primconvert.c @@ -129,11 +129,13 @@ util_primconvert_draw_vbo(struct primconvert_context *pc, new_info.index_bias = info->index_bias; new_info.start_instance = info->start_instance; new_info.instance_count = info->instance_count; - + new_info.primitive_restart = info->primitive_restart; + new_info.restart_index = info->restart_index; if (info->indexed) { u_index_translator(pc->primtypes_mask, info->mode, pc->saved_ib.index_size, info->count, pc->api_pv, pc->api_pv, + info->primitive_restart ? PR_ENABLE : PR_DISABLE, &new_info.mode, &new_ib.index_size, &new_info.count, &trans_func); src = ib->user_buffer; @@ -159,7 +161,7 @@ util_primconvert_draw_vbo(struct primconvert_context *pc, &new_ib.offset, &new_ib.buffer, &dst); if (info->indexed) { - trans_func(src, info->start, new_info.count, dst); + trans_func(src, info->start, info->count, new_info.count, info->restart_index, dst); } else { gen_func(info->start, new_info.count, dst); diff --git a/src/gallium/auxiliary/indices/u_unfilled_gen.py b/src/gallium/auxiliary/indices/u_unfilled_gen.py index 8864972..873e781 100644 --- a/src/gallium/auxiliary/indices/u_unfilled_gen.py +++ b/src/gallium/auxiliary/indices/u_unfilled_gen.py @@ -128,7 +128,11 @@ def preamble(intype, outtype, prim): if intype != GENERATE: print ' const void * _in,' print ' unsigned start,' - print ' unsigned nr,' + if intype != GENERATE: + print ' unsigned in_nr,' + print ' unsigned out_nr,' + if intype != GENERATE: + print ' unsigned restart_index,' print ' void *_out )' print '{' if intype != GENERATE: @@ -143,7 +147,7 @@ def postamble(): def tris(intype, outtype): preamble(intype, outtype, prim='tris') - print ' for (i = start, j = 0; j < nr; j+=6, i+=3) { ' + print ' for (i = start, j = 0; j < out_nr; j+=6, i+=3) { ' do_tri( intype, outtype, 'out+j', 'i', 'i+1', 'i+2' ); print ' }' postamble() @@ -151,7 +155,7 @@ def tris(intype, outtype): def tristrip(intype, outtype): preamble(intype, outtype, prim='tristrip') - print ' for (i = start, j = 0; j < nr; j+=6, i++) { ' + print ' for (i = start, j = 0; j < out_nr; j+=6, i++) { ' do_tri( intype, outtype, 'out+j', 'i', 'i+1/*+(i&1)*/', 'i+2/*-(i&1)*/' ); print ' }' postamble() @@ -159,7 +163,7 @@ def tristrip(intype, outtype): def trifan(intype, outtype): preamble(intype, outtype, prim='trifan') - print ' for (i = start, j = 0; j < nr; j+=6, i++) { ' + print ' for (i = start, j = 0; j < out_nr; j+=6, i++) { ' do_tri( intype, outtype, 'out+j', '0', 'i+1', 'i+2' ); print ' }' postamble() @@ -168,15 +172,15 @@ def trifan(intype, outtype): def polygon(intype, outtype): preamble(intype, outtype, prim='polygon') - print ' for (i = start, j = 0; j < nr; j+=2, i++) { ' - line( intype, outtype, 'out+j', 'i', '(i+1)%(nr/2)' ) + print ' for (i = start, j = 0; j < out_nr; j+=2, i++) { ' + line( intype, outtype, 'out+j', 'i', '(i+1)%(out_nr/2)' ) print ' }' postamble() def quads(intype, outtype): preamble(intype, outtype, prim='quads') - print ' for (i = start, j = 0; j < nr; j+=8, i+=4) { ' + print ' for (i = start, j = 0; j < out_nr; j+=8, i+=4) { ' do_quad( intype, outtype, 'out+j', 'i+0', 'i+1', 'i+2', 'i+3' ); print ' }' postamble() @@ -184,7 +188,7 @@ def quads(intype, outtype): def quadstrip(intype, outtype): preamble(intype, outtype, prim='quadstrip') - print ' for (i = start, j = 0; j < nr; j+=8, i+=2) { ' + print ' for (i = start, j = 0; j < out_nr; j+=8, i+=2) { ' do_quad( intype, outtype, 'out+j', 'i+2', 'i+0', 'i+1', 'i+3' ); print ' }' postamble() diff --git a/src/gallium/auxiliary/indices/u_unfilled_indices.c b/src/gallium/auxiliary/indices/u_unfilled_indices.c index 7a74c39..121877a 100644 --- a/src/gallium/auxiliary/indices/u_unfilled_indices.c +++ b/src/gallium/auxiliary/indices/u_unfilled_indices.c @@ -28,30 +28,36 @@ static void translate_ubyte_ushort( const void *in, unsigned start, - unsigned nr, + unsigned in_nr, + unsigned out_nr, + unsigned restart_index, void *out ) { const ubyte *in_ub = (const ubyte *)in; ushort *out_us = (ushort *)out; unsigned i; - for (i = 0; i < nr; i++) + for (i = 0; i < out_nr; i++) out_us[i] = (ushort) in_ub[i+start]; } static void translate_memcpy_ushort( const void *in, unsigned start, - unsigned nr, + unsigned in_nr, + unsigned out_nr, + unsigned restart_index, void *out ) { - memcpy(out, &((short *)in)[start], nr*sizeof(short)); + memcpy(out, &((short *)in)[start], out_nr*sizeof(short)); } static void translate_memcpy_uint( const void *in, unsigned start, - unsigned nr, + unsigned in_nr, + unsigned out_nr, + unsigned restart_index, void *out ) { - memcpy(out, &((int *)in)[start], nr*sizeof(int)); + memcpy(out, &((int *)in)[start], out_nr*sizeof(int)); } diff --git a/src/gallium/drivers/svga/svga_draw_elements.c b/src/gallium/drivers/svga/svga_draw_elements.c index 3384095..038500a 100644 --- a/src/gallium/drivers/svga/svga_draw_elements.c +++ b/src/gallium/drivers/svga/svga_draw_elements.c @@ -70,7 +70,7 @@ translate_indices(struct svga_hwtnl *hwtnl, struct pipe_resource *src, if (dst_map == NULL) goto fail; - translate((const char *) src_map + offset, 0, nr, dst_map); + translate((const char *) src_map + offset, 0, 0, nr, 0, dst_map); pipe_buffer_unmap(pipe, src_transfer); pipe_buffer_unmap(pipe, dst_transfer); @@ -153,6 +153,7 @@ svga_hwtnl_draw_range_elements(struct svga_hwtnl *hwtnl, count, hwtnl->api_pv, hwtnl->hw_pv, + PR_DISABLE, &gen_prim, &gen_size, &gen_nr, &gen_func); } From fredrik at kemper.freedesktop.org Fri Mar 20 00:38:11 2015 From: fredrik at kemper.freedesktop.org (Fredrik Höglund) Date: Thu, 19 Mar 2015 17:38:11 -0700 (PDT) Subject: Mesa (master): mesa: Make sure the buffer exists in _mesa_lookup_bufferobj_err Message-ID: <20150320003811.CA12476333@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 2fd21d8a84bd28461c964e2ab350389a55b7f001 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=2fd21d8a84bd28461c964e2ab350389a55b7f001 Author: Fredrik H?glund Date: Thu Mar 19 19:44:57 2015 +0100 mesa: Make sure the buffer exists in _mesa_lookup_bufferobj_err Generate GL_INVALID_OPERATION and return NULL when the buffer object hasn't been created. All callers expect this. v2: Use a more concise error message. Cc: Laura Ekstrand Reviewed-by: Laura Ekstrand --- src/mesa/main/bufferobj.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c index 78d3d78..9658770 100644 --- a/src/mesa/main/bufferobj.c +++ b/src/mesa/main/bufferobj.c @@ -1003,8 +1003,8 @@ _mesa_lookup_bufferobj_locked(struct gl_context *ctx, GLuint buffer) /** * A convenience function for direct state access functions that throws - * GL_INVALID_OPERATION if buffer is not the name of a buffer object in the - * hash table. + * GL_INVALID_OPERATION if buffer is not the name of an existing + * buffer object. */ struct gl_buffer_object * _mesa_lookup_bufferobj_err(struct gl_context *ctx, GLuint buffer, @@ -1013,9 +1013,11 @@ _mesa_lookup_bufferobj_err(struct gl_context *ctx, GLuint buffer, struct gl_buffer_object *bufObj; bufObj = _mesa_lookup_bufferobj(ctx, buffer); - if (!bufObj) + if (!bufObj || bufObj == &DummyBufferObject) { _mesa_error(ctx, GL_INVALID_OPERATION, - "%s(non-generated buffer name %u)", caller, buffer); + "%s(non-existent buffer object %u)", caller, buffer); + return NULL; + } return bufObj; } From nroberts at kemper.freedesktop.org Fri Mar 20 13:29:56 2015 From: nroberts at kemper.freedesktop.org (Neil Roberts) Date: Fri, 20 Mar 2015 06:29:56 -0700 (PDT) Subject: Mesa (master): i965: Store the GPU revision number in brw_context Message-ID: <20150320132956.215147624F@kemper.freedesktop.org> Module: Mesa Branch: master Commit: c02c4b567ce001f6605c46e71e089692b837bf26 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=c02c4b567ce001f6605c46e71e089692b837bf26 Author: Neil Roberts Date: Wed Mar 4 14:13:40 2015 +0000 i965: Store the GPU revision number in brw_context brwContextInit now queries the GPU revision number via a new parameter for DRM_I915_GETPARAM. This new parameter requires a kernel patch and a patch to libdrm. If the kernel doesn't support it then it will continue but set the revision number to -1. The intention is to use this to implement workarounds that are only needed on certain steppings of the GPU. Reviewed-by: Kristian H?gsberg --- configure.ac | 2 +- src/mesa/drivers/dri/i965/brw_context.c | 19 +++++++++++++++++++ src/mesa/drivers/dri/i965/brw_context.h | 4 ++++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 8c90b41..d864350 100644 --- a/configure.ac +++ b/configure.ac @@ -61,7 +61,7 @@ AC_SUBST([OSMESA_VERSION]) dnl Versions for external dependencies LIBDRM_REQUIRED=2.4.38 LIBDRM_RADEON_REQUIRED=2.4.56 -LIBDRM_INTEL_REQUIRED=2.4.52 +LIBDRM_INTEL_REQUIRED=2.4.60 LIBDRM_NVVIEUX_REQUIRED=2.4.33 LIBDRM_NOUVEAU_REQUIRED="2.4.33 libdrm >= 2.4.41" LIBDRM_FREEDRENO_REQUIRED=2.4.57 diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c index 88685cd..0d3af2c 100644 --- a/src/mesa/drivers/dri/i965/brw_context.c +++ b/src/mesa/drivers/dri/i965/brw_context.c @@ -658,6 +658,24 @@ brw_process_driconf_options(struct brw_context *brw) driQueryOptionb(options, "allow_glsl_extension_directive_midshader"); } +static int +brw_get_revision(int fd) +{ + struct drm_i915_getparam gp; + int revision; + int ret; + + memset(&gp, 0, sizeof(gp)); + gp.param = I915_PARAM_REVISION; + gp.value = &revision; + + ret = drmCommandWriteRead(fd, DRM_I915_GETPARAM, &gp, sizeof(gp)); + if (ret) + revision = -1; + + return revision; +} + GLboolean brwCreateContext(gl_api api, const struct gl_config *mesaVis, @@ -716,6 +734,7 @@ brwCreateContext(gl_api api, brw->has_negative_rhw_bug = devinfo->has_negative_rhw_bug; brw->needs_unlit_centroid_workaround = devinfo->needs_unlit_centroid_workaround; + brw->revision = brw_get_revision(sPriv->fd); brw->must_use_separate_stencil = screen->hw_must_use_separate_stencil; brw->has_swizzling = screen->hw_has_swizzling; diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h index 8b29e2a..e025011 100644 --- a/src/mesa/drivers/dri/i965/brw_context.h +++ b/src/mesa/drivers/dri/i965/brw_context.h @@ -1076,6 +1076,10 @@ struct brw_context int gen; int gt; + /* GT revision. This will be -1 if the revision couldn't be determined (eg, + * if the kernel doesn't support the query). + */ + int revision; bool is_g4x; bool is_baytrail; From nroberts at kemper.freedesktop.org Fri Mar 20 13:29:56 2015 From: nroberts at kemper.freedesktop.org (Neil Roberts) Date: Fri, 20 Mar 2015 06:29:56 -0700 (PDT) Subject: Mesa (master): i965: Refactor SIMD16-to-2xSIMD8 checks. Message-ID: <20150320132956.2A3837633A@kemper.freedesktop.org> Module: Mesa Branch: master Commit: bc4b18d2977a94a6fb513bf5955236a0e92298ca URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=bc4b18d2977a94a6fb513bf5955236a0e92298ca Author: Neil Roberts Date: Thu Mar 19 18:18:49 2015 +0000 i965: Refactor SIMD16-to-2xSIMD8 checks. The places that were checking whether 3-source instructions are supported have now been combined into a small helper function. This will be used in the next patch to add an additonal restriction. Based on a patch by Kenneth Graunke. Reviewed-by: Kenneth Graunke Reviewed-by: Matt Turner --- src/mesa/drivers/dri/i965/brw_fs_generator.cpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_fs_generator.cpp b/src/mesa/drivers/dri/i965/brw_fs_generator.cpp index 05a2db4..6eebee1 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_generator.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_generator.cpp @@ -1553,6 +1553,15 @@ fs_generator::enable_debug(const char *shader_name) this->shader_name = shader_name; } +/** + * Some hardware doesn't support SIMD16 instructions with 3 sources. + */ +static bool +brw_supports_simd16_3src(const struct brw_context *brw) +{ + return brw->is_haswell || brw->gen >= 8; +} + int fs_generator::generate_code(const cfg_t *cfg, int dispatch_width) { @@ -1646,7 +1655,7 @@ fs_generator::generate_code(const cfg_t *cfg, int dispatch_width) case BRW_OPCODE_MAD: assert(brw->gen >= 6); brw_set_default_access_mode(p, BRW_ALIGN_16); - if (dispatch_width == 16 && brw->gen < 8 && !brw->is_haswell) { + if (dispatch_width == 16 && !brw_supports_simd16_3src(brw)) { brw_set_default_compression_control(p, BRW_COMPRESSION_NONE); brw_inst *f = brw_MAD(p, firsthalf(dst), firsthalf(src[0]), firsthalf(src[1]), firsthalf(src[2])); brw_set_default_compression_control(p, BRW_COMPRESSION_2NDHALF); @@ -1667,7 +1676,7 @@ fs_generator::generate_code(const cfg_t *cfg, int dispatch_width) case BRW_OPCODE_LRP: assert(brw->gen >= 6); brw_set_default_access_mode(p, BRW_ALIGN_16); - if (dispatch_width == 16 && brw->gen < 8 && !brw->is_haswell) { + if (dispatch_width == 16 && !brw_supports_simd16_3src(brw)) { brw_set_default_compression_control(p, BRW_COMPRESSION_NONE); brw_inst *f = brw_LRP(p, firsthalf(dst), firsthalf(src[0]), firsthalf(src[1]), firsthalf(src[2])); brw_set_default_compression_control(p, BRW_COMPRESSION_2NDHALF); @@ -1804,7 +1813,7 @@ fs_generator::generate_code(const cfg_t *cfg, int dispatch_width) case BRW_OPCODE_BFE: assert(brw->gen >= 7); brw_set_default_access_mode(p, BRW_ALIGN_16); - if (dispatch_width == 16 && brw->gen < 8 && !brw->is_haswell) { + if (dispatch_width == 16 && !brw_supports_simd16_3src(brw)) { brw_set_default_compression_control(p, BRW_COMPRESSION_NONE); brw_BFE(p, firsthalf(dst), firsthalf(src[0]), firsthalf(src[1]), firsthalf(src[2])); brw_set_default_compression_control(p, BRW_COMPRESSION_2NDHALF); @@ -1844,7 +1853,8 @@ fs_generator::generate_code(const cfg_t *cfg, int dispatch_width) * Otherwise we would be able to emit compressed instructions like we * do for the other three-source instructions. */ - if (dispatch_width == 16 && brw->gen < 8) { + if (dispatch_width == 16 && + (brw->is_haswell || !brw_supports_simd16_3src(brw))) { brw_set_default_compression_control(p, BRW_COMPRESSION_NONE); brw_BFI2(p, firsthalf(dst), firsthalf(src[0]), firsthalf(src[1]), firsthalf(src[2])); brw_set_default_compression_control(p, BRW_COMPRESSION_2NDHALF); From nroberts at kemper.freedesktop.org Fri Mar 20 13:29:56 2015 From: nroberts at kemper.freedesktop.org (Neil Roberts) Date: Fri, 20 Mar 2015 06:29:56 -0700 (PDT) Subject: Mesa (master): i965/skl: Break down SIMD16 3-source instructions when required. Message-ID: <20150320132956.374BF7624F@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 706b916960c898cfc24110f14fa4def84caaba93 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=706b916960c898cfc24110f14fa4def84caaba93 Author: Kenneth Graunke Date: Wed Mar 4 12:53:45 2015 -0800 i965/skl: Break down SIMD16 3-source instructions when required. Several steppings of Skylake fail when using SIMD16 with 3-source instructions (such as MAD). This implements WaDisableSIMD16On3SrcInstr and fixes ~190 Piglit tests. Based on a patch by Neil Roberts. Signed-off-by: Kenneth Graunke Reviewed-by: Neil Roberts --- src/mesa/drivers/dri/i965/brw_fs_generator.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/mesa/drivers/dri/i965/brw_fs_generator.cpp b/src/mesa/drivers/dri/i965/brw_fs_generator.cpp index 6eebee1..3aa5c3c 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_generator.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_generator.cpp @@ -1559,6 +1559,12 @@ fs_generator::enable_debug(const char *shader_name) static bool brw_supports_simd16_3src(const struct brw_context *brw) { + /* WaDisableSIMD16On3SrcInstr: 3-source instructions don't work in SIMD16 + * on a few steppings of Skylake. + */ + if (brw->gen == 9) + return brw->revision != 2 && brw->revision != 3 && brw->revision != -1; + return brw->is_haswell || brw->gen >= 8; } From currojerez at kemper.freedesktop.org Fri Mar 20 15:17:09 2015 From: currojerez at kemper.freedesktop.org (Francisco Jerez) Date: Fri, 20 Mar 2015 08:17:09 -0700 (PDT) Subject: Mesa (master): i965: Set nr_params to the number of uniform components in the VS/GS path. Message-ID: <20150320151710.02AD37624F@kemper.freedesktop.org> Module: Mesa Branch: master Commit: fd149628e142af769c1c0ec037bc297d8a3e871f URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=fd149628e142af769c1c0ec037bc297d8a3e871f Author: Francisco Jerez Date: Thu Jan 22 17:08:23 2015 +0200 i965: Set nr_params to the number of uniform components in the VS/GS path. Both do_vs_prog and do_gs_prog initialize brw_stage_prog_data::nr_params to the number of uniform *vectors* required by the shader rather than the number of uniform components, contradicting the comment. This is inconsistent with what the state upload code and scalar path expect but it happens to work until Gen8 because vec4_visitor interprets it as a number of vectors on construction and later on overwrites its original value with the number of uniform components referenced by the shader. Also there's no need to add the number of samplers, they're not actually passed in as uniforms. Fixes a memory corruption issue on BDW with SIMD8 VS. Cc: "10.5" Reviewed-by: Kenneth Graunke --- src/mesa/drivers/dri/i965/brw_gs.c | 6 +----- src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp | 3 ++- src/mesa/drivers/dri/i965/brw_vs.c | 10 +--------- 3 files changed, 4 insertions(+), 15 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_gs.c b/src/mesa/drivers/dri/i965/brw_gs.c index efcff09..45c157a 100644 --- a/src/mesa/drivers/dri/i965/brw_gs.c +++ b/src/mesa/drivers/dri/i965/brw_gs.c @@ -69,11 +69,7 @@ do_gs_prog(struct brw_context *brw, rzalloc_array(NULL, const gl_constant_value *, param_count); c.prog_data.base.base.pull_param = rzalloc_array(NULL, const gl_constant_value *, param_count); - /* Setting nr_params here NOT to the size of the param and pull_param - * arrays, but to the number of uniform components vec4_visitor - * needs. vec4_visitor::setup_uniforms() will set it back to a proper value. - */ - c.prog_data.base.base.nr_params = ALIGN(param_count, 4) / 4 + gs->num_samplers; + c.prog_data.base.base.nr_params = param_count; if (brw->gen >= 7) { if (gp->program.OutputType == GL_POINTS) { diff --git a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp index d5c6e9b..05bda43 100644 --- a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp +++ b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp @@ -3671,7 +3671,8 @@ vec4_visitor::vec4_visitor(struct brw_context *brw, */ this->uniform_array_size = 1; if (prog_data) { - this->uniform_array_size = MAX2(stage_prog_data->nr_params, 1); + this->uniform_array_size = + MAX2(DIV_ROUND_UP(stage_prog_data->nr_params, 4), 1); } this->uniform_size = rzalloc_array(mem_ctx, int, this->uniform_array_size); diff --git a/src/mesa/drivers/dri/i965/brw_vs.c b/src/mesa/drivers/dri/i965/brw_vs.c index 2aefd35..ba2c23d 100644 --- a/src/mesa/drivers/dri/i965/brw_vs.c +++ b/src/mesa/drivers/dri/i965/brw_vs.c @@ -241,15 +241,7 @@ do_vs_prog(struct brw_context *brw, rzalloc_array(NULL, const gl_constant_value *, param_count); stage_prog_data->pull_param = rzalloc_array(NULL, const gl_constant_value *, param_count); - - /* Setting nr_params here NOT to the size of the param and pull_param - * arrays, but to the number of uniform components vec4_visitor - * needs. vec4_visitor::setup_uniforms() will set it back to a proper value. - */ - stage_prog_data->nr_params = ALIGN(param_count, 4) / 4; - if (vs) { - stage_prog_data->nr_params += vs->num_samplers; - } + stage_prog_data->nr_params = param_count; GLbitfield64 outputs_written = vp->program.Base.OutputsWritten; prog_data.inputs_read = vp->program.Base.InputsRead; From currojerez at kemper.freedesktop.org Fri Mar 20 15:17:10 2015 From: currojerez at kemper.freedesktop.org (Francisco Jerez) Date: Fri, 20 Mar 2015 08:17:10 -0700 (PDT) Subject: Mesa (master): i965: Factor out logic to build a send message instruction with indirect descriptor. Message-ID: <20150320151710.119627624F@kemper.freedesktop.org> Module: Mesa Branch: master Commit: a902a5d6ba921ab006496aeecab0f68bca7ffb09 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=a902a5d6ba921ab006496aeecab0f68bca7ffb09 Author: Francisco Jerez Date: Thu Mar 19 15:44:24 2015 +0200 i965: Factor out logic to build a send message instruction with indirect descriptor. This is going to be useful because the Gen7+ uniform and varying pull constant, texturing, typed and untyped surface read, write, and atomic generation code on the vec4 and fs back-end all require the same logic to handle conditionally indirect surface indices. In pseudocode: | if (surface.file == BRW_IMMEDIATE_VALUE) { | inst = brw_SEND(p, dst, payload); | set_descriptor_control_bits(inst, surface, ...); | } else { | inst = brw_OR(p, addr, surface, 0); | set_descriptor_control_bits(inst, ...); | inst = brw_SEND(p, dst, payload); | set_indirect_send_descriptor(inst, addr); | } This patch abstracts out this frequently recurring pattern so we can now write: | inst = brw_send_indirect_message(p, sfid, dst, payload, surface) | set_descriptor_control_bits(inst, ...); without worrying about handling the immediate and indirect surface index cases explicitly. v2: Rebase. Improve documentatation and commit message. (Topi) Preserve UW destination type cargo-cult. (Topi, Ken, Matt) Reviewed-by: Topi Pohjolainen Acked-by: Kenneth Graunke --- src/mesa/drivers/dri/i965/brw_eu.h | 21 ++++++-- src/mesa/drivers/dri/i965/brw_eu_emit.c | 58 ++++++++++++++------ src/mesa/drivers/dri/i965/brw_fs_generator.cpp | 63 ++++++---------------- src/mesa/drivers/dri/i965/brw_vec4_generator.cpp | 37 +++---------- 4 files changed, 83 insertions(+), 96 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_eu.h b/src/mesa/drivers/dri/i965/brw_eu.h index d9ad5bd..a87787e 100644 --- a/src/mesa/drivers/dri/i965/brw_eu.h +++ b/src/mesa/drivers/dri/i965/brw_eu.h @@ -205,11 +205,6 @@ void brw_set_sampler_message(struct brw_compile *p, unsigned simd_mode, unsigned return_format); -void brw_set_indirect_send_descriptor(struct brw_compile *p, - brw_inst *insn, - unsigned sfid, - struct brw_reg descriptor); - void brw_set_dp_read_message(struct brw_compile *p, brw_inst *insn, unsigned binding_table_index, @@ -242,6 +237,22 @@ void brw_urb_WRITE(struct brw_compile *p, unsigned offset, unsigned swizzle); +/** + * Send message to shared unit \p sfid with a possibly indirect descriptor \p + * desc. If \p desc is not an immediate it will be transparently loaded to an + * address register using an OR instruction. The returned instruction can be + * passed as argument to the usual brw_set_*_message() functions in order to + * specify any additional descriptor bits -- If \p desc is an immediate this + * will be the SEND instruction itself, otherwise it will be the OR + * instruction. + */ +struct brw_inst * +brw_send_indirect_message(struct brw_compile *p, + unsigned sfid, + struct brw_reg dst, + struct brw_reg payload, + struct brw_reg desc); + void brw_ff_sync(struct brw_compile *p, struct brw_reg dest, unsigned msg_reg_nr, diff --git a/src/mesa/drivers/dri/i965/brw_eu_emit.c b/src/mesa/drivers/dri/i965/brw_eu_emit.c index 1ca79a9..0920e17 100644 --- a/src/mesa/drivers/dri/i965/brw_eu_emit.c +++ b/src/mesa/drivers/dri/i965/brw_eu_emit.c @@ -772,21 +772,6 @@ brw_set_sampler_message(struct brw_compile *p, } } -void brw_set_indirect_send_descriptor(struct brw_compile *p, - brw_inst *insn, - unsigned sfid, - struct brw_reg descriptor) -{ - /* Only a0.0 may be used as SEND's descriptor operand. */ - assert(descriptor.file == BRW_ARCHITECTURE_REGISTER_FILE); - assert(descriptor.type == BRW_REGISTER_TYPE_UD); - assert(descriptor.nr == BRW_ARF_ADDRESS); - assert(descriptor.subnr == 0); - - brw_set_message_descriptor(p, insn, sfid, 0, 0, false, false); - brw_set_src1(p, insn, descriptor); -} - static void gen7_set_dp_scratch_message(struct brw_compile *p, brw_inst *inst, @@ -2496,6 +2481,49 @@ void brw_urb_WRITE(struct brw_compile *p, swizzle); } +struct brw_inst * +brw_send_indirect_message(struct brw_compile *p, + unsigned sfid, + struct brw_reg dst, + struct brw_reg payload, + struct brw_reg desc) +{ + const struct brw_context *brw = p->brw; + struct brw_inst *send, *setup; + + assert(desc.type == BRW_REGISTER_TYPE_UD); + + if (desc.file == BRW_IMMEDIATE_VALUE) { + setup = send = next_insn(p, BRW_OPCODE_SEND); + brw_set_src1(p, send, desc); + + } else { + struct brw_reg addr = retype(brw_address_reg(0), BRW_REGISTER_TYPE_UD); + + brw_push_insn_state(p); + brw_set_default_access_mode(p, BRW_ALIGN_1); + brw_set_default_mask_control(p, BRW_MASK_DISABLE); + brw_set_default_predicate_control(p, BRW_PREDICATE_NONE); + + /* Load the indirect descriptor to an address register using OR so the + * caller can specify additional descriptor bits with the usual + * brw_set_*_message() helper functions. + */ + setup = brw_OR(p, addr, desc, brw_imm_ud(0)); + + brw_pop_insn_state(p); + + send = next_insn(p, BRW_OPCODE_SEND); + brw_set_src1(p, send, addr); + } + + brw_set_dest(p, send, dst); + brw_set_src0(p, send, retype(payload, BRW_REGISTER_TYPE_UD)); + brw_inst_set_sfid(brw, send, sfid); + + return setup; +} + static int brw_find_next_block_end(struct brw_compile *p, int start_offset) { diff --git a/src/mesa/drivers/dri/i965/brw_fs_generator.cpp b/src/mesa/drivers/dri/i965/brw_fs_generator.cpp index 3aa5c3c..25a0ea3 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_generator.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_generator.cpp @@ -762,9 +762,10 @@ fs_generator::generate_tex(fs_inst *inst, struct brw_reg dst, struct brw_reg src brw_AND(p, addr, addr, brw_imm_ud(0x0ff)); brw_OR(p, addr, addr, temp); - /* a0.0 |= */ - brw_inst *insn_or = brw_next_insn(p, BRW_OPCODE_OR); - brw_set_sampler_message(p, insn_or, + /* dst = send(offset, a0.0 | ) */ + brw_inst *insn = brw_send_indirect_message( + p, BRW_SFID_SAMPLER, dst, src, addr); + brw_set_sampler_message(p, insn, 0 /* surface */, 0 /* sampler */, msg_type, @@ -773,17 +774,6 @@ fs_generator::generate_tex(fs_inst *inst, struct brw_reg dst, struct brw_reg src inst->header_present /* header */, simd_mode, return_format); - brw_inst_set_exec_size(p->brw, insn_or, BRW_EXECUTE_1); - brw_inst_set_src1_reg_type(p->brw, insn_or, BRW_REGISTER_TYPE_UD); - brw_set_src0(p, insn_or, addr); - brw_set_dest(p, insn_or, addr); - - - /* dst = send(offset, a0.0) */ - brw_inst *insn_send = brw_next_insn(p, BRW_OPCODE_SEND); - brw_set_dest(p, insn_send, dst); - brw_set_src0(p, insn_send, src); - brw_set_indirect_send_descriptor(p, insn_send, BRW_SFID_SAMPLER, addr); brw_pop_insn_state(p); @@ -1091,29 +1081,18 @@ fs_generator::generate_uniform_pull_constant_load_gen7(fs_inst *inst, brw_set_src0(p, insn_and, vec1(retype(index, BRW_REGISTER_TYPE_UD))); brw_set_src1(p, insn_and, brw_imm_ud(0x0ff)); - - /* a0.0 |= */ - brw_inst *insn_or = brw_next_insn(p, BRW_OPCODE_OR); - brw_set_sampler_message(p, insn_or, - 0 /* surface */, - 0 /* sampler */, + /* dst = send(payload, a0.0 | ) */ + brw_inst *insn = brw_send_indirect_message( + p, BRW_SFID_SAMPLER, dst, src, addr); + brw_set_sampler_message(p, insn, + 0, + 0, /* LD message ignores sampler unit */ GEN5_SAMPLER_MESSAGE_SAMPLE_LD, - 1 /* rlen */, + 1, /* rlen */ mlen, header_present, BRW_SAMPLER_SIMD_MODE_SIMD4X2, 0); - brw_inst_set_exec_size(p->brw, insn_or, BRW_EXECUTE_1); - brw_inst_set_src1_reg_type(p->brw, insn_or, BRW_REGISTER_TYPE_UD); - brw_set_src0(p, insn_or, addr); - brw_set_dest(p, insn_or, addr); - - - /* dst = send(offset, a0.0) */ - brw_inst *insn_send = brw_next_insn(p, BRW_OPCODE_SEND); - brw_set_dest(p, insn_send, dst); - brw_set_src0(p, insn_send, src); - brw_set_indirect_send_descriptor(p, insn_send, BRW_SFID_SAMPLER, addr); brw_pop_insn_state(p); @@ -1250,10 +1229,11 @@ fs_generator::generate_varying_pull_constant_load_gen7(fs_inst *inst, brw_set_src0(p, insn_and, vec1(retype(index, BRW_REGISTER_TYPE_UD))); brw_set_src1(p, insn_and, brw_imm_ud(0x0ff)); - - /* a0.0 |= */ - brw_inst *insn_or = brw_next_insn(p, BRW_OPCODE_OR); - brw_set_sampler_message(p, insn_or, + /* dst = send(offset, a0.0 | ) */ + brw_inst *insn = brw_send_indirect_message( + p, BRW_SFID_SAMPLER, retype(dst, BRW_REGISTER_TYPE_UW), + offset, addr); + brw_set_sampler_message(p, insn, 0 /* surface */, 0 /* sampler */, GEN5_SAMPLER_MESSAGE_SAMPLE_LD, @@ -1262,17 +1242,6 @@ fs_generator::generate_varying_pull_constant_load_gen7(fs_inst *inst, false /* header */, simd_mode, 0); - brw_inst_set_exec_size(p->brw, insn_or, BRW_EXECUTE_1); - brw_inst_set_src1_reg_type(p->brw, insn_or, BRW_REGISTER_TYPE_UD); - brw_set_src0(p, insn_or, addr); - brw_set_dest(p, insn_or, addr); - - - /* dst = send(offset, a0.0) */ - brw_inst *insn_send = brw_next_insn(p, BRW_OPCODE_SEND); - brw_set_dest(p, insn_send, retype(dst, BRW_REGISTER_TYPE_UW)); - brw_set_src0(p, insn_send, offset); - brw_set_indirect_send_descriptor(p, insn_send, BRW_SFID_SAMPLER, addr); brw_pop_insn_state(p); diff --git a/src/mesa/drivers/dri/i965/brw_vec4_generator.cpp b/src/mesa/drivers/dri/i965/brw_vec4_generator.cpp index e3a94ff..5ac0e76 100644 --- a/src/mesa/drivers/dri/i965/brw_vec4_generator.cpp +++ b/src/mesa/drivers/dri/i965/brw_vec4_generator.cpp @@ -419,9 +419,10 @@ vec4_generator::generate_tex(vec4_instruction *inst, brw_AND(p, addr, addr, brw_imm_ud(0x0ff)); brw_OR(p, addr, addr, temp); - /* a0.0 |= */ - brw_inst *insn_or = brw_next_insn(p, BRW_OPCODE_OR); - brw_set_sampler_message(p, insn_or, + /* dst = send(offset, a0.0 | ) */ + brw_inst *insn = brw_send_indirect_message( + p, BRW_SFID_SAMPLER, dst, src, addr); + brw_set_sampler_message(p, insn, 0 /* surface */, 0 /* sampler */, msg_type, @@ -430,17 +431,6 @@ vec4_generator::generate_tex(vec4_instruction *inst, inst->header_present /* header */, BRW_SAMPLER_SIMD_MODE_SIMD4X2, return_format); - brw_inst_set_exec_size(p->brw, insn_or, BRW_EXECUTE_1); - brw_inst_set_src1_reg_type(p->brw, insn_or, BRW_REGISTER_TYPE_UD); - brw_set_src0(p, insn_or, addr); - brw_set_dest(p, insn_or, addr); - - - /* dst = send(offset, a0.0) */ - brw_inst *insn_send = brw_next_insn(p, BRW_OPCODE_SEND); - brw_set_dest(p, insn_send, dst); - brw_set_src0(p, insn_send, src); - brw_set_indirect_send_descriptor(p, insn_send, BRW_SFID_SAMPLER, addr); brw_pop_insn_state(p); @@ -1101,10 +1091,10 @@ vec4_generator::generate_pull_constant_load_gen7(vec4_instruction *inst, brw_set_src0(p, insn_and, vec1(retype(surf_index, BRW_REGISTER_TYPE_UD))); brw_set_src1(p, insn_and, brw_imm_ud(0x0ff)); - - /* a0.0 |= */ - brw_inst *insn_or = brw_next_insn(p, BRW_OPCODE_OR); - brw_set_sampler_message(p, insn_or, + /* dst = send(offset, a0.0 | ) */ + brw_inst *insn = brw_send_indirect_message( + p, BRW_SFID_SAMPLER, dst, src, addr); + brw_set_sampler_message(p, insn, 0 /* surface */, 0 /* sampler */, GEN5_SAMPLER_MESSAGE_SAMPLE_LD, @@ -1113,17 +1103,6 @@ vec4_generator::generate_pull_constant_load_gen7(vec4_instruction *inst, header_present /* header */, BRW_SAMPLER_SIMD_MODE_SIMD4X2, 0); - brw_inst_set_exec_size(p->brw, insn_or, BRW_EXECUTE_1); - brw_inst_set_src1_reg_type(p->brw, insn_or, BRW_REGISTER_TYPE_UD); - brw_set_src0(p, insn_or, addr); - brw_set_dest(p, insn_or, addr); - - - /* dst = send(offset, a0.0) */ - brw_inst *insn_send = brw_next_insn(p, BRW_OPCODE_SEND); - brw_set_dest(p, insn_send, dst); - brw_set_src0(p, insn_send, src); - brw_set_indirect_send_descriptor(p, insn_send, BRW_SFID_SAMPLER, addr); brw_pop_insn_state(p); From currojerez at kemper.freedesktop.org Fri Mar 20 15:17:10 2015 From: currojerez at kemper.freedesktop.org (Francisco Jerez) Date: Fri, 20 Mar 2015 08:17:10 -0700 (PDT) Subject: Mesa (master): i965: Don't disable exec masking for sampler message sends. Message-ID: <20150320151710.228B27624F@kemper.freedesktop.org> Module: Mesa Branch: master Commit: a815cd8449c207956176020e752cd0051ed842ec URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=a815cd8449c207956176020e752cd0051ed842ec Author: Francisco Jerez Date: Thu Feb 26 17:24:03 2015 +0200 i965: Don't disable exec masking for sampler message sends. This was telling the sampler to do texture fetches for *all* channels in the non-constant surface index case, what could have reduced throughput unnecessarily when some of the channels were disabled by control flow. Reviewed-by: Topi Pohjolainen Acked-by: Kenneth Graunke --- src/mesa/drivers/dri/i965/brw_fs_generator.cpp | 8 ++++---- src/mesa/drivers/dri/i965/brw_vec4_generator.cpp | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_fs_generator.cpp b/src/mesa/drivers/dri/i965/brw_fs_generator.cpp index 25a0ea3..260f508 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_generator.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_generator.cpp @@ -762,6 +762,8 @@ fs_generator::generate_tex(fs_inst *inst, struct brw_reg dst, struct brw_reg src brw_AND(p, addr, addr, brw_imm_ud(0x0ff)); brw_OR(p, addr, addr, temp); + brw_pop_insn_state(p); + /* dst = send(offset, a0.0 | ) */ brw_inst *insn = brw_send_indirect_message( p, BRW_SFID_SAMPLER, dst, src, addr); @@ -775,8 +777,6 @@ fs_generator::generate_tex(fs_inst *inst, struct brw_reg dst, struct brw_reg src simd_mode, return_format); - brw_pop_insn_state(p); - /* visitor knows more than we do about the surface limit required, * so has already done marking. */ @@ -1229,6 +1229,8 @@ fs_generator::generate_varying_pull_constant_load_gen7(fs_inst *inst, brw_set_src0(p, insn_and, vec1(retype(index, BRW_REGISTER_TYPE_UD))); brw_set_src1(p, insn_and, brw_imm_ud(0x0ff)); + brw_pop_insn_state(p); + /* dst = send(offset, a0.0 | ) */ brw_inst *insn = brw_send_indirect_message( p, BRW_SFID_SAMPLER, retype(dst, BRW_REGISTER_TYPE_UW), @@ -1243,8 +1245,6 @@ fs_generator::generate_varying_pull_constant_load_gen7(fs_inst *inst, simd_mode, 0); - brw_pop_insn_state(p); - /* visitor knows more than we do about the surface limit required, * so has already done marking. */ diff --git a/src/mesa/drivers/dri/i965/brw_vec4_generator.cpp b/src/mesa/drivers/dri/i965/brw_vec4_generator.cpp index 5ac0e76..2bcddb1 100644 --- a/src/mesa/drivers/dri/i965/brw_vec4_generator.cpp +++ b/src/mesa/drivers/dri/i965/brw_vec4_generator.cpp @@ -419,6 +419,8 @@ vec4_generator::generate_tex(vec4_instruction *inst, brw_AND(p, addr, addr, brw_imm_ud(0x0ff)); brw_OR(p, addr, addr, temp); + brw_pop_insn_state(p); + /* dst = send(offset, a0.0 | ) */ brw_inst *insn = brw_send_indirect_message( p, BRW_SFID_SAMPLER, dst, src, addr); @@ -432,8 +434,6 @@ vec4_generator::generate_tex(vec4_instruction *inst, BRW_SAMPLER_SIMD_MODE_SIMD4X2, return_format); - brw_pop_insn_state(p); - /* visitor knows more than we do about the surface limit required, * so has already done marking. */ @@ -1091,6 +1091,8 @@ vec4_generator::generate_pull_constant_load_gen7(vec4_instruction *inst, brw_set_src0(p, insn_and, vec1(retype(surf_index, BRW_REGISTER_TYPE_UD))); brw_set_src1(p, insn_and, brw_imm_ud(0x0ff)); + brw_pop_insn_state(p); + /* dst = send(offset, a0.0 | ) */ brw_inst *insn = brw_send_indirect_message( p, BRW_SFID_SAMPLER, dst, src, addr); @@ -1104,8 +1106,6 @@ vec4_generator::generate_pull_constant_load_gen7(vec4_instruction *inst, BRW_SAMPLER_SIMD_MODE_SIMD4X2, 0); - brw_pop_insn_state(p); - /* visitor knows more than we do about the surface limit required, * so has already done marking. */ From currojerez at kemper.freedesktop.org Fri Mar 20 15:17:10 2015 From: currojerez at kemper.freedesktop.org (Francisco Jerez) Date: Fri, 20 Mar 2015 08:17:10 -0700 (PDT) Subject: Mesa (master): i965: Pass number of components explicitly to brw_untyped_atomic and _surface_read. Message-ID: <20150320151710.3338D7624F@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 959d16e38e007b29349d7371fb390a5449c88341 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=959d16e38e007b29349d7371fb390a5449c88341 Author: Francisco Jerez Date: Thu Feb 26 12:56:19 2015 +0200 i965: Pass number of components explicitly to brw_untyped_atomic and _surface_read. And calculate the message response size based on the number of components rather than the other way around. This simplifies their interface somewhat and allows the caller to request a writeback message with more than one vector component in SIMD4x2 mode. Reviewed-by: Topi Pohjolainen Acked-by: Kenneth Graunke --- src/mesa/drivers/dri/i965/brw_eu.h | 4 +-- src/mesa/drivers/dri/i965/brw_eu_emit.c | 30 +++++++++++++++++----- src/mesa/drivers/dri/i965/brw_fs_generator.cpp | 9 +++---- src/mesa/drivers/dri/i965/brw_vec4_generator.cpp | 5 ++-- 4 files changed, 32 insertions(+), 16 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_eu.h b/src/mesa/drivers/dri/i965/brw_eu.h index a87787e..f8fd155 100644 --- a/src/mesa/drivers/dri/i965/brw_eu.h +++ b/src/mesa/drivers/dri/i965/brw_eu.h @@ -405,7 +405,7 @@ brw_untyped_atomic(struct brw_compile *p, unsigned atomic_op, unsigned bind_table_index, unsigned msg_length, - unsigned response_length); + bool response_expected); void brw_untyped_surface_read(struct brw_compile *p, @@ -413,7 +413,7 @@ brw_untyped_surface_read(struct brw_compile *p, struct brw_reg mrf, unsigned bind_table_index, unsigned msg_length, - unsigned response_length); + unsigned num_channels); void brw_pixel_interpolator_query(struct brw_compile *p, diff --git a/src/mesa/drivers/dri/i965/brw_eu_emit.c b/src/mesa/drivers/dri/i965/brw_eu_emit.c index 0920e17..8b134a5 100644 --- a/src/mesa/drivers/dri/i965/brw_eu_emit.c +++ b/src/mesa/drivers/dri/i965/brw_eu_emit.c @@ -2729,6 +2729,20 @@ brw_svb_write(struct brw_compile *p, send_commit_msg); /* send_commit_msg */ } +static unsigned +brw_surface_payload_size(struct brw_compile *p, + unsigned num_channels, + bool has_simd4x2, + bool has_simd16) +{ + if (has_simd4x2 && brw_inst_access_mode(p->brw, p->current) == BRW_ALIGN_16) + return 1; + else if (has_simd16 && p->compressed) + return 2 * num_channels; + else + return num_channels; +} + static void brw_set_dp_untyped_atomic_message(struct brw_compile *p, brw_inst *insn, @@ -2782,7 +2796,8 @@ brw_untyped_atomic(struct brw_compile *p, unsigned atomic_op, unsigned bind_table_index, unsigned msg_length, - unsigned response_length) { + bool response_expected) +{ const struct brw_context *brw = p->brw; brw_inst *insn = brw_next_insn(p, BRW_OPCODE_SEND); @@ -2790,7 +2805,9 @@ brw_untyped_atomic(struct brw_compile *p, brw_set_src0(p, insn, retype(payload, BRW_REGISTER_TYPE_UD)); brw_set_src1(p, insn, brw_imm_d(0)); brw_set_dp_untyped_atomic_message( - p, insn, atomic_op, bind_table_index, msg_length, response_length, + p, insn, atomic_op, bind_table_index, msg_length, + brw_surface_payload_size(p, response_expected, + brw->gen >= 8 || brw->is_haswell, true), brw_inst_access_mode(brw, insn) == BRW_ALIGN_1); } @@ -2800,12 +2817,12 @@ brw_set_dp_untyped_surface_read_message(struct brw_compile *p, unsigned bind_table_index, unsigned msg_length, unsigned response_length, + unsigned num_channels, bool header_present) { const struct brw_context *brw = p->brw; const unsigned dispatch_width = (brw_inst_exec_size(brw, insn) == BRW_EXECUTE_16 ? 16 : 8); - const unsigned num_channels = response_length / (dispatch_width / 8); if (brw->gen >= 8 || brw->is_haswell) { brw_set_message_descriptor(p, insn, HSW_SFID_DATAPORT_DATA_CACHE_1, @@ -2843,7 +2860,7 @@ brw_untyped_surface_read(struct brw_compile *p, struct brw_reg mrf, unsigned bind_table_index, unsigned msg_length, - unsigned response_length) + unsigned num_channels) { const struct brw_context *brw = p->brw; brw_inst *insn = next_insn(p, BRW_OPCODE_SEND); @@ -2851,8 +2868,9 @@ brw_untyped_surface_read(struct brw_compile *p, brw_set_dest(p, insn, retype(dest, BRW_REGISTER_TYPE_UD)); brw_set_src0(p, insn, retype(mrf, BRW_REGISTER_TYPE_UD)); brw_set_dp_untyped_surface_read_message( - p, insn, bind_table_index, msg_length, response_length, - brw_inst_access_mode(brw, insn) == BRW_ALIGN_1); + p, insn, bind_table_index, msg_length, + brw_surface_payload_size(p, num_channels, true, true), + num_channels, brw_inst_access_mode(brw, insn) == BRW_ALIGN_1); } void diff --git a/src/mesa/drivers/dri/i965/brw_fs_generator.cpp b/src/mesa/drivers/dri/i965/brw_fs_generator.cpp index 260f508..bd12147 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_generator.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_generator.cpp @@ -1494,8 +1494,9 @@ fs_generator::generate_untyped_atomic(fs_inst *inst, struct brw_reg dst, surf_index.file == BRW_IMMEDIATE_VALUE && surf_index.type == BRW_REGISTER_TYPE_UD); - brw_untyped_atomic(p, dst, payload, atomic_op.dw1.ud, surf_index.dw1.ud, - inst->mlen, inst->exec_size / 8); + brw_untyped_atomic(p, dst, payload, + atomic_op.dw1.ud, surf_index.dw1.ud, + inst->mlen, true); brw_mark_surface_used(prog_data, surf_index.dw1.ud); } @@ -1508,9 +1509,7 @@ fs_generator::generate_untyped_surface_read(fs_inst *inst, struct brw_reg dst, assert(surf_index.file == BRW_IMMEDIATE_VALUE && surf_index.type == BRW_REGISTER_TYPE_UD); - brw_untyped_surface_read(p, dst, payload, - surf_index.dw1.ud, - inst->mlen, inst->exec_size / 8); + brw_untyped_surface_read(p, dst, payload, surf_index.dw1.ud, inst->mlen, 1); brw_mark_surface_used(prog_data, surf_index.dw1.ud); } diff --git a/src/mesa/drivers/dri/i965/brw_vec4_generator.cpp b/src/mesa/drivers/dri/i965/brw_vec4_generator.cpp index 2bcddb1..9714785 100644 --- a/src/mesa/drivers/dri/i965/brw_vec4_generator.cpp +++ b/src/mesa/drivers/dri/i965/brw_vec4_generator.cpp @@ -1125,7 +1125,7 @@ vec4_generator::generate_untyped_atomic(vec4_instruction *inst, brw_untyped_atomic(p, dst, brw_message_reg(inst->base_mrf), atomic_op.dw1.ud, surf_index.dw1.ud, - inst->mlen, 1); + inst->mlen, true); brw_mark_surface_used(&prog_data->base, surf_index.dw1.ud); } @@ -1139,8 +1139,7 @@ vec4_generator::generate_untyped_surface_read(vec4_instruction *inst, surf_index.type == BRW_REGISTER_TYPE_UD); brw_untyped_surface_read(p, dst, brw_message_reg(inst->base_mrf), - surf_index.dw1.ud, - inst->mlen, 1); + surf_index.dw1.ud, inst->mlen, 1); brw_mark_surface_used(&prog_data->base, surf_index.dw1.ud); } From currojerez at kemper.freedesktop.org Fri Mar 20 15:17:10 2015 From: currojerez at kemper.freedesktop.org (Francisco Jerez) Date: Fri, 20 Mar 2015 08:17:10 -0700 (PDT) Subject: Mesa (master): i965: Mask out unused Align16 components in brw_untyped_atomic. Message-ID: <20150320151710.3E4E37624F@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 1cc00f1875e7b830db27945090ad78be41157dc9 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=1cc00f1875e7b830db27945090ad78be41157dc9 Author: Francisco Jerez Date: Thu Feb 26 13:58:21 2015 +0200 i965: Mask out unused Align16 components in brw_untyped_atomic. This is currently not a problem because the vec4 visitor happens to mask out unused components from the destination, but it might become an issue when we start using atomics without writeback message. In any case it seems sensible to set it again here because the consequences of setting the wrong writemask (random graphics memory corruption) are difficult to debug and can easily go unnoticed. Reviewed-by: Topi Pohjolainen Acked-by: Kenneth Graunke --- src/mesa/drivers/dri/i965/brw_eu_emit.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_eu_emit.c b/src/mesa/drivers/dri/i965/brw_eu_emit.c index 8b134a5..1fe9e7b 100644 --- a/src/mesa/drivers/dri/i965/brw_eu_emit.c +++ b/src/mesa/drivers/dri/i965/brw_eu_emit.c @@ -2799,16 +2799,25 @@ brw_untyped_atomic(struct brw_compile *p, bool response_expected) { const struct brw_context *brw = p->brw; + const bool align1 = brw_inst_access_mode(brw, p->current) == BRW_ALIGN_1; + /* Mask out unused components -- This is especially important in Align16 + * mode on generations that don't have native support for SIMD4x2 atomics, + * because unused but enabled components will cause the dataport to perform + * additional atomic operations on the addresses that happen to be in the + * uninitialized Y, Z and W coordinates of the payload. + */ + const unsigned mask = align1 ? WRITEMASK_XYZW : WRITEMASK_X; brw_inst *insn = brw_next_insn(p, BRW_OPCODE_SEND); - brw_set_dest(p, insn, retype(dest, BRW_REGISTER_TYPE_UD)); + brw_set_dest(p, insn, retype(brw_writemask(dest, mask), + BRW_REGISTER_TYPE_UD)); brw_set_src0(p, insn, retype(payload, BRW_REGISTER_TYPE_UD)); brw_set_src1(p, insn, brw_imm_d(0)); brw_set_dp_untyped_atomic_message( p, insn, atomic_op, bind_table_index, msg_length, brw_surface_payload_size(p, response_expected, brw->gen >= 8 || brw->is_haswell, true), - brw_inst_access_mode(brw, insn) == BRW_ALIGN_1); + align1); } static void From cwabbott0 at kemper.freedesktop.org Fri Mar 20 15:59:06 2015 From: cwabbott0 at kemper.freedesktop.org (Connor Abbott) Date: Fri, 20 Mar 2015 08:59:06 -0700 (PDT) Subject: Mesa (master): i965/fs: bail on move-to-flag in sel peephole Message-ID: <20150320155906.D84527624F@kemper.freedesktop.org> Module: Mesa Branch: master Commit: ccb9cbc849af50c435ec69498281cd3cef52d02e URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=ccb9cbc849af50c435ec69498281cd3cef52d02e Author: Connor Abbott Date: Thu Mar 19 20:58:58 2015 -0400 i965/fs: bail on move-to-flag in sel peephole Fixes a piglit regression (shaders/glsl-fs-vec4-indexing-temp-dst-in-nested-loop-combined) with my series for GVN. Reviewed-by: Matt Turner Signed-off-by: Connor Abbott --- src/mesa/drivers/dri/i965/brw_fs_sel_peephole.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/mesa/drivers/dri/i965/brw_fs_sel_peephole.cpp b/src/mesa/drivers/dri/i965/brw_fs_sel_peephole.cpp index ee485fa..740ba67 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_sel_peephole.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_sel_peephole.cpp @@ -176,7 +176,9 @@ fs_visitor::opt_peephole_sel() /* Check that the MOVs are the right form. */ if (!then_mov[i]->dst.equals(else_mov[i]->dst) || then_mov[i]->is_partial_write() || - else_mov[i]->is_partial_write()) { + else_mov[i]->is_partial_write() || + then_mov[i]->conditional_mod != BRW_CONDITIONAL_NONE || + else_mov[i]->conditional_mod != BRW_CONDITIONAL_NONE) { movs = i; break; } From idr at kemper.freedesktop.org Fri Mar 20 19:28:29 2015 From: idr at kemper.freedesktop.org (Ian Romanick) Date: Fri, 20 Mar 2015 12:28:29 -0700 (PDT) Subject: Mesa (master): i965/fs: Use correct null destination register in cmod tests Message-ID: <20150320192829.362967624F@kemper.freedesktop.org> Module: Mesa Branch: master Commit: a04b520890c669ce012b4b18165392dcabe0b27b URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=a04b520890c669ce012b4b18165392dcabe0b27b Author: Ian Romanick Date: Thu Mar 19 16:44:14 2015 -0700 i965/fs: Use correct null destination register in cmod tests Signed-off-by: Ian Romanick Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=89670 Reviewed-by: Matt Turner Cc: Vinson Lee --- src/mesa/drivers/dri/i965/test_fs_cmod_propagation.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/mesa/drivers/dri/i965/test_fs_cmod_propagation.cpp b/src/mesa/drivers/dri/i965/test_fs_cmod_propagation.cpp index 1ce14f8..ed8744d 100644 --- a/src/mesa/drivers/dri/i965/test_fs_cmod_propagation.cpp +++ b/src/mesa/drivers/dri/i965/test_fs_cmod_propagation.cpp @@ -459,7 +459,7 @@ TEST_F(cmod_propagation_test, andnz_one) v->emit(BRW_OPCODE_CMP, retype(dest, BRW_REGISTER_TYPE_F), src0, zero) ->conditional_mod = BRW_CONDITIONAL_L; - v->emit(BRW_OPCODE_AND, v->reg_null_f, dest, one) + v->emit(BRW_OPCODE_AND, v->reg_null_d, dest, one) ->conditional_mod = BRW_CONDITIONAL_NZ; /* = Before = @@ -494,7 +494,7 @@ TEST_F(cmod_propagation_test, andnz_non_one) v->emit(BRW_OPCODE_CMP, retype(dest, BRW_REGISTER_TYPE_F), src0, zero) ->conditional_mod = BRW_CONDITIONAL_L; - v->emit(BRW_OPCODE_AND, v->reg_null_f, dest, nonone) + v->emit(BRW_OPCODE_AND, v->reg_null_d, dest, nonone) ->conditional_mod = BRW_CONDITIONAL_NZ; /* = Before = @@ -529,7 +529,7 @@ TEST_F(cmod_propagation_test, andz_one) v->emit(BRW_OPCODE_CMP, retype(dest, BRW_REGISTER_TYPE_F), src0, zero) ->conditional_mod = BRW_CONDITIONAL_L; - v->emit(BRW_OPCODE_AND, v->reg_null_f, dest, one) + v->emit(BRW_OPCODE_AND, v->reg_null_d, dest, one) ->conditional_mod = BRW_CONDITIONAL_Z; /* = Before = From airlied at kemper.freedesktop.org Fri Mar 20 22:15:03 2015 From: airlied at kemper.freedesktop.org (Dave Airlie) Date: Fri, 20 Mar 2015 15:15:03 -0700 (PDT) Subject: Mesa (master): mesa: reorder gl_texture_unit Message-ID: <20150320221503.0BC4276359@kemper.freedesktop.org> Module: Mesa Branch: master Commit: cbaff50828205188d738f5727261b8a95861ef38 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=cbaff50828205188d738f5727261b8a95861ef38 Author: Dave Airlie Date: Fri Mar 20 16:00:10 2015 +1000 mesa: reorder gl_texture_unit drops size from 520 -> 512 bytes, which then makes gl_texture_attrib go from 99984 to 98440. Acked-by: Brian Paul Reviewed-by: Alex Deucher alexander.deucher at amd.com> Signed-off-by: Dave Airlie --- src/mesa/main/mtypes.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index d9f0086..9a52b2f 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -1349,6 +1349,9 @@ struct gl_texture_unit GLfloat LodBias; /**< for biasing mipmap levels */ + /** Texture targets that have a non-default texture bound */ + GLbitfield _BoundTextures; + /** Current sampler object (GL_ARB_sampler_objects) */ struct gl_sampler_object *Sampler; @@ -1375,8 +1378,6 @@ struct gl_texture_unit /** Points to highest priority, complete and enabled texture object */ struct gl_texture_object *_Current; - /** Texture targets that have a non-default texture bound */ - GLbitfield _BoundTextures; }; From airlied at kemper.freedesktop.org Fri Mar 20 22:15:02 2015 From: airlied at kemper.freedesktop.org (Dave Airlie) Date: Fri, 20 Mar 2015 15:15:02 -0700 (PDT) Subject: Mesa (master): mesa: reorder gl_multisample_attrib Message-ID: <20150320221502.C17057624F@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 684c91401472a3bf60c219901dbc2727aab8c351 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=684c91401472a3bf60c219901dbc2727aab8c351 Author: Dave Airlie Date: Fri Mar 20 15:58:09 2015 +1000 mesa: reorder gl_multisample_attrib drops size from 28 bytes to 20. Acked-by: Brian Paul Reviewed-by: Alex Deucher alexander.deucher at amd.com> Signed-off-by: Dave Airlie --- src/mesa/main/mtypes.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index c43c6ac..a428a59 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -900,13 +900,15 @@ struct gl_multisample_attrib GLboolean SampleAlphaToCoverage; GLboolean SampleAlphaToOne; GLboolean SampleCoverage; - GLfloat SampleCoverageValue; GLboolean SampleCoverageInvert; GLboolean SampleShading; - GLfloat MinSampleShadingValue; /* ARB_texture_multisample / GL3.2 additions */ GLboolean SampleMask; + + GLfloat SampleCoverageValue; + GLfloat MinSampleShadingValue; + /** The GL spec defines this as an array but >32x MSAA is madness */ GLbitfield SampleMaskValue; }; From airlied at kemper.freedesktop.org Fri Mar 20 22:15:02 2015 From: airlied at kemper.freedesktop.org (Dave Airlie) Date: Fri, 20 Mar 2015 15:15:02 -0700 (PDT) Subject: Mesa (master): mesa: reorder gl_point_attrib Message-ID: <20150320221502.ECD77760B4@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 83606b490491adbe9f3b8af9413f2a23b7896ff1 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=83606b490491adbe9f3b8af9413f2a23b7896ff1 Author: Dave Airlie Date: Fri Mar 20 15:59:01 2015 +1000 mesa: reorder gl_point_attrib this drops the size from 52 bytes to 48 bytes. Acked-by: Brian Paul Reviewed-by: Alex Deucher alexander.deucher at amd.com> Signed-off-by: Dave Airlie --- src/mesa/main/mtypes.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index a428a59..d9f0086 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -979,11 +979,11 @@ struct gl_pixel_attrib */ struct gl_point_attrib { - GLboolean SmoothFlag; /**< True if GL_POINT_SMOOTH is enabled */ GLfloat Size; /**< User-specified point size */ GLfloat Params[3]; /**< GL_EXT_point_parameters */ GLfloat MinSize, MaxSize; /**< GL_EXT_point_parameters */ GLfloat Threshold; /**< GL_EXT_point_parameters */ + GLboolean SmoothFlag; /**< True if GL_POINT_SMOOTH is enabled */ GLboolean _Attenuated; /**< True if Params != [1, 0, 0] */ GLboolean PointSprite; /**< GL_NV/ARB_point_sprite */ GLboolean CoordReplace[MAX_TEXTURE_COORD_UNITS]; /**< GL_ARB_point_sprite*/ From airlied at kemper.freedesktop.org Fri Mar 20 22:15:03 2015 From: airlied at kemper.freedesktop.org (Dave Airlie) Date: Fri, 20 Mar 2015 15:15:03 -0700 (PDT) Subject: Mesa (master): mesa: reorder gl_array_attrib Message-ID: <20150320221503.2BF2C7624F@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 401b11843b91112e2f5957c2b174b564cd1825b3 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=401b11843b91112e2f5957c2b174b564cd1825b3 Author: Dave Airlie Date: Fri Mar 20 16:07:24 2015 +1000 mesa: reorder gl_array_attrib drops 80 bytes to 72. Acked-by: Brian Paul Reviewed-by: Alex Deucher alexander.deucher at amd.com> Signed-off-by: Dave Airlie --- src/mesa/main/mtypes.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 627c144..72db275 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -1710,6 +1710,9 @@ struct gl_array_attrib GLuint RestartIndex; /*@}*/ + /** One of the DRAW_xxx flags, not consumed by drivers */ + gl_draw_method DrawMethod; + /* GL_ARB_vertex_buffer_object */ struct gl_buffer_object *ArrayBufferObj; @@ -1719,9 +1722,6 @@ struct gl_array_attrib */ const struct gl_client_array **_DrawArrays; /**< 0..VERT_ATTRIB_MAX-1 */ - /** One of the DRAW_xxx flags, not consumed by drivers */ - gl_draw_method DrawMethod; - /** Legal array datatypes and the API for which they have been computed */ GLbitfield LegalTypesMask; gl_api LegalTypesMaskAPI; From airlied at kemper.freedesktop.org Fri Mar 20 22:15:03 2015 From: airlied at kemper.freedesktop.org (Dave Airlie) Date: Fri, 20 Mar 2015 15:15:03 -0700 (PDT) Subject: Mesa (master): mesa: reorder gl_transform_feedback_object Message-ID: <20150320221503.46E7B7624F@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 7b634fed5918bb55b7335170a57b297830d0817f URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=7b634fed5918bb55b7335170a57b297830d0817f Author: Dave Airlie Date: Fri Mar 20 16:52:44 2015 +1000 mesa: reorder gl_transform_feedback_object Reduces size from 184 to 176 bytes. Acked-by: Brian Paul Reviewed-by: Alex Deucher alexander.deucher at amd.com> Signed-off-by: Dave Airlie --- src/mesa/main/mtypes.h | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 72db275..1b8341d 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -1883,8 +1883,8 @@ struct gl_transform_feedback_info struct gl_transform_feedback_object { GLuint Name; /**< AKA the object ID */ - GLchar *Label; /**< GL_KHR_debug */ GLint RefCount; + GLchar *Label; /**< GL_KHR_debug */ GLboolean Active; /**< Is transform feedback enabled? */ GLboolean Paused; /**< Is transform feedback paused? */ GLboolean EndedAnytime; /**< Has EndTransformFeedback been called @@ -1892,14 +1892,6 @@ struct gl_transform_feedback_object GLboolean EverBound; /**< Has this object been bound? */ /** - * The shader program active when BeginTransformFeedback() was called. - * When active and unpaused, this equals ctx->Shader.CurrentProgram[stage], - * where stage is the pipeline stage that is the source of data for - * transform feedback. - */ - struct gl_shader_program *shader_program; - - /** * GLES: if Active is true, remaining number of primitives which can be * rendered without overflow. This is necessary to track because GLES * requires us to generate INVALID_OPERATION if a call to glDrawArrays or @@ -1910,6 +1902,14 @@ struct gl_transform_feedback_object */ unsigned GlesRemainingPrims; + /** + * The shader program active when BeginTransformFeedback() was called. + * When active and unpaused, this equals ctx->Shader.CurrentProgram[stage], + * where stage is the pipeline stage that is the source of data for + * transform feedback. + */ + struct gl_shader_program *shader_program; + /** The feedback buffers */ GLuint BufferNames[MAX_FEEDBACK_BUFFERS]; struct gl_buffer_object *Buffers[MAX_FEEDBACK_BUFFERS]; From airlied at kemper.freedesktop.org Fri Mar 20 22:15:03 2015 From: airlied at kemper.freedesktop.org (Dave Airlie) Date: Fri, 20 Mar 2015 15:15:03 -0700 (PDT) Subject: Mesa (master): mesa: reorder gl_client_array Message-ID: <20150320221503.1BF947635A@kemper.freedesktop.org> Module: Mesa Branch: master Commit: b3f6e0bb587457cbfab3c04cae9d062843369eb9 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=b3f6e0bb587457cbfab3c04cae9d062843369eb9 Author: Dave Airlie Date: Fri Mar 20 16:02:46 2015 +1000 mesa: reorder gl_client_array drops from 56 to 48 bytes, drops gl_vertex_array_object from 4584 to 4320 bytes Acked-by: Brian Paul Reviewed-by: Alex Deucher alexander.deucher at amd.com> Signed-off-by: Dave Airlie --- src/mesa/main/mtypes.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 9a52b2f..627c144 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -1539,12 +1539,12 @@ struct gl_client_array GLenum Format; /**< default: GL_RGBA, but may be GL_BGRA */ GLsizei Stride; /**< user-specified stride */ GLsizei StrideB; /**< actual stride in bytes */ + GLuint _ElementSize; /**< size of each element in bytes */ const GLubyte *Ptr; /**< Points to array data */ GLboolean Enabled; /**< Enabled flag is a boolean */ GLboolean Normalized; /**< GL_ARB_vertex_program */ GLboolean Integer; /**< Integer-valued? */ GLuint InstanceDivisor; /**< GL_ARB_instanced_arrays */ - GLuint _ElementSize; /**< size of each element in bytes */ struct gl_buffer_object *BufferObj;/**< GL_ARB_vertex_buffer_object */ }; From airlied at kemper.freedesktop.org Fri Mar 20 22:15:03 2015 From: airlied at kemper.freedesktop.org (Dave Airlie) Date: Fri, 20 Mar 2015 15:15:03 -0700 (PDT) Subject: Mesa (master): mesa: reorder gl_program, gl_shader, gl_shader_program Message-ID: <20150320221503.50AC37633A@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 0ff4726a0632b9c15d349cd05070b57fd61f1f98 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=0ff4726a0632b9c15d349cd05070b57fd61f1f98 Author: Dave Airlie Date: Fri Mar 20 16:54:40 2015 +1000 mesa: reorder gl_program, gl_shader, gl_shader_program gl_program : 1344->1336 gl_shader: 488->472 gl_shader_program: 352->344. Acked-by: Brian Paul Reviewed-by: Alex Deucher alexander.deucher at amd.com> Signed-off-by: Dave Airlie --- src/mesa/main/mtypes.h | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 1b8341d..f8f21d8 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -2232,8 +2232,9 @@ enum gl_frag_depth_layout struct gl_program { GLuint Id; - GLubyte *String; /**< Null-terminated program text */ GLint RefCount; + GLubyte *String; /**< Null-terminated program text */ + GLenum Target; /**< GL_VERTEX/FRAGMENT_PROGRAM_ARB, GL_GEOMETRY_PROGRAM_NV */ GLenum Format; /**< String encoding format */ @@ -2536,18 +2537,20 @@ struct gl_shader GLenum Type; gl_shader_stage Stage; GLuint Name; /**< AKA the handle */ - GLchar *Label; /**< GL_KHR_debug */ GLint RefCount; /**< Reference count */ + GLchar *Label; /**< GL_KHR_debug */ GLboolean DeletePending; GLboolean CompileStatus; - const GLchar *Source; /**< Source code string */ + GLboolean IsES; /**< True if this shader uses GLSL ES */ + GLuint SourceChecksum; /**< for debug/logging purposes */ + const GLchar *Source; /**< Source code string */ + struct gl_program *Program; /**< Post-compile assembly code */ GLchar *InfoLog; struct gl_sl_pragmas Pragmas; unsigned Version; /**< GLSL version used for linking */ - GLboolean IsES; /**< True if this shader uses GLSL ES */ /** * \name Sampler tracking @@ -2591,8 +2594,8 @@ struct gl_shader * * These fields are only set post-linking. */ - struct gl_uniform_block *UniformBlocks; unsigned NumUniformBlocks; + struct gl_uniform_block *UniformBlocks; struct exec_list *ir; struct glsl_symbol_table *symbols; @@ -2882,8 +2885,8 @@ struct gl_shader_program */ unsigned LastClipDistanceArraySize; - struct gl_uniform_block *UniformBlocks; unsigned NumUniformBlocks; + struct gl_uniform_block *UniformBlocks; /** * Indices into the _LinkedShaders's UniformBlocks[] array for each stage From airlied at kemper.freedesktop.org Fri Mar 20 22:15:03 2015 From: airlied at kemper.freedesktop.org (Dave Airlie) Date: Fri, 20 Mar 2015 15:15:03 -0700 (PDT) Subject: Mesa (master): mesa: reduce gl_colorbuffer_attrib and gl_fog_attrib Message-ID: <20150320221503.75E607624F@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 2dbd8284e72c8b3fe412a7e1c7734e9685fedd7d URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=2dbd8284e72c8b3fe412a7e1c7734e9685fedd7d Author: Dave Airlie Date: Fri Mar 20 17:05:40 2015 +1000 mesa: reduce gl_colorbuffer_attrib and gl_fog_attrib These 392->388 and 72->68. Acked-by: Brian Paul Reviewed-by: Alex Deucher alexander.deucher at amd.com> Signed-off-by: Dave Airlie --- src/mesa/main/mtypes.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 42075aa..4e1b468 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -693,15 +693,16 @@ struct gl_colorbuffer_attrib * \name Logic op */ /*@{*/ - GLenum LogicOp; /**< Logic operator */ GLboolean IndexLogicOpEnabled; /**< Color index logic op enabled flag */ GLboolean ColorLogicOpEnabled; /**< RGBA logic op enabled flag */ + GLenum LogicOp; /**< Logic operator */ + /*@}*/ GLboolean DitherFlag; /**< Dither enable flag */ - GLenum ClampFragmentColor; /**< GL_TRUE, GL_FALSE or GL_FIXED_ONLY_ARB */ GLboolean _ClampFragmentColor; /** < with GL_FIXED_ONLY_ARB resolved */ + GLenum ClampFragmentColor; /**< GL_TRUE, GL_FALSE or GL_FIXED_ONLY_ARB */ GLenum ClampReadColor; /**< GL_TRUE, GL_FALSE or GL_FIXED_ONLY_ARB */ GLboolean sRGBEnabled; /**< Framebuffer sRGB blending/updating requested */ @@ -799,6 +800,7 @@ struct gl_eval_attrib struct gl_fog_attrib { GLboolean Enabled; /**< Fog enabled flag */ + GLboolean ColorSumEnabled; GLfloat ColorUnclamped[4]; /**< Fog color */ GLfloat Color[4]; /**< Fog color */ GLfloat Density; /**< Density >= 0.0 */ @@ -806,7 +808,6 @@ struct gl_fog_attrib GLfloat End; /**< End distance in eye coords */ GLfloat Index; /**< Fog index */ GLenum Mode; /**< Fog mode */ - GLboolean ColorSumEnabled; GLenum FogCoordinateSource; /**< GL_EXT_fog_coord */ GLfloat _Scale; /**< (End == Start) ? 1.0 : 1.0 / (End - Start) */ GLenum FogDistanceMode; /**< GL_NV_fog_distance */ From airlied at kemper.freedesktop.org Fri Mar 20 22:15:03 2015 From: airlied at kemper.freedesktop.org (Dave Airlie) Date: Fri, 20 Mar 2015 15:15:03 -0700 (PDT) Subject: Mesa (master): mesa: repack gl_texture_attrib. Message-ID: <20150320221503.85DF67624F@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 974e4783a5c7ee9d378124f6dcfc6a0ffd9727db URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=974e4783a5c7ee9d378124f6dcfc6a0ffd9727db Author: Dave Airlie Date: Fri Mar 20 17:10:57 2015 +1000 mesa: repack gl_texture_attrib. This removes a hole, and puts the large allocation at the end, Acked-by: Brian Paul Reviewed-by: Alex Deucher alexander.deucher at amd.com> Signed-off-by: Dave Airlie --- src/mesa/main/mtypes.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 4e1b468..587507b 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -1388,16 +1388,15 @@ struct gl_texture_unit struct gl_texture_attrib { GLuint CurrentUnit; /**< GL_ACTIVE_TEXTURE */ - struct gl_texture_unit Unit[MAX_COMBINED_TEXTURE_IMAGE_UNITS]; + + /** GL_ARB_seamless_cubemap */ + GLboolean CubeMapSeamless; struct gl_texture_object *ProxyTex[NUM_TEXTURE_TARGETS]; /** GL_ARB_texture_buffer_object */ struct gl_buffer_object *BufferObject; - /** GL_ARB_seamless_cubemap */ - GLboolean CubeMapSeamless; - /** Texture coord units/sets used for fragment texturing */ GLbitfield _EnabledCoordUnits; @@ -1415,6 +1414,8 @@ struct gl_texture_attrib /** Largest index + 1 of texture units that have had any CurrentTex set. */ GLint NumCurrentTexUsed; + + struct gl_texture_unit Unit[MAX_COMBINED_TEXTURE_IMAGE_UNITS]; }; From airlied at kemper.freedesktop.org Fri Mar 20 22:15:03 2015 From: airlied at kemper.freedesktop.org (Dave Airlie) Date: Fri, 20 Mar 2015 15:15:03 -0700 (PDT) Subject: Mesa (master): mesa: fix hole in vertex_array_object Message-ID: <20150320221503.929817624F@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 727eb4c4e7edc3eeb8126000379d9e2bab985773 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=727eb4c4e7edc3eeb8126000379d9e2bab985773 Author: Dave Airlie Date: Fri Mar 20 17:13:03 2015 +1000 mesa: fix hole in vertex_array_object this just removes 4 bytes from this object. Acked-by: Brian Paul Reviewed-by: Alex Deucher alexander.deucher at amd.com> Signed-off-by: Dave Airlie --- src/mesa/main/mtypes.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 587507b..68a5d5c 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -1605,9 +1605,11 @@ struct gl_vertex_array_object { /** Name of the VAO as received from glGenVertexArray. */ GLuint Name; - GLchar *Label; /**< GL_KHR_debug */ GLint RefCount; + + GLchar *Label; /**< GL_KHR_debug */ + mtx_t Mutex; /** From airlied at kemper.freedesktop.org Fri Mar 20 22:15:03 2015 From: airlied at kemper.freedesktop.org (Dave Airlie) Date: Fri, 20 Mar 2015 15:15:03 -0700 (PDT) Subject: Mesa (master): mesa: reorder gl_framebuffer Message-ID: <20150320221503.A42E97624F@kemper.freedesktop.org> Module: Mesa Branch: master Commit: b99c7defaca2bd89d02c40b0c42dac105b46293c URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=b99c7defaca2bd89d02c40b0c42dac105b46293c Author: Dave Airlie Date: Fri Mar 20 17:21:57 2015 +1000 mesa: reorder gl_framebuffer this reduces it from 1088 -> 1080 bytes Acked-by: Brian Paul Reviewed-by: Alex Deucher alexander.deucher at amd.com> Signed-off-by: Dave Airlie --- src/mesa/main/mtypes.h | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 68a5d5c..e77c4f0 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -3275,9 +3275,10 @@ struct gl_framebuffer * polygon face orientation, and polygon stipple will have to be inverted. */ GLuint Name; + GLint RefCount; + GLchar *Label; /**< GL_KHR_debug */ - GLint RefCount; GLboolean DeletePending; /** @@ -3311,6 +3312,13 @@ struct gl_framebuffer GLboolean _AllColorBuffersFixedPoint; /* no integer, no float */ GLboolean _HasSNormOrFloatColorBuffer; + /** + * The maximum number of layers in the framebuffer, or 0 if the framebuffer + * is not layered. For cube maps and cube map arrays, each cube face + * counts as a layer. + */ + GLuint MaxNumLayers; + /** Array of all renderbuffer attachments, indexed by BUFFER_* tokens. */ struct gl_renderbuffer_attachment Attachment[BUFFER_COUNT]; @@ -3327,13 +3335,6 @@ struct gl_framebuffer struct gl_renderbuffer *_ColorDrawBuffers[MAX_DRAW_BUFFERS]; struct gl_renderbuffer *_ColorReadBuffer; - /** - * The maximum number of layers in the framebuffer, or 0 if the framebuffer - * is not layered. For cube maps and cube map arrays, each cube face - * counts as a layer. - */ - GLuint MaxNumLayers; - /** Delete this framebuffer */ void (*Delete)(struct gl_framebuffer *fb); }; From airlied at kemper.freedesktop.org Fri Mar 20 22:15:03 2015 From: airlied at kemper.freedesktop.org (Dave Airlie) Date: Fri, 20 Mar 2015 15:15:03 -0700 (PDT) Subject: Mesa (master): mesa: reorder gl_light_attrib Message-ID: <20150320221503.B09387624F@kemper.freedesktop.org> Module: Mesa Branch: master Commit: ad6ede260f7b2b7356217c4a0d196edba9ebd5e9 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=ad6ede260f7b2b7356217c4a0d196edba9ebd5e9 Author: Dave Airlie Date: Fri Mar 20 17:25:15 2015 +1000 mesa: reorder gl_light_attrib reduces from 2664->2656. Acked-by: Brian Paul Reviewed-by: Alex Deucher alexander.deucher at amd.com> Signed-off-by: Dave Airlie --- src/mesa/main/mtypes.h | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index e77c4f0..1b45494 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -847,16 +847,17 @@ struct gl_light_attrib struct gl_material Material; GLboolean Enabled; /**< Lighting enabled flag */ + GLboolean ColorMaterialEnabled; + GLenum ShadeModel; /**< GL_FLAT or GL_SMOOTH */ GLenum ProvokingVertex; /**< GL_EXT_provoking_vertex */ GLenum ColorMaterialFace; /**< GL_FRONT, BACK or FRONT_AND_BACK */ GLenum ColorMaterialMode; /**< GL_AMBIENT, GL_DIFFUSE, etc */ GLbitfield _ColorMaterialBitmask; /**< bitmask formed from Face and Mode */ - GLboolean ColorMaterialEnabled; - GLenum ClampVertexColor; /**< GL_TRUE, GL_FALSE, GL_FIXED_ONLY */ - GLboolean _ClampVertexColor; - struct gl_light EnabledList; /**< List sentinel */ + + GLboolean _ClampVertexColor; + GLenum ClampVertexColor; /**< GL_TRUE, GL_FALSE, GL_FIXED_ONLY */ /** * Derived state for optimizations: @@ -864,6 +865,8 @@ struct gl_light_attrib /*@{*/ GLboolean _NeedEyeCoords; GLboolean _NeedVertices; /**< Use fast shader? */ + struct gl_light EnabledList; /**< List sentinel */ + GLfloat _BaseColor[2][3]; /*@}*/ }; From airlied at kemper.freedesktop.org Fri Mar 20 22:15:03 2015 From: airlied at kemper.freedesktop.org (Dave Airlie) Date: Fri, 20 Mar 2015 15:15:03 -0700 (PDT) Subject: Mesa (master): mesa: reorder prog_instruction Message-ID: <20150320221503.3A5F27624F@kemper.freedesktop.org> Module: Mesa Branch: master Commit: e17b0435c54bf14d9d1c9a9815814eb11fc66636 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=e17b0435c54bf14d9d1c9a9815814eb11fc66636 Author: Dave Airlie Date: Fri Mar 20 16:26:59 2015 +1000 mesa: reorder prog_instruction reduces size from 64 to 56 bytes. Acked-by: Brian Paul Reviewed-by: Alex Deucher alexander.deucher at amd.com> Signed-off-by: Dave Airlie --- src/mesa/program/prog_instruction.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/mesa/program/prog_instruction.h b/src/mesa/program/prog_instruction.h index 0957bd9..ab3acbc 100644 --- a/src/mesa/program/prog_instruction.h +++ b/src/mesa/program/prog_instruction.h @@ -366,11 +366,11 @@ struct prog_instruction */ GLint BranchTarget; - /** for debugging purposes */ - const char *Comment; - /** for driver use (try to remove someday) */ GLint Aux; + + /** for debugging purposes */ + const char *Comment; }; From airlied at kemper.freedesktop.org Fri Mar 20 22:15:03 2015 From: airlied at kemper.freedesktop.org (Dave Airlie) Date: Fri, 20 Mar 2015 15:15:03 -0700 (PDT) Subject: Mesa (master): mesa: reorder gl_image_unit Message-ID: <20150320221503.656497624F@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 2c016ed35fff36e39a457db8efbc82ec90d4f5da URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=2c016ed35fff36e39a457db8efbc82ec90d4f5da Author: Dave Airlie Date: Fri Mar 20 17:01:55 2015 +1000 mesa: reorder gl_image_unit reduces 40->32 but reduces use in context from 7680->6144. Acked-by: Brian Paul Reviewed-by: Alex Deucher alexander.deucher at amd.com> Signed-off-by: Dave Airlie --- src/mesa/main/mtypes.h | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index f8f21d8..42075aa 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -4167,6 +4167,13 @@ struct gl_image_unit GLboolean Layered; /** + * GL_TRUE if the state of this image unit is valid and access from + * the shader is allowed. Otherwise loads from this unit should + * return zero and stores should have no effect. + */ + GLboolean _Valid; + + /** * Layer of the texture object bound to this unit, or zero if the * whole level is bound. */ @@ -4190,12 +4197,6 @@ struct gl_image_unit */ mesa_format _ActualFormat; - /** - * GL_TRUE if the state of this image unit is valid and access from - * the shader is allowed. Otherwise loads from this unit should - * return zero and stores should have no effect. - */ - GLboolean _Valid; }; /** From evelikov at kemper.freedesktop.org Sat Mar 21 00:47:39 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Fri, 20 Mar 2015 17:47:39 -0700 (PDT) Subject: Mesa (10.4): Update version to 10.4.7 Message-ID: <20150321004739.CF5FE7624F@kemper.freedesktop.org> Module: Mesa Branch: 10.4 Commit: b7b218f3f696d236047bc24dbf2c4b5596fc9a4a URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=b7b218f3f696d236047bc24dbf2c4b5596fc9a4a Author: Emil Velikov Date: Sat Mar 21 00:19:39 2015 +0000 Update version to 10.4.7 Signed-off-by: Emil Velikov --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 9a9af46..c3e4df7 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -10.4.6 +10.4.7 From evelikov at kemper.freedesktop.org Sat Mar 21 00:47:39 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Fri, 20 Mar 2015 17:47:39 -0700 (PDT) Subject: Mesa: tag mesa-10.4.7: Mesa 10.4.7 Release Message-ID: <20150321004739.F0C877624F@kemper.freedesktop.org> Module: Mesa Branch: refs/tags/mesa-10.4.7 Tag: ebf849f5175b93d9cbcf440f171aaa9e9441a715 URL: http://cgit.freedesktop.org/mesa/mesa/tag/?id=ebf849f5175b93d9cbcf440f171aaa9e9441a715 Tagger: Emil Velikov Date: Sat Mar 21 00:27:21 2015 +0000 Mesa 10.4.7 Release From evelikov at kemper.freedesktop.org Sat Mar 21 00:47:39 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Fri, 20 Mar 2015 17:47:39 -0700 (PDT) Subject: Mesa (10.4): docs: Add sha256 sums for the 10.4.7 release Message-ID: <20150321004739.E1CD27624F@kemper.freedesktop.org> Module: Mesa Branch: 10.4 Commit: cb154bb22116910c462f7a83f4401bd01e15c34d URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=cb154bb22116910c462f7a83f4401bd01e15c34d Author: Emil Velikov Date: Sat Mar 21 00:50:13 2015 +0000 docs: Add sha256 sums for the 10.4.7 release Signed-off-by: Emil Velikov --- docs/relnotes/10.4.7.html | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/relnotes/10.4.7.html b/docs/relnotes/10.4.7.html index 27a475c..0191353 100644 --- a/docs/relnotes/10.4.7.html +++ b/docs/relnotes/10.4.7.html @@ -30,7 +30,9 @@ because compatibility contexts are not supported.

          SHA256 checksums

          -TBD
          +9e7b59267199658808f8b33e0410b86fbafbdcd52378658b9df65fac9d24947f  MesaLib-10.4.7.tar.gz
          +2c351c98671f9a7ab3fd9c601bb7a255801b1580f5dd0992639f99152801b0d2  MesaLib-10.4.7.tar.bz2
          +d14ac578b5ce16560757b53fbd1cb4d6b34652f8e110e4b10a019adc82e67ffd  MesaLib-10.4.7.zip
           

          New features

          From evelikov at kemper.freedesktop.org Sat Mar 21 00:47:39 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Fri, 20 Mar 2015 17:47:39 -0700 (PDT) Subject: Mesa (10.4): Add release notes for the 10.4.7 release Message-ID: <20150321004739.D80517633A@kemper.freedesktop.org> Module: Mesa Branch: 10.4 Commit: d26f3c1f860e267964d2bd74a86235ae702af3f4 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=d26f3c1f860e267964d2bd74a86235ae702af3f4 Author: Emil Velikov Date: Sat Mar 21 00:26:27 2015 +0000 Add release notes for the 10.4.7 release Signed-off-by: Emil Velikov --- docs/relnotes/10.4.7.html | 132 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 132 insertions(+) diff --git a/docs/relnotes/10.4.7.html b/docs/relnotes/10.4.7.html new file mode 100644 index 0000000..27a475c --- /dev/null +++ b/docs/relnotes/10.4.7.html @@ -0,0 +1,132 @@ + + + + + Mesa Release Notes + + + + +
          +

          The Mesa 3D Graphics Library

          +
          + + +
          + +

          Mesa 10.4.7 Release Notes / March 20, 2015

          + +

          +Mesa 10.4.7 is a bug fix release which fixes bugs found since the 10.4.6 release. +

          +

          +Mesa 10.4.7 implements the OpenGL 3.3 API, but the version reported by +glGetString(GL_VERSION) or glGetIntegerv(GL_MAJOR_VERSION) / +glGetIntegerv(GL_MINOR_VERSION) depends on the particular driver being used. +Some drivers don't support all the features required in OpenGL 3.3. OpenGL +3.3 is only available if requested at context creation +because compatibility contexts are not supported. +

          + +

          SHA256 checksums

          +
          +TBD
          +
          + +

          New features

          +

          None

          + +

          Bug fixes

          + +

          This list is likely incomplete.

          + +
            + +
          • Bug 79202 - valgrind errors in glsl-fs-uniform-array-loop-unroll.shader_test; random code generation
          • + +
          • Bug 89156 - r300g: GL_COMPRESSED_RED_RGTC1 / ATI1N support broken
          • + +
          • Bug 89224 - Incorrect rendering of Unigine Valley running in VM on VMware Workstation
          • + +
          • Bug 89530 - FTBFS in loader: missing fstat
          • + +
          + +

          Changes

          + +

          Andrey Sudnik (1):

          +
            +
          • i965/vec4: Don't lose the saturate modifier in copy propagation.
          • +
          + +

          Daniel Stone (1):

          +
            +
          • egl: Take alpha bits into account when selecting GBM formats
          • +
          + +

          Emil Velikov (6):

          +
            +
          • docs: Add sha256 sums for the 10.4.6 release
          • +
          • cherry-ignore: add not applicable/rejected commits
          • +
          • mesa: rename format_info.c to format_info.h
          • +
          • loader: include <sys/stat.h> for non-sysfs builds
          • +
          • auxiliary/os: fix the android build - s/drm_munmap/os_munmap/
          • +
          • Update version to 10.4.7
          • +
          + +

          Iago Toral Quiroga (1):

          +
            +
          • i965: Fix out-of-bounds accesses into pull_constant_loc array
          • +
          + +

          Ilia Mirkin (4):

          +
            +
          • freedreno: move fb state copy after checking for size change
          • +
          • freedreno/ir3: fix array count returned by TXQ
          • +
          • freedreno/ir3: get the # of miplevels from getinfo
          • +
          • freedreno: fix slice pitch calculations
          • +
          + +

          Marc-Andre Lureau (1):

          +
            +
          • gallium/auxiliary/indices: fix start param
          • +
          + +

          Marek Ol??k (4):

          +
            +
          • r300g: fix RGTC1 and LATC1 SNORM formats
          • +
          • r300g: fix a crash when resolving into an sRGB texture
          • +
          • r300g: fix sRGB->sRGB blits
          • +
          • radeonsi: increase coords array size for radeon_llvm_emit_prepare_cube_coords
          • +
          + +

          Mario Kleiner (1):

          +
            +
          • glx: Handle out-of-sequence swap completion events correctly. (v2)
          • +
          + +

          Matt Turner (2):

          +
            +
          • r300g: Use PATH_MAX instead of limiting ourselves to 100 chars.
          • +
          • r300g: Check return value of snprintf().
          • +
          + +

          Rob Clark (2):

          +
            +
          • freedreno/ir3: fix silly typo for binning pass shaders
          • +
          • freedreno: update generated headers
          • +
          + +

          Samuel Iglesias Gonsalvez (1):

          +
            +
          • glsl: optimize (0 cmp x + y) into (-x cmp y).
          • +
          + +

          Stefan D?singer (1):

          +
            +
          • r300g: Fix the ATI1N swizzle (RGTC1 and LATC1)
          • +
          + +
          + + From evelikov at kemper.freedesktop.org Sat Mar 21 00:51:39 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Fri, 20 Mar 2015 17:51:39 -0700 (PDT) Subject: Mesa (master): docs: Add sha256 sums for the 10.4.7 release Message-ID: <20150321005139.3DF377633A@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 0030eef62b7090fe790a8e7f0e6ab801a36a8b05 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=0030eef62b7090fe790a8e7f0e6ab801a36a8b05 Author: Emil Velikov Date: Sat Mar 21 00:50:13 2015 +0000 docs: Add sha256 sums for the 10.4.7 release Signed-off-by: Emil Velikov (cherry picked from commit cb154bb22116910c462f7a83f4401bd01e15c34d) --- docs/relnotes/10.4.7.html | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/relnotes/10.4.7.html b/docs/relnotes/10.4.7.html index 27a475c..0191353 100644 --- a/docs/relnotes/10.4.7.html +++ b/docs/relnotes/10.4.7.html @@ -30,7 +30,9 @@ because compatibility contexts are not supported.

          SHA256 checksums

          -TBD
          +9e7b59267199658808f8b33e0410b86fbafbdcd52378658b9df65fac9d24947f  MesaLib-10.4.7.tar.gz
          +2c351c98671f9a7ab3fd9c601bb7a255801b1580f5dd0992639f99152801b0d2  MesaLib-10.4.7.tar.bz2
          +d14ac578b5ce16560757b53fbd1cb4d6b34652f8e110e4b10a019adc82e67ffd  MesaLib-10.4.7.zip
           

          New features

          From evelikov at kemper.freedesktop.org Sat Mar 21 00:51:39 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Fri, 20 Mar 2015 17:51:39 -0700 (PDT) Subject: Mesa (master): Add release notes for the 10.4.7 release Message-ID: <20150321005139.34A587624F@kemper.freedesktop.org> Module: Mesa Branch: master Commit: befb5d1c94a13fddb1ce508714c909479aeb49c3 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=befb5d1c94a13fddb1ce508714c909479aeb49c3 Author: Emil Velikov Date: Sat Mar 21 00:26:27 2015 +0000 Add release notes for the 10.4.7 release Signed-off-by: Emil Velikov (cherry picked from commit d26f3c1f860e267964d2bd74a86235ae702af3f4) --- docs/relnotes/10.4.7.html | 132 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 132 insertions(+) diff --git a/docs/relnotes/10.4.7.html b/docs/relnotes/10.4.7.html new file mode 100644 index 0000000..27a475c --- /dev/null +++ b/docs/relnotes/10.4.7.html @@ -0,0 +1,132 @@ + + + + + Mesa Release Notes + + + + +
          +

          The Mesa 3D Graphics Library

          +
          + + +
          + +

          Mesa 10.4.7 Release Notes / March 20, 2015

          + +

          +Mesa 10.4.7 is a bug fix release which fixes bugs found since the 10.4.6 release. +

          +

          +Mesa 10.4.7 implements the OpenGL 3.3 API, but the version reported by +glGetString(GL_VERSION) or glGetIntegerv(GL_MAJOR_VERSION) / +glGetIntegerv(GL_MINOR_VERSION) depends on the particular driver being used. +Some drivers don't support all the features required in OpenGL 3.3. OpenGL +3.3 is only available if requested at context creation +because compatibility contexts are not supported. +

          + +

          SHA256 checksums

          +
          +TBD
          +
          + +

          New features

          +

          None

          + +

          Bug fixes

          + +

          This list is likely incomplete.

          + +
            + +
          • Bug 79202 - valgrind errors in glsl-fs-uniform-array-loop-unroll.shader_test; random code generation
          • + +
          • Bug 89156 - r300g: GL_COMPRESSED_RED_RGTC1 / ATI1N support broken
          • + +
          • Bug 89224 - Incorrect rendering of Unigine Valley running in VM on VMware Workstation
          • + +
          • Bug 89530 - FTBFS in loader: missing fstat
          • + +
          + +

          Changes

          + +

          Andrey Sudnik (1):

          +
            +
          • i965/vec4: Don't lose the saturate modifier in copy propagation.
          • +
          + +

          Daniel Stone (1):

          +
            +
          • egl: Take alpha bits into account when selecting GBM formats
          • +
          + +

          Emil Velikov (6):

          +
            +
          • docs: Add sha256 sums for the 10.4.6 release
          • +
          • cherry-ignore: add not applicable/rejected commits
          • +
          • mesa: rename format_info.c to format_info.h
          • +
          • loader: include <sys/stat.h> for non-sysfs builds
          • +
          • auxiliary/os: fix the android build - s/drm_munmap/os_munmap/
          • +
          • Update version to 10.4.7
          • +
          + +

          Iago Toral Quiroga (1):

          +
            +
          • i965: Fix out-of-bounds accesses into pull_constant_loc array
          • +
          + +

          Ilia Mirkin (4):

          +
            +
          • freedreno: move fb state copy after checking for size change
          • +
          • freedreno/ir3: fix array count returned by TXQ
          • +
          • freedreno/ir3: get the # of miplevels from getinfo
          • +
          • freedreno: fix slice pitch calculations
          • +
          + +

          Marc-Andre Lureau (1):

          +
            +
          • gallium/auxiliary/indices: fix start param
          • +
          + +

          Marek Ol??k (4):

          +
            +
          • r300g: fix RGTC1 and LATC1 SNORM formats
          • +
          • r300g: fix a crash when resolving into an sRGB texture
          • +
          • r300g: fix sRGB->sRGB blits
          • +
          • radeonsi: increase coords array size for radeon_llvm_emit_prepare_cube_coords
          • +
          + +

          Mario Kleiner (1):

          +
            +
          • glx: Handle out-of-sequence swap completion events correctly. (v2)
          • +
          + +

          Matt Turner (2):

          +
            +
          • r300g: Use PATH_MAX instead of limiting ourselves to 100 chars.
          • +
          • r300g: Check return value of snprintf().
          • +
          + +

          Rob Clark (2):

          +
            +
          • freedreno/ir3: fix silly typo for binning pass shaders
          • +
          • freedreno: update generated headers
          • +
          + +

          Samuel Iglesias Gonsalvez (1):

          +
            +
          • glsl: optimize (0 cmp x + y) into (-x cmp y).
          • +
          + +

          Stefan D?singer (1):

          +
            +
          • r300g: Fix the ATI1N swizzle (RGTC1 and LATC1)
          • +
          + +
          + + From evelikov at kemper.freedesktop.org Sat Mar 21 00:51:39 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Fri, 20 Mar 2015 17:51:39 -0700 (PDT) Subject: Mesa (master): docs: add news item and link release notes for mesa 10.4.7 Message-ID: <20150321005139.4997E7624F@kemper.freedesktop.org> Module: Mesa Branch: master Commit: b2dccfd17eb045ce240cda232d40edb5dc1c7c31 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=b2dccfd17eb045ce240cda232d40edb5dc1c7c31 Author: Emil Velikov Date: Sat Mar 21 00:54:14 2015 +0000 docs: add news item and link release notes for mesa 10.4.7 Signed-off-by: Emil Velikov --- docs/index.html | 6 ++++++ docs/relnotes.html | 1 + 2 files changed, 7 insertions(+) diff --git a/docs/index.html b/docs/index.html index 9144a43..9bc5843 100644 --- a/docs/index.html +++ b/docs/index.html @@ -16,6 +16,12 @@

          News

          +

          March 20, 2015

          +

          +Mesa 10.4.7 is released. +This is a bug-fix release. +

          +

          March 13, 2015

          Mesa 10.5.1 is released. diff --git a/docs/relnotes.html b/docs/relnotes.html index 9a9c0ba..023f7dd8 100644 --- a/docs/relnotes.html +++ b/docs/relnotes.html @@ -21,6 +21,7 @@ The release notes summarize what's new or changed in each Mesa release.

            +
          • 10.4.7 release notes
          • 10.5.1 release notes
          • 10.5.0 release notes
          • 10.4.6 release notes From sroland at kemper.freedesktop.org Sat Mar 21 00:52:25 2015 From: sroland at kemper.freedesktop.org (Roland Scheidegger) Date: Fri, 20 Mar 2015 17:52:25 -0700 (PDT) Subject: Mesa (master): llvmpipe: use global llvm context for PIPE_SUBSYSTEM_EMBEDDED Message-ID: <20150321005225.747627624F@kemper.freedesktop.org> Module: Mesa Branch: master Commit: e8039208c4a771b0c1fb8a44623bcf0261508f87 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=e8039208c4a771b0c1fb8a44623bcf0261508f87 Author: Roland Scheidegger Date: Sat Mar 21 01:13:54 2015 +0100 llvmpipe: use global llvm context for PIPE_SUBSYSTEM_EMBEDDED There's 2 reasons why we'd want to use the global context: 1) There still seems to be one memory "leak" left when using multiple llvm contexts (it is not a true leak as the memory disappears into some still addressable pool but nevertheless the memory consumption grows). See http://cgit.freedesktop.org/~jrfonseca/llvm-jitstress/ 2) These contexts get kinda big - even when disposing modules etc. after compiling a shader the LLVMContext can easily be over 100kB. So when there's lots of llvm contexts arounds it adds up. The downside is that at least right now this is absolutely not thread safe, so this only works safely in environments where multiple pipe contexts are not used concurrently. Reviewed-by: Jose Fonseca --- src/gallium/drivers/llvmpipe/lp_context.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/gallium/drivers/llvmpipe/lp_context.c b/src/gallium/drivers/llvmpipe/lp_context.c index 06cc820..80cb657 100644 --- a/src/gallium/drivers/llvmpipe/lp_context.c +++ b/src/gallium/drivers/llvmpipe/lp_context.c @@ -46,6 +46,10 @@ #include "lp_query.h" #include "lp_setup.h" +/* This is only safe if there's just one concurrent context */ +#ifdef PIPE_SUBSYSTEM_EMBEDDED +#define USE_GLOBAL_LLVM_CONTEXT +#endif static void llvmpipe_destroy( struct pipe_context *pipe ) { @@ -93,7 +97,9 @@ static void llvmpipe_destroy( struct pipe_context *pipe ) lp_delete_setup_variants(llvmpipe); +#ifndef USE_GLOBAL_LLVM_CONTEXT LLVMContextDispose(llvmpipe->context); +#endif llvmpipe->context = NULL; align_free( llvmpipe ); @@ -164,7 +170,12 @@ llvmpipe_create_context( struct pipe_screen *screen, void *priv ) llvmpipe_init_context_resource_funcs( &llvmpipe->pipe ); llvmpipe_init_surface_functions(llvmpipe); +#ifdef USE_GLOBAL_LLVM_CONTEXT + llvmpipe->context = LLVMGetGlobalContext(); +#else llvmpipe->context = LLVMContextCreate(); +#endif + if (!llvmpipe->context) goto fail; From evelikov at kemper.freedesktop.org Sat Mar 21 17:29:30 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Sat, 21 Mar 2015 10:29:30 -0700 (PDT) Subject: Mesa (master): winsys/sw/fbdev: remove unused software winsys Message-ID: <20150321172930.42A757635B@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 65a8d4d6ddbed8fd47cd4efc38d4a344add5ec5a URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=65a8d4d6ddbed8fd47cd4efc38d4a344add5ec5a Author: Emil Velikov Date: Sat Mar 14 22:36:27 2015 +0000 winsys/sw/fbdev: remove unused software winsys st/egl was its only user. Signed-off-by: Emil Velikov Acked-by: Matt Turner --- configure.ac | 1 - src/gallium/Makefile.am | 4 - src/gallium/winsys/sw/fbdev/Makefile.am | 33 ---- src/gallium/winsys/sw/fbdev/Makefile.sources | 3 - src/gallium/winsys/sw/fbdev/SConscript | 20 --- src/gallium/winsys/sw/fbdev/fbdev_sw_winsys.c | 239 ------------------------- src/gallium/winsys/sw/fbdev/fbdev_sw_winsys.h | 44 ----- 7 files changed, 344 deletions(-) diff --git a/configure.ac b/configure.ac index e0aec6d..b40ea7f 100644 --- a/configure.ac +++ b/configure.ac @@ -2418,7 +2418,6 @@ AC_CONFIG_FILES([Makefile src/gallium/winsys/radeon/drm/Makefile src/gallium/winsys/svga/drm/Makefile src/gallium/winsys/sw/dri/Makefile - src/gallium/winsys/sw/fbdev/Makefile src/gallium/winsys/sw/kms-dri/Makefile src/gallium/winsys/sw/null/Makefile src/gallium/winsys/sw/wrapper/Makefile diff --git a/src/gallium/Makefile.am b/src/gallium/Makefile.am index 47579ed..9285037 100644 --- a/src/gallium/Makefile.am +++ b/src/gallium/Makefile.am @@ -96,10 +96,6 @@ if HAVE_DRI2 SUBDIRS += winsys/sw/kms-dri endif -if HAVE_EGL_PLATFORM_FBDEV -SUBDIRS += winsys/sw/fbdev -endif - SUBDIRS += winsys/sw/wrapper ## diff --git a/src/gallium/winsys/sw/fbdev/Makefile.am b/src/gallium/winsys/sw/fbdev/Makefile.am deleted file mode 100644 index 93c8f88..0000000 --- a/src/gallium/winsys/sw/fbdev/Makefile.am +++ /dev/null @@ -1,33 +0,0 @@ -# Copyright ? 2012 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 Makefile.sources -include $(top_srcdir)/src/gallium/Automake.inc - -AM_CFLAGS = \ - $(GALLIUM_WINSYS_CFLAGS) - -noinst_LTLIBRARIES = libfbdev.la - -libfbdev_la_SOURCES = $(C_SOURCES) - -EXTRA_DIST = SConscript diff --git a/src/gallium/winsys/sw/fbdev/Makefile.sources b/src/gallium/winsys/sw/fbdev/Makefile.sources deleted file mode 100644 index dd48051..0000000 --- a/src/gallium/winsys/sw/fbdev/Makefile.sources +++ /dev/null @@ -1,3 +0,0 @@ -C_SOURCES := \ - fbdev_sw_winsys.c \ - fbdev_sw_winsys.h diff --git a/src/gallium/winsys/sw/fbdev/SConscript b/src/gallium/winsys/sw/fbdev/SConscript deleted file mode 100644 index bf504ad..0000000 --- a/src/gallium/winsys/sw/fbdev/SConscript +++ /dev/null @@ -1,20 +0,0 @@ -####################################################################### -# SConscript for fbdev winsys - - -Import('*') - -if env['platform'] == 'linux': - - env = env.Clone() - - env.Append(CPPPATH = [ - '#/src/gallium/include', - '#/src/gallium/auxiliary', - ]) - - ws_fbdev = env.ConvenienceLibrary( - target = 'ws_fbdev', - source = env.ParseSourceList('Makefile.sources', 'C_SOURCES'), - ) - Export('ws_fbdev') diff --git a/src/gallium/winsys/sw/fbdev/fbdev_sw_winsys.c b/src/gallium/winsys/sw/fbdev/fbdev_sw_winsys.c deleted file mode 100644 index cc3ce1a..0000000 --- a/src/gallium/winsys/sw/fbdev/fbdev_sw_winsys.c +++ /dev/null @@ -1,239 +0,0 @@ -/* - * Mesa 3-D graphics library - * - * Copyright (C) 2010 LunarG Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice 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. - * - * Authors: - * Chia-I Wu - */ - -#include -#include -#include - -#include "pipe/p_compiler.h" -#include "util/u_format.h" -#include "util/u_math.h" -#include "util/u_memory.h" -#include "state_tracker/sw_winsys.h" - -#include "fbdev_sw_winsys.h" - -struct fbdev_sw_displaytarget -{ - enum pipe_format format; - unsigned width; - unsigned height; - unsigned stride; - - void *data; - void *mapped; -}; - -struct fbdev_sw_winsys -{ - struct sw_winsys base; - - int fd; - - struct fb_fix_screeninfo finfo; - unsigned rows; - unsigned stride; -}; - -static INLINE struct fbdev_sw_displaytarget * -fbdev_sw_displaytarget(struct sw_displaytarget *dt) -{ - return (struct fbdev_sw_displaytarget *) dt; -} - -static INLINE struct fbdev_sw_winsys * -fbdev_sw_winsys(struct sw_winsys *ws) -{ - return (struct fbdev_sw_winsys *) ws; -} - -static void -fbdev_displaytarget_display(struct sw_winsys *ws, - struct sw_displaytarget *dt, - void *winsys_private, - struct pipe_box *box) -{ - struct fbdev_sw_winsys *fbdev = fbdev_sw_winsys(ws); - struct fbdev_sw_displaytarget *src = fbdev_sw_displaytarget(dt); - const struct fbdev_sw_drawable *dst = - (const struct fbdev_sw_drawable *) winsys_private; - unsigned height, row_offset, row_len, i; - void *fbmem; - - /* FIXME format conversion */ - if (dst->format != src->format) { - assert(0); - return; - } - - height = dst->height; - if (dst->y + dst->height > fbdev->rows) { - /* nothing to copy */ - if (dst->y >= fbdev->rows) - return; - - height = fbdev->rows - dst->y; - } - - row_offset = util_format_get_stride(dst->format, dst->x); - row_len = util_format_get_stride(dst->format, dst->width); - if (row_offset + row_len > fbdev->stride) { - /* nothing to copy */ - if (row_offset >= fbdev->stride) - return; - - row_len = fbdev->stride - row_offset; - } - - fbmem = mmap(0, fbdev->finfo.smem_len, - PROT_WRITE, MAP_SHARED, fbdev->fd, 0); - if (fbmem == MAP_FAILED) - return; - - for (i = 0; i < height; i++) { - char *from = (char *) src->data + src->stride * i; - char *to = (char *) fbmem + fbdev->stride * (dst->y + i) + row_offset; - - memcpy(to, from, row_len); - } - - munmap(fbmem, fbdev->finfo.smem_len); -} - -static void -fbdev_displaytarget_unmap(struct sw_winsys *ws, - struct sw_displaytarget *dt) -{ - struct fbdev_sw_displaytarget *fbdt = fbdev_sw_displaytarget(dt); - fbdt->mapped = NULL; -} - -static void * -fbdev_displaytarget_map(struct sw_winsys *ws, - struct sw_displaytarget *dt, - unsigned flags) -{ - struct fbdev_sw_displaytarget *fbdt = fbdev_sw_displaytarget(dt); - fbdt->mapped = fbdt->data; - return fbdt->mapped; -} - -static void -fbdev_displaytarget_destroy(struct sw_winsys *ws, - struct sw_displaytarget *dt) -{ - struct fbdev_sw_displaytarget *fbdt = fbdev_sw_displaytarget(dt); - - if (fbdt->data) - align_free(fbdt->data); - - FREE(fbdt); -} - -static struct sw_displaytarget * -fbdev_displaytarget_create(struct sw_winsys *ws, - unsigned tex_usage, - enum pipe_format format, - unsigned width, unsigned height, - unsigned alignment, - unsigned *stride) -{ - struct fbdev_sw_displaytarget *fbdt; - unsigned nblocksy, size, format_stride; - - fbdt = CALLOC_STRUCT(fbdev_sw_displaytarget); - if (!fbdt) - return NULL; - - fbdt->format = format; - fbdt->width = width; - fbdt->height = height; - - format_stride = util_format_get_stride(format, width); - fbdt->stride = align(format_stride, alignment); - - nblocksy = util_format_get_nblocksy(format, height); - size = fbdt->stride * nblocksy; - - fbdt->data = align_malloc(size, alignment); - if (!fbdt->data) { - FREE(fbdt); - return NULL; - } - - *stride = fbdt->stride; - - return (struct sw_displaytarget *) fbdt; -} - -static boolean -fbdev_is_displaytarget_format_supported(struct sw_winsys *ws, - unsigned tex_usage, - enum pipe_format format) -{ - return TRUE; -} - -static void -fbdev_destroy(struct sw_winsys *ws) -{ - struct fbdev_sw_winsys *fbdev = fbdev_sw_winsys(ws); - - FREE(fbdev); -} - -struct sw_winsys * -fbdev_create_sw_winsys(int fd) -{ - struct fbdev_sw_winsys *fbdev; - - fbdev = CALLOC_STRUCT(fbdev_sw_winsys); - if (!fbdev) - return NULL; - - fbdev->fd = fd; - if (ioctl(fbdev->fd, FBIOGET_FSCREENINFO, &fbdev->finfo)) { - FREE(fbdev); - return NULL; - } - - fbdev->rows = fbdev->finfo.smem_len / fbdev->finfo.line_length; - fbdev->stride = fbdev->finfo.line_length; - - fbdev->base.destroy = fbdev_destroy; - fbdev->base.is_displaytarget_format_supported = - fbdev_is_displaytarget_format_supported; - - fbdev->base.displaytarget_create = fbdev_displaytarget_create; - fbdev->base.displaytarget_destroy = fbdev_displaytarget_destroy; - fbdev->base.displaytarget_map = fbdev_displaytarget_map; - fbdev->base.displaytarget_unmap = fbdev_displaytarget_unmap; - - fbdev->base.displaytarget_display = fbdev_displaytarget_display; - - return &fbdev->base; -} diff --git a/src/gallium/winsys/sw/fbdev/fbdev_sw_winsys.h b/src/gallium/winsys/sw/fbdev/fbdev_sw_winsys.h deleted file mode 100644 index 23c723a..0000000 --- a/src/gallium/winsys/sw/fbdev/fbdev_sw_winsys.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Mesa 3-D graphics library - * - * Copyright (C) 2010 LunarG Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice 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. - * - * Authors: - * Chia-I Wu - */ - -#ifndef FBDEV_SW_WINSYS -#define FBDEV_SW_WINSYS - -struct sw_winsys; -enum pipe_format; - -/* for pipe_screen::flush_frontbuffer */ -struct fbdev_sw_drawable { - enum pipe_format format; - unsigned x, y; - unsigned width, height; -}; - -struct sw_winsys * -fbdev_create_sw_winsys(int fd); - -#endif /* FBDEV_SW_WINSYS */ From evelikov at kemper.freedesktop.org Sat Mar 21 17:29:30 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Sat, 21 Mar 2015 10:29:30 -0700 (PDT) Subject: Mesa (master): winsys/sw/wayland: remove unused winsys Message-ID: <20150321172930.39E6D7635A@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 1081ed9dc38e7f84b3a7a6e4461a188ae30bd9a2 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=1081ed9dc38e7f84b3a7a6e4461a188ae30bd9a2 Author: Emil Velikov Date: Sat Mar 14 22:36:26 2015 +0000 winsys/sw/wayland: remove unused winsys st/egl was its only user. Signed-off-by: Emil Velikov Acked-by: Matt Turner --- configure.ac | 1 - src/gallium/Makefile.am | 4 - src/gallium/winsys/sw/wayland/Makefile.am | 32 --- src/gallium/winsys/sw/wayland/Makefile.sources | 3 - src/gallium/winsys/sw/wayland/wayland_sw_winsys.c | 286 --------------------- src/gallium/winsys/sw/wayland/wayland_sw_winsys.h | 42 --- 6 files changed, 368 deletions(-) diff --git a/configure.ac b/configure.ac index d864350..e0aec6d 100644 --- a/configure.ac +++ b/configure.ac @@ -2421,7 +2421,6 @@ AC_CONFIG_FILES([Makefile src/gallium/winsys/sw/fbdev/Makefile src/gallium/winsys/sw/kms-dri/Makefile src/gallium/winsys/sw/null/Makefile - src/gallium/winsys/sw/wayland/Makefile src/gallium/winsys/sw/wrapper/Makefile src/gallium/winsys/sw/xlib/Makefile src/gallium/winsys/vc4/drm/Makefile diff --git a/src/gallium/Makefile.am b/src/gallium/Makefile.am index 69e2e1e..47579ed 100644 --- a/src/gallium/Makefile.am +++ b/src/gallium/Makefile.am @@ -100,10 +100,6 @@ if HAVE_EGL_PLATFORM_FBDEV SUBDIRS += winsys/sw/fbdev endif -if HAVE_EGL_PLATFORM_WAYLAND -SUBDIRS += winsys/sw/wayland -endif - SUBDIRS += winsys/sw/wrapper ## diff --git a/src/gallium/winsys/sw/wayland/Makefile.am b/src/gallium/winsys/sw/wayland/Makefile.am deleted file mode 100644 index 443ff19..0000000 --- a/src/gallium/winsys/sw/wayland/Makefile.am +++ /dev/null @@ -1,32 +0,0 @@ -# Copyright ? 2012 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 Makefile.sources -include $(top_srcdir)/src/gallium/Automake.inc - -AM_CFLAGS = \ - $(GALLIUM_WINSYS_CFLAGS) \ - $(WAYLAND_CFLAGS) - -noinst_LTLIBRARIES = libws_wayland.la - -libws_wayland_la_SOURCES = $(C_SOURCES) diff --git a/src/gallium/winsys/sw/wayland/Makefile.sources b/src/gallium/winsys/sw/wayland/Makefile.sources deleted file mode 100644 index 570ccc6..0000000 --- a/src/gallium/winsys/sw/wayland/Makefile.sources +++ /dev/null @@ -1,3 +0,0 @@ -C_SOURCES := \ - wayland_sw_winsys.c \ - wayland_sw_winsys.h diff --git a/src/gallium/winsys/sw/wayland/wayland_sw_winsys.c b/src/gallium/winsys/sw/wayland/wayland_sw_winsys.c deleted file mode 100644 index e428613..0000000 --- a/src/gallium/winsys/sw/wayland/wayland_sw_winsys.c +++ /dev/null @@ -1,286 +0,0 @@ -/* - * Mesa 3-D graphics library - * - * Copyright (C) 2011 Benjamin Franzke - * - * 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 -#include -#include -#include - -#include "pipe/p_compiler.h" -#include "pipe/p_defines.h" -#include "pipe/p_state.h" -#include "util/u_format.h" -#include "util/u_math.h" -#include "util/u_memory.h" -#include "state_tracker/sw_winsys.h" - -#include -#include "wayland_sw_winsys.h" - -struct wayland_sw_displaytarget -{ - int fd; - unsigned size; - - unsigned width; - unsigned height; - unsigned stride; - - enum pipe_format format; - - void *map; - unsigned map_count; -}; - -struct wayland_sw_winsys -{ - struct sw_winsys base; - - struct wl_display *display; -}; - -static INLINE struct wayland_sw_displaytarget * -wayland_sw_displaytarget(struct sw_displaytarget *dt) -{ - return (struct wayland_sw_displaytarget *) dt; -} - -static INLINE struct wayland_sw_winsys * -wayland_sw_winsys(struct sw_winsys *ws) -{ - return (struct wayland_sw_winsys *) ws; -} - -static void -wayland_displaytarget_display(struct sw_winsys *ws, - struct sw_displaytarget *dt, - void *context_private, - struct pipe_box *box) -{ -} - -static void -wayland_displaytarget_unmap(struct sw_winsys *ws, - struct sw_displaytarget *dt) -{ - struct wayland_sw_displaytarget *wldt = wayland_sw_displaytarget(dt); - - wldt->map_count--; - if (wldt->map_count > 0) - return; - - munmap(wldt->map, wldt->size); - wldt->map = NULL; -} - -static void * -wayland_displaytarget_map(struct sw_winsys *ws, - struct sw_displaytarget *dt, - unsigned flags) -{ - struct wayland_sw_displaytarget *wldt = wayland_sw_displaytarget(dt); - uint mmap_flags = 0; - - if (wldt->map) { - wldt->map_count++; - return wldt->map; - } - - if (flags & PIPE_TRANSFER_READ) - mmap_flags |= PROT_READ; - if (flags & PIPE_TRANSFER_WRITE) - mmap_flags |= PROT_WRITE; - - wldt->map = mmap(NULL, wldt->size, mmap_flags, - MAP_SHARED, wldt->fd, 0); - - if (wldt->map == MAP_FAILED) - return NULL; - - wldt->map_count = 1; - - return wldt->map; -} - -static void -wayland_displaytarget_destroy(struct sw_winsys *ws, - struct sw_displaytarget *dt) -{ - struct wayland_sw_displaytarget *wldt = wayland_sw_displaytarget(dt); - - if (wldt->map) - wayland_displaytarget_unmap(ws, dt); - - FREE(wldt); -} - -static boolean -wayland_is_displaytarget_format_supported(struct sw_winsys *ws, - unsigned tex_usage, - enum pipe_format format) -{ - switch (format) { - case PIPE_FORMAT_B8G8R8X8_UNORM: - case PIPE_FORMAT_B8G8R8A8_UNORM: - return TRUE; - default: - return FALSE; - } -} - -static struct sw_displaytarget * -wayland_displaytarget_create(struct sw_winsys *ws, - unsigned tex_usage, - enum pipe_format format, - unsigned width, unsigned height, - unsigned alignment, - unsigned *stride) -{ - struct wayland_sw_displaytarget *wldt; - unsigned nblocksy, format_stride; - char filename[] = "/tmp/wayland-shm-XXXXXX"; - - if (!wayland_is_displaytarget_format_supported(ws, tex_usage, format)) - return NULL; - - wldt = CALLOC_STRUCT(wayland_sw_displaytarget); - if (!wldt) - return NULL; - - wldt->map = NULL; - - wldt->format = format; - wldt->width = width; - wldt->height = height; - - format_stride = util_format_get_stride(format, width); - wldt->stride = align(format_stride, alignment); - - nblocksy = util_format_get_nblocksy(format, height); - wldt->size = wldt->stride * nblocksy; - - wldt->fd = mkstemp(filename); - if (wldt->fd < 0) { - FREE(wldt); - return NULL; - } - - if (ftruncate(wldt->fd, wldt->size) < 0) { - unlink(filename); - close(wldt->fd); - FREE(wldt); - return NULL; - } - - unlink(filename); - - *stride = wldt->stride; - - return (struct sw_displaytarget *) wldt; -} - -static struct sw_displaytarget * -wayland_displaytarget_from_handle(struct sw_winsys *ws, - const struct pipe_resource *templet, - struct winsys_handle *whandle, - unsigned *stride) -{ - struct wayland_sw_displaytarget *wldt; - unsigned nblocksy; - - if (!wayland_is_displaytarget_format_supported(ws, 0, templet->format)) - return NULL; - - wldt = CALLOC_STRUCT(wayland_sw_displaytarget); - if (!wldt) - return NULL; - - wldt->fd = whandle->fd; - wldt->stride = whandle->stride; - wldt->width = templet->width0; - wldt->height = templet->height0; - wldt->format = templet->format; - - nblocksy = util_format_get_nblocksy(wldt->format, wldt->height); - - wldt->size = wldt->stride * nblocksy; - - wldt->map = NULL; - - *stride = wldt->stride; - - return (struct sw_displaytarget *) wldt; -} - - -static boolean -wayland_displaytarget_get_handle(struct sw_winsys *ws, - struct sw_displaytarget *dt, - struct winsys_handle *whandle) -{ - struct wayland_sw_displaytarget *wldt = wayland_sw_displaytarget(dt); - - whandle->fd = wldt->fd; - whandle->stride = wldt->stride; - whandle->size = wldt->size; - - return TRUE; -} - -static void -wayland_destroy(struct sw_winsys *ws) -{ - struct wayland_sw_winsys *wayland = wayland_sw_winsys(ws); - - FREE(wayland); -} - -struct sw_winsys * -wayland_create_sw_winsys(struct wl_display *display) -{ - struct wayland_sw_winsys *wlws; - - wlws = CALLOC_STRUCT(wayland_sw_winsys); - if (!wlws) - return NULL; - - wlws->display = display; - - wlws->base.destroy = wayland_destroy; - wlws->base.is_displaytarget_format_supported = - wayland_is_displaytarget_format_supported; - - wlws->base.displaytarget_create = wayland_displaytarget_create; - wlws->base.displaytarget_from_handle = wayland_displaytarget_from_handle; - wlws->base.displaytarget_get_handle = wayland_displaytarget_get_handle; - wlws->base.displaytarget_destroy = wayland_displaytarget_destroy; - wlws->base.displaytarget_map = wayland_displaytarget_map; - wlws->base.displaytarget_unmap = wayland_displaytarget_unmap; - - wlws->base.displaytarget_display = wayland_displaytarget_display; - - return &wlws->base; -} - -/* vim: set sw=3 ts=8 sts=3 expandtab: */ diff --git a/src/gallium/winsys/sw/wayland/wayland_sw_winsys.h b/src/gallium/winsys/sw/wayland/wayland_sw_winsys.h deleted file mode 100644 index f8c36d0..0000000 --- a/src/gallium/winsys/sw/wayland/wayland_sw_winsys.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Mesa 3-D graphics library - * - * Copyright (C) 2011 Benjamin Franzke - * - * 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. - */ - -#ifndef WAYLAND_SW_WINSYS -#define WAYLAND_SW_WINSYS - -struct sw_winsys; -struct wl_display; - -struct winsys_handle { - int fd; - unsigned stride; - unsigned size; -}; - -struct sw_winsys * -wayland_create_sw_winsys(struct wl_display *display); - -#endif /* WAYLAND_SW_WINSYS */ - -/* vim: set sw=3 ts=8 sts=3 expandtab: */ From evelikov at kemper.freedesktop.org Sat Mar 21 17:29:30 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Sat, 21 Mar 2015 10:29:30 -0700 (PDT) Subject: Mesa (master): gallium/docs: remove information about identity driver Message-ID: <20150321172930.5CB2D7639A@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 84041bab3f3673c92861d31321a25158831a74fa URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=84041bab3f3673c92861d31321a25158831a74fa Author: Emil Velikov Date: Sat Mar 14 22:36:30 2015 +0000 gallium/docs: remove information about identity driver Removed from tree. Signed-off-by: Emil Velikov Acked-by: Matt Turner --- src/gallium/docs/source/distro.rst | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/gallium/docs/source/distro.rst b/src/gallium/docs/source/distro.rst index 000b031..0785c0c 100644 --- a/src/gallium/docs/source/distro.rst +++ b/src/gallium/docs/source/distro.rst @@ -12,13 +12,6 @@ Intel i915 Driver for Intel i915 and i945 chipsets. -Identity -^^^^^^^^ - -Wrapper driver. The identity driver is a simple skeleton that passes through -all of its :ref:`Context` and :ref:`Screen` methods to an underlying Context -and Screen, and as such, it is an excellent starting point for new drivers. - LLVM Softpipe ^^^^^^^^^^^^^ From evelikov at kemper.freedesktop.org Sat Mar 21 17:29:30 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Sat, 21 Mar 2015 10:29:30 -0700 (PDT) Subject: Mesa (master): docs: update the egl_platforms list Message-ID: <20150321172930.5540476397@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 55029b2bab707616eb8a296e1d67cbedde0985b3 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=55029b2bab707616eb8a296e1d67cbedde0985b3 Author: Emil Velikov Date: Sat Mar 14 22:36:29 2015 +0000 docs: update the egl_platforms list Add the missing wayland, null, android and haiku platforms. Signed-off-by: Emil Velikov Acked-by: Matt Turner --- docs/egl.html | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/docs/egl.html b/docs/egl.html index d46181e..d946bb0 100644 --- a/docs/egl.html +++ b/docs/egl.html @@ -88,8 +88,11 @@ types such as EGLNativeDisplayType or EGLNativeWindowType defined for.

            The available platforms are x11, drm, -and gdi. The gdi platform can -only be built with SCons. Unless for special needs, the build system should +wayland, null, android, +haiku, and gdi. The android platform +can only be built as a system component, part of AOSP, while the +haiku and gdi platforms can only be built with SCons. +Unless for special needs, the build system should select the right platforms automatically.

            From evelikov at kemper.freedesktop.org Sat Mar 21 17:29:30 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Sat, 21 Mar 2015 10:29:30 -0700 (PDT) Subject: Mesa (master): egl/main: drop platform fbdev specific code Message-ID: <20150321172930.4C3397635C@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 0d6e7620f35331be301ec3177c0d9236838a845b URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=0d6e7620f35331be301ec3177c0d9236838a845b Author: Emil Velikov Date: Sat Mar 14 22:36:28 2015 +0000 egl/main: drop platform fbdev specific code st/egl was the only one which had support for this platform. Signed-off-by: Emil Velikov Acked-by: Matt Turner --- configure.ac | 3 +-- docs/egl.html | 2 +- src/egl/main/Makefile.am | 4 ---- src/egl/main/egldisplay.c | 16 ---------------- src/egl/main/egldisplay.h | 1 - 5 files changed, 2 insertions(+), 24 deletions(-) diff --git a/configure.ac b/configure.ac index b40ea7f..94e0d87 100644 --- a/configure.ac +++ b/configure.ac @@ -1781,7 +1781,7 @@ for plat in $egl_platforms; do AC_MSG_ERROR([EGL platform drm requires libdrm >= $LIBDRM_REQUIRED]) ;; - android|fbdev|gdi|null) + android|gdi|null) ;; *) @@ -1810,7 +1810,6 @@ fi AM_CONDITIONAL(HAVE_EGL_PLATFORM_X11, echo "$egl_platforms" | grep -q 'x11') AM_CONDITIONAL(HAVE_EGL_PLATFORM_WAYLAND, echo "$egl_platforms" | grep -q 'wayland') AM_CONDITIONAL(HAVE_EGL_PLATFORM_DRM, echo "$egl_platforms" | grep -q 'drm') -AM_CONDITIONAL(HAVE_EGL_PLATFORM_FBDEV, echo "$egl_platforms" | grep -q 'fbdev') AM_CONDITIONAL(HAVE_EGL_PLATFORM_NULL, echo "$egl_platforms" | grep -q 'null') AM_CONDITIONAL(HAVE_EGL_DRIVER_DRI2, test "x$HAVE_EGL_DRIVER_DRI2" != "x") diff --git a/docs/egl.html b/docs/egl.html index a715a3a..d46181e 100644 --- a/docs/egl.html +++ b/docs/egl.html @@ -88,7 +88,7 @@ types such as EGLNativeDisplayType or EGLNativeWindowType defined for.

            The available platforms are x11, drm, -fbdev, and gdi. The gdi platform can +and gdi. The gdi platform can only be built with SCons. Unless for special needs, the build system should select the right platforms automatically.

            diff --git a/src/egl/main/Makefile.am b/src/egl/main/Makefile.am index a4db210..893ad26 100644 --- a/src/egl/main/Makefile.am +++ b/src/egl/main/Makefile.am @@ -65,10 +65,6 @@ AM_CFLAGS += -DHAVE_DRM_PLATFORM libEGL_la_LIBADD += ../../gbm/libgbm.la endif -if HAVE_EGL_PLATFORM_FBDEV -AM_CFLAGS += -DHAVE_FBDEV_PLATFORM -endif - if HAVE_EGL_PLATFORM_NULL AM_CFLAGS += -DHAVE_NULL_PLATFORM endif diff --git a/src/egl/main/egldisplay.c b/src/egl/main/egldisplay.c index b7a5b8f..a3ecba8 100644 --- a/src/egl/main/egldisplay.c +++ b/src/egl/main/egldisplay.c @@ -56,11 +56,6 @@ #ifdef HAVE_DRM_PLATFORM #include #endif -#ifdef HAVE_FBDEV_PLATFORM -#include -#include -#include -#endif /** @@ -74,7 +69,6 @@ static const struct { { _EGL_PLATFORM_X11, "x11" }, { _EGL_PLATFORM_WAYLAND, "wayland" }, { _EGL_PLATFORM_DRM, "drm" }, - { _EGL_PLATFORM_FBDEV, "fbdev" }, { _EGL_PLATFORM_NULL, "null" }, { _EGL_PLATFORM_ANDROID, "android" }, { _EGL_PLATFORM_HAIKU, "haiku" } @@ -144,19 +138,9 @@ _eglPointerIsDereferencable(void *p) static _EGLPlatformType _eglNativePlatformDetectNativeDisplay(void *nativeDisplay) { -#ifdef HAVE_FBDEV_PLATFORM - struct stat buf; -#endif - if (nativeDisplay == EGL_DEFAULT_DISPLAY) return _EGL_INVALID_PLATFORM; -#ifdef HAVE_FBDEV_PLATFORM - /* fbdev is the only platform that can be a file descriptor. */ - if (fstat((intptr_t) nativeDisplay, &buf) == 0 && S_ISCHR(buf.st_mode)) - return _EGL_PLATFORM_FBDEV; -#endif - if (_eglPointerIsDereferencable(nativeDisplay)) { void *first_pointer = *(void **) nativeDisplay; diff --git a/src/egl/main/egldisplay.h b/src/egl/main/egldisplay.h index 5a845d8..f8782f9 100644 --- a/src/egl/main/egldisplay.h +++ b/src/egl/main/egldisplay.h @@ -44,7 +44,6 @@ enum _egl_platform_type { _EGL_PLATFORM_X11, _EGL_PLATFORM_WAYLAND, _EGL_PLATFORM_DRM, - _EGL_PLATFORM_FBDEV, _EGL_PLATFORM_NULL, _EGL_PLATFORM_ANDROID, _EGL_PLATFORM_HAIKU, From evelikov at kemper.freedesktop.org Sat Mar 21 17:29:30 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Sat, 21 Mar 2015 10:29:30 -0700 (PDT) Subject: Mesa (master): galahad: remove driver Message-ID: <20150321172930.66CA9763CF@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 429a4355259b3c4fe80838b499a8d8afa41f290a URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=429a4355259b3c4fe80838b499a8d8afa41f290a Author: Emil Velikov Date: Sat Mar 14 22:36:31 2015 +0000 galahad: remove driver Signed-off-by: Emil Velikov Acked-by: Matt Turner --- configure.ac | 1 - src/gallium/Makefile.am | 1 - src/gallium/SConscript | 1 - src/gallium/auxiliary/target-helpers/inline_debug_helper.h | 8 -------- src/gallium/docs/source/debugging.rst | 4 ---- src/gallium/docs/source/distro.rst | 9 --------- src/gallium/targets/dri/Makefile.am | 2 -- src/gallium/targets/dri/SConscript | 4 ++-- src/gallium/targets/graw-gdi/SConscript | 4 ++-- src/gallium/targets/graw-xlib/SConscript | 6 +++--- src/gallium/targets/libgl-xlib/Makefile.am | 5 ++--- src/gallium/targets/libgl-xlib/SConscript | 4 ++-- src/gallium/targets/pipe-loader/Makefile.am | 4 +--- 13 files changed, 12 insertions(+), 41 deletions(-) diff --git a/configure.ac b/configure.ac index 94e0d87..a8eb0c9 100644 --- a/configure.ac +++ b/configure.ac @@ -2368,7 +2368,6 @@ AC_CONFIG_FILES([Makefile src/gallium/auxiliary/Makefile src/gallium/auxiliary/pipe-loader/Makefile src/gallium/drivers/freedreno/Makefile - src/gallium/drivers/galahad/Makefile src/gallium/drivers/i915/Makefile src/gallium/drivers/ilo/Makefile src/gallium/drivers/llvmpipe/Makefile diff --git a/src/gallium/Makefile.am b/src/gallium/Makefile.am index 9285037..ede6e21 100644 --- a/src/gallium/Makefile.am +++ b/src/gallium/Makefile.am @@ -11,7 +11,6 @@ SUBDIRS += auxiliary ## SUBDIRS += \ - drivers/galahad \ drivers/noop \ drivers/trace \ drivers/rbug diff --git a/src/gallium/SConscript b/src/gallium/SConscript index 9b9011f..680ad92 100644 --- a/src/gallium/SConscript +++ b/src/gallium/SConscript @@ -12,7 +12,6 @@ SConscript('auxiliary/SConscript') # These are common and work across all platforms SConscript([ - 'drivers/galahad/SConscript', 'drivers/llvmpipe/SConscript', 'drivers/rbug/SConscript', 'drivers/softpipe/SConscript', diff --git a/src/gallium/auxiliary/target-helpers/inline_debug_helper.h b/src/gallium/auxiliary/target-helpers/inline_debug_helper.h index faae180..0648e59 100644 --- a/src/gallium/auxiliary/target-helpers/inline_debug_helper.h +++ b/src/gallium/auxiliary/target-helpers/inline_debug_helper.h @@ -19,10 +19,6 @@ #include "rbug/rbug_public.h" #endif -#ifdef GALLIUM_GALAHAD -#include "galahad/glhd_public.h" -#endif - #ifdef GALLIUM_NOOP #include "noop/noop_public.h" #endif @@ -42,10 +38,6 @@ debug_screen_wrap(struct pipe_screen *screen) screen = trace_screen_create(screen); #endif -#if defined(GALLIUM_GALAHAD) - screen = galahad_screen_create(screen); -#endif - #if defined(GALLIUM_NOOP) screen = noop_screen_create(screen); #endif diff --git a/src/gallium/docs/source/debugging.rst b/src/gallium/docs/source/debugging.rst index 8566dbd..8e96a6e 100644 --- a/src/gallium/docs/source/debugging.rst +++ b/src/gallium/docs/source/debugging.rst @@ -21,10 +21,6 @@ This option controls if the debug variables should be printed to stderr. This is probably the most useful variable, since it allows you to find which variables a driver uses. -.. envvar:: GALLIUM_GALAHAD (false) - -Controls if the :ref:`galahad` sanity checker module should be used. - .. envvar:: GALLIUM_RBUG (false) Controls if the :ref:`rbug` should be used. diff --git a/src/gallium/docs/source/distro.rst b/src/gallium/docs/source/distro.rst index 0785c0c..15468b6 100644 --- a/src/gallium/docs/source/distro.rst +++ b/src/gallium/docs/source/distro.rst @@ -78,15 +78,6 @@ Rbug Wrapper driver. :ref:`rbug` driver used with stand alone rbug-gui. -.. _galahad: - -Galahad -^^^^^^^ - -Wrapper driver. Sanity checker for the internal gallium state. Normally -a driver should n't have to sanity check the input it gets from a state -tracker. Any wrong state received should be perceived as a state tracker bug. - State Trackers -------------- diff --git a/src/gallium/targets/dri/Makefile.am b/src/gallium/targets/dri/Makefile.am index aaeb950..f9e4ada 100644 --- a/src/gallium/targets/dri/Makefile.am +++ b/src/gallium/targets/dri/Makefile.am @@ -11,7 +11,6 @@ AM_CFLAGS = \ AM_CPPFLAGS = \ $(DEFINES) \ -DDRI_TARGET \ - -DGALLIUM_GALAHAD \ -DGALLIUM_NOOP \ -DGALLIUM_RBUG \ -DGALLIUM_TRACE @@ -46,7 +45,6 @@ gallium_dri_la_LIBADD = \ $(top_builddir)/src/gallium/state_trackers/dri/libdri.la \ $(top_builddir)/src/gallium/auxiliary/libgalliumvl.la \ $(top_builddir)/src/gallium/auxiliary/libgallium.la \ - $(top_builddir)/src/gallium/drivers/galahad/libgalahad.la \ $(top_builddir)/src/gallium/drivers/noop/libnoop.la \ $(top_builddir)/src/gallium/drivers/rbug/librbug.la \ $(top_builddir)/src/gallium/drivers/trace/libtrace.la \ diff --git a/src/gallium/targets/dri/SConscript b/src/gallium/targets/dri/SConscript index a732247..a51ed56 100644 --- a/src/gallium/targets/dri/SConscript +++ b/src/gallium/targets/dri/SConscript @@ -18,8 +18,8 @@ if env['build'] == 'release': env.Append(CPPDEFINES = ['GALLIUM_RBUG']) env.Prepend(LIBS = [rbug]) else: - env.Append(CPPDEFINES = ['GALLIUM_TRACE', 'GALLIUM_RBUG', 'GALLIUM_GALAHAD']) - env.Prepend(LIBS = [trace, rbug, galahad]) + env.Append(CPPDEFINES = ['GALLIUM_TRACE', 'GALLIUM_RBUG']) + env.Prepend(LIBS = [trace, rbug]) if env['llvm']: env.Append(CPPDEFINES = 'GALLIUM_LLVMPIPE') diff --git a/src/gallium/targets/graw-gdi/SConscript b/src/gallium/targets/graw-gdi/SConscript index f8db6e6..67d4373 100644 --- a/src/gallium/targets/graw-gdi/SConscript +++ b/src/gallium/targets/graw-gdi/SConscript @@ -23,8 +23,8 @@ sources = [ ] if True: - env.Append(CPPDEFINES = ['GALLIUM_TRACE', 'GALLIUM_RBUG', 'GALLIUM_GALAHAD', 'GALLIUM_SOFTPIPE']) - env.Prepend(LIBS = [trace, rbug, galahad, softpipe]) + env.Append(CPPDEFINES = ['GALLIUM_TRACE', 'GALLIUM_RBUG', 'GALLIUM_SOFTPIPE']) + env.Prepend(LIBS = [trace, rbug, softpipe]) if env['llvm']: env.Append(CPPDEFINES = 'GALLIUM_LLVMPIPE') diff --git a/src/gallium/targets/graw-xlib/SConscript b/src/gallium/targets/graw-xlib/SConscript index 886811b..bf9cf72 100644 --- a/src/gallium/targets/graw-xlib/SConscript +++ b/src/gallium/targets/graw-xlib/SConscript @@ -20,7 +20,7 @@ env.Append(CPPPATH = [ '#src/gallium/winsys', ]) -env.Append(CPPDEFINES = ['GALLIUM_RBUG', 'GALLIUM_TRACE', 'GALLIUM_GALAHAD']) +env.Append(CPPDEFINES = ['GALLIUM_RBUG', 'GALLIUM_TRACE']) sources = [ 'graw_xlib.c', @@ -28,8 +28,8 @@ sources = [ ] if True: - env.Append(CPPDEFINES = ['GALLIUM_TRACE', 'GALLIUM_RBUG', 'GALLIUM_GALAHAD', 'GALLIUM_SOFTPIPE']) - env.Prepend(LIBS = [trace, rbug, galahad, softpipe]) + env.Append(CPPDEFINES = ['GALLIUM_TRACE', 'GALLIUM_RBUG', 'GALLIUM_SOFTPIPE']) + env.Prepend(LIBS = [trace, rbug, softpipe]) if env['llvm']: env.Append(CPPDEFINES = 'GALLIUM_LLVMPIPE') diff --git a/src/gallium/targets/libgl-xlib/Makefile.am b/src/gallium/targets/libgl-xlib/Makefile.am index de56e28..33b0d13 100644 --- a/src/gallium/targets/libgl-xlib/Makefile.am +++ b/src/gallium/targets/libgl-xlib/Makefile.am @@ -37,8 +37,8 @@ AM_CPPFLAGS = \ -I$(top_srcdir)/src/gallium/winsys \ -DGALLIUM_SOFTPIPE \ -DGALLIUM_RBUG \ - -DGALLIUM_TRACE \ - -DGALLIUM_GALAHAD + -DGALLIUM_TRACE + AM_CFLAGS = $(X11_INCLUDES) lib_LTLIBRARIES = lib at GL_LIB@.la @@ -62,7 +62,6 @@ lib at GL_LIB@_la_LIBADD = \ $(top_builddir)/src/gallium/drivers/softpipe/libsoftpipe.la \ $(top_builddir)/src/gallium/drivers/trace/libtrace.la \ $(top_builddir)/src/gallium/drivers/rbug/librbug.la \ - $(top_builddir)/src/gallium/drivers/galahad/libgalahad.la \ $(top_builddir)/src/mapi/glapi/libglapi.la \ $(top_builddir)/src/mesa/libmesagallium.la \ $(top_builddir)/src/gallium/auxiliary/libgallium.la \ diff --git a/src/gallium/targets/libgl-xlib/SConscript b/src/gallium/targets/libgl-xlib/SConscript index 6975188..df5a220 100644 --- a/src/gallium/targets/libgl-xlib/SConscript +++ b/src/gallium/targets/libgl-xlib/SConscript @@ -39,8 +39,8 @@ sources = [ ] if True: - env.Append(CPPDEFINES = ['GALLIUM_TRACE', 'GALLIUM_RBUG', 'GALLIUM_GALAHAD', 'GALLIUM_SOFTPIPE']) - env.Prepend(LIBS = [trace, rbug, galahad, softpipe]) + env.Append(CPPDEFINES = ['GALLIUM_TRACE', 'GALLIUM_RBUG', 'GALLIUM_SOFTPIPE']) + env.Prepend(LIBS = [trace, rbug, softpipe]) if env['llvm']: env.Append(CPPDEFINES = ['GALLIUM_LLVMPIPE']) diff --git a/src/gallium/targets/pipe-loader/Makefile.am b/src/gallium/targets/pipe-loader/Makefile.am index fe40f5b..967cdb7 100644 --- a/src/gallium/targets/pipe-loader/Makefile.am +++ b/src/gallium/targets/pipe-loader/Makefile.am @@ -30,8 +30,7 @@ AM_CPPFLAGS = \ $(LIBDRM_CFLAGS) \ $(VISIBILITY_CFLAGS) \ -DGALLIUM_RBUG \ - -DGALLIUM_TRACE \ - -DGALLIUM_GALAHAD + -DGALLIUM_TRACE pipedir = $(libdir)/gallium-pipe pipe_LTLIBRARIES = @@ -56,7 +55,6 @@ PIPE_LIBS += \ $(top_builddir)/src/util/libmesautil.la \ $(top_builddir)/src/gallium/drivers/rbug/librbug.la \ $(top_builddir)/src/gallium/drivers/trace/libtrace.la \ - $(top_builddir)/src/gallium/drivers/galahad/libgalahad.la \ $(GALLIUM_COMMON_LIB_DEPS) AM_LDFLAGS = \ From evelikov at kemper.freedesktop.org Sat Mar 21 17:29:30 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Sat, 21 Mar 2015 10:29:30 -0700 (PDT) Subject: Mesa (master): egl: cut down static storage size for {Version, ClientAPI}String Message-ID: <20150321172930.75BBB76409@kemper.freedesktop.org> Module: Mesa Branch: master Commit: bbaf22a998f89eb720a3995fa2216512deed5f76 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=bbaf22a998f89eb720a3995fa2216512deed5f76 Author: Emil Velikov Date: Thu Mar 19 01:36:08 2015 +0000 egl: cut down static storage size for {Version,ClientAPI}String Both seems to be excessively long, namely: ClientAPIString can get up-to 47 based on current code, while the name of the driver can dictate the length of the VersionString, currently it is around 11. Let's pad each to 100, rather than the current 1000. Signed-off-by: Emil Velikov Reviewed-by: Brian Paul --- src/egl/main/egldisplay.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/egl/main/egldisplay.h b/src/egl/main/egldisplay.h index f8782f9..d7f5dba 100644 --- a/src/egl/main/egldisplay.h +++ b/src/egl/main/egldisplay.h @@ -153,8 +153,8 @@ struct _egl_display _EGLExtensions Extensions; /**< Extensions supported */ /* these fields are derived from above */ - char VersionString[1000]; /**< EGL_VERSION */ - char ClientAPIsString[1000]; /**< EGL_CLIENT_APIS */ + char VersionString[100]; /**< EGL_VERSION */ + char ClientAPIsString[100]; /**< EGL_CLIENT_APIS */ char ExtensionsString[_EGL_MAX_EXTENSIONS_LEN]; /**< EGL_EXTENSIONS */ _EGLArray *Screens; From evelikov at kemper.freedesktop.org Sat Mar 21 17:29:30 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Sat, 21 Mar 2015 10:29:30 -0700 (PDT) Subject: Mesa (master): st/gbm: remove state-tracker Message-ID: <20150321172930.319E276359@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 48c7461d5a0d5cb0f3df5025d7849d27e73a80b3 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=48c7461d5a0d5cb0f3df5025d7849d27e73a80b3 Author: Emil Velikov Date: Sat Mar 14 22:36:25 2015 +0000 st/gbm: remove state-tracker st/egl was its only user. Signed-off-by: Emil Velikov Acked-by: Matt Turner --- src/gallium/Makefile.am | 2 - src/gallium/state_trackers/gbm/Makefile.am | 48 --- src/gallium/state_trackers/gbm/Makefile.sources | 3 - src/gallium/state_trackers/gbm/gbm_drm.c | 308 -------------------- .../state_trackers/gbm/gbm_gallium_drmint.h | 67 ----- src/gallium/targets/gbm/Makefile.am | 95 ------ src/gallium/targets/gbm/gallium-gbm-symbols-check | 13 - src/gallium/targets/gbm/gbm.sym | 6 - src/gallium/targets/gbm/target.c | 1 - 9 files changed, 543 deletions(-) diff --git a/src/gallium/Makefile.am b/src/gallium/Makefile.am index 652cb13..69e2e1e 100644 --- a/src/gallium/Makefile.am +++ b/src/gallium/Makefile.am @@ -114,8 +114,6 @@ EXTRA_DIST = \ docs \ README.portability \ SConscript \ - state_trackers/gbm \ - targets/gbm \ winsys/sw/gdi \ winsys/sw/hgl diff --git a/src/gallium/state_trackers/gbm/Makefile.am b/src/gallium/state_trackers/gbm/Makefile.am deleted file mode 100644 index 50995b3..0000000 --- a/src/gallium/state_trackers/gbm/Makefile.am +++ /dev/null @@ -1,48 +0,0 @@ -# Copyright ? 2012 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 Makefile.sources -include $(top_srcdir)/src/gallium/Automake.inc - -AM_CFLAGS = \ - $(GALLIUM_CFLAGS) \ - $(X11_INCLUDES) \ - $(VISIBILITY_CFLAGS) - -AM_CPPFLAGS = \ - -I$(top_srcdir)/src/gbm/main \ - $(GALLIUM_PIPE_LOADER_DEFINES) \ - -DPIPE_SEARCH_DIR=\"$(libdir)/gallium-pipe\" - -if HAVE_GALLIUM_STATIC_TARGETS -AM_CPPFLAGS += \ - -DGALLIUM_STATIC_TARGETS=1 -endif - -if HAVE_EGL_PLATFORM_WAYLAND -AM_CFLAGS += $(WAYLAND_CFLAGS) -AM_CPPFLAGS += -DHAVE_WAYLAND_PLATFORM -endif - -noinst_LTLIBRARIES = libgbm.la - -libgbm_la_SOURCES = $(C_SOURCES) diff --git a/src/gallium/state_trackers/gbm/Makefile.sources b/src/gallium/state_trackers/gbm/Makefile.sources deleted file mode 100644 index 1ab961c..0000000 --- a/src/gallium/state_trackers/gbm/Makefile.sources +++ /dev/null @@ -1,3 +0,0 @@ -C_SOURCES := \ - gbm_drm.c \ - gbm_gallium_drmint.h diff --git a/src/gallium/state_trackers/gbm/gbm_drm.c b/src/gallium/state_trackers/gbm/gbm_drm.c deleted file mode 100644 index da6d724..0000000 --- a/src/gallium/state_trackers/gbm/gbm_drm.c +++ /dev/null @@ -1,308 +0,0 @@ -/* - * Copyright ? 2011 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. - * - * Authors: - * Benjamin Franzke - */ - -#include "util/u_memory.h" -#include "util/u_inlines.h" - -#include "pipe-loader/pipe_loader.h" -#include "state_tracker/drm_driver.h" - -#include -#include - -#include "gbm_gallium_drmint.h" - -/* For importing wl_buffer */ -#if HAVE_WAYLAND_PLATFORM -#include "../../../egl/wayland/wayland-drm/wayland-drm.h" -#endif - -static INLINE enum pipe_format -gbm_format_to_gallium(enum gbm_bo_format format) -{ - switch (format) { - case GBM_BO_FORMAT_XRGB8888: - return PIPE_FORMAT_BGRX8888_UNORM; - case GBM_BO_FORMAT_ARGB8888: - return PIPE_FORMAT_BGRA8888_UNORM; - default: - return PIPE_FORMAT_NONE; - } - - return PIPE_FORMAT_NONE; -} - -static INLINE uint -gbm_usage_to_gallium(uint usage) -{ - uint resource_usage = 0; - - if (usage & GBM_BO_USE_SCANOUT) - resource_usage |= PIPE_BIND_SCANOUT; - - if (usage & GBM_BO_USE_RENDERING) - resource_usage |= PIPE_BIND_RENDER_TARGET | PIPE_BIND_SAMPLER_VIEW; - - if (usage & GBM_BO_USE_CURSOR) - resource_usage |= PIPE_BIND_CURSOR; - - return resource_usage; -} - -static int -gbm_gallium_drm_is_format_supported(struct gbm_device *gbm, - enum gbm_bo_format format, - uint32_t usage) -{ - struct gbm_gallium_drm_device *gdrm = gbm_gallium_drm_device(gbm); - enum pipe_format pf; - - pf = gbm_format_to_gallium(format); - if (pf == PIPE_FORMAT_NONE) - return 0; - - if (!gdrm->screen->is_format_supported(gdrm->screen, pf, PIPE_TEXTURE_2D, 0, - gbm_usage_to_gallium(usage))) - return 0; - - if (usage & GBM_BO_USE_SCANOUT && format != GBM_BO_FORMAT_XRGB8888) - return 0; - - return 1; -} - -static void -gbm_gallium_drm_bo_destroy(struct gbm_bo *_bo) -{ - struct gbm_gallium_drm_bo *bo = gbm_gallium_drm_bo(_bo); - - pipe_resource_reference(&bo->resource, NULL); - free(bo); -} - -static struct gbm_bo * -gbm_gallium_drm_bo_import(struct gbm_device *gbm, - uint32_t type, void *buffer, uint32_t usage) -{ - struct gbm_gallium_drm_device *gdrm = gbm_gallium_drm_device(gbm); - struct gbm_gallium_drm_bo *bo; - struct winsys_handle whandle; - struct pipe_resource *resource; - - switch (type) { -#if HAVE_WAYLAND_PLATFORM - case GBM_BO_IMPORT_WL_BUFFER: - { - struct wl_drm_buffer *wb = (struct wl_drm_buffer *) buffer; - - resource = wb->driver_buffer; - break; - } -#endif - - case GBM_BO_IMPORT_EGL_IMAGE: - if (!gdrm->lookup_egl_image) - return NULL; - - resource = gdrm->lookup_egl_image(gdrm->lookup_egl_image_data, buffer); - if (resource == NULL) - return NULL; - break; - - default: - return NULL; - } - - bo = CALLOC_STRUCT(gbm_gallium_drm_bo); - if (bo == NULL) - return NULL; - - bo->base.base.gbm = gbm; - bo->base.base.width = resource->width0; - bo->base.base.height = resource->height0; - - switch (resource->format) { - case PIPE_FORMAT_BGRX8888_UNORM: - bo->base.base.format = GBM_BO_FORMAT_XRGB8888; - break; - case PIPE_FORMAT_BGRA8888_UNORM: - bo->base.base.format = GBM_BO_FORMAT_ARGB8888; - break; - default: - FREE(bo); - return NULL; - } - - pipe_resource_reference(&bo->resource, resource); - - memset(&whandle, 0, sizeof(whandle)); - whandle.type = DRM_API_HANDLE_TYPE_KMS; - gdrm->screen->resource_get_handle(gdrm->screen, bo->resource, &whandle); - - bo->base.base.handle.u32 = whandle.handle; - bo->base.base.stride = whandle.stride; - - return &bo->base.base; -} - -static struct gbm_bo * -gbm_gallium_drm_bo_create(struct gbm_device *gbm, - uint32_t width, uint32_t height, - enum gbm_bo_format format, uint32_t usage) -{ - struct gbm_gallium_drm_device *gdrm = gbm_gallium_drm_device(gbm); - struct gbm_gallium_drm_bo *bo; - struct pipe_resource templ; - struct winsys_handle whandle; - enum pipe_format pf; - - bo = CALLOC_STRUCT(gbm_gallium_drm_bo); - if (bo == NULL) - return NULL; - - bo->base.base.gbm = gbm; - bo->base.base.width = width; - bo->base.base.height = height; - bo->base.base.format = format; - - pf = gbm_format_to_gallium(format); - if (pf == PIPE_FORMAT_NONE) - return NULL; - - memset(&templ, 0, sizeof(templ)); - templ.bind = gbm_usage_to_gallium(usage); - templ.format = pf; - templ.target = PIPE_TEXTURE_2D; - templ.last_level = 0; - templ.width0 = width; - templ.height0 = height; - templ.depth0 = 1; - templ.array_size = 1; - - bo->resource = gdrm->screen->resource_create(gdrm->screen, &templ); - if (bo->resource == NULL) { - FREE(bo); - return NULL; - } - - memset(&whandle, 0, sizeof(whandle)); - whandle.type = DRM_API_HANDLE_TYPE_KMS; - gdrm->screen->resource_get_handle(gdrm->screen, bo->resource, &whandle); - - bo->base.base.handle.u32 = whandle.handle; - bo->base.base.stride = whandle.stride; - - return &bo->base.base; -} - -static void -gbm_gallium_drm_destroy(struct gbm_device *gbm) -{ - struct gbm_gallium_drm_device *gdrm = gbm_gallium_drm_device(gbm); - - free(gdrm->base.driver_name); - gdrm->screen->destroy(gdrm->screen); -#if !GALLIUM_STATIC_TARGETS - pipe_loader_release(&gdrm->dev, 1); -#endif - free(gdrm); -} - -#if !GALLIUM_STATIC_TARGETS -#ifdef HAVE_PIPE_LOADER_DRM -static const char * -get_library_search_path(void) -{ - const char *search_path = NULL; - - /* don't allow setuid apps to use GBM_BACKENDS_PATH */ - if (geteuid() == getuid()) - search_path = getenv("GBM_BACKENDS_PATH"); - if (search_path == NULL) - search_path = PIPE_SEARCH_DIR; - - return search_path; -} -#endif -#endif - -static struct gbm_device * -gbm_gallium_drm_device_create(int fd) -{ - struct gbm_gallium_drm_device *gdrm; - - gdrm = calloc(1, sizeof *gdrm); - if (!gdrm) - return NULL; - - gdrm->base.base.fd = fd; - gdrm->base.base.bo_create = gbm_gallium_drm_bo_create; - gdrm->base.base.bo_import = gbm_gallium_drm_bo_import; - gdrm->base.base.bo_destroy = gbm_gallium_drm_bo_destroy; - gdrm->base.base.is_format_supported = gbm_gallium_drm_is_format_supported; - gdrm->base.base.destroy = gbm_gallium_drm_destroy; - - gdrm->base.type = GBM_DRM_DRIVER_TYPE_GALLIUM; - gdrm->base.base.name = "drm"; - -#if GALLIUM_STATIC_TARGETS - gdrm->screen = dd_create_screen(gdrm->base.base.fd); -#else -#ifdef HAVE_PIPE_LOADER_DRM - if (pipe_loader_drm_probe_fd(&gdrm->dev, gdrm->base.base.fd, false)) - gdrm->screen = pipe_loader_create_screen(gdrm->dev, - get_library_search_path()); -#endif /* HAVE_PIPE_LOADER_DRM */ -#endif - - if (gdrm->screen == NULL) - goto out_no_screen; - -#if GALLIUM_STATIC_TARGETS - gdrm->base.driver_name = strdup(dd_driver_name()); -#else -#ifdef HAVE_PIPE_LOADER_DRM - gdrm->base.driver_name = strdup(gdrm->dev->driver_name); -#endif /* HAVE_PIPE_LOADER_DRM */ -#endif - return &gdrm->base.base; - -out_no_screen: - debug_printf("failed to load gallium_gbm\n"); -#if !GALLIUM_STATIC_TARGETS - if (gdrm->dev) - pipe_loader_release(&gdrm->dev, 1); -#endif - free(gdrm); - return NULL; -} - - -GBM_EXPORT struct gbm_backend gbm_backend = { - .backend_name = "gallium_drm", - .create_device = gbm_gallium_drm_device_create, -}; diff --git a/src/gallium/state_trackers/gbm/gbm_gallium_drmint.h b/src/gallium/state_trackers/gbm/gbm_gallium_drmint.h deleted file mode 100644 index 8b05ef9..0000000 --- a/src/gallium/state_trackers/gbm/gbm_gallium_drmint.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright ? 2011 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. - * - * Authors: - * Benjamin Franzke - */ - -#ifndef _GBM_GALLIUM_DRMINT_H_ -#define _GBM_GALLIUM_DRMINT_H_ - -#include "pipe/p_state.h" - -#include "gbmint.h" - -#include "common_drm.h" - -struct gbm_gallium_drm_device { - struct gbm_drm_device base; - - struct pipe_screen *screen; - struct pipe_loader_device *dev; - - struct pipe_resource *(*lookup_egl_image)(void *data, - void *egl_image); - void *lookup_egl_image_data; - -}; - -struct gbm_gallium_drm_bo { - struct gbm_drm_bo base; - - struct pipe_resource *resource; -}; - -static inline struct gbm_gallium_drm_device * -gbm_gallium_drm_device(struct gbm_device *gbm) -{ - return (struct gbm_gallium_drm_device *) gbm; -} - -static inline struct gbm_gallium_drm_bo * -gbm_gallium_drm_bo(struct gbm_bo *bo) -{ - return (struct gbm_gallium_drm_bo *) bo; -} - -#endif diff --git a/src/gallium/targets/gbm/Makefile.am b/src/gallium/targets/gbm/Makefile.am deleted file mode 100644 index aaf7580..0000000 --- a/src/gallium/targets/gbm/Makefile.am +++ /dev/null @@ -1,95 +0,0 @@ -# Copyright ? 2012 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 $(top_srcdir)/src/gallium/Automake.inc - -AM_CFLAGS = \ - $(GALLIUM_TARGET_CFLAGS) - -gbmdir = $(libdir)/gbm -gbm_LTLIBRARIES = gbm_gallium_drm.la - -nodist_EXTRA_gbm_gallium_drm_la_SOURCES = dummy.cpp -gbm_gallium_drm_la_SOURCES = - -gbm_gallium_drm_la_LIBADD = \ - $(top_builddir)/src/gallium/state_trackers/gbm/libgbm.la \ - $(top_builddir)/src/gallium/auxiliary/libgalliumvl_stub.la \ - $(top_builddir)/src/gallium/auxiliary/libgallium.la \ - $(top_builddir)/src/util/libmesautil.la \ - $(LIBDRM_LIBS) \ - $(GALLIUM_COMMON_LIB_DEPS) - -gbm_gallium_drm_la_LDFLAGS = \ - -module \ - -no-undefined \ - -avoid-version \ - $(GC_SECTIONS) \ - $(LD_NO_UNDEFINED) - -if HAVE_LD_VERSION_SCRIPT -gbm_gallium_drm_la_LDFLAGS += \ - -Wl,--version-script=$(top_srcdir)/src/gallium/targets/gbm/gbm.sym -endif - -EXTRA_gbm_gallium_drm_la_DEPENDENCIES = gbm.sym -EXTRA_DIST = gallium-gbm-symbols-check gbm.sym - -if HAVE_GALLIUM_STATIC_TARGETS - -TARGET_DRIVERS = -TARGET_CPPFLAGS = -TARGET_LIB_DEPS = $(top_builddir)/src/loader/libloader.la - -include $(top_srcdir)/src/gallium/drivers/i915/Automake.inc - -include $(top_srcdir)/src/gallium/drivers/ilo/Automake.inc - -include $(top_srcdir)/src/gallium/drivers/nouveau/Automake.inc - -include $(top_srcdir)/src/gallium/drivers/r300/Automake.inc -include $(top_srcdir)/src/gallium/drivers/r600/Automake.inc -include $(top_srcdir)/src/gallium/drivers/radeonsi/Automake.inc - -include $(top_srcdir)/src/gallium/drivers/svga/Automake.inc - -include $(top_srcdir)/src/gallium/drivers/freedreno/Automake.inc - -gbm_gallium_drm_la_SOURCES += target.c -gbm_gallium_drm_la_CPPFLAGS = $(TARGET_CPPFLAGS) -gbm_gallium_drm_la_LIBADD += $(TARGET_LIB_DEPS) \ - $(TARGET_RADEON_WINSYS) $(TARGET_RADEON_COMMON) - -else # HAVE_GALLIUM_STATIC_TARGETS -gbm_gallium_drm_la_LIBADD += \ - $(top_builddir)/src/gallium/auxiliary/pipe-loader/libpipe_loader.la \ - $(GALLIUM_PIPE_LOADER_WINSYS_LIBS) \ - $(GALLIUM_PIPE_LOADER_LIBS) - -endif # HAVE_GALLIUM_STATIC_TARGETS - -if HAVE_MESA_LLVM -gbm_gallium_drm_la_LIBADD += $(LLVM_LIBS) -gbm_gallium_drm_la_LDFLAGS += $(LLVM_LDFLAGS) -endif - -TESTS = gallium-gbm-symbols-check diff --git a/src/gallium/targets/gbm/gallium-gbm-symbols-check b/src/gallium/targets/gbm/gallium-gbm-symbols-check deleted file mode 100755 index 52b20ab..0000000 --- a/src/gallium/targets/gbm/gallium-gbm-symbols-check +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash - -FUNCS=$(nm -D --defined-only ${1-.libs/gbm_gallium_drm.so} | egrep -o "T .*|D .*" | cut -c 3- | while read func; do -( grep -q "^$func$" || echo $func ) < Module: Mesa Branch: master Commit: 0bff196b225be13f91ec34da06093a13a9ed425b URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=0bff196b225be13f91ec34da06093a13a9ed425b Author: Emil Velikov Date: Sat Mar 21 17:21:21 2015 +0000 docs: note the removal of gbm_gallium, galahad and identity Signed-off-by: Emil Velikov --- docs/relnotes/10.6.0.html | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/relnotes/10.6.0.html b/docs/relnotes/10.6.0.html index a396109..00aaaa5 100644 --- a/docs/relnotes/10.6.0.html +++ b/docs/relnotes/10.6.0.html @@ -61,7 +61,10 @@ TBD.
            • Removed classic Windows software rasterizer.
            • Removed egl_gallium EGL driver.
            • +
            • Removed gbm_gallium GBM driver.
            • Removed OpenVG support.
            • +
            • Removed the galahad gallium driver.
            • +
            • Removed the identity gallium driver.
        From evelikov at kemper.freedesktop.org Sat Mar 21 22:38:16 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Sat, 21 Mar 2015 15:38:16 -0700 (PDT) Subject: Mesa (master): galahad: actually remove the driver Message-ID: <20150321223816.6762376359@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 7c7954b09dd28502aedb3eed312672620b9e6b7a URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=7c7954b09dd28502aedb3eed312672620b9e6b7a Author: Emil Velikov Date: Sat Mar 21 22:30:52 2015 +0000 galahad: actually remove the driver Should have been part of 429a4355259(galahad: remove driver). Seems like I've erroneously committed the trimmed patch. Reported-by: Marek Ol??k Signed-off-by: Emil Velikov --- src/gallium/drivers/galahad/Makefile.am | 16 - src/gallium/drivers/galahad/Makefile.sources | 8 - src/gallium/drivers/galahad/SConscript | 12 - src/gallium/drivers/galahad/glhd_context.c | 1056 -------------------------- src/gallium/drivers/galahad/glhd_context.h | 69 -- src/gallium/drivers/galahad/glhd_objects.c | 186 ----- src/gallium/drivers/galahad/glhd_objects.h | 179 ----- src/gallium/drivers/galahad/glhd_public.h | 37 - src/gallium/drivers/galahad/glhd_screen.c | 387 ---------- src/gallium/drivers/galahad/glhd_screen.h | 48 -- 10 files changed, 1998 deletions(-) Diff: http://cgit.freedesktop.org/mesa/mesa/diff/?id=7c7954b09dd28502aedb3eed312672620b9e6b7a From jrfonseca at kemper.freedesktop.org Sun Mar 22 08:23:36 2015 From: jrfonseca at kemper.freedesktop.org (Jose Fonseca) Date: Sun, 22 Mar 2015 01:23:36 -0700 (PDT) Subject: Mesa (master): glsl: Avoid GLboolean vs bool arithmetic MSVC warnings. Message-ID: <20150322082336.EAA2476359@kemper.freedesktop.org> Module: Mesa Branch: master Commit: d01a7cdae576162791813c131027a6e675a4e6c7 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=d01a7cdae576162791813c131027a6e675a4e6c7 Author: Jose Fonseca Date: Wed Mar 18 14:21:15 2015 +0000 glsl: Avoid GLboolean vs bool arithmetic MSVC warnings. Note that GLboolean is an alias for unsigned char, which lacks the implicit true/false semantics that C++/C99 bool have. Reviewed-by: Brian Paul v2: Change gl_shader::IsES and gl_shader_program::IsES to be bool as recommended by Ian Romanick. Reviewed-by: Brian Paul Reviewed-by: Ian Romanick --- src/glsl/linker.cpp | 5 +++-- src/mesa/main/mtypes.h | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp index 0c44677..4349f09 100644 --- a/src/glsl/linker.cpp +++ b/src/glsl/linker.cpp @@ -2542,8 +2542,9 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog) goto done; } - prog->ARB_fragment_coord_conventions_enable |= - prog->Shaders[i]->ARB_fragment_coord_conventions_enable; + if (prog->Shaders[i]->ARB_fragment_coord_conventions_enable) { + prog->ARB_fragment_coord_conventions_enable = true; + } gl_shader_stage shader_type = prog->Shaders[i]->Stage; shader_list[shader_type][num_shaders[shader_type]] = prog->Shaders[i]; diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 1b45494..8e1dba6 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -2548,7 +2548,7 @@ struct gl_shader GLchar *Label; /**< GL_KHR_debug */ GLboolean DeletePending; GLboolean CompileStatus; - GLboolean IsES; /**< True if this shader uses GLSL ES */ + bool IsES; /**< True if this shader uses GLSL ES */ GLuint SourceChecksum; /**< for debug/logging purposes */ const GLchar *Source; /**< Source code string */ @@ -2924,7 +2924,7 @@ struct gl_shader_program GLchar *InfoLog; unsigned Version; /**< GLSL version used for linking */ - GLboolean IsES; /**< True if this program uses GLSL ES */ + bool IsES; /**< True if this program uses GLSL ES */ /** * Per-stage shaders resulting from the first stage of linking. From jrfonseca at kemper.freedesktop.org Sun Mar 22 08:23:36 2015 From: jrfonseca at kemper.freedesktop.org (Jose Fonseca) Date: Sun, 22 Mar 2015 01:23:36 -0700 (PDT) Subject: Mesa (master): glsl: Disable MSVC switch warning on a per-file basis. Message-ID: <20150322082337.016A07635A@kemper.freedesktop.org> Module: Mesa Branch: master Commit: fb78cccd7b5c29f9ecd2c86b530449e903dcc093 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=fb78cccd7b5c29f9ecd2c86b530449e903dcc093 Author: Jose Fonseca Date: Thu Mar 19 22:24:20 2015 +0000 glsl: Disable MSVC switch warning on a per-file basis. This addresses ...\glsl_parser.cpp(...) : warning C4065: switch statement contains 'default' but no 'case' labels This is on code generated by bison, which we have little control. It seems useful to have this warning otherwise enabled. Reviewed-by: Brian Paul Reviewed-by: Ian Romanick --- src/glsl/glsl_parser.yy | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/glsl/glsl_parser.yy b/src/glsl/glsl_parser.yy index 90c216e..aceb3b9 100644 --- a/src/glsl/glsl_parser.yy +++ b/src/glsl/glsl_parser.yy @@ -34,6 +34,10 @@ #include "glsl_types.h" #include "main/context.h" +#ifdef _MSC_VER +#pragma warning( disable : 4065 ) // switch statement contains 'default' but no 'case' labels +#endif + #undef yyerror static void yyerror(YYLTYPE *loc, _mesa_glsl_parse_state *st, const char *msg) From jrfonseca at kemper.freedesktop.org Sun Mar 22 08:23:37 2015 From: jrfonseca at kemper.freedesktop.org (Jose Fonseca) Date: Sun, 22 Mar 2015 01:23:37 -0700 (PDT) Subject: Mesa (master): st/vdpau: Avoid constness cast warnings. Message-ID: <20150322082337.0CD4D76359@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 60eff442772865bc98f05fe4c18bf468fff39e20 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=60eff442772865bc98f05fe4c18bf468fff39e20 Author: Jose Fonseca Date: Thu Mar 19 13:14:41 2015 +0000 st/vdpau: Avoid constness cast warnings. Fixes MSVC warning C4090: '=' : different 'const' qualifiers Reviewed-by: Brian Paul Reviewed-by: Christian K?nig --- src/mesa/state_tracker/st_vdpau.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesa/state_tracker/st_vdpau.c b/src/mesa/state_tracker/st_vdpau.c index 6ccaf3e..63af119 100644 --- a/src/mesa/state_tracker/st_vdpau.c +++ b/src/mesa/state_tracker/st_vdpau.c @@ -66,7 +66,7 @@ st_vdpau_map_surface(struct gl_context *ctx, GLenum target, GLenum access, struct pipe_sampler_view templ, **sampler_view; mesa_format texFormat; - getProcAddr = ctx->vdpGetProcAddress; + getProcAddr = (void *)ctx->vdpGetProcAddress; if (output) { VdpOutputSurfaceGallium *f; From jrfonseca at kemper.freedesktop.org Sun Mar 22 08:23:37 2015 From: jrfonseca at kemper.freedesktop.org (Jose Fonseca) Date: Sun, 22 Mar 2015 01:23:37 -0700 (PDT) Subject: Mesa (master): include: Ensure float.h is included for DBL_MAX. Message-ID: <20150322082337.144C576359@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 8d5c303ab965c928eef684755c2db9cd441e37ad URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=8d5c303ab965c928eef684755c2db9cd441e37ad Author: Jose Fonseca Date: Thu Mar 19 11:51:08 2015 +0000 include: Ensure float.h is included for DBL_MAX. I didn't actually hit the issue in practice, but just happen to notice while looking at the code. Reviewed-by: Brian Paul --- include/c99_math.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/c99_math.h b/include/c99_math.h index bd35d1b..5b01d53 100644 --- a/include/c99_math.h +++ b/include/c99_math.h @@ -71,6 +71,7 @@ roundf(float x) #endif #ifndef INFINITY +#include // DBL_MAX #define INFINITY (DBL_MAX + DBL_MAX) #endif From jrfonseca at kemper.freedesktop.org Sun Mar 22 08:23:37 2015 From: jrfonseca at kemper.freedesktop.org (Jose Fonseca) Date: Sun, 22 Mar 2015 01:23:37 -0700 (PDT) Subject: Mesa (master): configure: Bail out with MinGW targets. Message-ID: <20150322082337.1CBD176359@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 8f0274c6c645f65a59cb54e14c299cbe131b162d URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=8f0274c6c645f65a59cb54e14c299cbe131b162d Author: Jose Fonseca Date: Thu Mar 19 13:38:52 2015 +0000 configure: Bail out with MinGW targets. We only support native Windows builds with SCons. Tested with: ./configure --host=i686-w64-mingw32 Reviewed-by: Brian Paul --- configure.ac | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/configure.ac b/configure.ac index a8eb0c9..08378f5 100644 --- a/configure.ac +++ b/configure.ac @@ -46,6 +46,13 @@ AC_CONFIG_MACRO_DIR([m4]) AC_CANONICAL_SYSTEM AM_INIT_AUTOMAKE([foreign tar-ustar dist-xz]) +dnl We only support native Windows builds (MinGW/MSVC) through SCons. +case "$host_os" in +mingw*) + AC_MSG_ERROR([MinGW build not supported through autoconf/automake, use SCons instead]) + ;; +esac + # Support silent build rules, requires at least automake-1.11. Disable # by either passing --disable-silent-rules to configure or passing V=1 # to make @@ -651,7 +658,7 @@ AC_CHECK_FUNCS([dladdr]) LIBS="$save_LIBS" case "$host_os" in -darwin*|mingw*) +darwin*) ;; *) AC_CHECK_FUNCS([clock_gettime], [CLOCK_LIB=], @@ -665,16 +672,10 @@ dnl See if posix_memalign is available AC_CHECK_FUNC([posix_memalign], [DEFINES="$DEFINES -DHAVE_POSIX_MEMALIGN"]) dnl Check for pthreads -case "$host_os" in -mingw*) - ;; -*) - AX_PTHREAD - if test "x$ax_pthread_ok" = xno; then - AC_MSG_ERROR([Building mesa on this platform requires pthreads]) - fi - ;; -esac +AX_PTHREAD +if test "x$ax_pthread_ok" = xno; then + AC_MSG_ERROR([Building mesa on this platform requires pthreads]) +fi dnl AX_PTHREADS leaves PTHREAD_LIBS empty for gcc and sets PTHREAD_CFLAGS dnl to -pthread, which causes problems if we need -lpthread to appear in dnl pkgconfig files. @@ -905,7 +906,7 @@ AM_CONDITIONAL(HAVE_DRI_GLX, test "x$enable_glx" = xyes -a \ case "$host_os" in darwin*) dri_platform='apple' ;; -gnu*|mingw*|cygwin*) +gnu*|cygwin*) dri_platform='none' ;; *) dri_platform='drm' ;; From jrfonseca at kemper.freedesktop.org Sun Mar 22 08:23:37 2015 From: jrfonseca at kemper.freedesktop.org (Jose Fonseca) Date: Sun, 22 Mar 2015 01:23:37 -0700 (PDT) Subject: Mesa (master): scons: Define YY_USE_CONST on MSVC. Message-ID: <20150322082337.32A2076359@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 015e8b6384bbdba8421c5dafd4783dba4d3a9182 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=015e8b6384bbdba8421c5dafd4783dba4d3a9182 Author: Jose Fonseca Date: Thu Mar 19 11:53:36 2015 +0000 scons: Define YY_USE_CONST on MSVC. This prevents the MSVC from warning C4090: 'function' : different 'const' qualifiers when compiling flex generated lexers. Reviewed-by: Brian Paul --- scons/gallium.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/scons/gallium.py b/scons/gallium.py index 2b11526..9924f1e 100755 --- a/scons/gallium.py +++ b/scons/gallium.py @@ -622,6 +622,14 @@ def generate(env): # Load tools env.Tool('lex') + if env['msvc']: + env.Append(LEXFLAGS = [ + # Force flex to use const keyword in prototypes, as relies on + # __cplusplus or __STDC__ macro to determine whether it's safe to + # use const keyword, but MSVC never defines __STDC__ unless we + # disable all MSVC extensions. + '-DYY_USE_CONST=', + ]) env.Tool('yacc') if env['llvm']: env.Tool('llvm') From jrfonseca at kemper.freedesktop.org Sun Mar 22 08:23:37 2015 From: jrfonseca at kemper.freedesktop.org (Jose Fonseca) Date: Sun, 22 Mar 2015 01:23:37 -0700 (PDT) Subject: Mesa (master): scons: Prefer winflexbison, and use --wincompat when available. Message-ID: <20150322082337.3A3F876359@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 9c1c657e19ff373315b517ca58f87227b336f3b7 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=9c1c657e19ff373315b517ca58f87227b336f3b7 Author: Jose Fonseca Date: Thu Mar 19 13:30:19 2015 +0000 scons: Prefer winflexbison, and use --wincompat when available. This avoids MSVC the warning warning C4013: 'isatty' undefined; assuming extern returning int with certain versions of flex. Reviewed-by: Brian Paul v2: Add win flex-bison link to docs/install.html. --- docs/install.html | 4 ++-- scons/gallium.py | 40 +++++++++++++++++++++++++++++++++------- 2 files changed, 35 insertions(+), 9 deletions(-) diff --git a/docs/install.html b/docs/install.html index 9dbfce5..a90c2b2 100644 --- a/docs/install.html +++ b/docs/install.html @@ -55,8 +55,8 @@ Versions 2.5.35 and 2.4.1, respectively, (or later) should work.
        On Windows with MinGW, install flex and bison with:
        mingw-get install msys-flex msys-bison
        -For MSVC on Windows, you can find flex/bison programs on the -Mesa ftp site. +For MSVC on Windows, install +Win flex-bison.
      diff --git a/scons/gallium.py b/scons/gallium.py index 9924f1e..1564970 100755 --- a/scons/gallium.py +++ b/scons/gallium.py @@ -35,7 +35,7 @@ import os import os.path import re import subprocess -import platform as _platform +import platform as host_platform import sys import tempfile @@ -147,6 +147,17 @@ def check_cc(env, cc, expr, cpp_opt = '-E'): return result +def check_prog(env, prog): + """Check whether this program exists.""" + + sys.stdout.write('Checking for %s ... ' % prog) + + result = env.Detect(prog) + + sys.stdout.write(' %s\n' % ['no', 'yes'][int(bool(result))]) + return result + + def generate(env): """Common environment generation code""" @@ -186,7 +197,7 @@ def generate(env): env['gcc'] = 0 env['clang'] = 0 env['msvc'] = 0 - if _platform.system() == 'Windows': + if host_platform.system() == 'Windows': env['msvc'] = check_cc(env, 'MSVC', 'defined(_MSC_VER)', '/E') if not env['msvc']: env['gcc'] = check_cc(env, 'GCC', 'defined(__GNUC__) && !defined(__clang__)') @@ -210,10 +221,10 @@ def generate(env): # Determine whether we are cross compiling; in particular, whether we need # to compile code generators with a different compiler as the target code. - host_platform = _platform.system().lower() - if host_platform.startswith('cygwin'): - host_platform = 'cygwin' - host_machine = os.environ.get('PROCESSOR_ARCHITEW6432', os.environ.get('PROCESSOR_ARCHITECTURE', _platform.machine())) + hosthost_platform = host_platform.system().lower() + if hosthost_platform.startswith('cygwin'): + hosthost_platform = 'cygwin' + host_machine = os.environ.get('PROCESSOR_ARCHITEW6432', os.environ.get('PROCESSOR_ARCHITECTURE', host_platform.machine())) host_machine = { 'x86': 'x86', 'i386': 'x86', @@ -224,7 +235,7 @@ def generate(env): 'AMD64': 'x86_64', 'x86_64': 'x86_64', }.get(host_machine, 'generic') - env['crosscompile'] = platform != host_platform + env['crosscompile'] = platform != hosthost_platform if machine == 'x86_64' and host_machine != 'x86_64': env['crosscompile'] = True env['hostonly'] = False @@ -630,7 +641,22 @@ def generate(env): # disable all MSVC extensions. '-DYY_USE_CONST=', ]) + if host_platform.system() == 'Windows': + # Prefer winflexbison binaries, as not only they are easier to install + # (no additional dependencies), but also better Windows support. + if check_prog(env, 'win_flex'): + env["LEX"] = 'win_flex' + env.Append(LEXFLAGS = [ + # windows compatibility (uses instead of and + # _isatty, _fileno functions) + '--wincompat' + ]) + env.Tool('yacc') + if host_platform.system() == 'Windows': + if check_prog(env, 'win_bison'): + env["YACC"] = 'win_bison' + if env['llvm']: env.Tool('llvm') From jrfonseca at kemper.freedesktop.org Sun Mar 22 08:23:37 2015 From: jrfonseca at kemper.freedesktop.org (Jose Fonseca) Date: Sun, 22 Mar 2015 01:23:37 -0700 (PDT) Subject: Mesa (master): scons: Cleanup flex/bison settings specification. Message-ID: <20150322082337.41D0D76359@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 31e47a59ad542c72a56f1eee1b402b23d42e4475 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=31e47a59ad542c72a56f1eee1b402b23d42e4475 Author: Jose Fonseca Date: Thu Mar 19 13:35:18 2015 +0000 scons: Cleanup flex/bison settings specification. Reviewed-by: Brian Paul --- src/glsl/SConscript | 20 ++++++++++++-------- src/mesa/SConscript | 2 +- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/glsl/SConscript b/src/glsl/SConscript index 26de455..284b375 100644 --- a/src/glsl/SConscript +++ b/src/glsl/SConscript @@ -24,22 +24,26 @@ env.Prepend(LIBS = [mesautil]) # Make glcpp-parse.h and glsl_parser.h reachable from the include path. env.Append(CPPPATH = [Dir('.').abspath, Dir('glcpp').abspath]) -env.Append(YACCFLAGS = '-d -p "glcpp_parser_"') +glcpp_env = env.Clone() +glcpp_env.Append(YACCFLAGS = [ + '-d', + '-p', 'glcpp_parser_' +]) -parser_env = env.Clone() -parser_env.Append(YACCFLAGS = [ +glsl_env = env.Clone() +glsl_env.Append(YACCFLAGS = [ '--defines=%s' % File('glsl_parser.h').abspath, '-p', '_mesa_glsl_', ]) # without this line scons will expect "glsl_parser.hpp" instead of # "glsl_parser.h", causing glsl_parser.cpp to be regenerated every time -parser_env['YACCHXXFILESUFFIX'] = '.h' +glsl_env['YACCHXXFILESUFFIX'] = '.h' -glcpp_lexer = env.CFile('glcpp/glcpp-lex.c', 'glcpp/glcpp-lex.l') -glcpp_parser = env.CFile('glcpp/glcpp-parse.c', 'glcpp/glcpp-parse.y') -glsl_lexer = parser_env.CXXFile('glsl_lexer.cpp', 'glsl_lexer.ll') -glsl_parser = parser_env.CXXFile('glsl_parser.cpp', 'glsl_parser.yy') +glcpp_lexer = glcpp_env.CFile('glcpp/glcpp-lex.c', 'glcpp/glcpp-lex.l') +glcpp_parser = glcpp_env.CFile('glcpp/glcpp-parse.c', 'glcpp/glcpp-parse.y') +glsl_lexer = glsl_env.CXXFile('glsl_lexer.cpp', 'glsl_lexer.ll') +glsl_parser = glsl_env.CXXFile('glsl_parser.cpp', 'glsl_parser.yy') # common generated sources glsl_sources = [ diff --git a/src/mesa/SConscript b/src/mesa/SConscript index 72d9811..a563fd2 100644 --- a/src/mesa/SConscript +++ b/src/mesa/SConscript @@ -39,7 +39,7 @@ else: # parse Makefile.sources source_lists = env.ParseSourceList('Makefile.sources') -env.Append(YACCFLAGS = '-d -p "_mesa_program_"') +env.Append(YACCFLAGS = ['-d', '-p', '_mesa_program_']) env.CFile('program/lex.yy.c', 'program/program_lexer.l') env.CFile('program/program_parse.tab.c', 'program/program_parse.y') From jrfonseca at kemper.freedesktop.org Sun Mar 22 08:23:37 2015 From: jrfonseca at kemper.freedesktop.org (Jose Fonseca) Date: Sun, 22 Mar 2015 01:23:37 -0700 (PDT) Subject: Mesa (master): scons: Silence MSVC C4351 warning. Message-ID: <20150322082337.51DA276359@kemper.freedesktop.org> Module: Mesa Branch: master Commit: e4d95982ee36097a86c4afec3f34924964978c21 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=e4d95982ee36097a86c4afec3f34924964978c21 Author: Jose Fonseca Date: Thu Mar 19 22:22:26 2015 +0000 scons: Silence MSVC C4351 warning. It warns about change in MSVC behavior -- array initialisation used to be non-standard, but is standard now, assuming I understand correctly http://en.cppreference.com/w/cpp/language/zero_initialization . Reviewed-by: Brian Paul --- scons/gallium.py | 1 + 1 file changed, 1 insertion(+) diff --git a/scons/gallium.py b/scons/gallium.py index 1564970..7050412 100755 --- a/scons/gallium.py +++ b/scons/gallium.py @@ -510,6 +510,7 @@ def generate(env): '/wd4056', # overflow in floating-point constant arithmetic '/wd4244', # conversion from 'type1' to 'type2', possible loss of data '/wd4305', # truncation from 'type1' to 'type2' + '/wd4351', # new behavior: elements of array 'array' will be default initialized '/wd4756', # overflow in constant arithmetic '/wd4800', # forcing value to bool 'true' or 'false' (performance warning) '/wd4996', # disable deprecated POSIX name warnings From jrfonseca at kemper.freedesktop.org Sun Mar 22 08:23:37 2015 From: jrfonseca at kemper.freedesktop.org (Jose Fonseca) Date: Sun, 22 Mar 2015 01:23:37 -0700 (PDT) Subject: Mesa (master): gallivm: Silence unused variable warnings on release builds. Message-ID: <20150322082337.68DB076359@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 397b491173f0d2df4deb44d21c170bf16840d507 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=397b491173f0d2df4deb44d21c170bf16840d507 Author: Jose Fonseca Date: Fri Mar 20 12:02:42 2015 +0000 gallivm: Silence unused variable warnings on release builds. Reviewed-by: Brian Paul --- src/gallium/auxiliary/gallivm/lp_bld_arit.c | 2 ++ src/gallium/auxiliary/gallivm/lp_bld_bitarit.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/gallium/auxiliary/gallivm/lp_bld_arit.c b/src/gallium/auxiliary/gallivm/lp_bld_arit.c index 956b37a..9daa93e 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_arit.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_arit.c @@ -1831,6 +1831,8 @@ lp_build_round_altivec(struct lp_build_context *bld, assert(lp_check_value(type, a)); assert(util_cpu_caps.has_altivec); + (void)type; + switch (mode) { case LP_BUILD_ROUND_NEAREST: intrinsic = "llvm.ppc.altivec.vrfin"; diff --git a/src/gallium/auxiliary/gallivm/lp_bld_bitarit.c b/src/gallium/auxiliary/gallivm/lp_bld_bitarit.c index 9892d7a..f3fa5f4 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_bitarit.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_bitarit.c @@ -182,6 +182,8 @@ lp_build_shl(struct lp_build_context *bld, LLVMValueRef a, LLVMValueRef b) assert(lp_check_value(type, a)); assert(lp_check_value(type, b)); + (void)type; + res = LLVMBuildShl(builder, a, b, ""); return res; From jrfonseca at kemper.freedesktop.org Sun Mar 22 08:23:37 2015 From: jrfonseca at kemper.freedesktop.org (Jose Fonseca) Date: Sun, 22 Mar 2015 01:23:37 -0700 (PDT) Subject: Mesa (master): scons: Ensure git_sha1.h's directory exists. Message-ID: <20150322082337.23F9776359@kemper.freedesktop.org> Module: Mesa Branch: master Commit: e6330f9f56d6df2c59191513630d837ef3a7b1a9 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=e6330f9f56d6df2c59191513630d837ef3a7b1a9 Author: Jose Fonseca Date: Thu Mar 19 13:31:37 2015 +0000 scons: Ensure git_sha1.h's directory exists. Reviewed-by: Brian Paul --- src/mesa/SConscript | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/mesa/SConscript b/src/mesa/SConscript index cc5d242..72d9811 100644 --- a/src/mesa/SConscript +++ b/src/mesa/SConscript @@ -130,7 +130,9 @@ def write_git_sha1_h_file(filename): (commit, foo) = subprocess.Popen(args, stdout=subprocess.PIPE).communicate() except: # git log command didn't work - if not os.path.exists(filename): + dirname = os.path.dirname(filename) + if not os.path.exists(dirname): + os.makedirs(dirname) # create an empty file if none already exists f = open(filename, "w") f.close() From jrfonseca at kemper.freedesktop.org Sun Mar 22 08:23:37 2015 From: jrfonseca at kemper.freedesktop.org (Jose Fonseca) Date: Sun, 22 Mar 2015 01:23:37 -0700 (PDT) Subject: Mesa (master): scons: Tell MSVC STL library to not use exceptions. Message-ID: <20150322082337.2B5A576359@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 357d1fc81aceec6dda866ea74962ee2ddf3aa350 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=357d1fc81aceec6dda866ea74962ee2ddf3aa350 Author: Jose Fonseca Date: Fri Mar 20 06:27:59 2015 +0000 scons: Tell MSVC STL library to not use exceptions. MSVC defaults to no exceptions unless /EH option is passed (which we don't), while MSVC's STL defaults to use exceptions unless _HAS_EXCEPTIONS=0 is defined, which we didn't. This fixes warning C4530: C++ exception handler used, but unwind semantics are not enabled. Specify /EHsc Reviewed-by: Brian Paul --- scons/gallium.py | 1 + 1 file changed, 1 insertion(+) diff --git a/scons/gallium.py b/scons/gallium.py index b4018e7..2b11526 100755 --- a/scons/gallium.py +++ b/scons/gallium.py @@ -351,6 +351,7 @@ def generate(env): '_SCL_SECURE_NO_WARNINGS', '_SCL_SECURE_NO_DEPRECATE', '_ALLOW_KEYWORD_MACROS', + '_HAS_EXCEPTIONS=0', # Tell C++ STL to not use exceptions ] if env['build'] in ('debug', 'checked'): cppdefines += ['_DEBUG'] From jrfonseca at kemper.freedesktop.org Sun Mar 22 08:23:37 2015 From: jrfonseca at kemper.freedesktop.org (Jose Fonseca) Date: Sun, 22 Mar 2015 01:23:37 -0700 (PDT) Subject: Mesa (master): scons: Match some of LLVM warning options. Message-ID: <20150322082337.48CEA76359@kemper.freedesktop.org> Module: Mesa Branch: master Commit: e518d97d7e8136384d5310235e2dd295170bfdcd URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=e518d97d7e8136384d5310235e2dd295170bfdcd Author: Jose Fonseca Date: Thu Mar 19 22:09:20 2015 +0000 scons: Match some of LLVM warning options. Reviewed-by: Brian Paul --- scons/llvm.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scons/llvm.py b/scons/llvm.py index d145de8..be7df9f 100644 --- a/scons/llvm.py +++ b/scons/llvm.py @@ -132,6 +132,11 @@ def generate(env): # Some of the LLVM C headers use the inline keyword without # defining it. env.Append(CPPDEFINES = [('inline', '__inline')]) + # Match some of the warning options from llvm/cmake/modules/HandleLLVMOptions.cmake + env.AppendUnique(CXXFLAGS = [ + '/wd4355', # 'this' : used in base member initializer list + '/wd4624', # 'derived class' : destructor could not be generated because a base class destructor is inaccessible + ]) if env['build'] in ('debug', 'checked'): # LLVM libraries are static, build with /MT, and they # automatically link agains LIBCMT. When we're doing a From jrfonseca at kemper.freedesktop.org Sun Mar 22 08:23:37 2015 From: jrfonseca at kemper.freedesktop.org (Jose Fonseca) Date: Sun, 22 Mar 2015 01:23:37 -0700 (PDT) Subject: Mesa (master): scons: Silence conversion from 'size_t' to 'type', possible loss of data on MSVC. Message-ID: <20150322082337.60A9876359@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 06ac7178108ff8eb6e3eae103a302d79f0972d1a URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=06ac7178108ff8eb6e3eae103a302d79f0972d1a Author: Jose Fonseca Date: Fri Mar 20 12:01:23 2015 +0000 scons: Silence conversion from 'size_t' to 'type', possible loss of data on MSVC. Most cases seem harmless, though that might not always be the case. Maybe one day we can get gcc to complain about these and fix them throughout the code, but until then let's silence them. Reviewed-by: Brian Paul --- scons/gallium.py | 1 + 1 file changed, 1 insertion(+) diff --git a/scons/gallium.py b/scons/gallium.py index b4df145..efc65e7 100755 --- a/scons/gallium.py +++ b/scons/gallium.py @@ -509,6 +509,7 @@ def generate(env): '/wd4018', # signed/unsigned mismatch '/wd4056', # overflow in floating-point constant arithmetic '/wd4244', # conversion from 'type1' to 'type2', possible loss of data + '/wd4267', # 'var' : conversion from 'size_t' to 'type', possible loss of data '/wd4305', # truncation from 'type1' to 'type2' '/wd4351', # new behavior: elements of array 'array' will be default initialized '/wd4756', # overflow in constant arithmetic From jrfonseca at kemper.freedesktop.org Sun Mar 22 08:23:37 2015 From: jrfonseca at kemper.freedesktop.org (Jose Fonseca) Date: Sun, 22 Mar 2015 01:23:37 -0700 (PDT) Subject: Mesa (master): scons: Ensure inttypes.h is always pre-included on MSVC. Message-ID: <20150322082337.5983176359@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 15c5595bb144d8018ebd922c6914772958cbf2b2 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=15c5595bb144d8018ebd922c6914772958cbf2b2 Author: Jose Fonseca Date: Fri Mar 20 06:53:09 2015 +0000 scons: Ensure inttypes.h is always pre-included on MSVC. It's a bit hackish couldn't find another solution. See code comment for details. The warning is useful, so universally disabling doesn't sound a good idea. Fixes warning C4005: 'xxx' : macro redefinition Reviewed-by: Brian Paul --- scons/gallium.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/scons/gallium.py b/scons/gallium.py index 7050412..b4df145 100755 --- a/scons/gallium.py +++ b/scons/gallium.py @@ -642,6 +642,13 @@ def generate(env): # disable all MSVC extensions. '-DYY_USE_CONST=', ]) + # Flex relies on __STDC_VERSION__>=199901L to decide when to include + # C99 inttypes.h. We always have inttypes.h available with MSVC + # (either the one bundled with MSVC 2013, or the one we bundle + # ourselves), but we can't just define __STDC_VERSION__ without + # breaking stuff, as MSVC doesn't fully support C99. There's also no + # way to premptively include stdint. + env.Append(CCFLAGS = ['-FIinttypes.h']) if host_platform.system() == 'Windows': # Prefer winflexbison binaries, as not only they are easier to install # (no additional dependencies), but also better Windows support. From airlied at kemper.freedesktop.org Sun Mar 22 23:55:47 2015 From: airlied at kemper.freedesktop.org (Dave Airlie) Date: Sun, 22 Mar 2015 16:55:47 -0700 (PDT) Subject: Mesa (master): i965: define I915_PARAM_REVISION Message-ID: <20150322235547.776E57633A@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 484f9f4fcd53fcaa768e63934a5f74346bfb46a9 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=484f9f4fcd53fcaa768e63934a5f74346bfb46a9 Author: Dave Airlie Date: Mon Mar 23 09:54:52 2015 +1000 i965: define I915_PARAM_REVISION we are broken against the libdrm 2.4.60 minimum specified, so fix it for now. Signed-off-by: Dave Airlie --- src/mesa/drivers/dri/i965/brw_context.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c index 0d3af2c..a39443a 100644 --- a/src/mesa/drivers/dri/i965/brw_context.c +++ b/src/mesa/drivers/dri/i965/brw_context.c @@ -658,6 +658,11 @@ brw_process_driconf_options(struct brw_context *brw) driQueryOptionb(options, "allow_glsl_extension_directive_midshader"); } +/* drop when libdrm 2.4.61 is released */ +#ifndef I915_PARAM_REVISION +#define I915_PARAM_REVISION 32 +#endif + static int brw_get_revision(int fd) { From jekstrand at kemper.freedesktop.org Mon Mar 23 08:04:31 2015 From: jekstrand at kemper.freedesktop.org (Jason Ekstrand) Date: Mon, 23 Mar 2015 01:04:31 -0700 (PDT) Subject: Mesa (master): i965/fs: Make emit_lrp return an fs_inst Message-ID: <20150323080431.53AF47633A@kemper.freedesktop.org> Module: Mesa Branch: master Commit: a3e05898e9915566ca3cfbfe40a0c9ea92b0d0d9 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=a3e05898e9915566ca3cfbfe40a0c9ea92b0d0d9 Author: Jason Ekstrand Date: Tue Mar 17 11:36:10 2015 -0700 i965/fs: Make emit_lrp return an fs_inst Reviewed-by: Matt Turner Reviewed-by: Ian Romanick --- src/mesa/drivers/dri/i965/brw_fs.h | 4 ++-- src/mesa/drivers/dri/i965/brw_fs_visitor.cpp | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_fs.h b/src/mesa/drivers/dri/i965/brw_fs.h index 608262f..278a8ee 100644 --- a/src/mesa/drivers/dri/i965/brw_fs.h +++ b/src/mesa/drivers/dri/i965/brw_fs.h @@ -303,8 +303,8 @@ public: fs_reg fix_math_operand(fs_reg src); fs_inst *emit_math(enum opcode op, fs_reg dst, fs_reg src0); fs_inst *emit_math(enum opcode op, fs_reg dst, fs_reg src0, fs_reg src1); - void emit_lrp(const fs_reg &dst, const fs_reg &x, const fs_reg &y, - const fs_reg &a); + fs_inst *emit_lrp(const fs_reg &dst, const fs_reg &x, const fs_reg &y, + const fs_reg &a); void emit_minmax(enum brw_conditional_mod conditionalmod, const fs_reg &dst, const fs_reg &src0, const fs_reg &src1); void emit_discard_jump(); diff --git a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp index 2920a82..e6fb0cb 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp @@ -288,7 +288,7 @@ fs_visitor::visit(ir_dereference_array *ir) this->result = src; } -void +fs_inst * fs_visitor::emit_lrp(const fs_reg &dst, const fs_reg &x, const fs_reg &y, const fs_reg &a) { @@ -305,12 +305,12 @@ fs_visitor::emit_lrp(const fs_reg &dst, const fs_reg &x, const fs_reg &y, emit(ADD(one_minus_a, negative_a, fs_reg(1.0f))); emit(MUL(x_times_one_minus_a, x, one_minus_a)); - emit(ADD(dst, x_times_one_minus_a, y_times_a)); + return emit(ADD(dst, x_times_one_minus_a, y_times_a)); } else { /* The LRP instruction actually does op1 * op0 + op2 * (1 - op0), so * we need to reorder the operands. */ - emit(LRP(dst, a, y, x)); + return emit(LRP(dst, a, y, x)); } } From jekstrand at kemper.freedesktop.org Mon Mar 23 08:04:31 2015 From: jekstrand at kemper.freedesktop.org (Jason Ekstrand) Date: Mon, 23 Mar 2015 01:04:31 -0700 (PDT) Subject: Mesa (master): i965/nir: Do boolean resolves on GEN <= 5 Message-ID: <20150323080431.9344B7639A@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 41d64fa184671d372f6630deaf2401b00d4e984a URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=41d64fa184671d372f6630deaf2401b00d4e984a Author: Jason Ekstrand Date: Tue Mar 17 11:49:04 2015 -0700 i965/nir: Do boolean resolves on GEN <= 5 v2: A couple comment clean-ups from Matt Reviewed-by: Matt Turner --- src/mesa/drivers/dri/i965/brw_fs_nir.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp index 90071f6..8507090 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp @@ -25,6 +25,7 @@ #include "glsl/ir_optimization.h" #include "glsl/nir/glsl_to_nir.h" #include "brw_fs.h" +#include "brw_nir.h" static void nir_optimize(nir_shader *nir) @@ -155,6 +156,14 @@ fs_visitor::emit_nir_code() nir_convert_from_ssa(nir); nir_validate_shader(nir); + /* This is the last pass we run before we start emitting stuff. It + * determines when we need to insert boolean resolves on Gen <= 5. We + * run it last because it stashes data in instr->pass_flags and we don't + * want that to be squashed by other NIR passes. + */ + if (brw->gen <= 5) + brw_nir_analyze_boolean_resolves(nir); + /* emit the arrays used for inputs and outputs - load/store intrinsics will * be converted to reads/writes of these arrays */ @@ -1261,6 +1270,17 @@ fs_visitor::nir_emit_alu(nir_alu_instr *instr) default: unreachable("unhandled instruction"); } + + /* If we need to do a boolean resolve, replace the result with -(x & 1) + * to sign extend the low bit to 0/~0 + */ + if (brw->gen <= 5 && + (instr->instr.pass_flags & BRW_NIR_BOOLEAN_MASK) == BRW_NIR_BOOLEAN_NEEDS_RESOLVE) { + fs_reg masked = vgrf(glsl_type::int_type); + emit(AND(masked, result, fs_reg(1))); + masked.negate = true; + emit(MOV(result, masked)); + } } fs_reg From jekstrand at kemper.freedesktop.org Mon Mar 23 08:04:31 2015 From: jekstrand at kemper.freedesktop.org (Jason Ekstrand) Date: Mon, 23 Mar 2015 01:04:31 -0700 (PDT) Subject: Mesa (master): i965/nir: Use emit_lrp for emitting flrp Message-ID: <20150323080431.5E1DE7635A@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 235c728020af352ee0f4b7d598c951f4a4e83232 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=235c728020af352ee0f4b7d598c951f4a4e83232 Author: Jason Ekstrand Date: Tue Mar 17 11:37:09 2015 -0700 i965/nir: Use emit_lrp for emitting flrp Reviewed-by: Matt Turner Reviewed-by: Ian Romanick --- src/mesa/drivers/dri/i965/brw_fs_nir.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp index 5d88fe7..a059dbb 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp @@ -1243,8 +1243,7 @@ fs_visitor::nir_emit_alu(nir_alu_instr *instr) break; case nir_op_flrp: - /* TODO emulate for gen < 6 */ - inst = emit(LRP(result, op[2], op[1], op[0])); + inst = emit_lrp(result, op[0], op[1], op[2]); inst->saturate = instr->dest.saturate; break; From jekstrand at kemper.freedesktop.org Mon Mar 23 08:04:31 2015 From: jekstrand at kemper.freedesktop.org (Jason Ekstrand) Date: Mon, 23 Mar 2015 01:04:31 -0700 (PDT) Subject: Mesa (master): i965/nir: Properly set the predicate on the SEL used in min /max Message-ID: <20150323080431.7A78A7635C@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 2612e569e04e29500f81ed233bd86b45ef583495 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=2612e569e04e29500f81ed233bd86b45ef583495 Author: Jason Ekstrand Date: Tue Mar 17 13:43:10 2015 -0700 i965/nir: Properly set the predicate on the SEL used in min/max Reviewed-by: Matt Turner --- src/mesa/drivers/dri/i965/brw_fs_nir.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp index a059dbb..90071f6 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp @@ -1136,6 +1136,7 @@ fs_visitor::nir_emit_alu(nir_alu_instr *instr) } else { emit(CMP(reg_null_d, op[0], op[1], BRW_CONDITIONAL_L)); inst = emit(SEL(result, op[0], op[1])); + inst->predicate = BRW_PREDICATE_NORMAL; } inst->saturate = instr->dest.saturate; break; @@ -1149,6 +1150,7 @@ fs_visitor::nir_emit_alu(nir_alu_instr *instr) } else { emit(CMP(reg_null_d, op[0], op[1], BRW_CONDITIONAL_GE)); inst = emit(SEL(result, op[0], op[1])); + inst->predicate = BRW_PREDICATE_NORMAL; } inst->saturate = instr->dest.saturate; break; From jekstrand at kemper.freedesktop.org Mon Mar 23 08:04:31 2015 From: jekstrand at kemper.freedesktop.org (Jason Ekstrand) Date: Mon, 23 Mar 2015 01:04:31 -0700 (PDT) Subject: Mesa (master): i965/nir: Use signed integer type for booleans Message-ID: <20150323080431.A029E7635A@kemper.freedesktop.org> Module: Mesa Branch: master Commit: a6d4a108d27f2b635748c583fe0507f04b3b493e URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=a6d4a108d27f2b635748c583fe0507f04b3b493e Author: Jason Ekstrand Date: Tue Mar 17 19:57:59 2015 -0700 i965/nir: Use signed integer type for booleans FS instructions with NIR on i965: total instructions in shared programs: 2663561 -> 2619051 (-1.67%) instructions in affected programs: 1612965 -> 1568455 (-2.76%) helped: 5455 HURT: 12 FS instructions with NIR on g4x: total instructions in shared programs: 2352633 -> 2307908 (-1.90%) instructions in affected programs: 1441842 -> 1397117 (-3.10%) helped: 5463 HURT: 11 FS instructions with NIR on ilk: total instructions in shared programs: 3997305 -> 3934278 (-1.58%) instructions in affected programs: 2189409 -> 2126382 (-2.88%) helped: 8969 HURT: 22 FS instructions with NIR on hsw (snb and ivb were similar): total instructions in shared programs: 4109389 -> 4109242 (-0.00%) instructions in affected programs: 109869 -> 109722 (-0.13%) helped: 339 HURT: 190 No SIMD16 programs were gained or lost on any platform Reviewed-by: Matt Turner --- src/mesa/drivers/dri/i965/brw_fs_nir.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp index 8507090..69f296c 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp @@ -522,7 +522,7 @@ fs_visitor::nir_emit_if(nir_if *if_stmt) /* first, put the condition into f0 */ fs_inst *inst = emit(MOV(reg_null_d, retype(get_nir_src(if_stmt->condition), - BRW_REGISTER_TYPE_UD))); + BRW_REGISTER_TYPE_D))); inst->conditional_mod = BRW_CONDITIONAL_NZ; emit(IF(BRW_PREDICATE_NORMAL)); @@ -598,9 +598,9 @@ static brw_reg_type brw_type_for_nir_type(nir_alu_type type) { switch (type) { - case nir_type_bool: case nir_type_unsigned: return BRW_REGISTER_TYPE_UD; + case nir_type_bool: case nir_type_int: return BRW_REGISTER_TYPE_D; case nir_type_float: @@ -1279,7 +1279,7 @@ fs_visitor::nir_emit_alu(nir_alu_instr *instr) fs_reg masked = vgrf(glsl_type::int_type); emit(AND(masked, result, fs_reg(1))); masked.negate = true; - emit(MOV(result, masked)); + emit(MOV(retype(result, BRW_REGISTER_TYPE_D), masked)); } } From jekstrand at kemper.freedesktop.org Mon Mar 23 08:04:31 2015 From: jekstrand at kemper.freedesktop.org (Jason Ekstrand) Date: Mon, 23 Mar 2015 01:04:31 -0700 (PDT) Subject: Mesa (master): i965/nir: Use NIR lowering for ffma for gen < 6 Message-ID: <20150323080431.6BCC77635B@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 80390f91a0e200ae29a678bda495b91f6452023a URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=80390f91a0e200ae29a678bda495b91f6452023a Author: Jason Ekstrand Date: Tue Mar 17 13:10:19 2015 -0700 i965/nir: Use NIR lowering for ffma for gen < 6 Reviewed-by: Matt Turner --- src/mesa/drivers/dri/i965/brw_context.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c index a39443a..ed6fdff 100644 --- a/src/mesa/drivers/dri/i965/brw_context.c +++ b/src/mesa/drivers/dri/i965/brw_context.c @@ -551,7 +551,12 @@ brw_initialize_context_constants(struct brw_context *brw) ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxInputComponents = 128; } - static const nir_shader_compiler_options nir_options = { + static const nir_shader_compiler_options gen4_nir_options = { + .native_integers = true, + .lower_ffma = true, + }; + + static const nir_shader_compiler_options gen6_nir_options = { .native_integers = true, }; @@ -568,7 +573,10 @@ brw_initialize_context_constants(struct brw_context *brw) (i == MESA_SHADER_FRAGMENT); ctx->Const.ShaderCompilerOptions[i].EmitNoIndirectUniform = false; ctx->Const.ShaderCompilerOptions[i].LowerClipDistance = true; - ctx->Const.ShaderCompilerOptions[i].NirOptions = &nir_options; + if (brw->gen >= 6) + ctx->Const.ShaderCompilerOptions[i].NirOptions = &gen6_nir_options; + else + ctx->Const.ShaderCompilerOptions[i].NirOptions = &gen4_nir_options; } ctx->Const.ShaderCompilerOptions[MESA_SHADER_VERTEX].OptimizeForAOS = true; From jekstrand at kemper.freedesktop.org Mon Mar 23 08:04:31 2015 From: jekstrand at kemper.freedesktop.org (Jason Ekstrand) Date: Mon, 23 Mar 2015 01:04:31 -0700 (PDT) Subject: Mesa (master): i965: Add a NIR analysis pass for determining when a boolean resolve is needed Message-ID: <20150323080431.871EF76397@kemper.freedesktop.org> Module: Mesa Branch: master Commit: a55af2699feb8f64d6f480b223204da071606721 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=a55af2699feb8f64d6f480b223204da071606721 Author: Jason Ekstrand Date: Tue Mar 17 11:29:01 2015 -0700 i965: Add a NIR analysis pass for determining when a boolean resolve is needed v2: Fix the spelling of analyze and re-arrange code for better readability as per Connor's comments. v3: Make the naming of things more consistent and add a pile of comments v4: Stop trying to avoid vectors Reviewed-by: Matt Turner Reviewed-by: Connor Abbott --- src/mesa/drivers/dri/i965/Makefile.sources | 2 + src/mesa/drivers/dri/i965/brw_nir.h | 78 ++++++ .../dri/i965/brw_nir_analyze_boolean_resolves.c | 268 ++++++++++++++++++++ 3 files changed, 348 insertions(+) diff --git a/src/mesa/drivers/dri/i965/Makefile.sources b/src/mesa/drivers/dri/i965/Makefile.sources index c69441b..3a3df70 100644 --- a/src/mesa/drivers/dri/i965/Makefile.sources +++ b/src/mesa/drivers/dri/i965/Makefile.sources @@ -73,6 +73,8 @@ i965_FILES = \ brw_meta_util.h \ brw_misc_state.c \ brw_multisample_state.h \ + brw_nir.h \ + brw_nir_analyze_boolean_resolves.c \ brw_object_purgeable.c \ brw_packed_float.c \ brw_performance_monitor.c \ diff --git a/src/mesa/drivers/dri/i965/brw_nir.h b/src/mesa/drivers/dri/i965/brw_nir.h new file mode 100644 index 0000000..27782a3 --- /dev/null +++ b/src/mesa/drivers/dri/i965/brw_nir.h @@ -0,0 +1,78 @@ +/* + * Copyright ? 2015 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. + */ + +#pragma once + +#include "glsl/nir/nir.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* Flags set in the instr->pass_flags field by i965 analysis passes */ +enum { + BRW_NIR_NON_BOOLEAN = 0x0, + + /* Indicates that the given instruction's destination is a boolean + * value but that it needs to be resolved before it can be used. + * On Gen <= 5, CMP instructions return a 32-bit value where the bottom + * bit represents the actual true/false value of the compare and the top + * 31 bits are undefined. In order to use this value, we have to do a + * "resolve" operation by replacing the value of the CMP with -(x & 1) + * to sign-extend the bottom bit to 0/~0. + */ + BRW_NIR_BOOLEAN_NEEDS_RESOLVE = 0x1, + + /* Indicates that the given instruction's destination is a boolean + * value that has intentionally been left unresolved. Not all boolean + * values need to be resolved immediately. For instance, if we have + * + * CMP r1 r2 r3 + * CMP r4 r5 r6 + * AND r7 r1 r4 + * + * We don't have to resolve the result of the two CMP instructions + * immediately because the AND still does an AND of the bottom bits. + * Instead, we can save ourselves instructions by delaying the resolve + * until after the AND. The result of the two CMP instructions is left + * as BRW_NIR_BOOLEAN_UNRESOLVED. + */ + BRW_NIR_BOOLEAN_UNRESOLVED = 0x2, + + /* Indicates a that the given instruction's destination is a boolean + * value that does not need a resolve. For instance, if you AND two + * values that are BRW_NIR_BOOLEAN_NEEDS_RESOLVE then we know that both + * values will be 0/~0 before we get them and the result of the AND is + * also guaranteed to be 0/~0 and does not need a resolve. + */ + BRW_NIR_BOOLEAN_NO_RESOLVE = 0x3, + + /* A mask to mask the boolean status values off of instr->pass_flags */ + BRW_NIR_BOOLEAN_MASK = 0x3, +}; + +void brw_nir_analyze_boolean_resolves(nir_shader *nir); + +#ifdef __cplusplus +} +#endif diff --git a/src/mesa/drivers/dri/i965/brw_nir_analyze_boolean_resolves.c b/src/mesa/drivers/dri/i965/brw_nir_analyze_boolean_resolves.c new file mode 100644 index 0000000..3a27cf1 --- /dev/null +++ b/src/mesa/drivers/dri/i965/brw_nir_analyze_boolean_resolves.c @@ -0,0 +1,268 @@ +/* + * Copyright ? 2015 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. + * + * Authors: + * Jason Ekstrand + */ + +#include "brw_nir.h" + +/* + * This file implements an analysis pass that determines when we have to do + * a boolean resolve on Gen <= 5. Instructions that need a boolean resolve + * will have the booleans portion of the instr->pass_flags field set to + * BRW_NIR_BOOLEAN_NEEDS_RESOLVE. + */ + + +/** Returns the resolve status for the given source + * + * If the source has a parent instruction then the resolve status is the + * status of the parent instruction. If the source does not have a parent + * instruction then we don't know so we return NON_BOOLEAN. + */ +static uint8_t +get_resolve_status_for_src(nir_src *src) +{ + nir_instr *src_instr; + if (src->is_ssa) { + src_instr = src->ssa->parent_instr; + } else { + src_instr = src->reg.reg->parent_instr; + } + + if (src_instr) { + uint8_t resolve_status = src_instr->pass_flags & BRW_NIR_BOOLEAN_MASK; + + /* If the source instruction needs resolve, then from the perspective + * of the user, it's a true boolean. + */ + if (resolve_status == BRW_NIR_BOOLEAN_NEEDS_RESOLVE) + resolve_status = BRW_NIR_BOOLEAN_NO_RESOLVE; + return resolve_status; + } else { + return BRW_NIR_NON_BOOLEAN; + } +} + +/** Marks the given source as needing a resolve + * + * If the given source corresponds to an unresolved boolean it marks it as + * needing a resolve. Otherwise, we leave it alone. + */ +static bool +src_mark_needs_resolve(nir_src *src, void *void_state) +{ + nir_instr *src_instr; + if (src->is_ssa) { + src_instr = src->ssa->parent_instr; + } else { + src_instr = src->reg.reg->parent_instr; + } + + if (src_instr) { + uint8_t resolve_status = src_instr->pass_flags & BRW_NIR_BOOLEAN_MASK; + + /* If the source instruction is unresolved, then mark it as needing + * to be resolved. + */ + if (resolve_status == BRW_NIR_BOOLEAN_UNRESOLVED) { + src_instr->pass_flags &= ~BRW_NIR_BOOLEAN_MASK; + src_instr->pass_flags |= BRW_NIR_BOOLEAN_NEEDS_RESOLVE; + } + + } + + return true; +} + +static bool +analyze_boolean_resolves_block(nir_block *block, void *void_state) +{ + nir_foreach_instr(block, instr) { + switch (instr->type) { + case nir_instr_type_alu: { + /* For ALU instructions, the resolve status is handled in a + * three-step process. + * + * 1) Look at the instruction type and sources and determine if it + * can be left unresolved. + * + * 2) Look at the destination and see if we have to resolve + * anyway. (This is the case if this instruction is not the + * only instruction writing to a given register.) + * + * 3) If the instruction has a resolve status other than + * BOOL_UNRESOLVED or BOOL_NEEDS_RESOLVE then we walk through + * the sources and ensure that they are also resolved. This + * ensures that we don't end up with any stray unresolved + * booleans going into ADDs or something like that. + */ + + uint8_t resolve_status; + nir_alu_instr *alu = nir_instr_as_alu(instr); + switch (alu->op) { + case nir_op_flt: + case nir_op_ilt: + case nir_op_ult: + case nir_op_fge: + case nir_op_ige: + case nir_op_uge: + case nir_op_feq: + case nir_op_ieq: + case nir_op_fne: + case nir_op_ine: + case nir_op_f2b: + case nir_op_i2b: + /* This instruction will turn into a CMP when we actually emit + * so the result will have to be resolved before it can be used. + */ + resolve_status = BRW_NIR_BOOLEAN_UNRESOLVED; + + /* Even though the destination is allowed to be left unresolved, + * the sources are treated as regular integers or floats so + * they need to be resolved. + */ + nir_foreach_src(instr, src_mark_needs_resolve, NULL); + break; + + case nir_op_imov: + case nir_op_inot: + /* This is a single-source instruction. Just copy the resolve + * status from the source. + */ + resolve_status = get_resolve_status_for_src(&alu->src[0].src); + break; + + case nir_op_iand: + case nir_op_ior: + case nir_op_ixor: { + uint8_t src0_status = get_resolve_status_for_src(&alu->src[0].src); + uint8_t src1_status = get_resolve_status_for_src(&alu->src[1].src); + + if (src0_status == src1_status) { + resolve_status = src0_status; + } else if (src0_status == BRW_NIR_NON_BOOLEAN || + src1_status == BRW_NIR_NON_BOOLEAN) { + /* If one of the sources is a non-boolean then the whole + * thing is a non-boolean. + */ + resolve_status = BRW_NIR_NON_BOOLEAN; + } else { + /* At this point one of them is a true boolean and one is a + * boolean that needs a resolve. We could either resolve the + * unresolved source or we could resolve here. If we resolve + * the unresolved source then we get two resolves for the price + * of one. Just set this one to BOOLEAN_NO_RESOLVE and we'll + * let the code below force a resolve on the unresolved source. + */ + resolve_status = BRW_NIR_BOOLEAN_NO_RESOLVE; + } + break; + } + + default: + resolve_status = BRW_NIR_NON_BOOLEAN; + } + + /* If the destination is SSA-like, go ahead allow unresolved booleans. + * If the destination register doesn't have a well-defined parent_instr + * we need to resolve immediately. + */ + if (alu->dest.dest.reg.reg->parent_instr == NULL && + resolve_status == BRW_NIR_BOOLEAN_UNRESOLVED) { + resolve_status = BRW_NIR_BOOLEAN_NEEDS_RESOLVE; + } + + instr->pass_flags = (instr->pass_flags & ~BRW_NIR_BOOLEAN_MASK) | + resolve_status; + + /* Finally, resolve sources if it's needed */ + switch (resolve_status) { + case BRW_NIR_BOOLEAN_NEEDS_RESOLVE: + case BRW_NIR_BOOLEAN_UNRESOLVED: + /* This instruction is either unresolved or we're doing the + * resolve here; leave the sources alone. + */ + break; + + case BRW_NIR_BOOLEAN_NO_RESOLVE: + case BRW_NIR_NON_BOOLEAN: + nir_foreach_src(instr, src_mark_needs_resolve, NULL); + break; + + default: + unreachable("Invalid boolean flag"); + } + + break; + } + + case nir_instr_type_load_const: { + nir_load_const_instr *load = nir_instr_as_load_const(instr); + + /* For load_const instructions, it's a boolean exactly when it holds + * one of the values NIR_TRUE or NIR_FALSE. + * + * Since load_const instructions don't have any sources, we don't + * have to worry about resolving them. + */ + instr->pass_flags &= ~BRW_NIR_BOOLEAN_MASK; + if (load->value.u[0] == NIR_TRUE || load->value.u[0] == NIR_FALSE) { + instr->pass_flags |= BRW_NIR_BOOLEAN_NO_RESOLVE; + } else { + instr->pass_flags |= BRW_NIR_NON_BOOLEAN; + } + continue; + } + + default: + /* Everything else is an unknown non-boolean value and needs to + * have all sources resolved. + */ + instr->pass_flags = (instr->pass_flags & ~BRW_NIR_BOOLEAN_MASK) | + BRW_NIR_NON_BOOLEAN; + nir_foreach_src(instr, src_mark_needs_resolve, NULL); + continue; + } + } + + nir_if *following_if = nir_block_get_following_if(block); + if (following_if) + src_mark_needs_resolve(&following_if->condition, NULL); + + return true; +} + +static void +analyze_boolean_resolves_impl(nir_function_impl *impl) +{ + nir_foreach_block(impl, analyze_boolean_resolves_block, NULL); +} + +void +brw_nir_analyze_boolean_resolves(nir_shader *shader) +{ + nir_foreach_overload(shader, overload) + if (overload->impl) + analyze_boolean_resolves_impl(overload->impl); +} From tpalli at kemper.freedesktop.org Mon Mar 23 09:19:05 2015 From: tpalli at kemper.freedesktop.org (Tapani Pälli) Date: Mon, 23 Mar 2015 02:19:05 -0700 (PDT) Subject: Mesa (master): glsl: fix names in lower_constant_arrays_to_uniforms Message-ID: <20150323091905.85F227633A@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 3cf99701ba6c9e56c9126fdbb74107a31ffcbcfb URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=3cf99701ba6c9e56c9126fdbb74107a31ffcbcfb Author: Tapani P?lli Date: Mon Mar 23 09:12:35 2015 +0200 glsl: fix names in lower_constant_arrays_to_uniforms Patch changes lowering pass to use unique name for each uniform so that arrays from different stages cannot end up having same name. v2: instead of global counter, use pointer to achieve unique name (Kenneth Graunke) Signed-off-by: Tapani P?lli Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=89590 Reviewed-by: Chris Forbes Cc: 10.5 10.4 --- src/glsl/lower_const_arrays_to_uniforms.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/glsl/lower_const_arrays_to_uniforms.cpp b/src/glsl/lower_const_arrays_to_uniforms.cpp index 2243f47..44967dc 100644 --- a/src/glsl/lower_const_arrays_to_uniforms.cpp +++ b/src/glsl/lower_const_arrays_to_uniforms.cpp @@ -49,7 +49,6 @@ public: { instructions = insts; progress = false; - index = 0; } bool run() @@ -63,7 +62,6 @@ public: private: exec_list *instructions; bool progress; - unsigned index; }; void @@ -82,7 +80,7 @@ lower_const_array_visitor::handle_rvalue(ir_rvalue **rvalue) void *mem_ctx = ralloc_parent(con); - char *uniform_name = ralloc_asprintf(mem_ctx, "constarray__%d", index++); + char *uniform_name = ralloc_asprintf(mem_ctx, "constarray__%p", dra); ir_variable *uni = new(mem_ctx) ir_variable(con->type, uniform_name, ir_var_uniform); From currojerez at kemper.freedesktop.org Mon Mar 23 13:03:47 2015 From: currojerez at kemper.freedesktop.org (Francisco Jerez) Date: Mon, 23 Mar 2015 06:03:47 -0700 (PDT) Subject: Mesa (master): 31 new commits Message-ID: <20150323130347.3E4287633A@kemper.freedesktop.org> URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=3d1bba7c9be856ed4e7611ef92796430556a2f6d Author: Francisco Jerez Date: Wed Mar 18 21:06:28 2015 +0200 i965/vec4: Fix handling of multiple register reads and writes in dead_code_eliminate(). Reviewed-by: Matt Turner URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=2babde35b9a38a0561a87dc2d7cb431e9aabbd5a Author: Francisco Jerez Date: Mon Mar 23 14:08:49 2015 +0200 i965/vec4: Calculate live intervals with subregister granularity. Reviewed-by: Matt Turner URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=e6e655ef76bb22193b31af2841cb50fda0c39461 Author: Francisco Jerez Date: Wed Mar 18 20:49:43 2015 +0200 i965/vec4: Define helpers to calculate the common live interval of a range of variables. These will be especially useful when we start keeping track of liveness information for each subregister. Reviewed-by: Matt Turner URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=eddb87402ea7ce68357a3d93b0dbb41857be27f6 Author: Francisco Jerez Date: Wed Mar 18 20:17:23 2015 +0200 i965/vec4: Define helper functions to convert a register to a variable index. Reviewed-by: Matt Turner URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=ce030a63993f7192c6aa4c5b9180f9543a6a76bc Author: Francisco Jerez Date: Thu Mar 19 15:08:16 2015 +0200 i965/vec4: Don't lose the force_writemask_all flag during CSE. And set it in the MOV instructions that copy the temporary to the original destination if the generator instruction had it set. Reviewed-by: Matt Turner URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=1db9c0cd0c0f4a1a0a4409e4c90cd0f0d0bce68d Author: Francisco Jerez Date: Wed Mar 18 19:51:01 2015 +0200 i965/vec4: Fix handling of multiple register reads and writes in opt_cse(). Reviewed-by: Matt Turner URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=d041a43c0f3e01c9d6f81244cbf1c85d4f3a17d5 Author: Francisco Jerez Date: Wed Mar 18 19:46:54 2015 +0200 i965/vec4: Fix handling of multiple register reads and writes during copy propagation. Reviewed-by: Matt Turner URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=588859e18cb597612e56980a65a762ef069363e4 Author: Francisco Jerez Date: Wed Mar 18 19:45:40 2015 +0200 i965/vec4: Fix handling of multiple register reads and writes in split_virtual_grfs(). Reviewed-by: Matt Turner URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=9304f60cbe7c348a4771a7746606730bea3ae45f Author: Francisco Jerez Date: Wed Mar 18 19:43:44 2015 +0200 i965/vec4: Fix handling of multiple register reads and writes in opt_register_coalesce(). Reviewed-by: Matt Turner URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=74c7e5d35181d31e4448c614f6aa62c1e1f60694 Author: Francisco Jerez Date: Wed Mar 18 19:35:31 2015 +0200 i965: Define method to check whether a backend_reg is inside a given range. Reviewed-by: Matt Turner URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=bf6eb37e0b62fa61c01a32dc5ccb6a7ab00be5f4 Author: Francisco Jerez Date: Wed Mar 18 16:03:30 2015 +0200 i965/vec4: Remove dependency of vec4_live_variables on the visitor. Reviewed-by: Matt Turner URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=2e7622a48714934411c84cdd8b6576b2b8ce311d Author: Francisco Jerez Date: Thu Mar 19 15:30:06 2015 +0200 i965/vec4: Trivial copy propagate clean-up. Fix typo and punctuation in a comment, break long line and add space before curly bracket. Reviewed-by: Abdiel Janulgue URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=7526ee36bcb89c867f4ec94f4585952195429841 Author: Francisco Jerez Date: Wed Mar 18 15:51:45 2015 +0200 i965/vec4: Add argument index and type checks to SEL saturate propagation. SEL saturate propagation already implicitly relies on these assumptions. Reviewed-by: Abdiel Janulgue URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=24073b2cd7c15d989a40c1b7bc30e8be200ff328 Author: Francisco Jerez Date: Thu Mar 19 18:25:30 2015 +0200 i965/vec4: Fix broken saturate mask check in copy propagation. try_copy_propagate() was checking the bit of the saturate mask for the arg-th component of the source to decide whether the whole source should be saturated (WTF?). We need to swizzle the original saturate mask and check that for all enabled channels the saturate flag is either set or unset, as we cannot saturate a subset of destination components only. Reviewed-by: Abdiel Janulgue URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=18dc59c21295a2a4acf4b69cb7e7ea502c8dd8c8 Author: Francisco Jerez Date: Wed Mar 18 15:45:16 2015 +0200 i965/vec4: Don't lose copy propagation saturate bits for not written components. Reviewed-by: Abdiel Janulgue URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=a3733defbe4f87acd1b6dca716b861f2dfaea05a Author: Francisco Jerez Date: Wed Mar 18 15:39:03 2015 +0200 Revert "i965/vec4: Don't lose the saturate modifier in copy propagation." This reverts commit 0dfec59a2785cf7a87ee5128889ecebe810b611b. The change prevented propagation of copies with the saturate flag set, making the whole saturate mask tracking completely useless. A proper fix follows. Reviewed-by: Abdiel Janulgue URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=21c829e5cc6fefa5a42550e9043fade3e9e54e64 Author: Francisco Jerez Date: Wed Mar 18 15:40:25 2015 +0200 i965/vec4: Remove unused method definition. Reviewed-by: Matt Turner URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=516d45f78a3bbab0288c49c0f876ebdf4ad05bff Author: Francisco Jerez Date: Wed Mar 18 21:19:28 2015 +0200 i965/vec4: Some more trivial swizzle clean-up. Reviewed-by: Matt Turner URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=430c6bf70e48c08ba4dc9e00f2b88e2230793010 Author: Francisco Jerez Date: Wed Mar 18 15:27:58 2015 +0200 i965/vec4: Improve src_reg/dst_reg conversion constructors. This simplifies the src_reg/dst_reg conversion constructors using the swizzle utils introduced in a previous patch. It also makes them more useful by changing their semantics slightly: dst_reg(src_reg) used to set the writemask to XYZW if the src_reg swizzle was anything other than XXXX, which was almost certainly not what the caller intended if the swizzle was non-trivial. After this patch the same components that are present in the swizzle will be enabled in the resulting writemask. src_reg(dst_reg) used to set the first components of the swizzle to the enabled components of the writemask and then replicate the last enabled component to fill the swizzle, which, in cases where the writemask didn't have exactly the first n components set, would in general not be compatible with the original dst_reg. E.g.: | ADD(tmp, src_reg(tmp), src_reg(1)); would *not* do what one would expect (add one to each of the enabled components of tmp) if tmp didn't have a writemask of the described form (e.g. YZ, YW, XZW would all fail). This pattern actually occurs in many different places in the VEC4 back-end, it's a wonder that it hasn't caused piglit failures until now. After this patch src_reg(dst_reg) will construct a swizzle with each enabled component at its natural position (e.g. Y at the second position, Z at the third, and so on). The resulting swizzle will behave like the identity when used in any instruction with the original writemask. I've manually verified that *none* of the callers of both conversion constructors were relying on the previous broken semantics. There are no piglit regressions on any generation. Reviewed-by: Matt Turner URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=62fd3353387547504966d77f3350afc9b688ef93 Author: Francisco Jerez Date: Wed Mar 18 15:21:20 2015 +0200 i965/vec4: Pass argument by reference to src_reg/dst_reg conversion constructors. Reviewed-by: Matt Turner URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=23bda945f570b4f566ed39b4c1de89a957247df7 Author: Francisco Jerez Date: Wed Mar 18 21:18:08 2015 +0200 i965/vec4: Remove swizzle_for_size() in favour of brw_swizzle_for_size(). It could be objected that swizzle_for_size() is "faster" than brw_swizzle_for_size(). It's not measurably better in any reasonable CPU-bound benchmark on VLV according to the Finnish benchmarking system (including the SynMark2 DrvShComp shader compilation benchmark). Reviewed-by: Matt Turner URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=5bcca9f8dc34a13e34270d284bcf8a49b52bb58e Author: Francisco Jerez Date: Wed Mar 18 15:26:10 2015 +0200 i965/vec4: Remove broken vector size deduction in setup_builtin_uniform_values(). This seemed to be trying to deduce the number of uniform vector components from the parameter swizzle, but the algorithm would always give 4 as result. Instead grab the correct number of components from the GLSL type. Reviewed-by: Matt Turner URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=132cdcc468d0e40f422dd96303a61ee231be1a92 Author: Francisco Jerez Date: Wed Mar 18 21:15:05 2015 +0200 i965/vec4: Simplify visitor handling of swizzles using the swizzle utils. Reviewed-by: Matt Turner URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=9a17e4e900256b5be73d935fa5f35c98b3b0d7fe Author: Francisco Jerez Date: Wed Mar 18 21:11:20 2015 +0200 i965/vec4: Simplify opt_register_coalesce() using the swizzle utils. Reviewed-by: Matt Turner URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=05ec72d8ecdba04a81745fbc3ca0df40c7fb8828 Author: Francisco Jerez Date: Wed Mar 18 21:09:51 2015 +0200 i965/vec4: Simplify reswizzle() using the swizzle utils. Reviewed-by: Matt Turner URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=7b30493dc4f0b1346fe4c1fe52211f0c0d7ed229 Author: Francisco Jerez Date: Wed Mar 18 21:08:52 2015 +0200 i965/vec4: Simplify opt_reduce_swizzle() using the swizzle utils. Reviewed-by: Matt Turner URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=eb9bd3a1b0d6c518f9a38d81c0729feb38474f5a Author: Francisco Jerez Date: Thu Mar 19 16:03:57 2015 +0200 i965: Fix signedness of backend_reg::reg_offset. And make it 16-bit so it packs nicely with the previous field. Reviewed-by: Matt Turner URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=7e816c7feb8cffa878546eee363240b1b66d5c42 Author: Francisco Jerez Date: Wed Mar 18 15:24:06 2015 +0200 i965/vec4: Fix signedness of dst_reg::writemask. Reviewed-by: Matt Turner URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=7678fb9c639f25313f3ae2e2b539e424370d3ec6 Author: Francisco Jerez Date: Wed Mar 18 15:22:52 2015 +0200 i965/vec4: Don't use GL types in the IR data structures. Reviewed-by: Matt Turner URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=7bc02c786df437024e2a8582192a66ddb5e40624 Author: Francisco Jerez Date: Wed Mar 18 14:32:37 2015 +0200 i965/vec4: Fix signedness of brw_is_single_value_swizzle() argument. Reviewed-by: Matt Turner URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=cff670b009ee8c8a60d1551148bf02038824507b Author: Francisco Jerez Date: Wed Mar 18 14:34:51 2015 +0200 i965: Define some useful swizzle helper functions. This defines helper functions implementing some common swizzle transformations that are usually open-coded in the compiler back-end, causing a lot of clutter. Some optimization passes will become almost trivial implemented in terms of these functions (e.g. vec4_visitor::opt_reduce_swizzle()). Reviewed-by: Matt Turner From tstellar at kemper.freedesktop.org Mon Mar 23 14:33:08 2015 From: tstellar at kemper.freedesktop.org (Tom Stellard) Date: Mon, 23 Mar 2015 07:33:08 -0700 (PDT) Subject: Mesa (master): clover: Add a space at the end of CL_DEVICE_OPENCL_C_VERSION Message-ID: <20150323143308.26CC576336@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 96f9cc9181403a93208cb44786c485ce44492eda URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=96f9cc9181403a93208cb44786c485ce44492eda Author: Tom Stellard Date: Fri Mar 20 23:55:58 2015 +0000 clover: Add a space at the end of CL_DEVICE_OPENCL_C_VERSION This is required by the spec. Reviewed-by: Jan Vesely Reviewed-by: Francisco Jerez --- src/gallium/state_trackers/clover/api/device.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gallium/state_trackers/clover/api/device.cpp b/src/gallium/state_trackers/clover/api/device.cpp index 5d1f4ab..04f293d 100644 --- a/src/gallium/state_trackers/clover/api/device.cpp +++ b/src/gallium/state_trackers/clover/api/device.cpp @@ -341,7 +341,7 @@ clGetDeviceInfo(cl_device_id d_dev, cl_device_info param, break; case CL_DEVICE_OPENCL_C_VERSION: - buf.as_string() = "OpenCL C 1.1"; + buf.as_string() = "OpenCL C 1.1 "; break; case CL_DEVICE_PARENT_DEVICE: From tstellar at kemper.freedesktop.org Mon Mar 23 14:33:08 2015 From: tstellar at kemper.freedesktop.org (Tom Stellard) Date: Mon, 23 Mar 2015 07:33:08 -0700 (PDT) Subject: Mesa (master): clover: Add all the mandatory 1.1 extensions to the extension string Message-ID: <20150323143308.3112B7635A@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 2b12b1752ae18c468cb01e94c78544ca5783dc44 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=2b12b1752ae18c468cb01e94c78544ca5783dc44 Author: Tom Stellard Date: Sat Mar 21 00:25:34 2015 +0000 clover: Add all the mandatory 1.1 extensions to the extension string Reviewed-by: Jan Vesely Reviewed-by: Francisco Jerez --- src/gallium/state_trackers/clover/api/device.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/gallium/state_trackers/clover/api/device.cpp b/src/gallium/state_trackers/clover/api/device.cpp index 04f293d..43e7475 100644 --- a/src/gallium/state_trackers/clover/api/device.cpp +++ b/src/gallium/state_trackers/clover/api/device.cpp @@ -301,7 +301,13 @@ clGetDeviceInfo(cl_device_id d_dev, cl_device_info param, break; case CL_DEVICE_EXTENSIONS: - buf.as_string() = dev.has_doubles() ? "cl_khr_fp64" : ""; + buf.as_string() = + "cl_khr_global_int32_base_atomics" + " cl_khr_global_int32_extended_atomics" + " cl_khr_local_int32_base_atomics" + " cl_khr_local_int32_extended_atomics" + " cl_khr_byte_addressable_store" + + std::string(dev.has_doubles() ? " cl_khr_fp64" : ""); break; case CL_DEVICE_PLATFORM: From tstellar at kemper.freedesktop.org Mon Mar 23 14:33:08 2015 From: tstellar at kemper.freedesktop.org (Tom Stellard) Date: Mon, 23 Mar 2015 07:33:08 -0700 (PDT) Subject: Mesa (master): gallium: remove trailing whitespace in p_screen.h Message-ID: <20150323143308.4849E76336@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 9280f17e823cbdbddf30a4ae5e2de9f2d327d33c URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=9280f17e823cbdbddf30a4ae5e2de9f2d327d33c Author: Giuseppe Bilotta Date: Sun Mar 22 07:20:59 2015 +0100 gallium: remove trailing whitespace in p_screen.h Signed-off-by: Giuseppe Bilotta Reviewed-by: Michel D?nzer --- src/gallium/include/pipe/p_screen.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gallium/include/pipe/p_screen.h b/src/gallium/include/pipe/p_screen.h index ac88506..4018f8a 100644 --- a/src/gallium/include/pipe/p_screen.h +++ b/src/gallium/include/pipe/p_screen.h @@ -147,7 +147,7 @@ struct pipe_screen { */ boolean (*can_create_resource)(struct pipe_screen *screen, const struct pipe_resource *templat); - + /** * Create a new texture object, using the given template info. */ From tstellar at kemper.freedesktop.org Mon Mar 23 14:33:08 2015 From: tstellar at kemper.freedesktop.org (Tom Stellard) Date: Mon, 23 Mar 2015 07:33:08 -0700 (PDT) Subject: Mesa (master): clover: The unit for CL_DEVICE_MEM_BASE_ADDR_ALIGN is bits not bytes Message-ID: <20150323143308.3CB797635B@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 6e17936bf84c286c3540fe559838bc2a4d975539 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=6e17936bf84c286c3540fe559838bc2a4d975539 Author: Tom Stellard Date: Sat Mar 21 00:44:47 2015 +0000 clover: The unit for CL_DEVICE_MEM_BASE_ADDR_ALIGN is bits not bytes Reviewed-by: Jan Vesely Reviewed-by: Francisco Jerez --- src/gallium/state_trackers/clover/api/device.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/gallium/state_trackers/clover/api/device.cpp b/src/gallium/state_trackers/clover/api/device.cpp index 43e7475..bc93f91 100644 --- a/src/gallium/state_trackers/clover/api/device.cpp +++ b/src/gallium/state_trackers/clover/api/device.cpp @@ -196,6 +196,9 @@ clGetDeviceInfo(cl_device_id d_dev, cl_device_info param, break; case CL_DEVICE_MEM_BASE_ADDR_ALIGN: + buf.as_scalar() = 128 * 8; + break; + case CL_DEVICE_MIN_DATA_TYPE_ALIGN_SIZE: buf.as_scalar() = 128; break; From tstellar at kemper.freedesktop.org Mon Mar 23 14:33:08 2015 From: tstellar at kemper.freedesktop.org (Tom Stellard) Date: Mon, 23 Mar 2015 07:33:08 -0700 (PDT) Subject: Mesa (master): gallium: introduce get_device_vendor() entrypoint for pipes Message-ID: <20150323143308.561C476336@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 31d4e6fbffb0c5bcaf92e2c2953f58dc072295d6 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=31d4e6fbffb0c5bcaf92e2c2953f58dc072295d6 Author: Giuseppe Bilotta Date: Sun Mar 22 07:21:00 2015 +0100 gallium: introduce get_device_vendor() entrypoint for pipes This will be needed by Clover to return the correct information to CL_DEVICE_VENDOR info queries. Signed-off-by: Giuseppe Bilotta Reviewed-by: Michel D?nzer --- src/gallium/docs/source/screen.rst | 6 ++++++ src/gallium/include/pipe/p_screen.h | 8 ++++++++ 2 files changed, 14 insertions(+) diff --git a/src/gallium/docs/source/screen.rst b/src/gallium/docs/source/screen.rst index 26cc9ff..4386bcf 100644 --- a/src/gallium/docs/source/screen.rst +++ b/src/gallium/docs/source/screen.rst @@ -462,6 +462,12 @@ get_vendor Returns the screen vendor. +get_device_vendor +^^^^^^^^^^^^^^^^^ + +Returns the actual vendor of the device driving the screen +(as opposed to the driver vendor). + .. _get_param: get_param diff --git a/src/gallium/include/pipe/p_screen.h b/src/gallium/include/pipe/p_screen.h index 4018f8a..21e7dd3 100644 --- a/src/gallium/include/pipe/p_screen.h +++ b/src/gallium/include/pipe/p_screen.h @@ -72,6 +72,14 @@ struct pipe_screen { const char *(*get_vendor)( struct pipe_screen * ); /** + * Returns the device vendor. + * + * The returned value should return the actual device vendor/manufacturer, + * rather than a potentially generic driver string. + */ + const char *(*get_device_vendor)( struct pipe_screen * ); + + /** * Query an integer-valued capability/parameter/limit * \param param one of PIPE_CAP_x */ From tstellar at kemper.freedesktop.org Mon Mar 23 14:33:08 2015 From: tstellar at kemper.freedesktop.org (Tom Stellard) Date: Mon, 23 Mar 2015 07:33:08 -0700 (PDT) Subject: Mesa (master): gallium: implement get_device_vendor() for existing drivers Message-ID: <20150323143308.686A876336@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 76039b38f0ef54ca61cbe72b899dfcf0f0c724e4 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=76039b38f0ef54ca61cbe72b899dfcf0f0c724e4 Author: Giuseppe Bilotta Date: Sun Mar 22 07:21:01 2015 +0100 gallium: implement get_device_vendor() for existing drivers The only hackish ones are llvmpipe and softpipe, which currently return the same string as for get_vendor(), while ideally they should return the CPU vendor. Signed-off-by: Giuseppe Bilotta Reviewed-by: Tom Stellard --- src/gallium/drivers/freedreno/freedreno_screen.c | 8 ++++++++ src/gallium/drivers/i915/i915_screen.c | 7 +++++++ src/gallium/drivers/ilo/ilo_screen.c | 7 +++++++ src/gallium/drivers/llvmpipe/lp_screen.c | 1 + src/gallium/drivers/noop/noop_pipe.c | 6 ++++++ src/gallium/drivers/nouveau/nouveau_screen.c | 7 +++++++ src/gallium/drivers/r300/r300_screen.c | 6 ++++++ src/gallium/drivers/radeon/r600_pipe_common.c | 6 ++++++ src/gallium/drivers/rbug/rbug_screen.c | 10 ++++++++++ src/gallium/drivers/softpipe/sp_screen.c | 1 + src/gallium/drivers/svga/svga_screen.c | 1 + src/gallium/drivers/trace/tr_screen.c | 22 ++++++++++++++++++++++ src/gallium/drivers/vc4/vc4_screen.c | 1 + 13 files changed, 83 insertions(+) diff --git a/src/gallium/drivers/freedreno/freedreno_screen.c b/src/gallium/drivers/freedreno/freedreno_screen.c index cdcc0da..1e47089 100644 --- a/src/gallium/drivers/freedreno/freedreno_screen.c +++ b/src/gallium/drivers/freedreno/freedreno_screen.c @@ -95,6 +95,13 @@ fd_screen_get_vendor(struct pipe_screen *pscreen) return "freedreno"; } +static const char * +fd_screen_get_device_vendor(struct pipe_screen *pscreen) +{ + return "Qualcomm"; +} + + static uint64_t fd_screen_get_timestamp(struct pipe_screen *pscreen) { @@ -531,6 +538,7 @@ fd_screen_create(struct fd_device *dev) pscreen->get_name = fd_screen_get_name; pscreen->get_vendor = fd_screen_get_vendor; + pscreen->get_device_vendor = fd_screen_get_device_vendor; pscreen->get_timestamp = fd_screen_get_timestamp; diff --git a/src/gallium/drivers/i915/i915_screen.c b/src/gallium/drivers/i915/i915_screen.c index 50847e2..7216160 100644 --- a/src/gallium/drivers/i915/i915_screen.c +++ b/src/gallium/drivers/i915/i915_screen.c @@ -55,6 +55,12 @@ i915_get_vendor(struct pipe_screen *screen) } static const char * +i915_get_device_vendor(struct pipe_screen *screen) +{ + return "Intel"; +} + +static const char * i915_get_name(struct pipe_screen *screen) { static char buffer[128]; @@ -548,6 +554,7 @@ i915_screen_create(struct i915_winsys *iws) is->base.get_name = i915_get_name; is->base.get_vendor = i915_get_vendor; + is->base.get_device_vendor = i915_get_device_vendor; is->base.get_param = i915_get_param; is->base.get_shader_param = i915_get_shader_param; is->base.get_paramf = i915_get_paramf; diff --git a/src/gallium/drivers/ilo/ilo_screen.c b/src/gallium/drivers/ilo/ilo_screen.c index bf0a84a..80ea4c7 100644 --- a/src/gallium/drivers/ilo/ilo_screen.c +++ b/src/gallium/drivers/ilo/ilo_screen.c @@ -515,6 +515,12 @@ ilo_get_vendor(struct pipe_screen *screen) } static const char * +ilo_get_device_vendor(struct pipe_screen *screen) +{ + return "Intel"; +} + +static const char * ilo_get_name(struct pipe_screen *screen) { struct ilo_screen *is = ilo_screen(screen); @@ -844,6 +850,7 @@ ilo_screen_create(struct intel_winsys *ws) is->base.destroy = ilo_screen_destroy; is->base.get_name = ilo_get_name; is->base.get_vendor = ilo_get_vendor; + is->base.get_device_vendor = ilo_get_device_vendor; is->base.get_param = ilo_get_param; is->base.get_paramf = ilo_get_paramf; is->base.get_shader_param = ilo_get_shader_param; diff --git a/src/gallium/drivers/llvmpipe/lp_screen.c b/src/gallium/drivers/llvmpipe/lp_screen.c index 3387d3a..4b45725 100644 --- a/src/gallium/drivers/llvmpipe/lp_screen.c +++ b/src/gallium/drivers/llvmpipe/lp_screen.c @@ -589,6 +589,7 @@ llvmpipe_create_screen(struct sw_winsys *winsys) screen->base.get_name = llvmpipe_get_name; screen->base.get_vendor = llvmpipe_get_vendor; + screen->base.get_device_vendor = llvmpipe_get_vendor; // TODO should be the CPU vendor screen->base.get_param = llvmpipe_get_param; screen->base.get_shader_param = llvmpipe_get_shader_param; screen->base.get_paramf = llvmpipe_get_paramf; diff --git a/src/gallium/drivers/noop/noop_pipe.c b/src/gallium/drivers/noop/noop_pipe.c index 8cb8c70..6fb2277 100644 --- a/src/gallium/drivers/noop/noop_pipe.c +++ b/src/gallium/drivers/noop/noop_pipe.c @@ -305,6 +305,11 @@ static const char *noop_get_vendor(struct pipe_screen* pscreen) return "X.Org"; } +static const char *noop_get_device_vendor(struct pipe_screen* pscreen) +{ + return "NONE"; +} + static const char *noop_get_name(struct pipe_screen* pscreen) { return "NOOP"; @@ -376,6 +381,7 @@ struct pipe_screen *noop_screen_create(struct pipe_screen *oscreen) screen->destroy = noop_destroy_screen; screen->get_name = noop_get_name; screen->get_vendor = noop_get_vendor; + screen->get_device_vendor = noop_get_device_vendor; screen->get_param = noop_get_param; screen->get_shader_param = noop_get_shader_param; screen->get_paramf = noop_get_paramf; diff --git a/src/gallium/drivers/nouveau/nouveau_screen.c b/src/gallium/drivers/nouveau/nouveau_screen.c index 517978d..b4f1413 100644 --- a/src/gallium/drivers/nouveau/nouveau_screen.c +++ b/src/gallium/drivers/nouveau/nouveau_screen.c @@ -43,6 +43,12 @@ nouveau_screen_get_vendor(struct pipe_screen *pscreen) return "nouveau"; } +static const char * +nouveau_screen_get_device_vendor(struct pipe_screen *pscreen) +{ + return "NVIDIA"; +} + static uint64_t nouveau_screen_get_timestamp(struct pipe_screen *pscreen) { @@ -182,6 +188,7 @@ nouveau_screen_init(struct nouveau_screen *screen, struct nouveau_device *dev) pscreen->get_name = nouveau_screen_get_name; pscreen->get_vendor = nouveau_screen_get_vendor; + pscreen->get_device_vendor = nouveau_screen_get_device_vendor; pscreen->get_timestamp = nouveau_screen_get_timestamp; diff --git a/src/gallium/drivers/r300/r300_screen.c b/src/gallium/drivers/r300/r300_screen.c index 752d7e5..a7b59d8 100644 --- a/src/gallium/drivers/r300/r300_screen.c +++ b/src/gallium/drivers/r300/r300_screen.c @@ -47,6 +47,11 @@ static const char* r300_get_vendor(struct pipe_screen* pscreen) return "X.Org R300 Project"; } +static const char* r300_get_device_vendor(struct pipe_screen* pscreen) +{ + return "ATI"; +} + static const char* chip_families[] = { "unknown", "ATI R300", @@ -695,6 +700,7 @@ struct pipe_screen* r300_screen_create(struct radeon_winsys *rws) r300screen->screen.destroy = r300_destroy_screen; r300screen->screen.get_name = r300_get_name; r300screen->screen.get_vendor = r300_get_vendor; + r300screen->screen.get_device_vendor = r300_get_device_vendor; r300screen->screen.get_param = r300_get_param; r300screen->screen.get_shader_param = r300_get_shader_param; r300screen->screen.get_paramf = r300_get_paramf; diff --git a/src/gallium/drivers/radeon/r600_pipe_common.c b/src/gallium/drivers/radeon/r600_pipe_common.c index dabe53c..0ef5fc2 100644 --- a/src/gallium/drivers/radeon/r600_pipe_common.c +++ b/src/gallium/drivers/radeon/r600_pipe_common.c @@ -332,6 +332,11 @@ static const char* r600_get_vendor(struct pipe_screen* pscreen) return "X.Org"; } +static const char* r600_get_device_vendor(struct pipe_screen* pscreen) +{ + return "AMD"; +} + static const char* r600_get_name(struct pipe_screen* pscreen) { struct r600_common_screen *rscreen = (struct r600_common_screen*)pscreen; @@ -825,6 +830,7 @@ bool r600_common_screen_init(struct r600_common_screen *rscreen, rscreen->b.get_name = r600_get_name; rscreen->b.get_vendor = r600_get_vendor; + rscreen->b.get_device_vendor = r600_get_device_vendor; rscreen->b.get_compute_param = r600_get_compute_param; rscreen->b.get_paramf = r600_get_paramf; rscreen->b.get_driver_query_info = r600_get_driver_query_info; diff --git a/src/gallium/drivers/rbug/rbug_screen.c b/src/gallium/drivers/rbug/rbug_screen.c index 731cc60..d5a3164 100644 --- a/src/gallium/drivers/rbug/rbug_screen.c +++ b/src/gallium/drivers/rbug/rbug_screen.c @@ -68,6 +68,15 @@ rbug_screen_get_vendor(struct pipe_screen *_screen) return screen->get_vendor(screen); } +static const char * +rbug_screen_get_device_vendor(struct pipe_screen *_screen) +{ + struct rbug_screen *rb_screen = rbug_screen(_screen); + struct pipe_screen *screen = rb_screen->screen; + + return screen->get_device_vendor(screen); +} + static int rbug_screen_get_param(struct pipe_screen *_screen, enum pipe_cap param) @@ -267,6 +276,7 @@ rbug_screen_create(struct pipe_screen *screen) rb_screen->base.destroy = rbug_screen_destroy; rb_screen->base.get_name = rbug_screen_get_name; rb_screen->base.get_vendor = rbug_screen_get_vendor; + rb_screen->base.get_device_vendor = rbug_screen_get_device_vendor; rb_screen->base.get_param = rbug_screen_get_param; rb_screen->base.get_shader_param = rbug_screen_get_shader_param; rb_screen->base.get_paramf = rbug_screen_get_paramf; diff --git a/src/gallium/drivers/softpipe/sp_screen.c b/src/gallium/drivers/softpipe/sp_screen.c index a269328..d289e28 100644 --- a/src/gallium/drivers/softpipe/sp_screen.c +++ b/src/gallium/drivers/softpipe/sp_screen.c @@ -427,6 +427,7 @@ softpipe_create_screen(struct sw_winsys *winsys) screen->base.get_name = softpipe_get_name; screen->base.get_vendor = softpipe_get_vendor; + screen->base.get_device_vendor = softpipe_get_vendor; // TODO should be the CPU vendor screen->base.get_param = softpipe_get_param; screen->base.get_shader_param = softpipe_get_shader_param; screen->base.get_paramf = softpipe_get_paramf; diff --git a/src/gallium/drivers/svga/svga_screen.c b/src/gallium/drivers/svga/svga_screen.c index 7b01d35..ab26413 100644 --- a/src/gallium/drivers/svga/svga_screen.c +++ b/src/gallium/drivers/svga/svga_screen.c @@ -635,6 +635,7 @@ svga_screen_create(struct svga_winsys_screen *sws) screen->destroy = svga_destroy_screen; screen->get_name = svga_get_name; screen->get_vendor = svga_get_vendor; + screen->get_device_vendor = svga_get_vendor; // TODO actual device vendor screen->get_param = svga_get_param; screen->get_shader_param = svga_get_shader_param; screen->get_paramf = svga_get_paramf; diff --git a/src/gallium/drivers/trace/tr_screen.c b/src/gallium/drivers/trace/tr_screen.c index 3a82cc4..266626d 100644 --- a/src/gallium/drivers/trace/tr_screen.c +++ b/src/gallium/drivers/trace/tr_screen.c @@ -82,6 +82,27 @@ trace_screen_get_vendor(struct pipe_screen *_screen) } +static const char * +trace_screen_get_device_vendor(struct pipe_screen *_screen) +{ + struct trace_screen *tr_scr = trace_screen(_screen); + struct pipe_screen *screen = tr_scr->screen; + const char *result; + + trace_dump_call_begin("pipe_screen", "get_device_vendor"); + + trace_dump_arg(ptr, screen); + + result = screen->get_device_vendor(screen); + + trace_dump_ret(string, result); + + trace_dump_call_end(); + + return result; +} + + static int trace_screen_get_param(struct pipe_screen *_screen, enum pipe_cap param) @@ -470,6 +491,7 @@ trace_screen_create(struct pipe_screen *screen) tr_scr->base.destroy = trace_screen_destroy; tr_scr->base.get_name = trace_screen_get_name; tr_scr->base.get_vendor = trace_screen_get_vendor; + tr_scr->base.get_device_vendor = trace_screen_get_device_vendor; tr_scr->base.get_param = trace_screen_get_param; tr_scr->base.get_shader_param = trace_screen_get_shader_param; tr_scr->base.get_paramf = trace_screen_get_paramf; diff --git a/src/gallium/drivers/vc4/vc4_screen.c b/src/gallium/drivers/vc4/vc4_screen.c index 0be8ec2..03dd865 100644 --- a/src/gallium/drivers/vc4/vc4_screen.c +++ b/src/gallium/drivers/vc4/vc4_screen.c @@ -472,6 +472,7 @@ vc4_screen_create(int fd) pscreen->get_name = vc4_screen_get_name; pscreen->get_vendor = vc4_screen_get_vendor; + pscreen->get_device_vendor = vc4_screen_get_vendor; return pscreen; } From tstellar at kemper.freedesktop.org Mon Mar 23 14:33:08 2015 From: tstellar at kemper.freedesktop.org (Tom Stellard) Date: Mon, 23 Mar 2015 07:33:08 -0700 (PDT) Subject: Mesa (master): clover: use get_device_vendor instead of get_vendor Message-ID: <20150323143308.752EB7635A@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 7932b30892ef898ec4c74ac1f972cb462f19962b URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=7932b30892ef898ec4c74ac1f972cb462f19962b Author: Giuseppe Bilotta Date: Sun Mar 22 07:21:02 2015 +0100 clover: use get_device_vendor instead of get_vendor The pipe's get_vendor method returns something more akin to a driver vendor string in most cases, instead of the actual device vendor. Use get_device_vendor instead, which was introduced specifically for this purpose. Signed-off-by: Giuseppe Bilotta Reviewed-by: Michel D?nzer Reviewed-by: Francisco Jerez --- src/gallium/state_trackers/clover/core/device.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gallium/state_trackers/clover/core/device.cpp b/src/gallium/state_trackers/clover/core/device.cpp index c3f3b4e..42b45b7 100644 --- a/src/gallium/state_trackers/clover/core/device.cpp +++ b/src/gallium/state_trackers/clover/core/device.cpp @@ -192,7 +192,7 @@ device::device_name() const { std::string device::vendor_name() const { - return pipe->get_vendor(pipe); + return pipe->get_device_vendor(pipe); } enum pipe_shader_ir From tstellar at kemper.freedesktop.org Mon Mar 23 15:49:04 2015 From: tstellar at kemper.freedesktop.org (Tom Stellard) Date: Mon, 23 Mar 2015 08:49:04 -0700 (PDT) Subject: Mesa (master): gallivm: Use MCInstrInfo in the disassembler for querying instruction info Message-ID: <20150323154904.BF3AE76336@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 769b366b83dcc12bfe06935f816023cdcfbdf578 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=769b366b83dcc12bfe06935f816023cdcfbdf578 Author: Tom Stellard Date: Mon Mar 23 14:37:24 2015 +0000 gallivm: Use MCInstrInfo in the disassembler for querying instruction info This fixes the build since llvm r232885 and also simplifies the code. --- src/gallium/auxiliary/gallivm/lp_bld_debug.cpp | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/gallium/auxiliary/gallivm/lp_bld_debug.cpp b/src/gallium/auxiliary/gallivm/lp_bld_debug.cpp index 2c4ed21..bf6268b 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_debug.cpp +++ b/src/gallium/auxiliary/gallivm/lp_bld_debug.cpp @@ -276,12 +276,6 @@ disassemble(const void* func, llvm::raw_ostream & Out) #endif OwningPtr TM(T->createTargetMachine(Triple, sys::getHostCPUName(), "", options)); -#if HAVE_LLVM >= 0x0306 - const TargetInstrInfo *TII = TM->getSubtargetImpl()->getInstrInfo(); -#else - const TargetInstrInfo *TII = TM->getInstrInfo(); -#endif - /* * Wrap the data in a MemoryObject */ @@ -336,7 +330,7 @@ disassemble(const void* func, llvm::raw_ostream & Out) pc += Size; - const MCInstrDesc &TID = TII->get(Inst.getOpcode()); + const MCInstrDesc &TID = MII->get(Inst.getOpcode()); /* * Keep track of forward jumps to a nearby address. From tstellar at kemper.freedesktop.org Mon Mar 23 18:25:51 2015 From: tstellar at kemper.freedesktop.org (Tom Stellard) Date: Mon, 23 Mar 2015 11:25:51 -0700 (PDT) Subject: Mesa (master): clover: Return 0 as storage size for local kernel args that are not set v2 Message-ID: <20150323182551.1EDFE76336@kemper.freedesktop.org> Module: Mesa Branch: master Commit: dfb1ae9d914b7723ef50fdd2efe811feebc045ad URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=dfb1ae9d914b7723ef50fdd2efe811feebc045ad Author: Tom Stellard Date: Fri Mar 20 22:19:43 2015 +0000 clover: Return 0 as storage size for local kernel args that are not set v2 The storage size for local kernel args can be queried before the arguments are set by using the CL_KERNEL_LOCAL_MEM_SIZE param of clGetKernelWorkGroupInfo(). The spec says that if local kernel arguments have not been specified, then we should assume their size is 0. v2: - Implement using c++11 member initialization. Reviewed-by: Jan Vesely Reviewed-by: Francisco Jerez Cc: 10.5 10.4 --- src/gallium/state_trackers/clover/core/kernel.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gallium/state_trackers/clover/core/kernel.hpp b/src/gallium/state_trackers/clover/core/kernel.hpp index bf5998d..d6432a4 100644 --- a/src/gallium/state_trackers/clover/core/kernel.hpp +++ b/src/gallium/state_trackers/clover/core/kernel.hpp @@ -175,7 +175,7 @@ namespace clover { virtual void unbind(exec_context &ctx); private: - size_t _storage; + size_t _storage = 0; }; class constant_argument : public argument { From evelikov at kemper.freedesktop.org Mon Mar 23 22:17:27 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Mon, 23 Mar 2015 15:17:27 -0700 (PDT) Subject: Mesa (master): mapi: Make private copies of name strings provided by client. Message-ID: <20150323221727.928F676336@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 1110113a7f0b6f9b21dd26dee8e95a021041c71c URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=1110113a7f0b6f9b21dd26dee8e95a021041c71c Author: Mario Kleiner Date: Thu Mar 12 23:34:12 2015 +0100 mapi: Make private copies of name strings provided by client. glXGetProcAddress("glFoo") ends up in stub_add_dynamic() to create dynamic stubs for dynamic functions. stub_add_dynamic() doesn't store the caller provided name string "Foo" in a mesa private copy, but just stores a pointer to the "glFoo" string passed to glXGetProcAddress - a pointer into arbitrary memory outside mesa's control. If the caller passes some dynamically allocated/changing memory buffer to glXGetProcAddress(), or the caller gets unmapped from memory, e.g., some dynamically loaded application plugin which uses OpenGL, this ends badly - with a dangling pointer. strdup() the name string provided by the client to avoid this problem. Cc: "10.3 10.4 10.5" Signed-off-by: Mario Kleiner Reviewed-by: Brian Paul --- src/mapi/stub.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mapi/stub.c b/src/mapi/stub.c index 05436ba..45e4f7d 100644 --- a/src/mapi/stub.c +++ b/src/mapi/stub.c @@ -102,7 +102,7 @@ stub_add_dynamic(const char *name) if (!stub->addr) return NULL; - stub->name = (const void *) name; + stub->name = (const void *) strdup(name); /* to be fixed later */ stub->slot = -1; From imirkin at kemper.freedesktop.org Tue Mar 24 00:59:31 2015 From: imirkin at kemper.freedesktop.org (Ilia Mirkin) Date: Mon, 23 Mar 2015 17:59:31 -0700 (PDT) Subject: Mesa (master): Revert "nv50,nvc0: remove bogus 64_FLOAT formats" Message-ID: <20150324005931.3F25476336@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 43277fcd59b163a8bdd00d7875557bb71ecf48ff URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=43277fcd59b163a8bdd00d7875557bb71ecf48ff Author: Ilia Mirkin Date: Mon Mar 23 20:53:19 2015 -0400 Revert "nv50,nvc0: remove bogus 64_FLOAT formats" This reverts commit 20346808cf4f1ee4f320afaf18f94043fb146f2e. The conversion is actually done since these are the *B macro variants and no vtx format is supplied, which makes them go through the translate module. This restores the following piglit tests to passing: draw-vertices user gl-2.0-vertexattribpointer Signed-off-by: Ilia Mirkin --- src/gallium/drivers/nouveau/nv50/nv50_formats.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/gallium/drivers/nouveau/nv50/nv50_formats.c b/src/gallium/drivers/nouveau/nv50/nv50_formats.c index 6a1b11c..0f86ba1 100644 --- a/src/gallium/drivers/nouveau/nv50/nv50_formats.c +++ b/src/gallium/drivers/nouveau/nv50/nv50_formats.c @@ -436,4 +436,9 @@ const struct nv50_format nv50_format_table[PIPE_FORMAT_COUNT] = F3B(R32G32B32_FIXED, NONE, C0, C1, C2, xx, FLOAT, 32_32_32, V), F2B(R32G32_FIXED, NONE, C0, C1, xx, xx, FLOAT, 32_32, V), F1B(R32_FIXED, NONE, C0, xx, xx, xx, FLOAT, 32, V), + + C4B(R64G64B64A64_FLOAT, NONE, C0, C1, C2, C3, FLOAT, 32_32_32_32, V), + F3B(R64G64B64_FLOAT, NONE, C0, C1, C2, xx, FLOAT, 32_32_32, V), + F2B(R64G64_FLOAT, NONE, C0, C1, xx, xx, FLOAT, 32_32, V), + F1B(R64_FLOAT, NONE, C0, xx, xx, xx, FLOAT, 32, V), }; From imirkin at kemper.freedesktop.org Tue Mar 24 14:11:42 2015 From: imirkin at kemper.freedesktop.org (Ilia Mirkin) Date: Tue, 24 Mar 2015 07:11:42 -0700 (PDT) Subject: Mesa (master): glsl: avoid calling base_alignment when samplers are involved Message-ID: <20150324141143.0199376332@kemper.freedesktop.org> Module: Mesa Branch: master Commit: baa22c8825133a69fd0657f09d2a027236233eb1 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=baa22c8825133a69fd0657f09d2a027236233eb1 Author: Ilia Mirkin Date: Mon Mar 23 06:32:08 2015 -0400 glsl: avoid calling base_alignment when samplers are involved Earlier commit 53bf7c8fd2e changed the logic to always call base_alignment on structs. 1ec715ce8b12 hacked the function to return 0 for sampler fields, but didn't handle sampler arrays. Instead of extending the hack, avoid calling base_alignment in the first place on non-UBO uniforms. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=89726 Signed-off-by: Ilia Mirkin Reviewed-by: Tapani Palli --- src/glsl/glsl_types.cpp | 9 --------- src/glsl/link_uniforms.cpp | 4 ++++ 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/src/glsl/glsl_types.cpp b/src/glsl/glsl_types.cpp index 38b37a6..be87b0a 100644 --- a/src/glsl/glsl_types.cpp +++ b/src/glsl/glsl_types.cpp @@ -1077,15 +1077,6 @@ glsl_type::std140_base_alignment(bool row_major) const return base_alignment; } - /* A sampler may never occur in a UBO (without bindless of some sort), - * however it is convenient to use this alignment function even with - * regular uniforms. This allows use of this function on uniform structs - * that contain samplers. - */ - if (this->is_sampler()) { - return 0; - } - assert(!"not reached"); return -1; } diff --git a/src/glsl/link_uniforms.cpp b/src/glsl/link_uniforms.cpp index 799c74b..59adc29 100644 --- a/src/glsl/link_uniforms.cpp +++ b/src/glsl/link_uniforms.cpp @@ -547,6 +547,8 @@ private: virtual void enter_record(const glsl_type *type, const char *name, bool row_major) { assert(type->is_record()); + if (this->ubo_block_index == -1) + return; this->ubo_byte_offset = glsl_align( this->ubo_byte_offset, type->std140_base_alignment(row_major)); } @@ -554,6 +556,8 @@ private: virtual void leave_record(const glsl_type *type, const char *name, bool row_major) { assert(type->is_record()); + if (this->ubo_block_index == -1) + return; this->ubo_byte_offset = glsl_align( this->ubo_byte_offset, type->std140_base_alignment(row_major)); } From anholt at kemper.freedesktop.org Tue Mar 24 17:39:47 2015 From: anholt at kemper.freedesktop.org (Eric Anholt) Date: Tue, 24 Mar 2015 10:39:47 -0700 (PDT) Subject: Mesa (master): vc4: Add some useful debug printfs for miptrees. Message-ID: <20150324173947.D2A9F76332@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 9bafcf630ab009b3b39bbe3c0f4370386bc5a6b2 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=9bafcf630ab009b3b39bbe3c0f4370386bc5a6b2 Author: Eric Anholt Date: Mon Mar 23 17:38:29 2015 -0700 vc4: Add some useful debug printfs for miptrees. I keep rewriting these. --- src/gallium/drivers/vc4/vc4_resource.c | 37 ++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/src/gallium/drivers/vc4/vc4_resource.c b/src/gallium/drivers/vc4/vc4_resource.c index a26b346..b8efa0d 100644 --- a/src/gallium/drivers/vc4/vc4_resource.c +++ b/src/gallium/drivers/vc4/vc4_resource.c @@ -33,12 +33,24 @@ #include "vc4_resource.h" #include "vc4_tiling.h" +static bool miptree_debug = false; + static void vc4_resource_bo_alloc(struct vc4_resource *rsc) { struct pipe_resource *prsc = &rsc->base.b; struct pipe_screen *pscreen = prsc->screen; + if (miptree_debug) { + fprintf(stderr, "alloc %p: size %d + offset %d -> %d\n", + rsc, + rsc->slices[0].size, + rsc->slices[0].offset, + rsc->slices[0].offset + + rsc->slices[0].size + + rsc->cube_map_stride * (prsc->array_size - 1)); + } + vc4_bo_unreference(&rsc->bo); rsc->bo = vc4_bo_alloc(vc4_screen(pscreen), rsc->slices[0].offset + @@ -267,6 +279,22 @@ vc4_setup_slices(struct vc4_resource *rsc) slice->size = level_height * slice->stride; offset += slice->size; + + if (miptree_debug) { + static const char tiling_chars[] = { + [VC4_TILING_FORMAT_LINEAR] = 'R', + [VC4_TILING_FORMAT_LT] = 'L', + [VC4_TILING_FORMAT_T] = 'T' + }; + fprintf(stderr, + "rsc setup %p (format %d), %dx%d: " + "level %d (%c) -> %dx%d, stride %d at 0x%08x\n", + rsc, rsc->vc4_format, + prsc->width0, prsc->height0, + i, tiling_chars[slice->tiling], + level_width, level_height, + slice->stride, slice->offset); + } } /* The texture base pointer that has to point to level 0 doesn't have @@ -385,6 +413,15 @@ vc4_resource_from_handle(struct pipe_screen *pscreen, rsc->vc4_format = get_resource_texture_format(prsc); + if (miptree_debug) { + fprintf(stderr, + "rsc import %p (format %d), %dx%d: " + "level 0 (R) -> stride %d at 0x%08x\n", + rsc, rsc->vc4_format, + prsc->width0, prsc->height0, + slice->stride, slice->offset); + } + return prsc; fail: From anholt at kemper.freedesktop.org Tue Mar 24 17:39:47 2015 From: anholt at kemper.freedesktop.org (Eric Anholt) Date: Tue, 24 Mar 2015 10:39:47 -0700 (PDT) Subject: Mesa (master): vc4: Make a new #define for making code conditional on the simulator. Message-ID: <20150324173947.DC8B476332@kemper.freedesktop.org> Module: Mesa Branch: master Commit: af3d7471943d54e692f2dd7448321a4f96e56ed2 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=af3d7471943d54e692f2dd7448321a4f96e56ed2 Author: Eric Anholt Date: Mon Mar 23 17:26:40 2015 -0700 vc4: Make a new #define for making code conditional on the simulator. I'd like to compile as much of the device-specific code as possible when building for simulator, and using if (using_simulator) instead of ifdefs helps. --- src/gallium/drivers/vc4/vc4_bufmgr.c | 24 ++++++++++++++---------- src/gallium/drivers/vc4/vc4_context.h | 6 ++++++ src/gallium/drivers/vc4/vc4_resource.c | 10 +++++----- 3 files changed, 25 insertions(+), 15 deletions(-) diff --git a/src/gallium/drivers/vc4/vc4_bufmgr.c b/src/gallium/drivers/vc4/vc4_bufmgr.c index 8c5ee64..0077864 100644 --- a/src/gallium/drivers/vc4/vc4_bufmgr.c +++ b/src/gallium/drivers/vc4/vc4_bufmgr.c @@ -318,13 +318,19 @@ vc4_wait_seqno(struct vc4_screen *screen, uint64_t seqno, uint64_t timeout_ns) if (screen->finished_seqno >= seqno) return true; -#ifndef USE_VC4_SIMULATOR struct drm_vc4_wait_seqno wait; memset(&wait, 0, sizeof(wait)); wait.seqno = seqno; wait.timeout_ns = timeout_ns; - int ret = drmIoctl(screen->fd, DRM_IOCTL_VC4_WAIT_SEQNO, &wait); + int ret; + if (!using_vc4_simulator) + ret = drmIoctl(screen->fd, DRM_IOCTL_VC4_WAIT_SEQNO, &wait); + else { + wait.seqno = screen->finished_seqno; + ret = 0; + } + if (ret == -ETIME) { return false; } else if (ret != 0) { @@ -334,15 +340,11 @@ vc4_wait_seqno(struct vc4_screen *screen, uint64_t seqno, uint64_t timeout_ns) screen->finished_seqno = wait.seqno; return true; } -#else - return true; -#endif } bool vc4_bo_wait(struct vc4_bo *bo, uint64_t timeout_ns) { -#ifndef USE_VC4_SIMULATOR struct vc4_screen *screen = bo->screen; struct drm_vc4_wait_bo wait; @@ -350,7 +352,12 @@ vc4_bo_wait(struct vc4_bo *bo, uint64_t timeout_ns) wait.handle = bo->handle; wait.timeout_ns = timeout_ns; - int ret = drmIoctl(screen->fd, DRM_IOCTL_VC4_WAIT_BO, &wait); + int ret; + if (!using_vc4_simulator) + ret = drmIoctl(screen->fd, DRM_IOCTL_VC4_WAIT_BO, &wait); + else + ret = 0; + if (ret == -ETIME) { return false; } else if (ret != 0) { @@ -359,9 +366,6 @@ vc4_bo_wait(struct vc4_bo *bo, uint64_t timeout_ns) } else { return true; } -#else - return true; -#endif } void * diff --git a/src/gallium/drivers/vc4/vc4_context.h b/src/gallium/drivers/vc4/vc4_context.h index e3d797e..fa1cc43 100644 --- a/src/gallium/drivers/vc4/vc4_context.h +++ b/src/gallium/drivers/vc4/vc4_context.h @@ -38,6 +38,12 @@ #include "vc4_cl.h" #include "vc4_qir.h" +#ifdef USE_VC4_SIMULATOR +#define using_vc4_simulator true +#else +#define using_vc4_simulator false +#endif + #define VC4_DIRTY_BLEND (1 << 0) #define VC4_DIRTY_RASTERIZER (1 << 1) #define VC4_DIRTY_ZSA (1 << 2) diff --git a/src/gallium/drivers/vc4/vc4_resource.c b/src/gallium/drivers/vc4/vc4_resource.c index b8efa0d..0dda0d8 100644 --- a/src/gallium/drivers/vc4/vc4_resource.c +++ b/src/gallium/drivers/vc4/vc4_resource.c @@ -404,11 +404,11 @@ vc4_resource_from_handle(struct pipe_screen *pscreen, if (!rsc->bo) goto fail; -#ifdef USE_VC4_SIMULATOR - slice->stride = align(prsc->width0 * rsc->cpp, 16); -#else - slice->stride = handle->stride; -#endif + if (!using_vc4_simulator) + slice->stride = handle->stride; + else + slice->stride = align(prsc->width0 * rsc->cpp, 16); + slice->tiling = VC4_TILING_FORMAT_LINEAR; rsc->vc4_format = get_resource_texture_format(prsc); From anholt at kemper.freedesktop.org Tue Mar 24 17:39:47 2015 From: anholt at kemper.freedesktop.org (Eric Anholt) Date: Tue, 24 Mar 2015 10:39:47 -0700 (PDT) Subject: Mesa (master): vc4: Use our device-specific ioctls for create/mmap. Message-ID: <20150324173947.E61787635A@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 25d60763d9c2767c279f28ac2a7eddcd245f4259 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=25d60763d9c2767c279f28ac2a7eddcd245f4259 Author: Eric Anholt Date: Mon Mar 23 17:17:17 2015 -0700 vc4: Use our device-specific ioctls for create/mmap. They don't do anything special for us, but I've been told by kernel maintainers that relying on dumb for my acceleration-capable buffers is not OK. --- src/gallium/drivers/vc4/vc4_bufmgr.c | 51 ++++++++++++++++++++++++---------- 1 file changed, 36 insertions(+), 15 deletions(-) diff --git a/src/gallium/drivers/vc4/vc4_bufmgr.c b/src/gallium/drivers/vc4/vc4_bufmgr.c index 0077864..4bb2c71 100644 --- a/src/gallium/drivers/vc4/vc4_bufmgr.c +++ b/src/gallium/drivers/vc4/vc4_bufmgr.c @@ -65,6 +65,8 @@ struct vc4_bo * vc4_bo_alloc(struct vc4_screen *screen, uint32_t size, const char *name) { struct vc4_bo *bo; + int ret; + size = align(size, 4096); bo = vc4_bo_from_cache(screen, size, name); @@ -81,22 +83,31 @@ vc4_bo_alloc(struct vc4_screen *screen, uint32_t size, const char *name) bo->name = name; bo->private = true; - struct drm_mode_create_dumb create; - memset(&create, 0, sizeof(create)); + if (!using_vc4_simulator) { + struct drm_vc4_create_bo create; + memset(&create, 0, sizeof(create)); + + create.size = size; + + ret = drmIoctl(screen->fd, DRM_IOCTL_VC4_CREATE_BO, &create); + bo->handle = create.handle; + } else { + struct drm_mode_create_dumb create; + memset(&create, 0, sizeof(create)); - create.width = 128; - create.bpp = 8; - create.height = (size + 127) / 128; + create.width = 128; + create.bpp = 8; + create.height = (size + 127) / 128; - int ret = drmIoctl(screen->fd, DRM_IOCTL_MODE_CREATE_DUMB, &create); + ret = drmIoctl(screen->fd, DRM_IOCTL_MODE_CREATE_DUMB, &create); + bo->handle = create.handle; + assert(create.size >= size); + } if (ret != 0) { fprintf(stderr, "create ioctl failure\n"); abort(); } - bo->handle = create.handle; - assert(create.size >= size); - return bo; } @@ -371,25 +382,35 @@ vc4_bo_wait(struct vc4_bo *bo, uint64_t timeout_ns) void * vc4_bo_map_unsynchronized(struct vc4_bo *bo) { + uint64_t offset; int ret; if (bo->map) return bo->map; - struct drm_mode_map_dumb map; - memset(&map, 0, sizeof(map)); - map.handle = bo->handle; - ret = drmIoctl(bo->screen->fd, DRM_IOCTL_MODE_MAP_DUMB, &map); + if (!using_vc4_simulator) { + struct drm_vc4_mmap_bo map; + memset(&map, 0, sizeof(map)); + map.handle = bo->handle; + ret = drmIoctl(bo->screen->fd, DRM_IOCTL_VC4_MMAP_BO, &map); + offset = map.offset; + } else { + struct drm_mode_map_dumb map; + memset(&map, 0, sizeof(map)); + map.handle = bo->handle; + ret = drmIoctl(bo->screen->fd, DRM_IOCTL_MODE_MAP_DUMB, &map); + offset = map.offset; + } if (ret != 0) { fprintf(stderr, "map ioctl failure\n"); abort(); } bo->map = mmap(NULL, bo->size, PROT_READ | PROT_WRITE, MAP_SHARED, - bo->screen->fd, map.offset); + bo->screen->fd, offset); if (bo->map == MAP_FAILED) { fprintf(stderr, "mmap of bo %d (offset 0x%016llx, size %d) failed\n", - bo->handle, (long long)map.offset, bo->size); + bo->handle, (long long)offset, bo->size); abort(); } From anholt at kemper.freedesktop.org Tue Mar 24 17:39:48 2015 From: anholt at kemper.freedesktop.org (Eric Anholt) Date: Tue, 24 Mar 2015 10:39:48 -0700 (PDT) Subject: Mesa (master): vc4: Write the alignment of level width consistently in validation. Message-ID: <20150324173948.1387A76332@kemper.freedesktop.org> Module: Mesa Branch: master Commit: b3ea377f8629ada57c67632a89f0d2e9d2faf23c URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=b3ea377f8629ada57c67632a89f0d2e9d2faf23c Author: Eric Anholt Date: Mon Mar 23 16:34:24 2015 -0700 vc4: Write the alignment of level width consistently in validation. 16 / cpp happens to be the same as utile_w on the only raster format supported (4 bytes per pixel), but simulator/hw source code generally talks in terms of utiles. --- src/gallium/drivers/vc4/kernel/vc4_validate.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gallium/drivers/vc4/kernel/vc4_validate.c b/src/gallium/drivers/vc4/kernel/vc4_validate.c index 0691a8d..568b625 100644 --- a/src/gallium/drivers/vc4/kernel/vc4_validate.c +++ b/src/gallium/drivers/vc4/kernel/vc4_validate.c @@ -164,7 +164,7 @@ check_tex_size(struct vc4_exec_info *exec, struct drm_gem_cma_object *fbo, switch (tiling_format) { case VC4_TILING_FORMAT_LINEAR: - aligned_width = roundup(width, 16 / cpp); + aligned_width = roundup(width, utile_w); aligned_height = height; break; case VC4_TILING_FORMAT_T: @@ -951,7 +951,7 @@ reloc_tex(struct vc4_exec_info *exec, aligned_height = roundup(level_height, utile_h); break; default: - aligned_width = roundup(level_width, 16 / cpp); + aligned_width = roundup(level_width, utile_w); aligned_height = level_height; break; } From anholt at kemper.freedesktop.org Tue Mar 24 17:39:48 2015 From: anholt at kemper.freedesktop.org (Eric Anholt) Date: Tue, 24 Mar 2015 10:39:48 -0700 (PDT) Subject: Mesa (master): vc4: Fix pitch alignment of linear textures. Message-ID: <20150324173948.1FB1E76332@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 7f797e3d173c7a84aa5d231a1c173b00e84ea44f URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=7f797e3d173c7a84aa5d231a1c173b00e84ea44f Author: Eric Anholt Date: Mon Mar 16 14:48:26 2015 -0700 vc4: Fix pitch alignment of linear textures. Fixes some non-power-of-two texture rendering when I force ARGB8888 to raster. --- src/gallium/drivers/vc4/vc4_resource.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gallium/drivers/vc4/vc4_resource.c b/src/gallium/drivers/vc4/vc4_resource.c index b8628ec..544c032 100644 --- a/src/gallium/drivers/vc4/vc4_resource.c +++ b/src/gallium/drivers/vc4/vc4_resource.c @@ -258,7 +258,7 @@ vc4_setup_slices(struct vc4_resource *rsc) if (!rsc->tiled) { slice->tiling = VC4_TILING_FORMAT_LINEAR; - level_width = align(level_width, 16); + level_width = align(level_width, utile_w); } else { if (vc4_size_is_lt(level_width, level_height, rsc->cpp)) { From anholt at kemper.freedesktop.org Tue Mar 24 17:39:48 2015 From: anholt at kemper.freedesktop.org (Eric Anholt) Date: Tue, 24 Mar 2015 10:39:48 -0700 (PDT) Subject: Mesa (master): vc4: Fix use of a bool as an enum. Message-ID: <20150324173948.06C7076332@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 8975a09494cb6ee7b010fddb0ca5a7a74d46b0c7 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=8975a09494cb6ee7b010fddb0ca5a7a74d46b0c7 Author: Eric Anholt Date: Mon Mar 16 14:14:22 2015 -0700 vc4: Fix use of a bool as an enum. The enum compared to was 0, so it worked out, but it sure looked wrong. --- src/gallium/drivers/vc4/vc4_resource.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gallium/drivers/vc4/vc4_resource.c b/src/gallium/drivers/vc4/vc4_resource.c index c640cf6..b8628ec 100644 --- a/src/gallium/drivers/vc4/vc4_resource.c +++ b/src/gallium/drivers/vc4/vc4_resource.c @@ -256,7 +256,7 @@ vc4_setup_slices(struct vc4_resource *rsc) level_height = u_minify(pot_height, i); } - if (rsc->tiled == VC4_TILING_FORMAT_LINEAR) { + if (!rsc->tiled) { slice->tiling = VC4_TILING_FORMAT_LINEAR; level_width = align(level_width, 16); } else { From anholt at kemper.freedesktop.org Tue Mar 24 17:39:48 2015 From: anholt at kemper.freedesktop.org (Eric Anholt) Date: Tue, 24 Mar 2015 10:39:48 -0700 (PDT) Subject: Mesa (master): vc4: Allow DRI3 on simulation, as well. Message-ID: <20150324173948.2A89C76332@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 4df13f55b6c2cdda82b7909e1b089cc72f4c1151 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=4df13f55b6c2cdda82b7909e1b089cc72f4c1151 Author: Eric Anholt Date: Mon Mar 23 16:15:11 2015 -0700 vc4: Allow DRI3 on simulation, as well. The problem I'd seen before seems to be gone. --- src/gallium/auxiliary/target-helpers/inline_drm_helper.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/gallium/auxiliary/target-helpers/inline_drm_helper.h b/src/gallium/auxiliary/target-helpers/inline_drm_helper.h index df818fe..54c1c6c 100644 --- a/src/gallium/auxiliary/target-helpers/inline_drm_helper.h +++ b/src/gallium/auxiliary/target-helpers/inline_drm_helper.h @@ -472,6 +472,11 @@ dd_configuration(enum drm_conf conf) if (strcmp(driver_name, "vc4") == 0) return configuration_query(conf); else +#if defined(USE_VC4_SIMULATOR) + if (strcmp(driver_name, "i965") == 0) + return configuration_query(conf); + else +#endif #endif return NULL; } From anholt at kemper.freedesktop.org Tue Mar 24 17:39:48 2015 From: anholt at kemper.freedesktop.org (Eric Anholt) Date: Tue, 24 Mar 2015 10:39:48 -0700 (PDT) Subject: Mesa (master): vc4: Add a dump-the-surface-contents routine. Message-ID: <20150324173948.36CB076332@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 7bc39c8418ee5de49e3d38aaf5f9e478ff78874c URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=7bc39c8418ee5de49e3d38aaf5f9e478ff78874c Author: Eric Anholt Date: Wed Jan 14 09:58:35 2015 +1300 vc4: Add a dump-the-surface-contents routine. This has been useful once again while trying to debug stride issues between render targets and texturing. --- src/gallium/drivers/vc4/vc4_resource.c | 100 ++++++++++++++++++++++++++++++++ src/gallium/drivers/vc4/vc4_resource.h | 1 + 2 files changed, 101 insertions(+) diff --git a/src/gallium/drivers/vc4/vc4_resource.c b/src/gallium/drivers/vc4/vc4_resource.c index 544c032..cbb334f 100644 --- a/src/gallium/drivers/vc4/vc4_resource.c +++ b/src/gallium/drivers/vc4/vc4_resource.c @@ -468,6 +468,106 @@ vc4_surface_destroy(struct pipe_context *pctx, struct pipe_surface *psurf) FREE(psurf); } +/** Debug routine to dump the contents of an 8888 surface to the console */ +void +vc4_dump_surface(struct pipe_surface *psurf) +{ + if (!psurf) + return; + + struct pipe_resource *prsc = psurf->texture; + struct vc4_resource *rsc = vc4_resource(prsc); + uint32_t *map = vc4_bo_map(rsc->bo); + uint32_t stride = rsc->slices[0].stride / 4; + uint32_t width = psurf->width; + uint32_t height = psurf->height; + uint32_t chunk_w = width / 79; + uint32_t chunk_h = height / 40; + uint32_t found_colors[10]; + uint32_t num_found_colors = 0; + + if (rsc->vc4_format != VC4_TEXTURE_TYPE_RGBA32R) { + fprintf(stderr, "%s: Unsupported format %s\n", + __func__, util_format_short_name(psurf->format)); + return; + } + + for (int by = 0; by < height; by += chunk_h) { + for (int bx = 0; bx < width; bx += chunk_w) { + int all_found_color = -1; /* nothing found */ + + for (int y = by; y < MIN2(height, by + chunk_h); y++) { + for (int x = bx; x < MIN2(width, bx + chunk_w); x++) { + uint32_t pix = map[y * stride + x]; + + int i; + for (i = 0; i < num_found_colors; i++) { + if (pix == found_colors[i]) + break; + } + if (i == num_found_colors && + num_found_colors < + ARRAY_SIZE(found_colors)) { + found_colors[num_found_colors++] = pix; + } + + if (i < num_found_colors) { + if (all_found_color == -1) + all_found_color = i; + else if (i != all_found_color) + all_found_color = ARRAY_SIZE(found_colors); + } + } + } + /* If all pixels for this chunk have a consistent + * value, then print a character for it. Either a + * fixed name (particularly common for piglit tests), + * or a runtime-generated number. + */ + if (all_found_color >= 0 && + all_found_color < ARRAY_SIZE(found_colors)) { + static const struct { + uint32_t val; + const char *c; + } named_colors[] = { + { 0xff000000, "?" }, + { 0x00000000, "?" }, + { 0xffff0000, "r" }, + { 0xff00ff00, "g" }, + { 0xff0000ff, "b" }, + { 0xffffffff, "w" }, + }; + int i; + for (i = 0; i < ARRAY_SIZE(named_colors); i++) { + if (named_colors[i].val == + found_colors[all_found_color]) { + fprintf(stderr, "%s", + named_colors[i].c); + break; + } + } + /* For unnamed colors, print a number and the + * numbers will have values printed at the + * end. + */ + if (i == ARRAY_SIZE(named_colors)) { + fprintf(stderr, "%c", + '0' + all_found_color); + } + } else { + /* If there's no consistent color, print this. + */ + fprintf(stderr, "."); + } + } + fprintf(stderr, "\n"); + } + + for (int i = 0; i < num_found_colors; i++) { + fprintf(stderr, "color %d: 0x%08x\n", i, found_colors[i]); + } +} + static void vc4_flush_resource(struct pipe_context *pctx, struct pipe_resource *resource) { diff --git a/src/gallium/drivers/vc4/vc4_resource.h b/src/gallium/drivers/vc4/vc4_resource.h index 90b58e1..b2359f0 100644 --- a/src/gallium/drivers/vc4/vc4_resource.h +++ b/src/gallium/drivers/vc4/vc4_resource.h @@ -112,5 +112,6 @@ void vc4_update_shadow_baselevel_texture(struct pipe_context *pctx, struct pipe_sampler_view *view); void vc4_update_shadow_index_buffer(struct pipe_context *pctx, const struct pipe_index_buffer *ib); +void vc4_dump_surface(struct pipe_surface *psurf); #endif /* VC4_RESOURCE_H */ From anholt at kemper.freedesktop.org Tue Mar 24 17:39:47 2015 From: anholt at kemper.freedesktop.org (Eric Anholt) Date: Tue, 24 Mar 2015 10:39:47 -0700 (PDT) Subject: Mesa (master): vc4: Decide the HW's format before laying out the miptree. Message-ID: <20150324173947.F049776332@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 04605c21f65bfbc78018c5bafa8cbf49e96a33b5 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=04605c21f65bfbc78018c5bafa8cbf49e96a33b5 Author: Eric Anholt Date: Mon Mar 23 16:21:25 2015 -0700 vc4: Decide the HW's format before laying out the miptree. I'm experimenting with a workaround for raster texture misrendering on hardware, and this lets me look at the format chosen when computing strides. --- src/gallium/drivers/vc4/vc4_resource.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/gallium/drivers/vc4/vc4_resource.c b/src/gallium/drivers/vc4/vc4_resource.c index 0dda0d8..c640cf6 100644 --- a/src/gallium/drivers/vc4/vc4_resource.c +++ b/src/gallium/drivers/vc4/vc4_resource.c @@ -373,14 +373,14 @@ vc4_resource_create(struct pipe_screen *pscreen, rsc->tiled = true; } + if (tmpl->target != PIPE_BUFFER) + rsc->vc4_format = get_resource_texture_format(prsc); + vc4_setup_slices(rsc); vc4_resource_bo_alloc(rsc); if (!rsc->bo) goto fail; - if (tmpl->target != PIPE_BUFFER) - rsc->vc4_format = get_resource_texture_format(prsc); - return prsc; fail: vc4_resource_destroy(pscreen, prsc); From aphogat at kemper.freedesktop.org Tue Mar 24 18:16:46 2015 From: aphogat at kemper.freedesktop.org (Anuj Phogat) Date: Tue, 24 Mar 2015 11:16:46 -0700 (PDT) Subject: Mesa (master): glsl: Generate link error for non-matching gl_FragCoord redeclarations Message-ID: <20150324181646.5E97D76332@kemper.freedesktop.org> Module: Mesa Branch: master Commit: d8208312a3a200b4e6d71ce533d835b2d705234a URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=d8208312a3a200b4e6d71ce533d835b2d705234a Author: Anuj Phogat Date: Thu Mar 5 11:07:52 2015 -0800 glsl: Generate link error for non-matching gl_FragCoord redeclarations in different fragment shaders. This also applies to a case when gl_FragCoord is redeclared with no layout qualifiers in one fragment shader and not declared but used in other fragment shader. Signed-off-by: Anuj Phogat Khronos Bug#12957 Cc: "10.5" Reviewed-by: Chris Forbes --- src/glsl/linker.cpp | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp index 4349f09..85830e6 100644 --- a/src/glsl/linker.cpp +++ b/src/glsl/linker.cpp @@ -1377,24 +1377,13 @@ link_fs_input_layout_qualifiers(struct gl_shader_program *prog, * "If gl_FragCoord is redeclared in any fragment shader in a program, * it must be redeclared in all the fragment shaders in that program * that have a static use gl_FragCoord." - * - * Exclude the case when one of the 'linked_shader' or 'shader' redeclares - * gl_FragCoord with no layout qualifiers but the other one doesn't - * redeclare it. If we strictly follow GLSL 1.50 spec's language, it - * should be a link error. But, generating link error for this case will - * be a wrong behaviour which spec didn't intend to do and it could also - * break some applications. */ if ((linked_shader->redeclares_gl_fragcoord && !shader->redeclares_gl_fragcoord - && shader->uses_gl_fragcoord - && (linked_shader->origin_upper_left - || linked_shader->pixel_center_integer)) + && shader->uses_gl_fragcoord) || (shader->redeclares_gl_fragcoord && !linked_shader->redeclares_gl_fragcoord - && linked_shader->uses_gl_fragcoord - && (shader->origin_upper_left - || shader->pixel_center_integer))) { + && linked_shader->uses_gl_fragcoord)) { linker_error(prog, "fragment shader defined with conflicting " "layout qualifiers for gl_FragCoord\n"); } From evelikov at kemper.freedesktop.org Tue Mar 24 20:50:47 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Tue, 24 Mar 2015 13:50:47 -0700 (PDT) Subject: Mesa (master): gbm: remove gbm_gallium_drm from the loader Message-ID: <20150324205047.49D5E76332@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 113d59fb557c377316904010ce88b9a87b4cc4d7 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=113d59fb557c377316904010ce88b9a87b4cc4d7 Author: Emil Velikov Date: Sat Mar 21 17:45:26 2015 +0000 gbm: remove gbm_gallium_drm from the loader No longer used as of commit 48c7461d5a0(st/gbm: remove state-tracker) v2: Add commit message. Signed-off-by: Emil Velikov Reviewed-by: Kristian H?gsberg (v1) --- src/gbm/main/backend.c | 24 ------------------------ 1 file changed, 24 deletions(-) diff --git a/src/gbm/main/backend.c b/src/gbm/main/backend.c index aceb662..4929d73 100644 --- a/src/gbm/main/backend.c +++ b/src/gbm/main/backend.c @@ -30,7 +30,6 @@ #include #include #include -#include #include "backend.h" @@ -45,41 +44,18 @@ struct backend_desc { static const struct backend_desc backends[] = { { "gbm_dri.so", &gbm_dri_backend }, - { "gbm_gallium_drm.so", NULL }, }; static const void * load_backend(const struct backend_desc *backend) { - char path[PATH_MAX]; const void *init = NULL; - void *module; - const char *name; - const char *entrypoint = "gbm_backend"; if (backend == NULL) return NULL; - name = backend->name; - if (backend->builtin) { init = backend->builtin; - } else { - if (name[0] != '/') - snprintf(path, sizeof path, MODULEDIR "/%s", name); - else - snprintf(path, sizeof path, "%s", name); - - module = dlopen(path, RTLD_NOW | RTLD_GLOBAL); - if (!module) { - fprintf(stderr, - "failed to load module: %s\n", dlerror()); - return NULL; - } - - init = dlsym(module, entrypoint); - if (!init) - return NULL; } return init; From evelikov at kemper.freedesktop.org Tue Mar 24 20:50:47 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Tue, 24 Mar 2015 13:50:47 -0700 (PDT) Subject: Mesa (master): makefile: add all headers to the tarball Message-ID: <20150324205047.563B276332@kemper.freedesktop.org> Module: Mesa Branch: master Commit: b2439602bef14387ccb1ea63ea452af4f15e8889 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=b2439602bef14387ccb1ea63ea452af4f15e8889 Author: Emil Velikov Date: Mon Mar 23 16:17:34 2015 +0000 makefile: add all headers to the tarball Signed-off-by: Emil Velikov Reviewed-by: Matt Turner --- Makefile.am | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/Makefile.am b/Makefile.am index f4f0912..9f49ce6 100644 --- a/Makefile.am +++ b/Makefile.am @@ -44,12 +44,15 @@ EXTRA_DIST = \ scons \ SConstruct -noinst_HEADERS = \ - include/c99_compat.h \ - include/c99 \ - include/c11 \ - include/D3D9 \ - include/HaikuGL \ +noinst_HEADERS = \ + include/c99_alloca.h \ + include/c99_compat.h \ + include/c99_math.h \ + include/c99 \ + include/c11 \ + include/D3D9 \ + include/HaikuGL \ + include/no_extern_c.h \ include/pci_ids # We list some directories in EXTRA_DIST, but don't actually want to include From evelikov at kemper.freedesktop.org Tue Mar 24 20:50:47 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Tue, 24 Mar 2015 13:50:47 -0700 (PDT) Subject: Mesa (master): gallium/util: Use HAVE___BUILTIN_FFS* macros. Message-ID: <20150324205047.8089476332@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 726d99b19740dca6787ab819ab99bc9d942d80a6 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=726d99b19740dca6787ab819ab99bc9d942d80a6 Author: Jonathan Gray Date: Tue Mar 17 12:49:39 2015 +1100 gallium/util: Use HAVE___BUILTIN_FFS* macros. Make use of the builtin ffs macros and split out ffsll to a seperate block. Needed for at least OpenBSD which does not have ffsll in libc. Signed-off-by: Jonathan Gray Reviewed-by: Emil Velikov --- src/gallium/auxiliary/util/u_math.h | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/gallium/auxiliary/util/u_math.h b/src/gallium/auxiliary/util/u_math.h index 8f62cac..3d27a59 100644 --- a/src/gallium/auxiliary/util/u_math.h +++ b/src/gallium/auxiliary/util/u_math.h @@ -383,14 +383,28 @@ unsigned ffs( unsigned u ) return i; } -#elif defined(__MINGW32__) || defined(PIPE_OS_ANDROID) +#elif defined(__MINGW32__) || defined(PIPE_OS_ANDROID) || \ + defined(HAVE___BUILTIN_FFS) #define ffs __builtin_ffs -#define ffsll __builtin_ffsll #endif #endif /* FFS_DEFINED */ /** + * Find first bit set in long long. Least significant bit is 1. + * Return 0 if no bits set. + */ +#ifndef FFSLL_DEFINED +#define FFSLL_DEFINED 1 + +#if defined(__MINGW32__) || defined(PIPE_OS_ANDROID) || \ + defined(HAVE___BUILTIN_FFSLL) +#define ffsll __builtin_ffsll +#endif + +#endif /* FFSLL_DEFINED */ + +/** * Find last bit set in a word. The least significant bit is 1. * Return 0 if no bits are set. */ From evelikov at kemper.freedesktop.org Tue Mar 24 20:50:47 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Tue, 24 Mar 2015 13:50:47 -0700 (PDT) Subject: Mesa (master): configure.ac: move AC_MSG_RESULT reporting back into the m4 macro Message-ID: <20150324205047.8D35476332@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 248eb54eb6117cc5a863ba2deaa14c3bee0b5d41 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=248eb54eb6117cc5a863ba2deaa14c3bee0b5d41 Author: Emil Velikov Date: Mon Mar 23 17:49:23 2015 +0000 configure.ac: move AC_MSG_RESULT reporting back into the m4 macro The one who does AC_MSG_CHECKING should provide the AC_MSG_RESULT. Fixes: ced9425327b (configure: Introduce new output variable to ax_check_python_mako_module.m4" Cc: "10.5" Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=89328 Signed-off-by: Emil Velikov Reviewed-by: Samuel Iglesias Gonsalvez --- configure.ac | 4 +--- m4/ax_check_python_mako_module.m4 | 2 ++ 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index 08378f5..3e5b6f5 100644 --- a/configure.ac +++ b/configure.ac @@ -123,9 +123,7 @@ if test "x$INDENT" != "xcat"; then fi AX_CHECK_PYTHON_MAKO_MODULE($PYTHON_MAKO_REQUIRED) -if test -n "$PYTHON2" -a "x$acv_mako_found" = "xyes"; then - AC_MSG_RESULT(yes) -else +if test -n "$PYTHON2" -a "x$acv_mako_found" != "xyes"; then AC_MSG_ERROR([Python mako module v$PYTHON_MAKO_REQUIRED or higher not found]) fi diff --git a/m4/ax_check_python_mako_module.m4 b/m4/ax_check_python_mako_module.m4 index ee68a7c..7d9bb51 100644 --- a/m4/ax_check_python_mako_module.m4 +++ b/m4/ax_check_python_mako_module.m4 @@ -54,8 +54,10 @@ else: " | $PYTHON2 - if test $? -ne 0 ; then + AC_MSG_RESULT(no) AC_SUBST(acv_mako_found, 'no') else + AC_MSG_RESULT(yes) AC_SUBST(acv_mako_found, 'yes') fi ]) From evelikov at kemper.freedesktop.org Tue Mar 24 20:50:47 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Tue, 24 Mar 2015 13:50:47 -0700 (PDT) Subject: Mesa (master): glsl: add the remaining files to the tarball Message-ID: <20150324205047.6533E76332@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 9950eec173d056e324332c12fa269c852cc931aa URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=9950eec173d056e324332c12fa269c852cc931aa Author: Emil Velikov Date: Mon Mar 23 16:17:35 2015 +0000 glsl: add the remaining files to the tarball Signed-off-by: Emil Velikov Reviewed-by: Matt Turner --- src/glsl/Makefile.am | 1 + src/glsl/Makefile.sources | 1 + 2 files changed, 2 insertions(+) diff --git a/src/glsl/Makefile.am b/src/glsl/Makefile.am index b466a3b..ed90366 100644 --- a/src/glsl/Makefile.am +++ b/src/glsl/Makefile.am @@ -46,6 +46,7 @@ EXTRA_DIST = tests glcpp/tests README TODO glcpp/README \ glcpp/glcpp-lex.l \ glcpp/glcpp-parse.y \ nir/nir_algebraic.py \ + nir/nir_builder_opcodes_h.py \ nir/nir_constant_expressions.py \ nir/nir_opcodes.py \ nir/nir_opcodes_c.py \ diff --git a/src/glsl/Makefile.sources b/src/glsl/Makefile.sources index b876642..8d29c55 100644 --- a/src/glsl/Makefile.sources +++ b/src/glsl/Makefile.sources @@ -57,6 +57,7 @@ NIR_FILES = \ nir/nir_to_ssa.c \ nir/nir_types.h \ nir/nir_validate.c \ + nir/nir_vla.h \ nir/nir_worklist.c \ nir/nir_worklist.h \ nir/nir_types.cpp \ From evelikov at kemper.freedesktop.org Tue Mar 24 20:50:47 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Tue, 24 Mar 2015 13:50:47 -0700 (PDT) Subject: Mesa (master): i965: add the remaining files to the tarball Message-ID: <20150324205047.71E7E76332@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 8cce7b05f19207d331a1abe294c201e0c3ee6ec1 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=8cce7b05f19207d331a1abe294c201e0c3ee6ec1 Author: Emil Velikov Date: Mon Mar 23 16:17:36 2015 +0000 i965: add the remaining files to the tarball Signed-off-by: Emil Velikov Reviewed-by: Matt Turner --- src/mesa/drivers/dri/i965/Makefile.sources | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/mesa/drivers/dri/i965/Makefile.sources b/src/mesa/drivers/dri/i965/Makefile.sources index 3a3df70..498d5a7 100644 --- a/src/mesa/drivers/dri/i965/Makefile.sources +++ b/src/mesa/drivers/dri/i965/Makefile.sources @@ -64,6 +64,9 @@ i965_FILES = \ brw_gs_surface_state.c \ brw_inst.h \ brw_interpolation_map.c \ + brw_ir_allocator.h \ + brw_ir_fs.h \ + brw_ir_vec4.h \ brw_lower_texture_gradients.cpp \ brw_lower_unnormalized_offset.cpp \ brw_meta_fast_clear.c \ From mattst88 at kemper.freedesktop.org Tue Mar 24 21:45:16 2015 From: mattst88 at kemper.freedesktop.org (Matt Turner) Date: Tue, 24 Mar 2015 14:45:16 -0700 (PDT) Subject: Mesa (master): glsl: Recognize sat(add(b2f(a), b2f(b))) as a logical OR. Message-ID: <20150324214516.C133076332@kemper.freedesktop.org> Module: Mesa Branch: master Commit: b481ebbe399fdc6386fd52f890ba7c310d333ed5 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=b481ebbe399fdc6386fd52f890ba7c310d333ed5 Author: Matt Turner Date: Wed Mar 18 10:39:38 2015 -0700 glsl: Recognize sat(add(b2f(a), b2f(b))) as a logical OR. Transform this into b2f(or(a, b)). Reviewed-by: Ian Romanick --- src/glsl/opt_algebraic.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/glsl/opt_algebraic.cpp b/src/glsl/opt_algebraic.cpp index 0d1f3fc..98c852a 100644 --- a/src/glsl/opt_algebraic.cpp +++ b/src/glsl/opt_algebraic.cpp @@ -421,6 +421,18 @@ ir_algebraic_visitor::handle_expression(ir_expression *ir) break; } + case ir_unop_saturate: + if (op_expr[0] && op_expr[0]->operation == ir_binop_add) { + ir_expression *b2f_0 = op_expr[0]->operands[0]->as_expression(); + ir_expression *b2f_1 = op_expr[0]->operands[1]->as_expression(); + + if (b2f_0 && b2f_0->operation == ir_unop_b2f && + b2f_1 && b2f_1->operation == ir_unop_b2f) { + return b2f(logic_or(b2f_0->operands[0], b2f_1->operands[0])); + } + } + break; + case ir_binop_add: if (is_vec_zero(op_const[0])) return ir->operands[1]; From mattst88 at kemper.freedesktop.org Tue Mar 24 21:45:16 2015 From: mattst88 at kemper.freedesktop.org (Matt Turner) Date: Tue, 24 Mar 2015 14:45:16 -0700 (PDT) Subject: Mesa (master): glsl: Allow vector logic ops to be generated. Message-ID: <20150324214516.9E50E76332@kemper.freedesktop.org> Module: Mesa Branch: master Commit: c8acbd1bfdafa892e6c5e9a6d9100aa2e69b9096 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=c8acbd1bfdafa892e6c5e9a6d9100aa2e69b9096 Author: Matt Turner Date: Tue Mar 17 23:27:38 2015 -0700 glsl: Allow vector logic ops to be generated. They're not accessible from the source language, but optimizations are allowed to generate them. Reviewed-by: Ian Romanick --- src/glsl/ir_validate.cpp | 6 +++--- src/mesa/drivers/dri/i965/brw_fs_channel_expressions.cpp | 9 +++------ 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/glsl/ir_validate.cpp b/src/glsl/ir_validate.cpp index 7a7688c..72c5f06 100644 --- a/src/glsl/ir_validate.cpp +++ b/src/glsl/ir_validate.cpp @@ -543,9 +543,9 @@ ir_validate::visit_leave(ir_expression *ir) case ir_binop_logic_and: case ir_binop_logic_xor: case ir_binop_logic_or: - assert(ir->type == glsl_type::bool_type); - assert(ir->operands[0]->type == glsl_type::bool_type); - assert(ir->operands[1]->type == glsl_type::bool_type); + assert(ir->type->base_type == GLSL_TYPE_BOOL); + assert(ir->operands[0]->type->base_type == GLSL_TYPE_BOOL); + assert(ir->operands[1]->type->base_type == GLSL_TYPE_BOOL); break; case ir_binop_dot: 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 933fdde..4049b09 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_channel_expressions.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_channel_expressions.cpp @@ -271,6 +271,9 @@ ir_channel_expressions_visitor::visit_leave(ir_assignment *ir) case ir_binop_bit_and: case ir_binop_bit_xor: case ir_binop_bit_or: + case ir_binop_logic_and: + case ir_binop_logic_xor: + case ir_binop_logic_or: case ir_binop_less: case ir_binop_greater: case ir_binop_lequal: @@ -329,12 +332,6 @@ ir_channel_expressions_visitor::visit_leave(ir_assignment *ir) break; } - case ir_binop_logic_and: - case ir_binop_logic_xor: - case ir_binop_logic_or: - ir->fprint(stderr); - fprintf(stderr, "\n"); - unreachable("not reached: expression operates on scalars only"); case ir_binop_all_equal: case ir_binop_any_nequal: { ir_expression *last = NULL; From mattst88 at kemper.freedesktop.org Tue Mar 24 21:45:16 2015 From: mattst88 at kemper.freedesktop.org (Matt Turner) Date: Tue, 24 Mar 2015 14:45:16 -0700 (PDT) Subject: Mesa (master): nir: Handle mixed scalar/vector arguments to logical and/or /xor. Message-ID: <20150324214516.AA8C27635A@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 95729d2458515788ed84c81698033b8ef170bd4e URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=95729d2458515788ed84c81698033b8ef170bd4e Author: Matt Turner Date: Mon Mar 23 16:04:41 2015 -0700 nir: Handle mixed scalar/vector arguments to logical and/or/xor. Reviewed-by: Connor Abbott --- src/glsl/nir/glsl_to_nir.cpp | 39 +++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/src/glsl/nir/glsl_to_nir.cpp b/src/glsl/nir/glsl_to_nir.cpp index 357944d..e6f5ffc 100644 --- a/src/glsl/nir/glsl_to_nir.cpp +++ b/src/glsl/nir/glsl_to_nir.cpp @@ -1210,6 +1210,9 @@ nir_visitor::visit(ir_expression *ir) case ir_binop_bit_and: case ir_binop_bit_or: case ir_binop_bit_xor: + case ir_binop_logic_and: + case ir_binop_logic_or: + case ir_binop_logic_xor: case ir_binop_lshift: case ir_binop_rshift: switch (ir->operation) { @@ -1270,6 +1273,24 @@ nir_visitor::visit(ir_expression *ir) case ir_binop_bit_xor: op = nir_op_ixor; break; + case ir_binop_logic_and: + if (supports_ints) + op = nir_op_iand; + else + op = nir_op_fand; + break; + case ir_binop_logic_or: + if (supports_ints) + op = nir_op_ior; + else + op = nir_op_for; + break; + case ir_binop_logic_xor: + if (supports_ints) + op - nir_op_ixor; + else + op = nir_op_fxor; + break; case ir_binop_lshift: op = nir_op_ishl; break; @@ -1444,24 +1465,6 @@ nir_visitor::visit(ir_expression *ir) } } break; - case ir_binop_logic_and: - if (supports_ints) - emit(nir_op_iand, dest_size, srcs); - else - emit(nir_op_fand, dest_size, srcs); - break; - case ir_binop_logic_or: - if (supports_ints) - emit(nir_op_ior, dest_size, srcs); - else - emit(nir_op_for, dest_size, srcs); - break; - case ir_binop_logic_xor: - if (supports_ints) - emit(nir_op_ixor, dest_size, srcs); - else - emit(nir_op_fxor, dest_size, srcs); - break; case ir_binop_dot: switch (ir->operands[0]->type->vector_elements) { case 2: emit(nir_op_fdot2, dest_size, srcs); break; From mattst88 at kemper.freedesktop.org Tue Mar 24 21:45:16 2015 From: mattst88 at kemper.freedesktop.org (Matt Turner) Date: Tue, 24 Mar 2015 14:45:16 -0700 (PDT) Subject: Mesa (master): nir: Recognize mul(b2f(a), b2f(b)) as a logical AND. Message-ID: <20150324214516.C880A76332@kemper.freedesktop.org> Module: Mesa Branch: master Commit: c31158d2cb06a864cf44d6d4f2c539e359990d3d URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=c31158d2cb06a864cf44d6d4f2c539e359990d3d Author: Matt Turner Date: Tue Mar 17 23:30:32 2015 -0700 nir: Recognize mul(b2f(a), b2f(b)) as a logical AND. Transform this into b2f(and(a, b)). total instructions in shared programs: 6205448 -> 6204391 (-0.02%) instructions in affected programs: 284030 -> 282973 (-0.37%) helped: 903 HURT: 6 Acked-by: Ian Romanick Reviewed-by: Connor Abbott --- src/glsl/nir/nir_opt_algebraic.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/glsl/nir/nir_opt_algebraic.py b/src/glsl/nir/nir_opt_algebraic.py index ef855aa..f956edf 100644 --- a/src/glsl/nir/nir_opt_algebraic.py +++ b/src/glsl/nir/nir_opt_algebraic.py @@ -95,6 +95,8 @@ optimizations = [ (('fsat', a), ('fmin', ('fmax', a, 0.0), 1.0), 'options->lower_fsat'), (('fsat', ('fsat', a)), ('fsat', a)), (('fmin', ('fmax', ('fmin', ('fmax', a, 0.0), 1.0), 0.0), 1.0), ('fmin', ('fmax', a, 0.0), 1.0)), + # Emulating booleans + (('fmul', ('b2f', a), ('b2f', b)), ('b2f', ('iand', a, b))), # Comparison with the same args. Note that these are not done for # the float versions because NaN always returns false on float # inequalities. From mattst88 at kemper.freedesktop.org Tue Mar 24 21:45:16 2015 From: mattst88 at kemper.freedesktop.org (Matt Turner) Date: Tue, 24 Mar 2015 14:45:16 -0700 (PDT) Subject: Mesa (master): glsl: Recognize mul(b2f(a), b2f(b)) as a logical AND. Message-ID: <20150324214516.B3A8C7635B@kemper.freedesktop.org> Module: Mesa Branch: master Commit: c8e8f660365515560af029651e593f7ee700401c URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=c8e8f660365515560af029651e593f7ee700401c Author: Matt Turner Date: Tue Mar 17 23:28:27 2015 -0700 glsl: Recognize mul(b2f(a), b2f(b)) as a logical AND. Transform this into b2f(and(a, b)). total instructions in shared programs: 6190291 -> 6189225 (-0.02%) instructions in affected programs: 267247 -> 266181 (-0.40%) helped: 866 Reviewed-by: Ian Romanick --- src/glsl/opt_algebraic.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/glsl/opt_algebraic.cpp b/src/glsl/opt_algebraic.cpp index 69c03ea..0d1f3fc 100644 --- a/src/glsl/opt_algebraic.cpp +++ b/src/glsl/opt_algebraic.cpp @@ -518,6 +518,10 @@ ir_algebraic_visitor::handle_expression(ir_expression *ir) if (is_vec_negative_one(op_const[1])) return neg(ir->operands[0]); + if (op_expr[0] && op_expr[0]->operation == ir_unop_b2f && + op_expr[1] && op_expr[1]->operation == ir_unop_b2f) { + return b2f(logic_and(op_expr[0]->operands[0], op_expr[1]->operands[0])); + } /* Reassociate multiplication of constants so that we can do * constant folding. From mattst88 at kemper.freedesktop.org Tue Mar 24 21:45:16 2015 From: mattst88 at kemper.freedesktop.org (Matt Turner) Date: Tue, 24 Mar 2015 14:45:16 -0700 (PDT) Subject: Mesa (master): nir: Recognize sat(add(b2f(a), b2f(b))) as a logical OR. Message-ID: <20150324214516.D363F76332@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 3fb56805f0dbfe929cd733e15566197bc0733290 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=3fb56805f0dbfe929cd733e15566197bc0733290 Author: Matt Turner Date: Tue Mar 17 23:30:43 2015 -0700 nir: Recognize sat(add(b2f(a), b2f(b))) as a logical OR. Transform this into b2f(or(a, b)). instructions in affected programs: 432 -> 430 (-0.46%) helped: 2 Acked-by: Ian Romanick Reviewed-by: Connor Abbott Reviewed-by: Jason Ekstrand --- src/glsl/nir/nir_opt_algebraic.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/glsl/nir/nir_opt_algebraic.py b/src/glsl/nir/nir_opt_algebraic.py index f956edf..1ee51a0 100644 --- a/src/glsl/nir/nir_opt_algebraic.py +++ b/src/glsl/nir/nir_opt_algebraic.py @@ -97,6 +97,7 @@ optimizations = [ (('fmin', ('fmax', ('fmin', ('fmax', a, 0.0), 1.0), 0.0), 1.0), ('fmin', ('fmax', a, 0.0), 1.0)), # Emulating booleans (('fmul', ('b2f', a), ('b2f', b)), ('b2f', ('iand', a, b))), + (('fsat', ('fadd', ('b2f', a), ('b2f', b))), ('b2f', ('ior', a, b))), # Comparison with the same args. Note that these are not done for # the float versions because NaN always returns false on float # inequalities. From mattst88 at kemper.freedesktop.org Wed Mar 25 02:15:01 2015 From: mattst88 at kemper.freedesktop.org (Matt Turner) Date: Tue, 24 Mar 2015 19:15:01 -0700 (PDT) Subject: Mesa (master): nir: Fix typo. Message-ID: <20150325021501.208ED76332@kemper.freedesktop.org> Module: Mesa Branch: master Commit: babd0fa3e28ae673128aaab55bd59fc3b7135be3 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=babd0fa3e28ae673128aaab55bd59fc3b7135be3 Author: Matt Turner Date: Tue Mar 24 19:14:18 2015 -0700 nir: Fix typo. --- src/glsl/nir/glsl_to_nir.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/glsl/nir/glsl_to_nir.cpp b/src/glsl/nir/glsl_to_nir.cpp index e6f5ffc..f48a34b 100644 --- a/src/glsl/nir/glsl_to_nir.cpp +++ b/src/glsl/nir/glsl_to_nir.cpp @@ -1287,7 +1287,7 @@ nir_visitor::visit(ir_expression *ir) break; case ir_binop_logic_xor: if (supports_ints) - op - nir_op_ixor; + op = nir_op_ixor; else op = nir_op_fxor; break; From krh at kemper.freedesktop.org Wed Mar 25 05:03:52 2015 From: krh at kemper.freedesktop.org (Kristian Høgsberg) Date: Tue, 24 Mar 2015 22:03:52 -0700 (PDT) Subject: Mesa (master): mesa: Apply visibility flags to src/Makefile.am targets Message-ID: <20150325050352.1145F76332@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 169b389a34966b921fe4b75baff5503c3a31a98a URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=169b389a34966b921fe4b75baff5503c3a31a98a Author: Kristian H?gsberg Date: Tue Mar 24 09:41:08 2015 -0700 mesa: Apply visibility flags to src/Makefile.am targets We were building libglsl_util.la without our visibility flags and leaking hash_table_* symbols. Signed-off-by: Kristian H?gsberg Reviewed-by: Matt Turner --- src/Makefile.am | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Makefile.am b/src/Makefile.am index 8edf333..874a333 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -55,6 +55,9 @@ endif EXTRA_DIST = egl/docs getopt hgl SConscript +AM_CFLAGS = $(VISIBILITY_CFLAGS) +AM_CXXFLAGS = $(VISIBILITY_CXXFLAGS) + AM_CPPFLAGS = \ -I$(top_srcdir)/include/ \ -I$(top_srcdir)/src/mapi/ \ From mperes at kemper.freedesktop.org Wed Mar 25 08:07:15 2015 From: mperes at kemper.freedesktop.org (Martin Peres) Date: Wed, 25 Mar 2015 01:07:15 -0700 (PDT) Subject: Mesa (master): main: replace tabs by 8 spaces in bufferobj.c Message-ID: <20150325080715.C656776332@kemper.freedesktop.org> Module: Mesa Branch: master Commit: cd0763b78f041167ba7c33f3c766f8082d3343e1 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=cd0763b78f041167ba7c33f3c766f8082d3343e1 Author: Martin Peres Date: Wed Feb 11 11:21:56 2015 +0200 main: replace tabs by 8 spaces in bufferobj.c Reviewed-by: Laura Ekstrand Signed-off-by: Martin Peres --- src/mesa/main/queryobj.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/mesa/main/queryobj.c b/src/mesa/main/queryobj.c index 0842b54..067d6c1 100644 --- a/src/mesa/main/queryobj.c +++ b/src/mesa/main/queryobj.c @@ -710,8 +710,8 @@ _mesa_GetQueryObjectiv(GLuint id, GLenum pname, GLint *params) } break; case GL_QUERY_RESULT_AVAILABLE_ARB: - if (!q->Ready) - ctx->Driver.CheckQuery( ctx, q ); + if (!q->Ready) + ctx->Driver.CheckQuery( ctx, q ); *params = q->Ready; break; default: @@ -761,8 +761,8 @@ _mesa_GetQueryObjectuiv(GLuint id, GLenum pname, GLuint *params) } break; case GL_QUERY_RESULT_AVAILABLE_ARB: - if (!q->Ready) - ctx->Driver.CheckQuery( ctx, q ); + if (!q->Ready) + ctx->Driver.CheckQuery( ctx, q ); *params = q->Ready; break; default: @@ -801,8 +801,8 @@ _mesa_GetQueryObjecti64v(GLuint id, GLenum pname, GLint64EXT *params) *params = q->Result; break; case GL_QUERY_RESULT_AVAILABLE_ARB: - if (!q->Ready) - ctx->Driver.CheckQuery( ctx, q ); + if (!q->Ready) + ctx->Driver.CheckQuery( ctx, q ); *params = q->Ready; break; default: @@ -841,8 +841,8 @@ _mesa_GetQueryObjectui64v(GLuint id, GLenum pname, GLuint64EXT *params) *params = q->Result; break; case GL_QUERY_RESULT_AVAILABLE_ARB: - if (!q->Ready) - ctx->Driver.CheckQuery( ctx, q ); + if (!q->Ready) + ctx->Driver.CheckQuery( ctx, q ); *params = q->Ready; break; default: From mperes at kemper.freedesktop.org Wed Mar 25 08:07:15 2015 From: mperes at kemper.freedesktop.org (Martin Peres) Date: Wed, 25 Mar 2015 01:07:15 -0700 (PDT) Subject: Mesa (master): main: fix the validation of the number of samples Message-ID: <20150325080715.DE65476332@kemper.freedesktop.org> Module: Mesa Branch: master Commit: fc76fac4199f06e26d6c9b4fbb87b85f802b06f3 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=fc76fac4199f06e26d6c9b4fbb87b85f802b06f3 Author: Martin Peres Date: Fri Feb 13 18:14:15 2015 +0200 main: fix the validation of the number of samples Maybe this should be the job of the dispatch layer. v2: - add the section name and pdf page number of the quote (Laura) - OpenGL 3.0 core does not exist, get rid of "core" Signed-off-by: Martin Peres --- src/mesa/main/multisample.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/mesa/main/multisample.c b/src/mesa/main/multisample.c index 0e9207b..816837b 100644 --- a/src/mesa/main/multisample.c +++ b/src/mesa/main/multisample.c @@ -150,6 +150,15 @@ GLenum _mesa_check_sample_count(struct gl_context *ctx, GLenum target, GLenum internalFormat, GLsizei samples) { + /* Section 2.5 (GL Errors) of OpenGL 3.0 specification, page 16: + * + * "If a negative number is provided where an argument of type sizei or + * sizeiptr is specified, the error INVALID VALUE is generated." + */ + if (samples < 0) { + return GL_INVALID_VALUE; + } + /* Section 4.4 (Framebuffer objects), page 198 of the OpenGL ES 3.0.0 * specification says: * From mperes at kemper.freedesktop.org Wed Mar 25 08:07:16 2015 From: mperes at kemper.freedesktop.org (Martin Peres) Date: Wed, 25 Mar 2015 01:07:16 -0700 (PDT) Subject: Mesa (master): main: Added entry point for glGetTransformFeedbackiv Message-ID: <20150325080716.2990476332@kemper.freedesktop.org> Module: Mesa Branch: master Commit: e59d2434a075176ebc94438f81d742e222da3e82 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=e59d2434a075176ebc94438f81d742e222da3e82 Author: Martin Peres Date: Mon Feb 16 16:13:58 2015 +0200 main: Added entry point for glGetTransformFeedbackiv v2: Review from Laura Ekstrand - use the transform feedback object lookup wrapper Reviewed-by: Laura Ekstrand Signed-off-by: Martin Peres --- src/mapi/glapi/gen/ARB_direct_state_access.xml | 6 ++++++ src/mesa/main/tests/dispatch_sanity.cpp | 1 + src/mesa/main/transformfeedback.c | 25 ++++++++++++++++++++++++ src/mesa/main/transformfeedback.h | 3 +++ 4 files changed, 35 insertions(+) diff --git a/src/mapi/glapi/gen/ARB_direct_state_access.xml b/src/mapi/glapi/gen/ARB_direct_state_access.xml index 2375df4..341181e 100644 --- a/src/mapi/glapi/gen/ARB_direct_state_access.xml +++ b/src/mapi/glapi/gen/ARB_direct_state_access.xml @@ -28,6 +28,12 @@ + + + + + + diff --git a/src/mesa/main/tests/dispatch_sanity.cpp b/src/mesa/main/tests/dispatch_sanity.cpp index a259272..be22fe7 100644 --- a/src/mesa/main/tests/dispatch_sanity.cpp +++ b/src/mesa/main/tests/dispatch_sanity.cpp @@ -925,6 +925,7 @@ const struct function gl_core_functions_possible[] = { { "glCreateTransformFeedbacks", 45, -1 }, { "glTransformFeedbackBufferBase", 45, -1 }, { "glTransformFeedbackBufferRange", 45, -1 }, + { "glGetTransformFeedbackiv", 45, -1 }, { "glCreateBuffers", 45, -1 }, { "glNamedBufferStorage", 45, -1 }, { "glNamedBufferData", 45, -1 }, diff --git a/src/mesa/main/transformfeedback.c b/src/mesa/main/transformfeedback.c index e6b9803..0900d41 100644 --- a/src/mesa/main/transformfeedback.c +++ b/src/mesa/main/transformfeedback.c @@ -1203,3 +1203,28 @@ _mesa_ResumeTransformFeedback(void) assert(ctx->Driver.ResumeTransformFeedback); ctx->Driver.ResumeTransformFeedback(ctx, obj); } + +extern void GLAPIENTRY +_mesa_GetTransformFeedbackiv(GLuint xfb, GLenum pname, GLint *param) +{ + struct gl_transform_feedback_object *obj; + GET_CURRENT_CONTEXT(ctx); + + obj = lookup_transform_feedback_object_err(ctx, xfb, + "glGetTransformFeedbackiv"); + if(!obj) { + return; + } + + switch(pname) { + case GL_TRANSFORM_FEEDBACK_PAUSED: + *param = obj->Paused; + break; + case GL_TRANSFORM_FEEDBACK_ACTIVE: + *param = obj->Active; + break; + default: + _mesa_error(ctx, GL_INVALID_ENUM, + "glGetTransformFeedbackiv(pname=%i)", pname); + } +} diff --git a/src/mesa/main/transformfeedback.h b/src/mesa/main/transformfeedback.h index 9ec7d38..af7d568 100644 --- a/src/mesa/main/transformfeedback.h +++ b/src/mesa/main/transformfeedback.h @@ -156,4 +156,7 @@ extern void GLAPIENTRY _mesa_TransformFeedbackBufferRange(GLuint xfb, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +extern void GLAPIENTRY +_mesa_GetTransformFeedbackiv(GLuint xfb, GLenum pname, GLint *param); + #endif /* TRANSFORM_FEEDBACK_H */ From mperes at kemper.freedesktop.org Wed Mar 25 08:07:15 2015 From: mperes at kemper.freedesktop.org (Martin Peres) Date: Wed, 25 Mar 2015 01:07:15 -0700 (PDT) Subject: Mesa (master): main: replace tabs by 8 spaces in fbobject.c Message-ID: <20150325080715.D1F3E76332@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 7bd8b48084971b1e0d852136e5436776e8ffb044 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=7bd8b48084971b1e0d852136e5436776e8ffb044 Author: Martin Peres Date: Thu Feb 12 17:54:43 2015 +0200 main: replace tabs by 8 spaces in fbobject.c Reviewed-by: Laura Ekstrand Signed-off-by: Martin Peres --- src/mesa/main/fbobject.c | 166 +++++++++++++++++++++++----------------------- 1 file changed, 83 insertions(+), 83 deletions(-) diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c index f8d0d92..bccac91 100644 --- a/src/mesa/main/fbobject.c +++ b/src/mesa/main/fbobject.c @@ -212,13 +212,13 @@ get_attachment(struct gl_context *ctx, struct gl_framebuffer *fb, */ i = attachment - GL_COLOR_ATTACHMENT0_EXT; if (i >= ctx->Const.MaxColorAttachments - || (i > 0 && ctx->API == API_OPENGLES)) { - return NULL; + || (i > 0 && ctx->API == API_OPENGLES)) { + return NULL; } return &fb->Attachment[BUFFER_COLOR0 + i]; case GL_DEPTH_STENCIL_ATTACHMENT: if (!_mesa_is_desktop_gl(ctx) && !_mesa_is_gles3(ctx)) - return NULL; + return NULL; /* fall-through */ case GL_DEPTH_ATTACHMENT_EXT: return &fb->Attachment[BUFFER_DEPTH]; @@ -1122,28 +1122,28 @@ _mesa_test_framebuffer_completeness(struct gl_context *ctx, if (_mesa_is_desktop_gl(ctx) && !ctx->Extensions.ARB_ES2_compatibility) { /* Check that all DrawBuffers are present */ for (j = 0; j < ctx->Const.MaxDrawBuffers; j++) { - if (fb->ColorDrawBuffer[j] != GL_NONE) { - const struct gl_renderbuffer_attachment *att - = get_attachment(ctx, fb, fb->ColorDrawBuffer[j]); - assert(att); - if (att->Type == GL_NONE) { - fb->_Status = GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT; - fbo_incomplete(ctx, "missing drawbuffer", j); - return; - } - } + if (fb->ColorDrawBuffer[j] != GL_NONE) { + const struct gl_renderbuffer_attachment *att + = get_attachment(ctx, fb, fb->ColorDrawBuffer[j]); + assert(att); + if (att->Type == GL_NONE) { + fb->_Status = GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT; + fbo_incomplete(ctx, "missing drawbuffer", j); + return; + } + } } /* Check that the ReadBuffer is present */ if (fb->ColorReadBuffer != GL_NONE) { - const struct gl_renderbuffer_attachment *att - = get_attachment(ctx, fb, fb->ColorReadBuffer); - assert(att); - if (att->Type == GL_NONE) { - fb->_Status = GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT; + const struct gl_renderbuffer_attachment *att + = get_attachment(ctx, fb, fb->ColorReadBuffer); + assert(att); + if (att->Type == GL_NONE) { + fb->_Status = GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT; fbo_incomplete(ctx, "missing readbuffer", -1); - return; - } + return; + } } } @@ -1233,12 +1233,12 @@ bind_renderbuffer(GLenum target, GLuint renderbuffer, bool allow_user_names) } if (!newRb) { - /* create new renderbuffer object */ - newRb = ctx->Driver.NewRenderbuffer(ctx, renderbuffer); - if (!newRb) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glBindRenderbufferEXT"); - return; - } + /* create new renderbuffer object */ + newRb = ctx->Driver.NewRenderbuffer(ctx, renderbuffer); + if (!newRb) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glBindRenderbufferEXT"); + return; + } assert(newRb->AllocStorage); _mesa_HashInsert(ctx->Shared->RenderBuffers, renderbuffer, newRb); newRb->RefCount = 1; /* referenced by hash table */ @@ -1333,9 +1333,9 @@ _mesa_DeleteRenderbuffers(GLsizei n, const GLuint *renderbuffers) for (i = 0; i < n; i++) { if (renderbuffers[i] > 0) { - struct gl_renderbuffer *rb; - rb = _mesa_lookup_renderbuffer(ctx, renderbuffers[i]); - if (rb) { + struct gl_renderbuffer *rb; + rb = _mesa_lookup_renderbuffer(ctx, renderbuffers[i]); + if (rb) { /* check if deleting currently bound renderbuffer object */ if (rb == ctx->CurrentRenderbuffer) { /* bind default */ @@ -1368,17 +1368,17 @@ _mesa_DeleteRenderbuffers(GLsizei n, const GLuint *renderbuffers) _mesa_detach_renderbuffer(ctx, ctx->ReadBuffer, rb); } - /* Remove from hash table immediately, to free the ID. + /* Remove from hash table immediately, to free the ID. * But the object will not be freed until it's no longer * referenced anywhere else. */ - _mesa_HashRemove(ctx->Shared->RenderBuffers, renderbuffers[i]); + _mesa_HashRemove(ctx->Shared->RenderBuffers, renderbuffers[i]); if (rb != &DummyRenderbuffer) { /* no longer referenced by hash table */ _mesa_reference_renderbuffer(&rb, NULL); - } - } + } + } } } } @@ -1941,7 +1941,7 @@ _mesa_RenderbufferStorageMultisample(GLenum target, GLsizei samples, */ void GLAPIENTRY _es_RenderbufferStorageEXT(GLenum target, GLenum internalFormat, - GLsizei width, GLsizei height) + GLsizei width, GLsizei height) { switch (internalFormat) { case GL_RGB565: @@ -2116,12 +2116,12 @@ bind_framebuffer(GLenum target, GLuint framebuffer, bool allow_user_names) } if (!newDrawFb) { - /* create new framebuffer object */ - newDrawFb = ctx->Driver.NewFramebuffer(ctx, framebuffer); - if (!newDrawFb) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glBindFramebufferEXT"); - return; - } + /* create new framebuffer object */ + newDrawFb = ctx->Driver.NewFramebuffer(ctx, framebuffer); + if (!newDrawFb) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glBindFramebufferEXT"); + return; + } _mesa_HashInsert(ctx->Shared->FrameBuffers, framebuffer, newDrawFb); } newReadFb = newDrawFb; @@ -2224,9 +2224,9 @@ _mesa_DeleteFramebuffers(GLsizei n, const GLuint *framebuffers) for (i = 0; i < n; i++) { if (framebuffers[i] > 0) { - struct gl_framebuffer *fb; - fb = _mesa_lookup_framebuffer(ctx, framebuffers[i]); - if (fb) { + struct gl_framebuffer *fb; + fb = _mesa_lookup_framebuffer(ctx, framebuffers[i]); + if (fb) { assert(fb == &DummyFramebuffer || fb->Name == framebuffers[i]); /* check if deleting currently bound framebuffer object */ @@ -2241,16 +2241,16 @@ _mesa_DeleteFramebuffers(GLsizei n, const GLuint *framebuffers) _mesa_BindFramebuffer(GL_READ_FRAMEBUFFER, 0); } - /* remove from hash table immediately, to free the ID */ - _mesa_HashRemove(ctx->Shared->FrameBuffers, framebuffers[i]); + /* remove from hash table immediately, to free the ID */ + _mesa_HashRemove(ctx->Shared->FrameBuffers, framebuffers[i]); if (fb != &DummyFramebuffer) { /* But the object will not be freed until it's no longer * bound in any context. */ _mesa_reference_framebuffer(&fb, NULL); - } - } + } + } } } } @@ -2498,34 +2498,34 @@ framebuffer_texture(struct gl_context *ctx, const char *caller, GLenum target, _mesa_tex_target_to_face(textarget) == fb->Attachment[BUFFER_STENCIL].CubeMapFace && zoffset == fb->Attachment[BUFFER_STENCIL].Zoffset) { - /* The texture object is already attached to the stencil attachment - * point. Don't create a new renderbuffer; just reuse the stencil - * attachment's. This is required to prevent a GL error in - * glGetFramebufferAttachmentParameteriv(GL_DEPTH_STENCIL). - */ - reuse_framebuffer_texture_attachment(fb, BUFFER_DEPTH, - BUFFER_STENCIL); + /* The texture object is already attached to the stencil attachment + * point. Don't create a new renderbuffer; just reuse the stencil + * attachment's. This is required to prevent a GL error in + * glGetFramebufferAttachmentParameteriv(GL_DEPTH_STENCIL). + */ + reuse_framebuffer_texture_attachment(fb, BUFFER_DEPTH, + BUFFER_STENCIL); } else if (attachment == GL_STENCIL_ATTACHMENT && - texObj == fb->Attachment[BUFFER_DEPTH].Texture && + texObj == fb->Attachment[BUFFER_DEPTH].Texture && level == fb->Attachment[BUFFER_DEPTH].TextureLevel && _mesa_tex_target_to_face(textarget) == fb->Attachment[BUFFER_DEPTH].CubeMapFace && zoffset == fb->Attachment[BUFFER_DEPTH].Zoffset) { - /* As above, but with depth and stencil transposed. */ - reuse_framebuffer_texture_attachment(fb, BUFFER_STENCIL, - BUFFER_DEPTH); + /* As above, but with depth and stencil transposed. */ + reuse_framebuffer_texture_attachment(fb, BUFFER_STENCIL, + BUFFER_DEPTH); } else { - set_texture_attachment(ctx, fb, att, texObj, textarget, - level, zoffset, layered); - if (attachment == GL_DEPTH_STENCIL_ATTACHMENT) { - /* Above we created a new renderbuffer and attached it to the - * depth attachment point. Now attach it to the stencil attachment - * point too. - */ - assert(att == &fb->Attachment[BUFFER_DEPTH]); - reuse_framebuffer_texture_attachment(fb,BUFFER_STENCIL, - BUFFER_DEPTH); - } + set_texture_attachment(ctx, fb, att, texObj, textarget, + level, zoffset, layered); + if (attachment == GL_DEPTH_STENCIL_ATTACHMENT) { + /* Above we created a new renderbuffer and attached it to the + * depth attachment point. Now attach it to the stencil attachment + * point too. + */ + assert(att == &fb->Attachment[BUFFER_DEPTH]); + reuse_framebuffer_texture_attachment(fb,BUFFER_STENCIL, + BUFFER_DEPTH); + } } /* Set the render-to-texture flag. We'll check this flag in @@ -2541,8 +2541,8 @@ framebuffer_texture(struct gl_context *ctx, const char *caller, GLenum target, else { remove_attachment(ctx, att); if (attachment == GL_DEPTH_STENCIL_ATTACHMENT) { - assert(att == &fb->Attachment[BUFFER_DEPTH]); - remove_attachment(ctx, &fb->Attachment[BUFFER_STENCIL]); + assert(att == &fb->Attachment[BUFFER_DEPTH]); + remove_attachment(ctx, &fb->Attachment[BUFFER_STENCIL]); } } @@ -2721,16 +2721,16 @@ _mesa_FramebufferRenderbuffer(GLenum target, GLenum attachment, if (renderbuffer) { rb = _mesa_lookup_renderbuffer(ctx, renderbuffer); if (!rb) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glFramebufferRenderbuffer(non-existant" + _mesa_error(ctx, GL_INVALID_OPERATION, + "glFramebufferRenderbuffer(non-existant" " renderbuffer %u)", renderbuffer); - return; + return; } else if (rb == &DummyRenderbuffer) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glFramebufferRenderbuffer(renderbuffer %u)", + _mesa_error(ctx, GL_INVALID_OPERATION, + "glFramebufferRenderbuffer(renderbuffer %u)", renderbuffer); - return; + return; } } else { @@ -2795,9 +2795,9 @@ _mesa_GetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, if ((!_mesa_is_desktop_gl(ctx) || !ctx->Extensions.ARB_framebuffer_object) && !_mesa_is_gles3(ctx)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glGetFramebufferAttachmentParameteriv(bound FBO = 0)"); - return; + _mesa_error(ctx, GL_INVALID_OPERATION, + "glGetFramebufferAttachmentParameteriv(bound FBO = 0)"); + return; } if (_mesa_is_gles3(ctx) && attachment != GL_BACK && @@ -2855,10 +2855,10 @@ _mesa_GetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, return; case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT: if (att->Type == GL_RENDERBUFFER_EXT) { - *params = att->Renderbuffer->Name; + *params = att->Renderbuffer->Name; } else if (att->Type == GL_TEXTURE) { - *params = att->Texture->Name; + *params = att->Texture->Name; } else { assert(att->Type == GL_NONE); @@ -2871,7 +2871,7 @@ _mesa_GetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, return; case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT: if (att->Type == GL_TEXTURE) { - *params = att->TextureLevel; + *params = att->TextureLevel; } else if (att->Type == GL_NONE) { _mesa_error(ctx, err, From mperes at kemper.freedesktop.org Wed Mar 25 08:07:15 2015 From: mperes at kemper.freedesktop.org (Martin Peres) Date: Wed, 25 Mar 2015 01:07:15 -0700 (PDT) Subject: Mesa (master): main: Added entry point for glCreateTransformFeedbacks Message-ID: <20150325080715.EE75576332@kemper.freedesktop.org> Module: Mesa Branch: master Commit: c86cb2da255216524974eb1c92caa1ecb378e32e URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=c86cb2da255216524974eb1c92caa1ecb378e32e Author: Martin Peres Date: Wed Jan 14 18:17:21 2015 +0200 main: Added entry point for glCreateTransformFeedbacks v2: Review from Laura Ekstrand - generate the name of the gl method once - shorten some lines to stay in the 78 chars limit v3: Review from Fredrik H?glund - rename gl_mthd_name to func - set EverBound in _mesa_create_transform_feedbacks in the dsa case v4: - rename _mesa_create_transform_feedbacks to create_transform_feedbacks and make it static Reviewed-by: Laura Ekstrand Signed-off-by: Martin Peres --- src/mapi/glapi/gen/ARB_direct_state_access.xml | 7 +++ src/mesa/main/tests/dispatch_sanity.cpp | 1 + src/mesa/main/transformfeedback.c | 67 ++++++++++++++++++------ src/mesa/main/transformfeedback.h | 3 ++ 4 files changed, 63 insertions(+), 15 deletions(-) diff --git a/src/mapi/glapi/gen/ARB_direct_state_access.xml b/src/mapi/glapi/gen/ARB_direct_state_access.xml index 641e68f..0c7e880 100644 --- a/src/mapi/glapi/gen/ARB_direct_state_access.xml +++ b/src/mapi/glapi/gen/ARB_direct_state_access.xml @@ -7,6 +7,13 @@ + + + + + + + diff --git a/src/mesa/main/tests/dispatch_sanity.cpp b/src/mesa/main/tests/dispatch_sanity.cpp index 59ebb21..899a188 100644 --- a/src/mesa/main/tests/dispatch_sanity.cpp +++ b/src/mesa/main/tests/dispatch_sanity.cpp @@ -922,6 +922,7 @@ const struct function gl_core_functions_possible[] = { { "glClipControl", 45, -1 }, /* GL_ARB_direct_state_access */ + { "glCreateTransformFeedbacks", 45, -1 }, { "glCreateBuffers", 45, -1 }, { "glNamedBufferStorage", 45, -1 }, { "glNamedBufferData", 45, -1 }, diff --git a/src/mesa/main/transformfeedback.c b/src/mesa/main/transformfeedback.c index ce678c8..3c19406 100644 --- a/src/mesa/main/transformfeedback.c +++ b/src/mesa/main/transformfeedback.c @@ -825,25 +825,24 @@ _mesa_lookup_transform_feedback_object(struct gl_context *ctx, GLuint name) _mesa_HashLookup(ctx->TransformFeedback.Objects, name); } - -/** - * Create new transform feedback objects. Transform feedback objects - * encapsulate the state related to transform feedback to allow quickly - * switching state (and drawing the results, below). - * Part of GL_ARB_transform_feedback2. - */ -void GLAPIENTRY -_mesa_GenTransformFeedbacks(GLsizei n, GLuint *names) +static void +create_transform_feedbacks(struct gl_context *ctx, GLsizei n, GLuint *ids, + bool dsa) { GLuint first; - GET_CURRENT_CONTEXT(ctx); + const char* func; + + if (dsa) + func = "glCreateTransformFeedbacks"; + else + func = "glGenTransformFeedbacks"; if (n < 0) { - _mesa_error(ctx, GL_INVALID_VALUE, "glGenTransformFeedbacks(n < 0)"); + _mesa_error(ctx, GL_INVALID_VALUE, "%s(n < 0)", func); return; } - if (!names) + if (!ids) return; /* we don't need contiguous IDs, but this might be faster */ @@ -854,18 +853,56 @@ _mesa_GenTransformFeedbacks(GLsizei n, GLuint *names) struct gl_transform_feedback_object *obj = ctx->Driver.NewTransformFeedback(ctx, first + i); if (!obj) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glGenTransformFeedbacks"); + _mesa_error(ctx, GL_OUT_OF_MEMORY, "%s", func); return; } - names[i] = first + i; + ids[i] = first + i; _mesa_HashInsert(ctx->TransformFeedback.Objects, first + i, obj); + if (dsa) { + /* this is normally done at bind time in the non-dsa case */ + obj->EverBound = GL_TRUE; + } } } else { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glGenTransformFeedbacks"); + _mesa_error(ctx, GL_OUT_OF_MEMORY, "%s", func); } } +/** + * Create new transform feedback objects. Transform feedback objects + * encapsulate the state related to transform feedback to allow quickly + * switching state (and drawing the results, below). + * Part of GL_ARB_transform_feedback2. + */ +void GLAPIENTRY +_mesa_GenTransformFeedbacks(GLsizei n, GLuint *names) +{ + GET_CURRENT_CONTEXT(ctx); + + /* GenTransformFeedbacks should just reserve the object names that a + * subsequent call to BindTransformFeedback should actively create. For + * the sake of simplicity, we reserve the names and create the objects + * straight away. + */ + + create_transform_feedbacks(ctx, n, names, false); +} + +/** + * Create new transform feedback objects. Transform feedback objects + * encapsulate the state related to transform feedback to allow quickly + * switching state (and drawing the results, below). + * Part of GL_ARB_direct_state_access. + */ +void GLAPIENTRY +_mesa_CreateTransformFeedbacks(GLsizei n, GLuint *names) +{ + GET_CURRENT_CONTEXT(ctx); + + create_transform_feedbacks(ctx, n, names, true); +} + /** * Is the given ID a transform feedback object? diff --git a/src/mesa/main/transformfeedback.h b/src/mesa/main/transformfeedback.h index 87f4080..9de1fef 100644 --- a/src/mesa/main/transformfeedback.h +++ b/src/mesa/main/transformfeedback.h @@ -102,6 +102,9 @@ _mesa_lookup_transform_feedback_object(struct gl_context *ctx, GLuint name); extern void GLAPIENTRY _mesa_GenTransformFeedbacks(GLsizei n, GLuint *names); +extern void GLAPIENTRY +_mesa_CreateTransformFeedbacks(GLsizei n, GLuint *names); + extern GLboolean GLAPIENTRY _mesa_IsTransformFeedback(GLuint name); From mperes at kemper.freedesktop.org Wed Mar 25 08:07:16 2015 From: mperes at kemper.freedesktop.org (Martin Peres) Date: Wed, 25 Mar 2015 01:07:16 -0700 (PDT) Subject: Mesa (master): main: Added entry point for glTransformFeedbackBufferBase Message-ID: <20150325080716.0B68376332@kemper.freedesktop.org> Module: Mesa Branch: master Commit: a5d165afed8dae34f0b4f281fc1c390d019e9b97 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=a5d165afed8dae34f0b4f281fc1c390d019e9b97 Author: Martin Peres Date: Tue Jan 20 16:30:32 2015 +0200 main: Added entry point for glTransformFeedbackBufferBase v2: Review from Laura Ekstrand - give more helpful error messages - factor the lookup code for the xfb and objBuf - replace some already-existing tabs with spaces - add comments to explain the cases where xfb == 0 or buffer == 0 - fix the condition for binding the transform buffer or not v3: Review from Laura Ekstrand - rename _mesa_lookup_bufferobj_err to _mesa_lookup_transform_feedback_bufferobj_err and make it static to avoid a future conflict - make _mesa_lookup_transform_feedback_object_err static v4: Review from Laura Ekstrand - add the pdf page number when quoting the spec - rename some of the symbols to follow the public/private conventions v5: Review from Laura Ekstrand - properly rename some of the symbols to follow the public/private conventions - fix some alignments - add quotes around a spec citation - add back a newline I accidentally deleted - add spaces around the ternary operator usages Signed-off-by: Martin Peres Reviewed-by: Laura Ekstrand --- src/mapi/glapi/gen/ARB_direct_state_access.xml | 6 ++ src/mesa/main/bufferobj.c | 9 +- src/mesa/main/tests/dispatch_sanity.cpp | 1 + src/mesa/main/transformfeedback.c | 138 ++++++++++++++++++------ src/mesa/main/transformfeedback.h | 10 +- 5 files changed, 129 insertions(+), 35 deletions(-) diff --git a/src/mapi/glapi/gen/ARB_direct_state_access.xml b/src/mapi/glapi/gen/ARB_direct_state_access.xml index 0c7e880..02e33cd 100644 --- a/src/mapi/glapi/gen/ARB_direct_state_access.xml +++ b/src/mapi/glapi/gen/ARB_direct_state_access.xml @@ -14,6 +14,12 @@ + + + + + + diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c index 9658770..e737936 100644 --- a/src/mesa/main/bufferobj.c +++ b/src/mesa/main/bufferobj.c @@ -3885,8 +3885,9 @@ _mesa_BindBufferRange(GLenum target, GLuint index, switch (target) { case GL_TRANSFORM_FEEDBACK_BUFFER: - _mesa_bind_buffer_range_transform_feedback(ctx, index, bufObj, - offset, size); + _mesa_bind_buffer_range_transform_feedback(ctx, + ctx->TransformFeedback.CurrentObject, + index, bufObj, offset, size); return; case GL_UNIFORM_BUFFER: bind_buffer_range_uniform_buffer(ctx, index, bufObj, offset, size); @@ -3950,7 +3951,9 @@ _mesa_BindBufferBase(GLenum target, GLuint index, GLuint buffer) switch (target) { case GL_TRANSFORM_FEEDBACK_BUFFER: - _mesa_bind_buffer_base_transform_feedback(ctx, index, bufObj); + _mesa_bind_buffer_base_transform_feedback(ctx, + ctx->TransformFeedback.CurrentObject, + index, bufObj, false); return; case GL_UNIFORM_BUFFER: bind_buffer_base_uniform_buffer(ctx, index, bufObj); diff --git a/src/mesa/main/tests/dispatch_sanity.cpp b/src/mesa/main/tests/dispatch_sanity.cpp index 899a188..315571d 100644 --- a/src/mesa/main/tests/dispatch_sanity.cpp +++ b/src/mesa/main/tests/dispatch_sanity.cpp @@ -923,6 +923,7 @@ const struct function gl_core_functions_possible[] = { /* GL_ARB_direct_state_access */ { "glCreateTransformFeedbacks", 45, -1 }, + { "glTransformFeedbackBufferBase", 45, -1 }, { "glCreateBuffers", 45, -1 }, { "glNamedBufferStorage", 45, -1 }, { "glNamedBufferData", 45, -1 }, diff --git a/src/mesa/main/transformfeedback.c b/src/mesa/main/transformfeedback.c index 3c19406..1b2bd8d 100644 --- a/src/mesa/main/transformfeedback.c +++ b/src/mesa/main/transformfeedback.c @@ -514,22 +514,24 @@ _mesa_EndTransformFeedback(void) * Helper used by BindBufferRange() and BindBufferBase(). */ static void -bind_buffer_range(struct gl_context *ctx, GLuint index, +bind_buffer_range(struct gl_context *ctx, + struct gl_transform_feedback_object *obj, + GLuint index, struct gl_buffer_object *bufObj, - GLintptr offset, GLsizeiptr size) + GLintptr offset, GLsizeiptr size, + bool dsa) { - struct gl_transform_feedback_object *obj = - ctx->TransformFeedback.CurrentObject; - /* Note: no need to FLUSH_VERTICES or flag NewTransformFeedback, because * transform feedback buffers can't be changed while transform feedback is * active. */ - /* The general binding point */ - _mesa_reference_buffer_object(ctx, - &ctx->TransformFeedback.CurrentBuffer, - bufObj); + if (!dsa) { + /* The general binding point */ + _mesa_reference_buffer_object(ctx, + &ctx->TransformFeedback.CurrentBuffer, + bufObj); + } /* The per-attribute binding point */ _mesa_set_transform_feedback_binding(ctx, obj, index, bufObj, offset, size); @@ -543,15 +545,12 @@ bind_buffer_range(struct gl_context *ctx, GLuint index, */ void _mesa_bind_buffer_range_transform_feedback(struct gl_context *ctx, - GLuint index, - struct gl_buffer_object *bufObj, - GLintptr offset, - GLsizeiptr size) + struct gl_transform_feedback_object *obj, + GLuint index, + struct gl_buffer_object *bufObj, + GLintptr offset, + GLsizeiptr size) { - struct gl_transform_feedback_object *obj; - - obj = ctx->TransformFeedback.CurrentObject; - if (obj->Active) { _mesa_error(ctx, GL_INVALID_OPERATION, "glBindBufferRange(transform feedback active)"); @@ -559,13 +558,15 @@ _mesa_bind_buffer_range_transform_feedback(struct gl_context *ctx, } if (index >= ctx->Const.MaxTransformFeedbackBuffers) { - _mesa_error(ctx, GL_INVALID_VALUE, "glBindBufferRange(index=%d)", index); + _mesa_error(ctx, GL_INVALID_VALUE, "glBindBufferRange(index=%d " + "out of bounds)", index); return; } if (size & 0x3) { /* must a multiple of four */ - _mesa_error(ctx, GL_INVALID_VALUE, "glBindBufferRange(size=%d)", (int) size); + _mesa_error(ctx, GL_INVALID_VALUE, "glBindBufferRange(size=%d)", + (int) size); return; } @@ -576,38 +577,109 @@ _mesa_bind_buffer_range_transform_feedback(struct gl_context *ctx, return; } - bind_buffer_range(ctx, index, bufObj, offset, size); + bind_buffer_range(ctx, obj, index, bufObj, offset, size, false); } /** * Specify a buffer object to receive transform feedback results. * As above, but start at offset = 0. - * Called from the glBindBufferBase() function. + * Called from the glBindBufferBase() and glTransformFeedbackBufferBase() + * functions. */ void _mesa_bind_buffer_base_transform_feedback(struct gl_context *ctx, - GLuint index, - struct gl_buffer_object *bufObj) + struct gl_transform_feedback_object *obj, + GLuint index, + struct gl_buffer_object *bufObj, + bool dsa) { - struct gl_transform_feedback_object *obj; - - obj = ctx->TransformFeedback.CurrentObject; - if (obj->Active) { _mesa_error(ctx, GL_INVALID_OPERATION, - "glBindBufferBase(transform feedback active)"); + "%s(transform feedback active)", + dsa ? "glTransformFeedbackBufferBase" : "glBindBufferBase"); return; } if (index >= ctx->Const.MaxTransformFeedbackBuffers) { - _mesa_error(ctx, GL_INVALID_VALUE, "glBindBufferBase(index=%d)", index); + _mesa_error(ctx, GL_INVALID_VALUE, "%s(index=%d out of bounds)", + dsa ? "glTransformFeedbackBufferBase" : "glBindBufferBase", + index); return; } - bind_buffer_range(ctx, index, bufObj, 0, 0); + bind_buffer_range(ctx, obj, index, bufObj, 0, 0, dsa); } +/** + * Wrapper around lookup_transform_feedback_object that throws + * GL_INVALID_OPERATION if id is not in the hash table. After calling + * _mesa_error, it returns NULL. + */ +static struct gl_transform_feedback_object * +lookup_transform_feedback_object_err(struct gl_context *ctx, + GLuint xfb, const char* func) +{ + struct gl_transform_feedback_object *obj; + + obj = _mesa_lookup_transform_feedback_object(ctx, xfb); + if (!obj) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "%s(xfb=%u: non-generated object name)", func, xfb); + } + + return obj; +} + +/** + * Wrapper around _mesa_lookup_bufferobj that throws GL_INVALID_VALUE if id + * is not in the hash table. Specialised version for the + * transform-feedback-related functions. After calling _mesa_error, it + * returns NULL. + */ +static struct gl_buffer_object * +lookup_transform_feedback_bufferobj_err(struct gl_context *ctx, + GLuint buffer, const char* func) +{ + struct gl_buffer_object *bufObj; + + /* OpenGL 4.5 core profile, 13.2, pdf page 444: buffer must be zero or the + * name of an existing buffer object. + */ + if (buffer == 0) { + bufObj = ctx->Shared->NullBufferObj; + } else { + bufObj = _mesa_lookup_bufferobj(ctx, buffer); + if (!bufObj) { + _mesa_error(ctx, GL_INVALID_VALUE, "%s(invalid buffer=%u)", func, + buffer); + } + } + + return bufObj; +} + +void GLAPIENTRY +_mesa_TransformFeedbackBufferBase(GLuint xfb, GLuint index, GLuint buffer) +{ + GET_CURRENT_CONTEXT(ctx); + struct gl_transform_feedback_object *obj; + struct gl_buffer_object *bufObj; + + obj = lookup_transform_feedback_object_err(ctx, xfb, + "glTransformFeedbackBufferBase"); + if(!obj) { + return; + } + + bufObj = lookup_transform_feedback_bufferobj_err(ctx, buffer, + "glTransformFeedbackBufferBase"); + if(!bufObj) { + return; + } + + _mesa_bind_buffer_base_transform_feedback(ctx, obj, index, bufObj, true); +} /** * Specify a buffer object to receive transform feedback results, plus the @@ -660,7 +732,7 @@ _mesa_BindBufferOffsetEXT(GLenum target, GLuint index, GLuint buffer, return; } - bind_buffer_range(ctx, index, bufObj, offset, 0); + bind_buffer_range(ctx, obj, index, bufObj, offset, 0, false); } @@ -817,6 +889,10 @@ _mesa_GetTransformFeedbackVarying(GLuint program, GLuint index, struct gl_transform_feedback_object * _mesa_lookup_transform_feedback_object(struct gl_context *ctx, GLuint name) { + /* OpenGL 4.5 core profile, 13.2 pdf page 444: "xfb must be zero, indicating + * the default transform feedback object, or the name of an existing + * transform feedback object." + */ if (name == 0) { return ctx->TransformFeedback.DefaultObject; } diff --git a/src/mesa/main/transformfeedback.h b/src/mesa/main/transformfeedback.h index 9de1fef..aac7433 100644 --- a/src/mesa/main/transformfeedback.h +++ b/src/mesa/main/transformfeedback.h @@ -65,6 +65,7 @@ _mesa_EndTransformFeedback(void); extern void _mesa_bind_buffer_range_transform_feedback(struct gl_context *ctx, + struct gl_transform_feedback_object *obj, GLuint index, struct gl_buffer_object *bufObj, GLintptr offset, @@ -72,8 +73,10 @@ _mesa_bind_buffer_range_transform_feedback(struct gl_context *ctx, extern void _mesa_bind_buffer_base_transform_feedback(struct gl_context *ctx, + struct gl_transform_feedback_object *obj, GLuint index, - struct gl_buffer_object *bufObj); + struct gl_buffer_object *bufObj, + bool dsa); extern void GLAPIENTRY _mesa_BindBufferOffsetEXT(GLenum target, GLuint index, GLuint buffer, @@ -144,4 +147,9 @@ _mesa_set_transform_feedback_binding(struct gl_context *ctx, tfObj->RequestedSize[index] = size; } +/*** GL_ARB_direct_state_access ***/ + +extern void GLAPIENTRY +_mesa_TransformFeedbackBufferBase(GLuint xfb, GLuint index, GLuint buffer); + #endif /* TRANSFORM_FEEDBACK_H */ From mperes at kemper.freedesktop.org Wed Mar 25 08:07:16 2015 From: mperes at kemper.freedesktop.org (Martin Peres) Date: Wed, 25 Mar 2015 01:07:16 -0700 (PDT) Subject: Mesa (master): main: Added entry point for glGetTransformFeedbacki64_v Message-ID: <20150325080716.4508876332@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 6ead10d08f0a4e0ccc699437ed424a0019c07ef8 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=6ead10d08f0a4e0ccc699437ed424a0019c07ef8 Author: Martin Peres Date: Thu Jan 22 16:55:29 2015 +0200 main: Added entry point for glGetTransformFeedbacki64_v v2: Review from Laura Ekstrand - use the transform feedback object lookup wrapper v3: - use the new name of _mesa_lookup_transform_feedback_object_err v4: Review from Laura Ekstrand - fix some alignement problems Reviewed-by: Laura Ekstrand Signed-off-by: Martin Peres --- src/mapi/glapi/gen/ARB_direct_state_access.xml | 7 ++++++ src/mesa/main/tests/dispatch_sanity.cpp | 1 + src/mesa/main/transformfeedback.c | 32 ++++++++++++++++++++++++ src/mesa/main/transformfeedback.h | 4 +++ 4 files changed, 44 insertions(+) diff --git a/src/mapi/glapi/gen/ARB_direct_state_access.xml b/src/mapi/glapi/gen/ARB_direct_state_access.xml index 89b1c7f..51de351 100644 --- a/src/mapi/glapi/gen/ARB_direct_state_access.xml +++ b/src/mapi/glapi/gen/ARB_direct_state_access.xml @@ -41,6 +41,13 @@ + + + + + + + diff --git a/src/mesa/main/tests/dispatch_sanity.cpp b/src/mesa/main/tests/dispatch_sanity.cpp index c31ce43..e963162 100644 --- a/src/mesa/main/tests/dispatch_sanity.cpp +++ b/src/mesa/main/tests/dispatch_sanity.cpp @@ -927,6 +927,7 @@ const struct function gl_core_functions_possible[] = { { "glTransformFeedbackBufferRange", 45, -1 }, { "glGetTransformFeedbackiv", 45, -1 }, { "glGetTransformFeedbacki_v", 45, -1 }, + { "glGetTransformFeedbacki64_v", 45, -1 }, { "glCreateBuffers", 45, -1 }, { "glNamedBufferStorage", 45, -1 }, { "glNamedBufferData", 45, -1 }, diff --git a/src/mesa/main/transformfeedback.c b/src/mesa/main/transformfeedback.c index 4f9dada..0a6d00c 100644 --- a/src/mesa/main/transformfeedback.c +++ b/src/mesa/main/transformfeedback.c @@ -1257,3 +1257,35 @@ _mesa_GetTransformFeedbacki_v(GLuint xfb, GLenum pname, GLuint index, "glGetTransformFeedbacki_v(pname=%i)", pname); } } + +extern void GLAPIENTRY +_mesa_GetTransformFeedbacki64_v(GLuint xfb, GLenum pname, GLuint index, + GLint64 *param) +{ + struct gl_transform_feedback_object *obj; + GET_CURRENT_CONTEXT(ctx); + + obj = lookup_transform_feedback_object_err(ctx, xfb, + "glGetTransformFeedbacki64_v"); + if(!obj) { + return; + } + + if (index >= ctx->Const.MaxTransformFeedbackBuffers) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glGetTransformFeedbacki64_v(index=%i)", index); + return; + } + + switch(pname) { + case GL_TRANSFORM_FEEDBACK_BUFFER_START: + *param = obj->Offset[index]; + break; + case GL_TRANSFORM_FEEDBACK_BUFFER_SIZE: + *param = obj->RequestedSize[index]; + break; + default: + _mesa_error(ctx, GL_INVALID_ENUM, + "glGetTransformFeedbacki64_v(pname=%i)", pname); + } +} diff --git a/src/mesa/main/transformfeedback.h b/src/mesa/main/transformfeedback.h index 631ab2f..bb9729c 100644 --- a/src/mesa/main/transformfeedback.h +++ b/src/mesa/main/transformfeedback.h @@ -163,4 +163,8 @@ extern void GLAPIENTRY _mesa_GetTransformFeedbacki_v(GLuint xfb, GLenum pname, GLuint index, GLint *param); +extern void GLAPIENTRY +_mesa_GetTransformFeedbacki64_v(GLuint xfb, GLenum pname, GLuint index, + GLint64 *param); + #endif /* TRANSFORM_FEEDBACK_H */ From mperes at kemper.freedesktop.org Wed Mar 25 08:07:16 2015 From: mperes at kemper.freedesktop.org (Martin Peres) Date: Wed, 25 Mar 2015 01:07:16 -0700 (PDT) Subject: Mesa (master): main: Added entry point for glCreateQueries Message-ID: <20150325080716.51D6E76332@kemper.freedesktop.org> Module: Mesa Branch: master Commit: c3c1ed874e57b439e856a3eec735181b3221730e URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=c3c1ed874e57b439e856a3eec735181b3221730e Author: Martin Peres Date: Tue Feb 10 17:13:06 2015 +0200 main: Added entry point for glCreateQueries v2: - display the name of the target instead of its id (Laura) Reviewed-by: Laura Ekstrand Signed-off-by: Martin Peres --- src/mapi/glapi/gen/ARB_direct_state_access.xml | 8 +++ src/mesa/main/queryobj.c | 76 +++++++++++++++++++++--- src/mesa/main/queryobj.h | 2 + src/mesa/main/tests/dispatch_sanity.cpp | 1 + 4 files changed, 80 insertions(+), 7 deletions(-) diff --git a/src/mapi/glapi/gen/ARB_direct_state_access.xml b/src/mapi/glapi/gen/ARB_direct_state_access.xml index 51de351..a6d991c 100644 --- a/src/mapi/glapi/gen/ARB_direct_state_access.xml +++ b/src/mapi/glapi/gen/ARB_direct_state_access.xml @@ -420,5 +420,13 @@ + + + + + + + + diff --git a/src/mesa/main/queryobj.c b/src/mesa/main/queryobj.c index 067d6c1..1935058 100644 --- a/src/mesa/main/queryobj.c +++ b/src/mesa/main/queryobj.c @@ -233,18 +233,22 @@ get_query_binding_point(struct gl_context *ctx, GLenum target, GLuint index) } } - -void GLAPIENTRY -_mesa_GenQueries(GLsizei n, GLuint *ids) +/** + * Create $n query objects and store them in *ids. Make them of type $target + * if dsa is set. Called from _mesa_GenQueries() and _mesa_CreateQueries(). + */ +static void +create_queries(struct gl_context *ctx, GLenum target, GLsizei n, GLuint *ids, + bool dsa) { + const char *func = dsa ? "glGenQueries" : "glCreateQueries"; GLuint first; - GET_CURRENT_CONTEXT(ctx); if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, "glGenQueries(%d)\n", n); + _mesa_debug(ctx, "%s(%d)\n", func, n); if (n < 0) { - _mesa_error(ctx, GL_INVALID_VALUE, "glGenQueriesARB(n < 0)"); + _mesa_error(ctx, GL_INVALID_VALUE, "%s(n < 0)", func); return; } @@ -255,8 +259,12 @@ _mesa_GenQueries(GLsizei n, GLuint *ids) struct gl_query_object *q = ctx->Driver.NewQueryObject(ctx, first + i); if (!q) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glGenQueriesARB"); + _mesa_error(ctx, GL_OUT_OF_MEMORY, "%s", func); return; + } else if (dsa) { + /* Do the equivalent of binding the buffer with a target */ + q->Target = target; + q->EverBound = GL_TRUE; } ids[i] = first + i; _mesa_HashInsert(ctx->Query.QueryObjects, first + i, q); @@ -264,6 +272,36 @@ _mesa_GenQueries(GLsizei n, GLuint *ids) } } +void GLAPIENTRY +_mesa_GenQueries(GLsizei n, GLuint *ids) +{ + GET_CURRENT_CONTEXT(ctx); + create_queries(ctx, 0, n, ids, false); +} + +void GLAPIENTRY +_mesa_CreateQueries(GLenum target, GLsizei n, GLuint *ids) +{ + GET_CURRENT_CONTEXT(ctx); + + switch (target) { + case GL_SAMPLES_PASSED: + case GL_ANY_SAMPLES_PASSED: + case GL_ANY_SAMPLES_PASSED_CONSERVATIVE: + case GL_TIME_ELAPSED: + case GL_TIMESTAMP: + case GL_PRIMITIVES_GENERATED: + case GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN: + break; + default: + _mesa_error(ctx, GL_INVALID_ENUM, "glCreateQueries(invalid target = %s)", + _mesa_lookup_enum_by_nr(target)); + return; + } + + create_queries(ctx, target, n, ids, true); +} + void GLAPIENTRY _mesa_DeleteQueries(GLsizei n, const GLuint *ids) @@ -424,6 +462,18 @@ _mesa_BeginQueryIndexed(GLenum target, GLuint index, GLuint id) } } + /* This possibly changes the target of a buffer allocated by + * CreateQueries. Issue 39) in the ARB_direct_state_access extension states + * the following: + * + * "CreateQueries adds a , so strictly speaking the + * command isn't needed for BeginQuery/EndQuery, but in the end, this also + * isn't a selector, so we decided not to change it." + * + * Updating the target of the query object should be acceptable, so let's + * do that. + */ + q->Target = target; q->Active = GL_TRUE; q->Result = 0; @@ -541,6 +591,18 @@ _mesa_QueryCounter(GLuint id, GLenum target) return; } + /* This possibly changes the target of a buffer allocated by + * CreateQueries. Issue 39) in the ARB_direct_state_access extension states + * the following: + * + * "CreateQueries adds a , so strictly speaking the + * command isn't needed for BeginQuery/EndQuery, but in the end, this also + * isn't a selector, so we decided not to change it." + * + * Updating the target of the query object should be acceptable, so let's + * do that. + */ + q->Target = target; q->Result = 0; q->Ready = GL_FALSE; diff --git a/src/mesa/main/queryobj.h b/src/mesa/main/queryobj.h index 6cbcabd..431d420 100644 --- a/src/mesa/main/queryobj.h +++ b/src/mesa/main/queryobj.h @@ -51,6 +51,8 @@ _mesa_free_queryobj_data(struct gl_context *ctx); void GLAPIENTRY _mesa_GenQueries(GLsizei n, GLuint *ids); void GLAPIENTRY +_mesa_CreateQueries(GLenum target, GLsizei n, GLuint *ids); +void GLAPIENTRY _mesa_DeleteQueries(GLsizei n, const GLuint *ids); GLboolean GLAPIENTRY _mesa_IsQuery(GLuint id); diff --git a/src/mesa/main/tests/dispatch_sanity.cpp b/src/mesa/main/tests/dispatch_sanity.cpp index e963162..e5362fb 100644 --- a/src/mesa/main/tests/dispatch_sanity.cpp +++ b/src/mesa/main/tests/dispatch_sanity.cpp @@ -976,6 +976,7 @@ const struct function gl_core_functions_possible[] = { { "glTextureStorage3DMultisample", 45, -1 }, { "glTextureBuffer", 45, -1 }, { "glTextureBufferRange", 45, -1 }, + { "glCreateQueries", 45, -1 }, /* GL_EXT_polygon_offset_clamp */ { "glPolygonOffsetClampEXT", 11, -1 }, From mperes at kemper.freedesktop.org Wed Mar 25 08:07:16 2015 From: mperes at kemper.freedesktop.org (Martin Peres) Date: Wed, 25 Mar 2015 01:07:16 -0700 (PDT) Subject: Mesa (master): main: Added entry point for glCreateProgramPipelines Message-ID: <20150325080716.6E6E876332@kemper.freedesktop.org> Module: Mesa Branch: master Commit: b09f2ee8f7b76f30a75eec61ea8225a434365d49 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=b09f2ee8f7b76f30a75eec61ea8225a434365d49 Author: Martin Peres Date: Wed Feb 11 18:12:21 2015 +0200 main: Added entry point for glCreateProgramPipelines v2: - add spaces in an error message (Laura) Reviewed-by: Laura Ekstrand Signed-off-by: Martin Peres --- src/mapi/glapi/gen/ARB_direct_state_access.xml | 7 +++++ src/mesa/main/pipelineobj.c | 35 ++++++++++++++++++++---- src/mesa/main/pipelineobj.h | 3 ++ src/mesa/main/tests/dispatch_sanity.cpp | 1 + 4 files changed, 40 insertions(+), 6 deletions(-) diff --git a/src/mapi/glapi/gen/ARB_direct_state_access.xml b/src/mapi/glapi/gen/ARB_direct_state_access.xml index 05b9f3f..9d7a59a 100644 --- a/src/mapi/glapi/gen/ARB_direct_state_access.xml +++ b/src/mapi/glapi/gen/ARB_direct_state_access.xml @@ -420,6 +420,13 @@ + + + + + + + diff --git a/src/mesa/main/pipelineobj.c b/src/mesa/main/pipelineobj.c index fb241af..0fefa7d 100644 --- a/src/mesa/main/pipelineobj.c +++ b/src/mesa/main/pipelineobj.c @@ -498,16 +498,18 @@ _mesa_DeleteProgramPipelines(GLsizei n, const GLuint *pipelines) * \param n Number of IDs to generate. * \param pipelines pipeline of \c n locations to store the IDs. */ -void GLAPIENTRY -_mesa_GenProgramPipelines(GLsizei n, GLuint *pipelines) +static void +create_program_pipelines(struct gl_context *ctx, GLsizei n, GLuint *pipelines, + bool dsa) { - GET_CURRENT_CONTEXT(ctx); - + const char *func; GLuint first; GLint i; + func = dsa ? "glCreateProgramPipelines" : "glGenProgramPipelines"; + if (n < 0) { - _mesa_error(ctx, GL_INVALID_VALUE, "glGenProgramPipelines(n<0)"); + _mesa_error(ctx, GL_INVALID_VALUE, "%s (n < 0)", func); return; } @@ -523,16 +525,37 @@ _mesa_GenProgramPipelines(GLsizei n, GLuint *pipelines) obj = _mesa_new_pipeline_object(ctx, name); if (!obj) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glGenProgramPipelines"); + _mesa_error(ctx, GL_OUT_OF_MEMORY, "%s", func); return; } + if (dsa) { + /* make dsa-allocated objects behave like program objects */ + obj->EverBound = GL_TRUE; + } + save_pipeline_object(ctx, obj); pipelines[i] = first + i; } } +void GLAPIENTRY +_mesa_GenProgramPipelines(GLsizei n, GLuint *pipelines) +{ + GET_CURRENT_CONTEXT(ctx); + + create_program_pipelines(ctx, n, pipelines, false); +} + +void GLAPIENTRY +_mesa_CreateProgramPipelines(GLsizei n, GLuint *pipelines) +{ + GET_CURRENT_CONTEXT(ctx); + + create_program_pipelines(ctx, n, pipelines, true); +} + /** * Determine if ID is the name of an pipeline object. * diff --git a/src/mesa/main/pipelineobj.h b/src/mesa/main/pipelineobj.h index 7285a78..b57bcb9 100644 --- a/src/mesa/main/pipelineobj.h +++ b/src/mesa/main/pipelineobj.h @@ -82,6 +82,9 @@ _mesa_DeleteProgramPipelines(GLsizei n, const GLuint *pipelines); extern void GLAPIENTRY _mesa_GenProgramPipelines(GLsizei n, GLuint *pipelines); +void GLAPIENTRY +_mesa_CreateProgramPipelines(GLsizei n, GLuint *pipelines); + extern GLboolean GLAPIENTRY _mesa_IsProgramPipeline(GLuint pipeline); diff --git a/src/mesa/main/tests/dispatch_sanity.cpp b/src/mesa/main/tests/dispatch_sanity.cpp index c6dd50b..cc14674 100644 --- a/src/mesa/main/tests/dispatch_sanity.cpp +++ b/src/mesa/main/tests/dispatch_sanity.cpp @@ -976,6 +976,7 @@ const struct function gl_core_functions_possible[] = { { "glTextureStorage3DMultisample", 45, -1 }, { "glTextureBuffer", 45, -1 }, { "glTextureBufferRange", 45, -1 }, + { "glCreateProgramPipelines", 45, -1 }, { "glCreateQueries", 45, -1 }, { "glGetQueryBufferObjectiv", 45, -1 }, { "glGetQueryBufferObjectuiv", 45, -1 }, From mperes at kemper.freedesktop.org Wed Mar 25 08:07:16 2015 From: mperes at kemper.freedesktop.org (Martin Peres) Date: Wed, 25 Mar 2015 01:07:16 -0700 (PDT) Subject: Mesa (master): main: Added entry point for glCreateSamplers Message-ID: <20150325080716.7D17376332@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 73a9d0fbe5a6d2d9e8ef98531bf662343dcc1abe URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=73a9d0fbe5a6d2d9e8ef98531bf662343dcc1abe Author: Martin Peres Date: Thu Feb 12 13:12:19 2015 +0200 main: Added entry point for glCreateSamplers Because of the current way the code is architectured, there is no functional difference between the DSA and the non-DSA path. Reviewed-by: Laura Ekstrand Signed-off-by: Martin Peres --- src/mapi/glapi/gen/ARB_direct_state_access.xml | 7 +++++++ src/mesa/main/samplerobj.c | 25 ++++++++++++++++++------ src/mesa/main/samplerobj.h | 2 ++ src/mesa/main/tests/dispatch_sanity.cpp | 1 + 4 files changed, 29 insertions(+), 6 deletions(-) diff --git a/src/mapi/glapi/gen/ARB_direct_state_access.xml b/src/mapi/glapi/gen/ARB_direct_state_access.xml index 9d7a59a..9bba64b 100644 --- a/src/mapi/glapi/gen/ARB_direct_state_access.xml +++ b/src/mapi/glapi/gen/ARB_direct_state_access.xml @@ -420,6 +420,13 @@ + + + + + + + diff --git a/src/mesa/main/samplerobj.c b/src/mesa/main/samplerobj.c index d66b0b5..a3aacc6 100644 --- a/src/mesa/main/samplerobj.c +++ b/src/mesa/main/samplerobj.c @@ -181,19 +181,18 @@ _mesa_delete_sampler_object(struct gl_context *ctx, free(sampObj); } - -void GLAPIENTRY -_mesa_GenSamplers(GLsizei count, GLuint *samplers) +static void +create_samplers(struct gl_context *ctx, GLsizei count, GLuint *samplers, + const char *caller) { - GET_CURRENT_CONTEXT(ctx); GLuint first; GLint i; if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, "glGenSamplers(%d)\n", count); + _mesa_debug(ctx, "%s(%d)\n", caller, count); if (count < 0) { - _mesa_error(ctx, GL_INVALID_VALUE, "glGenSamplers"); + _mesa_error(ctx, GL_INVALID_VALUE, "%s(n<0)", caller); return; } @@ -211,6 +210,20 @@ _mesa_GenSamplers(GLsizei count, GLuint *samplers) } } +void GLAPIENTRY +_mesa_GenSamplers(GLsizei count, GLuint *samplers) +{ + GET_CURRENT_CONTEXT(ctx); + create_samplers(ctx, count, samplers, "glGenSamplers"); +} + +void GLAPIENTRY +_mesa_CreateSamplers(GLsizei count, GLuint *samplers) +{ + GET_CURRENT_CONTEXT(ctx); + create_samplers(ctx, count, samplers, "glCreateSamplers"); +} + void GLAPIENTRY _mesa_DeleteSamplers(GLsizei count, const GLuint *samplers) diff --git a/src/mesa/main/samplerobj.h b/src/mesa/main/samplerobj.h index 1bb3193..988b874 100644 --- a/src/mesa/main/samplerobj.h +++ b/src/mesa/main/samplerobj.h @@ -80,6 +80,8 @@ _mesa_init_sampler_object_functions(struct dd_function_table *driver); void GLAPIENTRY _mesa_GenSamplers(GLsizei count, GLuint *samplers); void GLAPIENTRY +_mesa_CreateSamplers(GLsizei count, GLuint *samplers); +void GLAPIENTRY _mesa_DeleteSamplers(GLsizei count, const GLuint *samplers); GLboolean GLAPIENTRY _mesa_IsSampler(GLuint sampler); diff --git a/src/mesa/main/tests/dispatch_sanity.cpp b/src/mesa/main/tests/dispatch_sanity.cpp index cc14674..67c3b33 100644 --- a/src/mesa/main/tests/dispatch_sanity.cpp +++ b/src/mesa/main/tests/dispatch_sanity.cpp @@ -976,6 +976,7 @@ const struct function gl_core_functions_possible[] = { { "glTextureStorage3DMultisample", 45, -1 }, { "glTextureBuffer", 45, -1 }, { "glTextureBufferRange", 45, -1 }, + { "glCreateSamplers", 45, -1 }, { "glCreateProgramPipelines", 45, -1 }, { "glCreateQueries", 45, -1 }, { "glGetQueryBufferObjectiv", 45, -1 }, From mperes at kemper.freedesktop.org Wed Mar 25 08:07:16 2015 From: mperes at kemper.freedesktop.org (Martin Peres) Date: Wed, 25 Mar 2015 01:07:16 -0700 (PDT) Subject: Mesa (master): main: Added entry point for glCreateRenderbuffers Message-ID: <20150325080716.89BA17635A@kemper.freedesktop.org> Module: Mesa Branch: master Commit: a34669b96166ffe839168bc8effc60aba9aa4178 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=a34669b96166ffe839168bc8effc60aba9aa4178 Author: Martin Peres Date: Thu Feb 12 18:52:10 2015 +0200 main: Added entry point for glCreateRenderbuffers v2: - refactor bindRenderBuffer and create_render_buffers to fix an assertion Reviewed-by: Laura Ekstrand Signed-off-by: Martin Peres --- src/mapi/glapi/gen/ARB_direct_state_access.xml | 7 +++ src/mesa/main/fbobject.c | 72 ++++++++++++++++++------ src/mesa/main/fbobject.h | 3 + src/mesa/main/tests/dispatch_sanity.cpp | 1 + 4 files changed, 65 insertions(+), 18 deletions(-) diff --git a/src/mapi/glapi/gen/ARB_direct_state_access.xml b/src/mapi/glapi/gen/ARB_direct_state_access.xml index 9bba64b..976dcc8 100644 --- a/src/mapi/glapi/gen/ARB_direct_state_access.xml +++ b/src/mapi/glapi/gen/ARB_direct_state_access.xml @@ -152,6 +152,13 @@ + + + + + + + diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c index bccac91..8083bc1 100644 --- a/src/mesa/main/fbobject.c +++ b/src/mesa/main/fbobject.c @@ -1205,6 +1205,26 @@ _mesa_IsRenderbuffer(GLuint renderbuffer) } +static struct gl_renderbuffer * +allocate_renderbuffer(struct gl_context *ctx, GLuint renderbuffer, + const char *func) +{ + struct gl_renderbuffer *newRb; + + /* create new renderbuffer object */ + newRb = ctx->Driver.NewRenderbuffer(ctx, renderbuffer); + if (!newRb) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "%s", func); + return NULL; + } + assert(newRb->AllocStorage); + _mesa_HashInsert(ctx->Shared->RenderBuffers, renderbuffer, newRb); + newRb->RefCount = 1; /* referenced by hash table */ + + return newRb; +} + + static void bind_renderbuffer(GLenum target, GLuint renderbuffer, bool allow_user_names) { @@ -1233,15 +1253,7 @@ bind_renderbuffer(GLenum target, GLuint renderbuffer, bool allow_user_names) } if (!newRb) { - /* create new renderbuffer object */ - newRb = ctx->Driver.NewRenderbuffer(ctx, renderbuffer); - if (!newRb) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glBindRenderbufferEXT"); - return; - } - assert(newRb->AllocStorage); - _mesa_HashInsert(ctx->Shared->RenderBuffers, renderbuffer, newRb); - newRb->RefCount = 1; /* referenced by hash table */ + newRb = allocate_renderbuffer(ctx, renderbuffer, "glBindRenderbufferEXT"); } } else { @@ -1383,16 +1395,17 @@ _mesa_DeleteRenderbuffers(GLsizei n, const GLuint *renderbuffers) } } - -void GLAPIENTRY -_mesa_GenRenderbuffers(GLsizei n, GLuint *renderbuffers) +static void +create_render_buffers(struct gl_context *ctx, GLsizei n, GLuint *renderbuffers, + bool dsa) { - GET_CURRENT_CONTEXT(ctx); + const char *func = dsa ? "glCreateRenderbuffers" : "glGenRenderbuffers"; + struct gl_renderbuffer *obj; GLuint first; GLint i; if (n < 0) { - _mesa_error(ctx, GL_INVALID_VALUE, "glGenRenderbuffersEXT(n)"); + _mesa_error(ctx, GL_INVALID_VALUE, "%s(n<0)", func); return; } @@ -1404,14 +1417,37 @@ _mesa_GenRenderbuffers(GLsizei n, GLuint *renderbuffers) for (i = 0; i < n; i++) { GLuint name = first + i; renderbuffers[i] = name; - /* insert dummy placeholder into hash table */ - mtx_lock(&ctx->Shared->Mutex); - _mesa_HashInsert(ctx->Shared->RenderBuffers, name, &DummyRenderbuffer); - mtx_unlock(&ctx->Shared->Mutex); + + if (dsa) { + obj = allocate_renderbuffer(ctx, name, func); + } else { + obj = &DummyRenderbuffer; + + /* insert the object into the hash table */ + mtx_lock(&ctx->Shared->Mutex); + _mesa_HashInsert(ctx->Shared->RenderBuffers, name, obj); + mtx_unlock(&ctx->Shared->Mutex); + } } } +void GLAPIENTRY +_mesa_GenRenderbuffers(GLsizei n, GLuint *renderbuffers) +{ + GET_CURRENT_CONTEXT(ctx); + create_render_buffers(ctx, n, renderbuffers, false); +} + + +void GLAPIENTRY +_mesa_CreateRenderbuffers(GLsizei n, GLuint *renderbuffers) +{ + GET_CURRENT_CONTEXT(ctx); + create_render_buffers(ctx, n, renderbuffers, true); +} + + /** * Given an internal format token for a render buffer, return the * corresponding base format (one of GL_RGB, GL_RGBA, GL_STENCIL_INDEX, diff --git a/src/mesa/main/fbobject.h b/src/mesa/main/fbobject.h index 77fdef4..9ab6b0b 100644 --- a/src/mesa/main/fbobject.h +++ b/src/mesa/main/fbobject.h @@ -115,6 +115,9 @@ extern void GLAPIENTRY _mesa_GenRenderbuffers(GLsizei n, GLuint *renderbuffers); extern void GLAPIENTRY +_mesa_CreateRenderbuffers(GLsizei n, GLuint *renderbuffers); + +extern void GLAPIENTRY _mesa_RenderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height); diff --git a/src/mesa/main/tests/dispatch_sanity.cpp b/src/mesa/main/tests/dispatch_sanity.cpp index 67c3b33..5383865 100644 --- a/src/mesa/main/tests/dispatch_sanity.cpp +++ b/src/mesa/main/tests/dispatch_sanity.cpp @@ -943,6 +943,7 @@ const struct function gl_core_functions_possible[] = { { "glGetNamedBufferParameteri64v", 45, -1 }, { "glGetNamedBufferPointerv", 45, -1 }, { "glGetNamedBufferSubData", 45, -1 }, + { "glCreateRenderbuffers", 45, -1 }, { "glCreateTextures", 45, -1 }, { "glTextureStorage1D", 45, -1 }, { "glTextureStorage2D", 45, -1 }, From mperes at kemper.freedesktop.org Wed Mar 25 08:07:16 2015 From: mperes at kemper.freedesktop.org (Martin Peres) Date: Wed, 25 Mar 2015 01:07:16 -0700 (PDT) Subject: Mesa (master): main: Added entry points for NamedRenderbufferStorage/ Multisample Message-ID: <20150325080716.A2AD97635A@kemper.freedesktop.org> Module: Mesa Branch: master Commit: bf11c195a59a3d545d91917f503dcee81d48ab09 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=bf11c195a59a3d545d91917f503dcee81d48ab09 Author: Martin Peres Date: Fri Feb 13 15:35:48 2015 +0200 main: Added entry points for NamedRenderbufferStorage/Multisample v2: Review from Laura Ekstrand - get rid of a change that should not have happened in this patch - improve the error messages - fix alignments - fix a capitalization in a function name in an error message v3: Review from Laura Ekstrand - move the test for the validity of the renderbuffer to less generic functions - get rid of some changes that accidentally landed in the wrong commit - revert some alignment fixes v3: Review from Laura Ekstrand - check that the lookup returns a valid renderbuffer - cosmetic changes to some error messages Reviewed-by: Laura Ekstrand Signed-off-by: Martin Peres --- src/mapi/glapi/gen/ARB_direct_state_access.xml | 15 +++ src/mesa/main/fbobject.c | 157 +++++++++++++++++------- src/mesa/main/fbobject.h | 9 ++ src/mesa/main/tests/dispatch_sanity.cpp | 2 + 4 files changed, 142 insertions(+), 41 deletions(-) diff --git a/src/mapi/glapi/gen/ARB_direct_state_access.xml b/src/mapi/glapi/gen/ARB_direct_state_access.xml index d4e1f7c..8a092d6 100644 --- a/src/mapi/glapi/gen/ARB_direct_state_access.xml +++ b/src/mapi/glapi/gen/ARB_direct_state_access.xml @@ -159,6 +159,21 @@ + + + + + + + + + + + + + + + diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c index 377f915..072e1a8 100644 --- a/src/mesa/main/fbobject.c +++ b/src/mesa/main/fbobject.c @@ -1785,40 +1785,17 @@ invalidate_rb(GLuint key, void *data, void *userData) /** - * Helper function used by _mesa_RenderbufferStorage() and - * _mesa_RenderbufferStorageMultisample(). - * samples will be NO_SAMPLES if called by _mesa_RenderbufferStorage(). + * Helper function used by renderbuffer_storage_direct() and + * renderbuffer_storage_target(). + * samples will be NO_SAMPLES if called by a non-multisample function. */ static void -renderbuffer_storage(GLenum target, GLenum internalFormat, - GLsizei width, GLsizei height, GLsizei samples) +renderbuffer_storage(struct gl_context *ctx, struct gl_renderbuffer *rb, + GLenum internalFormat, GLsizei width, + GLsizei height, GLsizei samples, const char *func) { - const char *func = samples == NO_SAMPLES ? - "glRenderbufferStorage" : "glRenderbufferStorageMultisample"; - struct gl_renderbuffer *rb; GLenum baseFormat; GLenum sample_count_error; - GET_CURRENT_CONTEXT(ctx); - - if (MESA_VERBOSE & VERBOSE_API) { - if (samples == NO_SAMPLES) - _mesa_debug(ctx, "%s(%s, %s, %d, %d)\n", - func, - _mesa_lookup_enum_by_nr(target), - _mesa_lookup_enum_by_nr(internalFormat), - width, height); - else - _mesa_debug(ctx, "%s(%s, %s, %d, %d, %d)\n", - func, - _mesa_lookup_enum_by_nr(target), - _mesa_lookup_enum_by_nr(internalFormat), - width, height, samples); - } - - if (target != GL_RENDERBUFFER_EXT) { - _mesa_error(ctx, GL_INVALID_ENUM, "%s(target)", func); - return; - } baseFormat = _mesa_base_fbo_format(ctx, internalFormat); if (baseFormat == 0) { @@ -1828,12 +1805,14 @@ renderbuffer_storage(GLenum target, GLenum internalFormat, } if (width < 0 || width > (GLsizei) ctx->Const.MaxRenderbufferSize) { - _mesa_error(ctx, GL_INVALID_VALUE, "%s(width)", func); + _mesa_error(ctx, GL_INVALID_VALUE, "%s(invalid width %d)", func, + width); return; } if (height < 0 || height > (GLsizei) ctx->Const.MaxRenderbufferSize) { - _mesa_error(ctx, GL_INVALID_VALUE, "%s(height)", func); + _mesa_error(ctx, GL_INVALID_VALUE, "%s(invalid height %d)", func, + height); return; } @@ -1845,7 +1824,7 @@ renderbuffer_storage(GLenum target, GLenum internalFormat, /* check the sample count; * note: driver may choose to use more samples than what's requested */ - sample_count_error = _mesa_check_sample_count(ctx, target, + sample_count_error = _mesa_check_sample_count(ctx, GL_RENDERBUFFER, internalFormat, samples); if (sample_count_error != GL_NO_ERROR) { _mesa_error(ctx, sample_count_error, "%s(samples)", func); @@ -1853,12 +1832,6 @@ renderbuffer_storage(GLenum target, GLenum internalFormat, } } - rb = ctx->CurrentRenderbuffer; - if (!rb) { - _mesa_error(ctx, GL_INVALID_OPERATION, "%s", func); - return; - } - FLUSH_VERTICES(ctx, _NEW_BUFFERS); if (rb->InternalFormat == internalFormat && @@ -1900,6 +1873,83 @@ renderbuffer_storage(GLenum target, GLenum internalFormat, } } +/** + * Helper function used by _mesa_NamedRenderbufferStorage*(). + * samples will be NO_SAMPLES if called by a non-multisample function. + */ +static void +renderbuffer_storage_named(GLuint renderbuffer, GLenum internalFormat, + GLsizei width, GLsizei height, GLsizei samples, + const char *func) +{ + GET_CURRENT_CONTEXT(ctx); + + if (MESA_VERBOSE & VERBOSE_API) { + if (samples == NO_SAMPLES) + _mesa_debug(ctx, "%s(%u, %s, %d, %d)\n", + func, renderbuffer, + _mesa_lookup_enum_by_nr(internalFormat), + width, height); + else + _mesa_debug(ctx, "%s(%u, %s, %d, %d, %d)\n", + func, renderbuffer, + _mesa_lookup_enum_by_nr(internalFormat), + width, height, samples); + } + + struct gl_renderbuffer *rb = _mesa_lookup_renderbuffer(ctx, renderbuffer); + if (!rb || rb == &DummyRenderbuffer) { + /* ID was reserved, but no real renderbuffer object made yet */ + _mesa_error(ctx, GL_INVALID_OPERATION, "%s(invalid renderbuffer %u)", + func, renderbuffer); + return; + } + + renderbuffer_storage(ctx, rb, internalFormat, width, height, samples, func); +} + +/** + * Helper function used by _mesa_RenderbufferStorage() and + * _mesa_RenderbufferStorageMultisample(). + * samples will be NO_SAMPLES if called by _mesa_RenderbufferStorage(). + */ +static void +renderbuffer_storage_target(GLenum target, GLenum internalFormat, + GLsizei width, GLsizei height, GLsizei samples, + const char *func) +{ + GET_CURRENT_CONTEXT(ctx); + + if (MESA_VERBOSE & VERBOSE_API) { + if (samples == NO_SAMPLES) + _mesa_debug(ctx, "%s(%s, %s, %d, %d)\n", + func, + _mesa_lookup_enum_by_nr(target), + _mesa_lookup_enum_by_nr(internalFormat), + width, height); + else + _mesa_debug(ctx, "%s(%s, %s, %d, %d, %d)\n", + func, + _mesa_lookup_enum_by_nr(target), + _mesa_lookup_enum_by_nr(internalFormat), + width, height, samples); + } + + if (target != GL_RENDERBUFFER_EXT) { + _mesa_error(ctx, GL_INVALID_ENUM, "%s(target)", func); + return; + } + + if (!ctx->CurrentRenderbuffer) { + _mesa_error(ctx, GL_INVALID_OPERATION, "%s(no renderbuffer bound)", + func); + return; + } + + renderbuffer_storage(ctx, ctx->CurrentRenderbuffer, internalFormat, width, + height, samples, func); +} + void GLAPIENTRY _mesa_EGLImageTargetRenderbufferStorageOES(GLenum target, GLeglImageOES image) @@ -1959,7 +2009,8 @@ _mesa_RenderbufferStorage(GLenum target, GLenum internalFormat, * glRenderbufferStorageMultisample() with samples=0. We pass in * a token value here just for error reporting purposes. */ - renderbuffer_storage(target, internalFormat, width, height, NO_SAMPLES); + renderbuffer_storage_target(target, internalFormat, width, height, + NO_SAMPLES, "glRenderbufferStorage"); } @@ -1968,7 +2019,8 @@ _mesa_RenderbufferStorageMultisample(GLenum target, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height) { - renderbuffer_storage(target, internalFormat, width, height, samples); + renderbuffer_storage_target(target, internalFormat, width, height, + samples, "glRenderbufferStorageMultisample"); } @@ -1989,7 +2041,30 @@ _es_RenderbufferStorageEXT(GLenum target, GLenum internalFormat, break; } - renderbuffer_storage(target, internalFormat, width, height, 0); + renderbuffer_storage_target(target, internalFormat, width, height, 0, + "glRenderbufferStorageEXT"); +} + +void GLAPIENTRY +_mesa_NamedRenderbufferStorage(GLuint renderbuffer, GLenum internalformat, + GLsizei width, GLsizei height) +{ + /* GL_ARB_fbo says calling this function is equivalent to calling + * glRenderbufferStorageMultisample() with samples=0. We pass in + * a token value here just for error reporting purposes. + */ + renderbuffer_storage_named(renderbuffer, internalformat, width, height, + NO_SAMPLES, "glNamedRenderbufferStorage"); +} + +void GLAPIENTRY +_mesa_NamedRenderbufferStorageMultisample(GLuint renderbuffer, GLsizei samples, + GLenum internalformat, + GLsizei width, GLsizei height) +{ + renderbuffer_storage_named(renderbuffer, internalformat, width, height, + samples, + "glNamedRenderbufferStorageMultisample"); } diff --git a/src/mesa/main/fbobject.h b/src/mesa/main/fbobject.h index b92149b..61aa1f5 100644 --- a/src/mesa/main/fbobject.h +++ b/src/mesa/main/fbobject.h @@ -131,6 +131,15 @@ _es_RenderbufferStorageEXT(GLenum target, GLenum internalFormat, GLsizei width, GLsizei height); extern void GLAPIENTRY +_mesa_NamedRenderbufferStorage(GLuint renderbuffer, GLenum internalformat, + GLsizei width, GLsizei height); + +extern void GLAPIENTRY +_mesa_NamedRenderbufferStorageMultisample(GLuint renderbuffer, GLsizei samples, + GLenum internalformat, + GLsizei width, GLsizei height); + +extern void GLAPIENTRY _mesa_EGLImageTargetRenderbufferStorageOES(GLenum target, GLeglImageOES image); extern void GLAPIENTRY diff --git a/src/mesa/main/tests/dispatch_sanity.cpp b/src/mesa/main/tests/dispatch_sanity.cpp index bb573d4..eb83e4d 100644 --- a/src/mesa/main/tests/dispatch_sanity.cpp +++ b/src/mesa/main/tests/dispatch_sanity.cpp @@ -944,6 +944,8 @@ const struct function gl_core_functions_possible[] = { { "glGetNamedBufferPointerv", 45, -1 }, { "glGetNamedBufferSubData", 45, -1 }, { "glCreateRenderbuffers", 45, -1 }, + { "glNamedRenderbufferStorage", 45, -1 }, + { "glNamedRenderbufferStorageMultisample", 45, -1 }, { "glGetNamedRenderbufferParameteriv", 45, -1 }, { "glCreateTextures", 45, -1 }, { "glTextureStorage1D", 45, -1 }, From mperes at kemper.freedesktop.org Wed Mar 25 08:07:16 2015 From: mperes at kemper.freedesktop.org (Martin Peres) Date: Wed, 25 Mar 2015 01:07:16 -0700 (PDT) Subject: Mesa (master): main: Added entry point for glTransformFeedbackBufferRange Message-ID: <20150325080716.1B61676332@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 296d82376e5d31961c02f6669f2012eb7bf4439d URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=296d82376e5d31961c02f6669f2012eb7bf4439d Author: Martin Peres Date: Wed Jan 21 12:22:11 2015 +0200 main: Added entry point for glTransformFeedbackBufferRange v2: review from Laura Ekstrand - use the refactored code to lookup the objects - improve some error messages - factor out the gl method name computation - better handle the spec differences between the DSA and non-DSA cases - quote the spec a little more v3: review from Laura Ekstrand - use the new name of _mesa_lookup_bufferobj_err - swap the comments around the offset and size checks v4: review from Laura Ekstrand - add more spec quotes - properly fix the comments around the offset and size checks v5: review from Laura Ekstrand - add quotes on the spec citations - revert some changes in the printf format v6: review from Laura Ekstrand - remove a redondant "gl" in a method name Signed-off-by: Martin Peres Reviewed-by: Laura Ekstrand --- src/mapi/glapi/gen/ARB_direct_state_access.xml | 8 +++ src/mesa/main/bufferobj.c | 3 +- src/mesa/main/tests/dispatch_sanity.cpp | 1 + src/mesa/main/transformfeedback.c | 92 ++++++++++++++++++++---- src/mesa/main/transformfeedback.h | 6 +- 5 files changed, 94 insertions(+), 16 deletions(-) diff --git a/src/mapi/glapi/gen/ARB_direct_state_access.xml b/src/mapi/glapi/gen/ARB_direct_state_access.xml index 02e33cd..2375df4 100644 --- a/src/mapi/glapi/gen/ARB_direct_state_access.xml +++ b/src/mapi/glapi/gen/ARB_direct_state_access.xml @@ -20,6 +20,14 @@ + + + + + + + + diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c index e737936..c45cec4 100644 --- a/src/mesa/main/bufferobj.c +++ b/src/mesa/main/bufferobj.c @@ -3887,7 +3887,8 @@ _mesa_BindBufferRange(GLenum target, GLuint index, case GL_TRANSFORM_FEEDBACK_BUFFER: _mesa_bind_buffer_range_transform_feedback(ctx, ctx->TransformFeedback.CurrentObject, - index, bufObj, offset, size); + index, bufObj, offset, size, + false); return; case GL_UNIFORM_BUFFER: bind_buffer_range_uniform_buffer(ctx, index, bufObj, offset, size); diff --git a/src/mesa/main/tests/dispatch_sanity.cpp b/src/mesa/main/tests/dispatch_sanity.cpp index 315571d..a259272 100644 --- a/src/mesa/main/tests/dispatch_sanity.cpp +++ b/src/mesa/main/tests/dispatch_sanity.cpp @@ -924,6 +924,7 @@ const struct function gl_core_functions_possible[] = { /* GL_ARB_direct_state_access */ { "glCreateTransformFeedbacks", 45, -1 }, { "glTransformFeedbackBufferBase", 45, -1 }, + { "glTransformFeedbackBufferRange", 45, -1 }, { "glCreateBuffers", 45, -1 }, { "glNamedBufferStorage", 45, -1 }, { "glNamedBufferData", 45, -1 }, diff --git a/src/mesa/main/transformfeedback.c b/src/mesa/main/transformfeedback.c index 1b2bd8d..e6b9803 100644 --- a/src/mesa/main/transformfeedback.c +++ b/src/mesa/main/transformfeedback.c @@ -541,7 +541,8 @@ bind_buffer_range(struct gl_context *ctx, /** * Specify a buffer object to receive transform feedback results. Plus, * specify the starting offset to place the results, and max size. - * Called from the glBindBufferRange() function. + * Called from the glBindBufferRange() and glTransformFeedbackBufferRange + * functions. */ void _mesa_bind_buffer_range_transform_feedback(struct gl_context *ctx, @@ -549,35 +550,74 @@ _mesa_bind_buffer_range_transform_feedback(struct gl_context *ctx, GLuint index, struct gl_buffer_object *bufObj, GLintptr offset, - GLsizeiptr size) + GLsizeiptr size, + bool dsa) { + const char *gl_methd_name; + if (dsa) + gl_methd_name = "glTransformFeedbackBufferRange"; + else + gl_methd_name = "glBindBufferRange"; + + if (obj->Active) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glBindBufferRange(transform feedback active)"); + _mesa_error(ctx, GL_INVALID_OPERATION, "%s(transform feedback active)", + gl_methd_name); return; } if (index >= ctx->Const.MaxTransformFeedbackBuffers) { - _mesa_error(ctx, GL_INVALID_VALUE, "glBindBufferRange(index=%d " - "out of bounds)", index); + /* OpenGL 4.5 core profile, 6.1, pdf page 82: "An INVALID_VALUE error is + * generated if index is greater than or equal to the number of binding + * points for transform feedback, as described in section 6.7.1." + */ + _mesa_error(ctx, GL_INVALID_VALUE, "%s(index=%d out of bounds)", + gl_methd_name, index); return; } if (size & 0x3) { - /* must a multiple of four */ - _mesa_error(ctx, GL_INVALID_VALUE, "glBindBufferRange(size=%d)", - (int) size); + /* OpenGL 4.5 core profile, 6.7, pdf page 103: multiple of 4 */ + _mesa_error(ctx, GL_INVALID_VALUE, "%s(size=%d must be a multiple of " + "four)", gl_methd_name, (int) size); return; } if (offset & 0x3) { - /* must be multiple of four */ - _mesa_error(ctx, GL_INVALID_VALUE, - "glBindBufferRange(offset=%d)", (int) offset); + /* OpenGL 4.5 core profile, 6.7, pdf page 103: multiple of 4 */ + _mesa_error(ctx, GL_INVALID_VALUE, "%s(offset=%d must be a multiple " + "of four)", gl_methd_name, (int) offset); return; - } + } + + if (offset < 0) { + /* OpenGL 4.5 core profile, 6.1, pdf page 82: "An INVALID_VALUE error is + * generated by BindBufferRange if offset is negative." + * + * OpenGL 4.5 core profile, 13.2, pdf page 445: "An INVALID_VALUE error + * is generated by TransformFeedbackBufferRange if offset is negative." + */ + _mesa_error(ctx, GL_INVALID_VALUE, "%s(offset=%d must be >= 0)", + gl_methd_name, + (int) offset); + return; + } + + if (size <= 0 && (dsa || bufObj != ctx->Shared->NullBufferObj)) { + /* OpenGL 4.5 core profile, 6.1, pdf page 82: "An INVALID_VALUE error is + * generated by BindBufferRange if buffer is non-zero and size is less + * than or equal to zero." + * + * OpenGL 4.5 core profile, 13.2, pdf page 445: "An INVALID_VALUE error + * is generated by TransformFeedbackBufferRange if size is less than or + * equal to zero." + */ + _mesa_error(ctx, GL_INVALID_VALUE, "%s(size=%d must be > 0)", + gl_methd_name, (int) size); + return; + } - bind_buffer_range(ctx, obj, index, bufObj, offset, size, false); + bind_buffer_range(ctx, obj, index, bufObj, offset, size, dsa); } @@ -681,6 +721,30 @@ _mesa_TransformFeedbackBufferBase(GLuint xfb, GLuint index, GLuint buffer) _mesa_bind_buffer_base_transform_feedback(ctx, obj, index, bufObj, true); } +void GLAPIENTRY +_mesa_TransformFeedbackBufferRange(GLuint xfb, GLuint index, GLuint buffer, + GLintptr offset, GLsizeiptr size) +{ + GET_CURRENT_CONTEXT(ctx); + struct gl_transform_feedback_object *obj; + struct gl_buffer_object *bufObj; + + obj = lookup_transform_feedback_object_err(ctx, xfb, + "glTransformFeedbackBufferRange"); + if(!obj) { + return; + } + + bufObj = lookup_transform_feedback_bufferobj_err(ctx, buffer, + "glTransformFeedbackBufferRange"); + if(!bufObj) { + return; + } + + _mesa_bind_buffer_range_transform_feedback(ctx, obj, index, bufObj, offset, + size, true); +} + /** * Specify a buffer object to receive transform feedback results, plus the * offset in the buffer to start placing results. diff --git a/src/mesa/main/transformfeedback.h b/src/mesa/main/transformfeedback.h index aac7433..9ec7d38 100644 --- a/src/mesa/main/transformfeedback.h +++ b/src/mesa/main/transformfeedback.h @@ -69,7 +69,7 @@ _mesa_bind_buffer_range_transform_feedback(struct gl_context *ctx, GLuint index, struct gl_buffer_object *bufObj, GLintptr offset, - GLsizeiptr size); + GLsizeiptr size, bool dsa); extern void _mesa_bind_buffer_base_transform_feedback(struct gl_context *ctx, @@ -152,4 +152,8 @@ _mesa_set_transform_feedback_binding(struct gl_context *ctx, extern void GLAPIENTRY _mesa_TransformFeedbackBufferBase(GLuint xfb, GLuint index, GLuint buffer); +extern void GLAPIENTRY +_mesa_TransformFeedbackBufferRange(GLuint xfb, GLuint index, GLuint buffer, + GLintptr offset, GLsizeiptr size); + #endif /* TRANSFORM_FEEDBACK_H */ From mperes at kemper.freedesktop.org Wed Mar 25 08:07:16 2015 From: mperes at kemper.freedesktop.org (Martin Peres) Date: Wed, 25 Mar 2015 01:07:16 -0700 (PDT) Subject: Mesa (master): main: Added entry point for glGetTransformFeedbacki_v Message-ID: <20150325080716.385CF76332@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 8799ecddb680f908b719df531dfe740e056ccb77 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=8799ecddb680f908b719df531dfe740e056ccb77 Author: Martin Peres Date: Mon Feb 16 16:13:59 2015 +0200 main: Added entry point for glGetTransformFeedbacki_v v2: Review from Laura Ekstrand - use the transform feedback object lookup wrapper v3: - use the new name of _mesa_lookup_transform_feedback_object_err Reviewed-by: Laura Ekstrand Signed-off-by: Martin Peres --- src/mapi/glapi/gen/ARB_direct_state_access.xml | 7 ++++++ src/mesa/main/tests/dispatch_sanity.cpp | 1 + src/mesa/main/transformfeedback.c | 29 ++++++++++++++++++++++++ src/mesa/main/transformfeedback.h | 4 ++++ 4 files changed, 41 insertions(+) diff --git a/src/mapi/glapi/gen/ARB_direct_state_access.xml b/src/mapi/glapi/gen/ARB_direct_state_access.xml index 341181e..89b1c7f 100644 --- a/src/mapi/glapi/gen/ARB_direct_state_access.xml +++ b/src/mapi/glapi/gen/ARB_direct_state_access.xml @@ -34,6 +34,13 @@ + + + + + + + diff --git a/src/mesa/main/tests/dispatch_sanity.cpp b/src/mesa/main/tests/dispatch_sanity.cpp index be22fe7..c31ce43 100644 --- a/src/mesa/main/tests/dispatch_sanity.cpp +++ b/src/mesa/main/tests/dispatch_sanity.cpp @@ -926,6 +926,7 @@ const struct function gl_core_functions_possible[] = { { "glTransformFeedbackBufferBase", 45, -1 }, { "glTransformFeedbackBufferRange", 45, -1 }, { "glGetTransformFeedbackiv", 45, -1 }, + { "glGetTransformFeedbacki_v", 45, -1 }, { "glCreateBuffers", 45, -1 }, { "glNamedBufferStorage", 45, -1 }, { "glNamedBufferData", 45, -1 }, diff --git a/src/mesa/main/transformfeedback.c b/src/mesa/main/transformfeedback.c index 0900d41..4f9dada 100644 --- a/src/mesa/main/transformfeedback.c +++ b/src/mesa/main/transformfeedback.c @@ -1228,3 +1228,32 @@ _mesa_GetTransformFeedbackiv(GLuint xfb, GLenum pname, GLint *param) "glGetTransformFeedbackiv(pname=%i)", pname); } } + +extern void GLAPIENTRY +_mesa_GetTransformFeedbacki_v(GLuint xfb, GLenum pname, GLuint index, + GLint *param) +{ + struct gl_transform_feedback_object *obj; + GET_CURRENT_CONTEXT(ctx); + + obj = lookup_transform_feedback_object_err(ctx, xfb, + "glGetTransformFeedbacki_v"); + if(!obj) { + return; + } + + if (index >= ctx->Const.MaxTransformFeedbackBuffers) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glGetTransformFeedbacki_v(index=%i)", index); + return; + } + + switch(pname) { + case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING: + *param = obj->BufferNames[index]; + break; + default: + _mesa_error(ctx, GL_INVALID_ENUM, + "glGetTransformFeedbacki_v(pname=%i)", pname); + } +} diff --git a/src/mesa/main/transformfeedback.h b/src/mesa/main/transformfeedback.h index af7d568..631ab2f 100644 --- a/src/mesa/main/transformfeedback.h +++ b/src/mesa/main/transformfeedback.h @@ -159,4 +159,8 @@ _mesa_TransformFeedbackBufferRange(GLuint xfb, GLuint index, GLuint buffer, extern void GLAPIENTRY _mesa_GetTransformFeedbackiv(GLuint xfb, GLenum pname, GLint *param); +extern void GLAPIENTRY +_mesa_GetTransformFeedbacki_v(GLuint xfb, GLenum pname, GLuint index, + GLint *param); + #endif /* TRANSFORM_FEEDBACK_H */ From mperes at kemper.freedesktop.org Wed Mar 25 08:07:16 2015 From: mperes at kemper.freedesktop.org (Martin Peres) Date: Wed, 25 Mar 2015 01:07:16 -0700 (PDT) Subject: Mesa (master): main: Added entry points for glGetQueryBufferObject* Message-ID: <20150325080716.5DB0376332@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 19e6efc0ad0e937bd89c00967d06f54d987810bc URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=19e6efc0ad0e937bd89c00967d06f54d987810bc Author: Martin Peres Date: Mon Feb 16 12:20:19 2015 +0200 main: Added entry points for glGetQueryBufferObject* These entry points will be fleshed out when the GL_ARB_query_buffer_object extension gets implemented. In the meantime, return GL_INVALID_OPERATION as suggested by Ian. Reviewed-by: Laura Ekstrand Signed-off-by: Martin Peres --- src/mapi/glapi/gen/ARB_direct_state_access.xml | 27 ++++++++++++++++ src/mesa/main/queryobj.c | 39 ++++++++++++++++++++++++ src/mesa/main/queryobj.h | 12 ++++++++ src/mesa/main/tests/dispatch_sanity.cpp | 4 +++ 4 files changed, 82 insertions(+) diff --git a/src/mapi/glapi/gen/ARB_direct_state_access.xml b/src/mapi/glapi/gen/ARB_direct_state_access.xml index a6d991c..05b9f3f 100644 --- a/src/mapi/glapi/gen/ARB_direct_state_access.xml +++ b/src/mapi/glapi/gen/ARB_direct_state_access.xml @@ -428,5 +428,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/mesa/main/queryobj.c b/src/mesa/main/queryobj.c index 1935058..fbccf3f 100644 --- a/src/mesa/main/queryobj.c +++ b/src/mesa/main/queryobj.c @@ -914,6 +914,45 @@ _mesa_GetQueryObjectui64v(GLuint id, GLenum pname, GLuint64EXT *params) } /** + * New with GL_ARB_query_buffer_object + */ +void GLAPIENTRY +_mesa_GetQueryBufferObjectiv(GLuint id, GLuint buffer, GLenum pname, + GLintptr offset) +{ + GET_CURRENT_CONTEXT(ctx); + _mesa_error(ctx, GL_INVALID_OPERATION, "glGetQueryBufferObjectiv"); +} + + +void GLAPIENTRY +_mesa_GetQueryBufferObjectuiv(GLuint id, GLuint buffer, GLenum pname, + GLintptr offset) +{ + GET_CURRENT_CONTEXT(ctx); + _mesa_error(ctx, GL_INVALID_OPERATION, "glGetQueryBufferObjectuiv"); +} + + +void GLAPIENTRY +_mesa_GetQueryBufferObjecti64v(GLuint id, GLuint buffer, GLenum pname, + GLintptr offset) +{ + GET_CURRENT_CONTEXT(ctx); + _mesa_error(ctx, GL_INVALID_OPERATION, "glGetQueryBufferObjecti64v"); +} + + +void GLAPIENTRY +_mesa_GetQueryBufferObjectui64v(GLuint id, GLuint buffer, GLenum pname, + GLintptr offset) +{ + GET_CURRENT_CONTEXT(ctx); + _mesa_error(ctx, GL_INVALID_OPERATION, "glGetQueryBufferObjectui64v"); +} + + +/** * Allocate/init the context state related to query objects. */ void diff --git a/src/mesa/main/queryobj.h b/src/mesa/main/queryobj.h index 431d420..d1036fc 100644 --- a/src/mesa/main/queryobj.h +++ b/src/mesa/main/queryobj.h @@ -79,5 +79,17 @@ void GLAPIENTRY _mesa_GetQueryObjecti64v(GLuint id, GLenum pname, GLint64EXT *params); void GLAPIENTRY _mesa_GetQueryObjectui64v(GLuint id, GLenum pname, GLuint64EXT *params); +void GLAPIENTRY +_mesa_GetQueryBufferObjectiv(GLuint id, GLuint buffer, GLenum pname, + GLintptr offset); +void GLAPIENTRY +_mesa_GetQueryBufferObjectuiv(GLuint id, GLuint buffer, GLenum pname, + GLintptr offset); +void GLAPIENTRY +_mesa_GetQueryBufferObjecti64v(GLuint id, GLuint buffer, GLenum pname, + GLintptr offset); +void GLAPIENTRY +_mesa_GetQueryBufferObjectui64v(GLuint id, GLuint buffer, GLenum pname, + GLintptr offset); #endif /* QUERYOBJ_H */ diff --git a/src/mesa/main/tests/dispatch_sanity.cpp b/src/mesa/main/tests/dispatch_sanity.cpp index e5362fb..c6dd50b 100644 --- a/src/mesa/main/tests/dispatch_sanity.cpp +++ b/src/mesa/main/tests/dispatch_sanity.cpp @@ -977,6 +977,10 @@ const struct function gl_core_functions_possible[] = { { "glTextureBuffer", 45, -1 }, { "glTextureBufferRange", 45, -1 }, { "glCreateQueries", 45, -1 }, + { "glGetQueryBufferObjectiv", 45, -1 }, + { "glGetQueryBufferObjectuiv", 45, -1 }, + { "glGetQueryBufferObjecti64v", 45, -1 }, + { "glGetQueryBufferObjectui64v", 45, -1 }, /* GL_EXT_polygon_offset_clamp */ { "glPolygonOffsetClampEXT", 11, -1 }, From mperes at kemper.freedesktop.org Wed Mar 25 08:07:16 2015 From: mperes at kemper.freedesktop.org (Martin Peres) Date: Wed, 25 Mar 2015 01:07:16 -0700 (PDT) Subject: Mesa (master): docs: Update progress on ARB_direct_state_access. Message-ID: <20150325080716.ABE7776332@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 31a30fb342624658f9ab3f9febd06c59b3a3d2c8 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=31a30fb342624658f9ab3f9febd06c59b3a3d2c8 Author: Martin Peres Date: Thu Mar 19 19:44:56 2015 +0200 docs: Update progress on ARB_direct_state_access. v2: - Fix the state of the Program pipelines and Query objects (Laura) Signed-off-by: Martin Peres --- docs/GL3.txt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/GL3.txt b/docs/GL3.txt index 93fa60d..3614260 100644 --- a/docs/GL3.txt +++ b/docs/GL3.txt @@ -193,15 +193,15 @@ GL 4.5, GLSL 4.50: GL_ARB_cull_distance not started GL_ARB_derivative_control DONE (i965, nv50, nvc0, r600) GL_ARB_direct_state_access started - - Transform Feedback object started (Martin Peres) + - Transform Feedback object DONE - Buffer object DONE - Framebuffer object started (Laura Ekstrand) - - Renderbuffer object started (Martin Peres) + - Renderbuffer object DONE - Texture object DONE - Vertex array object started (Fredrik H?glund) - - Sampler object started (Martin Peres) - - Program Pipeline object started (Martin Peres) - - Query object started (Martin Peres) + - Sampler object DONE + - Program Pipeline object DONE + - Query object DONE (will require changes when GL_ARB_query_buffer_object lands) GL_ARB_get_texture_sub_image started (Brian Paul) GL_ARB_shader_texture_image_samples not started GL_ARB_texture_barrier DONE (nv50, nvc0, r600, radeonsi) From mperes at kemper.freedesktop.org Wed Mar 25 08:07:16 2015 From: mperes at kemper.freedesktop.org (Martin Peres) Date: Wed, 25 Mar 2015 01:07:16 -0700 (PDT) Subject: Mesa (master): main: Added entry point for glGetNamedRenderbufferParameteriv Message-ID: <20150325080716.971D576332@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 245e5c4813eb30e32bd61a08ae32ee278b09d1cf URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=245e5c4813eb30e32bd61a08ae32ee278b09d1cf Author: Martin Peres Date: Fri Feb 13 15:46:55 2015 +0200 main: Added entry point for glGetNamedRenderbufferParameteriv v2: - improve an error message v3: - move a test to less generic functions - fix an alignment v4: - take the caller as a parameter instead of bool dsa - check that the lookup returns a valid renderbuffer Reviewed-by: Laura Ekstrand Signed-off-by: Martin Peres --- src/mapi/glapi/gen/ARB_direct_state_access.xml | 6 +++ src/mesa/main/fbobject.c | 63 +++++++++++++++++------- src/mesa/main/fbobject.h | 4 ++ src/mesa/main/tests/dispatch_sanity.cpp | 1 + 4 files changed, 56 insertions(+), 18 deletions(-) diff --git a/src/mapi/glapi/gen/ARB_direct_state_access.xml b/src/mapi/glapi/gen/ARB_direct_state_access.xml index 976dcc8..d4e1f7c 100644 --- a/src/mapi/glapi/gen/ARB_direct_state_access.xml +++ b/src/mapi/glapi/gen/ARB_direct_state_access.xml @@ -159,6 +159,12 @@ + + + + + + diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c index 8083bc1..377f915 100644 --- a/src/mesa/main/fbobject.c +++ b/src/mesa/main/fbobject.c @@ -1993,25 +1993,11 @@ _es_RenderbufferStorageEXT(GLenum target, GLenum internalFormat, } -void GLAPIENTRY -_mesa_GetRenderbufferParameteriv(GLenum target, GLenum pname, GLint *params) +static void +get_render_buffer_parameteriv(struct gl_context *ctx, + struct gl_renderbuffer *rb, GLenum pname, + GLint *params, const char *func) { - struct gl_renderbuffer *rb; - GET_CURRENT_CONTEXT(ctx); - - if (target != GL_RENDERBUFFER_EXT) { - _mesa_error(ctx, GL_INVALID_ENUM, - "glGetRenderbufferParameterivEXT(target)"); - return; - } - - rb = ctx->CurrentRenderbuffer; - if (!rb) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glGetRenderbufferParameterivEXT"); - return; - } - /* No need to flush here since we're just quering state which is * not effected by rendering. */ @@ -2042,10 +2028,51 @@ _mesa_GetRenderbufferParameteriv(GLenum target, GLenum pname, GLint *params) } /* fallthrough */ default: + _mesa_error(ctx, GL_INVALID_ENUM, "%s(invalid pname=%s)", func, + _mesa_lookup_enum_by_nr(pname)); + return; + } +} + + +void GLAPIENTRY +_mesa_GetRenderbufferParameteriv(GLenum target, GLenum pname, GLint *params) +{ + GET_CURRENT_CONTEXT(ctx); + + if (target != GL_RENDERBUFFER_EXT) { _mesa_error(ctx, GL_INVALID_ENUM, "glGetRenderbufferParameterivEXT(target)"); return; } + + if (!ctx->CurrentRenderbuffer) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glGetRenderbufferParameterivEXT" + "(no renderbuffer bound)"); + return; + } + + get_render_buffer_parameteriv(ctx, ctx->CurrentRenderbuffer, pname, + params, "glGetRenderbufferParameteriv"); +} + + +void GLAPIENTRY +_mesa_GetNamedRenderbufferParameteriv(GLuint renderbuffer, GLenum pname, + GLint *params) +{ + GET_CURRENT_CONTEXT(ctx); + + struct gl_renderbuffer *rb = _mesa_lookup_renderbuffer(ctx, renderbuffer); + if (!rb || rb == &DummyRenderbuffer) { + /* ID was reserved, but no real renderbuffer object made yet */ + _mesa_error(ctx, GL_INVALID_OPERATION, "glGetNamedRenderbufferParameteriv" + "(invalid renderbuffer %i)", renderbuffer); + return; + } + + get_render_buffer_parameteriv(ctx, rb, pname, params, + "glGetNamedRenderbufferParameteriv"); } diff --git a/src/mesa/main/fbobject.h b/src/mesa/main/fbobject.h index 9ab6b0b..b92149b 100644 --- a/src/mesa/main/fbobject.h +++ b/src/mesa/main/fbobject.h @@ -137,6 +137,10 @@ extern void GLAPIENTRY _mesa_GetRenderbufferParameteriv(GLenum target, GLenum pname, GLint *params); +void GLAPIENTRY +_mesa_GetNamedRenderbufferParameteriv(GLuint renderbuffer, GLenum pname, + GLint *params); + extern GLboolean GLAPIENTRY _mesa_IsFramebuffer(GLuint framebuffer); diff --git a/src/mesa/main/tests/dispatch_sanity.cpp b/src/mesa/main/tests/dispatch_sanity.cpp index 5383865..bb573d4 100644 --- a/src/mesa/main/tests/dispatch_sanity.cpp +++ b/src/mesa/main/tests/dispatch_sanity.cpp @@ -944,6 +944,7 @@ const struct function gl_core_functions_possible[] = { { "glGetNamedBufferPointerv", 45, -1 }, { "glGetNamedBufferSubData", 45, -1 }, { "glCreateRenderbuffers", 45, -1 }, + { "glGetNamedRenderbufferParameteriv", 45, -1 }, { "glCreateTextures", 45, -1 }, { "glTextureStorage1D", 45, -1 }, { "glTextureStorage2D", 45, -1 }, From jrfonseca at kemper.freedesktop.org Wed Mar 25 10:44:19 2015 From: jrfonseca at kemper.freedesktop.org (Jose Fonseca) Date: Wed, 25 Mar 2015 03:44:19 -0700 (PDT) Subject: Mesa (master): scons: Fix git_sha1.h generation fallback. Message-ID: <20150325104419.2B44B76332@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 5db57b8a55bb1961f1ada029f63c1f07511d60aa URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=5db57b8a55bb1961f1ada029f63c1f07511d60aa Author: Jose Fonseca Date: Mon Mar 23 10:48:31 2015 +0000 scons: Fix git_sha1.h generation fallback. I didn't meant to remove the 'if not os.path.exists(filename)' statement. Reviewed-by: Brian Paul --- src/mesa/SConscript | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/mesa/SConscript b/src/mesa/SConscript index a563fd2..5b80a21 100644 --- a/src/mesa/SConscript +++ b/src/mesa/SConscript @@ -130,9 +130,10 @@ def write_git_sha1_h_file(filename): (commit, foo) = subprocess.Popen(args, stdout=subprocess.PIPE).communicate() except: # git log command didn't work - dirname = os.path.dirname(filename) - if not os.path.exists(dirname): - os.makedirs(dirname) + if not os.path.exists(filename): + dirname = os.path.dirname(filename) + if not os.path.exists(dirname): + os.makedirs(dirname) # create an empty file if none already exists f = open(filename, "w") f.close() From jrfonseca at kemper.freedesktop.org Wed Mar 25 10:44:19 2015 From: jrfonseca at kemper.freedesktop.org (Jose Fonseca) Date: Wed, 25 Mar 2015 03:44:19 -0700 (PDT) Subject: Mesa (master): scons: Don't build osmesa. Message-ID: <20150325104419.4C80976332@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 69db422218b0264b5b8eef45bd003a2544e9cbd6 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=69db422218b0264b5b8eef45bd003a2544e9cbd6 Author: Jose Fonseca Date: Tue Mar 24 20:30:03 2015 +0000 scons: Don't build osmesa. There doesn't seem much interest on osmesa on Windows, particularly classic osmesa. If there is indeed interest in osmesa on Windows, we should instead integrate src/gallium/targets/osmesa into SCons. Reviewed-by: Brian Paul --- src/mesa/drivers/SConscript | 2 -- src/mesa/drivers/osmesa/SConscript | 39 ------------------------------------ src/mesa/drivers/osmesa/osmesa.def | 15 -------------- 3 files changed, 56 deletions(-) diff --git a/src/mesa/drivers/SConscript b/src/mesa/drivers/SConscript index 17813da..db65678 100644 --- a/src/mesa/drivers/SConscript +++ b/src/mesa/drivers/SConscript @@ -1,7 +1,5 @@ Import('*') -SConscript('osmesa/SConscript') - if env['x11']: SConscript('x11/SConscript') diff --git a/src/mesa/drivers/osmesa/SConscript b/src/mesa/drivers/osmesa/SConscript deleted file mode 100644 index caa14d3..0000000 --- a/src/mesa/drivers/osmesa/SConscript +++ /dev/null @@ -1,39 +0,0 @@ -Import('*') - -env = env.Clone() - -env.Prepend(CPPPATH = [ - '#src', - '#src/mapi', - '#src/mesa', - Dir('../../../mapi'), # src/mapi build path for python-generated GL API files/headers -]) - -env.Prepend(LIBS = [ - mesautil, - glapi, - mesa, - glsl, -]) - -sources = [ - 'osmesa.c', -] - -if env['platform'] == 'windows': - env.AppendUnique(CPPDEFINES = [ - '_GDI32_', # prevent wgl* being declared __declspec(dllimport) - 'BUILD_GL32', # declare gl* as __declspec(dllexport) in Mesa headers - ]) - if not env['gles']: - # prevent _glapi_* from being declared __declspec(dllimport) - env.Append(CPPDEFINES = ['_GLAPI_NO_EXPORTS']) - - sources += ['osmesa.def'] - -osmesa = env.SharedLibrary( - target ='osmesa', - source = sources, -) - -env.Alias('osmesa', osmesa) diff --git a/src/mesa/drivers/osmesa/osmesa.def b/src/mesa/drivers/osmesa/osmesa.def deleted file mode 100644 index 06afab7..0000000 --- a/src/mesa/drivers/osmesa/osmesa.def +++ /dev/null @@ -1,15 +0,0 @@ -;DESCRIPTION 'Mesa OSMesa lib for Win32' -VERSION 4.1 - -EXPORTS - OSMesaColorClamp - OSMesaCreateContext - OSMesaCreateContextExt - OSMesaDestroyContext - OSMesaMakeCurrent - OSMesaGetCurrentContext - OSMesaPixelStore - OSMesaGetIntegerv - OSMesaGetDepthBuffer - OSMesaGetColorBuffer - OSMesaGetProcAddress From jrfonseca at kemper.freedesktop.org Wed Mar 25 10:44:19 2015 From: jrfonseca at kemper.freedesktop.org (Jose Fonseca) Date: Wed, 25 Mar 2015 03:44:19 -0700 (PDT) Subject: Mesa (master): scons: Don't build loader on Windows. Message-ID: <20150325104419.40D257635B@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 47870d658b777722d48d6b9084d66e270a04e52e URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=47870d658b777722d48d6b9084d66e270a04e52e Author: Jose Fonseca Date: Tue Mar 24 20:26:21 2015 +0000 scons: Don't build loader on Windows. EGL was the last user. Reviewed-by: Brian Paul --- src/SConscript | 3 ++- src/loader/Makefile.am | 1 - 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/SConscript b/src/SConscript index 40b7fc1..b0578e8 100644 --- a/src/SConscript +++ b/src/SConscript @@ -12,7 +12,8 @@ if env['hostonly']: # compilation Return() -SConscript('loader/SConscript') +if env['platform'] != 'windows': + SConscript('loader/SConscript') # When env['gles'] is set, the targets defined in mapi/glapi/SConscript are not # used. libgl-xlib and libgl-gdi adapt themselves to use the targets defined diff --git a/src/loader/Makefile.am b/src/loader/Makefile.am index 3d32279..36ddba8 100644 --- a/src/loader/Makefile.am +++ b/src/loader/Makefile.am @@ -30,7 +30,6 @@ libloader_la_CPPFLAGS = \ -I$(top_srcdir)/include \ -I$(top_srcdir)/src \ $(VISIBILITY_CFLAGS) \ - $(MSVC2013_COMPAT_CFLAGS) \ $(LIBUDEV_CFLAGS) libloader_la_SOURCES = $(LOADER_C_FILES) From jrfonseca at kemper.freedesktop.org Wed Mar 25 10:44:19 2015 From: jrfonseca at kemper.freedesktop.org (Jose Fonseca) Date: Wed, 25 Mar 2015 03:44:19 -0700 (PDT) Subject: Mesa (master): scons: Don't build egl on Windows. Message-ID: <20150325104419.3006676331@kemper.freedesktop.org> Module: Mesa Branch: master Commit: f9b8c9299d10542c9806927018a488f84adcb036 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=f9b8c9299d10542c9806927018a488f84adcb036 Author: Jose Fonseca Date: Tue Mar 24 20:11:36 2015 +0000 scons: Don't build egl on Windows. Useless, as there are no drivers for it. Reviewed-by: Brian Paul --- src/SConscript | 2 +- src/egl/main/Makefile.am | 1 - src/egl/main/SConscript | 11 +---------- 3 files changed, 2 insertions(+), 12 deletions(-) diff --git a/src/SConscript b/src/SConscript index 188ab08..40b7fc1 100644 --- a/src/SConscript +++ b/src/SConscript @@ -30,7 +30,7 @@ SConscript('mesa/SConscript') if not env['embedded']: if env['platform'] not in ('cygwin', 'darwin', 'freebsd', 'haiku', 'windows'): SConscript('glx/SConscript') - if env['platform'] not in ['darwin', 'haiku', 'sunos']: + if env['platform'] not in ['darwin', 'haiku', 'sunos', 'windows']: if env['dri']: SConscript('egl/drivers/dri2/SConscript') SConscript('egl/main/SConscript') diff --git a/src/egl/main/Makefile.am b/src/egl/main/Makefile.am index 893ad26..b661736 100644 --- a/src/egl/main/Makefile.am +++ b/src/egl/main/Makefile.am @@ -26,7 +26,6 @@ AM_CFLAGS = \ -I$(top_srcdir)/src/gbm/main \ $(DEFINES) \ $(VISIBILITY_CFLAGS) \ - $(MSVC2013_COMPAT_CFLAGS) \ $(EGL_CFLAGS) \ -D_EGL_NATIVE_PLATFORM=$(EGL_NATIVE_PLATFORM) \ -D_EGL_DRIVER_SEARCH_DIR=\"$(libdir)/egl\" \ diff --git a/src/egl/main/SConscript b/src/egl/main/SConscript index b4e9b67..c001283 100644 --- a/src/egl/main/SConscript +++ b/src/egl/main/SConscript @@ -6,20 +6,11 @@ Import('*') env = env.Clone() -env.MSVC2013Compat() - env.Append(CPPDEFINES = [ '_EGL_DRIVER_SEARCH_DIR=\\"\\"', ]) -if env['platform'] == 'windows': - env.Append(CPPDEFINES = [ - '_EGL_NATIVE_PLATFORM=_EGL_PLATFORM_WINDOWS', - '_EGL_OS_WINDOWS', - '_EGL_GET_CORE_ADDRESSES', - 'KHRONOS_DLL_EXPORTS', - ]) -elif env['platform'] == 'haiku': +if env['platform'] == 'haiku': env.Append(CPPDEFINES = [ '_EGL_NATIVE_PLATFORM=_EGL_PLATFORM_HAIKU', '_EGL_OS_UNIX', From jrfonseca at kemper.freedesktop.org Wed Mar 25 10:44:19 2015 From: jrfonseca at kemper.freedesktop.org (Jose Fonseca) Date: Wed, 25 Mar 2015 03:44:19 -0700 (PDT) Subject: Mesa (master): c99_math: Don't reimplement lrint and friends on MSVC 2013. Message-ID: <20150325104419.5A57076332@kemper.freedesktop.org> Module: Mesa Branch: master Commit: fdb507e3d6a9a78f8a42bc8d6f7e60816627403e URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=fdb507e3d6a9a78f8a42bc8d6f7e60816627403e Author: Jose Fonseca Date: Tue Mar 24 13:16:24 2015 +0000 c99_math: Don't reimplement lrint and friends on MSVC 2013. MSVC 2013 declares these functions, both for C and C++ source files. This was caught with MSVC in analyze mode. Reviewed-by: Brian Paul --- include/c99_math.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/c99_math.h b/include/c99_math.h index 5b01d53..ee0dd10 100644 --- a/include/c99_math.h +++ b/include/c99_math.h @@ -82,7 +82,8 @@ roundf(float x) #endif /* _MSC_VER */ -#if __STDC_VERSION__ < 199901L && (!defined(__cplusplus) || defined(_MSC_VER)) +#if (defined(_MSC_VER) && _MSC_VER < 1800) || \ + (!defined(_MSC_VER) && __STDC_VERSION__ < 199901L && !defined(__cplusplus)) static inline long int lrint(double d) { From jrfonseca at kemper.freedesktop.org Wed Mar 25 10:44:19 2015 From: jrfonseca at kemper.freedesktop.org (Jose Fonseca) Date: Wed, 25 Mar 2015 03:44:19 -0700 (PDT) Subject: Mesa (master): mesa: Avoid MSVC C6334 warning in /analyze mode. Message-ID: <20150325104419.63B0D76332@kemper.freedesktop.org> Module: Mesa Branch: master Commit: cb88edbd4e9cb198013129a360cb3d4163ac3837 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=cb88edbd4e9cb198013129a360cb3d4163ac3837 Author: Jose Fonseca Date: Tue Mar 24 19:01:46 2015 +0000 mesa: Avoid MSVC C6334 warning in /analyze mode. MSVC's implementation of signbit(x) uses sizeof(x) with expressions to dispatch to an internal function based on the argument's type (float, double, etc), but that raises a flag with MSVC's own static analyzer, and because this is an inline function in a header it causes substantial warning spam. Reviewed-by: Brian Paul --- src/mesa/main/macros.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/mesa/main/macros.h b/src/mesa/main/macros.h index 2d7a6a1..3344ec8 100644 --- a/src/mesa/main/macros.h +++ b/src/mesa/main/macros.h @@ -789,7 +789,14 @@ NORMALIZE_3FV(GLfloat v[3]) static inline GLboolean DIFFERENT_SIGNS(GLfloat x, GLfloat y) { +#ifdef _MSC_VER +#pragma warning( push ) +#pragma warning( disable : 6334 ) /* sizeof operator applied to an expression with an operator may yield unexpected results */ +#endif return signbit(x) != signbit(y); +#ifdef _MSC_VER +#pragma warning( pop ) +#endif } From jrfonseca at kemper.freedesktop.org Wed Mar 25 10:44:19 2015 From: jrfonseca at kemper.freedesktop.org (Jose Fonseca) Date: Wed, 25 Mar 2015 03:44:19 -0700 (PDT) Subject: Mesa (master): scons: Disable MSVC warnings about inconsistent function annotation. Message-ID: <20150325104419.6D9B176332@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 28c54400af1ee04306342f67e56dc9e37933c538 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=28c54400af1ee04306342f67e56dc9e37933c538 Author: Jose Fonseca Date: Tue Mar 24 19:50:48 2015 +0000 scons: Disable MSVC warnings about inconsistent function annotation. Somehow, merely including any of the *intrin.h headers causes dozens of this warnings (when compiling pretty much every source file). MSVC does not always complain the same -- so it's possible we're doing something weird --, but silence these warnings in the meanwhile. Reviewed-by: Brian Paul --- scons/gallium.py | 1 + 1 file changed, 1 insertion(+) diff --git a/scons/gallium.py b/scons/gallium.py index efc65e7..51b84d7 100755 --- a/scons/gallium.py +++ b/scons/gallium.py @@ -549,6 +549,7 @@ def generate(env): env.Append(CCFLAGS = [ '/analyze', #'/analyze:log', '${TARGET.base}.xml', + '/wd28251', # Inconsistent annotation for function ]) if env['clang']: # scan-build will produce more comprehensive output From jrfonseca at kemper.freedesktop.org Wed Mar 25 10:44:19 2015 From: jrfonseca at kemper.freedesktop.org (Jose Fonseca) Date: Wed, 25 Mar 2015 03:44:19 -0700 (PDT) Subject: Mesa (master): util/u_atomic: Ignore warnings interlocked accesses. Message-ID: <20150325104419.77B8F76332@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 25d6cdd2ff1f00e0eab532956c0ae17d4ffa42da URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=25d6cdd2ff1f00e0eab532956c0ae17d4ffa42da Author: Jose Fonseca Date: Tue Mar 24 19:56:21 2015 +0000 util/u_atomic: Ignore warnings interlocked accesses. These are due how we implemented the atomic tests, not the atomic implementation itself. It's also difficult to refactor the code to avoid the warnings due to the use of macros -- the code would be quite hairy. Reviewed-by: Brian Paul --- src/util/u_atomic_test.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/util/u_atomic_test.c b/src/util/u_atomic_test.c index 939cfe4..7844f61 100644 --- a/src/util/u_atomic_test.c +++ b/src/util/u_atomic_test.c @@ -36,6 +36,11 @@ #include "u_atomic.h" +#ifdef _MSC_VER +#pragma warning( disable : 28112 ) /* Accessing a local variable via an Interlocked function */ +#pragma warning( disable : 28113 ) /* A variable which is accessed via an Interlocked function must always be accessed via an Interlocked function */ +#endif + /* Test only assignment-like operations, which are supported on all types */ #define test_atomic_assign(type, ones) \ From idr at kemper.freedesktop.org Wed Mar 25 17:42:16 2015 From: idr at kemper.freedesktop.org (Ian Romanick) Date: Wed, 25 Mar 2015 10:42:16 -0700 (PDT) Subject: Mesa (master): glsl: Add is_rvalue, is_dereference, and is_jump methods Message-ID: <20150325174216.6302C76338@kemper.freedesktop.org> Module: Mesa Branch: master Commit: a284c6300665d4388dae14363807a57bb82e4cb5 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=a284c6300665d4388dae14363807a57bb82e4cb5 Author: Ian Romanick Date: Tue Mar 24 08:55:15 2015 -0700 glsl: Add is_rvalue, is_dereference, and is_jump methods These functions deteremine when an IR node is one of the non-leaf classes. v2: Adjust indentation to line up. Suggested by Matt. Signed-off-by: Ian Romanick Reviewed-by: Francisco Jerez --- src/glsl/ir.h | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/glsl/ir.h b/src/glsl/ir.h index fdc22ed..b3a98b8 100644 --- a/src/glsl/ir.h +++ b/src/glsl/ir.h @@ -109,6 +109,31 @@ public: virtual ir_instruction *clone(void *mem_ctx, struct hash_table *ht) const = 0; + bool is_rvalue() const + { + return ir_type == ir_type_dereference_array || + ir_type == ir_type_dereference_record || + ir_type == ir_type_dereference_variable || + ir_type == ir_type_constant || + ir_type == ir_type_expression || + ir_type == ir_type_swizzle || + ir_type == ir_type_texture; + } + + bool is_dereference() const + { + return ir_type == ir_type_dereference_array || + ir_type == ir_type_dereference_record || + ir_type == ir_type_dereference_variable; + } + + bool is_jump() const + { + return ir_type == ir_type_loop_jump || + ir_type == ir_type_return || + ir_type == ir_type_discard; + } + /** * \name IR instruction downcast functions * From idr at kemper.freedesktop.org Wed Mar 25 17:42:16 2015 From: idr at kemper.freedesktop.org (Ian Romanick) Date: Wed, 25 Mar 2015 10:42:16 -0700 (PDT) Subject: Mesa (master): glsl: Implement remaining as_foo functions with macros Message-ID: <20150325174216.6FFDC7635A@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 0c4ee62045ed184a5b9662f940b8a9e9bd454734 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=0c4ee62045ed184a5b9662f940b8a9e9bd454734 Author: Ian Romanick Date: Tue Mar 24 09:02:24 2015 -0700 glsl: Implement remaining as_foo functions with macros The downcast functions for non-leaf classes were previously implemented "by hand." Now they are implemented using macros based on the is_foo functions added in the previous patch. v2: Remove redundant parenthesis. Suggested by Curro (on the next patch). Signed-off-by: Ian Romanick Reviewed-by: Francisco Jerez --- src/glsl/ir.h | 40 +++++++++------------------------------- 1 file changed, 9 insertions(+), 31 deletions(-) diff --git a/src/glsl/ir.h b/src/glsl/ir.h index b3a98b8..0284b02 100644 --- a/src/glsl/ir.h +++ b/src/glsl/ir.h @@ -142,39 +142,17 @@ public: * Additional downcast functions will be added as needed. */ /*@{*/ - class ir_rvalue *as_rvalue() - { - assume(this != NULL); - if (ir_type == ir_type_dereference_array || - ir_type == ir_type_dereference_record || - ir_type == ir_type_dereference_variable || - ir_type == ir_type_constant || - ir_type == ir_type_expression || - ir_type == ir_type_swizzle || - ir_type == ir_type_texture) - return (class ir_rvalue *) this; - return NULL; - } - - class ir_dereference *as_dereference() - { - assume(this != NULL); - if (ir_type == ir_type_dereference_array || - ir_type == ir_type_dereference_record || - ir_type == ir_type_dereference_variable) - return (class ir_dereference *) this; - return NULL; + #define AS_BASE(TYPE) \ + class ir_##TYPE *as_##TYPE() \ + { \ + assume(this != NULL); \ + return is_##TYPE() ? (ir_##TYPE *) this : NULL; \ } - class ir_jump *as_jump() - { - assume(this != NULL); - if (ir_type == ir_type_loop_jump || - ir_type == ir_type_return || - ir_type == ir_type_discard) - return (class ir_jump *) this; - return NULL; - } + AS_BASE(rvalue) + AS_BASE(dereference) + AS_BASE(jump) + #undef AS_BASE #define AS_CHILD(TYPE) \ class ir_##TYPE * as_##TYPE() \ From idr at kemper.freedesktop.org Wed Mar 25 17:42:16 2015 From: idr at kemper.freedesktop.org (Ian Romanick) Date: Wed, 25 Mar 2015 10:42:16 -0700 (PDT) Subject: Mesa (master): glsl: Constify the as_foo functions Message-ID: <20150325174216.7C54D76338@kemper.freedesktop.org> Module: Mesa Branch: master Commit: dec9664e35a35b447f21ea15631ae5a5404e9624 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=dec9664e35a35b447f21ea15631ae5a5404e9624 Author: Ian Romanick Date: Tue Mar 24 09:14:35 2015 -0700 glsl: Constify the as_foo functions Now that they're all implemented using macros, this is trivial. v2: Remove redundant parenthesis. Suggested by Curro. Signed-off-by: Ian Romanick Reviewed-by: Francisco Jerez --- src/glsl/ir.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/glsl/ir.h b/src/glsl/ir.h index 0284b02..b95ba2c 100644 --- a/src/glsl/ir.h +++ b/src/glsl/ir.h @@ -147,6 +147,11 @@ public: { \ assume(this != NULL); \ return is_##TYPE() ? (ir_##TYPE *) this : NULL; \ + } \ + const class ir_##TYPE *as_##TYPE() const \ + { \ + assume(this != NULL); \ + return is_##TYPE() ? (ir_##TYPE *) this : NULL; \ } AS_BASE(rvalue) @@ -159,6 +164,11 @@ public: { \ assume(this != NULL); \ return ir_type == ir_type_##TYPE ? (ir_##TYPE *) this : NULL; \ + } \ + const class ir_##TYPE * as_##TYPE() const \ + { \ + assume(this != NULL); \ + return ir_type == ir_type_##TYPE ? (const ir_##TYPE *) this : NULL; \ } AS_CHILD(variable) AS_CHILD(function) From idr at kemper.freedesktop.org Wed Mar 25 17:42:16 2015 From: idr at kemper.freedesktop.org (Ian Romanick) Date: Wed, 25 Mar 2015 10:42:16 -0700 (PDT) Subject: Mesa (master): glsl: Constify ir_instruction::equals Message-ID: <20150325174216.86FE176338@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 60757802471ba5a13e31cac7786eed3f369b6927 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=60757802471ba5a13e31cac7786eed3f369b6927 Author: Ian Romanick Date: Wed Mar 18 19:00:48 2015 -0700 glsl: Constify ir_instruction::equals v2: Don't be lazy. Constify the as_foo functions and use those instead of ugly casts. Suggested by Curro. Signed-off-by: Ian Romanick Reviewed-by: Francisco Jerez --- src/glsl/ir.h | 21 ++++++++++++++------- src/glsl/ir_equals.cpp | 20 ++++++++++++-------- 2 files changed, 26 insertions(+), 15 deletions(-) diff --git a/src/glsl/ir.h b/src/glsl/ir.h index b95ba2c..09275b3 100644 --- a/src/glsl/ir.h +++ b/src/glsl/ir.h @@ -196,7 +196,8 @@ public: * in particular. No support for other instruction types (assignments, * jumps, calls, etc.) is planned. */ - virtual bool equals(ir_instruction *ir, enum ir_node_type ignore = ir_type_unset); + virtual bool equals(const ir_instruction *ir, + enum ir_node_type ignore = ir_type_unset) const; protected: ir_instruction(enum ir_node_type t) @@ -1611,7 +1612,8 @@ public: */ ir_expression(int op, ir_rvalue *op0, ir_rvalue *op1, ir_rvalue *op2); - virtual bool equals(ir_instruction *ir, enum ir_node_type ignore = ir_type_unset); + virtual bool equals(const ir_instruction *ir, + enum ir_node_type ignore = ir_type_unset) const; virtual ir_expression *clone(void *mem_ctx, struct hash_table *ht) const; @@ -1922,7 +1924,8 @@ public: virtual ir_visitor_status accept(ir_hierarchical_visitor *); - virtual bool equals(ir_instruction *ir, enum ir_node_type ignore = ir_type_unset); + virtual bool equals(const ir_instruction *ir, + enum ir_node_type ignore = ir_type_unset) const; /** * Return a string representing the ir_texture_opcode. @@ -2023,7 +2026,8 @@ public: virtual ir_visitor_status accept(ir_hierarchical_visitor *); - virtual bool equals(ir_instruction *ir, enum ir_node_type ignore = ir_type_unset); + virtual bool equals(const ir_instruction *ir, + enum ir_node_type ignore = ir_type_unset) const; bool is_lvalue() const { @@ -2076,7 +2080,8 @@ public: virtual ir_constant *constant_expression_value(struct hash_table *variable_context = NULL); - virtual bool equals(ir_instruction *ir, enum ir_node_type ignore = ir_type_unset); + virtual bool equals(const ir_instruction *ir, + enum ir_node_type ignore = ir_type_unset) const; /** * Get the variable that is ultimately referenced by an r-value @@ -2122,7 +2127,8 @@ public: virtual ir_constant *constant_expression_value(struct hash_table *variable_context = NULL); - virtual bool equals(ir_instruction *ir, enum ir_node_type ignore = ir_type_unset); + virtual bool equals(const ir_instruction *ir, + enum ir_node_type ignore = ir_type_unset) const; /** * Get the variable that is ultimately referenced by an r-value @@ -2232,7 +2238,8 @@ public: virtual ir_visitor_status accept(ir_hierarchical_visitor *); - virtual bool equals(ir_instruction *ir, enum ir_node_type ignore = ir_type_unset); + virtual bool equals(const ir_instruction *ir, + enum ir_node_type ignore = ir_type_unset) const; /** * Get a particular component of a constant as a specific type diff --git a/src/glsl/ir_equals.cpp b/src/glsl/ir_equals.cpp index 65376cd..cc1964e 100644 --- a/src/glsl/ir_equals.cpp +++ b/src/glsl/ir_equals.cpp @@ -28,7 +28,8 @@ * can't access a's vtable in that case. */ static bool -possibly_null_equals(ir_instruction *a, ir_instruction *b, enum ir_node_type ignore) +possibly_null_equals(const ir_instruction *a, const ir_instruction *b, + enum ir_node_type ignore) { if (!a || !b) return !a && !b; @@ -41,13 +42,13 @@ possibly_null_equals(ir_instruction *a, ir_instruction *b, enum ir_node_type ign * about. */ bool -ir_instruction::equals(ir_instruction *, enum ir_node_type) +ir_instruction::equals(const ir_instruction *, enum ir_node_type) const { return false; } bool -ir_constant::equals(ir_instruction *ir, enum ir_node_type) +ir_constant::equals(const ir_instruction *ir, enum ir_node_type) const { const ir_constant *other = ir->as_constant(); if (!other) @@ -65,7 +66,8 @@ ir_constant::equals(ir_instruction *ir, enum ir_node_type) } bool -ir_dereference_variable::equals(ir_instruction *ir, enum ir_node_type) +ir_dereference_variable::equals(const ir_instruction *ir, + enum ir_node_type) const { const ir_dereference_variable *other = ir->as_dereference_variable(); if (!other) @@ -75,7 +77,8 @@ ir_dereference_variable::equals(ir_instruction *ir, enum ir_node_type) } bool -ir_dereference_array::equals(ir_instruction *ir, enum ir_node_type ignore) +ir_dereference_array::equals(const ir_instruction *ir, + enum ir_node_type ignore) const { const ir_dereference_array *other = ir->as_dereference_array(); if (!other) @@ -94,7 +97,8 @@ ir_dereference_array::equals(ir_instruction *ir, enum ir_node_type ignore) } bool -ir_swizzle::equals(ir_instruction *ir, enum ir_node_type ignore) +ir_swizzle::equals(const ir_instruction *ir, + enum ir_node_type ignore) const { const ir_swizzle *other = ir->as_swizzle(); if (!other) @@ -116,7 +120,7 @@ ir_swizzle::equals(ir_instruction *ir, enum ir_node_type ignore) } bool -ir_texture::equals(ir_instruction *ir, enum ir_node_type ignore) +ir_texture::equals(const ir_instruction *ir, enum ir_node_type ignore) const { const ir_texture *other = ir->as_texture(); if (!other) @@ -179,7 +183,7 @@ ir_texture::equals(ir_instruction *ir, enum ir_node_type ignore) } bool -ir_expression::equals(ir_instruction *ir, enum ir_node_type ignore) +ir_expression::equals(const ir_instruction *ir, enum ir_node_type ignore) const { const ir_expression *other = ir->as_expression(); if (!other) From evelikov at kemper.freedesktop.org Wed Mar 25 20:57:57 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Wed, 25 Mar 2015 13:57:57 -0700 (PDT) Subject: Mesa (master): automake: add missing egl files to the tarball Message-ID: <20150325205757.87ADB76338@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 5dc573e5de0eb49bc8622558789ebc4adf03926c URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=5dc573e5de0eb49bc8622558789ebc4adf03926c Author: Emil Velikov Date: Sat Mar 21 20:45:22 2015 +0000 automake: add missing egl files to the tarball Namely the Haiku EGL driver backend and the SConscript for the dri2 EGL driver backend. Cc: Alexander von Gluck IV Cc: mesa-stable at lists.freedesktop.org Signed-off-by: Emil Velikov --- src/Makefile.am | 5 ++++- src/egl/drivers/dri2/Makefile.am | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Makefile.am b/src/Makefile.am index 874a333..18cb4ce 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -53,7 +53,10 @@ if HAVE_GALLIUM SUBDIRS += gallium endif -EXTRA_DIST = egl/docs getopt hgl SConscript +EXTRA_DIST = \ + egl/drivers/haiku \ + egl/docs \ + getopt hgl SConscript AM_CFLAGS = $(VISIBILITY_CFLAGS) AM_CXXFLAGS = $(VISIBILITY_CXXFLAGS) diff --git a/src/egl/drivers/dri2/Makefile.am b/src/egl/drivers/dri2/Makefile.am index 79a40e8..f589600 100644 --- a/src/egl/drivers/dri2/Makefile.am +++ b/src/egl/drivers/dri2/Makefile.am @@ -64,3 +64,5 @@ if HAVE_EGL_PLATFORM_DRM libegl_dri2_la_SOURCES += platform_drm.c AM_CFLAGS += -DHAVE_DRM_PLATFORM endif + +EXTRA_DIST = SConscript From mattst88 at kemper.freedesktop.org Wed Mar 25 22:07:17 2015 From: mattst88 at kemper.freedesktop.org (Matt Turner) Date: Wed, 25 Mar 2015 15:07:17 -0700 (PDT) Subject: Mesa (master): glsl: Use INFINITY instead of std::numeric_limits:: infinity(). Message-ID: <20150325220717.281D976338@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 871f1080d0f7b7444458de40b67de7938c220922 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=871f1080d0f7b7444458de40b67de7938c220922 Author: Matt Turner Date: Mon Jan 12 22:35:53 2015 -0800 glsl: Use INFINITY instead of std::numeric_limits::infinity(). Reviewed-by: Jose Fonseca --- src/glsl/builtin_functions.cpp | 4 ++-- src/glsl/s_expression.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/glsl/builtin_functions.cpp b/src/glsl/builtin_functions.cpp index c607572..524b8d6 100644 --- a/src/glsl/builtin_functions.cpp +++ b/src/glsl/builtin_functions.cpp @@ -60,7 +60,7 @@ #include "ir_builder.h" #include "glsl_parser_extras.h" #include "program/prog_instruction.h" -#include +#include #define M_PIf ((float) M_PI) #define M_PI_2f ((float) M_PI_2) @@ -3215,7 +3215,7 @@ builtin_builder::_isinf(builtin_available_predicate avail, const glsl_type *type ir_constant_data infinities; for (int i = 0; i < type->vector_elements; i++) { - infinities.f[i] = std::numeric_limits::infinity(); + infinities.f[i] = INFINITY; } body.emit(ret(equal(abs(x), imm(type, infinities)))); diff --git a/src/glsl/s_expression.cpp b/src/glsl/s_expression.cpp index 7eaa491..f82e155 100644 --- a/src/glsl/s_expression.cpp +++ b/src/glsl/s_expression.cpp @@ -23,8 +23,8 @@ */ #include -#include #include +#include #include "s_expression.h" s_symbol::s_symbol(const char *str, size_t n) @@ -70,7 +70,7 @@ read_atom(void *ctx, const char *&src, char *&symbol_buffer) // requires strtof to parse '+INF' as +Infinity, but we still support some // non-C99-compliant compilers (e.g. MSVC). if (n == 4 && strncmp(src, "+INF", 4) == 0) { - expr = new(ctx) s_float(std::numeric_limits::infinity()); + expr = new(ctx) s_float(INFINITY); } else { // Check if the atom is a number. char *float_end = NULL; From kwg at kemper.freedesktop.org Wed Mar 25 23:18:09 2015 From: kwg at kemper.freedesktop.org (Kenneth Graunke) Date: Wed, 25 Mar 2015 16:18:09 -0700 (PDT) Subject: Mesa (master): i965/fs: Implement texture projection support. Message-ID: <20150325231809.B3CE87635B@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 649173b473ded2d7b1aded91cd4aab42eaeb5766 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=649173b473ded2d7b1aded91cd4aab42eaeb5766 Author: Kenneth Graunke Date: Sat Jan 31 23:36:52 2015 -0800 i965/fs: Implement texture projection support. Our fragment program backend implements support for TXP directly, and there's no NIR lowering pass to remove the projection. When we switch fragment program support over to NIR, we need to support it somehow. It's easy enough to support directly. v2: Split out offset/tex_offset rename (requested by Jordan). Signed-off-by: Kenneth Graunke Reviewed-by: Jordan Justen --- src/mesa/drivers/dri/i965/brw_fs_nir.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp index 98ea70c..0b8ed1a 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp @@ -1744,6 +1744,7 @@ fs_visitor::nir_emit_texture(nir_tex_instr *instr) int lod_components = 0, offset_components = 0; fs_reg coordinate, shadow_comparitor, lod, lod2, sample_index, mcs, tex_offset; + fs_reg projector; for (unsigned i = 0; i < instr->num_srcs; i++) { fs_reg src = get_nir_src(instr->src[i].src); @@ -1796,7 +1797,8 @@ fs_visitor::nir_emit_texture(nir_tex_instr *instr) offset_components = instr->coord_components; break; case nir_tex_src_projector: - unreachable("should be lowered"); + projector = retype(src, BRW_REGISTER_TYPE_F); + break; case nir_tex_src_sampler_offset: { /* Figure out the highest possible sampler index and mark it as used */ @@ -1820,6 +1822,13 @@ fs_visitor::nir_emit_texture(nir_tex_instr *instr) } } + if (projector.file != BAD_FILE) { + fs_reg invproj = vgrf(glsl_type::float_type); + emit_math(SHADER_OPCODE_RCP, invproj, projector); + for (int i = 0; i < 3; i++) + emit(MUL(offset(coordinate, i), offset(coordinate, i), invproj)); + } + if (instr->op == nir_texop_txf_ms) { if (brw->gen >= 7 && key_tex->compressed_multisample_layout_mask & (1 << sampler)) { From kwg at kemper.freedesktop.org Wed Mar 25 23:18:09 2015 From: kwg at kemper.freedesktop.org (Kenneth Graunke) Date: Wed, 25 Mar 2015 16:18:09 -0700 (PDT) Subject: Mesa (master): i965/fs: Rename offset to tex_offset to avoid shadowing offset(). Message-ID: <20150325231809.97B6676331@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 0a9bcf9e39409ea5acfdfbcf0c388e41e0f9ea45 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=0a9bcf9e39409ea5acfdfbcf0c388e41e0f9ea45 Author: Kenneth Graunke Date: Wed Mar 25 13:12:20 2015 -0700 i965/fs: Rename offset to tex_offset to avoid shadowing offset(). fs_visitor::nir_emit_texture() created an fs_reg variable called offset, which shadowed the offset() helper function in brw_ir_fs.h. Rename the variable to tex_offset so we can still call offset(). Signed-off-by: Kenneth Graunke Reviewed-by: Jordan Justen --- src/mesa/drivers/dri/i965/brw_fs_nir.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp index 69f296c..98ea70c 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp @@ -1743,7 +1743,7 @@ fs_visitor::nir_emit_texture(nir_tex_instr *instr) int lod_components = 0, offset_components = 0; - fs_reg coordinate, shadow_comparitor, lod, lod2, sample_index, mcs, offset; + fs_reg coordinate, shadow_comparitor, lod, lod2, sample_index, mcs, tex_offset; for (unsigned i = 0; i < instr->num_srcs; i++) { fs_reg src = get_nir_src(instr->src[i].src); @@ -1789,7 +1789,7 @@ fs_visitor::nir_emit_texture(nir_tex_instr *instr) sample_index = retype(src, BRW_REGISTER_TYPE_UD); break; case nir_tex_src_offset: - offset = retype(src, BRW_REGISTER_TYPE_D); + tex_offset = retype(src, BRW_REGISTER_TYPE_D); if (instr->is_array) offset_components = instr->coord_components - 1; else @@ -1832,7 +1832,7 @@ fs_visitor::nir_emit_texture(nir_tex_instr *instr) for (unsigned i = 0; i < 3; i++) { if (instr->const_offset[i] != 0) { assert(offset_components == 0); - offset = fs_reg(brw_texture_offset(ctx, instr->const_offset, 3)); + tex_offset = fs_reg(brw_texture_offset(ctx, instr->const_offset, 3)); break; } } @@ -1874,7 +1874,7 @@ fs_visitor::nir_emit_texture(nir_tex_instr *instr) emit_texture(op, dest_type, coordinate, instr->coord_components, shadow_comparitor, lod, lod2, lod_components, sample_index, - offset, mcs, gather_component, + tex_offset, mcs, gather_component, is_cube_array, is_rect, sampler, sampler_reg, texunit); fs_reg dest = get_nir_dest(instr->dest); From kwg at kemper.freedesktop.org Wed Mar 25 23:18:09 2015 From: kwg at kemper.freedesktop.org (Kenneth Graunke) Date: Wed, 25 Mar 2015 16:18:09 -0700 (PDT) Subject: Mesa (master): nir: Add glsl_float_type() wrapper. Message-ID: <20150325231809.7D93476338@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 3120345f407695e9fef96e4fa98f7ff3af8c38ce URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=3120345f407695e9fef96e4fa98f7ff3af8c38ce Author: Kenneth Graunke Date: Mon Feb 23 19:56:00 2015 -0800 nir: Add glsl_float_type() wrapper. Signed-off-by: Kenneth Graunke Reviewed-by: Jordan Justen --- src/glsl/nir/nir_types.cpp | 6 ++++++ src/glsl/nir/nir_types.h | 1 + 2 files changed, 7 insertions(+) diff --git a/src/glsl/nir/nir_types.cpp b/src/glsl/nir/nir_types.cpp index a13c3e1..f0d0b46 100644 --- a/src/glsl/nir/nir_types.cpp +++ b/src/glsl/nir/nir_types.cpp @@ -143,6 +143,12 @@ glsl_void_type(void) } const glsl_type * +glsl_float_type(void) +{ + return glsl_type::float_type; +} + +const glsl_type * glsl_vec4_type(void) { return glsl_type::vec4_type; diff --git a/src/glsl/nir/nir_types.h b/src/glsl/nir/nir_types.h index 494051a..276d4ad 100644 --- a/src/glsl/nir/nir_types.h +++ b/src/glsl/nir/nir_types.h @@ -69,6 +69,7 @@ bool glsl_type_is_scalar(const struct glsl_type *type); bool glsl_type_is_matrix(const struct glsl_type *type); const struct glsl_type *glsl_void_type(void); +const struct glsl_type *glsl_float_type(void); const struct glsl_type *glsl_vec4_type(void); const struct glsl_type *glsl_array_type(const struct glsl_type *base, unsigned elements); From kwg at kemper.freedesktop.org Wed Mar 25 23:20:07 2015 From: kwg at kemper.freedesktop.org (Kenneth Graunke) Date: Wed, 25 Mar 2015 16:20:07 -0700 (PDT) Subject: Mesa (master): i965: Drop unnecessary brw->gen >= 8 check from scalar VS code. Message-ID: <20150325232007.B7DF576338@kemper.freedesktop.org> Module: Mesa Branch: master Commit: ef09cfb51e0c1cc9e3c6f370813a843a6ecaa4e2 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=ef09cfb51e0c1cc9e3c6f370813a843a6ecaa4e2 Author: Kenneth Graunke Date: Wed Mar 25 15:15:43 2015 -0700 i965: Drop unnecessary brw->gen >= 8 check from scalar VS code. brw->scalar_vs already implies that brw->gen >= 8. Signed-off-by: Kenneth Graunke Reviewed-by: Jordan Justen --- src/mesa/drivers/dri/i965/brw_vec4.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesa/drivers/dri/i965/brw_vec4.cpp b/src/mesa/drivers/dri/i965/brw_vec4.cpp index 918519c..9d2e375 100644 --- a/src/mesa/drivers/dri/i965/brw_vec4.cpp +++ b/src/mesa/drivers/dri/i965/brw_vec4.cpp @@ -1823,7 +1823,7 @@ brw_vs_emit(struct brw_context *brw, if (unlikely(INTEL_DEBUG & DEBUG_VS)) brw_dump_ir("vertex", prog, &shader->base, &c->vp->program.Base); - if (prog && brw->gen >= 8 && brw->scalar_vs) { + if (prog && brw->scalar_vs) { fs_visitor v(brw, mem_ctx, &c->key, prog_data, prog, &c->vp->program, 8); if (!v.run_vs()) { if (prog) { From evelikov at kemper.freedesktop.org Thu Mar 26 01:44:45 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Wed, 25 Mar 2015 18:44:45 -0700 (PDT) Subject: Mesa (10.5): glsl: optimize (0 cmp x + y) into (-x cmp y). Message-ID: <20150326014445.412D07635B@kemper.freedesktop.org> Module: Mesa Branch: 10.5 Commit: 5e572b1ccee4adfba9441c793b53b7950de560c5 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=5e572b1ccee4adfba9441c793b53b7950de560c5 Author: Samuel Iglesias Gonsalvez Date: Tue Feb 24 19:02:57 2015 +0100 glsl: optimize (0 cmp x + y) into (-x cmp y). The optimization done by commit 34ec1a24d did not take it into account. Fixes: dEQP-GLES3.functional.shaders.random.all_features.fragment.20 Signed-off-by: Samuel Iglesias Gonsalvez Reviewed-by: Ian Romanick Reviewed-by: Matt Turner Cc: "10.4 10.5" (cherry picked from commit b43bbfa90ace596c8b2e0b3954a5f69924726c59) --- src/glsl/opt_algebraic.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/glsl/opt_algebraic.cpp b/src/glsl/opt_algebraic.cpp index fae58c7..7f25fc4 100644 --- a/src/glsl/opt_algebraic.cpp +++ b/src/glsl/opt_algebraic.cpp @@ -578,9 +578,18 @@ ir_algebraic_visitor::handle_expression(ir_expression *ir) if (!is_vec_zero(zero)) continue; - return new(mem_ctx) ir_expression(ir->operation, - add->operands[0], - neg(add->operands[1])); + /* Depending of the zero position we want to optimize + * (0 cmp x+y) into (-x cmp y) or (x+y cmp 0) into (x cmp -y) + */ + if (add_pos == 1) { + return new(mem_ctx) ir_expression(ir->operation, + neg(add->operands[0]), + add->operands[1]); + } else { + return new(mem_ctx) ir_expression(ir->operation, + add->operands[0], + neg(add->operands[1])); + } } break; From evelikov at kemper.freedesktop.org Thu Mar 26 01:44:45 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Wed, 25 Mar 2015 18:44:45 -0700 (PDT) Subject: Mesa (10.5): automake: add missing egl files to the tarball Message-ID: <20150326014445.34C1176338@kemper.freedesktop.org> Module: Mesa Branch: 10.5 Commit: d80bc65016671abccaac3746efba0f1d704b7d07 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=d80bc65016671abccaac3746efba0f1d704b7d07 Author: Emil Velikov Date: Sat Mar 21 20:45:22 2015 +0000 automake: add missing egl files to the tarball Namely the Haiku EGL driver backend and the SConscript for the dri2 EGL driver backend. Cc: Alexander von Gluck IV Cc: mesa-stable at lists.freedesktop.org Signed-off-by: Emil Velikov (cherry picked from commit 5dc573e5de0eb49bc8622558789ebc4adf03926c) --- src/Makefile.am | 5 ++++- src/egl/drivers/dri2/Makefile.am | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Makefile.am b/src/Makefile.am index 8edf333..006e2ff 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -53,7 +53,10 @@ if HAVE_GALLIUM SUBDIRS += gallium endif -EXTRA_DIST = egl/docs getopt hgl SConscript +EXTRA_DIST = \ + egl/drivers/haiku \ + egl/docs \ + getopt hgl SConscript AM_CPPFLAGS = \ -I$(top_srcdir)/include/ \ diff --git a/src/egl/drivers/dri2/Makefile.am b/src/egl/drivers/dri2/Makefile.am index 79a40e8..f589600 100644 --- a/src/egl/drivers/dri2/Makefile.am +++ b/src/egl/drivers/dri2/Makefile.am @@ -64,3 +64,5 @@ if HAVE_EGL_PLATFORM_DRM libegl_dri2_la_SOURCES += platform_drm.c AM_CFLAGS += -DHAVE_DRM_PLATFORM endif + +EXTRA_DIST = SConscript From evelikov at kemper.freedesktop.org Thu Mar 26 01:44:45 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Wed, 25 Mar 2015 18:44:45 -0700 (PDT) Subject: Mesa (10.5): freedreno: fix slice pitch calculations Message-ID: <20150326014445.4EAB876397@kemper.freedesktop.org> Module: Mesa Branch: 10.5 Commit: 411f975a8129f4eb91a28a52d524059fdb174515 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=411f975a8129f4eb91a28a52d524059fdb174515 Author: Ilia Mirkin Date: Fri Mar 13 01:36:57 2015 -0400 freedreno: fix slice pitch calculations For example if width were 65, the first slice would get 96 while the second would get 32. However the hardware appears to expect the second pitch to be 64, based on halving the 96 (and aligning up to 32). This fixes texelFetch piglit tests on a3xx below a certain size. Going higher they break again, but most likely due to unrelated reasons. Signed-off-by: Ilia Mirkin Cc: "10.4 10.5" Reviewed-by: Rob Clark (cherry picked from commit 620e29b74821fd75b24495ab2bfddea53fc75350) --- src/gallium/drivers/freedreno/freedreno_resource.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gallium/drivers/freedreno/freedreno_resource.c b/src/gallium/drivers/freedreno/freedreno_resource.c index c7b4e57..69e5452 100644 --- a/src/gallium/drivers/freedreno/freedreno_resource.c +++ b/src/gallium/drivers/freedreno/freedreno_resource.c @@ -213,7 +213,7 @@ setup_slices(struct fd_resource *rsc, uint32_t alignment) for (level = 0; level <= prsc->last_level; level++) { struct fd_resource_slice *slice = fd_resource_slice(rsc, level); - slice->pitch = align(width, 32); + slice->pitch = width = align(width, 32); slice->offset = size; /* 1d array, 2d array, 3d textures (but not cube!) must all have the * same layer size for each miplevel on a3xx. These are also the From evelikov at kemper.freedesktop.org Thu Mar 26 01:44:45 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Wed, 25 Mar 2015 18:44:45 -0700 (PDT) Subject: Mesa (10.5): st/egl: don't ship the dri2.c link at the tarball Message-ID: <20150326014445.3A1EB7635A@kemper.freedesktop.org> Module: Mesa Branch: 10.5 Commit: 2beab3c01c7be935fc7d2f1f025373cadebdeb4d URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=2beab3c01c7be935fc7d2f1f025373cadebdeb4d Author: Emil Velikov Date: Sat Mar 21 22:09:03 2015 +0000 st/egl: don't ship the dri2.c link at the tarball During 'make dist' the path of the symbolic link (x11/dri2.c) becomes too long, and tar converts it to hard one. To make it more complicated on Haiku tar errors out (due to lack of hardlink support) rather than falling back to the next best thing. So remove the symlink from git, and disable the scons x11_drm egl code. The offending code is not build with either automake nor android. Brian, Jose would you have any objections against this ? I was playing around to get the symlink resolved, although I could not get the dependency tracking resolved, so env.Command() was never executed :-\ Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=89680 Cc: mesa-stable at lists.freedesktop.org Cc: Alexander von Gluck IV Cc: Brian Paul Acked-by: Jose Fonseca Signed-off-by: Emil Velikov --- src/gallium/state_trackers/egl/Makefile.sources | 1 - src/gallium/state_trackers/egl/SConscript | 3 ++- src/gallium/state_trackers/egl/x11/dri2.c | 1 - 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/gallium/state_trackers/egl/Makefile.sources b/src/gallium/state_trackers/egl/Makefile.sources index 03ded58..0551c16 100644 --- a/src/gallium/state_trackers/egl/Makefile.sources +++ b/src/gallium/state_trackers/egl/Makefile.sources @@ -52,6 +52,5 @@ x11_FILES := \ x11/native_ximage.c x11_drm_FILES := \ - x11/dri2.c \ x11/x11_screen.c \ x11/x11_screen.h diff --git a/src/gallium/state_trackers/egl/SConscript b/src/gallium/state_trackers/egl/SConscript index 3727fb2..a94abc2 100644 --- a/src/gallium/state_trackers/egl/SConscript +++ b/src/gallium/state_trackers/egl/SConscript @@ -39,7 +39,8 @@ else: '#/src/mapi', ]) sources.append(env.ParseSourceList('Makefile.sources', 'x11_FILES')) - if env['drm']: + if env['drm'] and False: + # XXX: Disabled as we're don't generate the x11/dri2.c symlink at buildtime. env.Append(CPPDEFINES = ['GLX_DIRECT_RENDERING']) sources.append(env.ParseSourceList('Makefile.sources', 'x11_drm_FILES')) if env['drm'] and False: diff --git a/src/gallium/state_trackers/egl/x11/dri2.c b/src/gallium/state_trackers/egl/x11/dri2.c deleted file mode 120000 index 344a11c..0000000 --- a/src/gallium/state_trackers/egl/x11/dri2.c +++ /dev/null @@ -1 +0,0 @@ -../../../../glx/dri2.c \ No newline at end of file From evelikov at kemper.freedesktop.org Thu Mar 26 01:44:45 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Wed, 25 Mar 2015 18:44:45 -0700 (PDT) Subject: Mesa (10.5): auxiliary/os: fix the android build - s/drm_munmap/os_munmap/ Message-ID: <20150326014445.6A91D76409@kemper.freedesktop.org> Module: Mesa Branch: 10.5 Commit: 0410d9b18646948c9d1e11592589d98b298e7b34 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=0410d9b18646948c9d1e11592589d98b298e7b34 Author: Emil Velikov Date: Mon Mar 16 15:00:18 2015 +0000 auxiliary/os: fix the android build - s/drm_munmap/os_munmap/ Squash this silly typo introduced with commit c63eb5dd5ec(auxiliary/os: get the mmap/munmap wrappers working with android) Cc: "10.4 10.5" Signed-off-by: Emil Velikov Reviewed-by: Brian Paul (cherry picked from commit 55f0c0a29f788c5df4820e81c0cf93613ccedf5e) --- src/gallium/auxiliary/os/os_mman.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gallium/auxiliary/os/os_mman.h b/src/gallium/auxiliary/os/os_mman.h index 19c9a5b..3fc8c43 100644 --- a/src/gallium/auxiliary/os/os_mman.h +++ b/src/gallium/auxiliary/os/os_mman.h @@ -70,8 +70,8 @@ static INLINE void *os_mmap(void *addr, size_t length, int prot, int flags, return __mmap2(addr, length, prot, flags, fd, (size_t) (offset >> 12)); } -# define drm_munmap(addr, length) \ - munmap(addr, length) +# define os_munmap(addr, length) \ + munmap(addr, length) #else /* assume large file support exists */ From evelikov at kemper.freedesktop.org Thu Mar 26 01:44:45 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Wed, 25 Mar 2015 18:44:45 -0700 (PDT) Subject: Mesa (10.5): c11/threads: Use PTHREAD_MUTEX_RECURSIVE by default Message-ID: <20150326014445.5DFC7763CF@kemper.freedesktop.org> Module: Mesa Branch: 10.5 Commit: 29810e43dad8573b5986c58bcd208463ddf18957 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=29810e43dad8573b5986c58bcd208463ddf18957 Author: Felix Janda Date: Mon Feb 2 20:04:16 2015 +0100 c11/threads: Use PTHREAD_MUTEX_RECURSIVE by default Previously PTHREAD_MUTEX_RECURSIVE_NP had been used on linux for compatibility with old glibc. Since mesa defines __GNU_SOURCE__ on linux PTHREAD_MUTEX_RECURSIVE is also available since at least 1998. So we can unconditionally use the portable version PTHREAD_MUTEX_RECURSIVE. Cc: "10.5" Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=88534 Reviewed-by: Emil Velikov (cherry picked from commit aead7fe2e2b6c89258f80a25299f4ec0fece2d95) --- include/c11/threads_posix.h | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/include/c11/threads_posix.h b/include/c11/threads_posix.h index f9c165d..2182c28 100644 --- a/include/c11/threads_posix.h +++ b/include/c11/threads_posix.h @@ -177,13 +177,8 @@ mtx_init(mtx_t *mtx, int type) && type != (mtx_try|mtx_recursive)) return thrd_error; pthread_mutexattr_init(&attr); - if ((type & mtx_recursive) != 0) { -#if defined(__linux__) || defined(__linux) - pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE_NP); -#else + if ((type & mtx_recursive) != 0) pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE); -#endif - } pthread_mutex_init(mtx, &attr); pthread_mutexattr_destroy(&attr); return thrd_success; From evelikov at kemper.freedesktop.org Thu Mar 26 01:44:45 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Wed, 25 Mar 2015 18:44:45 -0700 (PDT) Subject: Mesa (10.5): loader: include for non-sysfs builds Message-ID: <20150326014445.6462E763D0@kemper.freedesktop.org> Module: Mesa Branch: 10.5 Commit: af3e6e28580b7c1cc6899f77d6a1b6db9b05e0e9 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=af3e6e28580b7c1cc6899f77d6a1b6db9b05e0e9 Author: Emil Velikov Date: Wed Mar 11 19:12:35 2015 +0000 loader: include for non-sysfs builds Required by fstat(), otherwise we'll error out due to implicit function declaration. Cc: "10.4 10.5" Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=89530 Signed-off-by: Emil Velikov Reported-by: Vadim Rutkovsky Tested-by: Vadim Rutkovsky (cherry picked from commit 771cd266b9d00bdcf2cf7acaa3c8363c358d7478) --- src/loader/loader.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/loader/loader.c b/src/loader/loader.c index 94c993a..638ebf2 100644 --- a/src/loader/loader.c +++ b/src/loader/loader.c @@ -64,6 +64,7 @@ * Rob Clark */ +#include #include #include #include @@ -80,7 +81,6 @@ #endif #endif #ifdef HAVE_SYSFS -#include #include #endif #include "loader.h" From evelikov at kemper.freedesktop.org Thu Mar 26 01:44:45 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Wed, 25 Mar 2015 18:44:45 -0700 (PDT) Subject: Mesa (10.5): mapi: Make private copies of name strings provided by client. Message-ID: <20150326014445.947B876413@kemper.freedesktop.org> Module: Mesa Branch: 10.5 Commit: d6413ed98fe07479d16cd2033d5379e06e5ce6d7 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=d6413ed98fe07479d16cd2033d5379e06e5ce6d7 Author: Mario Kleiner Date: Thu Mar 12 23:34:12 2015 +0100 mapi: Make private copies of name strings provided by client. glXGetProcAddress("glFoo") ends up in stub_add_dynamic() to create dynamic stubs for dynamic functions. stub_add_dynamic() doesn't store the caller provided name string "Foo" in a mesa private copy, but just stores a pointer to the "glFoo" string passed to glXGetProcAddress - a pointer into arbitrary memory outside mesa's control. If the caller passes some dynamically allocated/changing memory buffer to glXGetProcAddress(), or the caller gets unmapped from memory, e.g., some dynamically loaded application plugin which uses OpenGL, this ends badly - with a dangling pointer. strdup() the name string provided by the client to avoid this problem. Cc: "10.3 10.4 10.5" Signed-off-by: Mario Kleiner Reviewed-by: Brian Paul (cherry picked from commit 1110113a7f0b6f9b21dd26dee8e95a021041c71c) --- src/mapi/stub.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mapi/stub.c b/src/mapi/stub.c index dfadbe1..45ccc6a 100644 --- a/src/mapi/stub.c +++ b/src/mapi/stub.c @@ -110,7 +110,7 @@ stub_add_dynamic(const char *name) if (!stub->addr) return NULL; - stub->name = (const void *) name; + stub->name = (const void *) strdup(name); /* to be fixed later */ stub->slot = -1; From evelikov at kemper.freedesktop.org Thu Mar 26 01:44:45 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Wed, 25 Mar 2015 18:44:45 -0700 (PDT) Subject: Mesa (10.5): radeonsi: increase coords array size for radeon_llvm_emit_prepare_cube_coords Message-ID: <20150326014445.78D3F7640D@kemper.freedesktop.org> Module: Mesa Branch: 10.5 Commit: d33bf8150f96fdb8c6c1ff1acf6870dbe54ca715 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=d33bf8150f96fdb8c6c1ff1acf6870dbe54ca715 Author: Marek Ol??k Date: Tue Mar 17 17:47:17 2015 +0100 radeonsi: increase coords array size for radeon_llvm_emit_prepare_cube_coords radeon_llvm_emit_prepare_cube_coords uses coords[4] in some cases (TXB2 etc.) Discovered by Coverity. Reported by Ilia Mirkin. Cc: 10.5 10.4 Reviewed-by: Michel D?nzer (cherry picked from commit a984abdad39df2d8ceb4c46e11f4ce1344c36c86) --- src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c | 2 +- src/gallium/drivers/radeonsi/si_shader.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c b/src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c index dce5b55..7f52d44 100644 --- a/src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c +++ b/src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c @@ -748,7 +748,7 @@ static void txp_fetch_args( const struct tgsi_full_instruction * inst = emit_data->inst; LLVMValueRef src_w; unsigned chan; - LLVMValueRef coords[4]; + LLVMValueRef coords[5]; emit_data->dst_type = LLVMVectorType(bld_base->base.elem_type, 4); src_w = lp_build_emit_fetch(bld_base, emit_data->inst, 0, TGSI_CHAN_W); diff --git a/src/gallium/drivers/radeonsi/si_shader.c b/src/gallium/drivers/radeonsi/si_shader.c index e6849ad..81ce3f6 100644 --- a/src/gallium/drivers/radeonsi/si_shader.c +++ b/src/gallium/drivers/radeonsi/si_shader.c @@ -1520,7 +1520,7 @@ static void tex_fetch_args( const struct tgsi_full_instruction * inst = emit_data->inst; unsigned opcode = inst->Instruction.Opcode; unsigned target = inst->Texture.Texture; - LLVMValueRef coords[4]; + LLVMValueRef coords[5]; LLVMValueRef address[16]; int ref_pos; unsigned num_coords = tgsi_util_get_texture_coord_dim(target, &ref_pos); From evelikov at kemper.freedesktop.org Thu Mar 26 01:44:45 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Wed, 25 Mar 2015 18:44:45 -0700 (PDT) Subject: Mesa (10.5): i965: Set nr_params to the number of uniform components in the VS/GS path. Message-ID: <20150326014445.80D1A7640E@kemper.freedesktop.org> Module: Mesa Branch: 10.5 Commit: 859b4afc973a27f4aeb6ee68d5a019d9210c0ac9 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=859b4afc973a27f4aeb6ee68d5a019d9210c0ac9 Author: Francisco Jerez Date: Thu Jan 22 17:08:23 2015 +0200 i965: Set nr_params to the number of uniform components in the VS/GS path. Both do_vs_prog and do_gs_prog initialize brw_stage_prog_data::nr_params to the number of uniform *vectors* required by the shader rather than the number of uniform components, contradicting the comment. This is inconsistent with what the state upload code and scalar path expect but it happens to work until Gen8 because vec4_visitor interprets it as a number of vectors on construction and later on overwrites its original value with the number of uniform components referenced by the shader. Also there's no need to add the number of samplers, they're not actually passed in as uniforms. Fixes a memory corruption issue on BDW with SIMD8 VS. Cc: "10.5" Reviewed-by: Kenneth Graunke (cherry picked from commit fd149628e142af769c1c0ec037bc297d8a3e871f) [Emil Velikov: s/DIV_ROUND_UP/CEILING/] Signed-off-by: Emil Velikov --- src/mesa/drivers/dri/i965/brw_gs.c | 6 +----- src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp | 3 ++- src/mesa/drivers/dri/i965/brw_vs.c | 10 +--------- 3 files changed, 4 insertions(+), 15 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_gs.c b/src/mesa/drivers/dri/i965/brw_gs.c index d96a21e..aad9b0c 100644 --- a/src/mesa/drivers/dri/i965/brw_gs.c +++ b/src/mesa/drivers/dri/i965/brw_gs.c @@ -69,11 +69,7 @@ do_gs_prog(struct brw_context *brw, rzalloc_array(NULL, const gl_constant_value *, param_count); c.prog_data.base.base.pull_param = rzalloc_array(NULL, const gl_constant_value *, param_count); - /* Setting nr_params here NOT to the size of the param and pull_param - * arrays, but to the number of uniform components vec4_visitor - * needs. vec4_visitor::setup_uniforms() will set it back to a proper value. - */ - c.prog_data.base.base.nr_params = ALIGN(param_count, 4) / 4 + gs->num_samplers; + c.prog_data.base.base.nr_params = param_count; if (brw->gen >= 7) { if (gp->program.OutputType == GL_POINTS) { diff --git a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp index 3912a49..1add0bd 100644 --- a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp +++ b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp @@ -3628,7 +3628,8 @@ vec4_visitor::vec4_visitor(struct brw_context *brw, */ this->uniform_array_size = 1; if (prog_data) { - this->uniform_array_size = MAX2(stage_prog_data->nr_params, 1); + this->uniform_array_size = + MAX2(CEILING(stage_prog_data->nr_params, 4), 1); } this->uniform_size = rzalloc_array(mem_ctx, int, this->uniform_array_size); diff --git a/src/mesa/drivers/dri/i965/brw_vs.c b/src/mesa/drivers/dri/i965/brw_vs.c index 2d56b74..f360d4e 100644 --- a/src/mesa/drivers/dri/i965/brw_vs.c +++ b/src/mesa/drivers/dri/i965/brw_vs.c @@ -241,15 +241,7 @@ do_vs_prog(struct brw_context *brw, rzalloc_array(NULL, const gl_constant_value *, param_count); stage_prog_data->pull_param = rzalloc_array(NULL, const gl_constant_value *, param_count); - - /* Setting nr_params here NOT to the size of the param and pull_param - * arrays, but to the number of uniform components vec4_visitor - * needs. vec4_visitor::setup_uniforms() will set it back to a proper value. - */ - stage_prog_data->nr_params = ALIGN(param_count, 4) / 4; - if (vs) { - stage_prog_data->nr_params += vs->num_samplers; - } + stage_prog_data->nr_params = param_count; GLbitfield64 outputs_written = vp->program.Base.OutputsWritten; prog_data.inputs_read = vp->program.Base.InputsRead; From evelikov at kemper.freedesktop.org Thu Mar 26 01:44:45 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Wed, 25 Mar 2015 18:44:45 -0700 (PDT) Subject: Mesa (10.5): configure: Introduce new output variable to ax_check_python_mako_module.m4 Message-ID: <20150326014445.A31FE76450@kemper.freedesktop.org> Module: Mesa Branch: 10.5 Commit: e98909b0567b8a83a6a953cfa4ee4e7beef436b9 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=e98909b0567b8a83a6a953cfa4ee4e7beef436b9 Author: Samuel Iglesias Gonsalvez Date: Mon Mar 2 10:49:31 2015 +0100 configure: Introduce new output variable to ax_check_python_mako_module.m4 This output variables gives more flexibility for future changes in autoconf to detect if it is needed to auto-generate files and check for the auto-generation dependencies. It is still returning error when Python is not installed. Signed-off-by: Samuel Iglesias Gonsalvez Reviewed-by: Kai Wasserb?ch (cherry picked from commit ced9425327be6cb557a4a1217a1dac29b18d1a09) Squashed with commit configure.ac: move AC_MSG_RESULT reporting back into the m4 macro The one who does AC_MSG_CHECKING should provide the AC_MSG_RESULT. Fixes: ced9425327b (configure: Introduce new output variable to ax_check_python_mako_module.m4" Cc: "10.5" Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=89328 Signed-off-by: Emil Velikov Reviewed-by: Samuel Iglesias Gonsalvez (cherry picked from commit 248eb54eb6117cc5a863ba2deaa14c3bee0b5d41) --- configure.ac | 6 +++++- m4/ax_check_python_mako_module.m4 | 6 ++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index f596a9d..20e6d62 100644 --- a/configure.ac +++ b/configure.ac @@ -78,6 +78,7 @@ XCBDRI2_REQUIRED=1.8 XCBGLX_REQUIRED=1.8.1 XSHMFENCE_REQUIRED=1.1 XVMC_REQUIRED=1.0.6 +PYTHON_MAKO_REQUIRED=0.3.4 dnl Check for progs AC_PROG_CPP @@ -113,7 +114,10 @@ if test "x$INDENT" != "xcat"; then fi fi -AX_CHECK_PYTHON_MAKO_MODULE(0.3.4) +AX_CHECK_PYTHON_MAKO_MODULE($PYTHON_MAKO_REQUIRED) +if test -n "$PYTHON2" -a "x$acv_mako_found" != "xyes"; then + AC_MSG_ERROR([Python mako module v$PYTHON_MAKO_REQUIRED or higher not found]) +fi AC_PROG_INSTALL diff --git a/m4/ax_check_python_mako_module.m4 b/m4/ax_check_python_mako_module.m4 index 2fc029b..7d9bb51 100644 --- a/m4/ax_check_python_mako_module.m4 +++ b/m4/ax_check_python_mako_module.m4 @@ -54,8 +54,10 @@ else: " | $PYTHON2 - if test $? -ne 0 ; then - AC_MSG_ERROR(mako $1 or later is required.) + AC_MSG_RESULT(no) + AC_SUBST(acv_mako_found, 'no') else - AC_MSG_RESULT(yes) + AC_MSG_RESULT(yes) + AC_SUBST(acv_mako_found, 'yes') fi ]) From evelikov at kemper.freedesktop.org Thu Mar 26 01:44:45 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Wed, 25 Mar 2015 18:44:45 -0700 (PDT) Subject: Mesa (10.5): freedreno/a3xx: use the same layer size for all slices Message-ID: <20150326014445.480147635C@kemper.freedesktop.org> Module: Mesa Branch: 10.5 Commit: 3fa76f3f79962c608f2adbdad2bd942006683690 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=3fa76f3f79962c608f2adbdad2bd942006683690 Author: Ilia Mirkin Date: Fri Mar 13 00:53:49 2015 -0400 freedreno/a3xx: use the same layer size for all slices We only program in one layer size per texture, so that means that all levels must share one size. This makes the piglit test bin/texelFetch fs sampler2DArray have the same breakage as its non-array version instead of being completely off, and makes bin/ext_texture_array-gen-mipmap start passing. Signed-off-by: Ilia Mirkin Cc: "10.4 10.5" Reviewed-by: Rob Clark (cherry picked from commit 89b26d5a360ebde11a69f2cdefa66e4d6a2a13fd) --- src/gallium/drivers/freedreno/freedreno_resource.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/gallium/drivers/freedreno/freedreno_resource.c b/src/gallium/drivers/freedreno/freedreno_resource.c index c412407..c7b4e57 100644 --- a/src/gallium/drivers/freedreno/freedreno_resource.c +++ b/src/gallium/drivers/freedreno/freedreno_resource.c @@ -215,7 +215,14 @@ setup_slices(struct fd_resource *rsc, uint32_t alignment) slice->pitch = align(width, 32); slice->offset = size; - slice->size0 = align(slice->pitch * height * rsc->cpp, alignment); + /* 1d array, 2d array, 3d textures (but not cube!) must all have the + * same layer size for each miplevel on a3xx. These are also the + * targets that have non-1 alignment. + */ + if (level == 0 || layers_in_level == 1 || alignment == 1) + slice->size0 = align(slice->pitch * height * rsc->cpp, alignment); + else + slice->size0 = rsc->slices[0].size0; size += slice->size0 * depth * layers_in_level; From evelikov at kemper.freedesktop.org Thu Mar 26 01:44:45 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Wed, 25 Mar 2015 18:44:45 -0700 (PDT) Subject: Mesa (10.5): freedreno: update generated headers Message-ID: <20150326014445.57B5B7639A@kemper.freedesktop.org> Module: Mesa Branch: 10.5 Commit: 2e0f2ad59c8d98ebe545d911747079a1a7958acf URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=2e0f2ad59c8d98ebe545d911747079a1a7958acf Author: Rob Clark Date: Sun Mar 15 17:59:01 2015 -0400 freedreno: update generated headers Fix a3xx texture layer-size. Signed-off-by: Rob Clark Cc: "10.4 10.5" (cherry picked from commit e92bc6b38e90339a394e95a562bcce35c3ee9696) --- src/gallium/drivers/freedreno/a2xx/a2xx.xml.h | 2 +- src/gallium/drivers/freedreno/a3xx/a3xx.xml.h | 4 ++-- src/gallium/drivers/freedreno/a4xx/a4xx.xml.h | 2 +- src/gallium/drivers/freedreno/adreno_common.xml.h | 2 +- src/gallium/drivers/freedreno/adreno_pm4.xml.h | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/gallium/drivers/freedreno/a2xx/a2xx.xml.h b/src/gallium/drivers/freedreno/a2xx/a2xx.xml.h index de415ab..3811bc5 100644 --- a/src/gallium/drivers/freedreno/a2xx/a2xx.xml.h +++ b/src/gallium/drivers/freedreno/a2xx/a2xx.xml.h @@ -13,7 +13,7 @@ The rules-ng-ng source files this header was generated from are: - /home/robclark/src/freedreno/envytools/rnndb/adreno/a2xx.xml ( 32901 bytes, from 2014-06-02 15:21:30) - /home/robclark/src/freedreno/envytools/rnndb/adreno/adreno_common.xml ( 10551 bytes, from 2014-11-13 22:44:30) - /home/robclark/src/freedreno/envytools/rnndb/adreno/adreno_pm4.xml ( 15085 bytes, from 2014-12-20 21:49:41) -- /home/robclark/src/freedreno/envytools/rnndb/adreno/a3xx.xml ( 64848 bytes, from 2015-02-20 18:21:24) +- /home/robclark/src/freedreno/envytools/rnndb/adreno/a3xx.xml ( 64771 bytes, from 2015-03-15 21:55:57) - /home/robclark/src/freedreno/envytools/rnndb/adreno/a4xx.xml ( 51942 bytes, from 2015-02-24 17:14:02) Copyright (C) 2013-2014 by the following authors: diff --git a/src/gallium/drivers/freedreno/a3xx/a3xx.xml.h b/src/gallium/drivers/freedreno/a3xx/a3xx.xml.h index f0912b4..87626ac 100644 --- a/src/gallium/drivers/freedreno/a3xx/a3xx.xml.h +++ b/src/gallium/drivers/freedreno/a3xx/a3xx.xml.h @@ -13,7 +13,7 @@ The rules-ng-ng source files this header was generated from are: - /home/robclark/src/freedreno/envytools/rnndb/adreno/a2xx.xml ( 32901 bytes, from 2014-06-02 15:21:30) - /home/robclark/src/freedreno/envytools/rnndb/adreno/adreno_common.xml ( 10551 bytes, from 2014-11-13 22:44:30) - /home/robclark/src/freedreno/envytools/rnndb/adreno/adreno_pm4.xml ( 15085 bytes, from 2014-12-20 21:49:41) -- /home/robclark/src/freedreno/envytools/rnndb/adreno/a3xx.xml ( 64848 bytes, from 2015-02-20 18:21:24) +- /home/robclark/src/freedreno/envytools/rnndb/adreno/a3xx.xml ( 64771 bytes, from 2015-03-15 21:55:57) - /home/robclark/src/freedreno/envytools/rnndb/adreno/a4xx.xml ( 51942 bytes, from 2015-02-24 17:14:02) Copyright (C) 2013-2015 by the following authors: @@ -2677,7 +2677,7 @@ static inline uint32_t A3XX_TEX_CONST_2_SWAP(enum a3xx_color_swap val) } #define REG_A3XX_TEX_CONST_3 0x00000003 -#define A3XX_TEX_CONST_3_LAYERSZ1__MASK 0x0000000f +#define A3XX_TEX_CONST_3_LAYERSZ1__MASK 0x00001fff #define A3XX_TEX_CONST_3_LAYERSZ1__SHIFT 0 static inline uint32_t A3XX_TEX_CONST_3_LAYERSZ1(uint32_t val) { diff --git a/src/gallium/drivers/freedreno/a4xx/a4xx.xml.h b/src/gallium/drivers/freedreno/a4xx/a4xx.xml.h index 73e9de6..0e80564 100644 --- a/src/gallium/drivers/freedreno/a4xx/a4xx.xml.h +++ b/src/gallium/drivers/freedreno/a4xx/a4xx.xml.h @@ -13,7 +13,7 @@ The rules-ng-ng source files this header was generated from are: - /home/robclark/src/freedreno/envytools/rnndb/adreno/a2xx.xml ( 32901 bytes, from 2014-06-02 15:21:30) - /home/robclark/src/freedreno/envytools/rnndb/adreno/adreno_common.xml ( 10551 bytes, from 2014-11-13 22:44:30) - /home/robclark/src/freedreno/envytools/rnndb/adreno/adreno_pm4.xml ( 15085 bytes, from 2014-12-20 21:49:41) -- /home/robclark/src/freedreno/envytools/rnndb/adreno/a3xx.xml ( 64848 bytes, from 2015-02-20 18:21:24) +- /home/robclark/src/freedreno/envytools/rnndb/adreno/a3xx.xml ( 64771 bytes, from 2015-03-15 21:55:57) - /home/robclark/src/freedreno/envytools/rnndb/adreno/a4xx.xml ( 51942 bytes, from 2015-02-24 17:14:02) Copyright (C) 2013-2015 by the following authors: diff --git a/src/gallium/drivers/freedreno/adreno_common.xml.h b/src/gallium/drivers/freedreno/adreno_common.xml.h index 868decd..163ac54 100644 --- a/src/gallium/drivers/freedreno/adreno_common.xml.h +++ b/src/gallium/drivers/freedreno/adreno_common.xml.h @@ -13,7 +13,7 @@ The rules-ng-ng source files this header was generated from are: - /home/robclark/src/freedreno/envytools/rnndb/adreno/a2xx.xml ( 32901 bytes, from 2014-06-02 15:21:30) - /home/robclark/src/freedreno/envytools/rnndb/adreno/adreno_common.xml ( 10551 bytes, from 2014-11-13 22:44:30) - /home/robclark/src/freedreno/envytools/rnndb/adreno/adreno_pm4.xml ( 15085 bytes, from 2014-12-20 21:49:41) -- /home/robclark/src/freedreno/envytools/rnndb/adreno/a3xx.xml ( 64848 bytes, from 2015-02-20 18:21:24) +- /home/robclark/src/freedreno/envytools/rnndb/adreno/a3xx.xml ( 64771 bytes, from 2015-03-15 21:55:57) - /home/robclark/src/freedreno/envytools/rnndb/adreno/a4xx.xml ( 51942 bytes, from 2015-02-24 17:14:02) Copyright (C) 2013-2014 by the following authors: diff --git a/src/gallium/drivers/freedreno/adreno_pm4.xml.h b/src/gallium/drivers/freedreno/adreno_pm4.xml.h index 19f8eb5..05afc66 100644 --- a/src/gallium/drivers/freedreno/adreno_pm4.xml.h +++ b/src/gallium/drivers/freedreno/adreno_pm4.xml.h @@ -13,7 +13,7 @@ The rules-ng-ng source files this header was generated from are: - /home/robclark/src/freedreno/envytools/rnndb/adreno/a2xx.xml ( 32901 bytes, from 2014-06-02 15:21:30) - /home/robclark/src/freedreno/envytools/rnndb/adreno/adreno_common.xml ( 10551 bytes, from 2014-11-13 22:44:30) - /home/robclark/src/freedreno/envytools/rnndb/adreno/adreno_pm4.xml ( 15085 bytes, from 2014-12-20 21:49:41) -- /home/robclark/src/freedreno/envytools/rnndb/adreno/a3xx.xml ( 64848 bytes, from 2015-02-20 18:21:24) +- /home/robclark/src/freedreno/envytools/rnndb/adreno/a3xx.xml ( 64771 bytes, from 2015-03-15 21:55:57) - /home/robclark/src/freedreno/envytools/rnndb/adreno/a4xx.xml ( 51942 bytes, from 2015-02-24 17:14:02) Copyright (C) 2013-2014 by the following authors: From evelikov at kemper.freedesktop.org Thu Mar 26 01:44:45 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Wed, 25 Mar 2015 18:44:45 -0700 (PDT) Subject: Mesa (10.5): glsl: Generate link error for non-matching gl_FragCoord redeclarations Message-ID: <20150326014445.9BF217644F@kemper.freedesktop.org> Module: Mesa Branch: 10.5 Commit: d83d2ea9a6562314388c0a1941137001960b6453 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=d83d2ea9a6562314388c0a1941137001960b6453 Author: Anuj Phogat Date: Thu Mar 5 11:07:52 2015 -0800 glsl: Generate link error for non-matching gl_FragCoord redeclarations in different fragment shaders. This also applies to a case when gl_FragCoord is redeclared with no layout qualifiers in one fragment shader and not declared but used in other fragment shader. Signed-off-by: Anuj Phogat Khronos Bug#12957 Cc: "10.5" Reviewed-by: Chris Forbes (cherry picked from commit d8208312a3a200b4e6d71ce533d835b2d705234a) --- src/glsl/linker.cpp | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp index 3f5eac1..01526de 100644 --- a/src/glsl/linker.cpp +++ b/src/glsl/linker.cpp @@ -1364,24 +1364,13 @@ link_fs_input_layout_qualifiers(struct gl_shader_program *prog, * "If gl_FragCoord is redeclared in any fragment shader in a program, * it must be redeclared in all the fragment shaders in that program * that have a static use gl_FragCoord." - * - * Exclude the case when one of the 'linked_shader' or 'shader' redeclares - * gl_FragCoord with no layout qualifiers but the other one doesn't - * redeclare it. If we strictly follow GLSL 1.50 spec's language, it - * should be a link error. But, generating link error for this case will - * be a wrong behaviour which spec didn't intend to do and it could also - * break some applications. */ if ((linked_shader->redeclares_gl_fragcoord && !shader->redeclares_gl_fragcoord - && shader->uses_gl_fragcoord - && (linked_shader->origin_upper_left - || linked_shader->pixel_center_integer)) + && shader->uses_gl_fragcoord) || (shader->redeclares_gl_fragcoord && !linked_shader->redeclares_gl_fragcoord - && linked_shader->uses_gl_fragcoord - && (shader->origin_upper_left - || shader->pixel_center_integer))) { + && linked_shader->uses_gl_fragcoord)) { linker_error(prog, "fragment shader defined with conflicting " "layout qualifiers for gl_FragCoord\n"); } From evelikov at kemper.freedesktop.org Thu Mar 26 01:44:45 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Wed, 25 Mar 2015 18:44:45 -0700 (PDT) Subject: Mesa (10.5): glsl: fix names in lower_constant_arrays_to_uniforms Message-ID: <20150326014445.874F87640F@kemper.freedesktop.org> Module: Mesa Branch: 10.5 Commit: c2760f0a1603b12b64237252d12b611b1d7883f3 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=c2760f0a1603b12b64237252d12b611b1d7883f3 Author: Tapani P?lli Date: Mon Mar 23 09:12:35 2015 +0200 glsl: fix names in lower_constant_arrays_to_uniforms Patch changes lowering pass to use unique name for each uniform so that arrays from different stages cannot end up having same name. v2: instead of global counter, use pointer to achieve unique name (Kenneth Graunke) Signed-off-by: Tapani P?lli Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=89590 Reviewed-by: Chris Forbes Cc: 10.5 10.4 (cherry picked from commit 3cf99701ba6c9e56c9126fdbb74107a31ffcbcfb) --- src/glsl/lower_const_arrays_to_uniforms.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/glsl/lower_const_arrays_to_uniforms.cpp b/src/glsl/lower_const_arrays_to_uniforms.cpp index 2243f47..44967dc 100644 --- a/src/glsl/lower_const_arrays_to_uniforms.cpp +++ b/src/glsl/lower_const_arrays_to_uniforms.cpp @@ -49,7 +49,6 @@ public: { instructions = insts; progress = false; - index = 0; } bool run() @@ -63,7 +62,6 @@ public: private: exec_list *instructions; bool progress; - unsigned index; }; void @@ -82,7 +80,7 @@ lower_const_array_visitor::handle_rvalue(ir_rvalue **rvalue) void *mem_ctx = ralloc_parent(con); - char *uniform_name = ralloc_asprintf(mem_ctx, "constarray__%d", index++); + char *uniform_name = ralloc_asprintf(mem_ctx, "constarray__%p", dra); ir_variable *uni = new(mem_ctx) ir_variable(con->type, uniform_name, ir_var_uniform); From evelikov at kemper.freedesktop.org Thu Mar 26 01:44:45 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Wed, 25 Mar 2015 18:44:45 -0700 (PDT) Subject: Mesa (10.5): glx: Handle out-of-sequence swap completion events correctly. (v2) Message-ID: <20150326014445.716557640B@kemper.freedesktop.org> Module: Mesa Branch: 10.5 Commit: 8ebda1f1448c20adf2ff1ffbe31fd8aa52a27718 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=8ebda1f1448c20adf2ff1ffbe31fd8aa52a27718 Author: Mario Kleiner Date: Thu Mar 12 20:34:06 2015 +0100 glx: Handle out-of-sequence swap completion events correctly. (v2) The code for emitting INTEL_swap_events swap completion events needs to translate from 32-Bit sbc on the wire to 64-Bit sbc for the events and handle wraparound accordingly. It assumed that events would be sent by the server in the order their corresponding swap requests were emitted from the client, iow. sbc count should be always increasing. This was correct for DRI2. This is not always the case under the DRI3/Present backend, where the Present extension can execute presents and send out completion events in a different order than the submission order of the present requests, due to client code specifying targetMSC target vblank counts which are not strictly monotonically increasing. This confused the wraparound handling. This patch fixes the problem by handling 32-Bit wraparound in both directions. As long as successive swap completion events real 64-Bit sbc's don't differ by more than 2^30, this should be able to do the right thing. How this is supposed to work: awire->sbc contains the low 32-Bits of the true 64-Bit sbc of the current swap event, transmitted over the wire. glxDraw->lastEventSbc contains the low 32-Bits of the 64-Bit sbc of the most recently processed swap event. glxDraw->eventSbcWrap is a 64-Bit offset which tracks the upper 32-Bits of the current sbc. The final 64-Bit output sbc aevent->sbc is computed from the sum of awire->sbc and glxDraw->eventSbcWrap. Under DRI3/Present, swap completion events can be received slightly out of order due to non-monotic targetMsc specified by client code, e.g., present request submission: Submission sbc: 1 2 3 targetMsc: 10 11 9 Reception of completion events: Completion sbc: 3 1 2 The completion sequence 3, 1, 2 would confuse the old wraparound handling made for DRI2 as 1 < 3 --> Assumes a 32-Bit wraparound has happened when it hasn't. The client can queue multiple present requests, in the case of Mesa up to n requests for n-buffered rendering, e.g., n = 2-4 in the current Mesa GLX DRI3/Present implementation. In the case of direct Pixmap presents via xcb_present_pixmap() the number n is limited by the amount of memory available. We reasonably assume that the number of outstanding requests n is much less than 2 billion due to memory contraints and common sense. Therefore while the order of received sbc's can be a bit scrambled, successive 64-Bit sbc's won't deviate by much, a given sbc may be a few counts lower or higher than the previous received sbc. Therefore any large difference between the incoming awire->sbc and the last recorded glxDraw->lastEventSbc will be due to 32-Bit wraparound and we need to adapt glxDraw->eventSbcWrap accordingly to adjust the upper 32-Bits of the sbc. Two cases, correponding to the two if-statements in the patch: a) Previous sbc event was below the last 2^32 boundary, in the previous glxDraw->eventSbcWrap epoch, the new sbc event is in the next 2^32 epoch, therefore the low 32-Bit awire->sbc wrapped around to zero, or close to zero --> awire->sbc is apparently much lower than the glxDraw->lastEventSbc recorded for the previous epoch --> We need to increment glxDraw->eventSbcWrap by 2^32 to adjust the current epoch to be one higher than the previous one. --> Case a) also handles the old DRI2 behaviour. b) Previous sbc event was above closest 2^32 boundary, but now a late event from the previous 2^32 epoch arrives, with a true sbc that belongs to the previous 2^32 segment, so the awire->sbc of this late event has a high count close to 2^32, whereas glxDraw->lastEventSbc is closer to zero --> awire->sbc is much greater than glXDraw->lastEventSbc. --> We need to decrement glxDraw->eventSbcWrap by 2^32 to adjust the current epoch back to the previous lower epoch of this late completion event. We assume such a wraparound to a higher (a) epoch or lower (b) epoch has happened if awire->sbc and glxDraw->lastEventSbc differ by more than 2^30 counts, as such a difference can only happen on wraparound, or if somehow 2^30 present requests would be pending for a given drawable inside the server, which is rather unlikely. v2: Explain the reason for this patch and the new wraparound handling much more extensive in commit message, no code change wrt. initial version. Cc: "10.3 10.4 10.5" Signed-off-by: Mario Kleiner Reviewed-by: Michel D?nzer (cherry picked from commit cc5ddd584d17abd422ae4d8e83805969485740d9) --- src/glx/glxext.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/glx/glxext.c b/src/glx/glxext.c index 68c359e..fdc24d4 100644 --- a/src/glx/glxext.c +++ b/src/glx/glxext.c @@ -143,8 +143,13 @@ __glXWireToEvent(Display *dpy, XEvent *event, xEvent *wire) aevent->ust = ((CARD64)awire->ust_hi << 32) | awire->ust_lo; aevent->msc = ((CARD64)awire->msc_hi << 32) | awire->msc_lo; - if (awire->sbc < glxDraw->lastEventSbc) - glxDraw->eventSbcWrap += 0x100000000; + /* Handle 32-Bit wire sbc wraparound in both directions to cope with out + * of sequence 64-Bit sbc's + */ + if ((int64_t) awire->sbc < ((int64_t) glxDraw->lastEventSbc - 0x40000000)) + glxDraw->eventSbcWrap += 0x100000000; + if ((int64_t) awire->sbc > ((int64_t) glxDraw->lastEventSbc + 0x40000000)) + glxDraw->eventSbcWrap -= 0x100000000; glxDraw->lastEventSbc = awire->sbc; aevent->sbc = awire->sbc + glxDraw->eventSbcWrap; return True; From evelikov at kemper.freedesktop.org Thu Mar 26 01:44:45 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Wed, 25 Mar 2015 18:44:45 -0700 (PDT) Subject: Mesa (10.5): clover: Return 0 as storage size for local kernel args that are not set v2 Message-ID: <20150326014445.8DCC876411@kemper.freedesktop.org> Module: Mesa Branch: 10.5 Commit: 3147f0bd25c45c9bd2a2b1fec622eb1821e11df8 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=3147f0bd25c45c9bd2a2b1fec622eb1821e11df8 Author: Tom Stellard Date: Fri Mar 20 22:19:43 2015 +0000 clover: Return 0 as storage size for local kernel args that are not set v2 The storage size for local kernel args can be queried before the arguments are set by using the CL_KERNEL_LOCAL_MEM_SIZE param of clGetKernelWorkGroupInfo(). The spec says that if local kernel arguments have not been specified, then we should assume their size is 0. v2: - Implement using c++11 member initialization. Reviewed-by: Jan Vesely Reviewed-by: Francisco Jerez Cc: 10.5 10.4 (cherry picked from commit dfb1ae9d914b7723ef50fdd2efe811feebc045ad) --- src/gallium/state_trackers/clover/core/kernel.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gallium/state_trackers/clover/core/kernel.hpp b/src/gallium/state_trackers/clover/core/kernel.hpp index bf5998d..d6432a4 100644 --- a/src/gallium/state_trackers/clover/core/kernel.hpp +++ b/src/gallium/state_trackers/clover/core/kernel.hpp @@ -175,7 +175,7 @@ namespace clover { virtual void unbind(exec_context &ctx); private: - size_t _storage; + size_t _storage = 0; }; class constant_argument : public argument { From airlied at kemper.freedesktop.org Thu Mar 26 02:04:33 2015 From: airlied at kemper.freedesktop.org (Dave Airlie) Date: Wed, 25 Mar 2015 19:04:33 -0700 (PDT) Subject: Mesa (master): st_glsl_to_tgsi: only do mov copy propagation on temps (v2) Message-ID: <20150326020433.AA81B76338@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 91e3533481d6921c4b46109742d6f67b7f897f86 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=91e3533481d6921c4b46109742d6f67b7f897f86 Author: Dave Airlie Date: Thu Mar 26 09:17:39 2015 +1000 st_glsl_to_tgsi: only do mov copy propagation on temps (v2) Don't propagate ARRAYs This should fix: https://bugs.freedesktop.org/show_bug.cgi?id=89759 v2: just specify arrays so we get input propagation Signed-off-by: Dave Airlie Cc: mesa-stable at lists.freedesktop.org Reviewed-by: Ilia Mirkin --- src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp index efee4b2..b619326 100644 --- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp +++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp @@ -3937,6 +3937,7 @@ glsl_to_tgsi_visitor::copy_propagate(void) inst->dst[0].index == inst->src[0].index) && !inst->dst[0].reladdr && !inst->saturate && + inst->src[0].file != PROGRAM_ARRAY && !inst->src[0].reladdr && !inst->src[0].reladdr2 && !inst->src[0].negate) { From imirkin at kemper.freedesktop.org Fri Mar 27 01:12:04 2015 From: imirkin at kemper.freedesktop.org (Ilia Mirkin) Date: Thu, 26 Mar 2015 18:12:04 -0700 (PDT) Subject: Mesa (master): st/mesa: update arrays when the current attrib has been updated Message-ID: <20150327011204.333FC76331@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 9d1b5febb62d74c9fc564635d4e0fa5207928c46 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=9d1b5febb62d74c9fc564635d4e0fa5207928c46 Author: Ilia Mirkin Date: Thu Mar 26 15:14:22 2015 -0400 st/mesa: update arrays when the current attrib has been updated Fixes the recently-sent gl-2.0-vertex-const-attr piglit test. Makes sure to revalidate arrays when only the current attribute has been updated via glVertexAttrib*. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=89754 Signed-off-by: Ilia Mirkin Reviewed-by: Marek Ol??k Cc: "10.4 10.5" --- src/mesa/state_tracker/st_atom_array.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesa/state_tracker/st_atom_array.c b/src/mesa/state_tracker/st_atom_array.c index 9b52f97..d4fb8b8 100644 --- a/src/mesa/state_tracker/st_atom_array.c +++ b/src/mesa/state_tracker/st_atom_array.c @@ -598,7 +598,7 @@ static void update_array(struct st_context *st) const struct st_tracked_state st_update_array = { "st_update_array", /* name */ { /* dirty */ - 0, /* mesa */ + _NEW_CURRENT_ATTRIB, /* mesa */ ST_NEW_VERTEX_ARRAYS | ST_NEW_VERTEX_PROGRAM, /* st */ }, update_array /* update */ From imirkin at kemper.freedesktop.org Fri Mar 27 01:12:04 2015 From: imirkin at kemper.freedesktop.org (Ilia Mirkin) Date: Thu, 26 Mar 2015 18:12:04 -0700 (PDT) Subject: Mesa (master): st/mesa: initialize have_fma in constructor Message-ID: <20150327011204.544967635C@kemper.freedesktop.org> Module: Mesa Branch: master Commit: f95a6b2ff4237181fd7e9622e19e9aa0719a1f21 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=f95a6b2ff4237181fd7e9622e19e9aa0719a1f21 Author: Ilia Mirkin Date: Thu Mar 26 19:33:01 2015 -0400 st/mesa: initialize have_fma in constructor Spotted by Coverity. Signed-off-by: Ilia Mirkin Reviewed-by: Brian Paul --- src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp index b619326..e97ab83 100644 --- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp +++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp @@ -3465,6 +3465,7 @@ glsl_to_tgsi_visitor::glsl_to_tgsi_visitor() shader = NULL; options = NULL; have_sqrt = false; + have_fma = false; } glsl_to_tgsi_visitor::~glsl_to_tgsi_visitor() From imirkin at kemper.freedesktop.org Fri Mar 27 01:12:04 2015 From: imirkin at kemper.freedesktop.org (Ilia Mirkin) Date: Thu, 26 Mar 2015 18:12:04 -0700 (PDT) Subject: Mesa (master): tgsi: fix out-of-bounds access for cube arrays Message-ID: <20150327011204.5ECD676397@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 626434893a048f3ba89a751998fcb3789a3dbb96 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=626434893a048f3ba89a751998fcb3789a3dbb96 Author: Ilia Mirkin Date: Thu Mar 26 19:06:37 2015 -0400 tgsi: fix out-of-bounds access for cube arrays The CUBE_ARRAY case uses r[4]. Make sure that the stack variable is there. Noticed by Coverity. Signed-off-by: Ilia Mirkin Reviewed-by: Roland Scheidegger --- src/gallium/auxiliary/tgsi/tgsi_exec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gallium/auxiliary/tgsi/tgsi_exec.c b/src/gallium/auxiliary/tgsi/tgsi_exec.c index 8d08059..d9e4050 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_exec.c +++ b/src/gallium/auxiliary/tgsi/tgsi_exec.c @@ -2344,7 +2344,7 @@ exec_sample(struct tgsi_exec_machine *mach, { const uint resource_unit = inst->Src[1].Register.Index; const uint sampler_unit = inst->Src[2].Register.Index; - union tgsi_exec_channel r[4], c1; + union tgsi_exec_channel r[5], c1; const union tgsi_exec_channel *lod = &ZeroVec; enum tgsi_sampler_control control = tgsi_sampler_lod_none; uint chan; From imirkin at kemper.freedesktop.org Fri Mar 27 01:12:04 2015 From: imirkin at kemper.freedesktop.org (Ilia Mirkin) Date: Thu, 26 Mar 2015 18:12:04 -0700 (PDT) Subject: Mesa (master): gallium/hud: avoid overflowing hud graph name size Message-ID: <20150327011204.3D7857635A@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 2e34faaf06f50741164209cc5743ab4d8579c94c URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=2e34faaf06f50741164209cc5743ab4d8579c94c Author: Ilia Mirkin Date: Thu Mar 26 19:37:50 2015 -0400 gallium/hud: avoid overflowing hud graph name size Spotted by Coverity. Signed-off-by: Ilia Mirkin Reviewed-by: Marek Ol??k --- src/gallium/auxiliary/hud/hud_driver_query.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gallium/auxiliary/hud/hud_driver_query.c b/src/gallium/auxiliary/hud/hud_driver_query.c index b48708c..53771fc 100644 --- a/src/gallium/auxiliary/hud/hud_driver_query.c +++ b/src/gallium/auxiliary/hud/hud_driver_query.c @@ -157,7 +157,8 @@ hud_pipe_query_install(struct hud_pane *pane, struct pipe_context *pipe, if (!gr) return; - strcpy(gr->name, name); + strncpy(gr->name, name, sizeof(gr->name)); + gr->name[sizeof(gr->name) - 1] = '\0'; gr->query_data = CALLOC_STRUCT(query_info); if (!gr->query_data) { FREE(gr); From imirkin at kemper.freedesktop.org Fri Mar 27 01:12:04 2015 From: imirkin at kemper.freedesktop.org (Ilia Mirkin) Date: Thu, 26 Mar 2015 18:12:04 -0700 (PDT) Subject: Mesa (master): gallium/util: remove u_linkage Message-ID: <20150327011204.487EB7635B@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 1b87d73a9f93fd0ce2c943964de9eae44affb991 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=1b87d73a9f93fd0ce2c943964de9eae44affb991 Author: Ilia Mirkin Date: Thu Mar 26 19:26:38 2015 -0400 gallium/util: remove u_linkage Does not appear to be used in tree. Coverity spotted some errors in the bitmask stuff, but the whole thing appears to be unused. Signed-off-by: Ilia Mirkin Reviewed-by: Brian Paul --- src/gallium/auxiliary/Makefile.sources | 2 - src/gallium/auxiliary/util/u_linkage.c | 149 ---------------------- src/gallium/auxiliary/util/u_linkage.h | 67 ---------- src/gallium/drivers/nouveau/nv30/nvfx_fragprog.c | 1 - src/gallium/drivers/nouveau/nv30/nvfx_vertprog.c | 1 - 5 files changed, 220 deletions(-) diff --git a/src/gallium/auxiliary/Makefile.sources b/src/gallium/auxiliary/Makefile.sources index b7174d6..09496fa 100644 --- a/src/gallium/auxiliary/Makefile.sources +++ b/src/gallium/auxiliary/Makefile.sources @@ -251,8 +251,6 @@ C_SOURCES := \ util/u_keymap.h \ util/u_linear.c \ util/u_linear.h \ - util/u_linkage.c \ - util/u_linkage.h \ util/u_math.c \ util/u_math.h \ util/u_memory.h \ diff --git a/src/gallium/auxiliary/util/u_linkage.c b/src/gallium/auxiliary/util/u_linkage.c deleted file mode 100644 index 245d941..0000000 --- a/src/gallium/auxiliary/util/u_linkage.c +++ /dev/null @@ -1,149 +0,0 @@ -/************************************************************************** - * - * Copyright 2010 Luca Barbieri - * - * 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 COPYRIGHT OWNER(S) 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. - * - **************************************************************************/ - -#include "util/u_debug.h" -#include "pipe/p_shader_tokens.h" -#include "tgsi/tgsi_parse.h" -#include "tgsi/tgsi_scan.h" -#include "util/u_linkage.h" - -/* we must only record the registers that are actually used, not just declared */ -static INLINE boolean -util_semantic_set_test_and_set(struct util_semantic_set *set, unsigned value) -{ - unsigned mask = 1 << (value % (sizeof(long) * 8)); - unsigned long *p = &set->masks[value / (sizeof(long) * 8)]; - unsigned long v = *p & mask; - *p |= mask; - return !!v; -} - -unsigned -util_semantic_set_from_program_file(struct util_semantic_set *set, const struct tgsi_token *tokens, enum tgsi_file_type file) -{ - struct tgsi_shader_info info; - struct tgsi_parse_context parse; - unsigned count = 0; - ubyte *semantic_name; - ubyte *semantic_index; - - tgsi_scan_shader(tokens, &info); - - if(file == TGSI_FILE_INPUT) - { - semantic_name = info.input_semantic_name; - semantic_index = info.input_semantic_index; - } - else if(file == TGSI_FILE_OUTPUT) - { - semantic_name = info.output_semantic_name; - semantic_index = info.output_semantic_index; - } - else - { - assert(0); - semantic_name = NULL; - semantic_index = NULL; - } - - tgsi_parse_init(&parse, tokens); - - memset(set->masks, 0, sizeof(set->masks)); - while(!tgsi_parse_end_of_tokens(&parse)) - { - tgsi_parse_token(&parse); - - if(parse.FullToken.Token.Type == TGSI_TOKEN_TYPE_INSTRUCTION) - { - const struct tgsi_full_instruction *finst = &parse.FullToken.FullInstruction; - unsigned i; - for(i = 0; i < finst->Instruction.NumDstRegs; ++i) - { - if(finst->Dst[i].Register.File == file) - { - unsigned idx = finst->Dst[i].Register.Index; - if(semantic_name[idx] == TGSI_SEMANTIC_GENERIC) - { - if(!util_semantic_set_test_and_set(set, semantic_index[idx])) - ++count; - } - } - } - - for(i = 0; i < finst->Instruction.NumSrcRegs; ++i) - { - if(finst->Src[i].Register.File == file) - { - unsigned idx = finst->Src[i].Register.Index; - if(semantic_name[idx] == TGSI_SEMANTIC_GENERIC) - { - if(!util_semantic_set_test_and_set(set, semantic_index[idx])) - ++count; - } - } - } - } - } - tgsi_parse_free(&parse); - - return count; -} - -#define UTIL_SEMANTIC_SET_FOR_EACH(i, set) for(i = 0; i < 256; ++i) if(set->masks[i / (sizeof(long) * 8)] & (1 << (i % (sizeof(long) * 8)))) - -void -util_semantic_layout_from_set(unsigned char *layout, const struct util_semantic_set *set, unsigned efficient_slots, unsigned num_slots) -{ - int first = -1; - int last = -1; - unsigned i; - - memset(layout, 0xff, num_slots); - - UTIL_SEMANTIC_SET_FOR_EACH(i, set) - { - if(first < 0) - first = i; - last = i; - } - - if (last < (int) efficient_slots) - { - UTIL_SEMANTIC_SET_FOR_EACH(i, set) - layout[i] = i; - } - else if ((last - first) < (int) efficient_slots) - { - UTIL_SEMANTIC_SET_FOR_EACH(i, set) - layout[i - first] = i; - } - else - { - unsigned idx = 0; - UTIL_SEMANTIC_SET_FOR_EACH(i, set) - layout[idx++] = i; - } -} diff --git a/src/gallium/auxiliary/util/u_linkage.h b/src/gallium/auxiliary/util/u_linkage.h deleted file mode 100644 index 7b23123..0000000 --- a/src/gallium/auxiliary/util/u_linkage.h +++ /dev/null @@ -1,67 +0,0 @@ -/************************************************************************** - * - * Copyright 2010 Luca Barbieri - * - * 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 COPYRIGHT OWNER(S) 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. - * - **************************************************************************/ - -#ifndef U_LINKAGE_H_ -#define U_LINKAGE_H_ - -#include "pipe/p_compiler.h" -#include "pipe/p_shader_tokens.h" - -struct util_semantic_set -{ - unsigned long masks[256 / 8 / sizeof(unsigned long)]; -}; - -static INLINE boolean -util_semantic_set_contains(struct util_semantic_set *set, unsigned char value) -{ - return !!(set->masks[value / (sizeof(long) * 8)] & (1 << (value / (sizeof(long) * 8)))); -} - -unsigned util_semantic_set_from_program_file(struct util_semantic_set *set, const struct tgsi_token *tokens, enum tgsi_file_type file); - -/* efficient_slots is the number of slots such that hardware performance is - * the same for using that amount, with holes, or less slots but with less - * holes. - * - * num_slots is the size of the layout array and hardware limit instead. - * - * efficient_slots == 0 or efficient_slots == num_slots are typical settings. - */ -void util_semantic_layout_from_set(unsigned char *layout, const struct util_semantic_set *set, unsigned efficient_slots, unsigned num_slots); - -static INLINE void -util_semantic_table_from_layout(unsigned char *table, size_t table_size, unsigned char *layout, - unsigned char first_slot_value, unsigned char num_slots) -{ - unsigned char i; - memset(table, 0xff, table_size); - - for(i = 0; i < num_slots; ++i) - table[layout[i]] = first_slot_value + i; -} - -#endif /* U_LINKAGE_H_ */ diff --git a/src/gallium/drivers/nouveau/nv30/nvfx_fragprog.c b/src/gallium/drivers/nouveau/nv30/nvfx_fragprog.c index 6600997..bbdca81 100644 --- a/src/gallium/drivers/nouveau/nv30/nvfx_fragprog.c +++ b/src/gallium/drivers/nouveau/nv30/nvfx_fragprog.c @@ -3,7 +3,6 @@ #include "pipe/p_defines.h" #include "pipe/p_state.h" #include "util/u_dynarray.h" -#include "util/u_linkage.h" #include "util/u_inlines.h" #include "util/u_debug.h" diff --git a/src/gallium/drivers/nouveau/nv30/nvfx_vertprog.c b/src/gallium/drivers/nouveau/nv30/nvfx_vertprog.c index 51e1fb6..29d506b 100644 --- a/src/gallium/drivers/nouveau/nv30/nvfx_vertprog.c +++ b/src/gallium/drivers/nouveau/nv30/nvfx_vertprog.c @@ -2,7 +2,6 @@ #include "pipe/p_defines.h" #include "pipe/p_state.h" #include "util/u_dynarray.h" -#include "util/u_linkage.h" #include "util/u_debug.h" #include "pipe/p_shader_tokens.h" From deathsimple at kemper.freedesktop.org Fri Mar 27 10:34:15 2015 From: deathsimple at kemper.freedesktop.org (Christian König) Date: Fri, 27 Mar 2015 03:34:15 -0700 (PDT) Subject: Mesa (master): gallium/vl: partially revert "Use util_cpu_to_le{16, 32} in many more places." Message-ID: <20150327103415.4221D76331@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 787aa26cb7b48504f7770cacfc321324ecafa29a URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=787aa26cb7b48504f7770cacfc321324ecafa29a Author: Christian K?nig Date: Thu Mar 26 14:49:18 2015 +0100 gallium/vl: partially revert "Use util_cpu_to_le{16,32} in many more places." The data in memory is in big endian format and needs to be converted into CPU byte order. So the patch actually reversed what needs to be done. Signed-off-by: Christian K?nig Reviewed-by: Matt Turner --- src/gallium/auxiliary/vl/vl_vlc.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/gallium/auxiliary/vl/vl_vlc.h b/src/gallium/auxiliary/vl/vl_vlc.h index cad9989..2f90595 100644 --- a/src/gallium/auxiliary/vl/vl_vlc.h +++ b/src/gallium/auxiliary/vl/vl_vlc.h @@ -149,7 +149,11 @@ vl_vlc_fillbits(struct vl_vlc *vlc) } else if (bytes_left >= 4) { /* enough bytes in buffer, read in a whole dword */ - uint64_t value = util_cpu_to_le32(*(const uint32_t*)vlc->data); + uint64_t value = *(const uint32_t*)vlc->data; + +#ifndef PIPE_ARCH_BIG_ENDIAN + value = util_bswap32(value); +#endif vlc->buffer |= value << vlc->invalid_bits; vlc->data += 4; From sroland at kemper.freedesktop.org Fri Mar 27 18:27:50 2015 From: sroland at kemper.freedesktop.org (Roland Scheidegger) Date: Fri, 27 Mar 2015 11:27:50 -0700 (PDT) Subject: Mesa (master): gallivm: pass jit_context pointer through to sampling Message-ID: <20150327182750.8B10676333@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 8dad9455ff748c543635b24908566c3b94cb93a9 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=8dad9455ff748c543635b24908566c3b94cb93a9 Author: Roland Scheidegger Date: Wed Mar 25 03:10:10 2015 +0100 gallivm: pass jit_context pointer through to sampling The callbacks used for getting the dynamic texture/sampler state were using the jit_context from the generated jit function. This works just fine, however that way it's impossible to generate separate functions for texture sampling, as will be done in the next commit. Hence, pass this pointer through all interfaces so it can be passed to a separate function (technically, it would probably be possible to extract this pointer from the current function instead, but this feels hacky and would probably require some more hacks if we'd use real functions instead of inlining all shader functions at some point). There should be no difference in the generated code for now. Reviewed-by: Jose Fonseca --- src/gallium/auxiliary/draw/draw_llvm.c | 9 +-- src/gallium/auxiliary/draw/draw_llvm.h | 3 +- src/gallium/auxiliary/draw/draw_llvm_sample.c | 28 +++---- src/gallium/auxiliary/gallivm/lp_bld_sample.c | 39 +++++----- src/gallium/auxiliary/gallivm/lp_bld_sample.h | 83 +++++++++++++-------- src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c | 74 +++++++++++------- src/gallium/auxiliary/gallivm/lp_bld_tgsi.h | 4 + src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c | 6 ++ src/gallium/drivers/llvmpipe/lp_state_fs.c | 5 +- src/gallium/drivers/llvmpipe/lp_tex_sample.c | 28 +++---- src/gallium/drivers/llvmpipe/lp_tex_sample.h | 4 +- 11 files changed, 171 insertions(+), 112 deletions(-) diff --git a/src/gallium/auxiliary/draw/draw_llvm.c b/src/gallium/auxiliary/draw/draw_llvm.c index 6e1fb40..1e6e699 100644 --- a/src/gallium/auxiliary/draw/draw_llvm.c +++ b/src/gallium/auxiliary/draw/draw_llvm.c @@ -620,6 +620,7 @@ generate_vs(struct draw_llvm_variant *variant, system_values, inputs, outputs, + context_ptr, draw_sampler, &llvm->draw->vs.vertex_shader->info, NULL); @@ -1630,9 +1631,7 @@ draw_llvm_generate(struct draw_llvm *llvm, struct draw_llvm_variant *variant, LLVMBuildStore(builder, lp_build_zero(gallivm, lp_int_type(vs_type)), clipmask_bool_ptr); /* code generated texture sampling */ - sampler = draw_llvm_sampler_soa_create( - draw_llvm_variant_key_samplers(key), - context_ptr); + sampler = draw_llvm_sampler_soa_create(draw_llvm_variant_key_samplers(key)); if (elts) { start = zero; @@ -2163,8 +2162,7 @@ draw_gs_llvm_generate(struct draw_llvm *llvm, draw_gs_jit_context_num_constants(variant->gallivm, context_ptr); /* code generated texture sampling */ - sampler = draw_llvm_sampler_soa_create(variant->key.samplers, - context_ptr); + sampler = draw_llvm_sampler_soa_create(variant->key.samplers); mask_val = generate_mask_value(variant, gs_type); lp_build_mask_begin(&mask, gallivm, gs_type, mask_val); @@ -2187,6 +2185,7 @@ draw_gs_llvm_generate(struct draw_llvm *llvm, &system_values, NULL, outputs, + context_ptr, sampler, &llvm->draw->gs.geometry_shader->info, (const struct lp_build_tgsi_gs_iface *)&gs_iface); diff --git a/src/gallium/auxiliary/draw/draw_llvm.h b/src/gallium/auxiliary/draw/draw_llvm.h index af1960e..9565fc6 100644 --- a/src/gallium/auxiliary/draw/draw_llvm.h +++ b/src/gallium/auxiliary/draw/draw_llvm.h @@ -526,8 +526,7 @@ void draw_gs_llvm_dump_variant_key(struct draw_gs_llvm_variant_key *key); struct lp_build_sampler_soa * -draw_llvm_sampler_soa_create(const struct draw_sampler_static_state *static_state, - LLVMValueRef context_ptr); +draw_llvm_sampler_soa_create(const struct draw_sampler_static_state *static_state); void draw_llvm_set_sampler_state(struct draw_context *draw, unsigned shader_stage); diff --git a/src/gallium/auxiliary/draw/draw_llvm_sample.c b/src/gallium/auxiliary/draw/draw_llvm_sample.c index a6341fa..16d075c 100644 --- a/src/gallium/auxiliary/draw/draw_llvm_sample.c +++ b/src/gallium/auxiliary/draw/draw_llvm_sample.c @@ -59,8 +59,6 @@ struct draw_llvm_sampler_dynamic_state struct lp_sampler_dynamic_state base; const struct draw_sampler_static_state *static_state; - - LLVMValueRef context_ptr; }; @@ -86,14 +84,13 @@ struct draw_llvm_sampler_soa static LLVMValueRef draw_llvm_texture_member(const struct lp_sampler_dynamic_state *base, struct gallivm_state *gallivm, + LLVMValueRef context_ptr, unsigned texture_unit, unsigned member_index, const char *member_name, boolean emit_load) { LLVMBuilderRef builder = gallivm->builder; - struct draw_llvm_sampler_dynamic_state *state = - (struct draw_llvm_sampler_dynamic_state *)base; LLVMValueRef indices[4]; LLVMValueRef ptr; LLVMValueRef res; @@ -109,7 +106,7 @@ draw_llvm_texture_member(const struct lp_sampler_dynamic_state *base, /* context[0].textures[unit].member */ indices[3] = lp_build_const_int32(gallivm, member_index); - ptr = LLVMBuildGEP(builder, state->context_ptr, indices, Elements(indices), ""); + ptr = LLVMBuildGEP(builder, context_ptr, indices, Elements(indices), ""); if (emit_load) res = LLVMBuildLoad(builder, ptr, ""); @@ -133,14 +130,13 @@ draw_llvm_texture_member(const struct lp_sampler_dynamic_state *base, static LLVMValueRef draw_llvm_sampler_member(const struct lp_sampler_dynamic_state *base, struct gallivm_state *gallivm, + LLVMValueRef context_ptr, unsigned sampler_unit, unsigned member_index, const char *member_name, boolean emit_load) { LLVMBuilderRef builder = gallivm->builder; - struct draw_llvm_sampler_dynamic_state *state = - (struct draw_llvm_sampler_dynamic_state *)base; LLVMValueRef indices[4]; LLVMValueRef ptr; LLVMValueRef res; @@ -156,7 +152,7 @@ draw_llvm_sampler_member(const struct lp_sampler_dynamic_state *base, /* context[0].samplers[unit].member */ indices[3] = lp_build_const_int32(gallivm, member_index); - ptr = LLVMBuildGEP(builder, state->context_ptr, indices, Elements(indices), ""); + ptr = LLVMBuildGEP(builder, context_ptr, indices, Elements(indices), ""); if (emit_load) res = LLVMBuildLoad(builder, ptr, ""); @@ -182,9 +178,11 @@ draw_llvm_sampler_member(const struct lp_sampler_dynamic_state *base, static LLVMValueRef \ draw_llvm_texture_##_name( const struct lp_sampler_dynamic_state *base, \ struct gallivm_state *gallivm, \ + LLVMValueRef context_ptr, \ unsigned texture_unit) \ { \ - return draw_llvm_texture_member(base, gallivm, texture_unit, _index, #_name, _emit_load ); \ + return draw_llvm_texture_member(base, gallivm, context_ptr, \ + texture_unit, _index, #_name, _emit_load ); \ } @@ -203,9 +201,11 @@ DRAW_LLVM_TEXTURE_MEMBER(mip_offsets, DRAW_JIT_TEXTURE_MIP_OFFSETS, FALSE) static LLVMValueRef \ draw_llvm_sampler_##_name( const struct lp_sampler_dynamic_state *base, \ struct gallivm_state *gallivm, \ + LLVMValueRef context_ptr, \ unsigned sampler_unit) \ { \ - return draw_llvm_sampler_member(base, gallivm, sampler_unit, _index, #_name, _emit_load ); \ + return draw_llvm_sampler_member(base, gallivm, context_ptr, \ + sampler_unit, _index, #_name, _emit_load ); \ } @@ -233,6 +233,7 @@ draw_llvm_sampler_soa_emit_fetch_texel(const struct lp_build_sampler_soa *base, boolean is_fetch, unsigned texture_index, unsigned sampler_index, + LLVMValueRef context_ptr, const LLVMValueRef *coords, const LLVMValueRef *offsets, const struct lp_derivatives *derivs, @@ -254,6 +255,7 @@ draw_llvm_sampler_soa_emit_fetch_texel(const struct lp_build_sampler_soa *base, is_fetch, texture_index, sampler_index, + context_ptr, coords, offsets, derivs, @@ -271,6 +273,7 @@ draw_llvm_sampler_soa_emit_size_query(const struct lp_build_sampler_soa *base, struct lp_type type, unsigned texture_unit, unsigned target, + LLVMValueRef context_ptr, boolean is_sviewinfo, enum lp_sampler_lod_property lod_property, LLVMValueRef explicit_lod, /* optional */ @@ -286,6 +289,7 @@ draw_llvm_sampler_soa_emit_size_query(const struct lp_build_sampler_soa *base, type, texture_unit, target, + context_ptr, is_sviewinfo, lod_property, explicit_lod, @@ -293,8 +297,7 @@ draw_llvm_sampler_soa_emit_size_query(const struct lp_build_sampler_soa *base, } struct lp_build_sampler_soa * -draw_llvm_sampler_soa_create(const struct draw_sampler_static_state *static_state, - LLVMValueRef context_ptr) +draw_llvm_sampler_soa_create(const struct draw_sampler_static_state *static_state) { struct draw_llvm_sampler_soa *sampler; @@ -319,7 +322,6 @@ draw_llvm_sampler_soa_create(const struct draw_sampler_static_state *static_stat sampler->dynamic_state.base.lod_bias = draw_llvm_sampler_lod_bias; sampler->dynamic_state.base.border_color = draw_llvm_sampler_border_color; sampler->dynamic_state.static_state = static_state; - sampler->dynamic_state.context_ptr = context_ptr; return &sampler->base; } diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample.c b/src/gallium/auxiliary/gallivm/lp_bld_sample.c index 7d18ee5..5b22045 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_sample.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_sample.c @@ -246,8 +246,8 @@ lp_build_rho(struct lp_build_sample_context *bld, * the messy cube maps for now) when requested. */ - first_level = bld->dynamic_state->first_level(bld->dynamic_state, - bld->gallivm, texture_unit); + first_level = bld->dynamic_state->first_level(bld->dynamic_state, bld->gallivm, + bld->context_ptr, texture_unit); first_level_vec = lp_build_broadcast_scalar(int_size_bld, first_level); int_size = lp_build_minify(int_size_bld, bld->int_size, first_level_vec, TRUE); float_size = lp_build_int_to_float(float_size_bld, int_size); @@ -714,6 +714,7 @@ lp_build_lod_selector(struct lp_build_sample_context *bld, { LLVMBuilderRef builder = bld->gallivm->builder; + struct lp_sampler_dynamic_state *dynamic_state = bld->dynamic_state; struct lp_build_context *lodf_bld = &bld->lodf_bld; LLVMValueRef lod; @@ -744,8 +745,8 @@ lp_build_lod_selector(struct lp_build_sample_context *bld, * This is hit during mipmap generation. */ LLVMValueRef min_lod = - bld->dynamic_state->min_lod(bld->dynamic_state, - bld->gallivm, sampler_unit); + dynamic_state->min_lod(dynamic_state, bld->gallivm, + bld->context_ptr, sampler_unit); lod = lp_build_broadcast_scalar(lodf_bld, min_lod); } @@ -835,8 +836,8 @@ lp_build_lod_selector(struct lp_build_sample_context *bld, /* add sampler lod bias */ if (bld->static_sampler_state->lod_bias_non_zero) { LLVMValueRef sampler_lod_bias = - bld->dynamic_state->lod_bias(bld->dynamic_state, - bld->gallivm, sampler_unit); + dynamic_state->lod_bias(dynamic_state, bld->gallivm, + bld->context_ptr, sampler_unit); sampler_lod_bias = lp_build_broadcast_scalar(lodf_bld, sampler_lod_bias); lod = LLVMBuildFAdd(builder, lod, sampler_lod_bias, "sampler_lod_bias"); @@ -845,16 +846,16 @@ lp_build_lod_selector(struct lp_build_sample_context *bld, /* clamp lod */ if (bld->static_sampler_state->apply_max_lod) { LLVMValueRef max_lod = - bld->dynamic_state->max_lod(bld->dynamic_state, - bld->gallivm, sampler_unit); + dynamic_state->max_lod(dynamic_state, bld->gallivm, + bld->context_ptr, sampler_unit); max_lod = lp_build_broadcast_scalar(lodf_bld, max_lod); lod = lp_build_min(lodf_bld, lod, max_lod); } if (bld->static_sampler_state->apply_min_lod) { LLVMValueRef min_lod = - bld->dynamic_state->min_lod(bld->dynamic_state, - bld->gallivm, sampler_unit); + dynamic_state->min_lod(dynamic_state, bld->gallivm, + bld->context_ptr, sampler_unit); min_lod = lp_build_broadcast_scalar(lodf_bld, min_lod); lod = lp_build_max(lodf_bld, lod, min_lod); @@ -901,12 +902,13 @@ lp_build_nearest_mip_level(struct lp_build_sample_context *bld, LLVMValueRef *out_of_bounds) { struct lp_build_context *leveli_bld = &bld->leveli_bld; + struct lp_sampler_dynamic_state *dynamic_state = bld->dynamic_state; LLVMValueRef first_level, last_level, level; - first_level = bld->dynamic_state->first_level(bld->dynamic_state, - bld->gallivm, texture_unit); - last_level = bld->dynamic_state->last_level(bld->dynamic_state, - bld->gallivm, texture_unit); + first_level = dynamic_state->first_level(dynamic_state, bld->gallivm, + bld->context_ptr, texture_unit); + last_level = dynamic_state->last_level(dynamic_state, bld->gallivm, + bld->context_ptr, texture_unit); first_level = lp_build_broadcast_scalar(leveli_bld, first_level); last_level = lp_build_broadcast_scalar(leveli_bld, last_level); @@ -956,6 +958,7 @@ lp_build_linear_mip_levels(struct lp_build_sample_context *bld, LLVMValueRef *level1_out) { LLVMBuilderRef builder = bld->gallivm->builder; + struct lp_sampler_dynamic_state *dynamic_state = bld->dynamic_state; struct lp_build_context *leveli_bld = &bld->leveli_bld; struct lp_build_context *levelf_bld = &bld->levelf_bld; LLVMValueRef first_level, last_level; @@ -964,10 +967,10 @@ lp_build_linear_mip_levels(struct lp_build_sample_context *bld, assert(bld->num_lods == bld->num_mips); - first_level = bld->dynamic_state->first_level(bld->dynamic_state, - bld->gallivm, texture_unit); - last_level = bld->dynamic_state->last_level(bld->dynamic_state, - bld->gallivm, texture_unit); + first_level = dynamic_state->first_level(dynamic_state, bld->gallivm, + bld->context_ptr, texture_unit); + last_level = dynamic_state->last_level(dynamic_state, bld->gallivm, + bld->context_ptr, texture_unit); first_level = lp_build_broadcast_scalar(leveli_bld, first_level); last_level = lp_build_broadcast_scalar(leveli_bld, last_level); diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample.h b/src/gallium/auxiliary/gallivm/lp_bld_sample.h index be05b13..be41ca0 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_sample.h +++ b/src/gallium/auxiliary/gallivm/lp_bld_sample.h @@ -138,79 +138,96 @@ struct lp_sampler_dynamic_state /** Obtain the base texture width (or number of elements) (returns int32) */ LLVMValueRef - (*width)( const struct lp_sampler_dynamic_state *state, - struct gallivm_state *gallivm, - unsigned texture_unit); + (*width)(const struct lp_sampler_dynamic_state *state, + struct gallivm_state *gallivm, + LLVMValueRef context_ptr, + unsigned texture_unit); /** Obtain the base texture height (returns int32) */ LLVMValueRef - (*height)( const struct lp_sampler_dynamic_state *state, - struct gallivm_state *gallivm, - unsigned texture_unit); + (*height)(const struct lp_sampler_dynamic_state *state, + struct gallivm_state *gallivm, + LLVMValueRef context_ptr, + unsigned texture_unit); /** Obtain the base texture depth (or array size) (returns int32) */ LLVMValueRef - (*depth)( const struct lp_sampler_dynamic_state *state, - struct gallivm_state *gallivm, - unsigned texture_unit); + (*depth)(const struct lp_sampler_dynamic_state *state, + struct gallivm_state *gallivm, + LLVMValueRef context_ptr, + unsigned texture_unit); /** Obtain the first mipmap level (base level) (returns int32) */ LLVMValueRef - (*first_level)( const struct lp_sampler_dynamic_state *state, - struct gallivm_state *gallivm, - unsigned texture_unit); + (*first_level)(const struct lp_sampler_dynamic_state *state, + struct gallivm_state *gallivm, + LLVMValueRef context_ptr, + unsigned texture_unit); /** Obtain the number of mipmap levels minus one (returns int32) */ LLVMValueRef - (*last_level)( const struct lp_sampler_dynamic_state *state, - struct gallivm_state *gallivm, - unsigned texture_unit); + (*last_level)(const struct lp_sampler_dynamic_state *state, + struct gallivm_state *gallivm, + LLVMValueRef context_ptr, + unsigned texture_unit); /** Obtain stride in bytes between image rows/blocks (returns int32) */ LLVMValueRef - (*row_stride)( const struct lp_sampler_dynamic_state *state, - struct gallivm_state *gallivm, - unsigned texture_unit); + (*row_stride)(const struct lp_sampler_dynamic_state *state, + struct gallivm_state *gallivm, + LLVMValueRef context_ptr, + unsigned texture_unit); /** Obtain stride in bytes between image slices (returns int32) */ LLVMValueRef - (*img_stride)( const struct lp_sampler_dynamic_state *state, - struct gallivm_state *gallivm, - unsigned texture_unit); + (*img_stride)(const struct lp_sampler_dynamic_state *state, + struct gallivm_state *gallivm, + LLVMValueRef context_ptr, + unsigned texture_unit); /** Obtain pointer to base of texture */ LLVMValueRef - (*base_ptr)( const struct lp_sampler_dynamic_state *state, - struct gallivm_state *gallivm, - unsigned texture_unit); + (*base_ptr)(const struct lp_sampler_dynamic_state *state, + struct gallivm_state *gallivm, + LLVMValueRef context_ptr, + unsigned texture_unit); /** Obtain pointer to array of mipmap offsets */ LLVMValueRef - (*mip_offsets)( const struct lp_sampler_dynamic_state *state, - struct gallivm_state *gallivm, - unsigned texture_unit); + (*mip_offsets)(const struct lp_sampler_dynamic_state *state, + struct gallivm_state *gallivm, + LLVMValueRef context_ptr, + unsigned texture_unit); /* These are callbacks for sampler state */ /** Obtain texture min lod (returns float) */ LLVMValueRef (*min_lod)(const struct lp_sampler_dynamic_state *state, - struct gallivm_state *gallivm, unsigned sampler_unit); + struct gallivm_state *gallivm, + LLVMValueRef context_ptr, + unsigned sampler_unit); /** Obtain texture max lod (returns float) */ LLVMValueRef (*max_lod)(const struct lp_sampler_dynamic_state *state, - struct gallivm_state *gallivm, unsigned sampler_unit); + struct gallivm_state *gallivm, + LLVMValueRef context_ptr, + unsigned sampler_unit); /** Obtain texture lod bias (returns float) */ LLVMValueRef (*lod_bias)(const struct lp_sampler_dynamic_state *state, - struct gallivm_state *gallivm, unsigned sampler_unit); + struct gallivm_state *gallivm, + LLVMValueRef context_ptr, + unsigned sampler_unit); /** Obtain texture border color (returns ptr to float[4]) */ LLVMValueRef (*border_color)(const struct lp_sampler_dynamic_state *state, - struct gallivm_state *gallivm, unsigned sampler_unit); + struct gallivm_state *gallivm, + LLVMValueRef context_ptr, + unsigned sampler_unit); }; @@ -305,6 +322,8 @@ struct lp_build_sample_context LLVMValueRef int_size; LLVMValueRef border_color_clamped; + + LLVMValueRef context_ptr; }; @@ -520,6 +539,7 @@ lp_build_sample_soa(struct gallivm_state *gallivm, boolean is_fetch, unsigned texture_index, unsigned sampler_index, + LLVMValueRef context_ptr, const LLVMValueRef *coords, const LLVMValueRef *offsets, const struct lp_derivatives *derivs, @@ -545,6 +565,7 @@ lp_build_size_query_soa(struct gallivm_state *gallivm, struct lp_type int_type, unsigned texture_unit, unsigned target, + LLVMValueRef context_ptr, boolean is_sviewinfo, enum lp_sampler_lod_property lod_property, LLVMValueRef explicit_lod, diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c index 99309fe..a90278e 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c @@ -1678,8 +1678,8 @@ lp_build_layer_coord(struct lp_build_sample_context *bld, LLVMValueRef num_layers; struct lp_build_context *int_coord_bld = &bld->int_coord_bld; - num_layers = bld->dynamic_state->depth(bld->dynamic_state, - bld->gallivm, texture_unit); + num_layers = bld->dynamic_state->depth(bld->dynamic_state, bld->gallivm, + bld->context_ptr, texture_unit); if (out_of_bounds) { LLVMValueRef out1, out; @@ -1815,7 +1815,8 @@ lp_build_sample_common(struct lp_build_sample_context *bld, case PIPE_TEX_MIPFILTER_NONE: /* always use mip level 0 */ first_level = bld->dynamic_state->first_level(bld->dynamic_state, - bld->gallivm, texture_index); + bld->gallivm, bld->context_ptr, + texture_index); first_level = lp_build_broadcast_scalar(&bld->leveli_bld, first_level); *ilevel0 = first_level; break; @@ -1840,8 +1841,8 @@ lp_build_clamp_border_color(struct lp_build_sample_context *bld, struct gallivm_state *gallivm = bld->gallivm; LLVMBuilderRef builder = gallivm->builder; LLVMValueRef border_color_ptr = - bld->dynamic_state->border_color(bld->dynamic_state, - gallivm, sampler_unit); + bld->dynamic_state->border_color(bld->dynamic_state, gallivm, + bld->context_ptr, sampler_unit); LLVMValueRef border_color; const struct util_format_description *format_desc = bld->format_desc; struct lp_type vec4_type = bld->texel_type; @@ -2246,8 +2247,8 @@ lp_build_fetch_texel(struct lp_build_sample_context *bld, else { assert(bld->num_mips == 1); if (bld->static_texture_state->target != PIPE_BUFFER) { - ilevel = bld->dynamic_state->first_level(bld->dynamic_state, - bld->gallivm, texture_unit); + ilevel = bld->dynamic_state->first_level(bld->dynamic_state, bld->gallivm, + bld->context_ptr, texture_unit); } else { ilevel = lp_build_const_int32(bld->gallivm, 0); @@ -2372,6 +2373,7 @@ lp_build_sample_soa(struct gallivm_state *gallivm, boolean is_fetch, unsigned texture_index, unsigned sampler_index, + LLVMValueRef context_ptr, const LLVMValueRef *coords, const LLVMValueRef *offsets, const struct lp_derivatives *derivs, /* optional */ @@ -2413,6 +2415,7 @@ lp_build_sample_soa(struct gallivm_state *gallivm, /* Setup our build context */ memset(&bld, 0, sizeof bld); bld.gallivm = gallivm; + bld.context_ptr = context_ptr; bld.static_sampler_state = &derived_sampler_state; bld.static_texture_state = static_texture_state; bld.dynamic_state = dynamic_state; @@ -2578,11 +2581,16 @@ lp_build_sample_soa(struct gallivm_state *gallivm, lp_build_context_init(&bld.lodi_bld, gallivm, bld.lodi_type); /* Get the dynamic state */ - tex_width = dynamic_state->width(dynamic_state, gallivm, texture_index); - bld.row_stride_array = dynamic_state->row_stride(dynamic_state, gallivm, texture_index); - bld.img_stride_array = dynamic_state->img_stride(dynamic_state, gallivm, texture_index); - bld.base_ptr = dynamic_state->base_ptr(dynamic_state, gallivm, texture_index); - bld.mip_offsets = dynamic_state->mip_offsets(dynamic_state, gallivm, texture_index); + tex_width = dynamic_state->width(dynamic_state, gallivm, + context_ptr, texture_index); + bld.row_stride_array = dynamic_state->row_stride(dynamic_state, gallivm, + context_ptr, texture_index); + bld.img_stride_array = dynamic_state->img_stride(dynamic_state, gallivm, + context_ptr, texture_index); + bld.base_ptr = dynamic_state->base_ptr(dynamic_state, gallivm, + context_ptr, texture_index); + bld.mip_offsets = dynamic_state->mip_offsets(dynamic_state, gallivm, + context_ptr, texture_index); /* Note that mip_offsets is an array[level] of offsets to texture images */ /* width, height, depth as single int vector */ @@ -2591,17 +2599,22 @@ lp_build_sample_soa(struct gallivm_state *gallivm, } else { bld.int_size = LLVMBuildInsertElement(builder, bld.int_size_in_bld.undef, - tex_width, LLVMConstInt(i32t, 0, 0), ""); + tex_width, + LLVMConstInt(i32t, 0, 0), ""); if (dims >= 2) { LLVMValueRef tex_height = - dynamic_state->height(dynamic_state, gallivm, texture_index); + dynamic_state->height(dynamic_state, gallivm, + context_ptr, texture_index); bld.int_size = LLVMBuildInsertElement(builder, bld.int_size, - tex_height, LLVMConstInt(i32t, 1, 0), ""); + tex_height, + LLVMConstInt(i32t, 1, 0), ""); if (dims >= 3) { LLVMValueRef tex_depth = - dynamic_state->depth(dynamic_state, gallivm, texture_index); + dynamic_state->depth(dynamic_state, gallivm, context_ptr, + texture_index); bld.int_size = LLVMBuildInsertElement(builder, bld.int_size, - tex_depth, LLVMConstInt(i32t, 2, 0), ""); + tex_depth, + LLVMConstInt(i32t, 2, 0), ""); } } } @@ -2717,6 +2730,7 @@ lp_build_sample_soa(struct gallivm_state *gallivm, /* Setup our build context */ memset(&bld4, 0, sizeof bld4); bld4.gallivm = bld.gallivm; + bld4.context_ptr = bld.context_ptr; bld4.static_texture_state = bld.static_texture_state; bld4.static_sampler_state = bld.static_sampler_state; bld4.dynamic_state = bld.dynamic_state; @@ -2876,6 +2890,7 @@ lp_build_sample_soa(struct gallivm_state *gallivm, } } + void lp_build_size_query_soa(struct gallivm_state *gallivm, const struct lp_static_texture_state *static_state, @@ -2883,6 +2898,7 @@ lp_build_size_query_soa(struct gallivm_state *gallivm, struct lp_type int_type, unsigned texture_unit, unsigned target, + LLVMValueRef context_ptr, boolean is_sviewinfo, enum lp_sampler_lod_property lod_property, LLVMValueRef explicit_lod, @@ -2954,8 +2970,10 @@ lp_build_size_query_soa(struct gallivm_state *gallivm, if (explicit_lod) { /* FIXME: this needs to honor per-element lod */ - lod = LLVMBuildExtractElement(gallivm->builder, explicit_lod, lp_build_const_int32(gallivm, 0), ""); - first_level = dynamic_state->first_level(dynamic_state, gallivm, texture_unit); + lod = LLVMBuildExtractElement(gallivm->builder, explicit_lod, + lp_build_const_int32(gallivm, 0), ""); + first_level = dynamic_state->first_level(dynamic_state, gallivm, + context_ptr, texture_unit); level = LLVMBuildAdd(gallivm->builder, lod, first_level, "level"); lod = lp_build_broadcast_scalar(&bld_int_vec4, level); } else { @@ -2965,25 +2983,29 @@ lp_build_size_query_soa(struct gallivm_state *gallivm, size = bld_int_vec4.undef; size = LLVMBuildInsertElement(gallivm->builder, size, - dynamic_state->width(dynamic_state, gallivm, texture_unit), + dynamic_state->width(dynamic_state, gallivm, + context_ptr, texture_unit), lp_build_const_int32(gallivm, 0), ""); if (dims >= 2) { size = LLVMBuildInsertElement(gallivm->builder, size, - dynamic_state->height(dynamic_state, gallivm, texture_unit), + dynamic_state->height(dynamic_state, gallivm, + context_ptr, texture_unit), lp_build_const_int32(gallivm, 1), ""); } if (dims >= 3) { size = LLVMBuildInsertElement(gallivm->builder, size, - dynamic_state->depth(dynamic_state, gallivm, texture_unit), + dynamic_state->depth(dynamic_state, gallivm, + context_ptr, texture_unit), lp_build_const_int32(gallivm, 2), ""); } size = lp_build_minify(&bld_int_vec4, size, lod, TRUE); if (has_array) { - LLVMValueRef layers = dynamic_state->depth(dynamic_state, gallivm, texture_unit); + LLVMValueRef layers = dynamic_state->depth(dynamic_state, gallivm, + context_ptr, texture_unit); if (target == PIPE_TEXTURE_CUBE_ARRAY) { /* * It looks like GL wants number of cubes, d3d10.1 has it undefined? @@ -3008,7 +3030,8 @@ lp_build_size_query_soa(struct gallivm_state *gallivm, /* everything is scalar for now */ lp_build_context_init(&leveli_bld, gallivm, lp_type_int_vec(32, 32)); - last_level = dynamic_state->last_level(dynamic_state, gallivm, texture_unit); + last_level = dynamic_state->last_level(dynamic_state, gallivm, + context_ptr, texture_unit); out = lp_build_cmp(&leveli_bld, PIPE_FUNC_LESS, level, first_level); out1 = lp_build_cmp(&leveli_bld, PIPE_FUNC_GREATER, level, last_level); @@ -3048,7 +3071,8 @@ lp_build_size_query_soa(struct gallivm_state *gallivm, else { LLVMValueRef last_level; - last_level = dynamic_state->last_level(dynamic_state, gallivm, texture_unit); + last_level = dynamic_state->last_level(dynamic_state, gallivm, + context_ptr, texture_unit); num_levels = lp_build_sub(&bld_int_scalar, last_level, first_level); num_levels = lp_build_add(&bld_int_scalar, num_levels, bld_int_scalar.one); } diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h b/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h index b411f05..8d53607 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h +++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h @@ -188,6 +188,7 @@ struct lp_build_sampler_soa boolean is_fetch, unsigned texture_index, unsigned sampler_index, + LLVMValueRef context_ptr, const LLVMValueRef *coords, const LLVMValueRef *offsets, const struct lp_derivatives *derivs, @@ -202,6 +203,7 @@ struct lp_build_sampler_soa struct lp_type type, unsigned unit, unsigned target, + LLVMValueRef context_ptr, boolean need_nr_mips, enum lp_sampler_lod_property, LLVMValueRef explicit_lod, /* optional */ @@ -237,6 +239,7 @@ lp_build_tgsi_soa(struct gallivm_state *gallivm, const struct lp_bld_tgsi_system_values *system_values, const LLVMValueRef (*inputs)[4], LLVMValueRef (*outputs)[4], + LLVMValueRef context_ptr, struct lp_build_sampler_soa *sampler, const struct tgsi_shader_info *info, const struct lp_build_tgsi_gs_iface *gs_iface); @@ -449,6 +452,7 @@ struct lp_build_tgsi_soa_context LLVMValueRef consts_sizes[LP_MAX_TGSI_CONST_BUFFERS]; const LLVMValueRef (*inputs)[TGSI_NUM_CHANNELS]; LLVMValueRef (*outputs)[TGSI_NUM_CHANNELS]; + LLVMValueRef context_ptr; const struct lp_build_sampler_soa *sampler; diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c index 3b2097f..3e82036 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c @@ -2151,6 +2151,7 @@ emit_tex( struct lp_build_tgsi_soa_context *bld, bld->bld_base.base.type, FALSE, unit, unit, + bld->context_ptr, coords, offsets, deriv_ptr, @@ -2314,6 +2315,7 @@ emit_sample(struct lp_build_tgsi_soa_context *bld, bld->bld_base.base.type, FALSE, texture_unit, sampler_unit, + bld->context_ptr, coords, offsets, deriv_ptr, @@ -2424,6 +2426,7 @@ emit_fetch_texels( struct lp_build_tgsi_soa_context *bld, bld->bld_base.base.type, TRUE, unit, unit, + bld->context_ptr, coords, offsets, NULL, @@ -2498,6 +2501,7 @@ emit_size_query( struct lp_build_tgsi_soa_context *bld, bld->bld_base.base.gallivm, bld->bld_base.int_bld.type, unit, pipe_target, + bld->context_ptr, TRUE, lod_property, explicit_lod, @@ -3656,6 +3660,7 @@ lp_build_tgsi_soa(struct gallivm_state *gallivm, const struct lp_bld_tgsi_system_values *system_values, const LLVMValueRef (*inputs)[TGSI_NUM_CHANNELS], LLVMValueRef (*outputs)[TGSI_NUM_CHANNELS], + LLVMValueRef context_ptr, struct lp_build_sampler_soa *sampler, const struct tgsi_shader_info *info, const struct lp_build_tgsi_gs_iface *gs_iface) @@ -3684,6 +3689,7 @@ lp_build_tgsi_soa(struct gallivm_state *gallivm, bld.sampler = sampler; bld.bld_base.info = info; bld.indirect_files = info->indirect_files; + bld.context_ptr = context_ptr; /* * If the number of temporaries is rather large then we just diff --git a/src/gallium/drivers/llvmpipe/lp_state_fs.c b/src/gallium/drivers/llvmpipe/lp_state_fs.c index 14fd6b9..35fe7b2 100644 --- a/src/gallium/drivers/llvmpipe/lp_state_fs.c +++ b/src/gallium/drivers/llvmpipe/lp_state_fs.c @@ -417,7 +417,8 @@ generate_fs_loop(struct gallivm_state *gallivm, lp_build_tgsi_soa(gallivm, tokens, type, &mask, consts_ptr, num_consts_ptr, &system_values, interp->inputs, - outputs, sampler, &shader->info.base, NULL); + outputs, context_ptr, + sampler, &shader->info.base, NULL); /* Alpha test */ if (key->alpha.enabled) { @@ -2302,7 +2303,7 @@ generate_fragment(struct llvmpipe_context *lp, LLVMPositionBuilderAtEnd(builder, block); /* code generated texture sampling */ - sampler = lp_llvm_sampler_soa_create(key->state, context_ptr); + sampler = lp_llvm_sampler_soa_create(key->state); num_fs = 16 / fs_type.length; /* number of loops per 4x4 stamp */ /* for 1d resources only run "upper half" of stamp */ diff --git a/src/gallium/drivers/llvmpipe/lp_tex_sample.c b/src/gallium/drivers/llvmpipe/lp_tex_sample.c index f0a4a34..1828069 100644 --- a/src/gallium/drivers/llvmpipe/lp_tex_sample.c +++ b/src/gallium/drivers/llvmpipe/lp_tex_sample.c @@ -65,8 +65,6 @@ struct llvmpipe_sampler_dynamic_state struct lp_sampler_dynamic_state base; const struct lp_sampler_static_state *static_state; - - LLVMValueRef context_ptr; }; @@ -92,13 +90,12 @@ struct lp_llvm_sampler_soa static LLVMValueRef lp_llvm_texture_member(const struct lp_sampler_dynamic_state *base, struct gallivm_state *gallivm, + LLVMValueRef context_ptr, unsigned texture_unit, unsigned member_index, const char *member_name, boolean emit_load) { - struct llvmpipe_sampler_dynamic_state *state = - (struct llvmpipe_sampler_dynamic_state *)base; LLVMBuilderRef builder = gallivm->builder; LLVMValueRef indices[4]; LLVMValueRef ptr; @@ -115,7 +112,7 @@ lp_llvm_texture_member(const struct lp_sampler_dynamic_state *base, /* context[0].textures[unit].member */ indices[3] = lp_build_const_int32(gallivm, member_index); - ptr = LLVMBuildGEP(builder, state->context_ptr, indices, Elements(indices), ""); + ptr = LLVMBuildGEP(builder, context_ptr, indices, Elements(indices), ""); if (emit_load) res = LLVMBuildLoad(builder, ptr, ""); @@ -141,9 +138,11 @@ lp_llvm_texture_member(const struct lp_sampler_dynamic_state *base, static LLVMValueRef \ lp_llvm_texture_##_name( const struct lp_sampler_dynamic_state *base, \ struct gallivm_state *gallivm, \ + LLVMValueRef context_ptr, \ unsigned texture_unit) \ { \ - return lp_llvm_texture_member(base, gallivm, texture_unit, _index, #_name, _emit_load ); \ + return lp_llvm_texture_member(base, gallivm, context_ptr, \ + texture_unit, _index, #_name, _emit_load ); \ } @@ -169,13 +168,12 @@ LP_LLVM_TEXTURE_MEMBER(mip_offsets, LP_JIT_TEXTURE_MIP_OFFSETS, FALSE) static LLVMValueRef lp_llvm_sampler_member(const struct lp_sampler_dynamic_state *base, struct gallivm_state *gallivm, + LLVMValueRef context_ptr, unsigned sampler_unit, unsigned member_index, const char *member_name, boolean emit_load) { - struct llvmpipe_sampler_dynamic_state *state = - (struct llvmpipe_sampler_dynamic_state *)base; LLVMBuilderRef builder = gallivm->builder; LLVMValueRef indices[4]; LLVMValueRef ptr; @@ -192,7 +190,7 @@ lp_llvm_sampler_member(const struct lp_sampler_dynamic_state *base, /* context[0].samplers[unit].member */ indices[3] = lp_build_const_int32(gallivm, member_index); - ptr = LLVMBuildGEP(builder, state->context_ptr, indices, Elements(indices), ""); + ptr = LLVMBuildGEP(builder, context_ptr, indices, Elements(indices), ""); if (emit_load) res = LLVMBuildLoad(builder, ptr, ""); @@ -209,9 +207,11 @@ lp_llvm_sampler_member(const struct lp_sampler_dynamic_state *base, static LLVMValueRef \ lp_llvm_sampler_##_name( const struct lp_sampler_dynamic_state *base, \ struct gallivm_state *gallivm, \ + LLVMValueRef context_ptr, \ unsigned sampler_unit) \ { \ - return lp_llvm_sampler_member(base, gallivm, sampler_unit, _index, #_name, _emit_load ); \ + return lp_llvm_sampler_member(base, gallivm, context_ptr, \ + sampler_unit, _index, #_name, _emit_load ); \ } @@ -239,6 +239,7 @@ lp_llvm_sampler_soa_emit_fetch_texel(const struct lp_build_sampler_soa *base, boolean is_fetch, unsigned texture_index, unsigned sampler_index, + LLVMValueRef context_ptr, const LLVMValueRef *coords, const LLVMValueRef *offsets, const struct lp_derivatives *derivs, @@ -265,6 +266,7 @@ lp_llvm_sampler_soa_emit_fetch_texel(const struct lp_build_sampler_soa *base, is_fetch, texture_index, sampler_index, + context_ptr, coords, offsets, derivs, @@ -281,6 +283,7 @@ lp_llvm_sampler_soa_emit_size_query(const struct lp_build_sampler_soa *base, struct lp_type type, unsigned texture_unit, unsigned target, + LLVMValueRef context_ptr, boolean is_sviewinfo, enum lp_sampler_lod_property lod_property, LLVMValueRef explicit_lod, /* optional */ @@ -296,6 +299,7 @@ lp_llvm_sampler_soa_emit_size_query(const struct lp_build_sampler_soa *base, type, texture_unit, target, + context_ptr, is_sviewinfo, lod_property, explicit_lod, @@ -304,8 +308,7 @@ lp_llvm_sampler_soa_emit_size_query(const struct lp_build_sampler_soa *base, struct lp_build_sampler_soa * -lp_llvm_sampler_soa_create(const struct lp_sampler_static_state *static_state, - LLVMValueRef context_ptr) +lp_llvm_sampler_soa_create(const struct lp_sampler_static_state *static_state) { struct lp_llvm_sampler_soa *sampler; @@ -331,7 +334,6 @@ lp_llvm_sampler_soa_create(const struct lp_sampler_static_state *static_state, sampler->dynamic_state.base.border_color = lp_llvm_sampler_border_color; sampler->dynamic_state.static_state = static_state; - sampler->dynamic_state.context_ptr = context_ptr; return &sampler->base; } diff --git a/src/gallium/drivers/llvmpipe/lp_tex_sample.h b/src/gallium/drivers/llvmpipe/lp_tex_sample.h index bca92d9..f4aff22 100644 --- a/src/gallium/drivers/llvmpipe/lp_tex_sample.h +++ b/src/gallium/drivers/llvmpipe/lp_tex_sample.h @@ -38,11 +38,9 @@ struct lp_sampler_static_state; /** * Pure-LLVM texture sampling code generator. * - * @param context_ptr LLVM value with the pointer to the struct lp_jit_context. */ struct lp_build_sampler_soa * -lp_llvm_sampler_soa_create(const struct lp_sampler_static_state *key, - LLVMValueRef context_ptr); +lp_llvm_sampler_soa_create(const struct lp_sampler_static_state *key); #endif /* LP_TEX_SAMPLE_H */ From sroland at kemper.freedesktop.org Fri Mar 27 18:27:50 2015 From: sroland at kemper.freedesktop.org (Roland Scheidegger) Date: Fri, 27 Mar 2015 11:27:50 -0700 (PDT) Subject: Mesa (master): gallivm: use llvm function calls for texturing instead of inlining Message-ID: <20150327182750.96D6E7635A@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 56076be2ac60f005770516a9ac305e60e6285497 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=56076be2ac60f005770516a9ac305e60e6285497 Author: Roland Scheidegger Date: Fri Mar 27 02:39:59 2015 +0100 gallivm: use llvm function calls for texturing instead of inlining There are issues with inlining everything, most notably llvm will use much more memory (and be slower) when compiling. Ideally we'd probably use functions for shader functions too but texture sampling usually is responsible for quite some IR (it can easily reach 80% of total IR instructions) so this seems like a good start. This still generates a different function for all different combinations just like before, however it is possible llvm is missing some optimization opportunities - it is believed though such opportunities should be somewhat rare, but at least for now it can still be switched off (at compile time only). It should probably make compiled code also smaller because the same function should be used for different variants in the same module (so for the opaque/partial or linear/elts variants). No piglit change (though it does indeed speed up unrealistic tests like fp-indirections2 by a factor of 30 or so). Has a small negative performance impact in openarena - I suspect this could be fixed by running some IPO passes (despite the private linkage, llvm right now does NO optimization at all wrt anything going past the call, even if there's just one caller - so things like values stored before the call and then always written by the function etc. will not be optimized away, nor will dead arguments (which we mostly shouldn't have) be eliminated, always constant arguments promoted etc.). v2: use proper return values instead of pointer function arguments. llvm supports aggregate return values, which do wonders here eliminating unnecessary stack variables - everything in fact will be returned in registers even without any IPO optimizations. It makes the code simpler too. With this I could not measure a peformance impact in openarena any longer (though since there's still no constant value propagation etc. into the tex functions this does not mean it couldn't have a negative impact elsewhere). v3: fix some minor issues suggested by Jose, and do disassembly (and the profiling) without hacks. Reviewed-by: Jose Fonseca --- src/gallium/auxiliary/gallivm/lp_bld_init.c | 44 ++- src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c | 420 ++++++++++++++++++++- 2 files changed, 438 insertions(+), 26 deletions(-) diff --git a/src/gallium/auxiliary/gallivm/lp_bld_init.c b/src/gallium/auxiliary/gallivm/lp_bld_init.c index 6133883..7b906c2 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_init.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_init.c @@ -113,6 +113,11 @@ create_pass_manager(struct gallivm_state *gallivm) gallivm->passmgr = LLVMCreateFunctionPassManagerForModule(gallivm->module); if (!gallivm->passmgr) return FALSE; + /* + * TODO: some per module pass manager with IPO passes might be helpful - + * the generated texture functions may benefit from inlining if they are + * simple, or constant propagation into them, etc. + */ // Old versions of LLVM get the DataLayout from the pass manager. LLVMAddTargetData(gallivm->target, gallivm->passmgr); @@ -556,6 +561,37 @@ gallivm_compile_module(struct gallivm_state *gallivm) assert(gallivm->engine); ++gallivm->compiled; + + if (gallivm_debug & GALLIVM_DEBUG_ASM) { + LLVMValueRef llvm_func = LLVMGetFirstFunction(gallivm->module); + + while (llvm_func) { + /* + * Need to filter out functions which don't have an implementation, + * such as the intrinsics. May not be sufficient in case of IPO? + * LLVMGetPointerToGlobal() will abort otherwise. + */ + if (!LLVMIsDeclaration(llvm_func)) { + void *func_code = LLVMGetPointerToGlobal(gallivm->engine, llvm_func); + lp_disassemble(llvm_func, func_code); + } + llvm_func = LLVMGetNextFunction(llvm_func); + } + } + +#if defined(PROFILE) + { + LLVMValueRef llvm_func = LLVMGetFirstFunction(gallivm->module); + + while (llvm_func) { + if (!LLVMIsDeclaration(llvm_func)) { + void *func_code = LLVMGetPointerToGlobal(gallivm->engine, llvm_func); + lp_profile(llvm_func, func_code); + } + llvm_func = LLVMGetNextFunction(llvm_func); + } + } +#endif } @@ -574,13 +610,5 @@ gallivm_jit_function(struct gallivm_state *gallivm, assert(code); jit_func = pointer_to_func(code); - if (gallivm_debug & GALLIVM_DEBUG_ASM) { - lp_disassemble(func, code); - } - -#if defined(PROFILE) - lp_profile(func, code); -#endif - return jit_func; } diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c index a90278e..9e74bd6 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c @@ -2357,30 +2357,30 @@ lp_build_sample_nop(struct gallivm_state *gallivm, /** - * Build texture sampling code. + * Build the actual texture sampling code. * 'texel' will return a vector of four LLVMValueRefs corresponding to * R, G, B, A. * \param type vector float type to use for coords, etc. * \param is_fetch if this is a texel fetch instruction. * \param derivs partial derivatives of (s,t,r,q) with respect to x and y */ -void -lp_build_sample_soa(struct gallivm_state *gallivm, - const struct lp_static_texture_state *static_texture_state, - const struct lp_static_sampler_state *static_sampler_state, - struct lp_sampler_dynamic_state *dynamic_state, - struct lp_type type, - boolean is_fetch, - unsigned texture_index, - unsigned sampler_index, - LLVMValueRef context_ptr, - const LLVMValueRef *coords, - const LLVMValueRef *offsets, - const struct lp_derivatives *derivs, /* optional */ - LLVMValueRef lod_bias, /* optional */ - LLVMValueRef explicit_lod, /* optional */ - enum lp_sampler_lod_property lod_property, - LLVMValueRef texel_out[4]) +static void +lp_build_sample_soa_code(struct gallivm_state *gallivm, + const struct lp_static_texture_state *static_texture_state, + const struct lp_static_sampler_state *static_sampler_state, + struct lp_sampler_dynamic_state *dynamic_state, + struct lp_type type, + boolean is_fetch, + unsigned texture_index, + unsigned sampler_index, + LLVMValueRef context_ptr, + const LLVMValueRef *coords, + const LLVMValueRef *offsets, + const struct lp_derivatives *derivs, /* optional */ + LLVMValueRef lod_bias, /* optional */ + LLVMValueRef explicit_lod, /* optional */ + enum lp_sampler_lod_property lod_property, + LLVMValueRef texel_out[4]) { unsigned target = static_texture_state->target; unsigned dims = texture_dims(target); @@ -2891,6 +2891,390 @@ lp_build_sample_soa(struct gallivm_state *gallivm, } +#define USE_TEX_FUNC_CALL 1 + +#define LP_MAX_TEX_FUNC_ARGS 32 + +#define LP_SAMPLER_FUNC_LOD_BIAS (1 << 0) +#define LP_SAMPLER_FUNC_LOD_EXPLICIT (1 << 1) +#define LP_SAMPLER_FUNC_EXPLICITDERIVS (1 << 2) +#define LP_SAMPLER_FUNC_SHADOW (1 << 3) +#define LP_SAMPLER_FUNC_OFFSETS (1 << 4) +#define LP_SAMPLER_FUNC_LOD_PROPERTY_SHIFT 5 + + +static inline void +get_target_info(enum pipe_texture_target target, + unsigned *num_coords, unsigned *num_derivs, + unsigned *num_offsets, unsigned *layer) +{ + unsigned dims = texture_dims(target); + *num_coords = dims; + *num_offsets = dims; + *num_derivs = (target == PIPE_TEXTURE_CUBE || + target == PIPE_TEXTURE_CUBE_ARRAY) ? 3 : dims; + *layer = has_layer_coord(target) ? 2: 0; + if (target == PIPE_TEXTURE_CUBE_ARRAY) { + /* + * dims doesn't include r coord for cubes - this is handled + * by layer instead, but need to fix up for cube arrays... + */ + *layer = 3; + *num_coords = 3; + } +} + + +/** + * Generate the function body for a texture sampling function. + */ +static void +lp_build_sample_gen_func(struct gallivm_state *gallivm, + const struct lp_static_texture_state *static_texture_state, + const struct lp_static_sampler_state *static_sampler_state, + struct lp_sampler_dynamic_state *dynamic_state, + struct lp_type type, + boolean is_fetch, + unsigned texture_index, + unsigned sampler_index, + LLVMValueRef function, + unsigned num_args, + unsigned sampler_bits, + enum lp_sampler_lod_property lod_property) +{ + + LLVMBuilderRef old_builder; + LLVMBasicBlockRef block; + LLVMValueRef coords[5]; + LLVMValueRef offsets[3] = { NULL }; + LLVMValueRef lod_bias = NULL; + LLVMValueRef explicit_lod = NULL; + LLVMValueRef context_ptr; + LLVMValueRef texel_out[4]; + struct lp_derivatives derivs; + struct lp_derivatives *deriv_ptr = NULL; + unsigned num_param = 0; + unsigned i, num_coords, num_derivs, num_offsets, layer; + + get_target_info(static_texture_state->target, + &num_coords, &num_derivs, &num_offsets, &layer); + + /* "unpack" arguments */ + context_ptr = LLVMGetParam(function, num_param++); + for (i = 0; i < num_coords; i++) { + coords[i] = LLVMGetParam(function, num_param++); + } + for (i = num_coords; i < 5; i++) { + /* This is rather unfortunate... */ + coords[i] = lp_build_undef(gallivm, type); + } + if (layer) { + coords[layer] = LLVMGetParam(function, num_param++); + } + if (sampler_bits & LP_SAMPLER_FUNC_SHADOW) { + coords[4] = LLVMGetParam(function, num_param++); + } + if (sampler_bits & LP_SAMPLER_FUNC_OFFSETS) { + for (i = 0; i < num_offsets; i++) { + offsets[i] = LLVMGetParam(function, num_param++); + } + } + if (sampler_bits & LP_SAMPLER_FUNC_LOD_BIAS) { + lod_bias = LLVMGetParam(function, num_param++); + } + else if (sampler_bits & LP_SAMPLER_FUNC_LOD_EXPLICIT) { + explicit_lod = LLVMGetParam(function, num_param++); + } + else if (sampler_bits & LP_SAMPLER_FUNC_EXPLICITDERIVS) { + for (i = 0; i < num_derivs; i++) { + derivs.ddx[i] = LLVMGetParam(function, num_param++); + derivs.ddy[i] = LLVMGetParam(function, num_param++); + } + deriv_ptr = &derivs; + } + + assert(num_args == num_param); + + /* + * Function body + */ + + old_builder = gallivm->builder; + block = LLVMAppendBasicBlockInContext(gallivm->context, function, "entry"); + gallivm->builder = LLVMCreateBuilderInContext(gallivm->context); + LLVMPositionBuilderAtEnd(gallivm->builder, block); + + lp_build_sample_soa_code(gallivm, + static_texture_state, + static_sampler_state, + dynamic_state, + type, + is_fetch, + texture_index, + sampler_index, + context_ptr, + coords, + offsets, + deriv_ptr, + lod_bias, + explicit_lod, + lod_property, + texel_out); + + LLVMBuildAggregateRet(gallivm->builder, texel_out, 4); + + LLVMDisposeBuilder(gallivm->builder); + gallivm->builder = old_builder; + + gallivm_verify_function(gallivm, function); +} + + +/** + * Call the matching function for texture sampling. + * If there's no match, generate a new one. + */ +static void +lp_build_sample_soa_func(struct gallivm_state *gallivm, + const struct lp_static_texture_state *static_texture_state, + const struct lp_static_sampler_state *static_sampler_state, + struct lp_sampler_dynamic_state *dynamic_state, + struct lp_type type, + boolean is_fetch, + unsigned texture_index, + unsigned sampler_index, + LLVMValueRef context_ptr, + const LLVMValueRef *coords, + const LLVMValueRef *offsets, + const struct lp_derivatives *derivs, /* optional */ + LLVMValueRef lod_bias, /* optional */ + LLVMValueRef explicit_lod, /* optional */ + enum lp_sampler_lod_property lod_property, + LLVMValueRef texel_out[4]) +{ + LLVMBuilderRef builder = gallivm->builder; + LLVMModuleRef module = LLVMGetGlobalParent(LLVMGetBasicBlockParent( + LLVMGetInsertBlock(builder))); + LLVMValueRef function, inst; + LLVMValueRef args[LP_MAX_TEX_FUNC_ARGS]; + LLVMBasicBlockRef bb; + LLVMValueRef tex_ret; + unsigned num_args = 0; + unsigned sampler_bits = 0; + char func_name[64]; + unsigned i, num_coords, num_derivs, num_offsets, layer; + + get_target_info(static_texture_state->target, + &num_coords, &num_derivs, &num_offsets, &layer); + + /* + * texture function matches are found by name. + * Thus the name has to include both the texture and sampler unit + * (which covers all static state) plus the actual texture functions + * (which is determined here somewhat awkwardly by presence of the + * corresponding LLVMValueRefs). Additionally, lod_property also + * has to be included (it could change if the lod for instance comes + * from a shader uniform or a temp reg). + */ + if (static_sampler_state->compare_mode != PIPE_TEX_COMPARE_NONE) { + sampler_bits |= LP_SAMPLER_FUNC_SHADOW; + } + if (offsets[0]) { + sampler_bits |= LP_SAMPLER_FUNC_OFFSETS; + } + if (lod_bias) { + sampler_bits |= LP_SAMPLER_FUNC_LOD_BIAS; + } + else if (explicit_lod) { + sampler_bits |= LP_SAMPLER_FUNC_LOD_EXPLICIT; + } + else if (derivs) { + sampler_bits |= LP_SAMPLER_FUNC_EXPLICITDERIVS; + } + sampler_bits |= lod_property << LP_SAMPLER_FUNC_LOD_PROPERTY_SHIFT; + + util_snprintf(func_name, sizeof(func_name), "texfunc_res_%d_sam_%d_%x", + texture_index, sampler_index, sampler_bits); + + function = LLVMGetNamedFunction(module, func_name); + + if(!function) { + LLVMTypeRef arg_types[LP_MAX_TEX_FUNC_ARGS]; + LLVMTypeRef ret_type; + LLVMTypeRef function_type; + LLVMTypeRef val_type[4]; + unsigned num_param = 0; + + /* + * Generate the function prototype. + */ + + arg_types[num_param++] = LLVMTypeOf(context_ptr); + for (i = 0; i < num_coords; i++) { + arg_types[num_param++] = LLVMTypeOf(coords[0]); + assert(LLVMTypeOf(coords[0]) == LLVMTypeOf(coords[i])); + } + if (layer) { + arg_types[num_param++] = LLVMTypeOf(coords[layer]); + assert(LLVMTypeOf(coords[0]) == LLVMTypeOf(coords[layer])); + } + if (sampler_bits & LP_SAMPLER_FUNC_SHADOW) { + arg_types[num_param++] = LLVMTypeOf(coords[0]); + } + if (sampler_bits & LP_SAMPLER_FUNC_OFFSETS) { + for (i = 0; i < num_offsets; i++) { + arg_types[num_param++] = LLVMTypeOf(offsets[0]); + assert(LLVMTypeOf(offsets[0]) == LLVMTypeOf(offsets[i])); + } + } + if (sampler_bits & LP_SAMPLER_FUNC_LOD_BIAS) { + arg_types[num_param++] = LLVMTypeOf(lod_bias); + } + else if (sampler_bits & LP_SAMPLER_FUNC_LOD_EXPLICIT) { + arg_types[num_param++] = LLVMTypeOf(explicit_lod); + } + else if (sampler_bits & LP_SAMPLER_FUNC_EXPLICITDERIVS) { + for (i = 0; i < num_derivs; i++) { + arg_types[num_param++] = LLVMTypeOf(derivs->ddx[i]); + arg_types[num_param++] = LLVMTypeOf(derivs->ddy[i]); + assert(LLVMTypeOf(derivs->ddx[0]) == LLVMTypeOf(derivs->ddx[i])); + assert(LLVMTypeOf(derivs->ddy[0]) == LLVMTypeOf(derivs->ddy[i])); + } + } + + ret_type = LLVMVoidTypeInContext(gallivm->context); + val_type[0] = val_type[1] = val_type[2] = val_type[3] = + lp_build_vec_type(gallivm, type); + ret_type = LLVMStructTypeInContext(gallivm->context, val_type, 4, 0); + function_type = LLVMFunctionType(ret_type, arg_types, num_param, 0); + function = LLVMAddFunction(module, func_name, function_type); + + for (i = 0; i < num_param; ++i) { + if(LLVMGetTypeKind(arg_types[i]) == LLVMPointerTypeKind) { + LLVMAddAttribute(LLVMGetParam(function, i), LLVMNoAliasAttribute); + } + } + + LLVMSetFunctionCallConv(function, LLVMFastCallConv); + LLVMSetLinkage(function, LLVMPrivateLinkage); + + lp_build_sample_gen_func(gallivm, + static_texture_state, + static_sampler_state, + dynamic_state, + type, + is_fetch, + texture_index, + sampler_index, + function, + num_param, + sampler_bits, + lod_property); + } + + num_args = 0; + args[num_args++] = context_ptr; + for (i = 0; i < num_coords; i++) { + args[num_args++] = coords[i]; + } + if (layer) { + args[num_args++] = coords[layer]; + } + if (sampler_bits & LP_SAMPLER_FUNC_SHADOW) { + args[num_args++] = coords[4]; + } + if (sampler_bits & LP_SAMPLER_FUNC_OFFSETS) { + for (i = 0; i < num_offsets; i++) { + args[num_args++] = offsets[i]; + } + } + if (sampler_bits & LP_SAMPLER_FUNC_LOD_BIAS) { + args[num_args++] = lod_bias; + } + else if (sampler_bits & LP_SAMPLER_FUNC_LOD_EXPLICIT) { + args[num_args++] = explicit_lod; + } + else if (sampler_bits & LP_SAMPLER_FUNC_EXPLICITDERIVS) { + for (i = 0; i < num_derivs; i++) { + args[num_args++] = derivs->ddx[i]; + args[num_args++] = derivs->ddy[i]; + } + } + + assert(num_args <= LP_MAX_TEX_FUNC_ARGS); + + tex_ret = LLVMBuildCall(builder, function, args, num_args, ""); + bb = LLVMGetInsertBlock(builder); + inst = LLVMGetLastInstruction(bb); + LLVMSetInstructionCallConv(inst, LLVMFastCallConv); + + for (i = 0; i < 4; i++) { + texel_out[i] = LLVMBuildExtractValue(gallivm->builder, tex_ret, i, ""); + } +} + + +/** + * Build texture sampling code. + * Either via a function call or inline it directly. + */ +void +lp_build_sample_soa(struct gallivm_state *gallivm, + const struct lp_static_texture_state *static_texture_state, + const struct lp_static_sampler_state *static_sampler_state, + struct lp_sampler_dynamic_state *dynamic_state, + struct lp_type type, + boolean is_fetch, + unsigned texture_index, + unsigned sampler_index, + LLVMValueRef context_ptr, + const LLVMValueRef *coords, + const LLVMValueRef *offsets, + const struct lp_derivatives *derivs, /* optional */ + LLVMValueRef lod_bias, /* optional */ + LLVMValueRef explicit_lod, /* optional */ + enum lp_sampler_lod_property lod_property, + LLVMValueRef texel_out[4]) +{ + if (USE_TEX_FUNC_CALL) { + lp_build_sample_soa_func(gallivm, + static_texture_state, + static_sampler_state, + dynamic_state, + type, + is_fetch, + texture_index, + sampler_index, + context_ptr, + coords, + offsets, + derivs, + lod_bias, + explicit_lod, + lod_property, + texel_out); + } + else { + lp_build_sample_soa_code(gallivm, + static_texture_state, + static_sampler_state, + dynamic_state, + type, + is_fetch, + texture_index, + sampler_index, + context_ptr, + coords, + offsets, + derivs, + lod_bias, + explicit_lod, + lod_property, + texel_out); + } +} + + void lp_build_size_query_soa(struct gallivm_state *gallivm, const struct lp_static_texture_state *static_state, From anholt at kemper.freedesktop.org Fri Mar 27 20:31:17 2015 From: anholt at kemper.freedesktop.org (Eric Anholt) Date: Fri, 27 Mar 2015 13:31:17 -0700 (PDT) Subject: Mesa (master): nir: Add optional lowering of flrp. Message-ID: <20150327203117.D611876333@kemper.freedesktop.org> Module: Mesa Branch: master Commit: afa9fc15613c3ebdc59245c9d4d8c1280b2a2a37 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=afa9fc15613c3ebdc59245c9d4d8c1280b2a2a37 Author: Eric Anholt Date: Wed Feb 18 12:24:38 2015 -0800 nir: Add optional lowering of flrp. Reviewed-by: Matt Turner Reviewed-by: Connor Abbott --- src/glsl/nir/nir.h | 1 + src/glsl/nir/nir_opt_algebraic.py | 1 + 2 files changed, 2 insertions(+) diff --git a/src/glsl/nir/nir.h b/src/glsl/nir/nir.h index 29fe942..7b886e3 100644 --- a/src/glsl/nir/nir.h +++ b/src/glsl/nir/nir.h @@ -1365,6 +1365,7 @@ typedef struct nir_function { typedef struct nir_shader_compiler_options { bool lower_ffma; + bool lower_flrp; bool lower_fpow; bool lower_fsat; bool lower_fsqrt; diff --git a/src/glsl/nir/nir_opt_algebraic.py b/src/glsl/nir/nir_opt_algebraic.py index 1ee51a0..20ec4d3 100644 --- a/src/glsl/nir/nir_opt_algebraic.py +++ b/src/glsl/nir/nir_opt_algebraic.py @@ -75,6 +75,7 @@ optimizations = [ (('flrp', a, b, 1.0), b), (('flrp', a, a, b), a), (('flrp', 0.0, a, b), ('fmul', a, b)), + (('flrp', a, b, c), ('fadd', ('fmul', c, ('fsub', b, a)), a), 'options->lower_flrp'), (('ffma', a, b, c), ('fadd', ('fmul', a, b), c), 'options->lower_ffma'), (('fadd', ('fmul', a, b), c), ('ffma', a, b, c), '!options->lower_ffma'), # Comparison simplifications From jvesely at kemper.freedesktop.org Fri Mar 27 22:57:39 2015 From: jvesely at kemper.freedesktop.org (Jan Vesely) Date: Fri, 27 Mar 2015 15:57:39 -0700 (PDT) Subject: Mesa (master): gallivm: Fix build since llvm r233411 Message-ID: <20150327225739.CCEE076333@kemper.freedesktop.org> Module: Mesa Branch: master Commit: a99a16a0cffbb79e1f9a2d2844c549e6ff91afdb URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=a99a16a0cffbb79e1f9a2d2844c549e6ff91afdb Author: Jan Vesely Date: Fri Mar 27 18:45:23 2015 -0400 gallivm: Fix build since llvm r233411 Signed-off-by: Jan Vesely Reviewed-by: Tom Stellard --- src/gallium/auxiliary/gallivm/lp_bld_debug.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/gallium/auxiliary/gallivm/lp_bld_debug.cpp b/src/gallium/auxiliary/gallivm/lp_bld_debug.cpp index bf6268b..d4d453d 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_debug.cpp +++ b/src/gallium/auxiliary/gallivm/lp_bld_debug.cpp @@ -322,7 +322,11 @@ disassemble(const void* func, llvm::raw_ostream & Out) /* * Print the instruction. */ +#if HAVE_LLVM >= 0x0307 + Printer->printInst(&Inst, Out, "", *STI); +#else Printer->printInst(&Inst, Out, ""); +#endif /* * Advance. From imirkin at kemper.freedesktop.org Fri Mar 27 23:04:02 2015 From: imirkin at kemper.freedesktop.org (Ilia Mirkin) Date: Fri, 27 Mar 2015 16:04:02 -0700 (PDT) Subject: Mesa (master): nv50/ir/gk110: fix offset flag position for TXD opcode Message-ID: <20150327230402.86C3C76246@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 58030a8f99d94d6c1bab02ef113d93c6c2636216 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=58030a8f99d94d6c1bab02ef113d93c6c2636216 Author: Ilia Mirkin Date: Fri Mar 27 18:38:24 2015 -0400 nv50/ir/gk110: fix offset flag position for TXD opcode Cc: "10.4 10.5" Signed-off-by: Ilia Mirkin --- src/gallium/drivers/nouveau/codegen/nv50_ir_emit_gk110.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_emit_gk110.cpp b/src/gallium/drivers/nouveau/codegen/nv50_ir_emit_gk110.cpp index 674be69..34cb06a 100644 --- a/src/gallium/drivers/nouveau/codegen/nv50_ir_emit_gk110.cpp +++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_emit_gk110.cpp @@ -1184,6 +1184,7 @@ CodeEmitterGK110::emitTEX(const TexInstruction *i) if (i->tex.useOffsets == 1) { switch (i->op) { case OP_TXF: code[1] |= 0x200; break; + case OP_TXD: code[1] |= 0x00400000; break; default: code[1] |= 0x800; break; } } From imirkin at kemper.freedesktop.org Fri Mar 27 23:04:02 2015 From: imirkin at kemper.freedesktop.org (Ilia Mirkin) Date: Fri, 27 Mar 2015 16:04:02 -0700 (PDT) Subject: Mesa (master): nv50/ir: take postFactor into account when doing peephole optimizations Message-ID: <20150327230402.761C076333@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 49b86007aa2bb599ada6cdbed7ff56246917f12e URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=49b86007aa2bb599ada6cdbed7ff56246917f12e Author: Ilia Mirkin Date: Wed Mar 25 18:00:00 2015 -0400 nv50/ir: take postFactor into account when doing peephole optimizations Multiply operations can have a post-factor on them, which other ops don't support. Only perform the peephole optimizations when there is no post-factor involved. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=89758 Cc: "10.4 10.5" Signed-off-by: Ilia Mirkin --- src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp b/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp index 6a4ea4e..dc048e6 100644 --- a/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp +++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp @@ -451,7 +451,9 @@ ConstantFolding::expr(Instruction *i, b->data.f32 = 0.0f; } switch (i->dType) { - case TYPE_F32: res.data.f32 = a->data.f32 * b->data.f32; break; + case TYPE_F32: + res.data.f32 = a->data.f32 * b->data.f32 * exp2f(i->postFactor); + break; case TYPE_F64: res.data.f64 = a->data.f64 * b->data.f64; break; case TYPE_S32: if (i->subOp == NV50_IR_SUBOP_MUL_HIGH) { @@ -579,6 +581,7 @@ ConstantFolding::expr(Instruction *i, i->src(0).mod = Modifier(0); i->src(1).mod = Modifier(0); + i->postFactor = 0; i->setSrc(0, new_ImmediateValue(i->bb->getProgram(), res.data.u32)); i->setSrc(1, NULL); @@ -682,7 +685,7 @@ ConstantFolding::tryCollapseChainedMULs(Instruction *mul2, Instruction *insn; Instruction *mul1 = NULL; // mul1 before mul2 int e = 0; - float f = imm2.reg.data.f32; + float f = imm2.reg.data.f32 * exp2f(mul2->postFactor); ImmediateValue imm1; assert(mul2->op == OP_MUL && mul2->dType == TYPE_F32); @@ -782,9 +785,10 @@ ConstantFolding::opnd(Instruction *i, ImmediateValue &imm0, int s) i->op = OP_MOV; i->setSrc(0, new_ImmediateValue(prog, 0u)); i->src(0).mod = Modifier(0); + i->postFactor = 0; i->setSrc(1, NULL); } else - if (imm0.isInteger(1) || imm0.isInteger(-1)) { + if (!i->postFactor && (imm0.isInteger(1) || imm0.isInteger(-1))) { if (imm0.isNegative()) i->src(t).mod = i->src(t).mod ^ Modifier(NV50_IR_MOD_NEG); i->op = i->src(t).mod.getOp(); @@ -797,7 +801,7 @@ ConstantFolding::opnd(Instruction *i, ImmediateValue &imm0, int s) i->src(0).mod = 0; i->setSrc(1, NULL); } else - if (imm0.isInteger(2) || imm0.isInteger(-2)) { + if (!i->postFactor && (imm0.isInteger(2) || imm0.isInteger(-2))) { if (imm0.isNegative()) i->src(t).mod = i->src(t).mod ^ Modifier(NV50_IR_MOD_NEG); i->op = OP_ADD; From tarceri at kemper.freedesktop.org Fri Mar 27 23:18:59 2015 From: tarceri at kemper.freedesktop.org (Timothy Arceri) Date: Fri, 27 Mar 2015 16:18:59 -0700 (PDT) Subject: Mesa (master): glsl: mark uniform and input interface blocks as read only Message-ID: <20150327231859.0448D76333@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 2cb149c2894679c5c7af81b40277f77cc0fb099d URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=2cb149c2894679c5c7af81b40277f77cc0fb099d Author: Timothy Arceri Date: Fri Mar 27 23:03:40 2015 +1100 glsl: mark uniform and input interface blocks as read only Reviewed-by: Mark Janes Reviewed-by: Kenneth Graunke --- src/glsl/ast_to_hir.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp index d387b2e..036ec17 100644 --- a/src/glsl/ast_to_hir.cpp +++ b/src/glsl/ast_to_hir.cpp @@ -5776,6 +5776,9 @@ ast_interface_block::hir(exec_list *instructions, var->data.matrix_layout = matrix_layout == GLSL_MATRIX_LAYOUT_INHERITED ? GLSL_MATRIX_LAYOUT_COLUMN_MAJOR : matrix_layout; + if (var_mode == ir_var_shader_in || var_mode == ir_var_uniform) + var->data.read_only = true; + if (state->stage == MESA_SHADER_GEOMETRY && var_mode == ir_var_shader_in) handle_geometry_shader_input_decl(state, loc, var); @@ -5816,6 +5819,9 @@ ast_interface_block::hir(exec_list *instructions, var->data.sample = fields[i].sample; var->init_interface_type(block_type); + if (var_mode == ir_var_shader_in || var_mode == ir_var_uniform) + var->data.read_only = true; + if (fields[i].matrix_layout == GLSL_MATRIX_LAYOUT_INHERITED) { var->data.matrix_layout = matrix_layout == GLSL_MATRIX_LAYOUT_INHERITED ? GLSL_MATRIX_LAYOUT_COLUMN_MAJOR : matrix_layout; From sroland at kemper.freedesktop.org Sat Mar 28 02:01:51 2015 From: sroland at kemper.freedesktop.org (Roland Scheidegger) Date: Fri, 27 Mar 2015 19:01:51 -0700 (PDT) Subject: Mesa (master): gallivm: fix texture function name (key) when using txf/ld Message-ID: <20150328020151.1BE0376333@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 764fc2be5ab61c86baaab746e7ea7702328c4f9f URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=764fc2be5ab61c86baaab746e7ea7702328c4f9f Author: Roland Scheidegger Date: Sat Mar 28 02:57:13 2015 +0100 gallivm: fix texture function name (key) when using txf/ld When using the texel fetch functions rather than ordinary texturing, the arguments are all int vecs instead of float vecs, not to mention the actual function would look completely different. Hence this must be included in the texture function name (which serves as the key) otherwise things crash badly when a shader accesses the same texture and sampler unit with both txf/ld and ordinary texturing instructions with otherwise matching keys. --- src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c index 9e74bd6..598d5fc 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c @@ -2900,7 +2900,8 @@ lp_build_sample_soa_code(struct gallivm_state *gallivm, #define LP_SAMPLER_FUNC_EXPLICITDERIVS (1 << 2) #define LP_SAMPLER_FUNC_SHADOW (1 << 3) #define LP_SAMPLER_FUNC_OFFSETS (1 << 4) -#define LP_SAMPLER_FUNC_LOD_PROPERTY_SHIFT 5 +#define LP_SAMPLER_FUNC_FETCH (1 << 5) +#define LP_SAMPLER_FUNC_LOD_PROPERTY_SHIFT 6 static inline void @@ -3091,6 +3092,9 @@ lp_build_sample_soa_func(struct gallivm_state *gallivm, else if (derivs) { sampler_bits |= LP_SAMPLER_FUNC_EXPLICITDERIVS; } + if (is_fetch) { + sampler_bits |= LP_SAMPLER_FUNC_FETCH; + } sampler_bits |= lod_property << LP_SAMPLER_FUNC_LOD_PROPERTY_SHIFT; util_snprintf(func_name, sizeof(func_name), "texfunc_res_%d_sam_%d_%x", @@ -3142,7 +3146,6 @@ lp_build_sample_soa_func(struct gallivm_state *gallivm, } } - ret_type = LLVMVoidTypeInContext(gallivm->context); val_type[0] = val_type[1] = val_type[2] = val_type[3] = lp_build_vec_type(gallivm, type); ret_type = LLVMStructTypeInContext(gallivm->context, val_type, 4, 0); From sroland at kemper.freedesktop.org Sat Mar 28 02:01:51 2015 From: sroland at kemper.freedesktop.org (Roland Scheidegger) Date: Fri, 27 Mar 2015 19:01:51 -0700 (PDT) Subject: Mesa (master): llvmpipe: simplify address calculation for 4x4 blocks Message-ID: <20150328020151.2612E7635A@kemper.freedesktop.org> Module: Mesa Branch: master Commit: b2424fb0304cf4afd363b35c1dab49fb7edddb08 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=b2424fb0304cf4afd363b35c1dab49fb7edddb08 Author: Roland Scheidegger Date: Fri Mar 27 16:49:54 2015 +0100 llvmpipe: simplify address calculation for 4x4 blocks These functions looked quite complicated, even though what they actually did was trivial (ever since we dropped swizzled rendering). Also drop lookup of format block per bytes done for each block, and do it once per scene instead. This improves everybody's favorite "benchmark" by 3% or so, though lp_rast_shade_quads_all() which calls this shows up still quite high for a function which does little more than call the jit function. (This would most likely be much better handled by the jit function itself, the strides are passed through anyway already, though for being able to handle layers it would definitely add some complexity.) Reviewed-by: Jose Fonseca --- src/gallium/drivers/llvmpipe/lp_rast.c | 20 ++++-- src/gallium/drivers/llvmpipe/lp_rast_priv.h | 87 +++++---------------------- src/gallium/drivers/llvmpipe/lp_scene.c | 3 + src/gallium/drivers/llvmpipe/lp_scene.h | 1 + 4 files changed, 35 insertions(+), 76 deletions(-) diff --git a/src/gallium/drivers/llvmpipe/lp_rast.c b/src/gallium/drivers/llvmpipe/lp_rast.c index 903e7c5..7019acb 100644 --- a/src/gallium/drivers/llvmpipe/lp_rast.c +++ b/src/gallium/drivers/llvmpipe/lp_rast.c @@ -91,6 +91,9 @@ lp_rast_tile_begin(struct lp_rasterizer_task *task, const struct cmd_bin *bin, int x, int y) { + unsigned i; + struct lp_scene *scene = task->scene; + LP_DBG(DEBUG_RAST, "%s %d,%d\n", __FUNCTION__, x, y); task->bin = bin; @@ -104,9 +107,18 @@ lp_rast_tile_begin(struct lp_rasterizer_task *task, task->thread_data.vis_counter = 0; task->ps_invocations = 0; - /* reset pointers to color and depth tile(s) */ - memset(task->color_tiles, 0, sizeof(task->color_tiles)); - task->depth_tile = NULL; + for (i = 0; i < task->scene->fb.nr_cbufs; i++) { + if (task->scene->fb.cbufs[i]) { + task->color_tiles[i] = scene->cbufs[i].map + + scene->cbufs[i].stride * task->y + + scene->cbufs[i].format_bytes * task->x; + } + } + if (task->scene->fb.zsbuf) { + task->depth_tile = scene->zsbuf.map + + scene->zsbuf.stride * task->y + + scene->zsbuf.format_bytes * task->x; + } } @@ -186,7 +198,7 @@ lp_rast_clear_zstencil(struct lp_rasterizer_task *task, if (scene->fb.zsbuf) { unsigned layer; - uint8_t *dst_layer = lp_rast_get_depth_tile_pointer(task, LP_TEX_USAGE_READ_WRITE); + uint8_t *dst_layer = task->depth_tile; block_size = util_format_get_blocksize(scene->fb.zsbuf->format); clear_value &= clear_mask; diff --git a/src/gallium/drivers/llvmpipe/lp_rast_priv.h b/src/gallium/drivers/llvmpipe/lp_rast_priv.h index d92230d..e6ebbcd 100644 --- a/src/gallium/drivers/llvmpipe/lp_rast_priv.h +++ b/src/gallium/drivers/llvmpipe/lp_rast_priv.h @@ -141,64 +141,6 @@ lp_rast_shade_quads_mask(struct lp_rasterizer_task *task, unsigned mask); - -/** - * Get pointer to the color tile - */ -static INLINE uint8_t * -lp_rast_get_color_tile_pointer(struct lp_rasterizer_task *task, - unsigned buf, enum lp_texture_usage usage) -{ - const struct lp_scene *scene = task->scene; - unsigned format_bytes; - - assert(task->x < scene->tiles_x * TILE_SIZE); - assert(task->y < scene->tiles_y * TILE_SIZE); - assert(task->x % TILE_SIZE == 0); - assert(task->y % TILE_SIZE == 0); - assert(buf < scene->fb.nr_cbufs); - - if (!task->color_tiles[buf]) { - struct pipe_surface *cbuf = scene->fb.cbufs[buf]; - assert(cbuf); - - format_bytes = util_format_get_blocksize(cbuf->format); - task->color_tiles[buf] = scene->cbufs[buf].map + scene->cbufs[buf].stride * task->y + - format_bytes * task->x; - } - - return task->color_tiles[buf]; -} - - -/** - * Get pointer to the depth tile - */ -static INLINE uint8_t * -lp_rast_get_depth_tile_pointer(struct lp_rasterizer_task *task, - enum lp_texture_usage usage) -{ - const struct lp_scene *scene = task->scene; - unsigned format_bytes; - - assert(task->x < scene->tiles_x * TILE_SIZE); - assert(task->y < scene->tiles_y * TILE_SIZE); - assert(task->x % TILE_SIZE == 0); - assert(task->y % TILE_SIZE == 0); - - if (!task->depth_tile) { - struct pipe_surface *dbuf = scene->fb.zsbuf; - assert(dbuf); - - format_bytes = util_format_get_blocksize(dbuf->format); - task->depth_tile = scene->zsbuf.map + scene->zsbuf.stride * task->y + - format_bytes * task->x; - } - - return task->depth_tile; -} - - /** * Get the pointer to a 4x4 color block (within a 64x64 tile). * \param x, y location of 4x4 block in window coords @@ -208,7 +150,7 @@ lp_rast_get_color_block_pointer(struct lp_rasterizer_task *task, unsigned buf, unsigned x, unsigned y, unsigned layer) { - unsigned px, py, pixel_offset, format_bytes; + unsigned px, py, pixel_offset; uint8_t *color; assert(x < task->scene->tiles_x * TILE_SIZE); @@ -217,16 +159,19 @@ lp_rast_get_color_block_pointer(struct lp_rasterizer_task *task, assert((y % TILE_VECTOR_HEIGHT) == 0); assert(buf < task->scene->fb.nr_cbufs); - format_bytes = util_format_get_blocksize(task->scene->fb.cbufs[buf]->format); - - color = lp_rast_get_color_tile_pointer(task, buf, LP_TEX_USAGE_READ_WRITE); - assert(color); + assert(task->color_tiles[buf]); + /* + * We don't actually benefit from having per tile cbuf/zsbuf pointers, + * it's just extra work - the mul/add would be exactly the same anyway. + * Fortunately the extra work (modulo) here is very cheap at least... + */ px = x % TILE_SIZE; py = y % TILE_SIZE; - pixel_offset = px * format_bytes + py * task->scene->cbufs[buf].stride; - color = color + pixel_offset; + pixel_offset = px * task->scene->cbufs[buf].format_bytes + + py * task->scene->cbufs[buf].stride; + color = task->color_tiles[buf] + pixel_offset; if (layer) { color += layer * task->scene->cbufs[buf].layer_stride; @@ -245,7 +190,7 @@ static INLINE uint8_t * lp_rast_get_depth_block_pointer(struct lp_rasterizer_task *task, unsigned x, unsigned y, unsigned layer) { - unsigned px, py, pixel_offset, format_bytes; + unsigned px, py, pixel_offset; uint8_t *depth; assert(x < task->scene->tiles_x * TILE_SIZE); @@ -253,16 +198,14 @@ lp_rast_get_depth_block_pointer(struct lp_rasterizer_task *task, assert((x % TILE_VECTOR_WIDTH) == 0); assert((y % TILE_VECTOR_HEIGHT) == 0); - format_bytes = util_format_get_blocksize(task->scene->fb.zsbuf->format); - - depth = lp_rast_get_depth_tile_pointer(task, LP_TEX_USAGE_READ_WRITE); - assert(depth); + assert(task->depth_tile); px = x % TILE_SIZE; py = y % TILE_SIZE; - pixel_offset = px * format_bytes + py * task->scene->zsbuf.stride; - depth = depth + pixel_offset; + pixel_offset = px * task->scene->zsbuf.format_bytes + + py * task->scene->zsbuf.stride; + depth = task->depth_tile + pixel_offset; if (layer) { depth += layer * task->scene->zsbuf.layer_stride; diff --git a/src/gallium/drivers/llvmpipe/lp_scene.c b/src/gallium/drivers/llvmpipe/lp_scene.c index e95d76a..2441b3c 100644 --- a/src/gallium/drivers/llvmpipe/lp_scene.c +++ b/src/gallium/drivers/llvmpipe/lp_scene.c @@ -174,6 +174,7 @@ lp_scene_begin_rasterization(struct lp_scene *scene) cbuf->u.tex.level, cbuf->u.tex.first_layer, LP_TEX_USAGE_READ_WRITE); + scene->cbufs[i].format_bytes = util_format_get_blocksize(cbuf->format); } else { struct llvmpipe_resource *lpr = llvmpipe_resource(cbuf->texture); @@ -182,6 +183,7 @@ lp_scene_begin_rasterization(struct lp_scene *scene) scene->cbufs[i].layer_stride = 0; scene->cbufs[i].map = lpr->data; scene->cbufs[i].map += cbuf->u.buf.first_element * pixstride; + scene->cbufs[i].format_bytes = util_format_get_blocksize(cbuf->format); } } @@ -194,6 +196,7 @@ lp_scene_begin_rasterization(struct lp_scene *scene) zsbuf->u.tex.level, zsbuf->u.tex.first_layer, LP_TEX_USAGE_READ_WRITE); + scene->zsbuf.format_bytes = util_format_get_blocksize(zsbuf->format); } } diff --git a/src/gallium/drivers/llvmpipe/lp_scene.h b/src/gallium/drivers/llvmpipe/lp_scene.h index 19a3811..ad23c20 100644 --- a/src/gallium/drivers/llvmpipe/lp_scene.h +++ b/src/gallium/drivers/llvmpipe/lp_scene.h @@ -142,6 +142,7 @@ struct lp_scene { uint8_t *map; unsigned stride; unsigned layer_stride; + unsigned format_bytes; } zsbuf, cbufs[PIPE_MAX_COLOR_BUFS]; /* The amount of layers in the fb (minimum of all attachments) */ From bwidawsk at kemper.freedesktop.org Sat Mar 28 04:05:02 2015 From: bwidawsk at kemper.freedesktop.org (Ben Widawsky) Date: Fri, 27 Mar 2015 21:05:02 -0700 (PDT) Subject: Mesa (master): i965/skl: Disable partial resolve in VC Message-ID: <20150328040502.AB78B76333@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 9d32d358500733249d3c0264c7458c2e5a65f515 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=9d32d358500733249d3c0264c7458c2e5a65f515 Author: Ben Widawsky Date: Thu Feb 26 18:14:17 2015 -0800 i965/skl: Disable partial resolve in VC Recomendation [sic] is to set this field to 1 always. Programming it to default value of 0, may have -ve impact on performance for MSAA WLs. Another don't suck bit which needs to get set. The patch wasn't as well tested as I would have liked, primarily I don't have perf numbers for it, but it's getting to a point where it is in danger of being lost. v2: v1 was a mix of two patches. Since 0x7004 is masked, we only need to set it once at initialization and make sure the pma workaround doesn't set the mask bit (which it doesn't). Move LRI to init gpu state (Ken) Add a comment. Signed-off-by: Ben Widawsky Reviewed-by: Kenneth Graunke Reviewed-by: Anuj Phogat --- src/mesa/drivers/dri/i965/brw_state_upload.c | 10 ++++++++++ src/mesa/drivers/dri/i965/intel_reg.h | 1 + 2 files changed, 11 insertions(+) diff --git a/src/mesa/drivers/dri/i965/brw_state_upload.c b/src/mesa/drivers/dri/i965/brw_state_upload.c index 1b84859..e446de6 100644 --- a/src/mesa/drivers/dri/i965/brw_state_upload.c +++ b/src/mesa/drivers/dri/i965/brw_state_upload.c @@ -337,6 +337,16 @@ brw_upload_initial_gpu_state(struct brw_context *brw) brw_upload_invariant_state(brw); + /* Recommended optimization for Victim Cache eviction in pixel backend. */ + if (brw->gen >= 9) { + BEGIN_BATCH(3); + OUT_BATCH(MI_LOAD_REGISTER_IMM | (3 - 2)); + OUT_BATCH(GEN7_CACHE_MODE_1); + OUT_BATCH((GEN9_PARTIAL_RESOLVE_DISABLE_IN_VC << 16) | + GEN9_PARTIAL_RESOLVE_DISABLE_IN_VC); + ADVANCE_BATCH(); + } + if (brw->gen >= 8) { gen8_emit_3dstate_sample_pattern(brw); } diff --git a/src/mesa/drivers/dri/i965/intel_reg.h b/src/mesa/drivers/dri/i965/intel_reg.h index e5730e2..488fb5b 100644 --- a/src/mesa/drivers/dri/i965/intel_reg.h +++ b/src/mesa/drivers/dri/i965/intel_reg.h @@ -144,5 +144,6 @@ #define GEN7_CACHE_MODE_1 0x7004 # define GEN8_HIZ_NP_PMA_FIX_ENABLE (1 << 11) # define GEN8_HIZ_NP_EARLY_Z_FAILS_DISABLE (1 << 13) +# define GEN9_PARTIAL_RESOLVE_DISABLE_IN_VC (1 << 1) # define GEN8_HIZ_PMA_MASK_BITS \ ((GEN8_HIZ_NP_PMA_FIX_ENABLE | GEN8_HIZ_NP_EARLY_Z_FAILS_DISABLE) << 16) From bwidawsk at kemper.freedesktop.org Sat Mar 28 04:05:02 2015 From: bwidawsk at kemper.freedesktop.org (Ben Widawsky) Date: Fri, 27 Mar 2015 21:05:02 -0700 (PDT) Subject: Mesa (master): i965/skl: Don't use the PMA depth stall workaround Message-ID: <20150328040502.BC1937635A@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 74fd226e34d0cf5e9ff43174ae69b4a66f5de1ab URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=74fd226e34d0cf5e9ff43174ae69b4a66f5de1ab Author: Ben Widawsky Date: Wed Mar 25 16:52:46 2015 -0700 i965/skl: Don't use the PMA depth stall workaround The PMA depth stall must be enabled (optimization turned off) under certain circumstances on gen8. This was supposedly fixed for Gen9, which means we do not need to check, or toggle the state. The hardware is supposed to enable the hardware optimization by default, unlike BDW, so we also don't need to set it at init. For whatever reason this improves stability on ETQW with the bug mentioned below. References: https://bugs.freedesktop.org/show_bug.cgi?id=89039 (doesn't fix) Signed-off-by: Ben Widawsky Tested-by: Anuj Phogat Reviewed-by: Kenneth Graunke --- src/mesa/drivers/dri/i965/gen8_depth_state.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/mesa/drivers/dri/i965/gen8_depth_state.c b/src/mesa/drivers/dri/i965/gen8_depth_state.c index c6494c9..3d126cf 100644 --- a/src/mesa/drivers/dri/i965/gen8_depth_state.c +++ b/src/mesa/drivers/dri/i965/gen8_depth_state.c @@ -368,6 +368,10 @@ static void gen8_emit_pma_stall_workaround(struct brw_context *brw) { uint32_t bits = 0; + + if (brw->gen >= 9) + return; + if (pma_fix_enable(brw)) bits |= GEN8_HIZ_NP_PMA_FIX_ENABLE | GEN8_HIZ_NP_EARLY_Z_FAILS_DISABLE; @@ -400,7 +404,8 @@ gen8_hiz_exec(struct brw_context *brw, struct intel_mipmap_tree *mt, return; /* Disable the PMA stall fix since we're about to do a HiZ operation. */ - write_pma_stall_bits(brw, 0); + if (brw->gen == 8) + write_pma_stall_bits(brw, 0); assert(mt->first_level == 0); assert(mt->logical_depth0 >= 1); From kwg at kemper.freedesktop.org Sat Mar 28 04:21:17 2015 From: kwg at kemper.freedesktop.org (Kenneth Graunke) Date: Fri, 27 Mar 2015 21:21:17 -0700 (PDT) Subject: Mesa (master): nir: Add nir_builder helpers for creating load_const intrinsics. Message-ID: <20150328042117.BCB6676333@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 75c922e0fed41acf28318b082f7f915c752ffe74 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=75c922e0fed41acf28318b082f7f915c752ffe74 Author: Kenneth Graunke Date: Wed Mar 25 02:11:52 2015 -0700 nir: Add nir_builder helpers for creating load_const intrinsics. Both prog->nir and tgsi->nir will want to use these. Signed-off-by: Kenneth Graunke Reviewed-by: Connor Abbott Reviewed-by: Eric Anholt --- src/glsl/nir/nir_builder.h | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/src/glsl/nir/nir_builder.h b/src/glsl/nir/nir_builder.h index 7c4f7fd..fe6cb37 100644 --- a/src/glsl/nir/nir_builder.h +++ b/src/glsl/nir/nir_builder.h @@ -47,6 +47,41 @@ nir_builder_insert_after_cf_list(nir_builder *build, build->cf_node_list = cf_node_list; } +static inline nir_ssa_def * +nir_build_imm(nir_builder *build, unsigned num_components, nir_const_value value) +{ + nir_load_const_instr *load_const = + nir_load_const_instr_create(build->shader, num_components); + if (!load_const) + return NULL; + + load_const->value = value; + + nir_instr_insert_after_cf_list(build->cf_node_list, &load_const->instr); + + return &load_const->def; +} + +static inline nir_ssa_def * +nir_imm_float(nir_builder *build, float x) +{ + nir_const_value v = { { .f = {x, 0, 0, 0} } }; + return nir_build_imm(build, 1, v); +} + +static inline nir_ssa_def * +nir_imm_vec4(nir_builder *build, float x, float y, float z, float w) +{ + nir_const_value v = { { .f = {x, y, z, w} } }; + return nir_build_imm(build, 4, v); +} + +static inline nir_ssa_def * +nir_imm_int(nir_builder *build, int x) +{ + nir_const_value v = { { .i = {x, 0, 0, 0} } }; + return nir_build_imm(build, 1, v); +} static inline nir_ssa_def * nir_build_alu(nir_builder *build, nir_op op, nir_ssa_def *src0, From kwg at kemper.freedesktop.org Sat Mar 28 04:21:17 2015 From: kwg at kemper.freedesktop.org (Kenneth Graunke) Date: Fri, 27 Mar 2015 21:21:17 -0700 (PDT) Subject: Mesa (master): nir: Implement a Mesa IR -> NIR translator. Message-ID: <20150328042117.D50BB76333@kemper.freedesktop.org> Module: Mesa Branch: master Commit: faf6106c6f6fa2ba90ec175baaa8b54bec9f5125 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=faf6106c6f6fa2ba90ec175baaa8b54bec9f5125 Author: Kenneth Graunke Date: Thu Jan 29 23:22:08 2015 -0800 nir: Implement a Mesa IR -> NIR translator. Shamelessly ripped off from Eric Anholt's tgsi_to_nir pass. This is not built on SCons, like the rest of NIR. v2: - Delete redundant c->s, c->impl, and c->cf_node_list pointers (Ken) - Use nir_builder directly instead of ptn_compile in more places (Ken) - Drop 'struct' keyword in front of nir_builder (ken) - Add a file level Doxygen comment (Ken) - Use scalar constants instead of splatting (Eric) - Use nir_builder helpers for constants, moves, and swizzles (Connor) v3: Minor indentation improvements. Signed-off-by: Kenneth Graunke Reviewed-by: Eric Anholt --- src/mesa/Makefile.am | 2 + src/mesa/Makefile.sources | 5 + src/mesa/program/prog_instruction.h | 2 + src/mesa/program/prog_to_nir.c | 1097 +++++++++++++++++++++++++++++++++++ src/mesa/program/prog_to_nir.h | 37 ++ 5 files changed, 1143 insertions(+) diff --git a/src/mesa/Makefile.am b/src/mesa/Makefile.am index 3dab8f0..60114e4 100644 --- a/src/mesa/Makefile.am +++ b/src/mesa/Makefile.am @@ -174,6 +174,7 @@ endif libmesa_la_SOURCES = \ $(MESA_FILES) \ $(PROGRAM_FILES) \ + $(PROGRAM_NIR_FILES) \ $(MESA_ASM_FILES_FOR_ARCH) libmesa_la_LIBADD = \ @@ -183,6 +184,7 @@ libmesa_la_LIBADD = \ libmesagallium_la_SOURCES = \ $(MESA_GALLIUM_FILES) \ $(PROGRAM_FILES) \ + $(PROGRAM_NIR_FILES) \ $(MESA_ASM_FILES_FOR_ARCH) libmesagallium_la_LIBADD = \ diff --git a/src/mesa/Makefile.sources b/src/mesa/Makefile.sources index 217be9a..cc166ce 100644 --- a/src/mesa/Makefile.sources +++ b/src/mesa/Makefile.sources @@ -520,6 +520,10 @@ PROGRAM_FILES = \ program/symbol_table.c \ program/symbol_table.h +PROGRAM_NIR_FILES = \ + program/prog_to_nir.c \ + program/prog_to_nir.h + ASM_C_FILES = \ x86/common_x86.c \ x86/x86_xform.c \ @@ -608,6 +612,7 @@ INCLUDE_DIRS = \ -I$(top_srcdir)/src \ -I$(top_srcdir)/src/glsl \ -I$(top_builddir)/src/glsl \ + -I$(top_builddir)/src/glsl/nir \ -I$(top_srcdir)/src/glsl/glcpp \ -I$(top_srcdir)/src/mesa \ -I$(top_builddir)/src/mesa \ diff --git a/src/mesa/program/prog_instruction.h b/src/mesa/program/prog_instruction.h index ab3acbc..96da198 100644 --- a/src/mesa/program/prog_instruction.h +++ b/src/mesa/program/prog_instruction.h @@ -59,6 +59,8 @@ #define SWIZZLE_NOOP MAKE_SWIZZLE4(0,1,2,3) #define GET_SWZ(swz, idx) (((swz) >> ((idx)*3)) & 0x7) #define GET_BIT(msk, idx) (((msk) >> (idx)) & 0x1) +/** Determine if swz contains SWIZZLE_ZERO/ONE/NIL for any components. */ +#define HAS_EXTENDED_SWIZZLE(swz) (swz & 0x924) #define SWIZZLE_XYZW MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Z, SWIZZLE_W) #define SWIZZLE_XXXX MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_X, SWIZZLE_X, SWIZZLE_X) diff --git a/src/mesa/program/prog_to_nir.c b/src/mesa/program/prog_to_nir.c new file mode 100644 index 0000000..d0e6110 --- /dev/null +++ b/src/mesa/program/prog_to_nir.c @@ -0,0 +1,1097 @@ +/* + * Copyright ? 2015 Intel Corporation + * Copyright ? 2014-2015 Broadcom + * Copyright (C) 2014 Rob Clark + * + * 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 "nir/nir.h" +#include "nir/nir_builder.h" +#include "glsl/list.h" +#include "main/imports.h" +#include "util/ralloc.h" + +#include "prog_to_nir.h" +#include "prog_instruction.h" +#include "prog_parameter.h" +#include "prog_print.h" + +/** + * \file prog_to_nir.c + * + * A translator from Mesa IR (prog_instruction.h) to NIR. This is primarily + * intended to support ARB_vertex_program, ARB_fragment_program, and fixed-function + * vertex processing. Full GLSL support should use glsl_to_nir instead. + */ + +struct ptn_compile { + struct gl_program *prog; + nir_builder build; + bool error; + + nir_variable *input_vars[VARYING_SLOT_MAX]; + nir_variable *output_vars[VARYING_SLOT_MAX]; + nir_register **output_regs; + nir_register **temp_regs; + + nir_register *addr_reg; +}; + +#define SWIZ(X, Y, Z, W) \ + (unsigned[4]){ SWIZZLE_##X, SWIZZLE_##Y, SWIZZLE_##Z, SWIZZLE_##W } +#define ptn_swizzle(b, src, x, y, z, w) nir_swizzle(b, src, SWIZ(x, y, z, w), 4, true) +#define ptn_channel(b, src, ch) nir_swizzle(b, src, SWIZ(ch, ch, ch, ch), 1, true) + +static nir_ssa_def * +ptn_src_for_dest(struct ptn_compile *c, nir_alu_dest *dest) +{ + nir_builder *b = &c->build; + + nir_alu_src src; + memset(&src, 0, sizeof(src)); + + if (dest->dest.is_ssa) + src.src = nir_src_for_ssa(&dest->dest.ssa); + else { + assert(!dest->dest.reg.indirect); + src.src = nir_src_for_reg(dest->dest.reg.reg); + src.src.reg.base_offset = dest->dest.reg.base_offset; + } + + for (int i = 0; i < 4; i++) + src.swizzle[i] = i; + + return nir_fmov_alu(b, src, 4); +} + +static nir_alu_dest +ptn_get_dest(struct ptn_compile *c, const struct prog_dst_register *prog_dst) +{ + nir_alu_dest dest; + + memset(&dest, 0, sizeof(dest)); + + switch (prog_dst->File) { + case PROGRAM_TEMPORARY: + dest.dest.reg.reg = c->temp_regs[prog_dst->Index]; + break; + case PROGRAM_OUTPUT: + dest.dest.reg.reg = c->output_regs[prog_dst->Index]; + break; + case PROGRAM_ADDRESS: + assert(prog_dst->Index == 0); + dest.dest.reg.reg = c->addr_reg; + break; + case PROGRAM_UNDEFINED: + break; + } + + dest.write_mask = prog_dst->WriteMask; + dest.saturate = false; + + assert(!prog_dst->RelAddr); + + return dest; +} + +/** + * Multiply the contents of the ADDR register by 4 to convert from the number + * of vec4s to the number of floating point components. + */ +static nir_ssa_def * +ptn_addr_reg_value(struct ptn_compile *c) +{ + nir_builder *b = &c->build; + nir_alu_src src; + memset(&src, 0, sizeof(src)); + src.src = nir_src_for_reg(c->addr_reg); + + return nir_imul(b, nir_fmov_alu(b, src, 1), nir_imm_int(b, 4)); +} + +static nir_ssa_def * +ptn_get_src(struct ptn_compile *c, const struct prog_src_register *prog_src) +{ + nir_builder *b = &c->build; + nir_alu_src src; + + memset(&src, 0, sizeof(src)); + + switch (prog_src->File) { + case PROGRAM_UNDEFINED: + return nir_imm_float(b, 0.0); + case PROGRAM_TEMPORARY: + assert(!prog_src->RelAddr && prog_src->Index >= 0); + src.src.reg.reg = c->temp_regs[prog_src->Index]; + break; + case PROGRAM_INPUT: { + /* ARB_vertex_program doesn't allow relative addressing on vertex + * attributes; ARB_fragment_program has no relative addressing at all. + */ + assert(!prog_src->RelAddr); + + assert(prog_src->Index >= 0 && prog_src->Index < VARYING_SLOT_MAX); + + nir_intrinsic_instr *load = + nir_intrinsic_instr_create(b->shader, nir_intrinsic_load_var); + load->num_components = 4; + load->variables[0] = + nir_deref_var_create(b->shader, c->input_vars[prog_src->Index]); + + nir_ssa_dest_init(&load->instr, &load->dest, 4, NULL); + nir_instr_insert_after_cf_list(b->cf_node_list, &load->instr); + + src.src = nir_src_for_ssa(&load->dest.ssa); + break; + } + case PROGRAM_STATE_VAR: + case PROGRAM_CONSTANT: { + /* We actually want to look at the type in the Parameters list for this, + * because it lets us upload constant builtin uniforms as actual + * constants. + */ + struct gl_program_parameter_list *plist = c->prog->Parameters; + gl_register_file file = prog_src->RelAddr ? prog_src->File : + plist->Parameters[prog_src->Index].Type; + + switch (file) { + case PROGRAM_CONSTANT: + if ((c->prog->IndirectRegisterFiles & (1 << PROGRAM_CONSTANT)) == 0) { + float *v = (float *) plist->ParameterValues[prog_src->Index]; + src.src = nir_src_for_ssa(nir_imm_vec4(b, v[0], v[1], v[2], v[3])); + break; + } + /* FALLTHROUGH */ + case PROGRAM_STATE_VAR: { + nir_intrinsic_op load_op = + prog_src->RelAddr ? nir_intrinsic_load_uniform_indirect : + nir_intrinsic_load_uniform; + nir_intrinsic_instr *load = nir_intrinsic_instr_create(b->shader, load_op); + nir_ssa_dest_init(&load->instr, &load->dest, 4, NULL); + load->num_components = 4; + + /* Multiply src->Index by 4 to scale from # of vec4s to components. */ + load->const_index[0] = 4 * prog_src->Index; + load->const_index[1] = 1; + + if (prog_src->RelAddr) { + nir_ssa_def *reladdr = ptn_addr_reg_value(c); + if (prog_src->Index < 0) { + /* This is a negative offset which should be added to the address + * register's value. + */ + reladdr = nir_iadd(b, reladdr, nir_imm_int(b, load->const_index[0])); + load->const_index[0] = 0; + } + load->src[0] = nir_src_for_ssa(reladdr); + } + + nir_instr_insert_after_cf_list(b->cf_node_list, &load->instr); + + src.src = nir_src_for_ssa(&load->dest.ssa); + break; + } + default: + fprintf(stderr, "bad uniform src register file: %s (%d)\n", + _mesa_register_file_name(file), file); + abort(); + } + break; + } + default: + fprintf(stderr, "unknown src register file: %s (%d)\n", + _mesa_register_file_name(prog_src->File), prog_src->File); + abort(); + } + + nir_ssa_def *def; + if (!HAS_EXTENDED_SWIZZLE(prog_src->Swizzle)) { + for (int i = 0; i < 4; i++) + src.swizzle[i] = GET_SWZ(prog_src->Swizzle, i); + + def = nir_fmov_alu(b, src, 4); + } else { + nir_ssa_def *chans[4]; + for (int i = 0; i < 4; i++) { + int swizzle = GET_SWZ(prog_src->Swizzle, i); + if (swizzle == SWIZZLE_ZERO) { + chans[i] = nir_imm_float(b, 0.0); + } else if (swizzle == SWIZZLE_ONE) { + chans[i] = nir_imm_float(b, 1.0); + } else { + assert(swizzle != SWIZZLE_NIL); + nir_alu_instr *mov = nir_alu_instr_create(b->shader, nir_op_fmov); + nir_ssa_dest_init(&mov->instr, &mov->dest.dest, 1, NULL); + mov->dest.write_mask = 0x1; + mov->src[0] = src; + mov->src[0].swizzle[0] = swizzle; + nir_instr_insert_after_cf_list(b->cf_node_list, &mov->instr); + + chans[i] = &mov->dest.dest.ssa; + } + } + def = nir_vec4(b, chans[0], chans[1], chans[2], chans[3]); + } + + if (prog_src->Abs) + def = nir_fabs(b, def); + + if (prog_src->Negate) + def = nir_fneg(b, def); + + return def; +} + +static void +ptn_alu(nir_builder *b, nir_op op, nir_alu_dest dest, nir_ssa_def **src) +{ + unsigned num_srcs = nir_op_infos[op].num_inputs; + nir_alu_instr *instr = nir_alu_instr_create(b->shader, op); + unsigned i; + + for (i = 0; i < num_srcs; i++) + instr->src[i].src = nir_src_for_ssa(src[i]); + + instr->dest = dest; + nir_instr_insert_after_cf_list(b->cf_node_list, &instr->instr); +} + +static void +ptn_move_dest_masked(nir_builder *b, nir_alu_dest dest, + nir_ssa_def *def, unsigned write_mask) +{ + if (!(dest.write_mask & write_mask)) + return; + + nir_alu_instr *mov = nir_alu_instr_create(b->shader, nir_op_fmov); + if (!mov) + return; + + mov->dest = dest; + mov->dest.write_mask &= write_mask; + mov->src[0].src = nir_src_for_ssa(def); + for (unsigned i = def->num_components; i < 4; i++) + mov->src[0].swizzle[i] = def->num_components - 1; + nir_instr_insert_after_cf_list(b->cf_node_list, &mov->instr); +} + +static void +ptn_move_dest(nir_builder *b, nir_alu_dest dest, nir_ssa_def *def) +{ + ptn_move_dest_masked(b, dest, def, WRITEMASK_XYZW); +} + +static void +ptn_arl(nir_builder *b, nir_alu_dest dest, nir_ssa_def **src) +{ + ptn_move_dest(b, dest, nir_f2i(b, nir_ffloor(b, src[0]))); +} + +/* EXP - Approximate Exponential Base 2 + * dst.x = 2^{\lfloor src.x\rfloor} + * dst.y = src.x - \lfloor src.x\rfloor + * dst.z = 2^{src.x} + * dst.w = 1.0 + */ +static void +ptn_exp(nir_builder *b, nir_alu_dest dest, nir_ssa_def **src) +{ + nir_ssa_def *srcx = ptn_channel(b, src[0], X); + + ptn_move_dest_masked(b, dest, nir_fexp2(b, nir_ffloor(b, srcx)), WRITEMASK_X); + ptn_move_dest_masked(b, dest, nir_fsub(b, srcx, nir_ffloor(b, srcx)), WRITEMASK_Y); + ptn_move_dest_masked(b, dest, nir_fexp2(b, srcx), WRITEMASK_Z); + ptn_move_dest_masked(b, dest, nir_imm_float(b, 1.0), WRITEMASK_W); +} + +/* LOG - Approximate Logarithm Base 2 + * dst.x = \lfloor\log_2{|src.x|}\rfloor + * dst.y = |src.x| * 2^{-\lfloor\log_2{|src.x|}\rfloor}} + * dst.z = \log_2{|src.x|} + * dst.w = 1.0 + */ +static void +ptn_log(nir_builder *b, nir_alu_dest dest, nir_ssa_def **src) +{ + nir_ssa_def *abs_srcx = nir_fabs(b, ptn_channel(b, src[0], X)); + nir_ssa_def *log2 = nir_flog2(b, abs_srcx); + nir_ssa_def *floor_log2 = nir_ffloor(b, log2); + + ptn_move_dest_masked(b, dest, floor_log2, WRITEMASK_X); + ptn_move_dest_masked(b, dest, + nir_fmul(b, abs_srcx, + nir_fexp2(b, nir_fneg(b, floor_log2))), + WRITEMASK_Y); + ptn_move_dest_masked(b, dest, log2, WRITEMASK_Z); + ptn_move_dest_masked(b, dest, nir_imm_float(b, 1.0), WRITEMASK_W); +} + +/* DST - Distance Vector + * dst.x = 1.0 + * dst.y = src0.y \times src1.y + * dst.z = src0.z + * dst.w = src1.w + */ +static void +ptn_dst(nir_builder *b, nir_alu_dest dest, nir_ssa_def **src) +{ + ptn_move_dest_masked(b, dest, nir_imm_float(b, 1.0), WRITEMASK_X); + ptn_move_dest_masked(b, dest, nir_fmul(b, src[0], src[1]), WRITEMASK_Y); + ptn_move_dest_masked(b, dest, nir_fmov(b, src[0]), WRITEMASK_Z); + ptn_move_dest_masked(b, dest, nir_fmov(b, src[1]), WRITEMASK_W); +} + +/* LIT - Light Coefficients + * dst.x = 1.0 + * dst.y = max(src.x, 0.0) + * dst.z = (src.x > 0.0) ? max(src.y, 0.0)^{clamp(src.w, -128.0, 128.0))} : 0 + * dst.w = 1.0 + */ +static void +ptn_lit(nir_builder *b, nir_alu_dest dest, nir_ssa_def **src) +{ + ptn_move_dest_masked(b, dest, nir_imm_float(b, 1.0), WRITEMASK_XW); + + ptn_move_dest_masked(b, dest, nir_fmax(b, ptn_channel(b, src[0], X), + nir_imm_float(b, 0.0)), WRITEMASK_Y); + + if (dest.write_mask & WRITEMASK_Z) { + nir_ssa_def *src0_y = ptn_channel(b, src[0], Y); + nir_ssa_def *wclamp = nir_fmax(b, nir_fmin(b, ptn_channel(b, src[0], W), + nir_imm_float(b, 128.0)), + nir_imm_float(b, -128.0)); + nir_ssa_def *pow = nir_fpow(b, nir_fmax(b, src0_y, nir_imm_float(b, 0.0)), + wclamp); + + nir_ssa_def *z; + if (b->shader->options->native_integers) { + z = nir_bcsel(b, + nir_fge(b, nir_imm_float(b, 0.0), ptn_channel(b, src[0], X)), + nir_imm_float(b, 0.0), + pow); + } else { + z = nir_fcsel(b, + nir_sge(b, nir_imm_float(b, 0.0), ptn_channel(b, src[0], X)), + nir_imm_float(b, 0.0), + pow); + } + + ptn_move_dest_masked(b, dest, z, WRITEMASK_Z); + } +} + +/* SCS - Sine Cosine + * dst.x = \cos{src.x} + * dst.y = \sin{src.x} + * dst.z = 0.0 + * dst.w = 1.0 + */ +static void +ptn_scs(nir_builder *b, nir_alu_dest dest, nir_ssa_def **src) +{ + ptn_move_dest_masked(b, dest, nir_fcos(b, ptn_channel(b, src[0], X)), + WRITEMASK_X); + ptn_move_dest_masked(b, dest, nir_fsin(b, ptn_channel(b, src[0], X)), + WRITEMASK_Y); + ptn_move_dest_masked(b, dest, nir_imm_float(b, 0.0), WRITEMASK_Z); + ptn_move_dest_masked(b, dest, nir_imm_float(b, 1.0), WRITEMASK_W); +} + +/** + * Emit SLT. For platforms with integers, prefer b2f(flt(...)). + */ +static void +ptn_slt(nir_builder *b, nir_alu_dest dest, nir_ssa_def **src) +{ + if (b->shader->options->native_integers) { + ptn_move_dest(b, dest, nir_b2f(b, nir_flt(b, src[0], src[1]))); + } else { + ptn_move_dest(b, dest, nir_slt(b, src[0], src[1])); + } +} + +/** + * Emit SGE. For platforms with integers, prefer b2f(fge(...)). + */ +static void +ptn_sge(nir_builder *b, nir_alu_dest dest, nir_ssa_def **src) +{ + if (b->shader->options->native_integers) { + ptn_move_dest(b, dest, nir_b2f(b, nir_fge(b, src[0], src[1]))); + } else { + ptn_move_dest(b, dest, nir_sge(b, src[0], src[1])); + } +} + +static void +ptn_sle(nir_builder *b, nir_alu_dest dest, nir_ssa_def **src) +{ + nir_ssa_def *commuted[] = { src[1], src[0] }; + ptn_sge(b, dest, commuted); +} + +static void +ptn_sgt(nir_builder *b, nir_alu_dest dest, nir_ssa_def **src) +{ + nir_ssa_def *commuted[] = { src[1], src[0] }; + ptn_slt(b, dest, commuted); +} + +/** + * Emit SEQ. For platforms with integers, prefer b2f(feq(...)). + */ +static void +ptn_seq(nir_builder *b, nir_alu_dest dest, nir_ssa_def **src) +{ + if (b->shader->options->native_integers) { + ptn_move_dest(b, dest, nir_b2f(b, nir_feq(b, src[0], src[1]))); + } else { + ptn_move_dest(b, dest, nir_seq(b, src[0], src[1])); + } +} + +/** + * Emit SNE. For platforms with integers, prefer b2f(fne(...)). + */ +static void +ptn_sne(nir_builder *b, nir_alu_dest dest, nir_ssa_def **src) +{ + if (b->shader->options->native_integers) { + ptn_move_dest(b, dest, nir_b2f(b, nir_fne(b, src[0], src[1]))); + } else { + ptn_move_dest(b, dest, nir_sne(b, src[0], src[1])); + } +} + +static void +ptn_xpd(nir_builder *b, nir_alu_dest dest, nir_ssa_def **src) +{ + ptn_move_dest_masked(b, dest, + nir_fsub(b, + nir_fmul(b, + ptn_swizzle(b, src[0], Y, Z, X, X), + ptn_swizzle(b, src[1], Z, X, Y, X)), + nir_fmul(b, + ptn_swizzle(b, src[1], Y, Z, X, X), + ptn_swizzle(b, src[0], Z, X, Y, X))), + WRITEMASK_XYZ); + ptn_move_dest_masked(b, dest, nir_imm_float(b, 1.0), WRITEMASK_W); +} + +static void +ptn_dp2(nir_builder *b, nir_alu_dest dest, nir_ssa_def **src) +{ + ptn_move_dest(b, dest, ptn_channel(b, nir_fdot2(b, src[0], src[1]), X)); +} + +static void +ptn_dp3(nir_builder *b, nir_alu_dest dest, nir_ssa_def **src) +{ + ptn_move_dest(b, dest, ptn_channel(b, nir_fdot3(b, src[0], src[1]), X)); +} + +static void +ptn_dp4(nir_builder *b, nir_alu_dest dest, nir_ssa_def **src) +{ + ptn_move_dest(b, dest, ptn_channel(b, nir_fdot4(b, src[0], src[1]), X)); +} + +static void +ptn_dph(nir_builder *b, nir_alu_dest dest, nir_ssa_def **src) +{ + nir_ssa_def *dp3 = ptn_channel(b, nir_fdot3(b, src[0], src[1]), X); + ptn_move_dest(b, dest, nir_fadd(b, dp3, ptn_channel(b, src[1], W))); +} + +static void +ptn_cmp(nir_builder *b, nir_alu_dest dest, nir_ssa_def **src) +{ + if (b->shader->options->native_integers) { + ptn_move_dest(b, dest, nir_bcsel(b, + nir_flt(b, src[0], nir_imm_float(b, 0.0)), + src[1], src[2])); + } else { + ptn_move_dest(b, dest, nir_fcsel(b, + nir_slt(b, src[0], nir_imm_float(b, 0.0)), + src[1], src[2])); + } +} + +static void +ptn_lrp(nir_builder *b, nir_alu_dest dest, nir_ssa_def **src) +{ + ptn_move_dest(b, dest, nir_flrp(b, src[2], src[1], src[0])); +} + +static void +ptn_kil(nir_builder *b, nir_alu_dest dest, nir_ssa_def **src) +{ + nir_ssa_def *cmp = b->shader->options->native_integers ? + nir_bany4(b, nir_flt(b, src[0], nir_imm_float(b, 0.0))) : + nir_fany4(b, nir_slt(b, src[0], nir_imm_float(b, 0.0))); + + nir_intrinsic_instr *discard = + nir_intrinsic_instr_create(b->shader, nir_intrinsic_discard_if); + discard->src[0] = nir_src_for_ssa(cmp); + nir_instr_insert_after_cf_list(b->cf_node_list, &discard->instr); +} + +static void +ptn_tex(nir_builder *b, nir_alu_dest dest, nir_ssa_def **src, + struct prog_instruction *prog_inst) +{ + nir_tex_instr *instr; + nir_texop op; + unsigned num_srcs; + + switch (prog_inst->Opcode) { + case OPCODE_TEX: + op = nir_texop_tex; + num_srcs = 1; + break; + case OPCODE_TXB: + op = nir_texop_txb; + num_srcs = 2; + break; + case OPCODE_TXD: + op = nir_texop_txd; + num_srcs = 3; + break; + case OPCODE_TXL: + op = nir_texop_txl; + num_srcs = 2; + break; + case OPCODE_TXP: + op = nir_texop_tex; + num_srcs = 2; + break; + case OPCODE_TXP_NV: + assert(!"not handled"); + op = nir_texop_tex; + num_srcs = 2; + break; + default: + fprintf(stderr, "unknown tex op %d\n", prog_inst->Opcode); + abort(); + } + + if (prog_inst->TexShadow) + num_srcs++; + + instr = nir_tex_instr_create(b->shader, num_srcs); + instr->op = op; + instr->dest_type = nir_type_float; + instr->is_shadow = prog_inst->TexShadow; + instr->sampler_index = prog_inst->TexSrcUnit; + + switch (prog_inst->TexSrcTarget) { + case TEXTURE_1D_INDEX: + instr->sampler_dim = GLSL_SAMPLER_DIM_1D; + break; + case TEXTURE_2D_INDEX: + instr->sampler_dim = GLSL_SAMPLER_DIM_2D; + break; + case TEXTURE_3D_INDEX: + instr->sampler_dim = GLSL_SAMPLER_DIM_3D; + break; + case TEXTURE_CUBE_INDEX: + instr->sampler_dim = GLSL_SAMPLER_DIM_CUBE; + break; + case TEXTURE_RECT_INDEX: + instr->sampler_dim = GLSL_SAMPLER_DIM_RECT; + break; + default: + fprintf(stderr, "Unknown texture target %d\n", prog_inst->TexSrcTarget); + abort(); + } + + switch (instr->sampler_dim) { + case GLSL_SAMPLER_DIM_1D: + case GLSL_SAMPLER_DIM_BUF: + instr->coord_components = 1; + break; + case GLSL_SAMPLER_DIM_2D: + case GLSL_SAMPLER_DIM_RECT: + case GLSL_SAMPLER_DIM_EXTERNAL: + case GLSL_SAMPLER_DIM_MS: + instr->coord_components = 2; + break; + case GLSL_SAMPLER_DIM_3D: + case GLSL_SAMPLER_DIM_CUBE: + instr->coord_components = 3; + break; + } + + unsigned src_number = 0; + + instr->src[src_number].src = + nir_src_for_ssa(ptn_swizzle(b, src[0], X, Y, Z, W)); + instr->src[src_number].src_type = nir_tex_src_coord; + src_number++; + + if (prog_inst->Opcode == OPCODE_TXP) { + instr->src[src_number].src = nir_src_for_ssa(ptn_channel(b, src[0], W)); + instr->src[src_number].src_type = nir_tex_src_projector; + src_number++; + } + + if (prog_inst->Opcode == OPCODE_TXB) { + instr->src[src_number].src = nir_src_for_ssa(ptn_channel(b, src[0], W)); + instr->src[src_number].src_type = nir_tex_src_bias; + src_number++; + } + + if (prog_inst->Opcode == OPCODE_TXL) { + instr->src[src_number].src = nir_src_for_ssa(ptn_channel(b, src[0], W)); + instr->src[src_number].src_type = nir_tex_src_lod; + src_number++; + } + + if (instr->is_shadow) { + if (instr->coord_components < 3) + instr->src[src_number].src = nir_src_for_ssa(ptn_channel(b, src[0], Z)); + else + instr->src[src_number].src = nir_src_for_ssa(ptn_channel(b, src[0], W)); + + instr->src[src_number].src_type = nir_tex_src_comparitor; + src_number++; + } + + assert(src_number == num_srcs); + + nir_ssa_dest_init(&instr->instr, &instr->dest, 4, NULL); + nir_instr_insert_after_cf_list(b->cf_node_list, &instr->instr); + + /* Resolve the writemask on the texture op. */ + ptn_move_dest(b, dest, &instr->dest.ssa); +} + +static const nir_op op_trans[MAX_OPCODE] = { + [OPCODE_NOP] = 0, + [OPCODE_ABS] = nir_op_fabs, + [OPCODE_ADD] = nir_op_fadd, + [OPCODE_ARL] = 0, + [OPCODE_CMP] = 0, + [OPCODE_COS] = nir_op_fcos, + [OPCODE_DDX] = nir_op_fddx, + [OPCODE_DDY] = nir_op_fddy, + [OPCODE_DP2] = 0, + [OPCODE_DP3] = 0, + [OPCODE_DP4] = 0, + [OPCODE_DPH] = 0, + [OPCODE_DST] = 0, + [OPCODE_END] = 0, + [OPCODE_EX2] = nir_op_fexp2, + [OPCODE_EXP] = nir_op_fexp, + [OPCODE_FLR] = nir_op_ffloor, + [OPCODE_FRC] = nir_op_ffract, + [OPCODE_LG2] = nir_op_flog2, + [OPCODE_LIT] = 0, + [OPCODE_LOG] = 0, + [OPCODE_LRP] = 0, + [OPCODE_MAD] = nir_op_ffma, + [OPCODE_MAX] = nir_op_fmax, + [OPCODE_MIN] = nir_op_fmin, + [OPCODE_MOV] = nir_op_fmov, + [OPCODE_MUL] = nir_op_fmul, + [OPCODE_POW] = nir_op_fpow, + [OPCODE_RCP] = nir_op_frcp, + + [OPCODE_RSQ] = nir_op_frsq, + [OPCODE_SCS] = 0, + [OPCODE_SEQ] = 0, + [OPCODE_SGE] = 0, + [OPCODE_SGT] = 0, + [OPCODE_SIN] = nir_op_fsin, + [OPCODE_SLE] = 0, + [OPCODE_SLT] = 0, + [OPCODE_SNE] = 0, + [OPCODE_SSG] = nir_op_fsign, + [OPCODE_SUB] = nir_op_fsub, + [OPCODE_SWZ] = 0, + [OPCODE_TEX] = 0, + [OPCODE_TRUNC] = nir_op_ftrunc, + [OPCODE_TXB] = 0, + [OPCODE_TXD] = 0, + [OPCODE_TXL] = 0, + [OPCODE_TXP] = 0, + [OPCODE_TXP_NV] = 0, + [OPCODE_XPD] = 0, +}; + +static void +ptn_emit_instruction(struct ptn_compile *c, struct prog_instruction *prog_inst) +{ + nir_builder *b = &c->build; + unsigned i; + const unsigned op = prog_inst->Opcode; + + if (op == OPCODE_END) + return; + + nir_ssa_def *src[3]; + for (i = 0; i < 3; i++) { + src[i] = ptn_get_src(c, &prog_inst->SrcReg[i]); + } + nir_alu_dest dest = ptn_get_dest(c, &prog_inst->DstReg); + if (c->error) + return; + + switch (op) { + case OPCODE_RSQ: + ptn_move_dest(b, dest, nir_frsq(b, ptn_channel(b, src[0], X))); + break; + + case OPCODE_RCP: + ptn_move_dest(b, dest, nir_frcp(b, ptn_channel(b, src[0], X))); + break; + + case OPCODE_EX2: + ptn_move_dest(b, dest, nir_fexp2(b, ptn_channel(b, src[0], X))); + break; + + case OPCODE_LG2: + ptn_move_dest(b, dest, nir_flog2(b, ptn_channel(b, src[0], X))); + break; + + case OPCODE_POW: + ptn_move_dest(b, dest, nir_fpow(b, + ptn_channel(b, src[0], X), + ptn_channel(b, src[1], X))); + break; + + case OPCODE_COS: + ptn_move_dest(b, dest, nir_fcos(b, ptn_channel(b, src[0], X))); + break; + + case OPCODE_SIN: + ptn_move_dest(b, dest, nir_fsin(b, ptn_channel(b, src[0], X))); + break; + + case OPCODE_ARL: + ptn_arl(b, dest, src); + break; + + case OPCODE_EXP: + ptn_exp(b, dest, src); + break; + + case OPCODE_LOG: + ptn_log(b, dest, src); + break; + + case OPCODE_LRP: + ptn_lrp(b, dest, src); + break; + + case OPCODE_DST: + ptn_dst(b, dest, src); + break; + + case OPCODE_LIT: + ptn_lit(b, dest, src); + break; + + case OPCODE_XPD: + ptn_xpd(b, dest, src); + break; + + case OPCODE_DP2: + ptn_dp2(b, dest, src); + break; + + case OPCODE_DP3: + ptn_dp3(b, dest, src); + break; + + case OPCODE_DP4: + ptn_dp4(b, dest, src); + break; + + case OPCODE_DPH: + ptn_dph(b, dest, src); + break; + + case OPCODE_KIL: + ptn_kil(b, dest, src); + break; + + case OPCODE_CMP: + ptn_cmp(b, dest, src); + break; + + case OPCODE_SCS: + ptn_scs(b, dest, src); + break; + + case OPCODE_SLT: + ptn_slt(b, dest, src); + break; + + case OPCODE_SGT: + ptn_sgt(b, dest, src); + break; + + case OPCODE_SLE: + ptn_sle(b, dest, src); + break; + + case OPCODE_SGE: + ptn_sge(b, dest, src); + break; + + case OPCODE_SEQ: + ptn_seq(b, dest, src); + break; + + case OPCODE_SNE: + ptn_sne(b, dest, src); + break; + + case OPCODE_TEX: + case OPCODE_TXB: + case OPCODE_TXD: + case OPCODE_TXL: + case OPCODE_TXP: + case OPCODE_TXP_NV: + ptn_tex(b, dest, src, prog_inst); + break; + + case OPCODE_SWZ: + /* Extended swizzles were already handled in ptn_get_src(). */ + ptn_alu(b, nir_op_fmov, dest, src); + break; + + case OPCODE_NOP: + break; + + default: + if (op_trans[op] != 0 || op == OPCODE_MOV) { + ptn_alu(b, op_trans[op], dest, src); + } else { + fprintf(stderr, "unknown opcode: %s\n", _mesa_opcode_string(op)); + abort(); + } + break; + } + + if (prog_inst->SaturateMode) { + assert(prog_inst->SaturateMode == SATURATE_ZERO_ONE); + assert(!dest.dest.is_ssa); + ptn_move_dest(b, dest, nir_fsat(b, ptn_src_for_dest(c, &dest))); + } +} + +/** + * Puts a NIR intrinsic to store of each PROGRAM_OUTPUT value to the output + * variables at the end of the shader. + * + * We don't generate these incrementally as the PROGRAM_OUTPUT values are + * written, because there's no output load intrinsic, which means we couldn't + * handle writemasks. + */ +static void +ptn_add_output_stores(struct ptn_compile *c) +{ + nir_builder *b = &c->build; + + foreach_list_typed(nir_variable, var, node, &b->shader->outputs) { + nir_intrinsic_instr *store = + nir_intrinsic_instr_create(b->shader, nir_intrinsic_store_var); + store->num_components = 4; + store->variables[0] = + nir_deref_var_create(b->shader, c->output_vars[var->data.location]); + store->src[0].reg.reg = c->output_regs[var->data.location]; + nir_instr_insert_after_cf_list(c->build.cf_node_list, &store->instr); + } +} + +static void +setup_registers_and_variables(struct ptn_compile *c) +{ + nir_builder *b = &c->build; + struct nir_shader *shader = b->shader; + + /* Create input variables. */ + const int last_input = _mesa_fls(c->prog->InputsRead); + for (int i = 0; i <= last_input; i++) { + if (!(c->prog->InputsRead & BITFIELD64_BIT(i))) + continue; + nir_variable *var = rzalloc(shader, nir_variable); + var->type = glsl_vec4_type(); + var->data.read_only = true; + var->data.mode = nir_var_shader_in; + var->name = ralloc_asprintf(var, "in_%d", i); + var->data.location = i; + var->data.index = 0; + + if (c->prog->Target == GL_FRAGMENT_PROGRAM_ARB) { + struct gl_fragment_program *fp = + (struct gl_fragment_program *) c->prog; + + var->data.interpolation = fp->InterpQualifier[i]; + + if (i == VARYING_SLOT_POS) { + var->data.origin_upper_left = fp->OriginUpperLeft; + var->data.pixel_center_integer = fp->PixelCenterInteger; + } else if (i == VARYING_SLOT_FOGC) { + /* fogcoord is defined as . Make the actual + * input variable a float, and create a local containing the + * full vec4 value. + */ + var->type = glsl_float_type(); + + nir_intrinsic_instr *load_x = + nir_intrinsic_instr_create(shader, nir_intrinsic_load_var); + load_x->num_components = 1; + load_x->variables[0] = nir_deref_var_create(shader, var); + nir_ssa_dest_init(&load_x->instr, &load_x->dest, 1, NULL); + nir_instr_insert_after_cf_list(b->cf_node_list, &load_x->instr); + + nir_ssa_def *f001 = nir_vec4(b, &load_x->dest.ssa, nir_imm_float(b, 0.0), + nir_imm_float(b, 0.0), nir_imm_float(b, 1.0)); + + nir_variable *fullvar = rzalloc(shader, nir_variable); + fullvar->type = glsl_vec4_type(); + fullvar->data.mode = nir_var_local; + fullvar->name = "fogcoord_tmp"; + exec_list_push_tail(&b->impl->locals, &fullvar->node); + + nir_intrinsic_instr *store = + nir_intrinsic_instr_create(shader, nir_intrinsic_store_var); + store->num_components = 4; + store->variables[0] = nir_deref_var_create(shader, fullvar); + store->src[0] = nir_src_for_ssa(f001); + nir_instr_insert_after_cf_list(b->cf_node_list, &store->instr); + + /* Insert the real input into the list so the driver has real + * inputs, but set c->input_vars[i] to the temporary so we use + * the splatted value. + */ + exec_list_push_tail(&shader->inputs, &var->node); + c->input_vars[i] = fullvar; + continue; + } + } + + exec_list_push_tail(&shader->inputs, &var->node); + c->input_vars[i] = var; + } + + /* Create output registers and variables. */ + int max_outputs = _mesa_fls(c->prog->OutputsWritten); + c->output_regs = rzalloc_array(c, nir_register *, max_outputs); + + for (int i = 0; i < max_outputs; i++) { + if (!(c->prog->OutputsWritten & BITFIELD64_BIT(i))) + continue; + + /* Since we can't load from outputs in the IR, we make temporaries + * for the outputs and emit stores to the real outputs at the end of + * the shader. + */ + nir_register *reg = nir_local_reg_create(b->impl); + reg->num_components = 4; + + nir_variable *var = rzalloc(shader, nir_variable); + var->type = glsl_vec4_type(); + var->data.mode = nir_var_shader_out; + var->name = ralloc_asprintf(var, "out_%d", i); + + var->data.location = i; + var->data.index = 0; + + c->output_regs[i] = reg; + + exec_list_push_tail(&shader->outputs, &var->node); + c->output_vars[i] = var; + } + + /* Create temporary registers. */ + c->temp_regs = rzalloc_array(c, nir_register *, c->prog->NumTemporaries); + + nir_register *reg; + for (int i = 0; i < c->prog->NumTemporaries; i++) { + reg = nir_local_reg_create(b->impl); + if (!reg) { + c->error = true; + return; + } + reg->num_components = 4; + c->temp_regs[i] = reg; + } + + /* Create the address register (for ARB_vertex_program). */ + reg = nir_local_reg_create(b->impl); + if (!reg) { + c->error = true; + return; + } + reg->num_components = 1; + c->addr_reg = reg; + + /* Set the number of uniforms */ + shader->num_uniforms = 4 * c->prog->Parameters->NumParameters; +} + +struct nir_shader * +prog_to_nir(struct gl_program *prog, const nir_shader_compiler_options *options) +{ + struct ptn_compile *c; + struct nir_shader *s; + + c = rzalloc(NULL, struct ptn_compile); + if (!c) + return NULL; + s = nir_shader_create(NULL, options); + if (!s) + goto fail; + c->prog = prog; + + nir_function *func = nir_function_create(s, "main"); + nir_function_overload *overload = nir_function_overload_create(func); + nir_function_impl *impl = nir_function_impl_create(overload); + + c->build.shader = s; + c->build.impl = impl; + c->build.cf_node_list = &impl->body; + + setup_registers_and_variables(c); + if (unlikely(c->error)) + goto fail; + + for (unsigned int i = 0; i < prog->NumInstructions; i++) { + ptn_emit_instruction(c, &prog->Instructions[i]); + + if (unlikely(c->error)) + break; + } + + ptn_add_output_stores(c); + +fail: + if (c->error) { + ralloc_free(s); + s = NULL; + } + ralloc_free(c); + return s; +} diff --git a/src/mesa/program/prog_to_nir.h b/src/mesa/program/prog_to_nir.h new file mode 100644 index 0000000..3c9b664 --- /dev/null +++ b/src/mesa/program/prog_to_nir.h @@ -0,0 +1,37 @@ +/* + * Copyright ? 2015 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. + */ + +#pragma once +#ifndef PROG_TO_NIR_H +#define PROG_TO_NIR_H +#ifdef __cplusplus +extern "C" { +#endif + +struct nir_shader *prog_to_nir(struct gl_program *prog, + const nir_shader_compiler_options *options); + +#ifdef __cplusplus +} +#endif +#endif From kwg at kemper.freedesktop.org Sat Mar 28 04:21:18 2015 From: kwg at kemper.freedesktop.org (Kenneth Graunke) Date: Fri, 27 Mar 2015 21:21:18 -0700 (PDT) Subject: Mesa (master): i965/nir: Use NIR for ARB_vertex_program support on Gen8+. Message-ID: <20150328042118.18A7E76333@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 31dc63d5ca090fed3f1adcd4fd0db2f1f7aa19f7 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=31dc63d5ca090fed3f1adcd4fd0db2f1f7aa19f7 Author: Kenneth Graunke Date: Wed Mar 25 15:16:30 2015 -0700 i965/nir: Use NIR for ARB_vertex_program support on Gen8+. Everything is already in place; we simply have to take the scalar code generation path. This gives us SIMD8 VS programs, instead of SIMD4x2. v2: Rebase on the patch that drops brw->gen >= 8. Signed-off-by: Kenneth Graunke Reviewed-by: Jordan Justen Reviewed-by: Connor Abbott --- src/mesa/drivers/dri/i965/brw_vec4.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_vec4.cpp b/src/mesa/drivers/dri/i965/brw_vec4.cpp index 9d2e375..480e50c 100644 --- a/src/mesa/drivers/dri/i965/brw_vec4.cpp +++ b/src/mesa/drivers/dri/i965/brw_vec4.cpp @@ -1823,7 +1823,7 @@ brw_vs_emit(struct brw_context *brw, if (unlikely(INTEL_DEBUG & DEBUG_VS)) brw_dump_ir("vertex", prog, &shader->base, &c->vp->program.Base); - if (prog && brw->scalar_vs) { + if (brw->scalar_vs && (prog || brw_env_var_as_boolean("INTEL_USE_NIR", false))) { fs_visitor v(brw, mem_ctx, &c->key, prog_data, prog, &c->vp->program, 8); if (!v.run_vs()) { if (prog) { @@ -1841,9 +1841,15 @@ brw_vs_emit(struct brw_context *brw, &c->vp->program.Base, v.promoted_constants, v.runtime_check_aads_emit, "VS"); if (INTEL_DEBUG & DEBUG_VS) { - char *name = ralloc_asprintf(mem_ctx, "%s vertex shader %d", - prog->Label ? prog->Label : "unnamed", - prog->Name); + char *name; + if (prog) { + name = ralloc_asprintf(mem_ctx, "%s vertex shader %d", + prog->Label ? prog->Label : "unnamed", + prog->Name); + } else { + name = ralloc_asprintf(mem_ctx, "vertex program %d", + c->vp->program.Base.Id); + } g.enable_debug(name); } g.generate_code(v.cfg, 8); From kwg at kemper.freedesktop.org Sat Mar 28 04:21:17 2015 From: kwg at kemper.freedesktop.org (Kenneth Graunke) Date: Fri, 27 Mar 2015 21:21:17 -0700 (PDT) Subject: Mesa (master): nir: Add builder helpers for MOVs with ALU sources and swizzling MOVs. Message-ID: <20150328042117.C5C647635A@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 06f7bea96ab62e7de1523de837f5b69c1bac6513 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=06f7bea96ab62e7de1523de837f5b69c1bac6513 Author: Kenneth Graunke Date: Wed Mar 25 14:51:02 2015 -0700 nir: Add builder helpers for MOVs with ALU sources and swizzling MOVs. These will be useful for prog->nir and tgsi->nir. v2: Don't forget to mark nir_swizzle as inline (Eric). Signed-off-by: Kenneth Graunke Reviewed-by: Connor Abbott Reviewed-by: Eric Anholt --- src/glsl/nir/nir_builder.h | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/src/glsl/nir/nir_builder.h b/src/glsl/nir/nir_builder.h index fe6cb37..6459e9a 100644 --- a/src/glsl/nir/nir_builder.h +++ b/src/glsl/nir/nir_builder.h @@ -162,4 +162,48 @@ nir_##op(nir_builder *build, nir_ssa_def *src0, \ #include "nir_builder_opcodes.h" +/** + * Similar to nir_fmov, but takes a nir_alu_src instead of a nir_ssa_def. + */ +static inline nir_ssa_def * +nir_fmov_alu(nir_builder *build, nir_alu_src src, unsigned num_components) +{ + nir_alu_instr *mov = nir_alu_instr_create(build->shader, nir_op_fmov); + nir_ssa_dest_init(&mov->instr, &mov->dest.dest, num_components, NULL); + mov->dest.write_mask = (1 << num_components) - 1; + mov->src[0] = src; + nir_instr_insert_after_cf_list(build->cf_node_list, &mov->instr); + + return &mov->dest.dest.ssa; +} + +static inline nir_ssa_def * +nir_imov_alu(nir_builder *build, nir_alu_src src, unsigned num_components) +{ + nir_alu_instr *mov = nir_alu_instr_create(build->shader, nir_op_imov); + nir_ssa_dest_init(&mov->instr, &mov->dest.dest, num_components, NULL); + mov->dest.write_mask = (1 << num_components) - 1; + mov->src[0] = src; + nir_instr_insert_after_cf_list(build->cf_node_list, &mov->instr); + + return &mov->dest.dest.ssa; +} + +/** + * Construct an fmov or imov that reswizzles the source's components. + */ +static inline nir_ssa_def * +nir_swizzle(nir_builder *build, nir_ssa_def *src, unsigned swiz[4], + unsigned num_components, bool use_fmov) +{ + nir_alu_src alu_src; + memset(&alu_src, 0, sizeof(alu_src)); + alu_src.src = nir_src_for_ssa(src); + for (int i = 0; i < 4; i++) + alu_src.swizzle[i] = swiz[i]; + + return use_fmov ? nir_fmov_alu(build, alu_src, num_components) : + nir_imov_alu(build, alu_src, num_components); +} + #endif /* NIR_BUILDER_H */ From kwg at kemper.freedesktop.org Sat Mar 28 04:21:17 2015 From: kwg at kemper.freedesktop.org (Kenneth Graunke) Date: Fri, 27 Mar 2015 21:21:17 -0700 (PDT) Subject: Mesa (master): nir: Lower subtraction to add with negation when !lower_negate. Message-ID: <20150328042117.E14E976333@kemper.freedesktop.org> Module: Mesa Branch: master Commit: bf2c3bc316cbfcc19d1bb65ab7410784ed7a3dac URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=bf2c3bc316cbfcc19d1bb65ab7410784ed7a3dac Author: Kenneth Graunke Date: Wed Mar 25 15:22:12 2015 -0700 nir: Lower subtraction to add with negation when !lower_negate. prog->nir will generate fsub opcodes, but i965 doesn't implement them. We may as well lower them at the NIR level, since it's trivial to do. Suggested by Connor Abbott. Signed-off-by: Kenneth Graunke Reviewed-by: Connor Abbott Reviewed-by: Eric Anholt --- src/glsl/nir/nir_opt_algebraic.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/glsl/nir/nir_opt_algebraic.py b/src/glsl/nir/nir_opt_algebraic.py index 20ec4d3..66b456d 100644 --- a/src/glsl/nir/nir_opt_algebraic.py +++ b/src/glsl/nir/nir_opt_algebraic.py @@ -161,6 +161,8 @@ optimizations = [ # Subtracts (('fsub', a, ('fsub', 0.0, b)), ('fadd', a, b)), (('isub', a, ('isub', 0, b)), ('iadd', a, b)), + (('fsub', a, b), ('fadd', a, ('fneg', b)), '!options->lower_negate'), + (('isub', a, b), ('iadd', a, ('ineg', b)), '!options->lower_negate'), (('fneg', a), ('fsub', 0.0, a), 'options->lower_negate'), (('ineg', a), ('isub', 0, a), 'options->lower_negate'), (('fadd', a, ('fsub', 0.0, b)), ('fsub', a, b)), From kwg at kemper.freedesktop.org Sat Mar 28 04:21:18 2015 From: kwg at kemper.freedesktop.org (Kenneth Graunke) Date: Fri, 27 Mar 2015 21:21:18 -0700 (PDT) Subject: Mesa (master): i965: Move env_var_as_boolean to intel_debug.c. Message-ID: <20150328042118.0B32F76333@kemper.freedesktop.org> Module: Mesa Branch: master Commit: ac69ab7302dffa1350c64a9c69abd7721d0f0127 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=ac69ab7302dffa1350c64a9c69abd7721d0f0127 Author: Kenneth Graunke Date: Fri Mar 27 13:48:44 2015 -0700 i965: Move env_var_as_boolean to intel_debug.c. I need to use this in brw_vec4.cpp, so it can't be static anymore. Signed-off-by: Kenneth Graunke Reviewed-by: Matt Turner --- src/mesa/drivers/dri/i965/brw_fs.cpp | 24 ++---------------------- src/mesa/drivers/dri/i965/intel_debug.c | 25 +++++++++++++++++++++++++ src/mesa/drivers/dri/i965/intel_debug.h | 2 ++ 3 files changed, 29 insertions(+), 22 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp index 6969286..9c2ccce 100644 --- a/src/mesa/drivers/dri/i965/brw_fs.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs.cpp @@ -3850,26 +3850,6 @@ fs_visitor::allocate_registers() prog_data->total_scratch = brw_get_scratch_size(last_scratch); } -static bool -env_var_as_boolean(const char *var_name, bool default_value) -{ - const char *str = getenv(var_name); - if (str == NULL) - return default_value; - - if (strcmp(str, "1") == 0 || - strcasecmp(str, "true") == 0 || - strcasecmp(str, "yes") == 0) { - return true; - } else if (strcmp(str, "0") == 0 || - strcasecmp(str, "false") == 0 || - strcasecmp(str, "no") == 0) { - return false; - } else { - return default_value; - } -} - bool fs_visitor::run_vs() { @@ -3881,7 +3861,7 @@ fs_visitor::run_vs() if (INTEL_DEBUG & DEBUG_SHADER_TIME) emit_shader_time_begin(); - if (env_var_as_boolean("INTEL_USE_NIR", false)) { + if (brw_env_var_as_boolean("INTEL_USE_NIR", false)) { emit_nir_code(); } else { foreach_in_list(ir_instruction, ir, shader->base.ir) { @@ -3954,7 +3934,7 @@ fs_visitor::run_fs() /* Generate FS IR for main(). (the visitor only descends into * functions called "main"). */ - if (env_var_as_boolean("INTEL_USE_NIR", false)) { + if (brw_env_var_as_boolean("INTEL_USE_NIR", false)) { emit_nir_code(); } else if (shader) { foreach_in_list(ir_instruction, ir, shader->base.ir) { diff --git a/src/mesa/drivers/dri/i965/intel_debug.c b/src/mesa/drivers/dri/i965/intel_debug.c index 0cb7aef..a5b883c 100644 --- a/src/mesa/drivers/dri/i965/intel_debug.c +++ b/src/mesa/drivers/dri/i965/intel_debug.c @@ -106,3 +106,28 @@ brw_process_intel_debug_variable(struct brw_context *brw) if (INTEL_DEBUG & DEBUG_AUB) drm_intel_bufmgr_gem_set_aub_dump(brw->bufmgr, true); } + +/** + * Reads an environment variable and interprets its value as a boolean. + * + * Recognizes 0/false/no and 1/true/yes. Other values result in the default value. + */ +bool +brw_env_var_as_boolean(const char *var_name, bool default_value) +{ + const char *str = getenv(var_name); + if (str == NULL) + return default_value; + + if (strcmp(str, "1") == 0 || + strcasecmp(str, "true") == 0 || + strcasecmp(str, "yes") == 0) { + return true; + } else if (strcmp(str, "0") == 0 || + strcasecmp(str, "false") == 0 || + strcasecmp(str, "no") == 0) { + return false; + } else { + return default_value; + } +} diff --git a/src/mesa/drivers/dri/i965/intel_debug.h b/src/mesa/drivers/dri/i965/intel_debug.h index ed879ab..807ad98 100644 --- a/src/mesa/drivers/dri/i965/intel_debug.h +++ b/src/mesa/drivers/dri/i965/intel_debug.h @@ -115,3 +115,5 @@ extern uint64_t intel_debug_flag_for_shader_stage(gl_shader_stage stage); struct brw_context; extern void brw_process_intel_debug_variable(struct brw_context *brw); + +extern bool brw_env_var_as_boolean(const char *var_name, bool default_value); From kwg at kemper.freedesktop.org Sat Mar 28 04:21:17 2015 From: kwg at kemper.freedesktop.org (Kenneth Graunke) Date: Fri, 27 Mar 2015 21:21:17 -0700 (PDT) Subject: Mesa (master): i965/fs: Add ARB_fragment_program support to the NIR backend. Message-ID: <20150328042117.F1C7176333@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 826d3afb8f421a62020308813397e541e672381e URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=826d3afb8f421a62020308813397e541e672381e Author: Kenneth Graunke Date: Fri Jan 30 01:16:49 2015 -0800 i965/fs: Add ARB_fragment_program support to the NIR backend. Use prog_to_nir where we would normally call glsl_to_nir, handle program parameter lists, and skip a few things that don't exist. Using NIR generates much better shader code than Mesa IR, since we get real optimizations, as opposed to prog_optimize: total instructions in shared programs: 314007 -> 279892 (-10.86%) instructions in affected programs: 285173 -> 251058 (-11.96%) helped: 2001 HURT: 67 GAINED: 4 LOST: 7 v2: Change early return in nir_setup_uniforms to if/else (Jordan). Signed-off-by: Kenneth Graunke Reviewed-by: Jordan Justen Reviewed-by: Connor Abbott --- src/mesa/drivers/dri/i965/brw_fs.cpp | 16 ++++---- src/mesa/drivers/dri/i965/brw_fs_nir.cpp | 61 +++++++++++++++++++++--------- 2 files changed, 51 insertions(+), 26 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp index a57f501..6969286 100644 --- a/src/mesa/drivers/dri/i965/brw_fs.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs.cpp @@ -3954,15 +3954,13 @@ fs_visitor::run_fs() /* Generate FS IR for main(). (the visitor only descends into * functions called "main"). */ - if (shader) { - if (env_var_as_boolean("INTEL_USE_NIR", false)) { - emit_nir_code(); - } else { - foreach_in_list(ir_instruction, ir, shader->base.ir) { - base_ir = ir; - this->result = reg_undef; - ir->accept(this); - } + if (env_var_as_boolean("INTEL_USE_NIR", false)) { + emit_nir_code(); + } else if (shader) { + foreach_in_list(ir_instruction, ir, shader->base.ir) { + base_ir = ir; + this->result = reg_undef; + ir->accept(this); } } else { emit_fragment_program_code(); diff --git a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp index 0b8ed1a..21e52fe 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp @@ -24,6 +24,7 @@ #include "glsl/ir.h" #include "glsl/ir_optimization.h" #include "glsl/nir/glsl_to_nir.h" +#include "program/prog_to_nir.h" #include "brw_fs.h" #include "brw_nir.h" @@ -86,9 +87,15 @@ fs_visitor::emit_nir_code() const nir_shader_compiler_options *options = ctx->Const.ShaderCompilerOptions[stage].NirOptions; - /* first, lower the GLSL IR shader to NIR */ - lower_output_reads(shader->base.ir); - nir_shader *nir = glsl_to_nir(&shader->base, options); + nir_shader *nir; + /* First, lower the GLSL IR or Mesa IR to NIR */ + if (shader_prog) { + lower_output_reads(shader->base.ir); + nir = glsl_to_nir(&shader->base, options); + } else { + nir = prog_to_nir(prog, options); + nir_convert_to_ssa(nir); /* turn registers into SSA */ + } nir_validate_shader(nir); nir_lower_global_vars_to_local(nir); @@ -106,9 +113,18 @@ fs_visitor::emit_nir_code() /* Get rid of split copies */ nir_optimize(nir); - nir_assign_var_locations_scalar_direct_first(nir, &nir->uniforms, - &num_direct_uniforms, - &nir->num_uniforms); + if (shader_prog) { + nir_assign_var_locations_scalar_direct_first(nir, &nir->uniforms, + &num_direct_uniforms, + &nir->num_uniforms); + } else { + /* ARB programs generally create a giant array of "uniform" data, and allow + * indirect addressing without any boundaries. In the absence of bounds + * analysis, it's all or nothing. num_direct_uniforms is only useful when + * we have some direct and some indirect access; it doesn't matter here. + */ + num_direct_uniforms = 0; + } nir_assign_var_locations_scalar(&nir->inputs, &nir->num_inputs); nir_assign_var_locations_scalar(&nir->outputs, &nir->num_outputs); @@ -118,8 +134,10 @@ fs_visitor::emit_nir_code() nir_remove_dead_variables(nir); nir_validate_shader(nir); - nir_lower_samplers(nir, shader_prog, shader->base.Program); - nir_validate_shader(nir); + if (shader_prog) { + nir_lower_samplers(nir, shader_prog, shader->base.Program); + nir_validate_shader(nir); + } nir_lower_system_values(nir); nir_validate_shader(nir); @@ -320,16 +338,25 @@ fs_visitor::nir_setup_uniforms(nir_shader *shader) if (dispatch_width != 8) return; - foreach_list_typed(nir_variable, var, node, &shader->uniforms) { - /* UBO's and atomics don't take up space in the uniform file */ - - if (var->interface_type != NULL || var->type->contains_atomic()) - continue; + if (shader_prog) { + foreach_list_typed(nir_variable, var, node, &shader->uniforms) { + /* UBO's and atomics don't take up space in the uniform file */ + if (var->interface_type != NULL || var->type->contains_atomic()) + continue; - if (strncmp(var->name, "gl_", 3) == 0) - nir_setup_builtin_uniform(var); - else - nir_setup_uniform(var); + if (strncmp(var->name, "gl_", 3) == 0) + nir_setup_builtin_uniform(var); + else + nir_setup_uniform(var); + } + } else { + /* prog_to_nir doesn't create uniform variables; set param up directly. */ + for (unsigned p = 0; p < prog->Parameters->NumParameters; p++) { + for (unsigned int i = 0; i < 4; i++) { + stage_prog_data->param[4 * p + i] = + &prog->Parameters->ParameterValues[p][i]; + } + } } } From kwg at kemper.freedesktop.org Sat Mar 28 16:37:00 2015 From: kwg at kemper.freedesktop.org (Kenneth Graunke) Date: Sat, 28 Mar 2015 09:37:00 -0700 (PDT) Subject: Mesa (master): nir: Fix copy and pasted error message in nir_validate. Message-ID: <20150328163700.454E07624F@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 72b06fb08e40907cdf94d4f390f53f42240a4345 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=72b06fb08e40907cdf94d4f390f53f42240a4345 Author: Kenneth Graunke Date: Fri Mar 27 18:22:20 2015 -0700 nir: Fix copy and pasted error message in nir_validate. These are nir_cf_nodes, not ALU instructions. Also, use unreachable() to preempt said review feedback. v2: Do it right (thanks Ilia). Signed-off-by: Kenneth Graunke Reviewed-by: Jason Ekstrand --- src/glsl/nir/nir_validate.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/glsl/nir/nir_validate.c b/src/glsl/nir/nir_validate.c index f247ae0..e8c9d7b 100644 --- a/src/glsl/nir/nir_validate.c +++ b/src/glsl/nir/nir_validate.c @@ -680,8 +680,7 @@ validate_cf_node(nir_cf_node *node, validate_state *state) break; default: - assert(!"Invalid ALU instruction type"); - break; + unreachable("Invalid CF node type"); } } From imirkin at kemper.freedesktop.org Sat Mar 28 19:16:46 2015 From: imirkin at kemper.freedesktop.org (Ilia Mirkin) Date: Sat, 28 Mar 2015 12:16:46 -0700 (PDT) Subject: Mesa (master): freedreno/a3xx: LAYERSZ2 appears to have no effect on arrays Message-ID: <20150328191646.6FFAA7624F@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 3735643df3fc29d7ce84b2156c53f23a3092765c URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=3735643df3fc29d7ce84b2156c53f23a3092765c Author: Ilia Mirkin Date: Fri Mar 13 18:01:11 2015 -0400 freedreno/a3xx: LAYERSZ2 appears to have no effect on arrays Signed-off-by: Ilia Mirkin --- src/gallium/drivers/freedreno/a3xx/fd3_texture.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/gallium/drivers/freedreno/a3xx/fd3_texture.c b/src/gallium/drivers/freedreno/a3xx/fd3_texture.c index 567f6c7..05d826e 100644 --- a/src/gallium/drivers/freedreno/a3xx/fd3_texture.c +++ b/src/gallium/drivers/freedreno/a3xx/fd3_texture.c @@ -246,8 +246,7 @@ fd3_sampler_view_create(struct pipe_context *pctx, struct pipe_resource *prsc, case PIPE_TEXTURE_2D_ARRAY: so->texconst3 = A3XX_TEX_CONST_3_DEPTH(prsc->array_size - 1) | - A3XX_TEX_CONST_3_LAYERSZ1(rsc->slices[0].size0) | - A3XX_TEX_CONST_3_LAYERSZ2(rsc->slices[0].size0); + A3XX_TEX_CONST_3_LAYERSZ1(rsc->slices[0].size0); break; case PIPE_TEXTURE_3D: so->texconst3 = From imirkin at kemper.freedesktop.org Sat Mar 28 19:16:46 2015 From: imirkin at kemper.freedesktop.org (Ilia Mirkin) Date: Sat, 28 Mar 2015 12:16:46 -0700 (PDT) Subject: Mesa (master): freedreno/a3xx: fix 3d texture layout Message-ID: <20150328191646.787877635A@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 738c8319ac85b175994b35d1fdc4860e18184b93 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=738c8319ac85b175994b35d1fdc4860e18184b93 Author: Ilia Mirkin Date: Sun Mar 15 16:38:42 2015 -0400 freedreno/a3xx: fix 3d texture layout The SZ2 field contains the layer size of a lower miplevel. It only contains 4 bits, which limits the maximum layer size it can describe. In situations where the next miplevel would be too big, the hardware appears to keep minifying the size until it hits one of that size. Unfortunately the hardware's ideas about sizes can differ from freedreno's which can still lead to issues. Minimize those by stopping to minify as soon as possible. Signed-off-by: Ilia Mirkin Cc: "10.4 10.5" --- src/gallium/drivers/freedreno/a3xx/fd3_texture.c | 7 +++++-- src/gallium/drivers/freedreno/freedreno_resource.c | 16 +++++++++++----- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/gallium/drivers/freedreno/a3xx/fd3_texture.c b/src/gallium/drivers/freedreno/a3xx/fd3_texture.c index 05d826e..69e2d58 100644 --- a/src/gallium/drivers/freedreno/a3xx/fd3_texture.c +++ b/src/gallium/drivers/freedreno/a3xx/fd3_texture.c @@ -212,6 +212,7 @@ fd3_sampler_view_create(struct pipe_context *pctx, struct pipe_resource *prsc, struct fd_resource *rsc = fd_resource(prsc); unsigned lvl = cso->u.tex.first_level; unsigned miplevels = cso->u.tex.last_level - lvl; + uint32_t sz2 = 0; if (!so) return NULL; @@ -251,8 +252,10 @@ fd3_sampler_view_create(struct pipe_context *pctx, struct pipe_resource *prsc, case PIPE_TEXTURE_3D: so->texconst3 = A3XX_TEX_CONST_3_DEPTH(u_minify(prsc->depth0, lvl)) | - A3XX_TEX_CONST_3_LAYERSZ1(rsc->slices[0].size0) | - A3XX_TEX_CONST_3_LAYERSZ2(rsc->slices[0].size0); + A3XX_TEX_CONST_3_LAYERSZ1(rsc->slices[lvl].size0); + while (lvl < cso->u.tex.last_level && sz2 != rsc->slices[lvl+1].size0) + sz2 = rsc->slices[++lvl].size0; + so->texconst3 |= A3XX_TEX_CONST_3_LAYERSZ2(sz2); break; default: so->texconst3 = 0x00000000; diff --git a/src/gallium/drivers/freedreno/freedreno_resource.c b/src/gallium/drivers/freedreno/freedreno_resource.c index 69e5452..efafb89 100644 --- a/src/gallium/drivers/freedreno/freedreno_resource.c +++ b/src/gallium/drivers/freedreno/freedreno_resource.c @@ -215,14 +215,20 @@ setup_slices(struct fd_resource *rsc, uint32_t alignment) slice->pitch = width = align(width, 32); slice->offset = size; - /* 1d array, 2d array, 3d textures (but not cube!) must all have the - * same layer size for each miplevel on a3xx. These are also the - * targets that have non-1 alignment. + /* 1d array and 2d array textures must all have the same layer size + * for each miplevel on a3xx. 3d textures can have different layer + * sizes for high levels, but the hw auto-sizer is buggy (or at least + * different than what this code does), so as soon as the layer size + * range gets into range, we stop reducing it. */ - if (level == 0 || layers_in_level == 1 || alignment == 1) + if (prsc->target == PIPE_TEXTURE_3D && ( + level == 1 || + (level > 1 && rsc->slices[level - 1].size0 > 0xf000))) + slice->size0 = align(slice->pitch * height * rsc->cpp, alignment); + else if (level == 0 || rsc->layer_first || alignment == 1) slice->size0 = align(slice->pitch * height * rsc->cpp, alignment); else - slice->size0 = rsc->slices[0].size0; + slice->size0 = rsc->slices[level - 1].size0; size += slice->size0 * depth * layers_in_level; From imirkin at kemper.freedesktop.org Sat Mar 28 19:16:46 2015 From: imirkin at kemper.freedesktop.org (Ilia Mirkin) Date: Sat, 28 Mar 2015 12:16:46 -0700 (PDT) Subject: Mesa (master): freedreno/a3xx: point size should not be divided by 2 Message-ID: <20150328191646.813877635B@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 7fc5da8b9392042b5f8a989d2afa49ea1944f9a9 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=7fc5da8b9392042b5f8a989d2afa49ea1944f9a9 Author: Ilia Mirkin Date: Tue Mar 17 01:00:38 2015 -0400 freedreno/a3xx: point size should not be divided by 2 The division is probably a holdover from the days when the fixed point inline functions generated by headergen were broken. Also reduce the maximum point size to 4092 (vs 4096), which is what the blob does. Cc: "10.4 10.5" Signed-off-by: Ilia Mirkin --- src/gallium/drivers/freedreno/a3xx/fd3_rasterizer.c | 8 ++++---- src/gallium/drivers/freedreno/freedreno_screen.c | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/gallium/drivers/freedreno/a3xx/fd3_rasterizer.c b/src/gallium/drivers/freedreno/a3xx/fd3_rasterizer.c index 4b926b5..345f688 100644 --- a/src/gallium/drivers/freedreno/a3xx/fd3_rasterizer.c +++ b/src/gallium/drivers/freedreno/a3xx/fd3_rasterizer.c @@ -50,7 +50,7 @@ fd3_rasterizer_state_create(struct pipe_context *pctx, if (cso->point_size_per_vertex) { psize_min = util_get_min_point_size(cso); - psize_max = 8192; + psize_max = 4092; } else { /* Force the point size to be as if the vertex output was disabled. */ psize_min = cso->point_size; @@ -67,9 +67,9 @@ fd3_rasterizer_state_create(struct pipe_context *pctx, */ so->gras_cl_clip_cntl = A3XX_GRAS_CL_CLIP_CNTL_IJ_PERSP_CENTER; /* ??? */ so->gras_su_point_minmax = - A3XX_GRAS_SU_POINT_MINMAX_MIN(psize_min/2) | - A3XX_GRAS_SU_POINT_MINMAX_MAX(psize_max/2); - so->gras_su_point_size = A3XX_GRAS_SU_POINT_SIZE(cso->point_size/2); + A3XX_GRAS_SU_POINT_MINMAX_MIN(psize_min) | + A3XX_GRAS_SU_POINT_MINMAX_MAX(psize_max); + so->gras_su_point_size = A3XX_GRAS_SU_POINT_SIZE(cso->point_size); so->gras_su_poly_offset_scale = A3XX_GRAS_SU_POLY_OFFSET_SCALE_VAL(cso->offset_scale); so->gras_su_poly_offset_offset = diff --git a/src/gallium/drivers/freedreno/freedreno_screen.c b/src/gallium/drivers/freedreno/freedreno_screen.c index 1e47089..68c8105 100644 --- a/src/gallium/drivers/freedreno/freedreno_screen.c +++ b/src/gallium/drivers/freedreno/freedreno_screen.c @@ -300,7 +300,7 @@ fd_screen_get_paramf(struct pipe_screen *pscreen, enum pipe_capf param) case PIPE_CAPF_MAX_LINE_WIDTH_AA: case PIPE_CAPF_MAX_POINT_WIDTH: case PIPE_CAPF_MAX_POINT_WIDTH_AA: - return 8192.0f; + return 4092.0f; case PIPE_CAPF_MAX_TEXTURE_ANISOTROPY: return 16.0f; case PIPE_CAPF_MAX_TEXTURE_LOD_BIAS: From imirkin at kemper.freedesktop.org Sat Mar 28 19:16:46 2015 From: imirkin at kemper.freedesktop.org (Ilia Mirkin) Date: Sat, 28 Mar 2015 12:16:46 -0700 (PDT) Subject: Mesa (master): freedreno/a3xx: make vs-set point size work Message-ID: <20150328191646.8AD967635C@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 995f55a6cedfd47a2aed75178a1b0caed7059f20 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=995f55a6cedfd47a2aed75178a1b0caed7059f20 Author: Ilia Mirkin Date: Tue Mar 17 01:02:32 2015 -0400 freedreno/a3xx: make vs-set point size work This appears to need the A2XX version of the point list, so select it at draw time if necessary. Experimentally, always using the A2XX version causes hangs when PSIZE isn't actually emitted. Signed-off-by: Ilia Mirkin --- src/gallium/drivers/freedreno/a2xx/fd2_draw.c | 3 ++- src/gallium/drivers/freedreno/a3xx/fd3_draw.c | 6 ++++++ src/gallium/drivers/freedreno/freedreno_draw.h | 3 ++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/gallium/drivers/freedreno/a2xx/fd2_draw.c b/src/gallium/drivers/freedreno/a2xx/fd2_draw.c index dfc7202..f2efd5f 100644 --- a/src/gallium/drivers/freedreno/a2xx/fd2_draw.c +++ b/src/gallium/drivers/freedreno/a2xx/fd2_draw.c @@ -107,7 +107,8 @@ fd2_draw_vbo(struct fd_context *ctx, const struct pipe_draw_info *info) OUT_RING(ring, info->max_index); /* VGT_MAX_VTX_INDX */ OUT_RING(ring, info->min_index); /* VGT_MIN_VTX_INDX */ - fd_draw_emit(ctx, ring, IGNORE_VISIBILITY, info); + fd_draw_emit(ctx, ring, ctx->primtypes[info->mode], + IGNORE_VISIBILITY, info); OUT_PKT3(ring, CP_SET_CONSTANT, 2); OUT_RING(ring, CP_REG(REG_A2XX_UNKNOWN_2010)); diff --git a/src/gallium/drivers/freedreno/a3xx/fd3_draw.c b/src/gallium/drivers/freedreno/a3xx/fd3_draw.c index 179bf9c..48dd8da 100644 --- a/src/gallium/drivers/freedreno/a3xx/fd3_draw.c +++ b/src/gallium/drivers/freedreno/a3xx/fd3_draw.c @@ -58,6 +58,7 @@ draw_impl(struct fd_context *ctx, struct fd_ringbuffer *ring, struct fd3_emit *emit) { const struct pipe_draw_info *info = emit->info; + enum pc_di_primtype primtype = ctx->primtypes[info->mode]; fd3_emit_state(ctx, ring, emit); @@ -77,7 +78,12 @@ draw_impl(struct fd_context *ctx, struct fd_ringbuffer *ring, OUT_RING(ring, info->primitive_restart ? /* PC_RESTART_INDEX */ info->restart_index : 0xffffffff); + if (ctx->rasterizer && ctx->rasterizer->point_size_per_vertex && + info->mode == PIPE_PRIM_POINTS) + primtype = DI_PT_POINTLIST_A2XX; + fd_draw_emit(ctx, ring, + primtype, emit->key.binning_pass ? IGNORE_VISIBILITY : USE_VISIBILITY, info); } diff --git a/src/gallium/drivers/freedreno/freedreno_draw.h b/src/gallium/drivers/freedreno/freedreno_draw.h index 25e102f..3224fb1 100644 --- a/src/gallium/drivers/freedreno/freedreno_draw.h +++ b/src/gallium/drivers/freedreno/freedreno_draw.h @@ -113,6 +113,7 @@ size2indextype(unsigned index_size) /* this is same for a2xx/a3xx, so split into helper: */ static inline void fd_draw_emit(struct fd_context *ctx, struct fd_ringbuffer *ring, + enum pc_di_primtype primtype, enum pc_di_vis_cull_mode vismode, const struct pipe_draw_info *info) { @@ -138,7 +139,7 @@ fd_draw_emit(struct fd_context *ctx, struct fd_ringbuffer *ring, src_sel = DI_SRC_SEL_AUTO_INDEX; } - fd_draw(ctx, ring, ctx->primtypes[info->mode], vismode, src_sel, + fd_draw(ctx, ring, primtype, vismode, src_sel, info->count, info->instance_count - 1, idx_type, idx_size, idx_offset, idx_bo); } From imirkin at kemper.freedesktop.org Sat Mar 28 19:16:46 2015 From: imirkin at kemper.freedesktop.org (Ilia Mirkin) Date: Sat, 28 Mar 2015 12:16:46 -0700 (PDT) Subject: Mesa (master): freedreno/a3xx: add support for point sprite coordinate replacement Message-ID: <20150328191646.942907624F@kemper.freedesktop.org> Module: Mesa Branch: master Commit: ee670c9efa471aa78563b14f47bcd89220b608dc URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=ee670c9efa471aa78563b14f47bcd89220b608dc Author: Ilia Mirkin Date: Tue Mar 17 01:34:33 2015 -0400 freedreno/a3xx: add support for point sprite coordinate replacement This does not (yet) support different coordinate origins, so the tests still fail due to fbo flipping. Signed-off-by: Ilia Mirkin --- src/gallium/drivers/freedreno/a3xx/fd3_draw.c | 1 + src/gallium/drivers/freedreno/a3xx/fd3_emit.h | 2 + src/gallium/drivers/freedreno/a3xx/fd3_gmem.c | 1 + src/gallium/drivers/freedreno/a3xx/fd3_program.c | 54 ++++++++++------------ 4 files changed, 28 insertions(+), 30 deletions(-) diff --git a/src/gallium/drivers/freedreno/a3xx/fd3_draw.c b/src/gallium/drivers/freedreno/a3xx/fd3_draw.c index 48dd8da..a3f9549 100644 --- a/src/gallium/drivers/freedreno/a3xx/fd3_draw.c +++ b/src/gallium/drivers/freedreno/a3xx/fd3_draw.c @@ -158,6 +158,7 @@ fd3_draw_vbo(struct fd_context *ctx, const struct pipe_draw_info *info) }, .format = pipe_surface_format(pfb->cbufs[0]), .rasterflat = ctx->rasterizer && ctx->rasterizer->flatshade, + .sprite_coord_enable = ctx->rasterizer ? ctx->rasterizer->sprite_coord_enable : 0, }; unsigned dirty; diff --git a/src/gallium/drivers/freedreno/a3xx/fd3_emit.h b/src/gallium/drivers/freedreno/a3xx/fd3_emit.h index 3aa77b6..ce51c0c 100644 --- a/src/gallium/drivers/freedreno/a3xx/fd3_emit.h +++ b/src/gallium/drivers/freedreno/a3xx/fd3_emit.h @@ -55,6 +55,8 @@ struct fd3_emit { struct ir3_shader_key key; enum pipe_format format; uint32_t dirty; + + uint32_t sprite_coord_enable; bool rasterflat; /* cached to avoid repeated lookups of same variants: */ diff --git a/src/gallium/drivers/freedreno/a3xx/fd3_gmem.c b/src/gallium/drivers/freedreno/a3xx/fd3_gmem.c index 9b4f31c..8ec28d9 100644 --- a/src/gallium/drivers/freedreno/a3xx/fd3_gmem.c +++ b/src/gallium/drivers/freedreno/a3xx/fd3_gmem.c @@ -468,6 +468,7 @@ fd3_emit_tile_mem2gmem(struct fd_context *ctx, struct fd_tile *tile) struct fd3_emit emit = { .vtx = &fd3_ctx->blit_vbuf_state, .prog = &ctx->blit_prog, + .sprite_coord_enable = 1, .key = { .half_precision = fd3_half_precision(format), }, diff --git a/src/gallium/drivers/freedreno/a3xx/fd3_program.c b/src/gallium/drivers/freedreno/a3xx/fd3_program.c index b6c448e..1250dff 100644 --- a/src/gallium/drivers/freedreno/a3xx/fd3_program.c +++ b/src/gallium/drivers/freedreno/a3xx/fd3_program.c @@ -365,31 +365,40 @@ fd3_program_emit(struct fd_ringbuffer *ring, struct fd3_emit *emit) COND(vp->writes_psize, A3XX_VPC_ATTR_PSIZE)); OUT_RING(ring, 0x00000000); } else { - uint32_t vinterp[4], flatshade[2]; + uint32_t vinterp[4], flatshade[2], vpsrepl[4]; memset(vinterp, 0, sizeof(vinterp)); memset(flatshade, 0, sizeof(flatshade)); + memset(vpsrepl, 0, sizeof(vpsrepl)); /* figure out VARYING_INTERP / FLAT_SHAD register values: */ for (j = -1; (j = ir3_next_varying(fp, j)) < (int)fp->inputs_count; ) { uint32_t interp = fp->inputs[j].interpolate; - if ((interp == TGSI_INTERPOLATE_CONSTANT) || - ((interp == TGSI_INTERPOLATE_COLOR) && emit->rasterflat)) { - /* TODO might be cleaner to just +8 in SP_VS_VPC_DST_REG - * instead.. rather than -8 everywhere else.. - */ - uint32_t loc = fp->inputs[j].inloc - 8; - /* currently assuming varyings aligned to 4 (not - * packed): - */ - debug_assert((loc % 4) == 0); + /* TODO might be cleaner to just +8 in SP_VS_VPC_DST_REG + * instead.. rather than -8 everywhere else.. + */ + uint32_t inloc = fp->inputs[j].inloc - 8; + + /* currently assuming varyings aligned to 4 (not + * packed): + */ + debug_assert((inloc % 4) == 0); + if ((interp == TGSI_INTERPOLATE_CONSTANT) || + ((interp == TGSI_INTERPOLATE_COLOR) && emit->rasterflat)) { + uint32_t loc = inloc; for (i = 0; i < 4; i++, loc++) { vinterp[loc / 16] |= FLAT << ((loc % 16) * 2); flatshade[loc / 32] |= 1 << (loc % 32); } } + + /* TODO: Figure out if there's a way to make it spit out 0's and + * 1's for the .z and .w components. + */ + if (emit->sprite_coord_enable & (1 << sem2idx(fp->inputs[j].semantic))) + vpsrepl[inloc / 16] |= 0x09 << ((inloc % 16) * 2); } OUT_PKT0(ring, REG_A3XX_VPC_ATTR, 2); @@ -407,10 +416,10 @@ fd3_program_emit(struct fd_ringbuffer *ring, struct fd3_emit *emit) OUT_RING(ring, vinterp[3]); /* VPC_VARYING_INTERP[3].MODE */ OUT_PKT0(ring, REG_A3XX_VPC_VARYING_PS_REPL_MODE(0), 4); - OUT_RING(ring, fp->shader->vpsrepl[0]); /* VPC_VARYING_PS_REPL[0].MODE */ - OUT_RING(ring, fp->shader->vpsrepl[1]); /* VPC_VARYING_PS_REPL[1].MODE */ - OUT_RING(ring, fp->shader->vpsrepl[2]); /* VPC_VARYING_PS_REPL[2].MODE */ - OUT_RING(ring, fp->shader->vpsrepl[3]); /* VPC_VARYING_PS_REPL[3].MODE */ + OUT_RING(ring, vpsrepl[0]); /* VPC_VARYING_PS_REPL[0].MODE */ + OUT_RING(ring, vpsrepl[1]); /* VPC_VARYING_PS_REPL[1].MODE */ + OUT_RING(ring, vpsrepl[2]); /* VPC_VARYING_PS_REPL[2].MODE */ + OUT_RING(ring, vpsrepl[3]); /* VPC_VARYING_PS_REPL[3].MODE */ OUT_PKT0(ring, REG_A3XX_SP_FS_FLAT_SHAD_MODE_REG_0, 2); OUT_RING(ring, flatshade[0]); /* SP_FS_FLAT_SHAD_MODE_REG_0 */ @@ -436,19 +445,6 @@ fd3_program_emit(struct fd_ringbuffer *ring, struct fd3_emit *emit) } } -/* hack.. until we figure out how to deal w/ vpsrepl properly.. */ -static void -fix_blit_fp(struct pipe_context *pctx) -{ - struct fd_context *ctx = fd_context(pctx); - struct fd3_shader_stateobj *so = ctx->blit_prog.fp; - - so->shader->vpsrepl[0] = 0x99999999; - so->shader->vpsrepl[1] = 0x99999999; - so->shader->vpsrepl[2] = 0x99999999; - so->shader->vpsrepl[3] = 0x99999999; -} - void fd3_prog_init(struct pipe_context *pctx) { @@ -459,6 +455,4 @@ fd3_prog_init(struct pipe_context *pctx) pctx->delete_vs_state = fd3_vp_state_delete; fd_prog_init(pctx); - - fix_blit_fp(pctx); } From evelikov at kemper.freedesktop.org Sat Mar 28 19:17:52 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Sat, 28 Mar 2015 12:17:52 -0700 (PDT) Subject: Mesa (10.5): cherry-ignore: add commit non applicable for 10.5 Message-ID: <20150328191752.3CE6B7624F@kemper.freedesktop.org> Module: Mesa Branch: 10.5 Commit: fda3bc1e039c8a97a2f204ca5746a02045719259 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=fda3bc1e039c8a97a2f204ca5746a02045719259 Author: Emil Velikov Date: Sat Mar 28 18:33:46 2015 +0000 cherry-ignore: add commit non applicable for 10.5 Signed-off-by: Emil Velikov --- bin/.cherry-ignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/bin/.cherry-ignore b/bin/.cherry-ignore index 58c07fb..ec06241 100644 --- a/bin/.cherry-ignore +++ b/bin/.cherry-ignore @@ -21,3 +21,6 @@ d22391cb165af4ed2f9a9e5d6233072a432cc969 fe5fddd7e2df74233a2a02ae021418485f39d11c # xmlpool: make sure we ship options.h 8d8ca64c28170ec7e9ffa01638bcf8fd30a96088 + +# The optimisations mentioned are not available in 10.5 +627c68308683abbd6e563a09af6013a33938a790 i965/fs: in MAD optimizations, switch last argument to be immediate From evelikov at kemper.freedesktop.org Sat Mar 28 19:17:52 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Sat, 28 Mar 2015 12:17:52 -0700 (PDT) Subject: Mesa (10.5): docs: Add sha256 sums for the 10.5.2 release Message-ID: <20150328191752.5666D7624F@kemper.freedesktop.org> Module: Mesa Branch: 10.5 Commit: ff87ae1e003be7104d3550250af3343c01cea882 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=ff87ae1e003be7104d3550250af3343c01cea882 Author: Emil Velikov Date: Sat Mar 28 18:50:31 2015 +0000 docs: Add sha256 sums for the 10.5.2 release Signed-off-by: Emil Velikov --- docs/relnotes/10.5.2.html | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/relnotes/10.5.2.html b/docs/relnotes/10.5.2.html index b094b98..9114199 100644 --- a/docs/relnotes/10.5.2.html +++ b/docs/relnotes/10.5.2.html @@ -31,7 +31,8 @@ because compatibility contexts are not supported.

      SHA256 checksums

      -TBD
      +755220e160a9f22fda0dffd47746f997b6e196d03f8edc390df7793aecaaa541  mesa-10.5.2.tar.gz
      +2f4b6fb77c3e7d6f861558d0884a3073f575e1e673dad8d1b0624e78e9c4dd44  mesa-10.5.2.tar.xz
       
      From evelikov at kemper.freedesktop.org Sat Mar 28 19:17:52 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Sat, 28 Mar 2015 12:17:52 -0700 (PDT) Subject: Mesa (10.5): Update version to 10.5.2 Message-ID: <20150328191752.455357624F@kemper.freedesktop.org> Module: Mesa Branch: 10.5 Commit: ebbfa79755b09701db9381171d22cab48e947bfa URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=ebbfa79755b09701db9381171d22cab48e947bfa Author: Emil Velikov Date: Sat Mar 28 18:36:03 2015 +0000 Update version to 10.5.2 Signed-off-by: Emil Velikov --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 4a6e70e..a39233b 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -10.5.1 +10.5.2 From evelikov at kemper.freedesktop.org Sat Mar 28 19:17:52 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Sat, 28 Mar 2015 12:17:52 -0700 (PDT) Subject: Mesa (10.5): Add release notes for the 10.5.2 release Message-ID: <20150328191752.4E0CC7624F@kemper.freedesktop.org> Module: Mesa Branch: 10.5 Commit: 5e59f895c468c1ac497ad925b8bddd7f227c89a2 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=5e59f895c468c1ac497ad925b8bddd7f227c89a2 Author: Emil Velikov Date: Sat Mar 28 18:42:51 2015 +0000 Add release notes for the 10.5.2 release Signed-off-by: Emil Velikov --- docs/relnotes/10.5.2.html | 129 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 129 insertions(+) diff --git a/docs/relnotes/10.5.2.html b/docs/relnotes/10.5.2.html new file mode 100644 index 0000000..b094b98 --- /dev/null +++ b/docs/relnotes/10.5.2.html @@ -0,0 +1,129 @@ + + + + + Mesa Release Notes + + + + +
      +

      The Mesa 3D Graphics Library

      +
      + + +
      + +

      Mesa 10.5.2 Release Notes / March 28, 2015

      + +

      +Mesa 10.5.2 is a bug fix release which fixes bugs found since the 10.5.1 release. +

      +

      +Mesa 10.5.2 implements the OpenGL 3.3 API, but the version reported by +glGetString(GL_VERSION) or glGetIntegerv(GL_MAJOR_VERSION) / +glGetIntegerv(GL_MINOR_VERSION) depends on the particular driver being used. +Some drivers don't support all the features required in OpenGL 3.3. OpenGL +3.3 is only available if requested at context creation +because compatibility contexts are not supported. +

      + + +

      SHA256 checksums

      +
      +TBD
      +
      + + +

      New features

      +

      None

      + +

      Bug fixes

      + +

      This list is likely incomplete.

      + +
        + +
      • Bug 88534 - include/c11/threads_posix.h PTHREAD_MUTEX_RECURSIVE_NP not defined
      • + +
      • Bug 89328 - python required to build Mesa release tarballs
      • + +
      • Bug 89530 - FTBFS in loader: missing fstat
      • + +
      • Bug 89590 - Crash in glLinkProgram with shaders with multiple constant arrays
      • + +
      • Bug 89680 - Hard link exist in Mesa 10.5.1 sources
      • + +
      + + +

      Changes

      + +

      Anuj Phogat (1):

      +
        +
      • glsl: Generate link error for non-matching gl_FragCoord redeclarations
      • +
      + +

      Emil Velikov (7):

      +
        +
      • docs: Add sha256 sums for the 10.5.1 release
      • +
      • automake: add missing egl files to the tarball
      • +
      • st/egl: don't ship the dri2.c link at the tarball
      • +
      • loader: include <sys/stat.h> for non-sysfs builds
      • +
      • auxiliary/os: fix the android build - s/drm_munmap/os_munmap/
      • +
      • cherry-ignore: add commit non applicable for 10.5
      • +
      • Update version to 10.5.2
      • +
      + +

      Felix Janda (1):

      +
        +
      • c11/threads: Use PTHREAD_MUTEX_RECURSIVE by default
      • +
      + +

      Francisco Jerez (1):

      +
        +
      • i965: Set nr_params to the number of uniform components in the VS/GS path.
      • +
      + +

      Ilia Mirkin (2):

      +
        +
      • freedreno/a3xx: use the same layer size for all slices
      • +
      • freedreno: fix slice pitch calculations
      • +
      + +

      Marek Ol??k (1):

      +
        +
      • radeonsi: increase coords array size for radeon_llvm_emit_prepare_cube_coords
      • +
      + +

      Mario Kleiner (2):

      +
        +
      • glx: Handle out-of-sequence swap completion events correctly. (v2)
      • +
      • mapi: Make private copies of name strings provided by client.
      • +
      + +

      Rob Clark (1):

      +
        +
      • freedreno: update generated headers
      • +
      + +

      Samuel Iglesias Gonsalvez (2):

      +
        +
      • glsl: optimize (0 cmp x + y) into (-x cmp y).
      • +
      • configure: Introduce new output variable to ax_check_python_mako_module.m4
      • +
      + +

      Tapani P?lli (1):

      +
        +
      • glsl: fix names in lower_constant_arrays_to_uniforms
      • +
      + +

      Tom Stellard (1):

      +
        +
      • clover: Return 0 as storage size for local kernel args that are not set v2
      • +
      + + +
      + + From evelikov at kemper.freedesktop.org Sat Mar 28 19:17:52 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Sat, 28 Mar 2015 12:17:52 -0700 (PDT) Subject: Mesa: tag mesa-10.5.2: Mesa 10.5.2 release Message-ID: <20150328191752.691E97624F@kemper.freedesktop.org> Module: Mesa Branch: refs/tags/mesa-10.5.2 Tag: 256e70134d289aaac6869796966a8bd26262b472 URL: http://cgit.freedesktop.org/mesa/mesa/tag/?id=256e70134d289aaac6869796966a8bd26262b472 Tagger: Emil Velikov Date: Sat Mar 28 18:44:08 2015 +0000 Mesa 10.5.2 release From evelikov at kemper.freedesktop.org Sat Mar 28 19:18:37 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Sat, 28 Mar 2015 12:18:37 -0700 (PDT) Subject: Mesa (master): Add release notes for the 10.5.2 release Message-ID: <20150328191837.E85C07624F@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 6e19f6b4d0073ff863bb76cffd9e4dd637e3b628 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=6e19f6b4d0073ff863bb76cffd9e4dd637e3b628 Author: Emil Velikov Date: Sat Mar 28 18:42:51 2015 +0000 Add release notes for the 10.5.2 release Signed-off-by: Emil Velikov (cherry picked from commit 5e59f895c468c1ac497ad925b8bddd7f227c89a2) --- docs/relnotes/10.5.2.html | 129 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 129 insertions(+) diff --git a/docs/relnotes/10.5.2.html b/docs/relnotes/10.5.2.html new file mode 100644 index 0000000..b094b98 --- /dev/null +++ b/docs/relnotes/10.5.2.html @@ -0,0 +1,129 @@ + + + + + Mesa Release Notes + + + + +
      +

      The Mesa 3D Graphics Library

      +
      + + +
      + +

      Mesa 10.5.2 Release Notes / March 28, 2015

      + +

      +Mesa 10.5.2 is a bug fix release which fixes bugs found since the 10.5.1 release. +

      +

      +Mesa 10.5.2 implements the OpenGL 3.3 API, but the version reported by +glGetString(GL_VERSION) or glGetIntegerv(GL_MAJOR_VERSION) / +glGetIntegerv(GL_MINOR_VERSION) depends on the particular driver being used. +Some drivers don't support all the features required in OpenGL 3.3. OpenGL +3.3 is only available if requested at context creation +because compatibility contexts are not supported. +

      + + +

      SHA256 checksums

      +
      +TBD
      +
      + + +

      New features

      +

      None

      + +

      Bug fixes

      + +

      This list is likely incomplete.

      + +
        + +
      • Bug 88534 - include/c11/threads_posix.h PTHREAD_MUTEX_RECURSIVE_NP not defined
      • + +
      • Bug 89328 - python required to build Mesa release tarballs
      • + +
      • Bug 89530 - FTBFS in loader: missing fstat
      • + +
      • Bug 89590 - Crash in glLinkProgram with shaders with multiple constant arrays
      • + +
      • Bug 89680 - Hard link exist in Mesa 10.5.1 sources
      • + +
      + + +

      Changes

      + +

      Anuj Phogat (1):

      +
        +
      • glsl: Generate link error for non-matching gl_FragCoord redeclarations
      • +
      + +

      Emil Velikov (7):

      +
        +
      • docs: Add sha256 sums for the 10.5.1 release
      • +
      • automake: add missing egl files to the tarball
      • +
      • st/egl: don't ship the dri2.c link at the tarball
      • +
      • loader: include <sys/stat.h> for non-sysfs builds
      • +
      • auxiliary/os: fix the android build - s/drm_munmap/os_munmap/
      • +
      • cherry-ignore: add commit non applicable for 10.5
      • +
      • Update version to 10.5.2
      • +
      + +

      Felix Janda (1):

      +
        +
      • c11/threads: Use PTHREAD_MUTEX_RECURSIVE by default
      • +
      + +

      Francisco Jerez (1):

      +
        +
      • i965: Set nr_params to the number of uniform components in the VS/GS path.
      • +
      + +

      Ilia Mirkin (2):

      +
        +
      • freedreno/a3xx: use the same layer size for all slices
      • +
      • freedreno: fix slice pitch calculations
      • +
      + +

      Marek Ol??k (1):

      +
        +
      • radeonsi: increase coords array size for radeon_llvm_emit_prepare_cube_coords
      • +
      + +

      Mario Kleiner (2):

      +
        +
      • glx: Handle out-of-sequence swap completion events correctly. (v2)
      • +
      • mapi: Make private copies of name strings provided by client.
      • +
      + +

      Rob Clark (1):

      +
        +
      • freedreno: update generated headers
      • +
      + +

      Samuel Iglesias Gonsalvez (2):

      +
        +
      • glsl: optimize (0 cmp x + y) into (-x cmp y).
      • +
      • configure: Introduce new output variable to ax_check_python_mako_module.m4
      • +
      + +

      Tapani P?lli (1):

      +
        +
      • glsl: fix names in lower_constant_arrays_to_uniforms
      • +
      + +

      Tom Stellard (1):

      +
        +
      • clover: Return 0 as storage size for local kernel args that are not set v2
      • +
      + + +
      + + From evelikov at kemper.freedesktop.org Sat Mar 28 19:18:37 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Sat, 28 Mar 2015 12:18:37 -0700 (PDT) Subject: Mesa (master): docs: Add sha256 sums for the 10.5.2 release Message-ID: <20150328191837.F328B7624F@kemper.freedesktop.org> Module: Mesa Branch: master Commit: dc8d8a29515cc7dc96b9c0820e31de0bbe20ed38 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=dc8d8a29515cc7dc96b9c0820e31de0bbe20ed38 Author: Emil Velikov Date: Sat Mar 28 18:50:31 2015 +0000 docs: Add sha256 sums for the 10.5.2 release Signed-off-by: Emil Velikov (cherry picked from commit ff87ae1e003be7104d3550250af3343c01cea882) --- docs/relnotes/10.5.2.html | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/relnotes/10.5.2.html b/docs/relnotes/10.5.2.html index b094b98..9114199 100644 --- a/docs/relnotes/10.5.2.html +++ b/docs/relnotes/10.5.2.html @@ -31,7 +31,8 @@ because compatibility contexts are not supported.

      SHA256 checksums

      -TBD
      +755220e160a9f22fda0dffd47746f997b6e196d03f8edc390df7793aecaaa541  mesa-10.5.2.tar.gz
      +2f4b6fb77c3e7d6f861558d0884a3073f575e1e673dad8d1b0624e78e9c4dd44  mesa-10.5.2.tar.xz
       
      From evelikov at kemper.freedesktop.org Sat Mar 28 19:18:38 2015 From: evelikov at kemper.freedesktop.org (Emil Velikov) Date: Sat, 28 Mar 2015 12:18:38 -0700 (PDT) Subject: Mesa (master): docs: add news item and link release notes for mesa 10.5.2 Message-ID: <20150328191838.0AD067624F@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 938b17940fe0f9823665c1450c1254936651e9d9 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=938b17940fe0f9823665c1450c1254936651e9d9 Author: Emil Velikov Date: Sat Mar 28 19:01:15 2015 +0000 docs: add news item and link release notes for mesa 10.5.2 Signed-off-by: Emil Velikov --- docs/index.html | 6 ++++++ docs/relnotes.html | 1 + 2 files changed, 7 insertions(+) diff --git a/docs/index.html b/docs/index.html index 9bc5843..f6be764 100644 --- a/docs/index.html +++ b/docs/index.html @@ -16,6 +16,12 @@

      News

      +

      March 28, 2015

      +

      +Mesa 10.5.2 is released. +This is a bug-fix release. +

      +

      March 20, 2015

      Mesa 10.4.7 is released. diff --git a/docs/relnotes.html b/docs/relnotes.html index 023f7dd8..2bfd9ce 100644 --- a/docs/relnotes.html +++ b/docs/relnotes.html @@ -21,6 +21,7 @@ The release notes summarize what's new or changed in each Mesa release.

        +
      • 10.5.2 release notes
      • 10.4.7 release notes
      • 10.5.1 release notes
      • 10.5.0 release notes From tpalli at kemper.freedesktop.org Mon Mar 30 05:17:04 2015 From: tpalli at kemper.freedesktop.org (Tapani Pälli) Date: Sun, 29 Mar 2015 22:17:04 -0700 (PDT) Subject: Mesa (master): glsl: fix unreachable(!"") to unreachable("") Message-ID: <20150330051704.940F176250@kemper.freedesktop.org> Module: Mesa Branch: master Commit: ce83a6ec8142894531cfad8cd677cd3dc47eced7 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=ce83a6ec8142894531cfad8cd677cd3dc47eced7 Author: Tapani P?lli Date: Mon Mar 30 07:59:53 2015 +0300 glsl: fix unreachable(!"") to unreachable("") Correct error with commit 151fb1e where assert was renamed to unreachable without removing ! from string argument. Signed-off-by: Tapani P?lli Reviewed-by: Ilia Mirkin --- src/glsl/loop_controls.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/glsl/loop_controls.cpp b/src/glsl/loop_controls.cpp index d7f0b28..51804bb 100644 --- a/src/glsl/loop_controls.cpp +++ b/src/glsl/loop_controls.cpp @@ -139,7 +139,7 @@ calculate_iterations(ir_rvalue *from, ir_rvalue *to, ir_rvalue *increment, iter = new(mem_ctx) ir_constant(double(iter_value + bias[i])); break; default: - unreachable(!"Unsupported type for loop iterator."); + unreachable("Unsupported type for loop iterator."); } ir_expression *const mul = From daenzer at kemper.freedesktop.org Mon Mar 30 06:15:55 2015 From: daenzer at kemper.freedesktop.org (Michel Dänzer) Date: Sun, 29 Mar 2015 23:15:55 -0700 (PDT) Subject: Mesa (master): radeonsi: Cache LLVMTargetMachineRef in context instead of in screen Message-ID: <20150330061556.00BF376250@kemper.freedesktop.org> Module: Mesa Branch: master Commit: d64adc3a79e419062432cfa8d1cbc437676a3fbd URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=d64adc3a79e419062432cfa8d1cbc437676a3fbd Author: Michel D?nzer Date: Thu Mar 26 11:32:59 2015 +0900 radeonsi: Cache LLVMTargetMachineRef in context instead of in screen Fixes a crash in genymotion with several threads compiling shaders concurrently. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=89746 Cc: 10.5 Reviewed-by: Tom Stellard --- src/gallium/drivers/radeonsi/si_compute.c | 3 +- src/gallium/drivers/radeonsi/si_pipe.c | 43 ++++++++++++----------- src/gallium/drivers/radeonsi/si_pipe.h | 3 +- src/gallium/drivers/radeonsi/si_shader.c | 13 ++++--- src/gallium/drivers/radeonsi/si_shader.h | 5 +-- src/gallium/drivers/radeonsi/si_state_shaders.c | 4 ++- 6 files changed, 41 insertions(+), 30 deletions(-) diff --git a/src/gallium/drivers/radeonsi/si_compute.c b/src/gallium/drivers/radeonsi/si_compute.c index 8609b89..89bef2e 100644 --- a/src/gallium/drivers/radeonsi/si_compute.c +++ b/src/gallium/drivers/radeonsi/si_compute.c @@ -130,7 +130,8 @@ static void *si_create_compute_state( for (i = 0; i < program->num_kernels; i++) { LLVMModuleRef mod = radeon_llvm_get_kernel_module(program->llvm_ctx, i, code, header->num_bytes); - si_compile_llvm(sctx->screen, &program->kernels[i], mod); + si_compile_llvm(sctx->screen, &program->kernels[i], sctx->tm, + mod); LLVMDisposeModule(mod); } } diff --git a/src/gallium/drivers/radeonsi/si_pipe.c b/src/gallium/drivers/radeonsi/si_pipe.c index d335bda..0eada72 100644 --- a/src/gallium/drivers/radeonsi/si_pipe.c +++ b/src/gallium/drivers/radeonsi/si_pipe.c @@ -69,6 +69,11 @@ static void si_destroy_context(struct pipe_context *context) si_pm4_cleanup(sctx); r600_common_context_cleanup(&sctx->b); + +#if HAVE_LLVM >= 0x0306 + LLVMDisposeTargetMachine(sctx->tm); +#endif + FREE(sctx); } @@ -77,6 +82,12 @@ static struct pipe_context *si_create_context(struct pipe_screen *screen, void * struct si_context *sctx = CALLOC_STRUCT(si_context); struct si_screen* sscreen = (struct si_screen *)screen; struct radeon_winsys *ws = sscreen->b.ws; + LLVMTargetRef r600_target; +#if HAVE_LLVM >= 0x0306 + const char *triple = "amdgcn--"; +#else + const char *triple = "r600--"; +#endif int shader, i; if (sctx == NULL) @@ -170,6 +181,17 @@ static struct pipe_context *si_create_context(struct pipe_screen *screen, void * */ sctx->scratch_waves = 32 * sscreen->b.info.max_compute_units; +#if HAVE_LLVM >= 0x0306 + /* Initialize LLVM TargetMachine */ + r600_target = radeon_llvm_get_r600_target(triple); + sctx->tm = LLVMCreateTargetMachine(r600_target, triple, + r600_get_llvm_processor_name(sscreen->b.family), + "+DumpCode,+vgpr-spilling", + LLVMCodeGenLevelDefault, + LLVMRelocDefault, + LLVMCodeModelDefault); +#endif + return &sctx->b.b; fail: si_destroy_context(&sctx->b.b); @@ -445,12 +467,6 @@ static void si_destroy_screen(struct pipe_screen* pscreen) if (!sscreen->b.ws->unref(sscreen->b.ws)) return; -#if HAVE_LLVM >= 0x0306 - // r600_destroy_common_screen() frees sscreen, so we need to make - // sure to dispose the TargetMachine before we call it. - LLVMDisposeTargetMachine(sscreen->tm); -#endif - r600_destroy_common_screen(&sscreen->b); } @@ -508,12 +524,7 @@ static bool si_initialize_pipe_config(struct si_screen *sscreen) struct pipe_screen *radeonsi_screen_create(struct radeon_winsys *ws) { struct si_screen *sscreen = CALLOC_STRUCT(si_screen); - LLVMTargetRef r600_target; -#if HAVE_LLVM >= 0x0306 - const char *triple = "amdgcn--"; -#else - const char *triple = "r600--"; -#endif + if (sscreen == NULL) { return NULL; } @@ -541,13 +552,5 @@ struct pipe_screen *radeonsi_screen_create(struct radeon_winsys *ws) /* Create the auxiliary context. This must be done last. */ sscreen->b.aux_context = sscreen->b.b.context_create(&sscreen->b.b, NULL); -#if HAVE_LLVM >= 0x0306 - /* Initialize LLVM TargetMachine */ - r600_target = radeon_llvm_get_r600_target(triple); - sscreen->tm = LLVMCreateTargetMachine(r600_target, triple, - r600_get_llvm_processor_name(sscreen->b.family), - "+DumpCode,+vgpr-spilling", LLVMCodeGenLevelDefault, LLVMRelocDefault, - LLVMCodeModelDefault); -#endif return &sscreen->b.b; } diff --git a/src/gallium/drivers/radeonsi/si_pipe.h b/src/gallium/drivers/radeonsi/si_pipe.h index 422b873..f98c7a8 100644 --- a/src/gallium/drivers/radeonsi/si_pipe.h +++ b/src/gallium/drivers/radeonsi/si_pipe.h @@ -85,7 +85,6 @@ struct si_compute; struct si_screen { struct r600_common_screen b; - LLVMTargetMachineRef tm; }; struct si_sampler_view { @@ -203,6 +202,8 @@ struct si_context { struct pipe_resource *esgs_ring; struct pipe_resource *gsvs_ring; + LLVMTargetMachineRef tm; + /* SI state handling */ union si_state queued; union si_state emitted; diff --git a/src/gallium/drivers/radeonsi/si_shader.c b/src/gallium/drivers/radeonsi/si_shader.c index 4dcf756..b4709ac 100644 --- a/src/gallium/drivers/radeonsi/si_shader.c +++ b/src/gallium/drivers/radeonsi/si_shader.c @@ -72,6 +72,7 @@ struct si_shader_context int param_streamout_offset[4]; int param_vertex_id; int param_instance_id; + LLVMTargetMachineRef tm; LLVMValueRef const_md; LLVMValueRef const_resource[SI_NUM_CONST_BUFFERS]; LLVMValueRef ddxy_lds; @@ -2697,13 +2698,13 @@ int si_shader_binary_read(struct si_screen *sscreen, } int si_compile_llvm(struct si_screen *sscreen, struct si_shader *shader, - LLVMModuleRef mod) + LLVMTargetMachineRef tm, LLVMModuleRef mod) { int r = 0; bool dump = r600_can_dump_shader(&sscreen->b, shader->selector ? shader->selector->tokens : NULL); r = radeon_llvm_compile(mod, &shader->binary, - r600_get_llvm_processor_name(sscreen->b.family), dump, sscreen->tm); + r600_get_llvm_processor_name(sscreen->b.family), dump, tm); if (r) { return r; @@ -2791,7 +2792,7 @@ static int si_generate_gs_copy_shader(struct si_screen *sscreen, fprintf(stderr, "Copy Vertex Shader for Geometry Shader:\n\n"); r = si_compile_llvm(sscreen, si_shader_ctx->shader, - bld_base->base.gallivm->module); + si_shader_ctx->tm, bld_base->base.gallivm->module); radeon_llvm_dispose(&si_shader_ctx->radeon_bld); @@ -2836,7 +2837,8 @@ static void si_dump_key(unsigned shader, union si_shader_key *key) } } -int si_shader_create(struct si_screen *sscreen, struct si_shader *shader) +int si_shader_create(struct si_screen *sscreen, LLVMTargetMachineRef tm, + struct si_shader *shader) { struct si_shader_selector *sel = shader->selector; struct tgsi_token *tokens = sel->tokens; @@ -2909,6 +2911,7 @@ int si_shader_create(struct si_screen *sscreen, struct si_shader *shader) si_shader_ctx.shader = shader; si_shader_ctx.type = tgsi_get_processor_type(tokens); si_shader_ctx.screen = sscreen; + si_shader_ctx.tm = tm; switch (si_shader_ctx.type) { case TGSI_PROCESSOR_VERTEX: @@ -2964,7 +2967,7 @@ int si_shader_create(struct si_screen *sscreen, struct si_shader *shader) radeon_llvm_finalize_module(&si_shader_ctx.radeon_bld); mod = bld_base->base.gallivm->module; - r = si_compile_llvm(sscreen, shader, mod); + r = si_compile_llvm(sscreen, shader, tm, mod); if (r) { fprintf(stderr, "LLVM failed to compile shader\n"); goto out; diff --git a/src/gallium/drivers/radeonsi/si_shader.h b/src/gallium/drivers/radeonsi/si_shader.h index 5b602ac..51055af 100644 --- a/src/gallium/drivers/radeonsi/si_shader.h +++ b/src/gallium/drivers/radeonsi/si_shader.h @@ -183,9 +183,10 @@ static inline struct si_shader* si_get_vs_state(struct si_context *sctx) } /* radeonsi_shader.c */ -int si_shader_create(struct si_screen *sscreen, struct si_shader *shader); +int si_shader_create(struct si_screen *sscreen, LLVMTargetMachineRef tm, + struct si_shader *shader); int si_compile_llvm(struct si_screen *sscreen, struct si_shader *shader, - LLVMModuleRef mod); + LLVMTargetMachineRef tm, LLVMModuleRef mod); void si_shader_destroy(struct pipe_context *ctx, struct si_shader *shader); unsigned si_shader_io_get_unique_index(unsigned semantic_name, unsigned index); int si_shader_binary_read(struct si_screen *sscreen, struct si_shader *shader, diff --git a/src/gallium/drivers/radeonsi/si_state_shaders.c b/src/gallium/drivers/radeonsi/si_state_shaders.c index 382738a..b0a6fb9 100644 --- a/src/gallium/drivers/radeonsi/si_state_shaders.c +++ b/src/gallium/drivers/radeonsi/si_state_shaders.c @@ -405,6 +405,7 @@ static INLINE void si_shader_selector_key(struct pipe_context *ctx, static int si_shader_select(struct pipe_context *ctx, struct si_shader_selector *sel) { + struct si_context *sctx = (struct si_context *)ctx; union si_shader_key key; struct si_shader * shader = NULL; int r; @@ -444,7 +445,8 @@ static int si_shader_select(struct pipe_context *ctx, shader->next_variant = sel->current; sel->current = shader; - r = si_shader_create((struct si_screen*)ctx->screen, shader); + r = si_shader_create((struct si_screen*)ctx->screen, sctx->tm, + shader); if (unlikely(r)) { R600_ERR("Failed to build shader variant (type=%u) %d\n", sel->type, r); From samuelig at kemper.freedesktop.org Mon Mar 30 11:30:07 2015 From: samuelig at kemper.freedesktop.org (Samuel Iglesias Gonsálvez) Date: Mon, 30 Mar 2015 04:30:07 -0700 (PDT) Subject: Mesa (master): glsl: fail when a shader' s input var has not an equivalent out var in previous Message-ID: <20150330113007.5795776250@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 18004c338f6be8af2e36d2f54972c60136229aeb URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=18004c338f6be8af2e36d2f54972c60136229aeb Author: Samuel Iglesias Gonsalvez Date: Fri Nov 28 11:23:20 2014 +0100 glsl: fail when a shader's input var has not an equivalent out var in previous GLSL ES 3.00 spec, 4.3.10 (Linking of Vertex Outputs and Fragment Inputs), page 45 says the following: "The type of vertex outputs and fragment input with the same name must match, otherwise the link command will fail. The precision does not need to match. Only those fragment inputs statically used (i.e. read) in the fragment shader must be declared as outputs in the vertex shader; declaring superfluous vertex shader outputs is permissible." [...] "The term static use means that after preprocessing the shader includes at least one statement that accesses the input or output, even if that statement is never actually executed." And it includes a table with all the possibilities. Similar table or content is present in other GLSL specs: GLSL 4.40, GLSL 1.50, etc but for more stages (vertex and geometry shaders, etc). This patch detects that case and returns a link error. It fixes the following dEQP test: dEQP-GLES3.functional.shaders.linkage.varying.rules.illegal_usage_1 However, it adds a new regression in piglit because the test hasn't a vertex shader and it checks the link status. bin/glslparsertest \ tests/spec/glsl-1.50/compiler/gs-also-uses-smooth-flat-noperspective.geom pass \ 1.50 --check-link This piglit test is wrong according to the spec wording above, so if this patch is merged it should be updated. Signed-off-by: Samuel Iglesias Gonsalvez Reviewed-by: Ben Widawsky --- src/glsl/link_varyings.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/glsl/link_varyings.cpp b/src/glsl/link_varyings.cpp index 2261799..d6fb1ea 100644 --- a/src/glsl/link_varyings.cpp +++ b/src/glsl/link_varyings.cpp @@ -263,6 +263,19 @@ cross_validate_outputs_to_inputs(struct gl_shader_program *prog, if (output != NULL) { cross_validate_types_and_qualifiers(prog, input, output, consumer->Stage, producer->Stage); + } else { + /* Check for input vars with unmatched output vars in prev stage + * taking into account that interface blocks could have a matching + * output but with different name, so we ignore them. + */ + assert(!input->data.assigned); + if (input->data.used && !input->get_interface_type() && + !input->data.explicit_location) + linker_error(prog, + "%s shader input `%s' " + "has no matching output in the previous stage\n", + _mesa_shader_stage_to_string(consumer->Stage), + input->name); } } } From anholt at kemper.freedesktop.org Mon Mar 30 16:40:08 2015 From: anholt at kemper.freedesktop.org (Eric Anholt) Date: Mon, 30 Mar 2015 09:40:08 -0700 (PDT) Subject: Mesa (master): vc4: Make integer multiply use 24 bits for the low parts. Message-ID: <20150330164008.49E7F7633A@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 5df8bf86fe40ae95ad3888cb167ce80c710af227 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=5df8bf86fe40ae95ad3888cb167ce80c710af227 Author: Eric Anholt Date: Sun Mar 29 21:21:10 2015 -0700 vc4: Make integer multiply use 24 bits for the low parts. The hardware uses the low 24 bits in integer multiplies, so we can have fewer high bits (and so probably drop them more frequently). --- src/gallium/drivers/vc4/vc4_program.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/gallium/drivers/vc4/vc4_program.c b/src/gallium/drivers/vc4/vc4_program.c index 56a3a96..49b9466 100644 --- a/src/gallium/drivers/vc4/vc4_program.c +++ b/src/gallium/drivers/vc4/vc4_program.c @@ -367,13 +367,13 @@ tgsi_to_qir_umul(struct vc4_compile *c, enum qop op, struct qreg *src, int i) { struct qreg src0_hi = qir_SHR(c, src[0 * 4 + i], - qir_uniform_ui(c, 16)); + qir_uniform_ui(c, 24)); struct qreg src0_lo = qir_AND(c, src[0 * 4 + i], - qir_uniform_ui(c, 0xffff)); + qir_uniform_ui(c, 0xffffff)); struct qreg src1_hi = qir_SHR(c, src[1 * 4 + i], - qir_uniform_ui(c, 16)); + qir_uniform_ui(c, 24)); struct qreg src1_lo = qir_AND(c, src[1 * 4 + i], - qir_uniform_ui(c, 0xffff)); + qir_uniform_ui(c, 0xffffff)); struct qreg hilo = qir_MUL24(c, src0_hi, src1_lo); struct qreg lohi = qir_MUL24(c, src0_lo, src1_hi); @@ -381,7 +381,7 @@ tgsi_to_qir_umul(struct vc4_compile *c, return qir_ADD(c, lolo, qir_SHL(c, qir_ADD(c, hilo, lohi), - qir_uniform_ui(c, 16))); + qir_uniform_ui(c, 24))); } static struct qreg From anholt at kemper.freedesktop.org Mon Mar 30 16:40:08 2015 From: anholt at kemper.freedesktop.org (Eric Anholt) Date: Mon, 30 Mar 2015 09:40:08 -0700 (PDT) Subject: Mesa (master): vc4: Don' t bother masking out the low 24 bits for integer multiplies Message-ID: <20150330164008.566EA7635A@kemper.freedesktop.org> Module: Mesa Branch: master Commit: c519c4d85e7b4f9cad4e51dc08e8ae99bf3c810d URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=c519c4d85e7b4f9cad4e51dc08e8ae99bf3c810d Author: Eric Anholt Date: Sun Mar 29 21:26:16 2015 -0700 vc4: Don't bother masking out the low 24 bits for integer multiplies The hardware just uses the low 24 lines, saving us an AND to drop the high bits. total uniforms in shared programs: 13433 -> 13423 (-0.07%) uniforms in affected programs: 356 -> 346 (-2.81%) total instructions in shared programs: 40003 -> 39989 (-0.03%) instructions in affected programs: 910 -> 896 (-1.54%) --- src/gallium/drivers/vc4/vc4_program.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/src/gallium/drivers/vc4/vc4_program.c b/src/gallium/drivers/vc4/vc4_program.c index 49b9466..9e145e5 100644 --- a/src/gallium/drivers/vc4/vc4_program.c +++ b/src/gallium/drivers/vc4/vc4_program.c @@ -366,18 +366,14 @@ tgsi_to_qir_umul(struct vc4_compile *c, struct tgsi_full_instruction *tgsi_inst, enum qop op, struct qreg *src, int i) { - struct qreg src0_hi = qir_SHR(c, src[0 * 4 + i], - qir_uniform_ui(c, 24)); - struct qreg src0_lo = qir_AND(c, src[0 * 4 + i], - qir_uniform_ui(c, 0xffffff)); - struct qreg src1_hi = qir_SHR(c, src[1 * 4 + i], - qir_uniform_ui(c, 24)); - struct qreg src1_lo = qir_AND(c, src[1 * 4 + i], - qir_uniform_ui(c, 0xffffff)); - - struct qreg hilo = qir_MUL24(c, src0_hi, src1_lo); - struct qreg lohi = qir_MUL24(c, src0_lo, src1_hi); - struct qreg lolo = qir_MUL24(c, src0_lo, src1_lo); + struct qreg src0 = src[0 * 4 + i]; + struct qreg src0_hi = qir_SHR(c, src0, qir_uniform_ui(c, 24)); + struct qreg src1 = src[1 * 4 + i]; + struct qreg src1_hi = qir_SHR(c, src1, qir_uniform_ui(c, 24)); + + struct qreg hilo = qir_MUL24(c, src0_hi, src1); + struct qreg lohi = qir_MUL24(c, src0, src1_hi); + struct qreg lolo = qir_MUL24(c, src0, src1); return qir_ADD(c, lolo, qir_SHL(c, qir_ADD(c, hilo, lohi), From brianp at kemper.freedesktop.org Mon Mar 30 17:26:11 2015 From: brianp at kemper.freedesktop.org (Brian Paul) Date: Mon, 30 Mar 2015 10:26:11 -0700 (PDT) Subject: Mesa (master): glsl: allow ForceGLSLVersion to override #version directives Message-ID: <20150330172611.E5A487633A@kemper.freedesktop.org> Module: Mesa Branch: master Commit: dbe67d76e0487b04a7b6081d9d46666db3c3ee3e URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=dbe67d76e0487b04a7b6081d9d46666db3c3ee3e Author: Brian Paul Date: Fri Mar 27 10:54:10 2015 -0600 glsl: allow ForceGLSLVersion to override #version directives Previously, the ctx->Const.ForceGLSLVersion setting only worked if the shader lacked a #version directive. Now, the ForceGLSLVersion setting will override the #version directive too. This change should be safe since it should be rare to have an app that has a mix of shader versions and we only wanted to override the #version for shaders which lacked the #version directive. Reviewed-by: Ilia Mirkin --- src/glsl/glsl_parser_extras.cpp | 11 +++++++---- src/glsl/glsl_parser_extras.h | 1 + src/mesa/main/mtypes.h | 4 ++-- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/glsl/glsl_parser_extras.cpp b/src/glsl/glsl_parser_extras.cpp index 79624bc..0aa3c54 100644 --- a/src/glsl/glsl_parser_extras.cpp +++ b/src/glsl/glsl_parser_extras.cpp @@ -73,8 +73,8 @@ _mesa_glsl_parse_state::_mesa_glsl_parse_state(struct gl_context *_ctx, this->uses_builtin_functions = false; /* Set default language version and extensions */ - this->language_version = ctx->Const.ForceGLSLVersion ? - ctx->Const.ForceGLSLVersion : 110; + this->language_version = 110; + this->forced_language_version = ctx->Const.ForceGLSLVersion; this->es_shader = false; this->ARB_texture_rectangle_enable = true; @@ -320,11 +320,14 @@ _mesa_glsl_parse_state::process_version_directive(YYLTYPE *locp, int version, this->ARB_texture_rectangle_enable = false; } - this->language_version = version; + if (this->forced_language_version) + this->language_version = this->forced_language_version; + else + this->language_version = version; bool supported = false; for (unsigned i = 0; i < this->num_supported_versions; i++) { - if (this->supported_versions[i].ver == (unsigned) version + if (this->supported_versions[i].ver == this->language_version && this->supported_versions[i].es == this->es_shader) { supported = true; break; diff --git a/src/glsl/glsl_parser_extras.h b/src/glsl/glsl_parser_extras.h index 0975c86..1f5478b 100644 --- a/src/glsl/glsl_parser_extras.h +++ b/src/glsl/glsl_parser_extras.h @@ -226,6 +226,7 @@ struct _mesa_glsl_parse_state { bool es_shader; unsigned language_version; + unsigned forced_language_version; gl_shader_stage stage; /** diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 8e1dba6..f718768 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -3527,8 +3527,8 @@ struct gl_constants GLboolean ForceGLSLExtensionsWarn; /** - * If non-zero, forces GLSL shaders without the #version directive to behave - * as if they began with "#version ForceGLSLVersion". + * If non-zero, forces GLSL shaders to behave as if they began + * with "#version ForceGLSLVersion". */ GLuint ForceGLSLVersion; From anholt at kemper.freedesktop.org Mon Mar 30 20:03:26 2015 From: anholt at kemper.freedesktop.org (Eric Anholt) Date: Mon, 30 Mar 2015 13:03:26 -0700 (PDT) Subject: Mesa (master): vc4: Add a constant folding pass. Message-ID: <20150330200326.BA5387633A@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 8c5dcdbccb68b73d2856d9c1faafadc536e682e3 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=8c5dcdbccb68b73d2856d9c1faafadc536e682e3 Author: Eric Anholt Date: Mon Mar 30 10:38:21 2015 -0700 vc4: Add a constant folding pass. This cleans up some pointless operations generated by the in-driver mul24 lowering (commonly generated by making a vec4 index for a matrix in a uniform array). I could fill in other operations, but pretty much anything else ought to be getting handled at the NIR level, I think. total uniforms in shared programs: 13423 -> 13421 (-0.01%) uniforms in affected programs: 346 -> 344 (-0.58%) --- src/gallium/drivers/vc4/Makefile.sources | 1 + src/gallium/drivers/vc4/vc4_opt_constant_folding.c | 110 ++++++++++++++++++++ src/gallium/drivers/vc4/vc4_qir.c | 1 + src/gallium/drivers/vc4/vc4_qir.h | 1 + 4 files changed, 113 insertions(+) diff --git a/src/gallium/drivers/vc4/Makefile.sources b/src/gallium/drivers/vc4/Makefile.sources index c7254ea..ec0f25c 100644 --- a/src/gallium/drivers/vc4/Makefile.sources +++ b/src/gallium/drivers/vc4/Makefile.sources @@ -12,6 +12,7 @@ C_SOURCES := \ vc4_fence.c \ vc4_formats.c \ vc4_opt_algebraic.c \ + vc4_opt_constant_folding.c \ vc4_opt_copy_propagation.c \ vc4_opt_cse.c \ vc4_opt_dead_code.c \ diff --git a/src/gallium/drivers/vc4/vc4_opt_constant_folding.c b/src/gallium/drivers/vc4/vc4_opt_constant_folding.c new file mode 100644 index 0000000..ac9be5c --- /dev/null +++ b/src/gallium/drivers/vc4/vc4_opt_constant_folding.c @@ -0,0 +1,110 @@ +/* + * Copyright ? 2015 Broadcom + * + * 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. + */ + +/** + * @file vc4_opt_constant_folding.c + * + * Simple constant folding pass to clean up operations on only constants, + * which we might have generated within vc4_program.c. + */ + +#include "vc4_qir.h" +#include "util/u_math.h" + +static bool debug; + +static void +dump_from(struct vc4_compile *c, struct qinst *inst) +{ + if (!debug) + return; + + fprintf(stderr, "optimizing: "); + qir_dump_inst(c, inst); + fprintf(stderr, "\n"); +} + +static void +dump_to(struct vc4_compile *c, struct qinst *inst) +{ + if (!debug) + return; + + fprintf(stderr, "to: "); + qir_dump_inst(c, inst); + fprintf(stderr, "\n"); +} + +static bool +constant_fold(struct vc4_compile *c, struct qinst *inst) +{ + int nsrc = qir_get_op_nsrc(inst->op); + uint32_t ui[nsrc]; + + for (int i = 0; i < nsrc; i++) { + struct qreg reg = inst->src[i]; + if (reg.file == QFILE_UNIF && + c->uniform_contents[reg.index] == QUNIFORM_CONSTANT) { + ui[i] = c->uniform_data[reg.index]; + } else if (reg.file == QFILE_SMALL_IMM) { + ui[i] = reg.index; + } else { + return false; + } + } + + uint32_t result = 0; + switch (inst->op) { + case QOP_SHR: + result = ui[0] >> ui[1]; + break; + + default: + return false; + } + + dump_from(c, inst); + + inst->src[0] = qir_uniform_ui(c, result); + for (int i = 1; i < nsrc; i++) + inst->src[i] = c->undef; + inst->op = QOP_MOV; + + dump_to(c, inst); + return true; +} + +bool +qir_opt_constant_folding(struct vc4_compile *c) +{ + bool progress = false; + struct simple_node *node; + + foreach(node, &c->instructions) { + struct qinst *inst = (struct qinst *)node; + if (constant_fold(c, inst)) + progress = true; + } + + return progress; +} diff --git a/src/gallium/drivers/vc4/vc4_qir.c b/src/gallium/drivers/vc4/vc4_qir.c index e453d84..93be98a 100644 --- a/src/gallium/drivers/vc4/vc4_qir.c +++ b/src/gallium/drivers/vc4/vc4_qir.c @@ -512,6 +512,7 @@ qir_optimize(struct vc4_compile *c) OPTPASS(qir_opt_algebraic); OPTPASS(qir_opt_cse); + OPTPASS(qir_opt_constant_folding); OPTPASS(qir_opt_copy_propagation); OPTPASS(qir_opt_dead_code); OPTPASS(qir_opt_small_immediates); diff --git a/src/gallium/drivers/vc4/vc4_qir.h b/src/gallium/drivers/vc4/vc4_qir.h index 4f910e3..6cc8dbe 100644 --- a/src/gallium/drivers/vc4/vc4_qir.h +++ b/src/gallium/drivers/vc4/vc4_qir.h @@ -396,6 +396,7 @@ const char *qir_get_stage_name(enum qstage stage); void qir_optimize(struct vc4_compile *c); bool qir_opt_algebraic(struct vc4_compile *c); +bool qir_opt_constant_folding(struct vc4_compile *c); bool qir_opt_copy_propagation(struct vc4_compile *c); bool qir_opt_cse(struct vc4_compile *c); bool qir_opt_dead_code(struct vc4_compile *c); From anholt at kemper.freedesktop.org Mon Mar 30 20:03:26 2015 From: anholt at kemper.freedesktop.org (Eric Anholt) Date: Mon, 30 Mar 2015 13:03:26 -0700 (PDT) Subject: Mesa (master): vc4: Drop integer multiplies with 0 to moves of 0. Message-ID: <20150330200326.C3BC57635A@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 1dcc1ee314a6907213e2abd5337ec0bbba3bd1bf URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=1dcc1ee314a6907213e2abd5337ec0bbba3bd1bf Author: Eric Anholt Date: Mon Mar 30 10:44:28 2015 -0700 vc4: Drop integer multiplies with 0 to moves of 0. This cleans up more instructions generated by uniform array indexing multiplies. total instructions in shared programs: 39989 -> 39961 (-0.07%) instructions in affected programs: 896 -> 868 (-3.12%) --- src/gallium/drivers/vc4/vc4_opt_algebraic.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/gallium/drivers/vc4/vc4_opt_algebraic.c b/src/gallium/drivers/vc4/vc4_opt_algebraic.c index d17669a..e40e0f3 100644 --- a/src/gallium/drivers/vc4/vc4_opt_algebraic.c +++ b/src/gallium/drivers/vc4/vc4_opt_algebraic.c @@ -248,6 +248,14 @@ qir_opt_algebraic(struct vc4_compile *c) } break; + case QOP_MUL24: + if (replace_x_0_with_0(c, inst, 0) || + replace_x_0_with_0(c, inst, 1)) { + progress = true; + break; + } + break; + case QOP_AND: if (replace_x_0_with_0(c, inst, 0) || replace_x_0_with_0(c, inst, 1)) { From daenzer at kemper.freedesktop.org Tue Mar 31 08:40:48 2015 From: daenzer at kemper.freedesktop.org (Michel Dänzer) Date: Tue, 31 Mar 2015 01:40:48 -0700 (PDT) Subject: Mesa (master): gallivm: Fix build against LLVM 3.7 SVN r233648 Message-ID: <20150331084048.B11D47633A@kemper.freedesktop.org> Module: Mesa Branch: master Commit: b8797a78752daf9e1d4c06d5555a81efea4bb85a URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=b8797a78752daf9e1d4c06d5555a81efea4bb85a Author: Michel D?nzer Date: Tue Mar 31 15:05:01 2015 +0900 gallivm: Fix build against LLVM 3.7 SVN r233648 Reviewed-by: Jose Fonseca --- src/gallium/auxiliary/gallivm/lp_bld_debug.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/gallium/auxiliary/gallivm/lp_bld_debug.cpp b/src/gallium/auxiliary/gallivm/lp_bld_debug.cpp index d4d453d..65d2896 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_debug.cpp +++ b/src/gallium/auxiliary/gallivm/lp_bld_debug.cpp @@ -256,8 +256,13 @@ disassemble(const void* func, llvm::raw_ostream & Out) } +#if HAVE_LLVM >= 0x0307 + OwningPtr Printer( + T->createMCInstPrinter(llvm::Triple(Triple), AsmPrinterVariant, *AsmInfo, *MII, *MRI)); +#else OwningPtr Printer( T->createMCInstPrinter(AsmPrinterVariant, *AsmInfo, *MII, *MRI, *STI)); +#endif if (!Printer) { Out << "error: no instruction printer for target " << Triple.c_str() << "\n"; Out.flush(); From jrfonseca at kemper.freedesktop.org Tue Mar 31 08:43:52 2015 From: jrfonseca at kemper.freedesktop.org (Jose Fonseca) Date: Tue, 31 Mar 2015 01:43:52 -0700 (PDT) Subject: Mesa (master): util/debug: Update MgwHelp link, drop BfdHelp link. Message-ID: <20150331084352.5A7297633A@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 0fc5b80e7abae061dd5b0a17a0e775619a5245be URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=0fc5b80e7abae061dd5b0a17a0e775619a5245be Author: Jose Fonseca Date: Wed Mar 18 22:06:44 2015 +0000 util/debug: Update MgwHelp link, drop BfdHelp link. --- src/gallium/auxiliary/util/u_debug_symbol.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/src/gallium/auxiliary/util/u_debug_symbol.c b/src/gallium/auxiliary/util/u_debug_symbol.c index bba9122..5424932 100644 --- a/src/gallium/auxiliary/util/u_debug_symbol.c +++ b/src/gallium/auxiliary/util/u_debug_symbol.c @@ -82,18 +82,10 @@ getDbgHelpProcAddress(LPCSTR lpProcName) hModule = LoadLibraryA("mgwhelp.dll"); if (!hModule) { _debug_printf("warning: mgwhelp.dll not found: symbol names will not be resolved\n" - "warning: download it from http://code.google.com/p/jrfonseca/wiki/DrMingw#MgwHelp\n"); + "warning: download it from https://github.com/jrfonseca/drmingw/#mgwhelp\n"); } } - - /* - * bfdhelp.dll was the predecessor of mgwhelp.dll. It is available from - * http://people.freedesktop.org/~jrfonseca/bfdhelp/ for now. - */ - if (!hModule) { - hModule = LoadLibraryA("bfdhelp.dll"); - } - #endif +#endif /* * Fallback to the real DbgHelp. From sroland at kemper.freedesktop.org Tue Mar 31 15:24:05 2015 From: sroland at kemper.freedesktop.org (Roland Scheidegger) Date: Tue, 31 Mar 2015 08:24:05 -0700 (PDT) Subject: Mesa (master): gallivm: add gather support to sampler interface Message-ID: <20150331152405.50A1676336@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 73c6914195bd3cc81f52192d4ec8e23fc6239c41 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=73c6914195bd3cc81f52192d4ec8e23fc6239c41 Author: Roland Scheidegger Date: Sun Mar 29 23:21:56 2015 +0200 gallivm: add gather support to sampler interface Luckily thanks to the revamped interface this is a lot less work now... Reviewed-by: Jose Fonseca --- src/gallium/auxiliary/gallivm/lp_bld_sample.h | 18 ++++++++---- src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c | 31 ++++++++++++--------- src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c | 6 ++-- 3 files changed, 34 insertions(+), 21 deletions(-) diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample.h b/src/gallium/auxiliary/gallivm/lp_bld_sample.h index b95ee6f..640b7e0 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_sample.h +++ b/src/gallium/auxiliary/gallivm/lp_bld_sample.h @@ -76,13 +76,21 @@ enum lp_sampler_lod_control { }; +enum lp_sampler_op_type { + LP_SAMPLER_OP_TEXTURE, + LP_SAMPLER_OP_FETCH, + LP_SAMPLER_OP_GATHER +}; + + #define LP_SAMPLER_SHADOW (1 << 0) #define LP_SAMPLER_OFFSETS (1 << 1) -#define LP_SAMPLER_FETCH (1 << 2) -#define LP_SAMPLER_LOD_CONTROL_SHIFT 3 -#define LP_SAMPLER_LOD_CONTROL_MASK (3 << 3) -#define LP_SAMPLER_LOD_PROPERTY_SHIFT 5 -#define LP_SAMPLER_LOD_PROPERTY_MASK (3 << 5) +#define LP_SAMPLER_OP_TYPE_SHIFT 2 +#define LP_SAMPLER_OP_TYPE_MASK (3 << 2) +#define LP_SAMPLER_LOD_CONTROL_SHIFT 4 +#define LP_SAMPLER_LOD_CONTROL_MASK (3 << 4) +#define LP_SAMPLER_LOD_PROPERTY_SHIFT 6 +#define LP_SAMPLER_LOD_PROPERTY_MASK (3 << 6) struct lp_sampler_params { diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c index 82ef359..962f478 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c @@ -2391,9 +2391,10 @@ lp_build_sample_soa_code(struct gallivm_state *gallivm, LLVMValueRef tex_width, newcoords[5]; enum lp_sampler_lod_property lod_property; enum lp_sampler_lod_control lod_control; + enum lp_sampler_op_type op_type; LLVMValueRef lod_bias = NULL; LLVMValueRef explicit_lod = NULL; - boolean is_fetch = !!(sample_key & LP_SAMPLER_FETCH); + boolean op_is_tex; if (0) { enum pipe_format fmt = static_texture_state->format; @@ -2404,6 +2405,10 @@ lp_build_sample_soa_code(struct gallivm_state *gallivm, LP_SAMPLER_LOD_PROPERTY_SHIFT; lod_control = (sample_key & LP_SAMPLER_LOD_CONTROL_MASK) >> LP_SAMPLER_LOD_CONTROL_SHIFT; + op_type = (sample_key & LP_SAMPLER_OP_TYPE_MASK) >> + LP_SAMPLER_OP_TYPE_SHIFT; + + op_is_tex = op_type == LP_SAMPLER_OP_TEXTURE; if (lod_control == LP_SAMPLER_LOD_BIAS) { lod_bias = lod; @@ -2534,7 +2539,7 @@ lp_build_sample_soa_code(struct gallivm_state *gallivm, (gallivm_debug & GALLIVM_DEBUG_NO_RHO_APPROX) && (static_texture_state->target == PIPE_TEXTURE_CUBE || static_texture_state->target == PIPE_TEXTURE_CUBE_ARRAY) && - (!is_fetch && mip_filter != PIPE_TEX_MIPFILTER_NONE)) { + (op_is_tex && mip_filter != PIPE_TEX_MIPFILTER_NONE)) { /* * special case for using per-pixel lod even for implicit lod, * which is generally never required (ok by APIs) except to please @@ -2548,23 +2553,23 @@ lp_build_sample_soa_code(struct gallivm_state *gallivm, } else if (lod_property == LP_SAMPLER_LOD_PER_ELEMENT || (explicit_lod || lod_bias || derivs)) { - if ((is_fetch && target != PIPE_BUFFER) || - (!is_fetch && mip_filter != PIPE_TEX_MIPFILTER_NONE)) { + if ((!op_is_tex && target != PIPE_BUFFER) || + (op_is_tex && mip_filter != PIPE_TEX_MIPFILTER_NONE)) { bld.num_mips = type.length; bld.num_lods = type.length; } - else if (!is_fetch && min_img_filter != mag_img_filter) { + else if (op_is_tex && min_img_filter != mag_img_filter) { bld.num_mips = 1; bld.num_lods = type.length; } } /* TODO: for true scalar_lod should only use 1 lod value */ - else if ((is_fetch && explicit_lod && target != PIPE_BUFFER) || - (!is_fetch && mip_filter != PIPE_TEX_MIPFILTER_NONE)) { + else if ((!op_is_tex && explicit_lod && target != PIPE_BUFFER) || + (op_is_tex && mip_filter != PIPE_TEX_MIPFILTER_NONE)) { bld.num_mips = num_quads; bld.num_lods = num_quads; } - else if (!is_fetch && min_img_filter != mag_img_filter) { + else if (op_is_tex && min_img_filter != mag_img_filter) { bld.num_mips = 1; bld.num_lods = num_quads; } @@ -2658,7 +2663,7 @@ lp_build_sample_soa_code(struct gallivm_state *gallivm, texel_out); } - else if (is_fetch) { + else if (op_type == LP_SAMPLER_OP_FETCH) { lp_build_fetch_texel(&bld, texture_index, newcoords, lod, offsets, texel_out); @@ -2786,18 +2791,18 @@ lp_build_sample_soa_code(struct gallivm_state *gallivm, (gallivm_debug & GALLIVM_DEBUG_NO_RHO_APPROX) && (static_texture_state->target == PIPE_TEXTURE_CUBE || static_texture_state->target == PIPE_TEXTURE_CUBE_ARRAY) && - (!is_fetch && mip_filter != PIPE_TEX_MIPFILTER_NONE)) { + (op_is_tex && mip_filter != PIPE_TEX_MIPFILTER_NONE)) { bld4.num_mips = type4.length; bld4.num_lods = type4.length; } if (lod_property == LP_SAMPLER_LOD_PER_ELEMENT && (explicit_lod || lod_bias || derivs)) { - if ((is_fetch && target != PIPE_BUFFER) || - (!is_fetch && mip_filter != PIPE_TEX_MIPFILTER_NONE)) { + if ((!op_is_tex && target != PIPE_BUFFER) || + (op_is_tex && mip_filter != PIPE_TEX_MIPFILTER_NONE)) { bld4.num_mips = type4.length; bld4.num_lods = type4.length; } - else if (!is_fetch && min_img_filter != mag_img_filter) { + else if (op_is_tex && min_img_filter != mag_img_filter) { bld4.num_mips = 1; bld4.num_lods = type4.length; } diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c index 6a71da6..ae527b2 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c @@ -1974,7 +1974,7 @@ emit_tex( struct lp_build_tgsi_soa_context *bld, unsigned num_derivs, num_offsets, i; unsigned shadow_coord = 0; unsigned layer_coord = 0; - unsigned sample_key = 0; + unsigned sample_key = LP_SAMPLER_OP_TEXTURE << LP_SAMPLER_OP_TYPE_SHIFT; memset(¶ms, 0, sizeof(params)); @@ -2179,7 +2179,7 @@ emit_sample(struct lp_build_tgsi_soa_context *bld, unsigned num_offsets, num_derivs, i; unsigned layer_coord = 0; - unsigned sample_key = 0; + unsigned sample_key = LP_SAMPLER_OP_TEXTURE << LP_SAMPLER_OP_TYPE_SHIFT; memset(¶ms, 0, sizeof(params)); @@ -2356,7 +2356,7 @@ emit_fetch_texels( struct lp_build_tgsi_soa_context *bld, enum lp_sampler_lod_property lod_property = LP_SAMPLER_LOD_SCALAR; unsigned dims, i; unsigned layer_coord = 0; - unsigned sample_key = LP_SAMPLER_FETCH; + unsigned sample_key = LP_SAMPLER_OP_FETCH << LP_SAMPLER_OP_TYPE_SHIFT; memset(¶ms, 0, sizeof(params)); From sroland at kemper.freedesktop.org Tue Mar 31 15:24:05 2015 From: sroland at kemper.freedesktop.org (Roland Scheidegger) Date: Tue, 31 Mar 2015 08:24:05 -0700 (PDT) Subject: Mesa (master): gallivm: implement TG4 for ARB_texture_gather Message-ID: <20150331152405.64C3676336@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 0753b135f6e83b171d8a1b08aea967374f3542bc URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=0753b135f6e83b171d8a1b08aea967374f3542bc Author: Roland Scheidegger Date: Sun Mar 29 23:40:31 2015 +0200 gallivm: implement TG4 for ARB_texture_gather This is quite trivial, essentially just follow all the same code you'd use with linear min/mag (and no mip) filter, then just skip the filtering after looking up the texels in favor of direct assignment of the right channel to the result. (This is though not true for the multi-offset version if we'd want to support it - for this would probably need to do something along the lines of 4x nearest sampling due to the necessity of doing coord wrapping individually per texel.) Supports multi-channel formats. >From the SM5 gather cap bit, should support non-constant offsets, plus shadow comparisons (the former untested), but not component selection (should be easy to implement but all this stuff is not really exposable anyway for now). Reviewed-by: Jose Fonseca --- src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c | 137 ++++++++++++++++----- src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c | 36 ++++-- 2 files changed, 133 insertions(+), 40 deletions(-) diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c index 962f478..ff508e2 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c @@ -840,6 +840,7 @@ lp_build_masklerp2d(struct lp_build_context *bld, */ static void lp_build_sample_image_linear(struct lp_build_sample_context *bld, + boolean is_gather, LLVMValueRef size, LLVMValueRef linear_mask, LLVMValueRef row_stride_vec, @@ -853,6 +854,7 @@ lp_build_sample_image_linear(struct lp_build_sample_context *bld, LLVMBuilderRef builder = bld->gallivm->builder; struct lp_build_context *ivec_bld = &bld->int_coord_bld; struct lp_build_context *coord_bld = &bld->coord_bld; + struct lp_build_context *texel_bld = &bld->texel_bld; const unsigned dims = bld->dims; LLVMValueRef width_vec; LLVMValueRef height_vec; @@ -875,7 +877,16 @@ lp_build_sample_image_linear(struct lp_build_sample_context *bld, seamless_cube_filter = (bld->static_texture_state->target == PIPE_TEXTURE_CUBE || bld->static_texture_state->target == PIPE_TEXTURE_CUBE_ARRAY) && bld->static_sampler_state->seamless_cube_map; - accurate_cube_corners = ACCURATE_CUBE_CORNERS && seamless_cube_filter; + /* + * XXX I don't know how this is really supposed to work with gather. From GL + * spec wording (not gather specific) it sounds like the 4th missing texel + * should be an average of the other 3, hence for gather could return this. + * This is however NOT how the code here works, which just fixes up the + * weights used for filtering instead. And of course for gather there is + * no filter to tweak... + */ + accurate_cube_corners = ACCURATE_CUBE_CORNERS && seamless_cube_filter && + !is_gather; lp_build_extract_image_sizes(bld, &bld->int_size_bld, @@ -1160,10 +1171,11 @@ lp_build_sample_image_linear(struct lp_build_sample_context *bld, data_ptr, mipoffsets, neighbors[0][1]); if (dims == 1) { + assert(!is_gather); if (bld->static_sampler_state->compare_mode == PIPE_TEX_COMPARE_NONE) { /* Interpolate two samples from 1D image to produce one color */ for (chan = 0; chan < 4; chan++) { - colors_out[chan] = lp_build_lerp(&bld->texel_bld, s_fpart, + colors_out[chan] = lp_build_lerp(texel_bld, s_fpart, neighbors[0][0][chan], neighbors[0][1][chan], 0); @@ -1174,7 +1186,7 @@ lp_build_sample_image_linear(struct lp_build_sample_context *bld, cmpval0 = lp_build_sample_comparefunc(bld, coords[4], neighbors[0][0][0]); cmpval1 = lp_build_sample_comparefunc(bld, coords[4], neighbors[0][1][0]); /* simplified lerp, AND mask with weight and add */ - colors_out[0] = lp_build_masklerp(&bld->texel_bld, s_fpart, + colors_out[0] = lp_build_masklerp(texel_bld, s_fpart, cmpval0, cmpval1); colors_out[1] = colors_out[2] = colors_out[3] = colors_out[0]; } @@ -1301,15 +1313,38 @@ lp_build_sample_image_linear(struct lp_build_sample_context *bld, } if (bld->static_sampler_state->compare_mode == PIPE_TEX_COMPARE_NONE) { - /* Bilinear interpolate the four samples from the 2D image / 3D slice */ - for (chan = 0; chan < 4; chan++) { - colors0[chan] = lp_build_lerp_2d(&bld->texel_bld, - s_fpart, t_fpart, - neighbors[0][0][chan], - neighbors[0][1][chan], - neighbors[1][0][chan], - neighbors[1][1][chan], - 0); + if (is_gather) { + /* + * Just assign the red channel (no component selection yet). + * This is a bit hackish, we usually do the swizzle at the + * end of sampling (much less values to swizzle), but this + * obviously cannot work when using gather. + */ + unsigned chan_swiz = bld->static_texture_state->swizzle_r; + colors0[0] = lp_build_swizzle_soa_channel(texel_bld, + neighbors[1][0], + chan_swiz); + colors0[1] = lp_build_swizzle_soa_channel(texel_bld, + neighbors[1][1], + chan_swiz); + colors0[2] = lp_build_swizzle_soa_channel(texel_bld, + neighbors[0][1], + chan_swiz); + colors0[3] = lp_build_swizzle_soa_channel(texel_bld, + neighbors[0][0], + chan_swiz); + } + else { + /* Bilinear interpolate the four samples from the 2D image / 3D slice */ + for (chan = 0; chan < 4; chan++) { + colors0[chan] = lp_build_lerp_2d(texel_bld, + s_fpart, t_fpart, + neighbors[0][0][chan], + neighbors[0][1][chan], + neighbors[1][0][chan], + neighbors[1][1][chan], + 0); + } } } else { @@ -1318,9 +1353,34 @@ lp_build_sample_image_linear(struct lp_build_sample_context *bld, cmpval01 = lp_build_sample_comparefunc(bld, coords[4], neighbors[0][1][0]); cmpval10 = lp_build_sample_comparefunc(bld, coords[4], neighbors[1][0][0]); cmpval11 = lp_build_sample_comparefunc(bld, coords[4], neighbors[1][1][0]); - colors0[0] = lp_build_masklerp2d(&bld->texel_bld, s_fpart, t_fpart, - cmpval00, cmpval01, cmpval10, cmpval11); - colors0[1] = colors0[2] = colors0[3] = colors0[0]; + + if (is_gather) { + /* more hacks for swizzling, should be X, ONE or ZERO... */ + unsigned chan_swiz = bld->static_texture_state->swizzle_r; + if (chan_swiz <= PIPE_SWIZZLE_ALPHA) { + colors0[0] = lp_build_select(texel_bld, cmpval10, + texel_bld->one, texel_bld->zero); + colors0[1] = lp_build_select(texel_bld, cmpval11, + texel_bld->one, texel_bld->zero); + colors0[2] = lp_build_select(texel_bld, cmpval01, + texel_bld->one, texel_bld->zero); + colors0[3] = lp_build_select(texel_bld, cmpval00, + texel_bld->one, texel_bld->zero); + } + else if (chan_swiz == PIPE_SWIZZLE_ZERO) { + colors0[0] = colors0[1] = colors0[2] = colors0[3] = + texel_bld->zero; + } + else { + colors0[0] = colors0[1] = colors0[2] = colors0[3] = + texel_bld->one; + } + } + else { + colors0[0] = lp_build_masklerp2d(texel_bld, s_fpart, t_fpart, + cmpval00, cmpval01, cmpval10, cmpval11); + colors0[1] = colors0[2] = colors0[3] = colors0[0]; + } } if (accurate_cube_corners) { @@ -1341,6 +1401,8 @@ lp_build_sample_image_linear(struct lp_build_sample_context *bld, LLVMValueRef neighbors1[2][2][4]; LLVMValueRef colors1[4]; + assert(!is_gather); + /* get x0/x1/y0/y1 texels at z1 */ lp_build_sample_texel_soa(bld, width_vec, height_vec, depth_vec, @@ -1366,7 +1428,7 @@ lp_build_sample_image_linear(struct lp_build_sample_context *bld, if (bld->static_sampler_state->compare_mode == PIPE_TEX_COMPARE_NONE) { /* Bilinear interpolate the four samples from the second Z slice */ for (chan = 0; chan < 4; chan++) { - colors1[chan] = lp_build_lerp_2d(&bld->texel_bld, + colors1[chan] = lp_build_lerp_2d(texel_bld, s_fpart, t_fpart, neighbors1[0][0][chan], neighbors1[0][1][chan], @@ -1376,7 +1438,7 @@ lp_build_sample_image_linear(struct lp_build_sample_context *bld, } /* Linearly interpolate the two samples from the two 3D slices */ for (chan = 0; chan < 4; chan++) { - colors_out[chan] = lp_build_lerp(&bld->texel_bld, + colors_out[chan] = lp_build_lerp(texel_bld, r_fpart, colors0[chan], colors1[chan], 0); @@ -1388,13 +1450,13 @@ lp_build_sample_image_linear(struct lp_build_sample_context *bld, cmpval01 = lp_build_sample_comparefunc(bld, coords[4], neighbors[0][1][0]); cmpval10 = lp_build_sample_comparefunc(bld, coords[4], neighbors[1][0][0]); cmpval11 = lp_build_sample_comparefunc(bld, coords[4], neighbors[1][1][0]); - colors1[0] = lp_build_masklerp2d(&bld->texel_bld, s_fpart, t_fpart, + colors1[0] = lp_build_masklerp2d(texel_bld, s_fpart, t_fpart, cmpval00, cmpval01, cmpval10, cmpval11); /* Linearly interpolate the two samples from the two 3D slices */ - colors_out[0] = lp_build_lerp(&bld->texel_bld, - r_fpart, - colors0[0], colors1[0], - 0); + colors_out[0] = lp_build_lerp(texel_bld, + r_fpart, + colors0[0], colors1[0], + 0); colors_out[1] = colors_out[2] = colors_out[3] = colors_out[0]; } } @@ -1418,6 +1480,7 @@ static void lp_build_sample_mipmap(struct lp_build_sample_context *bld, unsigned img_filter, unsigned mip_filter, + boolean is_gather, LLVMValueRef *coords, const LLVMValueRef *offsets, LLVMValueRef ilevel0, @@ -1459,7 +1522,7 @@ lp_build_sample_mipmap(struct lp_build_sample_context *bld, } else { assert(img_filter == PIPE_TEX_FILTER_LINEAR); - lp_build_sample_image_linear(bld, size0, NULL, + lp_build_sample_image_linear(bld, is_gather, size0, NULL, row_stride0_vec, img_stride0_vec, data_ptr0, mipoff0, coords, offsets, colors0); @@ -1520,7 +1583,7 @@ lp_build_sample_mipmap(struct lp_build_sample_context *bld, colors1); } else { - lp_build_sample_image_linear(bld, size1, NULL, + lp_build_sample_image_linear(bld, FALSE, size1, NULL, row_stride1_vec, img_stride1_vec, data_ptr1, mipoff1, coords, offsets, colors1); @@ -1594,7 +1657,7 @@ lp_build_sample_mipmap_both(struct lp_build_sample_context *bld, mipoff0 = lp_build_get_mip_offsets(bld, ilevel0); } - lp_build_sample_image_linear(bld, size0, linear_mask, + lp_build_sample_image_linear(bld, FALSE, size0, linear_mask, row_stride0_vec, img_stride0_vec, data_ptr0, mipoff0, coords, offsets, colors0); @@ -1638,7 +1701,7 @@ lp_build_sample_mipmap_both(struct lp_build_sample_context *bld, mipoff1 = lp_build_get_mip_offsets(bld, ilevel1); } - lp_build_sample_image_linear(bld, size1, linear_mask, + lp_build_sample_image_linear(bld, FALSE, size1, linear_mask, row_stride1_vec, img_stride1_vec, data_ptr1, mipoff1, coords, offsets, colors1); @@ -2061,6 +2124,7 @@ lp_build_clamp_border_color(struct lp_build_sample_context *bld, static void lp_build_sample_general(struct lp_build_sample_context *bld, unsigned sampler_unit, + boolean is_gather, LLVMValueRef *coords, const LLVMValueRef *offsets, LLVMValueRef lod_positive, @@ -2105,6 +2169,7 @@ lp_build_sample_general(struct lp_build_sample_context *bld, if (min_filter == mag_filter) { /* no need to distinguish between minification and magnification */ lp_build_sample_mipmap(bld, min_filter, mip_filter, + is_gather, coords, offsets, ilevel0, ilevel1, lod_fpart, texels); @@ -2126,7 +2191,7 @@ lp_build_sample_general(struct lp_build_sample_context *bld, lp_build_if(&if_ctx, bld->gallivm, lod_positive); { /* Use the minification filter */ - lp_build_sample_mipmap(bld, min_filter, mip_filter, + lp_build_sample_mipmap(bld, min_filter, mip_filter, FALSE, coords, offsets, ilevel0, ilevel1, lod_fpart, texels); @@ -2135,6 +2200,7 @@ lp_build_sample_general(struct lp_build_sample_context *bld, { /* Use the magnification filter */ lp_build_sample_mipmap(bld, mag_filter, PIPE_TEX_MIPFILTER_NONE, + FALSE, coords, offsets, ilevel0, NULL, NULL, texels); @@ -2187,7 +2253,7 @@ lp_build_sample_general(struct lp_build_sample_context *bld, * All pixels require just nearest filtering, which is way * cheaper than linear, hence do a separate path for that. */ - lp_build_sample_mipmap(bld, PIPE_TEX_FILTER_NEAREST, + lp_build_sample_mipmap(bld, PIPE_TEX_FILTER_NEAREST, FALSE, mip_filter_for_nearest, coords, offsets, ilevel0, ilevel1, lod_fpart, @@ -2488,6 +2554,16 @@ lp_build_sample_soa_code(struct gallivm_state *gallivm, } else { derived_sampler_state.min_mip_filter = PIPE_TEX_MIPFILTER_NONE; } + if (op_type == LP_SAMPLER_OP_GATHER) { + /* + * gather4 is exactly like GL_LINEAR filtering but in the end skipping + * the actual filtering. Using mostly the same paths, so cube face + * selection, coord wrapping etc. all naturally uses the same code. + */ + derived_sampler_state.min_mip_filter = PIPE_TEX_MIPFILTER_NONE; + derived_sampler_state.min_img_filter = PIPE_TEX_FILTER_LINEAR; + derived_sampler_state.mag_img_filter = PIPE_TEX_FILTER_LINEAR; + } mip_filter = derived_sampler_state.min_mip_filter; if (0) { @@ -2673,6 +2749,7 @@ lp_build_sample_soa_code(struct gallivm_state *gallivm, LLVMValueRef lod_fpart = NULL, lod_positive = NULL; LLVMValueRef ilevel0 = NULL, ilevel1 = NULL; boolean use_aos = util_format_fits_8unorm(bld.format_desc) && + op_is_tex && /* not sure this is strictly needed or simply impossible */ derived_sampler_state.compare_mode == PIPE_TEX_COMPARE_NONE && lp_is_simple_wrap_mode(derived_sampler_state.wrap_s); @@ -2743,6 +2820,7 @@ lp_build_sample_soa_code(struct gallivm_state *gallivm, else { lp_build_sample_general(&bld, sampler_index, + op_type == LP_SAMPLER_OP_GATHER, newcoords, offsets, lod_positive, lod_fpart, ilevel0, ilevel1, @@ -2889,6 +2967,7 @@ lp_build_sample_soa_code(struct gallivm_state *gallivm, newcoords4[4] = lp_build_extract_range(gallivm, newcoords[4], 4*i, 4); lp_build_sample_general(&bld4, sampler_index, + op_type == LP_SAMPLER_OP_GATHER, newcoords4, offsets4, lod_positive4, lod_fpart4, ilevel04, ilevel14, @@ -2905,7 +2984,7 @@ lp_build_sample_soa_code(struct gallivm_state *gallivm, } } - if (target != PIPE_BUFFER) { + if (target != PIPE_BUFFER && op_type != LP_SAMPLER_OP_GATHER) { apply_sampler_swizzle(&bld, texel_out); } diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c index ae527b2..17b68ff 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c @@ -1961,7 +1961,8 @@ emit_tex( struct lp_build_tgsi_soa_context *bld, const struct tgsi_full_instruction *inst, enum lp_build_tex_modifier modifier, LLVMValueRef *texel, - unsigned sampler_reg) + unsigned sampler_reg, + enum lp_sampler_op_type sampler_op) { unsigned unit = inst->Src[sampler_reg].Register.Index; LLVMValueRef oow = NULL; @@ -1974,7 +1975,7 @@ emit_tex( struct lp_build_tgsi_soa_context *bld, unsigned num_derivs, num_offsets, i; unsigned shadow_coord = 0; unsigned layer_coord = 0; - unsigned sample_key = LP_SAMPLER_OP_TEXTURE << LP_SAMPLER_OP_TYPE_SHIFT; + unsigned sample_key = sampler_op << LP_SAMPLER_OP_TYPE_SHIFT; memset(¶ms, 0, sizeof(params)); @@ -2137,7 +2138,7 @@ emit_tex( struct lp_build_tgsi_soa_context *bld, } sample_key |= lod_property << LP_SAMPLER_LOD_PROPERTY_SHIFT; - /* some advanced gather instructions (txgo) would require 4 offsets */ + /* we don't handle the 4 offset version of tg4 */ if (inst->Texture.NumOffsets == 1) { unsigned dim; sample_key |= LP_SAMPLER_OFFSETS; @@ -2972,7 +2973,7 @@ tex_emit( struct lp_build_tgsi_soa_context * bld = lp_soa_context(bld_base); emit_tex(bld, emit_data->inst, LP_BLD_TEX_MODIFIER_NONE, - emit_data->output, 1); + emit_data->output, 1, LP_SAMPLER_OP_TEXTURE); } static void @@ -2984,7 +2985,7 @@ tex2_emit( struct lp_build_tgsi_soa_context * bld = lp_soa_context(bld_base); emit_tex(bld, emit_data->inst, LP_BLD_TEX_MODIFIER_NONE, - emit_data->output, 2); + emit_data->output, 2, LP_SAMPLER_OP_TEXTURE); } static void @@ -2996,7 +2997,7 @@ txb_emit( struct lp_build_tgsi_soa_context * bld = lp_soa_context(bld_base); emit_tex(bld, emit_data->inst, LP_BLD_TEX_MODIFIER_LOD_BIAS, - emit_data->output, 1); + emit_data->output, 1, LP_SAMPLER_OP_TEXTURE); } static void @@ -3008,7 +3009,7 @@ txb2_emit( struct lp_build_tgsi_soa_context * bld = lp_soa_context(bld_base); emit_tex(bld, emit_data->inst, LP_BLD_TEX_MODIFIER_LOD_BIAS, - emit_data->output, 2); + emit_data->output, 2, LP_SAMPLER_OP_TEXTURE); } static void @@ -3020,7 +3021,7 @@ txd_emit( struct lp_build_tgsi_soa_context * bld = lp_soa_context(bld_base); emit_tex(bld, emit_data->inst, LP_BLD_TEX_MODIFIER_EXPLICIT_DERIV, - emit_data->output, 3); + emit_data->output, 3, LP_SAMPLER_OP_TEXTURE); } static void @@ -3032,7 +3033,7 @@ txl_emit( struct lp_build_tgsi_soa_context * bld = lp_soa_context(bld_base); emit_tex(bld, emit_data->inst, LP_BLD_TEX_MODIFIER_EXPLICIT_LOD, - emit_data->output, 1); + emit_data->output, 1, LP_SAMPLER_OP_TEXTURE); } static void @@ -3044,7 +3045,7 @@ txl2_emit( struct lp_build_tgsi_soa_context * bld = lp_soa_context(bld_base); emit_tex(bld, emit_data->inst, LP_BLD_TEX_MODIFIER_EXPLICIT_LOD, - emit_data->output, 2); + emit_data->output, 2, LP_SAMPLER_OP_TEXTURE); } static void @@ -3056,7 +3057,19 @@ txp_emit( struct lp_build_tgsi_soa_context * bld = lp_soa_context(bld_base); emit_tex(bld, emit_data->inst, LP_BLD_TEX_MODIFIER_PROJECTED, - emit_data->output, 1); + emit_data->output, 1, LP_SAMPLER_OP_TEXTURE); +} + +static void +tg4_emit( + const struct lp_build_tgsi_action * action, + struct lp_build_tgsi_context * bld_base, + struct lp_build_emit_data * emit_data) +{ + struct lp_build_tgsi_soa_context * bld = lp_soa_context(bld_base); + + emit_tex(bld, emit_data->inst, LP_BLD_TEX_MODIFIER_NONE, + emit_data->output, 2, LP_SAMPLER_OP_GATHER); } static void @@ -3775,6 +3788,7 @@ lp_build_tgsi_soa(struct gallivm_state *gallivm, bld.bld_base.op_actions[TGSI_OPCODE_TEX2].emit = tex2_emit; bld.bld_base.op_actions[TGSI_OPCODE_TXB2].emit = txb2_emit; bld.bld_base.op_actions[TGSI_OPCODE_TXL2].emit = txl2_emit; + bld.bld_base.op_actions[TGSI_OPCODE_TG4].emit = tg4_emit; /* DX10 sampling ops */ bld.bld_base.op_actions[TGSI_OPCODE_SAMPLE].emit = sample_emit; bld.bld_base.op_actions[TGSI_OPCODE_SAMPLE_B].emit = sample_b_emit; From sroland at kemper.freedesktop.org Tue Mar 31 15:24:05 2015 From: sroland at kemper.freedesktop.org (Roland Scheidegger) Date: Tue, 31 Mar 2015 08:24:05 -0700 (PDT) Subject: Mesa (master): llvmpipe: enable ARB_texture_gather Message-ID: <20150331152405.7382B76336@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 489866938f8bf85625f0f452006a3422a2585950 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=489866938f8bf85625f0f452006a3422a2585950 Author: Roland Scheidegger Date: Tue Mar 31 17:23:17 2015 +0200 llvmpipe: enable ARB_texture_gather Just announce support for 4 components. While here also increase the max/min texel offsets (the limit is completely artificial, was chosen because that's what other hardware did, however there's other drivers using larger limits). Over a thousand little piglits skip->pass. v2: update docs/GL3.txt Reviewed-by: Jose Fonseca --- docs/GL3.txt | 2 +- src/gallium/drivers/llvmpipe/lp_screen.c | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/docs/GL3.txt b/docs/GL3.txt index 3614260..94166e2 100644 --- a/docs/GL3.txt +++ b/docs/GL3.txt @@ -115,7 +115,7 @@ GL 4.0, GLSL 4.00: GL_ARB_tessellation_shader started (Chris, Ilia) GL_ARB_texture_buffer_object_rgb32 DONE (i965, nvc0, r600, radeonsi, llvmpipe, softpipe) GL_ARB_texture_cube_map_array DONE (i965, nv50, nvc0, r600, radeonsi, llvmpipe, softpipe) - GL_ARB_texture_gather DONE (i965, nv50, nvc0, r600, radeonsi) + GL_ARB_texture_gather DONE (i965, nv50, nvc0, r600, radeonsi, llvmpipe) GL_ARB_texture_query_lod DONE (i965, nv50, nvc0, r600, radeonsi) GL_ARB_transform_feedback2 DONE (i965, nv50, nvc0, r600, radeonsi) GL_ARB_transform_feedback3 DONE (i965, nv50, nvc0, r600, radeonsi) diff --git a/src/gallium/drivers/llvmpipe/lp_screen.c b/src/gallium/drivers/llvmpipe/lp_screen.c index 4b45725..f4ba596 100644 --- a/src/gallium/drivers/llvmpipe/lp_screen.c +++ b/src/gallium/drivers/llvmpipe/lp_screen.c @@ -180,10 +180,10 @@ llvmpipe_get_param(struct pipe_screen *screen, enum pipe_cap param) /* this is a lie could support arbitrary large offsets */ case PIPE_CAP_MIN_TEXTURE_GATHER_OFFSET: case PIPE_CAP_MIN_TEXEL_OFFSET: - return -8; + return -32; case PIPE_CAP_MAX_TEXTURE_GATHER_OFFSET: case PIPE_CAP_MAX_TEXEL_OFFSET: - return 7; + return 31; case PIPE_CAP_CONDITIONAL_RENDER: return 1; case PIPE_CAP_TEXTURE_BARRIER: @@ -249,6 +249,7 @@ llvmpipe_get_param(struct pipe_screen *screen, enum pipe_cap param) case PIPE_CAP_BUFFER_MAP_PERSISTENT_COHERENT: return 1; case PIPE_CAP_MAX_TEXTURE_GATHER_COMPONENTS: + return 4; case PIPE_CAP_TEXTURE_GATHER_SM5: case PIPE_CAP_TEXTURE_QUERY_LOD: case PIPE_CAP_SAMPLE_SHADING: From sroland at kemper.freedesktop.org Tue Mar 31 15:24:05 2015 From: sroland at kemper.freedesktop.org (Roland Scheidegger) Date: Tue, 31 Mar 2015 08:24:05 -0700 (PDT) Subject: Mesa (master): gallivm: simplify sampler interface Message-ID: <20150331152405.406C776336@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 1863ed21ffbb3ab7fd9875dc25e32ececea79d50 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=1863ed21ffbb3ab7fd9875dc25e32ececea79d50 Author: Roland Scheidegger Date: Sat Mar 28 20:51:23 2015 +0100 gallivm: simplify sampler interface This has got a bit out of control with more and more parameters added. Worse, whenever something in there changes all callees have to be updated for that, even though they don't really do much with any parameter in there except pass it on to the actual sampling function. Hence simply put almost everything into a struct. Also instead of relying on some arguments being NULL, be explicit and set this in a key (which is just reused for function generation for simplicity). (The code still relies on them being NULL in the end for now.) Technically there is a minimal functional change here for shadow sampling: if shadow sampling is done is now determined explicitly by the texture function (either sample_c or the gl-style tex func inherit this from target) instead of the static texture state. These two should always match, however. Otherwise, it should generate all the same code. Reviewed-by: Jose Fonseca --- src/gallium/auxiliary/draw/draw_llvm_sample.c | 31 +-- src/gallium/auxiliary/gallivm/lp_bld_sample.h | 48 +++-- src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c | 227 +++++++++------------ src/gallium/auxiliary/gallivm/lp_bld_tgsi.h | 17 +- src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c | 133 ++++++------ src/gallium/drivers/llvmpipe/lp_tex_sample.c | 33 +-- 6 files changed, 218 insertions(+), 271 deletions(-) diff --git a/src/gallium/auxiliary/draw/draw_llvm_sample.c b/src/gallium/auxiliary/draw/draw_llvm_sample.c index 16d075c..32cad59 100644 --- a/src/gallium/auxiliary/draw/draw_llvm_sample.c +++ b/src/gallium/auxiliary/draw/draw_llvm_sample.c @@ -229,38 +229,19 @@ draw_llvm_sampler_soa_destroy(struct lp_build_sampler_soa *sampler) static void draw_llvm_sampler_soa_emit_fetch_texel(const struct lp_build_sampler_soa *base, struct gallivm_state *gallivm, - struct lp_type type, - boolean is_fetch, - unsigned texture_index, - unsigned sampler_index, - LLVMValueRef context_ptr, - const LLVMValueRef *coords, - const LLVMValueRef *offsets, - const struct lp_derivatives *derivs, - LLVMValueRef lod_bias, /* optional */ - LLVMValueRef explicit_lod, /* optional */ - enum lp_sampler_lod_property lod_property, - LLVMValueRef *texel) + const struct lp_sampler_params *params) { struct draw_llvm_sampler_soa *sampler = (struct draw_llvm_sampler_soa *)base; + unsigned texture_index = params->texture_index; + unsigned sampler_index = params->sampler_index; assert(texture_index < PIPE_MAX_SHADER_SAMPLER_VIEWS); assert(sampler_index < PIPE_MAX_SAMPLERS); - lp_build_sample_soa(gallivm, - &sampler->dynamic_state.static_state[texture_index].texture_state, + lp_build_sample_soa(&sampler->dynamic_state.static_state[texture_index].texture_state, &sampler->dynamic_state.static_state[sampler_index].sampler_state, &sampler->dynamic_state.base, - type, - is_fetch, - texture_index, - sampler_index, - context_ptr, - coords, - offsets, - derivs, - lod_bias, explicit_lod, lod_property, - texel); + gallivm, params); } @@ -306,7 +287,7 @@ draw_llvm_sampler_soa_create(const struct draw_sampler_static_state *static_stat return NULL; sampler->base.destroy = draw_llvm_sampler_soa_destroy; - sampler->base.emit_fetch_texel = draw_llvm_sampler_soa_emit_fetch_texel; + sampler->base.emit_tex_sample = draw_llvm_sampler_soa_emit_fetch_texel; sampler->base.emit_size_query = draw_llvm_sampler_soa_emit_size_query; sampler->dynamic_state.base.width = draw_llvm_texture_width; sampler->dynamic_state.base.height = draw_llvm_texture_height; diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample.h b/src/gallium/auxiliary/gallivm/lp_bld_sample.h index be41ca0..b95ee6f 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_sample.h +++ b/src/gallium/auxiliary/gallivm/lp_bld_sample.h @@ -68,6 +68,37 @@ enum lp_sampler_lod_property { }; +enum lp_sampler_lod_control { + LP_SAMPLER_LOD_IMPLICIT, + LP_SAMPLER_LOD_BIAS, + LP_SAMPLER_LOD_EXPLICIT, + LP_SAMPLER_LOD_DERIVATIVES, +}; + + +#define LP_SAMPLER_SHADOW (1 << 0) +#define LP_SAMPLER_OFFSETS (1 << 1) +#define LP_SAMPLER_FETCH (1 << 2) +#define LP_SAMPLER_LOD_CONTROL_SHIFT 3 +#define LP_SAMPLER_LOD_CONTROL_MASK (3 << 3) +#define LP_SAMPLER_LOD_PROPERTY_SHIFT 5 +#define LP_SAMPLER_LOD_PROPERTY_MASK (3 << 5) + +struct lp_sampler_params +{ + struct lp_type type; + unsigned texture_index; + unsigned sampler_index; + unsigned sample_key; + LLVMValueRef context_ptr; + const LLVMValueRef *coords; + const LLVMValueRef *offsets; + LLVMValueRef lod; + const struct lp_derivatives *derivs; + LLVMValueRef *texel; +}; + + /** * Texture static state. * @@ -531,22 +562,11 @@ lp_build_sample_offset(struct lp_build_context *bld, void -lp_build_sample_soa(struct gallivm_state *gallivm, - const struct lp_static_texture_state *static_texture_state, +lp_build_sample_soa(const struct lp_static_texture_state *static_texture_state, const struct lp_static_sampler_state *static_sampler_state, struct lp_sampler_dynamic_state *dynamic_texture_state, - struct lp_type fp_type, - boolean is_fetch, - unsigned texture_index, - unsigned sampler_index, - LLVMValueRef context_ptr, - const LLVMValueRef *coords, - const LLVMValueRef *offsets, - const struct lp_derivatives *derivs, - LLVMValueRef lod_bias, - LLVMValueRef explicit_lod, - enum lp_sampler_lod_property lod_property, - LLVMValueRef texel_out[4]); + struct gallivm_state *gallivm, + const struct lp_sampler_params *params); void diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c index 598d5fc..82ef359 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c @@ -2361,7 +2361,7 @@ lp_build_sample_nop(struct gallivm_state *gallivm, * 'texel' will return a vector of four LLVMValueRefs corresponding to * R, G, B, A. * \param type vector float type to use for coords, etc. - * \param is_fetch if this is a texel fetch instruction. + * \param sample_key * \param derivs partial derivatives of (s,t,r,q) with respect to x and y */ static void @@ -2370,16 +2370,14 @@ lp_build_sample_soa_code(struct gallivm_state *gallivm, const struct lp_static_sampler_state *static_sampler_state, struct lp_sampler_dynamic_state *dynamic_state, struct lp_type type, - boolean is_fetch, + unsigned sample_key, unsigned texture_index, unsigned sampler_index, LLVMValueRef context_ptr, const LLVMValueRef *coords, const LLVMValueRef *offsets, const struct lp_derivatives *derivs, /* optional */ - LLVMValueRef lod_bias, /* optional */ - LLVMValueRef explicit_lod, /* optional */ - enum lp_sampler_lod_property lod_property, + LLVMValueRef lod, /* optional */ LLVMValueRef texel_out[4]) { unsigned target = static_texture_state->target; @@ -2391,12 +2389,41 @@ lp_build_sample_soa_code(struct gallivm_state *gallivm, LLVMTypeRef i32t = LLVMInt32TypeInContext(gallivm->context); LLVMBuilderRef builder = gallivm->builder; LLVMValueRef tex_width, newcoords[5]; + enum lp_sampler_lod_property lod_property; + enum lp_sampler_lod_control lod_control; + LLVMValueRef lod_bias = NULL; + LLVMValueRef explicit_lod = NULL; + boolean is_fetch = !!(sample_key & LP_SAMPLER_FETCH); if (0) { enum pipe_format fmt = static_texture_state->format; debug_printf("Sample from %s\n", util_format_name(fmt)); } + lod_property = (sample_key & LP_SAMPLER_LOD_PROPERTY_MASK) >> + LP_SAMPLER_LOD_PROPERTY_SHIFT; + lod_control = (sample_key & LP_SAMPLER_LOD_CONTROL_MASK) >> + LP_SAMPLER_LOD_CONTROL_SHIFT; + + if (lod_control == LP_SAMPLER_LOD_BIAS) { + lod_bias = lod; + assert(lod); + assert(derivs == NULL); + } + else if (lod_control == LP_SAMPLER_LOD_EXPLICIT) { + explicit_lod = lod; + assert(lod); + assert(derivs == NULL); + } + else if (lod_control == LP_SAMPLER_LOD_DERIVATIVES) { + assert(derivs); + assert(lod == NULL); + } + else { + assert(derivs == NULL); + assert(lod == NULL); + } + if (static_texture_state->format == PIPE_FORMAT_NONE) { /* * If there's nothing bound, format is NONE, and we must return @@ -2633,7 +2660,7 @@ lp_build_sample_soa_code(struct gallivm_state *gallivm, else if (is_fetch) { lp_build_fetch_texel(&bld, texture_index, newcoords, - explicit_lod, offsets, + lod, offsets, texel_out); } @@ -2895,15 +2922,6 @@ lp_build_sample_soa_code(struct gallivm_state *gallivm, #define LP_MAX_TEX_FUNC_ARGS 32 -#define LP_SAMPLER_FUNC_LOD_BIAS (1 << 0) -#define LP_SAMPLER_FUNC_LOD_EXPLICIT (1 << 1) -#define LP_SAMPLER_FUNC_EXPLICITDERIVS (1 << 2) -#define LP_SAMPLER_FUNC_SHADOW (1 << 3) -#define LP_SAMPLER_FUNC_OFFSETS (1 << 4) -#define LP_SAMPLER_FUNC_FETCH (1 << 5) -#define LP_SAMPLER_FUNC_LOD_PROPERTY_SHIFT 6 - - static inline void get_target_info(enum pipe_texture_target target, unsigned *num_coords, unsigned *num_derivs, @@ -2935,27 +2953,27 @@ lp_build_sample_gen_func(struct gallivm_state *gallivm, const struct lp_static_sampler_state *static_sampler_state, struct lp_sampler_dynamic_state *dynamic_state, struct lp_type type, - boolean is_fetch, unsigned texture_index, unsigned sampler_index, LLVMValueRef function, unsigned num_args, - unsigned sampler_bits, - enum lp_sampler_lod_property lod_property) + unsigned sample_key) { - LLVMBuilderRef old_builder; LLVMBasicBlockRef block; LLVMValueRef coords[5]; LLVMValueRef offsets[3] = { NULL }; - LLVMValueRef lod_bias = NULL; - LLVMValueRef explicit_lod = NULL; + LLVMValueRef lod = NULL; LLVMValueRef context_ptr; LLVMValueRef texel_out[4]; struct lp_derivatives derivs; struct lp_derivatives *deriv_ptr = NULL; unsigned num_param = 0; unsigned i, num_coords, num_derivs, num_offsets, layer; + enum lp_sampler_lod_control lod_control; + + lod_control = (sample_key & LP_SAMPLER_LOD_CONTROL_MASK) >> + LP_SAMPLER_LOD_CONTROL_SHIFT; get_target_info(static_texture_state->target, &num_coords, &num_derivs, &num_offsets, &layer); @@ -2972,21 +2990,19 @@ lp_build_sample_gen_func(struct gallivm_state *gallivm, if (layer) { coords[layer] = LLVMGetParam(function, num_param++); } - if (sampler_bits & LP_SAMPLER_FUNC_SHADOW) { + if (sample_key & LP_SAMPLER_SHADOW) { coords[4] = LLVMGetParam(function, num_param++); } - if (sampler_bits & LP_SAMPLER_FUNC_OFFSETS) { + if (sample_key & LP_SAMPLER_OFFSETS) { for (i = 0; i < num_offsets; i++) { offsets[i] = LLVMGetParam(function, num_param++); } } - if (sampler_bits & LP_SAMPLER_FUNC_LOD_BIAS) { - lod_bias = LLVMGetParam(function, num_param++); - } - else if (sampler_bits & LP_SAMPLER_FUNC_LOD_EXPLICIT) { - explicit_lod = LLVMGetParam(function, num_param++); + if (lod_control == LP_SAMPLER_LOD_BIAS || + lod_control == LP_SAMPLER_LOD_EXPLICIT) { + lod = LLVMGetParam(function, num_param++); } - else if (sampler_bits & LP_SAMPLER_FUNC_EXPLICITDERIVS) { + else if (lod_control == LP_SAMPLER_LOD_DERIVATIVES) { for (i = 0; i < num_derivs; i++) { derivs.ddx[i] = LLVMGetParam(function, num_param++); derivs.ddy[i] = LLVMGetParam(function, num_param++); @@ -3010,16 +3026,14 @@ lp_build_sample_gen_func(struct gallivm_state *gallivm, static_sampler_state, dynamic_state, type, - is_fetch, + sample_key, texture_index, sampler_index, context_ptr, coords, offsets, deriv_ptr, - lod_bias, - explicit_lod, - lod_property, + lod, texel_out); LLVMBuildAggregateRet(gallivm->builder, texel_out, 4); @@ -3040,18 +3054,7 @@ lp_build_sample_soa_func(struct gallivm_state *gallivm, const struct lp_static_texture_state *static_texture_state, const struct lp_static_sampler_state *static_sampler_state, struct lp_sampler_dynamic_state *dynamic_state, - struct lp_type type, - boolean is_fetch, - unsigned texture_index, - unsigned sampler_index, - LLVMValueRef context_ptr, - const LLVMValueRef *coords, - const LLVMValueRef *offsets, - const struct lp_derivatives *derivs, /* optional */ - LLVMValueRef lod_bias, /* optional */ - LLVMValueRef explicit_lod, /* optional */ - enum lp_sampler_lod_property lod_property, - LLVMValueRef texel_out[4]) + const struct lp_sampler_params *params) { LLVMBuilderRef builder = gallivm->builder; LLVMModuleRef module = LLVMGetGlobalParent(LLVMGetBasicBlockParent( @@ -3061,9 +3064,18 @@ lp_build_sample_soa_func(struct gallivm_state *gallivm, LLVMBasicBlockRef bb; LLVMValueRef tex_ret; unsigned num_args = 0; - unsigned sampler_bits = 0; char func_name[64]; unsigned i, num_coords, num_derivs, num_offsets, layer; + unsigned texture_index = params->texture_index; + unsigned sampler_index = params->sampler_index; + unsigned sample_key = params->sample_key; + const LLVMValueRef *coords = params->coords; + const LLVMValueRef *offsets = params->offsets; + const struct lp_derivatives *derivs = params->derivs; + enum lp_sampler_lod_control lod_control; + + lod_control = (sample_key & LP_SAMPLER_LOD_CONTROL_MASK) >> + LP_SAMPLER_LOD_CONTROL_SHIFT; get_target_info(static_texture_state->target, &num_coords, &num_derivs, &num_offsets, &layer); @@ -3071,34 +3083,13 @@ lp_build_sample_soa_func(struct gallivm_state *gallivm, /* * texture function matches are found by name. * Thus the name has to include both the texture and sampler unit - * (which covers all static state) plus the actual texture functions - * (which is determined here somewhat awkwardly by presence of the - * corresponding LLVMValueRefs). Additionally, lod_property also - * has to be included (it could change if the lod for instance comes - * from a shader uniform or a temp reg). + * (which covers all static state) plus the actual texture function + * (including things like offsets, shadow coord, lod control). + * Additionally lod_property has to be included too. */ - if (static_sampler_state->compare_mode != PIPE_TEX_COMPARE_NONE) { - sampler_bits |= LP_SAMPLER_FUNC_SHADOW; - } - if (offsets[0]) { - sampler_bits |= LP_SAMPLER_FUNC_OFFSETS; - } - if (lod_bias) { - sampler_bits |= LP_SAMPLER_FUNC_LOD_BIAS; - } - else if (explicit_lod) { - sampler_bits |= LP_SAMPLER_FUNC_LOD_EXPLICIT; - } - else if (derivs) { - sampler_bits |= LP_SAMPLER_FUNC_EXPLICITDERIVS; - } - if (is_fetch) { - sampler_bits |= LP_SAMPLER_FUNC_FETCH; - } - sampler_bits |= lod_property << LP_SAMPLER_FUNC_LOD_PROPERTY_SHIFT; util_snprintf(func_name, sizeof(func_name), "texfunc_res_%d_sam_%d_%x", - texture_index, sampler_index, sampler_bits); + texture_index, sampler_index, sample_key); function = LLVMGetNamedFunction(module, func_name); @@ -3113,7 +3104,7 @@ lp_build_sample_soa_func(struct gallivm_state *gallivm, * Generate the function prototype. */ - arg_types[num_param++] = LLVMTypeOf(context_ptr); + arg_types[num_param++] = LLVMTypeOf(params->context_ptr); for (i = 0; i < num_coords; i++) { arg_types[num_param++] = LLVMTypeOf(coords[0]); assert(LLVMTypeOf(coords[0]) == LLVMTypeOf(coords[i])); @@ -3122,22 +3113,20 @@ lp_build_sample_soa_func(struct gallivm_state *gallivm, arg_types[num_param++] = LLVMTypeOf(coords[layer]); assert(LLVMTypeOf(coords[0]) == LLVMTypeOf(coords[layer])); } - if (sampler_bits & LP_SAMPLER_FUNC_SHADOW) { + if (sample_key & LP_SAMPLER_SHADOW) { arg_types[num_param++] = LLVMTypeOf(coords[0]); } - if (sampler_bits & LP_SAMPLER_FUNC_OFFSETS) { + if (sample_key & LP_SAMPLER_OFFSETS) { for (i = 0; i < num_offsets; i++) { arg_types[num_param++] = LLVMTypeOf(offsets[0]); assert(LLVMTypeOf(offsets[0]) == LLVMTypeOf(offsets[i])); } } - if (sampler_bits & LP_SAMPLER_FUNC_LOD_BIAS) { - arg_types[num_param++] = LLVMTypeOf(lod_bias); - } - else if (sampler_bits & LP_SAMPLER_FUNC_LOD_EXPLICIT) { - arg_types[num_param++] = LLVMTypeOf(explicit_lod); + if (lod_control == LP_SAMPLER_LOD_BIAS || + lod_control == LP_SAMPLER_LOD_EXPLICIT) { + arg_types[num_param++] = LLVMTypeOf(params->lod); } - else if (sampler_bits & LP_SAMPLER_FUNC_EXPLICITDERIVS) { + else if (lod_control == LP_SAMPLER_LOD_DERIVATIVES) { for (i = 0; i < num_derivs; i++) { arg_types[num_param++] = LLVMTypeOf(derivs->ddx[i]); arg_types[num_param++] = LLVMTypeOf(derivs->ddy[i]); @@ -3147,7 +3136,7 @@ lp_build_sample_soa_func(struct gallivm_state *gallivm, } val_type[0] = val_type[1] = val_type[2] = val_type[3] = - lp_build_vec_type(gallivm, type); + lp_build_vec_type(gallivm, params->type); ret_type = LLVMStructTypeInContext(gallivm->context, val_type, 4, 0); function_type = LLVMFunctionType(ret_type, arg_types, num_param, 0); function = LLVMAddFunction(module, func_name, function_type); @@ -3165,39 +3154,35 @@ lp_build_sample_soa_func(struct gallivm_state *gallivm, static_texture_state, static_sampler_state, dynamic_state, - type, - is_fetch, + params->type, texture_index, sampler_index, function, num_param, - sampler_bits, - lod_property); + sample_key); } num_args = 0; - args[num_args++] = context_ptr; + args[num_args++] = params->context_ptr; for (i = 0; i < num_coords; i++) { args[num_args++] = coords[i]; } if (layer) { args[num_args++] = coords[layer]; } - if (sampler_bits & LP_SAMPLER_FUNC_SHADOW) { + if (sample_key & LP_SAMPLER_SHADOW) { args[num_args++] = coords[4]; } - if (sampler_bits & LP_SAMPLER_FUNC_OFFSETS) { + if (sample_key & LP_SAMPLER_OFFSETS) { for (i = 0; i < num_offsets; i++) { args[num_args++] = offsets[i]; } } - if (sampler_bits & LP_SAMPLER_FUNC_LOD_BIAS) { - args[num_args++] = lod_bias; - } - else if (sampler_bits & LP_SAMPLER_FUNC_LOD_EXPLICIT) { - args[num_args++] = explicit_lod; + if (lod_control == LP_SAMPLER_LOD_BIAS || + lod_control == LP_SAMPLER_LOD_EXPLICIT) { + args[num_args++] = params->lod; } - else if (sampler_bits & LP_SAMPLER_FUNC_EXPLICITDERIVS) { + else if (lod_control == LP_SAMPLER_LOD_DERIVATIVES) { for (i = 0; i < num_derivs; i++) { args[num_args++] = derivs->ddx[i]; args[num_args++] = derivs->ddy[i]; @@ -3212,7 +3197,7 @@ lp_build_sample_soa_func(struct gallivm_state *gallivm, LLVMSetInstructionCallConv(inst, LLVMFastCallConv); for (i = 0; i < 4; i++) { - texel_out[i] = LLVMBuildExtractValue(gallivm->builder, tex_ret, i, ""); + params->texel[i] = LLVMBuildExtractValue(gallivm->builder, tex_ret, i, ""); } } @@ -3222,58 +3207,34 @@ lp_build_sample_soa_func(struct gallivm_state *gallivm, * Either via a function call or inline it directly. */ void -lp_build_sample_soa(struct gallivm_state *gallivm, - const struct lp_static_texture_state *static_texture_state, +lp_build_sample_soa(const struct lp_static_texture_state *static_texture_state, const struct lp_static_sampler_state *static_sampler_state, struct lp_sampler_dynamic_state *dynamic_state, - struct lp_type type, - boolean is_fetch, - unsigned texture_index, - unsigned sampler_index, - LLVMValueRef context_ptr, - const LLVMValueRef *coords, - const LLVMValueRef *offsets, - const struct lp_derivatives *derivs, /* optional */ - LLVMValueRef lod_bias, /* optional */ - LLVMValueRef explicit_lod, /* optional */ - enum lp_sampler_lod_property lod_property, - LLVMValueRef texel_out[4]) + struct gallivm_state *gallivm, + const struct lp_sampler_params *params) { if (USE_TEX_FUNC_CALL) { lp_build_sample_soa_func(gallivm, static_texture_state, static_sampler_state, dynamic_state, - type, - is_fetch, - texture_index, - sampler_index, - context_ptr, - coords, - offsets, - derivs, - lod_bias, - explicit_lod, - lod_property, - texel_out); + params); } else { lp_build_sample_soa_code(gallivm, static_texture_state, static_sampler_state, dynamic_state, - type, - is_fetch, - texture_index, - sampler_index, - context_ptr, - coords, - offsets, - derivs, - lod_bias, - explicit_lod, - lod_property, - texel_out); + params->type, + params->sample_key, + params->texture_index, + params->sampler_index, + params->context_ptr, + params->coords, + params->offsets, + params->derivs, + params->lod, + params->texel); } } diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h b/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h index 8d53607..3f76b79 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h +++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h @@ -182,20 +182,9 @@ struct lp_build_sampler_soa (*destroy)( struct lp_build_sampler_soa *sampler ); void - (*emit_fetch_texel)( const struct lp_build_sampler_soa *sampler, - struct gallivm_state *gallivm, - struct lp_type type, - boolean is_fetch, - unsigned texture_index, - unsigned sampler_index, - LLVMValueRef context_ptr, - const LLVMValueRef *coords, - const LLVMValueRef *offsets, - const struct lp_derivatives *derivs, - LLVMValueRef lod_bias, /* optional */ - LLVMValueRef explicit_lod, /* optional */ - enum lp_sampler_lod_property, - LLVMValueRef *texel); + (*emit_tex_sample)(const struct lp_build_sampler_soa *sampler, + struct gallivm_state *gallivm, + const struct lp_sampler_params *params); void (*emit_size_query)( const struct lp_build_sampler_soa *sampler, diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c index 3e82036..6a71da6 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c @@ -1964,16 +1964,19 @@ emit_tex( struct lp_build_tgsi_soa_context *bld, unsigned sampler_reg) { unsigned unit = inst->Src[sampler_reg].Register.Index; - LLVMValueRef lod_bias, explicit_lod; LLVMValueRef oow = NULL; + LLVMValueRef lod = NULL; LLVMValueRef coords[5]; LLVMValueRef offsets[3] = { NULL }; struct lp_derivatives derivs; - struct lp_derivatives *deriv_ptr = NULL; + struct lp_sampler_params params; enum lp_sampler_lod_property lod_property = LP_SAMPLER_LOD_SCALAR; unsigned num_derivs, num_offsets, i; unsigned shadow_coord = 0; unsigned layer_coord = 0; + unsigned sample_key = 0; + + memset(¶ms, 0, sizeof(params)); if (!bld->sampler) { _debug_printf("warning: found texture instruction but no sampler generator supplied\n"); @@ -2053,7 +2056,6 @@ emit_tex( struct lp_build_tgsi_soa_context *bld, /* Note lod and especially projected are illegal in a LOT of cases */ if (modifier == LP_BLD_TEX_MODIFIER_LOD_BIAS || modifier == LP_BLD_TEX_MODIFIER_EXPLICIT_LOD) { - LLVMValueRef lod; if (inst->Texture.Texture == TGSI_TEXTURE_SHADOWCUBE || inst->Texture.Texture == TGSI_TEXTURE_CUBE_ARRAY) { /* note that shadow cube array with bias/explicit lod does not exist */ @@ -2063,19 +2065,13 @@ emit_tex( struct lp_build_tgsi_soa_context *bld, lod = lp_build_emit_fetch(&bld->bld_base, inst, 0, 3); } if (modifier == LP_BLD_TEX_MODIFIER_LOD_BIAS) { - lod_bias = lod; - explicit_lod = NULL; + sample_key |= LP_SAMPLER_LOD_BIAS << LP_SAMPLER_LOD_CONTROL_SHIFT; } else if (modifier == LP_BLD_TEX_MODIFIER_EXPLICIT_LOD) { - lod_bias = NULL; - explicit_lod = lod; + sample_key |= LP_SAMPLER_LOD_EXPLICIT << LP_SAMPLER_LOD_CONTROL_SHIFT; } lod_property = lp_build_lod_property(&bld->bld_base, inst, 0); } - else { - lod_bias = NULL; - explicit_lod = NULL; - } if (modifier == LP_BLD_TEX_MODIFIER_PROJECTED) { oow = lp_build_emit_fetch(&bld->bld_base, inst, 0, 3); @@ -2104,6 +2100,7 @@ emit_tex( struct lp_build_tgsi_soa_context *bld, } /* Shadow coord occupies always 5th slot. */ if (shadow_coord) { + sample_key |= LP_SAMPLER_SHADOW; if (shadow_coord == 4) { coords[4] = lp_build_emit_fetch(&bld->bld_base, inst, 1, 0); } @@ -2116,11 +2113,12 @@ emit_tex( struct lp_build_tgsi_soa_context *bld, if (modifier == LP_BLD_TEX_MODIFIER_EXPLICIT_DERIV) { unsigned dim; + sample_key |= LP_SAMPLER_LOD_DERIVATIVES << LP_SAMPLER_LOD_CONTROL_SHIFT; for (dim = 0; dim < num_derivs; ++dim) { derivs.ddx[dim] = lp_build_emit_fetch(&bld->bld_base, inst, 1, dim); derivs.ddy[dim] = lp_build_emit_fetch(&bld->bld_base, inst, 2, dim); } - deriv_ptr = &derivs; + params.derivs = &derivs; /* * could also check all src regs if constant but I doubt such * cases exist in practice. @@ -2137,26 +2135,30 @@ emit_tex( struct lp_build_tgsi_soa_context *bld, lod_property = LP_SAMPLER_LOD_PER_ELEMENT; } } + sample_key |= lod_property << LP_SAMPLER_LOD_PROPERTY_SHIFT; /* some advanced gather instructions (txgo) would require 4 offsets */ if (inst->Texture.NumOffsets == 1) { unsigned dim; + sample_key |= LP_SAMPLER_OFFSETS; for (dim = 0; dim < num_offsets; dim++) { offsets[dim] = lp_build_emit_fetch_texoffset(&bld->bld_base, inst, 0, dim); } } - bld->sampler->emit_fetch_texel(bld->sampler, - bld->bld_base.base.gallivm, - bld->bld_base.base.type, - FALSE, - unit, unit, - bld->context_ptr, - coords, - offsets, - deriv_ptr, - lod_bias, explicit_lod, lod_property, - texel); + params.type = bld->bld_base.base.type; + params.sample_key = sample_key; + params.texture_index = unit; + params.sampler_index = unit; + params.context_ptr = bld->context_ptr; + params.coords = coords; + params.offsets = offsets; + params.lod = lod; + params.texel = texel; + + bld->sampler->emit_tex_sample(bld->sampler, + bld->bld_base.base.gallivm, + ¶ms); } static void @@ -2168,15 +2170,18 @@ emit_sample(struct lp_build_tgsi_soa_context *bld, { struct gallivm_state *gallivm = bld->bld_base.base.gallivm; unsigned texture_unit, sampler_unit; - LLVMValueRef lod_bias, explicit_lod; + LLVMValueRef lod = NULL; LLVMValueRef coords[5]; LLVMValueRef offsets[3] = { NULL }; struct lp_derivatives derivs; - struct lp_derivatives *deriv_ptr = NULL; + struct lp_sampler_params params; enum lp_sampler_lod_property lod_property = LP_SAMPLER_LOD_SCALAR; unsigned num_offsets, num_derivs, i; unsigned layer_coord = 0; + unsigned sample_key = 0; + + memset(¶ms, 0, sizeof(params)); if (!bld->sampler) { _debug_printf("warning: found texture instruction but no sampler generator supplied\n"); @@ -2238,25 +2243,19 @@ emit_sample(struct lp_build_tgsi_soa_context *bld, if (modifier == LP_BLD_TEX_MODIFIER_LOD_BIAS || modifier == LP_BLD_TEX_MODIFIER_EXPLICIT_LOD) { - LLVMValueRef lod = lp_build_emit_fetch(&bld->bld_base, inst, 3, 0); + lod = lp_build_emit_fetch(&bld->bld_base, inst, 3, 0); if (modifier == LP_BLD_TEX_MODIFIER_LOD_BIAS) { - lod_bias = lod; - explicit_lod = NULL; + sample_key |= LP_SAMPLER_LOD_BIAS << LP_SAMPLER_LOD_CONTROL_SHIFT; } else if (modifier == LP_BLD_TEX_MODIFIER_EXPLICIT_LOD) { - lod_bias = NULL; - explicit_lod = lod; + sample_key |= LP_SAMPLER_LOD_EXPLICIT << LP_SAMPLER_LOD_CONTROL_SHIFT; } lod_property = lp_build_lod_property(&bld->bld_base, inst, 0); } else if (modifier == LP_BLD_TEX_MODIFIER_LOD_ZERO) { - lod_bias = NULL; /* XXX might be better to explicitly pass the level zero information */ - explicit_lod = lp_build_const_vec(gallivm, bld->bld_base.base.type, 0.0F); - } - else { - lod_bias = NULL; - explicit_lod = NULL; + sample_key |= LP_SAMPLER_LOD_EXPLICIT << LP_SAMPLER_LOD_CONTROL_SHIFT; + lod = lp_build_const_vec(gallivm, bld->bld_base.base.type, 0.0F); } for (i = 0; i < num_derivs; i++) { @@ -2275,16 +2274,18 @@ emit_sample(struct lp_build_tgsi_soa_context *bld, } /* Shadow coord occupies always 5th slot. */ if (compare) { + sample_key |= LP_SAMPLER_SHADOW; coords[4] = lp_build_emit_fetch(&bld->bld_base, inst, 3, 0); } if (modifier == LP_BLD_TEX_MODIFIER_EXPLICIT_DERIV) { unsigned dim; + sample_key |= LP_SAMPLER_LOD_DERIVATIVES << LP_SAMPLER_LOD_CONTROL_SHIFT; for (dim = 0; dim < num_derivs; ++dim) { derivs.ddx[dim] = lp_build_emit_fetch(&bld->bld_base, inst, 3, dim); derivs.ddy[dim] = lp_build_emit_fetch(&bld->bld_base, inst, 4, dim); } - deriv_ptr = &derivs; + params.derivs = &derivs; /* * could also check all src regs if constant but I doubt such * cases exist in practice. @@ -2305,22 +2306,26 @@ emit_sample(struct lp_build_tgsi_soa_context *bld, /* some advanced gather instructions (txgo) would require 4 offsets */ if (inst->Texture.NumOffsets == 1) { unsigned dim; + sample_key |= LP_SAMPLER_OFFSETS; for (dim = 0; dim < num_offsets; dim++) { offsets[dim] = lp_build_emit_fetch_texoffset(&bld->bld_base, inst, 0, dim); } } + sample_key |= lod_property << LP_SAMPLER_LOD_PROPERTY_SHIFT; - bld->sampler->emit_fetch_texel(bld->sampler, - bld->bld_base.base.gallivm, - bld->bld_base.base.type, - FALSE, - texture_unit, sampler_unit, - bld->context_ptr, - coords, - offsets, - deriv_ptr, - lod_bias, explicit_lod, lod_property, - texel); + params.type = bld->bld_base.base.type; + params.sample_key = sample_key; + params.texture_index = texture_unit; + params.sampler_index = sampler_unit; + params.context_ptr = bld->context_ptr; + params.coords = coords; + params.offsets = offsets; + params.lod = lod; + params.texel = texel; + + bld->sampler->emit_tex_sample(bld->sampler, + bld->bld_base.base.gallivm, + ¶ms); if (inst->Src[1].Register.SwizzleX != PIPE_SWIZZLE_RED || inst->Src[1].Register.SwizzleY != PIPE_SWIZZLE_GREEN || @@ -2347,9 +2352,13 @@ emit_fetch_texels( struct lp_build_tgsi_soa_context *bld, LLVMValueRef explicit_lod = NULL; LLVMValueRef coords[5]; LLVMValueRef offsets[3] = { NULL }; + struct lp_sampler_params params; enum lp_sampler_lod_property lod_property = LP_SAMPLER_LOD_SCALAR; unsigned dims, i; unsigned layer_coord = 0; + unsigned sample_key = LP_SAMPLER_FETCH; + + memset(¶ms, 0, sizeof(params)); if (!bld->sampler) { _debug_printf("warning: found texture instruction but no sampler generator supplied\n"); @@ -2399,6 +2408,7 @@ emit_fetch_texels( struct lp_build_tgsi_soa_context *bld, if (target != TGSI_TEXTURE_BUFFER && target != TGSI_TEXTURE_2D_MSAA && target != TGSI_TEXTURE_2D_ARRAY_MSAA) { + sample_key |= LP_SAMPLER_LOD_EXPLICIT << LP_SAMPLER_LOD_CONTROL_SHIFT; explicit_lod = lp_build_emit_fetch(&bld->bld_base, inst, 0, 3); lod_property = lp_build_lod_property(&bld->bld_base, inst, 0); } @@ -2416,22 +2426,27 @@ emit_fetch_texels( struct lp_build_tgsi_soa_context *bld, if (inst->Texture.NumOffsets == 1) { unsigned dim; + sample_key |= LP_SAMPLER_OFFSETS; for (dim = 0; dim < dims; dim++) { offsets[dim] = lp_build_emit_fetch_texoffset(&bld->bld_base, inst, 0, dim); } } + sample_key |= lod_property << LP_SAMPLER_LOD_PROPERTY_SHIFT; - bld->sampler->emit_fetch_texel(bld->sampler, - bld->bld_base.base.gallivm, - bld->bld_base.base.type, - TRUE, - unit, unit, - bld->context_ptr, - coords, - offsets, - NULL, - NULL, explicit_lod, lod_property, - texel); + params.type = bld->bld_base.base.type; + params.sample_key = sample_key; + params.texture_index = unit; + params.sampler_index = unit; + params.context_ptr = bld->context_ptr; + params.coords = coords; + params.offsets = offsets; + params.derivs = NULL; + params.lod = explicit_lod; + params.texel = texel; + + bld->sampler->emit_tex_sample(bld->sampler, + bld->bld_base.base.gallivm, + ¶ms); if (is_samplei && (inst->Src[1].Register.SwizzleX != PIPE_SWIZZLE_RED || diff --git a/src/gallium/drivers/llvmpipe/lp_tex_sample.c b/src/gallium/drivers/llvmpipe/lp_tex_sample.c index 1828069..316d1c5 100644 --- a/src/gallium/drivers/llvmpipe/lp_tex_sample.c +++ b/src/gallium/drivers/llvmpipe/lp_tex_sample.c @@ -235,43 +235,24 @@ lp_llvm_sampler_soa_destroy(struct lp_build_sampler_soa *sampler) static void lp_llvm_sampler_soa_emit_fetch_texel(const struct lp_build_sampler_soa *base, struct gallivm_state *gallivm, - struct lp_type type, - boolean is_fetch, - unsigned texture_index, - unsigned sampler_index, - LLVMValueRef context_ptr, - const LLVMValueRef *coords, - const LLVMValueRef *offsets, - const struct lp_derivatives *derivs, - LLVMValueRef lod_bias, /* optional */ - LLVMValueRef explicit_lod, /* optional */ - enum lp_sampler_lod_property lod_property, - LLVMValueRef *texel) + const struct lp_sampler_params *params) { struct lp_llvm_sampler_soa *sampler = (struct lp_llvm_sampler_soa *)base; + unsigned texture_index = params->texture_index; + unsigned sampler_index = params->sampler_index; assert(sampler_index < PIPE_MAX_SAMPLERS); assert(texture_index < PIPE_MAX_SHADER_SAMPLER_VIEWS); if (LP_PERF & PERF_NO_TEX) { - lp_build_sample_nop(gallivm, type, coords, texel); + lp_build_sample_nop(gallivm, params->type, params->coords, params->texel); return; } - lp_build_sample_soa(gallivm, - &sampler->dynamic_state.static_state[texture_index].texture_state, + lp_build_sample_soa(&sampler->dynamic_state.static_state[texture_index].texture_state, &sampler->dynamic_state.static_state[sampler_index].sampler_state, &sampler->dynamic_state.base, - type, - is_fetch, - texture_index, - sampler_index, - context_ptr, - coords, - offsets, - derivs, - lod_bias, explicit_lod, lod_property, - texel); + gallivm, params); } /** @@ -317,7 +298,7 @@ lp_llvm_sampler_soa_create(const struct lp_sampler_static_state *static_state) return NULL; sampler->base.destroy = lp_llvm_sampler_soa_destroy; - sampler->base.emit_fetch_texel = lp_llvm_sampler_soa_emit_fetch_texel; + sampler->base.emit_tex_sample = lp_llvm_sampler_soa_emit_fetch_texel; sampler->base.emit_size_query = lp_llvm_sampler_soa_emit_size_query; sampler->dynamic_state.base.width = lp_llvm_texture_width; sampler->dynamic_state.base.height = lp_llvm_texture_height; From leoliu at kemper.freedesktop.org Tue Mar 31 16:43:03 2015 From: leoliu at kemper.freedesktop.org (Leo Liu) Date: Tue, 31 Mar 2015 09:43:03 -0700 (PDT) Subject: Mesa (master): st/omx/enc: export framerate to vce driver Message-ID: <20150331164303.A746976336@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 8e3668a7c0c725285d1d23cf5f2bc32c69114650 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=8e3668a7c0c725285d1d23cf5f2bc32c69114650 Author: Leo Liu Date: Mon Mar 30 13:25:15 2015 -0400 st/omx/enc: export framerate to vce driver The framerate will be used for video usability info support by VCE driver Signed-off-by: Leo Liu Reviewed-by: Christian K?nig --- src/gallium/state_trackers/omx/vid_enc.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/gallium/state_trackers/omx/vid_enc.c b/src/gallium/state_trackers/omx/vid_enc.c index 83624c5..ae1a98f 100644 --- a/src/gallium/state_trackers/omx/vid_enc.c +++ b/src/gallium/state_trackers/omx/vid_enc.c @@ -1015,6 +1015,9 @@ static void enc_ControlPicture(omx_base_PortType *port, struct pipe_h264_enc_pic break; } + rate_ctrl->frame_rate_den = OMX_VID_ENC_CONTROL_FRAME_RATE_DEN_DEFAULT; + rate_ctrl->frame_rate_num = ((priv->frame_rate) >> 16) * rate_ctrl->frame_rate_den; + if (rate_ctrl->rate_ctrl_method != PIPE_H264_ENC_RATE_CONTROL_METHOD_DISABLE) { if (priv->bitrate.nTargetBitrate < OMX_VID_ENC_BITRATE_MIN) rate_ctrl->target_bitrate = OMX_VID_ENC_BITRATE_MIN; @@ -1023,8 +1026,6 @@ static void enc_ControlPicture(omx_base_PortType *port, struct pipe_h264_enc_pic else rate_ctrl->target_bitrate = OMX_VID_ENC_BITRATE_MAX; rate_ctrl->peak_bitrate = rate_ctrl->target_bitrate; - rate_ctrl->frame_rate_den = OMX_VID_ENC_CONTROL_FRAME_RATE_DEN_DEFAULT; - rate_ctrl->frame_rate_num = ((priv->frame_rate) >> 16) * rate_ctrl->frame_rate_den; if (rate_ctrl->target_bitrate < OMX_VID_ENC_BITRATE_MEDIAN) rate_ctrl->vbv_buffer_size = MIN2((rate_ctrl->target_bitrate * 2.75), OMX_VID_ENC_BITRATE_MEDIAN); else @@ -1039,8 +1040,7 @@ static void enc_ControlPicture(omx_base_PortType *port, struct pipe_h264_enc_pic } rate_ctrl->peak_bits_picture_integer = rate_ctrl->target_bits_picture; rate_ctrl->peak_bits_picture_fraction = 0; - } else - memset(rate_ctrl, 0, sizeof(struct pipe_h264_enc_rate_control)); + } picture->quant_i_frames = priv->quant.nQpI; picture->quant_p_frames = priv->quant.nQpP; From leoliu at kemper.freedesktop.org Tue Mar 31 16:43:03 2015 From: leoliu at kemper.freedesktop.org (Leo Liu) Date: Tue, 31 Mar 2015 09:43:03 -0700 (PDT) Subject: Mesa (master): radeon/vce: implement video usability information support Message-ID: <20150331164303.B1D3E7635A@kemper.freedesktop.org> Module: Mesa Branch: master Commit: a714fbacf7bc5dcbc316bbfcb6bd9cb38fb4f858 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=a714fbacf7bc5dcbc316bbfcb6bd9cb38fb4f858 Author: Leo Liu Date: Mon Mar 30 13:33:19 2015 -0400 radeon/vce: implement video usability information support This will help encoding VUI into the bitstream v2: make backward compatible Signed-off-by: Leo Liu Reviewed-by: Christian K?nig --- src/gallium/drivers/radeon/radeon_vce.c | 5 +++ src/gallium/drivers/radeon/radeon_vce.h | 2 + src/gallium/drivers/radeon/radeon_vce_40_2_2.c | 52 ++++++++++++++++++++++++ 3 files changed, 59 insertions(+) diff --git a/src/gallium/drivers/radeon/radeon_vce.c b/src/gallium/drivers/radeon/radeon_vce.c index 27a3832..6d34bd3 100644 --- a/src/gallium/drivers/radeon/radeon_vce.c +++ b/src/gallium/drivers/radeon/radeon_vce.c @@ -242,6 +242,8 @@ static void rvce_begin_frame(struct pipe_video_codec *encoder, enc->config_extension(enc); enc->motion_estimation(enc); enc->rdo(enc); + if (enc->use_vui) + enc->vui(enc); enc->pic_control(enc); enc->feedback(enc); flush(enc); @@ -352,6 +354,9 @@ struct pipe_video_codec *rvce_create_encoder(struct pipe_context *context, if (!enc) return NULL; + if ((rscreen->info.drm_major > 2) || (rscreen->info.drm_minor >= 42)) + enc->use_vui = true; + enc->base = *templ; enc->base.context = context; diff --git a/src/gallium/drivers/radeon/radeon_vce.h b/src/gallium/drivers/radeon/radeon_vce.h index 11febc8..7f0cd1f 100644 --- a/src/gallium/drivers/radeon/radeon_vce.h +++ b/src/gallium/drivers/radeon/radeon_vce.h @@ -75,6 +75,7 @@ struct rvce_encoder { void (*pic_control)(struct rvce_encoder *enc); void (*motion_estimation)(struct rvce_encoder *enc); void (*rdo)(struct rvce_encoder *enc); + void (*vui)(struct rvce_encoder *enc); void (*encode)(struct rvce_encoder *enc); void (*destroy)(struct rvce_encoder *enc); @@ -100,6 +101,7 @@ struct rvce_encoder { struct rvid_buffer *fb; struct rvid_buffer cpb; struct pipe_h264_enc_picture_desc pic; + bool use_vui; }; struct pipe_video_codec *rvce_create_encoder(struct pipe_context *context, diff --git a/src/gallium/drivers/radeon/radeon_vce_40_2_2.c b/src/gallium/drivers/radeon/radeon_vce_40_2_2.c index 06d3e95..b176aa7 100644 --- a/src/gallium/drivers/radeon/radeon_vce_40_2_2.c +++ b/src/gallium/drivers/radeon/radeon_vce_40_2_2.c @@ -248,6 +248,57 @@ static void rdo(struct rvce_encoder *enc) RVCE_END(); } +static void vui(struct rvce_encoder *enc) +{ + int i; + + RVCE_BEGIN(0x04000009); // vui + RVCE_CS(0x00000000); //aspectRatioInfoPresentFlag + RVCE_CS(0x00000000); //aspectRatioInfo.aspectRatioIdc + RVCE_CS(0x00000000); //aspectRatioInfo.sarWidth + RVCE_CS(0x00000000); //aspectRatioInfo.sarHeight + RVCE_CS(0x00000000); //overscanInfoPresentFlag + RVCE_CS(0x00000000); //overScanInfo.overscanAppropFlag + RVCE_CS(0x00000000); //videoSignalTypePresentFlag + RVCE_CS(0x00000005); //videoSignalTypeInfo.videoFormat + RVCE_CS(0x00000000); //videoSignalTypeInfo.videoFullRangeFlag + RVCE_CS(0x00000000); //videoSignalTypeInfo.colorDescriptionPresentFlag + RVCE_CS(0x00000002); //videoSignalTypeInfo.colorPrim + RVCE_CS(0x00000002); //videoSignalTypeInfo.transferChar + RVCE_CS(0x00000002); //videoSignalTypeInfo.matrixCoef + RVCE_CS(0x00000000); //chromaLocInfoPresentFlag + RVCE_CS(0x00000000); //chromaLocInfo.chromaLocTop + RVCE_CS(0x00000000); //chromaLocInfo.chromaLocBottom + RVCE_CS(0x00000001); //timingInfoPresentFlag + RVCE_CS(enc->pic.rate_ctrl.frame_rate_den); //timingInfo.numUnitsInTick + RVCE_CS(enc->pic.rate_ctrl.frame_rate_num * 2); //timingInfo.timeScale; + RVCE_CS(0x00000001); //timingInfo.fixedFrameRateFlag + RVCE_CS(0x00000000); //nalHRDParametersPresentFlag + RVCE_CS(0x00000000); //hrdParam.cpbCntMinus1 + RVCE_CS(0x00000004); //hrdParam.bitRateScale + RVCE_CS(0x00000006); //hrdParam.cpbSizeScale + for (i = 0; i < 32; i++) { + RVCE_CS(0x00000000); //hrdParam.bitRateValueMinus + RVCE_CS(0x00000000); //hrdParam.cpbSizeValueMinus + RVCE_CS(0x00000000); //hrdParam.cbrFlag + } + RVCE_CS(0x00000017); //hrdParam.initialCpbRemovalDelayLengthMinus1 + RVCE_CS(0x00000017); //hrdParam.cpbRemovalDelayLengthMinus1 + RVCE_CS(0x00000017); //hrdParam.dpbOutputDelayLengthMinus1 + RVCE_CS(0x00000018); //hrdParam.timeOffsetLength + RVCE_CS(0x00000000); //lowDelayHRDFlag + RVCE_CS(0x00000000); //picStructPresentFlag + RVCE_CS(0x00000000); //bitstreamRestrictionPresentFlag + RVCE_CS(0x00000001); //bitstreamRestrictions.motionVectorsOverPicBoundariesFlag + RVCE_CS(0x00000002); //bitstreamRestrictions.maxBytesPerPicDenom + RVCE_CS(0x00000001); //bitstreamRestrictions.maxBitsPerMbDenom + RVCE_CS(0x00000010); //bitstreamRestrictions.log2MaxMvLengthHori + RVCE_CS(0x00000010); //bitstreamRestrictions.log2MaxMvLengthVert + RVCE_CS(0x00000003); //bitstreamRestrictions.numReorderFrames + RVCE_CS(0x00000003); //bitstreamRestrictions.maxDecFrameBuffering + RVCE_END(); +} + static void encode(struct rvce_encoder *enc) { int i; @@ -396,6 +447,7 @@ void radeon_vce_40_2_2_init(struct rvce_encoder *enc) enc->pic_control = pic_control; enc->motion_estimation = motion_estimation; enc->rdo = rdo; + enc->vui = vui; enc->encode = encode; enc->destroy = destroy; } From tstellar at kemper.freedesktop.org Tue Mar 31 16:47:51 2015 From: tstellar at kemper.freedesktop.org (Tom Stellard) Date: Tue, 31 Mar 2015 09:47:51 -0700 (PDT) Subject: Mesa (master): clover: Return CL_BUILD_ERROR for CL_PROGRAM_BUILD_STATUS when compilation fails v2 Message-ID: <20150331164751.E1D7476336@kemper.freedesktop.org> Module: Mesa Branch: master Commit: fda7558057a301a5a0ee1cb4d68f09ea39b03bb3 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=fda7558057a301a5a0ee1cb4d68f09ea39b03bb3 Author: Tom Stellard Date: Tue Mar 24 17:17:22 2015 +0000 clover: Return CL_BUILD_ERROR for CL_PROGRAM_BUILD_STATUS when compilation fails v2 v2: - Don't use _errs map Cc: 10.5 10.4 Reviewed-by: Francisco Jerez --- src/gallium/state_trackers/clover/core/program.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gallium/state_trackers/clover/core/program.cpp b/src/gallium/state_trackers/clover/core/program.cpp index 8553ca7..c07548c 100644 --- a/src/gallium/state_trackers/clover/core/program.cpp +++ b/src/gallium/state_trackers/clover/core/program.cpp @@ -90,6 +90,8 @@ cl_build_status program::build_status(const device &dev) const { if (_binaries.count(&dev)) return CL_BUILD_SUCCESS; + else if (_logs.count(&dev)) + return CL_BUILD_ERROR; else return CL_BUILD_NONE; } From tstellar at kemper.freedesktop.org Tue Mar 31 16:47:51 2015 From: tstellar at kemper.freedesktop.org (Tom Stellard) Date: Tue, 31 Mar 2015 09:47:51 -0700 (PDT) Subject: Mesa (master): radeonsi/compute: Default to the same PIPE_SHADER_CAP values as other shader types v2 Message-ID: <20150331164751.D4A7176336@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 4c53d2acbb8b6fa48e91d7edaa81d95e19c2c40d URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=4c53d2acbb8b6fa48e91d7edaa81d95e19c2c40d Author: Tom Stellard Date: Sat Mar 21 00:27:16 2015 +0000 radeonsi/compute: Default to the same PIPE_SHADER_CAP values as other shader types v2 v2: - Fix typo Reviewed-by: Marek Ol??k --- src/gallium/drivers/radeonsi/si_pipe.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/gallium/drivers/radeonsi/si_pipe.c b/src/gallium/drivers/radeonsi/si_pipe.c index 0eada72..ae96b6b 100644 --- a/src/gallium/drivers/radeonsi/si_pipe.c +++ b/src/gallium/drivers/radeonsi/si_pipe.c @@ -398,8 +398,12 @@ static int si_get_shader_param(struct pipe_screen* pscreen, unsigned shader, enu return max_const_buffer_size; } default: - return 0; + /* If compute shaders don't require a special value + * for this cap, we can return the same value we + * do for other shader types. */ + break; } + break; default: /* TODO: support tessellation */ return 0; From nroberts at kemper.freedesktop.org Tue Mar 31 17:23:10 2015 From: nroberts at kemper.freedesktop.org (Neil Roberts) Date: Tue, 31 Mar 2015 10:23:10 -0700 (PDT) Subject: Mesa (master): i965/skl: Avoid using the 1D stencil layout for stencil-only images Message-ID: <20150331172310.6112076336@kemper.freedesktop.org> Module: Mesa Branch: master Commit: fe026d7ce5c59535c5296004b94138bdf8ef613c URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=fe026d7ce5c59535c5296004b94138bdf8ef613c Author: Neil Roberts Date: Tue Mar 31 14:58:28 2015 +0100 i965/skl: Avoid using the 1D stencil layout for stencil-only images Commit cf67ca9ffa9 made the layouting code pick a special layout for 1D images on Skylake. This should not be used for depth and stencil buffers because these need to be treated as 2D tiled images. However the patch was missing a check for images with a base format of GL_STENCIL_INDEX. In practice I don't think it's currently possible to hit this because Mesa doesn't support GL_ARB_texture_stencil8 and it's not possible to create a 1D renderbuffer, but it'll be good to be ready for when the extension is supported. Reviewed-by: Anuj Phogat --- src/mesa/drivers/dri/i965/brw_tex_layout.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/mesa/drivers/dri/i965/brw_tex_layout.c b/src/mesa/drivers/dri/i965/brw_tex_layout.c index 5e70cd2..7a1e09d 100644 --- a/src/mesa/drivers/dri/i965/brw_tex_layout.c +++ b/src/mesa/drivers/dri/i965/brw_tex_layout.c @@ -289,7 +289,8 @@ use_linear_1d_layout(struct brw_context *brw, GLenum base_format = _mesa_get_format_base_format(mt->format); if (base_format != GL_DEPTH_COMPONENT && - base_format != GL_DEPTH_STENCIL) + base_format != GL_DEPTH_STENCIL && + base_format != GL_STENCIL_INDEX) return true; } From brianp at kemper.freedesktop.org Tue Mar 31 17:49:53 2015 From: brianp at kemper.freedesktop.org (Brian Paul) Date: Tue, 31 Mar 2015 10:49:53 -0700 (PDT) Subject: Mesa (master): docs: document Viewperf 12 issues Message-ID: <20150331174953.D033B76336@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 3db0317351e02be4498c7833262ac919d597b396 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=3db0317351e02be4498c7833262ac919d597b396 Author: Brian Paul Date: Tue Mar 31 11:30:32 2015 -0600 docs: document Viewperf 12 issues Signed-off-by: Brian Paul --- docs/viewperf.html | 94 +++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 85 insertions(+), 9 deletions(-) diff --git a/docs/viewperf.html b/docs/viewperf.html index 23c6028..6b63b94 100644 --- a/docs/viewperf.html +++ b/docs/viewperf.html @@ -19,6 +19,7 @@

        This page lists known issues with SPEC Viewperf 11 +and SPEC Viewperf 12 when running on Mesa-based drivers.

        @@ -40,13 +41,15 @@ These issues have been reported to the SPEC organization in the hope that they'll be fixed in the future.

        +

        Viewperf 11

        +

        -Some of the Viewperf tests use a lot of memory. +Some of the Viewperf 11 tests use a lot of memory. At least 2GB of RAM is recommended.

        -

        Catia-03 test 2

        +

        Catia-03 test 2

        This test creates over 38000 vertex buffer objects. On some systems @@ -59,7 +62,7 @@ either in Viewperf or the Mesa driver. -

        Catia-03 tests 3, 4, 8

        +

        Catia-03 tests 3, 4, 8

        These tests use features of the @@ -79,7 +82,7 @@ Subsequent drawing calls become no-ops and the rendering is incorrect. -

        sw-02 tests 1, 2, 4, 6

        +

        sw-02 tests 1, 2, 4, 6

        These tests depend on the @@ -99,7 +102,7 @@ color. This is probably due to some uninitialized state somewhere. -

        sw-02 test 6

        +

        sw-02 test 6

        The lines drawn in this test appear in a random color. @@ -111,7 +114,7 @@ situation, we get a random color. -

        Lightwave-01 test 3

        +

        Lightwave-01 test 3

        This test uses a number of mipmapped textures, but the textures are @@ -172,7 +175,7 @@ However, we have no plans to implement this work-around in Mesa.

        -

        Maya-03 test 2

        +

        Maya-03 test 2

        This test makes some unusual calls to glRotate. For example: @@ -204,7 +207,7 @@ and with a semi-random color (between white and black) since GL_FOG is enabled.

        -

        Proe-05 test 1

        +

        Proe-05 test 1

        This uses depth testing but there's two problems: @@ -232,7 +235,7 @@ glClear is called so clearing the depth buffer would be a no-op anyway.

        -

        Proe-05 test 6

        +

        Proe-05 test 6

        This test draws an engine model with a two-pass algorithm. @@ -261,6 +264,79 @@ blending with appropriate patterns/modes to ensure the same fragments are produced in both passes.

        +

        Viewperf 12

        + +

        +Note that Viewperf 12 only runs on 64-bit Windows 7 or later. +

        + +

        catia-04

        + +

        +One of the catia tests calls wglGetProcAddress() to get some +GL_EXT_direct_state_access functions (such as glBindMultiTextureEXT) and some +GL_NV_half_float functions (such as glMultiTexCoord3hNV). +If the extension/function is not supported, wglGetProcAddress() can return NULL. +Unfortunately, Viewperf doesn't check for null pointers and crashes when it +later tries to use the pointer. +

        + +

        +Another catia test uses OpenGL 3.1's primitive restart feature. +But when Viewperf creates an OpenGL context, it doesn't request version 3.1 +If the driver returns version 3.0 or earlier all the calls related to primitive +restart generate an OpenGL error. +Some of the rendering is then incorrect. +

        + + +

        energy-01

        + +

        +This test creates a 3D luminance texture of size 1K x 1K x 1K. +If the OpenGL driver/device doesn't support a texture of this size +the glTexImage3D() call will fail with GL_INVALID_VALUE or GL_OUT_OF_MEMORY +and all that's rendered is plain white polygons. +Ideally, the test would use a proxy texture to determine the max 3D +texture size. But it does not do that. +

        + +

        maya-04

        + +

        +This test generates many GL_INVALID_OPERATION errors in its calls to +glUniform(). +Causes include: +

          +
        • Trying to set float uniforms with glUniformi() +
        • Trying to set float uniforms with glUniform3f() +
        • Trying to set matrix uniforms with glUniform() instead of glUniformMatrix(). +
        +

        +Apparently, the indexes returned by glGetUniformLocation() were hard-coded +into the application trace when it was created. +Since different implementations of glGetUniformLocation() may return different +values for any given uniform name, subsequent calls to glUniform() will be +invalid since they refer to the wrong uniform variables. +This causes many OpenGL errors and leads to incorrect rendering. +

        + +

        medical-01

        + +

        +This test uses a single GLSL fragment shader which contains a GLSL 1.20 +array initializer statement, but it neglects to specify +#version 120 at the top of the shader code. +So, the shader does not compile and all that's rendered is plain white polygons. +

        + +

        showcase-01

        + +

        +This is actually a DX11 test based on Autodesk's Showcase product. +As such, it won't run with Mesa. +

        +
      From mslusarz at kemper.freedesktop.org Tue Mar 31 20:12:04 2015 From: mslusarz at kemper.freedesktop.org (Marcin Ślusarz) Date: Tue, 31 Mar 2015 13:12:04 -0700 (PDT) Subject: Mesa (master): nouveau: synchronize "scratch runout" destruction with the command stream Message-ID: <20150331201204.A787876336@kemper.freedesktop.org> Module: Mesa Branch: master Commit: f9e2295560f9b4869fa2a94933c1881ec7970af4 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=f9e2295560f9b4869fa2a94933c1881ec7970af4 Author: Marcin ?lusarz Date: Tue Mar 31 22:04:31 2015 +0200 nouveau: synchronize "scratch runout" destruction with the command stream When nvc0_push_vbo calls nouveau_scratch_done it does not mean scratch buffers can be freed immediately. It means "when hardware advances to this place in the command stream the scratch buffers can be freed". To fix it, just postpone scratch runout destruction after current fence is signalled. The bug existed for a very long time. Nobody noticed, because "scratch runout" code path is rarely executed. Fixes hang at the very beginning of first mission in "Serious Sam 3" on nve7/gk107. It manifested as: nouveau E[ PFIFO][0000:01:00.0] read fault at 0x000a9e0000 [PTE] from GR/GPC0/PE_2 on channel 0x007f853000 [Sam3[17056]] Cc: "10.4 10.5" Reviewed-by: Ilia Mirkin --- src/gallium/drivers/nouveau/nouveau_buffer.c | 48 ++++++++++++++++--------- src/gallium/drivers/nouveau/nouveau_context.h | 8 +++-- 2 files changed, 37 insertions(+), 19 deletions(-) diff --git a/src/gallium/drivers/nouveau/nouveau_buffer.c b/src/gallium/drivers/nouveau/nouveau_buffer.c index 49ff100..32fa65c 100644 --- a/src/gallium/drivers/nouveau/nouveau_buffer.c +++ b/src/gallium/drivers/nouveau/nouveau_buffer.c @@ -846,17 +846,28 @@ nouveau_scratch_bo_alloc(struct nouveau_context *nv, struct nouveau_bo **pbo, 4096, size, NULL, pbo); } +static void +nouveau_scratch_unref_bos(void *d) +{ + struct runout *b = d; + int i; + + for (i = 0; i < b->nr; ++i) + nouveau_bo_ref(NULL, &b->bo[i]); + + FREE(b); +} + void nouveau_scratch_runout_release(struct nouveau_context *nv) { - if (!nv->scratch.nr_runout) + if (!nv->scratch.runout) + return; + + if (!nouveau_fence_work(nv->screen->fence.current, nouveau_scratch_unref_bos, + nv->scratch.runout)) return; - do { - --nv->scratch.nr_runout; - nouveau_bo_ref(NULL, &nv->scratch.runout[nv->scratch.nr_runout]); - } while (nv->scratch.nr_runout); - FREE(nv->scratch.runout); nv->scratch.end = 0; nv->scratch.runout = NULL; } @@ -868,21 +879,26 @@ static INLINE boolean nouveau_scratch_runout(struct nouveau_context *nv, unsigned size) { int ret; - const unsigned n = nv->scratch.nr_runout++; + unsigned n; - nv->scratch.runout = REALLOC(nv->scratch.runout, - (n + 0) * sizeof(*nv->scratch.runout), - (n + 1) * sizeof(*nv->scratch.runout)); - nv->scratch.runout[n] = NULL; - - ret = nouveau_scratch_bo_alloc(nv, &nv->scratch.runout[n], size); + if (nv->scratch.runout) + n = nv->scratch.runout->nr; + else + n = 0; + nv->scratch.runout = REALLOC(nv->scratch.runout, n == 0 ? 0 : + (sizeof(*nv->scratch.runout) + (n + 0) * sizeof(void *)), + sizeof(*nv->scratch.runout) + (n + 1) * sizeof(void *)); + nv->scratch.runout->nr = n + 1; + nv->scratch.runout->bo[n] = NULL; + + ret = nouveau_scratch_bo_alloc(nv, &nv->scratch.runout->bo[n], size); if (!ret) { - ret = nouveau_bo_map(nv->scratch.runout[n], 0, NULL); + ret = nouveau_bo_map(nv->scratch.runout->bo[n], 0, NULL); if (ret) - nouveau_bo_ref(NULL, &nv->scratch.runout[--nv->scratch.nr_runout]); + nouveau_bo_ref(NULL, &nv->scratch.runout->bo[--nv->scratch.runout->nr]); } if (!ret) { - nv->scratch.current = nv->scratch.runout[n]; + nv->scratch.current = nv->scratch.runout->bo[n]; nv->scratch.offset = 0; nv->scratch.end = size; nv->scratch.map = nv->scratch.current->map; diff --git a/src/gallium/drivers/nouveau/nouveau_context.h b/src/gallium/drivers/nouveau/nouveau_context.h index 14608d3..c2ba015 100644 --- a/src/gallium/drivers/nouveau/nouveau_context.h +++ b/src/gallium/drivers/nouveau/nouveau_context.h @@ -40,8 +40,10 @@ struct nouveau_context { unsigned end; struct nouveau_bo *bo[NOUVEAU_MAX_SCRATCH_BUFS]; struct nouveau_bo *current; - struct nouveau_bo **runout; - unsigned nr_runout; + struct runout { + unsigned nr; + struct nouveau_bo *bo[0]; + } *runout; unsigned bo_size; } scratch; @@ -71,7 +73,7 @@ static INLINE void nouveau_scratch_done(struct nouveau_context *nv) { nv->scratch.wrap = nv->scratch.id; - if (unlikely(nv->scratch.nr_runout)) + if (unlikely(nv->scratch.runout)) nouveau_scratch_runout_release(nv); } From mattst88 at kemper.freedesktop.org Tue Mar 31 21:48:14 2015 From: mattst88 at kemper.freedesktop.org (Matt Turner) Date: Tue, 31 Mar 2015 14:48:14 -0700 (PDT) Subject: Mesa (master): glsl: Implement type inferencing of matrix types. Message-ID: <20150331214814.72B157635A@kemper.freedesktop.org> Module: Mesa Branch: master Commit: cf2dc1624fe711ad0aa89322a1142eae46bbfc30 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=cf2dc1624fe711ad0aa89322a1142eae46bbfc30 Author: Matt Turner Date: Fri Mar 27 10:45:07 2015 -0700 glsl: Implement type inferencing of matrix types. Reviewed-by: Chris Forbes --- src/glsl/ir.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/glsl/ir.cpp b/src/glsl/ir.cpp index 54656f8..4b8ca9b 100644 --- a/src/glsl/ir.cpp +++ b/src/glsl/ir.cpp @@ -380,10 +380,12 @@ ir_expression::ir_expression(int op, ir_rvalue *op0, ir_rvalue *op1) } else if (op1->type->is_scalar()) { this->type = op0->type; } else { - /* FINISHME: matrix types */ - assert(!op0->type->is_matrix() && !op1->type->is_matrix()); - assert(op0->type == op1->type); - this->type = op0->type; + if (this->operation == ir_binop_mul) { + this->type = glsl_type::get_mul_type(op0->type, op1->type); + } else { + assert(op0->type == op1->type); + this->type = op0->type; + } } break; From mattst88 at kemper.freedesktop.org Tue Mar 31 21:48:14 2015 From: mattst88 at kemper.freedesktop.org (Matt Turner) Date: Tue, 31 Mar 2015 14:48:14 -0700 (PDT) Subject: Mesa (master): glsl: Remove bogus Makefile dependency. Message-ID: <20150331214814.899C67635C@kemper.freedesktop.org> Module: Mesa Branch: master Commit: ac6102bcc5dc85bf5bd1e25e0d94a91441673681 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=ac6102bcc5dc85bf5bd1e25e0d94a91441673681 Author: Matt Turner Date: Tue Mar 31 14:06:56 2015 -0700 glsl: Remove bogus Makefile dependency. --- src/glsl/Makefile.am | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/glsl/Makefile.am b/src/glsl/Makefile.am index ed90366..6cef973 100644 --- a/src/glsl/Makefile.am +++ b/src/glsl/Makefile.am @@ -252,8 +252,6 @@ nir/nir_opcodes.h: nir/nir_opcodes.py nir/nir_opcodes_h.py $(MKDIR_P) nir; \ $(PYTHON2) $(PYTHON_FLAGS) $(srcdir)/nir/nir_opcodes_h.py > $@ -nir/nir.h: nir/nir_opcodes.h - nir/nir_opcodes.c: nir/nir_opcodes.py nir/nir_opcodes_c.py $(MKDIR_P) nir; \ $(PYTHON2) $(PYTHON_FLAGS) $(srcdir)/nir/nir_opcodes_c.py > $@ From mattst88 at kemper.freedesktop.org Tue Mar 31 21:48:14 2015 From: mattst88 at kemper.freedesktop.org (Matt Turner) Date: Tue, 31 Mar 2015 14:48:14 -0700 (PDT) Subject: Mesa (master): glsl: Reassociate multiplication of mat*mat*vec. Message-ID: <20150331214814.7EE497635B@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 2c38f891ad82881cd3cc6e4323bfca7bdb13d13a URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=2c38f891ad82881cd3cc6e4323bfca7bdb13d13a Author: Matt Turner Date: Fri Mar 27 17:13:51 2015 -0700 glsl: Reassociate multiplication of mat*mat*vec. The typical case of mat4*mat4*vec4 is 80 scalar multiplications, but mat4*(mat4*vec4) is only 32. On HSW (with vec4 vertex shaders): instructions in affected programs: 4420 -> 3194 (-27.74%) On BDW (with scalar vertex shaders): instructions in affected programs: 12756 -> 6726 (-47.27%) Implementing a general matrix chain ordering is harder (or at least tedious) because of having to walk the GLSL IR to create a list of multiplicands. I'm guessing that this patch handles 90+% of cases, but of course to tell definitively you'd have to implement the general thing. Reviewed-by: Chris Forbes --- src/glsl/opt_algebraic.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/glsl/opt_algebraic.cpp b/src/glsl/opt_algebraic.cpp index 98c852a..a940d2f 100644 --- a/src/glsl/opt_algebraic.cpp +++ b/src/glsl/opt_algebraic.cpp @@ -290,6 +290,20 @@ ir_algebraic_visitor::handle_expression(ir_expression *ir) ir_expression *op_expr[4] = {NULL, NULL, NULL, NULL}; unsigned int i; + if (ir->operation == ir_binop_mul && + ir->operands[0]->type->is_matrix() && + ir->operands[1]->type->is_vector()) { + ir_expression *matrix_mul = ir->operands[0]->as_expression(); + + if (matrix_mul && matrix_mul->operation == ir_binop_mul && + matrix_mul->operands[0]->type->is_matrix() && + matrix_mul->operands[1]->type->is_matrix()) { + + return mul(matrix_mul->operands[0], + mul(matrix_mul->operands[1], ir->operands[1])); + } + } + assert(ir->get_num_operands() <= 4); for (i = 0; i < ir->get_num_operands(); i++) { if (ir->operands[i]->type->is_matrix()) From mattst88 at kemper.freedesktop.org Tue Mar 31 21:48:14 2015 From: mattst88 at kemper.freedesktop.org (Matt Turner) Date: Tue, 31 Mar 2015 14:48:14 -0700 (PDT) Subject: Mesa (master): glsl: Factor out a get_mul_type() function. Message-ID: <20150331214814.6A22F76336@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 73f6f9b9be1aedf85cfe15b87e3c543e5cc399d2 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=73f6f9b9be1aedf85cfe15b87e3c543e5cc399d2 Author: Matt Turner Date: Fri Mar 27 10:43:05 2015 -0700 glsl: Factor out a get_mul_type() function. Reviewed-by: Chris Forbes --- src/glsl/ast_to_hir.cpp | 62 ++++--------------------------------------- src/glsl/glsl_types.cpp | 67 +++++++++++++++++++++++++++++++++++++++++++++++ src/glsl/glsl_types.h | 6 +++++ 3 files changed, 78 insertions(+), 57 deletions(-) diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp index 036ec17..7836936 100644 --- a/src/glsl/ast_to_hir.cpp +++ b/src/glsl/ast_to_hir.cpp @@ -375,66 +375,14 @@ arithmetic_result_type(ir_rvalue * &value_a, ir_rvalue * &value_b, if (type_a == type_b) return type_a; } else { - if (type_a->is_matrix() && type_b->is_matrix()) { - /* Matrix multiply. The columns of A must match the rows of B. Given - * the other previously tested constraints, this means the vector type - * of a row from A must be the same as the vector type of a column from - * B. - */ - if (type_a->row_type() == type_b->column_type()) { - /* The resulting matrix has the number of columns of matrix B and - * the number of rows of matrix A. We get the row count of A by - * looking at the size of a vector that makes up a column. The - * transpose (size of a row) is done for B. - */ - const glsl_type *const type = - glsl_type::get_instance(type_a->base_type, - type_a->column_type()->vector_elements, - type_b->row_type()->vector_elements); - assert(type != glsl_type::error_type); + const glsl_type *type = glsl_type::get_mul_type(type_a, type_b); - return type; - } - } else if (type_a->is_matrix()) { - /* A is a matrix and B is a column vector. Columns of A must match - * rows of B. Given the other previously tested constraints, this - * means the vector type of a row from A must be the same as the - * vector the type of B. - */ - if (type_a->row_type() == type_b) { - /* The resulting vector has a number of elements equal to - * the number of rows of matrix A. */ - const glsl_type *const type = - glsl_type::get_instance(type_a->base_type, - type_a->column_type()->vector_elements, - 1); - assert(type != glsl_type::error_type); - - return type; - } - } else { - assert(type_b->is_matrix()); - - /* A is a row vector and B is a matrix. Columns of A must match rows - * of B. Given the other previously tested constraints, this means - * the type of A must be the same as the vector type of a column from - * B. - */ - if (type_a == type_b->column_type()) { - /* The resulting vector has a number of elements equal to - * the number of columns of matrix B. */ - const glsl_type *const type = - glsl_type::get_instance(type_a->base_type, - type_b->row_type()->vector_elements, - 1); - assert(type != glsl_type::error_type); - - return type; - } + if (type == glsl_type::error_type) { + _mesa_glsl_error(loc, state, + "size mismatch for matrix multiplication"); } - _mesa_glsl_error(loc, state, "size mismatch for matrix multiplication"); - return glsl_type::error_type; + return type; } diff --git a/src/glsl/glsl_types.cpp b/src/glsl/glsl_types.cpp index be87b0a..4aa36a7 100644 --- a/src/glsl/glsl_types.cpp +++ b/src/glsl/glsl_types.cpp @@ -825,6 +825,73 @@ glsl_type::get_interface_instance(const glsl_struct_field *fields, const glsl_type * +glsl_type::get_mul_type(const glsl_type *type_a, const glsl_type *type_b) +{ + if (type_a == type_b) { + return type_a; + } else if (type_a->is_matrix() && type_b->is_matrix()) { + /* Matrix multiply. The columns of A must match the rows of B. Given + * the other previously tested constraints, this means the vector type + * of a row from A must be the same as the vector type of a column from + * B. + */ + if (type_a->row_type() == type_b->column_type()) { + /* The resulting matrix has the number of columns of matrix B and + * the number of rows of matrix A. We get the row count of A by + * looking at the size of a vector that makes up a column. The + * transpose (size of a row) is done for B. + */ + const glsl_type *const type = + get_instance(type_a->base_type, + type_a->column_type()->vector_elements, + type_b->row_type()->vector_elements); + assert(type != error_type); + + return type; + } + } else if (type_a->is_matrix()) { + /* A is a matrix and B is a column vector. Columns of A must match + * rows of B. Given the other previously tested constraints, this + * means the vector type of a row from A must be the same as the + * vector the type of B. + */ + if (type_a->row_type() == type_b) { + /* The resulting vector has a number of elements equal to + * the number of rows of matrix A. */ + const glsl_type *const type = + get_instance(type_a->base_type, + type_a->column_type()->vector_elements, + 1); + assert(type != error_type); + + return type; + } + } else { + assert(type_b->is_matrix()); + + /* A is a row vector and B is a matrix. Columns of A must match rows + * of B. Given the other previously tested constraints, this means + * the type of A must be the same as the vector type of a column from + * B. + */ + if (type_a == type_b->column_type()) { + /* The resulting vector has a number of elements equal to + * the number of columns of matrix B. */ + const glsl_type *const type = + get_instance(type_a->base_type, + type_b->row_type()->vector_elements, + 1); + assert(type != error_type); + + return type; + } + } + + return error_type; +} + + +const glsl_type * glsl_type::field_type(const char *name) const { if (this->base_type != GLSL_TYPE_STRUCT diff --git a/src/glsl/glsl_types.h b/src/glsl/glsl_types.h index 7359e94..d383dd5 100644 --- a/src/glsl/glsl_types.h +++ b/src/glsl/glsl_types.h @@ -276,6 +276,12 @@ struct glsl_type { const char *block_name); /** + * Get the type resulting from a multiplication of \p type_a * \p type_b + */ + static const glsl_type *get_mul_type(const glsl_type *type_a, + const glsl_type *type_b); + + /** * Query the total number of scalars that make up a scalar, vector or matrix */ unsigned components() const From mattst88 at kemper.freedesktop.org Tue Mar 31 21:48:14 2015 From: mattst88 at kemper.freedesktop.org (Matt Turner) Date: Tue, 31 Mar 2015 14:48:14 -0700 (PDT) Subject: Mesa (master): i965: Mark brw_inst_bits' brw_inst* parameter const. Message-ID: <20150331214814.94E1776336@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 438c1c0080a00b073706a8708c5fd79dc42a7a15 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=438c1c0080a00b073706a8708c5fd79dc42a7a15 Author: Matt Turner Date: Sat Mar 28 11:01:29 2015 -0700 i965: Mark brw_inst_bits' brw_inst* parameter const. Reviewed-by: Kenneth Graunke --- src/mesa/drivers/dri/i965/brw_inst.h | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_inst.h b/src/mesa/drivers/dri/i965/brw_inst.h index 372aa2b..d067b72 100644 --- a/src/mesa/drivers/dri/i965/brw_inst.h +++ b/src/mesa/drivers/dri/i965/brw_inst.h @@ -44,7 +44,7 @@ typedef struct brw_inst { uint64_t data[2]; } brw_inst; -static inline uint64_t brw_inst_bits(brw_inst *inst, +static inline uint64_t brw_inst_bits(const brw_inst *inst, unsigned high, unsigned low); static inline void brw_inst_set_bits(brw_inst *inst, unsigned high, unsigned low, @@ -61,7 +61,7 @@ brw_inst_set_##name(const struct brw_context *brw, \ } \ static inline uint64_t \ brw_inst_##name(const struct brw_context *brw, \ - brw_inst *inst) \ + const brw_inst *inst) \ { \ assert(assertions); \ (void) brw; \ @@ -101,7 +101,7 @@ brw_inst_set_##name(const struct brw_context *brw, \ brw_inst_set_bits(inst, high, low, value); \ } \ static inline uint64_t \ -brw_inst_##name(const struct brw_context *brw, brw_inst *inst) \ +brw_inst_##name(const struct brw_context *brw, const brw_inst *inst) \ { \ BOUNDS(hi4, lo4, hi45, lo45, hi5, lo5, hi6, lo6, hi7, lo7, hi8, lo8) \ return brw_inst_bits(inst, high, low); \ @@ -262,7 +262,7 @@ brw_inst_set_uip(const struct brw_context *brw, } static inline int32_t -brw_inst_uip(const struct brw_context *brw, brw_inst *inst) +brw_inst_uip(const struct brw_context *brw, const brw_inst *inst) { assert(brw->gen >= 6); @@ -289,7 +289,7 @@ brw_inst_set_jip(const struct brw_context *brw, } static inline int32_t -brw_inst_jip(const struct brw_context *brw, brw_inst *inst) +brw_inst_jip(const struct brw_context *brw, const brw_inst *inst) { assert(brw->gen >= 6); @@ -310,7 +310,7 @@ brw_inst_set_##name(const struct brw_context *brw, brw_inst *inst, int16_t v) \ brw_inst_set_bits(inst, high, low, (uint16_t) v); \ } \ static inline int16_t \ -brw_inst_##name(const struct brw_context *brw, brw_inst *inst) \ +brw_inst_##name(const struct brw_context *brw, const brw_inst *inst) \ { \ assert(assertions); \ (void) brw; \ @@ -544,21 +544,21 @@ F(pi_message_data, MD(7), MD(0)) * @{ */ static inline int -brw_inst_imm_d(const struct brw_context *brw, brw_inst *insn) +brw_inst_imm_d(const struct brw_context *brw, const brw_inst *insn) { (void) brw; return brw_inst_bits(insn, 127, 96); } static inline unsigned -brw_inst_imm_ud(const struct brw_context *brw, brw_inst *insn) +brw_inst_imm_ud(const struct brw_context *brw, const brw_inst *insn) { (void) brw; return brw_inst_bits(insn, 127, 96); } static inline float -brw_inst_imm_f(const struct brw_context *brw, brw_inst *insn) +brw_inst_imm_f(const struct brw_context *brw, const brw_inst *insn) { fi_type ft; (void) brw; @@ -611,7 +611,7 @@ brw_inst_set_##reg##_ia1_addr_imm(const struct brw_context *brw, \ } \ static inline unsigned \ brw_inst_##reg##_ia1_addr_imm(const struct brw_context *brw, \ - brw_inst *inst) \ + const brw_inst *inst) \ { \ if (brw->gen >= 8) { \ return brw_inst_bits(inst, g8_high, g8_low) | \ @@ -642,7 +642,7 @@ brw_inst_set_##reg##_ia16_addr_imm(const struct brw_context *brw, \ } \ static inline unsigned \ brw_inst_##reg##_ia16_addr_imm(const struct brw_context *brw, \ - brw_inst *inst) \ + const brw_inst *inst) \ { \ if (brw->gen >= 8) { \ return brw_inst_bits(inst, g8_high, g8_low) | \ @@ -666,7 +666,7 @@ BRW_IA16_ADDR_IMM(dst, 57, 52, 47, 56, 52) * Bits indices range from 0..127; fields may not cross 64-bit boundaries. */ static inline uint64_t -brw_inst_bits(brw_inst *inst, unsigned high, unsigned low) +brw_inst_bits(const brw_inst *inst, unsigned high, unsigned low) { /* We assume the field doesn't cross 64-bit boundaries. */ const unsigned word = high / 64; From mattst88 at kemper.freedesktop.org Tue Mar 31 21:48:14 2015 From: mattst88 at kemper.freedesktop.org (Matt Turner) Date: Tue, 31 Mar 2015 14:48:14 -0700 (PDT) Subject: Mesa (master): i965/fs: Allow CSE to handle MULs with negated arguments. Message-ID: <20150331214814.9EBD676336@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 47c4b3854076adfe5a27b537f36262ac4ec4530d URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=47c4b3854076adfe5a27b537f36262ac4ec4530d Author: Matt Turner Date: Tue Jan 27 19:18:46 2015 -0800 i965/fs: Allow CSE to handle MULs with negated arguments. mul x, -y is equivalent to mul -x, y; and mul x, y is the negation of mul x, -y. With NIR: total instructions in shared programs: 6167779 -> 6161193 (-0.11%) instructions in affected programs: 983511 -> 976925 (-0.67%) helped: 4106 HURT: 16 GAINED: 18 LOST: 7 Without NIR: total instructions in shared programs: 6192323 -> 6185299 (-0.11%) instructions in affected programs: 987875 -> 980851 (-0.71%) helped: 4146 HURT: 16 GAINED: 16 LOST: 0 --- src/mesa/drivers/dri/i965/brw_fs_cse.cpp | 42 ++++++++++++++++++++++++++---- 1 file changed, 37 insertions(+), 5 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_fs_cse.cpp b/src/mesa/drivers/dri/i965/brw_fs_cse.cpp index ca5b32f..f2c4098 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_cse.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_cse.cpp @@ -109,7 +109,7 @@ is_expression(const fs_inst *const inst) } static bool -operands_match(const fs_inst *a, const fs_inst *b) +operands_match(const fs_inst *a, const fs_inst *b, bool *negate) { fs_reg *xs = a->src; fs_reg *ys = b->src; @@ -118,6 +118,35 @@ operands_match(const fs_inst *a, const fs_inst *b) return xs[0].equals(ys[0]) && ((xs[1].equals(ys[1]) && xs[2].equals(ys[2])) || (xs[2].equals(ys[1]) && xs[1].equals(ys[2]))); + } else if (a->opcode == BRW_OPCODE_MUL && a->dst.type == BRW_REGISTER_TYPE_F) { + bool xs0_negate = xs[0].negate; + bool xs1_negate = xs[1].file == IMM ? xs[1].fixed_hw_reg.dw1.f < 0.0f + : xs[1].negate; + bool ys0_negate = ys[0].negate; + bool ys1_negate = ys[1].file == IMM ? ys[1].fixed_hw_reg.dw1.f < 0.0f + : ys[1].negate; + float xs1_imm = xs[1].fixed_hw_reg.dw1.f; + float ys1_imm = ys[1].fixed_hw_reg.dw1.f; + + xs[0].negate = false; + xs[1].negate = false; + ys[0].negate = false; + ys[1].negate = false; + xs[1].fixed_hw_reg.dw1.f = fabsf(xs[1].fixed_hw_reg.dw1.f); + ys[1].fixed_hw_reg.dw1.f = fabsf(ys[1].fixed_hw_reg.dw1.f); + + bool ret = (xs[0].equals(ys[0]) && xs[1].equals(ys[1])) || + (xs[1].equals(ys[0]) && xs[0].equals(ys[1])); + + xs[0].negate = xs0_negate; + xs[1].negate = xs[1].file == IMM ? false : xs1_negate; + ys[0].negate = ys0_negate; + ys[1].negate = ys[1].file == IMM ? false : ys1_negate; + xs[1].fixed_hw_reg.dw1.f = xs1_imm; + ys[1].fixed_hw_reg.dw1.f = ys1_imm; + + *negate = (xs0_negate + xs1_negate) != (ys0_negate + ys1_negate); + return ret; } else if (!a->is_commutative()) { bool match = true; for (int i = 0; i < a->sources; i++) { @@ -134,7 +163,7 @@ operands_match(const fs_inst *a, const fs_inst *b) } static bool -instructions_match(fs_inst *a, fs_inst *b) +instructions_match(fs_inst *a, fs_inst *b, bool *negate) { return a->opcode == b->opcode && a->saturate == b->saturate && @@ -151,7 +180,7 @@ instructions_match(fs_inst *a, fs_inst *b) a->header_present == b->header_present && a->shadow_compare == b->shadow_compare) : true) && - operands_match(a, b); + operands_match(a, b, negate); } bool @@ -169,11 +198,12 @@ fs_visitor::opt_cse_local(bblock_t *block) (inst->dst.file != HW_REG || inst->dst.is_null())) { bool found = false; + bool negate = false; foreach_in_list_use_after(aeb_entry, entry, &aeb) { /* Match current instruction's expression against those in AEB. */ if (!(entry->generator->dst.is_null() && !inst->dst.is_null()) && - instructions_match(inst, entry->generator)) { + instructions_match(inst, entry->generator, &negate)) { found = true; progress = true; break; @@ -239,6 +269,7 @@ fs_visitor::opt_cse_local(bblock_t *block) } else { copy = MOV(dst, tmp); copy->force_writemask_all = inst->force_writemask_all; + copy->src[0].negate = negate; } inst->insert_before(block, copy); } @@ -259,9 +290,10 @@ fs_visitor::opt_cse_local(bblock_t *block) * the flag register if we just wrote it. */ if (inst->writes_flag()) { + bool negate; /* dummy */ if (entry->generator->reads_flag() || (entry->generator->writes_flag() && - !instructions_match(inst, entry->generator))) { + !instructions_match(inst, entry->generator, &negate))) { entry->remove(); ralloc_free(entry); continue; From sroland at kemper.freedesktop.org Tue Mar 31 22:57:57 2015 From: sroland at kemper.freedesktop.org (Roland Scheidegger) Date: Tue, 31 Mar 2015 15:57:57 -0700 (PDT) Subject: Mesa (master): gallivm: do some hack heuristic to disable texture functions Message-ID: <20150331225757.A552D76336@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 611bd80f3b4972622a9f2c155c95d3241668e4d9 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=611bd80f3b4972622a9f2c155c95d3241668e4d9 Author: Roland Scheidegger Date: Wed Apr 1 00:56:12 2015 +0200 gallivm: do some hack heuristic to disable texture functions We've seen some cases where performance can hurt quite a bit. Technically, the more simple the function the more overhead there is for using a function for this (and the less benefits this provides). Hence don't do this if we expect the generated code to be simple. There's an even more important reason why this hurts performance, which is shaders reusing the same unit with some of the same inputs, as llvm cannot figure out the calculations are the same if they are performned in the function (even just reusing the same unit without any input being the same provides such optimization opportunities though not very much). This is something which would need to be handled by IPO passes however. --- src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c | 40 +++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c index ff508e2..378c562 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c @@ -3297,7 +3297,47 @@ lp_build_sample_soa(const struct lp_static_texture_state *static_texture_state, struct gallivm_state *gallivm, const struct lp_sampler_params *params) { + boolean use_tex_func = FALSE; + + /* + * Do not use a function call if the sampling is "simple enough". + * We define this by + * a) format + * b) no mips (either one level only or no mip filter) + * No mips will definitely make the code smaller, though + * the format requirement is a bit iffy - there's some (SoA) formats + * which definitely generate less code. This does happen to catch + * some important cases though which are hurt quite a bit by using + * a call (though not really because of the call overhead but because + * they are reusing the same texture unit with some of the same + * parameters). + * Ideally we'd let llvm recognize this stuff by doing IPO passes. + */ + if (USE_TEX_FUNC_CALL) { + const struct util_format_description *format_desc; + boolean simple_format; + boolean simple_tex; + enum lp_sampler_op_type op_type; + format_desc = util_format_description(static_texture_state->format); + simple_format = !format_desc || + (util_format_is_rgba8_variant(format_desc) && + format_desc->colorspace == UTIL_FORMAT_COLORSPACE_RGB); + + op_type = (params->sample_key & LP_SAMPLER_OP_TYPE_MASK) >> + LP_SAMPLER_OP_TYPE_SHIFT; + simple_tex = + op_type != LP_SAMPLER_OP_TEXTURE || + ((static_sampler_state->min_mip_filter == PIPE_TEX_MIPFILTER_NONE || + static_texture_state->level_zero_only == TRUE) && + static_sampler_state->min_img_filter == static_sampler_state->mag_img_filter && + (static_sampler_state->min_img_filter == PIPE_TEX_FILTER_NEAREST || + static_sampler_state->min_img_filter == PIPE_TEX_FILTER_NEAREST)); + + use_tex_func = format_desc && !(simple_format && simple_tex); + } + + if (use_tex_func) { lp_build_sample_soa_func(gallivm, static_texture_state, static_sampler_state, From jljusten at kemper.freedesktop.org Tue Mar 31 23:44:35 2015 From: jljusten at kemper.freedesktop.org (Jordan Justen) Date: Tue, 31 Mar 2015 16:44:35 -0700 (PDT) Subject: Mesa (master): i965/state: Rename brw_upload_state to brw_upload_render_state Message-ID: <20150331234435.2FE3E76336@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 2c02baa4870cf08592ac64a576fd6a73262892fb URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=2c02baa4870cf08592ac64a576fd6a73262892fb Author: Jordan Justen Date: Sat Mar 7 20:20:03 2015 -0800 i965/state: Rename brw_upload_state to brw_upload_render_state Signed-off-by: Jordan Justen Reviewed-by: Kristian H?gsberg Reviewed-by: Kenneth Graunke --- src/mesa/drivers/dri/i965/brw_draw.c | 7 ++++--- src/mesa/drivers/dri/i965/brw_state.h | 2 +- src/mesa/drivers/dri/i965/brw_state_upload.c | 12 ++++++------ 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_draw.c b/src/mesa/drivers/dri/i965/brw_draw.c index 2d3de45..9b4d8e0 100644 --- a/src/mesa/drivers/dri/i965/brw_draw.c +++ b/src/mesa/drivers/dri/i965/brw_draw.c @@ -430,8 +430,9 @@ static void brw_try_draw_prims( struct gl_context *ctx, intel_prepare_render(brw); - /* This workaround has to happen outside of brw_upload_state() because it - * may flush the batchbuffer for a blit, affecting the state flags. + /* This workaround has to happen outside of brw_upload_render_state() + * because it may flush the batchbuffer for a blit, affecting the state + * flags. */ brw_workaround_depthstencil_alignment(brw, 0); @@ -508,7 +509,7 @@ retry: */ if (brw->state.dirty.brw) { brw->no_batch_wrap = true; - brw_upload_state(brw); + brw_upload_render_state(brw); } brw_emit_prim(brw, &prims[i], brw->primitive); diff --git a/src/mesa/drivers/dri/i965/brw_state.h b/src/mesa/drivers/dri/i965/brw_state.h index 71210b9..ae5ef1f 100644 --- a/src/mesa/drivers/dri/i965/brw_state.h +++ b/src/mesa/drivers/dri/i965/brw_state.h @@ -168,7 +168,7 @@ brw_depthbuffer_format(struct brw_context *brw); /*********************************************************************** * brw_state.c */ -void brw_upload_state(struct brw_context *brw); +void brw_upload_render_state(struct brw_context *brw); void brw_clear_dirty_bits(struct brw_context *brw); void brw_init_state(struct brw_context *brw); void brw_destroy_state(struct brw_context *brw); diff --git a/src/mesa/drivers/dri/i965/brw_state_upload.c b/src/mesa/drivers/dri/i965/brw_state_upload.c index e446de6..542600f 100644 --- a/src/mesa/drivers/dri/i965/brw_state_upload.c +++ b/src/mesa/drivers/dri/i965/brw_state_upload.c @@ -579,7 +579,7 @@ brw_upload_programs(struct brw_context *brw) /*********************************************************************** * Emit all state: */ -void brw_upload_state(struct brw_context *brw) +void brw_upload_render_state(struct brw_context *brw) { struct gl_context *ctx = &brw->ctx; struct brw_state_flags *state = &brw->state.dirty; @@ -686,11 +686,11 @@ void brw_upload_state(struct brw_context *brw) /** * Clear dirty bits to account for the fact that the state emitted by - * brw_upload_state() has been committed to the hardware. This is a separate - * call from brw_upload_state() because it's possible that after the call to - * brw_upload_state(), we will discover that we've run out of aperture space, - * and need to rewind the batch buffer to the state it had before the - * brw_upload_state() call. + * brw_upload_render_state() has been committed to the hardware. This is a + * separate call from brw_upload_render_state() because it's possible that + * after the call to brw_upload_render_state(), we will discover that we've + * run out of aperture space, and need to rewind the batch buffer to the state + * it had before the brw_upload_render_state() call. */ void brw_clear_dirty_bits(struct brw_context *brw) From jljusten at kemper.freedesktop.org Tue Mar 31 23:44:35 2015 From: jljusten at kemper.freedesktop.org (Jordan Justen) Date: Tue, 31 Mar 2015 16:44:35 -0700 (PDT) Subject: Mesa (master): i965/state: Create separate dirty state bits for each pipeline Message-ID: <20150331234435.505D476336@kemper.freedesktop.org> Module: Mesa Branch: master Commit: d70f4e6daf4a548eb6debaa2a1646fea21e5fbf3 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=d70f4e6daf4a548eb6debaa2a1646fea21e5fbf3 Author: Jordan Justen Date: Sat Mar 7 23:21:46 2015 -0800 i965/state: Create separate dirty state bits for each pipeline When clearing the state for a pipeline, we will save changed state for the other pipelines. v3: * Adjust brw_upload_pipeline_state * Don't pull pipeline state bits into common state bits * Don't clear pipeline state bits * Adjust 'clear' phase * brw_clear_dirty_bits is now brw_render_state_finished * Move cross-pipeline state flagging to brw_pipeline_state_finished * Move pipeline clears to brw_pipeline_state_finished Signed-off-by: Jordan Justen Reviewed-by: Kristian H?gsberg Reviewed-by: Kenneth Graunke --- src/mesa/drivers/dri/i965/brw_context.h | 1 + src/mesa/drivers/dri/i965/brw_state_upload.c | 101 +++++++++++++++++++------- 2 files changed, 75 insertions(+), 27 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h index e1481d5..52b27a9 100644 --- a/src/mesa/drivers/dri/i965/brw_context.h +++ b/src/mesa/drivers/dri/i965/brw_context.h @@ -1117,6 +1117,7 @@ struct brw_context GLuint NewGLState; struct { struct brw_state_flags dirty; + struct brw_state_flags pipelines[BRW_NUM_PIPELINES]; } state; struct brw_cache cache; diff --git a/src/mesa/drivers/dri/i965/brw_state_upload.c b/src/mesa/drivers/dri/i965/brw_state_upload.c index b15d8c5..8bd88f1 100644 --- a/src/mesa/drivers/dri/i965/brw_state_upload.c +++ b/src/mesa/drivers/dri/i965/brw_state_upload.c @@ -596,26 +596,45 @@ brw_upload_programs(struct brw_context *brw) brw_upload_wm_prog(brw); } -/*********************************************************************** - * Emit all state: - */ -void brw_upload_render_state(struct brw_context *brw) +static inline void +merge_ctx_state(struct brw_context *brw, + struct brw_state_flags *state) +{ + state->mesa |= brw->state.dirty.mesa; + state->brw |= brw->state.dirty.brw; +} + +static inline void +check_and_emit_atom(struct brw_context *brw, + struct brw_state_flags *state, + const struct brw_tracked_state *atom) +{ + if (check_state(state, &atom->dirty)) { + atom->emit(brw); + merge_ctx_state(brw, state); + } +} + +static inline void +brw_upload_pipeline_state(struct brw_context *brw, + enum brw_pipeline pipeline) { struct gl_context *ctx = &brw->ctx; - struct brw_state_flags *state = &brw->state.dirty; + struct brw_state_flags *brw_state = &brw->state.dirty; int i; static int dirty_count = 0; + struct brw_state_flags state = brw->state.pipelines[pipeline]; - state->mesa |= brw->NewGLState; + brw_state->mesa |= brw->NewGLState; brw->NewGLState = 0; - state->brw |= ctx->NewDriverState; + brw_state->brw |= ctx->NewDriverState; ctx->NewDriverState = 0; if (0) { /* Always re-emit all state. */ - state->mesa |= ~0; - state->brw |= ~0ull; + brw_state->mesa |= ~0; + brw_state->brw |= ~0ull; } if (brw->fragment_program != ctx->FragmentProgram._Current) { @@ -643,7 +662,9 @@ void brw_upload_render_state(struct brw_context *brw) brw->state.dirty.brw |= BRW_NEW_NUM_SAMPLES; } - if ((state->mesa | state->brw) == 0) + /* Exit early if no state is flagged as dirty */ + merge_ctx_state(brw, &state); + if ((state.mesa | state.brw) == 0) return; /* Emit Sandybridge workaround flushes on every primitive, for safety. */ @@ -651,6 +672,11 @@ void brw_upload_render_state(struct brw_context *brw) intel_emit_post_sync_nonzero_flush(brw); brw_upload_programs(brw); + merge_ctx_state(brw, &state); + + const struct brw_tracked_state *atoms = + brw_get_pipeline_atoms(brw, pipeline); + const int num_atoms = brw->num_atoms[pipeline]; if (unlikely(INTEL_DEBUG)) { /* Debug version which enforces various sanity checks on the @@ -659,15 +685,13 @@ void brw_upload_render_state(struct brw_context *brw) */ struct brw_state_flags examined, prev; memset(&examined, 0, sizeof(examined)); - prev = *state; + prev = state; - for (i = 0; i < brw->num_atoms[BRW_RENDER_PIPELINE]; i++) { - const struct brw_tracked_state *atom = &brw->render_atoms[i]; + for (i = 0; i < num_atoms; i++) { + const struct brw_tracked_state *atom = &atoms[i]; struct brw_state_flags generated; - if (check_state(state, &atom->dirty)) { - atom->emit(brw); - } + check_and_emit_atom(brw, &state, atom); accumulate_state(&examined, &atom->dirty); @@ -675,26 +699,24 @@ void brw_upload_render_state(struct brw_context *brw) * if (examined & generated) * fail; */ - xor_states(&generated, &prev, state); + xor_states(&generated, &prev, &state); assert(!check_state(&examined, &generated)); - prev = *state; + prev = state; } } else { - for (i = 0; i < brw->num_atoms[BRW_RENDER_PIPELINE]; i++) { - const struct brw_tracked_state *atom = &brw->render_atoms[i]; + for (i = 0; i < num_atoms; i++) { + const struct brw_tracked_state *atom = &atoms[i]; - if (check_state(state, &atom->dirty)) { - atom->emit(brw); - } + check_and_emit_atom(brw, &state, atom); } } if (unlikely(INTEL_DEBUG & DEBUG_STATE)) { STATIC_ASSERT(ARRAY_SIZE(brw_bits) == BRW_NUM_STATE_BITS + 1); - brw_update_dirty_count(mesa_bits, state->mesa); - brw_update_dirty_count(brw_bits, state->brw); + brw_update_dirty_count(mesa_bits, state.mesa); + brw_update_dirty_count(brw_bits, state.brw); if (dirty_count++ % 1000 == 0) { brw_print_dirty_count(mesa_bits); brw_print_dirty_count(brw_bits); @@ -703,6 +725,32 @@ void brw_upload_render_state(struct brw_context *brw) } } +/*********************************************************************** + * Emit all state: + */ +void brw_upload_render_state(struct brw_context *brw) +{ + brw_upload_pipeline_state(brw, BRW_RENDER_PIPELINE); +} + +static inline void +brw_pipeline_state_finished(struct brw_context *brw, + enum brw_pipeline pipeline) +{ + struct brw_state_flags *state = &brw->state.dirty; + + /* Save all dirty state into the other pipelines */ + for (int i = 0; i < BRW_NUM_PIPELINES; i++) { + if (i != pipeline) { + brw->state.pipelines[i].mesa |= state->mesa; + brw->state.pipelines[i].brw |= state->brw; + } else { + memset(&brw->state.pipelines[i], 0, sizeof(struct brw_state_flags)); + } + } + + memset(state, 0, sizeof(*state)); +} /** * Clear dirty bits to account for the fact that the state emitted by @@ -715,6 +763,5 @@ void brw_upload_render_state(struct brw_context *brw) void brw_render_state_finished(struct brw_context *brw) { - struct brw_state_flags *state = &brw->state.dirty; - memset(state, 0, sizeof(*state)); + brw_pipeline_state_finished(brw, BRW_RENDER_PIPELINE); } From jljusten at kemper.freedesktop.org Tue Mar 31 23:44:35 2015 From: jljusten at kemper.freedesktop.org (Jordan Justen) Date: Tue, 31 Mar 2015 16:44:35 -0700 (PDT) Subject: Mesa (master): i965/state: Only upload render programs for render state uploads Message-ID: <20150331234435.5BF6D76336@kemper.freedesktop.org> Module: Mesa Branch: master Commit: a8e39e19032d077a4adf7e451c608f3f139a05e2 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=a8e39e19032d077a4adf7e451c608f3f139a05e2 Author: Jordan Justen Date: Fri Mar 20 12:36:21 2015 -0700 i965/state: Only upload render programs for render state uploads Signed-off-by: Jordan Justen Reviewed-by: Kristian H?gsberg Reviewed-by: Kenneth Graunke --- src/mesa/drivers/dri/i965/brw_state_upload.c | 45 ++++++++++++++------------ 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_state_upload.c b/src/mesa/drivers/dri/i965/brw_state_upload.c index 8bd88f1..f24fcc7 100644 --- a/src/mesa/drivers/dri/i965/brw_state_upload.c +++ b/src/mesa/drivers/dri/i965/brw_state_upload.c @@ -583,17 +583,20 @@ brw_print_dirty_count(struct dirty_bit_map *bit_map) } } -static void -brw_upload_programs(struct brw_context *brw) +static inline void +brw_upload_programs(struct brw_context *brw, + enum brw_pipeline pipeline) { - brw_upload_vs_prog(brw); + if (pipeline == BRW_RENDER_PIPELINE) { + brw_upload_vs_prog(brw); - if (brw->gen < 6) - brw_upload_ff_gs_prog(brw); - else - brw_upload_gs_prog(brw); + if (brw->gen < 6) + brw_upload_ff_gs_prog(brw); + else + brw_upload_gs_prog(brw); - brw_upload_wm_prog(brw); + brw_upload_wm_prog(brw); + } } static inline void @@ -637,19 +640,21 @@ brw_upload_pipeline_state(struct brw_context *brw, brw_state->brw |= ~0ull; } - if (brw->fragment_program != ctx->FragmentProgram._Current) { - brw->fragment_program = ctx->FragmentProgram._Current; - brw->state.dirty.brw |= BRW_NEW_FRAGMENT_PROGRAM; - } + if (pipeline == BRW_RENDER_PIPELINE) { + if (brw->fragment_program != ctx->FragmentProgram._Current) { + brw->fragment_program = ctx->FragmentProgram._Current; + brw->state.dirty.brw |= BRW_NEW_FRAGMENT_PROGRAM; + } - if (brw->geometry_program != ctx->GeometryProgram._Current) { - brw->geometry_program = ctx->GeometryProgram._Current; - brw->state.dirty.brw |= BRW_NEW_GEOMETRY_PROGRAM; - } + if (brw->geometry_program != ctx->GeometryProgram._Current) { + brw->geometry_program = ctx->GeometryProgram._Current; + brw->state.dirty.brw |= BRW_NEW_GEOMETRY_PROGRAM; + } - if (brw->vertex_program != ctx->VertexProgram._Current) { - brw->vertex_program = ctx->VertexProgram._Current; - brw->state.dirty.brw |= BRW_NEW_VERTEX_PROGRAM; + if (brw->vertex_program != ctx->VertexProgram._Current) { + brw->vertex_program = ctx->VertexProgram._Current; + brw->state.dirty.brw |= BRW_NEW_VERTEX_PROGRAM; + } } if (brw->meta_in_progress != _mesa_meta_in_progress(ctx)) { @@ -671,7 +676,7 @@ brw_upload_pipeline_state(struct brw_context *brw, if (brw->gen == 6) intel_emit_post_sync_nonzero_flush(brw); - brw_upload_programs(brw); + brw_upload_programs(brw, pipeline); merge_ctx_state(brw, &state); const struct brw_tracked_state *atoms = From jljusten at kemper.freedesktop.org Tue Mar 31 23:44:35 2015 From: jljusten at kemper.freedesktop.org (Jordan Justen) Date: Tue, 31 Mar 2015 16:44:35 -0700 (PDT) Subject: Mesa (master): i965/state: Don't use brw->state.dirty.brw Message-ID: <20150331234435.7D09F76336@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 4e56a9ad46ff7fe85308ce12e21719ff2b476516 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=4e56a9ad46ff7fe85308ce12e21719ff2b476516 Author: Jordan Justen Date: Thu Mar 19 18:57:34 2015 -0700 i965/state: Don't use brw->state.dirty.brw Now, we only use ctx->NewDriverState. I used this bash & sed command in the i965 directory: for file in *.[ch] *.[ch]pp; do sed -i -e 's/state\.dirty\.brw/ctx.NewDriverState/g' $file done Followed by manual changes to brw_state_upload.c. Signed-off-by: Jordan Justen Reviewed-by: Kristian H?gsberg Reviewed-by: Kenneth Graunke --- src/mesa/drivers/dri/i965/brw_binding_tables.c | 2 +- src/mesa/drivers/dri/i965/brw_blorp.cpp | 2 +- src/mesa/drivers/dri/i965/brw_cc.c | 4 +-- src/mesa/drivers/dri/i965/brw_clip_state.c | 2 +- src/mesa/drivers/dri/i965/brw_curbe.c | 4 +-- src/mesa/drivers/dri/i965/brw_draw.c | 22 ++++++++--------- src/mesa/drivers/dri/i965/brw_draw_upload.c | 4 +-- src/mesa/drivers/dri/i965/brw_ff_gs.c | 2 +- src/mesa/drivers/dri/i965/brw_gs.c | 8 +++--- src/mesa/drivers/dri/i965/brw_gs_state.c | 2 +- src/mesa/drivers/dri/i965/brw_interpolation_map.c | 2 +- src/mesa/drivers/dri/i965/brw_meta_fast_clear.c | 4 +-- src/mesa/drivers/dri/i965/brw_misc_state.c | 4 +-- src/mesa/drivers/dri/i965/brw_program.c | 4 +-- src/mesa/drivers/dri/i965/brw_queryobj.c | 4 +-- src/mesa/drivers/dri/i965/brw_sampler_state.c | 2 +- src/mesa/drivers/dri/i965/brw_sf_state.c | 4 +-- src/mesa/drivers/dri/i965/brw_state.h | 2 +- src/mesa/drivers/dri/i965/brw_state_cache.c | 8 +++--- src/mesa/drivers/dri/i965/brw_state_upload.c | 27 ++++++++++----------- src/mesa/drivers/dri/i965/brw_urb.c | 2 +- src/mesa/drivers/dri/i965/brw_vs.c | 4 +-- src/mesa/drivers/dri/i965/brw_vs_state.c | 2 +- src/mesa/drivers/dri/i965/brw_vs_surface_state.c | 4 +-- src/mesa/drivers/dri/i965/brw_wm_state.c | 2 +- src/mesa/drivers/dri/i965/brw_wm_surface_state.c | 8 +++--- src/mesa/drivers/dri/i965/gen6_sol.c | 8 +++--- src/mesa/drivers/dri/i965/gen6_viewport_state.c | 4 +-- src/mesa/drivers/dri/i965/gen7_urb.c | 4 +-- src/mesa/drivers/dri/i965/gen7_vs_state.c | 2 +- src/mesa/drivers/dri/i965/gen8_misc_state.c | 2 +- src/mesa/drivers/dri/i965/intel_batchbuffer.c | 4 +-- src/mesa/drivers/dri/i965/intel_buffer_objects.c | 6 ++--- 33 files changed, 82 insertions(+), 83 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_binding_tables.c b/src/mesa/drivers/dri/i965/brw_binding_tables.c index 08e4191..459165a 100644 --- a/src/mesa/drivers/dri/i965/brw_binding_tables.c +++ b/src/mesa/drivers/dri/i965/brw_binding_tables.c @@ -84,7 +84,7 @@ brw_upload_binding_table(struct brw_context *brw, prog_data->binding_table.size_bytes); } - brw->state.dirty.brw |= brw_new_binding_table; + brw->ctx.NewDriverState |= brw_new_binding_table; if (brw->gen >= 7) { BEGIN_BATCH(2); diff --git a/src/mesa/drivers/dri/i965/brw_blorp.cpp b/src/mesa/drivers/dri/i965/brw_blorp.cpp index df00b77..78ac58e 100644 --- a/src/mesa/drivers/dri/i965/brw_blorp.cpp +++ b/src/mesa/drivers/dri/i965/brw_blorp.cpp @@ -276,7 +276,7 @@ retry: /* We've smashed all state compared to what the normal 3D pipeline * rendering tracks for GL. */ - brw->state.dirty.brw = ~0ull; + brw->ctx.NewDriverState = ~0ull; brw->no_depth_or_stencil = false; brw->ib.type = -1; diff --git a/src/mesa/drivers/dri/i965/brw_cc.c b/src/mesa/drivers/dri/i965/brw_cc.c index 02f5a3a..354c733 100644 --- a/src/mesa/drivers/dri/i965/brw_cc.c +++ b/src/mesa/drivers/dri/i965/brw_cc.c @@ -68,7 +68,7 @@ brw_upload_cc_vp(struct brw_context *brw) OUT_BATCH(brw->cc.vp_offset); ADVANCE_BATCH(); } else { - brw->state.dirty.brw |= BRW_NEW_CC_VP; + brw->ctx.NewDriverState |= BRW_NEW_CC_VP; } } @@ -230,7 +230,7 @@ static void upload_cc_unit(struct brw_context *brw) cc->cc4.cc_viewport_state_offset = (brw->batch.bo->offset64 + brw->cc.vp_offset) >> 5; /* reloc */ - brw->state.dirty.brw |= BRW_NEW_GEN4_UNIT_STATE; + brw->ctx.NewDriverState |= BRW_NEW_GEN4_UNIT_STATE; /* Emit CC viewport relocation */ drm_intel_bo_emit_reloc(brw->batch.bo, diff --git a/src/mesa/drivers/dri/i965/brw_clip_state.c b/src/mesa/drivers/dri/i965/brw_clip_state.c index 09a2523..4f241ac 100644 --- a/src/mesa/drivers/dri/i965/brw_clip_state.c +++ b/src/mesa/drivers/dri/i965/brw_clip_state.c @@ -158,7 +158,7 @@ brw_upload_clip_unit(struct brw_context *brw) clip->viewport_ymin = -1; clip->viewport_ymax = 1; - brw->state.dirty.brw |= BRW_NEW_GEN4_UNIT_STATE; + brw->ctx.NewDriverState |= BRW_NEW_GEN4_UNIT_STATE; } const struct brw_tracked_state brw_clip_unit = { diff --git a/src/mesa/drivers/dri/i965/brw_curbe.c b/src/mesa/drivers/dri/i965/brw_curbe.c index d0ec859..e45e2ab 100644 --- a/src/mesa/drivers/dri/i965/brw_curbe.c +++ b/src/mesa/drivers/dri/i965/brw_curbe.c @@ -134,7 +134,7 @@ static void calculate_curbe_offsets( struct brw_context *brw ) brw->curbe.vs_start, brw->curbe.vs_size ); - brw->state.dirty.brw |= BRW_NEW_CURBE_OFFSETS; + brw->ctx.NewDriverState |= BRW_NEW_CURBE_OFFSETS; } } @@ -292,7 +292,7 @@ emit: * We've found no documented reason why this should be necessary. */ if (brw->gen == 4 && !brw->is_g4x && - (brw->state.dirty.brw & (BRW_NEW_BATCH | BRW_NEW_PSP)) == 0) { + (brw->ctx.NewDriverState & (BRW_NEW_BATCH | BRW_NEW_PSP)) == 0) { BEGIN_BATCH(1); OUT_BATCH(MI_FLUSH); ADVANCE_BATCH(); diff --git a/src/mesa/drivers/dri/i965/brw_draw.c b/src/mesa/drivers/dri/i965/brw_draw.c index c573b50..96e2369 100644 --- a/src/mesa/drivers/dri/i965/brw_draw.c +++ b/src/mesa/drivers/dri/i965/brw_draw.c @@ -127,11 +127,11 @@ static void brw_set_prim(struct brw_context *brw, if (hw_prim != brw->primitive) { brw->primitive = hw_prim; - brw->state.dirty.brw |= BRW_NEW_PRIMITIVE; + brw->ctx.NewDriverState |= BRW_NEW_PRIMITIVE; if (reduced_prim[prim->mode] != brw->reduced_primitive) { brw->reduced_primitive = reduced_prim[prim->mode]; - brw->state.dirty.brw |= BRW_NEW_REDUCED_PRIMITIVE; + brw->ctx.NewDriverState |= BRW_NEW_REDUCED_PRIMITIVE; } } } @@ -147,7 +147,7 @@ static void gen6_set_prim(struct brw_context *brw, if (hw_prim != brw->primitive) { brw->primitive = hw_prim; - brw->state.dirty.brw |= BRW_NEW_PRIMITIVE; + brw->ctx.NewDriverState |= BRW_NEW_PRIMITIVE; } } @@ -334,7 +334,7 @@ static void brw_merge_inputs( struct brw_context *brw, if (brw->vb.attrib_wa_flags[i] != wa_flags) { brw->vb.attrib_wa_flags[i] = wa_flags; - brw->state.dirty.brw |= BRW_NEW_VS_ATTRIB_WORKAROUNDS; + brw->ctx.NewDriverState |= BRW_NEW_VS_ATTRIB_WORKAROUNDS; } } } @@ -441,11 +441,11 @@ static void brw_try_draw_prims( struct gl_context *ctx, brw_merge_inputs( brw, arrays ); brw->ib.ib = ib; - brw->state.dirty.brw |= BRW_NEW_INDICES; + brw->ctx.NewDriverState |= BRW_NEW_INDICES; brw->vb.min_index = min_index; brw->vb.max_index = max_index; - brw->state.dirty.brw |= BRW_NEW_VERTICES; + brw->ctx.NewDriverState |= BRW_NEW_VERTICES; for (i = 0; i < nr_prims; i++) { int estimated_max_prim_size; @@ -470,7 +470,7 @@ static void brw_try_draw_prims( struct gl_context *ctx, brw->num_instances = prims[i].num_instances; brw->basevertex = prims[i].basevertex; if (i > 0) { /* For i == 0 we just did this before the loop */ - brw->state.dirty.brw |= BRW_NEW_VERTICES; + brw->ctx.NewDriverState |= BRW_NEW_VERTICES; brw_merge_inputs(brw, arrays); } } @@ -502,12 +502,12 @@ static void brw_try_draw_prims( struct gl_context *ctx, retry: - /* Note that before the loop, brw->state.dirty.brw was set to != 0, and + /* Note that before the loop, brw->ctx.NewDriverState was set to != 0, and * that the state updated in the loop outside of this block is that in * *_set_prim or intel_batchbuffer_flush(), which only impacts - * brw->state.dirty.brw. + * brw->ctx.NewDriverState. */ - if (brw->state.dirty.brw) { + if (brw->ctx.NewDriverState) { brw->no_batch_wrap = true; brw_upload_render_state(brw); } @@ -533,7 +533,7 @@ retry: /* Now that we know we haven't run out of aperture space, we can safely * reset the dirty bits. */ - if (brw->state.dirty.brw) + if (brw->ctx.NewDriverState) brw_render_state_finished(brw); } diff --git a/src/mesa/drivers/dri/i965/brw_draw_upload.c b/src/mesa/drivers/dri/i965/brw_draw_upload.c index 52dcb6f..b1af0d7 100644 --- a/src/mesa/drivers/dri/i965/brw_draw_upload.c +++ b/src/mesa/drivers/dri/i965/brw_draw_upload.c @@ -919,11 +919,11 @@ static void brw_upload_indices(struct brw_context *brw) brw->ib.start_vertex_offset = offset / ib_type_size; if (brw->ib.bo != old_bo) - brw->state.dirty.brw |= BRW_NEW_INDEX_BUFFER; + brw->ctx.NewDriverState |= BRW_NEW_INDEX_BUFFER; if (index_buffer->type != brw->ib.type) { brw->ib.type = index_buffer->type; - brw->state.dirty.brw |= BRW_NEW_INDEX_BUFFER; + brw->ctx.NewDriverState |= BRW_NEW_INDEX_BUFFER; } } diff --git a/src/mesa/drivers/dri/i965/brw_ff_gs.c b/src/mesa/drivers/dri/i965/brw_ff_gs.c index 828e383..016fcdf 100644 --- a/src/mesa/drivers/dri/i965/brw_ff_gs.c +++ b/src/mesa/drivers/dri/i965/brw_ff_gs.c @@ -238,7 +238,7 @@ brw_upload_ff_gs_prog(struct brw_context *brw) populate_key(brw, &key); if (brw->ff_gs.prog_active != key.need_gs_prog) { - brw->state.dirty.brw |= BRW_NEW_FF_GS_PROG_DATA; + brw->ctx.NewDriverState |= BRW_NEW_FF_GS_PROG_DATA; brw->ff_gs.prog_active = key.need_gs_prog; } diff --git a/src/mesa/drivers/dri/i965/brw_gs.c b/src/mesa/drivers/dri/i965/brw_gs.c index 45c157a..ffe7476 100644 --- a/src/mesa/drivers/dri/i965/brw_gs.c +++ b/src/mesa/drivers/dri/i965/brw_gs.c @@ -307,13 +307,13 @@ brw_upload_gs_prog(struct brw_context *brw) if (gp == NULL) { /* No geometry shader. Vertex data just passes straight through. */ - if (brw->state.dirty.brw & BRW_NEW_VUE_MAP_VS) { + if (brw->ctx.NewDriverState & BRW_NEW_VUE_MAP_VS) { brw->vue_map_geom_out = brw->vue_map_vs; - brw->state.dirty.brw |= BRW_NEW_VUE_MAP_GEOM_OUT; + brw->ctx.NewDriverState |= BRW_NEW_VUE_MAP_GEOM_OUT; } if (brw->gen == 6 && - (brw->state.dirty.brw & BRW_NEW_TRANSFORM_FEEDBACK)) { + (brw->ctx.NewDriverState & BRW_NEW_TRANSFORM_FEEDBACK)) { gen6_brw_upload_ff_gs_prog(brw); return; } @@ -356,7 +356,7 @@ brw_upload_gs_prog(struct brw_context *brw) if (memcmp(&brw->gs.prog_data->base.vue_map, &brw->vue_map_geom_out, sizeof(brw->vue_map_geom_out)) != 0) { brw->vue_map_geom_out = brw->gs.prog_data->base.vue_map; - brw->state.dirty.brw |= BRW_NEW_VUE_MAP_GEOM_OUT; + brw->ctx.NewDriverState |= BRW_NEW_VUE_MAP_GEOM_OUT; } } diff --git a/src/mesa/drivers/dri/i965/brw_gs_state.c b/src/mesa/drivers/dri/i965/brw_gs_state.c index cb46ace..f7b1406 100644 --- a/src/mesa/drivers/dri/i965/brw_gs_state.c +++ b/src/mesa/drivers/dri/i965/brw_gs_state.c @@ -85,7 +85,7 @@ brw_upload_gs_unit(struct brw_context *brw) gs->gs6.max_vp_index = brw->ctx.Const.MaxViewports - 1; - brw->state.dirty.brw |= BRW_NEW_GEN4_UNIT_STATE; + brw->ctx.NewDriverState |= BRW_NEW_GEN4_UNIT_STATE; } const struct brw_tracked_state brw_gs_unit = { diff --git a/src/mesa/drivers/dri/i965/brw_interpolation_map.c b/src/mesa/drivers/dri/i965/brw_interpolation_map.c index 8ab17aa..b5da6f5 100644 --- a/src/mesa/drivers/dri/i965/brw_interpolation_map.c +++ b/src/mesa/drivers/dri/i965/brw_interpolation_map.c @@ -44,7 +44,7 @@ brw_setup_vue_interpolation(struct brw_context *brw) memset(&brw->interpolation_mode, INTERP_QUALIFIER_NONE, sizeof(brw->interpolation_mode)); - brw->state.dirty.brw |= BRW_NEW_INTERPOLATION_MAP; + brw->ctx.NewDriverState |= BRW_NEW_INTERPOLATION_MAP; if (!fprog) return; diff --git a/src/mesa/drivers/dri/i965/brw_meta_fast_clear.c b/src/mesa/drivers/dri/i965/brw_meta_fast_clear.c index c8f2a14..d45f1e6 100644 --- a/src/mesa/drivers/dri/i965/brw_meta_fast_clear.c +++ b/src/mesa/drivers/dri/i965/brw_meta_fast_clear.c @@ -376,7 +376,7 @@ set_fast_clear_op(struct brw_context *brw, uint32_t op) * 3DSTATE_PS. */ brw->wm.fast_clear_op = op; - brw->state.dirty.brw |= BRW_NEW_FRAGMENT_PROGRAM; + brw->ctx.NewDriverState |= BRW_NEW_FRAGMENT_PROGRAM; } static void @@ -401,7 +401,7 @@ use_rectlist(struct brw_context *brw, bool enable) * clear color value. */ brw->state.dirty.mesa |= _NEW_LIGHT | _NEW_BUFFERS; - brw->state.dirty.brw |= BRW_NEW_FRAGMENT_PROGRAM; + brw->ctx.NewDriverState |= BRW_NEW_FRAGMENT_PROGRAM; } bool diff --git a/src/mesa/drivers/dri/i965/brw_misc_state.c b/src/mesa/drivers/dri/i965/brw_misc_state.c index bc81076..78a46cb 100644 --- a/src/mesa/drivers/dri/i965/brw_misc_state.c +++ b/src/mesa/drivers/dri/i965/brw_misc_state.c @@ -98,7 +98,7 @@ static void upload_pipelined_state_pointers(struct brw_context *brw ) brw->cc.state_offset); ADVANCE_BATCH(); - brw->state.dirty.brw |= BRW_NEW_PSP; + brw->ctx.NewDriverState |= BRW_NEW_PSP; } static void upload_psp_urb_cbs(struct brw_context *brw ) @@ -1014,7 +1014,7 @@ static void upload_state_base_address( struct brw_context *brw ) * obvious. */ - brw->state.dirty.brw |= BRW_NEW_STATE_BASE_ADDRESS; + brw->ctx.NewDriverState |= BRW_NEW_STATE_BASE_ADDRESS; } const struct brw_tracked_state brw_state_base_address = { diff --git a/src/mesa/drivers/dri/i965/brw_program.c b/src/mesa/drivers/dri/i965/brw_program.c index 70b5a62..8920c34 100644 --- a/src/mesa/drivers/dri/i965/brw_program.c +++ b/src/mesa/drivers/dri/i965/brw_program.c @@ -136,7 +136,7 @@ brwProgramStringNotify(struct gl_context *ctx, brw_fragment_program_const(brw->fragment_program); if (newFP == curFP) - brw->state.dirty.brw |= BRW_NEW_FRAGMENT_PROGRAM; + brw->ctx.NewDriverState |= BRW_NEW_FRAGMENT_PROGRAM; newFP->id = get_new_program_id(brw->intelScreen); brw_add_texrect_params(prog); @@ -151,7 +151,7 @@ brwProgramStringNotify(struct gl_context *ctx, brw_vertex_program_const(brw->vertex_program); if (newVP == curVP) - brw->state.dirty.brw |= BRW_NEW_VERTEX_PROGRAM; + brw->ctx.NewDriverState |= BRW_NEW_VERTEX_PROGRAM; if (newVP->program.IsPositionInvariant) { _mesa_insert_mvp_code(ctx, &newVP->program); } diff --git a/src/mesa/drivers/dri/i965/brw_queryobj.c b/src/mesa/drivers/dri/i965/brw_queryobj.c index 2a90822..917a24f 100644 --- a/src/mesa/drivers/dri/i965/brw_queryobj.c +++ b/src/mesa/drivers/dri/i965/brw_queryobj.c @@ -251,7 +251,7 @@ brw_begin_query(struct gl_context *ctx, struct gl_query_object *q) * so turn them on now. */ brw->stats_wm++; - brw->state.dirty.brw |= BRW_NEW_STATS_WM; + brw->ctx.NewDriverState |= BRW_NEW_STATS_WM; break; default: @@ -308,7 +308,7 @@ brw_end_query(struct gl_context *ctx, struct gl_query_object *q) brw->query.obj = NULL; brw->stats_wm--; - brw->state.dirty.brw |= BRW_NEW_STATS_WM; + brw->ctx.NewDriverState |= BRW_NEW_STATS_WM; break; default: diff --git a/src/mesa/drivers/dri/i965/brw_sampler_state.c b/src/mesa/drivers/dri/i965/brw_sampler_state.c index c532850..c4bd949 100644 --- a/src/mesa/drivers/dri/i965/brw_sampler_state.c +++ b/src/mesa/drivers/dri/i965/brw_sampler_state.c @@ -573,7 +573,7 @@ brw_upload_sampler_state_table(struct brw_context *brw, /* Flag that the sampler state table pointer has changed; later atoms * will handle it. */ - brw->state.dirty.brw |= BRW_NEW_SAMPLER_STATE_TABLE; + brw->ctx.NewDriverState |= BRW_NEW_SAMPLER_STATE_TABLE; } } diff --git a/src/mesa/drivers/dri/i965/brw_sf_state.c b/src/mesa/drivers/dri/i965/brw_sf_state.c index 75d6451..e055837 100644 --- a/src/mesa/drivers/dri/i965/brw_sf_state.c +++ b/src/mesa/drivers/dri/i965/brw_sf_state.c @@ -109,7 +109,7 @@ static void upload_sf_vp(struct brw_context *brw) sfv->scissor.ymax = ctx->DrawBuffer->Height - ctx->DrawBuffer->_Ymin - 1; } - brw->state.dirty.brw |= BRW_NEW_SF_VP; + brw->ctx.NewDriverState |= BRW_NEW_SF_VP; } const struct brw_tracked_state brw_sf_vp = { @@ -291,7 +291,7 @@ static void upload_sf_unit( struct brw_context *brw ) (sf->sf5.viewport_transform << 1)), I915_GEM_DOMAIN_INSTRUCTION, 0); - brw->state.dirty.brw |= BRW_NEW_GEN4_UNIT_STATE; + brw->ctx.NewDriverState |= BRW_NEW_GEN4_UNIT_STATE; } const struct brw_tracked_state brw_sf_unit = { diff --git a/src/mesa/drivers/dri/i965/brw_state.h b/src/mesa/drivers/dri/i965/brw_state.h index e428183..bb920b2 100644 --- a/src/mesa/drivers/dri/i965/brw_state.h +++ b/src/mesa/drivers/dri/i965/brw_state.h @@ -156,7 +156,7 @@ static inline bool brw_state_dirty(struct brw_context *brw, GLuint mesa_flags, uint64_t brw_flags) { return ((brw->state.dirty.mesa & mesa_flags) | - (brw->state.dirty.brw & brw_flags)) != 0; + (brw->ctx.NewDriverState & brw_flags)) != 0; } /* brw_misc_state.c */ diff --git a/src/mesa/drivers/dri/i965/brw_state_cache.c b/src/mesa/drivers/dri/i965/brw_state_cache.c index 3b9d6cc..bfe7e51 100644 --- a/src/mesa/drivers/dri/i965/brw_state_cache.c +++ b/src/mesa/drivers/dri/i965/brw_state_cache.c @@ -157,7 +157,7 @@ brw_search_cache(struct brw_cache *cache, *(void **)out_aux = ((char *)item->key + item->key_size); if (item->offset != *inout_offset) { - brw->state.dirty.brw |= (1 << cache_id); + brw->ctx.NewDriverState |= (1 << cache_id); *inout_offset = item->offset; } @@ -195,7 +195,7 @@ brw_cache_new_bo(struct brw_cache *cache, uint32_t new_size) /* Since we have a new BO in place, we need to signal the units * that depend on it (state base address on gen5+, or unit state before). */ - brw->state.dirty.brw |= BRW_NEW_PROGRAM_CACHE; + brw->ctx.NewDriverState |= BRW_NEW_PROGRAM_CACHE; } /** @@ -339,7 +339,7 @@ brw_upload_cache(struct brw_cache *cache, *out_offset = item->offset; *(void **)out_aux = (void *)((char *)item->key + item->key_size); - cache->brw->state.dirty.brw |= 1 << cache_id; + cache->brw->ctx.NewDriverState |= 1 << cache_id; } void @@ -400,7 +400,7 @@ brw_clear_cache(struct brw_context *brw, struct brw_cache *cache) * any offsets leftover in brw_context will no longer be valid. */ brw->state.dirty.mesa |= ~0; - brw->state.dirty.brw |= ~0ull; + brw->ctx.NewDriverState |= ~0ull; intel_batchbuffer_flush(brw); } diff --git a/src/mesa/drivers/dri/i965/brw_state_upload.c b/src/mesa/drivers/dri/i965/brw_state_upload.c index 1e00566..255e892 100644 --- a/src/mesa/drivers/dri/i965/brw_state_upload.c +++ b/src/mesa/drivers/dri/i965/brw_state_upload.c @@ -439,17 +439,17 @@ void brw_init_state( struct brw_context *brw ) brw_upload_initial_gpu_state(brw); brw->state.dirty.mesa = ~0; - brw->state.dirty.brw = ~0ull; + brw->ctx.NewDriverState = ~0ull; /* ~0 is a nonsensical value which won't match anything we program, so * the programming will take effect on the first time around. */ brw->pma_stall_bits = ~0; - /* Make sure that brw->state.dirty.brw has enough bits to hold all possible + /* Make sure that brw->ctx.NewDriverState has enough bits to hold all possible * dirty flags. */ - STATIC_ASSERT(BRW_NUM_STATE_BITS <= 8 * sizeof(brw->state.dirty.brw)); + STATIC_ASSERT(BRW_NUM_STATE_BITS <= 8 * sizeof(brw->ctx.NewDriverState)); ctx->DriverFlags.NewTransformFeedback = BRW_NEW_TRANSFORM_FEEDBACK; ctx->DriverFlags.NewTransformFeedbackProg = BRW_NEW_TRANSFORM_FEEDBACK; @@ -624,7 +624,8 @@ merge_ctx_state(struct brw_context *brw, struct brw_state_flags *state) { state->mesa |= brw->state.dirty.mesa; - state->brw |= brw->state.dirty.brw; + state->brw |= brw->ctx.NewDriverState; + assert(brw->state.dirty.brw == 0ull); } static inline void @@ -651,40 +652,37 @@ brw_upload_pipeline_state(struct brw_context *brw, brw_state->mesa |= brw->NewGLState; brw->NewGLState = 0; - brw_state->brw |= ctx->NewDriverState; - ctx->NewDriverState = 0; - if (0) { /* Always re-emit all state. */ brw_state->mesa |= ~0; - brw_state->brw |= ~0ull; + ctx->NewDriverState = ~0ull; } if (pipeline == BRW_RENDER_PIPELINE) { if (brw->fragment_program != ctx->FragmentProgram._Current) { brw->fragment_program = ctx->FragmentProgram._Current; - brw->state.dirty.brw |= BRW_NEW_FRAGMENT_PROGRAM; + brw->ctx.NewDriverState |= BRW_NEW_FRAGMENT_PROGRAM; } if (brw->geometry_program != ctx->GeometryProgram._Current) { brw->geometry_program = ctx->GeometryProgram._Current; - brw->state.dirty.brw |= BRW_NEW_GEOMETRY_PROGRAM; + brw->ctx.NewDriverState |= BRW_NEW_GEOMETRY_PROGRAM; } if (brw->vertex_program != ctx->VertexProgram._Current) { brw->vertex_program = ctx->VertexProgram._Current; - brw->state.dirty.brw |= BRW_NEW_VERTEX_PROGRAM; + brw->ctx.NewDriverState |= BRW_NEW_VERTEX_PROGRAM; } } if (brw->meta_in_progress != _mesa_meta_in_progress(ctx)) { brw->meta_in_progress = _mesa_meta_in_progress(ctx); - brw->state.dirty.brw |= BRW_NEW_META_IN_PROGRESS; + brw->ctx.NewDriverState |= BRW_NEW_META_IN_PROGRESS; } if (brw->num_samples != ctx->DrawBuffer->Visual.samples) { brw->num_samples = ctx->DrawBuffer->Visual.samples; - brw->state.dirty.brw |= BRW_NEW_NUM_SAMPLES; + brw->ctx.NewDriverState |= BRW_NEW_NUM_SAMPLES; } /* Exit early if no state is flagged as dirty */ @@ -768,12 +766,13 @@ brw_pipeline_state_finished(struct brw_context *brw, for (int i = 0; i < BRW_NUM_PIPELINES; i++) { if (i != pipeline) { brw->state.pipelines[i].mesa |= state->mesa; - brw->state.pipelines[i].brw |= state->brw; + brw->state.pipelines[i].brw |= brw->ctx.NewDriverState; } else { memset(&brw->state.pipelines[i], 0, sizeof(struct brw_state_flags)); } } + brw->ctx.NewDriverState = 0ull; memset(state, 0, sizeof(*state)); } diff --git a/src/mesa/drivers/dri/i965/brw_urb.c b/src/mesa/drivers/dri/i965/brw_urb.c index e76db6a..6fcf1b0 100644 --- a/src/mesa/drivers/dri/i965/brw_urb.c +++ b/src/mesa/drivers/dri/i965/brw_urb.c @@ -204,7 +204,7 @@ done: brw->urb.cs_start, brw->urb.size); - brw->state.dirty.brw |= BRW_NEW_URB_FENCE; + brw->ctx.NewDriverState |= BRW_NEW_URB_FENCE; } } diff --git a/src/mesa/drivers/dri/i965/brw_vs.c b/src/mesa/drivers/dri/i965/brw_vs.c index ba2c23d..bf16f34 100644 --- a/src/mesa/drivers/dri/i965/brw_vs.c +++ b/src/mesa/drivers/dri/i965/brw_vs.c @@ -474,13 +474,13 @@ brw_upload_vs_prog(struct brw_context *brw) if (memcmp(&brw->vs.prog_data->base.vue_map, &brw->vue_map_geom_out, sizeof(brw->vue_map_geom_out)) != 0) { brw->vue_map_vs = brw->vs.prog_data->base.vue_map; - brw->state.dirty.brw |= BRW_NEW_VUE_MAP_VS; + brw->ctx.NewDriverState |= BRW_NEW_VUE_MAP_VS; if (brw->gen < 6) { /* No geometry shader support, so the VS VUE map is the VUE map for * the output of the "geometry" portion of the pipeline. */ brw->vue_map_geom_out = brw->vue_map_vs; - brw->state.dirty.brw |= BRW_NEW_VUE_MAP_GEOM_OUT; + brw->ctx.NewDriverState |= BRW_NEW_VUE_MAP_GEOM_OUT; } } } diff --git a/src/mesa/drivers/dri/i965/brw_vs_state.c b/src/mesa/drivers/dri/i965/brw_vs_state.c index 17bdbb9..b9b97a7 100644 --- a/src/mesa/drivers/dri/i965/brw_vs_state.c +++ b/src/mesa/drivers/dri/i965/brw_vs_state.c @@ -178,7 +178,7 @@ brw_upload_vs_unit(struct brw_context *brw) I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER); } - brw->state.dirty.brw |= BRW_NEW_GEN4_UNIT_STATE; + brw->ctx.NewDriverState |= BRW_NEW_GEN4_UNIT_STATE; } const struct brw_tracked_state brw_vs_unit = { 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 709cb43..f82a62b 100644 --- a/src/mesa/drivers/dri/i965/brw_vs_surface_state.c +++ b/src/mesa/drivers/dri/i965/brw_vs_surface_state.c @@ -62,7 +62,7 @@ brw_upload_pull_constants(struct brw_context *brw, if (!prog_data->nr_pull_params) { if (stage_state->surf_offset[surf_index]) { stage_state->surf_offset[surf_index] = 0; - brw->state.dirty.brw |= brw_new_constbuf; + brw->ctx.NewDriverState |= brw_new_constbuf; } return; } @@ -98,7 +98,7 @@ brw_upload_pull_constants(struct brw_context *brw, dword_pitch); drm_intel_bo_unreference(const_bo); - brw->state.dirty.brw |= brw_new_constbuf; + brw->ctx.NewDriverState |= brw_new_constbuf; } diff --git a/src/mesa/drivers/dri/i965/brw_wm_state.c b/src/mesa/drivers/dri/i965/brw_wm_state.c index 0dee1f8..afb4ebf 100644 --- a/src/mesa/drivers/dri/i965/brw_wm_state.c +++ b/src/mesa/drivers/dri/i965/brw_wm_state.c @@ -237,7 +237,7 @@ brw_upload_wm_unit(struct brw_context *brw) I915_GEM_DOMAIN_INSTRUCTION, 0); } - brw->state.dirty.brw |= BRW_NEW_GEN4_UNIT_STATE; + brw->ctx.NewDriverState |= BRW_NEW_GEN4_UNIT_STATE; } const struct brw_tracked_state brw_wm_unit = { 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 828893b..c9dac5b 100644 --- a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c +++ b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c @@ -763,7 +763,7 @@ brw_update_renderbuffer_surfaces(struct brw_context *brw) brw, fb->Width, fb->Height, fb->Visual.samples, &brw->wm.base.surf_offset[surf_index]); } - brw->state.dirty.brw |= BRW_NEW_SURFACES; + brw->ctx.NewDriverState |= BRW_NEW_SURFACES; } const struct brw_tracked_state brw_renderbuffer_surfaces = { @@ -852,7 +852,7 @@ brw_update_texture_surfaces(struct brw_context *brw) update_stage_texture_surfaces(brw, fs, &brw->wm.base, true); } - brw->state.dirty.brw |= BRW_NEW_SURFACES; + brw->ctx.NewDriverState |= BRW_NEW_SURFACES; } const struct brw_tracked_state brw_texture_surfaces = { @@ -907,7 +907,7 @@ brw_upload_ubo_surfaces(struct brw_context *brw, } if (shader->NumUniformBlocks) - brw->state.dirty.brw |= BRW_NEW_SURFACES; + brw->ctx.NewDriverState |= BRW_NEW_SURFACES; } static void @@ -959,7 +959,7 @@ brw_upload_abo_surfaces(struct brw_context *brw, } if (prog->NumAtomicBuffers) - brw->state.dirty.brw |= BRW_NEW_SURFACES; + brw->ctx.NewDriverState |= BRW_NEW_SURFACES; } static void diff --git a/src/mesa/drivers/dri/i965/gen6_sol.c b/src/mesa/drivers/dri/i965/gen6_sol.c index 0a66b1b..be80d7b 100644 --- a/src/mesa/drivers/dri/i965/gen6_sol.c +++ b/src/mesa/drivers/dri/i965/gen6_sol.c @@ -85,7 +85,7 @@ gen6_update_sol_surfaces(struct brw_context *brw) } } - brw->state.dirty.brw |= BRW_NEW_SURFACES; + brw->ctx.NewDriverState |= BRW_NEW_SURFACES; } const struct brw_tracked_state gen6_sol_surface = { @@ -131,7 +131,7 @@ brw_gs_upload_binding_table(struct brw_context *brw) } if (!need_binding_table) { if (brw->ff_gs.bind_bo_offset != 0) { - brw->state.dirty.brw |= BRW_NEW_GS_BINDING_TABLE; + brw->ctx.NewDriverState |= BRW_NEW_GS_BINDING_TABLE; brw->ff_gs.bind_bo_offset = 0; } return; @@ -162,7 +162,7 @@ brw_gs_upload_binding_table(struct brw_context *brw) if (!need_binding_table) { if (brw->gs.base.bind_bo_offset != 0) { brw->gs.base.bind_bo_offset = 0; - brw->state.dirty.brw |= BRW_NEW_GS_BINDING_TABLE; + brw->ctx.NewDriverState |= BRW_NEW_GS_BINDING_TABLE; } return; } @@ -179,7 +179,7 @@ brw_gs_upload_binding_table(struct brw_context *brw) BRW_MAX_SURFACES * sizeof(uint32_t)); } - brw->state.dirty.brw |= BRW_NEW_GS_BINDING_TABLE; + brw->ctx.NewDriverState |= BRW_NEW_GS_BINDING_TABLE; } const struct brw_tracked_state gen6_gs_binding_table = { diff --git a/src/mesa/drivers/dri/i965/gen6_viewport_state.c b/src/mesa/drivers/dri/i965/gen6_viewport_state.c index 81546e4..d804452 100644 --- a/src/mesa/drivers/dri/i965/gen6_viewport_state.c +++ b/src/mesa/drivers/dri/i965/gen6_viewport_state.c @@ -63,7 +63,7 @@ gen6_upload_clip_vp(struct brw_context *brw) vp->ymin = -gby; vp->ymax = gby; - brw->state.dirty.brw |= BRW_NEW_CLIP_VP; + brw->ctx.NewDriverState |= BRW_NEW_CLIP_VP; } const struct brw_tracked_state gen6_clip_vp = { @@ -105,7 +105,7 @@ gen6_upload_sf_vp(struct brw_context *brw) sfv->viewport.m31 = v[MAT_TY] * y_scale + y_bias; sfv->viewport.m32 = v[MAT_TZ] * depth_scale; - brw->state.dirty.brw |= BRW_NEW_SF_VP; + brw->ctx.NewDriverState |= BRW_NEW_SF_VP; } const struct brw_tracked_state gen6_sf_vp = { diff --git a/src/mesa/drivers/dri/i965/gen7_urb.c b/src/mesa/drivers/dri/i965/gen7_urb.c index 201f42e..d371c19 100644 --- a/src/mesa/drivers/dri/i965/gen7_urb.c +++ b/src/mesa/drivers/dri/i965/gen7_urb.c @@ -94,7 +94,7 @@ gen7_allocate_push_constants(struct brw_context *brw) * Similar text exists for the other 3DSTATE_PUSH_CONSTANT_ALLOC_* * commands. */ - brw->state.dirty.brw |= BRW_NEW_PUSH_CONSTANT_ALLOCATION; + brw->ctx.NewDriverState |= BRW_NEW_PUSH_CONSTANT_ALLOCATION; } void @@ -152,7 +152,7 @@ gen7_upload_urb(struct brw_context *brw) /* If we're just switching between programs with the same URB requirements, * skip the rest of the logic. */ - if (!(brw->state.dirty.brw & BRW_NEW_CONTEXT) && + if (!(brw->ctx.NewDriverState & BRW_NEW_CONTEXT) && brw->urb.vsize == vs_size && brw->urb.gs_present == gs_present && brw->urb.gsize == gs_size) { diff --git a/src/mesa/drivers/dri/i965/gen7_vs_state.c b/src/mesa/drivers/dri/i965/gen7_vs_state.c index 0e9b4fe..278b3ec 100644 --- a/src/mesa/drivers/dri/i965/gen7_vs_state.c +++ b/src/mesa/drivers/dri/i965/gen7_vs_state.c @@ -66,7 +66,7 @@ gen7_upload_constant_state(struct brw_context *brw, * that is sent */ if (brw->gen >= 9) - brw->state.dirty.brw |= BRW_NEW_SURFACES; + brw->ctx.NewDriverState |= BRW_NEW_SURFACES; } diff --git a/src/mesa/drivers/dri/i965/gen8_misc_state.c b/src/mesa/drivers/dri/i965/gen8_misc_state.c index bd1d5cc..88e425f 100644 --- a/src/mesa/drivers/dri/i965/gen8_misc_state.c +++ b/src/mesa/drivers/dri/i965/gen8_misc_state.c @@ -69,7 +69,7 @@ static void upload_state_base_address(struct brw_context *brw) } ADVANCE_BATCH(); - brw->state.dirty.brw |= BRW_NEW_STATE_BASE_ADDRESS; + brw->ctx.NewDriverState |= BRW_NEW_STATE_BASE_ADDRESS; } const struct brw_tracked_state gen8_state_base_address = { diff --git a/src/mesa/drivers/dri/i965/intel_batchbuffer.c b/src/mesa/drivers/dri/i965/intel_batchbuffer.c index 3cf44ad..e522e4e 100644 --- a/src/mesa/drivers/dri/i965/intel_batchbuffer.c +++ b/src/mesa/drivers/dri/i965/intel_batchbuffer.c @@ -181,9 +181,9 @@ brw_new_batch(struct brw_context *brw) * purposes means everything). */ if (brw->hw_ctx == NULL) - brw->state.dirty.brw |= BRW_NEW_CONTEXT; + brw->ctx.NewDriverState |= BRW_NEW_CONTEXT; - brw->state.dirty.brw |= BRW_NEW_BATCH; + brw->ctx.NewDriverState |= BRW_NEW_BATCH; brw->state_batch_count = 0; diff --git a/src/mesa/drivers/dri/i965/intel_buffer_objects.c b/src/mesa/drivers/dri/i965/intel_buffer_objects.c index f2d2bcb..3b0a206 100644 --- a/src/mesa/drivers/dri/i965/intel_buffer_objects.c +++ b/src/mesa/drivers/dri/i965/intel_buffer_objects.c @@ -107,11 +107,11 @@ alloc_buffer_object(struct brw_context *brw, /* the buffer might be bound as a uniform buffer, need to update it */ if (intel_obj->Base.UsageHistory & USAGE_UNIFORM_BUFFER) - brw->state.dirty.brw |= BRW_NEW_UNIFORM_BUFFER; + brw->ctx.NewDriverState |= BRW_NEW_UNIFORM_BUFFER; if (intel_obj->Base.UsageHistory & USAGE_TEXTURE_BUFFER) - brw->state.dirty.brw |= BRW_NEW_TEXTURE_BUFFER; + brw->ctx.NewDriverState |= BRW_NEW_TEXTURE_BUFFER; if (intel_obj->Base.UsageHistory & USAGE_ATOMIC_COUNTER_BUFFER) - brw->state.dirty.brw |= BRW_NEW_ATOMIC_BUFFER; + brw->ctx.NewDriverState |= BRW_NEW_ATOMIC_BUFFER; mark_buffer_inactive(intel_obj); } From jljusten at kemper.freedesktop.org Tue Mar 31 23:44:35 2015 From: jljusten at kemper.freedesktop.org (Jordan Justen) Date: Tue, 31 Mar 2015 16:44:35 -0700 (PDT) Subject: Mesa (master): i965/state: Remove brw->state.dirty Message-ID: <20150331234435.8FF5D76336@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 22ccdf12dd7b5db6eb0c8f2b03c3516f8376fdad URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=22ccdf12dd7b5db6eb0c8f2b03c3516f8376fdad Author: Jordan Justen Date: Fri Mar 20 00:46:03 2015 -0700 i965/state: Remove brw->state.dirty We now use brw->NewGLState and brw->ctx.NewDriverState instead. Suggested-by: Kenneth Graunke Signed-off-by: Jordan Justen Reviewed-by: Kristian H?gsberg Reviewed-by: Kenneth Graunke --- src/mesa/drivers/dri/i965/brw_context.h | 1 - src/mesa/drivers/dri/i965/brw_state_upload.c | 6 ------ 2 files changed, 7 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h index ed250d2..6c168a3 100644 --- a/src/mesa/drivers/dri/i965/brw_context.h +++ b/src/mesa/drivers/dri/i965/brw_context.h @@ -1117,7 +1117,6 @@ struct brw_context GLuint NewGLState; struct { - struct brw_state_flags dirty; struct brw_state_flags pipelines[BRW_NUM_PIPELINES]; } state; diff --git a/src/mesa/drivers/dri/i965/brw_state_upload.c b/src/mesa/drivers/dri/i965/brw_state_upload.c index f636906..ab316bf 100644 --- a/src/mesa/drivers/dri/i965/brw_state_upload.c +++ b/src/mesa/drivers/dri/i965/brw_state_upload.c @@ -624,9 +624,7 @@ merge_ctx_state(struct brw_context *brw, struct brw_state_flags *state) { state->mesa |= brw->NewGLState; - assert(brw->state.dirty.mesa == 0); state->brw |= brw->ctx.NewDriverState; - assert(brw->state.dirty.brw == 0ull); } static inline void @@ -645,7 +643,6 @@ brw_upload_pipeline_state(struct brw_context *brw, enum brw_pipeline pipeline) { struct gl_context *ctx = &brw->ctx; - struct brw_state_flags *brw_state = &brw->state.dirty; int i; static int dirty_count = 0; struct brw_state_flags state = brw->state.pipelines[pipeline]; @@ -758,8 +755,6 @@ static inline void brw_pipeline_state_finished(struct brw_context *brw, enum brw_pipeline pipeline) { - struct brw_state_flags *state = &brw->state.dirty; - /* Save all dirty state into the other pipelines */ for (int i = 0; i < BRW_NUM_PIPELINES; i++) { if (i != pipeline) { @@ -772,7 +767,6 @@ brw_pipeline_state_finished(struct brw_context *brw, brw->NewGLState = 0; brw->ctx.NewDriverState = 0ull; - memset(state, 0, sizeof(*state)); } /** From jljusten at kemper.freedesktop.org Tue Mar 31 23:44:35 2015 From: jljusten at kemper.freedesktop.org (Jordan Justen) Date: Tue, 31 Mar 2015 16:44:35 -0700 (PDT) Subject: Mesa (master): i965/state: Rename brw_clear_dirty_bits to brw_render_state_finished Message-ID: <20150331234435.396AE76336@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 736a31d46252187a04a7b5c0119e3ba9be2418cb URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=736a31d46252187a04a7b5c0119e3ba9be2418cb Author: Jordan Justen Date: Wed Mar 18 15:43:34 2015 -0700 i965/state: Rename brw_clear_dirty_bits to brw_render_state_finished Signed-off-by: Jordan Justen Reviewed-by: Kristian H?gsberg Reviewed-by: Kenneth Graunke --- src/mesa/drivers/dri/i965/brw_draw.c | 2 +- src/mesa/drivers/dri/i965/brw_state.h | 2 +- src/mesa/drivers/dri/i965/brw_state_upload.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_draw.c b/src/mesa/drivers/dri/i965/brw_draw.c index 9b4d8e0..c573b50 100644 --- a/src/mesa/drivers/dri/i965/brw_draw.c +++ b/src/mesa/drivers/dri/i965/brw_draw.c @@ -534,7 +534,7 @@ retry: * reset the dirty bits. */ if (brw->state.dirty.brw) - brw_clear_dirty_bits(brw); + brw_render_state_finished(brw); } if (brw->always_flush_batch) diff --git a/src/mesa/drivers/dri/i965/brw_state.h b/src/mesa/drivers/dri/i965/brw_state.h index ae5ef1f..f175c29 100644 --- a/src/mesa/drivers/dri/i965/brw_state.h +++ b/src/mesa/drivers/dri/i965/brw_state.h @@ -169,7 +169,7 @@ brw_depthbuffer_format(struct brw_context *brw); * brw_state.c */ void brw_upload_render_state(struct brw_context *brw); -void brw_clear_dirty_bits(struct brw_context *brw); +void brw_render_state_finished(struct brw_context *brw); void brw_init_state(struct brw_context *brw); void brw_destroy_state(struct brw_context *brw); diff --git a/src/mesa/drivers/dri/i965/brw_state_upload.c b/src/mesa/drivers/dri/i965/brw_state_upload.c index 542600f..f0d0bac 100644 --- a/src/mesa/drivers/dri/i965/brw_state_upload.c +++ b/src/mesa/drivers/dri/i965/brw_state_upload.c @@ -693,7 +693,7 @@ void brw_upload_render_state(struct brw_context *brw) * it had before the brw_upload_render_state() call. */ void -brw_clear_dirty_bits(struct brw_context *brw) +brw_render_state_finished(struct brw_context *brw) { struct brw_state_flags *state = &brw->state.dirty; memset(state, 0, sizeof(*state)); From jljusten at kemper.freedesktop.org Tue Mar 31 23:44:35 2015 From: jljusten at kemper.freedesktop.org (Jordan Justen) Date: Tue, 31 Mar 2015 16:44:35 -0700 (PDT) Subject: Mesa (master): i965/state: Add compute pipeline with empty atom lists Message-ID: <20150331234435.67F5A76336@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 20ef23b22721961c93b73700f619179d33747554 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=20ef23b22721961c93b73700f619179d33747554 Author: Jordan Justen Date: Sun Mar 8 00:08:18 2015 -0800 i965/state: Add compute pipeline with empty atom lists Signed-off-by: Jordan Justen Reviewed-by: Kristian H?gsberg Reviewed-by: Kenneth Graunke --- src/mesa/drivers/dri/i965/brw_context.h | 2 ++ src/mesa/drivers/dri/i965/brw_state.h | 2 ++ src/mesa/drivers/dri/i965/brw_state_upload.c | 34 +++++++++++++++++++++++++- 3 files changed, 37 insertions(+), 1 deletion(-) diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h index 52b27a9..ed250d2 100644 --- a/src/mesa/drivers/dri/i965/brw_context.h +++ b/src/mesa/drivers/dri/i965/brw_context.h @@ -151,6 +151,7 @@ struct brw_wm_prog_data; enum brw_pipeline { BRW_RENDER_PIPELINE, + BRW_COMPUTE_PIPELINE, BRW_NUM_PIPELINES }; @@ -1411,6 +1412,7 @@ struct brw_context int num_atoms[BRW_NUM_PIPELINES]; const struct brw_tracked_state render_atoms[57]; + const struct brw_tracked_state compute_atoms[1]; /* If (INTEL_DEBUG & DEBUG_BATCH) */ struct { diff --git a/src/mesa/drivers/dri/i965/brw_state.h b/src/mesa/drivers/dri/i965/brw_state.h index f175c29..e428183 100644 --- a/src/mesa/drivers/dri/i965/brw_state.h +++ b/src/mesa/drivers/dri/i965/brw_state.h @@ -170,6 +170,8 @@ brw_depthbuffer_format(struct brw_context *brw); */ void brw_upload_render_state(struct brw_context *brw); void brw_render_state_finished(struct brw_context *brw); +void brw_upload_compute_state(struct brw_context *brw); +void brw_compute_state_finished(struct brw_context *brw); void brw_init_state(struct brw_context *brw); void brw_destroy_state(struct brw_context *brw); diff --git a/src/mesa/drivers/dri/i965/brw_state_upload.c b/src/mesa/drivers/dri/i965/brw_state_upload.c index f24fcc7..1e00566 100644 --- a/src/mesa/drivers/dri/i965/brw_state_upload.c +++ b/src/mesa/drivers/dri/i965/brw_state_upload.c @@ -246,6 +246,10 @@ static const struct brw_tracked_state *gen7_render_atoms[] = &haswell_cut_index, }; +static const struct brw_tracked_state *gen7_compute_atoms[] = +{ +}; + static const struct brw_tracked_state *gen8_render_atoms[] = { /* Command packets: */ @@ -322,6 +326,10 @@ static const struct brw_tracked_state *gen8_render_atoms[] = &gen8_pma_fix, }; +static const struct brw_tracked_state *gen8_compute_atoms[] = +{ +}; + static void brw_upload_initial_gpu_state(struct brw_context *brw) { @@ -359,8 +367,10 @@ brw_get_pipeline_atoms(struct brw_context *brw, switch (pipeline) { case BRW_RENDER_PIPELINE: return brw->render_atoms; + case BRW_COMPUTE_PIPELINE: + return brw->compute_atoms; default: - STATIC_ASSERT(BRW_NUM_PIPELINES == 1); + STATIC_ASSERT(BRW_NUM_PIPELINES == 2); unreachable("Unsupported pipeline"); return NULL; } @@ -397,6 +407,10 @@ void brw_init_state( struct brw_context *brw ) ARRAY_SIZE(brw->render_atoms)); STATIC_ASSERT(ARRAY_SIZE(gen8_render_atoms) <= ARRAY_SIZE(brw->render_atoms)); + STATIC_ASSERT(ARRAY_SIZE(gen7_compute_atoms) <= + ARRAY_SIZE(brw->compute_atoms)); + STATIC_ASSERT(ARRAY_SIZE(gen8_compute_atoms) <= + ARRAY_SIZE(brw->compute_atoms)); brw_init_caches(brw); @@ -404,10 +418,16 @@ void brw_init_state( struct brw_context *brw ) brw_copy_pipeline_atoms(brw, BRW_RENDER_PIPELINE, gen8_render_atoms, ARRAY_SIZE(gen8_render_atoms)); + brw_copy_pipeline_atoms(brw, BRW_COMPUTE_PIPELINE, + gen8_compute_atoms, + ARRAY_SIZE(gen8_compute_atoms)); } else if (brw->gen == 7) { brw_copy_pipeline_atoms(brw, BRW_RENDER_PIPELINE, gen7_render_atoms, ARRAY_SIZE(gen7_render_atoms)); + brw_copy_pipeline_atoms(brw, BRW_COMPUTE_PIPELINE, + gen7_compute_atoms, + ARRAY_SIZE(gen7_compute_atoms)); } else if (brw->gen == 6) { brw_copy_pipeline_atoms(brw, BRW_RENDER_PIPELINE, gen6_atoms, ARRAY_SIZE(gen6_atoms)); @@ -770,3 +790,15 @@ brw_render_state_finished(struct brw_context *brw) { brw_pipeline_state_finished(brw, BRW_RENDER_PIPELINE); } + +void +brw_upload_compute_state(struct brw_context *brw) +{ + brw_upload_pipeline_state(brw, BRW_COMPUTE_PIPELINE); +} + +void +brw_compute_state_finished(struct brw_context *brw) +{ + brw_pipeline_state_finished(brw, BRW_COMPUTE_PIPELINE); +} From jljusten at kemper.freedesktop.org Tue Mar 31 23:44:35 2015 From: jljusten at kemper.freedesktop.org (Jordan Justen) Date: Tue, 31 Mar 2015 16:44:35 -0700 (PDT) Subject: Mesa (master): i965/state: Support multiple pipelines in brw->num_atoms Message-ID: <20150331234435.4325176336@kemper.freedesktop.org> Module: Mesa Branch: master Commit: db119550725d438c928c50382a2a675b37c24a66 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=db119550725d438c928c50382a2a675b37c24a66 Author: Jordan Justen Date: Sat Mar 7 22:44:39 2015 -0800 i965/state: Support multiple pipelines in brw->num_atoms brw->num_atoms is converted to an array, but currently just an array of length 1. Adds brw_copy_pipeline_atoms which copies the atoms for a pipeline, and sets brw->num_atoms[p] for pipeline p. v2: * Rename brw->atoms[] to render_atoms * Rename brw_add_pipeline_atoms to brw_copy_pipeline_atoms * Rename brw_pipeline_first_atom to brw_get_pipeline_atoms Signed-off-by: Jordan Justen Reviewed-by: Kristian H?gsberg Reviewed-by: Kenneth Graunke --- src/mesa/drivers/dri/i965/brw_context.h | 10 ++- src/mesa/drivers/dri/i965/brw_state_upload.c | 94 ++++++++++++++++---------- 2 files changed, 65 insertions(+), 39 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h index e025011..e1481d5 100644 --- a/src/mesa/drivers/dri/i965/brw_context.h +++ b/src/mesa/drivers/dri/i965/brw_context.h @@ -149,6 +149,12 @@ struct brw_vue_prog_key; struct brw_wm_prog_key; struct brw_wm_prog_data; +enum brw_pipeline { + BRW_RENDER_PIPELINE, + + BRW_NUM_PIPELINES +}; + enum brw_cache_id { BRW_CACHE_FS_PROG, BRW_CACHE_BLORP_BLIT_PROG, @@ -1402,8 +1408,8 @@ struct brw_context int entries_per_oa_snapshot; } perfmon; - int num_atoms; - const struct brw_tracked_state atoms[57]; + int num_atoms[BRW_NUM_PIPELINES]; + const struct brw_tracked_state render_atoms[57]; /* If (INTEL_DEBUG & DEBUG_BATCH) */ struct { diff --git a/src/mesa/drivers/dri/i965/brw_state_upload.c b/src/mesa/drivers/dri/i965/brw_state_upload.c index f0d0bac..b15d8c5 100644 --- a/src/mesa/drivers/dri/i965/brw_state_upload.c +++ b/src/mesa/drivers/dri/i965/brw_state_upload.c @@ -174,7 +174,7 @@ static const struct brw_tracked_state *gen6_atoms[] = &brw_vertices, }; -static const struct brw_tracked_state *gen7_atoms[] = +static const struct brw_tracked_state *gen7_render_atoms[] = { /* Command packets: */ @@ -246,7 +246,7 @@ static const struct brw_tracked_state *gen7_atoms[] = &haswell_cut_index, }; -static const struct brw_tracked_state *gen8_atoms[] = +static const struct brw_tracked_state *gen8_render_atoms[] = { /* Command packets: */ &gen8_state_base_address, @@ -352,48 +352,68 @@ brw_upload_initial_gpu_state(struct brw_context *brw) } } +static inline const struct brw_tracked_state * +brw_get_pipeline_atoms(struct brw_context *brw, + enum brw_pipeline pipeline) +{ + switch (pipeline) { + case BRW_RENDER_PIPELINE: + return brw->render_atoms; + default: + STATIC_ASSERT(BRW_NUM_PIPELINES == 1); + unreachable("Unsupported pipeline"); + return NULL; + } +} + +static void +brw_copy_pipeline_atoms(struct brw_context *brw, + enum brw_pipeline pipeline, + const struct brw_tracked_state **atoms, + int num_atoms) +{ + /* This is to work around brw_context::atoms being declared const. We want + * it to be const, but it needs to be initialized somehow! + */ + struct brw_tracked_state *context_atoms = + (struct brw_tracked_state *) brw_get_pipeline_atoms(brw, pipeline); + + for (int i = 0; i < num_atoms; i++) { + context_atoms[i] = *atoms[i]; + assert(context_atoms[i].dirty.mesa | context_atoms[i].dirty.brw); + assert(context_atoms[i].emit); + } + + brw->num_atoms[pipeline] = num_atoms; +} + void brw_init_state( struct brw_context *brw ) { struct gl_context *ctx = &brw->ctx; - const struct brw_tracked_state **atoms; - int num_atoms; - STATIC_ASSERT(ARRAY_SIZE(gen4_atoms) <= ARRAY_SIZE(brw->atoms)); - STATIC_ASSERT(ARRAY_SIZE(gen6_atoms) <= ARRAY_SIZE(brw->atoms)); - STATIC_ASSERT(ARRAY_SIZE(gen7_atoms) <= ARRAY_SIZE(brw->atoms)); - STATIC_ASSERT(ARRAY_SIZE(gen8_atoms) <= ARRAY_SIZE(brw->atoms)); + STATIC_ASSERT(ARRAY_SIZE(gen4_atoms) <= ARRAY_SIZE(brw->render_atoms)); + STATIC_ASSERT(ARRAY_SIZE(gen6_atoms) <= ARRAY_SIZE(brw->render_atoms)); + STATIC_ASSERT(ARRAY_SIZE(gen7_render_atoms) <= + ARRAY_SIZE(brw->render_atoms)); + STATIC_ASSERT(ARRAY_SIZE(gen8_render_atoms) <= + ARRAY_SIZE(brw->render_atoms)); brw_init_caches(brw); if (brw->gen >= 8) { - atoms = gen8_atoms; - num_atoms = ARRAY_SIZE(gen8_atoms); + brw_copy_pipeline_atoms(brw, BRW_RENDER_PIPELINE, + gen8_render_atoms, + ARRAY_SIZE(gen8_render_atoms)); } else if (brw->gen == 7) { - atoms = gen7_atoms; - num_atoms = ARRAY_SIZE(gen7_atoms); + brw_copy_pipeline_atoms(brw, BRW_RENDER_PIPELINE, + gen7_render_atoms, + ARRAY_SIZE(gen7_render_atoms)); } else if (brw->gen == 6) { - atoms = gen6_atoms; - num_atoms = ARRAY_SIZE(gen6_atoms); + brw_copy_pipeline_atoms(brw, BRW_RENDER_PIPELINE, + gen6_atoms, ARRAY_SIZE(gen6_atoms)); } else { - atoms = gen4_atoms; - num_atoms = ARRAY_SIZE(gen4_atoms); - } - - brw->num_atoms = num_atoms; - - /* This is to work around brw_context::atoms being declared const. We want - * it to be const, but it needs to be initialized somehow! - */ - struct brw_tracked_state *context_atoms = - (struct brw_tracked_state *) &brw->atoms[0]; - - for (int i = 0; i < num_atoms; i++) - context_atoms[i] = *atoms[i]; - - while (num_atoms--) { - assert((*atoms)->dirty.mesa | (*atoms)->dirty.brw); - assert((*atoms)->emit); - atoms++; + brw_copy_pipeline_atoms(brw, BRW_RENDER_PIPELINE, + gen4_atoms, ARRAY_SIZE(gen4_atoms)); } brw_upload_initial_gpu_state(brw); @@ -641,8 +661,8 @@ void brw_upload_render_state(struct brw_context *brw) memset(&examined, 0, sizeof(examined)); prev = *state; - for (i = 0; i < brw->num_atoms; i++) { - const struct brw_tracked_state *atom = &brw->atoms[i]; + for (i = 0; i < brw->num_atoms[BRW_RENDER_PIPELINE]; i++) { + const struct brw_tracked_state *atom = &brw->render_atoms[i]; struct brw_state_flags generated; if (check_state(state, &atom->dirty)) { @@ -661,8 +681,8 @@ void brw_upload_render_state(struct brw_context *brw) } } else { - for (i = 0; i < brw->num_atoms; i++) { - const struct brw_tracked_state *atom = &brw->atoms[i]; + for (i = 0; i < brw->num_atoms[BRW_RENDER_PIPELINE]; i++) { + const struct brw_tracked_state *atom = &brw->render_atoms[i]; if (check_state(state, &atom->dirty)) { atom->emit(brw); From jljusten at kemper.freedesktop.org Tue Mar 31 23:44:35 2015 From: jljusten at kemper.freedesktop.org (Jordan Justen) Date: Tue, 31 Mar 2015 16:44:35 -0700 (PDT) Subject: Mesa (master): i965/state: Don't use brw->state.dirty.mesa Message-ID: <20150331234435.86FFE76336@kemper.freedesktop.org> Module: Mesa Branch: master Commit: 7ecf3530d87e88971fd77d35ac23c5383630d35b URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=7ecf3530d87e88971fd77d35ac23c5383630d35b Author: Jordan Justen Date: Thu Mar 19 22:33:16 2015 -0700 i965/state: Don't use brw->state.dirty.mesa Now, we only use brw->NewGLState. I used this bash & sed command in the i965 directory: for file in *.[ch] *.[ch]pp; do sed -i -e 's/brw->state\.dirty\.mesa/brw->NewGLState/g' $file done Followed by manual changes to brw_state_upload.c. Signed-off-by: Jordan Justen Reviewed-by: Kristian H?gsberg Reviewed-by: Kenneth Graunke --- src/mesa/drivers/dri/i965/brw_meta_fast_clear.c | 4 ++-- src/mesa/drivers/dri/i965/brw_state.h | 2 +- src/mesa/drivers/dri/i965/brw_state_cache.c | 2 +- src/mesa/drivers/dri/i965/brw_state_upload.c | 13 ++++++------- src/mesa/drivers/dri/i965/gen8_depth_state.c | 2 +- 5 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_meta_fast_clear.c b/src/mesa/drivers/dri/i965/brw_meta_fast_clear.c index d45f1e6..06916e2 100644 --- a/src/mesa/drivers/dri/i965/brw_meta_fast_clear.c +++ b/src/mesa/drivers/dri/i965/brw_meta_fast_clear.c @@ -400,7 +400,7 @@ use_rectlist(struct brw_context *brw, bool enable) * _NEW_BUFFERS to make sure we emit new SURFACE_STATE with the new fast * clear color value. */ - brw->state.dirty.mesa |= _NEW_LIGHT | _NEW_BUFFERS; + brw->NewGLState |= _NEW_LIGHT | _NEW_BUFFERS; brw->ctx.NewDriverState |= BRW_NEW_FRAGMENT_PROGRAM; } @@ -602,7 +602,7 @@ brw_meta_fast_clear(struct brw_context *brw, struct gl_framebuffer *fb, * color before resolve and sets irb->mt->fast_clear_state to UNRESOLVED if * we render to it. */ - brw->state.dirty.mesa |= _NEW_BUFFERS; + brw->NewGLState |= _NEW_BUFFERS; /* Set the custom state back to normal and dirty the same bits as above */ diff --git a/src/mesa/drivers/dri/i965/brw_state.h b/src/mesa/drivers/dri/i965/brw_state.h index bb920b2..cfa67b6 100644 --- a/src/mesa/drivers/dri/i965/brw_state.h +++ b/src/mesa/drivers/dri/i965/brw_state.h @@ -155,7 +155,7 @@ extern const struct brw_tracked_state gen8_vs_state; static inline bool brw_state_dirty(struct brw_context *brw, GLuint mesa_flags, uint64_t brw_flags) { - return ((brw->state.dirty.mesa & mesa_flags) | + return ((brw->NewGLState & mesa_flags) | (brw->ctx.NewDriverState & brw_flags)) != 0; } diff --git a/src/mesa/drivers/dri/i965/brw_state_cache.c b/src/mesa/drivers/dri/i965/brw_state_cache.c index bfe7e51..89508e4 100644 --- a/src/mesa/drivers/dri/i965/brw_state_cache.c +++ b/src/mesa/drivers/dri/i965/brw_state_cache.c @@ -399,7 +399,7 @@ brw_clear_cache(struct brw_context *brw, struct brw_cache *cache) /* We need to make sure that the programs get regenerated, since * any offsets leftover in brw_context will no longer be valid. */ - brw->state.dirty.mesa |= ~0; + brw->NewGLState |= ~0; brw->ctx.NewDriverState |= ~0ull; intel_batchbuffer_flush(brw); } diff --git a/src/mesa/drivers/dri/i965/brw_state_upload.c b/src/mesa/drivers/dri/i965/brw_state_upload.c index 255e892..f636906 100644 --- a/src/mesa/drivers/dri/i965/brw_state_upload.c +++ b/src/mesa/drivers/dri/i965/brw_state_upload.c @@ -438,7 +438,7 @@ void brw_init_state( struct brw_context *brw ) brw_upload_initial_gpu_state(brw); - brw->state.dirty.mesa = ~0; + brw->NewGLState = ~0; brw->ctx.NewDriverState = ~0ull; /* ~0 is a nonsensical value which won't match anything we program, so @@ -623,7 +623,8 @@ static inline void merge_ctx_state(struct brw_context *brw, struct brw_state_flags *state) { - state->mesa |= brw->state.dirty.mesa; + state->mesa |= brw->NewGLState; + assert(brw->state.dirty.mesa == 0); state->brw |= brw->ctx.NewDriverState; assert(brw->state.dirty.brw == 0ull); } @@ -649,12 +650,9 @@ brw_upload_pipeline_state(struct brw_context *brw, static int dirty_count = 0; struct brw_state_flags state = brw->state.pipelines[pipeline]; - brw_state->mesa |= brw->NewGLState; - brw->NewGLState = 0; - if (0) { /* Always re-emit all state. */ - brw_state->mesa |= ~0; + brw->NewGLState = ~0; ctx->NewDriverState = ~0ull; } @@ -765,13 +763,14 @@ brw_pipeline_state_finished(struct brw_context *brw, /* Save all dirty state into the other pipelines */ for (int i = 0; i < BRW_NUM_PIPELINES; i++) { if (i != pipeline) { - brw->state.pipelines[i].mesa |= state->mesa; + brw->state.pipelines[i].mesa |= brw->NewGLState; brw->state.pipelines[i].brw |= brw->ctx.NewDriverState; } else { memset(&brw->state.pipelines[i], 0, sizeof(struct brw_state_flags)); } } + brw->NewGLState = 0; brw->ctx.NewDriverState = 0ull; memset(state, 0, sizeof(*state)); } diff --git a/src/mesa/drivers/dri/i965/gen8_depth_state.c b/src/mesa/drivers/dri/i965/gen8_depth_state.c index 3d126cf..b502650 100644 --- a/src/mesa/drivers/dri/i965/gen8_depth_state.c +++ b/src/mesa/drivers/dri/i965/gen8_depth_state.c @@ -509,5 +509,5 @@ gen8_hiz_exec(struct brw_context *brw, struct intel_mipmap_tree *mt, * * Setting _NEW_DEPTH and _NEW_BUFFERS covers it, but is rather overkill. */ - brw->state.dirty.mesa |= _NEW_DEPTH | _NEW_BUFFERS; + brw->NewGLState |= _NEW_DEPTH | _NEW_BUFFERS; }