[Mesa-dev] [PATCH 5/8] radeonsi: add driver support for layered rendering and AMD_vertex_shader_layer

2013-11-24 Thread Marek Olšák
From: Marek Olšák marek.ol...@amd.com

---
 src/gallium/drivers/radeonsi/radeonsi_shader.c | 14 +-
 src/gallium/drivers/radeonsi/radeonsi_shader.h |  1 +
 src/gallium/drivers/radeonsi/si_state.c| 23 ---
 src/gallium/drivers/radeonsi/si_state_draw.c   |  1 +
 4 files changed, 27 insertions(+), 12 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/radeonsi_shader.c 
b/src/gallium/drivers/radeonsi/radeonsi_shader.c
index ebe9125..96cc1aa 100644
--- a/src/gallium/drivers/radeonsi/radeonsi_shader.c
+++ b/src/gallium/drivers/radeonsi/radeonsi_shader.c
@@ -890,6 +890,7 @@ static void si_llvm_emit_epilogue(struct 
lp_build_tgsi_context * bld_base)
unsigned semantic_name;
unsigned param_count = 0;
int depth_index = -1, stencil_index = -1, psize_index = -1, 
edgeflag_index = -1;
+   int layer_index = -1;
int i;
 
if (si_shader_ctx-shader-selector-so.num_outputs) {
@@ -949,6 +950,11 @@ handle_semantic:
shader-vs_out_edgeflag = true;
edgeflag_index = index;
continue;
+   case TGSI_SEMANTIC_LAYER:
+   shader-vs_out_misc_write = true;
+   shader-vs_out_layer = true;
+   layer_index = index;
+   continue;
case TGSI_SEMANTIC_POSITION:
if (si_shader_ctx-type == 
TGSI_PROCESSOR_VERTEX) {
target = V_008DFC_SQ_EXP_POS;
@@ -1100,7 +1106,8 @@ handle_semantic:
if (shader-vs_out_misc_write) {
pos_args[1][0] = lp_build_const_int32(base-gallivm, /* 
writemask */
  
shader-vs_out_point_size |
- 
(shader-vs_out_edgeflag  1));
+ 
(shader-vs_out_edgeflag  1) |
+ 
(shader-vs_out_layer  2));
pos_args[1][1] = uint-zero; /* EXEC mask */
pos_args[1][2] = uint-zero; /* last export? */
pos_args[1][3] = lp_build_const_int32(base-gallivm, 
V_008DFC_SQ_EXP_POS + 1);
@@ -1130,6 +1137,11 @@ handle_semantic:
pos_args[1][6] = 
LLVMBuildBitCast(base-gallivm-builder, output,
  
base-elem_type, );
}
+
+   if (shader-vs_out_layer) {
+   pos_args[1][7] = 
LLVMBuildLoad(base-gallivm-builder,
+   
si_shader_ctx-radeon_bld.soa.outputs[layer_index][0], );
+   }
}
 
for (i = 0; i  4; i++)
diff --git a/src/gallium/drivers/radeonsi/radeonsi_shader.h 
b/src/gallium/drivers/radeonsi/radeonsi_shader.h
index 5432a87..174035d 100644
--- a/src/gallium/drivers/radeonsi/radeonsi_shader.h
+++ b/src/gallium/drivers/radeonsi/radeonsi_shader.h
@@ -114,6 +114,7 @@ struct si_shader {
boolvs_out_misc_write;
boolvs_out_point_size;
boolvs_out_edgeflag;
+   boolvs_out_layer;
unsignednr_cbufs;
unsignednr_pos_exports;
unsignedclip_dist_write;
diff --git a/src/gallium/drivers/radeonsi/si_state.c 
b/src/gallium/drivers/radeonsi/si_state.c
index fd5d2c6..7bae72a 100644
--- a/src/gallium/drivers/radeonsi/si_state.c
+++ b/src/gallium/drivers/radeonsi/si_state.c
@@ -1571,7 +1571,7 @@ static void si_cb(struct r600_context *rctx, struct 
si_pm4_state *pm4,
struct r600_surface *surf;
unsigned level = state-cbufs[cb]-u.tex.level;
unsigned pitch, slice;
-   unsigned color_info, color_attrib, color_pitch;
+   unsigned color_info, color_attrib, color_pitch, color_view;
unsigned tile_mode_index;
unsigned format, swap, ntype, endian;
uint64_t offset;
@@ -1584,10 +1584,19 @@ static void si_cb(struct r600_context *rctx, struct 
si_pm4_state *pm4,
rtex = (struct r600_texture*)state-cbufs[cb]-texture;
 
offset = rtex-surface.level[level].offset;
-   if (rtex-surface.level[level].mode  RADEON_SURF_MODE_1D) {
+
+   /* Layered rendering doesn't work with LINEAR_GENERAL.
+* (LINEAR_ALIGNED and others work) */
+   if (rtex-surface.level[level].mode == RADEON_SURF_MODE_LINEAR) {
+   assert(state-cbufs[cb]-u.tex.first_layer == 
state-cbufs[cb]-u.tex.last_layer);
offset += rtex-surface.level[level].slice_size *
  state-cbufs[cb]-u.tex.first_layer;
+   color_view = 0;
+   

[Mesa-dev] [PATCH 6/8] gallium: add support for AMD_vertex_shader_layer

2013-11-24 Thread Marek Olšák
From: Marek Olšák marek.ol...@amd.com

---
 src/gallium/docs/source/screen.rst   | 2 ++
 src/gallium/drivers/freedreno/freedreno_screen.c | 1 +
 src/gallium/drivers/i915/i915_screen.c   | 1 +
 src/gallium/drivers/ilo/ilo_screen.c | 2 ++
 src/gallium/drivers/llvmpipe/lp_screen.c | 2 ++
 src/gallium/drivers/nouveau/nv30/nv30_screen.c   | 1 +
 src/gallium/drivers/nouveau/nv50/nv50_screen.c   | 2 ++
 src/gallium/drivers/nouveau/nvc0/nvc0_screen.c   | 2 ++
 src/gallium/drivers/r300/r300_screen.c   | 1 +
 src/gallium/drivers/r600/r600_pipe.c | 1 +
 src/gallium/drivers/radeonsi/radeonsi_pipe.c | 1 +
 src/gallium/drivers/softpipe/sp_screen.c | 2 ++
 src/gallium/drivers/svga/svga_screen.c   | 1 +
 src/gallium/include/pipe/p_defines.h | 3 ++-
 src/mesa/state_tracker/st_extensions.c   | 7 +++
 src/mesa/state_tracker/st_program.c  | 4 
 16 files changed, 32 insertions(+), 1 deletion(-)

diff --git a/src/gallium/docs/source/screen.rst 
b/src/gallium/docs/source/screen.rst
index a01f548..5120b2c 100644
--- a/src/gallium/docs/source/screen.rst
+++ b/src/gallium/docs/source/screen.rst
@@ -176,6 +176,8 @@ The integer capabilities:
 * ``PIPE_CAP_MIXED_FRAMEBUFFER_SIZES``: Whether it is allowed to have
   different sizes for fb color/zs attachments. This controls whether
   ARB_framebuffer_object is provided.
+* ``PIPE_CAP_TGSI_VS_LAYER``: Whether TGSI_SEMANTIC_LAYER is supported
+  as a vertex shader output.
 
 
 .. _pipe_capf:
diff --git a/src/gallium/drivers/freedreno/freedreno_screen.c 
b/src/gallium/drivers/freedreno/freedreno_screen.c
index 20adf21..574d25a 100644
--- a/src/gallium/drivers/freedreno/freedreno_screen.c
+++ b/src/gallium/drivers/freedreno/freedreno_screen.c
@@ -197,6 +197,7 @@ fd_screen_get_param(struct pipe_screen *pscreen, enum 
pipe_cap param)
case PIPE_CAP_USER_INDEX_BUFFERS:
case PIPE_CAP_QUERY_PIPELINE_STATISTICS:
case PIPE_CAP_TEXTURE_BORDER_COLOR_QUIRK:
+case PIPE_CAP_TGSI_VS_LAYER:
return 0;
 
/* Stream output. */
diff --git a/src/gallium/drivers/i915/i915_screen.c 
b/src/gallium/drivers/i915/i915_screen.c
index 77607d0..3469068 100644
--- a/src/gallium/drivers/i915/i915_screen.c
+++ b/src/gallium/drivers/i915/i915_screen.c
@@ -220,6 +220,7 @@ i915_get_param(struct pipe_screen *screen, enum pipe_cap 
cap)
case PIPE_CAP_VERTEX_BUFFER_OFFSET_4BYTE_ALIGNED_ONLY:
case PIPE_CAP_VERTEX_BUFFER_STRIDE_4BYTE_ALIGNED_ONLY:
case PIPE_CAP_VERTEX_ELEMENT_SRC_OFFSET_4BYTE_ALIGNED_ONLY:
+   case PIPE_CAP_TGSI_VS_LAYER:
return 0;
 
case PIPE_CAP_GLSL_FEATURE_LEVEL:
diff --git a/src/gallium/drivers/ilo/ilo_screen.c 
b/src/gallium/drivers/ilo/ilo_screen.c
index a345b70..1f52df2 100644
--- a/src/gallium/drivers/ilo/ilo_screen.c
+++ b/src/gallium/drivers/ilo/ilo_screen.c
@@ -429,6 +429,8 @@ ilo_get_param(struct pipe_screen *screen, enum pipe_cap 
param)
   return PIPE_ENDIAN_LITTLE;
case PIPE_CAP_MIXED_FRAMEBUFFER_SIZES:
   return true;
+   case PIPE_CAP_TGSI_VS_LAYER:
+  return 0;
 
default:
   return 0;
diff --git a/src/gallium/drivers/llvmpipe/lp_screen.c 
b/src/gallium/drivers/llvmpipe/lp_screen.c
index f61df98..970b506 100644
--- a/src/gallium/drivers/llvmpipe/lp_screen.c
+++ b/src/gallium/drivers/llvmpipe/lp_screen.c
@@ -234,6 +234,8 @@ llvmpipe_get_param(struct pipe_screen *screen, enum 
pipe_cap param)
   return PIPE_MAX_VIEWPORTS;
case PIPE_CAP_ENDIANNESS:
   return PIPE_ENDIAN_NATIVE;
+   case PIPE_CAP_TGSI_VS_LAYER:
+  return 0;
}
/* should only get here on unhandled cases */
debug_printf(Unexpected PIPE_CAP %d query\n, param);
diff --git a/src/gallium/drivers/nouveau/nv30/nv30_screen.c 
b/src/gallium/drivers/nouveau/nv30/nv30_screen.c
index 807100e..fd214b9 100644
--- a/src/gallium/drivers/nouveau/nv30/nv30_screen.c
+++ b/src/gallium/drivers/nouveau/nv30/nv30_screen.c
@@ -126,6 +126,7 @@ nv30_screen_get_param(struct pipe_screen *pscreen, enum 
pipe_cap param)
case PIPE_CAP_TEXTURE_BORDER_COLOR_QUIRK:
case PIPE_CAP_MAX_TEXTURE_BUFFER_SIZE:
case PIPE_CAP_MIXED_FRAMEBUFFER_SIZES:
+   case PIPE_CAP_TGSI_VS_LAYER:
   return 0;
case PIPE_CAP_VERTEX_BUFFER_OFFSET_4BYTE_ALIGNED_ONLY:
case PIPE_CAP_VERTEX_BUFFER_STRIDE_4BYTE_ALIGNED_ONLY:
diff --git a/src/gallium/drivers/nouveau/nv50/nv50_screen.c 
b/src/gallium/drivers/nouveau/nv50/nv50_screen.c
index 0ce9e34..4ae0ee4 100644
--- a/src/gallium/drivers/nouveau/nv50/nv50_screen.c
+++ b/src/gallium/drivers/nouveau/nv50/nv50_screen.c
@@ -194,6 +194,8 @@ nv50_screen_get_param(struct pipe_screen *pscreen, enum 
pipe_cap param)
   return PIPE_QUIRK_TEXTURE_BORDER_COLOR_SWIZZLE_NV50;
case PIPE_CAP_ENDIANNESS:
   return PIPE_ENDIAN_LITTLE;
+   case PIPE_CAP_TGSI_VS_LAYER:
+  return 0;
default:
   NOUVEAU_ERR(unknown PIPE_CAP %d\n, param);
   return 0;
diff --git 

[Mesa-dev] [PATCH 7/8] gallium/util: implement layered framebuffer clear in u_blitter

2013-11-24 Thread Marek Olšák
From: Marek Olšák marek.ol...@amd.com

All bound layers (from first_layer to last_layer) should be cleared.

This uses a vertex shader which outputs gl_Layer = gl_InstanceID, so each
instance goes to a different layer. By rendering a quad and setting
the instance count to the number of layers, it will trivially clear all
layers.

This requires AMD_vertex_shader_layer (or PIPE_CAP_TGSI_VS_LAYER), which only
radeonsi supports at the moment. r600 could do this too. Standard DX11
hardware will have to use a geometry shader though, which has higher overhead.
---
 src/gallium/auxiliary/util/u_blitter.c| 72 ++-
 src/gallium/auxiliary/util/u_blitter.h|  2 +-
 src/gallium/auxiliary/util/u_framebuffer.c| 24 +
 src/gallium/auxiliary/util/u_framebuffer.h|  5 ++
 src/gallium/auxiliary/util/u_simple_shaders.c | 26 ++
 src/gallium/auxiliary/util/u_simple_shaders.h |  2 +
 src/gallium/drivers/ilo/ilo_blitter_pipe.c|  2 +-
 src/gallium/drivers/r300/r300_blit.c  |  4 +-
 src/gallium/drivers/r600/r600_blit.c  |  2 +-
 src/gallium/drivers/radeonsi/r600_blit.c  |  1 +
 10 files changed, 110 insertions(+), 30 deletions(-)

diff --git a/src/gallium/auxiliary/util/u_blitter.c 
b/src/gallium/auxiliary/util/u_blitter.c
index b95cbab..bb1920a 100644
--- a/src/gallium/auxiliary/util/u_blitter.c
+++ b/src/gallium/auxiliary/util/u_blitter.c
@@ -65,6 +65,7 @@ struct blitter_context_priv
/* Vertex shaders. */
void *vs; /** Vertex shader which passes {pos, generic} to the output.*/
void *vs_pos_only; /** Vertex shader which passes pos to the output.*/
+   void *vs_layered; /** Vertex shader which sets LAYER = INSTANCEID. */
 
/* Fragment shaders. */
void *fs_empty;
@@ -295,6 +296,7 @@ struct blitter_context *util_blitter_create(struct 
pipe_context *pipe)
  util_make_vertex_passthrough_shader(pipe, 2, semantic_names,
  semantic_indices);
}
+
if (ctx-has_stream_out) {
   struct pipe_stream_output_info so;
   const uint semantic_names[] = { TGSI_SEMANTIC_POSITION };
@@ -310,6 +312,11 @@ struct blitter_context *util_blitter_create(struct 
pipe_context *pipe)
  semantic_indices, so);
}
 
+   if (pipe-screen-get_param(pipe-screen, PIPE_CAP_TGSI_INSTANCEID) 
+   pipe-screen-get_param(pipe-screen, PIPE_CAP_TGSI_VS_LAYER)) {
+  ctx-vs_layered = util_make_layered_clear_vertex_shader(pipe);
+   }
+
/* set invariant vertex coordinates */
for (i = 0; i  4; i++)
   ctx-vertices[i][0][3] = 1; /*v.w*/
@@ -901,13 +908,14 @@ void util_blitter_cache_all_shaders(struct 
blitter_context *blitter)
 }
 
 static void blitter_set_common_draw_rect_state(struct blitter_context_priv 
*ctx,
-   boolean scissor)
+   boolean scissor,
+   boolean vs_layered)
 {
struct pipe_context *pipe = ctx-base.pipe;
 
pipe-bind_rasterizer_state(pipe, scissor ? ctx-rs_state_scissor
  : ctx-rs_state);
-   pipe-bind_vs_state(pipe, ctx-vs);
+   pipe-bind_vs_state(pipe, vs_layered ? ctx-vs_layered : ctx-vs);
if (ctx-has_geometry_shader)
   pipe-bind_gs_state(pipe, NULL);
if (ctx-has_stream_out)
@@ -915,19 +923,24 @@ static void blitter_set_common_draw_rect_state(struct 
blitter_context_priv *ctx,
 }
 
 static void blitter_draw(struct blitter_context_priv *ctx,
- int x1, int y1, int x2, int y2, float depth)
+ int x1, int y1, int x2, int y2, float depth,
+ unsigned num_instances)
 {
-   struct pipe_resource *buf = NULL;
-   unsigned offset = 0;
+   struct pipe_context *pipe = ctx-base.pipe;
+   struct pipe_vertex_buffer vb = {0};
 
blitter_set_rectangle(ctx, x1, y1, x2, y2, depth);
 
+   vb.stride = 8 * sizeof(float);
+
u_upload_data(ctx-upload, 0, sizeof(ctx-vertices), ctx-vertices,
- offset, buf);
+ vb.buffer_offset, vb.buffer);
u_upload_unmap(ctx-upload);
-   util_draw_vertex_buffer(ctx-base.pipe, NULL, buf, ctx-base.vb_slot,
-   offset, PIPE_PRIM_TRIANGLE_FAN, 4, 2);
-   pipe_resource_reference(buf, NULL);
+
+   pipe-set_vertex_buffers(pipe, ctx-base.vb_slot, 1, vb);
+   util_draw_arrays_instanced(pipe, PIPE_PRIM_TRIANGLE_FAN, 0, 4,
+  0, num_instances);
+   pipe_resource_reference(vb.buffer, NULL);
 }
 
 void util_blitter_draw_rectangle(struct blitter_context *blitter,
@@ -949,11 +962,12 @@ void util_blitter_draw_rectangle(struct blitter_context 
*blitter,
   default:;
}
 
-   blitter_draw(ctx, x1, y1, x2, y2, depth);
+   blitter_draw(ctx, x1, y1, x2, y2, depth, 1);
 }
 
 static void util_blitter_clear_custom(struct blitter_context *blitter,
  

[Mesa-dev] [PATCH 1/8] mesa: expose AMD_vertex_shader_layer in the core profile only

2013-11-24 Thread Marek Olšák
From: Marek Olšák marek.ol...@amd.com

It needs glFramebufferTexture, which isn't available in the compatibility
profile.
---
 src/mesa/main/extensions.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c
index 104618c..f7e7e4d 100644
--- a/src/mesa/main/extensions.c
+++ b/src/mesa/main/extensions.c
@@ -300,7 +300,7 @@ static const struct extension extension_table[] = {
{ GL_AMD_performance_monitor, o(AMD_performance_monitor), 
GL, 2007 },
{ GL_AMD_seamless_cubemap_per_texture,
o(AMD_seamless_cubemap_per_texture),GL, 2009 },
{ GL_AMD_shader_stencil_export,   
o(ARB_shader_stencil_export),   GL, 2009 },
-   { GL_AMD_vertex_shader_layer, o(AMD_vertex_shader_layer), 
GL, 2012 },
+   { GL_AMD_vertex_shader_layer, o(AMD_vertex_shader_layer), 
GLC,2012 },
{ GL_APPLE_object_purgeable,  o(APPLE_object_purgeable),  
GL, 2006 },
{ GL_APPLE_packed_pixels, o(dummy_true),  
GLL,2002 },
{ GL_APPLE_texture_max_level, o(dummy_true),  
 ES1 | ES2, 2009 },
-- 
1.8.3.2

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 2/8] st/mesa: allow GLSL 1.50 and 3.30 to be exposed

2013-11-24 Thread Marek Olšák
From: Marek Olšák marek.ol...@amd.com

---
 src/mesa/state_tracker/st_extensions.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/mesa/state_tracker/st_extensions.c 
b/src/mesa/state_tracker/st_extensions.c
index e8d0902..28171d9 100644
--- a/src/mesa/state_tracker/st_extensions.c
+++ b/src/mesa/state_tracker/st_extensions.c
@@ -594,7 +594,11 @@ void st_init_extensions(struct st_context *st)
/* Figure out GLSL support. */
glsl_feature_level = screen-get_param(screen, PIPE_CAP_GLSL_FEATURE_LEVEL);
 
-   if (glsl_feature_level = 140) {
+   if (glsl_feature_level = 330) {
+  ctx-Const.GLSLVersion = 330;
+   } else if (glsl_feature_level = 150) {
+  ctx-Const.GLSLVersion = 150;
+   } else if (glsl_feature_level = 140) {
   ctx-Const.GLSLVersion = 140;
} else if (glsl_feature_level = 130) {
   ctx-Const.GLSLVersion = 130;
-- 
1.8.3.2

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 4/8] radeonsi: implement OpenGL edge flags

2013-11-24 Thread Marek Olšák
From: Marek Olšák marek.ol...@amd.com

---
 src/gallium/drivers/radeonsi/radeonsi_shader.c | 52 +++---
 src/gallium/drivers/radeonsi/radeonsi_shader.h |  1 +
 src/gallium/drivers/radeonsi/si_state_draw.c   |  1 +
 3 files changed, 48 insertions(+), 6 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/radeonsi_shader.c 
b/src/gallium/drivers/radeonsi/radeonsi_shader.c
index 61e619a..ebe9125 100644
--- a/src/gallium/drivers/radeonsi/radeonsi_shader.c
+++ b/src/gallium/drivers/radeonsi/radeonsi_shader.c
@@ -889,7 +889,7 @@ static void si_llvm_emit_epilogue(struct 
lp_build_tgsi_context * bld_base)
LLVMValueRef pos_args[4][9] = { { 0 } };
unsigned semantic_name;
unsigned param_count = 0;
-   int depth_index = -1, stencil_index = -1;
+   int depth_index = -1, stencil_index = -1, psize_index = -1, 
edgeflag_index = -1;
int i;
 
if (si_shader_ctx-shader-selector-so.num_outputs) {
@@ -940,10 +940,15 @@ handle_semantic:
/* Select the correct target */
switch(semantic_name) {
case TGSI_SEMANTIC_PSIZE:
-   shader-vs_out_misc_write = 1;
-   shader-vs_out_point_size = 1;
-   target = V_008DFC_SQ_EXP_POS + 1;
-   break;
+   shader-vs_out_misc_write = true;
+   shader-vs_out_point_size = true;
+   psize_index = index;
+   continue;
+   case TGSI_SEMANTIC_EDGEFLAG:
+   shader-vs_out_misc_write = true;
+   shader-vs_out_edgeflag = true;
+   edgeflag_index = index;
+   continue;
case TGSI_SEMANTIC_POSITION:
if (si_shader_ctx-type == 
TGSI_PROCESSOR_VERTEX) {
target = V_008DFC_SQ_EXP_POS;
@@ -1018,7 +1023,6 @@ handle_semantic:
   
LLVMVoidTypeInContext(base-gallivm-context),
   args, 9);
}
-
}
 
if (semantic_name == TGSI_SEMANTIC_CLIPDIST) {
@@ -1092,6 +1096,42 @@ handle_semantic:
pos_args[0][8] = base-one;  /* W */
}
 
+   /* Write the misc vector (point size, edgeflag, layer, 
viewport). */
+   if (shader-vs_out_misc_write) {
+   pos_args[1][0] = lp_build_const_int32(base-gallivm, /* 
writemask */
+ 
shader-vs_out_point_size |
+ 
(shader-vs_out_edgeflag  1));
+   pos_args[1][1] = uint-zero; /* EXEC mask */
+   pos_args[1][2] = uint-zero; /* last export? */
+   pos_args[1][3] = lp_build_const_int32(base-gallivm, 
V_008DFC_SQ_EXP_POS + 1);
+   pos_args[1][4] = uint-zero; /* COMPR flag */
+   pos_args[1][5] = base-zero; /* X */
+   pos_args[1][6] = base-zero; /* Y */
+   pos_args[1][7] = base-zero; /* Z */
+   pos_args[1][8] = base-zero; /* W */
+
+   if (shader-vs_out_point_size) {
+   pos_args[1][5] = 
LLVMBuildLoad(base-gallivm-builder,
+   
si_shader_ctx-radeon_bld.soa.outputs[psize_index][0], );
+   }
+
+   if (shader-vs_out_edgeflag) {
+   LLVMValueRef output = 
LLVMBuildLoad(base-gallivm-builder,
+   
si_shader_ctx-radeon_bld.soa.outputs[edgeflag_index][0], );
+
+   /* The output is a float, but the hw expects an 
integer
+* with the first bit containing the edge flag. 
*/
+   output = 
LLVMBuildFPToUI(base-gallivm-builder, output,
+
bld_base-uint_bld.elem_type, );
+
+   output = lp_build_min(bld_base-int_bld, 
output, bld_base-int_bld.one);
+
+   /* The LLVM intrinsic expects a float. */
+   pos_args[1][6] = 
LLVMBuildBitCast(base-gallivm-builder, output,
+ 
base-elem_type, );
+   }
+   }
+
for (i = 0; i  4; i++)
if (pos_args[i][0])
shader-nr_pos_exports++;
diff --git a/src/gallium/drivers/radeonsi/radeonsi_shader.h 

[Mesa-dev] [PATCH 3/8] st/mesa: add support for layered framebuffers and consolidate code

2013-11-24 Thread Marek Olšák
From: Marek Olšák marek.ol...@amd.com

This is a subset of geometry shaders. It's all about setting first_layer and
last_layer correctly.

Also some code between st_render_texture and update_framebuffer_state is
consolidated. It doesn't use rtt_level and derives the level from dimensions
instead as the code in st_atom_framebuffer.c did.
---
 src/mesa/state_tracker/st_atom_framebuffer.c | 58 ++---
 src/mesa/state_tracker/st_cb_drawpixels.c| 19 +++---
 src/mesa/state_tracker/st_cb_fbo.c   | 97 +---
 src/mesa/state_tracker/st_cb_fbo.h   | 10 ++-
 src/mesa/state_tracker/st_cb_readpixels.c|  4 +-
 src/mesa/state_tracker/st_cb_texture.c   |  4 +-
 6 files changed, 99 insertions(+), 93 deletions(-)

diff --git a/src/mesa/state_tracker/st_atom_framebuffer.c 
b/src/mesa/state_tracker/st_atom_framebuffer.c
index c752640..51f079c 100644
--- a/src/mesa/state_tracker/st_atom_framebuffer.c
+++ b/src/mesa/state_tracker/st_atom_framebuffer.c
@@ -44,56 +44,6 @@
 
 
 /**
- * When doing GL render to texture, we have to be sure that finalize_texture()
- * didn't yank out the pipe_resource that we earlier created a surface for.
- * Check for that here and create a new surface if needed.
- */
-static void
-update_renderbuffer_surface(struct st_context *st,
-struct st_renderbuffer *strb)
-{
-   struct pipe_context *pipe = st-pipe;
-   struct pipe_resource *resource = strb-rtt ? strb-rtt-pt : strb-texture;
-   int rtt_width = strb-Base.Width;
-   int rtt_height = strb-Base.Height;
-   enum pipe_format format = st-ctx-Color.sRGBEnabled ? resource-format : 
util_format_linear(resource-format);
-
-   if (!strb-surface ||
-   strb-surface-texture-nr_samples != strb-Base.NumSamples ||
-   strb-surface-format != format ||
-   strb-surface-texture != resource ||
-   strb-surface-width != rtt_width ||
-   strb-surface-height != rtt_height) {
-  GLuint level;
-  /* find matching mipmap level size */
-  for (level = 0; level = resource-last_level; level++) {
- if (u_minify(resource-width0, level) == rtt_width 
- u_minify(resource-height0, level) == rtt_height) {
-struct pipe_surface surf_tmpl;
-memset(surf_tmpl, 0, sizeof(surf_tmpl));
-surf_tmpl.format = format;
-surf_tmpl.u.tex.level = level;
-surf_tmpl.u.tex.first_layer = strb-rtt_face + strb-rtt_slice;
-surf_tmpl.u.tex.last_layer = strb-rtt_face + strb-rtt_slice;
-
-pipe_surface_reference(strb-surface, NULL);
-
-strb-surface = pipe-create_surface(pipe,
- resource,
- surf_tmpl);
-#if 0
-printf(-- alloc new surface %d x %d into tex %p\n,
-   strb-surface-width, strb-surface-height,
-   texture);
-#endif
-break;
- }
-  }
-   }
-}
-
-
-/**
  * Update framebuffer state (color, depth, stencil, etc. buffers)
  */
 static void
@@ -121,10 +71,10 @@ update_framebuffer_state( struct st_context *st )
 
   if (strb) {
  /*printf(- framebuffer surface rtt %p\n, strb-rtt);*/
- if (strb-rtt ||
+ if (strb-is_rtt ||
  (strb-texture  util_format_is_srgb(strb-texture-format))) {
 /* rendering to a GL texture, may have to update surface */
-update_renderbuffer_surface(st, strb);
+st_update_renderbuffer_surface(st, strb);
  }
 
  if (strb-surface) {
@@ -144,9 +94,9 @@ update_framebuffer_state( struct st_context *st )
 */
strb = st_renderbuffer(fb-Attachment[BUFFER_DEPTH].Renderbuffer);
if (strb) {
-  if (strb-rtt) {
+  if (strb-is_rtt) {
  /* rendering to a GL texture, may have to update surface */
- update_renderbuffer_surface(st, strb);
+ st_update_renderbuffer_surface(st, strb);
   }
   pipe_surface_reference(framebuffer-zsbuf, strb-surface);
}
diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c 
b/src/mesa/state_tracker/st_cb_drawpixels.c
index 2ce4728..3058dfb 100644
--- a/src/mesa/state_tracker/st_cb_drawpixels.c
+++ b/src/mesa/state_tracker/st_cb_drawpixels.c
@@ -878,7 +878,8 @@ draw_stencil_pixels(struct gl_context *ctx, GLint x, GLint 
y,
}
 
stmap = pipe_transfer_map(pipe, strb-texture,
- strb-rtt_level, strb-rtt_face + strb-rtt_slice,
+ strb-surface-u.tex.level,
+ strb-surface-u.tex.first_layer,
  usage, x, y,
  width, height, pt);
 
@@ -1263,8 +1264,8 @@ copy_stencil_pixels(struct gl_context *ctx, GLint srcx, 
GLint srcy,
/* map the stencil buffer */
drawMap = pipe_transfer_map(pipe,
rbDraw-texture,
-   rbDraw-rtt_level,
-  

[Mesa-dev] [PATCH 8/8] st/mesa: implement layered framebuffer clear for the clear_with_quad fallback

2013-11-24 Thread Marek Olšák
From: Marek Olšák marek.ol...@amd.com

Same approach as in u_blitter.
---
 src/gallium/auxiliary/cso_cache/cso_context.c | 20 +
 src/gallium/auxiliary/cso_cache/cso_context.h |  5 +++
 src/mesa/state_tracker/st_cb_clear.c  | 58 +++
 src/mesa/state_tracker/st_context.h   |  1 +
 4 files changed, 68 insertions(+), 16 deletions(-)

diff --git a/src/gallium/auxiliary/cso_cache/cso_context.c 
b/src/gallium/auxiliary/cso_cache/cso_context.c
index 23d3245..0db0c3e 100644
--- a/src/gallium/auxiliary/cso_cache/cso_context.c
+++ b/src/gallium/auxiliary/cso_cache/cso_context.c
@@ -1411,3 +1411,23 @@ cso_draw_arrays(struct cso_context *cso, uint mode, uint 
start, uint count)
 
cso_draw_vbo(cso, info);
 }
+
+void
+cso_draw_arrays_instanced(struct cso_context *cso, uint mode,
+  uint start, uint count,
+  uint start_instance, uint instance_count)
+{
+   struct pipe_draw_info info;
+
+   util_draw_init_info(info);
+
+   info.mode = mode;
+   info.start = start;
+   info.count = count;
+   info.min_index = start;
+   info.max_index = start + count - 1;
+   info.start_instance = start_instance;
+   info.instance_count = instance_count;
+
+   cso_draw_vbo(cso, info);
+}
diff --git a/src/gallium/auxiliary/cso_cache/cso_context.h 
b/src/gallium/auxiliary/cso_cache/cso_context.h
index 82c8e18..4b433b1 100644
--- a/src/gallium/auxiliary/cso_cache/cso_context.h
+++ b/src/gallium/auxiliary/cso_cache/cso_context.h
@@ -228,6 +228,11 @@ void
 cso_draw_vbo(struct cso_context *cso,
  const struct pipe_draw_info *info);
 
+void
+cso_draw_arrays_instanced(struct cso_context *cso, uint mode,
+  uint start, uint count,
+  uint start_instance, uint instance_count);
+
 /* helper drawing function */
 void
 cso_draw_arrays(struct cso_context *cso, uint mode, uint start, uint count);
diff --git a/src/mesa/state_tracker/st_cb_clear.c 
b/src/mesa/state_tracker/st_cb_clear.c
index 8da664a..274cc47 100644
--- a/src/mesa/state_tracker/st_cb_clear.c
+++ b/src/mesa/state_tracker/st_cb_clear.c
@@ -51,6 +51,7 @@
 #include pipe/p_state.h
 #include pipe/p_defines.h
 #include util/u_format.h
+#include util/u_framebuffer.h
 #include util/u_inlines.h
 #include util/u_simple_shaders.h
 #include util/u_draw_quad.h
@@ -129,6 +130,26 @@ set_vertex_shader(struct st_context *st)
 }
 
 
+static void
+set_vertex_shader_layered(struct st_context *st)
+{
+   struct pipe_context *pipe = st-pipe;
+
+   if (!pipe-screen-get_param(pipe-screen, PIPE_CAP_TGSI_INSTANCEID) ||
+   !pipe-screen-get_param(pipe-screen, PIPE_CAP_TGSI_VS_LAYER)) {
+  assert(!Got layered clear, but the VS layer output is unsupported);
+  set_vertex_shader(st);
+  return;
+   }
+
+   if (!st-clear.vs_layered) {
+  st-clear.vs_layered = util_make_layered_clear_vertex_shader(pipe);
+   }
+
+   cso_set_vertex_shader_handle(st-cso_context, st-clear.vs_layered);
+}
+
+
 /**
  * Draw a screen-aligned quadrilateral.
  * Coords are clip coords with y=0=bottom.
@@ -136,15 +157,19 @@ set_vertex_shader(struct st_context *st)
 static void
 draw_quad(struct st_context *st,
   float x0, float y0, float x1, float y1, GLfloat z,
+  unsigned num_instances,
   const union pipe_color_union *color)
 {
-   struct pipe_context *pipe = st-pipe;
-   struct pipe_resource *vbuf = NULL;
-   GLuint i, offset;
+   struct cso_context *cso = st-cso_context;
+   struct pipe_vertex_buffer vb = {0};
+   GLuint i;
float (*vertices)[2][4];  /** vertex pos + color */
 
+   vb.stride = 8 * sizeof(float);
+
if (u_upload_alloc(st-uploader, 0, 4 * sizeof(vertices[0]),
-  offset, vbuf, (void **) vertices) != PIPE_OK) {
+  vb.buffer_offset, vb.buffer,
+  (void **) vertices) != PIPE_OK) {
   return;
}
 
@@ -174,16 +199,10 @@ draw_quad(struct st_context *st,
u_upload_unmap(st-uploader);
 
/* draw */
-   util_draw_vertex_buffer(pipe,
-   st-cso_context,
-   vbuf,
-   cso_get_aux_vertex_buffer_slot(st-cso_context),
-   offset,
-   PIPE_PRIM_TRIANGLE_FAN,
-   4,  /* verts */
-   2); /* attribs/vert */
-
-   pipe_resource_reference(vbuf, NULL);
+   cso_set_vertex_buffers(cso, cso_get_aux_vertex_buffer_slot(cso), 1, vb);
+   cso_draw_arrays_instanced(cso, PIPE_PRIM_TRIANGLE_FAN, 0, 4,
+ 0, num_instances);
+   pipe_resource_reference(vb.buffer, NULL);
 }
 
 
@@ -206,6 +225,8 @@ clear_with_quad(struct gl_context *ctx,
const GLfloat y0 = (GLfloat) ctx-DrawBuffer-_Ymin / fb_height * 2.0f - 
1.0f;
const GLfloat y1 = (GLfloat) ctx-DrawBuffer-_Ymax / fb_height * 2.0f - 
1.0f;
union pipe_color_union clearColor;
+   unsigned num_layers =
+  

[Mesa-dev] Request for support of GL_AMD_pinned_memory and GL_ARB_buffer_storage extensions

2013-11-24 Thread Tony Wasserka

Hello everyone,
I was told on IRC that my question would get most attention around here 
- so bear with me if this is the wrong place to ask


I'm one of the developers of the GC/Wii emulator Dolphin. We recently 
rewrote our OpenGL renderer to use modern OpenGL 3 features, however one 
thing that we stumbled upon are the lack of efficient (vertex/index) 
buffer data streaming mechanisms in OpenGL. Basically, most of our 
vertex data is used once and never again after that (we have to do this 
for accurate emulation) - so all vertex data gets streamed into one huge 
ring buffer (and analogously for index data, which uses its own huge 
ring buffer). For buffer streaming, we have multiple code paths using a 
combination of glMapBufferRange, glBufferSubData, fences and buffer 
orphaning, yet none of these come anywhere close to the performance of 
(legacy) rendering from a vertex array stored in RAM.


There are two OpenGL extensions which greatly help us in this situation: 
AMD's pinned memory [1], and buffer storage[2] in GL 4.4. We currently 
have no buffer storage code path, but usage of pinned memory gave us a 
speedup of up to 60% under heavy workloads when working with AMD's 
Catalyst driver under Windows. We expect the same speedup when using 
buffer storage (specifically we need CLIENT_STORAGE_BIT, if I recall 
correctly).


So the natural question that arises is: Is either of these two 
extensions going to be supported in mesa anytime soon or is it of lower 
priority than other extensions? Also, is the pinned memory extension AMD 
hardware specific or would it be possible to support it for other 
hardware, too? I'm not sure if buffer storage (being a GL 4.4 extension, 
and I read that it might actually depend on some other GL 4.3 extension) 
is possible to implement on older hardware, yet it would be very useful 
for us to have efficient streaming methods for old GPUs, too.


I hope this mail doesn't sound too commanding or anything, it's just 
supposed to be a friendly question on improving the emulator experience 
for our user base

Thanks in advance!

Best regards,
Tony

[1] http://www.opengl.org/registry/specs/AMD/pinned_memory.txt
[2] http://www.opengl.org/registry/specs/ARB/buffer_storage.txt

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 5/5] docs: describe the INTEL_* envvars that do exist

2013-11-24 Thread Kenneth Graunke
On 11/23/2013 09:13 PM, Chris Forbes wrote:
 Signed-off-by: Chris Forbes chr...@ijw.co.nz
 ---
  docs/envvars.html | 32 
  1 file changed, 32 insertions(+)
 
 diff --git a/docs/envvars.html b/docs/envvars.html
 index 81e74e6..d831826 100644
 --- a/docs/envvars.html
 +++ b/docs/envvars.html
 @@ -121,6 +121,38 @@ See the a href=xlibdriver.htmlXlib software driver 
 page/a for details.
  h2i945/i965 driver environment variables (non-Gallium)/h2
  
  ul
 +liINTEL_NO_HW - if set to 1, prevents batches from being submitted to the 
 hardware.
 +   This is useful for debugging hangs, etc./li
 +liINTEL_DEBUG - a comma-separated list of named flags, which do various 
 things:
 +ul
 +   litex - emit messages about textures./li
 +   listate - emit messages about state flag tracking/li
 +   liblit - emit messages about blit operations/li
 +   limiptree - emit messages about miptrees/li
 +   lifall/perf - emit messages about performance issues/li

Not sure if the old names are worth documenting.  I guess if people find
old text on wikis or something that says INTEL_DEBUG=fall, they'll know
what it means.

We might want to actually just drop the 'fall' name at this
point...people seem to have moved over completely.

 +   liperfmon - emit messages about AMD_performance_monitor/li
 +   libat - emit batch information/li
 +   lipix - emit messages about pixel operations/li
 +   libuf - emit messages about buffer objects/li
 +   lireg - emit messages about regions/li
 +   lifbo - emit messages about framebuffers/li
 +   lifs/wm - dump shader assembly for fragment shaders/li

I've pretty much universally moved over to INTEL_DEBUG=fs too, but I
don't know about others.

 +   ligs - dump shader assembly for geometry shaders/li
 +   lisync - emit messages about synchronization/li
 +   liprim - emit messages about drawing primitives/li
 +   livert - emit messages about vertex assembly/li
 +   lidri - emit messages about the DRI interface/li
 +   lisf - emit messages about the strips amp; fans unit (for old gens, 
 includes the SF program)/li
 +   listats - ?/li

This enables statistics counters for the vertex fetcher (on all
generations), and for other units on Gen4-5.  That said, the counters
aren't exposed other than reading registers, and on Gen6+ you can't even
use intel_reg_read due to hardware contexts.

Frankly, it seems pretty useless, and I think we ought to delete it.

 +   liurb - emit messages about URB setup/li
 +   livs - dump shader assembly for vertex shaders/li
 +   liclip - emit messages about the clip unit (for old gens, includes the 
 CLIP program)/li
 +   liaub - dump batches into an AUB trace for use with simulation 
 tools/li
 +   lishader_time - record how much GPU time is spent in each shader/li
 +   lino16 - suppress generation of 16-wide fragment shaders. useful for 
 debugging broken shaders/li
 +   liblorp - emit messages about the blorp operations (blits amp; 
 clears)/li
 +   linodualobj - suppress generation of dual-object geometry shader 
 code/li
 +/ul
  /ul

Thanks for doing this, Chris.  For the series:
Reviewed-by: Kenneth Graunke kenn...@whitecape.org
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] More projects for newbies

2013-11-24 Thread Klemen Košir
Hello!

I'll try to implement AMD_shader_trinary_minmax. This is my first
project, so I hope I'll be able to do it (correctly). It shouldn't take
me too long.

- Klemen Košir
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH] mesa: reduce memory used for short display lists

2013-11-24 Thread Brian Paul
From: Brian Paul bri...@vmware.com

Display lists allocate memory in chunks of 256 tokens (1KB) at a time.
If an app creates many short display lists or uses glXUseXFont() this
can waste quite a bit of memory.

This patch uses realloc() to trim short lists and reduce the memory
used.

Also, null/zero-out some list construction fields in _mesa_EndList().
---
 src/mesa/main/dlist.c |   35 +++
 1 file changed, 35 insertions(+)

diff --git a/src/mesa/main/dlist.c b/src/mesa/main/dlist.c
index d1e2035..cb40ff4 100644
--- a/src/mesa/main/dlist.c
+++ b/src/mesa/main/dlist.c
@@ -1067,6 +1067,37 @@ alloc_instruction(struct gl_context *ctx, OpCode opcode, 
GLuint nparams)
 }
 
 
+/**
+ * Called by EndList to try to reduce memory used for the list.
+ */
+static void
+trim_list(struct gl_context *ctx)
+{
+   /* If the list we're ending only has one allocated block of nodes/tokens
+* and its size isn't a full block size, realloc the block to use less
+* memory.  This is important for apps that create many small display
+* lists and apps that use glXUseXFont (many lists each containing one
+* glBitmap call).
+* Note: we currently only trim display lists that allocated one block
+* of tokens.  That hits the short list case which is what we're mainly
+* concerned with.  Trimming longer lists would involve traversing the
+* linked list of blocks.
+*/
+   struct gl_dlist_state *list = ctx-ListState;
+
+   if ((list-CurrentList-Head == list-CurrentBlock) 
+   (list-CurrentPos  BLOCK_SIZE)) {
+  /* There's only one block and it's not full, so realloc */
+  GLuint newSize = list-CurrentPos * sizeof(Node);
+  list-CurrentList-Head =
+  list-CurrentBlock = realloc(list-CurrentBlock, newSize);
+  if (!list-CurrentBlock) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, glEndList);
+  }
+   }
+}
+
+
 
 /*
  * Display List compilation functions
@@ -8242,6 +8273,8 @@ _mesa_EndList(void)
 
(void) alloc_instruction(ctx, OPCODE_END_OF_LIST, 0);
 
+   trim_list(ctx);
+
/* Destroy old list, if any */
destroy_list(ctx, ctx-ListState.CurrentList-Name);
 
@@ -8255,6 +8288,8 @@ _mesa_EndList(void)
   mesa_print_display_list(ctx-ListState.CurrentList-Name);
 
ctx-ListState.CurrentList = NULL;
+   ctx-ListState.CurrentBlock = NULL;
+   ctx-ListState.CurrentPos = 0;
ctx-ExecuteFlag = GL_TRUE;
ctx-CompileFlag = GL_FALSE;
 
-- 
1.7.9.5

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 3/5] radeon: change last instance of DEBUG_IOCTL to use RADEON_IOCTL

2013-11-24 Thread Alex Deucher
On Sun, Nov 24, 2013 at 12:13 AM, Chris Forbes chr...@ijw.co.nz wrote:
 DEBUG_IOCTL comes from i965, and is about to be removed. Both defines
 have the same value (4).

 Signed-off-by: Chris Forbes chr...@ijw.co.nz

Reviewed-by: Alex Deucher alexander.deuc...@amd.com

 ---
  src/mesa/drivers/dri/radeon/radeon_ioctl.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

 diff --git a/src/mesa/drivers/dri/radeon/radeon_ioctl.c 
 b/src/mesa/drivers/dri/radeon/radeon_ioctl.c
 index d6419f3..a542db1 100644
 --- a/src/mesa/drivers/dri/radeon/radeon_ioctl.c
 +++ b/src/mesa/drivers/dri/radeon/radeon_ioctl.c
 @@ -282,7 +282,7 @@ void radeonEmitVertexAOS( r100ContextPtr rmesa,
  #else
 BATCH_LOCALS(rmesa-radeon);

 -   if (RADEON_DEBUG  (RADEON_PRIMS|DEBUG_IOCTL))
 +   if (RADEON_DEBUG  (RADEON_PRIMS|RADEON_IOCTL))
fprintf(stderr, %s:  vertex_size 0x%x offset 0x%x \n,
   __FUNCTION__, vertex_size, offset);

 --
 1.8.4.2

 ___
 mesa-dev mailing list
 mesa-dev@lists.freedesktop.org
 http://lists.freedesktop.org/mailman/listinfo/mesa-dev
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 0/3] Implement DRI_PRIME support for Wayland

2013-11-24 Thread Alex Deucher
On Fri, Nov 22, 2013 at 8:52 AM, Axel Davy d...@clipper.ens.fr wrote:
 On 11/22/2013 01:16 AM, Kristian Høgsberg wrote:
 I'm not sold on the nested compositor for this use case.  It
 introduces another context switch between the game and the main
 compositor and more input and output lag.  Instead I think we need to
 consider whether we want a new __DRIimage entry point like:

   (*blitImage)(__DRIcontext *ctx, __DRIimage *src, __DRIimage *ctx)

 and then do the copy in platform_wayland.c when we have non-matching
 tile-formats.

 Kristian


 Thanks for the comments.

 There are advantages to both possibilities:
 using a nested compositor or doing the copy inside Mesa.

 I imagine doing a blit could be the default,
 and rendering directly to the linear buffer could be an option
 set by an env var, or driconf.

 I'm deeply convinced we should allow to render to the linear
 buffer without copy, and the nested compositor use-case makes sense.

 For the blit, a function

 (*blitImage)(__DRIcontext *ctx, __DRIimage *src, __DRIimage *dst)

 makes sense, but we would need another function
 (not related specifically to Prime):

 (*throttle) (__DRIcontext *ctx)

 Because rendering something heavy on non-intel card (intel cards to
 throttling automatically)
 cause input lag (and It is solved by forcing throttling at every swap).

 And ideally, we could have more control on tiling,
 for example if the computer has two AMD cards of the same
 generation with same tiling modes, we could always use tiling.


We can actually use 1D tiling across all families since R600 IIRC
since the tile size and alignment requirements are not asic dependent.
 Only 2D tiling as family dependencies.

Alex


I would like the compositor to still send the classic drm device in
the wl_drm.device event.  The client can then use stat(2) to stat it
and defer the corresponding render node from that by adding 128 to the
minor.  This way we don't break older mesa versions by sending them a
render node that they'll then fail to authenticate.

 I do not agree on this: if the compositor does run under a render-node,
 there are high chances it can't authenticate clients wanting to run
 on the not-render-node device.
 Moreover, I believe clients shouldn't use render-nodes by default if
 they can avoid it.

 I don't get the point of older mesa versions: why would you use an older
 Mesa version inside a more recent Mesa version?


 Some arguments in favor of allowing the nested compositor case to render
 without copy
 on another card:

 . XWayland inside would run as if the main device is the device of the
 nested compositor. (I can't say how X dri3 will support Prime, so I
 can't say yet if this is a big advantage or not). For example if Xrender is
 slow on the main card, you can with this system use Xrender on the other
 card.

 . In case you are under system compositors (like would KWin), you would
 like to be able to render your whole desktop on the card you want,
 without an additional copy.
 . We could imagine having outputs on different card, the compositor
 under system compositors would connect to multiple system compositors
 running on each card (and giving access to different outputs). The
 compositor would use card X: the system compositor on card X would have
 tiled buffers without copies, whereas the other system compositors would
 have untiled buffers without copies.

 . The nested compositor could allow the user to choose between capping
 the compositing to 60 fps
 or not. When we would cap the compositing to 60 fps, we would avoid some
 useless copies (while adding a very small latency between when the frame
 is sent and when it is displayed)

 (. The nested compositor could have additional features like recording
 using the acceleration of the other card )

 All these arguments can be put in short in: more flexibility


 For an heavy game  60 fps, I agree it makes much more sense to do the
 copy inside Mesa, than using a nested compositor.


 Axel Davy
 ___
 mesa-dev mailing list
 mesa-dev@lists.freedesktop.org
 http://lists.freedesktop.org/mailman/listinfo/mesa-dev
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] Anonymous structure in uniform question

2013-11-24 Thread Grigori Goronzy

On 21.11.2013 21:50, f.jo...@email.cz wrote:

The problem is, that each anonymous structure gets its own unique type,
without checking if such type already exists. It seems to me, that such
code is somewhat in the gray area - the rest of OpenGL implementations
doesn't seem to have a problem with this code (Intel on Win, OSX, Nvidia
and AMD drivers in Win, OSX and Linux), which of course doesn't mean
such a behavior is correct.



This should be allowed, according to GLSL (3.3) spec and grammar. It's 
just a bug/oversight in the linker, I guess. The GLSL linker already 
includes some special handling to match array types between stages. I 
added something similar for structs, see the attached patch. It's 
probably not the nicest approach (it duplicates some code from 
glsl_types.cpp), but seems to work fine. I don't really know the GLSL 
compiler/linker code, so YMMV. :)


Best regards
Grigori

From 386dc4f201a65a2a8740c8c9f4a039d5c8209a9c Mon Sep 17 00:00:00 2001
From: Grigori Goronzy g...@chown.ath.cx
Date: Sun, 24 Nov 2013 20:24:58 +0100
Subject: [PATCH] WIP: fix unnamed struct type conflicts

If two shader stages define the same unnamed struct type, they will
conflict. Compare struct types in this case, similar to how it is
done with arrays.
---
 src/glsl/linker.cpp | 35 +++
 1 file changed, 35 insertions(+)

diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp
index 1d53b65..7ca7bb9 100644
--- a/src/glsl/linker.cpp
+++ b/src/glsl/linker.cpp
@@ -556,6 +556,37 @@ validate_geometry_shader_executable(struct gl_shader_program *prog,
prog-Geom.UsesEndPrimitive = end_primitive.end_primitive_found();
 }
 
+static bool
+compare_record_types(const glsl_type *key1, const glsl_type *key2)
+{
+   if (key1-length != key2-length)
+  return false;
+
+   if (key1-interface_packing != key2-interface_packing)
+  return false;
+
+   for (unsigned i = 0; i  key1-length; i++) {
+  if (key1-fields.structure[i].type != key2-fields.structure[i].type)
+	 return false;
+  if (strcmp(key1-fields.structure[i].name,
+		 key2-fields.structure[i].name) != 0)
+	 return false;
+  if (key1-fields.structure[i].row_major
+ != key2-fields.structure[i].row_major)
+return false;
+  if (key1-fields.structure[i].location
+  != key2-fields.structure[i].location)
+ return false;
+  if (key1-fields.structure[i].interpolation
+  != key2-fields.structure[i].interpolation)
+ return false;
+  if (key1-fields.structure[i].centroid
+  != key2-fields.structure[i].centroid)
+ return false;
+   }
+
+   return true;
+}
 
 /**
  * Perform validation of global variables used across multiple shaders
@@ -609,6 +640,10 @@ cross_validate_globals(struct gl_shader_program *prog,
 		  if (var-type-length != 0) {
 		 existing-type = var-type;
 		  }
+   } else if (var-type-is_record()
+existing-type-is_record()
+compare_record_types(existing-type, var-type)) {
+  existing-type = var-type;
 	   } else {
 		  linker_error(prog, %s `%s' declared as type 
 			   `%s' and type `%s'\n,
-- 
1.8.1.2

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH] i965: Bump number of supported atomic counter buffers.

2013-11-24 Thread Francisco Jerez
Now that we have dynamic binding tables there's no good reason anymore
to expose so few atomic counter buffers.  Increase it to 16.
---
 src/mesa/drivers/dri/i965/brw_context.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/mesa/drivers/dri/i965/brw_context.h 
b/src/mesa/drivers/dri/i965/brw_context.h
index 63f0687..97f8906 100644
--- a/src/mesa/drivers/dri/i965/brw_context.h
+++ b/src/mesa/drivers/dri/i965/brw_context.h
@@ -660,7 +660,7 @@ struct brw_gs_prog_data
 #define BRW_MAX_DRAW_BUFFERS 8
 
 /** Max number of atomic counter buffer objects in a shader */
-#define BRW_MAX_ABO 4
+#define BRW_MAX_ABO 16
 
 /**
  * Max number of binding table entries used for stream output.
-- 
1.8.3.4

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 2/8] st/mesa: allow GLSL 1.50 and 3.30 to be exposed

2013-11-24 Thread Dave Airlie
I actually had a change for this reviewed already I'll push it.

Dave.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 1/8] mesa: expose AMD_vertex_shader_layer in the core profile only

2013-11-24 Thread Jordan Justen
On Sun, Nov 24, 2013 at 2:55 AM, Marek Olšák mar...@gmail.com wrote:
 From: Marek Olšák marek.ol...@amd.com

 It needs glFramebufferTexture, which isn't available in the compatibility
 profile.
 ---
  src/mesa/main/extensions.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

 diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c
 index 104618c..f7e7e4d 100644
 --- a/src/mesa/main/extensions.c
 +++ b/src/mesa/main/extensions.c
 @@ -300,7 +300,7 @@ static const struct extension extension_table[] = {
 { GL_AMD_performance_monitor, 
 o(AMD_performance_monitor), GL, 2007 },
 { GL_AMD_seamless_cubemap_per_texture,
 o(AMD_seamless_cubemap_per_texture),GL, 2009 },
 { GL_AMD_shader_stencil_export,   
 o(ARB_shader_stencil_export),   GL, 2009 },
 -   { GL_AMD_vertex_shader_layer, 
 o(AMD_vertex_shader_layer), GL, 2012 },
 +   { GL_AMD_vertex_shader_layer, 
 o(AMD_vertex_shader_layer), GLC,2012 },

Seems fine, but not required.

This would need to be reverted if GS4 was made available in compat,
which I don't think is currently planned.

-Jordan
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH] gallium/dri: Support DRI Image extension version 6 (v2)

2013-11-24 Thread christopher . halse . rogers
From: Christopher James Halse Rogers christopher.halse.rog...@canonical.com

v2: Pick out the correct gl_context pointer; now passes associated piglit
---
 src/gallium/state_trackers/dri/drm/dri2.c | 72 ++-
 1 file changed, 71 insertions(+), 1 deletion(-)

diff --git a/src/gallium/state_trackers/dri/drm/dri2.c 
b/src/gallium/state_trackers/dri/drm/dri2.c
index 868cd25..a8fb4ed 100644
--- a/src/gallium/state_trackers/dri/drm/dri2.c
+++ b/src/gallium/state_trackers/dri/drm/dri2.c
@@ -33,6 +33,9 @@
 #include util/u_format.h
 #include util/u_debug.h
 #include state_tracker/drm_driver.h
+#include state_tracker/st_texture.h
+#include state_tracker/st_context.h
+#include main/texobj.h
 
 #include dri_screen.h
 #include dri_context.h
@@ -825,6 +828,72 @@ dri2_from_planar(__DRIimage *image, int plane, void 
*loaderPrivate)
return img;
 }
 
+static __DRIimage *
+dri2_create_from_texture(__DRIcontext *context, int target, unsigned texture,
+ int depth, int level, unsigned *error,
+ void *loaderPrivate)
+{
+   __DRIimage *img;
+   struct gl_context *ctx = ((struct st_context 
*)dri_context(context)-st)-ctx;
+   struct gl_texture_object *obj;
+   struct pipe_resource *tex;
+   GLuint face = 0;
+
+   obj = _mesa_lookup_texture(ctx, texture);
+   if (!obj || obj-Target != target) {
+  *error = __DRI_IMAGE_ERROR_BAD_PARAMETER;
+  return NULL;
+   }
+
+   tex = st_get_texobj_resource(obj);
+   if (!tex) {
+  *error = __DRI_IMAGE_ERROR_BAD_PARAMETER;
+  return NULL;
+   }
+
+   if (target == GL_TEXTURE_CUBE_MAP)
+  face = depth;
+
+   _mesa_test_texobj_completeness(ctx, obj);
+   if (!obj-_BaseComplete || (level  0  !obj-_MipmapComplete)) {
+  *error = __DRI_IMAGE_ERROR_BAD_PARAMETER;
+  return NULL;
+   }
+
+   if (level  obj-BaseLevel || level  obj-_MaxLevel) {
+  *error = __DRI_IMAGE_ERROR_BAD_MATCH;
+  return NULL;
+   }
+
+   if (target == GL_TEXTURE_3D  obj-Image[face][level]-Depth  depth) {
+  *error = __DRI_IMAGE_ERROR_BAD_MATCH;
+  return NULL;
+   }
+
+   img = CALLOC_STRUCT(__DRIimageRec);
+   if (!img) {
+  *error = __DRI_IMAGE_ERROR_BAD_ALLOC;
+  return NULL;
+   }
+
+   pipe_resource_reference(img-texture, tex);
+
+   img-level = level;
+   img-layer = depth;
+   img-dri_format = driGLFormatToImageFormat(obj-_BufferObjectFormat);
+
+   img-loader_private = loaderPrivate;
+
+   if (img-dri_format == MESA_FORMAT_NONE) {
+  *error = __DRI_IMAGE_ERROR_BAD_PARAMETER;
+  free(img);
+  return NULL;
+   }
+
+   *error = __DRI_IMAGE_ERROR_SUCCESS;
+   return img;
+}
+
 static void
 dri2_destroy_image(__DRIimage *img)
 {
@@ -833,7 +902,7 @@ dri2_destroy_image(__DRIimage *img)
 }
 
 static struct __DRIimageExtensionRec dri2ImageExtension = {
-{ __DRI_IMAGE, 5 },
+{ __DRI_IMAGE, 6 },
 dri2_create_image_from_name,
 dri2_create_image_from_renderbuffer,
 dri2_destroy_image,
@@ -843,6 +912,7 @@ static struct __DRIimageExtensionRec dri2ImageExtension = {
 dri2_validate_usage,
 dri2_from_names,
 dri2_from_planar,
+dri2_create_from_texture,
 };
 
 /*
-- 
1.8.4.4

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH] gallium/dri: Support DRI Image extension version 7 (v3)

2013-11-24 Thread christopher . halse . rogers
From: Christopher James Halse Rogers christopher.halse.rog...@canonical.com

v2: Fix up queryImage return for ATTRIB_FD
Use driver_descriptor.configuration to determine whether the driver
supports DMA-BUF import/export.
v3: Really, truly, fix up queryImage return for ATTRIB_FD
---
 src/gallium/include/state_tracker/drm_driver.h |   2 +
 src/gallium/state_trackers/dri/drm/dri2.c  | 114 ++---
 2 files changed, 106 insertions(+), 10 deletions(-)

diff --git a/src/gallium/include/state_tracker/drm_driver.h 
b/src/gallium/include/state_tracker/drm_driver.h
index 5b76d87..959a762 100644
--- a/src/gallium/include/state_tracker/drm_driver.h
+++ b/src/gallium/include/state_tracker/drm_driver.h
@@ -45,6 +45,8 @@ struct winsys_handle
 enum drm_conf {
/* How many frames to allow before throttling. Or -1 to indicate any number 
*/
DRM_CONF_THROTTLE, /* DRM_CONF_INT. */
+   /* Can this driver, running on this kernel, import and export dma-buf fds? 
*/
+   DRM_CONF_SHARE_FD, /* DRM_CONF_BOOL. */
DRM_CONF_MAX
 };
 
diff --git a/src/gallium/state_trackers/dri/drm/dri2.c 
b/src/gallium/state_trackers/dri/drm/dri2.c
index 98f7b98..fe5576c 100644
--- a/src/gallium/state_trackers/dri/drm/dri2.c
+++ b/src/gallium/state_trackers/dri/drm/dri2.c
@@ -530,14 +530,14 @@ dri2_lookup_egl_image(struct dri_screen *screen, void 
*handle)
 }
 
 static __DRIimage *
-dri2_create_image_from_name(__DRIscreen *_screen,
-int width, int height, int format,
-int name, int pitch, void *loaderPrivate)
+dri2_create_image_from_winsys(__DRIscreen *_screen,
+  int width, int height, int format,
+  struct winsys_handle *whandle, int pitch,
+  void *loaderPrivate)
 {
struct dri_screen *screen = dri_screen(_screen);
__DRIimage *img;
struct pipe_resource templ;
-   struct winsys_handle whandle;
unsigned tex_usage;
enum pipe_format pf;
 
@@ -577,13 +577,10 @@ dri2_create_image_from_name(__DRIscreen *_screen,
templ.depth0 = 1;
templ.array_size = 1;
 
-   memset(whandle, 0, sizeof(whandle));
-   whandle.handle = name;
-   whandle.type = DRM_API_HANDLE_TYPE_SHARED;
-   whandle.stride = pitch * util_format_get_blocksize(pf);
+   whandle-stride = pitch * util_format_get_blocksize(pf);
 
img-texture = 
screen-base.screen-resource_from_handle(screen-base.screen,
- templ, whandle);
+ templ, whandle);
if (!img-texture) {
   FREE(img);
   return NULL;
@@ -598,6 +595,39 @@ dri2_create_image_from_name(__DRIscreen *_screen,
 }
 
 static __DRIimage *
+dri2_create_image_from_name(__DRIscreen *_screen,
+int width, int height, int format,
+int name, int pitch, void *loaderPrivate)
+{
+   struct winsys_handle whandle;
+
+   memset(whandle, 0, sizeof(whandle));
+   whandle.type = DRM_API_HANDLE_TYPE_SHARED;
+   whandle.handle = name;
+
+   return dri2_create_image_from_winsys(_screen, width, height, format,
+whandle, pitch, loaderPrivate);
+}
+
+static __DRIimage *
+dri2_create_image_from_fd(__DRIscreen *_screen,
+  int width, int height, int format,
+  int fd, int pitch, void *loaderPrivate)
+{
+   struct winsys_handle whandle;
+
+   if (fd  0)
+  return NULL;
+
+   memset(whandle, 0, sizeof(whandle));
+   whandle.type = DRM_API_HANDLE_TYPE_FD;
+   whandle.handle = (unsigned)fd;
+
+   return dri2_create_image_from_winsys(_screen, width, height, format,
+whandle, pitch, loaderPrivate);
+}
+
+static __DRIimage *
 dri2_create_image_from_renderbuffer(__DRIcontext *context,
int renderbuffer, void *loaderPrivate)
 {
@@ -708,6 +738,12 @@ dri2_query_image(__DRIimage *image, int attrib, int *value)
  image-texture, whandle);
   *value = whandle.handle;
   return GL_TRUE;
+   case __DRI_IMAGE_ATTRIB_FD:
+  whandle.type= DRM_API_HANDLE_TYPE_FD;
+  image-texture-screen-resource_get_handle(image-texture-screen,
+ image-texture, whandle);
+  *value = whandle.handle;
+  return GL_TRUE;
case __DRI_IMAGE_ATTRIB_FORMAT:
   *value = image-dri_format;
   return GL_TRUE;
@@ -897,6 +933,56 @@ dri2_create_from_texture(__DRIcontext *context, int 
target, unsigned texture,
return img;
 }
 
+static __DRIimage *
+dri2_from_fds(__DRIscreen *screen, int width, int height, int fourcc,
+  int *fds, int num_fds, int *strides, int *offsets,
+  void *loaderPrivate)
+{
+   __DRIimage *img;
+   int format, stride, dri_components;
+
+   if (num_fds != 1)
+  return NULL;
+   if (offsets[0] != 0)
+  return NULL;
+
+   switch(fourcc) {
+   case __DRI_IMAGE_FOURCC_RGB565:
+  format = __DRI_IMAGE_FORMAT_RGB565;
+  dri_components = __DRI_IMAGE_COMPONENTS_RGB;
+

[Mesa-dev] [PATCH] gallium/radeon: Implement hooks for DRI Image 7 (v2)

2013-11-24 Thread christopher . halse . rogers
From: Christopher James Halse Rogers r...@ubuntu.com

v2: Fix transliteration of lseek arguments
Ignore busy return from RADEON_GEM_BUSY ioctl; we're only after the domain
---
 src/gallium/targets/r300/common/drm_target.c |  27 +-
 src/gallium/targets/r600/common/drm_target.c |  16 
 src/gallium/targets/radeonsi/common/drm_target.c |  16 
 src/gallium/winsys/radeon/drm/radeon_drm_bo.c| 108 ++-
 4 files changed, 142 insertions(+), 25 deletions(-)

diff --git a/src/gallium/targets/r300/common/drm_target.c 
b/src/gallium/targets/r300/common/drm_target.c
index 2c10bbd..9b48446 100644
--- a/src/gallium/targets/r300/common/drm_target.c
+++ b/src/gallium/targets/r300/common/drm_target.c
@@ -51,4 +51,29 @@ create_screen(int fd)
return sws-screen;
 }
 
-DRM_DRIVER_DESCRIPTOR(r300, radeon, create_screen, NULL)
+/* Technically this is only true for kernels = 3.12, which
+ * support lseek on dma-buf fds.
+ *
+ * We could check for this in create_screen and return the correct
+ * value, but for now just return true in all cases.
+ * 
+ * createImageFromFds fails gracefully on kernel  3.12, so this
+ * shouldn't be a huge problem.
+ */
+static const struct drm_conf_ret share_fd_ret = {
+   .type = DRM_CONF_BOOL,
+   .val.val_int = true,
+};
+
+static const struct drm_conf_ret *drm_configuration(enum drm_conf conf)
+{
+   switch (conf) {
+   case DRM_CONF_SHARE_FD:
+  return share_fd_ret;
+   default:
+  break;
+   }
+   return NULL;
+}
+
+DRM_DRIVER_DESCRIPTOR(r300, radeon, create_screen, drm_configuration)
diff --git a/src/gallium/targets/r600/common/drm_target.c 
b/src/gallium/targets/r600/common/drm_target.c
index 28004ac..ab1eec6 100644
--- a/src/gallium/targets/r600/common/drm_target.c
+++ b/src/gallium/targets/r600/common/drm_target.c
@@ -55,11 +55,27 @@ static const struct drm_conf_ret throttle_ret = {
.val.val_int = 2,
 };
 
+/* Technically this is only true for kernels = 3.12, which
+ * support lseek on dma-buf fds.
+ *
+ * We could check for this in create_screen and return the correct
+ * value, but for now just return true in all cases.
+ * 
+ * createImageFromFds fails gracefully on kernel  3.12, so this
+ * shouldn't be a huge problem.
+ */
+static const struct drm_conf_ret share_fd_ret = {
+   .type = DRM_CONF_BOOL,
+   .val.val_int = true,
+};
+
 static const struct drm_conf_ret *drm_configuration(enum drm_conf conf)
 {
switch (conf) {
case DRM_CONF_THROTTLE:
   return throttle_ret;
+   case DRM_CONF_SHARE_FD:
+  return share_fd_ret;
default:
   break;
}
diff --git a/src/gallium/targets/radeonsi/common/drm_target.c 
b/src/gallium/targets/radeonsi/common/drm_target.c
index 9eef368..08ff47d 100644
--- a/src/gallium/targets/radeonsi/common/drm_target.c
+++ b/src/gallium/targets/radeonsi/common/drm_target.c
@@ -55,11 +55,27 @@ static const struct drm_conf_ret throttle_ret = {
.val.val_int = 2,
 };
 
+/* Technically this is only true for kernels = 3.12, which
+ * support lseek on dma-buf fds.
+ *
+ * We could check for this in create_screen and return the correct
+ * value, but for now just return true in all cases.
+ * 
+ * createImageFromFds fails gracefully on kernel  3.12, so this
+ * shouldn't be a huge problem.
+ */
+static const struct drm_conf_ret share_fd_ret = {
+   .type = DRM_CONF_BOOL,
+   .val.val_int = true,
+};
+
 static const struct drm_conf_ret *drm_configuration(enum drm_conf conf)
 {
switch (conf) {
case DRM_CONF_THROTTLE:
   return throttle_ret;
+   case DRM_CONF_SHARE_FD:
+  return share_fd_ret;
default:
   break;
}
diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_bo.c 
b/src/gallium/winsys/radeon/drm/radeon_drm_bo.c
index 5ddbc00..81dfdd4 100644
--- a/src/gallium/winsys/radeon/drm/radeon_drm_bo.c
+++ b/src/gallium/winsys/radeon/drm/radeon_drm_bo.c
@@ -40,6 +40,7 @@
 #include sys/ioctl.h
 #include xf86drm.h
 #include errno.h
+#include fcntl.h
 
 /*
  * this are copy from radeon_drm, once an updated libdrm is released
@@ -116,6 +117,8 @@ struct radeon_bomgr {
 
 /* List of buffer GEM names. Protected by bo_handles_mutex. */
 struct util_hash_table *bo_names;
+/* List of buffer handles. Protectded by bo_handles_mutex. */
+struct util_hash_table *bo_handles;
 pipe_mutex bo_handles_mutex;
 pipe_mutex bo_va_mutex;
 
@@ -370,12 +373,13 @@ static void radeon_bo_destroy(struct pb_buffer *_buf)
 
 memset(args, 0, sizeof(args));
 
+pipe_mutex_lock(bo-mgr-bo_handles_mutex);
+util_hash_table_remove(bo-mgr-bo_handles, (void*)(uintptr_t)bo-handle);
 if (bo-name) {
-pipe_mutex_lock(bo-mgr-bo_handles_mutex);
 util_hash_table_remove(bo-mgr-bo_names,
(void*)(uintptr_t)bo-name);
-pipe_mutex_unlock(bo-mgr-bo_handles_mutex);
 }
+pipe_mutex_unlock(bo-mgr-bo_handles_mutex);
 
 if (bo-ptr)
 os_munmap(bo-ptr, bo-base.size);
@@ -661,6 +665,7 @@ static void 

Re: [Mesa-dev] [PATCH 3/9] gallium/dri2: Set winsys_handle type to KMS for stride query.

2013-11-24 Thread Christopher James Halse Rogers
On Thu, 2013-11-21 at 14:12 +0100, Thomas Hellstrom wrote:
 On 11/21/2013 05:11 AM, christopher.halse.rog...@canonical.com wrote:
  From: Christopher James Halse Rogers r...@ubuntu.com
 
  Otherwise the default is TYPE_SHARED, which will flink the bo. This seems
  rather unnecessary for a simple stride query.
 
 Is there no way we can cache this stuff in a __DRIimage? Changing the 
 calling conventions to adapt to poor implementations seems like
 the wrong way to go. What if other drivers use a slow approach to get 
 the KMS handle?
 

Do you want me to add some extra gallium API to get this sort of image
metadata without using what's essentially a side-effect of
resource_get_handle? If this isn't a theoretical concern I can certainly
do so.

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] gallium/dri: Support DRI Image extension version 7 (v3)

2013-11-24 Thread Ben Skeggs
On Mon, Nov 25, 2013 at 1:57 PM,
christopher.halse.rog...@canonical.com wrote:
 From: Christopher James Halse Rogers christopher.halse.rog...@canonical.com
http://cgit.freedesktop.org/~keithp/mesa/log/?h=dri3


 v2: Fix up queryImage return for ATTRIB_FD
 Use driver_descriptor.configuration to determine whether the driver
 supports DMA-BUF import/export.
 v3: Really, truly, fix up queryImage return for ATTRIB_FD
 ---
  src/gallium/include/state_tracker/drm_driver.h |   2 +
  src/gallium/state_trackers/dri/drm/dri2.c  | 114 
 ++---
  2 files changed, 106 insertions(+), 10 deletions(-)

 diff --git a/src/gallium/include/state_tracker/drm_driver.h 
 b/src/gallium/include/state_tracker/drm_driver.h
 index 5b76d87..959a762 100644
 --- a/src/gallium/include/state_tracker/drm_driver.h
 +++ b/src/gallium/include/state_tracker/drm_driver.h
 @@ -45,6 +45,8 @@ struct winsys_handle
  enum drm_conf {
 /* How many frames to allow before throttling. Or -1 to indicate any 
 number */
 DRM_CONF_THROTTLE, /* DRM_CONF_INT. */
 +   /* Can this driver, running on this kernel, import and export dma-buf 
 fds? */
 +   DRM_CONF_SHARE_FD, /* DRM_CONF_BOOL. */
 DRM_CONF_MAX
  };

 diff --git a/src/gallium/state_trackers/dri/drm/dri2.c 
 b/src/gallium/state_trackers/dri/drm/dri2.c
 index 98f7b98..fe5576c 100644
 --- a/src/gallium/state_trackers/dri/drm/dri2.c
 +++ b/src/gallium/state_trackers/dri/drm/dri2.c
 @@ -530,14 +530,14 @@ dri2_lookup_egl_image(struct dri_screen *screen, void 
 *handle)
  }

  static __DRIimage *
 -dri2_create_image_from_name(__DRIscreen *_screen,
 -int width, int height, int format,
 -int name, int pitch, void *loaderPrivate)
 +dri2_create_image_from_winsys(__DRIscreen *_screen,
 +  int width, int height, int format,
 +  struct winsys_handle *whandle, int pitch,
 +  void *loaderPrivate)
  {
 struct dri_screen *screen = dri_screen(_screen);
 __DRIimage *img;
 struct pipe_resource templ;
 -   struct winsys_handle whandle;
 unsigned tex_usage;
 enum pipe_format pf;

 @@ -577,13 +577,10 @@ dri2_create_image_from_name(__DRIscreen *_screen,
 templ.depth0 = 1;
 templ.array_size = 1;

 -   memset(whandle, 0, sizeof(whandle));
 -   whandle.handle = name;
 -   whandle.type = DRM_API_HANDLE_TYPE_SHARED;
 -   whandle.stride = pitch * util_format_get_blocksize(pf);
 +   whandle-stride = pitch * util_format_get_blocksize(pf);

 img-texture = 
 screen-base.screen-resource_from_handle(screen-base.screen,
 - templ, whandle);
 + templ, whandle);
 if (!img-texture) {
FREE(img);
return NULL;
 @@ -598,6 +595,39 @@ dri2_create_image_from_name(__DRIscreen *_screen,
  }

  static __DRIimage *
 +dri2_create_image_from_name(__DRIscreen *_screen,
 +int width, int height, int format,
 +int name, int pitch, void *loaderPrivate)
 +{
 +   struct winsys_handle whandle;
 +
 +   memset(whandle, 0, sizeof(whandle));
 +   whandle.type = DRM_API_HANDLE_TYPE_SHARED;
 +   whandle.handle = name;
 +
 +   return dri2_create_image_from_winsys(_screen, width, height, format,
 +whandle, pitch, loaderPrivate);
 +}
 +
 +static __DRIimage *
 +dri2_create_image_from_fd(__DRIscreen *_screen,
 +  int width, int height, int format,
 +  int fd, int pitch, void *loaderPrivate)
 +{
 +   struct winsys_handle whandle;
 +
 +   if (fd  0)
 +  return NULL;
 +
 +   memset(whandle, 0, sizeof(whandle));
 +   whandle.type = DRM_API_HANDLE_TYPE_FD;
 +   whandle.handle = (unsigned)fd;
 +
 +   return dri2_create_image_from_winsys(_screen, width, height, format,
 +whandle, pitch, loaderPrivate);
 +}
 +
 +static __DRIimage *
  dri2_create_image_from_renderbuffer(__DRIcontext *context,
 int renderbuffer, void *loaderPrivate)
  {
 @@ -708,6 +738,12 @@ dri2_query_image(__DRIimage *image, int attrib, int 
 *value)
   image-texture, whandle);
*value = whandle.handle;
return GL_TRUE;
 +   case __DRI_IMAGE_ATTRIB_FD:
 +  whandle.type= DRM_API_HANDLE_TYPE_FD;
 +  image-texture-screen-resource_get_handle(image-texture-screen,
 + image-texture, whandle);
 +  *value = whandle.handle;
 +  return GL_TRUE;
 case __DRI_IMAGE_ATTRIB_FORMAT:
*value = image-dri_format;
return GL_TRUE;
 @@ -897,6 +933,56 @@ dri2_create_from_texture(__DRIcontext *context, int 
 target, unsigned texture,
 return img;
  }

 +static __DRIimage *
 +dri2_from_fds(__DRIscreen *screen, int width, int height, int fourcc,
 +  int *fds, int num_fds, int *strides, int *offsets,
 +  void *loaderPrivate)
 +{
 +   __DRIimage *img;
 +   int format, stride, 

Re: [Mesa-dev] [PATCH] gallium/dri: Support DRI Image extension version 7 (v3)

2013-11-24 Thread Christopher James Halse Rogers
On Mon, 2013-11-25 at 14:38 +1000, Ben Skeggs wrote:
 On Mon, Nov 25, 2013 at 1:57 PM,
 christopher.halse.rog...@canonical.com wrote:
  From: Christopher James Halse Rogers 
  christopher.halse.rog...@canonical.com
 http://cgit.freedesktop.org/~keithp/mesa/log/?h=dri3
 

Sure, why not? I don't really mind which series goes in - although I
think my patch series is more close to correct, as it won't break in
interesting ways on non-nvidia hardware.

You're welcome to roll the different patches into that branch if you
like.

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 00/11] Core mesa changes for ARB_shader_image_load_store.

2013-11-24 Thread Francisco Jerez
This is the first of three patch series enabling basic support for
ARB_shader_image_load_store on Intel Gen7 (and Gen7.5) hardware.  Most
of the necessary core mesa changes are part of this batch (except the
one patch that depends on GLSL changes).  I'll be sending a second
batch with the GLSL compiler changes shortly, and in at most a few
days a third, considerably more complex batch with the i965 driver and
compiler back-end changes.

I'll be pushing my patches here [1] as they come out so it's easy to
download and test all the dependencies together.

Thanks.

[1] http://cgit.freedesktop.org/~currojerez/mesa/log/?h=image-load-store

[PATCH 01/11] glapi: Update dispatch XML files for ARB_shader_image_load_store.
[PATCH 02/11] mesa: Add ARB_shader_image_load_store to the extension table.
[PATCH 03/11] mesa: Add state data structures requried for 
ARB_shader_image_load_store.
[PATCH 04/11] mesa: Add driver interface for ARB_shader_image_load_store.
[PATCH 05/11] mesa: Add image parameter queries for ARB_shader_image_load_store.
[PATCH 06/11] mesa: Add MESA_FORMAT_ABGR2101010.
[PATCH 07/11] mesa: Add MESA_FORMAT_SIGNED_RG88 and _RG1616.
[PATCH 08/11] mesa: Implement the GL entry points defined by 
ARB_shader_image_load_store.
[PATCH 09/11] mesa: Unbind deleted textures from the shader image units.
[PATCH 10/11] mesa: Validate image units when the texture state changes.
[PATCH 11/11] docs: Mark ARB_shader_image_load_store as work in progress.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 03/11] mesa: Add state data structures requried for ARB_shader_image_load_store.

2013-11-24 Thread Francisco Jerez
---
 src/mesa/main/config.h |   1 +
 src/mesa/main/dd.h |   1 +
 src/mesa/main/mtypes.h | 100 +
 src/mesa/main/texobj.c |   1 +
 4 files changed, 103 insertions(+)

diff --git a/src/mesa/main/config.h b/src/mesa/main/config.h
index 22bbfa0..8bd9765 100644
--- a/src/mesa/main/config.h
+++ b/src/mesa/main/config.h
@@ -175,6 +175,7 @@
 #define MAX_COMBINED_ATOMIC_BUFFERS(MAX_UNIFORM_BUFFERS * 6)
 /* Size of an atomic counter in bytes according to ARB_shader_atomic_counters 
*/
 #define ATOMIC_COUNTER_SIZE4
+#define MAX_IMAGE_UNITS32
 /*@}*/
 
 /**
diff --git a/src/mesa/main/dd.h b/src/mesa/main/dd.h
index b5b874f..648062f 100644
--- a/src/mesa/main/dd.h
+++ b/src/mesa/main/dd.h
@@ -39,6 +39,7 @@ struct gl_buffer_object;
 struct gl_context;
 struct gl_display_list;
 struct gl_framebuffer;
+struct gl_image_unit;
 struct gl_pixelstore_attrib;
 struct gl_program;
 struct gl_renderbuffer;
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index e9750f4..7be0664 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -1207,6 +1207,9 @@ struct gl_texture_object
 
/** GL_OES_EGL_image_external */
GLint RequiredTextureImageUnits;
+
+   /** GL_ARB_shader_image_load_store */
+   GLenum ImageFormatCompatibility;
 };
 
 
@@ -2373,6 +2376,29 @@ struct gl_shader
 */
   GLenum OutputType;
} Geom;
+
+   /**
+* Map from image uniform index to image unit (set by glUniform1i())
+*
+* An image uniform index is associated with each image uniform by
+* the linker.  The image index associated with each uniform is
+* stored in the \c gl_uniform_storage::image field.
+*/
+   GLubyte ImageUnits[MAX_IMAGE_UNITS];
+
+   /**
+* Access qualifier specified in the shader for each image uniform.
+* Either \c GL_READ_ONLY, \c GL_WRITE_ONLY or \c GL_READ_WRITE.
+*
+* It may be different, though only more strict than the value of
+* \c gl_image_unit::Access for the corresponding image unit.
+*/
+   GLenum ImageAccess[MAX_IMAGE_UNITS];
+
+   /**
+* Number of image uniforms defined in the shader.
+*/
+   GLuint NumImages;
 };
 
 
@@ -3077,9 +3103,13 @@ struct gl_program_constants
GLuint MaxUniformBlocks;
GLuint MaxCombinedUniformComponents;
GLuint MaxTextureImageUnits;
+
/* GL_ARB_shader_atomic_counters */
GLuint MaxAtomicBuffers;
GLuint MaxAtomicCounters;
+
+   /* GL_ARB_shader_image_load_store */
+   GLuint MaxImageUniforms;
 };
 
 
@@ -3302,6 +3332,12 @@ struct gl_constants
/** GL_ARB_vertex_attrib_binding */
GLint MaxVertexAttribRelativeOffset;
GLint MaxVertexAttribBindings;
+
+   /* GL_ARB_shader_image_load_store */
+   GLuint MaxImageUnits;
+   GLuint MaxCombinedImageUnitsAndFragmentOutputs;
+   GLuint MaxImageSamples;
+   GLuint MaxCombinedImageUniforms;
 };
 
 
@@ -3727,6 +3763,11 @@ struct gl_driver_flags
 * gl_context::AtomicBufferBindings
 */
GLbitfield NewAtomicBuffer;
+
+   /**
+* gl_context::ImageUnits
+*/
+   GLbitfield NewImageUnits;
 };
 
 struct gl_uniform_buffer_binding
@@ -3744,6 +3785,60 @@ struct gl_uniform_buffer_binding
 };
 
 /**
+ * ARB_shader_image_load_store image unit.
+ */
+struct gl_image_unit
+{
+   /**
+* Texture object bound to this unit.
+*/
+   struct gl_texture_object *TexObj;
+
+   /**
+* Level of the texture object bound to this unit.
+*/
+   GLuint Level;
+
+   /**
+* \c GL_TRUE if the whole level is bound as an array of layers, \c
+* GL_FALSE if only some specific layer of the texture is bound.
+* \sa Layer
+*/
+   GLboolean Layered;
+
+   /**
+* Layer of the texture object bound to this unit, or zero if \c
+* Layered is \c GL_TRUE.
+*/
+   GLuint Layer;
+
+   /**
+* Access allowed to this texture image.  Either \c GL_READ_ONLY,
+* \c GL_WRITE_ONLY or \c GL_READ_WRITE.
+*/
+   GLenum Access;
+
+   /**
+* GL internal format that determines the interpretation of the
+* image memory when shader image operations are performed through
+* this unit.
+*/
+   GLenum Format;
+
+   /**
+* Mesa format corresponding to \c Format.
+*/
+   gl_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;
+};
+
+/**
  * Binding point for an atomic counter buffer object.
  */
 struct gl_atomic_buffer_binding
@@ -3933,6 +4028,11 @@ struct gl_context
struct gl_atomic_buffer_binding
   AtomicBufferBindings[MAX_COMBINED_ATOMIC_BUFFERS];
 
+   /**
+* Array of image units for ARB_shader_image_load_store.
+*/
+   struct gl_image_unit ImageUnits[MAX_IMAGE_UNITS];
+
/*@}*/
 
struct gl_meta_state *Meta;  /** for meta operations */
diff --git a/src/mesa/main/texobj.c b/src/mesa/main/texobj.c
index 

[Mesa-dev] [PATCH 10/11] mesa: Validate image units when the texture state changes.

2013-11-24 Thread Francisco Jerez
---
 src/mesa/main/shaderimage.c | 11 +++
 src/mesa/main/shaderimage.h |  9 +
 src/mesa/main/texstate.c|  3 +++
 3 files changed, 23 insertions(+)

diff --git a/src/mesa/main/shaderimage.c b/src/mesa/main/shaderimage.c
index 627366b..3a59409 100644
--- a/src/mesa/main/shaderimage.c
+++ b/src/mesa/main/shaderimage.c
@@ -368,6 +368,17 @@ validate_image_unit(struct gl_context *ctx, struct 
gl_image_unit *u)
return GL_TRUE;
 }
 
+void
+_mesa_validate_image_units(struct gl_context *ctx)
+{
+   int i;
+
+   for (i = 0; i  ctx-Const.MaxImageUnits; ++i) {
+  struct gl_image_unit *u = ctx-ImageUnits[i];
+  u-_Valid = validate_image_unit(ctx, u);
+   }
+}
+
 static GLboolean
 validate_bind_image_texture(struct gl_context *ctx, GLuint unit,
 GLuint texture, GLint level, GLboolean layered,
diff --git a/src/mesa/main/shaderimage.h b/src/mesa/main/shaderimage.h
index f9d550b..aaecc5d 100644
--- a/src/mesa/main/shaderimage.h
+++ b/src/mesa/main/shaderimage.h
@@ -31,6 +31,15 @@
 
 struct gl_context;
 
+/**
+ * Recalculate the \c _Valid flag of a context's shader image units.
+ *
+ * To be called when the state of any texture bound to an image unit
+ * changes.
+ */
+void
+_mesa_validate_image_units(struct gl_context *ctx);
+
 void GLAPIENTRY
 _mesa_BindImageTexture(GLuint unit, GLuint texture, GLint level,
GLboolean layered, GLint layer, GLenum access,
diff --git a/src/mesa/main/texstate.c b/src/mesa/main/texstate.c
index ad80dcf..7720965 100644
--- a/src/mesa/main/texstate.c
+++ b/src/mesa/main/texstate.c
@@ -35,6 +35,7 @@
 #include context.h
 #include enums.h
 #include macros.h
+#include shaderimage.h
 #include texobj.h
 #include teximage.h
 #include texstate.h
@@ -674,6 +675,8 @@ update_texture_state( struct gl_context *ctx )
 
if (!fprog || !vprog)
   update_texgen(ctx);
+
+   _mesa_validate_image_units(ctx);
 }
 
 
-- 
1.8.3.4

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 04/11] mesa: Add driver interface for ARB_shader_image_load_store.

2013-11-24 Thread Francisco Jerez
---
 src/mesa/main/dd.h | 13 +
 1 file changed, 13 insertions(+)

diff --git a/src/mesa/main/dd.h b/src/mesa/main/dd.h
index 648062f..7a4c0a7 100644
--- a/src/mesa/main/dd.h
+++ b/src/mesa/main/dd.h
@@ -900,6 +900,19 @@ struct dd_function_table {
 * non-zero status should be returned for the duration of the reset.
 */
GLenum (*GetGraphicsResetStatus)(struct gl_context *ctx);
+
+   /**
+* \name GL_ARB_shader_image_load_store interface.
+*/
+   /** @{ */
+   void (*BindImageTexture)(struct gl_context *ctx,
+struct gl_image_unit *unit,
+struct gl_texture_object *texObj,
+GLint level, GLboolean layered, GLint layer,
+GLenum access, GLenum format);
+
+   void (*MemoryBarrier)(struct gl_context *ctx, GLbitfield barriers);
+   /** @} */
 };
 
 
-- 
1.8.3.4

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 06/11] mesa: Add MESA_FORMAT_ABGR2101010.

2013-11-24 Thread Francisco Jerez
Including pack/unpack and texstore code.  This texture format is a
requirement for ARB_shader_image_load_store.
---
 src/mesa/main/format_pack.c   | 29 +++
 src/mesa/main/format_unpack.c | 32 ++
 src/mesa/main/formats.c   | 19 ++
 src/mesa/main/formats.h   |  2 ++
 src/mesa/main/texstore.c  | 46 +++
 src/mesa/swrast/s_texfetch.c  |  6 ++
 6 files changed, 134 insertions(+)

diff --git a/src/mesa/main/format_pack.c b/src/mesa/main/format_pack.c
index 826fc10..9b6929d 100644
--- a/src/mesa/main/format_pack.c
+++ b/src/mesa/main/format_pack.c
@@ -1824,6 +1824,31 @@ pack_float_XBGR32323232_FLOAT(const GLfloat src[4], void 
*dst)
d[3] = 1.0;
 }
 
+/* MESA_FORMAT_ABGR2101010 */
+
+static void
+pack_ubyte_ABGR2101010(const GLubyte src[4], void *dst)
+{
+   GLuint *d = ((GLuint *) dst);
+   GLushort r = UBYTE_TO_USHORT(src[RCOMP]);
+   GLushort g = UBYTE_TO_USHORT(src[GCOMP]);
+   GLushort b = UBYTE_TO_USHORT(src[BCOMP]);
+   GLushort a = UBYTE_TO_USHORT(src[ACOMP]);
+   *d = PACK_COLOR_2101010_US(a, b, g, r);
+}
+
+static void
+pack_float_ABGR2101010(const GLfloat src[4], void *dst)
+{
+   GLuint *d = ((GLuint *) dst);
+   GLushort r, g, b, a;
+   UNCLAMPED_FLOAT_TO_USHORT(r, src[RCOMP]);
+   UNCLAMPED_FLOAT_TO_USHORT(g, src[GCOMP]);
+   UNCLAMPED_FLOAT_TO_USHORT(b, src[BCOMP]);
+   UNCLAMPED_FLOAT_TO_USHORT(a, src[ACOMP]);
+   *d = PACK_COLOR_2101010_US(a, b, g, r);
+}
+
 
 /**
  * Return a function that can pack a GLubyte rgba[4] color.
@@ -1978,6 +2003,8 @@ _mesa_get_pack_ubyte_rgba_function(gl_format format)
   table[MESA_FORMAT_XBGR32323232_UINT] = NULL;
   table[MESA_FORMAT_XBGR32323232_SINT] = NULL;
 
+  table[MESA_FORMAT_ABGR2101010] = pack_ubyte_ABGR2101010;
+
   initialized = GL_TRUE;
}
 
@@ -2136,6 +2163,8 @@ _mesa_get_pack_float_rgba_function(gl_format format)
   table[MESA_FORMAT_XBGR32323232_UINT] = NULL;
   table[MESA_FORMAT_XBGR32323232_SINT] = NULL;
 
+  table[MESA_FORMAT_ABGR2101010] = pack_float_ABGR2101010;
+
   initialized = GL_TRUE;
}
 
diff --git a/src/mesa/main/format_unpack.c b/src/mesa/main/format_unpack.c
index 0a8b8b1..fa55930 100644
--- a/src/mesa/main/format_unpack.c
+++ b/src/mesa/main/format_unpack.c
@@ -2268,6 +2268,18 @@ unpack_XBGR32323232_SINT(const void *src, GLfloat 
dst[][4], GLuint n)
}
 }
 
+static void
+unpack_ABGR2101010(const void *src, GLfloat dst[][4], GLuint n)
+{
+   const GLuint *s = ((const GLuint *) src);
+   GLuint i;
+   for (i = 0; i  n; i++) {
+  dst[i][RCOMP] = ((s[i]  0)  0x3ff) * (1.0F / 1023.0F);
+  dst[i][GCOMP] = ((s[i]  10)  0x3ff) * (1.0F / 1023.0F);
+  dst[i][BCOMP] = ((s[i]  20)  0x3ff) * (1.0F / 1023.0F);
+  dst[i][ACOMP] = ((s[i]  30)   0x03) * (1.0F / 3.0F);
+   }
+}
 
 /**
  * Return the unpacker function for the given format.
@@ -2481,6 +2493,8 @@ get_unpack_rgba_function(gl_format format)
   table[MESA_FORMAT_XBGR32323232_UINT] = unpack_XBGR32323232_UINT;
   table[MESA_FORMAT_XBGR32323232_SINT] = unpack_XBGR32323232_SINT;
 
+  table[MESA_FORMAT_ABGR2101010] = unpack_ABGR2101010;
+
   initialized = GL_TRUE;
}
 
@@ -3582,6 +3596,20 @@ unpack_int_rgba_XBGR32323232_UINT(const GLuint *src, 
GLuint dst[][4], GLuint n)
}
 }
 
+static void
+unpack_int_rgba_ABGR2101010(const GLuint *src, GLuint dst[][4], GLuint n)
+{
+   unsigned int i;
+
+   for (i = 0; i  n; i++) {
+  GLuint tmp = src[i];
+  dst[i][0] = (tmp  0)  0x3ff;
+  dst[i][1] = (tmp  10)  0x3ff;
+  dst[i][2] = (tmp  20)  0x3ff;
+  dst[i][3] = (tmp  30)  0x3;
+   }
+}
+
 void
 _mesa_unpack_uint_rgba_row(gl_format format, GLuint n,
const void *src, GLuint dst[][4])
@@ -3782,6 +3810,10 @@ _mesa_unpack_uint_rgba_row(gl_format format, GLuint n,
   unpack_int_rgba_XBGR32323232_UINT(src, dst, n);
   break;
 
+   case MESA_FORMAT_ABGR2101010:
+  unpack_int_rgba_ABGR2101010(src, dst, n);
+  break;
+
default:
   _mesa_problem(NULL, %s: bad format %s, __FUNCTION__,
 _mesa_get_format_name(format));
diff --git a/src/mesa/main/formats.c b/src/mesa/main/formats.c
index 07d2a72..c1ad0a3 100644
--- a/src/mesa/main/formats.c
+++ b/src/mesa/main/formats.c
@@ -1763,6 +1763,15 @@ static struct gl_format_info 
format_info[MESA_FORMAT_COUNT] =
   0, 0, 0, 0, 0,
   1, 1, 16
},
+   {
+  MESA_FORMAT_ABGR2101010,
+  MESA_FORMAT_ABGR2101010,
+  GL_RGBA,
+  GL_UNSIGNED_NORMALIZED,
+  10, 10, 10, 2,
+  0, 0, 0, 0, 0,
+  1, 1, 4
+   },
 };
 
 
@@ -2821,6 +2830,11 @@ _mesa_format_to_type_and_comps(gl_format format,
   *comps = 4;
   return;
 
+   case MESA_FORMAT_ABGR2101010:
+  *datatype = GL_UNSIGNED_INT_2_10_10_10_REV;
+  *comps = 4;
+  return;
+
case MESA_FORMAT_COUNT:
   assert(0);
   return;
@@ -3362,6 +3376,11 @@ 

[Mesa-dev] [PATCH 07/11] mesa: Add MESA_FORMAT_SIGNED_RG88 and _RG1616.

2013-11-24 Thread Francisco Jerez
Including pack/unpack and texstore code.  ARB_shader_image_load_store
requires support for the GL_RG8_SNORM and GL_RG16_SNORM formats, which
map to MESA_FORMAT_SIGNED_GR88 and MESA_FORMAT_SIGNED_GR1616 on
little-endian hosts, and MESA_FORMAT_SIGNED_RG88 and
MESA_FORMAT_SIGNED_RG1616 respectively on big-endian hosts -- only the
former were already present, add support for the latter.
---
 src/mesa/main/format_pack.c   | 28 
 src/mesa/main/format_unpack.c | 29 
 src/mesa/main/formats.c   | 35 +
 src/mesa/main/formats.h   |  3 +++
 src/mesa/main/texstore.c  | 61 ---
 src/mesa/swrast/s_texfetch.c  | 12 +
 6 files changed, 153 insertions(+), 15 deletions(-)

diff --git a/src/mesa/main/format_pack.c b/src/mesa/main/format_pack.c
index 9b6929d..49287e3 100644
--- a/src/mesa/main/format_pack.c
+++ b/src/mesa/main/format_pack.c
@@ -1849,6 +1849,31 @@ pack_float_ABGR2101010(const GLfloat src[4], void *dst)
*d = PACK_COLOR_2101010_US(a, b, g, r);
 }
 
+/*
+ * MESA_FORMAT_SIGNED_RG88
+ */
+
+static void
+pack_float_SIGNED_RG88(const GLfloat src[4], void *dst)
+{
+   GLushort *d = (GLushort *) dst;
+   GLbyte r = FLOAT_TO_BYTE(CLAMP(src[RCOMP], -1.0f, 1.0f));
+   GLbyte g = FLOAT_TO_BYTE(CLAMP(src[GCOMP], -1.0f, 1.0f));
+   *d = (r  8) | g;
+}
+
+/*
+ * MESA_FORMAT_SIGNED_RG1616
+ */
+
+static void
+pack_float_SIGNED_RG1616(const GLfloat src[4], void *dst)
+{
+   GLuint *d = (GLuint *) dst;
+   GLshort r = FLOAT_TO_SHORT(CLAMP(src[RCOMP], -1.0f, 1.0f));
+   GLshort g = FLOAT_TO_SHORT(CLAMP(src[GCOMP], -1.0f, 1.0f));
+   *d = (r  16) | (g  0x);
+}
 
 /**
  * Return a function that can pack a GLubyte rgba[4] color.
@@ -2165,6 +2190,9 @@ _mesa_get_pack_float_rgba_function(gl_format format)
 
   table[MESA_FORMAT_ABGR2101010] = pack_float_ABGR2101010;
 
+  table[MESA_FORMAT_SIGNED_RG88] = pack_float_SIGNED_RG88;
+  table[MESA_FORMAT_SIGNED_RG1616] = pack_float_SIGNED_RG1616;
+
   initialized = GL_TRUE;
}
 
diff --git a/src/mesa/main/format_unpack.c b/src/mesa/main/format_unpack.c
index fa55930..28a50f3 100644
--- a/src/mesa/main/format_unpack.c
+++ b/src/mesa/main/format_unpack.c
@@ -2281,6 +2281,32 @@ unpack_ABGR2101010(const void *src, GLfloat dst[][4], 
GLuint n)
}
 }
 
+static void
+unpack_SIGNED_RG88(const void *src, GLfloat dst[][4], GLuint n)
+{
+   const GLushort *s = ((const GLushort *) src);
+   GLuint i;
+   for (i = 0; i  n; i++) {
+  dst[i][RCOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s[i]  8) );
+  dst[i][GCOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s[i]  0xff) );
+  dst[i][BCOMP] = 0.0F;
+  dst[i][ACOMP] = 1.0F;
+   }
+}
+
+static void
+unpack_SIGNED_RG1616(const void *src, GLfloat dst[][4], GLuint n)
+{
+   const GLuint *s = ((const GLuint *) src);
+   GLuint i;
+   for (i = 0; i  n; i++) {
+  dst[i][RCOMP] = SHORT_TO_FLOAT_TEX( (GLshort) (s[i]  16) );
+  dst[i][GCOMP] = SHORT_TO_FLOAT_TEX( (GLshort) (s[i]  0x) );
+  dst[i][BCOMP] = 0.0F;
+  dst[i][ACOMP] = 1.0F;
+   }
+}
+
 /**
  * Return the unpacker function for the given format.
  */
@@ -2495,6 +2521,9 @@ get_unpack_rgba_function(gl_format format)
 
   table[MESA_FORMAT_ABGR2101010] = unpack_ABGR2101010;
 
+  table[MESA_FORMAT_SIGNED_RG88] = unpack_SIGNED_RG88;
+  table[MESA_FORMAT_SIGNED_RG1616] = unpack_SIGNED_RG1616;
+
   initialized = GL_TRUE;
}
 
diff --git a/src/mesa/main/formats.c b/src/mesa/main/formats.c
index c1ad0a3..4292e9e 100644
--- a/src/mesa/main/formats.c
+++ b/src/mesa/main/formats.c
@@ -1772,6 +1772,24 @@ static struct gl_format_info 
format_info[MESA_FORMAT_COUNT] =
   0, 0, 0, 0, 0,
   1, 1, 4
},
+   {
+  MESA_FORMAT_SIGNED_RG88,
+  MESA_FORMAT_SIGNED_RG88,
+  GL_RG,
+  GL_SIGNED_NORMALIZED,
+  8, 8, 0, 0,
+  0, 0, 0, 0, 0,
+  1, 1, 2
+   },
+   {
+  MESA_FORMAT_SIGNED_RG1616,
+  MESA_FORMAT_SIGNED_RG1616,
+  GL_RG,
+  GL_SIGNED_NORMALIZED,
+  16, 16, 0, 0,
+  0, 0, 0, 0, 0,
+  1, 1, 4
+   },
 };
 
 
@@ -2835,6 +2853,16 @@ _mesa_format_to_type_and_comps(gl_format format,
   *comps = 4;
   return;
 
+   case MESA_FORMAT_SIGNED_RG88:
+  *datatype = GL_BYTE;
+  *comps = 2;
+  return;
+
+   case MESA_FORMAT_SIGNED_RG1616:
+  *datatype = GL_SHORT;
+  *comps = 2;
+  return;
+
case MESA_FORMAT_COUNT:
   assert(0);
   return;
@@ -3381,6 +3409,13 @@ _mesa_format_matches_format_and_type(gl_format gl_format,
   return format == GL_RGBA  type == GL_UNSIGNED_INT_2_10_10_10_REV 
  !swapBytes;
 
+   case MESA_FORMAT_SIGNED_RG88:
+  return format == GL_RG  type == GL_BYTE  !littleEndian 
+ !swapBytes;
+
+   case MESA_FORMAT_SIGNED_RG1616:
+  return format == GL_RG  type == GL_SHORT  !littleEndian 
+ !swapBytes;
}
 
return GL_FALSE;
diff --git a/src/mesa/main/formats.h b/src/mesa/main/formats.h
index 

[Mesa-dev] [PATCH 11/11] docs: Mark ARB_shader_image_load_store as work in progress.

2013-11-24 Thread Francisco Jerez
---
 docs/GL3.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/docs/GL3.txt b/docs/GL3.txt
index 5f6fa7e..d6a1a1e 100644
--- a/docs/GL3.txt
+++ b/docs/GL3.txt
@@ -130,7 +130,7 @@ GL 4.2:
   GL_ARB_texture_storage   DONE (all drivers)
   GL_ARB_transform_feedback_instanced  DONE (i965, r600, 
radeonsi)
   GL_ARB_base_instance DONE (i965, nv50, nvc0, 
r600, radeonsi)
-  GL_ARB_shader_image_load_store   not started
+  GL_ARB_shader_image_load_store   in progress (curro)
   GL_ARB_conservative_depthDONE (all drivers that 
support GLSL 1.30)
   GL_ARB_shading_language_420pack  DONE (all drivers that 
support GLSL 1.30)
   GL_ARB_internalformat_query  DONE (i965, r300, r600, 
radeonsi)
-- 
1.8.3.4

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 08/11] mesa: Implement the GL entry points defined by ARB_shader_image_load_store.

2013-11-24 Thread Francisco Jerez
---
 src/mapi/glapi/gen/gl_genexec.py |   1 +
 src/mesa/Makefile.sources|   1 +
 src/mesa/main/shaderimage.c  | 457 +++
 src/mesa/main/shaderimage.h  |  42 
 4 files changed, 501 insertions(+)
 create mode 100644 src/mesa/main/shaderimage.c
 create mode 100644 src/mesa/main/shaderimage.h

diff --git a/src/mapi/glapi/gen/gl_genexec.py b/src/mapi/glapi/gen/gl_genexec.py
index 3ce190f..334a4bf 100644
--- a/src/mapi/glapi/gen/gl_genexec.py
+++ b/src/mapi/glapi/gen/gl_genexec.py
@@ -107,6 +107,7 @@ header = /**
 #include main/varray.h
 #include main/viewport.h
 #include main/shaderapi.h
+#include main/shaderimage.h
 #include main/uniforms.h
 #include main/syncobj.h
 #include main/formatquery.h
diff --git a/src/mesa/Makefile.sources b/src/mesa/Makefile.sources
index a84f8a7..7c67145 100644
--- a/src/mesa/Makefile.sources
+++ b/src/mesa/Makefile.sources
@@ -81,6 +81,7 @@ MAIN_FILES = \
$(SRCDIR)main/scissor.c \
$(SRCDIR)main/set.c \
$(SRCDIR)main/shaderapi.c \
+   $(SRCDIR)main/shaderimage.c \
$(SRCDIR)main/shaderobj.c \
$(SRCDIR)main/shader_query.cpp \
$(SRCDIR)main/shared.c \
diff --git a/src/mesa/main/shaderimage.c b/src/mesa/main/shaderimage.c
new file mode 100644
index 000..627366b
--- /dev/null
+++ b/src/mesa/main/shaderimage.c
@@ -0,0 +1,457 @@
+/*
+ * Copyright 2013 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the Software),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Authors:
+ *Francisco Jerez curroje...@riseup.net
+ */
+
+#include assert.h
+
+#include shaderimage.h
+#include mtypes.h
+#include formats.h
+#include errors.h
+#include context.h
+#include texobj.h
+
+/*
+ * Define endian-invariant aliases for some mesa formats that are
+ * defined in terms of their channel layout from LSB to MSB in a
+ * 32-bit word.  The actual byte offsets matter here because the user
+ * is allowed to bit-cast one format into another and get predictable
+ * results.
+ */
+#ifdef MESA_BIG_ENDIAN
+# define MESA_FORMAT_RGBA_8 MESA_FORMAT_RGBA
+# define MESA_FORMAT_RG_16 MESA_FORMAT_RG1616
+# define MESA_FORMAT_RG_8 MESA_FORMAT_RG88
+# define MESA_FORMAT_SIGNED_RGBA_8 MESA_FORMAT_SIGNED_RGBA
+# define MESA_FORMAT_SIGNED_RG_16 MESA_FORMAT_SIGNED_RG1616
+# define MESA_FORMAT_SIGNED_RG_8 MESA_FORMAT_SIGNED_RG88
+#else
+# define MESA_FORMAT_RGBA_8 MESA_FORMAT_RGBA_REV
+# define MESA_FORMAT_RG_16 MESA_FORMAT_GR1616
+# define MESA_FORMAT_RG_8 MESA_FORMAT_GR88
+# define MESA_FORMAT_SIGNED_RGBA_8 MESA_FORMAT_SIGNED_RGBA_REV
+# define MESA_FORMAT_SIGNED_RG_16 MESA_FORMAT_SIGNED_GR1616
+# define MESA_FORMAT_SIGNED_RG_8 MESA_FORMAT_SIGNED_RG88_REV
+#endif
+
+static gl_format
+get_image_format(GLenum format)
+{
+   switch (format) {
+   case GL_RGBA32F:
+  return MESA_FORMAT_RGBA_FLOAT32;
+
+   case GL_RGBA16F:
+  return MESA_FORMAT_RGBA_FLOAT16;
+
+   case GL_RG32F:
+  return MESA_FORMAT_RG_FLOAT32;
+
+   case GL_RG16F:
+  return MESA_FORMAT_RG_FLOAT16;
+
+   case GL_R11F_G11F_B10F:
+  return MESA_FORMAT_R11_G11_B10_FLOAT;
+
+   case GL_R32F:
+  return MESA_FORMAT_R_FLOAT32;
+
+   case GL_R16F:
+  return MESA_FORMAT_R_FLOAT16;
+
+   case GL_RGBA32UI:
+  return MESA_FORMAT_RGBA_UINT32;
+
+   case GL_RGBA16UI:
+  return MESA_FORMAT_RGBA_UINT16;
+
+   case GL_RGB10_A2UI:
+  return MESA_FORMAT_ABGR2101010_UINT;
+
+   case GL_RGBA8UI:
+  return MESA_FORMAT_RGBA_UINT8;
+
+   case GL_RG32UI:
+  return MESA_FORMAT_RG_UINT32;
+
+   case GL_RG16UI:
+  return MESA_FORMAT_RG_UINT16;
+
+   case GL_RG8UI:
+  return MESA_FORMAT_RG_UINT8;
+
+   case GL_R32UI:
+  return MESA_FORMAT_R_UINT32;
+
+   case GL_R16UI:
+  return MESA_FORMAT_R_UINT16;
+
+   case GL_R8UI:
+  return MESA_FORMAT_R_UINT8;
+
+   case GL_RGBA32I:
+  return MESA_FORMAT_RGBA_INT32;
+
+   case GL_RGBA16I:
+  return MESA_FORMAT_RGBA_INT16;
+
+   case 

[Mesa-dev] [PATCH 01/11] glapi: Update dispatch XML files for ARB_shader_image_load_store.

2013-11-24 Thread Francisco Jerez
And uncomment the relevant lines of the dispatch sanity test.
---
 src/mapi/glapi/gen/ARB_shader_image_load_store.xml | 89 ++
 src/mapi/glapi/gen/Makefile.am |  1 +
 src/mapi/glapi/gen/gl_API.xml  |  2 +
 src/mesa/main/tests/dispatch_sanity.cpp|  4 +-
 4 files changed, 94 insertions(+), 2 deletions(-)
 create mode 100644 src/mapi/glapi/gen/ARB_shader_image_load_store.xml

diff --git a/src/mapi/glapi/gen/ARB_shader_image_load_store.xml 
b/src/mapi/glapi/gen/ARB_shader_image_load_store.xml
new file mode 100644
index 000..9dfd76d
--- /dev/null
+++ b/src/mapi/glapi/gen/ARB_shader_image_load_store.xml
@@ -0,0 +1,89 @@
+?xml version=1.0?
+!DOCTYPE OpenGLAPI SYSTEM gl_API.dtd
+
+OpenGLAPI
+
+category name=GL_ARB_shader_image_load_store number=115
+
+enum name=VERTEX_ATTRIB_ARRAY_BARRIER_BIT value=0x0001/
+enum name=ELEMENT_ARRAY_BARRIER_BIT value=0x0002/
+enum name=UNIFORM_BARRIER_BIT value=0x0004/
+enum name=TEXTURE_FETCH_BARRIER_BIT value=0x0008/
+enum name=SHADER_IMAGE_ACCESS_BARRIER_BIT value=0x0020/
+enum name=COMMAND_BARRIER_BIT value=0x0040/
+enum name=PIXEL_BUFFER_BARRIER_BIT value=0x0080/
+enum name=TEXTURE_UPDATE_BARRIER_BIT value=0x0100/
+enum name=BUFFER_UPDATE_BARRIER_BIT value=0x0200/
+enum name=FRAMEBUFFER_BARRIER_BIT value=0x0400/
+enum name=TRANSFORM_FEEDBACK_BARRIER_BIT value=0x0800/
+enum name=ATOMIC_COUNTER_BARRIER_BIT value=0x1000/
+enum name=ALL_BARRIER_BITS value=0x/
+enum name=MAX_IMAGE_UNITS value=0x8F38/
+enum name=MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS value=0x8F39/
+enum name=IMAGE_BINDING_NAME value=0x8F3A/
+enum name=IMAGE_BINDING_LEVEL value=0x8F3B/
+enum name=IMAGE_BINDING_LAYERED value=0x8F3C/
+enum name=IMAGE_BINDING_LAYERED_EXT value=0x8F3C/
+enum name=IMAGE_BINDING_ACCESS value=0x8F3E/
+enum name=IMAGE_1D value=0x904C/
+enum name=IMAGE_2D value=0x904D/
+enum name=IMAGE_3D value=0x904E/
+enum name=IMAGE_2D_RECT value=0x904F/
+enum name=IMAGE_CUBE value=0x9050/
+enum name=IMAGE_BUFFER value=0x9051/
+enum name=IMAGE_1D_ARRAY value=0x9052/
+enum name=IMAGE_2D_ARRAY value=0x9053/
+enum name=IMAGE_CUBE_MAP_ARRAY value=0x9054/
+enum name=IMAGE_2D_MULTISAMPLE value=0x9055/
+enum name=IMAGE_2D_MULTISAMPLE_ARRAY value=0x9056/
+enum name=INT_IMAGE_1D value=0x9057/
+enum name=INT_IMAGE_2D value=0x9058/
+enum name=INT_IMAGE_3D value=0x9059/
+enum name=INT_IMAGE_2D_RECT value=0x905A/
+enum name=INT_IMAGE_CUBE value=0x905B/
+enum name=INT_IMAGE_BUFFER value=0x905C/
+enum name=INT_IMAGE_1D_ARRAY value=0x905D/
+enum name=INT_IMAGE_2D_ARRAY value=0x905E/
+enum name=INT_IMAGE_CUBE_MAP_ARRAY value=0x905F/
+enum name=INT_IMAGE_2D_MULTISAMPLE value=0x9060/
+enum name=INT_IMAGE_2D_MULTISAMPLE_ARRAY value=0x9061/
+enum name=UNSIGNED_INT_IMAGE_1D value=0x9062/
+enum name=UNSIGNED_INT_IMAGE_2D value=0x9063/
+enum name=UNSIGNED_INT_IMAGE_3D value=0x9064/
+enum name=UNSIGNED_INT_IMAGE_2D_RECT value=0x9065/
+enum name=UNSIGNED_INT_IMAGE_CUBE value=0x9066/
+enum name=UNSIGNED_INT_IMAGE_BUFFER value=0x9067/
+enum name=UNSIGNED_INT_IMAGE_1D_ARRAY value=0x9068/
+enum name=UNSIGNED_INT_IMAGE_2D_ARRAY value=0x9069/
+enum name=UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY value=0x906A/
+enum name=UNSIGNED_INT_IMAGE_2D_MULTISAMPLE value=0x906B/
+enum name=UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY value=0x906C/
+enum name=MAX_IMAGE_SAMPLES value=0x906D/
+enum name=IMAGE_BINDING_FORMAT value=0x906E/
+enum name=IMAGE_FORMAT_COMPATIBILITY_TYPE value=0x90C7/
+enum name=IMAGE_FORMAT_COMPATIBILITY_BY_SIZE value=0x90C8/
+enum name=IMAGE_FORMAT_COMPATIBILITY_BY_CLASS value=0x90C9/
+enum name=MAX_VERTEX_IMAGE_UNIFORMS value=0x90CA/
+enum name=MAX_TESS_CONTROL_IMAGE_UNIFORMS value=0x90CB/
+enum name=MAX_TESS_EVALUATION_IMAGE_UNIFORMS value=0x90CC/
+enum name=MAX_GEOMETRY_IMAGE_UNIFORMS value=0x90CD/
+enum name=MAX_FRAGMENT_IMAGE_UNIFORMS value=0x90CE/
+enum name=MAX_COMBINED_IMAGE_UNIFORMS value=0x90CF/
+
+function name=BindImageTexture offset=assign
+  param name=unit type=GLuint/
+  param name=texture type=GLuint/
+  param name=level type=GLint/
+  param name=layered type=GLboolean/
+  param name=layer type=GLint/
+  param name=access type=GLenum/
+  param name=format type=GLenum/
+/function
+
+function name=MemoryBarrier offset=assign
+  param name=barriers type=GLbitfield/
+/function
+
+/category
+
+/OpenGLAPI
diff --git a/src/mapi/glapi/gen/Makefile.am b/src/mapi/glapi/gen/Makefile.am
index 476d943..120fb3b 100644
--- a/src/mapi/glapi/gen/Makefile.am
+++ b/src/mapi/glapi/gen/Makefile.am
@@ -112,6 +112,7 @@ API_XML = \
ARB_sampler_objects.xml \
ARB_seamless_cube_map.xml \
ARB_shader_atomic_counters.xml \
+   ARB_shader_image_load_store.xml \
ARB_sync.xml \
ARB_texture_buffer_object.xml \
ARB_texture_buffer_range.xml \
diff --git a/src/mapi/glapi/gen/gl_API.xml b/src/mapi/glapi/gen/gl_API.xml
index a2d914a..460dbeb 100644
--- 

[Mesa-dev] [PATCH 05/11] mesa: Add image parameter queries for ARB_shader_image_load_store.

2013-11-24 Thread Francisco Jerez
---
 src/mesa/main/get.c  | 70 
 src/mesa/main/get_hash_params.py |  9 ++
 src/mesa/main/texparam.c |  6 
 3 files changed, 85 insertions(+)

diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c
index eee8550..db77a65 100644
--- a/src/mesa/main/get.c
+++ b/src/mesa/main/get.c
@@ -145,6 +145,7 @@ enum value_extra {
EXTRA_GLSL_130,
EXTRA_EXT_UBO_GS4,
EXTRA_EXT_ATOMICS_GS4,
+   EXTRA_EXT_SHADER_IMAGE_GS4,
 };
 
 #define NO_EXTRA NULL
@@ -338,6 +339,11 @@ static const int 
extra_ARB_shader_atomic_counters_and_geometry_shader[] = {
EXTRA_END
 };
 
+static const int extra_ARB_shader_image_load_store_and_geometry_shader[] = {
+   EXTRA_EXT_SHADER_IMAGE_GS4,
+   EXTRA_END
+};
+
 EXTRA_EXT(ARB_texture_cube_map);
 EXTRA_EXT(MESA_texture_array);
 EXTRA_EXT(NV_fog_distance);
@@ -375,6 +381,7 @@ EXTRA_EXT(ARB_texture_buffer_range);
 EXTRA_EXT(ARB_texture_multisample);
 EXTRA_EXT(ARB_texture_gather);
 EXTRA_EXT(ARB_shader_atomic_counters);
+EXTRA_EXT(ARB_shader_image_load_store);
 
 static const int
 extra_ARB_color_buffer_float_or_glcore[] = {
@@ -1023,6 +1030,11 @@ check_extra(struct gl_context *ctx, const char *func, 
const struct value_desc *d
  api_found = (ctx-Extensions.ARB_shader_atomic_counters 
   _mesa_has_geometry_shaders(ctx));
  break;
+  case EXTRA_EXT_SHADER_IMAGE_GS4:
+ api_check = GL_TRUE;
+ api_found = (ctx-Extensions.ARB_shader_image_load_store 
+  _mesa_has_geometry_shaders(ctx));
+ break;
   case EXTRA_END:
 break;
   default: /* *e is a offset into the extension struct */
@@ -1763,6 +1775,64 @@ find_value_indexed(const char *func, GLenum pname, 
GLuint index, union value *v)
   if (index = ctx-Const.VertexProgram.MaxAttribs)
   goto invalid_value;
   v-value_int = 
ctx-Array.ArrayObj-VertexBinding[VERT_ATTRIB_GENERIC(index)].Stride;
+
+   /* ARB_shader_image_load_store */
+   case GL_IMAGE_BINDING_NAME: {
+  struct gl_texture_object *t;
+
+  if (!ctx-Extensions.ARB_shader_image_load_store)
+ goto invalid_enum;
+  if (index  ctx-Const.MaxImageUnits)
+ goto invalid_value;
+
+  t = ctx-ImageUnits[index].TexObj;
+  v-value_int = (t ? t-Name : 0);
+  return TYPE_INT;
+   }
+
+   case GL_IMAGE_BINDING_LEVEL:
+  if (!ctx-Extensions.ARB_shader_image_load_store)
+ goto invalid_enum;
+  if (index  ctx-Const.MaxImageUnits)
+ goto invalid_value;
+
+  v-value_int = ctx-ImageUnits[index].Level;
+  return TYPE_INT;
+
+   case GL_IMAGE_BINDING_LAYERED:
+  if (!ctx-Extensions.ARB_shader_image_load_store)
+ goto invalid_enum;
+  if (index  ctx-Const.MaxImageUnits)
+ goto invalid_value;
+
+  v-value_int = ctx-ImageUnits[index].Layered;
+  return TYPE_INT;
+
+   case GL_IMAGE_BINDING_LAYER:
+  if (!ctx-Extensions.ARB_shader_image_load_store)
+ goto invalid_enum;
+  if (index  ctx-Const.MaxImageUnits)
+ goto invalid_value;
+
+  v-value_int = ctx-ImageUnits[index].Layer;
+  return TYPE_INT;
+
+   case GL_IMAGE_BINDING_ACCESS:
+  if (!ctx-Extensions.ARB_shader_image_load_store)
+ goto invalid_enum;
+  if (index  ctx-Const.MaxImageUnits)
+ goto invalid_value;
+
+  v-value_int = ctx-ImageUnits[index].Access;
+  return TYPE_INT;
+
+   case GL_IMAGE_BINDING_FORMAT:
+  if (!ctx-Extensions.ARB_shader_image_load_store)
+ goto invalid_enum;
+  if (index  ctx-Const.MaxImageUnits)
+ goto invalid_value;
+
+  v-value_int = ctx-ImageUnits[index].Format;
   return TYPE_INT;
}
 
diff --git a/src/mesa/main/get_hash_params.py b/src/mesa/main/get_hash_params.py
index c961fee..ab7a900 100644
--- a/src/mesa/main/get_hash_params.py
+++ b/src/mesa/main/get_hash_params.py
@@ -741,6 +741,15 @@ descriptor=[
 # GL_ARB_vertex_attrib_binding
   [ MAX_VERTEX_ATTRIB_RELATIVE_OFFSET, 
CONTEXT_ENUM(Const.MaxVertexAttribRelativeOffset), NO_EXTRA ],
   [ MAX_VERTEX_ATTRIB_BINDINGS, 
CONTEXT_ENUM(Const.MaxVertexAttribBindings), NO_EXTRA ],
+
+# GL_ARB_shader_image_load_store
+  [ MAX_IMAGE_UNITS, CONTEXT_INT(Const.MaxImageUnits), 
extra_ARB_shader_image_load_store],
+  [ MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS, 
CONTEXT_INT(Const.MaxCombinedImageUnitsAndFragmentOutputs), 
extra_ARB_shader_image_load_store],
+  [ MAX_IMAGE_SAMPLES, CONTEXT_INT(Const.MaxImageSamples), 
extra_ARB_shader_image_load_store],
+  [ MAX_VERTEX_IMAGE_UNIFORMS, 
CONTEXT_INT(Const.VertexProgram.MaxImageUniforms), 
extra_ARB_shader_image_load_store],
+  [ MAX_GEOMETRY_IMAGE_UNIFORMS, 
CONTEXT_INT(Const.GeometryProgram.MaxImageUniforms), 
extra_ARB_shader_image_load_store_and_geometry_shader],
+  [ MAX_FRAGMENT_IMAGE_UNIFORMS, 
CONTEXT_INT(Const.FragmentProgram.MaxImageUniforms), 
extra_ARB_shader_image_load_store],
+  [ MAX_COMBINED_IMAGE_UNIFORMS, 

[Mesa-dev] [PATCH 09/11] mesa: Unbind deleted textures from the shader image units.

2013-11-24 Thread Francisco Jerez
From ARB_shader_image_load_store:

   If a texture object bound to one or more image units is deleted by
   DeleteTextures, it is detached from each such image unit, as though
   BindImageTexture were called with unit identifying the image unit
   and texture set to zero.
---
 src/mesa/main/texobj.c | 25 +
 1 file changed, 25 insertions(+)

diff --git a/src/mesa/main/texobj.c b/src/mesa/main/texobj.c
index 4f732fc..1da1c4e 100644
--- a/src/mesa/main/texobj.c
+++ b/src/mesa/main/texobj.c
@@ -1098,6 +1098,25 @@ unbind_texobj_from_texunits(struct gl_context *ctx,
 
 
 /**
+ * Check if the given texture object is bound to any shader image unit
+ * and unbind it if that's the case.
+ */
+static void
+unbind_texobj_from_imgunits(struct gl_context *ctx,
+struct gl_texture_object *texObj)
+{
+   int i;
+
+   for (i = 0; i  ctx-Const.MaxImageUnits; i++) {
+  struct gl_image_unit *unit = ctx-ImageUnits[i];
+
+  if (texObj == unit-TexObj)
+ _mesa_reference_texobj(unit-TexObj, NULL);
+   }
+}
+
+
+/**
  * Delete named textures.
  *
  * \param n number of textures to be deleted.
@@ -1144,6 +1163,12 @@ _mesa_DeleteTextures( GLsizei n, const GLuint *textures)
  */
 unbind_texobj_from_texunits(ctx, delObj);
 
+/* Check if this texture is currently bound to any shader
+ * image unit.  If so, unbind it.
+ * See section 3.9.X of GL_ARB_shader_image_load_store.
+ */
+unbind_texobj_from_imgunits(ctx, delObj);
+
 _mesa_unlock_texture(ctx, delObj);
 
 ctx-NewState |= _NEW_TEXTURE;
-- 
1.8.3.4

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 02/11] mesa: Add ARB_shader_image_load_store to the extension table.

2013-11-24 Thread Francisco Jerez
---
 src/mesa/main/extensions.c | 1 +
 src/mesa/main/mtypes.h | 1 +
 2 files changed, 2 insertions(+)

diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c
index 104618c..19cf34d 100644
--- a/src/mesa/main/extensions.c
+++ b/src/mesa/main/extensions.c
@@ -123,6 +123,7 @@ static const struct extension extension_table[] = {
{ GL_ARB_seamless_cube_map,   o(ARB_seamless_cube_map),   
GL, 2009 },
{ GL_ARB_shader_atomic_counters,  
o(ARB_shader_atomic_counters),  GL, 2011 },
{ GL_ARB_shader_bit_encoding, o(ARB_shader_bit_encoding), 
GL, 2010 },
+   { GL_ARB_shader_image_load_store, 
o(ARB_shader_image_load_store), GL, 2011 },
{ GL_ARB_shader_objects,  o(dummy_true),  
GL, 2002 },
{ GL_ARB_shader_stencil_export,   
o(ARB_shader_stencil_export),   GL, 2009 },
{ GL_ARB_shader_texture_lod,  o(ARB_shader_texture_lod),  
GL, 2009 },
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index ecfb5e0..e9750f4 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -3348,6 +3348,7 @@ struct gl_extensions
GLboolean ARB_seamless_cube_map;
GLboolean ARB_shader_atomic_counters;
GLboolean ARB_shader_bit_encoding;
+   GLboolean ARB_shader_image_load_store;
GLboolean ARB_shader_stencil_export;
GLboolean ARB_shader_texture_lod;
GLboolean ARB_shading_language_packing;
-- 
1.8.3.4

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 02/17] Modified softpipe to return 64 in case of PIPE_CAP_MIN_MAP_BUFFER_ALIGNMENT.

2013-11-24 Thread Siavash Eliasi
---
 src/gallium/drivers/softpipe/sp_screen.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/gallium/drivers/softpipe/sp_screen.c 
b/src/gallium/drivers/softpipe/sp_screen.c
index 47ef20e..022b5bf 100644
--- a/src/gallium/drivers/softpipe/sp_screen.c
+++ b/src/gallium/drivers/softpipe/sp_screen.c
@@ -169,7 +169,7 @@ softpipe_get_param(struct pipe_screen *screen, enum 
pipe_cap param)
case PIPE_CAP_START_INSTANCE:
case PIPE_CAP_TEXTURE_MULTISAMPLE:
case PIPE_CAP_MIN_MAP_BUFFER_ALIGNMENT:
-  return 0;
+  return 64;
case PIPE_CAP_QUERY_TIMESTAMP:
case PIPE_CAP_CUBE_MAP_ARRAY:
   return 1;
-- 
1.8.4.2

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 04/17] Modified llvmpipe to return 64 in case of PIPE_CAP_MIN_MAP_BUFFER_ALIGNMENT.

2013-11-24 Thread Siavash Eliasi
---
 src/gallium/drivers/llvmpipe/lp_screen.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/gallium/drivers/llvmpipe/lp_screen.c 
b/src/gallium/drivers/llvmpipe/lp_screen.c
index f61df98..8be1779 100644
--- a/src/gallium/drivers/llvmpipe/lp_screen.c
+++ b/src/gallium/drivers/llvmpipe/lp_screen.c
@@ -220,6 +220,7 @@ llvmpipe_get_param(struct pipe_screen *screen, enum 
pipe_cap param)
case PIPE_CAP_START_INSTANCE:
case PIPE_CAP_TEXTURE_MULTISAMPLE:
case PIPE_CAP_MIN_MAP_BUFFER_ALIGNMENT:
+  return 64;
case PIPE_CAP_CUBE_MAP_ARRAY:
   return 0;
case PIPE_CAP_TEXTURE_BUFFER_OBJECTS:
-- 
1.8.4.2

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 01/17] Modified allocation routine to use alignment of 64 instead of 16.

2013-11-24 Thread Siavash Eliasi
---
 src/gallium/drivers/softpipe/sp_texture.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/gallium/drivers/softpipe/sp_texture.c 
b/src/gallium/drivers/softpipe/sp_texture.c
index 370f2b4..fb20748 100644
--- a/src/gallium/drivers/softpipe/sp_texture.c
+++ b/src/gallium/drivers/softpipe/sp_texture.c
@@ -88,7 +88,7 @@ softpipe_resource_layout(struct pipe_screen *screen,
   return FALSE;
 
if (allocate) {
-  spr-data = align_malloc(buffer_size, 16);
+  spr-data = align_malloc(buffer_size, 64);
   return spr-data != NULL;
}
else {
-- 
1.8.4.2

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 03/17] Modified allocation routines to use alignment of 64 instead of 16.

2013-11-24 Thread Siavash Eliasi
---
 src/gallium/drivers/llvmpipe/lp_texture.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/llvmpipe/lp_texture.c 
b/src/gallium/drivers/llvmpipe/lp_texture.c
index 0088b6a..d1ebeda 100644
--- a/src/gallium/drivers/llvmpipe/lp_texture.c
+++ b/src/gallium/drivers/llvmpipe/lp_texture.c
@@ -261,7 +261,7 @@ llvmpipe_resource_create(struct pipe_screen *_screen,
* read/write always LP_RASTER_BLOCK_SIZE pixels, but the element
* offset doesn't need to be aligned to LP_RASTER_BLOCK_SIZE.
*/
-  lpr-data = align_malloc(bytes + (LP_RASTER_BLOCK_SIZE - 1) * 4 * 
sizeof(float), 16);
+  lpr-data = align_malloc(bytes + (LP_RASTER_BLOCK_SIZE - 1) * 4 * 
sizeof(float), 64);
   /*
* buffers don't really have stride but it's probably safer
* (for code doing same calculations for buffers and textures)
@@ -746,7 +746,7 @@ llvmpipe_get_texture_image_address(struct llvmpipe_resource 
*lpr,
 static void
 alloc_image_data(struct llvmpipe_resource *lpr)
 {
-   uint alignment = MAX2(16, util_cpu_caps.cacheline);
+   uint alignment = MAX2(64, util_cpu_caps.cacheline);
uint level;
uint offset = 0;
 
-- 
1.8.4.2

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 00/17] Newbie Project : Enable ARB_map_buffer_alignment in all drivers

2013-11-24 Thread Siavash Eliasi
Hello, this is a series of patches to accomplish *Enable 
ARB_map_buffer_alignment in all drivers* newbie project suggested by Ian 
Romanick.

*Note* that I don't have write access, please merge them upstream after review 
process.


Best Regards,
Siavash Eliasi.

Siavash Eliasi (17):
  Modified allocation routine to use alignment of 64 instead of 16.
  Modified softpipe to return 64 in case of
PIPE_CAP_MIN_MAP_BUFFER_ALIGNMENT.
  Modified allocation routines to use alignment of 64 instead of 16.
  Modified llvmpipe to return 64 in case of
PIPE_CAP_MIN_MAP_BUFFER_ALIGNMENT.
  Modified i915_buffer_create to use memory allocation alignment of 64  
  instead of 16.
  Modified i915g to return 64 in case of
PIPE_CAP_MIN_MAP_BUFFER_ALIGNMENT.
  Modified svga to return 64 in case of
PIPE_CAP_MIN_MAP_BUFFER_ALIGNMENT.
  Modified ilo to return 4096 in case of
PIPE_CAP_MIN_MAP_BUFFER_ALIGNMENT.
  Modified Mesa state tracker to unconditionally enable
ARB_map_buffer_alignment.
  Modified _mesa_init_constants to set ctx-Const.MinMapBufferAlignment
to 64.
  Modified _mesa_buffer_data to use _mesa_align_malloc.
  Modified radeonBufferData to pass ctx-Const.MinMapBufferAlignment as
the alignment value to radeon_bo_open.
  Modified nouveau_bufferobj_data to pass
ctx-Const.MinMapBufferAlignment as the alignment value to
nouveau_bo_new.
  Modified i915 intel_bufferobj_data to use _mesa_align_malloc instead
of malloc.
  Modified brw_initialize_context_constants to set
ctx-Const.MinMapBufferAlignment to 4096.
  Modified extensions table to use o(dummy_true) instead of
o(ARB_map_buffer_alignment).
  Deleted gl_extensions::ARB_map_buffer_alignment and all of its use
cases.

 src/gallium/drivers/i915/i915_resource_buffer.c | 2 +-
 src/gallium/drivers/i915/i915_screen.c  | 1 +
 src/gallium/drivers/ilo/ilo_screen.c| 2 +-
 src/gallium/drivers/llvmpipe/lp_screen.c| 1 +
 src/gallium/drivers/llvmpipe/lp_texture.c   | 4 ++--
 src/gallium/drivers/softpipe/sp_screen.c| 2 +-
 src/gallium/drivers/softpipe/sp_texture.c   | 2 +-
 src/gallium/drivers/svga/svga_screen.c  | 1 +
 src/mesa/drivers/dri/i915/intel_buffer_objects.c| 4 ++--
 src/mesa/drivers/dri/i965/brw_context.c | 2 ++
 src/mesa/drivers/dri/nouveau/nouveau_bufferobj.c| 3 ++-
 src/mesa/drivers/dri/radeon/radeon_buffer_objects.c | 2 +-
 src/mesa/main/bufferobj.c   | 4 ++--
 src/mesa/main/context.c | 1 +
 src/mesa/main/extensions.c  | 2 +-
 src/mesa/main/get.c | 1 -
 src/mesa/main/get_hash_params.py| 2 +-
 src/mesa/main/mtypes.h  | 1 -
 src/mesa/state_tracker/st_extensions.c  | 4 +---
 19 files changed, 22 insertions(+), 19 deletions(-)

-- 
1.8.4.2

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 08/17] Modified ilo to return 4096 in case of PIPE_CAP_MIN_MAP_BUFFER_ALIGNMENT.

2013-11-24 Thread Siavash Eliasi
---
 src/gallium/drivers/ilo/ilo_screen.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/gallium/drivers/ilo/ilo_screen.c 
b/src/gallium/drivers/ilo/ilo_screen.c
index a345b70..466b21c 100644
--- a/src/gallium/drivers/ilo/ilo_screen.c
+++ b/src/gallium/drivers/ilo/ilo_screen.c
@@ -406,7 +406,7 @@ ilo_get_param(struct pipe_screen *screen, enum pipe_cap 
param)
case PIPE_CAP_TEXTURE_MULTISAMPLE:
   return false; /* TODO */
case PIPE_CAP_MIN_MAP_BUFFER_ALIGNMENT:
-  return 0;
+  return 4096;
case PIPE_CAP_CUBE_MAP_ARRAY:
case PIPE_CAP_TEXTURE_BUFFER_OBJECTS:
   return true;
-- 
1.8.4.2

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 05/17] Modified i915_buffer_create to use memory allocation alignment of 64 instead of 16.

2013-11-24 Thread Siavash Eliasi
---
 src/gallium/drivers/i915/i915_resource_buffer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/gallium/drivers/i915/i915_resource_buffer.c 
b/src/gallium/drivers/i915/i915_resource_buffer.c
index 80ec43a..fd29524 100644
--- a/src/gallium/drivers/i915/i915_resource_buffer.c
+++ b/src/gallium/drivers/i915/i915_resource_buffer.c
@@ -135,7 +135,7 @@ i915_buffer_create(struct pipe_screen *screen,
buf-b.vtbl = i915_buffer_vtbl;
pipe_reference_init(buf-b.b.reference, 1);
buf-b.b.screen = screen;
-   buf-data = align_malloc(template-width0, 16);
+   buf-data = align_malloc(template-width0, 64);
buf-free_on_destroy = TRUE;
 
if (!buf-data)
-- 
1.8.4.2

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 07/17] Modified svga to return 64 in case of PIPE_CAP_MIN_MAP_BUFFER_ALIGNMENT.

2013-11-24 Thread Siavash Eliasi
---
 src/gallium/drivers/svga/svga_screen.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/gallium/drivers/svga/svga_screen.c 
b/src/gallium/drivers/svga/svga_screen.c
index c16be16..9e67aa0 100644
--- a/src/gallium/drivers/svga/svga_screen.c
+++ b/src/gallium/drivers/svga/svga_screen.c
@@ -262,6 +262,7 @@ svga_get_param(struct pipe_screen *screen, enum pipe_cap 
param)
case PIPE_CAP_QUERY_TIMESTAMP:
case PIPE_CAP_TEXTURE_MULTISAMPLE:
case PIPE_CAP_MIN_MAP_BUFFER_ALIGNMENT:
+  return 64;
case PIPE_CAP_CUBE_MAP_ARRAY:
case PIPE_CAP_TEXTURE_BUFFER_OBJECTS:
case PIPE_CAP_TEXTURE_BUFFER_OFFSET_ALIGNMENT:
-- 
1.8.4.2

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 17/17] Deleted gl_extensions::ARB_map_buffer_alignment and all of its use cases.

2013-11-24 Thread Siavash Eliasi
---
 src/mesa/main/get.c| 1 -
 src/mesa/main/get_hash_params.py   | 2 +-
 src/mesa/main/mtypes.h | 1 -
 src/mesa/state_tracker/st_extensions.c | 2 --
 4 files changed, 1 insertion(+), 5 deletions(-)

diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c
index eee8550..6293b02 100644
--- a/src/mesa/main/get.c
+++ b/src/mesa/main/get.c
@@ -369,7 +369,6 @@ EXTRA_EXT(OES_EGL_image_external);
 EXTRA_EXT(ARB_blend_func_extended);
 EXTRA_EXT(ARB_uniform_buffer_object);
 EXTRA_EXT(ARB_timer_query);
-EXTRA_EXT(ARB_map_buffer_alignment);
 EXTRA_EXT(ARB_texture_cube_map_array);
 EXTRA_EXT(ARB_texture_buffer_range);
 EXTRA_EXT(ARB_texture_multisample);
diff --git a/src/mesa/main/get_hash_params.py b/src/mesa/main/get_hash_params.py
index c961fee..31f7867 100644
--- a/src/mesa/main/get_hash_params.py
+++ b/src/mesa/main/get_hash_params.py
@@ -715,7 +715,7 @@ descriptor=[
   [ TIMESTAMP, LOC_CUSTOM, TYPE_INT64, 0, extra_ARB_timer_query ],
 
 # GL_ARB_map_buffer_alignment
-  [ MIN_MAP_BUFFER_ALIGNMENT, CONTEXT_INT(Const.MinMapBufferAlignment), 
extra_ARB_map_buffer_alignment ],
+  [ MIN_MAP_BUFFER_ALIGNMENT, CONTEXT_INT(Const.MinMapBufferAlignment), 
NO_EXTRA ],
 
 # GL_ARB_texture_cube_map_array
   [ TEXTURE_BINDING_CUBE_MAP_ARRAY_ARB, LOC_CUSTOM, TYPE_INT, 
TEXTURE_CUBE_ARRAY_INDEX, extra_ARB_texture_cube_map_array ],
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index ecfb5e0..6a52c27 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -3339,7 +3339,6 @@ struct gl_extensions
GLboolean ARB_half_float_vertex;
GLboolean ARB_instanced_arrays;
GLboolean ARB_internalformat_query;
-   GLboolean ARB_map_buffer_alignment;
GLboolean ARB_map_buffer_range;
GLboolean ARB_occlusion_query;
GLboolean ARB_occlusion_query2;
diff --git a/src/mesa/state_tracker/st_extensions.c 
b/src/mesa/state_tracker/st_extensions.c
index 4707447..cbd5627 100644
--- a/src/mesa/state_tracker/st_extensions.c
+++ b/src/mesa/state_tracker/st_extensions.c
@@ -744,8 +744,6 @@ void st_init_extensions(struct st_context *st)
ctx-Const.MinMapBufferAlignment =
   screen-get_param(screen, PIPE_CAP_MIN_MAP_BUFFER_ALIGNMENT);
 
-   ctx-Extensions.ARB_map_buffer_alignment = GL_TRUE;
-
if (screen-get_param(screen, PIPE_CAP_TEXTURE_BUFFER_OBJECTS)) {
   ctx-Extensions.ARB_texture_buffer_object = GL_TRUE;
 
-- 
1.8.4.2

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 06/17] Modified i915g to return 64 in case of PIPE_CAP_MIN_MAP_BUFFER_ALIGNMENT.

2013-11-24 Thread Siavash Eliasi
---
 src/gallium/drivers/i915/i915_screen.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/gallium/drivers/i915/i915_screen.c 
b/src/gallium/drivers/i915/i915_screen.c
index 77607d0..3bc6ecf 100644
--- a/src/gallium/drivers/i915/i915_screen.c
+++ b/src/gallium/drivers/i915/i915_screen.c
@@ -213,6 +213,7 @@ i915_get_param(struct pipe_screen *screen, enum pipe_cap 
cap)
case PIPE_CAP_QUERY_PIPELINE_STATISTICS:
case PIPE_CAP_TEXTURE_MULTISAMPLE:
case PIPE_CAP_MIN_MAP_BUFFER_ALIGNMENT:
+  return 64;
case PIPE_CAP_TEXTURE_BORDER_COLOR_QUIRK:
   return 0;
case PIPE_CAP_MAX_DUAL_SOURCE_RENDER_TARGETS:
-- 
1.8.4.2

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 09/17] Modified Mesa state tracker to unconditionally enable ARB_map_buffer_alignment.

2013-11-24 Thread Siavash Eliasi
---
 src/mesa/state_tracker/st_extensions.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/mesa/state_tracker/st_extensions.c 
b/src/mesa/state_tracker/st_extensions.c
index e8d0902..4707447 100644
--- a/src/mesa/state_tracker/st_extensions.c
+++ b/src/mesa/state_tracker/st_extensions.c
@@ -743,9 +743,9 @@ void st_init_extensions(struct st_context *st)
 
ctx-Const.MinMapBufferAlignment =
   screen-get_param(screen, PIPE_CAP_MIN_MAP_BUFFER_ALIGNMENT);
-   if (ctx-Const.MinMapBufferAlignment = 64) {
-  ctx-Extensions.ARB_map_buffer_alignment = GL_TRUE;
-   }
+
+   ctx-Extensions.ARB_map_buffer_alignment = GL_TRUE;
+
if (screen-get_param(screen, PIPE_CAP_TEXTURE_BUFFER_OBJECTS)) {
   ctx-Extensions.ARB_texture_buffer_object = GL_TRUE;
 
-- 
1.8.4.2

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 12/17] Modified radeonBufferData to pass ctx-Const.MinMapBufferAlignment as the alignment value to radeon_bo_open.

2013-11-24 Thread Siavash Eliasi
---
 src/mesa/drivers/dri/radeon/radeon_buffer_objects.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/mesa/drivers/dri/radeon/radeon_buffer_objects.c 
b/src/mesa/drivers/dri/radeon/radeon_buffer_objects.c
index 40a16c3..ba7ab37 100644
--- a/src/mesa/drivers/dri/radeon/radeon_buffer_objects.c
+++ b/src/mesa/drivers/dri/radeon/radeon_buffer_objects.c
@@ -103,7 +103,7 @@ radeonBufferData(struct gl_context * ctx,
 radeon_obj-bo = radeon_bo_open(radeon-radeonScreen-bom,
 0,
 size,
-32,
+ctx-Const.MinMapBufferAlignment,
 RADEON_GEM_DOMAIN_GTT,
 0);
 
-- 
1.8.4.2

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 14/17] Modified i915 intel_bufferobj_data to use _mesa_align_malloc instead of malloc.

2013-11-24 Thread Siavash Eliasi
---
 src/mesa/drivers/dri/i915/intel_buffer_objects.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/mesa/drivers/dri/i915/intel_buffer_objects.c 
b/src/mesa/drivers/dri/i915/intel_buffer_objects.c
index bc58c70..4fbf954 100644
--- a/src/mesa/drivers/dri/i915/intel_buffer_objects.c
+++ b/src/mesa/drivers/dri/i915/intel_buffer_objects.c
@@ -137,7 +137,7 @@ intel_bufferobj_data(struct gl_context * ctx,
* contents anyway.
*/
   if (target == GL_ARRAY_BUFFER || target == GL_ELEMENT_ARRAY_BUFFER) {
-intel_obj-sys_buffer = malloc(size);
+intel_obj-sys_buffer = _mesa_align_malloc(size, 
ctx-Const.MinMapBufferAlignment);
 if (intel_obj-sys_buffer != NULL) {
if (data != NULL)
   memcpy(intel_obj-sys_buffer, data, size);
@@ -337,7 +337,7 @@ intel_bufferobj_map_range(struct gl_context * ctx,
if ((access  GL_MAP_INVALIDATE_RANGE_BIT) 
drm_intel_bo_busy(intel_obj-buffer)) {
   if (access  GL_MAP_FLUSH_EXPLICIT_BIT) {
-intel_obj-range_map_buffer = malloc(length);
+intel_obj-range_map_buffer = _mesa_align_malloc(length, 
ctx-Const.MinMapBufferAlignment);
 obj-Pointer = intel_obj-range_map_buffer;
   } else {
 intel_obj-range_map_bo = drm_intel_bo_alloc(intel-bufmgr,
-- 
1.8.4.2

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 16/17] Modified extensions table to use o(dummy_true) instead of o(ARB_map_buffer_alignment).

2013-11-24 Thread Siavash Eliasi
---
 src/mesa/main/extensions.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c
index 104618c..6f73694 100644
--- a/src/mesa/main/extensions.c
+++ b/src/mesa/main/extensions.c
@@ -107,7 +107,7 @@ static const struct extension extension_table[] = {
{ GL_ARB_instanced_arrays,o(ARB_instanced_arrays),
GL, 2008 },
{ GL_ARB_internalformat_query,
o(ARB_internalformat_query),GL, 2011 },
{ GL_ARB_invalidate_subdata,  o(dummy_true),  
GL, 2012 },
-   { GL_ARB_map_buffer_alignment,
o(ARB_map_buffer_alignment),GL, 2011 },
+   { GL_ARB_map_buffer_alignment,o(dummy_true),  
GL, 2011 },
{ GL_ARB_map_buffer_range,o(ARB_map_buffer_range),
GL, 2008 },
{ GL_ARB_multisample, o(dummy_true),  
GLL,1994 },
{ GL_ARB_multitexture,o(dummy_true),  
GLL,1998 },
-- 
1.8.4.2

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 11/17] Modified _mesa_buffer_data to use _mesa_align_malloc.

2013-11-24 Thread Siavash Eliasi
---
 src/mesa/main/bufferobj.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c
index b27f592..5581a5d 100644
--- a/src/mesa/main/bufferobj.c
+++ b/src/mesa/main/bufferobj.c
@@ -416,9 +416,9 @@ _mesa_buffer_data( struct gl_context *ctx, GLenum target, 
GLsizeiptrARB size,
 {
void * new_data;
 
-   (void) ctx; (void) target;
+   (void) target;
 
-   new_data = _mesa_realloc( bufObj-Data, bufObj-Size, size );
+   new_data = _mesa_align_malloc( size, ctx-Const.MinMapBufferAlignment );
if (new_data) {
   bufObj-Data = (GLubyte *) new_data;
   bufObj-Size = size;
-- 
1.8.4.2

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 15/17] Modified brw_initialize_context_constants to set ctx-Const.MinMapBufferAlignment to 4096.

2013-11-24 Thread Siavash Eliasi
---
 src/mesa/drivers/dri/i965/brw_context.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/mesa/drivers/dri/i965/brw_context.c 
b/src/mesa/drivers/dri/i965/brw_context.c
index 6e09077..679ec0e 100644
--- a/src/mesa/drivers/dri/i965/brw_context.c
+++ b/src/mesa/drivers/dri/i965/brw_context.c
@@ -320,6 +320,8 @@ brw_initialize_context_constants(struct brw_context *brw)
 
ctx-Const.MaxRenderbufferSize = 8192;
 
+   ctx-Const.MinMapBufferAlignment = 4096;
+
/* Hardware only supports a limited number of transform feedback buffers.
 * So we need to override the Mesa default (which is based only on software
 * limits).
-- 
1.8.4.2

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 13/17] Modified nouveau_bufferobj_data to pass ctx-Const.MinMapBufferAlignment as the alignment value to nouveau_bo_new.

2013-11-24 Thread Siavash Eliasi
---
 src/mesa/drivers/dri/nouveau/nouveau_bufferobj.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/mesa/drivers/dri/nouveau/nouveau_bufferobj.c 
b/src/mesa/drivers/dri/nouveau/nouveau_bufferobj.c
index 717c0b8..dc16585 100644
--- a/src/mesa/drivers/dri/nouveau/nouveau_bufferobj.c
+++ b/src/mesa/drivers/dri/nouveau/nouveau_bufferobj.c
@@ -95,7 +95,8 @@ nouveau_bufferobj_data(struct gl_context *ctx, GLenum target, 
GLsizeiptrARB size
} else {
/* Get a hardware BO */
ret = nouveau_bo_new(context_dev(ctx),
-NOUVEAU_BO_GART | NOUVEAU_BO_MAP, 0,
+NOUVEAU_BO_GART | NOUVEAU_BO_MAP,
+ctx-Const.MinMapBufferAlignment,
 size, NULL, nbo-bo);
assert(!ret);
}
-- 
1.8.4.2

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 00/17] Newbie Project : Enable ARB_map_buffer_alignment in all drivers

2013-11-24 Thread Timothy Arceri
I've only had a very quick scan over your patches but I think you need
to redo your patches that edit case statements as you are not just
changing the value of the intended case statement but also all of the
cases above it as they do not break or return they just fall through for
example:

--- a/src/gallium/drivers/llvmpipe/lp_screen.c
+++ b/src/gallium/drivers/llvmpipe/lp_screen.c
@@ -220,6 +220,7 @@ llvmpipe_get_param(struct pipe_screen *screen, enum
pipe_cap param)
case PIPE_CAP_START_INSTANCE:
case PIPE_CAP_TEXTURE_MULTISAMPLE:
case PIPE_CAP_MIN_MAP_BUFFER_ALIGNMENT:
+  return 64;
case PIPE_CAP_CUBE_MAP_ARRAY:
   return 0;

Here you are changing the value of PIPE_CAP_START_INSTANCE,
PIPE_CAP_TEXTURE_MULTISAMPLE, PIPE_CAP_MIN_MAP_BUFFER_ALIGNMENT and
possibly other cases above those from 0 to 64.

On Mon, 2013-11-25 at 09:06 +0330, Siavash Eliasi wrote:
 Hello, this is a series of patches to accomplish *Enable 
 ARB_map_buffer_alignment in all drivers* newbie project suggested by Ian 
 Romanick.
 
 *Note* that I don't have write access, please merge them upstream after 
 review process.
 
 
 Best Regards,
 Siavash Eliasi.
 
 Siavash Eliasi (17):
   Modified allocation routine to use alignment of 64 instead of 16.
   Modified softpipe to return 64 in case of
 PIPE_CAP_MIN_MAP_BUFFER_ALIGNMENT.
   Modified allocation routines to use alignment of 64 instead of 16.
   Modified llvmpipe to return 64 in case of
 PIPE_CAP_MIN_MAP_BUFFER_ALIGNMENT.
   Modified i915_buffer_create to use memory allocation alignment of 64  
   instead of 16.
   Modified i915g to return 64 in case of
 PIPE_CAP_MIN_MAP_BUFFER_ALIGNMENT.
   Modified svga to return 64 in case of
 PIPE_CAP_MIN_MAP_BUFFER_ALIGNMENT.
   Modified ilo to return 4096 in case of
 PIPE_CAP_MIN_MAP_BUFFER_ALIGNMENT.
   Modified Mesa state tracker to unconditionally enable
 ARB_map_buffer_alignment.
   Modified _mesa_init_constants to set ctx-Const.MinMapBufferAlignment
 to 64.
   Modified _mesa_buffer_data to use _mesa_align_malloc.
   Modified radeonBufferData to pass ctx-Const.MinMapBufferAlignment as
 the alignment value to radeon_bo_open.
   Modified nouveau_bufferobj_data to pass
 ctx-Const.MinMapBufferAlignment as the alignment value to
 nouveau_bo_new.
   Modified i915 intel_bufferobj_data to use _mesa_align_malloc instead
 of malloc.
   Modified brw_initialize_context_constants to set
 ctx-Const.MinMapBufferAlignment to 4096.
   Modified extensions table to use o(dummy_true) instead of
 o(ARB_map_buffer_alignment).
   Deleted gl_extensions::ARB_map_buffer_alignment and all of its use
 cases.
 
  src/gallium/drivers/i915/i915_resource_buffer.c | 2 +-
  src/gallium/drivers/i915/i915_screen.c  | 1 +
  src/gallium/drivers/ilo/ilo_screen.c| 2 +-
  src/gallium/drivers/llvmpipe/lp_screen.c| 1 +
  src/gallium/drivers/llvmpipe/lp_texture.c   | 4 ++--
  src/gallium/drivers/softpipe/sp_screen.c| 2 +-
  src/gallium/drivers/softpipe/sp_texture.c   | 2 +-
  src/gallium/drivers/svga/svga_screen.c  | 1 +
  src/mesa/drivers/dri/i915/intel_buffer_objects.c| 4 ++--
  src/mesa/drivers/dri/i965/brw_context.c | 2 ++
  src/mesa/drivers/dri/nouveau/nouveau_bufferobj.c| 3 ++-
  src/mesa/drivers/dri/radeon/radeon_buffer_objects.c | 2 +-
  src/mesa/main/bufferobj.c   | 4 ++--
  src/mesa/main/context.c | 1 +
  src/mesa/main/extensions.c  | 2 +-
  src/mesa/main/get.c | 1 -
  src/mesa/main/get_hash_params.py| 2 +-
  src/mesa/main/mtypes.h  | 1 -
  src/mesa/state_tracker/st_extensions.c  | 4 +---
  19 files changed, 22 insertions(+), 19 deletions(-)
 


___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH] Fixed setting switch cases prior to PIPE_CAP_MIN_MAP_BUFFER_ALIGNMENT incorrectly.

2013-11-24 Thread Siavash Eliasi
Thanks to Timothy Arceri for pointing that out!
---
 src/gallium/drivers/i915/i915_screen.c   | 4 ++--
 src/gallium/drivers/llvmpipe/lp_screen.c | 4 ++--
 src/gallium/drivers/softpipe/sp_screen.c | 1 +
 src/gallium/drivers/svga/svga_screen.c   | 4 ++--
 4 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/src/gallium/drivers/i915/i915_screen.c 
b/src/gallium/drivers/i915/i915_screen.c
index 3bc6ecf..2ffe65b 100644
--- a/src/gallium/drivers/i915/i915_screen.c
+++ b/src/gallium/drivers/i915/i915_screen.c
@@ -212,10 +212,10 @@ i915_get_param(struct pipe_screen *screen, enum pipe_cap 
cap)
case PIPE_CAP_QUERY_TIMESTAMP:
case PIPE_CAP_QUERY_PIPELINE_STATISTICS:
case PIPE_CAP_TEXTURE_MULTISAMPLE:
-   case PIPE_CAP_MIN_MAP_BUFFER_ALIGNMENT:
-  return 64;
case PIPE_CAP_TEXTURE_BORDER_COLOR_QUIRK:
   return 0;
+   case PIPE_CAP_MIN_MAP_BUFFER_ALIGNMENT:
+  return 64;
case PIPE_CAP_MAX_DUAL_SOURCE_RENDER_TARGETS:
case PIPE_CAP_STREAM_OUTPUT_PAUSE_RESUME:
case PIPE_CAP_VERTEX_BUFFER_OFFSET_4BYTE_ALIGNED_ONLY:
diff --git a/src/gallium/drivers/llvmpipe/lp_screen.c 
b/src/gallium/drivers/llvmpipe/lp_screen.c
index 8be1779..e27f148 100644
--- a/src/gallium/drivers/llvmpipe/lp_screen.c
+++ b/src/gallium/drivers/llvmpipe/lp_screen.c
@@ -219,10 +219,10 @@ llvmpipe_get_param(struct pipe_screen *screen, enum 
pipe_cap param)
   return 16;
case PIPE_CAP_START_INSTANCE:
case PIPE_CAP_TEXTURE_MULTISAMPLE:
-   case PIPE_CAP_MIN_MAP_BUFFER_ALIGNMENT:
-  return 64;
case PIPE_CAP_CUBE_MAP_ARRAY:
   return 0;
+   case PIPE_CAP_MIN_MAP_BUFFER_ALIGNMENT:
+  return 64;
case PIPE_CAP_TEXTURE_BUFFER_OBJECTS:
   return 1;
case PIPE_CAP_MAX_TEXTURE_BUFFER_SIZE:
diff --git a/src/gallium/drivers/softpipe/sp_screen.c 
b/src/gallium/drivers/softpipe/sp_screen.c
index 022b5bf..ab4fb4f 100644
--- a/src/gallium/drivers/softpipe/sp_screen.c
+++ b/src/gallium/drivers/softpipe/sp_screen.c
@@ -168,6 +168,7 @@ softpipe_get_param(struct pipe_screen *screen, enum 
pipe_cap param)
case PIPE_CAP_VERTEX_ELEMENT_SRC_OFFSET_4BYTE_ALIGNED_ONLY:
case PIPE_CAP_START_INSTANCE:
case PIPE_CAP_TEXTURE_MULTISAMPLE:
+  return 0;
case PIPE_CAP_MIN_MAP_BUFFER_ALIGNMENT:
   return 64;
case PIPE_CAP_QUERY_TIMESTAMP:
diff --git a/src/gallium/drivers/svga/svga_screen.c 
b/src/gallium/drivers/svga/svga_screen.c
index 9e67aa0..3244c95 100644
--- a/src/gallium/drivers/svga/svga_screen.c
+++ b/src/gallium/drivers/svga/svga_screen.c
@@ -261,14 +261,14 @@ svga_get_param(struct pipe_screen *screen, enum pipe_cap 
param)
case PIPE_CAP_START_INSTANCE:
case PIPE_CAP_QUERY_TIMESTAMP:
case PIPE_CAP_TEXTURE_MULTISAMPLE:
-   case PIPE_CAP_MIN_MAP_BUFFER_ALIGNMENT:
-  return 64;
case PIPE_CAP_CUBE_MAP_ARRAY:
case PIPE_CAP_TEXTURE_BUFFER_OBJECTS:
case PIPE_CAP_TEXTURE_BUFFER_OFFSET_ALIGNMENT:
case PIPE_CAP_QUERY_PIPELINE_STATISTICS:
case PIPE_CAP_MAX_TEXTURE_BUFFER_SIZE:
   return 0;
+   case PIPE_CAP_MIN_MAP_BUFFER_ALIGNMENT:
+  return 64;
case PIPE_CAP_VERTEX_ELEMENT_SRC_OFFSET_4BYTE_ALIGNED_ONLY:
   return 1;
case PIPE_CAP_MAX_VIEWPORTS:
-- 
1.8.4.2

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] i965: Bump number of supported atomic counter buffers.

2013-11-24 Thread Kenneth Graunke
On 11/24/2013 05:39 PM, Francisco Jerez wrote:
 Now that we have dynamic binding tables there's no good reason anymore
 to expose so few atomic counter buffers.  Increase it to 16.
 ---
  src/mesa/drivers/dri/i965/brw_context.h | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
 
 diff --git a/src/mesa/drivers/dri/i965/brw_context.h 
 b/src/mesa/drivers/dri/i965/brw_context.h
 index 63f0687..97f8906 100644
 --- a/src/mesa/drivers/dri/i965/brw_context.h
 +++ b/src/mesa/drivers/dri/i965/brw_context.h
 @@ -660,7 +660,7 @@ struct brw_gs_prog_data
  #define BRW_MAX_DRAW_BUFFERS 8
  
  /** Max number of atomic counter buffer objects in a shader */
 -#define BRW_MAX_ABO 4
 +#define BRW_MAX_ABO 16
  
  /**
   * Max number of binding table entries used for stream output.

Seems reasonable.

Reviewed-by: Kenneth Graunke kenn...@whitecape.org

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH] Fixed setting switch cases prior to PIPE_CAP_MIN_MAP_BUFFER_ALIGNMENT incorrectly.

2013-11-24 Thread Siavash Eliasi
Thanks to Timothy Arceri for pointing that out!
---
 src/gallium/drivers/i915/i915_screen.c   | 4 ++--
 src/gallium/drivers/llvmpipe/lp_screen.c | 4 ++--
 src/gallium/drivers/softpipe/sp_screen.c | 1 +
 src/gallium/drivers/svga/svga_screen.c   | 4 ++--
 4 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/src/gallium/drivers/i915/i915_screen.c 
b/src/gallium/drivers/i915/i915_screen.c
index 3bc6ecf..2ffe65b 100644
--- a/src/gallium/drivers/i915/i915_screen.c
+++ b/src/gallium/drivers/i915/i915_screen.c
@@ -212,10 +212,10 @@ i915_get_param(struct pipe_screen *screen, enum pipe_cap 
cap)
case PIPE_CAP_QUERY_TIMESTAMP:
case PIPE_CAP_QUERY_PIPELINE_STATISTICS:
case PIPE_CAP_TEXTURE_MULTISAMPLE:
-   case PIPE_CAP_MIN_MAP_BUFFER_ALIGNMENT:
-  return 64;
case PIPE_CAP_TEXTURE_BORDER_COLOR_QUIRK:
   return 0;
+   case PIPE_CAP_MIN_MAP_BUFFER_ALIGNMENT:
+  return 64;
case PIPE_CAP_MAX_DUAL_SOURCE_RENDER_TARGETS:
case PIPE_CAP_STREAM_OUTPUT_PAUSE_RESUME:
case PIPE_CAP_VERTEX_BUFFER_OFFSET_4BYTE_ALIGNED_ONLY:
diff --git a/src/gallium/drivers/llvmpipe/lp_screen.c 
b/src/gallium/drivers/llvmpipe/lp_screen.c
index 8be1779..e27f148 100644
--- a/src/gallium/drivers/llvmpipe/lp_screen.c
+++ b/src/gallium/drivers/llvmpipe/lp_screen.c
@@ -219,10 +219,10 @@ llvmpipe_get_param(struct pipe_screen *screen, enum 
pipe_cap param)
   return 16;
case PIPE_CAP_START_INSTANCE:
case PIPE_CAP_TEXTURE_MULTISAMPLE:
-   case PIPE_CAP_MIN_MAP_BUFFER_ALIGNMENT:
-  return 64;
case PIPE_CAP_CUBE_MAP_ARRAY:
   return 0;
+   case PIPE_CAP_MIN_MAP_BUFFER_ALIGNMENT:
+  return 64;
case PIPE_CAP_TEXTURE_BUFFER_OBJECTS:
   return 1;
case PIPE_CAP_MAX_TEXTURE_BUFFER_SIZE:
diff --git a/src/gallium/drivers/softpipe/sp_screen.c 
b/src/gallium/drivers/softpipe/sp_screen.c
index 022b5bf..ab4fb4f 100644
--- a/src/gallium/drivers/softpipe/sp_screen.c
+++ b/src/gallium/drivers/softpipe/sp_screen.c
@@ -168,6 +168,7 @@ softpipe_get_param(struct pipe_screen *screen, enum 
pipe_cap param)
case PIPE_CAP_VERTEX_ELEMENT_SRC_OFFSET_4BYTE_ALIGNED_ONLY:
case PIPE_CAP_START_INSTANCE:
case PIPE_CAP_TEXTURE_MULTISAMPLE:
+  return 0;
case PIPE_CAP_MIN_MAP_BUFFER_ALIGNMENT:
   return 64;
case PIPE_CAP_QUERY_TIMESTAMP:
diff --git a/src/gallium/drivers/svga/svga_screen.c 
b/src/gallium/drivers/svga/svga_screen.c
index 9e67aa0..3244c95 100644
--- a/src/gallium/drivers/svga/svga_screen.c
+++ b/src/gallium/drivers/svga/svga_screen.c
@@ -261,14 +261,14 @@ svga_get_param(struct pipe_screen *screen, enum pipe_cap 
param)
case PIPE_CAP_START_INSTANCE:
case PIPE_CAP_QUERY_TIMESTAMP:
case PIPE_CAP_TEXTURE_MULTISAMPLE:
-   case PIPE_CAP_MIN_MAP_BUFFER_ALIGNMENT:
-  return 64;
case PIPE_CAP_CUBE_MAP_ARRAY:
case PIPE_CAP_TEXTURE_BUFFER_OBJECTS:
case PIPE_CAP_TEXTURE_BUFFER_OFFSET_ALIGNMENT:
case PIPE_CAP_QUERY_PIPELINE_STATISTICS:
case PIPE_CAP_MAX_TEXTURE_BUFFER_SIZE:
   return 0;
+   case PIPE_CAP_MIN_MAP_BUFFER_ALIGNMENT:
+  return 64;
case PIPE_CAP_VERTEX_ELEMENT_SRC_OFFSET_4BYTE_ALIGNED_ONLY:
   return 1;
case PIPE_CAP_MAX_VIEWPORTS:
-- 
1.8.4.2

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 14/17] Modified i915 intel_bufferobj_data to use _mesa_align_malloc instead of malloc.

2013-11-24 Thread Chris Forbes
I'm not convinced that just using _mesa_align_malloc() is sufficient
here. Issue 2 from the ARB_map_buffer_alignment spec says:

2) What alignment should be used for MapBufferRange when offset is
non-zero?

RESOLVED:  The pointer returned should be consistent with the base of the
buffer being aligned.  For example, if a buffer was mapped with an
offset of 24 bytes on an implementation with a
MIN_MAP_BUFFER_ALIGNMENT of 64, the value of the pointer returned
would have a value of the form 64*N+24 for some integer N.

Cc'ing Ian, since I assume this is based on his instructions.

-- Chris


On Mon, Nov 25, 2013 at 6:36 PM, Siavash Eliasi siavashser...@gmail.com wrote:
 ---
  src/mesa/drivers/dri/i915/intel_buffer_objects.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)

 diff --git a/src/mesa/drivers/dri/i915/intel_buffer_objects.c 
 b/src/mesa/drivers/dri/i915/intel_buffer_objects.c
 index bc58c70..4fbf954 100644
 --- a/src/mesa/drivers/dri/i915/intel_buffer_objects.c
 +++ b/src/mesa/drivers/dri/i915/intel_buffer_objects.c
 @@ -137,7 +137,7 @@ intel_bufferobj_data(struct gl_context * ctx,
 * contents anyway.
 */
if (target == GL_ARRAY_BUFFER || target == GL_ELEMENT_ARRAY_BUFFER) {
 -intel_obj-sys_buffer = malloc(size);
 +intel_obj-sys_buffer = _mesa_align_malloc(size, 
 ctx-Const.MinMapBufferAlignment);
  if (intel_obj-sys_buffer != NULL) {
 if (data != NULL)
memcpy(intel_obj-sys_buffer, data, size);
 @@ -337,7 +337,7 @@ intel_bufferobj_map_range(struct gl_context * ctx,
 if ((access  GL_MAP_INVALIDATE_RANGE_BIT) 
 drm_intel_bo_busy(intel_obj-buffer)) {
if (access  GL_MAP_FLUSH_EXPLICIT_BIT) {
 -intel_obj-range_map_buffer = malloc(length);
 +intel_obj-range_map_buffer = _mesa_align_malloc(length, 
 ctx-Const.MinMapBufferAlignment);
  obj-Pointer = intel_obj-range_map_buffer;
} else {
  intel_obj-range_map_bo = drm_intel_bo_alloc(intel-bufmgr,
 --
 1.8.4.2

 ___
 mesa-dev mailing list
 mesa-dev@lists.freedesktop.org
 http://lists.freedesktop.org/mailman/listinfo/mesa-dev
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 00/17] Newbie Project : Enable ARB_map_buffer_alignment in all drivers

2013-11-24 Thread Chris Forbes
Tim's correct -- in this case you probably want to move the
PIPE_CAP_MIN_MAP_BUFFER_ALIGNMENT case up above the big 'this cap is
unsupported' catch-all.

-- Chris

On Mon, Nov 25, 2013 at 7:07 PM, Timothy Arceri t_arc...@yahoo.com.au wrote:
 I've only had a very quick scan over your patches but I think you need
 to redo your patches that edit case statements as you are not just
 changing the value of the intended case statement but also all of the
 cases above it as they do not break or return they just fall through for
 example:

 --- a/src/gallium/drivers/llvmpipe/lp_screen.c
 +++ b/src/gallium/drivers/llvmpipe/lp_screen.c
 @@ -220,6 +220,7 @@ llvmpipe_get_param(struct pipe_screen *screen, enum
 pipe_cap param)
 case PIPE_CAP_START_INSTANCE:
 case PIPE_CAP_TEXTURE_MULTISAMPLE:
 case PIPE_CAP_MIN_MAP_BUFFER_ALIGNMENT:
 +  return 64;
 case PIPE_CAP_CUBE_MAP_ARRAY:
return 0;

 Here you are changing the value of PIPE_CAP_START_INSTANCE,
 PIPE_CAP_TEXTURE_MULTISAMPLE, PIPE_CAP_MIN_MAP_BUFFER_ALIGNMENT and
 possibly other cases above those from 0 to 64.

 On Mon, 2013-11-25 at 09:06 +0330, Siavash Eliasi wrote:
 Hello, this is a series of patches to accomplish *Enable 
 ARB_map_buffer_alignment in all drivers* newbie project suggested by Ian 
 Romanick.

 *Note* that I don't have write access, please merge them upstream after 
 review process.


 Best Regards,
 Siavash Eliasi.

 Siavash Eliasi (17):
   Modified allocation routine to use alignment of 64 instead of 16.
   Modified softpipe to return 64 in case of
 PIPE_CAP_MIN_MAP_BUFFER_ALIGNMENT.
   Modified allocation routines to use alignment of 64 instead of 16.
   Modified llvmpipe to return 64 in case of
 PIPE_CAP_MIN_MAP_BUFFER_ALIGNMENT.
   Modified i915_buffer_create to use memory allocation alignment of 64
   instead of 16.
   Modified i915g to return 64 in case of
 PIPE_CAP_MIN_MAP_BUFFER_ALIGNMENT.
   Modified svga to return 64 in case of
 PIPE_CAP_MIN_MAP_BUFFER_ALIGNMENT.
   Modified ilo to return 4096 in case of
 PIPE_CAP_MIN_MAP_BUFFER_ALIGNMENT.
   Modified Mesa state tracker to unconditionally enable
 ARB_map_buffer_alignment.
   Modified _mesa_init_constants to set ctx-Const.MinMapBufferAlignment
 to 64.
   Modified _mesa_buffer_data to use _mesa_align_malloc.
   Modified radeonBufferData to pass ctx-Const.MinMapBufferAlignment as
 the alignment value to radeon_bo_open.
   Modified nouveau_bufferobj_data to pass
 ctx-Const.MinMapBufferAlignment as the alignment value to
 nouveau_bo_new.
   Modified i915 intel_bufferobj_data to use _mesa_align_malloc instead
 of malloc.
   Modified brw_initialize_context_constants to set
 ctx-Const.MinMapBufferAlignment to 4096.
   Modified extensions table to use o(dummy_true) instead of
 o(ARB_map_buffer_alignment).
   Deleted gl_extensions::ARB_map_buffer_alignment and all of its use
 cases.

  src/gallium/drivers/i915/i915_resource_buffer.c | 2 +-
  src/gallium/drivers/i915/i915_screen.c  | 1 +
  src/gallium/drivers/ilo/ilo_screen.c| 2 +-
  src/gallium/drivers/llvmpipe/lp_screen.c| 1 +
  src/gallium/drivers/llvmpipe/lp_texture.c   | 4 ++--
  src/gallium/drivers/softpipe/sp_screen.c| 2 +-
  src/gallium/drivers/softpipe/sp_texture.c   | 2 +-
  src/gallium/drivers/svga/svga_screen.c  | 1 +
  src/mesa/drivers/dri/i915/intel_buffer_objects.c| 4 ++--
  src/mesa/drivers/dri/i965/brw_context.c | 2 ++
  src/mesa/drivers/dri/nouveau/nouveau_bufferobj.c| 3 ++-
  src/mesa/drivers/dri/radeon/radeon_buffer_objects.c | 2 +-
  src/mesa/main/bufferobj.c   | 4 ++--
  src/mesa/main/context.c | 1 +
  src/mesa/main/extensions.c  | 2 +-
  src/mesa/main/get.c | 1 -
  src/mesa/main/get_hash_params.py| 2 +-
  src/mesa/main/mtypes.h  | 1 -
  src/mesa/state_tracker/st_extensions.c  | 4 +---
  19 files changed, 22 insertions(+), 19 deletions(-)



 ___
 mesa-dev mailing list
 mesa-dev@lists.freedesktop.org
 http://lists.freedesktop.org/mailman/listinfo/mesa-dev
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 00/17] Newbie Project : Enable ARB_map_buffer_alignment in all drivers

2013-11-24 Thread Chris Forbes
Ah, I see you have a follow-up that fixes this already.

Looks good, sorry for the noise.

-- Chris

On Mon, Nov 25, 2013 at 8:19 PM, Chris Forbes chr...@ijw.co.nz wrote:
 Tim's correct -- in this case you probably want to move the
 PIPE_CAP_MIN_MAP_BUFFER_ALIGNMENT case up above the big 'this cap is
 unsupported' catch-all.

 -- Chris

 On Mon, Nov 25, 2013 at 7:07 PM, Timothy Arceri t_arc...@yahoo.com.au wrote:
 I've only had a very quick scan over your patches but I think you need
 to redo your patches that edit case statements as you are not just
 changing the value of the intended case statement but also all of the
 cases above it as they do not break or return they just fall through for
 example:

 --- a/src/gallium/drivers/llvmpipe/lp_screen.c
 +++ b/src/gallium/drivers/llvmpipe/lp_screen.c
 @@ -220,6 +220,7 @@ llvmpipe_get_param(struct pipe_screen *screen, enum
 pipe_cap param)
 case PIPE_CAP_START_INSTANCE:
 case PIPE_CAP_TEXTURE_MULTISAMPLE:
 case PIPE_CAP_MIN_MAP_BUFFER_ALIGNMENT:
 +  return 64;
 case PIPE_CAP_CUBE_MAP_ARRAY:
return 0;

 Here you are changing the value of PIPE_CAP_START_INSTANCE,
 PIPE_CAP_TEXTURE_MULTISAMPLE, PIPE_CAP_MIN_MAP_BUFFER_ALIGNMENT and
 possibly other cases above those from 0 to 64.

 On Mon, 2013-11-25 at 09:06 +0330, Siavash Eliasi wrote:
 Hello, this is a series of patches to accomplish *Enable 
 ARB_map_buffer_alignment in all drivers* newbie project suggested by Ian 
 Romanick.

 *Note* that I don't have write access, please merge them upstream after 
 review process.


 Best Regards,
 Siavash Eliasi.

 Siavash Eliasi (17):
   Modified allocation routine to use alignment of 64 instead of 16.
   Modified softpipe to return 64 in case of
 PIPE_CAP_MIN_MAP_BUFFER_ALIGNMENT.
   Modified allocation routines to use alignment of 64 instead of 16.
   Modified llvmpipe to return 64 in case of
 PIPE_CAP_MIN_MAP_BUFFER_ALIGNMENT.
   Modified i915_buffer_create to use memory allocation alignment of 64
   instead of 16.
   Modified i915g to return 64 in case of
 PIPE_CAP_MIN_MAP_BUFFER_ALIGNMENT.
   Modified svga to return 64 in case of
 PIPE_CAP_MIN_MAP_BUFFER_ALIGNMENT.
   Modified ilo to return 4096 in case of
 PIPE_CAP_MIN_MAP_BUFFER_ALIGNMENT.
   Modified Mesa state tracker to unconditionally enable
 ARB_map_buffer_alignment.
   Modified _mesa_init_constants to set ctx-Const.MinMapBufferAlignment
 to 64.
   Modified _mesa_buffer_data to use _mesa_align_malloc.
   Modified radeonBufferData to pass ctx-Const.MinMapBufferAlignment as
 the alignment value to radeon_bo_open.
   Modified nouveau_bufferobj_data to pass
 ctx-Const.MinMapBufferAlignment as the alignment value to
 nouveau_bo_new.
   Modified i915 intel_bufferobj_data to use _mesa_align_malloc instead
 of malloc.
   Modified brw_initialize_context_constants to set
 ctx-Const.MinMapBufferAlignment to 4096.
   Modified extensions table to use o(dummy_true) instead of
 o(ARB_map_buffer_alignment).
   Deleted gl_extensions::ARB_map_buffer_alignment and all of its use
 cases.

  src/gallium/drivers/i915/i915_resource_buffer.c | 2 +-
  src/gallium/drivers/i915/i915_screen.c  | 1 +
  src/gallium/drivers/ilo/ilo_screen.c| 2 +-
  src/gallium/drivers/llvmpipe/lp_screen.c| 1 +
  src/gallium/drivers/llvmpipe/lp_texture.c   | 4 ++--
  src/gallium/drivers/softpipe/sp_screen.c| 2 +-
  src/gallium/drivers/softpipe/sp_texture.c   | 2 +-
  src/gallium/drivers/svga/svga_screen.c  | 1 +
  src/mesa/drivers/dri/i915/intel_buffer_objects.c| 4 ++--
  src/mesa/drivers/dri/i965/brw_context.c | 2 ++
  src/mesa/drivers/dri/nouveau/nouveau_bufferobj.c| 3 ++-
  src/mesa/drivers/dri/radeon/radeon_buffer_objects.c | 2 +-
  src/mesa/main/bufferobj.c   | 4 ++--
  src/mesa/main/context.c | 1 +
  src/mesa/main/extensions.c  | 2 +-
  src/mesa/main/get.c | 1 -
  src/mesa/main/get_hash_params.py| 2 +-
  src/mesa/main/mtypes.h  | 1 -
  src/mesa/state_tracker/st_extensions.c  | 4 +---
  19 files changed, 22 insertions(+), 19 deletions(-)



 ___
 mesa-dev mailing list
 mesa-dev@lists.freedesktop.org
 http://lists.freedesktop.org/mailman/listinfo/mesa-dev
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 02/11] mesa: Add ARB_shader_image_load_store to the extension table.

2013-11-24 Thread Chris Forbes
Does this want to be enabled in compatibility? I had assumed we
wouldn't, for the same reasons we don't enable texbo there.

On Mon, Nov 25, 2013 at 6:00 PM, Francisco Jerez curroje...@riseup.net wrote:
 ---
  src/mesa/main/extensions.c | 1 +
  src/mesa/main/mtypes.h | 1 +
  2 files changed, 2 insertions(+)

 diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c
 index 104618c..19cf34d 100644
 --- a/src/mesa/main/extensions.c
 +++ b/src/mesa/main/extensions.c
 @@ -123,6 +123,7 @@ static const struct extension extension_table[] = {
 { GL_ARB_seamless_cube_map,   o(ARB_seamless_cube_map), 
   GL, 2009 },
 { GL_ARB_shader_atomic_counters,  
 o(ARB_shader_atomic_counters),  GL, 2011 },
 { GL_ARB_shader_bit_encoding, 
 o(ARB_shader_bit_encoding), GL, 2010 },
 +   { GL_ARB_shader_image_load_store, 
 o(ARB_shader_image_load_store), GL, 2011 },
 { GL_ARB_shader_objects,  o(dummy_true),
   GL, 2002 },
 { GL_ARB_shader_stencil_export,   
 o(ARB_shader_stencil_export),   GL, 2009 },
 { GL_ARB_shader_texture_lod,  
 o(ARB_shader_texture_lod),  GL, 2009 },
 diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
 index ecfb5e0..e9750f4 100644
 --- a/src/mesa/main/mtypes.h
 +++ b/src/mesa/main/mtypes.h
 @@ -3348,6 +3348,7 @@ struct gl_extensions
 GLboolean ARB_seamless_cube_map;
 GLboolean ARB_shader_atomic_counters;
 GLboolean ARB_shader_bit_encoding;
 +   GLboolean ARB_shader_image_load_store;
 GLboolean ARB_shader_stencil_export;
 GLboolean ARB_shader_texture_lod;
 GLboolean ARB_shading_language_packing;
 --
 1.8.3.4

 ___
 mesa-dev mailing list
 mesa-dev@lists.freedesktop.org
 http://lists.freedesktop.org/mailman/listinfo/mesa-dev
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 00/17] Newbie Project : Enable ARB_map_buffer_alignment in all drivers

2013-11-24 Thread Siavash Eliasi

On 11/25/2013 10:50 AM, Chris Forbes wrote:

Ah, I see you have a follow-up that fixes this already.

Looks good, sorry for the noise.

-- Chris

I'm pretty new here and I'm not used to mailing lists, sorry if patches 
aren't showing up in correct place.


Should I send all of patches again (and possibly squash a few) or is 
that fine by moderators?

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 03/11] mesa: Add state data structures requried for ARB_shader_image_load_store.

2013-11-24 Thread Chris Forbes
In the commit message, s/requried/required/

Does holding onto the whole texture object make things easier? I had
assumed you could get by just referencing the right gl_texture_image,
but maybe that doesn't work out.

On Mon, Nov 25, 2013 at 6:00 PM, Francisco Jerez curroje...@riseup.net wrote:
 ---
  src/mesa/main/config.h |   1 +
  src/mesa/main/dd.h |   1 +
  src/mesa/main/mtypes.h | 100 
 +
  src/mesa/main/texobj.c |   1 +
  4 files changed, 103 insertions(+)

 diff --git a/src/mesa/main/config.h b/src/mesa/main/config.h
 index 22bbfa0..8bd9765 100644
 --- a/src/mesa/main/config.h
 +++ b/src/mesa/main/config.h
 @@ -175,6 +175,7 @@
  #define MAX_COMBINED_ATOMIC_BUFFERS(MAX_UNIFORM_BUFFERS * 6)
  /* Size of an atomic counter in bytes according to 
 ARB_shader_atomic_counters */
  #define ATOMIC_COUNTER_SIZE4
 +#define MAX_IMAGE_UNITS32
  /*@}*/

  /**
 diff --git a/src/mesa/main/dd.h b/src/mesa/main/dd.h
 index b5b874f..648062f 100644
 --- a/src/mesa/main/dd.h
 +++ b/src/mesa/main/dd.h
 @@ -39,6 +39,7 @@ struct gl_buffer_object;
  struct gl_context;
  struct gl_display_list;
  struct gl_framebuffer;
 +struct gl_image_unit;
  struct gl_pixelstore_attrib;
  struct gl_program;
  struct gl_renderbuffer;
 diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
 index e9750f4..7be0664 100644
 --- a/src/mesa/main/mtypes.h
 +++ b/src/mesa/main/mtypes.h
 @@ -1207,6 +1207,9 @@ struct gl_texture_object

 /** GL_OES_EGL_image_external */
 GLint RequiredTextureImageUnits;
 +
 +   /** GL_ARB_shader_image_load_store */
 +   GLenum ImageFormatCompatibility;
  };


 @@ -2373,6 +2376,29 @@ struct gl_shader
  */
GLenum OutputType;
 } Geom;
 +
 +   /**
 +* Map from image uniform index to image unit (set by glUniform1i())
 +*
 +* An image uniform index is associated with each image uniform by
 +* the linker.  The image index associated with each uniform is
 +* stored in the \c gl_uniform_storage::image field.
 +*/
 +   GLubyte ImageUnits[MAX_IMAGE_UNITS];
 +
 +   /**
 +* Access qualifier specified in the shader for each image uniform.
 +* Either \c GL_READ_ONLY, \c GL_WRITE_ONLY or \c GL_READ_WRITE.
 +*
 +* It may be different, though only more strict than the value of
 +* \c gl_image_unit::Access for the corresponding image unit.
 +*/
 +   GLenum ImageAccess[MAX_IMAGE_UNITS];
 +
 +   /**
 +* Number of image uniforms defined in the shader.
 +*/
 +   GLuint NumImages;
  };


 @@ -3077,9 +3103,13 @@ struct gl_program_constants
 GLuint MaxUniformBlocks;
 GLuint MaxCombinedUniformComponents;
 GLuint MaxTextureImageUnits;
 +
 /* GL_ARB_shader_atomic_counters */
 GLuint MaxAtomicBuffers;
 GLuint MaxAtomicCounters;
 +
 +   /* GL_ARB_shader_image_load_store */
 +   GLuint MaxImageUniforms;
  };


 @@ -3302,6 +3332,12 @@ struct gl_constants
 /** GL_ARB_vertex_attrib_binding */
 GLint MaxVertexAttribRelativeOffset;
 GLint MaxVertexAttribBindings;
 +
 +   /* GL_ARB_shader_image_load_store */
 +   GLuint MaxImageUnits;
 +   GLuint MaxCombinedImageUnitsAndFragmentOutputs;
 +   GLuint MaxImageSamples;
 +   GLuint MaxCombinedImageUniforms;
  };


 @@ -3727,6 +3763,11 @@ struct gl_driver_flags
  * gl_context::AtomicBufferBindings
  */
 GLbitfield NewAtomicBuffer;
 +
 +   /**
 +* gl_context::ImageUnits
 +*/
 +   GLbitfield NewImageUnits;
  };

  struct gl_uniform_buffer_binding
 @@ -3744,6 +3785,60 @@ struct gl_uniform_buffer_binding
  };

  /**
 + * ARB_shader_image_load_store image unit.
 + */
 +struct gl_image_unit
 +{
 +   /**
 +* Texture object bound to this unit.
 +*/
 +   struct gl_texture_object *TexObj;
 +
 +   /**
 +* Level of the texture object bound to this unit.
 +*/
 +   GLuint Level;
 +
 +   /**
 +* \c GL_TRUE if the whole level is bound as an array of layers, \c
 +* GL_FALSE if only some specific layer of the texture is bound.
 +* \sa Layer
 +*/
 +   GLboolean Layered;
 +
 +   /**
 +* Layer of the texture object bound to this unit, or zero if \c
 +* Layered is \c GL_TRUE.
 +*/
 +   GLuint Layer;
 +
 +   /**
 +* Access allowed to this texture image.  Either \c GL_READ_ONLY,
 +* \c GL_WRITE_ONLY or \c GL_READ_WRITE.
 +*/
 +   GLenum Access;
 +
 +   /**
 +* GL internal format that determines the interpretation of the
 +* image memory when shader image operations are performed through
 +* this unit.
 +*/
 +   GLenum Format;
 +
 +   /**
 +* Mesa format corresponding to \c Format.
 +*/
 +   gl_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;
 +};
 +
 +/**
   * Binding point for an atomic counter buffer object.
   */
  

Re: [Mesa-dev] [PATCH 10/11] mesa: Validate image units when the texture state changes.

2013-11-24 Thread Chris Forbes
It would be nice not to have to touch this memory when the extension
is unused|unsupported, but that might be a problem for another
patch...

-- Chris

On Mon, Nov 25, 2013 at 6:00 PM, Francisco Jerez curroje...@riseup.net wrote:
 ---
  src/mesa/main/shaderimage.c | 11 +++
  src/mesa/main/shaderimage.h |  9 +
  src/mesa/main/texstate.c|  3 +++
  3 files changed, 23 insertions(+)

 diff --git a/src/mesa/main/shaderimage.c b/src/mesa/main/shaderimage.c
 index 627366b..3a59409 100644
 --- a/src/mesa/main/shaderimage.c
 +++ b/src/mesa/main/shaderimage.c
 @@ -368,6 +368,17 @@ validate_image_unit(struct gl_context *ctx, struct 
 gl_image_unit *u)
 return GL_TRUE;
  }

 +void
 +_mesa_validate_image_units(struct gl_context *ctx)
 +{
 +   int i;
 +
 +   for (i = 0; i  ctx-Const.MaxImageUnits; ++i) {
 +  struct gl_image_unit *u = ctx-ImageUnits[i];
 +  u-_Valid = validate_image_unit(ctx, u);
 +   }
 +}
 +
  static GLboolean
  validate_bind_image_texture(struct gl_context *ctx, GLuint unit,
  GLuint texture, GLint level, GLboolean layered,
 diff --git a/src/mesa/main/shaderimage.h b/src/mesa/main/shaderimage.h
 index f9d550b..aaecc5d 100644
 --- a/src/mesa/main/shaderimage.h
 +++ b/src/mesa/main/shaderimage.h
 @@ -31,6 +31,15 @@

  struct gl_context;

 +/**
 + * Recalculate the \c _Valid flag of a context's shader image units.
 + *
 + * To be called when the state of any texture bound to an image unit
 + * changes.
 + */
 +void
 +_mesa_validate_image_units(struct gl_context *ctx);
 +
  void GLAPIENTRY
  _mesa_BindImageTexture(GLuint unit, GLuint texture, GLint level,
 GLboolean layered, GLint layer, GLenum access,
 diff --git a/src/mesa/main/texstate.c b/src/mesa/main/texstate.c
 index ad80dcf..7720965 100644
 --- a/src/mesa/main/texstate.c
 +++ b/src/mesa/main/texstate.c
 @@ -35,6 +35,7 @@
  #include context.h
  #include enums.h
  #include macros.h
 +#include shaderimage.h
  #include texobj.h
  #include teximage.h
  #include texstate.h
 @@ -674,6 +675,8 @@ update_texture_state( struct gl_context *ctx )

 if (!fprog || !vprog)
update_texgen(ctx);
 +
 +   _mesa_validate_image_units(ctx);
  }


 --
 1.8.3.4

 ___
 mesa-dev mailing list
 mesa-dev@lists.freedesktop.org
 http://lists.freedesktop.org/mailman/listinfo/mesa-dev
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 00/17] Newbie Project : Enable ARB_map_buffer_alignment in all drivers

2013-11-24 Thread Chris Forbes
It would be good to fold the fixes into the patches they belong in.

I'd wait until you collect review comments on the whole series, then
incorporate all the review you get and send out a new version at that
point.

-- Chris

On Mon, Nov 25, 2013 at 8:29 PM, Siavash Eliasi siavashser...@gmail.com wrote:
 On 11/25/2013 10:50 AM, Chris Forbes wrote:

 Ah, I see you have a follow-up that fixes this already.

 Looks good, sorry for the noise.

 -- Chris

 I'm pretty new here and I'm not used to mailing lists, sorry if patches
 aren't showing up in correct place.

 Should I send all of patches again (and possibly squash a few) or is that
 fine by moderators?
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 00/11] Core mesa changes for ARB_shader_image_load_store.

2013-11-24 Thread Chris Forbes
Patches 1-4, 8-11 are:

Reviewed-by: Chris Forbes chr...@ijw.co.nz

With the bounds checks fixed, patch 5 is also:

Reviewed-by: Chris Forbes chr...@ijw.co.nz

I haven't had time to read 6-7 carefully enough to convince myself
they are correct, but you can consider them

Acked-by: Chris Forbes chr...@ijw.co.nz

The various other bits of feedback I gave may or may not be useful.

-- Chris

On Mon, Nov 25, 2013 at 6:00 PM, Francisco Jerez curroje...@riseup.net wrote:
 This is the first of three patch series enabling basic support for
 ARB_shader_image_load_store on Intel Gen7 (and Gen7.5) hardware.  Most
 of the necessary core mesa changes are part of this batch (except the
 one patch that depends on GLSL changes).  I'll be sending a second
 batch with the GLSL compiler changes shortly, and in at most a few
 days a third, considerably more complex batch with the i965 driver and
 compiler back-end changes.

 I'll be pushing my patches here [1] as they come out so it's easy to
 download and test all the dependencies together.

 Thanks.

 [1] http://cgit.freedesktop.org/~currojerez/mesa/log/?h=image-load-store

 [PATCH 01/11] glapi: Update dispatch XML files for 
 ARB_shader_image_load_store.
 [PATCH 02/11] mesa: Add ARB_shader_image_load_store to the extension table.
 [PATCH 03/11] mesa: Add state data structures requried for 
 ARB_shader_image_load_store.
 [PATCH 04/11] mesa: Add driver interface for ARB_shader_image_load_store.
 [PATCH 05/11] mesa: Add image parameter queries for 
 ARB_shader_image_load_store.
 [PATCH 06/11] mesa: Add MESA_FORMAT_ABGR2101010.
 [PATCH 07/11] mesa: Add MESA_FORMAT_SIGNED_RG88 and _RG1616.
 [PATCH 08/11] mesa: Implement the GL entry points defined by 
 ARB_shader_image_load_store.
 [PATCH 09/11] mesa: Unbind deleted textures from the shader image units.
 [PATCH 10/11] mesa: Validate image units when the texture state changes.
 [PATCH 11/11] docs: Mark ARB_shader_image_load_store as work in progress.
 ___
 mesa-dev mailing list
 mesa-dev@lists.freedesktop.org
 http://lists.freedesktop.org/mailman/listinfo/mesa-dev
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 3/9] gallium/dri2: Set winsys_handle type to KMS for stride query.

2013-11-24 Thread Thomas Hellstrom

On 11/25/2013 05:06 AM, Christopher James Halse Rogers wrote:

On Thu, 2013-11-21 at 14:12 +0100, Thomas Hellstrom wrote:

On 11/21/2013 05:11 AM, christopher.halse.rog...@canonical.com wrote:

From: Christopher James Halse Rogers r...@ubuntu.com

Otherwise the default is TYPE_SHARED, which will flink the bo. This seems
rather unnecessary for a simple stride query.

Is there no way we can cache this stuff in a __DRIimage? Changing the
calling conventions to adapt to poor implementations seems like
the wrong way to go. What if other drivers use a slow approach to get
the KMS handle?


Do you want me to add some extra gallium API to get this sort of image
metadata without using what's essentially a side-effect of
resource_get_handle? If this isn't a theoretical concern I can certainly
do so


It's more of a theoretical concern. We can certainly revisit this at a 
later time.


Thanks,
Thomas
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev