Mesa (master): anv/cmd_buffer: fix off by one error in assertion

2017-07-25 Thread Iago Toral Quiroga
Module: Mesa
Branch: master
Commit: a848e693efc8e2a1d355dc1076409968b374153f
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=a848e693efc8e2a1d355dc1076409968b374153f

Author: Iago Toral Quiroga 
Date:   Wed Jul 19 12:49:33 2017 +0200

anv/cmd_buffer: fix off by one error in assertion

Cc: "17.2" 
Reviewed-by: Lionel Landwerlin 

---

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

diff --git a/src/intel/vulkan/anv_cmd_buffer.c 
b/src/intel/vulkan/anv_cmd_buffer.c
index 7317674843..3b59af8f6f 100644
--- a/src/intel/vulkan/anv_cmd_buffer.c
+++ b/src/intel/vulkan/anv_cmd_buffer.c
@@ -566,7 +566,7 @@ void anv_CmdBindVertexBuffers(
/* We have to defer setting up vertex buffer since we need the buffer
 * stride from the pipeline. */
 
-   assert(firstBinding + bindingCount < MAX_VBS);
+   assert(firstBinding + bindingCount <= MAX_VBS);
for (uint32_t i = 0; i < bindingCount; i++) {
   vb[firstBinding + i].buffer = anv_buffer_from_handle(pBuffers[i]);
   vb[firstBinding + i].offset = pOffsets[i];

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


Mesa (master): anv: only expose up to 28 vertex attributes

2017-07-25 Thread Iago Toral Quiroga
Module: Mesa
Branch: master
Commit: 31f1863ace73d31a579e5c36252a957818ad09cf
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=31f1863ace73d31a579e5c36252a957818ad09cf

Author: Iago Toral Quiroga 
Date:   Fri Jul 21 08:32:24 2017 +0200

anv: only expose up to 28 vertex attributes

The EU limit of 128 GRFs should allow 32 vertex elements of 4 GRFs.
However, the maximum allowed value of "Vertex URB Entry Read Length"
in SIMD8 is 15. And 15 * 8 = 120 gives us a limit of 30 vertex elements.
Because we also need to reserve a vertex buffer to upload
VertexIndex/InstanceIndex and another to upload DrawID when needed,
we can only expose 28.

Cc: "17.2" 
Reviewed-by: Lionel Landwerlin 

---

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

diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h
index faf7849891..86c430397c 100644
--- a/src/intel/vulkan/anv_private.h
+++ b/src/intel/vulkan/anv_private.h
@@ -89,7 +89,7 @@ struct gen_l3_config;
  */
 #define ANV_HZ_FC_VAL 1.0f
 
-#define MAX_VBS 31
+#define MAX_VBS 28
 #define MAX_SETS 8
 #define MAX_RTS  8
 #define MAX_VIEWPORTS   16

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


Mesa (master): i965: Shut up Coverity warning about HiZ buffers.

2017-07-25 Thread Kenneth Graunke
Module: Mesa
Branch: master
Commit: 445367242a221d8e7d0f8ce31a9df75e86f8af0e
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=445367242a221d8e7d0f8ce31a9df75e86f8af0e

Author: Kenneth Graunke 
Date:   Tue Jul 25 10:27:03 2017 -0700

i965: Shut up Coverity warning about HiZ buffers.

Here the AUX_USAGE_* mode indicates that we have HiZ, so we will have
a HiZ buffer.  But Coverity doesn't know that, so it thinks it might
be NULL because we checked hiz_buf != NULL earlier.

Reviewed-by: Jason Ekstrand 

---

 src/mesa/drivers/dri/i965/brw_blorp.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/mesa/drivers/dri/i965/brw_blorp.c 
b/src/mesa/drivers/dri/i965/brw_blorp.c
index a0f37780ef..b2987ca4fa 100644
--- a/src/mesa/drivers/dri/i965/brw_blorp.c
+++ b/src/mesa/drivers/dri/i965/brw_blorp.c
@@ -184,6 +184,7 @@ blorp_surf_for_miptree(struct brw_context *brw,
  surf->aux_addr.buffer = mt->mcs_buf->bo;
  surf->aux_addr.offset = mt->mcs_buf->offset;
   } else {
+ assert(mt->hiz_buf);
  assert(surf->aux_usage == ISL_AUX_USAGE_HIZ);
 
  surf->aux_addr.buffer = mt->hiz_buf->bo;

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


Mesa (master): i965: Fix = vs == in MCS aux usage assert.

2017-07-25 Thread Kenneth Graunke
Module: Mesa
Branch: master
Commit: 698636cc9762f090b75fd0421db7e654609e7715
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=698636cc9762f090b75fd0421db7e654609e7715

Author: Kenneth Graunke 
Date:   Tue Jul 25 10:22:01 2017 -0700

i965: Fix = vs == in MCS aux usage assert.

Caught by Coverity (CID 1415680).

Cc: "17.2" 
Reviewed-by: Jason Ekstrand 

---

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

diff --git a/src/mesa/drivers/dri/i965/brw_blorp.c 
b/src/mesa/drivers/dri/i965/brw_blorp.c
index 36f7ed2a39..a0f37780ef 100644
--- a/src/mesa/drivers/dri/i965/brw_blorp.c
+++ b/src/mesa/drivers/dri/i965/brw_blorp.c
@@ -1103,7 +1103,7 @@ brw_blorp_mcs_partial_resolve(struct brw_context *brw,
DBG("%s to mt %p layers %u-%u\n", __FUNCTION__, mt,
start_layer, start_layer + num_layers - 1);
 
-   assert(mt->aux_usage = ISL_AUX_USAGE_MCS);
+   assert(mt->aux_usage == ISL_AUX_USAGE_MCS);
 
const mesa_format format = _mesa_get_srgb_format_linear(mt->format);
enum isl_format isl_format = brw_blorp_to_isl_format(brw, format, true);

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


Mesa (master): i965: Fix offset addition in get_isl_surf.

2017-07-25 Thread Kenneth Graunke
Module: Mesa
Branch: master
Commit: f6e674fa5164a957e93e8dc1334a48c9e7ee7df9
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=f6e674fa5164a957e93e8dc1334a48c9e7ee7df9

Author: Kenneth Graunke 
Date:   Tue Jul 25 10:16:16 2017 -0700

i965: Fix offset addition in get_isl_surf.

Increase the value, not the pointer to the stack variable.

Caught by Coverity (CID 1415574).  Not shipped in a real release.

Cc: "17.2" 
Reviewed-by: Topi Pohjolainen 

---

 src/mesa/drivers/dri/i965/brw_wm_surface_state.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c 
b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
index 250806d28e..a0ca6ddf98 100644
--- a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
+++ b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
@@ -101,9 +101,9 @@ get_isl_surf(struct brw_context *brw, struct 
intel_mipmap_tree *mt,
assert(view->levels == 1 && view->array_len == 1);
assert(*tile_x == 0 && *tile_y == 0);
 
-   offset += intel_miptree_get_tile_offsets(mt, view->base_level,
-view->base_array_layer,
-tile_x, tile_y);
+   *offset += intel_miptree_get_tile_offsets(mt, view->base_level,
+ view->base_array_layer,
+ tile_x, tile_y);
 
/* Minify the logical dimensions of the texture. */
const unsigned l = view->base_level - mt->first_level;

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


Mesa (master): mesa/st: fix inconsistent indentation of st_cb_bufferobjects.c

2017-07-25 Thread Timothy Arceri
Module: Mesa
Branch: master
Commit: 7b48163d7c1e30fc2874177b29a3f37cb13ea584
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=7b48163d7c1e30fc2874177b29a3f37cb13ea584

Author: Andres Rodriguez 
Date:   Wed Jul 12 18:45:17 2017 -0400

mesa/st: fix inconsistent indentation of st_cb_bufferobjects.c

No changes, just re-indent.

Signed-off-by: Andres Rodriguez 
Reviewed-by: Timothy Arceri 

---

 src/mesa/state_tracker/st_cb_bufferobjects.c | 36 ++--
 1 file changed, 18 insertions(+), 18 deletions(-)

diff --git a/src/mesa/state_tracker/st_cb_bufferobjects.c 
b/src/mesa/state_tracker/st_cb_bufferobjects.c
index c1994d5221..68ec250101 100644
--- a/src/mesa/state_tracker/st_cb_bufferobjects.c
+++ b/src/mesa/state_tracker/st_cb_bufferobjects.c
@@ -96,9 +96,9 @@ st_bufferobj_free(struct gl_context *ctx, struct 
gl_buffer_object *obj)
  */
 static void
 st_bufferobj_subdata(struct gl_context *ctx,
-GLintptrARB offset,
-GLsizeiptrARB size,
-const void * data, struct gl_buffer_object *obj)
+ GLintptrARB offset,
+ GLsizeiptrARB size,
+ const void * data, struct gl_buffer_object *obj)
 {
struct st_buffer_object *st_obj = st_buffer_object(obj);
 
@@ -130,8 +130,8 @@ st_bufferobj_subdata(struct gl_context *ctx,
 * buffer directly.
 */
pipe_buffer_write(st_context(ctx)->pipe,
-st_obj->buffer,
-offset, size, data);
+ st_obj->buffer,
+ offset, size, data);
 }
 
 
@@ -173,12 +173,12 @@ st_bufferobj_get_subdata(struct gl_context *ctx,
  */
 static GLboolean
 st_bufferobj_data(struct gl_context *ctx,
- GLenum target,
- GLsizeiptrARB size,
- const void * data,
- GLenum usage,
+  GLenum target,
+  GLsizeiptrARB size,
+  const void * data,
+  GLenum usage,
   GLbitfield storageFlags,
- struct gl_buffer_object *obj)
+  struct gl_buffer_object *obj)
 {
struct st_context *st = st_context(ctx);
struct pipe_context *pipe = st->pipe;
@@ -263,7 +263,7 @@ st_bufferobj_data(struct gl_context *ctx,
   case GL_STATIC_DRAW:
   case GL_STATIC_COPY:
   default:
-pipe_usage = PIPE_USAGE_DEFAULT;
+ pipe_usage = PIPE_USAGE_DEFAULT;
  break;
   case GL_DYNAMIC_DRAW:
   case GL_DYNAMIC_COPY:
@@ -420,7 +420,7 @@ st_bufferobj_map_range(struct gl_context *ctx,
   flags |= PIPE_TRANSFER_COHERENT;
 
/* ... other flags ...
-*/
+   */
 
if (access & MESA_MAP_NOWAIT_BIT)
   flags |= PIPE_TRANSFER_DONTBLOCK;
@@ -431,10 +431,10 @@ st_bufferobj_map_range(struct gl_context *ctx,
assert(offset + length <= obj->Size);
 
obj->Mappings[index].Pointer = pipe_buffer_map_range(pipe,
-st_obj->buffer,
-offset, length,
-flags,
-&st_obj->transfer[index]);
+st_obj->buffer,
+offset, length,
+flags,
+
&st_obj->transfer[index]);
if (obj->Mappings[index].Pointer) {
   obj->Mappings[index].Offset = offset;
   obj->Mappings[index].Length = length;
@@ -556,8 +556,8 @@ st_clear_buffer_subdata(struct gl_context *ctx,
  */
 void
 st_bufferobj_validate_usage(struct st_context *st,
-   struct st_buffer_object *obj,
-   unsigned usage)
+struct st_buffer_object *obj,
+unsigned usage)
 {
 }
 

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


Mesa (master): mesa/st: move st_pipe_format_to_mesa_format() call to where its used

2017-07-25 Thread Timothy Arceri
Module: Mesa
Branch: master
Commit: 87e5f39cf1777a7fd3d8fc3c5fbc969ed743ea05
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=87e5f39cf1777a7fd3d8fc3c5fbc969ed743ea05

Author: Timothy Arceri 
Date:   Thu Jul 20 10:04:40 2017 +1000

mesa/st: move st_pipe_format_to_mesa_format() call to where its used

Reviewed-by: Grazvydas Ignotas 
Reviewed-by: Marek Olšák 

---

 src/mesa/state_tracker/st_format.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/src/mesa/state_tracker/st_format.c 
b/src/mesa/state_tracker/st_format.c
index 012f1a4015..64a3a81279 100644
--- a/src/mesa/state_tracker/st_format.c
+++ b/src/mesa/state_tracker/st_format.c
@@ -1035,12 +1035,11 @@ test_format_conversion(struct st_context *st)
 
/* Test all Gallium formats */
for (i = 1; i < PIPE_FORMAT_COUNT; i++) {
-  mesa_format mf = st_pipe_format_to_mesa_format(i);
-
   /* ETC formats are translated differently, skip them. */
   if (i == PIPE_FORMAT_ETC1_RGB8 && !st->has_etc1)
  continue;
 
+  mesa_format mf = st_pipe_format_to_mesa_format(i);
   if (_mesa_is_format_etc2(mf) && !st->has_etc2)
  continue;
 

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


Mesa (master): mesa/st: fix unused variable warnings

2017-07-25 Thread Timothy Arceri
Module: Mesa
Branch: master
Commit: 7ee383669fc34a9ebe1e722da47673025dbf72a5
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=7ee383669fc34a9ebe1e722da47673025dbf72a5

Author: Timothy Arceri 
Date:   Thu Jul 20 10:06:32 2017 +1000

mesa/st: fix unused variable warnings

Reviewed-by: Grazvydas Ignotas 
Reviewed-by: Marek Olšák 

---

 src/mesa/state_tracker/st_cb_bitmap.c | 5 +++--
 src/mesa/state_tracker/st_cb_drawpixels.c | 9 -
 src/mesa/state_tracker/st_cb_texture.c| 2 +-
 src/mesa/state_tracker/st_format.c| 5 +++--
 4 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/src/mesa/state_tracker/st_cb_bitmap.c 
b/src/mesa/state_tracker/st_cb_bitmap.c
index 7ba6d825c1..a5c7ed0ee6 100644
--- a/src/mesa/state_tracker/st_cb_bitmap.c
+++ b/src/mesa/state_tracker/st_cb_bitmap.c
@@ -301,8 +301,9 @@ draw_bitmap_quad(struct gl_context *ctx, GLint x, GLint y, 
GLfloat z,
   /* XXX if the bitmap is larger than the max texture size, break
* it up into chunks.
*/
-  GLuint maxSize = 1 << (pipe->screen->get_param(pipe->screen,
-PIPE_CAP_MAX_TEXTURE_2D_LEVELS) - 1);
+  GLuint MAYBE_UNUSED maxSize =
+ 1 << (pipe->screen->get_param(pipe->screen,
+   PIPE_CAP_MAX_TEXTURE_2D_LEVELS) - 1);
   assert(width <= (GLsizei) maxSize);
   assert(height <= (GLsizei) maxSize);
}
diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c 
b/src/mesa/state_tracker/st_cb_drawpixels.c
index 384f965474..1d88976ed9 100644
--- a/src/mesa/state_tracker/st_cb_drawpixels.c
+++ b/src/mesa/state_tracker/st_cb_drawpixels.c
@@ -464,7 +464,6 @@ make_texture(struct st_context *st,
 
{
   struct pipe_transfer *transfer;
-  GLboolean success;
   GLubyte *dest;
   const GLbitfield imageTransferStateSave = ctx->_ImageTransferState;
 
@@ -497,9 +496,9 @@ make_texture(struct st_context *st,
   format, type, /* src format/type */
   pixels,   /* data source */
   unpack);
- success = GL_TRUE;
   }
   else {
+ bool MAYBE_UNUSED success;
  success = _mesa_texstore(ctx, 2,   /* dims */
   baseInternalFormat, /* baseInternalFormat */
   mformat,  /* mesa_format */
@@ -509,13 +508,13 @@ make_texture(struct st_context *st,
   format, type, /* src format/type */
   pixels,   /* data source */
   unpack);
+
+ assert(success);
   }
 
   /* unmap */
   pipe_transfer_unmap(pipe, transfer);
 
-  assert(success);
-
   /* restore */
   ctx->_ImageTransferState = imageTransferStateSave;
}
@@ -570,7 +569,7 @@ draw_textured_quad(struct gl_context *ctx, GLint x, GLint 
y, GLfloat z,
const unsigned fb_width = _mesa_geometric_width(ctx->DrawBuffer);
const unsigned fb_height = _mesa_geometric_height(ctx->DrawBuffer);
GLfloat x0, y0, x1, y1;
-   GLsizei maxSize;
+   GLsizei MAYBE_UNUSED maxSize;
boolean normalized = sv[0]->texture->target == PIPE_TEXTURE_2D;
unsigned cso_state_mask;
 
diff --git a/src/mesa/state_tracker/st_cb_texture.c 
b/src/mesa/state_tracker/st_cb_texture.c
index f66e1bd0cb..d0a7b55c58 100644
--- a/src/mesa/state_tracker/st_cb_texture.c
+++ b/src/mesa/state_tracker/st_cb_texture.c
@@ -2396,7 +2396,7 @@ copy_image_data_to_texture(struct st_context *st,
 {
/* debug checks */
{
-  const struct gl_texture_image *dstImage =
+  const struct gl_texture_image MAYBE_UNUSED *dstImage =
  stObj->base.Image[stImage->base.Face][dstLevel];
   assert(dstImage);
   assert(dstImage->Width == stImage->base.Width);
diff --git a/src/mesa/state_tracker/st_format.c 
b/src/mesa/state_tracker/st_format.c
index 64a3a81279..348853affd 100644
--- a/src/mesa/state_tracker/st_format.c
+++ b/src/mesa/state_tracker/st_format.c
@@ -1028,7 +1028,7 @@ test_format_conversion(struct st_context *st)
 
   pf = st_mesa_format_to_pipe_format(st, i);
   if (pf != PIPE_FORMAT_NONE) {
- mesa_format mf = st_pipe_format_to_mesa_format(pf);
+ mesa_format MAYBE_UNUSED mf = st_pipe_format_to_mesa_format(pf);
  assert(mf == i);
   }
}
@@ -1044,7 +1044,8 @@ test_format_conversion(struct st_context *st)
  continue;
 
   if (mf != MESA_FORMAT_NONE) {
- enum pipe_format pf = st_mesa_format_to_pipe_format(st, mf);
+ enum pipe_format MAYBE_UNUSED pf =
+st_mesa_format_to_pipe_format(st, mf);
  assert(pf == i);
   }
}

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


Mesa (master): gallium/util: fix unused variable warning

2017-07-25 Thread Timothy Arceri
Module: Mesa
Branch: master
Commit: 17f05e52e750489c159541a178c363401c294249
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=17f05e52e750489c159541a178c363401c294249

Author: Timothy Arceri 
Date:   Thu Jul 20 10:03:28 2017 +1000

gallium/util: fix unused variable warning

Reviewed-by: Grazvydas Ignotas 
Reviewed-by: Marek Olšák 

---

 src/gallium/auxiliary/util/u_threaded_context.c | 8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/gallium/auxiliary/util/u_threaded_context.c 
b/src/gallium/auxiliary/util/u_threaded_context.c
index cb9ea3a908..a9fc670173 100644
--- a/src/gallium/auxiliary/util/u_threaded_context.c
+++ b/src/gallium/auxiliary/util/u_threaded_context.c
@@ -1978,9 +1978,11 @@ static void
 tc_call_generate_mipmap(struct pipe_context *pipe, union tc_payload *payload)
 {
struct tc_generate_mipmap *p = (struct tc_generate_mipmap *)payload;
-   bool result = pipe->generate_mipmap(pipe, p->res, p->format, p->base_level,
-   p->last_level, p->first_layer,
-   p->last_layer);
+   bool MAYBE_UNUSED result = pipe->generate_mipmap(pipe, p->res, p->format,
+p->base_level,
+p->last_level,
+p->first_layer,
+p->last_layer);
assert(result);
pipe_resource_reference(&p->res, NULL);
 }

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


Mesa (master): compiler: move glsl_interface_packing enum to shader_enums.h

2017-07-25 Thread Timothy Arceri
Module: Mesa
Branch: master
Commit: b0333e55b77ff16bff3ca4a744043f85d06b4633
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=b0333e55b77ff16bff3ca4a744043f85d06b4633

Author: Timothy Arceri 
Date:   Fri Jul 21 10:23:47 2017 +1000

compiler: move glsl_interface_packing enum to shader_enums.h

This allows us to drop the duplicate gl_uniform_block_packing enum.

Reviewed-by: Nicolai Hähnle 

---

 src/compiler/glsl/link_uniform_blocks.cpp | 11 +--
 src/compiler/glsl_types.h |  9 ++---
 src/compiler/shader_enums.h   |  7 +++
 src/mesa/main/mtypes.h| 11 +--
 4 files changed, 11 insertions(+), 27 deletions(-)

diff --git a/src/compiler/glsl/link_uniform_blocks.cpp 
b/src/compiler/glsl/link_uniform_blocks.cpp
index 249a767636..ef2f29dd7a 100644
--- a/src/compiler/glsl/link_uniform_blocks.cpp
+++ b/src/compiler/glsl/link_uniform_blocks.cpp
@@ -280,7 +280,7 @@ process_block_array_leaf(const char *name,
blocks[i].Binding = (b->has_binding) ? b->binding + *binding_offset : 0;
 
blocks[i].UniformBufferSize = 0;
-   blocks[i]._Packing = gl_uniform_block_packing(type->interface_packing);
+   blocks[i]._Packing = glsl_interface_packing(type->interface_packing);
blocks[i]._RowMajor = type->get_interface_row_major();
blocks[i].linearized_array_index = linearized_index;
 
@@ -354,15 +354,6 @@ create_buffer_blocks(void *mem_ctx, struct gl_context *ctx,
 */
ubo_visitor parcel(blocks, variables, num_variables, prog);
 
-   STATIC_ASSERT(unsigned(GLSL_INTERFACE_PACKING_STD140)
- == unsigned(ubo_packing_std140));
-   STATIC_ASSERT(unsigned(GLSL_INTERFACE_PACKING_SHARED)
- == unsigned(ubo_packing_shared));
-   STATIC_ASSERT(unsigned(GLSL_INTERFACE_PACKING_PACKED)
- == unsigned(ubo_packing_packed));
-   STATIC_ASSERT(unsigned(GLSL_INTERFACE_PACKING_STD430)
- == unsigned(ubo_packing_std430));
-
unsigned i = 0;
struct hash_entry *entry;
hash_table_foreach (block_hash, entry) {
diff --git a/src/compiler/glsl_types.h b/src/compiler/glsl_types.h
index 2857dc9ad9..f67465e6c8 100644
--- a/src/compiler/glsl_types.h
+++ b/src/compiler/glsl_types.h
@@ -28,6 +28,8 @@
 #include 
 #include 
 
+#include "shader_enums.h"
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -101,13 +103,6 @@ enum glsl_sampler_dim {
GLSL_SAMPLER_DIM_SUBPASS_MS, /* for multisampled vulkan input attachments */
 };
 
-enum glsl_interface_packing {
-   GLSL_INTERFACE_PACKING_STD140,
-   GLSL_INTERFACE_PACKING_SHARED,
-   GLSL_INTERFACE_PACKING_PACKED,
-   GLSL_INTERFACE_PACKING_STD430
-};
-
 enum glsl_matrix_layout {
/**
 * The layout of the matrix is inherited from the object containing the
diff --git a/src/compiler/shader_enums.h b/src/compiler/shader_enums.h
index 352f27040c..2f20e68c5d 100644
--- a/src/compiler/shader_enums.h
+++ b/src/compiler/shader_enums.h
@@ -567,6 +567,13 @@ enum glsl_interp_mode
INTERP_MODE_COUNT /**< Number of interpolation qualifiers */
 };
 
+enum glsl_interface_packing {
+   GLSL_INTERFACE_PACKING_STD140,
+   GLSL_INTERFACE_PACKING_SHARED,
+   GLSL_INTERFACE_PACKING_PACKED,
+   GLSL_INTERFACE_PACKING_STD430
+};
+
 const char *glsl_interp_mode_name(enum glsl_interp_mode qual);
 
 /**
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 0cb002469b..0d0536c775 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -2645,15 +2645,6 @@ struct gl_uniform_buffer_variable
 };
 
 
-enum gl_uniform_block_packing
-{
-   ubo_packing_std140,
-   ubo_packing_shared,
-   ubo_packing_packed,
-   ubo_packing_std430
-};
-
-
 struct gl_uniform_block
 {
/** Declared name of the uniform block */
@@ -2699,7 +2690,7 @@ struct gl_uniform_block
 * This isn't accessible through the API, but it is used while
 * cross-validating uniform blocks.
 */
-   enum gl_uniform_block_packing _Packing;
+   enum glsl_interface_packing _Packing;
GLboolean _RowMajor;
 };
 

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


Mesa (master): mesa: call binding functions directly from glDeleteBuffers

2017-07-25 Thread Timothy Arceri
Module: Mesa
Branch: master
Commit: 6be1c69b97175a0ae71dda584629b91093728c12
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=6be1c69b97175a0ae71dda584629b91093728c12

Author: Timothy Arceri 
Date:   Tue Jul 25 23:16:14 2017 +1000

mesa: call binding functions directly from glDeleteBuffers

This avoids useless error checking.

Reviewed-by: Samuel Pitoiset 

---

 src/mesa/main/bufferobj.c | 12 +---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c
index 324bbc6ea1..343e6c3ca5 100644
--- a/src/mesa/main/bufferobj.c
+++ b/src/mesa/main/bufferobj.c
@@ -1536,14 +1536,18 @@ _mesa_DeleteBuffers(GLsizei n, const GLuint *ids)
  }
  for (j = 0; j < MAX_FEEDBACK_BUFFERS; j++) {
 if (ctx->TransformFeedback.CurrentObject->Buffers[j] == bufObj) {
-   _mesa_BindBufferBase( GL_TRANSFORM_FEEDBACK_BUFFER, j, 0 );
+   _mesa_bind_buffer_base_transform_feedback(ctx,
+   
ctx->TransformFeedback.CurrentObject,
+   j, ctx->Shared->NullBufferObj,
+   false);
 }
  }
 
  /* unbind UBO binding points */
  for (j = 0; j < ctx->Const.MaxUniformBufferBindings; j++) {
 if (ctx->UniformBufferBindings[j].BufferObject == bufObj) {
-   _mesa_BindBufferBase( GL_UNIFORM_BUFFER, j, 0 );
+   bind_buffer_base_uniform_buffer(ctx, j,
+   ctx->Shared->NullBufferObj);
 }
  }
 
@@ -1554,7 +1558,8 @@ _mesa_DeleteBuffers(GLsizei n, const GLuint *ids)
  /* unbind SSBO binding points */
  for (j = 0; j < ctx->Const.MaxShaderStorageBufferBindings; j++) {
 if (ctx->ShaderStorageBufferBindings[j].BufferObject == bufObj) {
-   _mesa_BindBufferBase(GL_SHADER_STORAGE_BUFFER, j, 0);
+   bind_buffer_base_shader_storage_buffer(ctx, j,
+
ctx->Shared->NullBufferObj);
 }
  }
 
@@ -1566,6 +1571,7 @@ _mesa_DeleteBuffers(GLsizei n, const GLuint *ids)
  for (j = 0; j < ctx->Const.MaxAtomicBufferBindings; j++) {
 if (ctx->AtomicBufferBindings[j].BufferObject == bufObj) {
_mesa_BindBufferBase( GL_ATOMIC_COUNTER_BUFFER, j, 0 );
+   bind_atomic_buffer(ctx, j, ctx->Shared->NullBufferObj, 0, 0);
 }
  }
 

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


Mesa (master): mesa: move static binding functions above _mesa_DeleteBuffers()

2017-07-25 Thread Timothy Arceri
Module: Mesa
Branch: master
Commit: 003c8b116717c3bade740d299b3b2e6131a1ae0b
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=003c8b116717c3bade740d299b3b2e6131a1ae0b

Author: Timothy Arceri 
Date:   Tue Jul 25 23:34:06 2017 +1000

mesa: move static binding functions above _mesa_DeleteBuffers()

Reviewed-by: Samuel Pitoiset 

---

 src/mesa/main/bufferobj.c | 412 +++---
 1 file changed, 205 insertions(+), 207 deletions(-)

diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c
index 12fe2d3143..324bbc6ea1 100644
--- a/src/mesa/main/bufferobj.c
+++ b/src/mesa/main/bufferobj.c
@@ -1258,6 +1258,211 @@ _mesa_BindBuffer(GLenum target, GLuint buffer)
bind_buffer_object(ctx, bindTarget, buffer);
 }
 
+/**
+ * Binds a buffer object to an atomic buffer binding point.
+ *
+ * The caller is responsible for validating the offset,
+ * flushing the vertices and updating NewDriverState.
+ */
+static void
+set_atomic_buffer_binding(struct gl_context *ctx,
+  struct gl_atomic_buffer_binding *binding,
+  struct gl_buffer_object *bufObj,
+  GLintptr offset,
+  GLsizeiptr size)
+{
+   _mesa_reference_buffer_object(ctx, &binding->BufferObject, bufObj);
+
+   if (bufObj == ctx->Shared->NullBufferObj) {
+  binding->Offset = 0;
+  binding->Size = 0;
+   } else {
+  binding->Offset = offset;
+  binding->Size = size;
+  bufObj->UsageHistory |= USAGE_ATOMIC_COUNTER_BUFFER;
+   }
+}
+
+/**
+ * Binds a buffer object to a uniform buffer binding point.
+ *
+ * The caller is responsible for flushing vertices and updating
+ * NewDriverState.
+ */
+static void
+set_ubo_binding(struct gl_context *ctx,
+struct gl_uniform_buffer_binding *binding,
+struct gl_buffer_object *bufObj,
+GLintptr offset,
+GLsizeiptr size,
+GLboolean autoSize)
+{
+   _mesa_reference_buffer_object(ctx, &binding->BufferObject, bufObj);
+
+   binding->Offset = offset;
+   binding->Size = size;
+   binding->AutomaticSize = autoSize;
+
+   /* If this is a real buffer object, mark it has having been used
+* at some point as a UBO.
+*/
+   if (size >= 0)
+  bufObj->UsageHistory |= USAGE_UNIFORM_BUFFER;
+}
+
+/**
+ * Binds a buffer object to a shader storage buffer binding point.
+ *
+ * The caller is responsible for flushing vertices and updating
+ * NewDriverState.
+ */
+static void
+set_ssbo_binding(struct gl_context *ctx,
+ struct gl_shader_storage_buffer_binding *binding,
+ struct gl_buffer_object *bufObj,
+ GLintptr offset,
+ GLsizeiptr size,
+ GLboolean autoSize)
+{
+   _mesa_reference_buffer_object(ctx, &binding->BufferObject, bufObj);
+
+   binding->Offset = offset;
+   binding->Size = size;
+   binding->AutomaticSize = autoSize;
+
+   /* If this is a real buffer object, mark it has having been used
+* at some point as a SSBO.
+*/
+   if (size >= 0)
+  bufObj->UsageHistory |= USAGE_SHADER_STORAGE_BUFFER;
+}
+
+/**
+ * Binds a buffer object to a uniform buffer binding point.
+ *
+ * Unlike set_ubo_binding(), this function also flushes vertices
+ * and updates NewDriverState.  It also checks if the binding
+ * has actually changed before updating it.
+ */
+static void
+bind_uniform_buffer(struct gl_context *ctx,
+GLuint index,
+struct gl_buffer_object *bufObj,
+GLintptr offset,
+GLsizeiptr size,
+GLboolean autoSize)
+{
+   struct gl_uniform_buffer_binding *binding =
+  &ctx->UniformBufferBindings[index];
+
+   if (binding->BufferObject == bufObj &&
+   binding->Offset == offset &&
+   binding->Size == size &&
+   binding->AutomaticSize == autoSize) {
+  return;
+   }
+
+   FLUSH_VERTICES(ctx, 0);
+   ctx->NewDriverState |= ctx->DriverFlags.NewUniformBuffer;
+
+   set_ubo_binding(ctx, binding, bufObj, offset, size, autoSize);
+}
+
+/**
+ * Binds a buffer object to a shader storage buffer binding point.
+ *
+ * Unlike set_ssbo_binding(), this function also flushes vertices
+ * and updates NewDriverState.  It also checks if the binding
+ * has actually changed before updating it.
+ */
+static void
+bind_shader_storage_buffer(struct gl_context *ctx,
+   GLuint index,
+   struct gl_buffer_object *bufObj,
+   GLintptr offset,
+   GLsizeiptr size,
+   GLboolean autoSize)
+{
+   struct gl_shader_storage_buffer_binding *binding =
+  &ctx->ShaderStorageBufferBindings[index];
+
+   if (binding->BufferObject == bufObj &&
+   binding->Offset == offset &&
+   binding->Size == size &&
+   binding->AutomaticSize == autoSize) {
+  return;
+   }
+
+   FLUSH_VERTICES(ctx, 0

Mesa (master): mesa: drop useless assert

2017-07-25 Thread Timothy Arceri
Module: Mesa
Branch: master
Commit: 5fac8c116e82886d4e9235e4859d4c23969bf1d7
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=5fac8c116e82886d4e9235e4859d4c23969bf1d7

Author: Timothy Arceri 
Date:   Wed Jul 26 09:13:33 2017 +1000

mesa: drop useless assert

NewBufferObj() is called when the shared state is allocated so we
wouldn't get this far if it was NULL.

Reviewed-by: Samuel Pitoiset 

---

 src/mesa/main/bufferobj.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c
index 343e6c3ca5..cb666dcf13 100644
--- a/src/mesa/main/bufferobj.c
+++ b/src/mesa/main/bufferobj.c
@@ -989,7 +989,6 @@ _mesa_handle_bind_buffer_gen(struct gl_context *ctx,
   /* If this is a new buffer object id, or one which was generated but
* never used before, allocate a buffer object now.
*/
-  assert(ctx->Driver.NewBufferObject);
   buf = ctx->Driver.NewBufferObject(ctx, buffer);
   if (!buf) {
 _mesa_error(ctx, GL_OUT_OF_MEMORY, "%s", caller);

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


Mesa (master): mesa: don't try to re-generate the default buffer

2017-07-25 Thread Timothy Arceri
Module: Mesa
Branch: master
Commit: 4943353bff3192aabf652e61bb13830a9d576406
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=4943353bff3192aabf652e61bb13830a9d576406

Author: Timothy Arceri 
Date:   Tue Jul 25 23:06:03 2017 +1000

mesa: don't try to re-generate the default buffer

It should have been created by this point.

Reviewed-by: Samuel Pitoiset 

---

 src/mesa/main/bufferobj.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c
index 419972e371..12fe2d3143 100644
--- a/src/mesa/main/bufferobj.c
+++ b/src/mesa/main/bufferobj.c
@@ -4041,10 +4041,10 @@ bind_buffer_range(GLenum target, GLuint index, GLuint 
buffer, GLintptr offset,
   bufObj = ctx->Shared->NullBufferObj;
} else {
   bufObj = _mesa_lookup_bufferobj(ctx, buffer);
+  if (!_mesa_handle_bind_buffer_gen(ctx, buffer,
+&bufObj, "glBindBufferRange"))
+ return;
}
-   if (!_mesa_handle_bind_buffer_gen(ctx, buffer,
- &bufObj, "glBindBufferRange"))
-  return;
 
if (no_error) {
   switch (target) {
@@ -4139,10 +4139,10 @@ _mesa_BindBufferBase(GLenum target, GLuint index, 
GLuint buffer)
   bufObj = ctx->Shared->NullBufferObj;
} else {
   bufObj = _mesa_lookup_bufferobj(ctx, buffer);
+  if (!_mesa_handle_bind_buffer_gen(ctx, buffer,
+&bufObj, "glBindBufferBase"))
+ return;
}
-   if (!_mesa_handle_bind_buffer_gen(ctx, buffer,
- &bufObj, "glBindBufferBase"))
-  return;
 
if (!bufObj) {
   _mesa_error(ctx, GL_INVALID_OPERATION,

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


Mesa (master): broadcom/vc4: Switch the V3D 2.1 XML over to restricted address fields.

2017-07-25 Thread Eric Anholt
Module: Mesa
Branch: master
Commit: 4d4872708ef8dc4915f61274c1c795b8e8472357
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=4d4872708ef8dc4915f61274c1c795b8e8472357

Author: Eric Anholt 
Date:   Thu Jul 13 12:42:49 2017 -0700

broadcom/vc4: Switch the V3D 2.1 XML over to restricted address fields.

This keeps the flags out of v3d_decode.c's output.  In the generated code,
only the unpack functions see any change (where they now get the
restricted start value), and vc4 doesn't use the unpack functions yet.

---

 src/broadcom/cle/v3d_packet_v21.xml | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/broadcom/cle/v3d_packet_v21.xml 
b/src/broadcom/cle/v3d_packet_v21.xml
index b28f2b5eb6..3721815c2e 100644
--- a/src/broadcom/cle/v3d_packet_v21.xml
+++ b/src/broadcom/cle/v3d_packet_v21.xml
@@ -18,7 +18,7 @@
   
 
   
-
+
 
 
 
@@ -26,13 +26,13 @@
   
 
   
-
+
 
 
   
 
   
-
+
 
 
 
@@ -69,7 +69,7 @@
   
 
   
-
+
 
 
 

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


Mesa (master): broadcom/vc4: Switch the Viewport Center fields to a fixed-point representation.

2017-07-25 Thread Eric Anholt
Module: Mesa
Branch: master
Commit: b3c78a51f33a26b57f4bec64bab73ea720c1e619
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=b3c78a51f33a26b57f4bec64bab73ea720c1e619

Author: Eric Anholt 
Date:   Wed Jul 12 15:56:00 2017 -0700

broadcom/vc4: Switch the Viewport Center fields to a fixed-point representation.

This gets us automatic CL decoding to a floating-point value, and drops a
magic number from the emit code.  250x250 shader runner tests now say they
have a center of 125.0 instead of 2000.

---

 src/broadcom/cle/v3d_packet_v21.xml | 4 ++--
 src/gallium/drivers/vc4/vc4_emit.c  | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/broadcom/cle/v3d_packet_v21.xml 
b/src/broadcom/cle/v3d_packet_v21.xml
index 350cf294b5..b28f2b5eb6 100644
--- a/src/broadcom/cle/v3d_packet_v21.xml
+++ b/src/broadcom/cle/v3d_packet_v21.xml
@@ -212,8 +212,8 @@
   
 
   
-
-
+
+
   
 
   
diff --git a/src/gallium/drivers/vc4/vc4_emit.c 
b/src/gallium/drivers/vc4/vc4_emit.c
index d0a701f17b..b45ffb75aa 100644
--- a/src/gallium/drivers/vc4/vc4_emit.c
+++ b/src/gallium/drivers/vc4/vc4_emit.c
@@ -135,9 +135,9 @@ vc4_emit_state(struct pipe_context *pctx)
 
 cl_emit(&job->bcl, VIEWPORT_OFFSET, vp) {
 vp.viewport_centre_x_coordinate =
-16 * vc4->viewport.translate[0];
+vc4->viewport.translate[0];
 vp.viewport_centre_y_coordinate =
-16 * vc4->viewport.translate[1];
+vc4->viewport.translate[1];
 }
 }
 

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


Mesa (master): broadcom/genxml: Introduce a V3D packet/struct decoder.

2017-07-25 Thread Eric Anholt
Module: Mesa
Branch: master
Commit: 5b102160ae1b8b8322ab106d454cb69fb563fbed
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=5b102160ae1b8b8322ab106d454cb69fb563fbed

Author: Eric Anholt 
Date:   Wed Jul 12 13:15:34 2017 -0700

broadcom/genxml: Introduce a V3D packet/struct decoder.

This is copied from Intel's XML decoder, modified to handle V3D's
byte-oriented packets.

v2: Squash in robher's fixes for Android

---

 src/broadcom/Android.cle.mk |  35 ++
 src/broadcom/Android.genxml.mk  |   6 +
 src/broadcom/Android.mk |   1 +
 src/broadcom/Makefile.am|   8 +
 src/broadcom/Makefile.cle.am|   4 +
 src/broadcom/Makefile.genxml.am |   5 +
 src/broadcom/Makefile.sources   |   6 +
 src/broadcom/cle/v3d_decoder.c  | 855 
 src/broadcom/cle/v3d_decoder.h  | 146 +++
 9 files changed, 1066 insertions(+)

diff --git a/src/broadcom/Android.cle.mk b/src/broadcom/Android.cle.mk
new file mode 100644
index 00..9b728424fa
--- /dev/null
+++ b/src/broadcom/Android.cle.mk
@@ -0,0 +1,35 @@
+# Copyright © 2016 Intel Corporation
+# Copyright © 2016 Mauro Rossi 
+#
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the "Software"),
+# to deal in the Software without restriction, including without limitation
+# the rights to use, copy, modify, merge, publish, distribute, sublicense,
+# and/or sell copies of the Software, and to permit persons to whom the
+# Software is furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+# DEALINGS IN THE SOFTWARE.
+
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := libmesa_broadcom_cle
+
+LOCAL_MODULE_CLASS := STATIC_LIBRARIES
+
+LOCAL_SRC_FILES := $(BROADCOM_DECODER_FILES)
+
+LOCAL_STATIC_LIBRARIES := libmesa_broadcom_genxml
+
+LOCAL_SHARED_LIBRARIES := libexpat libz
+
+include $(MESA_COMMON_MK)
+include $(BUILD_STATIC_LIBRARY)
diff --git a/src/broadcom/Android.genxml.mk b/src/broadcom/Android.genxml.mk
index a504326135..d42701dffe 100644
--- a/src/broadcom/Android.genxml.mk
+++ b/src/broadcom/Android.genxml.mk
@@ -50,8 +50,14 @@ $(intermediates)/broadcom/cle/v3d_packet_v21_pack.h: 
PRIVATE_XML := $(LOCAL_PATH
 $(intermediates)/broadcom/cle/v3d_packet_v21_pack.h: 
$(LOCAL_PATH)/cle/v3d_packet_v21.xml $(LOCAL_PATH)/cle/gen_pack_header.py
$(call header-gen)
 
+$(intermediates)/broadcom/cle/v3d_xml.h: $(addprefix 
$(MESA_TOP)/src/broadcom/,$(BROADCOM_GENXML_XML_FILES)) 
$(MESA_TOP)/src/intel/genxml/gen_zipped_file.py
+   @mkdir -p $(dir $@)
+   @echo "Gen Header: $(PRIVATE_MODULE) <= $(notdir $(@))"
+   $(hide) $(MESA_PYTHON2) $(MESA_TOP)/src/intel/genxml/gen_zipped_file.py 
$(addprefix $(MESA_TOP)/src/broadcom/,$(BROADCOM_GENXML_XML_FILES)) > $@ || (rm 
-f $@; false)
+
 LOCAL_EXPORT_C_INCLUDE_DIRS := \
$(MESA_TOP)/src/broadcom/cle \
+   $(intermediates)/broadcom/cle \
$(intermediates)
 
 include $(MESA_COMMON_MK)
diff --git a/src/broadcom/Android.mk b/src/broadcom/Android.mk
index d2da907a21..b3bf405104 100644
--- a/src/broadcom/Android.mk
+++ b/src/broadcom/Android.mk
@@ -26,3 +26,4 @@ LOCAL_PATH := $(call my-dir)
 include $(LOCAL_PATH)/Makefile.sources
 
 include $(LOCAL_PATH)/Android.genxml.mk
+include $(LOCAL_PATH)/Android.cle.mk
diff --git a/src/broadcom/Makefile.am b/src/broadcom/Makefile.am
index f4a005b40c..cbcd970ecb 100644
--- a/src/broadcom/Makefile.am
+++ b/src/broadcom/Makefile.am
@@ -20,6 +20,13 @@
 # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
 # IN THE SOFTWARE.
 
+AM_CPPFLAGS = \
+   -I$(top_srcdir)/include \
+   -I$(top_builddir)/src \
+   -I$(top_srcdir)/src \
+   $(VALGRIND_CFLAGS) \
+   $(DEFINES)
+
 include Makefile.sources
 
 lib_LTLIBRARIES =
@@ -38,5 +45,6 @@ MKDIR_GEN = $(AM_V_at)$(MKDIR_P) $(@D)
 PYTHON_GEN = $(AM_V_GEN)$(PYTHON2) $(PYTHON_FLAGS)
 
 include Makefile.genxml.am
+include Makefile.cle.am
 
 CLEANFILES += $(BUILT_SOURCES)
diff --git a/src/broadcom/Makefile.cle.am b/src/broadcom/Makefile.cle.am
new file mode 100644
index 00..368826796d
--- /dev/null
+++ b/src/broadcom/Makefile.cle.am
@@ -0,0 +1,4 @@
+noinst_LTLIBRARIES += cle/libbroadcom_cle.la
+
+cle_libbroadcom_cle_la_CFLAGS = $(AM_CFLAGS)
+cle_libbroadcom_cle_la_SOURCES = $(BROADCOM_DECODER_FILES)
diff --git a/src/broadcom/Makefile.genxml.am b/src/broadcom/Make

Mesa (master): ra: Pull the body of a loop out to a helper function.

2017-07-25 Thread Eric Anholt
Module: Mesa
Branch: master
Commit: 30146f29a723a3a3abe7cf7ef6cc8567880a077d
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=30146f29a723a3a3abe7cf7ef6cc8567880a077d

Author: Eric Anholt 
Date:   Fri Oct 23 21:46:40 2015 +0100

ra: Pull the body of a loop out to a helper function.

I was going to indent this code another level, and decided it would be
easier to read as a helper.

Reviewed-by: Nicolai Hähnle 

---

 src/util/register_allocate.c | 31 +++
 1 file changed, 19 insertions(+), 12 deletions(-)

diff --git a/src/util/register_allocate.c b/src/util/register_allocate.c
index 8af93c0406..35ef9a714c 100644
--- a/src/util/register_allocate.c
+++ b/src/util/register_allocate.c
@@ -539,6 +539,23 @@ ra_simplify(struct ra_graph *g)
g->stack_optimistic_start = stack_optimistic_start;
 }
 
+static bool
+ra_any_neighbors_conflict(struct ra_graph *g, unsigned int n, unsigned int r)
+{
+   unsigned int i;
+
+   for (i = 0; i < g->nodes[n].adjacency_count; i++) {
+  unsigned int n2 = g->nodes[n].adjacency_list[i];
+
+  if (!g->nodes[n2].in_stack &&
+  BITSET_TEST(g->regs->regs[r].conflicts, g->nodes[n2].reg)) {
+ return true;
+  }
+   }
+
+   return false;
+}
+
 /**
  * Pops nodes from the stack back into the graph, coloring them with
  * registers as they go.
@@ -552,7 +569,6 @@ ra_select(struct ra_graph *g)
int start_search_reg = 0;
 
while (g->stack_count != 0) {
-  unsigned int i;
   unsigned int ri;
   unsigned int r = -1;
   int n = g->stack[g->stack_count - 1];
@@ -566,17 +582,8 @@ ra_select(struct ra_graph *g)
  if (!reg_belongs_to_class(r, c))
continue;
 
-/* Check if any of our neighbors conflict with this register choice. */
-for (i = 0; i < g->nodes[n].adjacency_count; i++) {
-   unsigned int n2 = g->nodes[n].adjacency_list[i];
-
-   if (!g->nodes[n2].in_stack &&
-   BITSET_TEST(g->regs->regs[r].conflicts, g->nodes[n2].reg)) {
-  break;
-   }
-}
-if (i == g->nodes[n].adjacency_count)
-   break;
+ if (!ra_any_neighbors_conflict(g, n, r))
+break;
   }
 
   /* set this to false even if we return here so that

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


Mesa (master): broadcom/vc4: Prefer blit via rendering to the software fallback.

2017-07-25 Thread Eric Anholt
Module: Mesa
Branch: master
Commit: 93fec49a75ce799bb6fe167f9409fd553a5781c6
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=93fec49a75ce799bb6fe167f9409fd553a5781c6

Author: Eric Anholt 
Date:   Mon Jul 24 12:34:23 2017 -0700

broadcom/vc4: Prefer blit via rendering to the software fallback.

I don't know how I managed to leave this here for so long.  Found when
working on a 1:1 overlapping blit extension for X11.

Cc: mesa-sta...@lists.freedesktop.org

---

 src/gallium/drivers/vc4/vc4_blit.c | 14 --
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/src/gallium/drivers/vc4/vc4_blit.c 
b/src/gallium/drivers/vc4/vc4_blit.c
index 1e056568ac..0e4ab5bfa0 100644
--- a/src/gallium/drivers/vc4/vc4_blit.c
+++ b/src/gallium/drivers/vc4/vc4_blit.c
@@ -212,14 +212,16 @@ vc4_blit(struct pipe_context *pctx, const struct 
pipe_blit_info *blit_info)
 if (vc4_tile_blit(pctx, blit_info))
 return;
 
-if (util_try_blit_via_copy_region(pctx, &info)) {
-return; /* done */
-}
-
 if (info.mask & PIPE_MASK_S) {
-fprintf(stderr, "cannot blit stencil, skipping\n");
+if (util_try_blit_via_copy_region(pctx, &info))
+return;
+
 info.mask &= ~PIPE_MASK_S;
+fprintf(stderr, "cannot blit stencil, skipping\n");
 }
 
-vc4_render_blit(pctx, &info);
+if (vc4_render_blit(pctx, &info))
+return;
+
+fprintf(stderr, "Unsupported blit\n");
 }

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


Mesa (master): broadcom/genxml: Support address fields with <32 bits

2017-07-25 Thread Eric Anholt
Module: Mesa
Branch: master
Commit: 82fdc106066002c5ed3a96a6aee01a8dc43dd7a5
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=82fdc106066002c5ed3a96a6aee01a8dc43dd7a5

Author: Eric Anholt 
Date:   Thu Jul 13 12:40:58 2017 -0700

broadcom/genxml: Support address fields with <32 bits

I was writing the XML such that the address field overlapped various flags
in the alignment bits, which caused pain when trying to unpack for decode.
Instead, keep the XML matching the docs (address fields don't overlap),
and just infer the appropriate shift value during decode.

During pack, the address is just applied to the appropriate bits
already, ignoring the sub-byte start/end fields.

---

 src/broadcom/cle/v3d_decoder.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/broadcom/cle/v3d_decoder.c b/src/broadcom/cle/v3d_decoder.c
index 66f74af306..ac33d87191 100644
--- a/src/broadcom/cle/v3d_decoder.c
+++ b/src/broadcom/cle/v3d_decoder.c
@@ -792,7 +792,7 @@ v3d_field_iterator_next(struct v3d_field_iterator *iter)
 case V3D_TYPE_ADDRESS:
 case V3D_TYPE_OFFSET:
 snprintf(iter->value, sizeof(iter->value), "0x%08"PRIx64,
- __gen_unpack_uint(iter->p, s, e));
+ __gen_unpack_uint(iter->p, s, e) << (31 - (e - s)));
 break;
 case V3D_TYPE_STRUCT:
 snprintf(iter->value, sizeof(iter->value), "",

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


Mesa (master): ra: Don't put a node in its own adjacency set.

2017-07-25 Thread Eric Anholt
Module: Mesa
Branch: master
Commit: 3dae034423c5cd0393e773e347a8c847ecd2734d
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=3dae034423c5cd0393e773e347a8c847ecd2734d

Author: Eric Anholt 
Date:   Thu May  4 15:49:39 2017 -0700

ra: Don't put a node in its own adjacency set.

All the paths looping over adjacency had guards against considering
themselves (the non-obvious one was ra_any_neighbors_conflict(), which has
in_stack set).

Reviewed-by: Nicolai Hähnle 

---

 src/util/register_allocate.c | 23 ++-
 1 file changed, 10 insertions(+), 13 deletions(-)

diff --git a/src/util/register_allocate.c b/src/util/register_allocate.c
index 35ef9a714c..0e2dd4a376 100644
--- a/src/util/register_allocate.c
+++ b/src/util/register_allocate.c
@@ -392,11 +392,11 @@ ra_add_node_adjacency(struct ra_graph *g, unsigned int 
n1, unsigned int n2)
 {
BITSET_SET(g->nodes[n1].adjacency, n2);
 
-   if (n1 != n2) {
-  int n1_class = g->nodes[n1].class;
-  int n2_class = g->nodes[n2].class;
-  g->nodes[n1].q_total += g->regs->classes[n1_class]->q[n2_class];
-   }
+   assert(n1 != n2);
+
+   int n1_class = g->nodes[n1].class;
+   int n2_class = g->nodes[n2].class;
+   g->nodes[n1].q_total += g->regs->classes[n1_class]->q[n2_class];
 
if (g->nodes[n1].adjacency_count >=
g->nodes[n1].adjacency_list_size) {
@@ -433,7 +433,6 @@ ra_alloc_interference_graph(struct ra_regs *regs, unsigned 
int count)
   g->nodes[i].adjacency_count = 0;
   g->nodes[i].q_total = 0;
 
-  ra_add_node_adjacency(g, i, i);
   g->nodes[i].reg = NO_REG;
}
 
@@ -451,7 +450,7 @@ void
 ra_add_node_interference(struct ra_graph *g,
  unsigned int n1, unsigned int n2)
 {
-   if (!BITSET_TEST(g->nodes[n1].adjacency, n2)) {
+   if (n1 != n2 && !BITSET_TEST(g->nodes[n1].adjacency, n2)) {
   ra_add_node_adjacency(g, n1, n2);
   ra_add_node_adjacency(g, n2, n1);
}
@@ -475,7 +474,7 @@ decrement_q(struct ra_graph *g, unsigned int n)
   unsigned int n2 = g->nodes[n].adjacency_list[i];
   unsigned int n2_class = g->nodes[n2].class;
 
-  if (n != n2 && !g->nodes[n2].in_stack) {
+  if (!g->nodes[n2].in_stack) {
  assert(g->nodes[n2].q_total >= 
g->regs->classes[n2_class]->q[n_class]);
  g->nodes[n2].q_total -= g->regs->classes[n2_class]->q[n_class];
   }
@@ -661,11 +660,9 @@ ra_get_spill_benefit(struct ra_graph *g, unsigned int n)
 */
for (j = 0; j < g->nodes[n].adjacency_count; j++) {
   unsigned int n2 = g->nodes[n].adjacency_list[j];
-  if (n != n2) {
-unsigned int n2_class = g->nodes[n2].class;
-benefit += ((float)g->regs->classes[n_class]->q[n2_class] /
-g->regs->classes[n_class]->p);
-  }
+  unsigned int n2_class = g->nodes[n2].class;
+  benefit += ((float)g->regs->classes[n_class]->q[n2_class] /
+  g->regs->classes[n_class]->p);
}
 
return benefit;

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


Mesa (master): broadcom/vc4: Use the RA callback to improve register selection's choices.

2017-07-25 Thread Eric Anholt
Module: Mesa
Branch: master
Commit: 53492917e2153e9f5eb503792c2793a8e4cba391
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=53492917e2153e9f5eb503792c2793a8e4cba391

Author: Eric Anholt 
Date:   Thu May  4 14:44:38 2017 -0700

broadcom/vc4: Use the RA callback to improve register selection's choices.

We simply pick r4 if available (anything else would force a MOV), then
round-robin through accumulators (avoids physical regfile RAW delay
slots), then round-robin through the physical regfile.

The effect on instruction count is pretty impressive:

total instructions in shared programs: 76563 -> 74526 (-2.66%)
instructions in affected programs: 66463 -> 64426 (-3.06%)

and we could probably do better with a little heuristic of "if we're going
to choose a physical reg, and other operands of instructions using this as
a src have the same physical regfile, then use the other regfile".

---

 src/gallium/drivers/vc4/vc4_register_allocate.c | 53 -
 1 file changed, 52 insertions(+), 1 deletion(-)

diff --git a/src/gallium/drivers/vc4/vc4_register_allocate.c 
b/src/gallium/drivers/vc4/vc4_register_allocate.c
index 506fdb593a..1d860ea058 100644
--- a/src/gallium/drivers/vc4/vc4_register_allocate.c
+++ b/src/gallium/drivers/vc4/vc4_register_allocate.c
@@ -101,7 +101,9 @@ static const struct qpu_reg vc4_regs[] = {
 QPU_R(B, 31),
 };
 #define ACC_INDEX 0
-#define AB_INDEX  (ACC_INDEX + 5)
+#define ACC_COUNT 5
+#define AB_INDEX  (ACC_INDEX + ACC_COUNT)
+#define AB_COUNT  64
 
 static void
 vc4_alloc_reg_set(struct vc4_context *vc4)
@@ -200,6 +202,49 @@ node_to_temp_priority(const void *in_a, const void *in_b)
 #define CLASS_BIT_R4   (1 << 2)
 #define CLASS_BIT_R0_R3(1 << 4)
 
+struct vc4_ra_select_callback_data {
+uint32_t next_acc;
+uint32_t next_ab;
+};
+
+static unsigned int
+vc4_ra_select_callback(struct ra_graph *g, BITSET_WORD *regs, void *data)
+{
+struct vc4_ra_select_callback_data *vc4_ra = data;
+
+/* If r4 is available, always choose it -- few other things can go
+ * there, and choosing anything else means inserting a mov.
+ */
+if (BITSET_TEST(regs, ACC_INDEX + 4))
+return ACC_INDEX + 4;
+
+/* Choose an accumulator if possible (no delay between write and
+ * read), but round-robin through them to give post-RA instruction
+ * selection more options.
+ */
+for (int i = 0; i < ACC_COUNT; i++) {
+int acc_off = (vc4_ra->next_acc + i) % ACC_COUNT;
+int acc = ACC_INDEX + acc_off;
+
+if (BITSET_TEST(regs, acc)) {
+vc4_ra->next_acc = acc_off + 1;
+return acc;
+}
+}
+
+for (int i = 0; i < AB_COUNT; i++) {
+int ab_off = (vc4_ra->next_ab + i) % AB_COUNT;
+int ab = AB_INDEX + ab_off;
+
+if (BITSET_TEST(regs, ab)) {
+vc4_ra->next_ab = ab_off + 1;
+return ab;
+}
+}
+
+unreachable("RA must pass us at least one possible reg.");
+}
+
 /**
  * Returns a mapping from QFILE_TEMP indices to struct qpu_regs.
  *
@@ -213,6 +258,10 @@ vc4_register_allocate(struct vc4_context *vc4, struct 
vc4_compile *c)
 uint8_t class_bits[c->num_temps];
 struct qpu_reg *temp_registers = calloc(c->num_temps,
 sizeof(*temp_registers));
+struct vc4_ra_select_callback_data callback_data = {
+.next_acc = 0,
+.next_ab = 0,
+};
 
 /* If things aren't ever written (undefined values), just read from
  * r0.
@@ -228,6 +277,8 @@ vc4_register_allocate(struct vc4_context *vc4, struct 
vc4_compile *c)
 /* Compute the live ranges so we can figure out interference. */
 qir_calculate_live_intervals(c);
 
+ra_set_select_reg_callback(g, vc4_ra_select_callback, &callback_data);
+
 for (uint32_t i = 0; i < c->num_temps; i++) {
 map[i].temp = i;
 map[i].priority = c->temp_end[i] - c->temp_start[i];

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


Mesa (master): broadcom: add editorconfig

2017-07-25 Thread Eric Anholt
Module: Mesa
Branch: master
Commit: 12b55c8e27bbbe59e646f969325c362137eb8fc1
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=12b55c8e27bbbe59e646f969325c362137eb8fc1

Author: Eric Anholt 
Date:   Fri Feb  3 13:30:42 2017 -0800

broadcom: add editorconfig

This is the same 8-space style used in the vc4 and vc5 gallium drivers.

---

 src/broadcom/.editorconfig | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/broadcom/.editorconfig b/src/broadcom/.editorconfig
new file mode 100644
index 00..f3d8c47915
--- /dev/null
+++ b/src/broadcom/.editorconfig
@@ -0,0 +1,3 @@
+[*.{c,h}]
+indent_style = space
+indent_size = 8

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


Mesa (master): ra: Add a callback for selecting a register from what' s available.

2017-07-25 Thread Eric Anholt
Module: Mesa
Branch: master
Commit: 7a34a0e8903249c41fae06fea22be105caf290df
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=7a34a0e8903249c41fae06fea22be105caf290df

Author: Eric Anholt 
Date:   Fri Oct 23 22:12:27 2015 +0100

ra: Add a callback for selecting a register from what's available.

VC4 has had a tension, similar to pre-Sandybridge Intel, where we want to
use low-numbered registers (more parallelism on Intel, fewer delay slots
on vc4), but in order to give instruction scheduling the most freedom to
avoid delays we want to round-robin between registers of the same cost.
Our two heuristics so far have chosen one end or the other of that
tradeoff.

The callback, instead, hands the driver the set of registers that are
available, and the driver gets to make its own choice.  This will be used
in vc4 to round-robin between registers of the same cost, and might be
used in the future for improving bank selection.

Reviewed-by: Nicolai Hähnle 

---

 src/util/register_allocate.c | 90 +---
 src/util/register_allocate.h |  6 +++
 2 files changed, 82 insertions(+), 14 deletions(-)

diff --git a/src/util/register_allocate.c b/src/util/register_allocate.c
index 0e2dd4a376..b06a61f24a 100644
--- a/src/util/register_allocate.c
+++ b/src/util/register_allocate.c
@@ -174,6 +174,10 @@ struct ra_graph {
 * stack.
 */
unsigned int stack_optimistic_start;
+
+   unsigned int (*select_reg_callback)(struct ra_graph *g, BITSET_WORD *regs,
+   void *data);
+   void *select_reg_callback_data;
 };
 
 /**
@@ -439,6 +443,16 @@ ra_alloc_interference_graph(struct ra_regs *regs, unsigned 
int count)
return g;
 }
 
+void ra_set_select_reg_callback(struct ra_graph *g,
+unsigned int (*callback)(struct ra_graph *g,
+ BITSET_WORD *regs,
+ void *data),
+void *data)
+{
+   g->select_reg_callback = callback;
+   g->select_reg_callback_data = data;
+}
+
 void
 ra_set_node_class(struct ra_graph *g,
   unsigned int n, unsigned int class)
@@ -555,6 +569,41 @@ ra_any_neighbors_conflict(struct ra_graph *g, unsigned int 
n, unsigned int r)
return false;
 }
 
+/* Computes a bitfield of what regs are available for a given register
+ * selection.
+ *
+ * This lets drivers implement a more complicated policy than our simple first
+ * or round robin policies (which don't require knowing the whole bitset)
+ */
+static bool
+ra_compute_available_regs(struct ra_graph *g, unsigned int n, BITSET_WORD 
*regs)
+{
+   struct ra_class *c = g->regs->classes[g->nodes[n].class];
+
+   /* Populate with the set of regs that are in the node's class. */
+   memcpy(regs, c->regs, BITSET_WORDS(g->regs->count) * sizeof(BITSET_WORD));
+
+   /* Remove any regs that conflict with nodes that we're adjacent to and have
+* already colored.
+*/
+   for (int i = 0; i < g->nodes[n].adjacency_count; i++) {
+  unsigned int n2 = g->nodes[n].adjacency_list[i];
+  unsigned int r = g->nodes[n2].reg;
+
+  if (!g->nodes[n2].in_stack) {
+ for (int j = 0; j < BITSET_WORDS(g->regs->count); j++)
+regs[j] &= ~g->regs->regs[r].conflicts[j];
+  }
+   }
+
+   for (int i = 0; i < BITSET_WORDS(g->regs->count); i++) {
+  if (regs[i])
+ return true;
+   }
+
+   return false;
+}
+
 /**
  * Pops nodes from the stack back into the graph, coloring them with
  * registers as they go.
@@ -566,6 +615,10 @@ static bool
 ra_select(struct ra_graph *g)
 {
int start_search_reg = 0;
+   BITSET_WORD *select_regs = NULL;
+
+   if (g->select_reg_callback)
+  select_regs = malloc(BITSET_WORDS(g->regs->count) * sizeof(BITSET_WORD));
 
while (g->stack_count != 0) {
   unsigned int ri;
@@ -573,25 +626,34 @@ ra_select(struct ra_graph *g)
   int n = g->stack[g->stack_count - 1];
   struct ra_class *c = g->regs->classes[g->nodes[n].class];
 
-  /* Find the lowest-numbered reg which is not used by a member
-   * of the graph adjacent to us.
-   */
-  for (ri = 0; ri < g->regs->count; ri++) {
- r = (start_search_reg + ri) % g->regs->count;
- if (!reg_belongs_to_class(r, c))
-   continue;
-
- if (!ra_any_neighbors_conflict(g, n, r))
-break;
-  }
-
   /* set this to false even if we return here so that
* ra_get_best_spill_node() considers this node later.
*/
   g->nodes[n].in_stack = false;
 
-  if (ri == g->regs->count)
-return false;
+  if (g->select_reg_callback) {
+ if (!ra_compute_available_regs(g, n, select_regs)) {
+free(select_regs);
+return false;
+ }
+
+ r = g->select_reg_callback(g, select_regs, 
g->select_reg_callback_data);
+  } else {
+ /* Find the lowest-numbered reg which is

Mesa (master): intel/decoder: Reuse the MAX2 macro instead of defining another one.

2017-07-25 Thread Eric Anholt
Module: Mesa
Branch: master
Commit: 19ffa4bfb281fb8814f666bac1d0c96a42e6edbb
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=19ffa4bfb281fb8814f666bac1d0c96a42e6edbb

Author: Eric Anholt 
Date:   Wed Jul 12 13:11:34 2017 -0700

intel/decoder: Reuse the MAX2 macro instead of defining another one.

Reviewed-by: Lionel Landwerlin 

---

 src/intel/common/gen_decoder.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/src/intel/common/gen_decoder.c b/src/intel/common/gen_decoder.c
index ba3a5139ae..60591ad666 100644
--- a/src/intel/common/gen_decoder.c
+++ b/src/intel/common/gen_decoder.c
@@ -39,8 +39,6 @@
 
 #define XML_BUFFER_SIZE 4096
 
-#define MAX(a, b) ((a) < (b) ? (b) : (a))
-
 #define MAKE_GEN(major, minor) ( ((major) << 8) | (minor) )
 
 struct gen_spec {
@@ -381,7 +379,7 @@ create_and_append_field(struct parser_context *ctx,
 const char **atts)
 {
if (ctx->group->nfields == ctx->group->fields_size) {
-  ctx->group->fields_size = MAX(ctx->group->fields_size * 2, 2);
+  ctx->group->fields_size = MAX2(ctx->group->fields_size * 2, 2);
   ctx->group->fields =
  (struct gen_field **) realloc(ctx->group->fields,
sizeof(ctx->group->fields[0]) *

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


Mesa (master): intel/decoder: Reuse the gen_make_gen() helper.

2017-07-25 Thread Eric Anholt
Module: Mesa
Branch: master
Commit: decd2b32aa56f1d8b31cd9cef5a0891097083cd6
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=decd2b32aa56f1d8b31cd9cef5a0891097083cd6

Author: Eric Anholt 
Date:   Wed Jul 12 13:22:46 2017 -0700

intel/decoder: Reuse the gen_make_gen() helper.

Reviewed-by: Lionel Landwerlin 

---

 src/intel/common/gen_decoder.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/src/intel/common/gen_decoder.c b/src/intel/common/gen_decoder.c
index 60591ad666..85880143f0 100644
--- a/src/intel/common/gen_decoder.c
+++ b/src/intel/common/gen_decoder.c
@@ -39,8 +39,6 @@
 
 #define XML_BUFFER_SIZE 4096
 
-#define MAKE_GEN(major, minor) ( ((major) << 8) | (minor) )
-
 struct gen_spec {
uint32_t gen;
 
@@ -420,7 +418,7 @@ start_element(void *data, const char *element_name, const 
char **atts)
   if (n == 1)
  minor = 0;
 
-  ctx->spec->gen = MAKE_GEN(major, minor);
+  ctx->spec->gen = gen_make_gen(major, minor);
} else if (strcmp(element_name, "instruction") == 0 ||
   strcmp(element_name, "struct") == 0) {
   ctx->group = create_group(ctx, name, atts, NULL);

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


Mesa (master): broadcom/vc4: Scissor blits performed using the rendering engine.

2017-07-25 Thread Eric Anholt
Module: Mesa
Branch: master
Commit: 16e17ce04b60ac6f3d9a89535ea583fabebead7a
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=16e17ce04b60ac6f3d9a89535ea583fabebead7a

Author: Eric Anholt 
Date:   Mon Jul 24 14:45:49 2017 -0700

broadcom/vc4: Scissor blits performed using the rendering engine.

Without this, a BlitFramebuffer would mark the whole framebuffer as being
changed (so we emit loads/stores of all of it) rather than just the
modified subset.

---

 src/gallium/drivers/vc4/vc4_blit.c | 9 +
 1 file changed, 9 insertions(+)

diff --git a/src/gallium/drivers/vc4/vc4_blit.c 
b/src/gallium/drivers/vc4/vc4_blit.c
index 0e4ab5bfa0..7f4c76968e 100644
--- a/src/gallium/drivers/vc4/vc4_blit.c
+++ b/src/gallium/drivers/vc4/vc4_blit.c
@@ -195,6 +195,15 @@ vc4_render_blit(struct pipe_context *ctx, struct 
pipe_blit_info *info)
 return false;
 }
 
+/* Enable the scissor, so we get a minimal set of tiles rendered. */
+if (!info->scissor_enable) {
+info->scissor_enable = true;
+info->scissor.minx = info->dst.box.x;
+info->scissor.miny = info->dst.box.y;
+info->scissor.maxx = info->dst.box.x + info->dst.box.width;
+info->scissor.maxy = info->dst.box.y + info->dst.box.height;
+}
+
 vc4_blitter_save(vc4);
 util_blitter_blit(vc4->blitter, info);
 

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


Mesa (master): broadcom/vc4: Use the XML decoder for CL dumping.

2017-07-25 Thread Eric Anholt
Module: Mesa
Branch: master
Commit: 299c9a2db1391f222e784aa54b4b5e321afdffc6
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=299c9a2db1391f222e784aa54b4b5e321afdffc6

Author: Eric Anholt 
Date:   Wed Jul 12 14:22:02 2017 -0700

broadcom/vc4: Use the XML decoder for CL dumping.

The VC4_DEBUG_CL output goes from:

0x0010 0x0010: 0x06 VC4_PACKET_START_TILE_BINNING
0x0011 0x0011: 0x38 VC4_PACKET_PRIMITIVE_LIST_FORMAT
0x0012 0x0012: 0x12
0x0013 0x0013: 0x66 VC4_PACKET_CLIP_WINDOW
0x0014 0x0014: 0x00
0x0015 0x0015: 0x00
0x0016 0x0016: 0x00
0x0017 0x0017: 0x00
0x0018 0x0018: 0xfa
0x0019 0x0019: 0x00
0x001a 0x001a: 0xfa
0x001b 0x001b: 0x00

to:

0x0010 0x0010: 0x06 Start Tile Binning
0x0011 0x0011: 0x38 Primitive List Format
Data Type: 1 (16-bit index)
Primitive Type: 2 (Triangles List)
0x0013 0x0013: 0x66 Clip Window
Clip Window Height in pixels: 250
Clip Window Width in pixels: 250
Clip Window Bottom Pixel Coordinate: 0
Clip Window Left Pixel Coordinate: 0

v2: Squash in robher's fixes for Android

---

 src/gallium/drivers/vc4/Android.mk|   5 +-
 src/gallium/drivers/vc4/Makefile.am   |   7 +-
 src/gallium/drivers/vc4/vc4_cl_dump.c | 463 ++
 3 files changed, 32 insertions(+), 443 deletions(-)

diff --git a/src/gallium/drivers/vc4/Android.mk 
b/src/gallium/drivers/vc4/Android.mk
index 8b19e52077..84bfaa839f 100644
--- a/src/gallium/drivers/vc4/Android.mk
+++ b/src/gallium/drivers/vc4/Android.mk
@@ -34,7 +34,10 @@ LOCAL_C_INCLUDES := \
 
 # We need libmesa_nir to get NIR's generated include directories.
 LOCAL_STATIC_LIBRARIES := \
-   libmesa_nir \
+   libmesa_nir
+
+LOCAL_WHOLE_STATIC_LIBRARIES := \
+   libmesa_broadcom_cle \
libmesa_broadcom_genxml
 
 LOCAL_MODULE := libmesa_pipe_vc4
diff --git a/src/gallium/drivers/vc4/Makefile.am 
b/src/gallium/drivers/vc4/Makefile.am
index 576f9b3ad1..9b0ef6ef79 100644
--- a/src/gallium/drivers/vc4/Makefile.am
+++ b/src/gallium/drivers/vc4/Makefile.am
@@ -38,7 +38,12 @@ AM_CFLAGS = \
 noinst_LTLIBRARIES = libvc4.la
 
 libvc4_la_SOURCES = $(C_SOURCES)
-libvc4_la_LIBADD = $(SIM_LIB)
+
+libvc4_la_LIBADD = \
+   $(SIM_LIB) \
+   $(top_builddir)/src/broadcom/cle/libbroadcom_cle.la \
+   $()
+
 libvc4_la_LDFLAGS = $(SIM_LDFLAGS)
 
 EXTRA_DIST = kernel/README
diff --git a/src/gallium/drivers/vc4/vc4_cl_dump.c 
b/src/gallium/drivers/vc4/vc4_cl_dump.c
index b14cf387d1..ca1b9a3152 100644
--- a/src/gallium/drivers/vc4/vc4_cl_dump.c
+++ b/src/gallium/drivers/vc4/vc4_cl_dump.c
@@ -27,460 +27,40 @@
 #include "vc4_cl_dump.h"
 #include "kernel/vc4_packet.h"
 
-#define __gen_user_data void
-#define __gen_address_type uint32_t
-#define __gen_address_offset(reloc) (*reloc)
-#define __gen_emit_reloc(cl, reloc)
-#define __gen_unpack_address __gen_unpack_uint
-
-#include "broadcom/cle/v3d_packet_v21_pack.h"
-
-#define dump_VC4_PACKET_LINE_WIDTH dump_float
-#define dump_VC4_PACKET_POINT_SIZE dump_float
-
-static void
-dump_float(void *cl, uint32_t offset, uint32_t hw_offset)
-{
-void *f = cl + offset;
-
-fprintf(stderr, "0x%08x 0x%08x:  %f (0x%08x)\n",
-offset, hw_offset, uif(*(uint32_t *)f), *(uint32_t *)f);
-}
-
-static void
-dump_VC4_PACKET_BRANCH_TO_SUB_LIST(void *cl, uint32_t offset, uint32_t 
hw_offset)
-{
-uint32_t *addr = cl + offset;
-
-fprintf(stderr, "0x%08x 0x%08x:  addr 0x%08x\n",
-offset, hw_offset, *addr);
-}
-
-static void
-dump_loadstore_full(void *cl, uint32_t offset, uint32_t hw_offset)
-{
-uint32_t bits = *(uint32_t *)(cl + offset);
-
-fprintf(stderr, "0x%08x 0x%08x:  addr 0x%08x%s%s%s%s\n",
-offset, hw_offset,
-bits & ~0xf,
-(bits & VC4_LOADSTORE_FULL_RES_DISABLE_CLEAR_ALL) ? "" : " 
clear",
-(bits & VC4_LOADSTORE_FULL_RES_DISABLE_ZS) ? "" : " zs",
-(bits & VC4_LOADSTORE_FULL_RES_DISABLE_COLOR) ? "" : " color",
-(bits & VC4_LOADSTORE_FULL_RES_EOF) ? " eof" : "");
-}
-
-static void
-dump_VC4_PACKET_LOAD_FULL_RES_TILE_BUFFER(void *cl, uint32_t offset, uint32_t 
hw_offset)
-{
-dump_loadstore_full(cl, offset, hw_offset);
-}
-
-static void
-dump_VC4_PACKET_STORE_FULL_RES_TILE_BUFFER(void *cl, uint32_t offset, uint32_t 
hw_offset)
-{
-dump_loadstore_full(cl, offset, hw_offset);
-}
-
-static void
-dump_loadstore_general(void *cl, uint32_t offset, uint32_t hw_offset)
-{
-uint8_t *bytes = cl + offset;
-uint32_t *addr = cl + offset + 2;
-
-const char *fullvg = "";
-const char *fullzs = "";
-const char *fullcolor = "";
-const char *buffer = "???";
-
-switch ((bytes[0] & 0x7)){
-case 0:
-buffer = "none";
-break;
-case 1:
-buffer = "color";
-   

Mesa (master): gallium/util: s/unsigned/enum tgsi_texture_type/

2017-07-25 Thread Brian Paul
Module: Mesa
Branch: master
Commit: 1ab8901d6fa03b907e4d6c0ee4291340bee72a9a
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=1ab8901d6fa03b907e4d6c0ee4291340bee72a9a

Author: Brian Paul 
Date:   Fri Jul 21 14:08:01 2017 -0600

gallium/util: s/unsigned/enum tgsi_texture_type/

Reviewed-by: Roland Scheidegger 

---

 src/gallium/auxiliary/util/u_blitter.c| 15 ---
 src/gallium/auxiliary/util/u_inlines.h|  2 +-
 src/gallium/auxiliary/util/u_simple_shaders.c | 15 ---
 src/gallium/auxiliary/util/u_simple_shaders.h | 13 +++--
 4 files changed, 24 insertions(+), 21 deletions(-)

diff --git a/src/gallium/auxiliary/util/u_blitter.c 
b/src/gallium/auxiliary/util/u_blitter.c
index 65c6f5d21f..5c826773d1 100644
--- a/src/gallium/auxiliary/util/u_blitter.c
+++ b/src/gallium/auxiliary/util/u_blitter.c
@@ -890,7 +890,8 @@ static void *blitter_get_fs_texfetch_col(struct 
blitter_context_priv *ctx,
  bool use_txf)
 {
struct pipe_context *pipe = ctx->base.pipe;
-   unsigned tgsi_tex = util_pipe_tex_to_tgsi_tex(target, src_nr_samples);
+   enum tgsi_texture_type tgsi_tex =
+  util_pipe_tex_to_tgsi_tex(target, src_nr_samples);
enum tgsi_return_type stype;
enum tgsi_return_type dtype;
unsigned type;
@@ -1004,7 +1005,7 @@ void *blitter_get_fs_texfetch_depth(struct 
blitter_context_priv *ctx,
 
   /* Create the fragment shader on-demand. */
   if (!*shader) {
- unsigned tgsi_tex;
+ enum tgsi_texture_type tgsi_tex;
  assert(!ctx->cached_all_shaders);
  tgsi_tex = util_pipe_tex_to_tgsi_tex(target, nr_samples);
  *shader = util_make_fs_blit_msaa_depth(pipe, tgsi_tex);
@@ -1021,7 +1022,7 @@ void *blitter_get_fs_texfetch_depth(struct 
blitter_context_priv *ctx,
 
   /* Create the fragment shader on-demand. */
   if (!*shader) {
- unsigned tgsi_tex;
+ enum tgsi_texture_type tgsi_tex;
  assert(!ctx->cached_all_shaders);
  tgsi_tex = util_pipe_tex_to_tgsi_tex(target, 0);
  *shader =
@@ -1049,7 +1050,7 @@ void *blitter_get_fs_texfetch_depthstencil(struct 
blitter_context_priv *ctx,
 
   /* Create the fragment shader on-demand. */
   if (!*shader) {
- unsigned tgsi_tex;
+ enum tgsi_texture_type tgsi_tex;
  assert(!ctx->cached_all_shaders);
  tgsi_tex = util_pipe_tex_to_tgsi_tex(target, nr_samples);
  *shader = util_make_fs_blit_msaa_depthstencil(pipe, tgsi_tex);
@@ -1066,7 +1067,7 @@ void *blitter_get_fs_texfetch_depthstencil(struct 
blitter_context_priv *ctx,
 
   /* Create the fragment shader on-demand. */
   if (!*shader) {
- unsigned tgsi_tex;
+ enum tgsi_texture_type tgsi_tex;
  assert(!ctx->cached_all_shaders);
  tgsi_tex = util_pipe_tex_to_tgsi_tex(target, 0);
  *shader =
@@ -1095,7 +1096,7 @@ void *blitter_get_fs_texfetch_stencil(struct 
blitter_context_priv *ctx,
 
   /* Create the fragment shader on-demand. */
   if (!*shader) {
- unsigned tgsi_tex;
+ enum tgsi_texture_type tgsi_tex;
  assert(!ctx->cached_all_shaders);
  tgsi_tex = util_pipe_tex_to_tgsi_tex(target, nr_samples);
  *shader = util_make_fs_blit_msaa_stencil(pipe, tgsi_tex);
@@ -1112,7 +1113,7 @@ void *blitter_get_fs_texfetch_stencil(struct 
blitter_context_priv *ctx,
 
   /* Create the fragment shader on-demand. */
   if (!*shader) {
- unsigned tgsi_tex;
+ enum tgsi_texture_type tgsi_tex;
  assert(!ctx->cached_all_shaders);
  tgsi_tex = util_pipe_tex_to_tgsi_tex(target, 0);
  *shader =
diff --git a/src/gallium/auxiliary/util/u_inlines.h 
b/src/gallium/auxiliary/util/u_inlines.h
index 4fc683a574..d57f61e954 100644
--- a/src/gallium/auxiliary/util/u_inlines.h
+++ b/src/gallium/auxiliary/util/u_inlines.h
@@ -562,7 +562,7 @@ util_query_clear_result(union pipe_query_result *result, 
unsigned type)
 }
 
 /** Convert PIPE_TEXTURE_x to TGSI_TEXTURE_x */
-static inline unsigned
+static inline enum tgsi_texture_type
 util_pipe_tex_to_tgsi_tex(enum pipe_texture_target pipe_tex_target,
   unsigned nr_samples)
 {
diff --git a/src/gallium/auxiliary/util/u_simple_shaders.c 
b/src/gallium/auxiliary/util/u_simple_shaders.c
index 79331b5638..127bb7a75d 100644
--- a/src/gallium/auxiliary/util/u_simple_shaders.c
+++ b/src/gallium/auxiliary/util/u_simple_shaders.c
@@ -594,7 +594,7 @@ util_make_fragment_cloneinput_shader(struct pipe_context 
*pipe, int num_cbufs,
 
 static void *
 util_make_fs_blit_msaa_gen(struct pipe_context *pipe,
-   unsigned tgsi_tex,
+   enum tgsi_texture_type tgsi_tex,
const char *samp_type,
const char *output_semantic,
const char *output_mask,
@@ -648,7 +648,7 @@ util_make_fs_blit_msaa_gen(struct pipe_context *pi

Mesa (master): svga: rework the FS white fragments code

2017-07-25 Thread Brian Paul
Module: Mesa
Branch: master
Commit: 71d3b69b239c2e2eb8b154229c5defc013b7c7b5
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=71d3b69b239c2e2eb8b154229c5defc013b7c7b5

Author: Brian Paul 
Date:   Fri Jul 21 09:38:10 2017 -0600

svga: rework the FS white fragments code

When we forcibly write white to FS outputs (for XOR mode emulation)
we were using a temp register.  But that's not really necessary.
This also fixes the case of writing white to multiple color buffers.

Subsequent changes will build on this.

Reviewed-by: Charmaine Lee 

---

 src/gallium/drivers/svga/svga_state_fs.c| 11 
 src/gallium/drivers/svga/svga_tgsi_vgpu10.c | 43 +++--
 2 files changed, 21 insertions(+), 33 deletions(-)

diff --git a/src/gallium/drivers/svga/svga_state_fs.c 
b/src/gallium/drivers/svga/svga_state_fs.c
index 07a3614d79..bf45216304 100644
--- a/src/gallium/drivers/svga/svga_state_fs.c
+++ b/src/gallium/drivers/svga/svga_state_fs.c
@@ -232,9 +232,7 @@ make_fs_key(const struct svga_context *svga,
 *   
 * SVGA_NEW_BLEND
 */
-   if (svga->curr.blend->need_white_fragments) {
-  key->fs.white_fragments = 1;
-   }
+   key->fs.white_fragments = svga->curr.blend->need_white_fragments;
 
 #ifdef DEBUG
/*
@@ -349,9 +347,10 @@ make_fs_key(const struct svga_context *svga,
   }
}
 
-   /* SVGA_NEW_FRAME_BUFFER */
-   if (fs->base.info.properties[TGSI_PROPERTY_FS_COLOR0_WRITES_ALL_CBUFS]) {
-  /* Replicate color0 output to N colorbuffers */
+   /* SVGA_NEW_FRAME_BUFFER | SVGA_NEW_BLEND */
+   if (fs->base.info.properties[TGSI_PROPERTY_FS_COLOR0_WRITES_ALL_CBUFS] ||
+   svga->curr.blend->need_white_fragments) {
+  /* Replicate color0 output (or white) to N colorbuffers */
   key->fs.write_color0_to_n_cbufs = svga->curr.framebuffer.nr_cbufs;
}
 
diff --git a/src/gallium/drivers/svga/svga_tgsi_vgpu10.c 
b/src/gallium/drivers/svga/svga_tgsi_vgpu10.c
index d9b76c265a..9f5cd4b285 100644
--- a/src/gallium/drivers/svga/svga_tgsi_vgpu10.c
+++ b/src/gallium/drivers/svga/svga_tgsi_vgpu10.c
@@ -2707,7 +2707,6 @@ emit_temporaries_declaration(struct 
svga_shader_emitter_v10 *emit)
}
else if (emit->unit == PIPE_SHADER_FRAGMENT) {
   if (emit->key.fs.alpha_func != SVGA3D_CMP_ALWAYS ||
-  emit->key.fs.white_fragments ||
   emit->key.fs.write_color0_to_n_cbufs > 1) {
  /* Allocate a temp to hold the output color */
  emit->fs.color_tmp_index = total_temps;
@@ -6414,11 +6413,9 @@ emit_alpha_test_instructions(struct 
svga_shader_emitter_v10 *emit,
emit_src_register(emit, &tmp_src_x);
end_emit_instruction(emit);
 
-   /* If we don't need to broadcast the color below or set fragments to
-* white, emit final color here.
+   /* If we don't need to broadcast the color below, emit the final color here.
 */
-   if (emit->key.fs.write_color0_to_n_cbufs <= 1 &&
-   !emit->key.fs.white_fragments) {
+   if (emit->key.fs.write_color0_to_n_cbufs <= 1) {
   /* MOV output.color, tempcolor */
   emit_instruction_op1(emit, VGPU10_OPCODE_MOV, &color_dst,
&color_src, FALSE); /* XXX saturate? */
@@ -6429,23 +6426,6 @@ emit_alpha_test_instructions(struct 
svga_shader_emitter_v10 *emit,
 
 
 /**
- * When we need to emit white for all fragments (for emulating XOR logicop
- * mode), this function copies white into the temporary color output register.
- */
-static void
-emit_set_color_white(struct svga_shader_emitter_v10 *emit,
- unsigned fs_color_tmp_index)
-{
-   struct tgsi_full_dst_register color_dst =
-  make_dst_temp_reg(fs_color_tmp_index);
-   struct tgsi_full_src_register white =
-  make_immediate_reg_float(emit, 1.0f);
-
-   emit_instruction_op1(emit, VGPU10_OPCODE_MOV, &color_dst, &white, FALSE);
-}
-
-
-/**
  * Emit instructions for writing a single color output to multiple
  * color buffers.
  * This is used when the TGSI_PROPERTY_FS_COLOR0_WRITES_ALL_CBUFS (or
@@ -6460,8 +6440,17 @@ emit_broadcast_color_instructions(struct 
svga_shader_emitter_v10 *emit,
 {
const unsigned n = emit->key.fs.write_color0_to_n_cbufs;
unsigned i;
-   struct tgsi_full_src_register color_src =
-  make_src_temp_reg(fs_color_tmp_index);
+   struct tgsi_full_src_register color_src;
+
+   if (emit->key.fs.white_fragments) {
+  /* set all color outputs to white */
+  color_src = make_immediate_reg_float(emit, 1.0f);
+   }
+   else {
+  /* set all color outputs to TEMP[fs_color_tmp_index] */
+  assert(fs_color_tmp_index != INVALID_INDEX);
+  color_src = make_src_temp_reg(fs_color_tmp_index);
+   }
 
assert(emit->unit == PIPE_SHADER_FRAGMENT);
 
@@ -6497,6 +6486,9 @@ emit_post_helpers(struct svga_shader_emitter_v10 *emit)
else if (emit->unit == PIPE_SHADER_FRAGMENT) {
   const unsigned fs_color_tmp_index = emit->fs.color_tmp_index;
 
+  assert(!(emit->key.fs.white_fragments &&
+   emit->key.fs.write_color0_to_n_cbu

Mesa (master): svga: implement MSAA alpha_to_one feature

2017-07-25 Thread Brian Paul
Module: Mesa
Branch: master
Commit: 91735e2d4a25df0685e5f4c8f0a064f9d58c6b8e
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=91735e2d4a25df0685e5f4c8f0a064f9d58c6b8e

Author: Brian Paul 
Date:   Fri Jul 21 10:37:36 2017 -0600

svga: implement MSAA alpha_to_one feature

The device doesn't directly support this feature so we implement it with
additional shader code which sets the color output(s) w component to
1.0 (or max_int or max_uint).

Fixes 16 Piglit ext_framebuffer_multisample/*alpha-to-one* tests.

v2: only support unorm/float buffers, not int/uint, per Roland.

Reviewed-by: Roland Scheidegger 
Reviewed-by: Charmaine Lee 

---

 src/gallium/drivers/svga/svga_context.h |  1 +
 src/gallium/drivers/svga/svga_pipe_blend.c  |  1 +
 src/gallium/drivers/svga/svga_shader.h  |  1 +
 src/gallium/drivers/svga/svga_state_fs.c|  3 ++
 src/gallium/drivers/svga/svga_tgsi_vgpu10.c | 52 -
 5 files changed, 57 insertions(+), 1 deletion(-)

diff --git a/src/gallium/drivers/svga/svga_context.h 
b/src/gallium/drivers/svga/svga_context.h
index d0306c036f..0d695a6492 100644
--- a/src/gallium/drivers/svga/svga_context.h
+++ b/src/gallium/drivers/svga/svga_context.h
@@ -106,6 +106,7 @@ struct svga_blend_state {
unsigned need_white_fragments:1;
unsigned independent_blend_enable:1;
unsigned alpha_to_coverage:1;
+   unsigned alpha_to_one:1;
unsigned blend_color_alpha:1;  /**< set blend color to alpha value */
 
/** Per-render target state */
diff --git a/src/gallium/drivers/svga/svga_pipe_blend.c 
b/src/gallium/drivers/svga/svga_pipe_blend.c
index 408e175fea..a29fbd3ac2 100644
--- a/src/gallium/drivers/svga/svga_pipe_blend.c
+++ b/src/gallium/drivers/svga/svga_pipe_blend.c
@@ -331,6 +331,7 @@ svga_create_blend_state(struct pipe_context *pipe,
blend->independent_blend_enable = templ->independent_blend_enable;
 
blend->alpha_to_coverage = templ->alpha_to_coverage;
+   blend->alpha_to_one = templ->alpha_to_one;
 
if (svga_have_vgpu10(svga)) {
   define_blend_state_object(svga, blend);
diff --git a/src/gallium/drivers/svga/svga_shader.h 
b/src/gallium/drivers/svga/svga_shader.h
index a594d120f8..dc462c94af 100644
--- a/src/gallium/drivers/svga/svga_shader.h
+++ b/src/gallium/drivers/svga/svga_shader.h
@@ -77,6 +77,7 @@ struct svga_compile_key
   unsigned light_twoside:1;
   unsigned front_ccw:1;
   unsigned white_fragments:1;
+  unsigned alpha_to_one:1;
   unsigned flatshade:1;
   unsigned pstipple:1;
   unsigned alpha_func:4;  /**< SVGA3D_CMP_x */
diff --git a/src/gallium/drivers/svga/svga_state_fs.c 
b/src/gallium/drivers/svga/svga_state_fs.c
index bf45216304..5e568993fe 100644
--- a/src/gallium/drivers/svga/svga_state_fs.c
+++ b/src/gallium/drivers/svga/svga_state_fs.c
@@ -25,6 +25,7 @@
 
 #include "util/u_inlines.h"
 #include "pipe/p_defines.h"
+#include "util/u_format.h"
 #include "util/u_math.h"
 #include "util/u_memory.h"
 #include "util/u_bitmask.h"
@@ -234,6 +235,8 @@ make_fs_key(const struct svga_context *svga,
 */
key->fs.white_fragments = svga->curr.blend->need_white_fragments;
 
+   key->fs.alpha_to_one = svga->curr.blend->alpha_to_one;
+
 #ifdef DEBUG
/*
 * We expect a consistent set of samplers and sampler views.
diff --git a/src/gallium/drivers/svga/svga_tgsi_vgpu10.c 
b/src/gallium/drivers/svga/svga_tgsi_vgpu10.c
index 9f5cd4b285..d7ec48eb8a 100644
--- a/src/gallium/drivers/svga/svga_tgsi_vgpu10.c
+++ b/src/gallium/drivers/svga/svga_tgsi_vgpu10.c
@@ -167,8 +167,8 @@ struct svga_shader_emitter_v10
 
/* For fragment shaders only */
struct {
-  /* apha test */
   unsigned color_out_index[PIPE_MAX_COLOR_BUFS];  /**< the real color 
output regs */
+  unsigned num_color_outputs;
   unsigned color_tmp_index;  /**< fake/temp color output reg */
   unsigned alpha_ref_index;  /**< immediate constant for alpha ref */
 
@@ -2499,6 +2499,9 @@ emit_output_declarations(struct svga_shader_emitter_v10 
*emit)
 
 emit->fs.color_out_index[semantic_index] = index;
 
+emit->fs.num_color_outputs = MAX2(emit->fs.num_color_outputs,
+  index + 1);
+
 /* The semantic index is the shader's color output/buffer index */
 emit_output_declaration(emit,
 VGPU10_OPCODE_DCL_OUTPUT, semantic_index,
@@ -2521,6 +2524,9 @@ emit_output_declarations(struct svga_shader_emitter_v10 
*emit)
 VGPU10_OPERAND_4_COMPONENT_MASK_ALL);
  emit->info.output_semantic_index[idx] = j;
   }
+
+  emit->fs.num_color_outputs =
+ emit->key.fs.write_color0_to_n_cbufs;
}
 }
 else {
@@ -6378,6 +6384,47 @@ emit_pre_helpers(struct svga_shader_emitter_v10 *emit)
 
 
 /**
+ * The device has no direct support for the pipe_blend_state::alpha_to_one
+ * 

Mesa (master): drirc: whitelist glthread for Overlord 1+2, Oil Rush, War Thunder, Saints Row 2

2017-07-25 Thread Marek Olšák
Module: Mesa
Branch: master
Commit: 22379f7cad75f4dab0c535a5fccfc180e390888f
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=22379f7cad75f4dab0c535a5fccfc180e390888f

Author: Kamil Páral 
Date:   Tue Jul 25 21:28:40 2017 +0200

drirc: whitelist glthread for Overlord 1+2, Oil Rush, War Thunder, Saints Row 2

Performance delta on Core i5-4570 + Radeon R9 270:
Overlord: +20% in certain locations
Overlord II: +20% in certain locations
Oil Rush: +12% in most locations
War Thunder: +4-9% in benchmarks
Saints Row 2: +10-35% in certain locations

---

 src/mesa/drivers/dri/common/drirc | 19 +--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/src/mesa/drivers/dri/common/drirc 
b/src/mesa/drivers/dri/common/drirc
index c9fcb59d82..30ac9c839b 100644
--- a/src/mesa/drivers/dri/common/drirc
+++ b/src/mesa/drivers/dri/common/drirc
@@ -187,9 +187,24 @@ TODO: document the other workarounds.
 
 
 
-   
+
 
-   
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
 
 
 

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


Mesa (master): i965: perf: flush batchbuffers at the beginning of queries

2017-07-25 Thread Lionel Landwerlin
Module: Mesa
Branch: master
Commit: 9f439ae1201cb049ffedb9b0e2d4f393fb0a761e
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=9f439ae1201cb049ffedb9b0e2d4f393fb0a761e

Author: Lionel Landwerlin 
Date:   Tue Jul 25 17:49:22 2017 +0100

i965: perf: flush batchbuffers at the beginning of queries

As Chris commented, it makes more sense to have batch buffer flushes
before the query. Usually applications like frame_retrace do a series
of queries and in that case, with flushes at the end of the queries,
we might still have the first query contained in 2 different batchs.
More generally it would be quite usual to have the query contained in
2 batch buffers because we never now what's the fill rate of the
current batch buffer.

If we move the flushing at the beginning of the queries, it's pretty
much guaranteed that queries will be contained in a single batch
buffer (unless the amount of commands is huge, but then it's only fair
to include reloading request times in the measurements).

Fixes: adafe4b733c02 ("i965: perf: minimize the chances to spread queries 
across batchbuffers")
Reported-by: Chris Wilson 
Signed-off-by: Lionel Landwerlin 
Cc: "17.2 17.1" 
Reviewed-by: Kenneth Graunke 

---

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

diff --git a/src/mesa/drivers/dri/i965/brw_performance_query.c 
b/src/mesa/drivers/dri/i965/brw_performance_query.c
index d7902de836..d8680b4879 100644
--- a/src/mesa/drivers/dri/i965/brw_performance_query.c
+++ b/src/mesa/drivers/dri/i965/brw_performance_query.c
@@ -1212,6 +1212,14 @@ brw_begin_perf_query(struct gl_context *ctx,
   obj->oa.begin_report_id = brw->perfquery.next_query_start_report_id;
   brw->perfquery.next_query_start_report_id += 2;
 
+  /* We flush the batchbuffer here to minimize the chances that MI_RPC
+   * delimiting commands end up in different batchbuffers. If that's the
+   * case, the measurement will include the time it takes for the kernel
+   * scheduler to load a new request into the hardware. This is manifested 
in
+   * tools like frameretrace by spikes in the "GPU Core Clocks" counter.
+   */
+  intel_batchbuffer_flush(brw);
+
   /* Take a starting OA counter snapshot. */
   brw->vtbl.emit_mi_report_perf_count(brw, obj->oa.bo, 0,
   obj->oa.begin_report_id);
@@ -1298,14 +1306,6 @@ brw_end_perf_query(struct gl_context *ctx,
  obj->oa.begin_report_id + 1);
   }
 
-  /* We flush the batchbuffer here to minimize the chances that MI_RPC
-   * delimiting commands end up in different batchbuffers. If that's the
-   * case, the measurement will include the time it takes for the kernel
-   * scheduler to load a new request into the hardware. This is manifested
-   * in tools like frameretrace by spikes in the "GPU Core Clocks"
-   * counter.
-   */
-  intel_batchbuffer_flush(brw);
   --brw->perfquery.n_active_oa_queries;
 
   /* NB: even though the query has now ended, it can't be accumulated

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


Mesa (master): st/dri: Check get-handle return value in queryImage

2017-07-25 Thread Daniel Stone
Module: Mesa
Branch: master
Commit: b4a18f13ce7f0e7d0307fb3388819345616752ce
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=b4a18f13ce7f0e7d0307fb3388819345616752ce

Author: Daniel Stone 
Date:   Mon Jul 24 14:42:56 2017 +0100

st/dri: Check get-handle return value in queryImage

In the DRIImage queryImage hook, check if resource_get_handle() failed
and return FALSE if so.

Signed-off-by: Daniel Stone 
Reviewed-by: Marek Olšák 

---

 src/gallium/state_trackers/dri/dri2.c | 30 ++
 1 file changed, 18 insertions(+), 12 deletions(-)

diff --git a/src/gallium/state_trackers/dri/dri2.c 
b/src/gallium/state_trackers/dri/dri2.c
index 19ee5f495e..3ebed7a98b 100644
--- a/src/gallium/state_trackers/dri/dri2.c
+++ b/src/gallium/state_trackers/dri/dri2.c
@@ -1183,26 +1183,30 @@ dri2_query_image(__DRIimage *image, int attrib, int 
*value)
switch (attrib) {
case __DRI_IMAGE_ATTRIB_STRIDE:
   whandle.type = DRM_API_HANDLE_TYPE_KMS;
-  image->texture->screen->resource_get_handle(image->texture->screen,
-NULL, image->texture, &whandle, usage);
+  if (!image->texture->screen->resource_get_handle(image->texture->screen,
+NULL, image->texture, &whandle, usage))
+ return GL_FALSE;
   *value = whandle.stride;
   return GL_TRUE;
case __DRI_IMAGE_ATTRIB_OFFSET:
   whandle.type = DRM_API_HANDLE_TYPE_KMS;
-  image->texture->screen->resource_get_handle(image->texture->screen,
-NULL, image->texture, &whandle, usage);
+  if (!image->texture->screen->resource_get_handle(image->texture->screen,
+NULL, image->texture, &whandle, usage))
+ return GL_FALSE;
   *value = whandle.offset;
   return GL_TRUE;
case __DRI_IMAGE_ATTRIB_HANDLE:
   whandle.type = DRM_API_HANDLE_TYPE_KMS;
-  image->texture->screen->resource_get_handle(image->texture->screen,
- NULL, image->texture, &whandle, usage);
+  if (!image->texture->screen->resource_get_handle(image->texture->screen,
+ NULL, image->texture, &whandle, usage))
+ return GL_FALSE;
   *value = whandle.handle;
   return GL_TRUE;
case __DRI_IMAGE_ATTRIB_NAME:
   whandle.type = DRM_API_HANDLE_TYPE_SHARED;
-  image->texture->screen->resource_get_handle(image->texture->screen,
- NULL, image->texture, &whandle, usage);
+  if (!image->texture->screen->resource_get_handle(image->texture->screen,
+ NULL, image->texture, &whandle, usage))
+ return GL_FALSE;
   *value = whandle.handle;
   return GL_TRUE;
case __DRI_IMAGE_ATTRIB_FD:
@@ -1235,14 +1239,16 @@ dri2_query_image(__DRIimage *image, int attrib, int 
*value)
   return GL_TRUE;
case __DRI_IMAGE_ATTRIB_MODIFIER_UPPER:
   whandle.type = DRM_API_HANDLE_TYPE_KMS;
-  image->texture->screen->resource_get_handle(image->texture->screen,
-NULL, image->texture, &whandle, usage);
+  if (!image->texture->screen->resource_get_handle(image->texture->screen,
+NULL, image->texture, &whandle, usage))
+ return GL_FALSE;
   *value = (whandle.modifier >> 32) & 0x;
   return GL_TRUE;
case __DRI_IMAGE_ATTRIB_MODIFIER_LOWER:
   whandle.type = DRM_API_HANDLE_TYPE_KMS;
-  image->texture->screen->resource_get_handle(image->texture->screen,
-NULL, image->texture, &whandle, usage);
+  if (!image->texture->screen->resource_get_handle(image->texture->screen,
+NULL, image->texture, &whandle, usage))
+ return GL_FALSE;
   *value = whandle.modifier & 0x;
   return GL_TRUE;
default:

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


Mesa (master): st/dri2: Return invalid modifier when no driver support

2017-07-25 Thread Daniel Stone
Module: Mesa
Branch: master
Commit: 45383d32d4fd0265a7133704cb3e6c15620177cd
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=45383d32d4fd0265a7133704cb3e6c15620177cd

Author: Daniel Stone 
Date:   Fri Jul 21 13:55:42 2017 +0100

st/dri2: Return invalid modifier when no driver support

Always initialise whandle.modifier for DRIImage modifier queries, so if
the driver doesn't support it then we return false for the query.

Signed-off-by: Daniel Stone 
Reviewed-by: Marek Olšák 
Fixes: d33fe8b84e45 ("st/dri: enable DRIimage modifier queries")

---

 src/gallium/state_trackers/dri/dri2.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/src/gallium/state_trackers/dri/dri2.c 
b/src/gallium/state_trackers/dri/dri2.c
index 3ebed7a98b..0cbc76f7f8 100644
--- a/src/gallium/state_trackers/dri/dri2.c
+++ b/src/gallium/state_trackers/dri/dri2.c
@@ -1239,16 +1239,22 @@ dri2_query_image(__DRIimage *image, int attrib, int 
*value)
   return GL_TRUE;
case __DRI_IMAGE_ATTRIB_MODIFIER_UPPER:
   whandle.type = DRM_API_HANDLE_TYPE_KMS;
+  whandle.modifier = DRM_FORMAT_MOD_INVALID;
   if (!image->texture->screen->resource_get_handle(image->texture->screen,
 NULL, image->texture, &whandle, usage))
  return GL_FALSE;
+  if (whandle.modifier == DRM_FORMAT_MOD_INVALID)
+ return GL_FALSE;
   *value = (whandle.modifier >> 32) & 0x;
   return GL_TRUE;
case __DRI_IMAGE_ATTRIB_MODIFIER_LOWER:
   whandle.type = DRM_API_HANDLE_TYPE_KMS;
+  whandle.modifier = DRM_FORMAT_MOD_INVALID;
   if (!image->texture->screen->resource_get_handle(image->texture->screen,
 NULL, image->texture, &whandle, usage))
  return GL_FALSE;
+  if (whandle.modifier == DRM_FORMAT_MOD_INVALID)
+ return GL_FALSE;
   *value = whandle.modifier & 0x;
   return GL_TRUE;
default:

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


Mesa (master): r600: Add support for B5G5R5A1.

2017-07-25 Thread Marek Olšák
Module: Mesa
Branch: master
Commit: e6d7937b86d8f3c7e0605741de8721caf991af05
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=e6d7937b86d8f3c7e0605741de8721caf991af05

Author: Michal Srb 
Date:   Mon Jul 17 09:34:44 2017 +0200

r600: Add support for B5G5R5A1.

Fixes rendercheck errors when using glamor acceleration in X server.

Signed-off-by: Marek Olšák 

---

 src/gallium/drivers/r600/r600_asm.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/src/gallium/drivers/r600/r600_asm.c 
b/src/gallium/drivers/r600/r600_asm.c
index f5c0e80919..a0f28d2776 100644
--- a/src/gallium/drivers/r600/r600_asm.c
+++ b/src/gallium/drivers/r600/r600_asm.c
@@ -2376,6 +2376,12 @@ void r600_vertex_data_type(enum pipe_format pformat,
return;
}
 
+   if (pformat == PIPE_FORMAT_B5G5R5A1_UNORM) {
+   *format = FMT_1_5_5_5;
+   *endian = r600_endian_swap(16);
+   return;
+   }
+
desc = util_format_description(pformat);
if (desc->layout != UTIL_FORMAT_LAYOUT_PLAIN) {
goto out_unknown;

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


Mesa (master): radeon/vcn: move message buffer to vram for now

2017-07-25 Thread Leo Liu
Module: Mesa
Branch: master
Commit: 82fcf3142f5dd43df530b5544350b957fd43f79f
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=82fcf3142f5dd43df530b5544350b957fd43f79f

Author: Leo Liu 
Date:   Tue Jul 18 09:48:02 2017 -0400

radeon/vcn: move message buffer to vram for now

To workaround an unknown bug.

Signed-off-by: Leo Liu 
Acked-by: Christian König 

---

 src/gallium/drivers/radeon/radeon_vcn_dec.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/gallium/drivers/radeon/radeon_vcn_dec.c 
b/src/gallium/drivers/radeon/radeon_vcn_dec.c
index bd93b849db..a60b969a27 100644
--- a/src/gallium/drivers/radeon/radeon_vcn_dec.c
+++ b/src/gallium/drivers/radeon/radeon_vcn_dec.c
@@ -1237,8 +1237,9 @@ struct pipe_video_codec *radeon_create_decoder(struct 
pipe_context *context,
unsigned msg_fb_it_size = FB_BUFFER_OFFSET + FB_BUFFER_SIZE;
if (have_it(dec))
msg_fb_it_size += IT_SCALING_TABLE_SIZE;
+   /* use vram to improve performance, workaround an unknown bug */
if (!rvid_create_buffer(dec->screen, &dec->msg_fb_it_buffers[i],
-   msg_fb_it_size, PIPE_USAGE_STAGING)) {
+   msg_fb_it_size, PIPE_USAGE_DEFAULT)) {
RVID_ERR("Can't allocated message buffers.\n");
goto error;
}

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


Mesa (master): trace: Correct transfer box size calculation.

2017-07-25 Thread Jose Fonseca
Module: Mesa
Branch: master
Commit: 8d655263cae8765895feec14ac0cd1ebcfdf6e3f
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=8d655263cae8765895feec14ac0cd1ebcfdf6e3f

Author: Jose Fonseca 
Date:   Mon Jul 24 14:20:03 2017 +0100

trace: Correct transfer box size calculation.

For textures we must not approximate the calculation with `stride *
height`, or `slice_stride * depth`, as that can easily lead to buffer
overflows, particularly for partial transfers.

This should address the issue that Bruce Cherniak found and diagnosed.

Reviewed-by: Roland Scheidegger 

---

 src/gallium/drivers/trace/tr_dump.c | 17 -
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/gallium/drivers/trace/tr_dump.c 
b/src/gallium/drivers/trace/tr_dump.c
index 78c72492dc..2003222cc1 100644
--- a/src/gallium/drivers/trace/tr_dump.c
+++ b/src/gallium/drivers/trace/tr_dump.c
@@ -448,23 +448,22 @@ void trace_dump_box_bytes(const void *data,
  unsigned stride,
  unsigned slice_stride)
 {
+   enum pipe_format format = resource->format;
size_t size;
 
+   assert(box->height > 0);
+   assert(box->depth > 0);
+
+   size =  util_format_get_nblocksx(format, box->width )  * 
util_format_get_blocksize(format)
++ (util_format_get_nblocksy(format, box->height) - 1) * stride
++  (box->depth   - 1) * slice_stride;
+
/*
 * Only dump buffer transfers to avoid huge files.
 * TODO: Make this run-time configurable
 */
if (resource->target != PIPE_BUFFER) {
   size = 0;
-   } else {
-  enum pipe_format format = resource->format;
-  if (slice_stride)
- size = box->depth * slice_stride;
-  else if (stride)
- size = util_format_get_nblocksy(format, box->height) * stride;
-  else {
- size = util_format_get_nblocksx(format, box->width) * 
util_format_get_blocksize(format);
-  }
}
 
trace_dump_bytes(data, size);

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


Mesa (master): mesa: add active_shader_program() helper

2017-07-25 Thread Samuel Pitoiset
Module: Mesa
Branch: master
Commit: c3ea898932cb2fd408339bab103fc8ac63908320
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=c3ea898932cb2fd408339bab103fc8ac63908320

Author: Samuel Pitoiset 
Date:   Fri Jul 21 15:16:06 2017 +0200

mesa: add active_shader_program() helper

To reduce code duplication.

Signed-off-by: Samuel Pitoiset 
Reviewed-by: Nicolai Hähnle 

---

 src/mesa/main/pipelineobj.c | 63 +++--
 1 file changed, 32 insertions(+), 31 deletions(-)

diff --git a/src/mesa/main/pipelineobj.c b/src/mesa/main/pipelineobj.c
index 172a014e3e..d7d99ec22d 100644
--- a/src/mesa/main/pipelineobj.c
+++ b/src/mesa/main/pipelineobj.c
@@ -371,24 +371,50 @@ _mesa_UseProgramStages(GLuint pipeline, GLbitfield 
stages, GLuint program)
use_program_stages(ctx, shProg, stages, pipe);
 }
 
-void GLAPIENTRY
-_mesa_ActiveShaderProgram_no_error(GLuint pipeline, GLuint program)
+static ALWAYS_INLINE void
+active_shader_program(struct gl_context *ctx, GLuint pipeline, GLuint program,
+  bool no_error)
 {
-   GET_CURRENT_CONTEXT(ctx);
struct gl_shader_program *shProg = NULL;
struct gl_pipeline_object *pipe = _mesa_lookup_pipeline_object(ctx, 
pipeline);
 
-   if (program)
-  shProg = _mesa_lookup_shader_program(ctx, program);
+   if (program) {
+  if (no_error) {
+ shProg = _mesa_lookup_shader_program(ctx, program);
+  } else {
+ shProg = _mesa_lookup_shader_program_err(ctx, program,
+  
"glActiveShaderProgram(program)");
+ if (shProg == NULL)
+return;
+  }
+   }
+
+   if (!no_error && !pipe) {
+  _mesa_error(ctx, GL_INVALID_OPERATION, 
"glActiveShaderProgram(pipeline)");
+  return;
+   }
 
/* Object is created by any Pipeline call but glGenProgramPipelines,
 * glIsProgramPipeline and GetProgramPipelineInfoLog
 */
pipe->EverBound = GL_TRUE;
 
+   if (!no_error && shProg != NULL && !shProg->data->LinkStatus) {
+  _mesa_error(ctx, GL_INVALID_OPERATION,
+"glActiveShaderProgram(program %u not linked)", shProg->Name);
+  return;
+   }
+
_mesa_reference_shader_program(ctx, &pipe->ActiveProgram, shProg);
 }
 
+void GLAPIENTRY
+_mesa_ActiveShaderProgram_no_error(GLuint pipeline, GLuint program)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   active_shader_program(ctx, pipeline, program, true);
+}
+
 /**
  * Use the named shader program for subsequent glUniform calls (if pipeline
  * bound)
@@ -397,36 +423,11 @@ void GLAPIENTRY
 _mesa_ActiveShaderProgram(GLuint pipeline, GLuint program)
 {
GET_CURRENT_CONTEXT(ctx);
-   struct gl_shader_program *shProg = NULL;
-   struct gl_pipeline_object *pipe = _mesa_lookup_pipeline_object(ctx, 
pipeline);
 
if (MESA_VERBOSE & VERBOSE_API)
   _mesa_debug(ctx, "glActiveShaderProgram(%u, %u)\n", pipeline, program);
 
-   if (program != 0) {
-  shProg = _mesa_lookup_shader_program_err(ctx, program,
-   
"glActiveShaderProgram(program)");
-  if (shProg == NULL)
- return;
-   }
-
-   if (!pipe) {
-  _mesa_error(ctx, GL_INVALID_OPERATION, 
"glActiveShaderProgram(pipeline)");
-  return;
-   }
-
-   /* Object is created by any Pipeline call but glGenProgramPipelines,
-* glIsProgramPipeline and GetProgramPipelineInfoLog
-*/
-   pipe->EverBound = GL_TRUE;
-
-   if ((shProg != NULL) && !shProg->data->LinkStatus) {
-  _mesa_error(ctx, GL_INVALID_OPERATION,
-"glActiveShaderProgram(program %u not linked)", shProg->Name);
-  return;
-   }
-
-   _mesa_reference_shader_program(ctx, &pipe->ActiveProgram, shProg);
+   active_shader_program(ctx, pipeline, program, false);
 }
 
 static ALWAYS_INLINE void

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


Mesa (master): mesa: add bind_program_pipeline() helper

2017-07-25 Thread Samuel Pitoiset
Module: Mesa
Branch: master
Commit: b8338f8df21f9f0d86ba88017e8e9dca54f74220
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=b8338f8df21f9f0d86ba88017e8e9dca54f74220

Author: Samuel Pitoiset 
Date:   Fri Jul 21 15:16:05 2017 +0200

mesa: add bind_program_pipeline() helper

To reduce code duplication.

Signed-off-by: Samuel Pitoiset 
Reviewed-by: Nicolai Hähnle 

---

 src/mesa/main/pipelineobj.c | 55 +
 1 file changed, 21 insertions(+), 34 deletions(-)

diff --git a/src/mesa/main/pipelineobj.c b/src/mesa/main/pipelineobj.c
index f4008c..172a014e3e 100644
--- a/src/mesa/main/pipelineobj.c
+++ b/src/mesa/main/pipelineobj.c
@@ -429,39 +429,9 @@ _mesa_ActiveShaderProgram(GLuint pipeline, GLuint program)
_mesa_reference_shader_program(ctx, &pipe->ActiveProgram, shProg);
 }
 
-void GLAPIENTRY
-_mesa_BindProgramPipeline_no_error(GLuint pipeline)
+static ALWAYS_INLINE void
+bind_program_pipeline(struct gl_context *ctx, GLuint pipeline, bool no_error)
 {
-   GET_CURRENT_CONTEXT(ctx);
-   struct gl_pipeline_object *newObj = NULL;
-
-   /* Rebinding the same pipeline object: no change.
-*/
-   if (ctx->_Shader->Name == pipeline)
-  return;
-
-   /* Get pointer to new pipeline object (newObj)
-*/
-   if (pipeline) {
-  /* non-default pipeline object */
-  newObj = _mesa_lookup_pipeline_object(ctx, pipeline);
-
-  /* Object is created by any Pipeline call but glGenProgramPipelines,
-   * glIsProgramPipeline and GetProgramPipelineInfoLog
-   */
-  newObj->EverBound = GL_TRUE;
-   }
-
-   _mesa_bind_pipeline(ctx, newObj);
-}
-
-/**
- * Make program of the pipeline current
- */
-void GLAPIENTRY
-_mesa_BindProgramPipeline(GLuint pipeline)
-{
-   GET_CURRENT_CONTEXT(ctx);
struct gl_pipeline_object *newObj = NULL;
 
if (MESA_VERBOSE & VERBOSE_API)
@@ -482,7 +452,7 @@ _mesa_BindProgramPipeline(GLuint pipeline)
 * - by BindProgramPipeline if the current transform feedback
 *   object is active and not paused;
 */
-   if (_mesa_is_xfb_active_and_unpaused(ctx)) {
+   if (!no_error && _mesa_is_xfb_active_and_unpaused(ctx)) {
   _mesa_error(ctx, GL_INVALID_OPERATION,
 "glBindProgramPipeline(transform feedback active)");
   return;
@@ -493,7 +463,7 @@ _mesa_BindProgramPipeline(GLuint pipeline)
if (pipeline) {
   /* non-default pipeline object */
   newObj = _mesa_lookup_pipeline_object(ctx, pipeline);
-  if (!newObj) {
+  if (!no_error && !newObj) {
  _mesa_error(ctx, GL_INVALID_OPERATION,
  "glBindProgramPipeline(non-gen name)");
  return;
@@ -508,6 +478,23 @@ _mesa_BindProgramPipeline(GLuint pipeline)
_mesa_bind_pipeline(ctx, newObj);
 }
 
+void GLAPIENTRY
+_mesa_BindProgramPipeline_no_error(GLuint pipeline)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   bind_program_pipeline(ctx, pipeline, true);
+}
+
+/**
+ * Make program of the pipeline current
+ */
+void GLAPIENTRY
+_mesa_BindProgramPipeline(GLuint pipeline)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   bind_program_pipeline(ctx, pipeline, false);
+}
+
 void
 _mesa_bind_pipeline(struct gl_context *ctx,
 struct gl_pipeline_object *pipe)

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


Mesa (master): util: fix warning/error on 32bit build

2017-07-25 Thread Tapani Pälli
Module: Mesa
Branch: master
Commit: 8dba6f8cf4d1f1d2dfd102c7ddc230995488247c
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=8dba6f8cf4d1f1d2dfd102c7ddc230995488247c

Author: Tapani Pälli 
Date:   Tue Jul 25 08:38:03 2017 +0300

util: fix warning/error on 32bit build

Add uintptr_t cast to fix 'cast to pointer from integer of different size'
warning on 32bit build (build error on Android M).

Signed-off-by: Tapani Pälli 
Reviewed-by: Michel Dänzer 
Reviewed-by: Samuel Pitoiset 

---

 src/util/hash_table.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/util/hash_table.c b/src/util/hash_table.c
index a9d442d680..1bda2149b9 100644
--- a/src/util/hash_table.c
+++ b/src/util/hash_table.c
@@ -588,7 +588,7 @@ _mesa_hash_table_u64_insert(struct hash_table_u64 *ht, 
uint64_t key,
}
 
if (sizeof(void *) == 8) {
-  _mesa_hash_table_insert(ht->table, (void *)key, data);
+  _mesa_hash_table_insert(ht->table, (void *)(uintptr_t)key, data);
} else {
   struct hash_key_u64 *_key = CALLOC_STRUCT(hash_key_u64);
 
@@ -604,7 +604,7 @@ static struct hash_entry *
 hash_table_u64_search(struct hash_table_u64 *ht, uint64_t key)
 {
if (sizeof(void *) == 8) {
-  return _mesa_hash_table_search(ht->table, (void *)key);
+  return _mesa_hash_table_search(ht->table, (void *)(uintptr_t)key);
} else {
   struct hash_key_u64 _key = { .value = key };
   return _mesa_hash_table_search(ht->table, &_key);

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


Mesa (master): egl: fix whitespace issues from eglimage code

2017-07-25 Thread Tapani Pälli
Module: Mesa
Branch: master
Commit: 3392026866e00a8d663b001d4240fc292d27319a
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=3392026866e00a8d663b001d4240fc292d27319a

Author: Tapani Pälli 
Date:   Mon Jul 24 14:10:50 2017 +0300

egl: fix whitespace issues from eglimage code

Signed-off-by: Tapani Pälli 
Reviewed-by: Emil Velikov 

---

 src/egl/main/eglimage.c | 20 ++--
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/src/egl/main/eglimage.c b/src/egl/main/eglimage.c
index 72a556e8db..46bf0c50f0 100644
--- a/src/egl/main/eglimage.c
+++ b/src/egl/main/eglimage.c
@@ -41,7 +41,7 @@ _eglParseKHRImageAttribs(_EGLImageAttribs *attrs, _EGLDisplay 
*dpy,
switch (attr) {
case EGL_IMAGE_PRESERVED_KHR:
   if (!dpy->Extensions.KHR_image_base)
-  return EGL_BAD_PARAMETER;
+ return EGL_BAD_PARAMETER;
 
   attrs->ImagePreserved = val;
   break;
@@ -144,9 +144,9 @@ _eglParseEXTImageDmaBufImportAttribs(_EGLImageAttribs 
*attrs, _EGLDisplay *dpy,
   attrs->DMABufPlanePitches[0].IsPresent = EGL_TRUE;
   break;
case EGL_DMA_BUF_PLANE1_FD_EXT:
-   attrs->DMABufPlaneFds[1].Value = val;
-   attrs->DMABufPlaneFds[1].IsPresent = EGL_TRUE;
-   break;
+  attrs->DMABufPlaneFds[1].Value = val;
+  attrs->DMABufPlaneFds[1].IsPresent = EGL_TRUE;
+  break;
case EGL_DMA_BUF_PLANE1_OFFSET_EXT:
   attrs->DMABufPlaneOffsets[1].Value = val;
   attrs->DMABufPlaneOffsets[1].IsPresent = EGL_TRUE;
@@ -288,30 +288,30 @@ _eglParseImageAttribList(_EGLImageAttribs *attrs, 
_EGLDisplay *dpy,
 
   err = _eglParseKHRImageAttribs(attrs, dpy, attr, val);
   if (err == EGL_SUCCESS)
-  continue;
+ continue;
 
   err = _eglParseMESADrmImageAttribs(attrs, dpy, attr, val);
   if (err == EGL_SUCCESS)
-  continue;
+ continue;
 
   err = _eglParseWLBindWaylandDisplayAttribs(attrs, dpy, attr, val);
   if (err == EGL_SUCCESS)
-  continue;
+ continue;
 
   err = _eglParseEXTImageDmaBufImportAttribs(attrs, dpy, attr, val);
   if (err == EGL_SUCCESS)
-  continue;
+ continue;
 
   /* EXT_image_dma_buf_import states that if invalid value is provided for
* its attributes, we should return EGL_BAD_ATTRIBUTE.
* Bail out ASAP, since follow-up calls can return another EGL_BAD error.
*/
   if (err == EGL_BAD_ATTRIBUTE)
-  return _eglError(err, __func__);
+ return _eglError(err, __func__);
 
   err = _eglParseEXTImageDmaBufImportModifiersAttribs(attrs, dpy, attr, 
val);
   if (err == EGL_SUCCESS)
-  continue;
+ continue;
 
   return _eglError(err, __func__);
}

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


Mesa (master): r600g: constify some args at r600_asm.c

2017-07-25 Thread Nicolai Hähnle
Module: Mesa
Branch: master
Commit: dacb3197774623fd1b8738af89aa0bbc7ba1333b
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=dacb3197774623fd1b8738af89aa0bbc7ba1333b

Author: Constantine Charlamov 
Date:   Mon Jul 17 04:04:51 2017 +0300

r600g: constify some args at r600_asm.c

Signed-off-by: Constantine Kharlamov 
Reviewed-by: Nicolai Hähnle 

---

 src/gallium/drivers/r600/r600_asm.c | 11 ++-
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/src/gallium/drivers/r600/r600_asm.c 
b/src/gallium/drivers/r600/r600_asm.c
index f333e7769a..f5c0e80919 100644
--- a/src/gallium/drivers/r600/r600_asm.c
+++ b/src/gallium/drivers/r600/r600_asm.c
@@ -43,7 +43,7 @@ static inline bool alu_writes(struct r600_bytecode_alu *alu)
return alu->dst.write || alu->is_op3;
 }
 
-static inline unsigned int r600_bytecode_get_num_operands(struct 
r600_bytecode_alu *alu)
+static inline unsigned int r600_bytecode_get_num_operands(const struct 
r600_bytecode_alu *alu)
 {
return r600_isa_alu(alu->op)->src_count;
 }
@@ -402,7 +402,8 @@ static int reserve_gpr(struct alu_bank_swizzle *bs, 
unsigned sel, unsigned chan,
return 0;
 }
 
-static int reserve_cfile(struct r600_bytecode *bc, struct alu_bank_swizzle 
*bs, unsigned sel, unsigned chan)
+static int reserve_cfile(const struct r600_bytecode *bc,
+struct alu_bank_swizzle *bs, unsigned sel, unsigned 
chan)
 {
int res, num_res = 4;
if (bc->chip_class >= R700) {
@@ -444,7 +445,7 @@ static int is_const(int sel)
sel <= V_SQ_ALU_SRC_LITERAL);
 }
 
-static int check_vector(struct r600_bytecode *bc, struct r600_bytecode_alu 
*alu,
+static int check_vector(const struct r600_bytecode *bc, const struct 
r600_bytecode_alu *alu,
struct alu_bank_swizzle *bs, int bank_swizzle)
 {
int r, src, num_src, sel, elem, cycle;
@@ -474,7 +475,7 @@ static int check_vector(struct r600_bytecode *bc, struct 
r600_bytecode_alu *alu,
return 0;
 }
 
-static int check_scalar(struct r600_bytecode *bc, struct r600_bytecode_alu 
*alu,
+static int check_scalar(const struct r600_bytecode *bc, const struct 
r600_bytecode_alu *alu,
struct alu_bank_swizzle *bs, int bank_swizzle)
 {
int r, src, num_src, const_count, sel, elem, cycle;
@@ -520,7 +521,7 @@ static int check_scalar(struct r600_bytecode *bc, struct 
r600_bytecode_alu *alu,
return 0;
 }
 
-static int check_and_set_bank_swizzle(struct r600_bytecode *bc,
+static int check_and_set_bank_swizzle(const struct r600_bytecode *bc,
  struct r600_bytecode_alu *slots[5])
 {
struct alu_bank_swizzle bs;

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


Mesa (master): r600g: remove unused "bc" args, and one unneeded forward declaration

2017-07-25 Thread Nicolai Hähnle
Module: Mesa
Branch: master
Commit: 3823e4905b60afadc119779dc0ca7f5ecfb9
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=3823e4905b60afadc119779dc0ca7f5ecfb9

Author: Constantine Charlamov 
Date:   Mon Jul 17 04:04:50 2017 +0300

r600g: remove unused "bc" args, and one unneeded forward declaration

To ease review just highlight "bc," string.

Signed-off-by: Constantine Kharlamov 
Reviewed-by: Nicolai Hähnle 

---

 src/gallium/drivers/r600/r600_asm.c | 85 +
 1 file changed, 40 insertions(+), 45 deletions(-)

diff --git a/src/gallium/drivers/r600/r600_asm.c 
b/src/gallium/drivers/r600/r600_asm.c
index 9e00528c5c..f333e7769a 100644
--- a/src/gallium/drivers/r600/r600_asm.c
+++ b/src/gallium/drivers/r600/r600_asm.c
@@ -43,15 +43,11 @@ static inline bool alu_writes(struct r600_bytecode_alu *alu)
return alu->dst.write || alu->is_op3;
 }
 
-static inline unsigned int r600_bytecode_get_num_operands(
-   struct r600_bytecode *bc, struct r600_bytecode_alu *alu)
+static inline unsigned int r600_bytecode_get_num_operands(struct 
r600_bytecode_alu *alu)
 {
return r600_isa_alu(alu->op)->src_count;
 }
 
-int r700_bytecode_alu_build(struct r600_bytecode *bc,
-   struct r600_bytecode_alu *alu, unsigned id);
-
 static struct r600_bytecode_cf *r600_bytecode_cf(void)
 {
struct r600_bytecode_cf *cf = CALLOC_STRUCT(r600_bytecode_cf);
@@ -236,7 +232,7 @@ int r600_bytecode_add_output(struct r600_bytecode *bc,
 }
 
 /* alu instructions that can ony exits once per group */
-static int is_alu_once_inst(struct r600_bytecode *bc, struct r600_bytecode_alu 
*alu)
+static int is_alu_once_inst(struct r600_bytecode_alu *alu)
 {
return r600_isa_alu(alu->op)->flags & (AF_KILL | AF_PRED) || 
alu->is_lds_idx_op || alu->op == ALU_OP0_GROUP_BARRIER;
 }
@@ -247,14 +243,14 @@ static int is_alu_reduction_inst(struct r600_bytecode 
*bc, struct r600_bytecode_
(r600_isa_alu_slots(bc->isa->hw_class, alu->op) == 
AF_4V);
 }
 
-static int is_alu_mova_inst(struct r600_bytecode *bc, struct r600_bytecode_alu 
*alu)
+static int is_alu_mova_inst(struct r600_bytecode_alu *alu)
 {
return r600_isa_alu(alu->op)->flags & AF_MOVA;
 }
 
-static int alu_uses_rel(struct r600_bytecode *bc, struct r600_bytecode_alu 
*alu)
+static int alu_uses_rel(struct r600_bytecode_alu *alu)
 {
-   unsigned num_src = r600_bytecode_get_num_operands(bc, alu);
+   unsigned num_src = r600_bytecode_get_num_operands(alu);
unsigned src;
 
if (alu->dst.rel) {
@@ -274,9 +270,9 @@ static int is_lds_read(int sel)
   return sel == EG_V_SQ_ALU_SRC_LDS_OQ_A_POP || sel == 
EG_V_SQ_ALU_SRC_LDS_OQ_B_POP;
 }
 
-static int alu_uses_lds(struct r600_bytecode *bc, struct r600_bytecode_alu 
*alu)
+static int alu_uses_lds(struct r600_bytecode_alu *alu)
 {
-   unsigned num_src = r600_bytecode_get_num_operands(bc, alu);
+   unsigned num_src = r600_bytecode_get_num_operands(alu);
unsigned src;
 
for (src = 0; src < num_src; ++src) {
@@ -287,7 +283,7 @@ static int alu_uses_lds(struct r600_bytecode *bc, struct 
r600_bytecode_alu *alu)
return 0;
 }
 
-static int is_alu_64bit_inst(struct r600_bytecode *bc, struct 
r600_bytecode_alu *alu)
+static int is_alu_64bit_inst(struct r600_bytecode_alu *alu)
 {
const struct alu_op_info *op = r600_isa_alu(alu->op);
return (op->flags & AF_64);
@@ -312,7 +308,7 @@ static int is_alu_any_unit_inst(struct r600_bytecode *bc, 
struct r600_bytecode_a
return slots == AF_VS;
 }
 
-static int is_nop_inst(struct r600_bytecode *bc, struct r600_bytecode_alu *alu)
+static int is_nop_inst(struct r600_bytecode_alu *alu)
 {
return alu->op == ALU_OP0_NOP;
 }
@@ -453,7 +449,7 @@ static int check_vector(struct r600_bytecode *bc, struct 
r600_bytecode_alu *alu,
 {
int r, src, num_src, sel, elem, cycle;
 
-   num_src = r600_bytecode_get_num_operands(bc, alu);
+   num_src = r600_bytecode_get_num_operands(alu);
for (src = 0; src < num_src; src++) {
sel = alu->src[src].sel;
elem = alu->src[src].chan;
@@ -483,7 +479,7 @@ static int check_scalar(struct r600_bytecode *bc, struct 
r600_bytecode_alu *alu,
 {
int r, src, num_src, const_count, sel, elem, cycle;
 
-   num_src = r600_bytecode_get_num_operands(bc, alu);
+   num_src = r600_bytecode_get_num_operands(alu);
for (const_count = 0, src = 0; src < num_src; ++src) {
sel = alu->src[src].sel;
elem = alu->src[src].chan;
@@ -618,7 +614,7 @@ static int replace_gpr_with_pv_ps(struct r600_bytecode *bc,
for (i = 0; i < max_slots; ++i) {
if (prev[i] && alu_writes(prev[i]) && !prev[i]->dst.rel) {
 
-   if (is_alu_64bit_inst(bc, prev[i])) {
+   if (is_alu_64bit_inst(prev[i])) {
gpr[i] = -1;
continue;