Mesa (master): tnl: Push down the gl_vertex_array inputs into tnl drivers.

2018-03-30 Thread Mathias Fröhlich
Module: Mesa
Branch: master
Commit: 784fdef4e7d6055eafe8a3e8e149a64d3ca5e5f6
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=784fdef4e7d6055eafe8a3e8e149a64d3ca5e5f6

Author: Mathias Fröhlich 
Date:   Sun Mar 25 19:16:54 2018 +0200

tnl: Push down the gl_vertex_array inputs into tnl drivers.

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

---

 src/mesa/drivers/dri/i915/intel_context.c  |  1 +
 src/mesa/drivers/dri/i965/brw_draw.c   |  4 +--
 src/mesa/drivers/dri/nouveau/nouveau_context.c |  1 +
 src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c   | 21 -
 src/mesa/drivers/dri/r200/r200_context.c   |  1 +
 src/mesa/drivers/dri/radeon/radeon_context.c   |  1 +
 src/mesa/drivers/dri/swrast/swrast.c   |  1 +
 src/mesa/drivers/osmesa/osmesa.c   |  1 +
 src/mesa/drivers/x11/xm_api.c  |  1 +
 src/mesa/tnl/t_context.c   |  6 ++--
 src/mesa/tnl/t_context.h   |  3 ++
 src/mesa/tnl/t_draw.c  | 42 --
 src/mesa/tnl/tnl.h | 14 +
 13 files changed, 88 insertions(+), 9 deletions(-)

diff --git a/src/mesa/drivers/dri/i915/intel_context.c 
b/src/mesa/drivers/dri/i915/intel_context.c
index 96d09ca947..f22ebbd7ac 100644
--- a/src/mesa/drivers/dri/i915/intel_context.c
+++ b/src/mesa/drivers/dri/i915/intel_context.c
@@ -380,6 +380,7 @@ void
 intelInitDriverFunctions(struct dd_function_table *functions)
 {
_mesa_init_driver_functions(functions);
+   _tnl_init_driver_draw_function(functions);
 
functions->Flush = intel_glFlush;
functions->Finish = intelFinish;
diff --git a/src/mesa/drivers/dri/i965/brw_draw.c 
b/src/mesa/drivers/dri/i965/brw_draw.c
index 5f52404bd6..4caaadd560 100644
--- a/src/mesa/drivers/dri/i965/brw_draw.c
+++ b/src/mesa/drivers/dri/i965/brw_draw.c
@@ -969,8 +969,8 @@ brw_draw_prims(struct gl_context *ctx,
  _mesa_enum_to_string(ctx->RenderMode));
   _swsetup_Wakeup(ctx);
   _tnl_wakeup(ctx);
-  _tnl_draw_prims(ctx, prims, nr_prims, ib,
-  index_bounds_valid, min_index, max_index, NULL, 0, NULL);
+  _tnl_draw(ctx, prims, nr_prims, ib,
+index_bounds_valid, min_index, max_index, NULL, 0, NULL);
   return;
}
 
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_context.c 
b/src/mesa/drivers/dri/nouveau/nouveau_context.c
index 5fab81d866..93f6ce473a 100644
--- a/src/mesa/drivers/dri/nouveau/nouveau_context.c
+++ b/src/mesa/drivers/dri/nouveau/nouveau_context.c
@@ -119,6 +119,7 @@ nouveau_context_init(struct gl_context *ctx, gl_api api,
 
/* Initialize the function pointers. */
_mesa_init_driver_functions();
+   _tnl_init_driver_draw_function();
nouveau_driver_functions_init();
nouveau_bufferobj_functions_init();
nouveau_texture_functions_init();
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c 
b/src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c
index a7b911c50e..10b5c15e41 100644
--- a/src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c
+++ b/src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c
@@ -537,6 +537,24 @@ TAG(vbo_check_render_prims)(struct gl_context *ctx,
tfb_vertcount, stream, indirect);
 }
 
+static void
+TAG(vbo_draw)(struct gl_context *ctx,
+ const struct _mesa_prim *prims, GLuint nr_prims,
+ const struct _mesa_index_buffer *ib,
+ GLboolean index_bounds_valid,
+ GLuint min_index, GLuint max_index,
+ struct gl_transform_feedback_object *tfb_vertcount,
+ unsigned stream,
+ struct gl_buffer_object *indirect)
+{
+   /* Borrow and update the inputs list from the tnl context */
+   _tnl_bind_inputs(ctx);
+
+   TAG(vbo_check_render_prims)(ctx, prims, nr_prims, ib,
+   index_bounds_valid, min_index, max_index,
+   tfb_vertcount, stream, indirect);
+}
+
 void
 TAG(vbo_init)(struct gl_context *ctx)
 {
@@ -546,7 +564,8 @@ TAG(vbo_init)(struct gl_context *ctx)
for (i = 0; i < VERT_ATTRIB_MAX; i++)
render->map[i] = -1;
 
-   vbo_set_draw_func(ctx, TAG(vbo_check_render_prims));
+   /* Overwrite our draw function */
+   ctx->Driver.Draw = TAG(vbo_draw);
vbo_use_buffer_objects(ctx);
 }
 
diff --git a/src/mesa/drivers/dri/r200/r200_context.c 
b/src/mesa/drivers/dri/r200/r200_context.c
index eb7d92f3c6..4524f06d10 100644
--- a/src/mesa/drivers/dri/r200/r200_context.c
+++ b/src/mesa/drivers/dri/r200/r200_context.c
@@ -227,6 +227,7 @@ GLboolean r200CreateContext( gl_api api,
 * (the texture functions are especially important)
 */
_mesa_init_driver_functions();
+   _tnl_init_driver_draw_function();
r200InitDriverFuncs();
r200InitIoctlFuncs();
r200InitStateFuncs(>radeon, );

Mesa (master): vbo: Remove the now unused vbo draw path.

2018-03-30 Thread Mathias Fröhlich
Module: Mesa
Branch: master
Commit: 461698af267f8001aa339c8ca1aec937083ad8fb
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=461698af267f8001aa339c8ca1aec937083ad8fb

Author: Mathias Fröhlich 
Date:   Sun Mar 25 19:16:54 2018 +0200

vbo: Remove the now unused vbo draw path.

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

---

 src/mesa/drivers/common/driverfuncs.c |  2 +-
 src/mesa/main/state.c | 12 ++---
 src/mesa/vbo/vbo.h| 20 ---
 src/mesa/vbo/vbo_context.c| 47 ---
 src/mesa/vbo/vbo_exec.c   |  8 --
 src/mesa/vbo/vbo_exec.h   |  4 ---
 src/mesa/vbo/vbo_private.h|  7 --
 7 files changed, 3 insertions(+), 97 deletions(-)

diff --git a/src/mesa/drivers/common/driverfuncs.c 
b/src/mesa/drivers/common/driverfuncs.c
index 2ddfdb5efa..11134b69e9 100644
--- a/src/mesa/drivers/common/driverfuncs.c
+++ b/src/mesa/drivers/common/driverfuncs.c
@@ -121,7 +121,7 @@ _mesa_init_driver_functions(struct dd_function_table 
*driver)
driver->NewATIfs = NULL;
 
/* Draw functions */
-   driver->Draw = _vbo_draw;
+   driver->Draw = NULL;
driver->DrawIndirect = _vbo_draw_indirect;
 
/* simple state commands */
diff --git a/src/mesa/main/state.c b/src/mesa/main/state.c
index fb97165db9..be8f3f302c 100644
--- a/src/mesa/main/state.c
+++ b/src/mesa/main/state.c
@@ -459,21 +459,13 @@ _mesa_set_vp_override(struct gl_context *ctx, GLboolean 
flag)
 
 
 static void
-set_new_array(struct gl_context *ctx)
-{
-   _vbo_set_recalculate_inputs(ctx);
-   ctx->NewDriverState |= ctx->DriverFlags.NewArray;
-}
-
-
-static void
 set_vertex_processing_mode(struct gl_context *ctx, gl_vertex_processing_mode m)
 {
if (ctx->VertexProgram._VPMode == m)
   return;
 
/* On change we may get new maps into the current values */
-   set_new_array(ctx);
+   ctx->NewDriverState |= ctx->DriverFlags.NewArray;
 
/* Finally memorize the value */
ctx->VertexProgram._VPMode = m;
@@ -532,7 +524,7 @@ _mesa_set_draw_vao(struct gl_context *ctx, struct 
gl_vertex_array_object *vao,
   new_array = true;
 
if (new_array)
-  set_new_array(ctx);
+  ctx->NewDriverState |= ctx->DriverFlags.NewArray;
 
ctx->Array._DrawVAOEnabledAttribs = enabled;
_mesa_set_varying_vp_inputs(ctx, enabled);
diff --git a/src/mesa/vbo/vbo.h b/src/mesa/vbo/vbo.h
index db136f9445..13f77d9db3 100644
--- a/src/mesa/vbo/vbo.h
+++ b/src/mesa/vbo/vbo.h
@@ -187,14 +187,6 @@ struct split_limits
 
 
 void
-_vbo_draw(struct gl_context *ctx, const struct _mesa_prim *prims,
-   GLuint nr_prims, const struct _mesa_index_buffer *ib,
-   GLboolean index_bounds_valid, GLuint min_index, GLuint 
max_index,
-   struct gl_transform_feedback_object *tfb_vertcount,
-   unsigned tfb_stream, struct gl_buffer_object *indirect);
-
-
-void
 _vbo_draw_indirect(struct gl_context *ctx, GLuint mode,
 struct gl_buffer_object *indirect_data,
 GLsizeiptr indirect_offset, unsigned draw_count,
@@ -231,9 +223,6 @@ void
 vbo_always_unmap_buffers(struct gl_context *ctx);
 
 void
-vbo_set_draw_func(struct gl_context *ctx, vbo_draw_func func);
-
-void
 vbo_sw_primitive_restart(struct gl_context *ctx,
  const struct _mesa_prim *prim,
  GLuint nr_prims,
@@ -261,15 +250,6 @@ struct vbo_inputs
 
 
 /**
- * Set the recalculate_inputs flag.
- * The method should in the longer run be replaced with listening for the
- * DriverFlags.NewArray flag in NewDriverState. But for now ...
- */
-void
-_vbo_set_recalculate_inputs(struct gl_context *ctx);
-
-
-/**
  * Initialize inputs.
  */
 void
diff --git a/src/mesa/vbo/vbo_context.c b/src/mesa/vbo/vbo_context.c
index 54cbab0c14..b8c28ceffb 100644
--- a/src/mesa/vbo/vbo_context.c
+++ b/src/mesa/vbo/vbo_context.c
@@ -186,7 +186,6 @@ _vbo_CreateContext(struct gl_context *ctx)
init_legacy_currval(ctx);
init_generic_currval(ctx);
init_mat_currval(ctx);
-   _vbo_init_inputs(>draw_arrays);
 
/* make sure all VBO_ATTRIB_ values can fit in an unsigned byte */
STATIC_ASSERT(VBO_ATTRIB_MAX <= 255);
@@ -235,52 +234,6 @@ _vbo_DestroyContext(struct gl_context *ctx)
 
 
 void
-vbo_set_draw_func(struct gl_context *ctx, vbo_draw_func func)
-{
-   struct vbo_context *vbo = vbo_context(ctx);
-   vbo->draw_prims = func;
-}
-
-
-/**
- * Examine the enabled vertex arrays to set the exec->array.inputs[] values.
- * These will point to the arrays to actually use for drawing.  Some will
- * be user-provided arrays, other will be zero-stride const-valued arrays.
- */
-static void
-vbo_bind_arrays(struct gl_context *ctx)
-{
-   struct vbo_context *vbo = vbo_context(ctx);
-   struct vbo_exec_context *exec = >exec;
-
-   _mesa_set_drawing_arrays(ctx, vbo->draw_arrays.inputs);
-
-   

Mesa (master): vbo: Remove unused includes to vbo_private.h

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

Author: Mathias Fröhlich 
Date:   Sun Mar 25 19:16:54 2018 +0200

vbo: Remove unused includes to vbo_private.h

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

---

 src/mesa/vbo/vbo_exec_array.c| 2 --
 src/mesa/vbo/vbo_primitive_restart.c | 1 -
 2 files changed, 3 deletions(-)

diff --git a/src/mesa/vbo/vbo_exec_array.c b/src/mesa/vbo/vbo_exec_array.c
index 51fd434dc4..b3ce138a09 100644
--- a/src/mesa/vbo/vbo_exec_array.c
+++ b/src/mesa/vbo/vbo_exec_array.c
@@ -39,8 +39,6 @@
 #include "main/macros.h"
 #include "main/transformfeedback.h"
 
-#include "vbo_private.h"
-
 
 /**
  * Check that element 'j' of the array has reasonable data.
diff --git a/src/mesa/vbo/vbo_primitive_restart.c 
b/src/mesa/vbo/vbo_primitive_restart.c
index 699b566dca..f170347fbe 100644
--- a/src/mesa/vbo/vbo_primitive_restart.c
+++ b/src/mesa/vbo/vbo_primitive_restart.c
@@ -33,7 +33,6 @@
 #include "main/varray.h"
 
 #include "vbo.h"
-#include "vbo_private.h"
 
 
 #define UPDATE_MIN2(a, b) (a) = MIN2((a), (b))

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


Mesa (master): gallium: Push down the gl_vertex_array inputs into gallium.

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

Author: Mathias Fröhlich 
Date:   Sun Mar 25 19:16:54 2018 +0200

gallium: Push down the gl_vertex_array inputs into gallium.

Let the gallium backend have its own gl_vertex_array array and basically
reimplement the way _vbo_draw works.

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

---

 src/mesa/state_tracker/st_cb_feedback.c | 35 ++---
 src/mesa/state_tracker/st_context.c |  9 -
 src/mesa/state_tracker/st_context.h |  4 
 src/mesa/state_tracker/st_draw.c| 16 ++-
 src/mesa/state_tracker/st_draw.h|  2 +-
 5 files changed, 52 insertions(+), 14 deletions(-)

diff --git a/src/mesa/state_tracker/st_cb_feedback.c 
b/src/mesa/state_tracker/st_cb_feedback.c
index 436062b1f8..b7a082fca3 100644
--- a/src/mesa/state_tracker/st_cb_feedback.c
+++ b/src/mesa/state_tracker/st_cb_feedback.c
@@ -40,6 +40,7 @@
 #include "main/imports.h"
 #include "main/context.h"
 #include "main/feedback.h"
+#include "main/varray.h"
 
 #include "vbo/vbo.h"
 
@@ -272,6 +273,34 @@ draw_glselect_stage(struct gl_context *ctx, struct 
draw_context *draw)
 
 
 static void
+feedback_draw_vbo(struct gl_context *ctx,
+  const struct _mesa_prim *prims,
+  GLuint nr_prims,
+  const struct _mesa_index_buffer *ib,
+  GLboolean index_bounds_valid,
+  GLuint min_index,
+  GLuint max_index,
+  struct gl_transform_feedback_object *tfb_vertcount,
+  unsigned stream,
+  struct gl_buffer_object *indirect)
+{
+   struct st_context *st = st_context(ctx);
+
+   /* The initial pushdown of the inputs array into the drivers */
+   _mesa_set_drawing_arrays(ctx, st->draw_arrays.inputs);
+   _vbo_update_inputs(ctx, >draw_arrays);
+
+   /* The above needs to happen outside of st_feedback_draw_vbo,
+* since st_RasterPossets _DrawArrays and does not want that to be
+* overwritten by _mesa_set_drawing_arrays.
+*/
+   st_feedback_draw_vbo(ctx, prims, nr_prims, ib, index_bounds_valid,
+min_index, max_index, tfb_vertcount,
+stream, indirect);
+}
+
+
+static void
 st_RenderMode(struct gl_context *ctx, GLenum newMode )
 {
struct st_context *st = st_context(ctx);
@@ -282,14 +311,14 @@ st_RenderMode(struct gl_context *ctx, GLenum newMode )
 
if (newMode == GL_RENDER) {
   /* restore normal VBO draw function */
-  st_init_draw(st);
+  st_init_draw_functions(>Driver);
}
else if (newMode == GL_SELECT) {
   if (!st->selection_stage)
  st->selection_stage = draw_glselect_stage(ctx, draw);
   draw_set_rasterize_stage(draw, st->selection_stage);
   /* Plug in new vbo draw function */
-  vbo_set_draw_func(ctx, st_feedback_draw_vbo);
+  ctx->Driver.Draw = feedback_draw_vbo;
}
else {
   struct gl_program *vp = st->ctx->VertexProgram._Current;
@@ -298,7 +327,7 @@ st_RenderMode(struct gl_context *ctx, GLenum newMode )
  st->feedback_stage = draw_glfeedback_stage(ctx, draw);
   draw_set_rasterize_stage(draw, st->feedback_stage);
   /* Plug in new vbo draw function */
-  vbo_set_draw_func(ctx, st_feedback_draw_vbo);
+  ctx->Driver.Draw = feedback_draw_vbo;
   /* need to generate/use a vertex program that emits pos/color/tex */
   if (vp)
  st->dirty |= ST_NEW_VERTEX_PROGRAM(st, st_vertex_program(vp));
diff --git a/src/mesa/state_tracker/st_context.c 
b/src/mesa/state_tracker/st_context.c
index 90b7f9359a..a3da0f8f1f 100644
--- a/src/mesa/state_tracker/st_context.c
+++ b/src/mesa/state_tracker/st_context.c
@@ -382,7 +382,6 @@ st_create_context_priv(struct gl_context *ctx, struct 
pipe_context *pipe,
 
st_init_atoms(st);
st_init_clear(st);
-   st_init_draw(st);
st_init_pbo_helpers(st);
 
/* Choose texture target for glDrawPixels, glBitmap, renderbuffers */
@@ -551,6 +550,9 @@ st_create_context_priv(struct gl_context *ctx, struct 
pipe_context *pipe,
/* Initialize context's winsys buffers list */
LIST_INITHEAD(>winsys_buffers);
 
+   /* Keep our list of gl_vertex_array inputs */
+   _vbo_init_inputs(>draw_arrays);
+
return st;
 }
 
@@ -715,6 +717,7 @@ st_init_driver_functions(struct pipe_screen *screen,
_mesa_init_shader_object_functions(functions);
_mesa_init_sampler_object_functions(functions);
 
+   st_init_draw_functions(functions);
st_init_blit_functions(functions);
st_init_bufferobject_functions(screen, functions);
st_init_clear_functions(functions);
@@ -752,10 +755,6 @@ st_init_driver_functions(struct pipe_screen *screen,
if (screen->get_param(screen, PIPE_CAP_STRING_MARKER))
   

Mesa (master): vbo: Readd the arrays argument to the legacy draw methods.

2018-03-30 Thread Mathias Fröhlich
Module: Mesa
Branch: master
Commit: 245f9a3977dcc097ded07c535b589b82191d5e94
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=245f9a3977dcc097ded07c535b589b82191d5e94

Author: Mathias Fröhlich 
Date:   Sun Mar 25 19:16:54 2018 +0200

vbo: Readd the arrays argument to the legacy draw methods.

The legacy draw paths from back before 2012 contained a gl_vertex_array
array for the inputs to be used for draw. So all draw methods from legacy
drivers and everything that goes through tnl are originally written
for this calling convention. The same goes for tools like t_rebase or
vbo_split*, that even partly still have the original calling convention
with a currently unused such pointer.
Back in 2012 patch 50f7e75

mesa: move gl_client_array*[] from vbo_draw_func into gl_context

introduced Array._DrawArrays, which was something that was IMO aiming for
a similar direction than Array._DrawVAO introduced recently.
Now several tools like t_rebase and vbo_split*, which are mostly used by
tnl based drivers, would need to be converted to use the internal
Array._DrawVAO instead of Array._DrawArrays. The same goes for the driver
backends that use any of these tools.
Alternatively we can reintroduce the gl_vertex_array array in its call
argument list and put these tools finally into the tnl directory.
So this change reintroduces this gl_vertex_array array for the legacy
draw paths that are still required for the tools t_rebase and vbo_split*.
A followup will move vbo_split also into tnl.

Note that none of the affected drivers use the DriverFlags.NewArray
driver bit. So it should be safe to remove this also for the legacy
draw path.

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

---

 src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c | 11 +++
 src/mesa/tnl/t_draw.c|  7 ---
 src/mesa/tnl/t_rebase.c  | 10 ++
 src/mesa/tnl/tnl.h   |  1 +
 src/mesa/vbo/vbo.h   |  2 ++
 src/mesa/vbo/vbo_split_copy.c|  8 +---
 src/mesa/vbo/vbo_split_inplace.c |  8 +---
 7 files changed, 18 insertions(+), 29 deletions(-)

diff --git a/src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c 
b/src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c
index 10b5c15e41..4533069692 100644
--- a/src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c
+++ b/src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c
@@ -239,6 +239,7 @@ get_max_client_stride(struct gl_context *ctx, const struct 
gl_vertex_array *arra
 
 static void
 TAG(vbo_render_prims)(struct gl_context *ctx,
+ const struct gl_vertex_array *arrays,
  const struct _mesa_prim *prims, GLuint nr_prims,
  const struct _mesa_index_buffer *ib,
  GLboolean index_bounds_valid,
@@ -476,6 +477,7 @@ vbo_draw_imm(struct gl_context *ctx, const struct 
gl_vertex_array *arrays,
 
 static void
 TAG(vbo_render_prims)(struct gl_context *ctx,
+ const struct gl_vertex_array *arrays,
  const struct _mesa_prim *prims, GLuint nr_prims,
  const struct _mesa_index_buffer *ib,
  GLboolean index_bounds_valid,
@@ -485,7 +487,6 @@ TAG(vbo_render_prims)(struct gl_context *ctx,
  struct gl_buffer_object *indirect)
 {
struct nouveau_render_state *render = to_render_state(ctx);
-   const struct gl_vertex_array *arrays = ctx->Array._DrawArrays;
 
if (!index_bounds_valid)
vbo_get_minmax_indices(ctx, prims, ib, _index, _index,
@@ -514,6 +515,7 @@ TAG(vbo_render_prims)(struct gl_context *ctx,
 
 static void
 TAG(vbo_check_render_prims)(struct gl_context *ctx,
+   const struct gl_vertex_array *arrays,
const struct _mesa_prim *prims, GLuint nr_prims,
const struct _mesa_index_buffer *ib,
GLboolean index_bounds_valid,
@@ -527,12 +529,12 @@ TAG(vbo_check_render_prims)(struct gl_context *ctx,
nouveau_validate_framebuffer(ctx);
 
if (nctx->fallback == HWTNL)
-   TAG(vbo_render_prims)(ctx, prims, nr_prims, ib,
+   TAG(vbo_render_prims)(ctx, arrays, prims, nr_prims, ib,
  index_bounds_valid, min_index, max_index,
  tfb_vertcount, stream, indirect);
 
if (nctx->fallback == SWTNL)
-   _tnl_draw_prims(ctx, prims, nr_prims, ib,
+   _tnl_draw_prims(ctx, arrays, prims, nr_prims, ib,
index_bounds_valid, min_index, max_index,
tfb_vertcount, stream, indirect);
 }
@@ -550,7 +552,8 @@ TAG(vbo_draw)(struct gl_context *ctx,
/* Borrow and update the inputs list from the tnl context */
_tnl_bind_inputs(ctx);
 
-   

Mesa (master): vbo: Use alloca for _vbo_draw_indirect.

2018-03-30 Thread Mathias Fröhlich
Module: Mesa
Branch: master
Commit: 1da345e56932b71067c069270828680aeb38d6b5
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=1da345e56932b71067c069270828680aeb38d6b5

Author: Mathias Fröhlich 
Date:   Wed Mar 28 07:19:02 2018 +0200

vbo: Use alloca for _vbo_draw_indirect.

Avoid using malloc in the draw path of mesa.
Since the draw_count is a user api input, fall back to malloc if
the amount of consumed stack space may get too high.

Reviewed-by: Brian Paul 
Reviewed-by: Marek Olšák 
Signed-off-by: Mathias Fröhlich 

---

 src/mesa/vbo/vbo_context.c | 79 --
 1 file changed, 55 insertions(+), 24 deletions(-)

diff --git a/src/mesa/vbo/vbo_context.c b/src/mesa/vbo/vbo_context.c
index b8c28ceffb..e50cee7a8c 100644
--- a/src/mesa/vbo/vbo_context.c
+++ b/src/mesa/vbo/vbo_context.c
@@ -233,26 +233,20 @@ _vbo_DestroyContext(struct gl_context *ctx)
 }
 
 
-void
-_vbo_draw_indirect(struct gl_context *ctx, GLuint mode,
-struct gl_buffer_object *indirect_data,
-GLsizeiptr indirect_offset, unsigned draw_count,
-unsigned stride,
-struct gl_buffer_object *indirect_draw_count_buffer,
-GLsizeiptr indirect_draw_count_offset,
-const struct _mesa_index_buffer *ib)
+/*
+ * Helper function for _vbo_draw_indirect below that additionally takes a zero
+ * initialized array of _mesa_prim scratch space memory as the last argument.
+ */
+static void
+draw_indirect(struct gl_context *ctx, GLuint mode,
+  struct gl_buffer_object *indirect_data,
+  GLsizeiptr indirect_offset, unsigned draw_count,
+  unsigned stride,
+  struct gl_buffer_object *indirect_draw_count_buffer,
+  GLsizeiptr indirect_draw_count_offset,
+  const struct _mesa_index_buffer *ib,
+  struct _mesa_prim *prim)
 {
-   struct _mesa_prim *prim;
-
-   prim = calloc(draw_count, sizeof(*prim));
-   if (prim == NULL) {
-  _mesa_error(ctx, GL_OUT_OF_MEMORY, "gl%sDraw%sIndirect%s",
-  (draw_count > 1) ? "Multi" : "",
-  ib ? "Elements" : "Arrays",
-  indirect_data ? "CountARB" : "");
-  return;
-   }
-
prim[0].begin = 1;
prim[draw_count - 1].end = 1;
for (unsigned i = 0; i < draw_count; ++i, indirect_offset += stride) {
@@ -266,10 +260,47 @@ _vbo_draw_indirect(struct gl_context *ctx, GLuint mode,
/* This should always be true at this time */
assert(indirect_data == ctx->DrawIndirectBuffer);
 
-   ctx->Driver.Draw(ctx, prim, draw_count,
-   ib, false, 0, ~0,
-   NULL, 0,
-   indirect_data);
+   ctx->Driver.Draw(ctx, prim, draw_count, ib, false, 0u, ~0u,
+NULL, 0, indirect_data);
+}
+
 
-   free(prim);
+/*
+ * Function to be put into dd_function_table::DrawIndirect as fallback.
+ * Calls into dd_function_table::Draw past adapting call arguments.
+ * See dd_function_table::DrawIndirect for call argument documentation.
+ */
+void
+_vbo_draw_indirect(struct gl_context *ctx, GLuint mode,
+   struct gl_buffer_object *indirect_data,
+   GLsizeiptr indirect_offset, unsigned draw_count,
+   unsigned stride,
+   struct gl_buffer_object *indirect_draw_count_buffer,
+   GLsizeiptr indirect_draw_count_offset,
+   const struct _mesa_index_buffer *ib)
+{
+   /* Use alloca for the prim space if we are somehow in bounds. */
+   if (draw_count*sizeof(struct _mesa_prim) < 1024) {
+  struct _mesa_prim *space = alloca(draw_count*sizeof(struct _mesa_prim));
+  memset(space, 0, draw_count*sizeof(struct _mesa_prim));
+
+  draw_indirect(ctx, mode, indirect_data, indirect_offset, draw_count,
+stride, indirect_draw_count_buffer,
+indirect_draw_count_offset, ib, space);
+   } else {
+  struct _mesa_prim *space = calloc(draw_count, sizeof(struct _mesa_prim));
+  if (space == NULL) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "gl%sDraw%sIndirect%s",
+ (draw_count > 1) ? "Multi" : "",
+ ib ? "Elements" : "Arrays",
+ indirect_data ? "CountARB" : "");
+ return;
+  }
+
+  draw_indirect(ctx, mode, indirect_data, indirect_offset, draw_count,
+stride, indirect_draw_count_buffer,
+indirect_draw_count_offset, ib, space);
+
+  free(space);
+   }
 }

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


Mesa (master): vbo: Move vbo_split into the tnl module.

2018-03-30 Thread Mathias Fröhlich
Module: Mesa
Branch: master
Commit: 6e9f00e3fc6f3b1331031f0995254c768d38ea81
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=6e9f00e3fc6f3b1331031f0995254c768d38ea81

Author: Mathias Fröhlich 
Date:   Sun Mar 25 19:16:54 2018 +0200

vbo: Move vbo_split into the tnl module.

Move the files, adapt to the naming scheme in tnl, update callers
and build system.

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

---

 src/mesa/Makefile.sources  | 10 +--
 src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c   |  4 +-
 src/mesa/meson.build   |  8 +--
 src/mesa/tnl/t_draw.c  |  8 +--
 src/mesa/tnl/t_rebase.c|  3 +-
 src/mesa/tnl/t_rebase.h|  4 +-
 src/mesa/{vbo/vbo_split.c => tnl/t_split.c}| 34 -
 src/mesa/{vbo/vbo_split.h => tnl/t_split.h}| 46 ++--
 .../{vbo/vbo_split_copy.c => tnl/t_split_copy.c}   | 23 +++---
 .../vbo_split_inplace.c => tnl/t_split_inplace.c}  | 51 +++---
 src/mesa/tnl/tnl.h | 80 +
 src/mesa/vbo/vbo.h | 81 --
 12 files changed, 178 insertions(+), 174 deletions(-)

diff --git a/src/mesa/Makefile.sources b/src/mesa/Makefile.sources
index 0446078136..92565ef8f5 100644
--- a/src/mesa/Makefile.sources
+++ b/src/mesa/Makefile.sources
@@ -372,6 +372,10 @@ TNL_FILES = \
tnl/t_pipeline.h \
tnl/t_rebase.c \
tnl/t_rebase.h \
+   tnl/t_split.c \
+   tnl/t_split_copy.c \
+   tnl/t_split.h \
+   tnl/t_split_inplace.c \
tnl/t_vb_cliptmp.h \
tnl/t_vb_fog.c \
tnl/t_vb_light.c \
@@ -411,11 +415,7 @@ VBO_FILES = \
vbo/vbo_save.c \
vbo/vbo_save_draw.c \
vbo/vbo_save.h \
-   vbo/vbo_save_loopback.c \
-   vbo/vbo_split.c \
-   vbo/vbo_split_copy.c \
-   vbo/vbo_split.h \
-   vbo/vbo_split_inplace.c
+   vbo/vbo_save_loopback.c
 
 STATETRACKER_FILES = \
state_tracker/st_atifs_to_tgsi.c \
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c 
b/src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c
index 4533069692..79b444cf55 100644
--- a/src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c
+++ b/src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c
@@ -277,8 +277,8 @@ vbo_maybe_split(struct gl_context *ctx, const struct 
gl_vertex_array *arrays,
.max_vb_size = ~0,
};
 
-   vbo_split_prims(ctx, arrays, prims, nr_prims, ib, min_index,
-   max_index, TAG(vbo_render_prims), );
+   _tnl_split_prims(ctx, arrays, prims, nr_prims, ib, min_index,
+max_index, TAG(vbo_render_prims), );
return GL_TRUE;
}
 
diff --git a/src/mesa/meson.build b/src/mesa/meson.build
index b74d169377..d2d058bfa3 100644
--- a/src/mesa/meson.build
+++ b/src/mesa/meson.build
@@ -343,10 +343,6 @@ files_libmesa_common = files(
   'vbo/vbo_save_draw.c',
   'vbo/vbo_save.h',
   'vbo/vbo_save_loopback.c',
-  'vbo/vbo_split.c',
-  'vbo/vbo_split_copy.c',
-  'vbo/vbo_split.h',
-  'vbo/vbo_split_inplace.c',
   'x86/common_x86.c',
 )
 
@@ -366,6 +362,10 @@ files_libmesa_classic = files(
   'tnl/t_pipeline.c',
   'tnl/t_pipeline.h',
   'tnl/t_rebase.c',
+  'tnl/t_split.c',
+  'tnl/t_split_copy.c',
+  'tnl/t_split.h',
+  'tnl/t_split_inplace.c',
   'tnl/t_vb_cliptmp.h',
   'tnl/t_vb_fog.c',
   'tnl/t_vb_light.c',
diff --git a/src/mesa/tnl/t_draw.c b/src/mesa/tnl/t_draw.c
index a0fd58432a..a83b98eede 100644
--- a/src/mesa/tnl/t_draw.c
+++ b/src/mesa/tnl/t_draw.c
@@ -486,10 +486,10 @@ void _tnl_draw_prims(struct gl_context *ctx,
   /* This will split the buffers one way or another and
* recursively call back into this function.
*/
-  vbo_split_prims( ctx, arrays, prim, nr_prims, ib, 
-  0, max_index + prim->basevertex,
-  _tnl_draw_prims,
-   );
+  _tnl_split_prims( ctx, arrays, prim, nr_prims, ib,
+0, max_index + prim->basevertex,
+_tnl_draw_prims,
+ );
}
else {
   /* May need to map a vertex buffer object for every attribute plus
diff --git a/src/mesa/tnl/t_rebase.c b/src/mesa/tnl/t_rebase.c
index 19e759f44b..d28512423c 100644
--- a/src/mesa/tnl/t_rebase.c
+++ b/src/mesa/tnl/t_rebase.c
@@ -51,6 +51,7 @@
 #include "main/glheader.h"
 #include "main/imports.h"
 #include "main/mtypes.h"
+#include "vbo/vbo.h"
 
 #include "t_rebase.h"
 
@@ -108,7 +109,7 @@ void t_rebase_prims( struct gl_context *ctx,
  const struct _mesa_index_buffer *ib,
  GLuint min_index,
  GLuint max_index,
- vbo_draw_func draw )
+ 

Mesa (master): vbo: Remove vbo_indirect_draw_func.

2018-03-30 Thread Mathias Fröhlich
Module: Mesa
Branch: master
Commit: 7f8db5ca471c1940b0be42f49d37c24af381979a
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=7f8db5ca471c1940b0be42f49d37c24af381979a

Author: Mathias Fröhlich 
Date:   Sun Mar 25 19:16:54 2018 +0200

vbo: Remove vbo_indirect_draw_func.

Remove the vbo_indirect_draw_func vbo callback and make the default
implementation use the drivers main draw callback function directly.
This will be needed with the next changes when drivers without own main
drivers DrawIndirect implementation get moved to the main drivers
Draw method.

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

---

 src/mesa/vbo/vbo.h | 32 
 src/mesa/vbo/vbo_context.c | 94 +++---
 src/mesa/vbo/vbo_private.h |  6 ---
 3 files changed, 30 insertions(+), 102 deletions(-)

diff --git a/src/mesa/vbo/vbo.h b/src/mesa/vbo/vbo.h
index ef2bf9221a..db136f9445 100644
--- a/src/mesa/vbo/vbo.h
+++ b/src/mesa/vbo/vbo.h
@@ -169,34 +169,6 @@ 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,
-   struct gl_buffer_object *indirect_data,
-   GLsizeiptr indirect_offset,
-   unsigned draw_count,
-   unsigned stride,
-   struct gl_buffer_object *indirect_draw_count_buffer,
-   GLsizeiptr indirect_draw_count_offset,
-   const struct _mesa_index_buffer *ib);
-
-
 
 
 /* Utility function to cope with various constraints on tnl modules or
@@ -262,10 +234,6 @@ void
 vbo_set_draw_func(struct gl_context *ctx, vbo_draw_func func);
 
 void
-vbo_set_indirect_draw_func(struct gl_context *ctx,
-   vbo_indirect_draw_func func);
-
-void
 vbo_sw_primitive_restart(struct gl_context *ctx,
  const struct _mesa_prim *prim,
  GLuint nr_prims,
diff --git a/src/mesa/vbo/vbo_context.c b/src/mesa/vbo/vbo_context.c
index 025d6d8de8..54cbab0c14 100644
--- a/src/mesa/vbo/vbo_context.c
+++ b/src/mesa/vbo/vbo_context.c
@@ -141,55 +141,6 @@ 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_buffer,
-GLsizeiptr indirect_offset,
-unsigned draw_count,
-unsigned stride,
-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);
-   struct _mesa_prim *prim;
-   GLsizei i;
-
-   prim = calloc(draw_count, sizeof(*prim));
-   if (prim == NULL) {
-  _mesa_error(ctx, GL_OUT_OF_MEMORY, "gl%sDraw%sIndirect%s",
-  (draw_count > 1) ? "Multi" : "",
-  ib ? "Elements" : "Arrays",
-  indirect_buffer ? "CountARB" : "");
-  return;
-   }
-
-   prim[0].begin = 1;
-   prim[draw_count - 1].end = 1;
-   for (i = 0; i < draw_count; ++i, indirect_offset += stride) {
-  prim[i].mode = mode;
-  prim[i].indexed = !!ib;
-  prim[i].indirect_offset = indirect_offset;
-  prim[i].is_indirect = 1;
-  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,
-   indirect_buffer);
-
-   free(prim);
-}
-
-
 void
 _vbo_install_exec_vtxfmt(struct gl_context *ctx)
 {
@@ -236,7 +187,6 @@ _vbo_CreateContext(struct gl_context *ctx)
init_generic_currval(ctx);
init_mat_currval(ctx);
_vbo_init_inputs(>draw_arrays);
-   

Mesa (master): i965: Push down the gl_vertex_array inputs into i965.

2018-03-30 Thread Mathias Fröhlich
Module: Mesa
Branch: master
Commit: 4db9d83a2dd5611776577bacdbdbf483b6bea937
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=4db9d83a2dd5611776577bacdbdbf483b6bea937

Author: Mathias Fröhlich 
Date:   Sun Mar 25 19:16:54 2018 +0200

i965: Push down the gl_vertex_array inputs into i965.

Let the i965 backend have its own gl_vertex_array array and basically
reimplement the way _vbo_draw works.
Note that brw_draw_indirect_prims calls brw_draw_prims internally
and gets its update to Array._DrawArray by this way.

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

---

 src/mesa/drivers/dri/i965/brw_context.c |  1 +
 src/mesa/drivers/dri/i965/brw_context.h |  4 
 src/mesa/drivers/dri/i965/brw_draw.c| 23 +--
 src/mesa/drivers/dri/i965/brw_draw.h|  1 +
 4 files changed, 23 insertions(+), 6 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_context.c 
b/src/mesa/drivers/dri/i965/brw_context.c
index 2e961a1ef6..01a3e16583 100644
--- a/src/mesa/drivers/dri/i965/brw_context.c
+++ b/src/mesa/drivers/dri/i965/brw_context.c
@@ -284,6 +284,7 @@ brw_init_driver_functions(struct brw_context *brw,
functions->GetString = intel_get_string;
functions->UpdateState = intel_update_state;
 
+   brw_init_draw_functions(functions);
intelInitTextureFuncs(functions);
intelInitTextureImageFuncs(functions);
intelInitTextureCopyImageFuncs(functions);
diff --git a/src/mesa/drivers/dri/i965/brw_context.h 
b/src/mesa/drivers/dri/i965/brw_context.h
index 177273c364..f049d08649 100644
--- a/src/mesa/drivers/dri/i965/brw_context.h
+++ b/src/mesa/drivers/dri/i965/brw_context.h
@@ -36,6 +36,7 @@
 #include 
 #include "main/macros.h"
 #include "main/mtypes.h"
+#include "vbo/vbo.h"
 #include "brw_structs.h"
 #include "brw_pipe_control.h"
 #include "compiler/brw_compiler.h"
@@ -954,6 +955,9 @@ struct brw_context
* These bitfields indicate which workarounds are needed.
*/
   uint8_t attrib_wa_flags[VERT_ATTRIB_MAX];
+
+  /* For the initial pushdown, keep the list of vbo inputs. */
+  struct vbo_inputs draw_arrays;
} vb;
 
struct {
diff --git a/src/mesa/drivers/dri/i965/brw_draw.c 
b/src/mesa/drivers/dri/i965/brw_draw.c
index 0d1ae8982c..5f52404bd6 100644
--- a/src/mesa/drivers/dri/i965/brw_draw.c
+++ b/src/mesa/drivers/dri/i965/brw_draw.c
@@ -34,6 +34,7 @@
 #include "main/macros.h"
 #include "main/transformfeedback.h"
 #include "main/framebuffer.h"
+#include "main/varray.h"
 #include "tnl/tnl.h"
 #include "vbo/vbo.h"
 #include "swrast/swrast.h"
@@ -941,11 +942,16 @@ brw_draw_prims(struct gl_context *ctx,
 {
unsigned i;
struct brw_context *brw = brw_context(ctx);
-   const struct gl_vertex_array *arrays = ctx->Array._DrawArrays;
+   const struct gl_vertex_array *arrays;
int predicate_state = brw->predicate.state;
struct brw_transform_feedback_object *xfb_obj =
   (struct brw_transform_feedback_object *) gl_xfb_obj;
 
+   /* The initial pushdown of the inputs array into the drivers */
+   _mesa_set_drawing_arrays(ctx, brw->vb.draw_arrays.inputs);
+   arrays = ctx->Array._DrawArrays;
+   _vbo_update_inputs(ctx, >vb.draw_arrays);
+
if (!brw_check_conditional_render(brw))
   return;
 
@@ -1075,14 +1081,19 @@ brw_draw_indirect_prims(struct gl_context *ctx,
 }
 
 void
-brw_draw_init(struct brw_context *brw)
+brw_init_draw_functions(struct dd_function_table *functions)
 {
-   struct gl_context *ctx = >ctx;
-
/* Register our drawing function:
 */
-   vbo_set_draw_func(ctx, brw_draw_prims);
-   vbo_set_indirect_draw_func(ctx, brw_draw_indirect_prims);
+   functions->Draw = brw_draw_prims;
+   functions->DrawIndirect = brw_draw_indirect_prims;
+}
+
+void
+brw_draw_init(struct brw_context *brw)
+{
+   /* Keep our list of gl_vertex_array inputs */
+   _vbo_init_inputs(>vb.draw_arrays);
 
for (int i = 0; i < VERT_ATTRIB_MAX; i++)
   brw->vb.inputs[i].buffer = -1;
diff --git a/src/mesa/drivers/dri/i965/brw_draw.h 
b/src/mesa/drivers/dri/i965/brw_draw.h
index c3a972c276..c74a2536aa 100644
--- a/src/mesa/drivers/dri/i965/brw_draw.h
+++ b/src/mesa/drivers/dri/i965/brw_draw.h
@@ -55,6 +55,7 @@ void brw_draw_prims(struct gl_context *ctx,
  unsigned stream,
 struct gl_buffer_object *indirect );
 
+void brw_init_draw_functions(struct dd_function_table *functions);
 void brw_draw_init( struct brw_context *brw );
 void brw_draw_destroy( struct brw_context *brw );
 

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


Mesa (master): nir/validator: Validate that all used variables exist

2018-03-30 Thread Jason Ekstrand
Module: Mesa
Branch: master
Commit: 9978f55cd1d28ccc5014ac56cafdd997eac5f222
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=9978f55cd1d28ccc5014ac56cafdd997eac5f222

Author: Jason Ekstrand 
Date:   Tue Mar 20 16:57:51 2018 -0700

nir/validator: Validate that all used variables exist

We were validating this for locals but nothing else.

Reviewed-by: Kenneth Graunke 

---

 src/compiler/nir/nir_validate.c | 17 -
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/compiler/nir/nir_validate.c b/src/compiler/nir/nir_validate.c
index 565cb2ef16..5566ceb298 100644
--- a/src/compiler/nir/nir_validate.c
+++ b/src/compiler/nir/nir_validate.c
@@ -96,7 +96,9 @@ typedef struct {
/* bitset of registers we have currently found; used to check uniqueness */
BITSET_WORD *regs_found;
 
-   /* map of local variable -> function implementation where it is defined */
+   /* map of variable -> function implementation where it is defined or NULL
+* if it is a global variable
+*/
struct hash_table *var_defs;
 
/* map of instruction/var/etc to failed assert string */
@@ -450,12 +452,10 @@ validate_deref_chain(nir_deref *deref, nir_variable_mode 
mode,
 static void
 validate_var_use(nir_variable *var, validate_state *state)
 {
-   if (var->data.mode == nir_var_local) {
-  struct hash_entry *entry = _mesa_hash_table_search(state->var_defs, var);
-
-  validate_assert(state, entry);
+   struct hash_entry *entry = _mesa_hash_table_search(state->var_defs, var);
+   validate_assert(state, entry);
+   if (var->data.mode == nir_var_local)
   validate_assert(state, (nir_function_impl *) entry->data == state->impl);
-   }
 }
 
 static void
@@ -1002,9 +1002,8 @@ validate_var_decl(nir_variable *var, bool is_global, 
validate_state *state)
 * support)
 */
 
-   if (!is_global) {
-  _mesa_hash_table_insert(state->var_defs, var, state->impl);
-   }
+   _mesa_hash_table_insert(state->var_defs, var,
+   is_global ? NULL : state->impl);
 
state->var = NULL;
 }

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


Mesa (master): intel/vec4: Set channel_sizes for MOV_INDIRECT sources

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

Author: Jason Ekstrand 
Date:   Fri Mar 23 09:27:55 2018 -0700

intel/vec4: Set channel_sizes for MOV_INDIRECT sources

Otherwise, any indirect push constant access results in an assertion
failure when we start digging through the channel_sizes array.  This
fixes dEQP-VK.pipeline.push_constant.graphics_pipeline.dynamic_index_vert
on Haswell.  It should be a harmless no-op for GL since indirect push
constants aren't used there.

Reviewed-by: Kenneth Graunke 
Fixes: e69e5c7006d "i965/vec4: load dvec3/4 uniforms first in the..."

---

 src/intel/compiler/brw_vec4.cpp | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/intel/compiler/brw_vec4.cpp b/src/intel/compiler/brw_vec4.cpp
index 2f352a1118..218925ccb1 100644
--- a/src/intel/compiler/brw_vec4.cpp
+++ b/src/intel/compiler/brw_vec4.cpp
@@ -695,8 +695,11 @@ vec4_visitor::pack_uniform_registers()
   * the next part of our packing algorithm.
   */
  int reg = inst->src[0].nr;
- for (unsigned i = 0; i < vec4s_read; i++)
+ int channel_size = type_sz(inst->src[0].type) / 4;
+ for (unsigned i = 0; i < vec4s_read; i++) {
 chans_used[reg + i] = 4;
+channel_sizes[reg + i] = MAX2(channel_sizes[reg + i], 
channel_size);
+ }
   }
}
 

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


Mesa (master): nir/lower_indirect_derefs: Support interp_var_at intrinsics

2018-03-30 Thread Jason Ekstrand
Module: Mesa
Branch: master
Commit: 6018f5b07966a0f85dea1ee6775d50a8c85fdee1
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=6018f5b07966a0f85dea1ee6775d50a8c85fdee1

Author: Jason Ekstrand 
Date:   Tue Mar 20 12:12:12 2018 -0700

nir/lower_indirect_derefs: Support interp_var_at intrinsics

This fixes the fs-interpolateAtCentroid-block-array piglit test on i965.

Reviewed-by: Kenneth Graunke 
Cc: mesa-sta...@lists.freedesktop.org

---

 src/compiler/nir/nir_lower_indirect_derefs.c | 13 +++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/src/compiler/nir/nir_lower_indirect_derefs.c 
b/src/compiler/nir/nir_lower_indirect_derefs.c
index c949224b15..02f202dea3 100644
--- a/src/compiler/nir/nir_lower_indirect_derefs.c
+++ b/src/compiler/nir/nir_lower_indirect_derefs.c
@@ -95,9 +95,15 @@ emit_load_store(nir_builder *b, nir_intrinsic_instr 
*orig_instr,
if (src == NULL) {
   /* This is a load instruction */
   nir_intrinsic_instr *load =
- nir_intrinsic_instr_create(b->shader, nir_intrinsic_load_var);
+ nir_intrinsic_instr_create(b->shader, orig_instr->intrinsic);
   load->num_components = orig_instr->num_components;
   load->variables[0] = nir_deref_var_clone(deref, load);
+
+  /* Copy over any sources.  This is needed for interp_var_at */
+  for (unsigned i = 0;
+   i < nir_intrinsic_infos[orig_instr->intrinsic].num_srcs; i++)
+ nir_src_copy(>src[i], _instr->src[i], load);
+
   unsigned bit_size = orig_instr->dest.ssa.bit_size;
   nir_ssa_dest_init(>instr, >dest,
 load->num_components, bit_size, NULL);
@@ -142,6 +148,9 @@ lower_indirect_block(nir_block *block, nir_builder *b,
 
   nir_intrinsic_instr *intrin = nir_instr_as_intrinsic(instr);
   if (intrin->intrinsic != nir_intrinsic_load_var &&
+  intrin->intrinsic != nir_intrinsic_interp_var_at_centroid &&
+  intrin->intrinsic != nir_intrinsic_interp_var_at_sample &&
+  intrin->intrinsic != nir_intrinsic_interp_var_at_offset &&
   intrin->intrinsic != nir_intrinsic_store_var)
  continue;
 
@@ -158,7 +167,7 @@ lower_indirect_block(nir_block *block, nir_builder *b,
 
   b->cursor = nir_before_instr(>instr);
 
-  if (intrin->intrinsic == nir_intrinsic_load_var) {
+  if (intrin->intrinsic != nir_intrinsic_store_var) {
  nir_ssa_def *result;
  emit_load_store(b, intrin, intrin->variables[0],
  >variables[0]->deref, , NULL);

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


Mesa (master): nir: Add src/dest num_components helpers

2018-03-30 Thread Jason Ekstrand
Module: Mesa
Branch: master
Commit: 956f17395bfcf7f8ce9dd5ac9fd14a13e86f3a8f
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=956f17395bfcf7f8ce9dd5ac9fd14a13e86f3a8f

Author: Jason Ekstrand 
Date:   Wed Mar 14 21:44:51 2018 -0700

nir: Add src/dest num_components helpers

We already have these for bit_size

Reviewed-by: Kenneth Graunke 

---

 src/compiler/nir/nir.h | 12 
 1 file changed, 12 insertions(+)

diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
index 9fff1f4647..5ba6a1f068 100644
--- a/src/compiler/nir/nir.h
+++ b/src/compiler/nir/nir.h
@@ -632,11 +632,23 @@ nir_src_bit_size(nir_src src)
 }
 
 static inline unsigned
+nir_src_num_components(nir_src src)
+{
+   return src.is_ssa ? src.ssa->num_components : src.reg.reg->num_components;
+}
+
+static inline unsigned
 nir_dest_bit_size(nir_dest dest)
 {
return dest.is_ssa ? dest.ssa.bit_size : dest.reg.reg->bit_size;
 }
 
+static inline unsigned
+nir_dest_num_components(nir_dest dest)
+{
+   return dest.is_ssa ? dest.ssa.num_components : dest.reg.reg->num_components;
+}
+
 void nir_src_copy(nir_src *dest, const nir_src *src, void *instr_or_if);
 void nir_dest_copy(nir_dest *dest, const nir_dest *src, nir_instr *instr);
 

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


Mesa (master): nir: Return a cursor from nir_instr_remove

2018-03-30 Thread Jason Ekstrand
Module: Mesa
Branch: master
Commit: a1452a94fca458c1129f527b775e1124a449ed2b
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=a1452a94fca458c1129f527b775e1124a449ed2b

Author: Jason Ekstrand 
Date:   Fri Mar 16 09:52:04 2018 -0700

nir: Return a cursor from nir_instr_remove

Because nir_instr_remove is an inline wrapper around nir_instr_remove_v,
the compiler should be able to tell that the return value is unused and
not emit the extra code in most cases.

Reviewed-by: Kenneth Graunke 

---

 src/compiler/nir/nir.c|  2 +-
 src/compiler/nir/nir.h| 16 +++-
 src/compiler/nir/nir_opt_copy_prop_vars.c | 19 ++-
 3 files changed, 18 insertions(+), 19 deletions(-)

diff --git a/src/compiler/nir/nir.c b/src/compiler/nir/nir.c
index 3fb16e6ca5..8364197480 100644
--- a/src/compiler/nir/nir.c
+++ b/src/compiler/nir/nir.c
@@ -1159,7 +1159,7 @@ remove_defs_uses(nir_instr *instr)
nir_foreach_src(instr, remove_use_cb, instr);
 }
 
-void nir_instr_remove(nir_instr *instr)
+void nir_instr_remove_v(nir_instr *instr)
 {
remove_defs_uses(instr);
exec_node_remove(>node);
diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
index 5ba6a1f068..cc7c401b40 100644
--- a/src/compiler/nir/nir.h
+++ b/src/compiler/nir/nir.h
@@ -2274,7 +2274,21 @@ nir_instr_insert_after_cf_list(struct exec_list *list, 
nir_instr *after)
nir_instr_insert(nir_after_cf_list(list), after);
 }
 
-void nir_instr_remove(nir_instr *instr);
+void nir_instr_remove_v(nir_instr *instr);
+
+static inline nir_cursor
+nir_instr_remove(nir_instr *instr)
+{
+   nir_cursor cursor;
+   nir_instr *prev = nir_instr_prev(instr);
+   if (prev) {
+  cursor = nir_after_instr(prev);
+   } else {
+  cursor = nir_before_block(instr->block);
+   }
+   nir_instr_remove_v(instr);
+   return cursor;
+}
 
 /** @} */
 
diff --git a/src/compiler/nir/nir_opt_copy_prop_vars.c 
b/src/compiler/nir/nir_opt_copy_prop_vars.c
index 89ddc8dd40..cc8f00f9d3 100644
--- a/src/compiler/nir/nir_opt_copy_prop_vars.c
+++ b/src/compiler/nir/nir_opt_copy_prop_vars.c
@@ -349,21 +349,6 @@ store_to_entry(struct copy_prop_var_state *state, struct 
copy_entry *entry,
}
 }
 
-/* Remove an instruction and return a cursor pointing to where it was */
-static nir_cursor
-instr_remove_cursor(nir_instr *instr)
-{
-   nir_cursor cursor;
-   nir_instr *prev = nir_instr_prev(instr);
-   if (prev) {
-  cursor = nir_after_instr(prev);
-   } else {
-  cursor = nir_before_block(instr->block);
-   }
-   nir_instr_remove(instr);
-   return cursor;
-}
-
 /* Do a "load" from an SSA-based entry return it in "value" as a value with a
  * single SSA def.  Because an entry could reference up to 4 different SSA
  * defs, a vecN operation may be inserted to combine them into a single SSA
@@ -396,7 +381,7 @@ load_from_ssa_entry_value(struct copy_prop_var_state *state,
 
if (all_same) {
   /* Our work here is done */
-  b->cursor = instr_remove_cursor(>instr);
+  b->cursor = nir_instr_remove(>instr);
   intrin->instr.block = NULL;
   return true;
}
@@ -594,7 +579,7 @@ load_from_deref_entry_value(struct copy_prop_var_state 
*state,
   value_tail->child = nir_deref_clone(src_tail->child, value_tail);
}
 
-   b->cursor = instr_remove_cursor(>instr);
+   b->cursor = nir_instr_remove(>instr);
 
return true;
 }

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


Mesa (master): nir/vars_to_ssa: Remove copies from the correct set

2018-03-30 Thread Jason Ekstrand
Module: Mesa
Branch: master
Commit: 0517d65f9639349d626aeb2af48ba9e4e605900d
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=0517d65f9639349d626aeb2af48ba9e4e605900d

Author: Jason Ekstrand 
Date:   Thu Mar 15 16:42:13 2018 -0700

nir/vars_to_ssa: Remove copies from the correct set

Reviewed-by: Kenneth Graunke 
Cc: mesa-sta...@lists.freedesktop.org

---

 src/compiler/nir/nir_lower_vars_to_ssa.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/compiler/nir/nir_lower_vars_to_ssa.c 
b/src/compiler/nir/nir_lower_vars_to_ssa.c
index e8cfe308d2..0cc65143e7 100644
--- a/src/compiler/nir/nir_lower_vars_to_ssa.c
+++ b/src/compiler/nir/nir_lower_vars_to_ssa.c
@@ -464,7 +464,7 @@ lower_copies_to_load_store(struct deref_node *node,
 
  struct set_entry *arg_entry = _mesa_set_search(arg_node->copies, 
copy);
  assert(arg_entry);
- _mesa_set_remove(node->copies, arg_entry);
+ _mesa_set_remove(arg_node->copies, arg_entry);
   }
 
   nir_instr_remove(>instr);

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


Mesa (master): st/wgl: check if WGL_SWAP_INTERVAL is defined in wglSwapIntervalEXT()

2018-03-30 Thread Brian Paul
Module: Mesa
Branch: master
Commit: c8906b845928955679b289dbc8e7a153071dffa7
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=c8906b845928955679b289dbc8e7a153071dffa7

Author: Brian Paul 
Date:   Fri Mar 30 14:44:50 2018 -0600

st/wgl: check if WGL_SWAP_INTERVAL is defined in wglSwapIntervalEXT()

This allows the WGL_SWAP_INTERVAL env var to override any application
calls to wglSwapIntervalEXT().  Useful for debugging, or to set the
interval to zero to effectively disable the swap interval.

Note: we also rename the previous instance of SVGA_SWAP_INTERVAL to
WGL_SWAP_INTERVAL since this is a WGL feature and not related to the
svga driver.

Reviewed-by: Charmaine Lee 

---

 src/gallium/state_trackers/wgl/stw_device.c   | 2 +-
 src/gallium/state_trackers/wgl/stw_ext_swapinterval.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/gallium/state_trackers/wgl/stw_device.c 
b/src/gallium/state_trackers/wgl/stw_device.c
index b88e1100eb..e43f12f7f2 100644
--- a/src/gallium/state_trackers/wgl/stw_device.c
+++ b/src/gallium/state_trackers/wgl/stw_device.c
@@ -135,7 +135,7 @@ stw_init(const struct stw_winsys *stw_winsys)
stw_pixelformat_init();
 
/* env var override for WGL_EXT_swap_control, useful for testing/debugging 
*/
-   const char *s = os_get_option("SVGA_SWAP_INTERVAL");
+   const char *s = os_get_option("WGL_SWAP_INTERVAL");
if (s) {
   stw_dev->swap_interval = atoi(s);
}
diff --git a/src/gallium/state_trackers/wgl/stw_ext_swapinterval.c 
b/src/gallium/state_trackers/wgl/stw_ext_swapinterval.c
index b2074a73fb..3b913e7db9 100644
--- a/src/gallium/state_trackers/wgl/stw_ext_swapinterval.c
+++ b/src/gallium/state_trackers/wgl/stw_ext_swapinterval.c
@@ -48,7 +48,7 @@ wglSwapIntervalEXT(int interval)
   SetLastError(ERROR_INVALID_DATA);
   return FALSE;
}
-   if (stw_dev) {
+   if (stw_dev && !os_get_option("WGL_SWAP_INTERVAL")) {
   stw_dev->swap_interval = interval;
}
return TRUE;

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


Mesa (master): docs: document WGL_SWAP_INTERVAL env var

2018-03-30 Thread Brian Paul
Module: Mesa
Branch: master
Commit: bebf758c4925d828b3df5e0f4168abc56e71859d
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=bebf758c4925d828b3df5e0f4168abc56e71859d

Author: Brian Paul 
Date:   Tue Mar 27 12:39:05 2018 -0600

docs: document WGL_SWAP_INTERVAL env var

Reviewed-by: Charmaine Lee 

---

 docs/envvars.html | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/docs/envvars.html b/docs/envvars.html
index a08f5b9402..08c259cc7b 100644
--- a/docs/envvars.html
+++ b/docs/envvars.html
@@ -323,6 +323,12 @@ such as the OpenGL program's name and command line 
arguments.
 See the driver code for other, lesser-used variables.
 
 
+WGL environment variables
+
+WGL_SWAP_INTERVAL - to set a swap interval, equivalent to calling
+wglSwapIntervalEXT() in an application.  If this environment variable
+is set, application calls to wglSwapIntervalEXT() will have no effect.
+
 
 VA-API state tracker environment variables
 

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


Mesa (master): glapi: define GL_API to be KEYWORD1 in glapi_dispatch.c (v2)

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

Author: Brian Paul 
Date:   Tue Mar 27 12:56:49 2018 -0600

glapi: define GL_API to be KEYWORD1 in glapi_dispatch.c (v2)

This fixes a Windows build warning where the prototypes for the ES
function in the header file don't match the prototypes in this file
because the GL_API and GLAPI macros are defined differently.

v2: defined GL_API to KEYWORD1 instead of GLAPI, per Mathias.

Reviewed-by: Mathias Fröhlich 

---

 src/mapi/glapi/glapi_dispatch.c | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/src/mapi/glapi/glapi_dispatch.c b/src/mapi/glapi/glapi_dispatch.c
index 323952366d..ca15449ed0 100644
--- a/src/mapi/glapi/glapi_dispatch.c
+++ b/src/mapi/glapi/glapi_dispatch.c
@@ -97,6 +97,13 @@
  */
 #include 
 
+
+/* Redefine GL_API to avoid MSVC/MinGW warnings about different dllimport
+ * attributes for these prototypes vs those in the GLES/gl.h header.
+ */
+#undef GL_API
+#define GL_API KEYWORD1
+
 GL_API void GL_APIENTRY glClearDepthf (GLclampf depth);
 GL_API void GL_APIENTRY glClipPlanef (GLenum plane, const GLfloat *equation);
 GL_API void GL_APIENTRY glFrustumf (GLfloat left, GLfloat right, GLfloat 
bottom, GLfloat top, GLfloat zNear, GLfloat zFar);

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


Mesa (master): nir/spirv: move NORETURN annotation on _vtn_fail() prototype

2018-03-30 Thread Brian Paul
Module: Mesa
Branch: master
Commit: c58c9f712d89c1004a0e455c1ed02ff6e8f4fb3c
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=c58c9f712d89c1004a0e455c1ed02ff6e8f4fb3c

Author: Brian Paul 
Date:   Fri Mar 30 11:07:46 2018 -0600

nir/spirv: move NORETURN annotation on _vtn_fail() prototype

This needs to before the function, not after, to compile with MSVC.
This works with gcc too.

Reviewed-by: Neil Roberts 

---

 src/compiler/spirv/vtn_private.h | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/compiler/spirv/vtn_private.h b/src/compiler/spirv/vtn_private.h
index 269de92225..982b426e70 100644
--- a/src/compiler/spirv/vtn_private.h
+++ b/src/compiler/spirv/vtn_private.h
@@ -71,8 +71,10 @@ void _vtn_warn(struct vtn_builder *b, const char *file, 
unsigned line,
  * So long as these two things continue to hold, we can easily longjmp back to
  * spirv_to_nir(), clean up the builder, and return NULL.
  */
-void _vtn_fail(struct vtn_builder *b, const char *file, unsigned line,
-   const char *fmt, ...) NORETURN PRINTFLIKE(4, 5);
+NORETURN void
+_vtn_fail(struct vtn_builder *b, const char *file, unsigned line,
+ const char *fmt, ...) PRINTFLIKE(4, 5);
+
 #define vtn_fail(...) _vtn_fail(b, __FILE__, __LINE__, __VA_ARGS__)
 
 /** Fail if the given expression evaluates to true */

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


Mesa (master): nir/spirv: s/uint32_t/SpvOp/ in various functions

2018-03-30 Thread Brian Paul
Module: Mesa
Branch: master
Commit: f3164c2ed96a119c73f16c4703bf5ad9feff1416
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=f3164c2ed96a119c73f16c4703bf5ad9feff1416

Author: Brian Paul 
Date:   Fri Mar 30 11:10:11 2018 -0600

nir/spirv: s/uint32_t/SpvOp/ in various functions

The MSVC compiler warns when the function parameter types don't
exactly match with respect to enum vs. uint32_t.  Use SpvOp everywhere.

Alternately, uint32_t could be used everywhere.  There doesn't seem
to be an advantage to one over the other.

Reviewed-by: Neil Roberts 

---

 src/compiler/spirv/vtn_amd.c | 4 ++--
 src/compiler/spirv/vtn_glsl450.c | 2 +-
 src/compiler/spirv/vtn_private.h | 8 
 3 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/src/compiler/spirv/vtn_amd.c b/src/compiler/spirv/vtn_amd.c
index 320e3b0586..0d5b429783 100644
--- a/src/compiler/spirv/vtn_amd.c
+++ b/src/compiler/spirv/vtn_amd.c
@@ -27,7 +27,7 @@
 #include "GLSL.ext.AMD.h"
 
 bool
-vtn_handle_amd_gcn_shader_instruction(struct vtn_builder *b, uint32_t 
ext_opcode,
+vtn_handle_amd_gcn_shader_instruction(struct vtn_builder *b, SpvOp ext_opcode,
   const uint32_t *w, unsigned count)
 {
const struct glsl_type *dest_type =
@@ -57,7 +57,7 @@ vtn_handle_amd_gcn_shader_instruction(struct vtn_builder *b, 
uint32_t ext_opcode
 }
 
 bool
-vtn_handle_amd_shader_trinary_minmax_instruction(struct vtn_builder *b, 
uint32_t ext_opcode,
+vtn_handle_amd_shader_trinary_minmax_instruction(struct vtn_builder *b, SpvOp 
ext_opcode,
  const uint32_t *w, unsigned 
count)
 {
struct nir_builder *nb = >nb;
diff --git a/src/compiler/spirv/vtn_glsl450.c b/src/compiler/spirv/vtn_glsl450.c
index eb0b90f797..d208215ccb 100644
--- a/src/compiler/spirv/vtn_glsl450.c
+++ b/src/compiler/spirv/vtn_glsl450.c
@@ -810,7 +810,7 @@ handle_glsl450_interpolation(struct vtn_builder *b, enum 
GLSLstd450 opcode,
 }
 
 bool
-vtn_handle_glsl450_instruction(struct vtn_builder *b, uint32_t ext_opcode,
+vtn_handle_glsl450_instruction(struct vtn_builder *b, SpvOp ext_opcode,
const uint32_t *w, unsigned count)
 {
switch ((enum GLSLstd450)ext_opcode) {
diff --git a/src/compiler/spirv/vtn_private.h b/src/compiler/spirv/vtn_private.h
index 982b426e70..b501bbf9b4 100644
--- a/src/compiler/spirv/vtn_private.h
+++ b/src/compiler/spirv/vtn_private.h
@@ -230,7 +230,7 @@ struct vtn_function {
SpvFunctionControlMask control;
 };
 
-typedef bool (*vtn_instruction_handler)(struct vtn_builder *, uint32_t,
+typedef bool (*vtn_instruction_handler)(struct vtn_builder *, SpvOp,
 const uint32_t *, unsigned);
 
 void vtn_build_cfg(struct vtn_builder *b, const uint32_t *words,
@@ -718,7 +718,7 @@ void vtn_handle_alu(struct vtn_builder *b, SpvOp opcode,
 void vtn_handle_subgroup(struct vtn_builder *b, SpvOp opcode,
  const uint32_t *w, unsigned count);
 
-bool vtn_handle_glsl450_instruction(struct vtn_builder *b, uint32_t ext_opcode,
+bool vtn_handle_glsl450_instruction(struct vtn_builder *b, SpvOp ext_opcode,
 const uint32_t *words, unsigned count);
 
 struct vtn_builder* vtn_create_builder(const uint32_t *words, size_t 
word_count,
@@ -744,9 +744,9 @@ vtn_u64_literal(const uint32_t *w)
return (uint64_t)w[1] << 32 | w[0];
 }
 
-bool vtn_handle_amd_gcn_shader_instruction(struct vtn_builder *b, uint32_t 
ext_opcode,
+bool vtn_handle_amd_gcn_shader_instruction(struct vtn_builder *b, SpvOp 
ext_opcode,
const uint32_t *words, unsigned 
count);
 
-bool vtn_handle_amd_shader_trinary_minmax_instruction(struct vtn_builder *b, 
uint32_t ext_opcode,
+bool vtn_handle_amd_shader_trinary_minmax_instruction(struct vtn_builder *b, 
SpvOp ext_opcode,
  const uint32_t *words, 
unsigned count);
 #endif /* _VTN_PRIVATE_H_ */

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


Mesa (master): spirv: s/uint/unsigned/ to fix MSVC build

2018-03-30 Thread Brian Paul
Module: Mesa
Branch: master
Commit: 26bc983c8374fd98dc3b8f8fa273f3063e3ac249
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=26bc983c8374fd98dc3b8f8fa273f3063e3ac249

Author: Brian Paul 
Date:   Fri Mar 30 11:30:05 2018 -0600

spirv: s/uint/unsigned/ to fix MSVC build

Reviewed-by: Neil Roberts 

---

 src/compiler/spirv/vtn_cfg.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/compiler/spirv/vtn_cfg.c b/src/compiler/spirv/vtn_cfg.c
index 3d5de378ac..e7d2f9ea61 100644
--- a/src/compiler/spirv/vtn_cfg.c
+++ b/src/compiler/spirv/vtn_cfg.c
@@ -513,7 +513,7 @@ vtn_cfg_walk_blocks(struct vtn_builder *b, struct list_head 
*cf_list,
  "Selector of OpSelect must have a type of OpTypeInt");
 
  bool is_default = true;
- const uint bitsize = nir_alu_type_get_type_size(cond_type);
+ const unsigned bitsize = nir_alu_type_get_type_size(cond_type);
  for (const uint32_t *w = block->branch + 2; w < branch_end;) {
 uint64_t literal = 0;
 if (!is_default) {

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


Mesa (master): nir/spirv: fix MSVC syntax error in vtn_handle_texture()

2018-03-30 Thread Brian Paul
Module: Mesa
Branch: master
Commit: cb619a3c9a49d27f60a2a616f719af17bc9f54d2
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=cb619a3c9a49d27f60a2a616f719af17bc9f54d2

Author: Brian Paul 
Date:   Fri Mar 30 11:09:07 2018 -0600

nir/spirv: fix MSVC syntax error in vtn_handle_texture()

Reviewed-by: Neil Roberts 

---

 src/compiler/spirv/spirv_to_nir.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/compiler/spirv/spirv_to_nir.c 
b/src/compiler/spirv/spirv_to_nir.c
index 2550ef0a23..72ab426e80 100644
--- a/src/compiler/spirv/spirv_to_nir.c
+++ b/src/compiler/spirv/spirv_to_nir.c
@@ -2086,8 +2086,9 @@ vtn_handle_texture(struct vtn_builder *b, SpvOp opcode,
  (*p++) = vtn_tex_src(b, w[idx++], nir_tex_src_offset);
 
   if (operands & SpvImageOperandsConstOffsetsMask) {
+ nir_tex_src none = {0};
  gather_offsets = vtn_ssa_value(b, w[idx++]);
- (*p++) = (nir_tex_src){};
+ (*p++) = none;
   }
 
   if (operands & SpvImageOperandsSampleMask) {

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


Mesa (master): nir/spirv: fix MSVC warning in vtn_align_u32()

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

Author: Brian Paul 
Date:   Fri Mar 30 11:06:50 2018 -0600

nir/spirv: fix MSVC warning in vtn_align_u32()

Fixes warning that "negation of an unsigned value results in an
unsigned value".

Reviewed-by: Neil Roberts 

---

 src/compiler/spirv/vtn_private.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/compiler/spirv/vtn_private.h b/src/compiler/spirv/vtn_private.h
index d8a00f99b9..269de92225 100644
--- a/src/compiler/spirv/vtn_private.h
+++ b/src/compiler/spirv/vtn_private.h
@@ -732,7 +732,7 @@ void vtn_handle_decoration(struct vtn_builder *b, SpvOp 
opcode,
 static inline uint32_t
 vtn_align_u32(uint32_t v, uint32_t a)
 {
-   assert(a != 0 && a == (a & -a));
+   assert(a != 0 && a == (a & -((int32_t) a)));
return (v + a - 1) & ~(a - 1);
 }
 

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


Mesa (master): spirv: Fix building with SCons

2018-03-30 Thread Brian Paul
Module: Mesa
Branch: master
Commit: 31d91f019b58ca362c05db1fd0c75fedd169cd7b
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=31d91f019b58ca362c05db1fd0c75fedd169cd7b

Author: Neil Roberts 
Date:   Fri Mar 30 09:12:00 2018 -0600

spirv: Fix building with SCons

The SCons build broke with commit ba975140d3c9 because a SPIR-V
function is called from Mesa main. This adds a convenience library for
SPIR-V and adds it to everything that was including nir. It also adds
both nir and spirv to drivers/x11/SConscript.

Also add nir/spirv modules to osmesa and libgl-gdi targets. (Brian Paul)

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=105817
Reviewed-by: Brian Paul 
Tested-by: Brian Paul 

---

 src/compiler/Makefile.nir.am  |  3 +-
 src/compiler/SConscript   |  1 +
 src/compiler/SConscript.spirv | 54 +++
 src/gallium/targets/dri/SConscript|  1 +
 src/gallium/targets/haiku-softpipe/SConscript |  1 +
 src/gallium/targets/libgl-gdi/SConscript  |  6 ++-
 src/gallium/targets/libgl-xlib/SConscript |  1 +
 src/gallium/targets/osmesa/SConscript |  1 +
 src/mesa/drivers/osmesa/SConscript|  2 +
 src/mesa/drivers/x11/SConscript   |  2 +
 10 files changed, 70 insertions(+), 2 deletions(-)

diff --git a/src/compiler/Makefile.nir.am b/src/compiler/Makefile.nir.am
index 32e4145b70..27dc129e57 100644
--- a/src/compiler/Makefile.nir.am
+++ b/src/compiler/Makefile.nir.am
@@ -100,4 +100,5 @@ EXTRA_DIST += \
nir/nir_opt_algebraic.py\
nir/tests \
nir/README \
-   SConscript.nir
+   SConscript.nir \
+   SConstript.spirv
diff --git a/src/compiler/SConscript b/src/compiler/SConscript
index 44509a9a95..0a0c073742 100644
--- a/src/compiler/SConscript
+++ b/src/compiler/SConscript
@@ -27,3 +27,4 @@ Export('compiler')
 
 SConscript('SConscript.glsl')
 SConscript('SConscript.nir')
+SConscript('SConscript.spirv')
diff --git a/src/compiler/SConscript.spirv b/src/compiler/SConscript.spirv
new file mode 100644
index 00..49410881d0
--- /dev/null
+++ b/src/compiler/SConscript.spirv
@@ -0,0 +1,54 @@
+import common
+
+Import('*')
+
+from sys import executable as python_cmd
+
+env = env.Clone()
+
+env.MSVC2013Compat()
+
+env.Prepend(CPPPATH = [
+'#include',
+'#src',
+'#src/mapi',
+'#src/mesa',
+'#src/gallium/include',
+'#src/gallium/auxiliary',
+'#src/compiler/nir',
+'#src/compiler/spirv',
+])
+
+# Make generated headers reachable from the include path.
+env.Prepend(CPPPATH = [Dir('.').abspath, Dir('nir').abspath])
+env.Prepend(CPPPATH = [Dir('.').abspath, Dir('spirv').abspath])
+
+# spirv generated sources
+
+env.CodeGenerate(
+target = 'spirv/spirv_info.c',
+script = 'spirv/spirv_info_c.py',
+source = ['spirv/spirv.core.grammar.json'],
+command = python_cmd + ' $SCRIPT $SOURCE $TARGET'
+)
+
+env.CodeGenerate(
+target = 'spirv/vtn_gather_types.c',
+script = 'spirv/vtn_gather_types_c.py',
+source = ['spirv/spirv.core.grammar.json'],
+command = python_cmd + ' $SCRIPT $SOURCE $TARGET'
+)
+
+# parse Makefile.sources
+source_lists = env.ParseSourceList('Makefile.sources')
+
+spirv_sources = source_lists['SPIRV_FILES']
+spirv_sources += source_lists['SPIRV_GENERATED_FILES']
+
+spirv = env.ConvenienceLibrary(
+target = 'spirv',
+source = spirv_sources,
+)
+
+env.Alias('spirv', spirv)
+Export('spirv')
diff --git a/src/gallium/targets/dri/SConscript 
b/src/gallium/targets/dri/SConscript
index f5c2818d04..ff6ce3bf4e 100644
--- a/src/gallium/targets/dri/SConscript
+++ b/src/gallium/targets/dri/SConscript
@@ -45,6 +45,7 @@ env.Prepend(LIBS = [
 mesa,
 glsl,
 nir,
+spirv,
 gallium,
 megadrivers_stub,
 dri_common,
diff --git a/src/gallium/targets/haiku-softpipe/SConscript 
b/src/gallium/targets/haiku-softpipe/SConscript
index f80c167d83..89792fba13 100644
--- a/src/gallium/targets/haiku-softpipe/SConscript
+++ b/src/gallium/targets/haiku-softpipe/SConscript
@@ -10,6 +10,7 @@ env.Prepend(LIBS = [
 mesa,
 glsl,
 nir,
+spirv,
 gallium
 ])
 
diff --git a/src/gallium/targets/libgl-gdi/SConscript 
b/src/gallium/targets/libgl-gdi/SConscript
index d3251caec5..b5ba0fabcd 100644
--- a/src/gallium/targets/libgl-gdi/SConscript
+++ b/src/gallium/targets/libgl-gdi/SConscript
@@ -18,7 +18,11 @@ env.Append(LIBS = [
 'ws2_32',
 ])
 
-env.Prepend(LIBS = [mesautil])
+env.Prepend(LIBS = [
+mesautil,
+nir,
+spirv
+])
 
 sources = ['libgl_gdi.c']
 drivers = []
diff --git a/src/gallium/targets/libgl-xlib/SConscript 
b/src/gallium/targets/libgl-xlib/SConscript
index a81ac79325..b94ef350b1 100644
--- a/src/gallium/targets/libgl-xlib/SConscript
+++ b/src/gallium/targets/libgl-xlib/SConscript
@@ -33,6 +33,7 @@ env.Prepend(LIBS = [
 mesa,
 glsl,
 nir,
+spirv,
 gallium,
 

Mesa (master): st/mesa: add missing GLSL_TYPE_[U]INT8 cases in st_glsl_type_dword_size()

2018-03-30 Thread Brian Paul
Module: Mesa
Branch: master
Commit: fa18a427e929ecc04a9980e517db96663debea29
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=fa18a427e929ecc04a9980e517db96663debea29

Author: Brian Paul 
Date:   Wed Mar 28 19:38:00 2018 -0600

st/mesa: add missing GLSL_TYPE_[U]INT8 cases in st_glsl_type_dword_size()

Silences a compiler warning about unhandled enum switch cases.

Reviewed-by: Mathias Fröhlich 

---

 src/mesa/state_tracker/st_glsl_types.cpp | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/mesa/state_tracker/st_glsl_types.cpp 
b/src/mesa/state_tracker/st_glsl_types.cpp
index baba2d414b..42d4e9cef2 100644
--- a/src/mesa/state_tracker/st_glsl_types.cpp
+++ b/src/mesa/state_tracker/st_glsl_types.cpp
@@ -124,6 +124,9 @@ st_glsl_type_dword_size(const struct glsl_type *type)
case GLSL_TYPE_INT16:
case GLSL_TYPE_FLOAT16:
   return DIV_ROUND_UP(type->components(), 2);
+   case GLSL_TYPE_UINT8:
+   case GLSL_TYPE_INT8:
+  return DIV_ROUND_UP(type->components(), 4);
case GLSL_TYPE_DOUBLE:
case GLSL_TYPE_UINT64:
case GLSL_TYPE_INT64:

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


Mesa (master): mesa: fix MSVC bitshift overflow warnings

2018-03-30 Thread Brian Paul
Module: Mesa
Branch: master
Commit: cdc34e2cea73b7932e51ad407595d487d2d565c3
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=cdc34e2cea73b7932e51ad407595d487d2d565c3

Author: Brian Paul 
Date:   Fri Mar 30 09:06:01 2018 -0600

mesa: fix MSVC bitshift overflow warnings

In the BITFIELD_MASK() macro, if b==32 the expression evaluates to
~0u, but the compiler still sees the expression (1 << 32) in the
unused part and issues a warning about integer bitshift overflow.

Fix that by using (b) % 32 to ensure the max shift is 31 bits.

This issue has been present for a while, but shows up much more
often because of the recent VBO changes.

Reviewed-by: Mathias Fröhlich 
Reviewed-by: Roland Scheidegger 

---

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

diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 801bd17666..b7a7b34a09 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -59,7 +59,7 @@ extern "C" {
 #define BITFIELD_BIT(b)  ((GLbitfield)1 << (b))
 /** Set all bits up to excluding bit b */
 #define BITFIELD_MASK(b)  \
-   ((b) == 32 ? (~(GLbitfield)0) : BITFIELD_BIT(b) - 1)
+   ((b) == 32 ? (~(GLbitfield)0) : BITFIELD_BIT((b) % 32) - 1)
 /** Set count bits starting from bit b  */
 #define BITFIELD_RANGE(b, count) \
(BITFIELD_MASK((b) + (count)) & ~BITFIELD_MASK(b))

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


Mesa (master): vbo: MaxVertexAttribStride is not always set

2018-03-30 Thread Jakob Bornecrantz
Module: Mesa
Branch: master
Commit: e16b92ad7eee358dd419f82912ca23f7b6843baa
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=e16b92ad7eee358dd419f82912ca23f7b6843baa

Author: Jakob Bornecrantz 
Date:   Fri Mar 30 16:00:09 2018 +0100

vbo: MaxVertexAttribStride is not always set

This assert is hit on hardware which does not expose GL 4.4 or GLES 3.1.

Reviewed-by: Mathias Fröhlich 
Signed-off-by: Jakob Bornecrantz 

---

 src/mesa/vbo/vbo_save_api.c | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/mesa/vbo/vbo_save_api.c b/src/mesa/vbo/vbo_save_api.c
index a367a569c8..71304ede49 100644
--- a/src/mesa/vbo/vbo_save_api.c
+++ b/src/mesa/vbo/vbo_save_api.c
@@ -492,8 +492,13 @@ update_vao(struct gl_context *ctx,
_mesa_reference_vao(ctx, vao, NULL);
*vao = _mesa_new_vao(ctx, ~((GLuint)0));
 
+   /*
+* assert(stride <= ctx->Const.MaxVertexAttribStride);
+* MaxVertexAttribStride is not set for drivers that does not
+* expose GL 44 or GLES 31.
+*/
+
/* Bind the buffer object at binding point 0 */
-   assert(stride <= ctx->Const.MaxVertexAttribStride);
_mesa_bind_vertex_buffer(ctx, *vao, 0, bo, buffer_offset, stride, false);
 
/* Retrieve the mapping from VBO_ATTRIB to VERT_ATTRIB space

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


Mesa (master): x11: Only report supported DRI3/Present versions

2018-03-30 Thread Daniel Stone
Module: Mesa
Branch: master
Commit: 696762eef57e83b4027acbdf0a6e74d1f75083b0
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=696762eef57e83b4027acbdf0a6e74d1f75083b0

Author: Daniel Stone 
Date:   Thu Mar 22 15:23:49 2018 +

x11: Only report supported DRI3/Present versions

The version passed to QueryVersion requests is the version that the
client supports. We were just passing in whatever version of XCB was
present on the system, which may not be a version that Mesa actually
explicitly supports, e.g. it might bring unwanted semantics.

Set specific protocol versions which we support, and only pass those.

Signed-off-by: Daniel Stone 
Fixes: 7aeef2d4efd ("dri3: allow building against older xcb (v3)")
Reviewed-by: Emil Velikov 

---

 src/egl/drivers/dri2/platform_x11_dri3.c | 20 
 src/glx/dri3_glx.c   | 22 --
 2 files changed, 32 insertions(+), 10 deletions(-)

diff --git a/src/egl/drivers/dri2/platform_x11_dri3.c 
b/src/egl/drivers/dri2/platform_x11_dri3.c
index 5e531e21cb..a41e40156d 100644
--- a/src/egl/drivers/dri2/platform_x11_dri3.c
+++ b/src/egl/drivers/dri2/platform_x11_dri3.c
@@ -520,6 +520,18 @@ struct dri2_egl_display_vtbl dri3_x11_display_vtbl = {
.close_screen_notify = dri3_close_screen_notify,
 };
 
+/* Only request versions of these protocols which we actually support. */
+#define DRI3_SUPPORTED_MAJOR 1
+#define PRESENT_SUPPORTED_MAJOR 1
+
+#ifdef HAVE_DRI3_MODIFIERS
+#define DRI3_SUPPORTED_MINOR 2
+#define PRESENT_SUPPORTED_MINOR 2
+#else
+#define PRESENT_SUPPORTED_MINOR 0
+#define DRI3_SUPPORTED_MINOR 0
+#endif
+
 EGLBoolean
 dri3_x11_connect(struct dri2_egl_display *dri2_dpy)
 {
@@ -542,12 +554,12 @@ dri3_x11_connect(struct dri2_egl_display *dri2_dpy)
   return EGL_FALSE;
 
dri3_query_cookie = xcb_dri3_query_version(dri2_dpy->conn,
-  XCB_DRI3_MAJOR_VERSION,
-  XCB_DRI3_MINOR_VERSION);
+  DRI3_SUPPORTED_MAJOR,
+  DRI3_SUPPORTED_MINOR);
 
present_query_cookie = xcb_present_query_version(dri2_dpy->conn,
-XCB_PRESENT_MAJOR_VERSION,
-XCB_PRESENT_MINOR_VERSION);
+PRESENT_SUPPORTED_MAJOR,
+PRESENT_SUPPORTED_MINOR);
 
dri3_query =
   xcb_dri3_query_version_reply(dri2_dpy->conn, dri3_query_cookie, );
diff --git a/src/glx/dri3_glx.c b/src/glx/dri3_glx.c
index c48a8ba532..ce60b95c71 100644
--- a/src/glx/dri3_glx.c
+++ b/src/glx/dri3_glx.c
@@ -1026,6 +1026,18 @@ dri3_destroy_display(__GLXDRIdisplay * dpy)
free(dpy);
 }
 
+/* Only request versions of these protocols which we actually support. */
+#define DRI3_SUPPORTED_MAJOR 1
+#define PRESENT_SUPPORTED_MAJOR 1
+
+#ifdef HAVE_DRI3_MODIFIERS
+#define DRI3_SUPPORTED_MINOR 2
+#define PRESENT_SUPPORTED_MINOR 2
+#else
+#define PRESENT_SUPPORTED_MINOR 0
+#define DRI3_SUPPORTED_MINOR 0
+#endif
+
 /** dri3_create_display
  *
  * Allocate, initialize and return a __DRIdisplayPrivate object.
@@ -1057,13 +1069,11 @@ dri3_create_display(Display * dpy)
   return NULL;
 
dri3_cookie = xcb_dri3_query_version(c,
-XCB_DRI3_MAJOR_VERSION,
-XCB_DRI3_MINOR_VERSION);
-
-
+DRI3_SUPPORTED_MAJOR,
+DRI3_SUPPORTED_MINOR);
present_cookie = xcb_present_query_version(c,
-   XCB_PRESENT_MAJOR_VERSION,
-   XCB_PRESENT_MINOR_VERSION);
+  PRESENT_SUPPORTED_MAJOR,
+  PRESENT_SUPPORTED_MINOR);
 
pdp = malloc(sizeof *pdp);
if (pdp == NULL)

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


Mesa (master): radv: set SAMPLE_RATE to the number of samples of the current fb

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

Author: Samuel Pitoiset 
Date:   Mon Mar 26 11:28:48 2018 +0200

radv: set SAMPLE_RATE to the number of samples of the current fb

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

---

 src/amd/vulkan/radv_cmd_buffer.c |  7 +--
 src/amd/vulkan/radv_pass.c   | 12 ++--
 src/amd/vulkan/radv_private.h|  1 +
 3 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/src/amd/vulkan/radv_cmd_buffer.c b/src/amd/vulkan/radv_cmd_buffer.c
index cadb06f0af..f0a0b08678 100644
--- a/src/amd/vulkan/radv_cmd_buffer.c
+++ b/src/amd/vulkan/radv_cmd_buffer.c
@@ -1180,15 +1180,18 @@ void radv_set_db_count_control(struct radv_cmd_buffer 
*cmd_buffer)
db_count_control = S_028004_ZPASS_INCREMENT_DISABLE(1);
}
} else {
+   const struct radv_subpass *subpass = cmd_buffer->state.subpass;
+   uint32_t sample_rate = subpass ? 
util_logbase2(subpass->max_sample_count) : 0;
+
if (cmd_buffer->device->physical_device->rad_info.chip_class >= 
CIK) {
db_count_control = S_028004_PERFECT_ZPASS_COUNTS(1) |
-   S_028004_SAMPLE_RATE(0) | /* TODO: set this to 
the number of samples of the current framebuffer */
+   S_028004_SAMPLE_RATE(sample_rate) |
S_028004_ZPASS_ENABLE(1) |
S_028004_SLICE_EVEN_ENABLE(1) |
S_028004_SLICE_ODD_ENABLE(1);
} else {
db_count_control = S_028004_PERFECT_ZPASS_COUNTS(1) |
-   S_028004_SAMPLE_RATE(0); /* TODO: set this to 
the number of samples of the current framebuffer */
+   S_028004_SAMPLE_RATE(sample_rate);
}
}
 
diff --git a/src/amd/vulkan/radv_pass.c b/src/amd/vulkan/radv_pass.c
index 3028955716..d059af54f9 100644
--- a/src/amd/vulkan/radv_pass.c
+++ b/src/amd/vulkan/radv_pass.c
@@ -106,6 +106,7 @@ VkResult radv_CreateRenderPass(
p = pass->subpass_attachments;
for (uint32_t i = 0; i < pCreateInfo->subpassCount; i++) {
const VkSubpassDescription *desc = >pSubpasses[i];
+   uint32_t color_sample_count = 1, depth_sample_count = 1;
struct radv_subpass *subpass = >subpasses[i];
 
subpass->input_count = desc->inputAttachmentCount;
@@ -132,8 +133,10 @@ VkResult radv_CreateRenderPass(
for (uint32_t j = 0; j < desc->colorAttachmentCount; 
j++) {
subpass->color_attachments[j]
= desc->pColorAttachments[j];
-   if (desc->pColorAttachments[j].attachment != 
VK_ATTACHMENT_UNUSED)
+   if (desc->pColorAttachments[j].attachment != 
VK_ATTACHMENT_UNUSED) {

pass->attachments[desc->pColorAttachments[j].attachment].view_mask |= 
subpass->view_mask;
+   color_sample_count = 
pCreateInfo->pAttachments[desc->pColorAttachments[j].attachment].samples;
+   }
}
}
 
@@ -156,11 +159,16 @@ VkResult radv_CreateRenderPass(
if (desc->pDepthStencilAttachment) {
subpass->depth_stencil_attachment =
*desc->pDepthStencilAttachment;
-   if (desc->pDepthStencilAttachment->attachment != 
VK_ATTACHMENT_UNUSED)
+   if (desc->pDepthStencilAttachment->attachment != 
VK_ATTACHMENT_UNUSED) {

pass->attachments[desc->pDepthStencilAttachment->attachment].view_mask |= 
subpass->view_mask;
+   depth_sample_count = 
pCreateInfo->pAttachments[desc->pDepthStencilAttachment->attachment].samples;
+   }
} else {
subpass->depth_stencil_attachment.attachment = 
VK_ATTACHMENT_UNUSED;
}
+
+   subpass->max_sample_count = MAX2(color_sample_count,
+depth_sample_count);
}
 
for (unsigned i = 0; i < pCreateInfo->dependencyCount; ++i) {
diff --git a/src/amd/vulkan/radv_private.h b/src/amd/vulkan/radv_private.h
index ce2e487bdb..a5cbad6cfe 100644
--- a/src/amd/vulkan/radv_private.h
+++ b/src/amd/vulkan/radv_private.h
@@ -1586,6 +1586,7 @@ struct radv_subpass {
struct radv_subpass_barrier  start_barrier;
 
uint32_t view_mask;
+   VkSampleCountFlagBits  

Mesa (master): nir: s/uint/unsigned/ to fix MSVC/MinGW build

2018-03-30 Thread Brian Paul
Module: Mesa
Branch: master
Commit: fc1d1dbe81e16041ec0d84811d171f7d42975eea
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=fc1d1dbe81e16041ec0d84811d171f7d42975eea

Author: Brian Paul 
Date:   Thu Mar 29 22:02:37 2018 -0600

nir: s/uint/unsigned/ to fix MSVC/MinGW build

Reviewed-by: Roland Scheidegger 
Reviewed-by: Neha Bhende 

---

 src/compiler/glsl/glsl_to_nir.cpp  | 2 +-
 src/compiler/nir/nir_gather_info.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/compiler/glsl/glsl_to_nir.cpp 
b/src/compiler/glsl/glsl_to_nir.cpp
index c4a6d52a5b..dbb58d82e8 100644
--- a/src/compiler/glsl/glsl_to_nir.cpp
+++ b/src/compiler/glsl/glsl_to_nir.cpp
@@ -369,7 +369,7 @@ nir_visitor::visit(ir_variable *ir)
   /* Mark all the locations that require two slots */
   if (shader->info.stage == MESA_SHADER_VERTEX &&
   glsl_type_is_dual_slot(glsl_without_array(var->type))) {
- for (uint i = 0; i < glsl_count_attribute_slots(var->type, true); 
i++) {
+ for (unsigned i = 0; i < glsl_count_attribute_slots(var->type, true); 
i++) {
 uint64_t bitfield = BITFIELD64_BIT(var->data.location + i);
 shader->info.vs.double_inputs |= bitfield;
  }
diff --git a/src/compiler/nir/nir_gather_info.c 
b/src/compiler/nir/nir_gather_info.c
index 743f968035..5530009255 100644
--- a/src/compiler/nir/nir_gather_info.c
+++ b/src/compiler/nir/nir_gather_info.c
@@ -250,7 +250,7 @@ gather_intrinsic_info(nir_intrinsic_instr *instr, 
nir_shader *shader)
  if (shader->info.stage == MESA_SHADER_VERTEX &&
  var->data.mode == nir_var_shader_in &&
  glsl_type_is_dual_slot(glsl_without_array(var->type))) {
-for (uint i = 0; i < glsl_count_attribute_slots(var->type, false); 
i++) {
+for (unsigned i = 0; i < glsl_count_attribute_slots(var->type, 
false); i++) {
int idx = var->data.location + i;
shader->info.vs.double_inputs |= BITFIELD64_BIT(idx);
 }

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


Mesa (master): mesa/glspirv: Add a _mesa_spirv_to_nir() function

2018-03-30 Thread Alejandro Pinheiro
Module: Mesa
Branch: master
Commit: abb6d0797c8a0c32f45d38d7a41e96b2db47a47d
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=abb6d0797c8a0c32f45d38d7a41e96b2db47a47d

Author: Eduardo Lima Mitev 
Date:   Fri Oct 13 10:31:50 2017 +0200

mesa/glspirv: Add a _mesa_spirv_to_nir() function

This is basically a wrapper around spirv_to_nir() that includes
arguments setup and post-conversion validation.

v2: * Rebase update (SpirVCapabilities not a pointer anymore,
spirv_to_nir_options added, and others).
* Code-style improvements and remove debug hunk. (Timothy Arceri)

Reviewed-by: Timothy Arceri 

---

 src/mesa/main/glspirv.c | 58 +
 src/mesa/main/glspirv.h |  7 ++
 2 files changed, 65 insertions(+)

diff --git a/src/mesa/main/glspirv.c b/src/mesa/main/glspirv.c
index 7aa06f8e8c..71dc9154ef 100644
--- a/src/mesa/main/glspirv.c
+++ b/src/mesa/main/glspirv.c
@@ -174,6 +174,64 @@ _mesa_spirv_link_shaders(struct gl_context *ctx, struct 
gl_shader_program *prog)
}
 }
 
+nir_shader *
+_mesa_spirv_to_nir(struct gl_context *ctx,
+   const struct gl_shader_program *prog,
+   gl_shader_stage stage,
+   const nir_shader_compiler_options *options)
+{
+   nir_shader *nir = NULL;
+
+   struct gl_linked_shader *linked_shader = prog->_LinkedShaders[stage];
+   assert (linked_shader);
+
+   struct gl_shader_spirv_data *spirv_data = linked_shader->spirv_data;
+   assert(spirv_data);
+
+   struct gl_spirv_module *spirv_module = spirv_data->SpirVModule;
+   assert (spirv_module != NULL);
+
+   const char *entry_point_name = spirv_data->SpirVEntryPoint;
+   assert(entry_point_name);
+
+   struct nir_spirv_specialization *spec_entries =
+  calloc(sizeof(*spec_entries),
+ spirv_data->NumSpecializationConstants);
+
+   for (unsigned i = 0; i < spirv_data->NumSpecializationConstants; ++i) {
+  spec_entries[i].id = spirv_data->SpecializationConstantsIndex[i];
+  spec_entries[i].data32 = spirv_data->SpecializationConstantsValue[i];
+  spec_entries[i].defined_on_module = false;
+   }
+
+   const struct spirv_to_nir_options spirv_options = {
+  .caps = ctx->Const.SpirVCapabilities
+   };
+
+   nir_function *entry_point =
+  spirv_to_nir((const uint32_t *) _module->Binary[0],
+   spirv_module->Length / 4,
+   spec_entries, spirv_data->NumSpecializationConstants,
+   stage, entry_point_name,
+   _options,
+   options);
+   free(spec_entries);
+
+   assert (entry_point);
+   nir = entry_point->shader;
+   assert(nir->info.stage == stage);
+
+   nir->options = options;
+
+   nir->info.name =
+  ralloc_asprintf(nir, "SPIRV:%s:%d",
+  _mesa_shader_stage_to_abbrev(nir->info.stage),
+  prog->Name);
+   nir_validate_shader(nir);
+
+   return nir;
+}
+
 void GLAPIENTRY
 _mesa_SpecializeShaderARB(GLuint shader,
   const GLchar *pEntryPoint,
diff --git a/src/mesa/main/glspirv.h b/src/mesa/main/glspirv.h
index 0f03b75c11..81626ce75b 100644
--- a/src/mesa/main/glspirv.h
+++ b/src/mesa/main/glspirv.h
@@ -24,6 +24,7 @@
 #ifndef GLSPIRV_H
 #define GLSPIRV_H
 
+#include "compiler/nir/nir.h"
 #include "mtypes.h"
 
 #ifdef __cplusplus
@@ -80,6 +81,12 @@ void
 _mesa_spirv_link_shaders(struct gl_context *ctx,
  struct gl_shader_program *prog);
 
+nir_shader *
+_mesa_spirv_to_nir(struct gl_context *ctx,
+   const struct gl_shader_program *prog,
+   gl_shader_stage stage,
+   const nir_shader_compiler_options *options);
+
 /**
  * \name API functions
  */

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


Mesa (master): i965: Call spirv_to_nir() instead of glsl_to_nir() for SPIR-V shaders

2018-03-30 Thread Alejandro Pinheiro
Module: Mesa
Branch: master
Commit: e7d97aa75ded652a36e8addad52d075c51b58c33
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=e7d97aa75ded652a36e8addad52d075c51b58c33

Author: Eduardo Lima Mitev 
Date:   Tue Oct 10 14:55:56 2017 +0200

i965: Call spirv_to_nir() instead of glsl_to_nir() for SPIR-V shaders

This is the main fork of the shader compilation code-path, where a NIR
shader is obtained by calling spirv_to_nir() or glsl_to_nir(),
depending on its nature..

v2: Use 'spirv_data' member from gl_linked_shader to know which method
   to call. (Timothy Arceri)

Reviewed-by: Timothy Arceri 

---

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

diff --git a/src/mesa/drivers/dri/i965/brw_program.c 
b/src/mesa/drivers/dri/i965/brw_program.c
index 4579a58b82..fc77926d6e 100644
--- a/src/mesa/drivers/dri/i965/brw_program.c
+++ b/src/mesa/drivers/dri/i965/brw_program.c
@@ -31,6 +31,7 @@
 
 #include 
 #include "main/imports.h"
+#include "main/glspirv.h"
 #include "program/prog_parameter.h"
 #include "program/prog_print.h"
 #include "program/prog_to_nir.h"
@@ -74,9 +75,14 @@ brw_create_nir(struct brw_context *brw,
   ctx->Const.ShaderCompilerOptions[stage].NirOptions;
nir_shader *nir;
 
-   /* First, lower the GLSL IR or Mesa IR to NIR */
+   /* First, lower the GLSL/Mesa IR or SPIR-V to NIR */
if (shader_prog) {
-  nir = glsl_to_nir(shader_prog, stage, options);
+  if (shader_prog->_LinkedShaders[stage]->spirv_data)
+ nir = _mesa_spirv_to_nir(ctx, shader_prog, stage, options);
+  else
+ nir = glsl_to_nir(shader_prog, stage, options);
+  assert (nir);
+
   nir_remove_dead_variables(nir, nir_var_shader_in | nir_var_shader_out);
   nir_lower_returns(nir);
   nir_validate_shader(nir);

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


Mesa (master): mesa: Implement glSpecializeShaderARB

2018-03-30 Thread Alejandro Pinheiro
Module: Mesa
Branch: master
Commit: ba975140d3c99b60c63846c3c08bd158f7c95d42
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=ba975140d3c99b60c63846c3c08bd158f7c95d42

Author: Nicolai Hähnle 
Date:   Sat Jun 10 21:36:24 2017 +0200

mesa: Implement glSpecializeShaderARB

v2:
  * Use gl_spirv_validation instead of spirv_to_nir.  This method just
validates the shader. The conversion to NIR will happen later,
during linking. (Alejandro Piñeiro)
  * Use gl_shader_spirv_data struct to store the SPIR-V data.
(Eduardo Lima)
  * Use the 'spirv_data' member to tell if the gl_shader is a SPIR-V
shader, instead of a dedicated flag. (Timothy Arceri)

Signed-off-by: Nicolai Hähnle 
Signed-off-by: Alejandro Piñeiro 
Signed-off-by: Eduardo Lima Mitev 

Reviewed-by: Timothy Arceri 

---

 src/mesa/main/glspirv.c | 107 +++-
 1 file changed, 105 insertions(+), 2 deletions(-)

diff --git a/src/mesa/main/glspirv.c b/src/mesa/main/glspirv.c
index 03f761219b..b1185ca5fd 100644
--- a/src/mesa/main/glspirv.c
+++ b/src/mesa/main/glspirv.c
@@ -23,6 +23,11 @@
 
 #include "glspirv.h"
 #include "errors.h"
+#include "shaderobj.h"
+
+#include "compiler/nir/nir.h"
+#include "compiler/spirv/nir_spirv.h"
+
 #include "util/u_atomic.h"
 
 void
@@ -106,7 +111,105 @@ _mesa_SpecializeShaderARB(GLuint shader,
   const GLuint *pConstantValue)
 {
GET_CURRENT_CONTEXT(ctx);
+   struct gl_shader *sh;
+   bool has_entry_point;
+   struct nir_spirv_specialization *spec_entries = NULL;
+
+   if (!ctx->Extensions.ARB_gl_spirv) {
+  _mesa_error(ctx, GL_INVALID_OPERATION, "glSpecializeShaderARB");
+  return;
+   }
+
+   sh = _mesa_lookup_shader_err(ctx, shader, "glSpecializeShaderARB");
+   if (!sh)
+  return;
+
+   if (!sh->spirv_data) {
+  _mesa_error(ctx, GL_INVALID_OPERATION,
+  "glSpecializeShaderARB(not SPIR-V)");
+  return;
+   }
+
+   if (sh->CompileStatus) {
+  _mesa_error(ctx, GL_INVALID_OPERATION,
+  "glSpecializeShaderARB(already specialized)");
+  return;
+   }
+
+   struct gl_shader_spirv_data *spirv_data = sh->spirv_data;
+
+   /* From the GL_ARB_gl_spirv spec:
+*
+*"The OpenGL API expects the SPIR-V module to have already been
+* validated, and can return an error if it discovers anything invalid
+* in the module. An invalid SPIR-V module is allowed to result in
+* undefined behavior."
+*
+* However, the following errors still need to be detected (from the same
+* spec):
+*
+*"INVALID_VALUE is generated if  does not name a valid
+* entry point for .
+*
+* INVALID_VALUE is generated if any element of 
+* refers to a specialization constant that does not exist in the
+* shader module contained in ."
+*
+* We cannot flag those errors a-priori because detecting them requires
+* parsing the module. However, flagging them during specialization is okay,
+* since it makes no difference in terms of application-visible state.
+*/
+   spec_entries = calloc(sizeof(*spec_entries), numSpecializationConstants);
+
+   for (unsigned i = 0; i < numSpecializationConstants; ++i) {
+  spec_entries[i].id = pConstantIndex[i];
+  spec_entries[i].data32 = pConstantValue[i];
+  spec_entries[i].defined_on_module = false;
+   }
+
+   has_entry_point =
+  gl_spirv_validation((uint32_t *)_data->SpirVModule->Binary[0],
+  spirv_data->SpirVModule->Length / 4,
+  spec_entries, numSpecializationConstants,
+  sh->Stage, pEntryPoint);
+
+   /* See previous spec comment */
+   if (!has_entry_point) {
+  _mesa_error(ctx, GL_INVALID_VALUE,
+  "glSpecializeShaderARB(\"%s\" is not a valid entry point"
+  " for shader)", pEntryPoint);
+  goto end;
+   }
+
+   for (unsigned i = 0; i < numSpecializationConstants; ++i) {
+  if (spec_entries[i].defined_on_module == false) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glSpecializeShaderARB(constant \"%i\" does not exist "
+ "in shader)", spec_entries[i].id);
+ goto end;
+  }
+   }
+
+   spirv_data->SpirVEntryPoint = ralloc_strdup(spirv_data, pEntryPoint);
+
+   /* Note that we didn't make a real compilation of the module (spirv_to_nir),
+* but just checked some error conditions. Real "compilation" will be done
+* later, upon linking.
+*/
+   sh->CompileStatus = COMPILE_SUCCESS;
+
+   spirv_data->NumSpecializationConstants = numSpecializationConstants;
+   spirv_data->SpecializationConstantsIndex =
+  rzalloc_array_size(spirv_data, sizeof(GLuint),
+ numSpecializationConstants);
+   spirv_data->SpecializationConstantsValue =
+  

Mesa (master): mesa/glspirv: Add _mesa_spirv_link_shaders() function

2018-03-30 Thread Alejandro Pinheiro
Module: Mesa
Branch: master
Commit: 9c36e9f8626fb2b02736abbd11e783b61a40959c
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=9c36e9f8626fb2b02736abbd11e783b61a40959c

Author: Eduardo Lima Mitev 
Date:   Tue Oct 10 10:46:29 2017 +0200

mesa/glspirv: Add _mesa_spirv_link_shaders() function

This is the equivalent to link_shaders() from
src/compiler/glsl/linker.cpp, but for SPIR-V programs. It just
creates the program and its gl_linked_shader objects, giving drivers
the opportunity to implement any linking of SPIR-V shaders they choose,
at a later stage.

v2: Bail out if we see more that one shader for the same stage, and
add a corresponding comment. (Timothy Arceri)

v3:
  * Adds also a linker error log to the condition above, with a
reference to the specification issue. (Timothy Arceri)
  * Squash with the patch adding the function boilerplate (Timothy
Arceri)

Reviewed-by: Timothy Arceri 

---

 src/mesa/main/glspirv.c | 71 +
 src/mesa/main/glspirv.h |  4 +++
 2 files changed, 75 insertions(+)

diff --git a/src/mesa/main/glspirv.c b/src/mesa/main/glspirv.c
index b1185ca5fd..7aa06f8e8c 100644
--- a/src/mesa/main/glspirv.c
+++ b/src/mesa/main/glspirv.c
@@ -28,6 +28,8 @@
 #include "compiler/nir/nir.h"
 #include "compiler/spirv/nir_spirv.h"
 
+#include "program/program.h"
+
 #include "util/u_atomic.h"
 
 void
@@ -103,6 +105,75 @@ _mesa_spirv_shader_binary(struct gl_context *ctx,
}
 }
 
+/**
+ * This is the equivalent to compiler/glsl/linker.cpp::link_shaders()
+ * but for SPIR-V programs.
+ *
+ * This method just creates the gl_linked_shader structs with a reference to
+ * the SPIR-V data collected during previous steps.
+ *
+ * The real linking happens later in the driver-specifc call LinkShader().
+ * This is so backends can implement different linking strategies for
+ * SPIR-V programs.
+ */
+void
+_mesa_spirv_link_shaders(struct gl_context *ctx, struct gl_shader_program 
*prog)
+{
+   prog->data->LinkStatus = LINKING_SUCCESS;
+   prog->data->Validated = false;
+
+   for (unsigned i = 0; i < prog->NumShaders; i++) {
+  struct gl_shader *shader = prog->Shaders[i];
+  gl_shader_stage shader_type = shader->Stage;
+
+  /* We only support one shader per stage. The gl_spirv spec doesn't seem
+   * to prevent this, but the way the API is designed, requiring all 
shaders
+   * to be specialized with an entry point, makes supporting this quite
+   * undefined.
+   *
+   * TODO: Turn this into a proper error once the spec bug
+   *  is resolved.
+   */
+  if (prog->_LinkedShaders[shader_type]) {
+ ralloc_strcat(>data->InfoLog,
+   "\nError trying to link more than one SPIR-V shader "
+   "per stage.\n");
+ prog->data->LinkStatus = LINKING_FAILURE;
+ return;
+  }
+
+  assert(shader->spirv_data);
+
+  struct gl_linked_shader *linked = rzalloc(NULL, struct gl_linked_shader);
+  linked->Stage = shader_type;
+
+  /* Create program and attach it to the linked shader */
+  struct gl_program *gl_prog =
+ ctx->Driver.NewProgram(ctx,
+_mesa_shader_stage_to_program(shader_type),
+prog->Name, false);
+  if (!gl_prog) {
+ prog->data->LinkStatus = LINKING_FAILURE;
+ _mesa_delete_linked_shader(ctx, linked);
+ return;
+  }
+
+  _mesa_reference_shader_program_data(ctx,
+  _prog->sh.data,
+  prog->data);
+
+  /* Don't use _mesa_reference_program() just take ownership */
+  linked->Program = gl_prog;
+
+  /* Reference the SPIR-V data from shader to the linked shader */
+  _mesa_shader_spirv_data_reference(>spirv_data,
+shader->spirv_data);
+
+  prog->_LinkedShaders[shader_type] = linked;
+  prog->data->linked_stages |= 1 << shader_type;
+   }
+}
+
 void GLAPIENTRY
 _mesa_SpecializeShaderARB(GLuint shader,
   const GLchar *pEntryPoint,
diff --git a/src/mesa/main/glspirv.h b/src/mesa/main/glspirv.h
index ba281f68be..0f03b75c11 100644
--- a/src/mesa/main/glspirv.h
+++ b/src/mesa/main/glspirv.h
@@ -76,6 +76,10 @@ _mesa_spirv_shader_binary(struct gl_context *ctx,
   unsigned n, struct gl_shader **shaders,
   const void* binary, size_t length);
 
+void
+_mesa_spirv_link_shaders(struct gl_context *ctx,
+ struct gl_shader_program *prog);
+
 /**
  * \name API functions
  */

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


Mesa (master): mesa: add gl_constants::SpirVCapabilities

2018-03-30 Thread Alejandro Pinheiro
Module: Mesa
Branch: master
Commit: ca5cc78206b993c8d7e765ed4350a1f62a2ee5ed
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=ca5cc78206b993c8d7e765ed4350a1f62a2ee5ed

Author: Nicolai Hähnle 
Date:   Sat Jun 10 21:35:26 2017 +0200

mesa: add gl_constants::SpirVCapabilities

For drivers to declare which SPIR-V features they support.

v2: Don't use a pointer (Ian Romanick)

Reviewed-by: Timothy Arceri 

---

 src/mesa/main/mtypes.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 08db8062ec..9ded02500d 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -4135,6 +4135,9 @@ struct gl_constants
 
/** Is the drivers uniform storage packed or padded to 16 bytes. */
bool PackedDriverUniformStorage;
+
+   /** GL_ARB_gl_spirv */
+   struct spirv_supported_capabilities SpirVCapabilities;
 };
 
 

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


Mesa (master): i965: initialize SPIR-V capabilities

2018-03-30 Thread Alejandro Pinheiro
Module: Mesa
Branch: master
Commit: 3761e675e27b85f43fe86afe37326c9012577e4b
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=3761e675e27b85f43fe86afe37326c9012577e4b

Author: Alejandro Piñeiro 
Date:   Sat Oct 14 09:23:24 2017 +0200

i965: initialize SPIR-V capabilities

Needed for ARB_gl_spirv. Those are not the same that the Intel vulkan
driver. From the ARB_spirv_extensions spec:

   "3. If a new GL extension is added that includes SPIR-V support via
   a new SPIR-V extension does it's SPIR-V extension also get
   enumerated by the SPIR_V_EXTENSIONS_ARB query?.

   RESOLVED. Yes. It's good to include it for consistency. Any SPIR-V
   functionality supported beyond the SPIR-V version that is required
   for the GL API version should be enumerated."

So in addition to the core SPIR-V support, there is the possibility of
specific GL extensions enabling specific SPIR-V extensions (so
capabilities). That would mean that it is possible that OpenGL and
Vulkan not having the same capabilities supported, even for the same
driver. For this reason it is better to keep them separated.

As an example: at the time of this patch writing Intel vulkan driver
support multiview, but there isn't any OpenGL multiview GL extension
supported.

Note: we initialize SPIR-V capabilities at brwCreateContext instead of
the usual brw_initialize_context_constants because we want to do that
only if the extension is enabled.

v2:
   * Rebase update (SpirVCapabilities not a pointer anymore)
   * Fill spirv capabilities for OpenGL >= 3.3 (Ian Romanick)

v3:
   * Drop multiview support, as i965 doesn't support any multiview GL
 extension (Jason)
   * Fill spirv capabilities only if the extension is enabled (Jason)

v4: Capabilities are supported only on gen7+. Added comment and assert
(Jason)

---

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

diff --git a/src/mesa/drivers/dri/i965/brw_context.c 
b/src/mesa/drivers/dri/i965/brw_context.c
index 4e37425099..2e961a1ef6 100644
--- a/src/mesa/drivers/dri/i965/brw_context.c
+++ b/src/mesa/drivers/dri/i965/brw_context.c
@@ -78,6 +78,7 @@
 
 #include "common/gen_defines.h"
 
+#include "compiler/spirv/nir_spirv.h"
 /***
  * Mesa's Driver Functions
  ***/
@@ -344,6 +345,26 @@ brw_init_driver_functions(struct brw_context *brw,
 }
 
 static void
+brw_initialize_spirv_supported_capabilities(struct brw_context *brw)
+{
+   const struct gen_device_info *devinfo = >screen->devinfo;
+   struct gl_context *ctx = >ctx;
+
+   /* The following SPIR-V capabilities are only supported on gen7+. In theory
+* you should enable the extension only on gen7+, but just in case let's
+* assert it.
+*/
+   assert(devinfo->gen >= 7);
+
+   ctx->Const.SpirVCapabilities.float64 = devinfo->gen >= 8;
+   ctx->Const.SpirVCapabilities.int64 = devinfo->gen >= 8;
+   ctx->Const.SpirVCapabilities.tessellation = true;
+   ctx->Const.SpirVCapabilities.draw_parameters = true;
+   ctx->Const.SpirVCapabilities.image_write_without_format = true;
+   ctx->Const.SpirVCapabilities.variable_pointers = true;
+}
+
+static void
 brw_initialize_context_constants(struct brw_context *brw)
 {
const struct gen_device_info *devinfo = >screen->devinfo;
@@ -1062,6 +1083,10 @@ brwCreateContext(gl_api api,
_mesa_override_extensions(ctx);
_mesa_compute_version(ctx);
 
+   /* GL_ARB_gl_spirv */
+   if (ctx->Extensions.ARB_gl_spirv)
+  brw_initialize_spirv_supported_capabilities(brw);
+
_mesa_initialize_dispatch_tables(ctx);
_mesa_initialize_vbo_vtxfmt(ctx);
 

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


Mesa (master): mesa/program: Link SPIR-V shaders using the SPIR-V code-path

2018-03-30 Thread Alejandro Pinheiro
Module: Mesa
Branch: master
Commit: 16f6634e7fb5ada308e55b852cd49251e7f3f8b1
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=16f6634e7fb5ada308e55b852cd49251e7f3f8b1

Author: Eduardo Lima Mitev 
Date:   Tue Oct 10 14:01:45 2017 +0200

mesa/program: Link SPIR-V shaders using the SPIR-V code-path

Reviewed-by: Timothy Arceri 

---

 src/mesa/program/ir_to_mesa.cpp | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp
index b0b322865b..49ef5ea52d 100644
--- a/src/mesa/program/ir_to_mesa.cpp
+++ b/src/mesa/program/ir_to_mesa.cpp
@@ -35,6 +35,7 @@
 #include "main/shaderapi.h"
 #include "main/shaderobj.h"
 #include "main/uniforms.h"
+#include "main/glspirv.h"
 #include "compiler/glsl/ast.h"
 #include "compiler/glsl/ir.h"
 #include "compiler/glsl/ir_expression_flattening.h"
@@ -3154,7 +3155,10 @@ _mesa_glsl_link_shader(struct gl_context *ctx, struct 
gl_shader_program *prog)
}
 
if (prog->data->LinkStatus) {
-  link_shaders(ctx, prog);
+  if (!spirv)
+ link_shaders(ctx, prog);
+  else
+ _mesa_spirv_link_shaders(ctx, prog);
}
 
/* If LinkStatus is LINKING_SUCCESS, then reset sampler validated to true.

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


Mesa (master): mesa: Add a reference to gl_shader_spirv_data to gl_linked_shader

2018-03-30 Thread Alejandro Pinheiro
Module: Mesa
Branch: master
Commit: 22b6b3d0a75406f577dcb6d554c96ed42ee35aff
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=22b6b3d0a75406f577dcb6d554c96ed42ee35aff

Author: Eduardo Lima Mitev 
Date:   Mon Nov 13 19:44:47 2017 +0100

mesa: Add a reference to gl_shader_spirv_data to gl_linked_shader

This is a reference to the spirv_data object stored in gl_shader, which
stores shader SPIR-V data that is needed during linking too.

Reviewed-by: Timothy Arceri 

---

 src/mesa/main/mtypes.h| 8 
 src/mesa/main/shaderobj.c | 1 +
 2 files changed, 9 insertions(+)

diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 9ded02500d..801bd17666 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -2651,6 +2651,14 @@ struct gl_linked_shader
struct exec_list *packed_varyings;
struct exec_list *fragdata_arrays;
struct glsl_symbol_table *symbols;
+
+   /**
+* ARB_gl_spirv related data.
+*
+* This is actually a reference to the gl_shader::spirv_data, which
+* stores information that is also needed during linking.
+*/
+   struct gl_shader_spirv_data *spirv_data;
 };
 
 
diff --git a/src/mesa/main/shaderobj.c b/src/mesa/main/shaderobj.c
index 5c1cdd6b27..834e2a92ec 100644
--- a/src/mesa/main/shaderobj.c
+++ b/src/mesa/main/shaderobj.c
@@ -137,6 +137,7 @@ void
 _mesa_delete_linked_shader(struct gl_context *ctx,
struct gl_linked_shader *sh)
 {
+   _mesa_shader_spirv_data_reference(>spirv_data, NULL);
_mesa_reference_program(ctx, >Program, NULL);
ralloc_free(sh);
 }

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


Mesa (master): spirv: add vtn_create_builder

2018-03-30 Thread Alejandro Pinheiro
Module: Mesa
Branch: master
Commit: bebe3d626e562bd2dd027f9bcd5fdeeab62997cd
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=bebe3d626e562bd2dd027f9bcd5fdeeab62997cd

Author: Alejandro Piñeiro 
Date:   Thu Jan 18 12:24:38 2018 +0100

spirv: add vtn_create_builder

Refactored from spirv_to_nir, in order to be reused later.

Reviewed-by: Timothy Arceri 

v2: renamed method (from vtn_builder_create), add explanatory comment
(Timothy)

---

 src/compiler/spirv/spirv_to_nir.c | 51 ++-
 src/compiler/spirv/vtn_private.h  |  4 +++
 2 files changed, 38 insertions(+), 17 deletions(-)

diff --git a/src/compiler/spirv/spirv_to_nir.c 
b/src/compiler/spirv/spirv_to_nir.c
index 4297622979..d895d82055 100644
--- a/src/compiler/spirv/spirv_to_nir.c
+++ b/src/compiler/spirv/spirv_to_nir.c
@@ -3972,14 +3972,12 @@ vtn_handle_body_instruction(struct vtn_builder *b, 
SpvOp opcode,
return true;
 }
 
-nir_function *
-spirv_to_nir(const uint32_t *words, size_t word_count,
- struct nir_spirv_specialization *spec, unsigned num_spec,
- gl_shader_stage stage, const char *entry_point_name,
- const struct spirv_to_nir_options *options,
- const nir_shader_compiler_options *nir_options)
+struct vtn_builder*
+vtn_create_builder(const uint32_t *words, size_t word_count,
+   gl_shader_stage stage, const char *entry_point_name,
+   const struct spirv_to_nir_options *options)
 {
-   /* Initialize the stn_builder object */
+   /* Initialize the vtn_builder object */
struct vtn_builder *b = rzalloc(NULL, struct vtn_builder);
b->spirv = words;
b->spirv_word_count = word_count;
@@ -3991,14 +3989,6 @@ spirv_to_nir(const uint32_t *words, size_t word_count,
b->entry_point_name = entry_point_name;
b->options = options;
 
-   /* See also _vtn_fail() */
-   if (setjmp(b->fail_jump)) {
-  ralloc_free(b);
-  return NULL;
-   }
-
-   const uint32_t *word_end = words + word_count;
-
/* Handle the SPIR-V header (first 4 dwords)  */
vtn_assert(word_count > 5);
 
@@ -4008,11 +3998,38 @@ spirv_to_nir(const uint32_t *words, size_t word_count,
unsigned value_id_bound = words[3];
vtn_assert(words[4] == 0);
 
-   words+= 5;
-
b->value_id_bound = value_id_bound;
b->values = rzalloc_array(b, struct vtn_value, value_id_bound);
 
+   return b;
+}
+
+nir_function *
+spirv_to_nir(const uint32_t *words, size_t word_count,
+ struct nir_spirv_specialization *spec, unsigned num_spec,
+ gl_shader_stage stage, const char *entry_point_name,
+ const struct spirv_to_nir_options *options,
+ const nir_shader_compiler_options *nir_options)
+
+{
+   const uint32_t *word_end = words + word_count;
+
+   struct vtn_builder *b = vtn_create_builder(words, word_count,
+  stage, entry_point_name,
+  options);
+
+   if (b == NULL)
+  return NULL;
+
+   /* See also _vtn_fail() */
+   if (setjmp(b->fail_jump)) {
+  ralloc_free(b);
+  return NULL;
+   }
+
+   /* Skip the SPIR-V header, handled at vtn_create_builder */
+   words+= 5;
+
/* Handle all the preamble instructions */
words = vtn_foreach_instruction(b, words, word_end,
vtn_handle_preamble_instruction);
diff --git a/src/compiler/spirv/vtn_private.h b/src/compiler/spirv/vtn_private.h
index bbc63ad20d..47d06f0f91 100644
--- a/src/compiler/spirv/vtn_private.h
+++ b/src/compiler/spirv/vtn_private.h
@@ -719,6 +719,10 @@ void vtn_handle_subgroup(struct vtn_builder *b, SpvOp 
opcode,
 bool vtn_handle_glsl450_instruction(struct vtn_builder *b, uint32_t ext_opcode,
 const uint32_t *words, unsigned count);
 
+struct vtn_builder* vtn_create_builder(const uint32_t *words, size_t 
word_count,
+   gl_shader_stage stage, const char 
*entry_point_name,
+   const struct spirv_to_nir_options 
*options);
+
 static inline uint32_t
 vtn_align_u32(uint32_t v, uint32_t a)
 {

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


Mesa (master): nir/spirv: add gl_spirv_validation method

2018-03-30 Thread Alejandro Pinheiro
Module: Mesa
Branch: master
Commit: 9063bf7ad8a9175c4eddba5d06d887c507f6b5be
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=9063bf7ad8a9175c4eddba5d06d887c507f6b5be

Author: Alejandro Piñeiro 
Date:   Thu Jan 18 12:31:52 2018 +0100

nir/spirv: add gl_spirv_validation method

ARB_gl_spirv adds the ability to use SPIR-V binaries, and a new
method, glSpecializeShader. Here we add a new function to do the
validation for this function:

From OpenGL 4.6 spec, section 7.2.1"

   "Shader Specialization", error table:

INVALID_VALUE is generated if  does not name a valid
entry point for .

INVALID_VALUE is generated if any element of 
refers to a specialization constant that does not exist in the
shader module contained in .""

v2: rebase update (spirv_to_nir options added, changes on the warning
logging, and others)

v3: include passing options on common initialization, doesn't call
setjmp on common_initialization

v4: (after Jason comments):
  * Rename common_initialization to vtn_builder_create
  * Move validation method and their helpers to own source file.
  * Create own handle_constant_decoration_cb instead of reuse existing one

v5: put vtn_build_create refactoring to their own patch (Jason)

v6: update after vtn_builder_create method renamed, add explanatory
comment, tweak existing comment and commit message (Timothy)

---

 src/compiler/Makefile.sources |   1 +
 src/compiler/nir/meson.build  |   1 +
 src/compiler/spirv/gl_spirv.c | 271 ++
 src/compiler/spirv/nir_spirv.h|   5 +
 src/compiler/spirv/spirv_to_nir.c |  35 +++--
 src/compiler/spirv/vtn_private.h  |   6 +
 6 files changed, 305 insertions(+), 14 deletions(-)

diff --git a/src/compiler/Makefile.sources b/src/compiler/Makefile.sources
index 273ce4cde4..aca9dab476 100644
--- a/src/compiler/Makefile.sources
+++ b/src/compiler/Makefile.sources
@@ -297,6 +297,7 @@ SPIRV_GENERATED_FILES = \
 SPIRV_FILES = \
spirv/GLSL.ext.AMD.h \
spirv/GLSL.std.450.h \
+   spirv/gl_spirv.c \
spirv/nir_spirv.h \
spirv/spirv.h \
spirv/spirv_info.h \
diff --git a/src/compiler/nir/meson.build b/src/compiler/nir/meson.build
index db89e27613..b28a565d0c 100644
--- a/src/compiler/nir/meson.build
+++ b/src/compiler/nir/meson.build
@@ -186,6 +186,7 @@ files_libnir = files(
   'nir_worklist.h',
   '../spirv/GLSL.ext.AMD.h',
   '../spirv/GLSL.std.450.h',
+  '../spirv/gl_spirv.c',
   '../spirv/nir_spirv.h',
   '../spirv/spirv.h',
   '../spirv/spirv_info.h',
diff --git a/src/compiler/spirv/gl_spirv.c b/src/compiler/spirv/gl_spirv.c
new file mode 100644
index 00..edb635a09d
--- /dev/null
+++ b/src/compiler/spirv/gl_spirv.c
@@ -0,0 +1,271 @@
+/*
+ * Copyright © 2017 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ *
+ *
+ */
+
+#include "nir_spirv.h"
+
+#include "vtn_private.h"
+#include "spirv_info.h"
+
+static bool
+vtn_validate_preamble_instruction(struct vtn_builder *b, SpvOp opcode,
+  const uint32_t *w, unsigned count)
+{
+   switch (opcode) {
+   case SpvOpSource:
+   case SpvOpSourceExtension:
+   case SpvOpSourceContinued:
+   case SpvOpExtension:
+   case SpvOpCapability:
+   case SpvOpExtInstImport:
+   case SpvOpMemoryModel:
+   case SpvOpString:
+   case SpvOpName:
+   case SpvOpMemberName:
+   case SpvOpExecutionMode:
+   case SpvOpDecorationGroup:
+   case SpvOpMemberDecorate:
+   case SpvOpGroupDecorate:
+   case SpvOpGroupMemberDecorate:
+  break;
+
+   case SpvOpEntryPoint:
+  vtn_handle_entry_point(b, w, count);
+  break;
+
+   case SpvOpDecorate:
+  vtn_handle_decoration(b, opcode, w, count);
+  break;
+
+   default:
+  return false; /* End of preamble */
+   }
+
+   return true;
+}
+
+static void
+spec_constant_decoration_cb(struct vtn_builder *b, struct vtn_value 

Mesa (master): i965: Don't call process_glsl_ir() for SPIR-V shaders

2018-03-30 Thread Alejandro Pinheiro
Module: Mesa
Branch: master
Commit: e7fc18097ef5770f0da4186050f772518f28174a
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=e7fc18097ef5770f0da4186050f772518f28174a

Author: Eduardo Lima Mitev 
Date:   Tue Oct 10 14:08:35 2017 +0200

i965: Don't call process_glsl_ir() for SPIR-V shaders

v2: Use 'spirv_data' from gl_linked_shader instead, to check if shader
   is SPIR-V. (Timothy Arceri)

Reviewed-by: Timothy Arceri 

---

 src/mesa/drivers/dri/i965/brw_link.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/mesa/drivers/dri/i965/brw_link.cpp 
b/src/mesa/drivers/dri/i965/brw_link.cpp
index 274a738cbb..7841626dc3 100644
--- a/src/mesa/drivers/dri/i965/brw_link.cpp
+++ b/src/mesa/drivers/dri/i965/brw_link.cpp
@@ -237,7 +237,8 @@ brw_link_shader(struct gl_context *ctx, struct 
gl_shader_program *shProg)
   struct gl_program *prog = shader->Program;
   prog->Parameters = _mesa_new_parameter_list();
 
-  process_glsl_ir(brw, shProg, shader);
+  if (!shader->spirv_data)
+ process_glsl_ir(brw, shProg, shader);
 
   _mesa_copy_linked_program_data(shProg, shader);
 

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