Mesa (master): r600/eg: add crap indirect compute support.

2018-02-01 Thread Dave Airlie
Module: Mesa
Branch: master
Commit: f9c121c420eb3d4b39aad3635b63cd48fe268783
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=f9c121c420eb3d4b39aad3635b63cd48fe268783

Author: Dave Airlie 
Date:   Tue Jan 30 12:21:59 2018 +1000

r600/eg: add crap indirect compute support.

I think the cp packets can be made work, but I think it might
need a kernel change, so for now just do the worst thing.

Reviewed-by: Roland Scheidegger 
Signed-off-by: Dave Airlie 

---

 src/gallium/drivers/r600/evergreen_compute.c | 26 +++---
 1 file changed, 19 insertions(+), 7 deletions(-)

diff --git a/src/gallium/drivers/r600/evergreen_compute.c 
b/src/gallium/drivers/r600/evergreen_compute.c
index 7880d0f723..b2c724feb0 100644
--- a/src/gallium/drivers/r600/evergreen_compute.c
+++ b/src/gallium/drivers/r600/evergreen_compute.c
@@ -630,13 +630,25 @@ static void evergreen_emit_dispatch(struct r600_context 
*rctx,
radeon_compute_set_context_reg(cs, R_0288E8_SQ_LDS_ALLOC,
lds_size | (num_waves << 14));
 
-   /* Dispatch packet */
-   radeon_emit(cs, PKT3C(PKT3_DISPATCH_DIRECT, 3, 0));
-   radeon_emit(cs, info->grid[0]);
-   radeon_emit(cs, info->grid[1]);
-   radeon_emit(cs, info->grid[2]);
-   /* VGT_DISPATCH_INITIATOR = COMPUTE_SHADER_EN */
-   radeon_emit(cs, 1);
+   if (info->indirect) {
+   struct r600_resource *indirect_resource = (struct r600_resource 
*)info->indirect;
+   unsigned *data = r600_buffer_map_sync_with_rings(>b, 
indirect_resource, PIPE_TRANSFER_READ);
+   if (data) {
+   radeon_emit(cs, PKT3C(PKT3_DISPATCH_DIRECT, 3, 0));
+   radeon_emit(cs, data[0]);
+   radeon_emit(cs, data[1]);
+   radeon_emit(cs, data[2]);
+   radeon_emit(cs, 1);
+   }
+   } else {
+   /* Dispatch packet */
+   radeon_emit(cs, PKT3C(PKT3_DISPATCH_DIRECT, 3, 0));
+   radeon_emit(cs, info->grid[0]);
+   radeon_emit(cs, info->grid[1]);
+   radeon_emit(cs, info->grid[2]);
+   /* VGT_DISPATCH_INITIATOR = COMPUTE_SHADER_EN */
+   radeon_emit(cs, 1);
+   }
 
if (rctx->is_debug)
eg_trace_emit(rctx);

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


Mesa (master): i965: Call prepare_external after implicit window-system MSAA resolves

2018-02-01 Thread Jason Ekstrand
Module: Mesa
Branch: master
Commit: 2f7205be47bbb730cdfa0a037224b9ebd5224fd1
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=2f7205be47bbb730cdfa0a037224b9ebd5224fd1

Author: Jason Ekstrand 
Date:   Wed Jan 31 17:31:39 2018 -0800

i965: Call prepare_external after implicit window-system MSAA resolves

This fixes some rendering corruption in a couple of Android apps that
use window-system MSAA.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=104741
Cc: mesa-sta...@lists.freedesktop.org
Reviewed-by: Tapani Pälli 

---

 src/mesa/drivers/dri/i965/brw_context.c | 15 +++
 1 file changed, 15 insertions(+)

diff --git a/src/mesa/drivers/dri/i965/brw_context.c 
b/src/mesa/drivers/dri/i965/brw_context.c
index addacf2cf8..e5d3b5c707 100644
--- a/src/mesa/drivers/dri/i965/brw_context.c
+++ b/src/mesa/drivers/dri/i965/brw_context.c
@@ -1283,6 +1283,21 @@ intel_resolve_for_dri2_flush(struct brw_context *brw,
  intel_miptree_prepare_external(brw, rb->mt);
   } else {
  intel_renderbuffer_downsample(brw, rb);
+
+ /* Call prepare_external on the single-sample miptree to do any
+  * needed resolves prior to handing it off to the window system.
+  * This is needed in the case that rb->singlesample_mt is Y-tiled
+  * with CCS_E enabled but without I915_FORMAT_MOD_Y_TILED_CCS_E.  In
+  * this case, the MSAA resolve above will write compressed data into
+  * rb->singlesample_mt.
+  *
+  * TODO: Some day, if we decide to care about the tiny performance
+  * hit we're taking by doing the MSAA resolve and then a CCS resolve,
+  * we could detect this case and just allocate the single-sampled
+  * miptree without aux.  However, that would be a lot of plumbing and
+  * this is a rather exotic case so it's not really worth it.
+  */
+ intel_miptree_prepare_external(brw, rb->singlesample_mt);
   }
}
 }

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


Mesa (master): r600: don't do stack workarounds for hemlock

2018-02-01 Thread Roland Scheidegger
Module: Mesa
Branch: master
Commit: c2f0e0885776f3f0a18b9db08149564d4b98e5b7
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=c2f0e0885776f3f0a18b9db08149564d4b98e5b7

Author: Roland Scheidegger 
Date:   Tue Jan 30 05:48:27 2018 +0100

r600: don't do stack workarounds for hemlock

By the looks of it it seems hemlock is treated separately to cypress, but
certainly it won't need the stack workarounds cedar/redwood (and
seemingly every other eg chip except cypress/juniper) need.
(Discovered by accident.)

Acked-by: Alex Deucher 

---

 src/gallium/drivers/r600/sb/sb_bc.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/gallium/drivers/r600/sb/sb_bc.h 
b/src/gallium/drivers/r600/sb/sb_bc.h
index b35671bf0f..a249395474 100644
--- a/src/gallium/drivers/r600/sb/sb_bc.h
+++ b/src/gallium/drivers/r600/sb/sb_bc.h
@@ -665,6 +665,7 @@ public:
return false;
 
switch (hw_chip) {
+   case HW_CHIP_HEMLOCK:
case HW_CHIP_CYPRESS:
case HW_CHIP_JUNIPER:
return false;

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


Mesa (master): r600: initial attempt at gl_HelperInvocation (v3)

2018-02-01 Thread Dave Airlie
Module: Mesa
Branch: master
Commit: 8fa5aade43d70468947d72029691544fa97ba43b
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=8fa5aade43d70468947d72029691544fa97ba43b

Author: Dave Airlie 
Date:   Wed Jan 31 14:28:26 2018 +1000

r600: initial attempt at gl_HelperInvocation (v3)

This passes the CTS and piglit tests.

This also disable sb for helper invocations until it doesn't
mess up the VPM flags.

Thanks to Ilia and Glenn for advice, and Roland for working
out the working evergreen path.

Reviewed-by: Roland Scheidegger 
Signed-off-by: Dave Airlie 

---

 src/gallium/drivers/r600/r600_asm.c|  7 ++-
 src/gallium/drivers/r600/r600_isa.c|  1 +
 src/gallium/drivers/r600/r600_isa.h|  5 +-
 src/gallium/drivers/r600/r600_shader.c | 95 ++
 src/gallium/drivers/r600/r600_shader.h |  1 +
 src/gallium/drivers/r600/r600_sq.h |  2 +
 6 files changed, 108 insertions(+), 3 deletions(-)

diff --git a/src/gallium/drivers/r600/r600_asm.c 
b/src/gallium/drivers/r600/r600_asm.c
index 21d069d81b..ec2d34e950 100644
--- a/src/gallium/drivers/r600/r600_asm.c
+++ b/src/gallium/drivers/r600/r600_asm.c
@@ -2099,9 +2099,12 @@ void r600_bytecode_disasm(struct r600_bytecode *bc)
fprintf(stderr, "%04d %08X %08X  %s ", id, 
bc->bytecode[id],
bc->bytecode[id + 1], 
cfop->name);
fprintf(stderr, "%d @%d ", cf->ndw / 4, 
cf->addr);
-   fprintf(stderr, "\n");
+   if (cf->vpm)
+   fprintf(stderr, "VPM ");
if (cf->end_of_program)
fprintf(stderr, "EOP ");
+   fprintf(stderr, "\n");
+
} else if (cfop->flags & CF_EXP) {
int o = 0;
const char *exp_type[] = {"PIXEL", "POS  ", 
"PARAM"};
@@ -2198,6 +2201,8 @@ void r600_bytecode_disasm(struct r600_bytecode *bc)
fprintf(stderr, "POP:%X ", 
cf->pop_count);
if (cf->count && (cfop->flags & CF_EMIT))
fprintf(stderr, "STREAM%d ", cf->count);
+   if (cf->vpm)
+   fprintf(stderr, "VPM ");
if (cf->end_of_program)
fprintf(stderr, "EOP ");
fprintf(stderr, "\n");
diff --git a/src/gallium/drivers/r600/r600_isa.c 
b/src/gallium/drivers/r600/r600_isa.c
index 2633cdcdb9..611b370bf5 100644
--- a/src/gallium/drivers/r600/r600_isa.c
+++ b/src/gallium/drivers/r600/r600_isa.c
@@ -506,6 +506,7 @@ static const struct cf_op_info cf_op_table[] = {
{"ALU_EXT",   {   -1,   -1, 0x0C, 0x0C },  
CF_CLAUSE | CF_ALU | CF_ALU_EXT  },
{"ALU_CONTINUE",  { 0x0D, 0x0D, 0x0D,   -1 },  
CF_CLAUSE | CF_ALU  },
{"ALU_BREAK", { 0x0E, 0x0E, 0x0E,   -1 },  
CF_CLAUSE | CF_ALU  },
+   {"ALU_VALID_PIXEL_MODE",  {   -1,   -1,   -1, 0x0E },  
CF_CLAUSE | CF_ALU  },
{"ALU_ELSE_AFTER",{ 0x0F, 0x0F, 0x0F, 0x0F },  
CF_CLAUSE | CF_ALU  },
{"CF_NATIVE", { 0x00, 0x00, 0x00, 0x00 },  
0  }
 };
diff --git a/src/gallium/drivers/r600/r600_isa.h 
b/src/gallium/drivers/r600/r600_isa.h
index f6e26976c5..fcaf1f766b 100644
--- a/src/gallium/drivers/r600/r600_isa.h
+++ b/src/gallium/drivers/r600/r600_isa.h
@@ -646,10 +646,11 @@ struct cf_op_info
 #define CF_OP_ALU_EXT  84
 #define CF_OP_ALU_CONTINUE 85
 #define CF_OP_ALU_BREAK86
-#define CF_OP_ALU_ELSE_AFTER   87
+#define CF_OP_ALU_VALID_PIXEL_MODE 87
+#define CF_OP_ALU_ELSE_AFTER   88
 
 /* CF_NATIVE means that r600_bytecode_cf contains pre-encoded native data */
-#define CF_NATIVE  88
+#define CF_NATIVE  89
 
 enum r600_chip_class {
ISA_CC_R600,
diff --git a/src/gallium/drivers/r600/r600_shader.c 
b/src/gallium/drivers/r600/r600_shader.c
index a462691f7a..13aa681049 100644
--- a/src/gallium/drivers/r600/r600_shader.c
+++ b/src/gallium/drivers/r600/r600_shader.c
@@ -197,6 +197,7 @@ int r600_pipe_shader_create(struct pipe_context *ctx,
 
use_sb &= !shader->shader.uses_atomics;
use_sb &= !shader->shader.uses_images;
+   use_sb &= !shader->shader.uses_helper_invocation;
 
/* Check if the bytecode has already been built. */
if (!shader->shader.bc.bytecode) {
@@ -346,6 +347,7 @@ struct r600_shader_ctx {
boolean clip_vertex_write;
unsigned

Mesa (master): radv: Don't expose VK_KHX_multiview on android.

2018-02-01 Thread Bas Nieuwenhuizen
Module: Mesa
Branch: master
Commit: 2ffe395cba0f7b3c1f1c41062f4376eae3a188b5
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=2ffe395cba0f7b3c1f1c41062f4376eae3a188b5

Author: Bas Nieuwenhuizen 
Date:   Wed Jan 31 12:31:30 2018 +0100

radv: Don't expose VK_KHX_multiview on android.

deqp does not allow any KHX extensions, and since deqp is included
in android-cts, android does not allow any khx extensions.

So disable VK_KHX_multiview on android.

Reviewed-by: Samuel Pitoiset 
CC: 18.0 

---

 src/amd/vulkan/radv_extensions.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/amd/vulkan/radv_extensions.py 
b/src/amd/vulkan/radv_extensions.py
index ab34c01cb6..e6c6e63627 100644
--- a/src/amd/vulkan/radv_extensions.py
+++ b/src/amd/vulkan/radv_extensions.py
@@ -81,7 +81,7 @@ EXTENSIONS = [
 Extension('VK_KHR_wayland_surface',   6, 
'VK_USE_PLATFORM_WAYLAND_KHR'),
 Extension('VK_KHR_xcb_surface',   6, 
'VK_USE_PLATFORM_XCB_KHR'),
 Extension('VK_KHR_xlib_surface',  6, 
'VK_USE_PLATFORM_XLIB_KHR'),
-Extension('VK_KHX_multiview', 1, True),
+Extension('VK_KHX_multiview', 1, '!ANDROID'),
 Extension('VK_EXT_debug_report',  9, True),
 Extension('VK_EXT_discard_rectangles',1, True),
 Extension('VK_EXT_external_memory_dma_buf',   1, True),

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


Mesa (master): vbo: Use static const VERT_ATTRIB->VBO_ATTRIB maps.

2018-02-01 Thread Mathias Fröhlich
Module: Mesa
Branch: master
Commit: 3d4fb879ddbce1c5da7199ae74bc2e7ae98d1b70
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=3d4fb879ddbce1c5da7199ae74bc2e7ae98d1b70

Author: Mathias Fröhlich 
Date:   Sat Jan 27 16:07:22 2018 +0100

vbo: Use static const VERT_ATTRIB->VBO_ATTRIB maps.

Instead of each context having its own map instance for
this purpose, use a global static const map.

v2: s,unsigned char,GLubyte,g
s,_VP_MODE_MAX,VP_MODE_MAX,g
Change comment style.

Signed-off-by: Mathias Fröhlich 
Reviewed-by: Brian Paul 

---

 src/mesa/vbo/vbo_context.c| 23 ++
 src/mesa/vbo/vbo_exec.c   | 74 +++
 src/mesa/vbo/vbo_exec_array.c |  5 ++-
 src/mesa/vbo/vbo_exec_draw.c  |  8 ++---
 src/mesa/vbo/vbo_private.h| 16 +++---
 src/mesa/vbo/vbo_save_draw.c  |  8 ++---
 6 files changed, 99 insertions(+), 35 deletions(-)

diff --git a/src/mesa/vbo/vbo_context.c b/src/mesa/vbo/vbo_context.c
index 4fa6f62ad0..5bc6bf0acd 100644
--- a/src/mesa/vbo/vbo_context.c
+++ b/src/mesa/vbo/vbo_context.c
@@ -236,27 +236,8 @@ _vbo_CreateContext(struct gl_context *ctx)
init_mat_currval(ctx);
vbo_set_indirect_draw_func(ctx, vbo_draw_indirect_prims);
 
-   /* Build mappings from VERT_ATTRIB -> VBO_ATTRIB depending on type
-* of vertex program active.
-*/
-   {
-  GLuint i;
-
-  /* make sure all VBO_ATTRIB_ values can fit in an unsigned byte */
-  STATIC_ASSERT(VBO_ATTRIB_MAX <= 255);
-
-  /* identity mapping */
-  for (i = 0; i < ARRAY_SIZE(vbo->map_vp_none); i++)
- vbo->map_vp_none[i] = i;
-  /* map material attribs to generic slots */
-  for (i = 0; i < VERT_ATTRIB_MAT_MAX; i++)
- vbo->map_vp_none[VERT_ATTRIB_MAT(i)]
-= VBO_ATTRIB_MAT_FRONT_AMBIENT + i;
-
-  for (i = 0; i < ARRAY_SIZE(vbo->map_vp_arb); i++)
- vbo->map_vp_arb[i] = i;
-   }
-
+   /* make sure all VBO_ATTRIB_ values can fit in an unsigned byte */
+   STATIC_ASSERT(VBO_ATTRIB_MAX <= 255);
 
/* Hook our functions into exec and compile dispatch tables.  These
 * will pretty much be permanently installed, which means that the
diff --git a/src/mesa/vbo/vbo_exec.c b/src/mesa/vbo/vbo_exec.c
index 82f204e3dc..fc06979dcb 100644
--- a/src/mesa/vbo/vbo_exec.c
+++ b/src/mesa/vbo/vbo_exec.c
@@ -32,6 +32,80 @@
 #include "main/vtxfmt.h"
 #include "vbo_private.h"
 
+const GLubyte
+_vbo_attribute_alias_map[VP_MODE_MAX][VERT_ATTRIB_MAX] = {
+   /* VP_FF: */
+   {
+  VBO_ATTRIB_POS, /* VERT_ATTRIB_POS */
+  VBO_ATTRIB_NORMAL,  /* VERT_ATTRIB_NORMAL */
+  VBO_ATTRIB_COLOR0,  /* VERT_ATTRIB_COLOR0 */
+  VBO_ATTRIB_COLOR1,  /* VERT_ATTRIB_COLOR1 */
+  VBO_ATTRIB_FOG, /* VERT_ATTRIB_FOG */
+  VBO_ATTRIB_COLOR_INDEX, /* VERT_ATTRIB_COLOR_INDEX */
+  VBO_ATTRIB_EDGEFLAG,/* VERT_ATTRIB_EDGEFLAG */
+  VBO_ATTRIB_TEX0,/* VERT_ATTRIB_TEX0 */
+  VBO_ATTRIB_TEX1,/* VERT_ATTRIB_TEX1 */
+  VBO_ATTRIB_TEX2,/* VERT_ATTRIB_TEX2 */
+  VBO_ATTRIB_TEX3,/* VERT_ATTRIB_TEX3 */
+  VBO_ATTRIB_TEX4,/* VERT_ATTRIB_TEX4 */
+  VBO_ATTRIB_TEX5,/* VERT_ATTRIB_TEX5 */
+  VBO_ATTRIB_TEX6,/* VERT_ATTRIB_TEX6 */
+  VBO_ATTRIB_TEX7,/* VERT_ATTRIB_TEX7 */
+  VBO_ATTRIB_POINT_SIZE,  /* VERT_ATTRIB_POINT_SIZE */
+  VBO_ATTRIB_GENERIC0,/* VERT_ATTRIB_GENERIC0 */
+  VBO_ATTRIB_GENERIC1,/* VERT_ATTRIB_GENERIC1 */
+  VBO_ATTRIB_GENERIC2,/* VERT_ATTRIB_GENERIC2 */
+  VBO_ATTRIB_GENERIC3,/* VERT_ATTRIB_GENERIC3 */
+  VBO_ATTRIB_MAT_FRONT_AMBIENT,   /* VERT_ATTRIB_GENERIC4 */
+  VBO_ATTRIB_MAT_BACK_AMBIENT,/* VERT_ATTRIB_GENERIC5 */
+  VBO_ATTRIB_MAT_FRONT_DIFFUSE,   /* VERT_ATTRIB_GENERIC6 */
+  VBO_ATTRIB_MAT_BACK_DIFFUSE,/* VERT_ATTRIB_GENERIC7 */
+  VBO_ATTRIB_MAT_FRONT_SPECULAR,  /* VERT_ATTRIB_GENERIC8 */
+  VBO_ATTRIB_MAT_BACK_SPECULAR,   /* VERT_ATTRIB_GENERIC9 */
+  VBO_ATTRIB_MAT_FRONT_EMISSION,  /* VERT_ATTRIB_GENERIC10 */
+  VBO_ATTRIB_MAT_BACK_EMISSION,   /* VERT_ATTRIB_GENERIC11 */
+  VBO_ATTRIB_MAT_FRONT_SHININESS, /* VERT_ATTRIB_GENERIC12 */
+  VBO_ATTRIB_MAT_BACK_SHININESS,  /* VERT_ATTRIB_GENERIC13 */
+  VBO_ATTRIB_MAT_FRONT_INDEXES,   /* VERT_ATTRIB_GENERIC14 */
+  VBO_ATTRIB_MAT_BACK_INDEXES /* VERT_ATTRIB_GENERIC15 */
+   },
+
+   /* VP_SHADER: */
+   {
+  VBO_ATTRIB_POS, /* VERT_ATTRIB_POS */
+  VBO_ATTRIB_NORMAL,  /* VERT_ATTRIB_NORMAL */
+  VBO_ATTRIB_COLOR0,  /* VERT_ATTRIB_COLOR0 */
+  VBO_ATTRIB_COLOR1,  /* VERT_ATTRIB_COLOR1 */
+  VBO_ATTRIB_FOG, /* VERT_ATTRIB_FOG */
+   

Mesa (master): vbo: Simplify input array distribution for dlist type draws.

2018-02-01 Thread Mathias Fröhlich
Module: Mesa
Branch: master
Commit: 5b3d58520f40d575adc83cbbcd1c1208932d16d1
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=5b3d58520f40d575adc83cbbcd1c1208932d16d1

Author: Mathias Fröhlich 
Date:   Sat Jan 27 16:07:22 2018 +0100

vbo: Simplify input array distribution for dlist type draws.

Using the newly introduced VAO array maps, we can
simplify vbo_bind_vertex_list.

Signed-off-by: Mathias Fröhlich 
Reviewed-by: Brian Paul 

---

 src/mesa/vbo/vbo_save_draw.c | 54 +++-
 1 file changed, 8 insertions(+), 46 deletions(-)

diff --git a/src/mesa/vbo/vbo_save_draw.c b/src/mesa/vbo/vbo_save_draw.c
index ad45f4d050..96a9bab029 100644
--- a/src/mesa/vbo/vbo_save_draw.c
+++ b/src/mesa/vbo/vbo_save_draw.c
@@ -27,6 +27,7 @@
  */
 
 #include 
+#include "main/arrayobj.h"
 #include "main/glheader.h"
 #include "main/bufferobj.h"
 #include "main/context.h"
@@ -140,54 +141,20 @@ bind_vertex_list(struct gl_context *ctx,
struct gl_vertex_array *arrays = save->arrays;
GLuint attr;
GLbitfield varying_inputs = 0x0;
-   bool generic_from_pos = false;
 
const enum vp_mode program_mode = get_vp_mode(ctx);
const GLubyte * const map = _vbo_attribute_alias_map[program_mode];
 
-   /* Install the default (ie Current) attributes first */
-   for (attr = 0; attr < VERT_ATTRIB_FF_MAX; attr++) {
-  save->inputs[attr] = >currval[VBO_ATTRIB_POS + attr];
-   }
-
-   /* Overlay other active attributes */
-   switch (program_mode) {
-   case VP_FF:
-  for (attr = 0; attr < VERT_ATTRIB_MAT0; attr++) {
- save->inputs[VERT_ATTRIB_GENERIC(attr)] =
->currval[VBO_ATTRIB_GENERIC0+attr];
-  }
-  for (attr = 0; attr < VERT_ATTRIB_MAT_MAX; attr++) {
- save->inputs[VERT_ATTRIB_MAT(attr)] =
->currval[VBO_ATTRIB_MAT_FRONT_AMBIENT+attr];
-  }
-  break;
-   case VP_SHADER:
-  for (attr = 0; attr < VERT_ATTRIB_GENERIC_MAX; attr++) {
- save->inputs[VERT_ATTRIB_GENERIC(attr)] =
->currval[VBO_ATTRIB_GENERIC0+attr];
-  }
-
-  /* check if VERT_ATTRIB_POS is not read but VERT_BIT_GENERIC0 is read.
-   * In that case we effectively need to route the data from
-   * glVertexAttrib(0, val) calls to feed into the GENERIC0 input.
-   */
-  const GLbitfield64 inputs_read =
- ctx->VertexProgram._Current->info.inputs_read;
-  if ((inputs_read & VERT_BIT_POS) == 0 &&
-  (inputs_read & VERT_BIT_GENERIC0)) {
- generic_from_pos = true;
-  }
-  break;
-   default:
-  unreachable("Bad vertex program mode");
-   }
-
+   /* Grab VERT_ATTRIB_{POS,GENERIC0} from VBO_ATTRIB_POS */
+   const gl_attribute_map_mode mode = ATTRIBUTE_MAP_MODE_POSITION;
+   const GLubyte *const array_map = _mesa_vao_attribute_map[mode];
for (attr = 0; attr < VERT_ATTRIB_MAX; attr++) {
-  const GLuint src = map[attr];
+  const GLuint src = map[array_map[attr]];
   const GLubyte size = node->attrsz[src];
 
-  if (size) {
+  if (size == 0) {
+ save->inputs[attr] = >currval[map[attr]];
+  } else {
  struct gl_vertex_array *array = [attr];
  const GLenum16 type = node->attrtype[src];
 
@@ -211,11 +178,6 @@ bind_vertex_list(struct gl_context *ctx,
   }
}
 
-   if (generic_from_pos) {
-  varying_inputs |= (varying_inputs & VERT_BIT_POS) << 
VERT_ATTRIB_GENERIC0;
-  save->inputs[VERT_ATTRIB_GENERIC0] = save->inputs[VERT_ATTRIB_POS];
-   }
-
_mesa_set_varying_vp_inputs(ctx, varying_inputs);
ctx->NewDriverState |= ctx->DriverFlags.NewArray;
 }

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


Mesa (master): mesa: Use defines for the aliased material array attributes.

2018-02-01 Thread Mathias Fröhlich
Module: Mesa
Branch: master
Commit: 38b41fd718cfffd11dab637d9d0cbd6c2a30b2c2
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=38b41fd718cfffd11dab637d9d0cbd6c2a30b2c2

Author: Mathias Fröhlich 
Date:   Sat Jan 27 16:07:22 2018 +0100

mesa: Use defines for the aliased material array attributes.

Instead of just assuming that the material attributes
just overlap with the generic attributes 0-12, give
them symbolic defines so that we can easier move them
to an other range.

Signed-off-by: Mathias Fröhlich 
Reviewed-by: Brian Paul 

---

 src/compiler/shader_enums.h | 10 ++
 src/mesa/drivers/dri/nouveau/nouveau_render_t.c |  2 +-
 src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c|  8 
 src/mesa/drivers/dri/nouveau/nv10_render.c  | 10 +-
 src/mesa/drivers/dri/nouveau/nv20_render.c  | 20 ++--
 src/mesa/main/ffvertex_prog.c   |  7 ---
 src/mesa/tnl/t_context.h|  2 +-
 src/mesa/vbo/vbo_context.c  |  4 ++--
 src/mesa/vbo/vbo_exec_array.c   | 10 +-
 src/mesa/vbo/vbo_exec_draw.c| 10 +++---
 src/mesa/vbo/vbo_save_draw.c|  9 ++---
 11 files changed, 55 insertions(+), 37 deletions(-)

diff --git a/src/compiler/shader_enums.h b/src/compiler/shader_enums.h
index ffe551ab20..aa296adb5a 100644
--- a/src/compiler/shader_enums.h
+++ b/src/compiler/shader_enums.h
@@ -124,6 +124,9 @@ const char *gl_vert_attrib_name(gl_vert_attrib attrib);
  * VERT_ATTRIB_GENERIC
  *   include the OpenGL 2.0+ GLSL generic shader attributes.
  *   These alias the generic GL_ARB_vertex_shader attributes.
+ * VERT_ATTRIB_MAT
+ *   include the generic shader attributes used to alias
+ *   varying material values for the TNL shader programs.
  */
 #define VERT_ATTRIB_FF(i)   (VERT_ATTRIB_POS + (i))
 #define VERT_ATTRIB_FF_MAX  VERT_ATTRIB_GENERIC0
@@ -134,6 +137,9 @@ const char *gl_vert_attrib_name(gl_vert_attrib attrib);
 #define VERT_ATTRIB_GENERIC(i)  (VERT_ATTRIB_GENERIC0 + (i))
 #define VERT_ATTRIB_GENERIC_MAX MAX_VERTEX_GENERIC_ATTRIBS
 
+#define VERT_ATTRIB_MAT(i)  VERT_ATTRIB_GENERIC(i)
+#define VERT_ATTRIB_MAT_MAX MAT_ATTRIB_MAX
+
 /**
  * Bitflags for vertex attributes.
  * These are used in bitfields in many places.
@@ -169,6 +175,10 @@ const char *gl_vert_attrib_name(gl_vert_attrib attrib);
 #define VERT_BIT_GENERIC(i)  VERT_BIT(VERT_ATTRIB_GENERIC(i))
 #define VERT_BIT_GENERIC_ALL \
BITFIELD_RANGE(VERT_ATTRIB_GENERIC(0), VERT_ATTRIB_GENERIC_MAX)
+
+#define VERT_BIT_MAT(i) VERT_BIT(VERT_ATTRIB_MAT(i))
+#define VERT_BIT_MAT_ALL \
+   BITFIELD_RANGE(VERT_ATTRIB_MAT(0), VERT_ATTRIB_MAT_MAX)
 /*@}*/
 
 #define MAX_VARYING 32 /**< number of float[4] vectors */
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_render_t.c 
b/src/mesa/drivers/dri/nouveau/nouveau_render_t.c
index db60b59c8f..5699f38f4d 100644
--- a/src/mesa/drivers/dri/nouveau/nouveau_render_t.c
+++ b/src/mesa/drivers/dri/nouveau/nouveau_render_t.c
@@ -188,7 +188,7 @@ static void
 TAG(emit_material)(struct gl_context *ctx, struct nouveau_array *a,
   const void *v)
 {
-   int attr = a->attr - VERT_ATTRIB_GENERIC0;
+   int attr = a->attr - VERT_ATTRIB_MAT(0);
int state = ((int []) {
NOUVEAU_STATE_MATERIAL_FRONT_AMBIENT,
NOUVEAU_STATE_MATERIAL_BACK_AMBIENT,
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c 
b/src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c
index fdd135c5d7..b9145e6851 100644
--- a/src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c
+++ b/src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c
@@ -118,8 +118,8 @@ vbo_choose_render_mode(struct gl_context *ctx, const struct 
gl_vertex_array **ar
render->mode = VBO;
 
if (ctx->Light.Enabled) {
-   for (i = 0; i < MAT_ATTRIB_MAX; i++) {
-   if (arrays[VERT_ATTRIB_GENERIC0 + i]->StrideB) {
+   for (i = 0; i < VERT_ATTRIB_MAT_MAX; i++) {
+   if (arrays[VERT_ATTRIB_MAT(i)]->StrideB) {
render->mode = IMM;
break;
}
@@ -138,7 +138,7 @@ vbo_emit_attr(struct gl_context *ctx, const struct 
gl_vertex_array **arrays,
RENDER_LOCALS(ctx);
 
if (!array->StrideB) {
-   if (attr >= VERT_ATTRIB_GENERIC0)
+   if (attr >= VERT_ATTRIB_MAT(0))
/* nouveau_update_state takes care of materials. */
return;
 
@@ -165,7 +165,7 @@ vbo_emit_attr(struct gl_context *ctx, const struct 
gl_vertex_array **arrays,
}
 }
 
-#define MAT(a) (VERT_ATTRIB_GENERIC0 + MAT_ATTRIB_##a)
+#define MAT(a) VERT_ATTRIB_MAT(MAT_ATTRIB_##a)
 
 static void
 vbo_choose_attrs(struct gl_context 

Mesa (master): vbo: Simplify input array distribution for imm type draws.

2018-02-01 Thread Mathias Fröhlich
Module: Mesa
Branch: master
Commit: fb10a7b7b0da7b4965a60a9427bf295825bf78c8
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=fb10a7b7b0da7b4965a60a9427bf295825bf78c8

Author: Mathias Fröhlich 
Date:   Sat Jan 27 16:07:22 2018 +0100

vbo: Simplify input array distribution for imm type draws.

Using the newly introduced VAO array maps, we can
simplify vbo_exec_bind_arrays.

Signed-off-by: Mathias Fröhlich 
Reviewed-by: Brian Paul 

---

 src/mesa/vbo/vbo_exec_draw.c | 81 
 1 file changed, 15 insertions(+), 66 deletions(-)

diff --git a/src/mesa/vbo/vbo_exec_draw.c b/src/mesa/vbo/vbo_exec_draw.c
index e3e050595c..b0cc394642 100644
--- a/src/mesa/vbo/vbo_exec_draw.c
+++ b/src/mesa/vbo/vbo_exec_draw.c
@@ -27,6 +27,7 @@
 
 #include 
 #include 
+#include "main/arrayobj.h"
 #include "main/glheader.h"
 #include "main/bufferobj.h"
 #include "main/context.h"
@@ -176,62 +177,20 @@ vbo_exec_bind_arrays(struct gl_context *ctx)
struct gl_vertex_array *arrays = exec->vtx.arrays;
GLuint attr;
GLbitfield varying_inputs = 0x0;
-   bool swap_pos = false;
 
const enum vp_mode program_mode = get_vp_mode(exec->ctx);
const GLubyte * const map = _vbo_attribute_alias_map[program_mode];
 
-   /* Install the default (ie Current) attributes first */
-   for (attr = 0; attr < VERT_ATTRIB_FF_MAX; attr++) {
-  exec->vtx.inputs[attr] = >currval[VBO_ATTRIB_POS+attr];
-   }
+   /* Grab VERT_ATTRIB_{POS,GENERIC0} from VBO_ATTRIB_POS */
+   const gl_attribute_map_mode mode = ATTRIBUTE_MAP_MODE_POSITION;
+   const GLubyte *const array_map = _mesa_vao_attribute_map[mode];
+   for (attr = 0; attr < VERT_ATTRIB_MAX; attr++) {
+  const GLuint src = map[array_map[attr]];
+  const GLubyte size = exec->vtx.attrsz[src];
 
-   /* Overlay other active attributes */
-   switch (program_mode) {
-   case VP_FF:
-  for (attr = 0; attr < VERT_ATTRIB_MAT0; attr++) {
- assert(VERT_ATTRIB_GENERIC(attr) < ARRAY_SIZE(exec->vtx.inputs));
- exec->vtx.inputs[VERT_ATTRIB_GENERIC(attr)] =
->currval[VBO_ATTRIB_GENERIC0+attr];
-  }
-  for (attr = 0; attr < VERT_ATTRIB_MAT_MAX; attr++) {
- assert(VERT_ATTRIB_MAT(attr) < ARRAY_SIZE(exec->vtx.inputs));
- exec->vtx.inputs[VERT_ATTRIB_MAT(attr)] =
->currval[VBO_ATTRIB_MAT_FRONT_AMBIENT+attr];
-  }
-  break;
-   case VP_SHADER:
-  for (attr = 0; attr < VERT_ATTRIB_GENERIC_MAX; attr++) {
- assert(VERT_ATTRIB_GENERIC(attr) < ARRAY_SIZE(exec->vtx.inputs));
- exec->vtx.inputs[VERT_ATTRIB_GENERIC(attr)] =
->currval[VBO_ATTRIB_GENERIC0+attr];
-  }
-
-  /* check if VERT_ATTRIB_POS is not read but VERT_BIT_GENERIC0 is read.
-   * In that case we effectively need to route the data from
-   * glVertexAttrib(0, val) calls to feed into the GENERIC0 input.
-   * The original state gets essentially restored below.
-   */
-  const GLbitfield64 inputs_read =
- ctx->VertexProgram._Current->info.inputs_read;
-  if ((inputs_read & VERT_BIT_POS) == 0 &&
-  (inputs_read & VERT_BIT_GENERIC0)) {
- swap_pos = true;
- exec->vtx.inputs[VERT_ATTRIB_GENERIC0] = exec->vtx.inputs[0];
- exec->vtx.attrsz[VERT_ATTRIB_GENERIC0] = exec->vtx.attrsz[0];
- exec->vtx.attrtype[VERT_ATTRIB_GENERIC0] = exec->vtx.attrtype[0];
- exec->vtx.attrptr[VERT_ATTRIB_GENERIC0] = exec->vtx.attrptr[0];
- exec->vtx.attrsz[0] = 0;
-  }
-  break;
-   default:
-  unreachable("Bad vertex program mode");
-   }
-
-   for (attr = 0; attr < VERT_ATTRIB_MAX ; attr++) {
-  const GLuint src = map[attr];
-
-  if (exec->vtx.attrsz[src]) {
+  if (size == 0) {
+ exec->vtx.inputs[attr] = >currval[map[attr]];
+  } else {
  GLsizeiptr offset = (GLbyte *)exec->vtx.attrptr[src] -
 (GLbyte *)exec->vtx.vertex;
 
@@ -251,13 +210,13 @@ vbo_exec_bind_arrays(struct gl_context *ctx)
 /* Ptr into ordinary app memory */
 arrays[attr].Ptr = (GLubyte *)exec->vtx.buffer_map + offset;
  }
- arrays[attr].Size = exec->vtx.attrsz[src];
+ arrays[attr].Size = size;
  arrays[attr].StrideB = exec->vtx.vertex_size * sizeof(GLfloat);
- arrays[attr].Type = exec->vtx.attrtype[src];
- arrays[attr].Integer =
-   vbo_attrtype_to_integer_flag(exec->vtx.attrtype[src]);
+ const GLenum16 type = exec->vtx.attrtype[src];
+ arrays[attr].Type = type;
+ arrays[attr].Integer = vbo_attrtype_to_integer_flag(type);
  arrays[attr].Format = GL_RGBA;
- arrays[attr]._ElementSize = arrays[attr].Size * sizeof(GLfloat);
+ arrays[attr]._ElementSize = size * sizeof(GLfloat);
  _mesa_reference_buffer_object(ctx,
[attr].BufferObj,
  

Mesa (master): vbo: Correctly handle attribute offsets in dlist draw.

2018-02-01 Thread Mathias Fröhlich
Module: Mesa
Branch: master
Commit: f37e29ac224887f1b4f0cb7c61e47fb4bc6671e1
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=f37e29ac224887f1b4f0cb7c61e47fb4bc6671e1

Author: Mathias Fröhlich 
Date:   Sat Jan 27 16:07:22 2018 +0100

vbo: Correctly handle attribute offsets in dlist draw.

When executing a display list draw, for the offset
list to be correct, the offset computation needs to
accumulate all attribute size values in order.
Specifically, if we are shuffling around the position
and generic0 attributes, we may violate the order or
if we do not walk the generic vbo attributes we may
skip some of the attributes.
Even if this is an unlikely usecase we can fix this use
case by precomputing the offsets on the full attribute list
and store the full offset list in the display list node.

v2: Formatting fix
v3: Rebase

Signed-off-by: Mathias Fröhlich 
Reviewed-by: Brian Paul 

---

 src/mesa/vbo/vbo_save.h  |  1 +
 src/mesa/vbo/vbo_save_api.c  | 19 ++
 src/mesa/vbo/vbo_save_draw.c | 47 +++-
 3 files changed, 36 insertions(+), 31 deletions(-)

diff --git a/src/mesa/vbo/vbo_save.h b/src/mesa/vbo/vbo_save.h
index 1dc66a598e..cb0bff2341 100644
--- a/src/mesa/vbo/vbo_save.h
+++ b/src/mesa/vbo/vbo_save.h
@@ -64,6 +64,7 @@ struct vbo_save_vertex_list {
GLbitfield64 enabled; /**< mask of enabled vbo arrays. */
GLubyte attrsz[VBO_ATTRIB_MAX];
GLenum16 attrtype[VBO_ATTRIB_MAX];
+   GLuint offsets[VBO_ATTRIB_MAX];
GLuint vertex_size;  /**< size in GLfloats */
 
/* Copy of the final vertex from node->vertex_store->bufferobj.
diff --git a/src/mesa/vbo/vbo_save_api.c b/src/mesa/vbo/vbo_save_api.c
index a0fb62d814..fb51bdb84e 100644
--- a/src/mesa/vbo/vbo_save_api.c
+++ b/src/mesa/vbo/vbo_save_api.c
@@ -420,6 +420,8 @@ compile_vertex_list(struct gl_context *ctx)
 {
struct vbo_save_context *save = _context(ctx)->save;
struct vbo_save_vertex_list *node;
+   GLuint offset;
+   unsigned i;
 
/* Allocate space for this structure in the display list currently
 * being compiled.
@@ -443,6 +445,23 @@ compile_vertex_list(struct gl_context *ctx)
node->vertex_size = save->vertex_size;
node->buffer_offset =
   (save->buffer_map - save->vertex_store->buffer_map) * sizeof(GLfloat);
+   if (aligned_vertex_buffer_offset(node)) {
+  /* The vertex size is an exact multiple of the buffer offset.
+   * This means that we can use zero-based vertex attribute pointers
+   * and specify the start of the primitive with the _mesa_prim::start
+   * field.  This results in issuing several draw calls with identical
+   * vertex attribute information.  This can result in fewer state
+   * changes in drivers.  In particular, the Gallium CSO module will
+   * filter out redundant vertex buffer changes.
+   */
+  offset = 0;
+   } else {
+  offset = node->buffer_offset;
+   }
+   for (i = 0; i < VBO_ATTRIB_MAX; ++i) {
+  node->offsets[i] = offset;
+  offset += node->attrsz[i] * sizeof(GLfloat);
+   }
node->vertex_count = save->vert_count;
node->wrap_count = save->copied.nr;
node->dangling_attr_ref = save->dangling_attr_ref;
diff --git a/src/mesa/vbo/vbo_save_draw.c b/src/mesa/vbo/vbo_save_draw.c
index cf824c66b0..486247f744 100644
--- a/src/mesa/vbo/vbo_save_draw.c
+++ b/src/mesa/vbo/vbo_save_draw.c
@@ -26,6 +26,7 @@
  *Keith Whitwell 
  */
 
+#include 
 #include "main/glheader.h"
 #include "main/bufferobj.h"
 #include "main/context.h"
@@ -137,29 +138,10 @@ bind_vertex_list(struct gl_context *ctx,
struct vbo_context *vbo = vbo_context(ctx);
struct vbo_save_context *save = >save;
struct gl_vertex_array *arrays = save->arrays;
-   GLuint buffer_offset = node->buffer_offset;
const GLubyte *map;
GLuint attr;
-   GLubyte node_attrsz[VBO_ATTRIB_MAX];  /* copy of node->attrsz[] */
-   GLenum16 node_attrtype[VBO_ATTRIB_MAX];  /* copy of node->attrtype[] */
GLbitfield varying_inputs = 0x0;
-
-   STATIC_ASSERT(sizeof(node_attrsz) == sizeof(node->attrsz));
-   memcpy(node_attrsz, node->attrsz, sizeof(node->attrsz));
-   STATIC_ASSERT(sizeof(node_attrtype) == sizeof(node->attrtype));
-   memcpy(node_attrtype, node->attrtype, sizeof(node->attrtype));
-
-   if (aligned_vertex_buffer_offset(node)) {
-  /* The vertex size is an exact multiple of the buffer offset.
-   * This means that we can use zero-based vertex attribute pointers
-   * and specify the start of the primitive with the _mesa_prim::start
-   * field.  This results in issuing several draw calls with identical
-   * vertex attribute information.  This can result in fewer state
-   * changes in drivers.  In particular, the Gallium CSO module will
-   * filter out redundant vertex buffer changes.
-   */
-  buffer_offset = 0;
-   }
+   bool generic_from_pos = false;
 
/* 

Mesa (master): mesa: Put materials at the end of the generic block.

2018-02-01 Thread Mathias Fröhlich
Module: Mesa
Branch: master
Commit: 186f03cfb021223f0a6f238da036517fbf240d26
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=186f03cfb021223f0a6f238da036517fbf240d26

Author: Mathias Fröhlich 
Date:   Sat Jan 27 16:07:22 2018 +0100

mesa: Put materials at the end of the generic block.

The materials are now moved to the end of the
generic attributes block to the range 4-15.

Before, the way the position and generic 0 attribute
is handled was dependent on the presence and kind of
the currently attached vertex program. With this
change the way the position attribute and the generic 0
attribute is treated only depends on the enabled
flag of those two arrays.
This will later help to untangle the update dependencies
between enabled arrays and shader inputs.

v2: s,VERT_ATTRIB_MAT_OFFSET,VERT_ATTRIB_MAT0,g

Signed-off-by: Mathias Fröhlich 
Reviewed-by: Brian Paul 

---

 src/compiler/shader_enums.h   |  7 ++-
 src/mesa/tnl/t_context.h  |  4 ++--
 src/mesa/vbo/vbo_exec_array.c | 14 +++---
 src/mesa/vbo/vbo_exec_draw.c  | 10 +-
 src/mesa/vbo/vbo_save_draw.c  |  8 
 5 files changed, 24 insertions(+), 19 deletions(-)

diff --git a/src/compiler/shader_enums.h b/src/compiler/shader_enums.h
index aa296adb5a..fb78ad384c 100644
--- a/src/compiler/shader_enums.h
+++ b/src/compiler/shader_enums.h
@@ -127,6 +127,8 @@ const char *gl_vert_attrib_name(gl_vert_attrib attrib);
  * VERT_ATTRIB_MAT
  *   include the generic shader attributes used to alias
  *   varying material values for the TNL shader programs.
+ *   They are located at the end of the generic attribute
+ *   block not to overlap with the generic 0 attribute.
  */
 #define VERT_ATTRIB_FF(i)   (VERT_ATTRIB_POS + (i))
 #define VERT_ATTRIB_FF_MAX  VERT_ATTRIB_GENERIC0
@@ -137,7 +139,10 @@ const char *gl_vert_attrib_name(gl_vert_attrib attrib);
 #define VERT_ATTRIB_GENERIC(i)  (VERT_ATTRIB_GENERIC0 + (i))
 #define VERT_ATTRIB_GENERIC_MAX MAX_VERTEX_GENERIC_ATTRIBS
 
-#define VERT_ATTRIB_MAT(i)  VERT_ATTRIB_GENERIC(i)
+#define VERT_ATTRIB_MAT0\
+   (VERT_ATTRIB_GENERIC_MAX - VERT_ATTRIB_MAT_MAX)
+#define VERT_ATTRIB_MAT(i)  \
+   VERT_ATTRIB_GENERIC((i) + VERT_ATTRIB_MAT0)
 #define VERT_ATTRIB_MAT_MAX MAT_ATTRIB_MAX
 
 /**
diff --git a/src/mesa/tnl/t_context.h b/src/mesa/tnl/t_context.h
index 48d7ced791..082110c607 100644
--- a/src/mesa/tnl/t_context.h
+++ b/src/mesa/tnl/t_context.h
@@ -158,8 +158,8 @@ enum {
 #define _TNL_FIRST_GENERIC _TNL_ATTRIB_GENERIC0
 #define _TNL_LAST_GENERIC  _TNL_ATTRIB_GENERIC15
 
-#define _TNL_FIRST_MAT   _TNL_ATTRIB_MAT_FRONT_AMBIENT /* GENERIC0 */
-#define _TNL_LAST_MAT_TNL_ATTRIB_MAT_BACK_INDEXES  /* GENERIC11 */
+#define _TNL_FIRST_MAT   _TNL_ATTRIB_MAT_FRONT_AMBIENT /* GENERIC4 */
+#define _TNL_LAST_MAT_TNL_ATTRIB_MAT_BACK_INDEXES  /* GENERIC15 */
 
 /* Number of available texture attributes */
 #define _TNL_NUM_TEX 8
diff --git a/src/mesa/vbo/vbo_exec_array.c b/src/mesa/vbo/vbo_exec_array.c
index d1f4da0c0e..98eb6466ba 100644
--- a/src/mesa/vbo/vbo_exec_array.c
+++ b/src/mesa/vbo/vbo_exec_array.c
@@ -335,20 +335,20 @@ recalculate_input_bindings(struct gl_context *ctx)
  }
   }
 
-  for (i = 0; i < VERT_ATTRIB_MAT_MAX; i++) {
- inputs[VERT_ATTRIB_MAT(i)] =
->currval[VBO_ATTRIB_MAT_FRONT_AMBIENT + i];
- const_inputs |= VERT_BIT_MAT(i);
-  }
-
   /* Could use just about anything, just to fill in the empty
* slots:
*/
-  for (i = VERT_ATTRIB_MAT_MAX; i < VERT_ATTRIB_GENERIC_MAX; i++) {
+  for (i = 0; i < VERT_ATTRIB_MAT0; i++) {
  inputs[VERT_ATTRIB_GENERIC(i)] =
 >currval[VBO_ATTRIB_GENERIC0 + i];
  const_inputs |= VERT_BIT_GENERIC(i);
   }
+
+  for (i = 0; i < VERT_ATTRIB_MAT_MAX; i++) {
+ inputs[VERT_ATTRIB_MAT(i)] =
+>currval[VBO_ATTRIB_MAT_FRONT_AMBIENT + i];
+ const_inputs |= VERT_BIT_MAT(i);
+  }
   break;
 
case VP_SHADER:
diff --git a/src/mesa/vbo/vbo_exec_draw.c b/src/mesa/vbo/vbo_exec_draw.c
index 2b7784694f..bd82825b51 100644
--- a/src/mesa/vbo/vbo_exec_draw.c
+++ b/src/mesa/vbo/vbo_exec_draw.c
@@ -187,16 +187,16 @@ vbo_exec_bind_arrays(struct gl_context *ctx)
/* Overlay other active attributes */
switch (get_vp_mode(exec->ctx)) {
case VP_FF:
+  for (attr = 0; attr < VERT_ATTRIB_MAT0; attr++) {
+ assert(VERT_ATTRIB_GENERIC(attr) < ARRAY_SIZE(exec->vtx.inputs));
+ exec->vtx.inputs[VERT_ATTRIB_GENERIC(attr)] =
+>currval[VBO_ATTRIB_GENERIC0+attr];
+  }
   for (attr = 0; attr < VERT_ATTRIB_MAT_MAX; attr++) {
  assert(VERT_ATTRIB_MAT(attr) < ARRAY_SIZE(exec->vtx.inputs));
  exec->vtx.inputs[VERT_ATTRIB_MAT(attr)] =
 >currval[VBO_ATTRIB_MAT_FRONT_AMBIENT+attr];
   }
-  for (attr = VERT_ATTRIB_MAT_MAX; 

Mesa (master): mesa: Track position/generic0 aliasing in the VAO.

2018-02-01 Thread Mathias Fröhlich
Module: Mesa
Branch: master
Commit: b4fd63015ac7fd73e0147ff078caec47be729e87
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=b4fd63015ac7fd73e0147ff078caec47be729e87

Author: Mathias Fröhlich 
Date:   Sat Jan 27 16:07:22 2018 +0100

mesa: Track position/generic0 aliasing in the VAO.

Since the first material attribute no longer aliases with
the generic0 attribute, only aliasing between generic0 and
position is left and entirely dependent on the enabled
state of the VAO. So introduce a gl_attribute_map_mode
in the VAO that is used to track how the position
and the generic 0 attribute alias.
Provide a static const array that can be used to
map from vertex program input indices to VERT_ATTRIB_*
indices. The outer dimension of the array is meant to
be indexed directly by the new VAO member variable.
Also provide methods on the VAO to convert bitmasks of
VERT_BIT's from the VAO numbering to the vertex processing
inputs numbering.

v2: s,unsigned char,GLubyte,g
s,_ATTRIBUTE_MAP_MODE_MAX,ATTRIBUTE_MAP_MODE_MAX,g
Change comment style, add comments.

Signed-off-by: Mathias Fröhlich 
Reviewed-by: Brian Paul 

---

 src/mesa/main/arrayobj.c | 131 +++
 src/mesa/main/arrayobj.h |  74 ++
 src/mesa/main/enable.c   |   5 ++
 src/mesa/main/mtypes.h   |  18 +++
 src/mesa/main/varray.c   |  18 +--
 5 files changed, 242 insertions(+), 4 deletions(-)

diff --git a/src/mesa/main/arrayobj.c b/src/mesa/main/arrayobj.c
index 7208f4c534..360d097ec1 100644
--- a/src/mesa/main/arrayobj.c
+++ b/src/mesa/main/arrayobj.c
@@ -54,6 +54,135 @@
 #include "util/bitscan.h"
 
 
+const GLubyte
+_mesa_vao_attribute_map[ATTRIBUTE_MAP_MODE_MAX][VERT_ATTRIB_MAX] =
+{
+   /* ATTRIBUTE_MAP_MODE_IDENTITY
+*
+* Grab vertex processing attribute VERT_ATTRIB_POS from
+* the VAO attribute VERT_ATTRIB_POS, and grab vertex processing
+* attribute VERT_ATTRIB_GENERIC0 from the VAO attribute
+* VERT_ATTRIB_GENERIC0.
+*/
+   {
+  VERT_ATTRIB_POS, /* VERT_ATTRIB_POS */
+  VERT_ATTRIB_NORMAL,  /* VERT_ATTRIB_NORMAL */
+  VERT_ATTRIB_COLOR0,  /* VERT_ATTRIB_COLOR0 */
+  VERT_ATTRIB_COLOR1,  /* VERT_ATTRIB_COLOR1 */
+  VERT_ATTRIB_FOG, /* VERT_ATTRIB_FOG */
+  VERT_ATTRIB_COLOR_INDEX, /* VERT_ATTRIB_COLOR_INDEX */
+  VERT_ATTRIB_EDGEFLAG,/* VERT_ATTRIB_EDGEFLAG */
+  VERT_ATTRIB_TEX0,/* VERT_ATTRIB_TEX0 */
+  VERT_ATTRIB_TEX1,/* VERT_ATTRIB_TEX1 */
+  VERT_ATTRIB_TEX2,/* VERT_ATTRIB_TEX2 */
+  VERT_ATTRIB_TEX3,/* VERT_ATTRIB_TEX3 */
+  VERT_ATTRIB_TEX4,/* VERT_ATTRIB_TEX4 */
+  VERT_ATTRIB_TEX5,/* VERT_ATTRIB_TEX5 */
+  VERT_ATTRIB_TEX6,/* VERT_ATTRIB_TEX6 */
+  VERT_ATTRIB_TEX7,/* VERT_ATTRIB_TEX7 */
+  VERT_ATTRIB_POINT_SIZE,  /* VERT_ATTRIB_POINT_SIZE */
+  VERT_ATTRIB_GENERIC0,/* VERT_ATTRIB_GENERIC0 */
+  VERT_ATTRIB_GENERIC1,/* VERT_ATTRIB_GENERIC1 */
+  VERT_ATTRIB_GENERIC2,/* VERT_ATTRIB_GENERIC2 */
+  VERT_ATTRIB_GENERIC3,/* VERT_ATTRIB_GENERIC3 */
+  VERT_ATTRIB_GENERIC4,/* VERT_ATTRIB_GENERIC4 */
+  VERT_ATTRIB_GENERIC5,/* VERT_ATTRIB_GENERIC5 */
+  VERT_ATTRIB_GENERIC6,/* VERT_ATTRIB_GENERIC6 */
+  VERT_ATTRIB_GENERIC7,/* VERT_ATTRIB_GENERIC7 */
+  VERT_ATTRIB_GENERIC8,/* VERT_ATTRIB_GENERIC8 */
+  VERT_ATTRIB_GENERIC9,/* VERT_ATTRIB_GENERIC9 */
+  VERT_ATTRIB_GENERIC10,   /* VERT_ATTRIB_GENERIC10 */
+  VERT_ATTRIB_GENERIC11,   /* VERT_ATTRIB_GENERIC11 */
+  VERT_ATTRIB_GENERIC12,   /* VERT_ATTRIB_GENERIC12 */
+  VERT_ATTRIB_GENERIC13,   /* VERT_ATTRIB_GENERIC13 */
+  VERT_ATTRIB_GENERIC14,   /* VERT_ATTRIB_GENERIC14 */
+  VERT_ATTRIB_GENERIC15/* VERT_ATTRIB_GENERIC15 */
+   },
+
+   /* ATTRIBUTE_MAP_MODE_POSITION
+*
+* Grab vertex processing attribute VERT_ATTRIB_POS as well as
+* vertex processing attribute VERT_ATTRIB_GENERIC0 from the
+* VAO attribute VERT_ATTRIB_POS.
+*/
+   {
+  VERT_ATTRIB_POS, /* VERT_ATTRIB_POS */
+  VERT_ATTRIB_NORMAL,  /* VERT_ATTRIB_NORMAL */
+  VERT_ATTRIB_COLOR0,  /* VERT_ATTRIB_COLOR0 */
+  VERT_ATTRIB_COLOR1,  /* VERT_ATTRIB_COLOR1 */
+  VERT_ATTRIB_FOG, /* VERT_ATTRIB_FOG */
+  VERT_ATTRIB_COLOR_INDEX, /* VERT_ATTRIB_COLOR_INDEX */
+  VERT_ATTRIB_EDGEFLAG,/* VERT_ATTRIB_EDGEFLAG */
+  VERT_ATTRIB_TEX0,/* VERT_ATTRIB_TEX0 */
+  VERT_ATTRIB_TEX1,/* 

Mesa (master): vbo: Simplify input array distribution for array type draws.

2018-02-01 Thread Mathias Fröhlich
Module: Mesa
Branch: master
Commit: 44b1454b968deb5ee0a5ecaf8cd06ed6bf11989a
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=44b1454b968deb5ee0a5ecaf8cd06ed6bf11989a

Author: Mathias Fröhlich 
Date:   Sat Jan 27 16:07:22 2018 +0100

vbo: Simplify input array distribution for array type draws.

Using the newly introduced VAO state variable, we can
simplify recalculate_input_bindings.

Signed-off-by: Mathias Fröhlich 
Reviewed-by: Brian Paul 

---

 src/mesa/vbo/vbo_exec_array.c | 110 +++---
 1 file changed, 27 insertions(+), 83 deletions(-)

diff --git a/src/mesa/vbo/vbo_exec_array.c b/src/mesa/vbo/vbo_exec_array.c
index ee4b7b56b6..42759d5897 100644
--- a/src/mesa/vbo/vbo_exec_array.c
+++ b/src/mesa/vbo/vbo_exec_array.c
@@ -313,43 +313,25 @@ recalculate_input_bindings(struct gl_context *ctx)
 {
struct vbo_context *vbo = vbo_context(ctx);
struct vbo_exec_context *exec = >exec;
-   const struct gl_array_attributes *array = ctx->Array.VAO->VertexAttrib;
-   struct gl_vertex_array *vertexAttrib = ctx->Array.VAO->_VertexAttrib;
+   const struct gl_vertex_array_object *vao = ctx->Array.VAO;
+   const struct gl_vertex_array *vertexAttrib = vao->_VertexAttrib;
const struct gl_vertex_array **inputs = >array.inputs[0];
-   GLbitfield const_inputs = 0x0;
-   GLuint i;
+
+   /* May shuffle the position and generic0 bits around */
+   GLbitfield vp_inputs = _mesa_get_vao_vp_inputs(vao);
 
const enum vp_mode program_mode = get_vp_mode(ctx);
+   const GLubyte *const map = _vbo_attribute_alias_map[program_mode];
switch (program_mode) {
case VP_FF:
   /* When no vertex program is active (or the vertex program is generated
* from fixed-function state).  We put the material values into the
-   * generic slots.  This is the only situation where material values
-   * are available as per-vertex attributes.
+   * generic slots.  Since the vao has no material arrays, mute these
+   * slots from the enabled arrays so that the current material values
+   * are pulled instead of the vao arrays.
*/
-  for (i = 0; i < VERT_ATTRIB_FF_MAX; i++) {
- if (array[VERT_ATTRIB_FF(i)].Enabled)
-inputs[i] = [VERT_ATTRIB_FF(i)];
- else {
-inputs[i] = >currval[VBO_ATTRIB_POS + i];
-const_inputs |= VERT_BIT_FF(i);
- }
-  }
-
-  /* Could use just about anything, just to fill in the empty
-   * slots:
-   */
-  for (i = 0; i < VERT_ATTRIB_MAT0; i++) {
- inputs[VERT_ATTRIB_GENERIC(i)] =
->currval[VBO_ATTRIB_GENERIC0 + i];
- const_inputs |= VERT_BIT_GENERIC(i);
-  }
+  vp_inputs &= VERT_BIT_FF_ALL;
 
-  for (i = 0; i < VERT_ATTRIB_MAT_MAX; i++) {
- inputs[VERT_ATTRIB_MAT(i)] =
->currval[VBO_ATTRIB_MAT_FRONT_AMBIENT + i];
- const_inputs |= VERT_BIT_MAT(i);
-  }
   break;
 
case VP_SHADER:
@@ -368,68 +350,30 @@ recalculate_input_bindings(struct gl_context *ctx)
* In all other APIs, only the generic attributes exist, and none of the
* slots are considered "magic."
*/
-  if (ctx->API == API_OPENGL_COMPAT) {
- if (array[VERT_ATTRIB_GENERIC0].Enabled)
-inputs[VERT_ATTRIB_POS] = [VERT_ATTRIB_GENERIC0];
- else if (array[VERT_ATTRIB_POS].Enabled)
-inputs[VERT_ATTRIB_POS] = [VERT_ATTRIB_POS];
- else {
-inputs[VERT_ATTRIB_POS] = >currval[VBO_ATTRIB_GENERIC0];
-const_inputs |= VERT_BIT_POS;
- }
-
- for (i = 1; i < VERT_ATTRIB_FF_MAX; i++) {
-if (array[VERT_ATTRIB_FF(i)].Enabled)
-   inputs[i] = [VERT_ATTRIB_FF(i)];
-else {
-   inputs[i] = >currval[VBO_ATTRIB_POS + i];
-   const_inputs |= VERT_BIT_FF(i);
-}
- }
-
- for (i = 1; i < VERT_ATTRIB_GENERIC_MAX; i++) {
-if (array[VERT_ATTRIB_GENERIC(i)].Enabled)
-   inputs[VERT_ATTRIB_GENERIC(i)] =
-  [VERT_ATTRIB_GENERIC(i)];
-else {
-   inputs[VERT_ATTRIB_GENERIC(i)] =
-  >currval[VBO_ATTRIB_GENERIC0 + i];
-   const_inputs |= VERT_BIT_GENERIC(i);
-}
- }
-
- inputs[VERT_ATTRIB_GENERIC0] = inputs[0];
-  } else {
- /* Other parts of the code assume that inputs[0] through
-  * inputs[VERT_ATTRIB_FF_MAX] will be non-NULL.  However, in OpenGL
-  * ES 2.0+ or OpenGL core profile, none of these arrays should ever
-  * be enabled.
-  */
- for (i = 0; i < VERT_ATTRIB_FF_MAX; i++) {
-assert(!array[VERT_ATTRIB_FF(i)].Enabled);
-
-inputs[i] = >currval[VBO_ATTRIB_POS + i];
-const_inputs |= VERT_BIT_FF(i);
- }
 
- for (i = 0; i < VERT_ATTRIB_GENERIC_MAX; i++) {
-

Mesa (master): gallivm/llvmpipe: add const qualifiers on sampler variables

2018-02-01 Thread Brian Paul
Module: Mesa
Branch: master
Commit: 7a044ef68b84ab850a2299462e03aedf94a3db02
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=7a044ef68b84ab850a2299462e03aedf94a3db02

Author: Brian Paul 
Date:   Thu Feb  1 13:17:08 2018 -0700

gallivm/llvmpipe: add const qualifiers on sampler variables

Once a lp_build_sampler_soa or lp_build_sampler_aos object is created,
it should never be modified.  Found by inspection.

Reviewed-by: Roland Scheidegger 

---

 src/gallium/auxiliary/draw/draw_llvm.c  | 2 +-
 src/gallium/auxiliary/gallivm/lp_bld_tgsi.h | 8 
 src/gallium/auxiliary/gallivm/lp_bld_tgsi_aos.c | 2 +-
 src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c | 2 +-
 src/gallium/drivers/llvmpipe/lp_state_fs.c  | 2 +-
 5 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/src/gallium/auxiliary/draw/draw_llvm.c 
b/src/gallium/auxiliary/draw/draw_llvm.c
index 8de29ea1fd..69c1080375 100644
--- a/src/gallium/auxiliary/draw/draw_llvm.c
+++ b/src/gallium/auxiliary/draw/draw_llvm.c
@@ -606,7 +606,7 @@ generate_vs(struct draw_llvm_variant *variant,
 const LLVMValueRef (*inputs)[TGSI_NUM_CHANNELS],
 const struct lp_bld_tgsi_system_values *system_values,
 LLVMValueRef context_ptr,
-struct lp_build_sampler_soa *draw_sampler,
+const struct lp_build_sampler_soa *draw_sampler,
 boolean clamp_vertex_color)
 {
struct draw_llvm *llvm = variant->llvm;
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h 
b/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h
index a50781..309ece88df 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h
+++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h
@@ -201,7 +201,7 @@ struct lp_build_sampler_soa
 struct lp_build_sampler_aos
 {
LLVMValueRef
-   (*emit_fetch_texel)( struct lp_build_sampler_aos *sampler,
+   (*emit_fetch_texel)( const struct lp_build_sampler_aos *sampler,
 struct lp_build_context *bld,
 unsigned target, /* TGSI_TEXTURE_* */
 unsigned unit,
@@ -228,7 +228,7 @@ lp_build_tgsi_soa(struct gallivm_state *gallivm,
   LLVMValueRef (*outputs)[4],
   LLVMValueRef context_ptr,
   LLVMValueRef thread_data_ptr,
-  struct lp_build_sampler_soa *sampler,
+  const struct lp_build_sampler_soa *sampler,
   const struct tgsi_shader_info *info,
   const struct lp_build_tgsi_gs_iface *gs_iface);
 
@@ -241,7 +241,7 @@ lp_build_tgsi_aos(struct gallivm_state *gallivm,
   LLVMValueRef consts_ptr,
   const LLVMValueRef *inputs,
   LLVMValueRef *outputs,
-  struct lp_build_sampler_aos *sampler,
+  const struct lp_build_sampler_aos *sampler,
   const struct tgsi_shader_info *info);
 
 
@@ -545,7 +545,7 @@ struct lp_build_tgsi_aos_context
const LLVMValueRef *inputs;
LLVMValueRef *outputs;
 
-   struct lp_build_sampler_aos *sampler;
+   const struct lp_build_sampler_aos *sampler;
 
struct tgsi_declaration_sampler_view sv[PIPE_MAX_SHADER_SAMPLER_VIEWS];
 
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_aos.c 
b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_aos.c
index 2529c6a8bf..85b2e8a207 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_aos.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_aos.c
@@ -862,7 +862,7 @@ lp_build_tgsi_aos(struct gallivm_state *gallivm,
   LLVMValueRef consts_ptr,
   const LLVMValueRef *inputs,
   LLVMValueRef *outputs,
-  struct lp_build_sampler_aos *sampler,
+  const struct lp_build_sampler_aos *sampler,
   const struct tgsi_shader_info *info)
 {
struct lp_build_tgsi_aos_context bld;
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c 
b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c
index 97efc3a399..fad74c6801 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c
@@ -3780,7 +3780,7 @@ lp_build_tgsi_soa(struct gallivm_state *gallivm,
   LLVMValueRef (*outputs)[TGSI_NUM_CHANNELS],
   LLVMValueRef context_ptr,
   LLVMValueRef thread_data_ptr,
-  struct lp_build_sampler_soa *sampler,
+  const struct lp_build_sampler_soa *sampler,
   const struct tgsi_shader_info *info,
   const struct lp_build_tgsi_gs_iface *gs_iface)
 {
diff --git a/src/gallium/drivers/llvmpipe/lp_state_fs.c 
b/src/gallium/drivers/llvmpipe/lp_state_fs.c
index 0daf7aecf6..603fd84f6b 100644
--- a/src/gallium/drivers/llvmpipe/lp_state_fs.c
+++ b/src/gallium/drivers/llvmpipe/lp_state_fs.c
@@ -299,7 +299,7 @@ generate_fs_loop(struct gallivm_state *gallivm,
  LLVMValueRef 

Mesa (master): vbo: s/drawcount/drawcount_offset

2018-02-01 Thread Brian Paul
Module: Mesa
Branch: master
Commit: c7bf05c833e488b3c8b598221910d52abdd8762f
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=c7bf05c833e488b3c8b598221910d52abdd8762f

Author: Brian Paul 
Date:   Wed Jan 31 16:11:12 2018 -0700

vbo: s/drawcount/drawcount_offset

This parameter (from the glMultiDrawArraysIndirectCountARB function)
is poorly named.  It's an offset into the buffer which contains the
number of primitives to draw.

Reviewed-by: Marek Olšák 
Reviewed-by: Mathias Fröhlich 

---

 src/mesa/vbo/vbo_exec_array.c | 28 
 1 file changed, 16 insertions(+), 12 deletions(-)

diff --git a/src/mesa/vbo/vbo_exec_array.c b/src/mesa/vbo/vbo_exec_array.c
index 1d2f806cd5..fc0d489065 100644
--- a/src/mesa/vbo/vbo_exec_array.c
+++ b/src/mesa/vbo/vbo_exec_array.c
@@ -1803,7 +1803,7 @@ static void
 vbo_validated_multidrawarraysindirectcount(struct gl_context *ctx,
GLenum mode,
GLintptr indirect,
-   GLintptr drawcount,
+   GLintptr drawcount_offset,
GLsizei maxdrawcount,
GLsizei stride)
 {
@@ -1818,7 +1818,7 @@ vbo_validated_multidrawarraysindirectcount(struct 
gl_context *ctx,
vbo->draw_indirect_prims(ctx, mode,
 ctx->DrawIndirectBuffer, offset,
 maxdrawcount, stride,
-ctx->ParameterBuffer, drawcount, NULL);
+ctx->ParameterBuffer, drawcount_offset, NULL);
 
if (MESA_DEBUG_FLAGS & DEBUG_ALWAYS_FLUSH)
   _mesa_flush(ctx);
@@ -1829,7 +1829,7 @@ static void
 vbo_validated_multidrawelementsindirectcount(struct gl_context *ctx,
  GLenum mode, GLenum type,
  GLintptr indirect,
- GLintptr drawcount,
+ GLintptr drawcount_offset,
  GLsizei maxdrawcount,
  GLsizei stride)
 {
@@ -1852,7 +1852,7 @@ vbo_validated_multidrawelementsindirectcount(struct 
gl_context *ctx,
vbo->draw_indirect_prims(ctx, mode,
 ctx->DrawIndirectBuffer, offset,
 maxdrawcount, stride,
-ctx->ParameterBuffer, drawcount, );
+ctx->ParameterBuffer, drawcount_offset, );
 
if (MESA_DEBUG_FLAGS & DEBUG_ALWAYS_FLUSH)
   _mesa_flush(ctx);
@@ -1861,7 +1861,7 @@ vbo_validated_multidrawelementsindirectcount(struct 
gl_context *ctx,
 
 static void GLAPIENTRY
 vbo_exec_MultiDrawArraysIndirectCount(GLenum mode, GLintptr indirect,
-  GLintptr drawcount,
+  GLintptr drawcount_offset,
   GLsizei maxdrawcount, GLsizei stride)
 {
GET_CURRENT_CONTEXT(ctx);
@@ -1870,7 +1870,7 @@ vbo_exec_MultiDrawArraysIndirectCount(GLenum mode, 
GLintptr indirect,
   _mesa_debug(ctx, "glMultiDrawArraysIndirectCountARB"
   "(%s, %lx, %lx, %i, %i)\n",
   _mesa_enum_to_string(mode),
-  (unsigned long) indirect, (unsigned long) drawcount,
+  (unsigned long) indirect, (unsigned long) drawcount_offset,
   maxdrawcount, stride);
 
/* If  is zero, the array elements are treated as tightly packed. */
@@ -1884,7 +1884,8 @@ vbo_exec_MultiDrawArraysIndirectCount(GLenum mode, 
GLintptr indirect,
  _mesa_update_state(ctx);
} else {
   if (!_mesa_validate_MultiDrawArraysIndirectCount(ctx, mode,
-   indirect, drawcount,
+   indirect,
+   drawcount_offset,
maxdrawcount, stride))
  return;
}
@@ -1892,14 +1893,16 @@ vbo_exec_MultiDrawArraysIndirectCount(GLenum mode, 
GLintptr indirect,
if (skip_validated_draw(ctx))
   return;
 
-   vbo_validated_multidrawarraysindirectcount(ctx, mode, indirect, drawcount,
+   vbo_validated_multidrawarraysindirectcount(ctx, mode, indirect,
+  drawcount_offset,
   maxdrawcount, stride);
 }
 
 
 static void GLAPIENTRY
 vbo_exec_MultiDrawElementsIndirectCount(GLenum mode, GLenum type,
-GLintptr indirect, GLintptr drawcount,
+GLintptr indirect,
+GLintptr drawcount_offset,

Mesa (master): svga: clean up retry_draw_range_elements(), retry_draw_arrays()

2018-02-01 Thread Brian Paul
Module: Mesa
Branch: master
Commit: 7a1401938b3514a95ffbdb2ec70987138ccabc3a
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=7a1401938b3514a95ffbdb2ec70987138ccabc3a

Author: Brian Paul 
Date:   Wed Jan 31 20:18:52 2018 -0700

svga: clean up retry_draw_range_elements(), retry_draw_arrays()

Get rid of a bunch of goto spaghetti.  Remove unneeded do_retry parameter.
No Piglit changes.  Also tested w/ Google Earth and other apps.

Reviewed-by: Neha Bhende 

---

 src/gallium/drivers/svga/svga_pipe_draw.c | 81 +++
 1 file changed, 27 insertions(+), 54 deletions(-)

diff --git a/src/gallium/drivers/svga/svga_pipe_draw.c 
b/src/gallium/drivers/svga/svga_pipe_draw.c
index 5fa562b08e..42525c3153 100644
--- a/src/gallium/drivers/svga/svga_pipe_draw.c
+++ b/src/gallium/drivers/svga/svga_pipe_draw.c
@@ -65,19 +65,14 @@ retry_draw_range_elements( struct svga_context *svga,
unsigned start,
unsigned count,
unsigned start_instance,
-   unsigned instance_count,
-   boolean do_retry )
+   unsigned instance_count)
 {
-   enum pipe_error ret = PIPE_OK;
+   enum pipe_error ret;
 
SVGA_STATS_TIME_PUSH(svga_sws(svga), SVGA_STATS_TIME_DRAWELEMENTS);
 
svga_hwtnl_set_fillmode(svga->hwtnl, svga->curr.rast->hw_fillmode);
 
-   ret = svga_update_state( svga, SVGA_STATE_HW_DRAW );
-   if (ret != PIPE_OK)
-  goto retry;
-
/** determine if flatshade is to be used after svga_update_state()
 *  in case the fragment shader is changed.
 */
@@ -86,29 +81,21 @@ retry_draw_range_elements( struct svga_context *svga,
 is_using_flat_shading(svga),
 svga->curr.rast->templ.flatshade_first);
 
-   ret = svga_hwtnl_draw_range_elements( svga->hwtnl,
- index_buffer, index_size, index_bias,
- min_index, max_index,
- prim, start, count,
- start_instance, instance_count);
-   if (ret != PIPE_OK)
-  goto retry;
-
-   goto done;
-
-retry:
-   svga_context_flush( svga, NULL );
-
-   if (do_retry)
-   {
-  ret = retry_draw_range_elements(svga,
-  index_buffer, index_size, index_bias,
-  min_index, max_index,
-  prim, start, count,
-  start_instance, instance_count, FALSE);
+   for (unsigned try = 0; try < 2; try++) {
+  ret = svga_update_state(svga, SVGA_STATE_HW_DRAW);
+  if (ret == PIPE_OK) {
+ ret = svga_hwtnl_draw_range_elements(svga->hwtnl,
+  index_buffer, index_size,
+  index_bias,
+  min_index, max_index,
+  prim, start, count,
+  start_instance, instance_count);
+ if (ret == PIPE_OK)
+break;
+  }
+  svga_context_flush(svga, NULL);
}
 
-done:
SVGA_STATS_TIME_POP(svga_sws(svga));
return ret;
 }
@@ -117,8 +104,7 @@ done:
 static enum pipe_error
 retry_draw_arrays( struct svga_context *svga,
enum pipe_prim_type prim, unsigned start, unsigned count,
-   unsigned start_instance, unsigned instance_count,
-   boolean do_retry )
+   unsigned start_instance, unsigned instance_count)
 {
enum pipe_error ret;
 
@@ -126,10 +112,6 @@ retry_draw_arrays( struct svga_context *svga,
 
svga_hwtnl_set_fillmode(svga->hwtnl, svga->curr.rast->hw_fillmode);
 
-   ret = svga_update_state( svga, SVGA_STATE_HW_DRAW );
-   if (ret != PIPE_OK)
-  goto retry;
-
/** determine if flatshade is to be used after svga_update_state()
 *  in case the fragment shader is changed.
 */
@@ -138,24 +120,17 @@ retry_draw_arrays( struct svga_context *svga,
 is_using_flat_shading(svga),
 svga->curr.rast->templ.flatshade_first);
 
-   ret = svga_hwtnl_draw_arrays(svga->hwtnl, prim, start, count,
-start_instance, instance_count);
-   if (ret != PIPE_OK)
-  goto retry;
-
-   goto done;
-
-retry:
-   if (ret == PIPE_ERROR_OUT_OF_MEMORY && do_retry)
-   {
-  svga_context_flush( svga, NULL );
-
-  ret = retry_draw_arrays(svga, prim, start, count,
-  start_instance, instance_count,
-  FALSE);
+   for (unsigned try = 0; try < 2; try++) {
+  ret = svga_update_state( svga, SVGA_STATE_HW_DRAW );
+  if (ret == PIPE_OK) {
+ ret = svga_hwtnl_draw_arrays(svga->hwtnl, 

Mesa (master): vbo: use vbo local var for draw call in vbo_save_playback_vertex_list()

2018-02-01 Thread Brian Paul
Module: Mesa
Branch: master
Commit: b0a2f38db9ec08b79362fb255097423ac5637eea
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=b0a2f38db9ec08b79362fb255097423ac5637eea

Author: Brian Paul 
Date:   Wed Jan 31 14:05:46 2018 -0700

vbo: use vbo local var for draw call in vbo_save_playback_vertex_list()

Reviewed-by: Marek Olšák 
Reviewed-by: Mathias Fröhlich 

---

 src/mesa/vbo/vbo_save_draw.c | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/src/mesa/vbo/vbo_save_draw.c b/src/mesa/vbo/vbo_save_draw.c
index fd0ccc1230..cf824c66b0 100644
--- a/src/mesa/vbo/vbo_save_draw.c
+++ b/src/mesa/vbo/vbo_save_draw.c
@@ -332,13 +332,13 @@ vbo_save_playback_vertex_list(struct gl_context *ctx, 
void *data)
   if (node->vertex_count > 0) {
  GLuint min_index = node->start_vertex;
  GLuint max_index = min_index + node->vertex_count - 1;
- vbo_context(ctx)->draw_prims(ctx,
-  node->prims,
-  node->prim_count,
-  NULL,
-  GL_TRUE,
-  min_index, max_index,
-  NULL, 0, NULL);
+ vbo->draw_prims(ctx,
+ node->prims,
+ node->prim_count,
+ NULL,
+ GL_TRUE,
+ min_index, max_index,
+ NULL, 0, NULL);
   }
}
 

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


Mesa (master): svga: whitespace/formatting fixes in svga_pipe_draw.c

2018-02-01 Thread Brian Paul
Module: Mesa
Branch: master
Commit: fa98730bf32501d7d7299d6c7264b06cf417e727
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=fa98730bf32501d7d7299d6c7264b06cf417e727

Author: Brian Paul 
Date:   Wed Jan 31 20:33:29 2018 -0700

svga: whitespace/formatting fixes in svga_pipe_draw.c

Reviewed-by: Neha Bhende 

---

 src/gallium/drivers/svga/svga_pipe_draw.c | 67 ---
 1 file changed, 34 insertions(+), 33 deletions(-)

diff --git a/src/gallium/drivers/svga/svga_pipe_draw.c 
b/src/gallium/drivers/svga/svga_pipe_draw.c
index 42525c3153..8cd7ab00b5 100644
--- a/src/gallium/drivers/svga/svga_pipe_draw.c
+++ b/src/gallium/drivers/svga/svga_pipe_draw.c
@@ -55,17 +55,17 @@ is_using_flat_shading(const struct svga_context *svga)
 
 
 static enum pipe_error
-retry_draw_range_elements( struct svga_context *svga,
-   struct pipe_resource *index_buffer,
-   unsigned index_size,
-   int index_bias,
-   unsigned min_index,
-   unsigned max_index,
-   enum pipe_prim_type prim,
-   unsigned start,
-   unsigned count,
-   unsigned start_instance,
-   unsigned instance_count)
+retry_draw_range_elements(struct svga_context *svga,
+  struct pipe_resource *index_buffer,
+  unsigned index_size,
+  int index_bias,
+  unsigned min_index,
+  unsigned max_index,
+  enum pipe_prim_type prim,
+  unsigned start,
+  unsigned count,
+  unsigned start_instance,
+  unsigned instance_count)
 {
enum pipe_error ret;
 
@@ -102,9 +102,9 @@ retry_draw_range_elements( struct svga_context *svga,
 
 
 static enum pipe_error
-retry_draw_arrays( struct svga_context *svga,
-   enum pipe_prim_type prim, unsigned start, unsigned count,
-   unsigned start_instance, unsigned instance_count)
+retry_draw_arrays(struct svga_context *svga,
+  enum pipe_prim_type prim, unsigned start, unsigned count,
+  unsigned start_instance, unsigned instance_count)
 {
enum pipe_error ret;
 
@@ -121,7 +121,7 @@ retry_draw_arrays( struct svga_context *svga,
 svga->curr.rast->templ.flatshade_first);
 
for (unsigned try = 0; try < 2; try++) {
-  ret = svga_update_state( svga, SVGA_STATE_HW_DRAW );
+  ret = svga_update_state(svga, SVGA_STATE_HW_DRAW);
   if (ret == PIPE_OK) {
  ret = svga_hwtnl_draw_arrays(svga->hwtnl, prim, start, count,
   start_instance, instance_count);
@@ -165,8 +165,8 @@ need_fallback_prim_restart(const struct svga_context *svga,
 static void
 svga_draw_vbo(struct pipe_context *pipe, const struct pipe_draw_info *info)
 {
-   struct svga_context *svga = svga_context( pipe );
-   enum pipe_prim_type reduced_prim = u_reduced_prim( info->mode );
+   struct svga_context *svga = svga_context(pipe);
+   enum pipe_prim_type reduced_prim = u_reduced_prim(info->mode);
unsigned count = info->count;
enum pipe_error ret = 0;
boolean needed_swtnl;
@@ -210,12 +210,12 @@ svga_draw_vbo(struct pipe_context *pipe, const struct 
pipe_draw_info *info)
   goto done;
}
 
-   if (!u_trim_pipe_prim( info->mode,  ))
+   if (!u_trim_pipe_prim(info->mode, ))
   goto done;
 
needed_swtnl = svga->state.sw.need_swtnl;
 
-   svga_update_state_retry( svga, SVGA_STATE_NEED_SWTNL );
+   svga_update_state_retry(svga, SVGA_STATE_NEED_SWTNL);
 
if (svga->state.sw.need_swtnl) {
   svga->hud.num_fallbacks++;  /* for SVGA_QUERY_NUM_FALLBACKS */
@@ -232,7 +232,7 @@ svga_draw_vbo(struct pipe_context *pipe, const struct 
pipe_draw_info *info)
   }
 
   /* Avoid leaking the previous hwtnl bias to swtnl */
-  svga_hwtnl_set_index_bias( svga->hwtnl, 0 );
+  svga_hwtnl_set_index_bias(svga->hwtnl, 0);
   ret = svga_swtnl_draw_vbo(svga, info, indexbuf, index_offset);
}
else {
@@ -242,17 +242,17 @@ svga_draw_vbo(struct pipe_context *pipe, const struct 
pipe_draw_info *info)
  assert(index_offset % info->index_size == 0);
  offset = index_offset / info->index_size;
 
- ret = retry_draw_range_elements( svga,
-  indexbuf,
-  info->index_size,
-  info->index_bias,
-  info->min_index,
-  info->max_index,
-  info->mode,
-  info->start + offset,
-  

Mesa (master): svga: remove unneeded #includes in svga_pipe_draw.c

2018-02-01 Thread Brian Paul
Module: Mesa
Branch: master
Commit: 84c36418646ae57f88e501efc23c4d7df921c197
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=84c36418646ae57f88e501efc23c4d7df921c197

Author: Brian Paul 
Date:   Wed Jan 31 20:36:35 2018 -0700

svga: remove unneeded #includes in svga_pipe_draw.c

Reviewed-by: Neha Bhende 

---

 src/gallium/drivers/svga/svga_pipe_draw.c | 7 ---
 1 file changed, 7 deletions(-)

diff --git a/src/gallium/drivers/svga/svga_pipe_draw.c 
b/src/gallium/drivers/svga/svga_pipe_draw.c
index 8cd7ab00b5..ee4a1057ad 100644
--- a/src/gallium/drivers/svga/svga_pipe_draw.c
+++ b/src/gallium/drivers/svga/svga_pipe_draw.c
@@ -24,21 +24,14 @@
  **/
 
 
-#include "util/u_format.h"
 #include "util/u_helpers.h"
 #include "util/u_inlines.h"
 #include "util/u_prim.h"
 #include "util/u_prim_restart.h"
-#include "util/u_upload_mgr.h"
-#include "indices/u_indices.h"
 
-#include "svga_hw_reg.h"
-#include "svga_cmd.h"
 #include "svga_context.h"
-#include "svga_screen.h"
 #include "svga_draw.h"
 #include "svga_shader.h"
-#include "svga_state.h"
 #include "svga_surface.h"
 #include "svga_swtnl.h"
 #include "svga_debug.h"

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


Mesa (master): svga: remove unused min/max_index params to draw_vgpu10()

2018-02-01 Thread Brian Paul
Module: Mesa
Branch: master
Commit: c7442895526a8c3e41eaf985827c66907d9e8ad6
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=c7442895526a8c3e41eaf985827c66907d9e8ad6

Author: Brian Paul 
Date:   Wed Jan 31 16:10:39 2018 -0700

svga: remove unused min/max_index params to draw_vgpu10()

Reviewed-by: Neha Bhende 

---

 src/gallium/drivers/svga/svga_draw.c | 7 +++
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/src/gallium/drivers/svga/svga_draw.c 
b/src/gallium/drivers/svga/svga_draw.c
index 5771903955..649bc228c0 100644
--- a/src/gallium/drivers/svga/svga_draw.c
+++ b/src/gallium/drivers/svga/svga_draw.c
@@ -511,8 +511,7 @@ static enum pipe_error
 draw_vgpu10(struct svga_hwtnl *hwtnl,
 const SVGA3dPrimitiveRange *range,
 unsigned vcount,
-unsigned min_index,
-unsigned max_index, struct pipe_resource *ib,
+struct pipe_resource *ib,
 unsigned start_instance, unsigned instance_count)
 {
struct svga_context *svga = hwtnl->svga;
@@ -1024,11 +1023,11 @@ svga_hwtnl_prim(struct svga_hwtnl *hwtnl,
 
if (svga_have_vgpu10(hwtnl->svga)) {
   /* draw immediately */
-  ret = draw_vgpu10(hwtnl, range, vcount, min_index, max_index, ib,
+  ret = draw_vgpu10(hwtnl, range, vcount, ib,
 start_instance, instance_count);
   if (ret != PIPE_OK) {
  svga_context_flush(hwtnl->svga, NULL);
- ret = draw_vgpu10(hwtnl, range, vcount, min_index, max_index, ib,
+ ret = draw_vgpu10(hwtnl, range, vcount, ib,
start_instance, instance_count);
  assert(ret == PIPE_OK);
   }

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


Mesa (master): vbo: change an argument in vbo_draw_indirect_prims()

2018-02-01 Thread Brian Paul
Module: Mesa
Branch: master
Commit: 1bdbeae17ce62f52b0ac19960c71078dff7a2da2
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=1bdbeae17ce62f52b0ac19960c71078dff7a2da2

Author: Brian Paul 
Date:   Wed Jan 31 16:19:07 2018 -0700

vbo: change an argument in vbo_draw_indirect_prims()

In vbo_draw_indirect_prims() pass the 'indirect_data' argument to
vbo->draw_prims().  All the callers are passing ctx->DrawIndirectBuffer
so this should be no functional change.  Add a (temporary) assertion to
be sure.

Reviewed-by: Marek Olšák 
Reviewed-by: Mathias Fröhlich 

---

 src/mesa/vbo/vbo_context.c | 17 -
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/src/mesa/vbo/vbo_context.c b/src/mesa/vbo/vbo_context.c
index f516c67843..3f55e27f9b 100644
--- a/src/mesa/vbo/vbo_context.c
+++ b/src/mesa/vbo/vbo_context.c
@@ -140,15 +140,19 @@ init_mat_currval(struct gl_context *ctx)
}
 }
 
+
+/**
+ * Fallback for when a driver does not call vbo_set_indirect_draw_func().
+ */
 static void
 vbo_draw_indirect_prims(struct gl_context *ctx,
 GLuint mode,
-struct gl_buffer_object *indirect_data,
+struct gl_buffer_object *indirect_buffer,
 GLsizeiptr indirect_offset,
 unsigned draw_count,
 unsigned stride,
-struct gl_buffer_object *indirect_params,
-GLsizeiptr indirect_params_offset,
+struct gl_buffer_object *indirect_draw_count_buffer,
+GLsizeiptr indirect_draw_count_offset,
 const struct _mesa_index_buffer *ib)
 {
struct vbo_context *vbo = vbo_context(ctx);
@@ -160,7 +164,7 @@ vbo_draw_indirect_prims(struct gl_context *ctx,
   _mesa_error(ctx, GL_OUT_OF_MEMORY, "gl%sDraw%sIndirect%s",
   (draw_count > 1) ? "Multi" : "",
   ib ? "Elements" : "Arrays",
-  indirect_params ? "CountARB" : "");
+  indirect_buffer ? "CountARB" : "");
   return;
}
 
@@ -174,10 +178,13 @@ vbo_draw_indirect_prims(struct gl_context *ctx,
   prim[i].draw_id = i;
}
 
+   /* This should always be true at this time */
+   assert(indirect_buffer == ctx->DrawIndirectBuffer);
+
vbo->draw_prims(ctx, prim, draw_count,
ib, false, 0, ~0,
NULL, 0,
-   ctx->DrawIndirectBuffer);
+   indirect_buffer);
 
free(prim);
 }

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


Mesa (master): vbo: add comments on the VBO draw function typedefs

2018-02-01 Thread Brian Paul
Module: Mesa
Branch: master
Commit: 1b7ad3ae974a8436edcbefcd5a52faa43c73ea8c
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=1b7ad3ae974a8436edcbefcd5a52faa43c73ea8c

Author: Brian Paul 
Date:   Wed Jan 31 16:15:53 2018 -0700

vbo: add comments on the VBO draw function typedefs

And rename indirect_params -> indirect_draw_count_buffer and
indirect_params_offset -> indirect_draw_count_offset to be more
specific.

Reviewed-by: Marek Olšák 
Reviewed-by: Mathias Fröhlich 

---

 src/mesa/vbo/vbo.h | 57 --
 1 file changed, 55 insertions(+), 2 deletions(-)

diff --git a/src/mesa/vbo/vbo.h b/src/mesa/vbo/vbo.h
index 164477f3ac..6ae6991cad 100644
--- a/src/mesa/vbo/vbo.h
+++ b/src/mesa/vbo/vbo.h
@@ -119,6 +119,43 @@ void
 vbo_save_EndCallList(struct gl_context *ctx);
 
 
+/**
+ * For indirect array drawing:
+ *
+ *typedef struct {
+ *   GLuint count;
+ *   GLuint primCount;
+ *   GLuint first;
+ *   GLuint baseInstance; // in GL 4.2 and later, must be zero otherwise
+ *} DrawArraysIndirectCommand;
+ *
+ * For indirect indexed drawing:
+ *
+ *typedef struct {
+ *   GLuint count;
+ *   GLuint primCount;
+ *   GLuint firstIndex;
+ *   GLint  baseVertex;
+ *   GLuint baseInstance; // in GL 4.2 and later, must be zero otherwise
+ *} DrawElementsIndirectCommand;
+ */
+
+
+/**
+ * Draw a number of primitives.
+ * \param prims  array [nr_prims] describing what to draw (prim type,
+ *   vertex count, first index, instance count, etc).
+ * \param ib  index buffer for indexed drawing, NULL for array drawing
+ * \param index_bounds_valid  are min_index and max_index valid?
+ * \param min_index  lowest vertex index used
+ * \param max_index  highest vertex index used
+ * \param tfb_vertcount  describes TFB output, or NULL
+ * \param stream  If called via DrawTransformFeedback, specifies the vertex
+ *stream buffer from which to get the vertex count
+ * \param indirect  If any prims are indirect, this specifies the buffer
+ *  to find the "DrawArrays/ElementsIndirectCommand" data.
+ *  This may be deprecated in the future
+ */
 typedef void (*vbo_draw_func)(struct gl_context *ctx,
   const struct _mesa_prim *prims,
   GLuint nr_prims,
@@ -131,6 +168,22 @@ typedef void (*vbo_draw_func)(struct gl_context *ctx,
   struct gl_buffer_object *indirect);
 
 
+/**
+ * Draw a primitive, getting the vertex count, instance count, start
+ * vertex, etc. from a buffer object.
+ * \param mode  GL_POINTS, GL_LINES, GL_TRIANGLE_STRIP, etc.
+ * \param indirect_data  buffer to get "DrawArrays/ElementsIndirectCommand" 
data
+ * \param indirect_offset  offset of first primitive in indrect_data buffer
+ * \param draw_count  number of primitives to draw
+ * \param stride  stride, in bytes, between 
"DrawArrays/ElementsIndirectCommand"
+ *objects
+ * \param indirect_draw_count_buffer  if non-NULL specifies a buffer to get the
+ *real draw_count value.  Used for
+ *GL_ARB_indirect_parameters.
+ * \param indirect_draw_count_offset  offset to the draw_count value in
+ *indirect_draw_count_buffer
+ * \param ib  index buffer for indexed drawing, NULL otherwise.
+ */
 typedef void (*vbo_indirect_draw_func)(
struct gl_context *ctx,
GLuint mode,
@@ -138,8 +191,8 @@ typedef void (*vbo_indirect_draw_func)(
GLsizeiptr indirect_offset,
unsigned draw_count,
unsigned stride,
-   struct gl_buffer_object *indirect_params,
-   GLsizeiptr indirect_params_offset,
+   struct gl_buffer_object *indirect_draw_count_buffer,
+   GLsizeiptr indirect_draw_count_offset,
const struct _mesa_index_buffer *ib);
 
 

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


Mesa (master): broadcom/vc5: Fix image_h setup for both loads and stores.

2018-02-01 Thread Eric Anholt
Module: Mesa
Branch: master
Commit: 06858c73485951c931bfec3a74d0117d26116905
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=06858c73485951c931bfec3a74d0117d26116905

Author: Eric Anholt 
Date:   Wed Jan 24 12:13:53 2018 +1100

broadcom/vc5: Fix image_h setup for both loads and stores.

The image_h for the tiling algorithm needs to be the padded-to-a-uifblock
height of the level, not the unpadded height or the height of level 0.
Fixes some cases of KHR-GLES3.texture_repeat_mode.* and
depthstencil-render-miplevels.

---

 src/gallium/drivers/vc5/vc5_resource.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/src/gallium/drivers/vc5/vc5_resource.c 
b/src/gallium/drivers/vc5/vc5_resource.c
index f37ffe928f..e2fe2826c2 100644
--- a/src/gallium/drivers/vc5/vc5_resource.c
+++ b/src/gallium/drivers/vc5/vc5_resource.c
@@ -133,8 +133,7 @@ vc5_resource_transfer_unmap(struct pipe_context *pctx,
   slice->stride,
   trans->map, ptrans->stride,
   slice->tiling, rsc->cpp,
-  u_minify(rsc->base.height0,
-   ptrans->level),
+  slice->size / slice->stride,
   >box);
 }
 free(trans->map);
@@ -265,7 +264,7 @@ vc5_resource_transfer_map(struct pipe_context *pctx,
  ptrans->box.z * 
rsc->cube_map_stride,
  slice->stride,
  slice->tiling, rsc->cpp,
- rsc->base.height0,
+ slice->size / slice->stride,
  >box);
 }
 return trans->map;

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


Mesa (master): broadcom/vc5: Fix a segfault on mix of booleans.

2018-02-01 Thread Eric Anholt
Module: Mesa
Branch: master
Commit: 353b42ccc745453dffe742d766831248f77d6e39
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=353b42ccc745453dffe742d766831248f77d6e39

Author: Eric Anholt 
Date:   Fri Jan 19 09:06:26 2018 -0800

broadcom/vc5: Fix a segfault on mix of booleans.

We don't have a src1 to look up if the compare instruction is "i2b".

---

 src/broadcom/compiler/nir_to_vir.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/broadcom/compiler/nir_to_vir.c 
b/src/broadcom/compiler/nir_to_vir.c
index 0e2e8e2daa..6bb2774143 100644
--- a/src/broadcom/compiler/nir_to_vir.c
+++ b/src/broadcom/compiler/nir_to_vir.c
@@ -528,7 +528,9 @@ ntq_emit_comparison(struct v3d_compile *c, struct qreg 
*dest,
 nir_alu_instr *sel_instr)
 {
 struct qreg src0 = ntq_get_alu_src(c, compare_instr, 0);
-struct qreg src1 = ntq_get_alu_src(c, compare_instr, 1);
+struct qreg src1;
+if (nir_op_infos[compare_instr->op].num_inputs > 1)
+src1 = ntq_get_alu_src(c, compare_instr, 1);
 bool cond_invert = false;
 
 switch (compare_instr->op) {

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


Mesa (master): broadcom/vc5: Rename the UIFCFG register in the UAPI.

2018-02-01 Thread Eric Anholt
Module: Mesa
Branch: master
Commit: 7239b3edbe754c6e85a6c3774d484e42a6253058
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=7239b3edbe754c6e85a6c3774d484e42a6253058

Author: Eric Anholt 
Date:   Sat Jan 20 15:57:08 2018 -0800

broadcom/vc5: Rename the UIFCFG register in the UAPI.

This matches the naming of the other hub regs we get, and I don't know for
sure if UIFCFG will be the same register between the hub and the cores on
all versions.

---

 src/gallium/drivers/vc5/v3dx_simulator.c | 2 +-
 src/gallium/drivers/vc5/vc5_drm.h| 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/vc5/v3dx_simulator.c 
b/src/gallium/drivers/vc5/v3dx_simulator.c
index 90fafaee1e..aed4aab204 100644
--- a/src/gallium/drivers/vc5/v3dx_simulator.c
+++ b/src/gallium/drivers/vc5/v3dx_simulator.c
@@ -103,7 +103,7 @@ v3dX(simulator_get_param_ioctl)(struct v3d_hw *v3d,
 struct drm_vc5_get_param *args)
 {
 static const uint32_t reg_map[] = {
-[DRM_VC5_PARAM_V3D_UIFCFG] = V3D_HUB_CTL_UIFCFG,
+[DRM_VC5_PARAM_V3D_HUB_UIFCFG] = V3D_HUB_CTL_UIFCFG,
 [DRM_VC5_PARAM_V3D_HUB_IDENT1] = V3D_HUB_CTL_IDENT1,
 [DRM_VC5_PARAM_V3D_HUB_IDENT2] = V3D_HUB_CTL_IDENT2,
 [DRM_VC5_PARAM_V3D_HUB_IDENT3] = V3D_HUB_CTL_IDENT3,
diff --git a/src/gallium/drivers/vc5/vc5_drm.h 
b/src/gallium/drivers/vc5/vc5_drm.h
index 2c21ee77a1..cd7e43ad47 100644
--- a/src/gallium/drivers/vc5/vc5_drm.h
+++ b/src/gallium/drivers/vc5/vc5_drm.h
@@ -172,7 +172,7 @@ struct drm_vc5_mmap_bo {
 };
 
 enum drm_vc5_param {
-DRM_VC5_PARAM_V3D_UIFCFG,
+DRM_VC5_PARAM_V3D_HUB_UIFCFG,
 DRM_VC5_PARAM_V3D_HUB_IDENT1,
 DRM_VC5_PARAM_V3D_HUB_IDENT2,
 DRM_VC5_PARAM_V3D_HUB_IDENT3,

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


Mesa (master): broadcom/vc5: Add the missing PIPE_CAP_FENCE_SIGNAL.

2018-02-01 Thread Eric Anholt
Module: Mesa
Branch: master
Commit: aec066c7aa35084ccf6391bdf96028ef6056af1e
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=aec066c7aa35084ccf6391bdf96028ef6056af1e

Author: Eric Anholt 
Date:   Wed Jan 31 17:38:22 2018 -0800

broadcom/vc5: Add the missing PIPE_CAP_FENCE_SIGNAL.

---

 src/gallium/drivers/vc5/vc5_screen.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/gallium/drivers/vc5/vc5_screen.c 
b/src/gallium/drivers/vc5/vc5_screen.c
index 2bbec37d19..b69562389b 100644
--- a/src/gallium/drivers/vc5/vc5_screen.c
+++ b/src/gallium/drivers/vc5/vc5_screen.c
@@ -249,6 +249,7 @@ vc5_screen_get_param(struct pipe_screen *pscreen, enum 
pipe_cap param)
 case PIPE_CAP_TGSI_CLOCK:
 case PIPE_CAP_TGSI_TEX_TXF_LZ:
 case PIPE_CAP_NATIVE_FENCE_FD:
+case PIPE_CAP_FENCE_SIGNAL:
 case PIPE_CAP_TGSI_MUL_ZERO_WINS:
 case PIPE_CAP_NIR_SAMPLERS_AS_DEREF:
 case PIPE_CAP_QUERY_SO_OVERFLOW:

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


Mesa (master): broadcom/vc5: Simplify separate stencil surface setup.

2018-02-01 Thread Eric Anholt
Module: Mesa
Branch: master
Commit: dea902c93352b875178fef9b8a65fd53e52696b3
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=dea902c93352b875178fef9b8a65fd53e52696b3

Author: Eric Anholt 
Date:   Sat Jan 20 16:44:53 2018 -0800

broadcom/vc5: Simplify separate stencil surface setup.

If we just make another gallium surface for the separate stencil, it's a
lot easier to keep track of which set of fields we're using in RCL setup.

This also incidentally fixes a little bug in setting up the surface's
padded height for separate stencil when the UIF-ness changes at different
levels of Z versus stencil.

---

 src/gallium/drivers/vc5/vc5_rcl.c  | 140 +++--
 src/gallium/drivers/vc5/vc5_resource.c |  28 +++
 src/gallium/drivers/vc5/vc5_resource.h |   8 +-
 3 files changed, 77 insertions(+), 99 deletions(-)

diff --git a/src/gallium/drivers/vc5/vc5_rcl.c 
b/src/gallium/drivers/vc5/vc5_rcl.c
index 8018bfdcba..86ea22628d 100644
--- a/src/gallium/drivers/vc5/vc5_rcl.c
+++ b/src/gallium/drivers/vc5/vc5_rcl.c
@@ -38,39 +38,29 @@ static void
 load_general(struct vc5_cl *cl, struct pipe_surface *psurf, int buffer)
 {
 struct vc5_surface *surf = vc5_surface(psurf);
-struct vc5_resource *rsc = vc5_resource(psurf->texture);
+bool separate_stencil = surf->separate_stencil && buffer == STENCIL;
+if (separate_stencil) {
+psurf = surf->separate_stencil;
+surf = vc5_surface(psurf);
+}
 
-struct vc5_resource *separate_stencil = NULL;
-if (rsc->separate_stencil && buffer == STENCIL)
-separate_stencil = rsc->separate_stencil;
+struct vc5_resource *rsc = vc5_resource(psurf->texture);
 
 cl_emit(cl, LOAD_TILE_BUFFER_GENERAL, load) {
 load.buffer_to_load = buffer;
-if (separate_stencil) {
-load.address = cl_address(separate_stencil->bo,
-  
surf->separate_stencil_offset);
-} else {
-load.address = cl_address(rsc->bo, surf->offset);
-}
+load.address = cl_address(rsc->bo, surf->offset);
 
 #if V3D_VERSION >= 40
-if (separate_stencil) {
+load.memory_format = surf->tiling;
+if (separate_stencil)
 load.input_image_format = V3D_OUTPUT_IMAGE_FORMAT_S8;
-load.memory_format = surf->separate_stencil_tiling;
-}  else {
+else
 load.input_image_format = surf->format;
-load.memory_format = surf->tiling;
-}
 
 if (surf->tiling == VC5_TILING_UIF_NO_XOR ||
 surf->tiling == VC5_TILING_UIF_XOR) {
-if (separate_stencil) {
-load.height_in_ub_or_stride =
-
surf->separate_stencil_padded_height_of_output_image_in_uif_blocks;
-} else {
-load.height_in_ub_or_stride =
-
surf->padded_height_of_output_image_in_uif_blocks;
-}
+load.height_in_ub_or_stride =
+
surf->padded_height_of_output_image_in_uif_blocks;
 } else if (surf->tiling == VC5_TILING_RASTER) {
 struct vc5_resource_slice *slice =
 >slices[psurf->u.tex.level];
@@ -92,24 +82,19 @@ store_general(struct vc5_job *job,
   int pipe_bit, bool last_store, bool general_color_clear)
 {
 struct vc5_surface *surf = vc5_surface(psurf);
+bool separate_stencil = surf->separate_stencil && buffer == STENCIL;
+if (separate_stencil) {
+psurf = surf->separate_stencil;
+surf = vc5_surface(psurf);
+}
+
 struct vc5_resource *rsc = vc5_resource(psurf->texture);
 
-struct vc5_resource *separate_stencil = NULL;
-if (rsc->separate_stencil && buffer == STENCIL) {
-separate_stencil = rsc->separate_stencil;
-separate_stencil->writes++;
-} else {
-rsc->writes++;
-}
+rsc->writes++;
 
 cl_emit(cl, STORE_TILE_BUFFER_GENERAL, store) {
 store.buffer_to_store = buffer;
-if (separate_stencil) {
-store.address = cl_address(separate_stencil->bo,
-   
surf->separate_stencil_offset);
-} else {
-store.address = cl_address(rsc->bo, surf->offset);
-}
+store.address = cl_address(rsc->bo, surf->offset);
 
 #if V3D_VERSION >= 40
 store.clear_buffer_being_stored =
@@ -117,23 

Mesa (master): broadcom/vc5: Add appropriate height padding for bank conflicts.

2018-02-01 Thread Eric Anholt
Module: Mesa
Branch: master
Commit: 5329f35ea12fe70e9eff131b60979b810cbc5028
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=5329f35ea12fe70e9eff131b60979b810cbc5028

Author: Eric Anholt 
Date:   Sun Jan 21 10:25:10 2018 +0800

broadcom/vc5: Add appropriate height padding for bank conflicts.

I thought I didn't need this because I was doing level-0-always-UIF and
that the pad there would propagate down, but it turns out that for level 1
the padding ends up being chosen by the HW.  This brings us closer to
being able to turn on UIF XOR for increased performance, as well.

---

 src/gallium/drivers/vc5/vc5_resource.c | 50 ++
 src/gallium/drivers/vc5/vc5_resource.h |  1 +
 src/gallium/drivers/vc5/vc5_screen.h   |  8 ++
 src/gallium/drivers/vc5/vc5_state.c|  4 +++
 4 files changed, 63 insertions(+)

diff --git a/src/gallium/drivers/vc5/vc5_resource.c 
b/src/gallium/drivers/vc5/vc5_resource.c
index 9ecd083b05..f37ffe928f 100644
--- a/src/gallium/drivers/vc5/vc5_resource.c
+++ b/src/gallium/drivers/vc5/vc5_resource.c
@@ -327,6 +327,52 @@ vc5_resource_get_handle(struct pipe_screen *pscreen,
 return FALSE;
 }
 
+/**
+ * Computes the HW's UIFblock padding for a given height/cpp.
+ *
+ * The goal of the padding is to keep pages of the same color (bank number) at
+ * least half a page away from each other vertically when crossing between
+ * between columns of UIF blocks.
+ */
+static uint32_t
+vc5_get_ub_pad(struct vc5_resource *rsc, uint32_t height)
+{
+uint32_t utile_h = vc5_utile_height(rsc->cpp);
+uint32_t uif_block_h = utile_h * 2;
+uint32_t height_ub = height / uif_block_h;
+uint32_t ub_row_size = 256 * 4;
+
+uint32_t page_ub_rows = VC5_UIFCFG_PAGE_SIZE / ub_row_size;
+uint32_t pc_ub_rows = VC5_PAGE_CACHE_SIZE / ub_row_size;
+uint32_t height_offset_in_pc = height_ub % pc_ub_rows;
+
+/* For the perfectly-aligned-for-UIF-XOR case, don't add any pad. */
+if (height_offset_in_pc == 0)
+return 0;
+
+uint32_t half_page_ub_rows = (page_ub_rows * 3) >> 1;
+
+/* Try padding up to where we're offset by at least half a page. */
+if (height_offset_in_pc < half_page_ub_rows) {
+/* If we fit entirely in the page cache, don't pad. */
+if (height_ub < pc_ub_rows)
+return 0;
+else
+return half_page_ub_rows - height_offset_in_pc;
+}
+
+/* If we're close to being aligned to page cache size, then round up
+ * and rely on XOR.
+ */
+if (height_offset_in_pc > (pc_ub_rows - half_page_ub_rows))
+return pc_ub_rows - height_offset_in_pc;
+
+/* Otherwise, we're far enough away (top and bottom) to not need any
+ * padding.
+ */
+return 0;
+}
+
 static void
 vc5_setup_slices(struct vc5_resource *rsc)
 {
@@ -400,6 +446,10 @@ vc5_setup_slices(struct vc5_resource *rsc)
 4 * uif_block_w);
 level_height = align(level_height,
  uif_block_h);
+
+slice->ub_pad = vc5_get_ub_pad(rsc,
+   level_height);
+level_height += slice->ub_pad * uif_block_h;
 }
 }
 
diff --git a/src/gallium/drivers/vc5/vc5_resource.h 
b/src/gallium/drivers/vc5/vc5_resource.h
index 631a7b8fba..31b2b66cf6 100644
--- a/src/gallium/drivers/vc5/vc5_resource.h
+++ b/src/gallium/drivers/vc5/vc5_resource.h
@@ -74,6 +74,7 @@ struct vc5_resource_slice {
 uint32_t offset;
 uint32_t stride;
 uint32_t size;
+uint8_t ub_pad;
 enum vc5_tiling_mode tiling;
 };
 
diff --git a/src/gallium/drivers/vc5/vc5_screen.h 
b/src/gallium/drivers/vc5/vc5_screen.h
index 28925d791c..52967e6bec 100644
--- a/src/gallium/drivers/vc5/vc5_screen.h
+++ b/src/gallium/drivers/vc5/vc5_screen.h
@@ -40,6 +40,14 @@ struct vc5_bo;
 #define VC5_MAX_DRAW_BUFFERS 4
 #define VC5_MAX_ATTRIBUTES 16
 
+/* These are tunable parameters in the HW design, but all the V3D
+ * implementations agree.
+ */
+#define VC5_UIFCFG_BANKS 8
+#define VC5_UIFCFG_PAGE_SIZE 4096
+#define VC5_UIFCFG_XOR_VALUE (1 << 4)
+#define VC5_PAGE_CACHE_SIZE (VC5_UIFCFG_PAGE_SIZE * VC5_UIFCFG_BANKS)
+
 struct vc5_simulator_file;
 
 struct vc5_screen {
diff --git a/src/gallium/drivers/vc5/vc5_state.c 
b/src/gallium/drivers/vc5/vc5_state.c
index ea867279a0..a055d252b6 100644
--- a/src/gallium/drivers/vc5/vc5_state.c
+++ b/src/gallium/drivers/vc5/vc5_state.c
@@ -31,6 +31,7 @@
 #include "util/u_helpers.h"
 
 #include "vc5_context.h"
+#include "vc5_tiling.h"
 #include "broadcom/common/v3d_macros.h"
 #include "broadcom/cle/v3dx_pack.h"
 
@@ -787,6 +788,9 @@ 

Mesa (master): broadcom/vc5: Skip over missing color buffers for a couple of checks.

2018-02-01 Thread Eric Anholt
Module: Mesa
Branch: master
Commit: eb765394c2fd8232158fe02c8644309657dc1fe3
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=eb765394c2fd8232158fe02c8644309657dc1fe3

Author: Eric Anholt 
Date:   Sat Jan 20 10:19:20 2018 -0800

broadcom/vc5: Skip over missing color buffers for a couple of checks.

Fixes crashes in piglit alpha-to-coverage-no-draw-buffer-zero 2

---

 src/gallium/drivers/vc5/vc5_program.c | 3 +++
 src/gallium/drivers/vc5/vc5_state.c   | 3 +++
 2 files changed, 6 insertions(+)

diff --git a/src/gallium/drivers/vc5/vc5_program.c 
b/src/gallium/drivers/vc5/vc5_program.c
index ddb51b7f02..881bd4501d 100644
--- a/src/gallium/drivers/vc5/vc5_program.c
+++ b/src/gallium/drivers/vc5/vc5_program.c
@@ -378,6 +378,9 @@ vc5_update_compiled_fs(struct vc5_context *vc5, uint8_t 
prim_mode)
 
 for (int i = 0; i < key->nr_cbufs; i++) {
 struct pipe_surface *cbuf = vc5->framebuffer.cbufs[i];
+if (!cbuf)
+continue;
+
 const struct util_format_description *desc =
 util_format_description(cbuf->format);
 
diff --git a/src/gallium/drivers/vc5/vc5_state.c 
b/src/gallium/drivers/vc5/vc5_state.c
index 81ae33d717..ea867279a0 100644
--- a/src/gallium/drivers/vc5/vc5_state.c
+++ b/src/gallium/drivers/vc5/vc5_state.c
@@ -443,6 +443,9 @@ vc5_set_framebuffer_state(struct pipe_context *pctx,
 vc5->blend_dst_alpha_one = 0;
 for (int i = 0; i < vc5->framebuffer.nr_cbufs; i++) {
 struct pipe_surface *cbuf = vc5->framebuffer.cbufs[i];
+if (!cbuf)
+continue;
+
 const struct util_format_description *desc =
 util_format_description(cbuf->format);
 

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


Mesa (master): mesa: fix query of GL_TEXTURE_COMPRESSION_HINT_ARB

2018-02-01 Thread Brian Paul
Module: Mesa
Branch: master
Commit: 030821a8737cd8a7be001e40dafc1879f3df7866
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=030821a8737cd8a7be001e40dafc1879f3df7866

Author: Baldur Karlsson 
Date:   Thu Feb  1 11:31:56 2018 -0700

mesa: fix query of GL_TEXTURE_COMPRESSION_HINT_ARB

Fixes: f96a69f916a ("mesa: replace GLenum with GLenum16 in common
structures (v4)")
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=104908
Reviewed-by: Brian Paul 

---

 src/mesa/main/get_hash_params.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/mesa/main/get_hash_params.py b/src/mesa/main/get_hash_params.py
index e10282a156..df082af207 100644
--- a/src/mesa/main/get_hash_params.py
+++ b/src/mesa/main/get_hash_params.py
@@ -783,7 +783,7 @@ descriptor=[
   [ "EDGE_FLAG_ARRAY_COUNT_EXT", "CONST(0), NO_EXTRA" ],
 
 # GL_ARB_texture_compression
-  [ "TEXTURE_COMPRESSION_HINT_ARB", "CONTEXT_INT(Hint.TextureCompression), 
NO_EXTRA" ],
+  [ "TEXTURE_COMPRESSION_HINT_ARB", "CONTEXT_ENUM16(Hint.TextureCompression), 
NO_EXTRA" ],
 
 # GL_EXT_compiled_vertex_array
   [ "ARRAY_ELEMENT_LOCK_FIRST_EXT", "CONTEXT_INT(Array.LockFirst), NO_EXTRA" ],

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


Mesa (master): renderonly: fix dumb BO allocation for non 32bpp formats

2018-02-01 Thread Lucas Stach
Module: Mesa
Branch: master
Commit: 0c71a19fe4368beaaf7ac676403b3079ad658890
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=0c71a19fe4368beaaf7ac676403b3079ad658890

Author: Lucas Stach 
Date:   Tue Jan 30 15:11:35 2018 +0100

renderonly: fix dumb BO allocation for non 32bpp formats

Take into account the resource format, instead of applying a hardcoded
32bpp. This not only over-allocates 16bpp formats, but also results in
a wrong stride being filled into the handle.

Fixes: 848b49b288f ("gallium: add renderonly library")
CC: 
Signed-off-by: Lucas Stach 
Reviewed-by: Philipp Zabel 
Reviewed-by: Daniel Stone 

---

 src/gallium/auxiliary/renderonly/renderonly.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/gallium/auxiliary/renderonly/renderonly.c 
b/src/gallium/auxiliary/renderonly/renderonly.c
index da91f12b2e..d31f458845 100644
--- a/src/gallium/auxiliary/renderonly/renderonly.c
+++ b/src/gallium/auxiliary/renderonly/renderonly.c
@@ -33,6 +33,7 @@
 
 #include "state_tracker/drm_driver.h"
 #include "pipe/p_screen.h"
+#include "util/u_format.h"
 #include "util/u_inlines.h"
 #include "util/u_memory.h"
 
@@ -73,7 +74,7 @@ renderonly_create_kms_dumb_buffer_for_resource(struct 
pipe_resource *rsc,
struct drm_mode_create_dumb create_dumb = {
   .width = rsc->width0,
   .height = rsc->height0,
-  .bpp = 32,
+  .bpp = util_format_get_blocksizebits(rsc->format),
};
struct drm_mode_destroy_dumb destroy_dumb = { };
 

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


Mesa (master): intel/decoder: Fix control / evaluation label mixup.

2018-02-01 Thread Kenneth Graunke
Module: Mesa
Branch: master
Commit: 85ec7abc3faf67450e829df25cf2ec81addff075
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=85ec7abc3faf67450e829df25cf2ec81addff075

Author: Kenneth Graunke 
Date:   Thu Feb  1 09:43:20 2018 -0800

intel/decoder: Fix control / evaluation label mixup.

Trivial.  DS is TES, HS is TCS.

---

 src/intel/tools/gen_batch_decoder.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/intel/tools/gen_batch_decoder.c 
b/src/intel/tools/gen_batch_decoder.c
index f09b8331f8..78db83b982 100644
--- a/src/intel/tools/gen_batch_decoder.c
+++ b/src/intel/tools/gen_batch_decoder.c
@@ -452,8 +452,8 @@ decode_single_ksp(struct gen_batch_decode_ctx *ctx, const 
uint32_t *p)
   strcmp(inst->name,   "GS_STATE") == 0 ? "geometry shader" :
   strcmp(inst->name,   "SF_STATE") == 0 ? "strips and fans shader" :
   strcmp(inst->name, "CLIP_STATE") == 0 ? "clip shader" :
-  strcmp(inst->name, "3DSTATE_DS") == 0 ? "tessellation control shader" :
-  strcmp(inst->name, "3DSTATE_HS") == 0 ? "tessellation evaluation shader" 
:
+  strcmp(inst->name, "3DSTATE_DS") == 0 ? "tessellation evaluation shader" 
:
+  strcmp(inst->name, "3DSTATE_HS") == 0 ? "tessellation control shader" :
   strcmp(inst->name, "3DSTATE_VS") == 0 ? (is_simd8 ? "SIMD8 vertex 
shader" : "vec4 vertex shader") :
   strcmp(inst->name, "3DSTATE_GS") == 0 ? (is_simd8 ? "SIMD8 geometry 
shader" : "vec4 geometry shader") :
   NULL;

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


Mesa (master): i965: Bump official kernel requirement to Linux v3.9.

2018-02-01 Thread Kenneth Graunke
Module: Mesa
Branch: master
Commit: c3cd2aac279908a2de755d9454f293761d7b8d5a
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=c3cd2aac279908a2de755d9454f293761d7b8d5a

Author: Kenneth Graunke 
Date:   Wed Jan 31 07:03:17 2018 -0800

i965: Bump official kernel requirement to Linux v3.9.

In commit 3f353342a6b6744773c26ed66b12afed42bd57af (present in 17.3.0)
we started unconditionally using I915_EXEC_NO_RELOC, which was
introduced in Linux v3.9.  ChromeOS kernel 3.8 has backported this,
so it should work too.

Running on older kernels would likely result in every single batch
being rejected by the kernel, which is pretty catastrophic.  Yet, it
appears that nobody noticed.  So, let's just bump the official
requirement and move forward ever so slowly.

Fixes: 3f353342a6b ("i965: Use I915_EXEC_NO_RELOC")
Reviewed-by: Chris Wilson 
Acked-by: Emil Velikov 

---

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

diff --git a/src/mesa/drivers/dri/i965/intel_screen.c 
b/src/mesa/drivers/dri/i965/intel_screen.c
index e1e520bc89..8c78b73b64 100644
--- a/src/mesa/drivers/dri/i965/intel_screen.c
+++ b/src/mesa/drivers/dri/i965/intel_screen.c
@@ -1779,8 +1779,8 @@ intel_init_bufmgr(struct intel_screen *screen)
   return false;
}
 
-   if (!intel_get_boolean(screen, I915_PARAM_HAS_WAIT_TIMEOUT)) {
-  fprintf(stderr, "[%s: %u] Kernel 3.6 required.\n", __func__, __LINE__);
+   if (!intel_get_boolean(screen, I915_PARAM_HAS_EXEC_NO_RELOC)) {
+  fprintf(stderr, "[%s: %u] Kernel 3.9 required.\n", __func__, __LINE__);
   return false;
}
 

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


Mesa (master): meson: don't install windows headers on non-windows platforms

2018-02-01 Thread Eric Engeström
Module: Mesa
Branch: master
Commit: 4c5f0b4fd45a5ca96a0e3137c177140dd85b149e
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=4c5f0b4fd45a5ca96a0e3137c177140dd85b149e

Author: Marc Dietrich 
Date:   Thu Feb  1 13:27:28 2018 +0100

meson: don't install windows headers on non-windows platforms

Only dive into the windows subdir if windows platform is selected.

Signed-off-by: Marc Dietrich 
Fixes: 5ef75cb02b2b4db5506b8 "meson: build src/glx/windows"
Reviewed-by: Eric Engestrom 

---

 src/glx/meson.build | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/glx/meson.build b/src/glx/meson.build
index 04cd647ee4..e645b22b5f 100644
--- a/src/glx/meson.build
+++ b/src/glx/meson.build
@@ -18,7 +18,9 @@
 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 # SOFTWARE.
 
-subdir('windows')
+if with_dri_platform == 'windows'
+  subdir('windows')
+endif
 
 files_libglx = files(
   'clientattrib.c',

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


Mesa (master): ac/nir: use ac_build_buffer_load_format for image buffer loads

2018-02-01 Thread Marek Olšák
Module: Mesa
Branch: master
Commit: b0a6053a995abc4dbf29a19d78a4e0d661df16ae
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=b0a6053a995abc4dbf29a19d78a4e0d661df16ae

Author: Marek Olšák 
Date:   Tue Jan 30 19:40:43 2018 +0100

ac/nir: use ac_build_buffer_load_format for image buffer loads

Reviewed-by: Samuel Pitoiset 

---

 src/amd/common/ac_nir_to_llvm.c | 21 +
 1 file changed, 13 insertions(+), 8 deletions(-)

diff --git a/src/amd/common/ac_nir_to_llvm.c b/src/amd/common/ac_nir_to_llvm.c
index 75d7b12995..05b937803f 100644
--- a/src/amd/common/ac_nir_to_llvm.c
+++ b/src/amd/common/ac_nir_to_llvm.c
@@ -3611,14 +3611,19 @@ static LLVMValueRef visit_image_load(struct 
ac_nir_context *ctx,
 
const enum glsl_sampler_dim dim = glsl_get_sampler_dim(type);
if (dim == GLSL_SAMPLER_DIM_BUF) {
-   params[0] = get_sampler_desc(ctx, instr->variables[0], 
AC_DESC_BUFFER, NULL, true, false);
-   params[1] = LLVMBuildExtractElement(ctx->ac.builder, 
get_src(ctx, instr->src[0]),
-   ctx->ac.i32_0, ""); /* 
vindex */
-   params[2] = ctx->ac.i32_0; /* voffset */
-   params[3] = ctx->ac.i1false;  /* glc */
-   params[4] = ctx->ac.i1false;  /* slc */
-   res = ac_build_intrinsic(>ac, 
"llvm.amdgcn.buffer.load.format.v4f32", ctx->ac.v4f32,
-params, 5, 0);
+   unsigned mask = nir_ssa_def_components_read(>dest.ssa);
+   unsigned num_channels = util_last_bit(mask);
+   LLVMValueRef rsrc, vindex;
+
+   rsrc = get_sampler_desc(ctx, instr->variables[0], 
AC_DESC_BUFFER, NULL, true, false);
+   vindex = LLVMBuildExtractElement(ctx->ac.builder, get_src(ctx, 
instr->src[0]),
+ctx->ac.i32_0, "");
+
+   /* TODO: set "glc" and "can_speculate" when OpenGL needs it. */
+   res = ac_build_buffer_load_format(>ac, rsrc, vindex,
+ ctx->ac.i32_0, num_channels,
+ false, false);
+   res = ac_build_expand_to_vec4(>ac, res, num_channels);
 
res = trim_vector(>ac, res, 
instr->dest.ssa.num_components);
res = ac_to_integer(>ac, res);

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


Mesa (master): radeonsi: use ac_build_buffer_load_format for image buffer loads

2018-02-01 Thread Marek Olšák
Module: Mesa
Branch: master
Commit: 71c6f64e54c72bbe023afd1af754b046555af442
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=71c6f64e54c72bbe023afd1af754b046555af442

Author: Marek Olšák 
Date:   Tue Jan 30 19:40:43 2018 +0100

radeonsi: use ac_build_buffer_load_format for image buffer loads

Reviewed-by: Samuel Pitoiset 

---

 src/gallium/drivers/radeonsi/si_shader_tgsi_mem.c | 14 ++
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_shader_tgsi_mem.c 
b/src/gallium/drivers/radeonsi/si_shader_tgsi_mem.c
index d89907e117..84d483abe2 100644
--- a/src/gallium/drivers/radeonsi/si_shader_tgsi_mem.c
+++ b/src/gallium/drivers/radeonsi/si_shader_tgsi_mem.c
@@ -566,11 +566,17 @@ static void load_emit(
}
 
if (inst->Memory.Texture == TGSI_TEXTURE_BUFFER) {
+   unsigned num_channels = 
util_last_bit(inst->Dst[0].Register.WriteMask);
+   LLVMValueRef result =
+   ac_build_buffer_load_format(>ac,
+   emit_data->args[0],
+   emit_data->args[1],
+   emit_data->args[2],
+   num_channels,
+   
LLVMConstIntGetZExtValue(emit_data->args[3]),
+   can_speculate);
emit_data->output[emit_data->chan] =
-   lp_build_intrinsic(
-   builder, 
"llvm.amdgcn.buffer.load.format.v4f32", emit_data->dst_type,
-   emit_data->args, emit_data->arg_count,
-   ac_get_load_intr_attribs(can_speculate));
+   ac_build_expand_to_vec4(>ac, result, num_channels);
} else {
ac_get_image_intr_name("llvm.amdgcn.image.load",
   emit_data->dst_type, /* 
vdata */

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


Mesa (master): ac: add glc parameter to ac_build_buffer_load_format

2018-02-01 Thread Marek Olšák
Module: Mesa
Branch: master
Commit: bac9fa9f17f86d16a25afde724985f7ae0ec1322
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=bac9fa9f17f86d16a25afde724985f7ae0ec1322

Author: Marek Olšák 
Date:   Tue Jan 30 19:24:07 2018 +0100

ac: add glc parameter to ac_build_buffer_load_format

Reviewed-by: Samuel Pitoiset 

---

 src/amd/common/ac_llvm_build.c| 3 ++-
 src/amd/common/ac_llvm_build.h| 1 +
 src/amd/common/ac_nir_to_llvm.c   | 4 ++--
 src/gallium/drivers/radeonsi/si_shader.c  | 2 +-
 src/gallium/drivers/radeonsi/si_shader_tgsi_mem.c | 2 +-
 5 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/src/amd/common/ac_llvm_build.c b/src/amd/common/ac_llvm_build.c
index a5cb72daed..762351f280 100644
--- a/src/amd/common/ac_llvm_build.c
+++ b/src/amd/common/ac_llvm_build.c
@@ -1049,10 +1049,11 @@ LLVMValueRef ac_build_buffer_load_format(struct 
ac_llvm_context *ctx,
 LLVMValueRef vindex,
 LLVMValueRef voffset,
 unsigned num_channels,
+bool glc,
 bool can_speculate)
 {
return ac_build_buffer_load_common(ctx, rsrc, vindex, voffset,
-  num_channels, false, false,
+  num_channels, glc, false,
   can_speculate, true);
 }
 
diff --git a/src/amd/common/ac_llvm_build.h b/src/amd/common/ac_llvm_build.h
index 3ae96781b6..f95ad6a27c 100644
--- a/src/amd/common/ac_llvm_build.h
+++ b/src/amd/common/ac_llvm_build.h
@@ -219,6 +219,7 @@ LLVMValueRef ac_build_buffer_load_format(struct 
ac_llvm_context *ctx,
 LLVMValueRef vindex,
 LLVMValueRef voffset,
 unsigned num_channels,
+bool glc,
 bool can_speculate);
 
 LLVMValueRef
diff --git a/src/amd/common/ac_nir_to_llvm.c b/src/amd/common/ac_nir_to_llvm.c
index 04fe51935a..75d7b12995 100644
--- a/src/amd/common/ac_nir_to_llvm.c
+++ b/src/amd/common/ac_nir_to_llvm.c
@@ -2298,7 +2298,7 @@ static LLVMValueRef build_tex_intrinsic(struct 
ac_nir_context *ctx,
   args->addr,
   ctx->ac.i32_0,
   util_last_bit(mask),
-  true);
+  false, true);
}
 
args->opcode = ac_image_sample;
@@ -5356,7 +5356,7 @@ handle_vs_input_decl(struct nir_to_llvm_context *ctx,
input = ac_build_buffer_load_format(>ac, t_list,
buffer_index,
ctx->ac.i32_0,
-   4, true);
+   4, false, true);
 
for (unsigned chan = 0; chan < 4; chan++) {
LLVMValueRef llvm_chan = LLVMConstInt(ctx->ac.i32, 
chan, false);
diff --git a/src/gallium/drivers/radeonsi/si_shader.c 
b/src/gallium/drivers/radeonsi/si_shader.c
index 78156f1ede..7b2dc8daf6 100644
--- a/src/gallium/drivers/radeonsi/si_shader.c
+++ b/src/gallium/drivers/radeonsi/si_shader.c
@@ -611,7 +611,7 @@ void si_llvm_load_input_vs(
 
input[i] = ac_build_buffer_load_format(>ac, t_list,
   vertex_index, voffset,
-  num_channels, true);
+  num_channels, false, 
true);
input[i] = ac_build_expand_to_vec4(>ac, input[i], 
num_channels);
}
 
diff --git a/src/gallium/drivers/radeonsi/si_shader_tgsi_mem.c 
b/src/gallium/drivers/radeonsi/si_shader_tgsi_mem.c
index 42cb3251e7..d89907e117 100644
--- a/src/gallium/drivers/radeonsi/si_shader_tgsi_mem.c
+++ b/src/gallium/drivers/radeonsi/si_shader_tgsi_mem.c
@@ -1828,7 +1828,7 @@ static void build_tex_intrinsic(const struct 
lp_build_tgsi_action *action,
emit_data->args[0],
emit_data->args[2],
emit_data->args[1],
-   num_channels, true);
+   num_channels, false, true);
emit_data->output[emit_data->chan] =
ac_build_expand_to_vec4(>ac, result, num_channels);
return;


Mesa (master): radeonsi: remove unused si_shader_context members

2018-02-01 Thread Marek Olšák
Module: Mesa
Branch: master
Commit: 472361dd7e2f82e3697047776967544348b4012a
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=472361dd7e2f82e3697047776967544348b4012a

Author: Marek Olšák 
Date:   Tue Jan 30 17:58:14 2018 +0100

radeonsi: remove unused si_shader_context members

Reviewed-by: Samuel Pitoiset 

---

 src/gallium/drivers/radeonsi/si_shader_internal.h   | 4 
 src/gallium/drivers/radeonsi/si_shader_tgsi_setup.c | 7 ---
 2 files changed, 11 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_shader_internal.h 
b/src/gallium/drivers/radeonsi/si_shader_internal.h
index 489c468f03..00b9b8d16a 100644
--- a/src/gallium/drivers/radeonsi/si_shader_internal.h
+++ b/src/gallium/drivers/radeonsi/si_shader_internal.h
@@ -191,10 +191,6 @@ struct si_shader_context {
 
LLVMTargetMachineRef tm;
 
-   unsigned range_md_kind;
-   unsigned fpmath_md_kind;
-   LLVMValueRef fpmath_md_2p5_ulp;
-
/* Preloaded descriptors. */
LLVMValueRef esgs_ring;
LLVMValueRef gsvs_ring[4];
diff --git a/src/gallium/drivers/radeonsi/si_shader_tgsi_setup.c 
b/src/gallium/drivers/radeonsi/si_shader_tgsi_setup.c
index fc141ca1e0..f70e2bdde8 100644
--- a/src/gallium/drivers/radeonsi/si_shader_tgsi_setup.c
+++ b/src/gallium/drivers/radeonsi/si_shader_tgsi_setup.c
@@ -1194,13 +1194,6 @@ void si_llvm_context_init(struct si_shader_context *ctx,
bld_base->emit_declaration = emit_declaration;
bld_base->emit_immediate = emit_immediate;
 
-   /* metadata allowing 2.5 ULP */
-   ctx->fpmath_md_kind = LLVMGetMDKindIDInContext(ctx->ac.context,
-  "fpmath", 6);
-   LLVMValueRef arg = LLVMConstReal(ctx->ac.f32, 2.5);
-   ctx->fpmath_md_2p5_ulp = LLVMMDNodeInContext(ctx->ac.context,
-, 1);
-
bld_base->op_actions[TGSI_OPCODE_BGNLOOP].emit = bgnloop_emit;
bld_base->op_actions[TGSI_OPCODE_BRK].emit = brk_emit;
bld_base->op_actions[TGSI_OPCODE_CONT].emit = cont_emit;

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


Mesa (master): radeonsi: load the right number of components for VS inputs and TBOs

2018-02-01 Thread Marek Olšák
Module: Mesa
Branch: master
Commit: be973ed21f6e456ebd753f26a99151d9ea6e765c
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=be973ed21f6e456ebd753f26a99151d9ea6e765c

Author: Marek Olšák 
Date:   Tue Jan 30 18:34:25 2018 +0100

radeonsi: load the right number of components for VS inputs and TBOs

The supported counts are 1, 2, 4. (3=4)

The following snippet loads float, vec2, vec3, and vec4:

Before:
buffer_load_format_x v9, v4, s[0:3], 0 idxen  ; E0002000 8904
buffer_load_format_xyzw v[0:3], v5, s[8:11], 0 idxen  ; E00C2000 80020005
s_waitcnt vmcnt(0); BF8C0F70
buffer_load_format_xyzw v[2:5], v6, s[12:15], 0 idxen ; E00C2000 80030206
s_waitcnt vmcnt(0); BF8C0F70
buffer_load_format_xyzw v[5:8], v7, s[4:7], 0 idxen   ; E00C2000 80010507

After:
buffer_load_format_x v10, v4, s[0:3], 0 idxen ; E0002000 8A04
buffer_load_format_xy v[8:9], v5, s[8:11], 0 idxen; E0042000 80020805
buffer_load_format_xyzw v[0:3], v6, s[12:15], 0 idxen ; E00C2000 80030006
s_waitcnt vmcnt(0); BF8C0F70
buffer_load_format_xyzw v[3:6], v7, s[4:7], 0 idxen   ; E00C2000 80010307

Reviewed-by: Samuel Pitoiset 

---

 src/amd/common/ac_llvm_build.c| 35 +++
 src/amd/common/ac_llvm_build.h|  3 ++
 src/gallium/drivers/radeonsi/si_shader.c  | 13 +++--
 src/gallium/drivers/radeonsi/si_shader_tgsi_mem.c |  8 --
 4 files changed, 54 insertions(+), 5 deletions(-)

diff --git a/src/amd/common/ac_llvm_build.c b/src/amd/common/ac_llvm_build.c
index 6afe7f9723..a5cb72daed 100644
--- a/src/amd/common/ac_llvm_build.c
+++ b/src/amd/common/ac_llvm_build.c
@@ -461,6 +461,41 @@ ac_build_gather_values(struct ac_llvm_context *ctx,
return ac_build_gather_values_extended(ctx, values, value_count, 1, 
false, false);
 }
 
+/* Expand a scalar or vector to <4 x type> by filling the remaining channels
+ * with undef. Extract at most num_channels components from the input.
+ */
+LLVMValueRef ac_build_expand_to_vec4(struct ac_llvm_context *ctx,
+LLVMValueRef value,
+unsigned num_channels)
+{
+   LLVMTypeRef elemtype;
+   LLVMValueRef chan[4];
+
+   if (LLVMGetTypeKind(LLVMTypeOf(value)) == LLVMVectorTypeKind) {
+   unsigned vec_size = LLVMGetVectorSize(LLVMTypeOf(value));
+   num_channels = MIN2(num_channels, vec_size);
+
+   if (num_channels >= 4)
+   return value;
+
+   for (unsigned i = 0; i < num_channels; i++)
+   chan[i] = ac_llvm_extract_elem(ctx, value, i);
+
+   elemtype = LLVMGetElementType(LLVMTypeOf(value));
+   } else {
+   if (num_channels) {
+   assert(num_channels == 1);
+   chan[0] = value;
+   }
+   elemtype = LLVMTypeOf(value);
+   }
+
+   while (num_channels < 4)
+   chan[num_channels++] = LLVMGetUndef(elemtype);
+
+   return ac_build_gather_values(ctx, chan, 4);
+}
+
 LLVMValueRef
 ac_build_fdiv(struct ac_llvm_context *ctx,
  LLVMValueRef num,
diff --git a/src/amd/common/ac_llvm_build.h b/src/amd/common/ac_llvm_build.h
index 78437d603e..3ae96781b6 100644
--- a/src/amd/common/ac_llvm_build.h
+++ b/src/amd/common/ac_llvm_build.h
@@ -141,6 +141,9 @@ LLVMValueRef
 ac_build_gather_values(struct ac_llvm_context *ctx,
   LLVMValueRef *values,
   unsigned value_count);
+LLVMValueRef ac_build_expand_to_vec4(struct ac_llvm_context *ctx,
+LLVMValueRef value,
+unsigned num_channels);
 
 LLVMValueRef
 ac_build_fdiv(struct ac_llvm_context *ctx,
diff --git a/src/gallium/drivers/radeonsi/si_shader.c 
b/src/gallium/drivers/radeonsi/si_shader.c
index 9458920b9d..78156f1ede 100644
--- a/src/gallium/drivers/radeonsi/si_shader.c
+++ b/src/gallium/drivers/radeonsi/si_shader.c
@@ -480,8 +480,8 @@ void si_llvm_load_input_vs(
unsigned input_index,
LLVMValueRef out[4])
 {
-   unsigned vs_blit_property =
-   
ctx->shader->selector->info.properties[TGSI_PROPERTY_VS_BLIT_SGPRS];
+   const struct tgsi_shader_info *info = >shader->selector->info;
+   unsigned vs_blit_property = 
info->properties[TGSI_PROPERTY_VS_BLIT_SGPRS];
 
if (vs_blit_property) {
LLVMValueRef vertex_id = ctx->abi.vertex_id;
@@ -555,6 +555,7 @@ void si_llvm_load_input_vs(
unsigned fix_fetch;
unsigned num_fetches;
unsigned fetch_stride;
+   unsigned num_channels;
 
LLVMValueRef t_list_ptr;
LLVMValueRef t_offset;
@@ -580,24 +581,29 @@ void si_llvm_load_input_vs(
case 

Mesa (master): configure: Default to gbm=no on osx

2018-02-01 Thread Jon TURNEY
Module: Mesa
Branch: master
Commit: 7ad7a07c88b1b1c697132e8f990c0d9530fdf827
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=7ad7a07c88b1b1c697132e8f990c0d9530fdf827

Author: Jon Turney 
Date:   Tue Jan 16 23:27:43 2018 +

configure: Default to gbm=no on osx

Signed-off-by: Jon Turney 
Reviewed-by: Emil Velikov 

---

 configure.ac | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/configure.ac b/configure.ac
index ae5162319d..daa040d319 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1270,10 +1270,10 @@ AC_ARG_ENABLE([xa],
 [enable_xa=no])
 AC_ARG_ENABLE([gbm],
[AS_HELP_STRING([--enable-gbm],
- [enable gbm library @<:@default=yes except cygwin@:>@])],
+ [enable gbm library @<:@default=yes except cygwin and macOS@:>@])],
[enable_gbm="$enableval"],
[case "$host_os" in
-   cygwin*)
+   cygwin* | darwin*)
   enable_gbm=no
   ;;
*)

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


Mesa (master): glx/apple: locate dispatch table functions to wrap by name

2018-02-01 Thread Jon TURNEY
Module: Mesa
Branch: master
Commit: d3540b405b975450b9c2f9d8eb273be062cbf73a
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=d3540b405b975450b9c2f9d8eb273be062cbf73a

Author: Jon Turney 
Date:   Tue Jan 16 16:26:57 2018 +

glx/apple: locate dispatch table functions to wrap by name

Avoid reaching into the dispatch table internals (and thus having to deal
with the complexities of remap etc.) by identifying functions to wrap by
name.

See:
https://lists.freedesktop.org/archives/mesa-dev/2015-June/086721.html et seq.
https://bugs.freedesktop.org/show_bug.cgi?id=90311

Signed-off-by: Jon Turney 
Reviewed-by: Emil Velikov 

---

 src/glx/apple/apple_glapi.c   | 12 +---
 src/mapi/glapi/gen/gl_gentable.py | 14 ++
 src/mapi/glapi/glapi.h|  3 +++
 3 files changed, 22 insertions(+), 7 deletions(-)

diff --git a/src/glx/apple/apple_glapi.c b/src/glx/apple/apple_glapi.c
index 4d19f7f6a3..f2248ab01a 100644
--- a/src/glx/apple/apple_glapi.c
+++ b/src/glx/apple/apple_glapi.c
@@ -41,7 +41,6 @@
 #include "main/glheader.h"
 #include "glapi.h"
 #include "glapitable.h"
-#include "main/dispatch.h"
 
 #include "apple_glx.h"
 #include "apple_xgl_api.h"
@@ -61,12 +60,11 @@ static void _apple_glapi_create_table(void) {
 assert(__applegl_api);
 memcpy(__applegl_api, __ogl_framework_api, sizeof(struct _glapi_table));
 
-SET_ReadPixels(__applegl_api, __applegl_glReadPixels);
-SET_CopyPixels(__applegl_api, __applegl_glCopyPixels);
-SET_CopyColorTable(__applegl_api, __applegl_glCopyColorTable);
-SET_DrawBuffer(__applegl_api, __applegl_glDrawBuffer);
-SET_DrawBuffers(__applegl_api, __applegl_glDrawBuffers);
-SET_Viewport(__applegl_api, __applegl_glViewport);
+_glapi_table_patch(__applegl_api, "ReadPixels", __applegl_glReadPixels);
+_glapi_table_patch(__applegl_api, "CopyPixels", __applegl_glCopyPixels);
+_glapi_table_patch(__applegl_api, "CopyColorTable", 
__applegl_glCopyColorTable);
+_glapi_table_patch(__applegl_api, "DrawBuffers", __applegl_glDrawBuffer);
+_glapi_table_patch(__applegl_api, "Viewport", __applegl_glViewport);
 }
 
 void apple_glapi_set_dispatch(void) {
diff --git a/src/mapi/glapi/gen/gl_gentable.py 
b/src/mapi/glapi/gen/gl_gentable.py
index 2f54d1d579..50153bbabd 100644
--- a/src/mapi/glapi/gen/gl_gentable.py
+++ b/src/mapi/glapi/gen/gl_gentable.py
@@ -56,6 +56,7 @@ header = """/* GLXEXT is the define used in the xserver when 
the GLX extension i
 #endif
 #include 
 #include 
+#include 
 
 #include "main/glheader.h"
 
@@ -144,6 +145,19 @@ _glapi_create_table_from_handle(void *handle, const char 
*symbol_prefix) {
 
 return disp;
 }
+
+void
+ _glapi_table_patch(struct _glapi_table *table, const char *name, void 
*wrapper)
+{
+   for (int func_index = 0; func_index < GLAPI_TABLE_COUNT; ++func_index) {
+  if (!strcmp(_glapi_table_func_names[func_index], name)) {
+((void **)table)[func_index] = wrapper;
+return;
+ }
+   }
+   fprintf(stderr, "could not patch %s in dispatch table\\n", name);
+}
+
 """
 
 
diff --git a/src/mapi/glapi/glapi.h b/src/mapi/glapi/glapi.h
index f1ad4c1b5e..d5d4e0a03a 100644
--- a/src/mapi/glapi/glapi.h
+++ b/src/mapi/glapi/glapi.h
@@ -161,6 +161,9 @@ _glapi_get_proc_name(unsigned int offset);
 #if defined(GLX_USE_APPLEGL) || defined(GLX_USE_WINDOWSGL)
 _GLAPI_EXPORT struct _glapi_table *
 _glapi_create_table_from_handle(void *handle, const char *symbol_prefix);
+
+_GLAPI_EXPORT void
+_glapi_table_patch(struct _glapi_table *, const char *name, void *wrapper);
 #endif
 
 

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


Mesa (master): osx: ld doesn't support --build-id

2018-02-01 Thread Jon TURNEY
Module: Mesa
Branch: master
Commit: f8ed9f24d5eac1549e480dd0348d091b4299302e
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=f8ed9f24d5eac1549e480dd0348d091b4299302e

Author: Jon Turney 
Date:   Sun Dec  3 21:58:12 2017 +

osx: ld doesn't support --build-id

Signed-off-by: Jon Turney 
Reviewed-by: Emil Velikov 

---

 configure.ac | 13 +
 src/mesa/drivers/dri/Makefile.am |  2 +-
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index daa040d319..a54b7cb665 100644
--- a/configure.ac
+++ b/configure.ac
@@ -686,6 +686,19 @@ LDFLAGS=$save_LDFLAGS
 AM_CONDITIONAL(HAVE_LD_DYNAMIC_LIST, test "$have_ld_dynamic_list" = "yes")
 
 dnl
+dnl OSX linker does not support build-id
+dnl
+case "$host_os" in
+darwin*)
+LD_BUILD_ID=""
+;;
+*)
+LD_BUILD_ID="-Wl,--build-id=sha1"
+;;
+esac
+AC_SUBST([LD_BUILD_ID])
+
+dnl
 dnl compatibility symlinks
 dnl
 case "$host_os" in
diff --git a/src/mesa/drivers/dri/Makefile.am b/src/mesa/drivers/dri/Makefile.am
index ae30996e02..3876d7c419 100644
--- a/src/mesa/drivers/dri/Makefile.am
+++ b/src/mesa/drivers/dri/Makefile.am
@@ -57,7 +57,7 @@ mesa_dri_drivers_la_LDFLAGS = \
-module \
-no-undefined \
-avoid-version \
-   -Wl,--build-id=sha1 \
+   $(LD_BUILD_ID) \
$(BSYMBOLIC) \
$(GC_SECTIONS) \
$(LD_NO_UNDEFINED)

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


Mesa (master): glx/apple: include util/debug.h for env_var_as_boolean prototype

2018-02-01 Thread Jon TURNEY
Module: Mesa
Branch: master
Commit: b37b7b42dcc33d636c3db0558d032d7d95664c56
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=b37b7b42dcc33d636c3db0558d032d7d95664c56

Author: Jon Turney 
Date:   Sat Dec  2 17:05:43 2017 +

glx/apple: include util/debug.h for env_var_as_boolean prototype

mesa/src/glx/glxcmds.c:1295:21: error: implicit declaration of function 
'env_var_as_boolean' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
mesa/src/glx/apple/apple_visual.c:85:28: error: implicit declaration of 
function 'env_var_as_boolean' is invalid in C99 
[-Werror,-Wimplicit-function-declaration]

Signed-off-by: Jon Turney 
Reviewed-by: Emil Velikov 

---

 src/glx/apple/apple_visual.c | 1 +
 src/glx/glxcmds.c| 1 +
 2 files changed, 2 insertions(+)

diff --git a/src/glx/apple/apple_visual.c b/src/glx/apple/apple_visual.c
index d482bfc4e7..4a90d77c3a 100644
--- a/src/glx/apple/apple_visual.c
+++ b/src/glx/apple/apple_visual.c
@@ -32,6 +32,7 @@
 #include 
 #include 
 #include 
+#include 
 
 /*  */
 #define glTexImage1D glTexImage1D_OSX
diff --git a/src/glx/glxcmds.c b/src/glx/glxcmds.c
index eee45d962d..943b81754f 100644
--- a/src/glx/glxcmds.c
+++ b/src/glx/glxcmds.c
@@ -43,6 +43,7 @@
 #ifdef GLX_USE_APPLEGL
 #include "apple/apple_glx_context.h"
 #include "apple/apple_glx.h"
+#include "util/debug.h"
 #else
 #include 
 #ifdef XF86VIDMODE

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


Mesa (master): mesa: remove usage of alloca in externalobjects.c v4

2018-02-01 Thread Andres Rodriguez
Module: Mesa
Branch: master
Commit: bbd00844a2244cfe2702a5577a8d68f65877952a
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=bbd00844a2244cfe2702a5577a8d68f65877952a

Author: Andres Rodriguez 
Date:   Wed Jan 31 12:22:41 2018 -0500

mesa: remove usage of alloca in externalobjects.c v4

Don't want an overly large numBufferBarriers/numTextureBarriers to blow
up the stack.

v2: handle malloc errors
v3: fix patch
v4: initialize texObjs/bufObjs

Suggested-by: Emil Velikov 
Signed-off-by: Andres Rodriguez 

---

 src/mesa/main/externalobjects.c | 60 -
 1 file changed, 48 insertions(+), 12 deletions(-)

diff --git a/src/mesa/main/externalobjects.c b/src/mesa/main/externalobjects.c
index 463debd268..35545c2e55 100644
--- a/src/mesa/main/externalobjects.c
+++ b/src/mesa/main/externalobjects.c
@@ -716,12 +716,14 @@ _mesa_WaitSemaphoreEXT(GLuint semaphore,
const GLenum *srcLayouts)
 {
GET_CURRENT_CONTEXT(ctx);
-   struct gl_semaphore_object *semObj;
-   struct gl_buffer_object **bufObjs;
-   struct gl_texture_object **texObjs;
+   struct gl_semaphore_object *semObj = NULL;
+   struct gl_buffer_object **bufObjs = NULL;
+   struct gl_texture_object **texObjs = NULL;
+
+   const char *func = "glWaitSemaphoreEXT";
 
if (!ctx->Extensions.EXT_semaphore) {
-  _mesa_error(ctx, GL_INVALID_OPERATION, 
"glWaitSemaphoreEXT(unsupported)");
+  _mesa_error(ctx, GL_INVALID_OPERATION, "%s(unsupported)", func);
   return;
}
 
@@ -734,12 +736,24 @@ _mesa_WaitSemaphoreEXT(GLuint semaphore,
FLUSH_VERTICES(ctx, 0);
FLUSH_CURRENT(ctx, 0);
 
-   bufObjs = alloca(sizeof(struct gl_buffer_object **) * numBufferBarriers);
+   bufObjs = malloc(sizeof(struct gl_buffer_object **) * numBufferBarriers);
+   if (!bufObjs) {
+  _mesa_error(ctx, GL_OUT_OF_MEMORY, "%s(numBufferBarriers=%u)",
+  func, numBufferBarriers);
+  goto end;
+   }
+
for (unsigned i = 0; i < numBufferBarriers; i++) {
   bufObjs[i] = _mesa_lookup_bufferobj(ctx, buffers[i]);
}
 
-   texObjs = alloca(sizeof(struct gl_texture_object **) * numTextureBarriers);
+   texObjs = malloc(sizeof(struct gl_texture_object **) * numTextureBarriers);
+   if (!texObjs) {
+  _mesa_error(ctx, GL_OUT_OF_MEMORY, "%s(numTextureBarriers=%u)",
+  func, numTextureBarriers);
+  goto end;
+   }
+
for (unsigned i = 0; i < numTextureBarriers; i++) {
   texObjs[i] = _mesa_lookup_texture(ctx, textures[i]);
}
@@ -748,6 +762,10 @@ _mesa_WaitSemaphoreEXT(GLuint semaphore,
  numBufferBarriers, bufObjs,
  numTextureBarriers, texObjs,
  srcLayouts);
+
+end:
+   free(bufObjs);
+   free(texObjs);
 }
 
 void GLAPIENTRY
@@ -759,12 +777,14 @@ _mesa_SignalSemaphoreEXT(GLuint semaphore,
  const GLenum *dstLayouts)
 {
GET_CURRENT_CONTEXT(ctx);
-   struct gl_semaphore_object *semObj;
-   struct gl_buffer_object **bufObjs;
-   struct gl_texture_object **texObjs;
+   struct gl_semaphore_object *semObj = NULL;
+   struct gl_buffer_object **bufObjs = NULL;
+   struct gl_texture_object **texObjs = NULL;
+
+   const char *func = "glSignalSemaphoreEXT";
 
if (!ctx->Extensions.EXT_semaphore) {
-  _mesa_error(ctx, GL_INVALID_OPERATION, 
"glSignalSemaphoreEXT(unsupported)");
+  _mesa_error(ctx, GL_INVALID_OPERATION, "%s(unsupported)", func);
   return;
}
 
@@ -777,12 +797,24 @@ _mesa_SignalSemaphoreEXT(GLuint semaphore,
FLUSH_VERTICES(ctx, 0);
FLUSH_CURRENT(ctx, 0);
 
-   bufObjs = alloca(sizeof(struct gl_buffer_object **) * numBufferBarriers);
+   bufObjs = malloc(sizeof(struct gl_buffer_object **) * numBufferBarriers);
+   if (!bufObjs) {
+  _mesa_error(ctx, GL_OUT_OF_MEMORY, "%s(numBufferBarriers=%u)",
+  func, numBufferBarriers);
+  goto end;
+   }
+
for (unsigned i = 0; i < numBufferBarriers; i++) {
   bufObjs[i] = _mesa_lookup_bufferobj(ctx, buffers[i]);
}
 
-   texObjs = alloca(sizeof(struct gl_texture_object **) * numTextureBarriers);
+   texObjs = malloc(sizeof(struct gl_texture_object **) * numTextureBarriers);
+   if (!texObjs) {
+  _mesa_error(ctx, GL_OUT_OF_MEMORY, "%s(numTextureBarriers=%u)",
+  func, numTextureBarriers);
+  goto end;
+   }
+
for (unsigned i = 0; i < numTextureBarriers; i++) {
   texObjs[i] = _mesa_lookup_texture(ctx, textures[i]);
}
@@ -791,6 +823,10 @@ _mesa_SignalSemaphoreEXT(GLuint semaphore,
numBufferBarriers, bufObjs,
numTextureBarriers, texObjs,
dstLayouts);
+
+end:
+   free(bufObjs);
+   free(texObjs);
 }
 
 void GLAPIENTRY

___

Mesa (master): radv: do not insert shaders in cache when it's disabled

2018-02-01 Thread Samuel Pitoiset
Module: Mesa
Branch: master
Commit: 2ef5ce11985c7ccd34887d00ab57e32d4036dbed
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=2ef5ce11985c7ccd34887d00ab57e32d4036dbed

Author: Samuel Pitoiset 
Date:   Wed Jan 31 15:53:37 2018 +0100

radv: do not insert shaders in cache when it's disabled

When the application doesn't provide its own pipeline cache,
the driver uses a in-memory cache but it shouldn't insert any
entries when the cache is explicitely disabled by the user.

Found while running my experimental pipeline-db tool with a
ton of shaders, the memory footprint was just huge, and sometimes
the process was even killed...

Signed-off-by: Samuel Pitoiset 
Reviewed-by: Bas Nieuwenhuizen 

---

 src/amd/vulkan/radv_pipeline_cache.c | 29 -
 1 file changed, 24 insertions(+), 5 deletions(-)

diff --git a/src/amd/vulkan/radv_pipeline_cache.c 
b/src/amd/vulkan/radv_pipeline_cache.c
index db48895817..7205a3d896 100644
--- a/src/amd/vulkan/radv_pipeline_cache.c
+++ b/src/amd/vulkan/radv_pipeline_cache.c
@@ -241,6 +241,17 @@ radv_pipeline_cache_add_entry(struct radv_pipeline_cache 
*cache,
radv_pipeline_cache_set_entry(cache, entry);
 }
 
+static bool
+radv_is_cache_disabled(struct radv_device *device)
+{
+   /* Pipeline caches can be disabled with RADV_DEBUG=nocache, with
+* MESA_GLSL_CACHE_DISABLE=1, and when VK_AMD_shader_info is requested.
+*/
+   return (device->instance->debug_flags & RADV_DEBUG_NO_CACHE) ||
+  !device->physical_device->disk_cache ||
+  device->keep_shader_info;
+}
+
 bool
 radv_create_shader_variants_from_pipeline_cache(struct radv_device *device,
struct radv_pipeline_cache 
*cache,
@@ -257,11 +268,10 @@ radv_create_shader_variants_from_pipeline_cache(struct 
radv_device *device,
entry = radv_pipeline_cache_search_unlocked(cache, sha1);
 
if (!entry) {
-   /* Again, don't cache when we want debug info, since this isn't
-* present in the cache. */
-   if (!device->physical_device->disk_cache ||
-   (device->instance->debug_flags & RADV_DEBUG_NO_CACHE) ||
-   device->keep_shader_info) {
+   /* Don't cache when we want debug info, since this isn't
+* present in the cache.
+*/
+   if (radv_is_cache_disabled(device)) {
pthread_mutex_unlock(>mutex);
return false;
}
@@ -362,6 +372,15 @@ radv_pipeline_cache_insert_shaders(struct radv_device 
*device,
pthread_mutex_unlock(>mutex);
return;
}
+
+   /* Don't cache when we want debug info, since this isn't
+* present in the cache.
+*/
+   if (radv_is_cache_disabled(device)) {
+   pthread_mutex_unlock(>mutex);
+   return;
+   }
+
size_t size = sizeof(*entry);
for (int i = 0; i < MESA_SHADER_STAGES; ++i)
if (variants[i])

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


Mesa (master): radv: store the bind point when creating descriptors with templates

2018-02-01 Thread Samuel Pitoiset
Module: Mesa
Branch: master
Commit: cf224014dd2d4e6651ae15d346e624065614e8fd
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=cf224014dd2d4e6651ae15d346e624065614e8fd

Author: Samuel Pitoiset 
Date:   Tue Jan 23 12:20:32 2018 +0100

radv: store the bind point when creating descriptors with templates

Signed-off-by: Samuel Pitoiset 
Reviewed-by: Bas Nieuwenhuizen 

---

 src/amd/vulkan/radv_descriptor_set.c | 1 +
 src/amd/vulkan/radv_private.h| 1 +
 2 files changed, 2 insertions(+)

diff --git a/src/amd/vulkan/radv_descriptor_set.c 
b/src/amd/vulkan/radv_descriptor_set.c
index b1ef66308d..bbabfa9b27 100644
--- a/src/amd/vulkan/radv_descriptor_set.c
+++ b/src/amd/vulkan/radv_descriptor_set.c
@@ -847,6 +847,7 @@ VkResult radv_CreateDescriptorUpdateTemplateKHR(VkDevice 
_device,
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
 
templ->entry_count = entry_count;
+   templ->bind_point = pCreateInfo->pipelineBindPoint;
 
for (i = 0; i < entry_count; i++) {
const VkDescriptorUpdateTemplateEntryKHR *entry = 
>pDescriptorUpdateEntries[i];
diff --git a/src/amd/vulkan/radv_private.h b/src/amd/vulkan/radv_private.h
index 6239e33183..463be84f4a 100644
--- a/src/amd/vulkan/radv_private.h
+++ b/src/amd/vulkan/radv_private.h
@@ -720,6 +720,7 @@ struct radv_descriptor_update_template_entry {
 
 struct radv_descriptor_update_template {
uint32_t entry_count;
+   VkPipelineBindPoint bind_point;
struct radv_descriptor_update_template_entry entry[0];
 };
 

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


Mesa (master): radv: use separate bindings for graphics and compute descriptors

2018-02-01 Thread Samuel Pitoiset
Module: Mesa
Branch: master
Commit: 4922e7f25c1a42779bab11aff6489d8a39a17061
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=4922e7f25c1a42779bab11aff6489d8a39a17061

Author: Samuel Pitoiset 
Date:   Tue Jan 23 12:10:44 2018 +0100

radv: use separate bindings for graphics and compute descriptors

The Vulkan spec says:

   "pipelineBindPoint is a VkPipelineBindPoint indicating whether
the descriptors will be used by graphics pipelines or compute
pipelines. There is a separate set of bind points for each of
graphics and compute, so binding one does not disturb the other."

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=104732
Signed-off-by: Samuel Pitoiset 
Reviewed-by: Bas Nieuwenhuizen 

---

 src/amd/vulkan/radv_cmd_buffer.c | 134 ++-
 src/amd/vulkan/radv_meta.c   |  19 +-
 src/amd/vulkan/radv_private.h|  25 ++--
 3 files changed, 125 insertions(+), 53 deletions(-)

diff --git a/src/amd/vulkan/radv_cmd_buffer.c b/src/amd/vulkan/radv_cmd_buffer.c
index 48fe09da53..8a384b114c 100644
--- a/src/amd/vulkan/radv_cmd_buffer.c
+++ b/src/amd/vulkan/radv_cmd_buffer.c
@@ -261,7 +261,10 @@ radv_cmd_buffer_destroy(struct radv_cmd_buffer *cmd_buffer)
if (cmd_buffer->upload.upload_bo)

cmd_buffer->device->ws->buffer_destroy(cmd_buffer->upload.upload_bo);
cmd_buffer->device->ws->cs_destroy(cmd_buffer->cs);
-   free(cmd_buffer->push_descriptors.set.mapped_ptr);
+
+   for (unsigned i = 0; i < VK_PIPELINE_BIND_POINT_RANGE_SIZE; i++)
+   free(cmd_buffer->descriptors[i].push_set.set.mapped_ptr);
+
vk_free(_buffer->pool->alloc, cmd_buffer);
 }
 
@@ -295,6 +298,12 @@ radv_reset_cmd_buffer(struct radv_cmd_buffer *cmd_buffer)
 
cmd_buffer->ring_offsets_idx = -1;
 
+   for (unsigned i = 0; i < VK_PIPELINE_BIND_POINT_RANGE_SIZE; i++) {
+   cmd_buffer->descriptors[i].dirty = 0;
+   cmd_buffer->descriptors[i].valid = 0;
+   cmd_buffer->descriptors[i].push_dirty = false;
+   }
+
if (cmd_buffer->device->physical_device->rad_info.chip_class >= GFX9) {
void *fence_ptr;
radv_cmd_buffer_upload_alloc(cmd_buffer, 8, 0,
@@ -490,21 +499,27 @@ radv_save_pipeline(struct radv_cmd_buffer *cmd_buffer,
 }
 
 void radv_set_descriptor_set(struct radv_cmd_buffer *cmd_buffer,
+VkPipelineBindPoint bind_point,
 struct radv_descriptor_set *set,
 unsigned idx)
 {
-   cmd_buffer->descriptors[idx] = set;
+   struct radv_descriptor_state *descriptors_state =
+   radv_get_descriptors_state(cmd_buffer, bind_point);
+
+   descriptors_state->sets[idx] = set;
if (set)
-   cmd_buffer->state.valid_descriptors |= (1u << idx);
+   descriptors_state->valid |= (1u << idx);
else
-   cmd_buffer->state.valid_descriptors &= ~(1u << idx);
-   cmd_buffer->state.descriptors_dirty |= (1u << idx);
-
+   descriptors_state->valid &= ~(1u << idx);
+   descriptors_state->dirty |= (1u << idx);
 }
 
 static void
-radv_save_descriptors(struct radv_cmd_buffer *cmd_buffer)
+radv_save_descriptors(struct radv_cmd_buffer *cmd_buffer,
+ VkPipelineBindPoint bind_point)
 {
+   struct radv_descriptor_state *descriptors_state =
+   radv_get_descriptors_state(cmd_buffer, bind_point);
struct radv_device *device = cmd_buffer->device;
struct radeon_winsys_cs *cs = cmd_buffer->cs;
uint32_t data[MAX_SETS * 2] = {};
@@ -515,8 +530,8 @@ radv_save_descriptors(struct radv_cmd_buffer *cmd_buffer)
MAYBE_UNUSED unsigned cdw_max = radeon_check_space(device->ws,
   cmd_buffer->cs, 4 + 
MAX_SETS * 2);
 
-   for_each_bit(i, cmd_buffer->state.valid_descriptors) {
-   struct radv_descriptor_set *set = cmd_buffer->descriptors[i];
+   for_each_bit(i, descriptors_state->valid) {
+   struct radv_descriptor_set *set = descriptors_state->sets[i];
data[i * 2] = (uintptr_t)set;
data[i * 2 + 1] = (uintptr_t)set >> 32;
}
@@ -1257,9 +1272,12 @@ radv_emit_descriptor_set_userdata(struct radv_cmd_buffer 
*cmd_buffer,
 }
 
 static void
-radv_flush_push_descriptors(struct radv_cmd_buffer *cmd_buffer)
+radv_flush_push_descriptors(struct radv_cmd_buffer *cmd_buffer,
+   VkPipelineBindPoint bind_point)
 {
-   struct radv_descriptor_set *set = _buffer->push_descriptors.set;
+   struct radv_descriptor_state *descriptors_state =
+   radv_get_descriptors_state(cmd_buffer, bind_point);
+   struct radv_descriptor_set *set = _state->push_set.set;
unsigned bo_offset;
 
if