Mesa (master): glsl: Improve the accuracy of the acos() approximation.

2016-03-03 Thread Kenneth Graunke
Module: Mesa
Branch: master
Commit: a6046d217d14130a46f6ffe42992fd745551a928
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=a6046d217d14130a46f6ffe42992fd745551a928

Author: Francisco Jerez 
Date:   Wed Mar  2 23:50:04 2016 -0800

glsl: Improve the accuracy of the acos() approximation.

The adjusted polynomial coefficients come from the numerical
minimization of the L2 norm of the relative error.  The old
coefficients would give a maximum relative error of about 15000 ULP in
the neighborhood around acos(x) = 0, the new ones give a relative
error bounded by less than 2000 ULP in the same neighborhood.

Fixes four dEQP subtests:
dEQP-GLES31.functional.shaders.builtin_functions.precision.acos.
highp_compute.{scalar,vec2,vec3,vec4}

Signed-off-by: Kenneth Graunke 
Reviewed-by: Iago Toral Quiroga 
Reviewed-by: Francisco Jerez 

---

 src/compiler/glsl/builtin_functions.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/compiler/glsl/builtin_functions.cpp 
b/src/compiler/glsl/builtin_functions.cpp
index 0d289c1..10fb21b 100644
--- a/src/compiler/glsl/builtin_functions.cpp
+++ b/src/compiler/glsl/builtin_functions.cpp
@@ -3262,7 +3262,7 @@ builtin_builder::_acos(const glsl_type *type)
ir_variable *x = in_var(type, "x");
MAKE_SIG(type, always_available, 1, x);
 
-   body.emit(ret(sub(imm(M_PI_2f), asin_expr(x, 0.086566724f, -0.03102955f;
+   body.emit(ret(sub(imm(M_PI_2f), asin_expr(x, 0.08132463f, -0.02363318f;
 
return sig;
 }

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (master): i965: Set MaxFramebufferWidth/Height to 16384, not viewport.

2016-03-03 Thread Kenneth Graunke
Module: Mesa
Branch: master
Commit: 9ec246796f95996868d61ffc9b52a2c1811bb66d
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=9ec246796f95996868d61ffc9b52a2c1811bb66d

Author: Kenneth Graunke 
Date:   Thu Mar  3 01:22:37 2016 -0800

i965: Set MaxFramebufferWidth/Height to 16384, not viewport.

dEQP-GLES31.functional.fbo.no_attachments.maximums.{all,height,size,width}
started hitting assertion failures when emitting SURFACE_STATE, after
commit e8fd60e7891c7 where Samuel increased the maximum viewport size to
32768, from 16384.

MaxFramebufferWidth/Height were being set to the maximum viewport size,
but are actually limited by the SURFACE_STATE width/height field range,
which is 16384 on Gen7+ (where ARB_framebuffer_no_attachments is
exposed).  So, reduce these to 16384 explicitly.

Fixes assert fails in the above mentioned dEQP tests.  (Those tests
still fail, however.)

Signed-off-by: Kenneth Graunke 
Reviewed-by: Samuel Iglesias Gonsálvez 

---

 src/mesa/drivers/dri/i965/brw_context.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_context.c 
b/src/mesa/drivers/dri/i965/brw_context.c
index 3783664..c66dd13 100644
--- a/src/mesa/drivers/dri/i965/brw_context.c
+++ b/src/mesa/drivers/dri/i965/brw_context.c
@@ -665,8 +665,8 @@ brw_initialize_context_constants(struct brw_context *brw)
   ctx->Const.MaxVertexStreams = MIN2(4, MAX_VERTEX_STREAMS);
 
/* ARB_framebuffer_no_attachments */
-   ctx->Const.MaxFramebufferWidth = ctx->Const.MaxViewportWidth;
-   ctx->Const.MaxFramebufferHeight = ctx->Const.MaxViewportHeight;
+   ctx->Const.MaxFramebufferWidth = 16384;
+   ctx->Const.MaxFramebufferHeight = 16384;
ctx->Const.MaxFramebufferLayers = ctx->Const.MaxArrayTextureLayers;
ctx->Const.MaxFramebufferSamples = max_samples;
 }

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (master): mesa: Make glGet queries initialize ctx-> Debug when necessary.

2016-03-03 Thread Kenneth Graunke
Module: Mesa
Branch: master
Commit: b4b50b074beae9b679e5acdbb4b49193e539576d
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=b4b50b074beae9b679e5acdbb4b49193e539576d

Author: Kenneth Graunke 
Date:   Wed Mar  2 23:19:27 2016 -0800

mesa: Make glGet queries initialize ctx->Debug when necessary.

dEQP-GLES31.functional.debug.state_query.debug_group_stack_depth_*
tries to call glGet on GL_DEBUG_GROUP_STACK_DEPTH right away, before
doing any other debug setup.  This should return 1.

However, because ctx->Debug wasn't allocated, we bailed and returned 0.

This patch removes the open-coded locking and switches the two glGet
functions to use _mesa_lock_debug_state(), which takes care of
allocating and initializing that state on the first time.  It also
conveniently takes care of unlocking on failure for us, so we don't
need to handle that in every caller.

Fixes dEQP-GLES31.functional.debug.state_query.debug_group_stack_depth_
{getboolean,getfloat,getinteger,getinteger64}.

Cc: mesa-sta...@lists.freedesktop.org
Signed-off-by: Kenneth Graunke 
Reviewed-by: Ilia Mirkin 
Reviewed-by: Timothy Arceri 
Reviewed-by: Emil Velikov 

---

 src/mesa/main/debug_output.c | 20 ++--
 1 file changed, 6 insertions(+), 14 deletions(-)

diff --git a/src/mesa/main/debug_output.c b/src/mesa/main/debug_output.c
index 10ee675..c2b9f05 100644
--- a/src/mesa/main/debug_output.c
+++ b/src/mesa/main/debug_output.c
@@ -761,15 +761,11 @@ _mesa_set_debug_state_int(struct gl_context *ctx, GLenum 
pname, GLint val)
 GLint
 _mesa_get_debug_state_int(struct gl_context *ctx, GLenum pname)
 {
-   struct gl_debug_state *debug;
GLint val;
 
-   mtx_lock(>DebugMutex);
-   debug = ctx->Debug;
-   if (!debug) {
-  mtx_unlock(>DebugMutex);
+   struct gl_debug_state *debug = _mesa_lock_debug_state(ctx);
+   if (!debug)
   return 0;
-   }
 
switch (pname) {
case GL_DEBUG_OUTPUT:
@@ -794,7 +790,7 @@ _mesa_get_debug_state_int(struct gl_context *ctx, GLenum 
pname)
   break;
}
 
-   mtx_unlock(>DebugMutex);
+   _mesa_unlock_debug_state(ctx);
 
return val;
 }
@@ -806,15 +802,11 @@ _mesa_get_debug_state_int(struct gl_context *ctx, GLenum 
pname)
 void *
 _mesa_get_debug_state_ptr(struct gl_context *ctx, GLenum pname)
 {
-   struct gl_debug_state *debug;
void *val;
+   struct gl_debug_state *debug = _mesa_lock_debug_state(ctx);
 
-   mtx_lock(>DebugMutex);
-   debug = ctx->Debug;
-   if (!debug) {
-  mtx_unlock(>DebugMutex);
+   if (!debug)
   return NULL;
-   }
 
switch (pname) {
case GL_DEBUG_CALLBACK_FUNCTION_ARB:
@@ -829,7 +821,7 @@ _mesa_get_debug_state_ptr(struct gl_context *ctx, GLenum 
pname)
   break;
}
 
-   mtx_unlock(>DebugMutex);
+   _mesa_unlock_debug_state(ctx);
 
return val;
 }

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (master): mesa: Allow Get*() of several forgotten IsEnabled() pnames.

2016-03-03 Thread Kenneth Graunke
Module: Mesa
Branch: master
Commit: aa37cbdff7bb1d2170f1603b02a8b8517255894f
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=aa37cbdff7bb1d2170f1603b02a8b8517255894f

Author: Kenneth Graunke 
Date:   Thu Mar  3 00:43:15 2016 -0800

mesa: Allow Get*() of several forgotten IsEnabled() pnames.

From section 6.2 ("State Tables") of the GL 2.1 specification
(the text also appears in the GL 3.0 and ES 3.1 specifications):
"However, state variables for which IsEnabled is listed as the query
 command can also be obtained using GetBooleanv, GetIntegerv, GetFloatv,
 and GetDoublev."

GL_DEBUG_OUTPUT, GL_DEBUG_OUTPUT_SYNCHRONOUS, and GL_FRAGMENT_SHADER_ATI
were missing from the glGet*() functions.  All other IsEnabled() pnames
look to be present, as far as I can tell.

Fixes 8 dEQP-GLES31.functional.debug.state_query subtests:
debug_output[_synchronous]_get{boolean,float,integer,integer64}.

Cc: mesa-sta...@lists.freedesktop.org
Signed-off-by: Kenneth Graunke 
Reviewed-by: Ilia Mirkin 
Reviewed-by: Emil Velikov 

---

 src/mesa/main/get.c  | 2 ++
 src/mesa/main/get_hash_params.py | 3 +++
 2 files changed, 5 insertions(+)

diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c
index f40c570..4cc82d8 100644
--- a/src/mesa/main/get.c
+++ b/src/mesa/main/get.c
@@ -1055,6 +1055,8 @@ find_custom_value(struct gl_context *ctx, const struct 
value_desc *d, union valu
   }
   break;
/* GL_KHR_DEBUG */
+   case GL_DEBUG_OUTPUT:
+   case GL_DEBUG_OUTPUT_SYNCHRONOUS:
case GL_DEBUG_LOGGED_MESSAGES:
case GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH:
case GL_DEBUG_GROUP_STACK_DEPTH:
diff --git a/src/mesa/main/get_hash_params.py b/src/mesa/main/get_hash_params.py
index 07d2d20..f9d66f8 100644
--- a/src/mesa/main/get_hash_params.py
+++ b/src/mesa/main/get_hash_params.py
@@ -126,6 +126,8 @@ descriptor=[
   [ "MAX_TEXTURE_MAX_ANISOTROPY_EXT", 
"CONTEXT_FLOAT(Const.MaxTextureMaxAnisotropy), 
extra_EXT_texture_filter_anisotropic" ],
 
 # GL_KHR_debug (GL 4.3)/ GL_ARB_debug_output
+  [ "DEBUG_OUTPUT", "LOC_CUSTOM, TYPE_BOOLEAN, 0, NO_EXTRA" ],
+  [ "DEBUG_OUTPUT_SYNCHRONOUS", "LOC_CUSTOM, TYPE_BOOLEAN, 0, NO_EXTRA" ],
   [ "DEBUG_LOGGED_MESSAGES", "LOC_CUSTOM, TYPE_INT, 0, NO_EXTRA" ],
   [ "DEBUG_NEXT_LOGGED_MESSAGE_LENGTH", "LOC_CUSTOM, TYPE_INT, 0, NO_EXTRA" ],
   [ "MAX_DEBUG_LOGGED_MESSAGES", "CONST(MAX_DEBUG_LOGGED_MESSAGES), NO_EXTRA" 
],
@@ -773,6 +775,7 @@ descriptor=[
   [ "DEPTH_CLAMP", "CONTEXT_BOOL(Transform.DepthClamp), extra_ARB_depth_clamp" 
],
 
 # GL_ATI_fragment_shader
+  [ "FRAGMENT_SHADER_ATI", "CONTEXT_BOOL(ATIFragmentShader.Enabled), 
extra_ATI_fragment_shader" ],
   [ "NUM_FRAGMENT_REGISTERS_ATI", "CONST(6), extra_ATI_fragment_shader" ],
   [ "NUM_FRAGMENT_CONSTANTS_ATI", "CONST(8), extra_ATI_fragment_shader" ],
   [ "NUM_PASSES_ATI", "CONST(2), extra_ATI_fragment_shader" ],

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (master): glsl: Parameterize asin_expr() on the fit coefficients.

2016-03-03 Thread Kenneth Graunke
Module: Mesa
Branch: master
Commit: 2795fbcae302cd8821b23821ebf8a2b256ff10d5
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=2795fbcae302cd8821b23821ebf8a2b256ff10d5

Author: Kenneth Graunke 
Date:   Wed Mar  2 23:39:18 2016 -0800

glsl: Parameterize asin_expr() on the fit coefficients.

This will allow us to share the implementation while using different
polynomials for asin() and acos().

Francisco Jerez did this in the SPIR-V front-end; I'm merely porting
his idea to the GLSL world.

Signed-off-by: Kenneth Graunke 
Reviewed-by: Iago Toral Quiroga 
Reviewed-by: Francisco Jerez 

---

 src/compiler/glsl/builtin_functions.cpp | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/compiler/glsl/builtin_functions.cpp 
b/src/compiler/glsl/builtin_functions.cpp
index 0a0dcc6..0d289c1 100644
--- a/src/compiler/glsl/builtin_functions.cpp
+++ b/src/compiler/glsl/builtin_functions.cpp
@@ -578,7 +578,7 @@ private:
ir_dereference_array *array_ref(ir_variable *var, int i);
ir_swizzle *matrix_elt(ir_variable *var, int col, int row);
 
-   ir_expression *asin_expr(ir_variable *x);
+   ir_expression *asin_expr(ir_variable *x, float p0, float p1);
void do_atan(ir_factory , const glsl_type *type, ir_variable *res, 
operand y_over_x);
 
/**
@@ -3212,7 +3212,7 @@ builtin_builder::_tan(const glsl_type *type)
 }
 
 ir_expression *
-builtin_builder::asin_expr(ir_variable *x)
+builtin_builder::asin_expr(ir_variable *x, float p0, float p1)
 {
return mul(sign(x),
   sub(imm(M_PI_2f),
@@ -3221,8 +3221,8 @@ builtin_builder::asin_expr(ir_variable *x)
   mul(abs(x),
   add(imm(M_PI_4f - 1.0f),
   mul(abs(x),
-  add(imm(0.086566724f),
-  mul(abs(x), 
imm(-0.03102955f));
+  add(imm(p0),
+  mul(abs(x), imm(p1));
 }
 
 ir_call *
@@ -3251,7 +3251,7 @@ builtin_builder::_asin(const glsl_type *type)
ir_variable *x = in_var(type, "x");
MAKE_SIG(type, always_available, 1, x);
 
-   body.emit(ret(asin_expr(x)));
+   body.emit(ret(asin_expr(x, 0.086566724f, -0.03102955f)));
 
return sig;
 }
@@ -3262,7 +3262,7 @@ builtin_builder::_acos(const glsl_type *type)
ir_variable *x = in_var(type, "x");
MAKE_SIG(type, always_available, 1, x);
 
-   body.emit(ret(sub(imm(M_PI_2f), asin_expr(x;
+   body.emit(ret(sub(imm(M_PI_2f), asin_expr(x, 0.086566724f, -0.03102955f;
 
return sig;
 }

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (vulkan): isl/surface_state: Set L2 bypass disable for certain BC* formats

2016-03-03 Thread Jason Ekstrand
Module: Mesa
Branch: vulkan
Commit: 56ba13c994fc3b1c4058bb99656dad6fa2aa819d
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=56ba13c994fc3b1c4058bb99656dad6fa2aa819d

Author: Jason Ekstrand 
Date:   Thu Mar  3 16:15:54 2016 -0800

isl/surface_state: Set L2 bypass disable for certain BC* formats

---

 src/intel/isl/isl_surface_state.c | 22 ++
 1 file changed, 22 insertions(+)

diff --git a/src/intel/isl/isl_surface_state.c 
b/src/intel/isl/isl_surface_state.c
index 0f45100..1607aa6 100644
--- a/src/intel/isl/isl_surface_state.c
+++ b/src/intel/isl/isl_surface_state.c
@@ -370,6 +370,28 @@ isl_genX(surf_fill_state_s)(const struct isl_device *dev, 
void *state,
   s.MIPCountLOD = MAX(info->view->levels, 1) - 1;
}
 
+#if GEN_GEN >= 8
+   /* From the CHV PRM, Volume 2d, page 321 (RENDER_SURFACE_STATE dword 0
+* bit 9 "Sampler L2 Bypass Mode Disable" Programming Notes):
+*
+*This bit must be set for the following surface types: BC2_UNORM
+*BC3_UNORM BC5_UNORM BC5_SNORM BC7_UNORM
+*/
+   if (GEN_GEN >= 9 || dev->info->is_cherryview) {
+  switch (info->view->format) {
+  case ISL_FORMAT_BC2_UNORM:
+  case ISL_FORMAT_BC3_UNORM:
+  case ISL_FORMAT_BC5_UNORM:
+  case ISL_FORMAT_BC5_SNORM:
+  case ISL_FORMAT_BC7_UNORM:
+ s.SamplerL2BypassModeDisable = true;
+ break;
+  default:
+ break;
+  }
+   }
+#endif
+
 #if 0
if (GEN_GEN == 8) {
   if (isl_format_is_integer(info->view->format)) {

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (master): Update docs to advertise new support for ARB_internalformat_query2

2016-03-03 Thread Eduardo Lima Mitev
Module: Mesa
Branch: master
Commit: 47392011c057e078848d0be84aaba540ef84e8c7
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=47392011c057e078848d0be84aaba540ef84e8c7

Author: Eduardo Lima Mitev 
Date:   Thu Mar  3 15:43:01 2016 +0100

Update docs to advertise new support for ARB_internalformat_query2

Support in Mesa main and i965 has just been added.

v2: Include note in 'New Features' of docs/relnotes/11.3.0.html.

Reviewed-by: Ilia Mirkin 

---

 docs/GL3.txt  | 2 +-
 docs/relnotes/11.3.0.html | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/docs/GL3.txt b/docs/GL3.txt
index d141c22..02dc6ea 100644
--- a/docs/GL3.txt
+++ b/docs/GL3.txt
@@ -158,7 +158,7 @@ GL 4.3, GLSL 4.30:
   GL_ARB_explicit_uniform_location DONE (all drivers that 
support GLSL)
   GL_ARB_fragment_layer_viewport   DONE (i965, nv50, nvc0, 
r600, radeonsi, llvmpipe)
   GL_ARB_framebuffer_no_attachmentsDONE (i965)
-  GL_ARB_internalformat_query2 in progress (elima)
+  GL_ARB_internalformat_query2 DONE (i965)
   GL_ARB_invalidate_subdataDONE (all drivers)
   GL_ARB_multi_draw_indirect   DONE (i965, nvc0, r600, 
radeonsi, llvmpipe, softpipe)
   GL_ARB_program_interface_query   DONE (all drivers)
diff --git a/docs/relnotes/11.3.0.html b/docs/relnotes/11.3.0.html
index fa65083..99445c2 100644
--- a/docs/relnotes/11.3.0.html
+++ b/docs/relnotes/11.3.0.html
@@ -44,6 +44,7 @@ Note: some of the new features are only available with 
certain drivers.
 
 
 
+GL_ARB_internalformat_query2 on i965
 GL_OES_texture_border_clamp and GL_EXT_texture_border_clamp on all drivers 
that support GL_ARB_texture_border_clamp
 GL_OES_shader_image_atomic on all drivers that support 
GL_ARB_shader_image_load_store
 

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (vulkan): anv: Compile shader stages in pipeline order.

2016-03-03 Thread Kenneth Graunke
Module: Mesa
Branch: vulkan
Commit: 623ce595a97cc3ec47be042867e24047162cd371
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=623ce595a97cc3ec47be042867e24047162cd371

Author: Kenneth Graunke 
Date:   Wed Feb 24 15:41:24 2016 -0800

anv: Compile shader stages in pipeline order.

Instead of the arbitrary order modules might be specified in.

Acked-by: Jason Ekstrand 

---

 src/intel/vulkan/anv_pipeline.c | 48 ++---
 1 file changed, 26 insertions(+), 22 deletions(-)

diff --git a/src/intel/vulkan/anv_pipeline.c b/src/intel/vulkan/anv_pipeline.c
index 647f2eb..fd6f8c9 100644
--- a/src/intel/vulkan/anv_pipeline.c
+++ b/src/intel/vulkan/anv_pipeline.c
@@ -1108,29 +1108,33 @@ anv_pipeline_init(struct anv_pipeline *pipeline,
pipeline->active_stages = 0;
pipeline->total_scratch = 0;
 
+   const VkPipelineShaderStageCreateInfo *pStages[MESA_SHADER_STAGES] = { 0, };
+   struct anv_shader_module *modules[MESA_SHADER_STAGES] = { 0, };
for (uint32_t i = 0; i < pCreateInfo->stageCount; i++) {
-  ANV_FROM_HANDLE(anv_shader_module, module,
-  pCreateInfo->pStages[i].module);
-
-  switch (pCreateInfo->pStages[i].stage) {
-  case VK_SHADER_STAGE_VERTEX_BIT:
- anv_pipeline_compile_vs(pipeline, cache, pCreateInfo, module,
- pCreateInfo->pStages[i].pName,
- pCreateInfo->pStages[i].pSpecializationInfo);
- break;
-  case VK_SHADER_STAGE_GEOMETRY_BIT:
- anv_pipeline_compile_gs(pipeline, cache, pCreateInfo, module,
- pCreateInfo->pStages[i].pName,
- pCreateInfo->pStages[i].pSpecializationInfo);
- break;
-  case VK_SHADER_STAGE_FRAGMENT_BIT:
- anv_pipeline_compile_fs(pipeline, cache, pCreateInfo, extra, module,
- pCreateInfo->pStages[i].pName,
- pCreateInfo->pStages[i].pSpecializationInfo);
- break;
-  default:
- anv_finishme("Unsupported shader stage");
-  }
+  gl_shader_stage stage = ffs(pCreateInfo->pStages[i].stage) - 1;
+  pStages[stage] = >pStages[i];
+  modules[stage] = anv_shader_module_from_handle(pStages[stage]->module);
+   }
+
+   if (modules[MESA_SHADER_VERTEX]) {
+  anv_pipeline_compile_vs(pipeline, cache, pCreateInfo,
+  modules[MESA_SHADER_VERTEX],
+  pStages[MESA_SHADER_VERTEX]->pName,
+  
pStages[MESA_SHADER_VERTEX]->pSpecializationInfo);
+   }
+
+   if (modules[MESA_SHADER_GEOMETRY]) {
+  anv_pipeline_compile_gs(pipeline, cache, pCreateInfo,
+  modules[MESA_SHADER_GEOMETRY],
+  pStages[MESA_SHADER_GEOMETRY]->pName,
+  
pStages[MESA_SHADER_GEOMETRY]->pSpecializationInfo);
+   }
+
+   if (modules[MESA_SHADER_FRAGMENT]) {
+  anv_pipeline_compile_fs(pipeline, cache, pCreateInfo, extra,
+  modules[MESA_SHADER_FRAGMENT],
+  pStages[MESA_SHADER_FRAGMENT]->pName,
+  
pStages[MESA_SHADER_FRAGMENT]->pSpecializationInfo);
}
 
if (!(pipeline->active_stages & VK_SHADER_STAGE_VERTEX_BIT)) {

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (vulkan): anv/meta: Replace copy_format w/ block size in do_buffer_copy()

2016-03-03 Thread Nanley Chery
Module: Mesa
Branch: vulkan
Commit: cfe70367503ffb49a850a17e03f4c7e4138af4f1
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=cfe70367503ffb49a850a17e03f4c7e4138af4f1

Author: Nanley Chery 
Date:   Sat Feb 27 14:25:00 2016 -0800

anv/meta: Replace copy_format w/ block size in do_buffer_copy()

This is a preparatory commit that will simplify the future usage of
this function.

Signed-off-by: Nanley Chery 
Reviewed-by: Jason Ekstrand 

---

 src/intel/vulkan/anv_meta_blit.c | 17 ++---
 1 file changed, 6 insertions(+), 11 deletions(-)

diff --git a/src/intel/vulkan/anv_meta_blit.c b/src/intel/vulkan/anv_meta_blit.c
index 216a0bf..9d41add 100644
--- a/src/intel/vulkan/anv_meta_blit.c
+++ b/src/intel/vulkan/anv_meta_blit.c
@@ -406,9 +406,10 @@ static void
 do_buffer_copy(struct anv_cmd_buffer *cmd_buffer,
struct anv_bo *src, uint64_t src_offset,
struct anv_bo *dest, uint64_t dest_offset,
-   int width, int height, VkFormat copy_format)
+   int width, int height, int bs)
 {
VkDevice vk_device = anv_device_to_handle(cmd_buffer->device);
+   VkFormat copy_format = vk_format_for_size(bs);
 
VkImageCreateInfo image_info = {
   .sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO,
@@ -534,8 +535,6 @@ void anv_CmdCopyBuffer(
  bs = MIN2(bs, 1 << fs);
   assert(pRegions[r].size % bs == 0);
 
-  VkFormat copy_format = vk_format_for_size(bs);
-
   /* This is maximum possible width/height our HW can handle */
   uint64_t max_surface_dim = 1 << 14;
 
@@ -544,7 +543,7 @@ void anv_CmdCopyBuffer(
   while (copy_size >= max_copy_size) {
  do_buffer_copy(cmd_buffer, src_buffer->bo, src_offset,
 dest_buffer->bo, dest_offset,
-max_surface_dim, max_surface_dim, copy_format);
+max_surface_dim, max_surface_dim, bs);
  copy_size -= max_copy_size;
  src_offset += max_copy_size;
  dest_offset += max_copy_size;
@@ -556,7 +555,7 @@ void anv_CmdCopyBuffer(
  uint64_t rect_copy_size = height * max_surface_dim * bs;
  do_buffer_copy(cmd_buffer, src_buffer->bo, src_offset,
 dest_buffer->bo, dest_offset,
-max_surface_dim, height, copy_format);
+max_surface_dim, height, bs);
  copy_size -= rect_copy_size;
  src_offset += rect_copy_size;
  dest_offset += rect_copy_size;
@@ -565,7 +564,7 @@ void anv_CmdCopyBuffer(
   if (copy_size != 0) {
  do_buffer_copy(cmd_buffer, src_buffer->bo, src_offset,
 dest_buffer->bo, dest_offset,
-copy_size / bs, 1, copy_format);
+copy_size / bs, 1, bs);
   }
}
 
@@ -601,17 +600,13 @@ void anv_CmdUpdateBuffer(
 
   memcpy(tmp_data.map, pData, copy_size);
 
-  VkFormat format;
   int bs;
   if ((copy_size & 15) == 0 && (dstOffset & 15) == 0) {
- format = VK_FORMAT_R32G32B32A32_UINT;
  bs = 16;
   } else if ((copy_size & 7) == 0 && (dstOffset & 7) == 0) {
- format = VK_FORMAT_R32G32_UINT;
  bs = 8;
   } else {
  assert((copy_size & 3) == 0 && (dstOffset & 3) == 0);
- format = VK_FORMAT_R32_UINT;
  bs = 4;
   }
 
@@ -619,7 +614,7 @@ void anv_CmdUpdateBuffer(
  _buffer->device->dynamic_state_block_pool.bo,
  tmp_data.offset,
  dst_buffer->bo, dst_buffer->offset + dstOffset,
- copy_size / bs, 1, format);
+ copy_size / bs, 1, bs);
 
   dataSize -= copy_size;
   dstOffset += copy_size;

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (vulkan): anv/meta: Use blitter API in anv_CmdCopyImage()

2016-03-03 Thread Nanley Chery
Module: Mesa
Branch: vulkan
Commit: 96ff4d0679e9243d4df070cc0eaef41e1b9d742b
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=96ff4d0679e9243d4df070cc0eaef41e1b9d742b

Author: Nanley Chery 
Date:   Mon Feb 29 12:19:51 2016 -0800

anv/meta: Use blitter API in anv_CmdCopyImage()

Signed-off-by: Nanley Chery 
Reviewed-by: Jason Ekstrand 

---

 src/intel/vulkan/anv_meta_blit.c | 113 +++
 1 file changed, 42 insertions(+), 71 deletions(-)

diff --git a/src/intel/vulkan/anv_meta_blit.c b/src/intel/vulkan/anv_meta_blit.c
index 8ca1871..2e529ee 100644
--- a/src/intel/vulkan/anv_meta_blit.c
+++ b/src/intel/vulkan/anv_meta_blit.c
@@ -836,7 +836,7 @@ void anv_CmdCopyImage(
 */
assert(src_image->samples == dest_image->samples);
 
-   meta_prepare_blit(cmd_buffer, _state);
+   anv_meta_begin_blit2d(cmd_buffer, _state);
 
for (unsigned r = 0; r < regionCount; r++) {
   assert(pRegions[r].srcSubresource.aspectMask ==
@@ -844,84 +844,55 @@ void anv_CmdCopyImage(
 
   VkImageAspectFlags aspect = pRegions[r].srcSubresource.aspectMask;
 
-  VkFormat src_format = choose_iview_format(src_image, aspect);
-  VkFormat dst_format = choose_iview_format(dest_image, aspect);
-
-  struct anv_image_view src_iview;
-  anv_image_view_init(_iview, cmd_buffer->device,
- &(VkImageViewCreateInfo) {
-.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO,
-.image = srcImage,
-.viewType = anv_meta_get_view_type(src_image),
-.format = src_format,
-.subresourceRange = {
-   .aspectMask = VK_IMAGE_ASPECT_COLOR_BIT,
-   .baseMipLevel = pRegions[r].srcSubresource.mipLevel,
-   .levelCount = 1,
-   .baseArrayLayer = pRegions[r].srcSubresource.baseArrayLayer,
-   .layerCount = pRegions[r].dstSubresource.layerCount,
-},
- },
- cmd_buffer, 0, VK_IMAGE_USAGE_SAMPLED_BIT);
-
-  const uint32_t dest_base_array_slice =
- anv_meta_get_iview_layer(dest_image, [r].dstSubresource,
-  [r].dstOffset);
+  /* Create blit surfaces */
+  struct isl_surf *src_isl_surf =
+ _image_get_surface_for_aspect_mask(src_image, aspect)->isl;
+  struct isl_surf *dst_isl_surf =
+ _image_get_surface_for_aspect_mask(dest_image, aspect)->isl;
+  struct anv_meta_blit2d_surf b_src = blit_surf_for_image(src_image, 
src_isl_surf);
+  struct anv_meta_blit2d_surf b_dst = blit_surf_for_image(dest_image, 
dst_isl_surf);
 
+  /* Start creating blit rect */
+  const VkOffset3D dst_offset_el = meta_region_offset_el(dest_image, 
[r].dstOffset);
+  const VkOffset3D src_offset_el = meta_region_offset_el(src_image, 
[r].srcOffset);
+  const VkExtent3D img_extent_el = 
meta_region_extent_el(src_image->vk_format,
+
[r].extent);
+  struct anv_meta_blit2d_rect rect = {
+ .width = img_extent_el.width,
+ .height = img_extent_el.height,
+  };
 
+  /* Loop through each 3D or array slice */
   unsigned num_slices_3d = pRegions[r].extent.depth;
   unsigned num_slices_array = pRegions[r].dstSubresource.layerCount;
   unsigned slice_3d = 0;
   unsigned slice_array = 0;
   while (slice_3d < num_slices_3d && slice_array < num_slices_array) {
- VkOffset3D src_offset = pRegions[r].srcOffset;
- src_offset.z += slice_3d + slice_array;
-
- uint32_t img_x = 0;
- uint32_t img_y = 0;
- uint32_t img_o = 0;
- if (isl_format_is_compressed(dest_image->format->isl_format))
-
isl_surf_get_image_intratile_offset_el(_buffer->device->isl_dev,
-   
_image->color_surface.isl,
-   
pRegions[r].dstSubresource.mipLevel,
-   
pRegions[r].dstSubresource.baseArrayLayer + slice_array,
-   pRegions[r].dstOffset.z + 
slice_3d,
-   _o, _x, _y);
-
- VkOffset3D dest_offset_el = meta_region_offset_el(dest_image, 
[r].dstOffset);
- dest_offset_el.x += img_x;
- dest_offset_el.y += img_y;
- dest_offset_el.z = 0;
-
- struct anv_image_view dest_iview;
- anv_image_view_init(_iview, cmd_buffer->device,
-&(VkImageViewCreateInfo) {
-   .sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO,
-   .image = destImage,
-   .viewType = anv_meta_get_view_type(dest_image),
-   .format = dst_format,
-   .subresourceRange = {
-  .aspectMask = VK_IMAGE_ASPECT_COLOR_BIT,
-  .baseMipLevel = 

Mesa (vulkan): anv/meta: Use blitter API for state-handling in Buffer Update/Copy

2016-03-03 Thread Nanley Chery
Module: Mesa
Branch: vulkan
Commit: d20f6abc85c1dc4f4a2aadd352b64502930a0541
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=d20f6abc85c1dc4f4a2aadd352b64502930a0541

Author: Nanley Chery 
Date:   Wed Mar  2 14:33:51 2016 -0800

anv/meta: Use blitter API for state-handling in Buffer Update/Copy

Signed-off-by: Nanley Chery 
Reviewed-by: Jason Ekstrand 

---

 src/intel/vulkan/anv_meta_blit.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/intel/vulkan/anv_meta_blit.c b/src/intel/vulkan/anv_meta_blit.c
index bd1c979..3fc4631 100644
--- a/src/intel/vulkan/anv_meta_blit.c
+++ b/src/intel/vulkan/anv_meta_blit.c
@@ -601,7 +601,7 @@ void anv_CmdCopyBuffer(
 
struct anv_meta_saved_state saved_state;
 
-   meta_prepare_blit(cmd_buffer, _state);
+   anv_meta_begin_blit2d(cmd_buffer, _state);
 
for (unsigned r = 0; r < regionCount; r++) {
   uint64_t src_offset = src_buffer->offset + pRegions[r].srcOffset;
@@ -661,7 +661,7 @@ void anv_CmdCopyBuffer(
   }
}
 
-   meta_finish_blit(cmd_buffer, _state);
+   anv_meta_end_blit2d(cmd_buffer, _state);
 }
 
 void anv_CmdUpdateBuffer(
@@ -675,7 +675,7 @@ void anv_CmdUpdateBuffer(
ANV_FROM_HANDLE(anv_buffer, dst_buffer, dstBuffer);
struct anv_meta_saved_state saved_state;
 
-   meta_prepare_blit(cmd_buffer, _state);
+   anv_meta_begin_blit2d(cmd_buffer, _state);
 
/* We can't quite grab a full block because the state stream needs a
 * little data at the top to build its linked list.
@@ -714,7 +714,7 @@ void anv_CmdUpdateBuffer(
   pData = (void *)pData + copy_size;
}
 
-   meta_finish_blit(cmd_buffer, _state);
+   anv_meta_end_blit2d(cmd_buffer, _state);
 }
 
 static VkFormat

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (vulkan): anv/meta: Add the beginnings of a blitter API

2016-03-03 Thread Nanley Chery
Module: Mesa
Branch: vulkan
Commit: 654f79a04512502df96d9e6ce99ac0f95516d193
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=654f79a04512502df96d9e6ce99ac0f95516d193

Author: Jason Ekstrand 
Date:   Thu Dec 31 15:37:54 2015 -0800

anv/meta: Add the beginnings of a blitter API

This API is designed to be an abstraction that sits between the VkCmdCopy
commands and the hardware.  The idea is that it is simple enough that it
*should* be implementable using the blitter but with enough extra data that
we can implement it with the 3-D pipeline efficiently.  One design
objective is to allow the user to supply enough information that we can
handle most blit operations with a single draw call even if they require
copying multiple rectangles.

---

 src/intel/vulkan/anv_meta.h | 48 +
 1 file changed, 48 insertions(+)

diff --git a/src/intel/vulkan/anv_meta.h b/src/intel/vulkan/anv_meta.h
index d33e9e6..f5dac12 100644
--- a/src/intel/vulkan/anv_meta.h
+++ b/src/intel/vulkan/anv_meta.h
@@ -70,6 +70,54 @@ anv_meta_get_iview_layer(const struct anv_image *dest_image,
  const VkImageSubresourceLayers *dest_subresource,
  const VkOffset3D *dest_offset);
 
+struct anv_meta_blit2d_surf {
+   struct anv_bo *bo;
+   enum isl_tiling tiling;
+
+   /** Base offset to the start of the image */
+   uint64_t base_offset;
+
+   uint32_t offset_x;
+   uint32_t offset_y;
+
+   /** The size of a unit in bytes. (Usually texel size) */
+   uint8_t units;
+
+   /** Stride between rows in bytes. */
+   uint32_t stride;
+
+   /** Possible vertical stride in rows.
+*
+* This is a hint to the blit engine that tells it that it can, if it
+* wants, split the surface into v_stride tall chunks.  The user makes
+* the guarantee that no rectangles it passes in will every cross a
+* v_stride boundary.  A v_stride value of 0 indicates that the user
+* cannot make such a guarantee.
+*/
+   uint32_t v_stride;
+};
+
+struct anv_meta_blit2d_rect {
+   uint32_t src_x, src_y;
+   uint32_t dst_x, dst_y;
+   uint32_t width, height;
+};
+
+static void
+anv_meta_begin_blit2d(struct anv_cmd_buffer *cmd_buffer,
+  struct anv_meta_saved_state *save);
+
+static void
+anv_meta_blit2d(struct anv_cmd_buffer *cmd_buffer,
+struct anv_meta_blit2d_surf *src,
+struct anv_meta_blit2d_surf *dst,
+unsigned num_rects,
+struct anv_meta_blit2d_rect *rects);
+
+static void
+anv_meta_end_blit2d(struct anv_cmd_buffer *cmd_buffer,
+struct anv_meta_saved_state *save);
+
 #ifdef __cplusplus
 }
 #endif

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (vulkan): anv/meta: Delete unused functions

2016-03-03 Thread Nanley Chery
Module: Mesa
Branch: vulkan
Commit: 8dddc3fb1e55a7cc82c0afe2c880c1ef485d21c1
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=8dddc3fb1e55a7cc82c0afe2c880c1ef485d21c1

Author: Nanley Chery 
Date:   Mon Feb 29 14:37:48 2016 -0800

anv/meta: Delete unused functions

Signed-off-by: Nanley Chery 
Reviewed-by: Jason Ekstrand 

---

 src/intel/vulkan/anv_meta_blit.c | 93 
 1 file changed, 93 deletions(-)

diff --git a/src/intel/vulkan/anv_meta_blit.c b/src/intel/vulkan/anv_meta_blit.c
index 3fc4631..b8a42f9 100644
--- a/src/intel/vulkan/anv_meta_blit.c
+++ b/src/intel/vulkan/anv_meta_blit.c
@@ -717,52 +717,6 @@ void anv_CmdUpdateBuffer(
anv_meta_end_blit2d(cmd_buffer, _state);
 }
 
-static VkFormat
-choose_iview_format(struct anv_image *image, VkImageAspectFlagBits aspect)
-{
-   assert(__builtin_popcount(aspect) == 1);
-
-   struct isl_surf *surf =
-  _image_get_surface_for_aspect_mask(image, aspect)->isl;
-
-   /* vkCmdCopyImage behaves like memcpy. Therefore we choose identical UINT
-* formats for the source and destination image views.
-*
-* From the Vulkan spec (2015-12-30):
-*
-*vkCmdCopyImage performs image copies in a similar manner to a host
-*memcpy. It does not perform general-purpose conversions such as
-*scaling, resizing, blending, color-space conversion, or format
-*conversions.  Rather, it simply copies raw image data. vkCmdCopyImage
-*can copy between images with different formats, provided the formats
-*are compatible as defined below.
-*
-*[The spec later defines compatibility as having the same number of
-*bytes per block].
-*/
-   return vk_format_for_size(isl_format_layouts[surf->format].bs);
-}
-
-static VkFormat
-choose_buffer_format(VkFormat format, VkImageAspectFlagBits aspect)
-{
-   assert(__builtin_popcount(aspect) == 1);
-
-   /* vkCmdCopy* commands behave like memcpy. Therefore we choose
-* compatable UINT formats for the source and destination image views.
-*
-* For the buffer, we go back to the original image format and get a
-* the format as if it were linear.  This way, for RGB formats, we get
-* an RGB format here even if the tiled image is RGBA. XXX: This doesn't
-* work if the buffer is the destination.
-*/
-   enum isl_format linear_format = anv_get_isl_format(format, aspect,
-  VK_IMAGE_TILING_LINEAR,
-  NULL);
-
-   return vk_format_for_size(isl_format_layouts[linear_format].bs);
-}
-
 void anv_CmdCopyImage(
 VkCommandBuffer commandBuffer,
 VkImage srcImage,
@@ -1051,53 +1005,6 @@ meta_copy_buffer_to_image(struct anv_cmd_buffer 
*cmd_buffer,
anv_meta_end_blit2d(cmd_buffer, _state);
 }
 
-static struct anv_image *
-make_image_for_buffer(VkDevice vk_device, VkBuffer vk_buffer, VkFormat format,
-  VkImageUsageFlags usage,
-  VkImageType image_type,
-  const VkAllocationCallbacks *alloc,
-  const VkBufferImageCopy *copy)
-{
-   ANV_FROM_HANDLE(anv_buffer, buffer, vk_buffer);
-
-   VkExtent3D extent = copy->imageExtent;
-   if (copy->bufferRowLength)
-  extent.width = copy->bufferRowLength;
-   if (copy->bufferImageHeight)
-  extent.height = copy->bufferImageHeight;
-   extent.depth = 1;
-   extent = meta_region_extent_el(format, );
-
-   VkImageAspectFlags aspect = copy->imageSubresource.aspectMask;
-   VkFormat buffer_format = choose_buffer_format(format, aspect);
-
-   VkImage vk_image;
-   VkResult result = anv_CreateImage(vk_device,
-  &(VkImageCreateInfo) {
- .sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO,
- .imageType = VK_IMAGE_TYPE_2D,
- .format = buffer_format,
- .extent = extent,
- .mipLevels = 1,
- .arrayLayers = 1,
- .samples = 1,
- .tiling = VK_IMAGE_TILING_LINEAR,
- .usage = usage,
- .flags = 0,
-  }, alloc, _image);
-   assert(result == VK_SUCCESS);
-
-   ANV_FROM_HANDLE(anv_image, image, vk_image);
-
-   /* We could use a vk call to bind memory, but that would require
-* creating a dummy memory object etc. so there's really no point.
-*/
-   image->bo = buffer->bo;
-   image->offset = buffer->offset + copy->bufferOffset;
-
-   return image;
-}
-
 void anv_CmdCopyBufferToImage(
 VkCommandBuffer commandBuffer,
 VkBuffersrcBuffer,

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (vulkan): anv/meta: Add function to create anv_meta_blit2d_surf from anv_image

2016-03-03 Thread Nanley Chery
Module: Mesa
Branch: vulkan
Commit: 61ad78d0d1ffafc89cdc9da9d5ae710be36e3089
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=61ad78d0d1ffafc89cdc9da9d5ae710be36e3089

Author: Nanley Chery 
Date:   Tue Mar  1 23:15:35 2016 -0800

anv/meta: Add function to create anv_meta_blit2d_surf from anv_image

v2: Keep pitch in units of bytes (Jason)

Signed-off-by: Nanley Chery 
Reviewed-by: Jason Ekstrand 

---

 src/intel/vulkan/anv_meta_blit.c | 13 +
 1 file changed, 13 insertions(+)

diff --git a/src/intel/vulkan/anv_meta_blit.c b/src/intel/vulkan/anv_meta_blit.c
index bef6675..044998d 100644
--- a/src/intel/vulkan/anv_meta_blit.c
+++ b/src/intel/vulkan/anv_meta_blit.c
@@ -417,6 +417,19 @@ vk_format_for_size(int bs)
}
 }
 
+static struct anv_meta_blit2d_surf
+blit_surf_for_image(const struct anv_image* image,
+const struct isl_surf *img_isl_surf)
+{
+   return (struct anv_meta_blit2d_surf) {
+.bo = image->bo,
+.tiling = img_isl_surf->tiling,
+.base_offset = image->offset,
+.bs = isl_format_get_layout(img_isl_surf->format)->bs,
+.pitch = isl_surf_get_row_pitch(img_isl_surf),
+   };
+}
+
 void
 anv_meta_blit2d(struct anv_cmd_buffer *cmd_buffer,
 struct anv_meta_blit2d_surf *src,

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (vulkan): anv/meta: Remove redundancies in do_buffer_copy()

2016-03-03 Thread Nanley Chery
Module: Mesa
Branch: vulkan
Commit: d1e48b994565c1d6c1cfa546ba7ab09145c12601
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=d1e48b994565c1d6c1cfa546ba7ab09145c12601

Author: Nanley Chery 
Date:   Sat Feb 27 13:29:04 2016 -0800

anv/meta: Remove redundancies in do_buffer_copy()

Signed-off-by: Nanley Chery 
Reviewed-by: Jason Ekstrand 

---

 src/intel/vulkan/anv_meta_blit.c | 46 
 1 file changed, 18 insertions(+), 28 deletions(-)

diff --git a/src/intel/vulkan/anv_meta_blit.c b/src/intel/vulkan/anv_meta_blit.c
index 9d41add..478b199 100644
--- a/src/intel/vulkan/anv_meta_blit.c
+++ b/src/intel/vulkan/anv_meta_blit.c
@@ -446,39 +446,29 @@ do_buffer_copy(struct anv_cmd_buffer *cmd_buffer,
anv_image_from_handle(dest_image)->bo = dest;
anv_image_from_handle(dest_image)->offset = dest_offset;
 
+   VkImageViewCreateInfo iview_info = {
+  .sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO,
+  .image = 0, /* TEMPLATE */
+  .viewType = VK_IMAGE_VIEW_TYPE_2D,
+  .format = copy_format,
+  .subresourceRange = {
+ .aspectMask = VK_IMAGE_ASPECT_COLOR_BIT,
+ .baseMipLevel = 0,
+ .levelCount = 1,
+ .baseArrayLayer = 0,
+ .layerCount = 1
+  },
+   };
+
struct anv_image_view src_iview;
+   iview_info.image = src_image;
anv_image_view_init(_iview, cmd_buffer->device,
-  &(VkImageViewCreateInfo) {
- .sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO,
- .image = src_image,
- .viewType = VK_IMAGE_VIEW_TYPE_2D,
- .format = copy_format,
- .subresourceRange = {
-.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT,
-.baseMipLevel = 0,
-.levelCount = 1,
-.baseArrayLayer = 0,
-.layerCount = 1
- },
-  },
-  cmd_buffer, 0, VK_IMAGE_USAGE_SAMPLED_BIT);
+  _info, cmd_buffer, 0, VK_IMAGE_USAGE_SAMPLED_BIT);
 
struct anv_image_view dest_iview;
+   iview_info.image = dest_image;
anv_image_view_init(_iview, cmd_buffer->device,
-  &(VkImageViewCreateInfo) {
- .sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO,
- .image = dest_image,
- .viewType = VK_IMAGE_VIEW_TYPE_2D,
- .format = copy_format,
- .subresourceRange = {
-.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT,
-.baseMipLevel = 0,
-.levelCount = 1,
-.baseArrayLayer = 0,
-.layerCount = 1,
- },
-  },
-  cmd_buffer, 0, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT);
+  _info, cmd_buffer, 0, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT);
 
meta_emit_blit(cmd_buffer,
   anv_image_from_handle(src_image),

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (vulkan): anv/image: Create a linear image when requested

2016-03-03 Thread Nanley Chery
Module: Mesa
Branch: vulkan
Commit: 1d9d90d9a6323c37e80b7870946597b470d8dec0
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=1d9d90d9a6323c37e80b7870946597b470d8dec0

Author: Nanley Chery 
Date:   Wed Mar  2 09:44:48 2016 -0800

anv/image: Create a linear image when requested

If a linear image is requested, the only possible result should be a
linearly-tiled surface.

Signed-off-by: Nanley Chery 
Reviewed-by: Jason Ekstrand 

---

 src/intel/vulkan/anv_image.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/intel/vulkan/anv_image.c b/src/intel/vulkan/anv_image.c
index 46cf241..dc1ea9c 100644
--- a/src/intel/vulkan/anv_image.c
+++ b/src/intel/vulkan/anv_image.c
@@ -120,7 +120,7 @@ make_surface(const struct anv_device *dev,
 
isl_tiling_flags_t tiling_flags = anv_info->isl_tiling_flags;
if (vk_info->tiling == VK_IMAGE_TILING_LINEAR)
-  tiling_flags &= ISL_TILING_LINEAR_BIT;
+  tiling_flags = ISL_TILING_LINEAR_BIT;
 
struct anv_surface *anv_surf = get_surface(image, aspect);
 

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (vulkan): anv/meta: Implement the blitter API functions

2016-03-03 Thread Nanley Chery
Module: Mesa
Branch: vulkan
Commit: 2e9b08b9b89c0cf10cc7ca73fd39380766943283
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=2e9b08b9b89c0cf10cc7ca73fd39380766943283

Author: Nanley Chery 
Date:   Sat Feb 27 12:26:21 2016 -0800

anv/meta: Implement the blitter API functions

Most of the code in anv_meta_blit2d() is borrowed from do_buffer_copy().

Create an image and image view for each rectangle.
Note: For tiled RGB images, ISL will align the image's row_pitch up to
the nearest tile width.

v2 (Jason):
Keep pitch in units of bytes
Make src_format and dst_format variables
s/dest/dst/ in every usage
v3: Fix dst_image width

Signed-off-by: Nanley Chery 
Reviewed-by: Jason Ekstrand 

---

 src/intel/vulkan/anv_meta.h  |   6 +-
 src/intel/vulkan/anv_meta_blit.c | 142 +++
 2 files changed, 145 insertions(+), 3 deletions(-)

diff --git a/src/intel/vulkan/anv_meta.h b/src/intel/vulkan/anv_meta.h
index 9521764..587c044 100644
--- a/src/intel/vulkan/anv_meta.h
+++ b/src/intel/vulkan/anv_meta.h
@@ -90,18 +90,18 @@ struct anv_meta_blit2d_rect {
uint32_t width, height;
 };
 
-static void
+void
 anv_meta_begin_blit2d(struct anv_cmd_buffer *cmd_buffer,
   struct anv_meta_saved_state *save);
 
-static void
+void
 anv_meta_blit2d(struct anv_cmd_buffer *cmd_buffer,
 struct anv_meta_blit2d_surf *src,
 struct anv_meta_blit2d_surf *dst,
 unsigned num_rects,
 struct anv_meta_blit2d_rect *rects);
 
-static void
+void
 anv_meta_end_blit2d(struct anv_cmd_buffer *cmd_buffer,
 struct anv_meta_saved_state *save);
 
diff --git a/src/intel/vulkan/anv_meta_blit.c b/src/intel/vulkan/anv_meta_blit.c
index 478b199..bef6675 100644
--- a/src/intel/vulkan/anv_meta_blit.c
+++ b/src/intel/vulkan/anv_meta_blit.c
@@ -119,6 +119,14 @@ meta_prepare_blit(struct anv_cmd_buffer *cmd_buffer,
  (1 << VK_DYNAMIC_STATE_VIEWPORT));
 }
 
+void
+anv_meta_begin_blit2d(struct anv_cmd_buffer *cmd_buffer,
+  struct anv_meta_saved_state *save)
+{
+   meta_prepare_blit(cmd_buffer, save);
+}
+
+
 /* Returns the user-provided VkBufferImageCopy::imageOffset in units of
  * elements rather than texels. One element equals one texel or one block
  * if Image is uncompressed or compressed, respectively.
@@ -372,6 +380,13 @@ meta_finish_blit(struct anv_cmd_buffer *cmd_buffer,
anv_meta_restore(saved_state, cmd_buffer);
 }
 
+void
+anv_meta_end_blit2d(struct anv_cmd_buffer *cmd_buffer,
+struct anv_meta_saved_state *save)
+{
+   meta_finish_blit(cmd_buffer, save);
+}
+
 static VkFormat
 vk_format_for_size(int bs)
 {
@@ -402,6 +417,133 @@ vk_format_for_size(int bs)
}
 }
 
+void
+anv_meta_blit2d(struct anv_cmd_buffer *cmd_buffer,
+struct anv_meta_blit2d_surf *src,
+struct anv_meta_blit2d_surf *dst,
+unsigned num_rects,
+struct anv_meta_blit2d_rect *rects)
+{
+   VkDevice vk_device = anv_device_to_handle(cmd_buffer->device);
+   VkFormat src_format = vk_format_for_size(src->bs);
+   VkFormat dst_format = vk_format_for_size(dst->bs);
+
+   for (unsigned r = 0; r < num_rects; ++r) {
+
+  /* Create VkImages */
+  VkImageCreateInfo image_info = {
+ .sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO,
+ .imageType = VK_IMAGE_TYPE_2D,
+ .format = 0, /* TEMPLATE */
+ .extent = {
+.width = 0, /* TEMPLATE */
+/* Pad to highest tile height to compensate for a vertical 
intratile offset */
+.height = MIN(rects[r].height + 64, 1 << 14),
+.depth = 1,
+ },
+ .mipLevels = 1,
+ .arrayLayers = 1,
+ .samples = 1,
+ .tiling = 0, /* TEMPLATE */
+ .usage = 0, /* TEMPLATE */
+  };
+  struct anv_image_create_info anv_image_info = {
+ .vk_info = _info,
+ .isl_tiling_flags = 0, /* TEMPLATE */
+  };
+
+  anv_image_info.isl_tiling_flags = 1 << src->tiling;
+  image_info.tiling = anv_image_info.isl_tiling_flags == 
ISL_TILING_LINEAR_BIT ?
+VK_IMAGE_TILING_LINEAR : VK_IMAGE_TILING_OPTIMAL;
+  image_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT;
+  image_info.format = src_format,
+  image_info.extent.width = src->pitch / src->bs;
+  VkImage src_image;
+  anv_image_create(vk_device, _image_info,
+ _buffer->pool->alloc, _image);
+
+  anv_image_info.isl_tiling_flags = 1 << dst->tiling;
+  image_info.tiling = anv_image_info.isl_tiling_flags == 
ISL_TILING_LINEAR_BIT ?
+VK_IMAGE_TILING_LINEAR : VK_IMAGE_TILING_OPTIMAL;
+  image_info.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
+  image_info.format = dst_format,
+  image_info.extent.width = dst->pitch / dst->bs;
+  VkImage 

Mesa (vulkan): anv/meta: Use blitter API in do_buffer_copy()

2016-03-03 Thread Nanley Chery
Module: Mesa
Branch: vulkan
Commit: 318b67d1578213b802443f06f767a1c9d6d00310
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=318b67d1578213b802443f06f767a1c9d6d00310

Author: Nanley Chery 
Date:   Sat Feb 27 17:11:55 2016 -0800

anv/meta: Use blitter API in do_buffer_copy()

v2: Keep pitch in units of bytes (Jason)

Signed-off-by: Nanley Chery 
Reviewed-by: Jason Ekstrand 

---

 src/intel/vulkan/anv_meta_blit.c | 94 +---
 1 file changed, 21 insertions(+), 73 deletions(-)

diff --git a/src/intel/vulkan/anv_meta_blit.c b/src/intel/vulkan/anv_meta_blit.c
index 2e529ee..bd1c979 100644
--- a/src/intel/vulkan/anv_meta_blit.c
+++ b/src/intel/vulkan/anv_meta_blit.c
@@ -563,81 +563,29 @@ do_buffer_copy(struct anv_cmd_buffer *cmd_buffer,
struct anv_bo *dest, uint64_t dest_offset,
int width, int height, int bs)
 {
-   VkDevice vk_device = anv_device_to_handle(cmd_buffer->device);
-   VkFormat copy_format = vk_format_for_size(bs);
-
-   VkImageCreateInfo image_info = {
-  .sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO,
-  .imageType = VK_IMAGE_TYPE_2D,
-  .format = copy_format,
-  .extent = {
- .width = width,
- .height = height,
- .depth = 1,
-  },
-  .mipLevels = 1,
-  .arrayLayers = 1,
-  .samples = 1,
-  .tiling = VK_IMAGE_TILING_LINEAR,
-  .usage = 0,
-  .flags = 0,
+   struct anv_meta_blit2d_surf b_src = {
+.bo = src,
+.tiling = ISL_TILING_LINEAR,
+.base_offset = src_offset,
+.bs = bs,
+.pitch = width * bs,
};
-
-   VkImage src_image;
-   image_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT;
-   anv_CreateImage(vk_device, _info,
-   _buffer->pool->alloc, _image);
-
-   VkImage dest_image;
-   image_info.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
-   anv_CreateImage(vk_device, _info,
-   _buffer->pool->alloc, _image);
-
-   /* We could use a vk call to bind memory, but that would require
-* creating a dummy memory object etc. so there's really no point.
-*/
-   anv_image_from_handle(src_image)->bo = src;
-   anv_image_from_handle(src_image)->offset = src_offset;
-   anv_image_from_handle(dest_image)->bo = dest;
-   anv_image_from_handle(dest_image)->offset = dest_offset;
-
-   VkImageViewCreateInfo iview_info = {
-  .sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO,
-  .image = 0, /* TEMPLATE */
-  .viewType = VK_IMAGE_VIEW_TYPE_2D,
-  .format = copy_format,
-  .subresourceRange = {
- .aspectMask = VK_IMAGE_ASPECT_COLOR_BIT,
- .baseMipLevel = 0,
- .levelCount = 1,
- .baseArrayLayer = 0,
- .layerCount = 1
-  },
+   struct anv_meta_blit2d_surf b_dst = {
+.bo = dest,
+.tiling = ISL_TILING_LINEAR,
+.base_offset = dest_offset,
+.bs = bs,
+.pitch = width * bs,
};
-
-   struct anv_image_view src_iview;
-   iview_info.image = src_image;
-   anv_image_view_init(_iview, cmd_buffer->device,
-  _info, cmd_buffer, 0, VK_IMAGE_USAGE_SAMPLED_BIT);
-
-   struct anv_image_view dest_iview;
-   iview_info.image = dest_image;
-   anv_image_view_init(_iview, cmd_buffer->device,
-  _info, cmd_buffer, 0, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT);
-
-   meta_emit_blit(cmd_buffer,
-  anv_image_from_handle(src_image),
-  _iview,
-  (VkOffset3D) { 0, 0, 0 },
-  (VkExtent3D) { width, height, 1 },
-  anv_image_from_handle(dest_image),
-  _iview,
-  (VkOffset3D) { 0, 0, 0 },
-  (VkExtent3D) { width, height, 1 },
-  VK_FILTER_NEAREST);
-
-   anv_DestroyImage(vk_device, src_image, _buffer->pool->alloc);
-   anv_DestroyImage(vk_device, dest_image, _buffer->pool->alloc);
+   struct anv_meta_blit2d_rect rect = {
+  .width = width,
+  .height = height,
+   };
+   anv_meta_blit2d(cmd_buffer,
+  _src,
+  _dst,
+  1,
+  );
 }
 
 void anv_CmdCopyBuffer(

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (vulkan): anv/meta: Modify blitter API fields

2016-03-03 Thread Nanley Chery
Module: Mesa
Branch: vulkan
Commit: 032bf172b48211af8fc892747dc4600fb6595f99
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=032bf172b48211af8fc892747dc4600fb6595f99

Author: Nanley Chery 
Date:   Thu Feb 25 15:21:12 2016 -0800

anv/meta: Modify blitter API fields

Some fields are unnecessary. The variables "pitch" and "bs" are used
for consistency with ISL.

v2: Keep pitch in units of bytes (Jason)

Signed-off-by: Nanley Chery 
Reviewed-by: Jason Ekstrand 

---

 src/intel/vulkan/anv_meta.h | 23 +--
 1 file changed, 5 insertions(+), 18 deletions(-)

diff --git a/src/intel/vulkan/anv_meta.h b/src/intel/vulkan/anv_meta.h
index f5dac12..9521764 100644
--- a/src/intel/vulkan/anv_meta.h
+++ b/src/intel/vulkan/anv_meta.h
@@ -77,24 +77,11 @@ struct anv_meta_blit2d_surf {
/** Base offset to the start of the image */
uint64_t base_offset;
 
-   uint32_t offset_x;
-   uint32_t offset_y;
-
-   /** The size of a unit in bytes. (Usually texel size) */
-   uint8_t units;
-
-   /** Stride between rows in bytes. */
-   uint32_t stride;
-
-   /** Possible vertical stride in rows.
-*
-* This is a hint to the blit engine that tells it that it can, if it
-* wants, split the surface into v_stride tall chunks.  The user makes
-* the guarantee that no rectangles it passes in will every cross a
-* v_stride boundary.  A v_stride value of 0 indicates that the user
-* cannot make such a guarantee.
-*/
-   uint32_t v_stride;
+   /** The size of an element in bytes. */
+   uint8_t bs;
+
+   /** Pitch between rows in bytes. */
+   uint32_t pitch;
 };
 
 struct anv_meta_blit2d_rect {

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (vulkan): anv/meta: Use blitter API for copies between Images and Buffers

2016-03-03 Thread Nanley Chery
Module: Mesa
Branch: vulkan
Commit: 9b6c95d46ee19224e8013a0fbc991f8b2135017d
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=9b6c95d46ee19224e8013a0fbc991f8b2135017d

Author: Nanley Chery 
Date:   Sat Feb 27 17:11:55 2016 -0800

anv/meta: Use blitter API for copies between Images and Buffers

Signed-off-by: Nanley Chery 
Reviewed-by: Jason Ekstrand 

---

 src/intel/vulkan/anv_meta_blit.c | 214 ++-
 1 file changed, 6 insertions(+), 208 deletions(-)

diff --git a/src/intel/vulkan/anv_meta_blit.c b/src/intel/vulkan/anv_meta_blit.c
index 8cda3d5..8ca1871 100644
--- a/src/intel/vulkan/anv_meta_blit.c
+++ b/src/intel/vulkan/anv_meta_blit.c
@@ -1189,121 +1189,10 @@ void anv_CmdCopyBufferToImage(
 {
ANV_FROM_HANDLE(anv_cmd_buffer, cmd_buffer, commandBuffer);
ANV_FROM_HANDLE(anv_image, dest_image, destImage);
-   VkDevice vk_device = anv_device_to_handle(cmd_buffer->device);
-   struct anv_meta_saved_state saved_state;
-
-   /* The Vulkan 1.0 spec says "dstImage must have a sample count equal to
-* VK_SAMPLE_COUNT_1_BIT."
-*/
-   assert(dest_image->samples == 1);
-
-   meta_prepare_blit(cmd_buffer, _state);
-
-   for (unsigned r = 0; r < regionCount; r++) {
-  VkImageAspectFlags aspect = pRegions[r].imageSubresource.aspectMask;
-
-  VkFormat image_format = choose_iview_format(dest_image, aspect);
-
-  struct anv_image *src_image =
- make_image_for_buffer(vk_device, srcBuffer, dest_image->vk_format,
-   VK_IMAGE_USAGE_SAMPLED_BIT,
-   dest_image->type, _buffer->pool->alloc,
-   [r]);
-
-  const uint32_t dest_base_array_slice =
- anv_meta_get_iview_layer(dest_image, [r].imageSubresource,
-  [r].imageOffset);
-
-  unsigned num_slices_3d = pRegions[r].imageExtent.depth;
-  unsigned num_slices_array = pRegions[r].imageSubresource.layerCount;
-  unsigned slice_3d = 0;
-  unsigned slice_array = 0;
-  while (slice_3d < num_slices_3d && slice_array < num_slices_array) {
- struct anv_image_view src_iview;
- anv_image_view_init(_iview, cmd_buffer->device,
-&(VkImageViewCreateInfo) {
-   .sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO,
-   .image = anv_image_to_handle(src_image),
-   .viewType = VK_IMAGE_VIEW_TYPE_2D,
-   .format = src_image->vk_format,
-   .subresourceRange = {
-  .aspectMask = VK_IMAGE_ASPECT_COLOR_BIT,
-  .baseMipLevel = 0,
-  .levelCount = 1,
-  .baseArrayLayer = 0,
-  .layerCount = 1,
-   },
-},
-cmd_buffer, 0, VK_IMAGE_USAGE_SAMPLED_BIT);
-
- uint32_t img_x = 0;
- uint32_t img_y = 0;
- uint32_t img_o = 0;
- if (isl_format_is_compressed(dest_image->format->isl_format))
-
isl_surf_get_image_intratile_offset_el(_buffer->device->isl_dev,
-   
_image->color_surface.isl,
-   
pRegions[r].imageSubresource.mipLevel,
-   
pRegions[r].imageSubresource.baseArrayLayer + slice_array,
-   pRegions[r].imageOffset.z + 
slice_3d,
-   _o, _x, _y);
-
- VkOffset3D dest_offset_el = meta_region_offset_el(dest_image, & 
pRegions[r].imageOffset);
- dest_offset_el.x += img_x;
- dest_offset_el.y += img_y;
- dest_offset_el.z = 0;
-
- struct anv_image_view dest_iview;
- anv_image_view_init(_iview, cmd_buffer->device,
-&(VkImageViewCreateInfo) {
-   .sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO,
-   .image = anv_image_to_handle(dest_image),
-   .viewType = anv_meta_get_view_type(dest_image),
-   .format = image_format,
-   .subresourceRange = {
-  .aspectMask = VK_IMAGE_ASPECT_COLOR_BIT,
-  .baseMipLevel = pRegions[r].imageSubresource.mipLevel,
-  .levelCount = 1,
-  .baseArrayLayer = dest_base_array_slice +
-slice_array + slice_3d,
-  .layerCount = 1
-   },
-},
-cmd_buffer, img_o, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT);
-
- const VkExtent3D img_extent_el = 
meta_region_extent_el(dest_image->vk_format,
-  
[r].imageExtent);
-
- meta_emit_blit(cmd_buffer,
-src_image,
-_iview,
-(VkOffset3D){0, 0, 0},
-img_extent_el,
-

Mesa (vulkan): anv/meta: Add function which copies between Buffers and Images

2016-03-03 Thread Nanley Chery
Module: Mesa
Branch: vulkan
Commit: 91640c34c6b474903fa5634f86f87c774d16db88
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=91640c34c6b474903fa5634f86f87c774d16db88

Author: Nanley Chery 
Date:   Mon Feb 29 14:28:25 2016 -0800

anv/meta: Add function which copies between Buffers and Images

v2: Keep pitch in units of bytes (Jason)

Signed-off-by: Nanley Chery 
Reviewed-by: Jason Ekstrand 

---

 src/intel/vulkan/anv_meta_blit.c | 92 
 1 file changed, 92 insertions(+)

diff --git a/src/intel/vulkan/anv_meta_blit.c b/src/intel/vulkan/anv_meta_blit.c
index 044998d..8cda3d5 100644
--- a/src/intel/vulkan/anv_meta_blit.c
+++ b/src/intel/vulkan/anv_meta_blit.c
@@ -1040,6 +1040,98 @@ void anv_CmdBlitImage(
meta_finish_blit(cmd_buffer, _state);
 }
 
+static void
+meta_copy_buffer_to_image(struct anv_cmd_buffer *cmd_buffer,
+  struct anv_buffer* buffer,
+  struct anv_image* image,
+  uint32_t regionCount,
+  const VkBufferImageCopy* pRegions,
+  bool forward)
+{
+   struct anv_meta_saved_state saved_state;
+
+   /* The Vulkan 1.0 spec says "dstImage must have a sample count equal to
+* VK_SAMPLE_COUNT_1_BIT."
+*/
+   assert(image->samples == 1);
+
+   anv_meta_begin_blit2d(cmd_buffer, _state);
+
+   for (unsigned r = 0; r < regionCount; r++) {
+
+  /* Start creating blit rect */
+  const VkOffset3D img_offset_el = meta_region_offset_el(image, 
[r].imageOffset);
+  const VkExtent3D bufferExtent = {
+ .width = pRegions[r].bufferRowLength,
+ .height = pRegions[r].bufferImageHeight,
+  };
+  const VkExtent3D buf_extent_el = meta_region_extent_el(image->vk_format, 
);
+  const VkExtent3D img_extent_el = meta_region_extent_el(image->vk_format,
+   
[r].imageExtent);
+  struct anv_meta_blit2d_rect rect = {
+ .width = MAX2(buf_extent_el.width, img_extent_el.width),
+ .height = MAX2(buf_extent_el.height, img_extent_el.height),
+  };
+
+  /* Create blit surfaces */
+  VkImageAspectFlags aspect = pRegions[r].imageSubresource.aspectMask;
+  const struct isl_surf *img_isl_surf =
+ _image_get_surface_for_aspect_mask(image, aspect)->isl;
+  struct anv_meta_blit2d_surf img_bsurf = blit_surf_for_image(image, 
img_isl_surf);
+  struct anv_meta_blit2d_surf buf_bsurf = {
+ .bo = buffer->bo,
+ .tiling = ISL_TILING_LINEAR,
+ .base_offset = buffer->offset + pRegions[r].bufferOffset,
+ .bs = forward ? image->format->isl_layout->bs : img_bsurf.bs,
+ .pitch = rect.width * buf_bsurf.bs,
+  };
+
+  /* Set direction-dependent variables */
+  struct anv_meta_blit2d_surf *dst_bsurf = forward ? _bsurf : 
_bsurf;
+  struct anv_meta_blit2d_surf *src_bsurf = forward ? _bsurf : 
_bsurf;
+  uint32_t *x_offset = forward ? _x : _x;
+  uint32_t *y_offset = forward ? _y : _y;
+
+  /* Loop through each 3D or array slice */
+  unsigned num_slices_3d = pRegions[r].imageExtent.depth;
+  unsigned num_slices_array = pRegions[r].imageSubresource.layerCount;
+  unsigned slice_3d = 0;
+  unsigned slice_array = 0;
+  while (slice_3d < num_slices_3d && slice_array < num_slices_array) {
+
+ /* Finish creating blit rect */
+ isl_surf_get_image_offset_el(img_isl_surf,
+pRegions[r].imageSubresource.mipLevel,
+
pRegions[r].imageSubresource.baseArrayLayer + slice_array,
+pRegions[r].imageOffset.z + slice_3d,
+x_offset,
+y_offset);
+ *x_offset += img_offset_el.x;
+ *y_offset += img_offset_el.y;
+
+ /* Perform Blit */
+ anv_meta_blit2d(cmd_buffer,
+src_bsurf,
+dst_bsurf,
+1,
+);
+
+ /* Once we've done the blit, all of the actual information about
+  * the image is embedded in the command buffer so we can just
+  * increment the offset directly in the image effectively
+  * re-binding it to different backing memory.
+  */
+ buf_bsurf.base_offset += rect.width * rect.height * buf_bsurf.bs;
+
+ if (image->type == VK_IMAGE_TYPE_3D)
+slice_3d++;
+ else
+slice_array++;
+  }
+   }
+   anv_meta_end_blit2d(cmd_buffer, _state);
+}
+
 static struct anv_image *
 make_image_for_buffer(VkDevice vk_device, VkBuffer vk_buffer, VkFormat format,
   VkImageUsageFlags usage,

___
mesa-commit mailing list

Mesa (vulkan): anv/meta: Add missing command to exit meta in anv_CmdUpdateBuffer()

2016-03-03 Thread Nanley Chery
Module: Mesa
Branch: vulkan
Commit: d50ff250ec25e4903ef9e82c47981aaed962e464
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=d50ff250ec25e4903ef9e82c47981aaed962e464

Author: Nanley Chery 
Date:   Wed Mar  2 14:27:17 2016 -0800

anv/meta: Add missing command to exit meta in anv_CmdUpdateBuffer()

Signed-off-by: Nanley Chery 
Reviewed-by: Jason Ekstrand 

---

 src/intel/vulkan/anv_meta_blit.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/intel/vulkan/anv_meta_blit.c b/src/intel/vulkan/anv_meta_blit.c
index 96a3b76..216a0bf 100644
--- a/src/intel/vulkan/anv_meta_blit.c
+++ b/src/intel/vulkan/anv_meta_blit.c
@@ -625,6 +625,8 @@ void anv_CmdUpdateBuffer(
   dstOffset += copy_size;
   pData = (void *)pData + copy_size;
}
+
+   meta_finish_blit(cmd_buffer, _state);
 }
 
 static VkFormat

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (vulkan): isl: Add function to get intratile offsets from x/y offsets

2016-03-03 Thread Nanley Chery
Module: Mesa
Branch: vulkan
Commit: 456f5b0314747c5e47435a6d9d708ef7895c7a49
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=456f5b0314747c5e47435a6d9d708ef7895c7a49

Author: Nanley Chery 
Date:   Fri Feb 26 14:49:51 2016 -0800

isl: Add function to get intratile offsets from x/y offsets

Signed-off-by: Nanley Chery 
Reviewed-by: Jason Ekstrand 

---

 src/intel/isl/isl.c | 43 +++
 src/intel/isl/isl.h | 12 
 2 files changed, 43 insertions(+), 12 deletions(-)

diff --git a/src/intel/isl/isl.c b/src/intel/isl/isl.c
index f7b4c70..7fd9eea 100644
--- a/src/intel/isl/isl.c
+++ b/src/intel/isl/isl.c
@@ -1414,11 +1414,10 @@ isl_surf_get_image_offset_el(const struct isl_surf 
*surf,
 }
 
 void
-isl_surf_get_image_intratile_offset_el(const struct isl_device *dev,
+isl_surf_get_image_intratile_offset_el_xy(const struct isl_device *dev,
const struct isl_surf *surf,
-   uint32_t level,
-   uint32_t logical_array_layer,
-   uint32_t logical_z_offset,
+   uint32_t total_x_offset_el,
+   uint32_t total_y_offset_el,
uint32_t *base_address_offset,
uint32_t *x_offset_el,
uint32_t *y_offset_el)
@@ -1428,14 +1427,6 @@ isl_surf_get_image_intratile_offset_el(const struct 
isl_device *dev,
struct isl_tile_info tile_info;
isl_surf_get_tile_info(dev, surf, _info);
 
-   uint32_t total_x_offset_el;
-   uint32_t total_y_offset_el;
-   isl_surf_get_image_offset_el(surf, level,
-logical_array_layer,
-logical_z_offset,
-_x_offset_el,
-_y_offset_el);
-
uint32_t small_y_offset_el = total_y_offset_el % tile_info.height;
uint32_t big_y_offset_el = total_y_offset_el - small_y_offset_el;
uint32_t big_y_offset_B = big_y_offset_el * surf->row_pitch;
@@ -1448,6 +1439,34 @@ isl_surf_get_image_intratile_offset_el(const struct 
isl_device *dev,
*base_address_offset = big_y_offset_B + big_x_offset_B;
*x_offset_el = small_x_offset_el;
*y_offset_el = small_y_offset_el;
+
+
+}
+
+void
+isl_surf_get_image_intratile_offset_el(const struct isl_device *dev,
+   const struct isl_surf *surf,
+   uint32_t level,
+   uint32_t logical_array_layer,
+   uint32_t logical_z_offset,
+   uint32_t *base_address_offset,
+   uint32_t *x_offset_el,
+   uint32_t *y_offset_el)
+{
+   uint32_t total_x_offset_el;
+   uint32_t total_y_offset_el;
+   isl_surf_get_image_offset_el(surf, level,
+logical_array_layer,
+logical_z_offset,
+_x_offset_el,
+_y_offset_el);
+
+   isl_surf_get_image_intratile_offset_el_xy(dev, surf,
+total_x_offset_el,
+total_y_offset_el,
+base_address_offset,
+x_offset_el,
+y_offset_el);
 }
 
 uint32_t
diff --git a/src/intel/isl/isl.h b/src/intel/isl/isl.h
index 7456975..5a48bce 100644
--- a/src/intel/isl/isl.h
+++ b/src/intel/isl/isl.h
@@ -1162,6 +1162,18 @@ isl_surf_get_image_intratile_offset_el(const struct 
isl_device *dev,
uint32_t *y_offset_el);
 
 /**
+ * See above.
+ */
+void
+isl_surf_get_image_intratile_offset_el_xy(const struct isl_device *dev,
+   const struct isl_surf *surf,
+   uint32_t total_x_offset_el,
+   uint32_t total_y_offset_el,
+   uint32_t *base_address_offset,
+   uint32_t *x_offset_el,
+   uint32_t *y_offset_el);
+
+/**
  * @brief Get value of 3DSTATE_DEPTH_BUFFER.SurfaceFormat
  *
  * @pre surf->usage has ISL_SURF_USAGE_DEPTH_BIT

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (vulkan): isl: Don' t filter tiling flags if a specific tiling bit is set

2016-03-03 Thread Nanley Chery
Module: Mesa
Branch: vulkan
Commit: 091f1da902c71ac8d3d27b325a118e2f683f1ae5
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=091f1da902c71ac8d3d27b325a118e2f683f1ae5

Author: Nanley Chery 
Date:   Tue Mar  1 17:32:14 2016 -0800

isl: Don't filter tiling flags if a specific tiling bit is set

If a specific bit is set, the intention to create a surface with a
specific tiling format should be respected.

Signed-off-by: Nanley Chery 
Reviewed-by: Jason Ekstrand 

---

 src/intel/isl/isl.c | 13 -
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/src/intel/isl/isl.c b/src/intel/isl/isl.c
index 7fd9eea..a366380 100644
--- a/src/intel/isl/isl.c
+++ b/src/intel/isl/isl.c
@@ -184,11 +184,14 @@ isl_surf_choose_tiling(const struct isl_device *dev,
 {
isl_tiling_flags_t tiling_flags = info->tiling_flags;
 
-   if (ISL_DEV_GEN(dev) >= 7) {
-  gen7_filter_tiling(dev, info, _flags);
-   } else {
-  isl_finishme("%s: gen%u", __func__, ISL_DEV_GEN(dev));
-  gen7_filter_tiling(dev, info, _flags);
+   /* Filter if multiple tiling options are given */
+   if (!isl_is_pow2(tiling_flags)) {
+  if (ISL_DEV_GEN(dev) >= 7) {
+ gen7_filter_tiling(dev, info, _flags);
+  } else {
+ isl_finishme("%s: gen%u", __func__, ISL_DEV_GEN(dev));
+ gen7_filter_tiling(dev, info, _flags);
+  }
}
 
#define CHOOSE(__tiling) \

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (vulkan): anv/util: Fix vector resizing

2016-03-03 Thread Jason Ekstrand
Module: Mesa
Branch: vulkan
Commit: 206414f92edb4a2149b504f9c296f687a9572ffe
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=206414f92edb4a2149b504f9c296f687a9572ffe

Author: Jason Ekstrand 
Date:   Thu Mar  3 08:17:36 2016 -0800

anv/util: Fix vector resizing

It wasn't properly handling the fact that wrap-around in the source may not
translate to wrap-around in the destination.  This really needs unit tests.

---

 src/intel/vulkan/anv_util.c | 31 +++
 1 file changed, 19 insertions(+), 12 deletions(-)

diff --git a/src/intel/vulkan/anv_util.c b/src/intel/vulkan/anv_util.c
index 22fd01c..62f4705 100644
--- a/src/intel/vulkan/anv_util.c
+++ b/src/intel/vulkan/anv_util.c
@@ -144,7 +144,7 @@ anv_vector_init(struct anv_vector *vector, uint32_t 
element_size, uint32_t size)
 void *
 anv_vector_add(struct anv_vector *vector)
 {
-   uint32_t offset, size, split, tail;
+   uint32_t offset, size, split, src_tail, dst_tail;
void *data;
 
if (vector->head - vector->tail == vector->size) {
@@ -152,18 +152,25 @@ anv_vector_add(struct anv_vector *vector)
   data = malloc(size);
   if (data == NULL)
  return NULL;
-  split = align_u32(vector->tail, vector->size);
-  tail = vector->tail & (vector->size - 1);
-  if (vector->head - split < vector->size) {
- memcpy(data + tail,
-vector->data + tail,
-split - vector->tail);
- memcpy(data + vector->size,
-vector->data, vector->head - split);
+  src_tail = vector->tail & (vector->size - 1);
+  dst_tail = vector->tail & (size - 1);
+  if (src_tail == 0) {
+ /* Since we know that the vector is full, this means that it's
+  * linear from start to end so we can do one copy.
+  */
+ memcpy(data + dst_tail, vector->data, vector->size);
   } else {
- memcpy(data + tail,
-vector->data + tail,
-vector->head - vector->tail);
+ /* In this case, the vector is split into two pieces and we have
+  * to do two copies.  We have to be careful to make sure each
+  * piece goes to the right locations.  Thanks to the change in
+  * size, it may or may not still wrap around.
+  */
+ split = align_u32(vector->tail, vector->size);
+ assert(vector->tail <= split && split < vector->head);
+ memcpy(data + dst_tail, vector->data + src_tail,
+split - vector->tail);
+ memcpy(data + (split & (size - 1)), vector->data,
+vector->head - split);
   }
   free(vector->data);
   vector->data = data;

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (master): 65 new commits

2016-03-03 Thread Eduardo Lima Mitev
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=4f028bfcc048d7cbd7a7239e9f61b4d7b708aebb
Author: Antia Puentes 
Date:   Wed Oct 21 15:25:30 2015 +0200

i965: Enable the ARB_internalformat_query2 extension

Reviewed-by: Dave Airlie 

URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=cbbdf8612d784faa0928208fd6599c6add2d0e48
Author: Eduardo Lima Mitev 
Date:   Tue Dec 22 17:16:50 2015 +0100

i965/formatquery: Add support for INTERNALFORMAT_PREFERRED query

This pname is tricky. The spec states that an internal format should be
returned, that is compatible with the passed internal format, and has
at least the same precision. There is no clear API to resolve this.

The closest we have (and what other drivers (i.e, NVidia proprietary) do,
is to return the same internal format given as parameter. But we validate
first that the passed internal format is supported by i965.

To check for support, we have the TextureFormatSupported map'. But
this map expects a 'mesa_format', which takes a format+typen. So, we must
first "come up" with a generic type that is suited for this internal format,
then get a mesa_format, and then do the validation.

The cleanest solution here is to add a method that does exactly what
the spec wants: a driver's preferred internal format from a given
internal format. But at this point we lack a clear view of what
defines this preference, and also there seems to be no API for it.

Reviewed-by: Dave Airlie 

URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=e064f43485b63053f5786f680407f15bc203763f
Author: Eduardo Lima Mitev 
Date:   Wed Feb 3 10:57:10 2016 +0100

mesa/glformats: Consider DEPTH/STENCIL when resolving a mesa_format

_mesa_format_from_format_and_type() is currently not considering DEPTH and
STENCIL formats, which are not array formats and are not handled anywhere.

This patch adds cases for common combinations of DEPTH/STENCIL format and
types.

Reviewed-by: Dave Airlie 

URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=ec299602a6a1db209e8e93c0853ccad1eb4ffa72
Author: Eduardo Lima Mitev 
Date:   Tue Dec 22 19:33:57 2015 +0100

mesa/formatquery: Add (GET_)TEXTURE_IMAGE_TYPE pnames

These basically reuse the default implementation of GL_READ_PIXELS_TYPE.

Reviewed-by: Dave Airlie 

URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=23f94146c987c380bcdebb0d787dc71e808afc27
Author: Eduardo Lima Mitev 
Date:   Tue Dec 22 19:19:32 2015 +0100

mesa/formatquery: Add (GET_)TEXTURE_IMAGE_FORMAT pnames

Reviewed-by: Dave Airlie 

URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=020671f2a3d47ff35e9937b4db3fa09df6f6d488
Author: Eduardo Lima Mitev 
Date:   Tue Dec 22 18:52:38 2015 +0100

mesa/formatquery: Add READ_PIXELS_TYPE pname

We call the driver to provide its preferred type, but also provide a
default implementation that selects a generic type based on the passed
internal format.

Reviewed-by: Dave Airlie 

URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=bec286f7246bedba9f7f34185f2e1e29befec3ab
Author: Eduardo Lima Mitev 
Date:   Tue Dec 22 18:38:06 2015 +0100

mesa/formatquery: Add READ_PIXELS_FORMAT pname

Reviewed-by: Dave Airlie 

URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=09550c16a51e89dbf64b0864d3fb4ddb6accac52
Author: Eduardo Lima Mitev 
Date:   Tue Dec 22 18:20:57 2015 +0100

mesa/formatquery: Add support for READ_PIXELS query

This is supported since very early version of OpenGL, but we still call the
driver to give it the opportunity to report caveat or no support.

Reviewed-by: Dave Airlie 

URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=8d7696f6380c38085029fff0eb00c3c18ea8e017
Author: Alejandro Piñeiro 
Date:   Tue Dec 22 20:06:19 2015 +0100

mesa/formatquery: added FILTER pname support

It discards out the targets and internalformats that explicitly
mention (per-spec) that doesn't support filter types other than
NEAREST or NEAREST_MIPMAP_NEAREST. Those are:

  * Texture buffers target
  * Multisample targets
  * Any integer internalformat

For the case of multisample targets, it was used the existing method
_mesa_target_allows_setting_sampler_parameter. This would scalate
better in the future if new targets appear that doesn't allow to
set sampler parameters.

We consider RENDERBUFFER to support LINEAR filters, because although
it doesn't support this filter for sampling, you 

Mesa (master): glsl/opt_array_splitting: Fix indentation

2016-03-03 Thread Iago Toral Quiroga
Module: Mesa
Branch: master
Commit: 283c8372cb74c3728c7837a85480251313cf002b
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=283c8372cb74c3728c7837a85480251313cf002b

Author: Iago Toral Quiroga 
Date:   Thu Mar  3 09:12:16 2016 +0100

glsl/opt_array_splitting: Fix indentation

Reviewed-by: Timothy Arceri 

---

 src/compiler/glsl/opt_array_splitting.cpp | 54 +++
 1 file changed, 26 insertions(+), 28 deletions(-)

diff --git a/src/compiler/glsl/opt_array_splitting.cpp 
b/src/compiler/glsl/opt_array_splitting.cpp
index 2f6afb0..a294da5 100644
--- a/src/compiler/glsl/opt_array_splitting.cpp
+++ b/src/compiler/glsl/opt_array_splitting.cpp
@@ -55,9 +55,9 @@ public:
   this->components = NULL;
   this->mem_ctx = NULL;
   if (var->type->is_array())
-this->size = var->type->length;
+ this->size = var->type->length;
   else
-this->size = var->type->matrix_columns;
+ this->size = var->type->matrix_columns;
}
 
ir_variable *var; /* The key: the variable's pointer. */
@@ -137,7 +137,7 @@ ir_array_reference_visitor::get_variable_entry(ir_variable 
*var)
 
foreach_in_list(variable_entry, entry, >variable_list) {
   if (entry->var == var)
-return entry;
+ return entry;
}
 
variable_entry *entry = new(mem_ctx) variable_entry(var);
@@ -218,7 +218,7 @@ 
ir_array_reference_visitor::visit_enter(ir_function_signature *ir)
 
 bool
 ir_array_reference_visitor::get_split_list(exec_list *instructions,
-  bool linked)
+   bool linked)
 {
visit_list_elements(this, instructions);
 
@@ -227,25 +227,25 @@ ir_array_reference_visitor::get_split_list(exec_list 
*instructions,
 */
if (!linked) {
   foreach_in_list(ir_instruction, node, instructions) {
-ir_variable *var = node->as_variable();
-if (var) {
-   variable_entry *entry = get_variable_entry(var);
-   if (entry)
-  entry->remove();
-}
+ ir_variable *var = node->as_variable();
+ if (var) {
+variable_entry *entry = get_variable_entry(var);
+if (entry)
+   entry->remove();
+ }
   }
}
 
/* Trim out variables we found that we can't split. */
foreach_in_list_safe(variable_entry, entry, _list) {
   if (debug) {
-printf("array %s@%p: decl %d, split %d\n",
-   entry->var->name, (void *) entry->var, entry->declaration,
-   entry->split);
+ printf("array %s@%p: decl %d, split %d\n",
+entry->var->name, (void *) entry->var, entry->declaration,
+entry->split);
   }
 
   if (!(entry->declaration && entry->split)) {
-entry->remove();
+ entry->remove();
   }
}
 
@@ -283,7 +283,7 @@ ir_array_splitting_visitor::get_splitting_entry(ir_variable 
*var)
 
foreach_in_list(variable_entry, entry, this->variable_list) {
   if (entry->var == var) {
-return entry;
+ return entry;
   }
}
 
@@ -311,7 +311,7 @@ ir_array_splitting_visitor::split_deref(ir_dereference 
**deref)
 
if (constant->value.i[0] >= 0 && constant->value.i[0] < (int)entry->size) {
   *deref = new(entry->mem_ctx)
-ir_dereference_variable(entry->components[constant->value.i[0]]);
+   
ir_dereference_variable(entry->components[constant->value.i[0]]);
} else {
   /* There was a constant array access beyond the end of the
* array.  This might have happened due to constant folding
@@ -320,8 +320,8 @@ ir_array_splitting_visitor::split_deref(ir_dereference 
**deref)
* variable.
*/
   ir_variable *temp = new(entry->mem_ctx) ir_variable(deref_array->type,
- "undef",
- ir_var_temporary);
+  "undef",
+  ir_var_temporary);
   entry->components[0]->insert_before(temp);
   *deref = new(entry->mem_ctx) ir_dereference_variable(temp);
}
@@ -383,23 +383,21 @@ optimize_split_arrays(exec_list *instructions, bool 
linked)
   const struct glsl_type *subtype;
 
   if (type->is_matrix())
-subtype = type->column_type();
+ subtype = type->column_type();
   else
-subtype = type->fields.array;
+ subtype = type->fields.array;
 
   entry->mem_ctx = ralloc_parent(entry->var);
 
-  entry->components = ralloc_array(mem_ctx,
-  ir_variable *,
-  entry->size);
+  entry->components = ralloc_array(mem_ctx, ir_variable *, entry->size);
 
   for (unsigned int i = 0; i < entry->size; i++) {
-const char *name = 

Mesa (master): glsl/opt_array_splitting: Fix crash when doing array indexing into other arrays

2016-03-03 Thread Iago Toral Quiroga
Module: Mesa
Branch: master
Commit: 4a600024242be2b8684ab2cc215171f31db594b0
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=4a600024242be2b8684ab2cc215171f31db594b0

Author: Iago Toral Quiroga 
Date:   Thu Mar  3 09:02:30 2016 +0100

glsl/opt_array_splitting: Fix crash when doing array indexing into other arrays

When we find indirect indexing into an array, the current implementation
of the array spliiting optimization pass does not look further into the
expression tree. However, if the variable expression involves variable
indexing into other arrays, we can miss that these other arrays also have
variable indexing. If that happens, the pass will crash later on after
hitting an assertion put there to ensure that split arrays are in fact
always indexed via constants:

shader_runner: opt_array_splitting.cpp:296:
void ir_array_splitting_visitor::split_deref(ir_dereference**): Assertion 
`constant' failed.

This patch fixes the problem by letting the pass step into the variable
index expression to identify these cases properly.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=89607
Reviewed-by: Timothy Arceri 

---

 src/compiler/glsl/opt_array_splitting.cpp | 14 --
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/src/compiler/glsl/opt_array_splitting.cpp 
b/src/compiler/glsl/opt_array_splitting.cpp
index cceec6b..2f6afb0 100644
--- a/src/compiler/glsl/opt_array_splitting.cpp
+++ b/src/compiler/glsl/opt_array_splitting.cpp
@@ -185,8 +185,18 @@ 
ir_array_reference_visitor::visit_enter(ir_dereference_array *ir)
/* If the access to the array has a variable index, we wouldn't
 * know which split variable this dereference should go to.
 */
-   if (entry && !ir->array_index->as_constant())
-  entry->split = false;
+   if (!ir->array_index->as_constant()) {
+  if (entry)
+ entry->split = false;
+  /* This variable indexing could come from a different array dereference
+   * that also has variable indexing, that is, something like 
a[b[a[b[0.
+   * If we return visit_continue_with_parent here for the first appearence
+   * of a, then we can miss that b also has indirect indexing (if this is
+   * the only place in the program where such indirect indexing into b
+   * happens), so keep going.
+   */
+  return visit_continue;
+   }
 
/* If the index is also array dereference, visit index. */
if (ir->array_index->as_dereference_array())

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-commit