[Mesa-dev] [RFC PATCH 61/65] radeonsi: upload new descriptors when resident buffers are invalidated

2017-05-19 Thread Samuel Pitoiset
When texture buffers are invalidated the addr in the resident
descriptor has to be updated but we can't create a new descriptor
because the resident handle has to be the same.

Instead, use the WRITE_DATA packet which allows to update memory
directly but graphics/compute have to be idle in case the GPU is
reading the descriptor.

Signed-off-by: Samuel Pitoiset 
---
 src/gallium/drivers/radeon/r600_pipe_common.h |   4 +
 src/gallium/drivers/radeonsi/si_descriptors.c | 121 ++
 src/gallium/drivers/radeonsi/si_pipe.h|   3 +
 3 files changed, 128 insertions(+)

diff --git a/src/gallium/drivers/radeon/r600_pipe_common.h 
b/src/gallium/drivers/radeon/r600_pipe_common.h
index b17b690fab..6c4df2e733 100644
--- a/src/gallium/drivers/radeon/r600_pipe_common.h
+++ b/src/gallium/drivers/radeon/r600_pipe_common.h
@@ -181,6 +181,10 @@ struct r600_resource {
 
/* Whether the resource has been exported via resource_get_handle. */
unsignedexternal_usage; /* PIPE_HANDLE_USAGE_* 
*/
+
+   /* Whether this resource is referenced by bindless handles. */
+   booltexture_handle_allocated;
+   boolimage_handle_allocated;
 };
 
 struct r600_transfer {
diff --git a/src/gallium/drivers/radeonsi/si_descriptors.c 
b/src/gallium/drivers/radeonsi/si_descriptors.c
index 05559d90d7..6adad06757 100644
--- a/src/gallium/drivers/radeonsi/si_descriptors.c
+++ b/src/gallium/drivers/radeonsi/si_descriptors.c
@@ -1849,6 +1849,55 @@ static void si_rebind_buffer(struct pipe_context *ctx, 
struct pipe_resource *buf
}
}
}
+
+   /* Bindless texture handles */
+   if (rbuffer->texture_handle_allocated) {
+   for (i = 0; i < sctx->num_resident_tex_handles; i++) {
+   struct si_texture_handle *tex_handle =
+   sctx->resident_tex_handles[i];
+   struct si_sampler_view *sview = tex_handle->view;
+   struct si_resident_descriptor *desc = tex_handle->desc;
+
+   if (sview->base.texture == buf) {
+   si_set_buf_desc_address(rbuffer,
+   
sview->base.u.buf.offset,
+   >desc_list[4]);
+   desc->dirty = true;
+   sctx->resident_descriptors_dirty = true;
+
+   radeon_add_to_buffer_list_check_mem(
+   >b, >b.gfx, rbuffer,
+   RADEON_USAGE_READ,
+   RADEON_PRIO_SAMPLER_BUFFER, true);
+   }
+   }
+   }
+
+   /* Bindless image handles */
+   if (rbuffer->image_handle_allocated) {
+   for (i = 0; i < sctx->num_resident_img_handles; i++) {
+   struct si_image_handle *img_handle =
+   sctx->resident_img_handles[i];
+   struct pipe_image_view *view = _handle->view;
+   struct si_resident_descriptor *desc = img_handle->desc;
+
+   if (view->resource == buf) {
+   if (view->access & PIPE_IMAGE_ACCESS_WRITE)
+   si_mark_image_range_valid(view);
+
+   si_set_buf_desc_address(rbuffer,
+   view->u.buf.offset,
+   >desc_list[4]);
+   desc->dirty = true;
+   sctx->resident_descriptors_dirty = true;
+
+   radeon_add_to_buffer_list_check_mem(
+   >b, >b.gfx, rbuffer,
+   RADEON_USAGE_READWRITE,
+   RADEON_PRIO_SAMPLER_BUFFER, true);
+   }
+   }
+   }
 }
 
 /* Reallocate a buffer a update all resource bindings where the buffer is
@@ -2365,6 +2414,8 @@ si_create_resident_descriptor(struct si_context *sctx, 
uint32_t *desc_list,
util_memcpy_cpu_to_le32(ptr + desc->offset, desc_list, size);
sscreen->b.ws->buffer_unmap(desc->buffer->buf);
 
+   memcpy(desc->desc_list, desc_list, sizeof(desc->desc_list));
+
return desc;
 }
 
@@ -2415,6 +2466,8 @@ static uint64_t si_create_texture_handle(struct 
pipe_context *ctx,
return 0;
}
 
+   r600_resource(sview->base.texture)->texture_handle_allocated = true;
+
return handle;
 }
 
@@ -2521,6 +2574,8 @@ static uint64_t si_create_image_handle(struct 
pipe_context *ctx,
return 0;
}
 
+   

[Mesa-dev] [RFC PATCH 39/65] st/mesa: make update_single_texture() non-static

2017-05-19 Thread Samuel Pitoiset
Signed-off-by: Samuel Pitoiset 
---
 src/mesa/state_tracker/st_atom_texture.c | 15 +--
 src/mesa/state_tracker/st_texture.h  |  5 +
 2 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/src/mesa/state_tracker/st_atom_texture.c 
b/src/mesa/state_tracker/st_atom_texture.c
index a99bc1a188..f9d726a609 100644
--- a/src/mesa/state_tracker/st_atom_texture.c
+++ b/src/mesa/state_tracker/st_atom_texture.c
@@ -52,10 +52,13 @@
 #include "cso_cache/cso_context.h"
 
 
-static GLboolean
-update_single_texture(struct st_context *st,
-  struct pipe_sampler_view **sampler_view,
- GLuint texUnit, unsigned glsl_version)
+/**
+ * Get a pipe_sampler_view object from a texture unit.
+ */
+GLboolean
+st_update_single_texture(struct st_context *st,
+ struct pipe_sampler_view **sampler_view,
+ GLuint texUnit, unsigned glsl_version)
 {
struct gl_context *ctx = st->ctx;
const struct gl_sampler_object *samp;
@@ -129,8 +132,8 @@ update_textures(struct st_context *st,
  const GLuint texUnit = prog->SamplerUnits[unit];
  GLboolean retval;
 
- retval = update_single_texture(st, _view, texUnit,
-glsl_version);
+ retval = st_update_single_texture(st, _view, texUnit,
+   glsl_version);
  if (retval == GL_FALSE)
 continue;
 
diff --git a/src/mesa/state_tracker/st_texture.h 
b/src/mesa/state_tracker/st_texture.h
index 1b4d1a3ea2..8eb0b4be47 100644
--- a/src/mesa/state_tracker/st_texture.h
+++ b/src/mesa/state_tracker/st_texture.h
@@ -264,4 +264,9 @@ st_convert_sampler(const struct st_context *st,
const struct gl_sampler_object *msamp,
struct pipe_sampler_state *sampler);
 
+GLboolean
+st_update_single_texture(struct st_context *st,
+ struct pipe_sampler_view **sampler_view,
+ GLuint texUnit, unsigned glsl_version);
+
 #endif
-- 
2.13.0

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


[Mesa-dev] [RFC PATCH 37/65] tgsi/scan: record bindless samplers/images usage

2017-05-19 Thread Samuel Pitoiset
Signed-off-by: Samuel Pitoiset 
---
 src/gallium/auxiliary/tgsi/tgsi_scan.c | 37 ++
 src/gallium/auxiliary/tgsi/tgsi_scan.h |  2 ++
 2 files changed, 39 insertions(+)

diff --git a/src/gallium/auxiliary/tgsi/tgsi_scan.c 
b/src/gallium/auxiliary/tgsi/tgsi_scan.c
index d1ef769ec4..d9c8db7c78 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_scan.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_scan.c
@@ -367,6 +367,43 @@ scan_instruction(struct tgsi_shader_info *info,
case TGSI_OPCODE_ENDLOOP:
   (*current_depth)--;
   break;
+   case TGSI_OPCODE_TEX:
+   case TGSI_OPCODE_TEX_LZ:
+   case TGSI_OPCODE_TXB:
+   case TGSI_OPCODE_TXD:
+   case TGSI_OPCODE_TXL:
+   case TGSI_OPCODE_TXP:
+   case TGSI_OPCODE_TXQ:
+   case TGSI_OPCODE_TXQS:
+   case TGSI_OPCODE_TXF:
+   case TGSI_OPCODE_TXF_LZ:
+   case TGSI_OPCODE_TEX2:
+   case TGSI_OPCODE_TXB2:
+   case TGSI_OPCODE_TXL2:
+   case TGSI_OPCODE_TG4:
+   case TGSI_OPCODE_LODQ:
+  if (fullinst->Texture.Bindless)
+ info->uses_bindless_samplers = true;
+  break;
+   case TGSI_OPCODE_RESQ:
+   case TGSI_OPCODE_LOAD:
+   case TGSI_OPCODE_ATOMUADD:
+   case TGSI_OPCODE_ATOMXCHG:
+   case TGSI_OPCODE_ATOMCAS:
+   case TGSI_OPCODE_ATOMAND:
+   case TGSI_OPCODE_ATOMOR:
+   case TGSI_OPCODE_ATOMXOR:
+   case TGSI_OPCODE_ATOMUMIN:
+   case TGSI_OPCODE_ATOMUMAX:
+   case TGSI_OPCODE_ATOMIMIN:
+   case TGSI_OPCODE_ATOMIMAX:
+  if (fullinst->Memory.Bindless)
+ info->uses_bindless_images = true;
+  break;
+   case TGSI_OPCODE_STORE:
+  if (fullinst->Memory.Bindless)
+ info->uses_bindless_images = true;
+  break;
default:
   break;
}
diff --git a/src/gallium/auxiliary/tgsi/tgsi_scan.h 
b/src/gallium/auxiliary/tgsi/tgsi_scan.h
index 98387c982c..473a0b6568 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_scan.h
+++ b/src/gallium/auxiliary/tgsi/tgsi_scan.h
@@ -135,6 +135,8 @@ struct tgsi_shader_info
boolean is_msaa_sampler[PIPE_MAX_SAMPLERS];
boolean uses_doubles; /**< uses any of the double instructions */
boolean uses_derivatives;
+   boolean uses_bindless_samplers;
+   boolean uses_bindless_images;
unsigned clipdist_writemask;
unsigned culldist_writemask;
unsigned num_written_culldistance;
-- 
2.13.0

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


[Mesa-dev] [RFC PATCH 18/65] mesa: add update_single_program_texture_state() helper

2017-05-19 Thread Samuel Pitoiset
This will also be used for looping over bindless samplers bound
to texture units.

Signed-off-by: Samuel Pitoiset 
---
 src/mesa/main/texstate.c | 36 +++-
 1 file changed, 23 insertions(+), 13 deletions(-)

diff --git a/src/mesa/main/texstate.c b/src/mesa/main/texstate.c
index 1aac3cdbd8..4fd853f386 100644
--- a/src/mesa/main/texstate.c
+++ b/src/mesa/main/texstate.c
@@ -612,15 +612,13 @@ update_texgen(struct gl_context *ctx)
 
 static struct gl_texture_object *
 update_single_program_texture(struct gl_context *ctx, struct gl_program *prog,
-  int s)
+  int unit)
 {
gl_texture_index target_index;
struct gl_texture_unit *texUnit;
struct gl_texture_object *texObj;
struct gl_sampler_object *sampler;
-   int unit;
 
-   unit = prog->SamplerUnits[s];
texUnit = >Texture.Unit[unit];
 
/* Note: If more than one bit was set in TexturesUsed[unit], then we should
@@ -666,6 +664,24 @@ update_single_program_texture(struct gl_context *ctx, 
struct gl_program *prog,
return texObj;
 }
 
+static inline void
+update_single_program_texture_state(struct gl_context *ctx,
+struct gl_program *prog,
+int unit,
+BITSET_WORD *enabled_texture_units)
+{
+   struct gl_texture_object *texObj;
+
+   texObj = update_single_program_texture(ctx, prog, unit);
+   if (!texObj)
+  return;
+
+   _mesa_reference_texobj(>Texture.Unit[unit]._Current, texObj);
+   BITSET_SET(enabled_texture_units, unit);
+   ctx->Texture._MaxEnabledTexImageUnit =
+  MAX2(ctx->Texture._MaxEnabledTexImageUnit, (int)unit);
+}
+
 static void
 update_program_texture_state(struct gl_context *ctx, struct gl_program **prog,
  BITSET_WORD *enabled_texture_units)
@@ -682,16 +698,10 @@ update_program_texture_state(struct gl_context *ctx, 
struct gl_program **prog,
 
   while (mask) {
  const int s = u_bit_scan();
- struct gl_texture_object *texObj;
-
- texObj = update_single_program_texture(ctx, prog[i], s);
- if (texObj) {
-int unit = prog[i]->SamplerUnits[s];
-_mesa_reference_texobj(>Texture.Unit[unit]._Current, texObj);
-BITSET_SET(enabled_texture_units, unit);
-ctx->Texture._MaxEnabledTexImageUnit =
-   MAX2(ctx->Texture._MaxEnabledTexImageUnit, (int)unit);
- }
+
+ update_single_program_texture_state(ctx, prog[i],
+ prog[i]->SamplerUnits[s],
+ enabled_texture_units);
   }
}
 
-- 
2.13.0

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


[Mesa-dev] [RFC PATCH 44/65] st/mesa: make bindless samplers/images bound to units resident

2017-05-19 Thread Samuel Pitoiset
Signed-off-by: Samuel Pitoiset 
---
 src/mesa/state_tracker/st_atom_constbuf.c |  6 ++
 src/mesa/state_tracker/st_texture.c   | 94 +++
 src/mesa/state_tracker/st_texture.h   |  8 +++
 3 files changed, 108 insertions(+)

diff --git a/src/mesa/state_tracker/st_atom_constbuf.c 
b/src/mesa/state_tracker/st_atom_constbuf.c
index 0c66994066..e4b585101d 100644
--- a/src/mesa/state_tracker/st_atom_constbuf.c
+++ b/src/mesa/state_tracker/st_atom_constbuf.c
@@ -80,6 +80,12 @@ void st_upload_constants(struct st_context *st, struct 
gl_program *prog)
   }
}
 
+   /* Make all bindless samplers/images bound texture/image units resident in
+* the context.
+*/
+   st_make_bound_samplers_resident(st, prog);
+   st_make_bound_images_resident(st, prog);
+
/* update constants */
if (params && params->NumParameters) {
   struct pipe_constant_buffer cb;
diff --git a/src/mesa/state_tracker/st_texture.c 
b/src/mesa/state_tracker/st_texture.c
index cde7759a61..74704b5c87 100644
--- a/src/mesa/state_tracker/st_texture.c
+++ b/src/mesa/state_tracker/st_texture.c
@@ -539,3 +539,97 @@ st_create_image_handle_from_unit(struct st_context *st,
 
return pipe->create_image_handle(pipe, );
 }
+
+
+/**
+ * Make all bindless samplers bound to texture units resident in the context.
+ */
+void
+st_make_bound_samplers_resident(struct st_context *st,
+struct gl_program *prog)
+{
+   enum pipe_shader_type shader = st_shader_stage_to_ptarget(prog->info.stage);
+   struct st_bound_handle *bound_handles = >bound_texture_handles[shader];
+   struct pipe_context *pipe = st->pipe;
+   GLuint64 handle;
+   int i;
+
+   /* Remove previous bound texture handles for this stage. */
+   st_destroy_bound_texture_handles_per_stage(st, shader);
+
+   if (likely(!prog->sh.HasBoundBindlessSampler))
+  return;
+
+   for (i = 0; i < prog->sh.NumBindlessSamplers; i++) {
+  struct gl_bindless_sampler *sampler = >sh.BindlessSamplers[i];
+
+  if (!sampler->bound)
+ continue;
+
+  /* Request a new texture handle from the driver and make it resident. */
+  handle = st_create_texture_handle_from_unit(st, prog, sampler->unit);
+  if (!handle)
+ continue;
+
+  pipe->make_texture_handle_resident(st->pipe, handle, true);
+
+  /* Overwrite the texture unit value by the resident handle before
+   * uploading the constant buffer.
+   */
+  *(uint64_t *)sampler->data = handle;
+
+  /* Store the handle in the context. */
+  bound_handles->handles = (uint64_t *)
+ realloc(bound_handles->handles,
+ (bound_handles->num_handles + 1) * sizeof(uint64_t));
+  bound_handles->handles[bound_handles->num_handles] = handle;
+  bound_handles->num_handles++;
+   }
+}
+
+
+/**
+ * Make all bindless images bound to image units resident in the context.
+ */
+void
+st_make_bound_images_resident(struct st_context *st,
+  struct gl_program *prog)
+{
+   enum pipe_shader_type shader = st_shader_stage_to_ptarget(prog->info.stage);
+   struct st_bound_handle *bound_handles = >bound_image_handles[shader];
+   struct pipe_context *pipe = st->pipe;
+   GLuint64 handle;
+   int i;
+
+   /* Remove previous bound image handles for this stage. */
+   st_destroy_bound_image_handles_per_stage(st, shader);
+
+   if (likely(!prog->sh.HasBoundBindlessImage))
+  return;
+
+   for (i = 0; i < prog->sh.NumBindlessImages; i++) {
+  struct gl_bindless_image *image = >sh.BindlessImages[i];
+
+  if (!image->bound)
+ continue;
+
+  /* Request a new image handle from the driver and make it resident. */
+  handle = st_create_image_handle_from_unit(st, prog, image->unit);
+  if (!handle)
+ continue;
+
+  pipe->make_image_handle_resident(st->pipe, handle, GL_READ_WRITE, true);
+
+  /* Overwrite the image unit value by the resident handle before uploading
+   * the constant buffer.
+   */
+  *(uint64_t *)image->data = handle;
+
+  /* Store the handle in the context. */
+  bound_handles->handles = (uint64_t *)
+ realloc(bound_handles->handles,
+ (bound_handles->num_handles + 1) * sizeof(uint64_t));
+  bound_handles->handles[bound_handles->num_handles] = handle;
+  bound_handles->num_handles++;
+   }
+}
diff --git a/src/mesa/state_tracker/st_texture.h 
b/src/mesa/state_tracker/st_texture.h
index b97814cb16..c9b778bcb6 100644
--- a/src/mesa/state_tracker/st_texture.h
+++ b/src/mesa/state_tracker/st_texture.h
@@ -284,4 +284,12 @@ st_update_single_texture(struct st_context *st,
  struct pipe_sampler_view **sampler_view,
  GLuint texUnit, unsigned glsl_version);
 
+void
+st_make_bound_samplers_resident(struct st_context *st,
+struct gl_program *prog);
+
+void
+st_make_bound_images_resident(struct st_context 

[Mesa-dev] [RFC PATCH 57/65] radeonsi: decompress resident textures/images before graphics/compute

2017-05-19 Thread Samuel Pitoiset
Similar to the existing decompression code path except that it
loops over the list of resident textures/images.

Signed-off-by: Samuel Pitoiset 
---
 src/gallium/drivers/radeonsi/si_blit.c| 67 +--
 src/gallium/drivers/radeonsi/si_descriptors.c | 44 ++
 src/gallium/drivers/radeonsi/si_pipe.h|  3 ++
 3 files changed, 111 insertions(+), 3 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_blit.c 
b/src/gallium/drivers/radeonsi/si_blit.c
index 4078f2498b..32041695e2 100644
--- a/src/gallium/drivers/radeonsi/si_blit.c
+++ b/src/gallium/drivers/radeonsi/si_blit.c
@@ -22,6 +22,7 @@
  */
 
 #include "si_pipe.h"
+#include "si_compute.h"
 #include "util/u_format.h"
 #include "util/u_surface.h"
 
@@ -680,9 +681,6 @@ static void si_decompress_textures(struct si_context *sctx, 
unsigned shader_mask
 {
unsigned compressed_colortex_counter, mask;
 
-   if (sctx->blitter->running)
-   return;
-
/* Update the compressed_colortex_mask if necessary. */
compressed_colortex_counter = 
p_atomic_read(>screen->b.compressed_colortex_counter);
if (compressed_colortex_counter != 
sctx->b.last_compressed_colortex_counter) {
@@ -709,14 +707,77 @@ static void si_decompress_textures(struct si_context 
*sctx, unsigned shader_mask
si_check_render_feedback(sctx);
 }
 
+static void si_decompress_resident_textures(struct si_context *sctx)
+{
+   unsigned i;
+
+   for (i = 0; i < sctx->num_resident_tex_handles; i++) {
+   struct si_texture_handle *tex_handle =
+   sctx->resident_tex_handles[i];
+   struct si_sampler_view *sview = tex_handle->view;
+   struct pipe_sampler_view *view = >base;
+   struct r600_texture *tex;
+
+   assert(view);
+   tex = (struct r600_texture *)view->texture;
+
+   if (view->texture->target == PIPE_BUFFER)
+   continue;
+
+   if (tex_handle->compressed_colortex)
+   si_decompress_color_texture(sctx, tex, 
view->u.tex.first_level,
+   view->u.tex.last_level);
+
+   if (tex_handle->depth_texture)
+   si_flush_depth_texture(sctx, tex,
+   sview->is_stencil_sampler ? PIPE_MASK_S : 
PIPE_MASK_Z,
+   view->u.tex.first_level, view->u.tex.last_level,
+   0, util_max_layer(>resource.b.b, 
view->u.tex.first_level));
+   }
+}
+
+static void si_decompress_resident_images(struct si_context *sctx)
+{
+   unsigned i;
+
+   for (i = 0; i < sctx->num_resident_img_handles; i++) {
+   struct si_image_handle *img_handle =
+   sctx->resident_img_handles[i];
+   struct pipe_image_view *view = _handle->view;
+   struct r600_texture *tex;
+
+   assert(view);
+   tex = (struct r600_texture *)view->resource;
+
+   if (view->resource->target == PIPE_BUFFER)
+   continue;
+
+   if (img_handle->compressed_colortex)
+   si_decompress_color_texture(sctx, tex, 
view->u.tex.level,
+   view->u.tex.level);
+   }
+}
+
 void si_decompress_graphics_textures(struct si_context *sctx)
 {
+   if (sctx->blitter->running)
+   return;
+
si_decompress_textures(sctx, u_bit_consecutive(0, 
SI_NUM_GRAPHICS_SHADERS));
+
+   si_decompress_resident_textures(sctx);
+   si_decompress_resident_images(sctx);
 }
 
 void si_decompress_compute_textures(struct si_context *sctx)
 {
+   if (sctx->blitter->running)
+   return;
+
si_decompress_textures(sctx, 1 << PIPE_SHADER_COMPUTE);
+
+   si_decompress_resident_textures(sctx);
+   si_decompress_resident_images(sctx);
 }
 
 static void si_clear(struct pipe_context *ctx, unsigned buffers,
diff --git a/src/gallium/drivers/radeonsi/si_descriptors.c 
b/src/gallium/drivers/radeonsi/si_descriptors.c
index e459f19d66..05559d90d7 100644
--- a/src/gallium/drivers/radeonsi/si_descriptors.c
+++ b/src/gallium/drivers/radeonsi/si_descriptors.c
@@ -1624,6 +1624,40 @@ static void si_set_polygon_stipple(struct pipe_context 
*ctx,
 
 /* TEXTURE METADATA ENABLE/DISABLE */
 
+static void
+si_resident_handles_update_compressed_colortex(struct si_context *sctx)
+{
+   unsigned i;
+
+   for (i = 0; i < sctx->num_resident_tex_handles; i++) {
+   struct si_texture_handle *tex_handle =
+   sctx->resident_tex_handles[i];
+   struct si_sampler_view *sview = tex_handle->view;
+   struct pipe_resource *res = sview->base.texture;
+
+   if (res && res->target != PIPE_BUFFER) {
+   struct r600_texture *rtex = (struct r600_texture 

[Mesa-dev] [RFC PATCH 36/65] st/glsl_to_tgsi: teach rename_temp_registers() about bindless samplers

2017-05-19 Thread Samuel Pitoiset
Signed-off-by: Samuel Pitoiset 
---
 src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp 
b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index ee1afdcd08..c69eefe013 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -4797,6 +4797,12 @@ glsl_to_tgsi_visitor::rename_temp_registers(int 
num_renames, struct rename_reg_p
   inst->tex_offsets[j].index = renames[k].new_reg;
   }
 
+  if (inst->resource.file == PROGRAM_TEMPORARY) {
+ for (k = 0; k < num_renames; k++)
+if (inst->resource.index == renames[k].old_reg)
+   inst->resource.index = renames[k].new_reg;
+  }
+
   for (j = 0; j < num_inst_dst_regs(inst); j++) {
  if (inst->dst[j].file == PROGRAM_TEMPORARY)
  for (k = 0; k < num_renames; k++)
-- 
2.13.0

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


[Mesa-dev] [RFC PATCH 53/65] radeonsi: add all resident buffers to the current CS

2017-05-19 Thread Samuel Pitoiset
Resident buffers have to be added to every new command stream.
Though, this could be slightly improved when current shaders
don't use any bindless textures/images but usually applications
tend to use bindless for almost every draw call, and the winsys
thread might help when buffers are added early.

Signed-off-by: Samuel Pitoiset 
---
 src/gallium/drivers/radeonsi/si_descriptors.c | 36 +++
 src/gallium/drivers/radeonsi/si_hw_context.c  |  1 +
 src/gallium/drivers/radeonsi/si_state.h   |  1 +
 3 files changed, 38 insertions(+)

diff --git a/src/gallium/drivers/radeonsi/si_descriptors.c 
b/src/gallium/drivers/radeonsi/si_descriptors.c
index a687506f7f..12f7ead619 100644
--- a/src/gallium/drivers/radeonsi/si_descriptors.c
+++ b/src/gallium/drivers/radeonsi/si_descriptors.c
@@ -2527,6 +2527,42 @@ static void si_make_image_handle_resident(struct 
pipe_context *ctx,
 }
 
 
+void si_all_resident_buffers_begin_new_cs(struct si_context *sctx)
+{
+   unsigned i;
+
+   /* Add all resident descriptors. */
+   for (i = 0; i < sctx->num_resident_descriptors; i++) {
+   struct r600_resource *desc = sctx->resident_descriptors[i];
+
+   radeon_add_to_buffer_list(>b, >b.gfx, desc,
+ RADEON_USAGE_READ,
+ RADEON_PRIO_DESCRIPTORS);
+   }
+
+   /* Add all resident texture handles. */
+   for (i = 0; i < sctx->num_resident_tex_handles; i++) {
+   struct si_texture_handle *tex_handle =
+   sctx->resident_tex_handles[i];
+   struct si_sampler_view *sview = tex_handle->view;
+
+   si_sampler_view_add_buffer(sctx, sview->base.texture,
+  RADEON_USAGE_READ,
+  sview->is_stencil_sampler, false);
+   }
+
+   /* Add all resident image handles. */
+   for (i = 0; i < sctx->num_resident_img_handles; i++) {
+   struct si_image_handle *img_handle =
+   sctx->resident_img_handles[i];
+   struct pipe_image_view *view = _handle->view;
+
+   si_sampler_view_add_buffer(sctx, view->resource,
+  RADEON_USAGE_READWRITE,
+  false, false);
+   }
+}
+
 /* INIT/DEINIT/UPLOAD */
 
 /* GFX9 has only 4KB of CE, while previous chips had 32KB. In order
diff --git a/src/gallium/drivers/radeonsi/si_hw_context.c 
b/src/gallium/drivers/radeonsi/si_hw_context.c
index 92c09cb633..345825af00 100644
--- a/src/gallium/drivers/radeonsi/si_hw_context.c
+++ b/src/gallium/drivers/radeonsi/si_hw_context.c
@@ -235,6 +235,7 @@ void si_begin_new_cs(struct si_context *ctx)
si_mark_atom_dirty(ctx, >b.streamout.enable_atom);
si_mark_atom_dirty(ctx, >b.render_cond_atom);
si_all_descriptors_begin_new_cs(ctx);
+   si_all_resident_buffers_begin_new_cs(ctx);
 
ctx->b.scissors.dirty_mask = (1 << R600_MAX_VIEWPORTS) - 1;
ctx->b.viewports.dirty_mask = (1 << R600_MAX_VIEWPORTS) - 1;
diff --git a/src/gallium/drivers/radeonsi/si_state.h 
b/src/gallium/drivers/radeonsi/si_state.h
index 3e9016c84a..e46af570d4 100644
--- a/src/gallium/drivers/radeonsi/si_state.h
+++ b/src/gallium/drivers/radeonsi/si_state.h
@@ -323,6 +323,7 @@ bool si_upload_graphics_shader_descriptors(struct 
si_context *sctx);
 bool si_upload_compute_shader_descriptors(struct si_context *sctx);
 void si_release_all_descriptors(struct si_context *sctx);
 void si_all_descriptors_begin_new_cs(struct si_context *sctx);
+void si_all_resident_buffers_begin_new_cs(struct si_context *sctx);
 void si_upload_const_buffer(struct si_context *sctx, struct r600_resource 
**rbuffer,
const uint8_t *ptr, unsigned size, uint32_t 
*const_offset);
 void si_update_all_texture_descriptors(struct si_context *sctx);
-- 
2.13.0

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


[Mesa-dev] [RFC PATCH 62/65] radeonsi: invalidate buffers which are made resident if needed

2017-05-19 Thread Samuel Pitoiset
When a buffer becomes resident, check if it has been invalidated,
if so update the descriptor and the dirty flag.

Signed-off-by: Samuel Pitoiset 
---
 src/gallium/drivers/radeonsi/si_descriptors.c | 34 +++
 1 file changed, 34 insertions(+)

diff --git a/src/gallium/drivers/radeonsi/si_descriptors.c 
b/src/gallium/drivers/radeonsi/si_descriptors.c
index 6adad06757..0866c54c23 100644
--- a/src/gallium/drivers/radeonsi/si_descriptors.c
+++ b/src/gallium/drivers/radeonsi/si_descriptors.c
@@ -2419,6 +2419,32 @@ si_create_resident_descriptor(struct si_context *sctx, 
uint32_t *desc_list,
return desc;
 }
 
+static void si_invalidate_resident_buf_desc(struct si_context *sctx,
+   struct si_resident_descriptor *desc,
+   struct pipe_resource *resource,
+   uint64_t offset)
+{
+   struct r600_resource *buf = r600_resource(resource);
+   uint32_t *desc_list = desc->desc_list;
+   uint64_t old_desc_va;
+
+   assert(resource->target == PIPE_BUFFER);
+
+   /* Retrieve the old buffer addr from the descriptor. */
+   old_desc_va  = desc_list[0];
+   old_desc_va |= ((uint64_t)G_008F04_BASE_ADDRESS_HI(desc_list[1]) << 32);
+
+   if (old_desc_va != buf->gpu_address + offset) {
+   /* The buffer has been invalidated when the handle wasn't
+* resident, update the descriptor and the dirty flag.
+*/
+   si_set_buf_desc_address(buf, offset, _list[4]);
+
+   desc->dirty = true;
+   sctx->resident_descriptors_dirty = true;
+   }
+}
+
 static uint64_t si_create_texture_handle(struct pipe_context *ctx,
 struct pipe_resource *texture,
 struct pipe_sampler_view *view,
@@ -2515,6 +2541,10 @@ static void si_make_texture_handle_resident(struct 
pipe_context *ctx,
is_compressed_colortex(rtex);
 
si_update_check_render_feedback(sctx, rtex);
+   } else {
+   si_invalidate_resident_buf_desc(sctx, tex_handle->desc,
+   sview->base.texture,
+   
sview->base.u.buf.offset);
}
 
si_add_resident_tex_handle(sctx, tex_handle);
@@ -2624,6 +2654,10 @@ static void si_make_image_handle_resident(struct 
pipe_context *ctx,
is_compressed_colortex(rtex);
 
si_update_check_render_feedback(sctx, rtex);
+   } else {
+   si_invalidate_resident_buf_desc(sctx, img_handle->desc,
+   view->resource,
+   view->u.buf.offset);
}
 
si_add_resident_img_handle(sctx, img_handle);
-- 
2.13.0

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


[Mesa-dev] [RFC PATCH 48/65] radeonsi: add a slab allocator for resident descriptors

2017-05-19 Thread Samuel Pitoiset
For each texture/image handles, we need to allocate a new
buffer for the resident descriptor. But when the number of
buffers added to the current CS becomes high, the overhead
in the winsys (and in the kernel) is important.

To reduce this bottleneck, the idea is to suballocate the
resident descriptors using a slab similar to the one used
in the winsys.

Currently, a buffer can hold 1024 resident descriptors but
this limit is arbitrary and could be changed in the future
for some reasons. Once a slab is allocated the "base" buffer
is added to a per-context residency list.

Signed-off-by: Samuel Pitoiset 
---
 src/gallium/drivers/radeonsi/si_descriptors.c | 150 ++
 src/gallium/drivers/radeonsi/si_pipe.c|  10 ++
 src/gallium/drivers/radeonsi/si_pipe.h|  15 +++
 src/gallium/drivers/radeonsi/si_state.h   |   8 ++
 4 files changed, 183 insertions(+)

diff --git a/src/gallium/drivers/radeonsi/si_descriptors.c 
b/src/gallium/drivers/radeonsi/si_descriptors.c
index 61eb2f10be..d337fc3f11 100644
--- a/src/gallium/drivers/radeonsi/si_descriptors.c
+++ b/src/gallium/drivers/radeonsi/si_descriptors.c
@@ -2005,6 +2005,156 @@ void si_emit_compute_shader_userdata(struct si_context 
*sctx)
sctx->shader_pointers_dirty &= ~compute_mask;
 }
 
+/* BINDLESS */
+
+static int si_add_resident_descriptor(struct si_context *sctx,
+ struct r600_resource *desc)
+{
+   int idx;
+
+   /* New resident descriptor, check if the backing array is large enough. 
*/
+   if (sctx->num_resident_descriptors >= sctx->max_resident_descriptors) {
+   unsigned new_max_descriptors =
+   MAX2(1, sctx->max_resident_descriptors * 2);
+   struct r600_resource **new_descriptors =
+   REALLOC(sctx->resident_descriptors,
+   sctx->num_resident_descriptors * 
(sizeof(*new_descriptors)),
+   new_max_descriptors * sizeof(*new_descriptors));
+
+   if (new_descriptors) {
+   sctx->resident_descriptors = new_descriptors;
+   sctx->max_resident_descriptors = new_max_descriptors;
+   } else {
+   fprintf(stderr, "si_add_resident_descriptor: "
+   "allocation failed\n");
+   return -1;
+   }
+   }
+
+   idx = sctx->num_resident_descriptors;
+   sctx->resident_descriptors[idx] = desc;
+   sctx->num_resident_descriptors++;
+
+   return 0;
+}
+
+static void si_del_resident_descriptor(struct si_context *sctx,
+  struct r600_resource *desc)
+{
+   unsigned i;
+   int size;
+
+   for (i = 0; i < sctx->num_resident_descriptors; i++) {
+   if (sctx->resident_descriptors[i] != desc)
+   continue;
+
+   if (i < sctx->num_resident_descriptors - 1) {
+   size = sizeof(*sctx->resident_descriptors) *
+   (sctx->num_resident_descriptors - 1 - i);
+
+   memmove(>resident_descriptors[i],
+   >resident_descriptors[i + 1], size);
+   }
+
+   sctx->num_resident_descriptors--;
+   return;
+   }
+}
+
+struct si_resident_descriptor_slab
+{
+   struct pb_slab base;
+   struct r600_resource *buffer;
+   struct si_resident_descriptor *entries;
+};
+
+bool si_resident_descriptor_can_reclaim_slab(void *priv,
+struct pb_slab_entry *entry)
+{
+   struct si_context *sctx = priv;
+   struct radeon_winsys *ws = sctx->b.ws;
+   struct si_resident_descriptor *desc = NULL; /* fix container_of */
+
+   desc = container_of(entry, desc, entry);
+
+   if (ws->cs_is_buffer_referenced(sctx->b.gfx.cs, desc->buffer->buf,
+   RADEON_USAGE_READ)) {
+   /* Do not allow to reclaim the buffer if the resident
+* descriptor is currently used.
+*/
+   return false;
+   }
+
+   return true;
+}
+
+struct pb_slab *si_resident_descriptor_slab_alloc(void *priv, unsigned heap,
+ unsigned entry_size,
+ unsigned group_index)
+{
+   struct si_context *sctx = priv;
+   struct si_screen *sscreen = sctx->screen;
+   struct si_resident_descriptor_slab *slab;
+
+   slab = CALLOC_STRUCT(si_resident_descriptor_slab);
+   if (!slab)
+   return NULL;
+
+   /* Create a buffer in VRAM for 1024 resident descriptors. */
+   slab->buffer = (struct r600_resource *)
+   pipe_buffer_create(>b.b, 0,
+  PIPE_USAGE_IMMUTABLE, 64 * 1024);
+   if (!slab->buffer)
+ 

[Mesa-dev] [RFC PATCH 46/65] st/mesa: disable per-context seamless cubemap when using texture handles

2017-05-19 Thread Samuel Pitoiset
The ARB_bindless_texture spec say:

   "If ARB_seamless_cubemap (or OpenGL 4.0, which includes it) is
supported, the per-context seamless cubemap enable is ignored
and treated as disabled when using texture handles."

   "If AMD_seamless_cubemap_per_texture is supported, the seamless
cube map texture parameter of the underlying texture does apply
when texture handles are used."

Signed-off-by: Samuel Pitoiset 
---
 src/mesa/state_tracker/st_atom_sampler.c | 18 --
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/src/mesa/state_tracker/st_atom_sampler.c 
b/src/mesa/state_tracker/st_atom_sampler.c
index c6d992fbb0..116c5380cf 100644
--- a/src/mesa/state_tracker/st_atom_sampler.c
+++ b/src/mesa/state_tracker/st_atom_sampler.c
@@ -226,8 +226,22 @@ st_convert_sampler(const struct st_context *st,
   sampler->compare_func = st_compare_func_to_pipe(msamp->CompareFunc);
}
 
-   sampler->seamless_cube_map =
-  ctx->Texture.CubeMapSeamless || msamp->CubeMapSeamless;
+   if (msamp->HandleAllocated) {
+  /* The ARB_bindless_texture spec says:
+   *
+   * "If ARB_seamless_cubemap (or OpenGL 4.0, which includes it) is
+   *  supported, the per-context seamless cubemap enable is ignored and
+   *  treated as disabled when using texture handles."
+   *
+   * "If AMD_seamless_cubemap_per_texture is supported, the seamless cube
+   *  map texture parameter of the underlying texture does apply when
+   *  texture handles are used."
+   */
+  sampler->seamless_cube_map = msamp->CubeMapSeamless;
+   } else {
+  sampler->seamless_cube_map =
+ ctx->Texture.CubeMapSeamless || msamp->CubeMapSeamless;
+   }
 }
 
 /**
-- 
2.13.0

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


[Mesa-dev] [RFC PATCH 63/65] radeonsi: add support for loading bindless samplers

2017-05-19 Thread Samuel Pitoiset
Signed-off-by: Samuel Pitoiset 
---
 src/gallium/drivers/radeonsi/si_shader_tgsi_mem.c | 17 -
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/src/gallium/drivers/radeonsi/si_shader_tgsi_mem.c 
b/src/gallium/drivers/radeonsi/si_shader_tgsi_mem.c
index bd8ecb70f8..c9397c2fb8 100644
--- a/src/gallium/drivers/radeonsi/si_shader_tgsi_mem.c
+++ b/src/gallium/drivers/radeonsi/si_shader_tgsi_mem.c
@@ -1207,6 +1207,20 @@ static void tex_fetch_ptrs(
 si_get_sampler_slot(reg->Register.Index), 
0);
}
 
+   if (reg->Register.File != TGSI_FILE_SAMPLER) {
+   struct gallivm_state *gallivm = >gallivm;
+   LLVMBuilderRef builder = gallivm->builder;
+
+   assert(inst->Texture.Bindless);
+
+   LLVMValueRef ptr =
+   lp_build_emit_fetch_src(bld_base, reg,
+   TGSI_TYPE_UNSIGNED64, 0);
+   list = LLVMBuildIntToPtr(builder, ptr,
+si_const_array(ctx->v8i32, 0), "");
+   index = LLVMConstInt(ctx->i32, 0, 0);
+   }
+
if (target == TGSI_TEXTURE_BUFFER)
*res_ptr = load_sampler_desc(ctx, list, index, DESC_BUFFER);
else
@@ -1786,7 +1800,8 @@ static void build_tex_intrinsic(const struct 
lp_build_tgsi_action *action,
opcode == TGSI_OPCODE_TG4) {
const unsigned src_idx = 2;
 
-   assert(inst->Src[src_idx].Register.File == TGSI_FILE_SAMPLER);
+   assert(inst->Src[src_idx].Register.File == TGSI_FILE_SAMPLER ||
+  inst->Texture.Bindless);
assert(inst->Texture.ReturnType != TGSI_RETURN_TYPE_UNKNOWN);
 
if (inst->Texture.ReturnType == TGSI_RETURN_TYPE_SINT ||
-- 
2.13.0

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


[Mesa-dev] [RFC PATCH 45/65] st/mesa: do not release sampler views for resident textures

2017-05-19 Thread Samuel Pitoiset
When a texture is referenced by one or more texture handles,
it might be resident and we shouldn't release the sampler views.

Signed-off-by: Samuel Pitoiset 
---
 src/mesa/state_tracker/st_sampler_view.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/src/mesa/state_tracker/st_sampler_view.c 
b/src/mesa/state_tracker/st_sampler_view.c
index c78a987486..690b50087c 100644
--- a/src/mesa/state_tracker/st_sampler_view.c
+++ b/src/mesa/state_tracker/st_sampler_view.c
@@ -115,6 +115,12 @@ st_texture_release_all_sampler_views(struct st_context *st,
 {
GLuint i;
 
+   if (stObj->base.HandleAllocated) {
+  /* Do not release sampler views when a texture is referenced by one or
+   * more texture handles because the texture might be resident. */
+  return;
+   }
+
/* XXX This should use sampler_views[i]->pipe, not st->pipe */
for (i = 0; i < stObj->num_sampler_views; ++i)
   pipe_sampler_view_release(st->pipe, >sampler_views[i]);
-- 
2.13.0

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


[Mesa-dev] [RFC PATCH 51/65] radeonsi: add si_set_shader_image_desc() helper

2017-05-19 Thread Samuel Pitoiset
To share some common code between bound and bindless images.

Signed-off-by: Samuel Pitoiset 
---
 src/gallium/drivers/radeonsi/si_descriptors.c | 78 ---
 1 file changed, 46 insertions(+), 32 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_descriptors.c 
b/src/gallium/drivers/radeonsi/si_descriptors.c
index e73dbc9f9f..abe39de583 100644
--- a/src/gallium/drivers/radeonsi/si_descriptors.c
+++ b/src/gallium/drivers/radeonsi/si_descriptors.c
@@ -748,28 +748,16 @@ si_mark_image_range_valid(const struct pipe_image_view 
*view)
   view->u.buf.offset + view->u.buf.size);
 }
 
-static void si_set_shader_image(struct si_context *ctx,
-   unsigned shader,
-   unsigned slot, const struct pipe_image_view 
*view,
-   bool skip_decompress)
+static void si_set_shader_image_desc(struct si_context *ctx,
+const struct pipe_image_view *view,
+bool skip_decompress,
+uint32_t *desc)
 {
struct si_screen *screen = ctx->screen;
-   struct si_images_info *images = >images[shader];
-   struct si_descriptors *descs = si_sampler_and_image_descriptors(ctx, 
shader);
struct r600_resource *res;
-   unsigned desc_slot = si_get_image_slot(slot);
-   uint32_t *desc = descs->list + desc_slot * 8;
-
-   if (!view || !view->resource) {
-   si_disable_shader_image(ctx, shader, slot);
-   return;
-   }
 
res = (struct r600_resource *)view->resource;
 
-   if (>views[slot] != view)
-   util_copy_image_view(>views[slot], view);
-
if (res->b.b.target == PIPE_BUFFER) {
if (view->access & PIPE_IMAGE_ACCESS_WRITE)
si_mark_image_range_valid(view);
@@ -779,9 +767,6 @@ static void si_set_shader_image(struct si_context *ctx,
  view->u.buf.offset,
  view->u.buf.size, desc);
si_set_buf_desc_address(res, view->u.buf.offset, desc + 4);
-
-   images->compressed_colortex_mask &= ~(1 << slot);
-   res->bind_history |= PIPE_BIND_SHADER_IMAGE;
} else {
static const unsigned char swizzle[4] = { 0, 1, 2, 3 };
struct r600_texture *tex = (struct r600_texture *)res;
@@ -799,22 +784,10 @@ static void si_set_shader_image(struct si_context *ctx,
 * The decompression is relatively cheap if the surface
 * has been decompressed already.
 */
-   if (r600_texture_disable_dcc(>b, tex))
-   uses_dcc = false;
-   else
+   if (!r600_texture_disable_dcc(>b, tex))
ctx->b.decompress_dcc(>b.b, tex);
}
 
-   if (is_compressed_colortex(tex)) {
-   images->compressed_colortex_mask |= 1 << slot;
-   } else {
-   images->compressed_colortex_mask &= ~(1 << slot);
-   }
-
-   if (uses_dcc &&
-   p_atomic_read(>framebuffers_bound))
-   ctx->need_check_render_feedback = true;
-
if (ctx->b.chip_class >= GFX9) {
/* Always set the base address. The swizzle modes don't
 * allow setting mipmap level offsets as the base.
@@ -850,6 +823,47 @@ static void si_set_shader_image(struct si_context *ctx,
   
util_format_get_blockwidth(view->format),
   false, desc);
}
+}
+
+static void si_set_shader_image(struct si_context *ctx,
+   unsigned shader,
+   unsigned slot, const struct pipe_image_view 
*view,
+   bool skip_decompress)
+{
+   struct si_images_info *images = >images[shader];
+   struct si_descriptors *descs = si_sampler_and_image_descriptors(ctx, 
shader);
+   struct r600_resource *res;
+   unsigned desc_slot = si_get_image_slot(slot);
+   uint32_t *desc = descs->list + desc_slot * 8;
+
+   if (!view || !view->resource) {
+   si_disable_shader_image(ctx, shader, slot);
+   return;
+   }
+
+   res = (struct r600_resource *)view->resource;
+
+   if (>views[slot] != view)
+   util_copy_image_view(>views[slot], view);
+
+   si_set_shader_image_desc(ctx, view, skip_decompress, desc);
+
+   if (res->b.b.target == PIPE_BUFFER) {
+   images->compressed_colortex_mask &= ~(1 << slot);
+   res->bind_history |= PIPE_BIND_SHADER_IMAGE;
+   } else {
+   struct 

[Mesa-dev] [RFC PATCH 64/65] radeonsi: add support for loading bindless images

2017-05-19 Thread Samuel Pitoiset
Signed-off-by: Samuel Pitoiset 
---
 src/gallium/drivers/radeonsi/si_shader_tgsi_mem.c | 31 ++-
 1 file changed, 25 insertions(+), 6 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_shader_tgsi_mem.c 
b/src/gallium/drivers/radeonsi/si_shader_tgsi_mem.c
index c9397c2fb8..1447a552b9 100644
--- a/src/gallium/drivers/radeonsi/si_shader_tgsi_mem.c
+++ b/src/gallium/drivers/radeonsi/si_shader_tgsi_mem.c
@@ -184,7 +184,10 @@ image_fetch_rsrc(
LLVMValueRef index;
bool dcc_off = is_store;
 
-   assert(image->Register.File == TGSI_FILE_IMAGE);
+   assert(image->Register.File == TGSI_FILE_IMAGE ||
+  image->Register.File == TGSI_FILE_CONSTANT ||
+  image->Register.File == TGSI_FILE_TEMPORARY ||
+  image->Register.File == TGSI_FILE_INPUT);
 
if (!image->Register.Indirect) {
const struct tgsi_shader_info *info = bld_base->info;
@@ -214,6 +217,18 @@ image_fetch_rsrc(
 index, "");
}
 
+   if (image->Register.File != TGSI_FILE_IMAGE) {
+   struct gallivm_state *gallivm = >gallivm;
+   LLVMBuilderRef builder = gallivm->builder;
+
+   LLVMValueRef ptr =
+   lp_build_emit_fetch_src(bld_base, image,
+   TGSI_TYPE_UNSIGNED64, 0);
+   rsrc_ptr = LLVMBuildIntToPtr(builder, ptr,
+si_const_array(ctx->v8i32, 0), "");
+   index = LLVMConstInt(ctx->i32, 0, 0);
+   }
+
*rsrc = load_image_desc(ctx, rsrc_ptr, index, target);
if (dcc_off && target != TGSI_TEXTURE_BUFFER)
*rsrc = force_dcc_off(ctx, *rsrc);
@@ -373,7 +388,8 @@ static void load_fetch_args(
 
buffer_append_args(ctx, emit_data, rsrc, ctx->i32_0,
   offset, false, false);
-   } else if (inst->Src[0].Register.File == TGSI_FILE_IMAGE) {
+   } else if (inst->Src[0].Register.File == TGSI_FILE_IMAGE ||
+  inst->Memory.Bindless) {
LLVMValueRef coords;
 
image_fetch_rsrc(bld_base, >Src[0], false, target, );
@@ -538,8 +554,9 @@ static bool is_oneway_access_only(const struct 
tgsi_full_instruction *inst,
 * images.
 */
if (inst->Src[0].Register.File == TGSI_FILE_BUFFER ||
-   (inst->Src[0].Register.File == TGSI_FILE_IMAGE &&
-inst->Memory.Texture == TGSI_TEXTURE_BUFFER)) {
+   (inst->Memory.Texture == TGSI_TEXTURE_BUFFER &&
+(inst->Src[0].Register.File == TGSI_FILE_IMAGE ||
+ inst->Memory.Bindless))) {
if (!shader_buffers_reverse_access_mask &&
!(info->images_buffers & images_reverse_access_mask))
return true;
@@ -640,7 +657,8 @@ static void store_fetch_args(
 
buffer_append_args(ctx, emit_data, rsrc, ctx->i32_0,
   offset, false, false);
-   } else if (inst->Dst[0].Register.File == TGSI_FILE_IMAGE) {
+   } else if (inst->Dst[0].Register.File == TGSI_FILE_IMAGE ||
+  inst->Memory.Bindless) {
unsigned target = inst->Memory.Texture;
LLVMValueRef coords;
 
@@ -859,7 +877,8 @@ static void atomic_fetch_args(
 
buffer_append_args(ctx, emit_data, rsrc, ctx->i32_0,
   offset, true, false);
-   } else if (inst->Src[0].Register.File == TGSI_FILE_IMAGE) {
+   } else if (inst->Src[0].Register.File == TGSI_FILE_IMAGE ||
+  inst->Memory.Bindless) {
unsigned target = inst->Memory.Texture;
LLVMValueRef coords;
 
-- 
2.13.0

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


[Mesa-dev] [RFC PATCH 54/65] radeonsi: only add descriptors in presence of resident handles

2017-05-19 Thread Samuel Pitoiset
This won't help much except for applications that use a ton
of resident handles. Though, this will reduce the winsys
overhead a little bit.

Signed-off-by: Samuel Pitoiset 
---
 src/gallium/drivers/radeonsi/si_descriptors.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/src/gallium/drivers/radeonsi/si_descriptors.c 
b/src/gallium/drivers/radeonsi/si_descriptors.c
index 12f7ead619..44a4b16712 100644
--- a/src/gallium/drivers/radeonsi/si_descriptors.c
+++ b/src/gallium/drivers/radeonsi/si_descriptors.c
@@ -2531,6 +2531,11 @@ void si_all_resident_buffers_begin_new_cs(struct 
si_context *sctx)
 {
unsigned i;
 
+   /* Skip adding the resident descriptors when no handles are resident.
+*/
+   if (!sctx->num_resident_tex_handles && !sctx->num_resident_img_handles)
+   return;
+
/* Add all resident descriptors. */
for (i = 0; i < sctx->num_resident_descriptors; i++) {
struct r600_resource *desc = sctx->resident_descriptors[i];
-- 
2.13.0

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


[Mesa-dev] [RFC PATCH 59/65] radeonsi: track use of bindless samplers/images from tgsi_shader_info

2017-05-19 Thread Samuel Pitoiset
This adds some new helper functions to know if the current draw
call (or dispatch compute) is using bindless samplers/images,
based on TGSI analysis.

Signed-off-by: Samuel Pitoiset 
---
 src/gallium/drivers/radeonsi/si_compute.c |  2 ++
 src/gallium/drivers/radeonsi/si_compute.h | 14 ++
 src/gallium/drivers/radeonsi/si_pipe.h| 20 
 src/gallium/drivers/radeonsi/si_shader.h  | 12 
 4 files changed, 48 insertions(+)

diff --git a/src/gallium/drivers/radeonsi/si_compute.c 
b/src/gallium/drivers/radeonsi/si_compute.c
index 4c980668d3..61fab7ddb0 100644
--- a/src/gallium/drivers/radeonsi/si_compute.c
+++ b/src/gallium/drivers/radeonsi/si_compute.c
@@ -108,6 +108,8 @@ static void si_create_compute_state_async(void *job, int 
thread_index)
program->shader.is_monolithic = true;
program->uses_grid_size = sel.info.uses_grid_size;
program->uses_block_size = sel.info.uses_block_size;
+   program->uses_bindless_samplers = sel.info.uses_bindless_samplers;
+   program->uses_bindless_images = sel.info.uses_bindless_images;
 
if (si_shader_create(program->screen, tm, >shader, debug)) {
program->shader.compilation_failed = true;
diff --git a/src/gallium/drivers/radeonsi/si_compute.h 
b/src/gallium/drivers/radeonsi/si_compute.h
index 764d708c4f..3cf1538267 100644
--- a/src/gallium/drivers/radeonsi/si_compute.h
+++ b/src/gallium/drivers/radeonsi/si_compute.h
@@ -49,6 +49,20 @@ struct si_compute {
unsigned variable_group_size : 1;
unsigned uses_grid_size:1;
unsigned uses_block_size:1;
+   unsigned uses_bindless_samplers:1;
+   unsigned uses_bindless_images:1;
 };
 
+static inline bool
+si_compute_uses_bindless_samplers(struct si_context *sctx)
+{
+   return sctx->cs_shader_state.program->uses_bindless_samplers;
+}
+
+static inline bool
+si_compute_uses_bindless_images(struct si_context *sctx)
+{
+   return sctx->cs_shader_state.program->uses_bindless_images;
+}
+
 #endif /* SI_COMPUTE_H */
diff --git a/src/gallium/drivers/radeonsi/si_pipe.h 
b/src/gallium/drivers/radeonsi/si_pipe.h
index 8d8efbda1f..c52b364959 100644
--- a/src/gallium/drivers/radeonsi/si_pipe.h
+++ b/src/gallium/drivers/radeonsi/si_pipe.h
@@ -544,6 +544,26 @@ static inline struct tgsi_shader_info 
*si_get_vs_info(struct si_context *sctx)
return NULL;
 }
 
+static inline bool
+si_graphics_uses_bindless_samplers(struct si_context *sctx)
+{
+   return si_shader_uses_bindless_samplers(sctx->vs_shader.cso)  ||
+  si_shader_uses_bindless_samplers(sctx->gs_shader.cso)  ||
+  si_shader_uses_bindless_samplers(sctx->ps_shader.cso)  ||
+  si_shader_uses_bindless_samplers(sctx->tcs_shader.cso) ||
+  si_shader_uses_bindless_samplers(sctx->tes_shader.cso);
+}
+
+static inline bool
+si_graphics_uses_bindless_images(struct si_context *sctx)
+{
+   return si_shader_uses_bindless_images(sctx->vs_shader.cso)  ||
+  si_shader_uses_bindless_images(sctx->gs_shader.cso)  ||
+  si_shader_uses_bindless_images(sctx->ps_shader.cso)  ||
+  si_shader_uses_bindless_images(sctx->tcs_shader.cso) ||
+  si_shader_uses_bindless_images(sctx->tes_shader.cso);
+}
+
 static inline struct si_shader* si_get_vs_state(struct si_context *sctx)
 {
if (sctx->gs_shader.current)
diff --git a/src/gallium/drivers/radeonsi/si_shader.h 
b/src/gallium/drivers/radeonsi/si_shader.h
index aab902b4c7..87bbbf9c2a 100644
--- a/src/gallium/drivers/radeonsi/si_shader.h
+++ b/src/gallium/drivers/radeonsi/si_shader.h
@@ -622,4 +622,16 @@ si_get_main_shader_part(struct si_shader_selector *sel,
return >main_shader_part;
 }
 
+static inline bool
+si_shader_uses_bindless_samplers(struct si_shader_selector *selector)
+{
+   return selector ? selector->info.uses_bindless_samplers : false;
+}
+
+static inline bool
+si_shader_uses_bindless_images(struct si_shader_selector *selector)
+{
+   return selector ? selector->info.uses_bindless_images : false;
+}
+
 #endif
-- 
2.13.0

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


[Mesa-dev] [RFC PATCH 34/65] st/glsl_to_tgsi: add support for bindless pack/unpack operations

2017-05-19 Thread Samuel Pitoiset
Signed-off-by: Samuel Pitoiset 
---
 src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 9 -
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp 
b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index 264b43c10b..f30544eb4c 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -2328,6 +2328,10 @@ glsl_to_tgsi_visitor::visit_expression(ir_expression* 
ir, st_src_reg *op)
case ir_unop_pack_int_2x32:
case ir_unop_unpack_uint_2x32:
case ir_unop_pack_uint_2x32:
+   case ir_unop_unpack_sampler_2x32:
+   case ir_unop_pack_sampler_2x32:
+   case ir_unop_unpack_image_2x32:
+   case ir_unop_pack_image_2x32:
   emit_asm(ir, TGSI_OPCODE_MOV, result_dst, op[0]);
   break;
 
@@ -2486,11 +2490,6 @@ glsl_to_tgsi_visitor::visit_expression(ir_expression* 
ir, st_src_reg *op)
case ir_unop_unpack_snorm_4x8:
case ir_unop_unpack_unorm_4x8:
 
-   case ir_unop_unpack_sampler_2x32:
-   case ir_unop_pack_sampler_2x32:
-   case ir_unop_unpack_image_2x32:
-   case ir_unop_pack_image_2x32:
-
case ir_quadop_vector:
case ir_binop_vector_extract:
case ir_triop_vector_insert:
-- 
2.13.0

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


[Mesa-dev] [RFC PATCH 00/65] ARB_bindless_texture for RadeonSI

2017-05-19 Thread Samuel Pitoiset
Hi,

This series implements ARB_bindless_texture for RadeonSI.

Reminder: the GLSL compiler part is already upstream.

This series has been mainly tested with Feral games, here's the list of
existing games that use ARB_bindless_texture (though not by default):

- DXMD
- Hitman
- Dirt Rally
- Mad Max

Today, Feral announced "Warhammer 40,000: Dawn of War III" (called DOW3) which
is going to be released next month. This game *requires* ARB_bindless_texture,
that now explains why I did all this work. :-) So, we have ~3 weeks for merging
this whole series. It would be very nice to have DOW3 support at day one!

=== Tracking bindless problems ===

The following games have been successfully tested:

- Dirt Rally
- Hitman
- Mad Max
- DOW3

For these:

- No rendering issues
- No VM faults (ie. amdgpu.vm_debug=1)

However, DXMD is currently broken because the bindless_sampler layout qualifier
is missing, which ends up by reporting a ton of INVALID_OPERATION errors. Note
that Feral implemented bindless support against NV_bindless_texture and not
ARB_bindless_texture. The main difference is that bindless_sampler is implicit
for NV_* while it's required for ARB_*. Feral plan to fix this soon.

All ARB_bindless_texture piglit tests pass with this series.

=== Tracking regressions/changes ===

- No regressions with the Intel CI system
- One piglit regression that needs to be fixed
  (arb_texture_multisample-sample-position)
- No shader-db changes
- No CPU overhead (glxgears and Heaven in low)

=== Performance results for DOW3 ===

DOW3 exposes two bindless texture modes:
- mode 1: all bindless (ie. no bound samplers)
- mode 2: bound/bindless (ie. only bindless when the limit is reached)

CPU: Intel(R) Core(TM) i5-4460  CPU @ 3.20GHz
NVIDIA blob: 381.22

== GTX 1060 ==

LOW:
 - mode 1: 89 FPS
 - mode 2: 51 FPS

MEDIUM:
 - mode 1: 49 FPS
 - mode 2: 28 FPS

HIGH:
 - mode 1: 32 FPS
 - mode 2: 19 FPS

The GTX 1060 performs very well with the all bindless mode (default), while
the bound/bindless mode is not good at all.

== RX480 ==

LOW:
 - mode 1: 67 FPS (-32%)
 - mode 2: 75 FPS (+32%)

MEDIUM:
 - mode 1: 38 FPS (-28%)
 - mode 2: 44 FPS (+57%)

HIGH:
 - mode 1: 26 FPS (-23%)
 - mode 2: 29 FPS (+52%)

The RX 480 performs very well with the bound/bindless mode (default), while
the all bindless mode still has to be improved.

The most important bottleneck with the all bindless mode is the number of
buffers that have to be added for every command stream. The overhead in the
winsys and in the kernel (amdgpu_cs_ioctl) becomes important in this situation.
This mode is still clearly CPU bound and should be improved (see the "Future
work" section).

Btw, without any optimisations, it was around 35FPS in low (mode 1).

=== Performance results for other Feral titles ===

I didn't record any numbers because these games have been initially
developed/tested against the NVIDIA blob which it's unaffected by a VERY huge
number of resident handles. While the AMD stack is really slow in this
situation. Though, as I said, all Feral games that use bindless work fine, we
just need to improve perf on both sides.

=== Future work ===

I have some ideas to try in order to improve performance with RadeonSI. I will
work on this once this series is upstream.

Please review,
Thanks!

Samuel Pitoiset (65):
  mapi: add GL_ARB_bindless_texture entry points
  mesa: implement ARB_bindless_texture
  mesa: add support for unsigned 64-bit vertex attributes
  mesa: add support for glUniformHandleui64*ARB()
  mesa: refuse to update sampler parameters when a handle is allocated
  mesa: refuse to update tex parameters when a handle is allocated
  mesa: refuse to change textures when a handle is allocated
  mesa: refuse to change tex buffers when a handle is allocated
  mesa: keep track of the current variable in add_uniform_to_shader
  mesa: store bindless samplers as PROGRAM_UNIFORM
  mesa: add infrastructure for bindless samplers/images bound to units
  glsl: process uniform samplers declared bindless
  glsl: process uniform images declared bindless
  glsl: pass the ir_variable object to set_opaque_binding()
  glsl: set the explicit binding value for bindless samplers/images
  glsl: add ir_variable::is_bindless()
  mesa: add update_single_shader_texture_used() helper
  mesa: add update_single_program_texture_state() helper
  mesa: update textures for bindless samplers bound to texture units
  mesa: pass gl_program to _mesa_associate_uniform_storage()
  mesa: associate uniform storage to bindless samplers/images
  mesa: handle bindless uniforms bound to texture/image units
  mesa: get rid of a workaround for bindless in _mesa_get_uniform()
  gallium: add PIPE_CAP_BINDLESS_TEXTURE
  gallium: add ARB_bindless_texture interface
  ddebug: add ARB_bindless_texture support
  trace: add ARB_bindless_texture support
  tc: add ARB_bindless_texture support
  tgsi: add new Bindless flag to tgsi_instruction_texture
  tgsi: add new Bindless flag to tgsi_instruction_memory
  

[Mesa-dev] [RFC PATCH 05/65] mesa: refuse to update sampler parameters when a handle is allocated

2017-05-19 Thread Samuel Pitoiset
The ARB_bindless_texture spec says:

   "The error INVALID_OPERATION is generated by SamplerParameter* if
 identifies a sampler object referenced by one or more
texture handles."

Signed-off-by: Samuel Pitoiset 
---
 src/mesa/main/samplerobj.c | 42 ++
 1 file changed, 42 insertions(+)

diff --git a/src/mesa/main/samplerobj.c b/src/mesa/main/samplerobj.c
index ee15c68b4f..cf4bcfce7c 100644
--- a/src/mesa/main/samplerobj.c
+++ b/src/mesa/main/samplerobj.c
@@ -801,6 +801,18 @@ _mesa_SamplerParameteri(GLuint sampler, GLenum pname, 
GLint param)
if (!sampObj)
   return;
 
+   if (sampObj->HandleAllocated) {
+  /* The ARB_bindless_texture spec says:
+   *
+   * "The error INVALID_OPERATION is generated by SamplerParameter* if
+   *   identifies a sampler object referenced by one or more
+   *  texture handles."
+   */
+  _mesa_error(ctx, GL_INVALID_OPERATION,
+  "glSamplerParameteri(immutable sampler)");
+  return;
+   }
+
switch (pname) {
case GL_TEXTURE_WRAP_S:
   res = set_sampler_wrap_s(ctx, sampObj, param);
@@ -884,6 +896,12 @@ _mesa_SamplerParameterf(GLuint sampler, GLenum pname, 
GLfloat param)
if (!sampObj)
   return;
 
+   if (sampObj->HandleAllocated) {
+  _mesa_error(ctx, GL_INVALID_OPERATION,
+  "glSamplerParameterf(immutable sampler)");
+  return;
+   }
+
switch (pname) {
case GL_TEXTURE_WRAP_S:
   res = set_sampler_wrap_s(ctx, sampObj, (GLint) param);
@@ -966,6 +984,12 @@ _mesa_SamplerParameteriv(GLuint sampler, GLenum pname, 
const GLint *params)
if (!sampObj)
   return;
 
+   if (sampObj->HandleAllocated) {
+  _mesa_error(ctx, GL_INVALID_OPERATION,
+  "glSamplerParameteriv(immutable sampler)");
+  return;
+   }
+
switch (pname) {
case GL_TEXTURE_WRAP_S:
   res = set_sampler_wrap_s(ctx, sampObj, params[0]);
@@ -1056,6 +1080,12 @@ _mesa_SamplerParameterfv(GLuint sampler, GLenum pname, 
const GLfloat *params)
if (!sampObj)
   return;
 
+   if (sampObj->HandleAllocated) {
+  _mesa_error(ctx, GL_INVALID_OPERATION,
+  "glSamplerParameterfv(immutable sampler)");
+  return;
+   }
+
switch (pname) {
case GL_TEXTURE_WRAP_S:
   res = set_sampler_wrap_s(ctx, sampObj, (GLint) params[0]);
@@ -1139,6 +1169,12 @@ _mesa_SamplerParameterIiv(GLuint sampler, GLenum pname, 
const GLint *params)
if (!sampObj)
   return;
 
+   if (sampObj->HandleAllocated) {
+  _mesa_error(ctx, GL_INVALID_OPERATION,
+  "glSamplerParameterIiv(immutable sampler)");
+  return;
+   }
+
switch (pname) {
case GL_TEXTURE_WRAP_S:
   res = set_sampler_wrap_s(ctx, sampObj, params[0]);
@@ -1223,6 +1259,12 @@ _mesa_SamplerParameterIuiv(GLuint sampler, GLenum pname, 
const GLuint *params)
if (!sampObj)
   return;
 
+   if (sampObj->HandleAllocated) {
+  _mesa_error(ctx, GL_INVALID_OPERATION,
+  "glSamplerParameterIuiv(immutable sampler)");
+  return;
+   }
+
switch (pname) {
case GL_TEXTURE_WRAP_S:
   res = set_sampler_wrap_s(ctx, sampObj, params[0]);
-- 
2.13.0

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


[Mesa-dev] [RFC PATCH 02/65] mesa: implement ARB_bindless_texture

2017-05-19 Thread Samuel Pitoiset
Signed-off-by: Samuel Pitoiset 
---
 src/mesa/main/context.c |   3 +
 src/mesa/main/dd.h  |  17 +
 src/mesa/main/mtypes.h  |  34 ++
 src/mesa/main/samplerobj.c  |   6 +
 src/mesa/main/shared.c  |  12 +
 src/mesa/main/texobj.c  |  12 +
 src/mesa/main/texturebindless.c | 827 +++-
 src/mesa/main/texturebindless.h |  28 ++
 8 files changed, 934 insertions(+), 5 deletions(-)

diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c
index 3570f94f5a..5321886a95 100644
--- a/src/mesa/main/context.c
+++ b/src/mesa/main/context.c
@@ -133,6 +133,7 @@
 #include "varray.h"
 #include "version.h"
 #include "viewport.h"
+#include "texturebindless.h"
 #include "program/program.h"
 #include "math/m_matrix.h"
 #include "main/dispatch.h" /* for _gloffset_COUNT */
@@ -855,6 +856,7 @@ init_attrib_groups(struct gl_context *ctx)
_mesa_init_transform_feedback( ctx );
_mesa_init_varray( ctx );
_mesa_init_viewport( ctx );
+   _mesa_init_resident_handles( ctx );
 
if (!_mesa_init_texture( ctx ))
   return GL_FALSE;
@@ -1339,6 +1341,7 @@ _mesa_free_context_data( struct gl_context *ctx )
_mesa_free_transform_feedback(ctx);
_mesa_free_performance_monitors(ctx);
_mesa_free_performance_queries(ctx);
+   _mesa_free_resident_handles(ctx);
 
_mesa_reference_buffer_object(ctx, >Pack.BufferObj, NULL);
_mesa_reference_buffer_object(ctx, >Unpack.BufferObj, NULL);
diff --git a/src/mesa/main/dd.h b/src/mesa/main/dd.h
index a9ca43d69e..d830f5184d 100644
--- a/src/mesa/main/dd.h
+++ b/src/mesa/main/dd.h
@@ -1050,6 +1050,23 @@ struct dd_function_table {
 GLintptr offset, GLsizeiptr size,
 GLboolean commit);
/*@}*/
+
+   /**
+* \name GL_ARB_bindless_texture interface
+*/
+   /*@{*/
+   GLuint64 (*NewTextureHandle)(struct gl_context *ctx,
+struct gl_texture_object *texObj,
+struct gl_sampler_object *sampObj);
+   void (*DeleteTextureHandle)(struct gl_context *ctx, GLuint64 handle);
+   void (*MakeTextureHandleResident)(struct gl_context *ctx, GLuint64 handle,
+ bool resident);
+   GLuint64 (*NewImageHandle)(struct gl_context *ctx,
+  struct gl_image_unit *imgObj);
+   void (*DeleteImageHandle)(struct gl_context *ctx, GLuint64 handle);
+   void (*MakeImageHandleResident)(struct gl_context *ctx, GLuint64 handle,
+   GLenum access, bool resident);
+   /*@}*/
 };
 
 
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index efc6920254..70865b373d 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -987,6 +987,9 @@ struct gl_sampler_object
GLenum CompareFunc; /**< GL_ARB_shadow */
GLenum sRGBDecode;   /**< GL_DECODE_EXT or GL_SKIP_DECODE_EXT */
GLboolean CubeMapSeamless;   /**< GL_AMD_seamless_cubemap_per_texture */
+   bool HandleAllocated;/**< GL_ARB_bindless_texture */
+
+   struct hash_table *Handles;
 };
 
 
@@ -1034,6 +1037,8 @@ struct gl_texture_object
GLuint NumLevels;   /**< GL_ARB_texture_view */
GLuint NumLayers;   /**< GL_ARB_texture_view */
 
+   GLboolean HandleAllocated;  /**< GL_ARB_bindless_texture */
+
/** Actual texture images, indexed by [cube face] and [mipmap level] */
struct gl_texture_image *Image[MAX_FACES][MAX_TEXTURE_LEVELS];
 
@@ -1051,6 +1056,10 @@ struct gl_texture_object
 
/** GL_ARB_shader_image_load_store */
GLenum ImageFormatCompatibilityType;
+
+   /** GL_ARB_bindless_texture */
+   struct hash_table *SamplerHandles;
+   struct hash_table *ImageHandles;
 };
 
 
@@ -1390,6 +1399,7 @@ struct gl_buffer_object
GLboolean Written;   /**< Ever written to? (for debugging) */
GLboolean Purgeable; /**< Is the buffer purgeable under memory pressure? */
GLboolean Immutable; /**< GL_ARB_buffer_storage */
+   GLboolean HandleAllocated; /**< GL_ARB_bindless_texture */
gl_buffer_usage UsageHistory; /**< How has this buffer been used so far? */
 
/** Counters used for buffer usage warnings */
@@ -3203,6 +3213,11 @@ struct gl_shared_state
/** GL_ARB_sampler_objects */
struct _mesa_HashTable *SamplerObjects;
 
+   /* GL_ARB_bindless_texture */
+   struct hash_table *TextureHandles;
+   struct hash_table *ImageHandles;
+   mtx_t HandlesMutex; /**< For texture/image handles safety */
+
/**
 * Some context in this share group was affected by a GPU reset
 *
@@ -4488,6 +4503,17 @@ struct gl_subroutine_index_binding
GLuint *IndexPtr;
 };
 
+struct gl_texture_handle_object
+{
+   struct gl_texture_object *texObj;
+   struct gl_sampler_object *sampObj;
+};
+
+struct gl_image_handle_object
+{
+   struct gl_image_unit imgObj;
+};
+
 /**
  * Mesa rendering context.
  *
@@ -4842,6 +4868,14 @@ struct gl_context
GLfloat 

[Mesa-dev] [RFC PATCH 04/65] mesa: add support for glUniformHandleui64*ARB()

2017-05-19 Thread Samuel Pitoiset
Bindless sampler/image handles are represented using 64-bit
unsigned integers.

The ARB_bindless_texture spec says:

   "The error INVALID_OPERATION is generated by UniformHandleui64{v}ARB
   if the sampler or image uniform being updated has the "bound_sampler"
   or "bound_image" layout qualifier"."

Signed-off-by: Samuel Pitoiset 
---
 src/compiler/glsl/ir_uniform.h  |  6 
 src/compiler/glsl/link_uniforms.cpp |  1 +
 src/compiler/glsl/shader_cache.cpp  |  2 ++
 src/mesa/main/uniform_query.cpp | 64 +
 src/mesa/main/uniforms.c| 15 +
 src/mesa/main/uniforms.h|  4 +++
 6 files changed, 92 insertions(+)

diff --git a/src/compiler/glsl/ir_uniform.h b/src/compiler/glsl/ir_uniform.h
index b6aec7fc4a..9841df8cde 100644
--- a/src/compiler/glsl/ir_uniform.h
+++ b/src/compiler/glsl/ir_uniform.h
@@ -201,6 +201,12 @@ struct gl_uniform_storage {
 * top-level shader storage block member. (GL_TOP_LEVEL_ARRAY_STRIDE).
 */
unsigned top_level_array_stride;
+
+   /**
+* Whether this uniform variable has the bindless_sampler or bindless_image
+* layout qualifier as specified by ARB_bindless_texture.
+*/
+   bool is_bindless;
 };
 
 #ifdef __cplusplus
diff --git a/src/compiler/glsl/link_uniforms.cpp 
b/src/compiler/glsl/link_uniforms.cpp
index b11739ce78..7c3ca75416 100644
--- a/src/compiler/glsl/link_uniforms.cpp
+++ b/src/compiler/glsl/link_uniforms.cpp
@@ -754,6 +754,7 @@ private:
 
   this->uniforms[id].is_shader_storage =
  current_var->is_in_shader_storage_block();
+  this->uniforms[id].is_bindless = current_var->data.bindless;
 
   /* Do not assign storage if the uniform is a builtin or buffer object */
   if (!this->uniforms[id].builtin &&
diff --git a/src/compiler/glsl/shader_cache.cpp 
b/src/compiler/glsl/shader_cache.cpp
index 800d3a2913..2bfddebcd7 100644
--- a/src/compiler/glsl/shader_cache.cpp
+++ b/src/compiler/glsl/shader_cache.cpp
@@ -578,6 +578,7 @@ write_uniforms(struct blob *metadata, struct 
gl_shader_program *prog)
   blob_write_uint32(metadata, 
prog->data->UniformStorage[i].is_shader_storage);
   blob_write_uint32(metadata, prog->data->UniformStorage[i].matrix_stride);
   blob_write_uint32(metadata, prog->data->UniformStorage[i].row_major);
+  blob_write_uint32(metadata, prog->data->UniformStorage[i].is_bindless);
   blob_write_uint32(metadata,
 
prog->data->UniformStorage[i].num_compatible_subroutines);
   blob_write_uint32(metadata,
@@ -642,6 +643,7 @@ read_uniforms(struct blob_reader *metadata, struct 
gl_shader_program *prog)
   uniforms[i].is_shader_storage = blob_read_uint32(metadata);
   uniforms[i].matrix_stride = blob_read_uint32(metadata);
   uniforms[i].row_major = blob_read_uint32(metadata);
+  uniforms[i].is_bindless = blob_read_uint32(metadata);
   uniforms[i].num_compatible_subroutines = blob_read_uint32(metadata);
   uniforms[i].top_level_array_size = blob_read_uint32(metadata);
   uniforms[i].top_level_array_stride = blob_read_uint32(metadata);
diff --git a/src/mesa/main/uniform_query.cpp b/src/mesa/main/uniform_query.cpp
index 16e3fe3d52..cc145f29e9 100644
--- a/src/mesa/main/uniform_query.cpp
+++ b/src/mesa/main/uniform_query.cpp
@@ -1173,6 +1173,70 @@ _mesa_uniform_matrix(GLint location, GLsizei count,
_mesa_propagate_uniforms_to_driver_storage(uni, offset, count);
 }
 
+/**
+ * Called via glUniformHandleui64*ARB() functions.
+ */
+extern "C" void
+_mesa_uniform_handle(GLint location, GLsizei count, const GLvoid *values,
+ struct gl_context *ctx, struct gl_shader_program *shProg)
+{
+   unsigned offset;
+   struct gl_uniform_storage *const uni =
+  validate_uniform_parameters(location, count, ,
+  ctx, shProg, "glUniformHandleui64*ARB");
+   if (uni == NULL)
+  return;
+
+   if (!uni->is_bindless) {
+  /* From section "Errors" of the ARB_bindless_texture spec:
+   *
+   * "The error INVALID_OPERATION is generated by
+   *  UniformHandleui64{v}ARB if the sampler or image uniform being
+   *  updated has the "bound_sampler" or "bound_image" layout qualifier."
+   *
+   * From section 4.4.6 of the ARB_bindless_texture spec:
+   *
+   * "In the absence of these qualifiers, sampler and image uniforms are
+   *  considered "bound". Additionally, if GL_ARB_bindless_texture is not
+   *  enabled, these uniforms are considered "bound"."
+   */
+  _mesa_error(ctx, GL_INVALID_OPERATION,
+  "glUniformHandleui64*ARB(non-bindless sampler/image 
uniform)");
+  return;
+   }
+
+   const unsigned components = uni->type->vector_elements;
+   const int size_mul = 2;
+
+   if (unlikely(ctx->_Shader->Flags & GLSL_UNIFORMS)) {
+  log_uniform(values, GLSL_TYPE_UINT64, components, 1, count,
+  false, shProg, location, uni);
+  

[Mesa-dev] [RFC PATCH 01/65] mapi: add GL_ARB_bindless_texture entry points

2017-05-19 Thread Samuel Pitoiset
Signed-off-by: Samuel Pitoiset 
---
 src/mapi/glapi/gen/ARB_bindless_texture.xml | 100 
 src/mapi/glapi/gen/Makefile.am  |   1 +
 src/mapi/glapi/gen/gl_API.xml   |   4 +-
 src/mapi/glapi/gen/gl_genexec.py|   1 +
 src/mesa/Makefile.sources   |   2 +
 src/mesa/main/api_loopback.c|  14 
 src/mesa/main/api_loopback.h|   6 ++
 src/mesa/main/dd.h  |   2 +
 src/mesa/main/tests/dispatch_sanity.cpp |  18 +
 src/mesa/main/texturebindless.c |  85 +++
 src/mesa/main/texturebindless.h |  68 +++
 src/mesa/main/uniforms.c|  24 +++
 src/mesa/main/uniforms.h|  12 
 src/mesa/main/varray.c  |   5 ++
 src/mesa/main/varray.h  |   3 +
 src/mesa/main/vtxfmt.c  |   4 ++
 src/mesa/vbo/vbo_attrib_tmp.h   |   9 +++
 src/mesa/vbo/vbo_exec_api.c |   3 +
 src/mesa/vbo/vbo_save_api.c |   3 +
 19 files changed, 363 insertions(+), 1 deletion(-)
 create mode 100644 src/mapi/glapi/gen/ARB_bindless_texture.xml
 create mode 100644 src/mesa/main/texturebindless.c
 create mode 100644 src/mesa/main/texturebindless.h

diff --git a/src/mapi/glapi/gen/ARB_bindless_texture.xml 
b/src/mapi/glapi/gen/ARB_bindless_texture.xml
new file mode 100644
index 00..bfad45651c
--- /dev/null
+++ b/src/mapi/glapi/gen/ARB_bindless_texture.xml
@@ -0,0 +1,100 @@
+
+
+
+
+
+
+
+   
+   
+
+   
+  
+  
+   
+
+   
+  
+  
+  
+   
+
+   
+  
+   
+
+   
+  
+   
+
+   
+  
+  
+  
+  
+  
+  
+   
+
+   
+  
+  
+   
+
+   
+  
+   
+
+   
+  
+  
+   
+
+   
+  
+  
+  
+   
+
+   
+  
+  
+  
+   
+
+   
+  
+  
+  
+  
+   
+
+   
+  
+  
+   
+
+   
+  
+  
+   
+
+   
+  
+  
+   
+
+   
+  
+  
+   
+
+   
+  
+  
+  
+   
+
+
+
+
diff --git a/src/mapi/glapi/gen/Makefile.am b/src/mapi/glapi/gen/Makefile.am
index ecd1c71175..80f9139e5d 100644
--- a/src/mapi/glapi/gen/Makefile.am
+++ b/src/mapi/glapi/gen/Makefile.am
@@ -119,6 +119,7 @@ API_XML = \
gl_and_glX_API.xml \
ARB_base_instance.xml \
ARB_blend_func_extended.xml \
+   ARB_bindless_texture.xml \
ARB_clear_buffer_object.xml \
ARB_clear_texture.xml \
ARB_clip_control.xml \
diff --git a/src/mapi/glapi/gen/gl_API.xml b/src/mapi/glapi/gen/gl_API.xml
index 762fb5a676..278fe14bb6 100644
--- a/src/mapi/glapi/gen/gl_API.xml
+++ b/src/mapi/glapi/gen/gl_API.xml
@@ -8284,7 +8284,9 @@
 
 
 
-
+
+
+http://www.w3.org/2001/XInclude"/>
 
 http://www.w3.org/2001/XInclude"/>
 
diff --git a/src/mapi/glapi/gen/gl_genexec.py b/src/mapi/glapi/gen/gl_genexec.py
index 37b1cc6be0..57e155bd1f 100644
--- a/src/mapi/glapi/gen/gl_genexec.py
+++ b/src/mapi/glapi/gen/gl_genexec.py
@@ -113,6 +113,7 @@ header = """/**
 #include "main/texstate.h"
 #include "main/texstorage.h"
 #include "main/barrier.h"
+#include "main/texturebindless.h"
 #include "main/textureview.h"
 #include "main/transformfeedback.h"
 #include "main/mtypes.h"
diff --git a/src/mesa/Makefile.sources b/src/mesa/Makefile.sources
index 8a65fbe663..b80882fb8d 100644
--- a/src/mesa/Makefile.sources
+++ b/src/mesa/Makefile.sources
@@ -240,6 +240,8 @@ MAIN_FILES = \
main/texstorage.h \
main/texstore.c \
main/texstore.h \
+   main/texturebindless.c \
+   main/texturebindless.h \
main/textureview.c \
main/textureview.h \
main/transformfeedback.c \
diff --git a/src/mesa/main/api_loopback.c b/src/mesa/main/api_loopback.c
index 59b59d3a9e..36e5194b93 100644
--- a/src/mesa/main/api_loopback.c
+++ b/src/mesa/main/api_loopback.c
@@ -1529,6 +1529,16 @@ _mesa_VertexAttribL1dv(GLuint index, const GLdouble *v)
 }
 
 void GLAPIENTRY
+_mesa_VertexAttribL1ui64ARB(GLuint index, GLuint64EXT x)
+{
+}
+
+void GLAPIENTRY
+_mesa_VertexAttribL1ui64vARB(GLuint index, const GLuint64EXT *v)
+{
+}
+
+void GLAPIENTRY
 _mesa_VertexAttribL2dv(GLuint index, const GLdouble *v)
 {
ATTRIB2_D(index, v[0], v[1]);
@@ -1789,5 +1799,9 @@ _mesa_loopback_init_api_table(const struct gl_context 
*ctx,
   SET_VertexAttribL2dv(dest, _mesa_VertexAttribL2dv);
   SET_VertexAttribL3dv(dest, _mesa_VertexAttribL3dv);
   SET_VertexAttribL4dv(dest, _mesa_VertexAttribL4dv);
+
+  /* GL_ARB_bindless_texture */
+  SET_VertexAttribL1ui64ARB(dest, _mesa_VertexAttribL1ui64ARB);
+  SET_VertexAttribL1ui64vARB(dest, _mesa_VertexAttribL1ui64vARB);
}
 }
diff --git a/src/mesa/main/api_loopback.h b/src/mesa/main/api_loopback.h
index 026bfd68e1..c1e7b24f09 100644
--- a/src/mesa/main/api_loopback.h
+++ b/src/mesa/main/api_loopback.h
@@ -481,4 +481,10 @@ void 

[Mesa-dev] [RFC PATCH 07/65] mesa: refuse to change textures when a handle is allocated

2017-05-19 Thread Samuel Pitoiset
The ARB_bindless_texture spec says:

   "The error INVALID_OPERATION is generated by TexImage*, CopyTexImage*,
CompressedTexImage*, TexBuffer*, TexParameter*, as well as other
functions defined in terms of these, if the texture object to be
modified is referenced by one or more texture or image handles."

Signed-off-by: Samuel Pitoiset 
---
 src/mesa/main/teximage.c | 25 -
 1 file changed, 24 insertions(+), 1 deletion(-)

diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
index fed1dad262..ac06b66985 100644
--- a/src/mesa/main/teximage.c
+++ b/src/mesa/main/teximage.c
@@ -1578,7 +1578,7 @@ legal_texsubimage_target(struct gl_context *ctx, GLuint 
dims, GLenum target,
 
 /**
  * Helper function to determine if a texture object is mutable (in terms
- * of GL_ARB_texture_storage).
+ * of GL_ARB_texture_storage/GL_ARB_bindless_texture).
  */
 static GLboolean
 mutable_tex_object(struct gl_context *ctx, GLenum target)
@@ -1587,6 +1587,17 @@ mutable_tex_object(struct gl_context *ctx, GLenum target)
if (!texObj)
   return GL_FALSE;
 
+   if (texObj->HandleAllocated) {
+  /* The ARB_bindless_texture spec says:
+   *
+   * "The error INVALID_OPERATION is generated by TexImage*, CopyTexImage*,
+   *  CompressedTexImage*, TexBuffer*, TexParameter*, as well as other
+   *  functions defined in terms of these, if the texture object to be
+   *  modified is referenced by one or more texture or image handles."
+   */
+  return GL_FALSE;
+   }
+
return !texObj->Immutable;
 }
 
@@ -5009,6 +5020,18 @@ texture_buffer_range(struct gl_context *ctx,
   return;
}
 
+   if (texObj->HandleAllocated) {
+  /* The ARB_bindless_texture spec says:
+   *
+   * "The error INVALID_OPERATION is generated by TexImage*, CopyTexImage*,
+   *  CompressedTexImage*, TexBuffer*, TexParameter*, as well as other
+   *  functions defined in terms of these, if the texture object to be
+   *  modified is referenced by one or more texture or image handles."
+   */
+  _mesa_error(ctx, GL_INVALID_OPERATION, "%s(immutable texture)", caller);
+  return;
+   }
+
format = _mesa_validate_texbuffer_format(ctx, internalFormat);
if (format == MESA_FORMAT_NONE) {
   _mesa_error(ctx, GL_INVALID_ENUM, "%s(internalFormat %s)",
-- 
2.13.0

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


[Mesa-dev] [RFC PATCH 06/65] mesa: refuse to update tex parameters when a handle is allocated

2017-05-19 Thread Samuel Pitoiset
The ARB_bindless_texture spec says:

   "The ARB_bindless_texture spec says: "The error INVALID_OPERATION
is generated by TexImage*, CopyTexImage*, CompressedTexImage*,
TexBuffer*, TexParameter*, as well as other functions defined in
terms of these, if the texture object to be modified is referenced
by one or more texture or image handles."

Signed-off-by: Samuel Pitoiset 
---
 src/mesa/main/texparam.c | 61 
 1 file changed, 61 insertions(+)

diff --git a/src/mesa/main/texparam.c b/src/mesa/main/texparam.c
index 0156bbd275..c73cf8bf83 100644
--- a/src/mesa/main/texparam.c
+++ b/src/mesa/main/texparam.c
@@ -1026,6 +1026,9 @@ _mesa_TexParameterf(GLenum target, GLenum pname, GLfloat 
param)
if (!texObj)
   return;
 
+   if (texObj->HandleAllocated)
+  return;
+
_mesa_texture_parameterf(ctx, texObj, pname, param, false);
 }
 
@@ -1039,6 +1042,9 @@ _mesa_TexParameterfv(GLenum target, GLenum pname, const 
GLfloat *params)
if (!texObj)
   return;
 
+   if (texObj->HandleAllocated)
+  return;
+
_mesa_texture_parameterfv(ctx, texObj, pname, params, false);
 }
 
@@ -1052,6 +1058,9 @@ _mesa_TexParameteri(GLenum target, GLenum pname, GLint 
param)
if (!texObj)
   return;
 
+   if (texObj->HandleAllocated)
+  return;
+
_mesa_texture_parameteri(ctx, texObj, pname, param, false);
 }
 
@@ -1065,6 +1074,9 @@ _mesa_TexParameteriv(GLenum target, GLenum pname, const 
GLint *params)
if (!texObj)
   return;
 
+   if (texObj->HandleAllocated)
+  return;
+
_mesa_texture_parameteriv(ctx, texObj, pname, params, false);
 }
 
@@ -1083,6 +1095,9 @@ _mesa_TexParameterIiv(GLenum target, GLenum pname, const 
GLint *params)
if (!texObj)
   return;
 
+   if (texObj->HandleAllocated)
+  return;
+
_mesa_texture_parameterIiv(ctx, texObj, pname, params, false);
 }
 
@@ -1101,6 +1116,9 @@ _mesa_TexParameterIuiv(GLenum target, GLenum pname, const 
GLuint *params)
if (!texObj)
   return;
 
+   if (texObj->HandleAllocated)
+  return;
+
_mesa_texture_parameterIuiv(ctx, texObj, pname, params, false);
 }
 
@@ -1118,6 +1136,19 @@ _mesa_TextureParameterfv(GLuint texture, GLenum pname, 
const GLfloat *params)
   return;
}
 
+   if (texObj->HandleAllocated) {
+  /* The ARB_bindless_texture spec says:
+   *
+   * "The error INVALID_OPERATION is generated by TexImage*, CopyTexImage*,
+   *  CompressedTexImage*, TexBuffer*, TexParameter*, as well as other
+   *  functions defined in terms of these, if the texture object to be
+   *  modified is referenced by one or more texture or image handles."
+   */
+  _mesa_error(ctx, GL_INVALID_OPERATION,
+  "glTextureParameterfv(immutable texture)");
+  return;
+   }
+
_mesa_texture_parameterfv(ctx, texObj, pname, params, true);
 }
 
@@ -1134,6 +1165,12 @@ _mesa_TextureParameterf(GLuint texture, GLenum pname, 
GLfloat param)
   return;
}
 
+   if (texObj->HandleAllocated) {
+  _mesa_error(ctx, GL_INVALID_OPERATION,
+  "glTextureParameterf(immutable texture)");
+  return;
+   }
+
_mesa_texture_parameterf(ctx, texObj, pname, param, true);
 }
 
@@ -1150,6 +1187,12 @@ _mesa_TextureParameteri(GLuint texture, GLenum pname, 
GLint param)
   return;
}
 
+   if (texObj->HandleAllocated) {
+  _mesa_error(ctx, GL_INVALID_OPERATION,
+  "glTextureParameteri(immutable texture)");
+  return;
+   }
+
_mesa_texture_parameteri(ctx, texObj, pname, param, true);
 }
 
@@ -1167,6 +1210,12 @@ _mesa_TextureParameteriv(GLuint texture, GLenum pname,
   return;
}
 
+   if (texObj->HandleAllocated) {
+  _mesa_error(ctx, GL_INVALID_OPERATION,
+  "glTextureParameteriv(immutable texture)");
+  return;
+   }
+
_mesa_texture_parameteriv(ctx, texObj, pname, params, true);
 }
 
@@ -1185,6 +1234,12 @@ _mesa_TextureParameterIiv(GLuint texture, GLenum pname, 
const GLint *params)
   return;
}
 
+   if (texObj->HandleAllocated) {
+  _mesa_error(ctx, GL_INVALID_OPERATION,
+  "glTextureParameterIiv(immutable texture)");
+  return;
+   }
+
_mesa_texture_parameterIiv(ctx, texObj, pname, params, true);
 }
 
@@ -1202,6 +1257,12 @@ _mesa_TextureParameterIuiv(GLuint texture, GLenum pname, 
const GLuint *params)
   return;
}
 
+   if (texObj->HandleAllocated) {
+  _mesa_error(ctx, GL_INVALID_OPERATION,
+  "glTextureParameterIuv(immutable texture)");
+  return;
+   }
+
_mesa_texture_parameterIuiv(ctx, texObj, pname, params, true);
 }
 
-- 
2.13.0

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


[Mesa-dev] [RFC PATCH 12/65] glsl: process uniform samplers declared bindless

2017-05-19 Thread Samuel Pitoiset
Signed-off-by: Samuel Pitoiset 
---
 src/compiler/glsl/link_uniforms.cpp | 83 -
 src/compiler/glsl/shader_cache.cpp  | 23 ++
 src/mesa/program/program.c  |  4 ++
 3 files changed, 99 insertions(+), 11 deletions(-)

diff --git a/src/compiler/glsl/link_uniforms.cpp 
b/src/compiler/glsl/link_uniforms.cpp
index 7c3ca75416..c962f98d59 100644
--- a/src/compiler/glsl/link_uniforms.cpp
+++ b/src/compiler/glsl/link_uniforms.cpp
@@ -418,10 +418,16 @@ public:
   struct string_to_uint_map *map,
   struct gl_uniform_storage *uniforms,
   union gl_constant_value *values)
-  : prog(prog), map(map), uniforms(uniforms), values(values)
+  : prog(prog), map(map), uniforms(uniforms), values(values),
+bindless_targets(NULL)
{
}
 
+   virtual ~parcel_out_uniform_storage()
+   {
+  free(this->bindless_targets);
+   }
+
void start_shader(gl_shader_stage shader_type)
{
   assert(shader_type < MESA_SHADER_STAGES);
@@ -434,6 +440,11 @@ public:
   this->next_subroutine = 0;
   this->record_array_count = 1;
   memset(this->targets, 0, sizeof(this->targets));
+
+  this->num_bindless_samplers = 0;
+  this->next_bindless_sampler = 0;
+  free(this->bindless_targets);
+  this->bindless_targets = NULL;
}
 
void set_and_process(ir_variable *var)
@@ -441,6 +452,7 @@ public:
   current_var = var;
   field_counter = 0;
   this->record_next_sampler = new string_to_uint_map;
+  this->record_next_bindless_sampler = new string_to_uint_map;
   this->record_next_image = new string_to_uint_map;
 
   buffer_block_index = -1;
@@ -502,6 +514,7 @@ public:
  process(var);
   }
   delete this->record_next_sampler;
+  delete this->record_next_bindless_sampler;
   delete this->record_next_image;
}
 
@@ -578,18 +591,39 @@ private:
   if (base_type->is_sampler()) {
  uniform->opaque[shader_type].active = true;
 
- if (!set_opaque_indices(base_type, uniform, name, this->next_sampler,
- this->record_next_sampler))
-return;
-
  const gl_texture_index target = base_type->sampler_index();
  const unsigned shadow = base_type->sampler_shadow;
- for (unsigned i = uniform->opaque[shader_type].index;
-  i < MIN2(this->next_sampler, MAX_SAMPLERS);
-  i++) {
-this->targets[i] = target;
-this->shader_samplers_used |= 1U << i;
-this->shader_shadow_samplers |= shadow << i;
+
+ if (current_var->data.bindless) {
+if (!set_opaque_indices(base_type, uniform, name,
+this->next_bindless_sampler,
+this->record_next_bindless_sampler))
+   return;
+
+this->num_bindless_samplers = this->next_bindless_sampler;
+
+this->bindless_targets = (gl_texture_index *)
+   realloc(this->bindless_targets,
+   this->num_bindless_samplers * sizeof(gl_texture_index));
+
+for (unsigned i = uniform->opaque[shader_type].index;
+ i < this->num_bindless_samplers;
+ i++) {
+   this->bindless_targets[i] = target;
+}
+ } else {
+if (!set_opaque_indices(base_type, uniform, name,
+this->next_sampler,
+this->record_next_sampler))
+   return;
+
+for (unsigned i = uniform->opaque[shader_type].index;
+ i < MIN2(this->next_sampler, MAX_SAMPLERS);
+ i++) {
+   this->targets[i] = target;
+   this->shader_samplers_used |= 1U << i;
+   this->shader_shadow_samplers |= shadow << i;
+}
  }
   }
}
@@ -827,6 +861,7 @@ private:
 
struct gl_uniform_storage *uniforms;
unsigned next_sampler;
+   unsigned next_bindless_sampler;
unsigned next_image;
unsigned next_subroutine;
 
@@ -859,6 +894,11 @@ private:
 */
struct string_to_uint_map *record_next_image;
 
+   /* Map for temporarily storing next bindless sampler index when handling
+* bindless samplers in struct arrays.
+*/
+   struct string_to_uint_map *record_next_bindless_sampler;
+
 public:
union gl_constant_value *values;
 
@@ -873,6 +913,16 @@ public:
 * Mask of samplers used by the current shader stage for shadows.
 */
unsigned shader_shadow_samplers;
+
+   /**
+* Number of bindless samplers used by the current shader stage.
+*/
+   unsigned num_bindless_samplers;
+
+   /**
+* Texture targets for bindless samplers used by the current stage.
+*/
+   gl_texture_index *bindless_targets;
 };
 
 static bool
@@ -1259,6 +1309,17 @@ 

[Mesa-dev] [RFC PATCH 03/65] mesa: add support for unsigned 64-bit vertex attributes

2017-05-19 Thread Samuel Pitoiset
This adds support in the VBO and array code to handle unsigned
64-bit vertex attributes as specified by ARB_bindless_texture.

Signed-off-by: Samuel Pitoiset 
---
 src/mapi/glapi/gen/apiexec.py |  3 +++
 src/mesa/main/api_loopback.c  |  4 
 src/mesa/main/varray.c| 18 ++
 src/mesa/vbo/vbo_attrib_tmp.h | 19 +++
 src/mesa/vbo/vbo_context.h|  2 ++
 src/mesa/vbo/vbo_exec_api.c   | 12 +---
 6 files changed, 55 insertions(+), 3 deletions(-)

diff --git a/src/mapi/glapi/gen/apiexec.py b/src/mapi/glapi/gen/apiexec.py
index e5e1b7d78c..61eda4b0f9 100644
--- a/src/mapi/glapi/gen/apiexec.py
+++ b/src/mapi/glapi/gen/apiexec.py
@@ -291,4 +291,7 @@ functions = {
 "ProgramUniform2ui64vARB": exec_info(core=31),
 "ProgramUniform3ui64vARB": exec_info(core=31),
 "ProgramUniform4ui64vARB": exec_info(core=31),
+
+# GL_ARB_bindless_texture
+"GetVertexAttribLui64vARB": exec_info(core=31),
 }
diff --git a/src/mesa/main/api_loopback.c b/src/mesa/main/api_loopback.c
index 36e5194b93..b552d17d6a 100644
--- a/src/mesa/main/api_loopback.c
+++ b/src/mesa/main/api_loopback.c
@@ -89,6 +89,8 @@
 #define ATTRIB3_D(index,x,y,z) CALL_VertexAttribL3d(GET_DISPATCH(), 
(index,x,y,z))
 #define ATTRIB4_D(index,x,y,z,w)CALL_VertexAttribL4d(GET_DISPATCH(), 
(index,x,y,z,w))
 
+#define ATTRIB1_UI64(index, x) CALL_VertexAttribL1ui64ARB(GET_DISPATCH(), 
(index, x))
+
 void GLAPIENTRY
 _mesa_Color3b( GLbyte red, GLbyte green, GLbyte blue )
 {
@@ -1531,11 +1533,13 @@ _mesa_VertexAttribL1dv(GLuint index, const GLdouble *v)
 void GLAPIENTRY
 _mesa_VertexAttribL1ui64ARB(GLuint index, GLuint64EXT x)
 {
+   ATTRIB1_UI64(index, x);
 }
 
 void GLAPIENTRY
 _mesa_VertexAttribL1ui64vARB(GLuint index, const GLuint64EXT *v)
 {
+   ATTRIB1_UI64(index, v[0]);
 }
 
 void GLAPIENTRY
diff --git a/src/mesa/main/varray.c b/src/mesa/main/varray.c
index fcb53d3986..2100cd1b9e 100644
--- a/src/mesa/main/varray.c
+++ b/src/mesa/main/varray.c
@@ -1356,6 +1356,24 @@ _mesa_GetVertexAttribiv(GLuint index, GLenum pname, 
GLint *params)
 void GLAPIENTRY
 _mesa_GetVertexAttribLui64vARB(GLuint index, GLenum pname, GLuint64EXT *params)
 {
+   GET_CURRENT_CONTEXT(ctx);
+
+   if (pname == GL_CURRENT_VERTEX_ATTRIB_ARB) {
+  const GLuint64 *v =
+ (const GLuint64 *)get_current_attrib(ctx, index,
+  "glGetVertexAttribLui64vARB");
+  if (v != NULL) {
+ params[0] = v[0];
+ params[1] = v[1];
+ params[2] = v[2];
+ params[3] = v[3];
+  }
+   }
+   else {
+  params[0] = (GLuint64) get_vertex_array_attrib(ctx, ctx->Array.VAO,
+ index, pname,
+ 
"glGetVertexAttribLui64vARB");
+   }
 }
 
 
diff --git a/src/mesa/vbo/vbo_attrib_tmp.h b/src/mesa/vbo/vbo_attrib_tmp.h
index 08b441aafb..8328445b2b 100644
--- a/src/mesa/vbo/vbo_attrib_tmp.h
+++ b/src/mesa/vbo/vbo_attrib_tmp.h
@@ -41,6 +41,8 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 FLOAT_AS_UNION(V2), FLOAT_AS_UNION(V3))
 #define ATTRD( A, N, V0, V1, V2, V3 ) \
 ATTR_UNION(A, N, GL_DOUBLE, double, V0, V1, V2, V3)
+#define ATTRUI64( A, N, V0, V1, V2, V3 ) \
+ATTR_UNION(A, N, GL_UNSIGNED_INT64_ARB, uint64_t, V0, V1, V2, V3)
 
 
 /* float */
@@ -246,6 +248,9 @@ static inline float conv_i2_to_norm_float(const struct 
gl_context *ctx, int i2)
 #define ATTR3D( A, X, Y, Z )ATTRD( A, 3, X, Y, Z, 1 )
 #define ATTR4D( A, X, Y, Z, W ) ATTRD( A, 4, X, Y, Z, W )
 
+#define ATTR1UIV64( A, V ) ATTRUI64( A, 1, (V)[0], 0, 0, 0 )
+#define ATTR1UI64( A, X )  ATTRUI64( A, 1, X, 0, 0, 0 )
+
 
 static void GLAPIENTRY
 TAG(Vertex2f)(GLfloat x, GLfloat y)
@@ -1305,11 +1310,25 @@ TAG(VertexAttribL4dv)(GLuint index, const GLdouble * v)
 static void GLAPIENTRY
 TAG(VertexAttribL1ui64ARB)(GLuint index, GLuint64EXT x)
 {
+   GET_CURRENT_CONTEXT(ctx);
+   if (index == 0 && _mesa_attr_zero_aliases_vertex(ctx))
+  ATTR1UI64(0, x);
+   else if (index < MAX_VERTEX_GENERIC_ATTRIBS)
+  ATTR1UI64(VBO_ATTRIB_GENERIC0 + index, x);
+   else
+  ERROR(GL_INVALID_VALUE);
 }
 
 static void GLAPIENTRY
 TAG(VertexAttribL1ui64vARB)(GLuint index, const GLuint64EXT *v)
 {
+   GET_CURRENT_CONTEXT(ctx);
+   if (index == 0 && _mesa_attr_zero_aliases_vertex(ctx))
+  ATTR1UIV64(0, v);
+   else if (index < MAX_VERTEX_GENERIC_ATTRIBS)
+  ATTR1UIV64(VBO_ATTRIB_GENERIC0 + index, v);
+   else
+  ERROR(GL_INVALID_VALUE);
 }
 
 #undef ATTR1FV
diff --git a/src/mesa/vbo/vbo_context.h b/src/mesa/vbo/vbo_context.h
index 5cf399ffcd..a54258455f 100644
--- a/src/mesa/vbo/vbo_context.h
+++ b/src/mesa/vbo/vbo_context.h
@@ -156,6 +156,7 @@ vbo_attrtype_to_integer_flag(GLenum format)
   return GL_FALSE;
case GL_INT:
case GL_UNSIGNED_INT:
+   case GL_UNSIGNED_INT64_ARB:
   return GL_TRUE;
default:
   assert(0);
@@ -170,6 +171,7 @@ 

Re: [Mesa-dev] [RFC PATCH 00/65] ARB_bindless_texture for RadeonSI

2017-05-19 Thread Ilia Mirkin
Great work, Samuel! Is this available in a branch somewhere?

On Fri, May 19, 2017 at 12:52 PM, Samuel Pitoiset
 wrote:
> Hi,
>
> This series implements ARB_bindless_texture for RadeonSI.
>
> Reminder: the GLSL compiler part is already upstream.
>
> This series has been mainly tested with Feral games, here's the list of
> existing games that use ARB_bindless_texture (though not by default):
>
> - DXMD
> - Hitman
> - Dirt Rally
> - Mad Max
>
> Today, Feral announced "Warhammer 40,000: Dawn of War III" (called DOW3) which
> is going to be released next month. This game *requires* ARB_bindless_texture,
> that now explains why I did all this work. :-) So, we have ~3 weeks for 
> merging
> this whole series. It would be very nice to have DOW3 support at day one!
>
> === Tracking bindless problems ===
>
> The following games have been successfully tested:
>
> - Dirt Rally
> - Hitman
> - Mad Max
> - DOW3
>
> For these:
>
> - No rendering issues
> - No VM faults (ie. amdgpu.vm_debug=1)
>
> However, DXMD is currently broken because the bindless_sampler layout 
> qualifier
> is missing, which ends up by reporting a ton of INVALID_OPERATION errors. Note
> that Feral implemented bindless support against NV_bindless_texture and not
> ARB_bindless_texture. The main difference is that bindless_sampler is implicit
> for NV_* while it's required for ARB_*. Feral plan to fix this soon.
>
> All ARB_bindless_texture piglit tests pass with this series.
>
> === Tracking regressions/changes ===
>
> - No regressions with the Intel CI system
> - One piglit regression that needs to be fixed
>   (arb_texture_multisample-sample-position)
> - No shader-db changes
> - No CPU overhead (glxgears and Heaven in low)
>
> === Performance results for DOW3 ===
>
> DOW3 exposes two bindless texture modes:
> - mode 1: all bindless (ie. no bound samplers)
> - mode 2: bound/bindless (ie. only bindless when the limit is reached)
>
> CPU: Intel(R) Core(TM) i5-4460  CPU @ 3.20GHz
> NVIDIA blob: 381.22
>
> == GTX 1060 ==
>
> LOW:
>  - mode 1: 89 FPS
>  - mode 2: 51 FPS
>
> MEDIUM:
>  - mode 1: 49 FPS
>  - mode 2: 28 FPS
>
> HIGH:
>  - mode 1: 32 FPS
>  - mode 2: 19 FPS
>
> The GTX 1060 performs very well with the all bindless mode (default), while
> the bound/bindless mode is not good at all.
>
> == RX480 ==
>
> LOW:
>  - mode 1: 67 FPS (-32%)
>  - mode 2: 75 FPS (+32%)
>
> MEDIUM:
>  - mode 1: 38 FPS (-28%)
>  - mode 2: 44 FPS (+57%)
>
> HIGH:
>  - mode 1: 26 FPS (-23%)
>  - mode 2: 29 FPS (+52%)
>
> The RX 480 performs very well with the bound/bindless mode (default), while
> the all bindless mode still has to be improved.
>
> The most important bottleneck with the all bindless mode is the number of
> buffers that have to be added for every command stream. The overhead in the
> winsys and in the kernel (amdgpu_cs_ioctl) becomes important in this 
> situation.
> This mode is still clearly CPU bound and should be improved (see the "Future
> work" section).
>
> Btw, without any optimisations, it was around 35FPS in low (mode 1).
>
> === Performance results for other Feral titles ===
>
> I didn't record any numbers because these games have been initially
> developed/tested against the NVIDIA blob which it's unaffected by a VERY huge
> number of resident handles. While the AMD stack is really slow in this
> situation. Though, as I said, all Feral games that use bindless work fine, we
> just need to improve perf on both sides.
>
> === Future work ===
>
> I have some ideas to try in order to improve performance with RadeonSI. I will
> work on this once this series is upstream.
>
> Please review,
> Thanks!
>
> Samuel Pitoiset (65):
>   mapi: add GL_ARB_bindless_texture entry points
>   mesa: implement ARB_bindless_texture
>   mesa: add support for unsigned 64-bit vertex attributes
>   mesa: add support for glUniformHandleui64*ARB()
>   mesa: refuse to update sampler parameters when a handle is allocated
>   mesa: refuse to update tex parameters when a handle is allocated
>   mesa: refuse to change textures when a handle is allocated
>   mesa: refuse to change tex buffers when a handle is allocated
>   mesa: keep track of the current variable in add_uniform_to_shader
>   mesa: store bindless samplers as PROGRAM_UNIFORM
>   mesa: add infrastructure for bindless samplers/images bound to units
>   glsl: process uniform samplers declared bindless
>   glsl: process uniform images declared bindless
>   glsl: pass the ir_variable object to set_opaque_binding()
>   glsl: set the explicit binding value for bindless samplers/images
>   glsl: add ir_variable::is_bindless()
>   mesa: add update_single_shader_texture_used() helper
>   mesa: add update_single_program_texture_state() helper
>   mesa: update textures for bindless samplers bound to texture units
>   mesa: pass gl_program to _mesa_associate_uniform_storage()
>   mesa: associate uniform storage to bindless samplers/images
>   mesa: handle bindless uniforms bound to texture/image 

[Mesa-dev] [PATCH 1/3] radeonsi: move building llvm.SI.load.const into ac_build_buffer_load

2017-05-19 Thread Marek Olšák
From: Marek Olšák 

---
 src/amd/common/ac_llvm_build.c   | 50 
 src/amd/common/ac_llvm_build.h   |  3 +-
 src/amd/common/ac_nir_to_llvm.c  |  2 +-
 src/gallium/drivers/radeonsi/si_shader.c | 23 +++
 4 files changed, 51 insertions(+), 27 deletions(-)

diff --git a/src/amd/common/ac_llvm_build.c b/src/amd/common/ac_llvm_build.c
index 87a1fb7..4b048ba 100644
--- a/src/amd/common/ac_llvm_build.c
+++ b/src/amd/common/ac_llvm_build.c
@@ -626,47 +626,73 @@ ac_build_buffer_store_dword(struct ac_llvm_context *ctx,
 LLVMValueRef
 ac_build_buffer_load(struct ac_llvm_context *ctx,
 LLVMValueRef rsrc,
 int num_channels,
 LLVMValueRef vindex,
 LLVMValueRef voffset,
 LLVMValueRef soffset,
 unsigned inst_offset,
 unsigned glc,
 unsigned slc,
-bool readonly_memory)
+bool readonly_memory,
+bool coherent)
 {
+   LLVMValueRef offset = LLVMConstInt(ctx->i32, inst_offset, 0);
+   if (voffset)
+   offset = LLVMBuildAdd(ctx->builder, offset, voffset, "");
+   if (soffset)
+   offset = LLVMBuildAdd(ctx->builder, offset, soffset, "");
+
+   /* Loads from a shader buffer that has no stores in the same shader
+* and is non-coherent with other shader invocations can use SMEM.
+*/
+   if (readonly_memory && !coherent) {
+   assert(vindex == NULL);
+   assert(glc == 0);
+   assert(slc == 0);
+
+   LLVMValueRef result[4];
+
+   for (int i = 0; i < num_channels; i++) {
+   if (i) {
+   offset = LLVMBuildAdd(ctx->builder, offset,
+ LLVMConstInt(ctx->i32, 4, 
0), "");
+   }
+   LLVMValueRef args[2] = {rsrc, offset};
+   result[i] = ac_build_intrinsic(ctx, 
"llvm.SI.load.const.v4i32",
+  ctx->f32, args, 2,
+  AC_FUNC_ATTR_READNONE |
+  AC_FUNC_ATTR_LEGACY);
+   }
+   if (num_channels == 1)
+   return result[0];
+
+   if (num_channels == 3)
+   result[num_channels++] = LLVMGetUndef(ctx->f32);
+   return ac_build_gather_values(ctx, result, num_channels);
+   }
+
unsigned func = CLAMP(num_channels, 1, 3) - 1;
 
LLVMValueRef args[] = {
LLVMBuildBitCast(ctx->builder, rsrc, ctx->v4i32, ""),
vindex ? vindex : LLVMConstInt(ctx->i32, 0, 0),
-   LLVMConstInt(ctx->i32, inst_offset, 0),
+   offset,
LLVMConstInt(ctx->i1, glc, 0),
LLVMConstInt(ctx->i1, slc, 0)
};
 
LLVMTypeRef types[] = {ctx->f32, LLVMVectorType(ctx->f32, 2),
   ctx->v4f32};
const char *type_names[] = {"f32", "v2f32", "v4f32"};
char name[256];
 
-   if (voffset) {
-   args[2] = LLVMBuildAdd(ctx->builder, args[2], voffset,
-   "");
-   }
-
-   if (soffset) {
-   args[2] = LLVMBuildAdd(ctx->builder, args[2], soffset,
-   "");
-   }
-
snprintf(name, sizeof(name), "llvm.amdgcn.buffer.load.%s",
 type_names[func]);
 
return ac_build_intrinsic(ctx, name, types[func], args,
  ARRAY_SIZE(args),
  /* READNONE means writes can't affect it, 
while
   * READONLY means that writes can affect it. 
*/
  readonly_memory && HAVE_LLVM >= 0x0400 ?
  AC_FUNC_ATTR_READNONE :
  AC_FUNC_ATTR_READONLY);
diff --git a/src/amd/common/ac_llvm_build.h b/src/amd/common/ac_llvm_build.h
index 0ecbc4a..754461b 100644
--- a/src/amd/common/ac_llvm_build.h
+++ b/src/amd/common/ac_llvm_build.h
@@ -136,21 +136,22 @@ ac_build_buffer_store_dword(struct ac_llvm_context *ctx,
 LLVMValueRef
 ac_build_buffer_load(struct ac_llvm_context *ctx,
 LLVMValueRef rsrc,
 int num_channels,
 LLVMValueRef vindex,
 LLVMValueRef voffset,
 LLVMValueRef soffset,
 unsigned inst_offset,
 unsigned glc,
 unsigned slc,
-bool readonly_memory);
+bool readonly_memory,
+bool coherent);
 
 LLVMValueRef 

[Mesa-dev] [PATCH 2/3] radeonsi: use ac_build_buffer_load for shader buffer loads

2017-05-19 Thread Marek Olšák
From: Marek Olšák 

---
 src/gallium/drivers/radeonsi/si_shader_tgsi_mem.c | 30 ++-
 1 file changed, 7 insertions(+), 23 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_shader_tgsi_mem.c 
b/src/gallium/drivers/radeonsi/si_shader_tgsi_mem.c
index bd8ecb7..c5b94b9 100644
--- a/src/gallium/drivers/radeonsi/si_shader_tgsi_mem.c
+++ b/src/gallium/drivers/radeonsi/si_shader_tgsi_mem.c
@@ -407,46 +407,30 @@ static unsigned get_store_intr_attribs(bool 
writeonly_memory)
return writeonly_memory && HAVE_LLVM >= 0x0400 ?
  LP_FUNC_ATTR_INACCESSIBLE_MEM_ONLY :
  LP_FUNC_ATTR_WRITEONLY;
 }
 
 static void load_emit_buffer(struct si_shader_context *ctx,
 struct lp_build_emit_data *emit_data,
 bool readonly_memory)
 {
const struct tgsi_full_instruction *inst = emit_data->inst;
-   struct gallivm_state *gallivm = >gallivm;
-   LLVMBuilderRef builder = gallivm->builder;
uint writemask = inst->Dst[0].Register.WriteMask;
uint count = util_last_bit(writemask);
-   const char *intrinsic_name;
-   LLVMTypeRef dst_type;
-
-   switch (count) {
-   case 1:
-   intrinsic_name = "llvm.amdgcn.buffer.load.f32";
-   dst_type = ctx->f32;
-   break;
-   case 2:
-   intrinsic_name = "llvm.amdgcn.buffer.load.v2f32";
-   dst_type = LLVMVectorType(ctx->f32, 2);
-   break;
-   default: // 3 & 4
-   intrinsic_name = "llvm.amdgcn.buffer.load.v4f32";
-   dst_type = ctx->v4f32;
-   count = 4;
-   }
+   LLVMValueRef *args = emit_data->args;
 
-   emit_data->output[emit_data->chan] = lp_build_intrinsic(
-   builder, intrinsic_name, dst_type,
-   emit_data->args, emit_data->arg_count,
-   get_load_intr_attribs(readonly_memory));
+   emit_data->output[emit_data->chan] =
+   ac_build_buffer_load(>ac, args[0], count, args[1],
+args[2], NULL, 0,
+LLVMConstIntGetZExtValue(args[3]),
+LLVMConstIntGetZExtValue(args[4]),
+readonly_memory, true);
 }
 
 static LLVMValueRef get_memory_ptr(struct si_shader_context *ctx,
const struct tgsi_full_instruction *inst,
LLVMTypeRef type, int arg)
 {
struct gallivm_state *gallivm = >gallivm;
LLVMBuilderRef builder = gallivm->builder;
LLVMValueRef offset, ptr;
int addr_space;
-- 
2.7.4

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


[Mesa-dev] [PATCH 3/4] i965: Use correct vs and gs size for gen6_upload_urb.

2017-05-19 Thread Rafael Antognolli
The documentation for SNB says that it expects a value [0,4] = [1,5], but we
don't really check whether the parameters are actually >= 1.

Additionally, on blorp we are calling gen6_upload_urb(gs_size = 0), which
causes it to be sent as -1, and that shouldn't be valid, but seems to be just
ignored. This patch fixes that before we convert the urb state emission to
genxml.

Signed-off-by: Rafael Antognolli 
---
 src/mesa/drivers/dri/i965/gen6_urb.c| 4 ++--
 src/mesa/drivers/dri/i965/genX_blorp_exec.c | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/gen6_urb.c 
b/src/mesa/drivers/dri/i965/gen6_urb.c
index e69a1df..8938035 100644
--- a/src/mesa/drivers/dri/i965/gen6_urb.c
+++ b/src/mesa/drivers/dri/i965/gen6_urb.c
@@ -78,8 +78,8 @@ gen6_upload_urb(struct brw_context *brw, unsigned vs_size,
   devinfo->urb.min_entries[MESA_SHADER_VERTEX]);
assert(brw->urb.nr_vs_entries % 4 == 0);
assert(brw->urb.nr_gs_entries % 4 == 0);
-   assert(vs_size <= 5);
-   assert(gs_size <= 5);
+   assert(vs_size >= 1 && vs_size <= 5);
+   assert(gs_size >= 1 && gs_size <= 5);
 
BEGIN_BATCH(3);
OUT_BATCH(_3DSTATE_URB << 16 | (3 - 2));
diff --git a/src/mesa/drivers/dri/i965/genX_blorp_exec.c 
b/src/mesa/drivers/dri/i965/genX_blorp_exec.c
index 7157420..5ee5435 100644
--- a/src/mesa/drivers/dri/i965/genX_blorp_exec.c
+++ b/src/mesa/drivers/dri/i965/genX_blorp_exec.c
@@ -169,7 +169,7 @@ blorp_emit_urb_config(struct blorp_batch *batch, unsigned 
vs_entry_size)
 
gen7_upload_urb(brw, vs_entry_size, false, false);
 #else
-   gen6_upload_urb(brw, vs_entry_size, false, 0);
+   gen6_upload_urb(brw, vs_entry_size, false, 1);
 #endif
 }
 
-- 
2.9.3

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


[Mesa-dev] [PATCH 2/4] genxml: Increase the field length by 1 bit.

2017-05-19 Thread Rafael Antognolli
VS, HS, DS and GS URB Starting Address field on the respective
3DSTATE_URB_?S instructions is 5 bits on gen7. However, if VS is the
only step enabled, the whole URB gets allocated (except for push
constant space) for the VS. But on some configurations, the size of the
URB is 32 "chunks" (8kB each chunk), so the starting address for all the
other shaders would be 32. But the field does not allow that (5 bits
means the max value is 31), and if we are using genxml, it will enforce
that we don't go over this size.

Unfortunately, the current code makes use of 6 bits (bits 30:25 and bit
31), by setting that to 32, so the 1 bit that is said on the
documentation to be MBZ is actually set to 1. But it works fine with
that.

I tried setting that address field to 0 when those shaders are not
active, while keeping the MBZ bit (31) at zero too, but that causes GPU
hangs. So my guess here is that the documentation is wrong and that this
field is actually 6 bits long, instead of 5.

Additionally, the same happens on Haswell, with these fields being 7
bits long instead of 6.

Signed-off-by: Rafael Antognolli 
---
 src/intel/genxml/gen7.xml  | 20 
 src/intel/genxml/gen75.xml | 20 
 2 files changed, 32 insertions(+), 8 deletions(-)

diff --git a/src/intel/genxml/gen7.xml b/src/intel/genxml/gen7.xml
index c98327a..ed5d593 100644
--- a/src/intel/genxml/gen7.xml
+++ b/src/intel/genxml/gen7.xml
@@ -1748,7 +1748,10 @@
 
 
 
-
+
+
 
 
   
@@ -1759,7 +1762,10 @@
 
 
 
-
+
+
 
 
   
@@ -1770,7 +1776,10 @@
 
 
 
-
+
+
 
 
   
@@ -1781,7 +1790,10 @@
 
 
 
-
+
+
 
 
   
diff --git a/src/intel/genxml/gen75.xml b/src/intel/genxml/gen75.xml
index 11f1462..36f0a0b 100644
--- a/src/intel/genxml/gen75.xml
+++ b/src/intel/genxml/gen75.xml
@@ -2061,7 +2061,10 @@
 
 
 
-
+
+
 
 
   
@@ -2072,8 +2075,11 @@
 
 
 
-
+
 
+
 
   
 
@@ -2083,7 +2089,10 @@
 
 
 
-
+
+
 
 
   
@@ -2094,7 +2103,10 @@
 
 
 
-
+
+
 
 
   
-- 
2.9.3

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


[Mesa-dev] [PATCH 4/4] i965: Move urb state emitting code to genxml.

2017-05-19 Thread Rafael Antognolli
Both gen6 and gen7+ were moved into the same function, but the code is
still quite split.

In order to make both functions have the same signature, I moved the
logic from upload_urb on gen6 that sets gs_size to vs_size into
genX(upload_urb), so we don't have to pass gs_size to that function
anymore.

Signed-off-by: Rafael Antognolli 
---
 src/mesa/drivers/dri/i965/brw_context.h   |  10 +-
 src/mesa/drivers/dri/i965/brw_state.h |   2 -
 src/mesa/drivers/dri/i965/gen6_urb.c  | 152 -
 src/mesa/drivers/dri/i965/gen7_urb.c  |  92 -
 src/mesa/drivers/dri/i965/genX_blorp_exec.c   |   6 +-
 src/mesa/drivers/dri/i965/genX_state_upload.c | 181 +-
 6 files changed, 184 insertions(+), 259 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_context.h 
b/src/mesa/drivers/dri/i965/brw_context.h
index 1f61e5f..505068a 100644
--- a/src/mesa/drivers/dri/i965/brw_context.h
+++ b/src/mesa/drivers/dri/i965/brw_context.h
@@ -1551,13 +1551,6 @@ gen7_emit_push_constant_state(struct brw_context *brw, 
unsigned vs_size,
   unsigned hs_size, unsigned ds_size,
   unsigned gs_size, unsigned fs_size);
 
-void
-gen6_upload_urb(struct brw_context *brw, unsigned vs_size,
-bool gs_present, unsigned gs_size);
-void
-gen7_upload_urb(struct brw_context *brw, unsigned vs_size,
-bool gs_present, bool tess_present);
-
 #define GENX_DECL(_ret, _name, ...)\
_ret gen4_##_name(__VA_ARGS__); \
_ret gen45_##_name(__VA_ARGS__);\
@@ -1569,6 +1562,9 @@ gen7_upload_urb(struct brw_context *brw, unsigned vs_size,
_ret gen9_##_name(__VA_ARGS__); \
typedef _ret (* _name ## _ptr)(__VA_ARGS__);
 
+GENX_DECL(void, upload_urb, struct brw_context *brw, unsigned vs_size,
+  bool gs_present, bool tess_present);
+
 /* brw_reset.c */
 extern GLenum
 brw_get_graphics_reset_status(struct gl_context *ctx);
diff --git a/src/mesa/drivers/dri/i965/brw_state.h 
b/src/mesa/drivers/dri/i965/brw_state.h
index 954969c..de0fa0b 100644
--- a/src/mesa/drivers/dri/i965/brw_state.h
+++ b/src/mesa/drivers/dri/i965/brw_state.h
@@ -106,11 +106,9 @@ extern const struct brw_tracked_state 
gen6_renderbuffer_surfaces;
 extern const struct brw_tracked_state gen6_sampler_state;
 extern const struct brw_tracked_state gen6_sol_surface;
 extern const struct brw_tracked_state gen6_sf_vp;
-extern const struct brw_tracked_state gen6_urb;
 extern const struct brw_tracked_state gen7_depthbuffer;
 extern const struct brw_tracked_state gen7_l3_state;
 extern const struct brw_tracked_state gen7_push_constant_space;
-extern const struct brw_tracked_state gen7_urb;
 extern const struct brw_tracked_state gen8_pma_fix;
 extern const struct brw_tracked_state brw_cs_work_groups_surface;
 
diff --git a/src/mesa/drivers/dri/i965/gen6_urb.c 
b/src/mesa/drivers/dri/i965/gen6_urb.c
index 8938035..e69de29 100644
--- a/src/mesa/drivers/dri/i965/gen6_urb.c
+++ b/src/mesa/drivers/dri/i965/gen6_urb.c
@@ -1,152 +0,0 @@
-/*
- * Copyright © 2009 Intel Corporation
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
- * IN THE SOFTWARE.
- *
- * Authors:
- *Eric Anholt 
- *
- */
-
-#include "main/macros.h"
-#include "intel_batchbuffer.h"
-#include "brw_context.h"
-#include "brw_state.h"
-#include "brw_defines.h"
-
-/**
- * When the GS is not in use, we assign the entire URB space to the VS.  When
- * the GS is in use, we split the URB space evenly between the VS and the GS.
- * This is not ideal, but it's simple.
- *
- *   URB size / 2   URB size / 2
- *   _-__   _-__
- *  /\ /\
- * +-+
- * | Vertex Shader 

[Mesa-dev] [PATCH 1/4] genxml: Add macros for exporting genxml functions.

2017-05-19 Thread Rafael Antognolli
The GENX_DECL() macro is used to declare prototypes of a given function
to each gen, so we don't have to manually add each of them to headers.

The second macro, genX_find(), is used to call the right function for
the running gen, but from code that is not gen specific.

Signed-off-by: Rafael Antognolli 
---
 src/mesa/drivers/dri/i965/brw_context.h | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/src/mesa/drivers/dri/i965/brw_context.h 
b/src/mesa/drivers/dri/i965/brw_context.h
index 6b37500..1f61e5f 100644
--- a/src/mesa/drivers/dri/i965/brw_context.h
+++ b/src/mesa/drivers/dri/i965/brw_context.h
@@ -1558,6 +1558,17 @@ void
 gen7_upload_urb(struct brw_context *brw, unsigned vs_size,
 bool gs_present, bool tess_present);
 
+#define GENX_DECL(_ret, _name, ...)\
+   _ret gen4_##_name(__VA_ARGS__); \
+   _ret gen45_##_name(__VA_ARGS__);\
+   _ret gen5_##_name(__VA_ARGS__); \
+   _ret gen6_##_name(__VA_ARGS__); \
+   _ret gen7_##_name(__VA_ARGS__); \
+   _ret gen75_##_name(__VA_ARGS__);\
+   _ret gen8_##_name(__VA_ARGS__); \
+   _ret gen9_##_name(__VA_ARGS__); \
+   typedef _ret (* _name ## _ptr)(__VA_ARGS__);
+
 /* brw_reset.c */
 extern GLenum
 brw_get_graphics_reset_status(struct gl_context *ctx);
-- 
2.9.3

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


[Mesa-dev] [RFC PATCH 49/65] radeonsi: add si_init_descriptor_list() helper

2017-05-19 Thread Samuel Pitoiset
This will be used in order to initialize resident descriptors
for bindless textures/images.

Signed-off-by: Samuel Pitoiset 
---
 src/gallium/drivers/radeonsi/si_descriptors.c | 15 +++
 1 file changed, 15 insertions(+)

diff --git a/src/gallium/drivers/radeonsi/si_descriptors.c 
b/src/gallium/drivers/radeonsi/si_descriptors.c
index d337fc3f11..b2fe6a3de7 100644
--- a/src/gallium/drivers/radeonsi/si_descriptors.c
+++ b/src/gallium/drivers/radeonsi/si_descriptors.c
@@ -95,6 +95,21 @@ static uint32_t null_image_descriptor[8] = {
 * descriptor */
 };
 
+static void si_init_descriptor_list(uint32_t *desc_list,
+   unsigned element_dw_size,
+   unsigned num_elements,
+   const uint32_t *null_descriptor)
+{
+   int i;
+
+   /* Initialize the array to NULL descriptors if the element size is 8. */
+   if (null_descriptor) {
+   assert(element_dw_size % 8 == 0);
+   for (i = 0; i < num_elements * element_dw_size / 8; i++)
+   memcpy(desc_list + i * 8, null_descriptor, 8 * 4);
+   }
+}
+
 static void si_init_descriptors(struct si_context *sctx,
struct si_descriptors *desc,
unsigned shader_userdata_index,
-- 
2.13.0

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


[Mesa-dev] [RFC PATCH 24/65] gallium: add PIPE_CAP_BINDLESS_TEXTURE

2017-05-19 Thread Samuel Pitoiset
Whether bindless texture operations are supported by the
underlying driver.

Signed-off-by: Samuel Pitoiset 
---
 src/gallium/docs/source/screen.rst   | 2 ++
 src/gallium/drivers/etnaviv/etnaviv_screen.c | 1 +
 src/gallium/drivers/freedreno/freedreno_screen.c | 1 +
 src/gallium/drivers/i915/i915_screen.c   | 1 +
 src/gallium/drivers/llvmpipe/lp_screen.c | 1 +
 src/gallium/drivers/nouveau/nv30/nv30_screen.c   | 1 +
 src/gallium/drivers/nouveau/nv50/nv50_screen.c   | 1 +
 src/gallium/drivers/nouveau/nvc0/nvc0_screen.c   | 1 +
 src/gallium/drivers/r300/r300_screen.c   | 1 +
 src/gallium/drivers/r600/r600_pipe.c | 1 +
 src/gallium/drivers/radeonsi/si_pipe.c   | 1 +
 src/gallium/drivers/softpipe/sp_screen.c | 1 +
 src/gallium/drivers/svga/svga_screen.c   | 1 +
 src/gallium/drivers/swr/swr_screen.cpp   | 1 +
 src/gallium/drivers/vc4/vc4_screen.c | 1 +
 src/gallium/drivers/virgl/virgl_screen.c | 1 +
 src/gallium/include/pipe/p_defines.h | 1 +
 17 files changed, 18 insertions(+)

diff --git a/src/gallium/docs/source/screen.rst 
b/src/gallium/docs/source/screen.rst
index 871669c0d9..fa524d419c 100644
--- a/src/gallium/docs/source/screen.rst
+++ b/src/gallium/docs/source/screen.rst
@@ -392,6 +392,8 @@ The integer capabilities:
 * ``PIPE_CAP_CAN_BIND_CONST_BUFFER_AS_VERTEX``: Whether a buffer with just
   PIPE_BIND_CONSTANT_BUFFER can be legally passed to set_vertex_buffers.
 * ``PIPE_CAP_ALLOW_MAPPED_BUFFERS_DURING_EXECUTION``: As the name says.
+* ``PIPE_CAP_BINDLESS_TEXTURE``: Whether bindless texture operations are
+  supported.
 
 
 .. _pipe_capf:
diff --git a/src/gallium/drivers/etnaviv/etnaviv_screen.c 
b/src/gallium/drivers/etnaviv/etnaviv_screen.c
index bf13184ad6..5d10f76815 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_screen.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_screen.c
@@ -256,6 +256,7 @@ etna_screen_get_param(struct pipe_screen *pscreen, enum 
pipe_cap param)
case PIPE_CAP_TGSI_TES_LAYER_VIEWPORT:
case PIPE_CAP_CAN_BIND_CONST_BUFFER_AS_VERTEX:
case PIPE_CAP_ALLOW_MAPPED_BUFFERS_DURING_EXECUTION:
+   case PIPE_CAP_BINDLESS_TEXTURE:
   return 0;
 
/* Stream output. */
diff --git a/src/gallium/drivers/freedreno/freedreno_screen.c 
b/src/gallium/drivers/freedreno/freedreno_screen.c
index a00afd3fa4..eb3ac61d6c 100644
--- a/src/gallium/drivers/freedreno/freedreno_screen.c
+++ b/src/gallium/drivers/freedreno/freedreno_screen.c
@@ -315,6 +315,7 @@ fd_screen_get_param(struct pipe_screen *pscreen, enum 
pipe_cap param)
case PIPE_CAP_TGSI_TES_LAYER_VIEWPORT:
case PIPE_CAP_CAN_BIND_CONST_BUFFER_AS_VERTEX:
case PIPE_CAP_ALLOW_MAPPED_BUFFERS_DURING_EXECUTION:
+   case PIPE_CAP_BINDLESS_TEXTURE:
return 0;
 
case PIPE_CAP_MAX_VIEWPORTS:
diff --git a/src/gallium/drivers/i915/i915_screen.c 
b/src/gallium/drivers/i915/i915_screen.c
index 1cf9441ef1..3ee59ab9fb 100644
--- a/src/gallium/drivers/i915/i915_screen.c
+++ b/src/gallium/drivers/i915/i915_screen.c
@@ -308,6 +308,7 @@ i915_get_param(struct pipe_screen *screen, enum pipe_cap 
cap)
case PIPE_CAP_TGSI_TES_LAYER_VIEWPORT:
case PIPE_CAP_CAN_BIND_CONST_BUFFER_AS_VERTEX:
case PIPE_CAP_ALLOW_MAPPED_BUFFERS_DURING_EXECUTION:
+   case PIPE_CAP_BINDLESS_TEXTURE:
   return 0;
 
case PIPE_CAP_MAX_VIEWPORTS:
diff --git a/src/gallium/drivers/llvmpipe/lp_screen.c 
b/src/gallium/drivers/llvmpipe/lp_screen.c
index 656de49549..de954c44c0 100644
--- a/src/gallium/drivers/llvmpipe/lp_screen.c
+++ b/src/gallium/drivers/llvmpipe/lp_screen.c
@@ -354,6 +354,7 @@ llvmpipe_get_param(struct pipe_screen *screen, enum 
pipe_cap param)
case PIPE_CAP_TGSI_TES_LAYER_VIEWPORT:
case PIPE_CAP_CAN_BIND_CONST_BUFFER_AS_VERTEX:
case PIPE_CAP_ALLOW_MAPPED_BUFFERS_DURING_EXECUTION:
+   case PIPE_CAP_BINDLESS_TEXTURE:
   return 0;
}
/* should only get here on unhandled cases */
diff --git a/src/gallium/drivers/nouveau/nv30/nv30_screen.c 
b/src/gallium/drivers/nouveau/nv30/nv30_screen.c
index e8d14bfea4..58c4f42f13 100644
--- a/src/gallium/drivers/nouveau/nv30/nv30_screen.c
+++ b/src/gallium/drivers/nouveau/nv30/nv30_screen.c
@@ -218,6 +218,7 @@ nv30_screen_get_param(struct pipe_screen *pscreen, enum 
pipe_cap param)
case PIPE_CAP_TGSI_BALLOT:
case PIPE_CAP_TGSI_TES_LAYER_VIEWPORT:
case PIPE_CAP_CAN_BIND_CONST_BUFFER_AS_VERTEX:
+   case PIPE_CAP_BINDLESS_TEXTURE:
   return 0;
 
case PIPE_CAP_VENDOR_ID:
diff --git a/src/gallium/drivers/nouveau/nv50/nv50_screen.c 
b/src/gallium/drivers/nouveau/nv50/nv50_screen.c
index 59afd14fac..e0b959cc4c 100644
--- a/src/gallium/drivers/nouveau/nv50/nv50_screen.c
+++ b/src/gallium/drivers/nouveau/nv50/nv50_screen.c
@@ -270,6 +270,7 @@ nv50_screen_get_param(struct pipe_screen *pscreen, enum 
pipe_cap param)
case PIPE_CAP_SPARSE_BUFFER_PAGE_SIZE:
case PIPE_CAP_TGSI_BALLOT:
case 

[Mesa-dev] [RFC PATCH 28/65] tc: add ARB_bindless_texture support

2017-05-19 Thread Samuel Pitoiset
Signed-off-by: Samuel Pitoiset 
---
 src/gallium/auxiliary/util/u_threaded_context.c| 147 +
 .../auxiliary/util/u_threaded_context_calls.h  |   4 +
 2 files changed, 151 insertions(+)

diff --git a/src/gallium/auxiliary/util/u_threaded_context.c 
b/src/gallium/auxiliary/util/u_threaded_context.c
index 8ea7f8aa26..36c2e4ed46 100644
--- a/src/gallium/auxiliary/util/u_threaded_context.c
+++ b/src/gallium/auxiliary/util/u_threaded_context.c
@@ -1086,6 +1086,147 @@ tc_stream_output_target_destroy(struct pipe_context 
*_pipe,
 
 
 /
+ * bindless
+ */
+
+static uint64_t
+tc_create_texture_handle(struct pipe_context *_pipe,
+ struct pipe_resource *res,
+ struct pipe_sampler_view *view,
+ const struct pipe_sampler_state *state)
+{
+   struct threaded_context *tc = threaded_context(_pipe);
+   struct pipe_context *pipe = tc->pipe;
+
+   tc_sync(tc);
+   return pipe->create_texture_handle(pipe, res, view, state);
+}
+
+struct tc_delete_texture_handle
+{
+   uint64_t handle;
+};
+
+static void
+tc_call_delete_texture_handle(struct pipe_context *pipe,
+  union tc_payload *payload)
+{
+   struct tc_delete_texture_handle *p =
+  (struct tc_delete_texture_handle *)payload;
+
+   pipe->delete_texture_handle(pipe, p->handle);
+}
+
+static void
+tc_delete_texture_handle(struct pipe_context *_pipe, uint64_t handle)
+{
+   struct threaded_context *tc = threaded_context(_pipe);
+   struct tc_delete_texture_handle *p =
+  tc_add_struct_typed_call(tc, TC_CALL_delete_texture_handle,
+   tc_delete_texture_handle);
+
+   p->handle = handle;
+}
+
+struct tc_make_texture_handle_resident
+{
+   uint64_t handle;
+   bool resident;
+};
+
+static void
+tc_call_make_texture_handle_resident(struct pipe_context *pipe,
+ union tc_payload *payload)
+{
+   struct tc_make_texture_handle_resident *p =
+  (struct tc_make_texture_handle_resident *)payload;
+
+   pipe->make_texture_handle_resident(pipe, p->handle, p->resident);
+}
+
+static void
+tc_make_texture_handle_resident(struct pipe_context *_pipe, uint64_t handle,
+bool resident)
+{
+   struct threaded_context *tc = threaded_context(_pipe);
+   struct tc_make_texture_handle_resident *p =
+  tc_add_struct_typed_call(tc, TC_CALL_make_texture_handle_resident,
+   tc_make_texture_handle_resident);
+
+   p->handle = handle;
+   p->resident = resident;
+}
+
+static uint64_t
+tc_create_image_handle(struct pipe_context *_pipe,
+   const struct pipe_image_view *image)
+{
+   struct threaded_context *tc = threaded_context(_pipe);
+   struct pipe_context *pipe = tc->pipe;
+
+   tc_sync(tc);
+   return pipe->create_image_handle(pipe, image);
+}
+
+struct tc_delete_image_handle
+{
+   uint64_t handle;
+};
+
+static void
+tc_call_delete_image_handle(struct pipe_context *pipe,
+union tc_payload *payload)
+{
+   struct tc_delete_image_handle *p =
+  (struct tc_delete_image_handle *)payload;
+
+   pipe->delete_image_handle(pipe, p->handle);
+}
+
+static void
+tc_delete_image_handle(struct pipe_context *_pipe, uint64_t handle)
+{
+   struct threaded_context *tc = threaded_context(_pipe);
+   struct tc_delete_image_handle *p =
+  tc_add_struct_typed_call(tc, TC_CALL_delete_image_handle,
+   tc_delete_image_handle);
+
+   p->handle = handle;
+}
+
+struct tc_make_image_handle_resident
+{
+   uint64_t handle;
+   unsigned access;
+   bool resident;
+};
+
+static void
+tc_call_make_image_handle_resident(struct pipe_context *pipe,
+ union tc_payload *payload)
+{
+   struct tc_make_image_handle_resident *p =
+  (struct tc_make_image_handle_resident *)payload;
+
+   pipe->make_image_handle_resident(pipe, p->handle, p->access, p->resident);
+}
+
+static void
+tc_make_image_handle_resident(struct pipe_context *_pipe, uint64_t handle,
+  unsigned access, bool resident)
+{
+   struct threaded_context *tc = threaded_context(_pipe);
+   struct tc_make_image_handle_resident *p =
+  tc_add_struct_typed_call(tc, TC_CALL_make_image_handle_resident,
+   tc_make_image_handle_resident);
+
+   p->handle = handle;
+   p->access = access;
+   p->resident = resident;
+}
+
+
+/
  * transfer
  */
 
@@ -2311,6 +2452,12 @@ threaded_context_create(struct pipe_context *pipe,
CTX_INIT(create_fence_fd);
CTX_INIT(fence_server_sync);
CTX_INIT(get_timestamp);
+   CTX_INIT(create_texture_handle);
+   CTX_INIT(delete_texture_handle);
+   CTX_INIT(make_texture_handle_resident);
+   CTX_INIT(create_image_handle);
+   

[Mesa-dev] [RFC PATCH 20/65] mesa: pass gl_program to _mesa_associate_uniform_storage()

2017-05-19 Thread Samuel Pitoiset
Signed-off-by: Samuel Pitoiset 
---
 src/mesa/program/ir_to_mesa.cpp| 7 ---
 src/mesa/program/ir_to_mesa.h  | 4 ++--
 src/mesa/state_tracker/st_glsl_to_nir.cpp  | 3 +--
 src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 3 +--
 src/mesa/state_tracker/st_shader_cache.c   | 3 +--
 5 files changed, 9 insertions(+), 11 deletions(-)

diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp
index 8ed249f8ca..5e6304036d 100644
--- a/src/mesa/program/ir_to_mesa.cpp
+++ b/src/mesa/program/ir_to_mesa.cpp
@@ -2537,9 +2537,11 @@ _mesa_generate_parameters_list_for_uniforms(struct 
gl_shader_program
 void
 _mesa_associate_uniform_storage(struct gl_context *ctx,
 struct gl_shader_program *shader_program,
-struct gl_program_parameter_list *params,
+struct gl_program *prog,
 bool propagate_to_storage)
 {
+   struct gl_program_parameter_list *params = prog->Parameters;
+
/* After adding each uniform to the parameter list, connect the storage for
 * the parameter with the tracking structure used by the API for the
 * uniform.
@@ -2987,8 +2989,7 @@ get_mesa_program(struct gl_context *ctx,
 * prog->ParameterValues to get reallocated (e.g., anything that adds a
 * program constant) has to happen before creating this linkage.
 */
-   _mesa_associate_uniform_storage(ctx, shader_program, prog->Parameters,
-   true);
+   _mesa_associate_uniform_storage(ctx, shader_program, prog, true);
if (!shader_program->data->LinkStatus) {
   goto fail_exit;
}
diff --git a/src/mesa/program/ir_to_mesa.h b/src/mesa/program/ir_to_mesa.h
index 09446197b2..e3d364455c 100644
--- a/src/mesa/program/ir_to_mesa.h
+++ b/src/mesa/program/ir_to_mesa.h
@@ -45,8 +45,8 @@ _mesa_generate_parameters_list_for_uniforms(struct 
gl_shader_program
*params);
 void
 _mesa_associate_uniform_storage(struct gl_context *ctx,
-   struct gl_shader_program *shader_program,
-struct gl_program_parameter_list *params,
+struct gl_shader_program *shader_program,
+struct gl_program *prog,
 bool propagate_to_storage);
 
 #ifdef __cplusplus
diff --git a/src/mesa/state_tracker/st_glsl_to_nir.cpp 
b/src/mesa/state_tracker/st_glsl_to_nir.cpp
index fd5eeea0f9..524eefa236 100644
--- a/src/mesa/state_tracker/st_glsl_to_nir.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_nir.cpp
@@ -436,8 +436,7 @@ st_nir_get_mesa_program(struct gl_context *ctx,
 * prog->ParameterValues to get reallocated (e.g., anything that adds a
 * program constant) has to happen before creating this linkage.
 */
-   _mesa_associate_uniform_storage(ctx, shader_program, prog->Parameters,
-   true);
+   _mesa_associate_uniform_storage(ctx, shader_program, prog, true);
 
struct st_vertex_program *stvp;
struct st_fragment_program *stfp;
diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp 
b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index 76cd4dc3a5..7571e7d495 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -6805,8 +6805,7 @@ get_mesa_program_tgsi(struct gl_context *ctx,
 * prog->ParameterValues to get reallocated (e.g., anything that adds a
 * program constant) has to happen before creating this linkage.
 */
-   _mesa_associate_uniform_storage(ctx, shader_program, prog->Parameters,
-   true);
+   _mesa_associate_uniform_storage(ctx, shader_program, prog, true);
if (!shader_program->data->LinkStatus) {
   free_glsl_to_tgsi_visitor(v);
   _mesa_reference_program(ctx, >Program, NULL);
diff --git a/src/mesa/state_tracker/st_shader_cache.c 
b/src/mesa/state_tracker/st_shader_cache.c
index 23416c0c3f..068b4e20bb 100644
--- a/src/mesa/state_tracker/st_shader_cache.c
+++ b/src/mesa/state_tracker/st_shader_cache.c
@@ -360,8 +360,7 @@ st_load_tgsi_from_disk_cache(struct gl_context *ctx,
  }
 
  st_set_prog_affected_state_flags(glprog);
- _mesa_associate_uniform_storage(ctx, prog, glprog->Parameters,
- false);
+ _mesa_associate_uniform_storage(ctx, prog, glprog, false);
 
  free(buffer);
   } else {
-- 
2.13.0

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


[Mesa-dev] [RFC PATCH 33/65] st/glsl_to_tgsi: add support for bindless images

2017-05-19 Thread Samuel Pitoiset
Signed-off-by: Samuel Pitoiset 
---
 src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 78 --
 1 file changed, 63 insertions(+), 15 deletions(-)

diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp 
b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index 5734d0e456..264b43c10b 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -288,7 +288,7 @@ public:
 
st_dst_reg dst[2];
st_src_reg src[4];
-   st_src_reg resource; /**< sampler or buffer register */
+   st_src_reg resource; /**< sampler, image or buffer register */
st_src_reg *tex_offsets;
 
/** Pointer to the ir source this tree came from for debugging */
@@ -3765,15 +3765,46 @@ glsl_to_tgsi_visitor::visit_image_intrinsic(ir_call *ir)
exec_node *param = ir->actual_parameters.get_head();
 
ir_dereference *img = (ir_dereference *)param;
-   const ir_variable *imgvar = img->variable_referenced();
-   const glsl_type *type = imgvar->type->without_array();
+   const struct glsl_struct_field *struct_field = NULL;
unsigned sampler_array_size = 1, sampler_base = 0;
+   unsigned memory_coherent, memory_volatile, memory_restrict, image_format;
+   const ir_variable *imgvar;
+   const glsl_type *type;
+
+   if (img->ir_type == ir_type_dereference_record) {
+  ir_dereference_record *r = img->as_dereference_record();
+  const glsl_type *struct_type = r->record->type;
+
+  for (unsigned i = 0; i < struct_type->length; i++) {
+ if (!strcmp(struct_type->fields.structure[i].name, r->field)) {
+struct_field = _type->fields.structure[i];
+break;
+ }
+  }
+  assert(struct_field);
+   }
+
+   imgvar = img->variable_referenced();
+
+   if (struct_field) {
+  type = struct_field->type;
+  memory_coherent = struct_field->memory_coherent;
+  memory_volatile = struct_field->memory_volatile;
+  memory_restrict = struct_field->memory_restrict;
+  image_format = struct_field->image_format;
+   } else {
+  type = imgvar->type->without_array();
+  memory_coherent = imgvar->data.memory_coherent;
+  memory_volatile = imgvar->data.memory_volatile;
+  memory_restrict = imgvar->data.memory_restrict;
+  image_format = imgvar->data.image_format;
+   }
 
st_src_reg reladdr;
st_src_reg image(PROGRAM_IMAGE, 0, GLSL_TYPE_UINT);
 
get_deref_offsets(img, _array_size, _base,
- (uint16_t*), , true);
+ (uint16_t*), , 
!imgvar->is_bindless());
 
if (reladdr.file != PROGRAM_UNDEFINED) {
   image.reladdr = ralloc(mem_ctx, st_src_reg);
@@ -3886,19 +3917,27 @@ glsl_to_tgsi_visitor::visit_image_intrinsic(ir_call *ir)
  inst->dst[0].writemask = WRITEMASK_XYZW;
}
 
-   inst->resource = image;
-   inst->sampler_array_size = sampler_array_size;
-   inst->sampler_base = sampler_base;
+   if (imgvar->is_bindless()) {
+  img->accept(this);
+  inst->resource = this->result;
+  inst->resource.swizzle = MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_Y,
+ SWIZZLE_X, SWIZZLE_Y);
+  inst->bindless = 1;
+   } else {
+  inst->resource = image;
+  inst->sampler_array_size = sampler_array_size;
+  inst->sampler_base = sampler_base;
+   }
 
inst->tex_target = type->sampler_index();
inst->image_format = st_mesa_format_to_pipe_format(st_context(ctx),
- _mesa_get_shader_image_format(imgvar->data.image_format));
+ _mesa_get_shader_image_format(image_format));
 
-   if (imgvar->data.memory_coherent)
+   if (memory_coherent)
   inst->buffer_access |= TGSI_MEMORY_COHERENT;
-   if (imgvar->data.memory_restrict)
+   if (memory_restrict)
   inst->buffer_access |= TGSI_MEMORY_RESTRICT;
-   if (imgvar->data.memory_volatile)
+   if (memory_volatile)
   inst->buffer_access |= TGSI_MEMORY_VOLATILE;
 }
 
@@ -5911,7 +5950,12 @@ compile_tgsi_instruction(struct st_translate *t,
   } else if (inst->resource.file == PROGRAM_BUFFER) {
  src[0] = t->buffers[inst->resource.index];
   } else {
- src[0] = t->images[inst->resource.index];
+ if (inst->resource.file == PROGRAM_IMAGE) {
+src[0] = t->images[inst->resource.index];
+ } else {
+/* Bindless images. */
+src[0] = translate_src(t, >resource);
+ }
  tex_target = st_translate_texture_target(inst->tex_target, 
inst->tex_shadow);
   }
   if (inst->resource.reladdr)
@@ -5919,7 +5963,7 @@ compile_tgsi_instruction(struct st_translate *t,
   assert(src[0].File != TGSI_FILE_NULL);
   ureg_memory_insn(ureg, inst->op, dst, num_dst, src, num_src,
inst->buffer_access,
-   tex_target, inst->image_format, 0);
+   tex_target, inst->image_format, inst->bindless);
   break;
 
case TGSI_OPCODE_STORE:
@@ -5928,7 +5972,11 @@ 

[Mesa-dev] [RFC PATCH 32/65] st/glsl_to_tgsi: add support for bindless samplers

2017-05-19 Thread Samuel Pitoiset
Signed-off-by: Samuel Pitoiset 
---
 src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 27 +--
 1 file changed, 21 insertions(+), 6 deletions(-)

diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp 
b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index ef6597e083..5734d0e456 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -306,6 +306,7 @@ public:
unsigned tex_offset_num_offset:3;
unsigned dead_mask:4; /**< Used in dead code elimination */
unsigned buffer_access:3; /**< buffer access type */
+   unsigned bindless:1; /**< bindless sampler/image */
 
const struct tgsi_opcode_info *info;
 };
@@ -4154,6 +4155,7 @@ glsl_to_tgsi_visitor::visit(ir_texture *ir)
const glsl_type *sampler_type = ir->sampler->type;
unsigned sampler_array_size = 1, sampler_base = 0;
bool is_cube_array = false, is_cube_shadow = false;
+   ir_variable *var = ir->sampler->variable_referenced();
unsigned i;
 
/* if we are a cube array sampler or a cube shadow */
@@ -4386,7 +4388,7 @@ glsl_to_tgsi_visitor::visit(ir_texture *ir)
st_src_reg sampler(PROGRAM_SAMPLER, 0, GLSL_TYPE_UINT);
 
get_deref_offsets(ir->sampler, _array_size, _base,
- (uint16_t *), , true);
+ (uint16_t *), , 
!var->is_bindless());
 
if (reladdr.file != PROGRAM_UNDEFINED) {
   sampler.reladdr = ralloc(mem_ctx, st_src_reg);
@@ -4423,9 +4425,17 @@ glsl_to_tgsi_visitor::visit(ir_texture *ir)
if (ir->shadow_comparator)
   inst->tex_shadow = GL_TRUE;
 
-   inst->resource = sampler;
-   inst->sampler_array_size = sampler_array_size;
-   inst->sampler_base = sampler_base;
+   if (var->is_bindless()) {
+  ir->sampler->accept(this);
+  inst->resource = this->result;
+  inst->resource.swizzle = MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_Y,
+ SWIZZLE_X, SWIZZLE_Y);
+  inst->bindless = 1;
+   } else {
+  inst->resource = sampler;
+  inst->sampler_array_size = sampler_array_size;
+  inst->sampler_base = sampler_base;
+   }
 
if (ir->offset) {
   if (!inst->tex_offsets)
@@ -5856,7 +5866,12 @@ compile_tgsi_instruction(struct st_translate *t,
case TGSI_OPCODE_TXL2:
case TGSI_OPCODE_TG4:
case TGSI_OPCODE_LODQ:
-  src[num_src] = t->samplers[inst->resource.index];
+  if (inst->resource.file == PROGRAM_SAMPLER) {
+ src[num_src] = t->samplers[inst->resource.index];
+  } else {
+ /* Bindless samplers. */
+ src[num_src] = translate_src(t, >resource);
+  }
   assert(src[num_src].File != TGSI_FILE_NULL);
   if (inst->resource.reladdr)
  src[num_src] =
@@ -5873,7 +5888,7 @@ compile_tgsi_instruction(struct st_translate *t,
 tex_target,
 st_translate_texture_type(inst->tex_type),
 texoffsets, inst->tex_offset_num_offset,
-src, num_src, 0);
+src, num_src, inst->bindless);
   return;
 
case TGSI_OPCODE_RESQ:
-- 
2.13.0

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


[Mesa-dev] [RFC PATCH 22/65] mesa: handle bindless uniforms bound to texture/image units

2017-05-19 Thread Samuel Pitoiset
Signed-off-by: Samuel Pitoiset 
---
 src/mesa/main/uniform_query.cpp | 122 ++--
 1 file changed, 116 insertions(+), 6 deletions(-)

diff --git a/src/mesa/main/uniform_query.cpp b/src/mesa/main/uniform_query.cpp
index cc145f29e9..be04e48d53 100644
--- a/src/mesa/main/uniform_query.cpp
+++ b/src/mesa/main/uniform_query.cpp
@@ -993,9 +993,25 @@ _mesa_uniform(GLint location, GLsizei count, const GLvoid 
*values,
  bool changed = false;
  for (int j = 0; j < count; j++) {
 unsigned unit = uni->opaque[i].index + offset + j;
-if (sh->Program->SamplerUnits[unit] != ((unsigned *) values)[j]) {
-   sh->Program->SamplerUnits[unit] = ((unsigned *) values)[j];
-   changed = true;
+unsigned value = ((unsigned *)values)[j];
+
+if (uni->is_bindless) {
+   struct gl_bindless_sampler *sampler =
+  >Program->sh.BindlessSamplers[unit];
+
+   /* Mark this bindless sampler as bound to a texture unit.
+*/
+   if (sampler->unit != value) {
+  sampler->unit = value;
+  changed = true;
+   }
+   sampler->bound = true;
+   sh->Program->sh.HasBoundBindlessSampler = true;
+} else {
+   if (sh->Program->SamplerUnits[unit] != value) {
+  sh->Program->SamplerUnits[unit] = value;
+  changed = true;
+   }
 }
  }
 
@@ -1024,9 +1040,23 @@ _mesa_uniform(GLint location, GLsizei count, const 
GLvoid *values,
  if (!uni->opaque[i].active)
 continue;
 
- for (int j = 0; j < count; j++)
-sh->Program->sh.ImageUnits[uni->opaque[i].index + offset + j] =
-   ((GLint *) values)[j];
+ for (int j = 0; j < count; j++) {
+unsigned unit = uni->opaque[i].index + offset + j;
+unsigned value = ((unsigned *)values)[j];
+
+if (uni->is_bindless) {
+   struct gl_bindless_image *image =
+  >Program->sh.BindlessImages[unit];
+
+   /* Mark this bindless image as bound to an image unit.
+*/
+   image->unit = value;
+   image->bound = true;
+   sh->Program->sh.HasBoundBindlessImage = true;
+} else {
+   sh->Program->sh.ImageUnits[unit] = value;
+}
+ }
   }
 
   ctx->NewDriverState |= ctx->DriverFlags.NewImageUnits;
@@ -1173,6 +1203,40 @@ _mesa_uniform_matrix(GLint location, GLsizei count,
_mesa_propagate_uniforms_to_driver_storage(uni, offset, count);
 }
 
+static void
+update_bound_bindless_sampler_flag(struct gl_program *prog)
+{
+   unsigned i;
+
+   if (likely(!prog->sh.HasBoundBindlessSampler))
+  return;
+
+   for (i = 0; i < prog->sh.NumBindlessSamplers; i++) {
+  struct gl_bindless_sampler *sampler = >sh.BindlessSamplers[i];
+
+  if (sampler->bound)
+ return;
+   }
+   prog->sh.HasBoundBindlessSampler = false;
+}
+
+static void
+update_bound_bindless_image_flag(struct gl_program *prog)
+{
+   unsigned i;
+
+   if (likely(!prog->sh.HasBoundBindlessImage))
+  return;
+
+   for (i = 0; i < prog->sh.NumBindlessImages; i++) {
+  struct gl_bindless_image *image = >sh.BindlessImages[i];
+
+  if (image->bound)
+ return;
+   }
+   prog->sh.HasBoundBindlessImage = false;
+}
+
 /**
  * Called via glUniformHandleui64*ARB() functions.
  */
@@ -1236,6 +1300,52 @@ _mesa_uniform_handle(GLint location, GLsizei count, 
const GLvoid *values,
   sizeof(uni->storage[0]) * components * count * size_mul);
 
_mesa_propagate_uniforms_to_driver_storage(uni, offset, count);
+
+   if (uni->type->is_sampler()) {
+  /* Mark this bindless sampler as not bound to a texture unit because
+   * it refers to a texture handle.
+   */
+  for (int i = 0; i < MESA_SHADER_STAGES; i++) {
+ struct gl_linked_shader *const sh = shProg->_LinkedShaders[i];
+
+ /* If the shader stage doesn't use the sampler uniform, skip this. */
+ if (!uni->opaque[i].active)
+continue;
+
+ for (int j = 0; j < count; j++) {
+unsigned unit = uni->opaque[i].index + offset + j;
+struct gl_bindless_sampler *sampler =
+   >Program->sh.BindlessSamplers[unit];
+
+sampler->bound = false;
+ }
+
+ update_bound_bindless_sampler_flag(sh->Program);
+  }
+   }
+
+   if (uni->type->is_image()) {
+  /* Mark this bindless image as not bound to an image unit because it
+   * refers to a texture handle.
+   */
+  for (int i = 0; i < MESA_SHADER_STAGES; i++) {
+ struct gl_linked_shader *sh = shProg->_LinkedShaders[i];
+
+ /* If the shader stage doesn't use the sampler uniform, skip this. */
+ if (!uni->opaque[i].active)

[Mesa-dev] [RFC PATCH 26/65] ddebug: add ARB_bindless_texture support

2017-05-19 Thread Samuel Pitoiset
Signed-off-by: Samuel Pitoiset 
---
 src/gallium/drivers/ddebug/dd_context.c | 61 +
 1 file changed, 61 insertions(+)

diff --git a/src/gallium/drivers/ddebug/dd_context.c 
b/src/gallium/drivers/ddebug/dd_context.c
index 8260d4f869..8a07411c46 100644
--- a/src/gallium/drivers/ddebug/dd_context.c
+++ b/src/gallium/drivers/ddebug/dd_context.c
@@ -764,6 +764,61 @@ dd_context_dump_debug_state(struct pipe_context *_pipe, 
FILE *stream,
return pipe->dump_debug_state(pipe, stream, flags);
 }
 
+static uint64_t
+dd_context_create_texture_handle(struct pipe_context *_pipe,
+ struct pipe_resource *res,
+ struct pipe_sampler_view *view,
+ const struct pipe_sampler_state *state)
+{
+   struct pipe_context *pipe = dd_context(_pipe)->pipe;
+
+   return pipe->create_texture_handle(pipe, res, view, state);
+}
+
+static void
+dd_context_delete_texture_handle(struct pipe_context *_pipe, uint64_t handle)
+{
+   struct pipe_context *pipe = dd_context(_pipe)->pipe;
+
+   pipe->delete_texture_handle(pipe, handle);
+}
+
+static void
+dd_context_make_texture_handle_resident(struct pipe_context *_pipe,
+uint64_t handle, bool resident)
+{
+   struct pipe_context *pipe = dd_context(_pipe)->pipe;
+
+   pipe->make_texture_handle_resident(pipe, handle, resident);
+}
+
+static uint64_t
+dd_context_create_image_handle(struct pipe_context *_pipe,
+   const struct pipe_image_view *image)
+{
+   struct pipe_context *pipe = dd_context(_pipe)->pipe;
+
+   return pipe->create_image_handle(pipe, image);
+}
+
+static void
+dd_context_delete_image_handle(struct pipe_context *_pipe, uint64_t handle)
+{
+   struct pipe_context *pipe = dd_context(_pipe)->pipe;
+
+   pipe->delete_image_handle(pipe, handle);
+}
+
+static void
+dd_context_make_image_handle_resident(struct pipe_context *_pipe,
+  uint64_t handle, unsigned access,
+  bool resident)
+{
+   struct pipe_context *pipe = dd_context(_pipe)->pipe;
+
+   pipe->make_image_handle_resident(pipe, handle, access, resident);
+}
+
 struct pipe_context *
 dd_context_create(struct dd_screen *dscreen, struct pipe_context *pipe)
 {
@@ -866,6 +921,12 @@ dd_context_create(struct dd_screen *dscreen, struct 
pipe_context *pipe)
CTX_INIT(set_device_reset_callback);
CTX_INIT(dump_debug_state);
CTX_INIT(emit_string_marker);
+   CTX_INIT(create_texture_handle);
+   CTX_INIT(delete_texture_handle);
+   CTX_INIT(make_texture_handle_resident);
+   CTX_INIT(create_image_handle);
+   CTX_INIT(delete_image_handle);
+   CTX_INIT(make_image_handle_resident);
 
dd_init_draw_functions(dctx);
 
-- 
2.13.0

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


[Mesa-dev] [RFC PATCH 10/65] mesa: store bindless samplers as PROGRAM_UNIFORM

2017-05-19 Thread Samuel Pitoiset
Old-style samplers (ie. bound samplers) are stored as
PROGRAM_SAMPLER, while bindless ones are PROGRAM_UNIFORM.

Signed-off-by: Samuel Pitoiset 
---
 src/mesa/program/ir_to_mesa.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp
index a1a788e9e8..8ed249f8ca 100644
--- a/src/mesa/program/ir_to_mesa.cpp
+++ b/src/mesa/program/ir_to_mesa.cpp
@@ -2462,7 +2462,7 @@ add_uniform_to_shader::visit_field(const glsl_type *type, 
const char *name,
}
 
gl_register_file file;
-   if (type->without_array()->is_sampler()) {
+   if (type->without_array()->is_sampler() && !var->data.bindless) {
   file = PROGRAM_SAMPLER;
} else {
   file = PROGRAM_UNIFORM;
-- 
2.13.0

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


[Mesa-dev] [RFC PATCH 17/65] mesa: add update_single_shader_texture_used() helper

2017-05-19 Thread Samuel Pitoiset
This will also be used for looping over bindless samplers bound
to texture units.

Signed-off-by: Samuel Pitoiset 
---
 src/mesa/main/uniforms.c | 67 +++-
 1 file changed, 38 insertions(+), 29 deletions(-)

diff --git a/src/mesa/main/uniforms.c b/src/mesa/main/uniforms.c
index 67c238e4f3..6706f794d7 100644
--- a/src/mesa/main/uniforms.c
+++ b/src/mesa/main/uniforms.c
@@ -63,6 +63,40 @@
  * TEXTURE_2D_INDEX, TEXTURE_3D_INDEX, etc.
  * We'll use that info for state validation before rendering.
  */
+static inline void
+update_single_shader_texture_used(struct gl_shader_program *shProg,
+  struct gl_program *prog,
+  GLuint unit, GLuint target)
+{
+   gl_shader_stage prog_stage =
+  _mesa_program_enum_to_shader_stage(prog->Target);
+
+   assert(unit < ARRAY_SIZE(prog->TexturesUsed));
+   assert(target < NUM_TEXTURE_TARGETS);
+
+   /* From section 7.10 (Samplers) of the OpenGL 4.5 spec:
+*
+* "It is not allowed to have variables of different sampler types pointing
+*  to the same texture image unit within a program object."
+*/
+   unsigned stages_mask = shProg->data->linked_stages;
+   while (stages_mask) {
+  const int stage = u_bit_scan(_mask);
+
+  /* Skip validation if we are yet to update textures used in this
+   * stage.
+   */
+  if (prog_stage < stage)
+ break;
+
+  struct gl_program *glprog = shProg->_LinkedShaders[stage]->Program;
+  if (glprog->TexturesUsed[unit] & ~(1 << target))
+ shProg->SamplersValidated = GL_FALSE;
+   }
+
+   prog->TexturesUsed[unit] |= (1 << target);
+}
+
 void
 _mesa_update_shader_textures_used(struct gl_shader_program *shProg,
   struct gl_program *prog)
@@ -78,35 +112,10 @@ _mesa_update_shader_textures_used(struct gl_shader_program 
*shProg,
 
while (mask) {
   const int s = u_bit_scan();
-  GLuint unit = prog->SamplerUnits[s];
-  GLuint tgt = prog->sh.SamplerTargets[s];
-  assert(unit < ARRAY_SIZE(prog->TexturesUsed));
-  assert(tgt < NUM_TEXTURE_TARGETS);
-
-  /* The types of the samplers associated with a particular texture
-   * unit must be an exact match.  Page 74 (page 89 of the PDF) of the
-   * OpenGL 3.3 core spec says:
-   *
-   * "It is not allowed to have variables of different sampler
-   * types pointing to the same texture image unit within a program
-   * object."
-   */
-  unsigned stages_mask = shProg->data->linked_stages;
-  while (stages_mask) {
- const int stage = u_bit_scan(_mask);
-
- /* Skip validation if we are yet to update textures used in this
-  * stage.
-  */
- if (prog_stage < stage)
-break;
-
- struct gl_program *glprog = shProg->_LinkedShaders[stage]->Program;
- if (glprog->TexturesUsed[unit] & ~(1 << tgt))
-shProg->SamplersValidated = GL_FALSE;
-  }
-
-  prog->TexturesUsed[unit] |= (1 << tgt);
+
+  update_single_shader_texture_used(shProg, prog,
+prog->SamplerUnits[s],
+prog->sh.SamplerTargets[s]);
}
 }
 
-- 
2.13.0

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


Re: [Mesa-dev] [RFC PATCH 00/65] ARB_bindless_texture for RadeonSI

2017-05-19 Thread Samuel Pitoiset



On 05/19/2017 07:05 PM, Ilia Mirkin wrote:

Great work, Samuel! Is this available in a branch somewhere?


Thanks Ilia!

Here's the branch:
https://cgit.freedesktop.org/~hakzsam/mesa/log/?h=arb_bindless_texture



On Fri, May 19, 2017 at 12:52 PM, Samuel Pitoiset
 wrote:

Hi,

This series implements ARB_bindless_texture for RadeonSI.

Reminder: the GLSL compiler part is already upstream.

This series has been mainly tested with Feral games, here's the list of
existing games that use ARB_bindless_texture (though not by default):

- DXMD
- Hitman
- Dirt Rally
- Mad Max

Today, Feral announced "Warhammer 40,000: Dawn of War III" (called DOW3) which
is going to be released next month. This game *requires* ARB_bindless_texture,
that now explains why I did all this work. :-) So, we have ~3 weeks for merging
this whole series. It would be very nice to have DOW3 support at day one!

=== Tracking bindless problems ===

The following games have been successfully tested:

- Dirt Rally
- Hitman
- Mad Max
- DOW3

For these:

- No rendering issues
- No VM faults (ie. amdgpu.vm_debug=1)

However, DXMD is currently broken because the bindless_sampler layout qualifier
is missing, which ends up by reporting a ton of INVALID_OPERATION errors. Note
that Feral implemented bindless support against NV_bindless_texture and not
ARB_bindless_texture. The main difference is that bindless_sampler is implicit
for NV_* while it's required for ARB_*. Feral plan to fix this soon.

All ARB_bindless_texture piglit tests pass with this series.

=== Tracking regressions/changes ===

- No regressions with the Intel CI system
- One piglit regression that needs to be fixed
   (arb_texture_multisample-sample-position)
- No shader-db changes
- No CPU overhead (glxgears and Heaven in low)

=== Performance results for DOW3 ===

DOW3 exposes two bindless texture modes:
- mode 1: all bindless (ie. no bound samplers)
- mode 2: bound/bindless (ie. only bindless when the limit is reached)

CPU: Intel(R) Core(TM) i5-4460  CPU @ 3.20GHz
NVIDIA blob: 381.22

== GTX 1060 ==

LOW:
  - mode 1: 89 FPS
  - mode 2: 51 FPS

MEDIUM:
  - mode 1: 49 FPS
  - mode 2: 28 FPS

HIGH:
  - mode 1: 32 FPS
  - mode 2: 19 FPS

The GTX 1060 performs very well with the all bindless mode (default), while
the bound/bindless mode is not good at all.

== RX480 ==

LOW:
  - mode 1: 67 FPS (-32%)
  - mode 2: 75 FPS (+32%)

MEDIUM:
  - mode 1: 38 FPS (-28%)
  - mode 2: 44 FPS (+57%)

HIGH:
  - mode 1: 26 FPS (-23%)
  - mode 2: 29 FPS (+52%)

The RX 480 performs very well with the bound/bindless mode (default), while
the all bindless mode still has to be improved.

The most important bottleneck with the all bindless mode is the number of
buffers that have to be added for every command stream. The overhead in the
winsys and in the kernel (amdgpu_cs_ioctl) becomes important in this situation.
This mode is still clearly CPU bound and should be improved (see the "Future
work" section).

Btw, without any optimisations, it was around 35FPS in low (mode 1).

=== Performance results for other Feral titles ===

I didn't record any numbers because these games have been initially
developed/tested against the NVIDIA blob which it's unaffected by a VERY huge
number of resident handles. While the AMD stack is really slow in this
situation. Though, as I said, all Feral games that use bindless work fine, we
just need to improve perf on both sides.

=== Future work ===

I have some ideas to try in order to improve performance with RadeonSI. I will
work on this once this series is upstream.

Please review,
Thanks!

Samuel Pitoiset (65):
   mapi: add GL_ARB_bindless_texture entry points
   mesa: implement ARB_bindless_texture
   mesa: add support for unsigned 64-bit vertex attributes
   mesa: add support for glUniformHandleui64*ARB()
   mesa: refuse to update sampler parameters when a handle is allocated
   mesa: refuse to update tex parameters when a handle is allocated
   mesa: refuse to change textures when a handle is allocated
   mesa: refuse to change tex buffers when a handle is allocated
   mesa: keep track of the current variable in add_uniform_to_shader
   mesa: store bindless samplers as PROGRAM_UNIFORM
   mesa: add infrastructure for bindless samplers/images bound to units
   glsl: process uniform samplers declared bindless
   glsl: process uniform images declared bindless
   glsl: pass the ir_variable object to set_opaque_binding()
   glsl: set the explicit binding value for bindless samplers/images
   glsl: add ir_variable::is_bindless()
   mesa: add update_single_shader_texture_used() helper
   mesa: add update_single_program_texture_state() helper
   mesa: update textures for bindless samplers bound to texture units
   mesa: pass gl_program to _mesa_associate_uniform_storage()
   mesa: associate uniform storage to bindless samplers/images
   mesa: handle bindless uniforms bound to texture/image units
   mesa: get rid of a workaround for bindless in 

Re: [Mesa-dev] Bug in 17.1.0-rc4 source packaging for swr?

2017-05-19 Thread Emil Velikov
On 19 May 2017 at 13:11, Chuck Atkins  wrote:
> Would it be feasible for packaging purposes to generate multiple headers,
> i.e. gen_builder._llvm38.hpp, gen_builder_llvm39.hpp,
> gen_builder_llvm40.hpp, etc. and then have gen_builder.hpp be a stub that
> just has something like:
>
> #include 
> #if llvm_version >= 4.0
> #include "gen_builder_llvm40.hpp"
> #elif llvm_version >= 3.9
> #include "gen_builder_llvm39.hpp"
> #elif llvm_version >= 3.8
> #include "gen_builder_llvm38.hpp"
> #else
> #error llvm version >= 3.8 is required
> #elif
>
Idea sounds ok, but has a few drawbacks:
 - creating all the files at the same time would be quite picky/hard
 - shipping only one file solves the issue only for some people

The original idea by Tim sounds OK imho and I'm actually giving it a try.

FWIW the diff between 3.9 and 4.0 seems quite trivial - see below.
It should be possible to update the python scripts to handle most/all of those.
Perhaps we can have this as a long term solution?

-Emil

@@ -86,6 +86,11 @@
return IRB()->CreateLifetimeEnd(Ptr, Size);
}

+CallInst* INVARIANT_START(Value *Ptr, ConstantInt *Size = nullptr)
+{
+return IRB()->CreateInvariantStart(Ptr, Size);
+}
+
CallInst* MASKED_LOAD(Value *Ptr, unsigned Align, Value *Mask, Value
*PassThru = nullptr, const Twine  = "")
{
return IRB()->CreateMaskedLoad(Ptr, Align, Mask, PassThru, Name);
@@ -176,6 +181,11 @@
return IRB()->CreateCondBr(Cond, True, False, BranchWeights, Unpredictable);
}

+BranchInst* COND_BR(Value *Cond, BasicBlock *True, BasicBlock *False,
Instruction *MDSrc)
+{
+return IRB()->CreateCondBr(Cond, True, False, MDSrc);
+}
+
SwitchInst* SWITCH(Value *V, BasicBlock *Dest, unsigned NumCases = 10,
MDNode *BranchWeights = nullptr, MDNode *Unpredictable = nullptr)
{
return IRB()->CreateSwitch(V, Dest, NumCases, BranchWeights, Unpredictable);
@@ -866,7 +876,7 @@
return IRB()->CreateCall(Callee, Args, Name, FPMathTag);
}

-CallInst* CALLA(llvm::FunctionType *FTy, Value *Callee,
ArrayRef Args, const Twine  = "", MDNode *FPMathTag =
nullptr)
+CallInst* CALLA(FunctionType *FTy, Value *Callee, ArrayRef
Args, const Twine  = "", MDNode *FPMathTag = nullptr)
{
return IRB()->CreateCall(FTy, Callee, Args, Name, FPMathTag);
}
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 3/3] radeonsi: document why we can't use SMEM for shader buffer loads yet

2017-05-19 Thread Marek Olšák
From: Marek Olšák 

---
 src/gallium/drivers/radeonsi/si_shader_tgsi_mem.c | 22 --
 1 file changed, 20 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_shader_tgsi_mem.c 
b/src/gallium/drivers/radeonsi/si_shader_tgsi_mem.c
index c5b94b9..9519e0d 100644
--- a/src/gallium/drivers/radeonsi/si_shader_tgsi_mem.c
+++ b/src/gallium/drivers/radeonsi/si_shader_tgsi_mem.c
@@ -410,27 +410,45 @@ static unsigned get_store_intr_attribs(bool 
writeonly_memory)
 }
 
 static void load_emit_buffer(struct si_shader_context *ctx,
 struct lp_build_emit_data *emit_data,
 bool readonly_memory)
 {
const struct tgsi_full_instruction *inst = emit_data->inst;
uint writemask = inst->Dst[0].Register.WriteMask;
uint count = util_last_bit(writemask);
LLVMValueRef *args = emit_data->args;
+   bool coherent = (inst->Memory.Qualifier &
+(TGSI_MEMORY_COHERENT | TGSI_MEMORY_VOLATILE)) != 0;
 
+   /* Force the use of VMEM for shader buffer loads, because LLVM doesn't
+* select SMEM for SI.load.const with a non-constant offset, and
+* constant offsets practically don't exist with shader buffers.
+*
+* Also, SI.load.const doesn't use inst_offset when it's lowered
+* to VMEM, so we just end up with more VALU instructions in the end
+* and no benefit.
+*
+* TODO: Remove this line once LLVM can select SMEM with a non-constant
+*   offset, and can derive inst_offset when VMEM is selected.
+*   After that, si_memory_barrier should invalidate sL1 for shader
+*   buffers.
+*/
+   coherent = true;
+
+   assert(LLVMConstIntGetZExtValue(args[1]) == 0); /* vindex */
emit_data->output[emit_data->chan] =
-   ac_build_buffer_load(>ac, args[0], count, args[1],
+   ac_build_buffer_load(>ac, args[0], count, NULL,
 args[2], NULL, 0,
 LLVMConstIntGetZExtValue(args[3]),
 LLVMConstIntGetZExtValue(args[4]),
-readonly_memory, true);
+readonly_memory, coherent);
 }
 
 static LLVMValueRef get_memory_ptr(struct si_shader_context *ctx,
const struct tgsi_full_instruction *inst,
LLVMTypeRef type, int arg)
 {
struct gallivm_state *gallivm = >gallivm;
LLVMBuilderRef builder = gallivm->builder;
LLVMValueRef offset, ptr;
int addr_space;
-- 
2.7.4

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


Re: [Mesa-dev] Bug in 17.1.0-rc4 source packaging for swr?

2017-05-19 Thread Rowley, Timothy O

On May 19, 2017, at 10:26 AM, Emil Velikov 
> wrote:

On 19 May 2017 at 13:11, Chuck Atkins 
> wrote:
Would it be feasible for packaging purposes to generate multiple headers,
i.e. gen_builder._llvm38.hpp, gen_builder_llvm39.hpp,
gen_builder_llvm40.hpp, etc. and then have gen_builder.hpp be a stub that
just has something like:

#include 
#if llvm_version >= 4.0
#include "gen_builder_llvm40.hpp"
#elif llvm_version >= 3.9
#include "gen_builder_llvm39.hpp"
#elif llvm_version >= 3.8
#include "gen_builder_llvm38.hpp"
#else
#error llvm version >= 3.8 is required
#elif

Idea sounds ok, but has a few drawbacks:
- creating all the files at the same time would be quite picky/hard
- shipping only one file solves the issue only for some people

We need to figure out where to put the burden of keeping gen_builder up to date:
  - swr developers take care of updating new versions as needed
  - build system + release maintainer generates a lower common denominator 
version

The original idea by Tim sounds OK imho and I'm actually giving it a try.

Are you referring to using a llvm-3.9 generated version?  Did you envision me 
checking that in a gen_builder.h file, or removing the logic that omitted it 
from the tarball and somehow enforcing that a packaging build needs llvm-3.9?

FWIW the diff between 3.9 and 4.0 seems quite trivial - see below.
It should be possible to update the python scripts to handle most/all of those.
Perhaps we can have this as a long term solution?

At this point llvm seems to be stable in just having intrinsics being added; 
for a while there was some churn.  Unless/until the swr driver/rasterizer 
starts to take advantage of new llvm intrinsics, we should be fine using the 
3.9 version.

-Tim


-Emil

@@ -86,6 +86,11 @@
   return IRB()->CreateLifetimeEnd(Ptr, Size);
}

+CallInst* INVARIANT_START(Value *Ptr, ConstantInt *Size = nullptr)
+{
+return IRB()->CreateInvariantStart(Ptr, Size);
+}
+
CallInst* MASKED_LOAD(Value *Ptr, unsigned Align, Value *Mask, Value
*PassThru = nullptr, const Twine  = "")
{
   return IRB()->CreateMaskedLoad(Ptr, Align, Mask, PassThru, Name);
@@ -176,6 +181,11 @@
   return IRB()->CreateCondBr(Cond, True, False, BranchWeights, Unpredictable);
}

+BranchInst* COND_BR(Value *Cond, BasicBlock *True, BasicBlock *False,
Instruction *MDSrc)
+{
+return IRB()->CreateCondBr(Cond, True, False, MDSrc);
+}
+
SwitchInst* SWITCH(Value *V, BasicBlock *Dest, unsigned NumCases = 10,
MDNode *BranchWeights = nullptr, MDNode *Unpredictable = nullptr)
{
   return IRB()->CreateSwitch(V, Dest, NumCases, BranchWeights, Unpredictable);
@@ -866,7 +876,7 @@
   return IRB()->CreateCall(Callee, Args, Name, FPMathTag);
}

-CallInst* CALLA(llvm::FunctionType *FTy, Value *Callee,
ArrayRef Args, const Twine  = "", MDNode *FPMathTag =
nullptr)
+CallInst* CALLA(FunctionType *FTy, Value *Callee, ArrayRef
Args, const Twine  = "", MDNode *FPMathTag = nullptr)
{
   return IRB()->CreateCall(FTy, Callee, Args, Name, FPMathTag);
}

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


[Mesa-dev] [RFC PATCH 29/65] tgsi: add new Bindless flag to tgsi_instruction_texture

2017-05-19 Thread Samuel Pitoiset
Old-style images are identified using TGSI_FILE_SAMPLER, but
bindless samplers can be TGSI_FILE_CONSTANT or TGSI_FILE_TEMPORARY.

To avoid backend compilers to be confused, this adds a new flag
that will only be set for bindless samplers.

Signed-off-by: Samuel Pitoiset 
---
 src/gallium/auxiliary/tgsi/tgsi_build.c|  4 
 src/gallium/auxiliary/tgsi/tgsi_ureg.c |  9 ++---
 src/gallium/auxiliary/tgsi/tgsi_ureg.h | 10 ++
 src/gallium/include/pipe/p_shader_tokens.h |  3 ++-
 src/mesa/state_tracker/st_atifs_to_tgsi.c  |  2 +-
 src/mesa/state_tracker/st_glsl_to_tgsi.cpp |  2 +-
 src/mesa/state_tracker/st_mesa_to_tgsi.c   |  2 +-
 7 files changed, 21 insertions(+), 11 deletions(-)

diff --git a/src/gallium/auxiliary/tgsi/tgsi_build.c 
b/src/gallium/auxiliary/tgsi/tgsi_build.c
index 00843241f8..be1931e482 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_build.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_build.c
@@ -721,6 +721,7 @@ tgsi_default_instruction_texture( void )
instruction_texture.Texture = TGSI_TEXTURE_UNKNOWN;
instruction_texture.NumOffsets = 0;
instruction_texture.ReturnType = TGSI_RETURN_TYPE_UNKNOWN;
+   instruction_texture.Bindless = 0;
instruction_texture.Padding = 0;
 
return instruction_texture;
@@ -731,6 +732,7 @@ tgsi_build_instruction_texture(
unsigned texture,
unsigned num_offsets,
unsigned return_type,
+   unsigned bindless,
struct tgsi_token *prev_token,
struct tgsi_instruction *instruction,
struct tgsi_header *header )
@@ -740,6 +742,7 @@ tgsi_build_instruction_texture(
instruction_texture.Texture = texture;
instruction_texture.NumOffsets = num_offsets;
instruction_texture.ReturnType = return_type;
+   instruction_texture.Bindless = bindless;
instruction_texture.Padding = 0;
instruction->Texture = 1;
 
@@ -1095,6 +1098,7 @@ tgsi_build_full_instruction(
  full_inst->Texture.Texture,
  full_inst->Texture.NumOffsets,
  full_inst->Texture.ReturnType,
+ full_inst->Texture.Bindless,
  prev_token,
  instruction,
  header   );
diff --git a/src/gallium/auxiliary/tgsi/tgsi_ureg.c 
b/src/gallium/auxiliary/tgsi/tgsi_ureg.c
index 5bd779728a..8efa95f009 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_ureg.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_ureg.c
@@ -1289,7 +1289,8 @@ ureg_fixup_label(struct ureg_program *ureg,
 void
 ureg_emit_texture(struct ureg_program *ureg,
   unsigned extended_token,
-  unsigned target, unsigned return_type, unsigned num_offsets)
+  unsigned target, unsigned return_type, unsigned num_offsets,
+  unsigned bindless)
 {
union tgsi_any_token *out, *insn;
 
@@ -1302,6 +1303,7 @@ ureg_emit_texture(struct ureg_program *ureg,
out[0].insn_texture.Texture = target;
out[0].insn_texture.NumOffsets = num_offsets;
out[0].insn_texture.ReturnType = return_type;
+   out[0].insn_texture.Bindless = bindless;
 }
 
 void
@@ -1391,7 +1393,8 @@ ureg_tex_insn(struct ureg_program *ureg,
   const struct tgsi_texture_offset *texoffsets,
   unsigned nr_offset,
   const struct ureg_src *src,
-  unsigned nr_src )
+  unsigned nr_src,
+  unsigned bindless)
 {
struct ureg_emit_insn_result insn;
unsigned i;
@@ -1410,7 +1413,7 @@ ureg_tex_insn(struct ureg_program *ureg,
  nr_src);
 
ureg_emit_texture( ureg, insn.extended_token, target, return_type,
-  nr_offset );
+  nr_offset, bindless );
 
for (i = 0; i < nr_offset; i++)
   ureg_emit_texture_offset( ureg, [i]);
diff --git a/src/gallium/auxiliary/tgsi/tgsi_ureg.h 
b/src/gallium/auxiliary/tgsi/tgsi_ureg.h
index 54f95ba565..9e30a41ff7 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_ureg.h
+++ b/src/gallium/auxiliary/tgsi/tgsi_ureg.h
@@ -559,7 +559,8 @@ ureg_tex_insn(struct ureg_program *ureg,
   const struct tgsi_texture_offset *texoffsets,
   unsigned nr_offset,
   const struct ureg_src *src,
-  unsigned nr_src );
+  unsigned nr_src,
+  unsigned bindless);
 
 
 void
@@ -597,7 +598,8 @@ ureg_emit_label(struct ureg_program *ureg,
 void
 ureg_emit_texture(struct ureg_program *ureg,
   unsigned insn_token,
-  unsigned target, unsigned return_type, unsigned num_offsets);
+  unsigned target, unsigned return_type, unsigned num_offsets,
+  unsigned bindless);
 
 void
 ureg_emit_texture_offset(struct ureg_program *ureg,
@@ -759,7 +761,7 @@ static inline void ureg_##op( struct ureg_program *ureg,
\
  1, \
  2);\
ureg_emit_texture( ureg, insn.extended_token, target,\
-

[Mesa-dev] [RFC PATCH 52/65] radeonsi: implement ARB_bindless_texture

2017-05-19 Thread Samuel Pitoiset
This implements the Gallium interface. Decompression of resident
textures/images will follow in the next patches.

Signed-off-by: Samuel Pitoiset 
---
 src/gallium/drivers/radeonsi/si_descriptors.c | 340 ++
 src/gallium/drivers/radeonsi/si_pipe.c|  12 +
 src/gallium/drivers/radeonsi/si_pipe.h|  26 ++
 3 files changed, 378 insertions(+)

diff --git a/src/gallium/drivers/radeonsi/si_descriptors.c 
b/src/gallium/drivers/radeonsi/si_descriptors.c
index abe39de583..a687506f7f 100644
--- a/src/gallium/drivers/radeonsi/si_descriptors.c
+++ b/src/gallium/drivers/radeonsi/si_descriptors.c
@@ -60,6 +60,7 @@
 #include "sid.h"
 #include "gfx9d.h"
 
+#include "util/hash_table.h"
 #include "util/u_format.h"
 #include "util/u_memory.h"
 #include "util/u_upload_mgr.h"
@@ -2193,6 +2194,339 @@ void si_resident_descriptor_slab_free(void *priv, 
struct pb_slab *pslab)
FREE(slab);
 }
 
+static int si_add_resident_tex_handle(struct si_context *sctx,
+ struct si_texture_handle *tex_handle)
+{
+   int idx;
+
+   /* New resident handle, check if the backing array is large enough. */
+   if (sctx->num_resident_tex_handles >= sctx->max_resident_tex_handles) {
+   unsigned new_max_handles =
+   MAX2(1, sctx->max_resident_tex_handles * 2);
+   struct si_texture_handle **new_handles =
+   REALLOC(sctx->resident_tex_handles,
+   sctx->num_resident_tex_handles * 
(sizeof(*new_handles)),
+   new_max_handles * sizeof(*new_handles));
+
+   if (new_handles) {
+   sctx->resident_tex_handles = new_handles;
+   sctx->max_resident_tex_handles = new_max_handles;
+   } else {
+   fprintf(stderr, "si_add_resident_tex_handle: "
+   "allocation failed\n");
+   return -1;
+   }
+   }
+
+   idx = sctx->num_resident_tex_handles;
+   sctx->resident_tex_handles[idx] = tex_handle;
+   sctx->num_resident_tex_handles++;
+
+   return 0;
+}
+
+static void si_del_resident_tex_handle(struct si_context *sctx,
+  struct si_texture_handle *tex_handle)
+{
+   unsigned i;
+   int size;
+
+   for (i = 0; i < sctx->num_resident_tex_handles; i++) {
+   if (sctx->resident_tex_handles[i] != tex_handle)
+   continue;
+
+   if (i < sctx->num_resident_tex_handles - 1) {
+   size = sizeof(*sctx->resident_tex_handles) *
+   (sctx->num_resident_tex_handles - 1 - i);
+
+   memmove(>resident_tex_handles[i],
+   >resident_tex_handles[i + 1], size);
+   }
+
+   sctx->num_resident_tex_handles--;
+   return;
+   }
+}
+
+static int si_add_resident_img_handle(struct si_context *sctx,
+ struct si_image_handle *img_handle)
+{
+   int idx;
+
+   /* New resident handle, check if the backing array is large enough. */
+   if (sctx->num_resident_img_handles >= sctx->max_resident_img_handles) {
+   unsigned new_max_handles =
+   MAX2(1, sctx->max_resident_img_handles * 2);
+   struct si_image_handle **new_handles =
+   REALLOC(sctx->resident_img_handles,
+   sctx->num_resident_img_handles * 
(sizeof(*new_handles)),
+   new_max_handles * sizeof(*new_handles));
+
+   if (new_handles) {
+   sctx->resident_img_handles = new_handles;
+   sctx->max_resident_img_handles = new_max_handles;
+   } else {
+   fprintf(stderr, "si_add_resident_img_handle: "
+   "allocation failed\n");
+   return -1;
+   }
+   }
+
+   idx = sctx->num_resident_img_handles;
+   sctx->resident_img_handles[idx] = img_handle;
+   sctx->num_resident_img_handles++;
+
+   return 0;
+}
+
+static void si_del_resident_img_handle(struct si_context *sctx,
+  struct si_image_handle *img_handle)
+{
+   unsigned i;
+   int size;
+
+   for (i = 0; i < sctx->num_resident_img_handles; i++) {
+   if (sctx->resident_img_handles[i] != img_handle)
+   continue;
+
+   if (i < sctx->num_resident_img_handles - 1) {
+   size = sizeof(*sctx->resident_img_handles) *
+   (sctx->num_resident_img_handles - 1 - i);
+
+   memmove(>resident_img_handles[i],
+   >resident_img_handles[i + 1], size);
+   }
+
+

[Mesa-dev] [RFC PATCH 56/65] radeonsi: decompress DCC for resident textures/images

2017-05-19 Thread Samuel Pitoiset
Analogous to bound textures/images. We should also update the
resident descriptors and disable COMPRESSION_EN for avoiding
useless DCC fetches, but I postpone this optimization for a
separate series.

Signed-off-by: Samuel Pitoiset 
---
 src/gallium/drivers/radeonsi/si_blit.c| 52 +++
 src/gallium/drivers/radeonsi/si_descriptors.c | 16 +
 2 files changed, 68 insertions(+)

diff --git a/src/gallium/drivers/radeonsi/si_blit.c 
b/src/gallium/drivers/radeonsi/si_blit.c
index 998288dba2..4078f2498b 100644
--- a/src/gallium/drivers/radeonsi/si_blit.c
+++ b/src/gallium/drivers/radeonsi/si_blit.c
@@ -611,6 +611,54 @@ static void si_check_render_feedback_images(struct 
si_context *sctx,
}
 }
 
+static void si_check_render_feedback_resident_textures(struct si_context *sctx)
+{
+   unsigned i;
+
+   for (i = 0; i < sctx->num_resident_tex_handles; i++) {
+   struct si_texture_handle *tex_handle =
+   sctx->resident_tex_handles[i];
+   struct pipe_sampler_view *view;
+   struct r600_texture *tex;
+
+   view = _handle->view->base;
+   if (view->texture->target == PIPE_BUFFER)
+   continue;
+
+   tex = (struct r600_texture *)view->texture;
+
+   si_check_render_feedback_texture(sctx, tex,
+view->u.tex.first_level,
+view->u.tex.last_level,
+view->u.tex.first_layer,
+view->u.tex.last_layer);
+   }
+}
+
+static void si_check_render_feedback_resident_images(struct si_context *sctx)
+{
+   unsigned i;
+
+   for (i = 0; i < sctx->num_resident_img_handles; i++) {
+   struct si_image_handle *img_handle =
+   sctx->resident_img_handles[i];
+   struct pipe_image_view *view;
+   struct r600_texture *tex;
+
+   view = _handle->view;
+   if (view->resource->target == PIPE_BUFFER)
+   continue;
+
+   tex = (struct r600_texture *)view->resource;
+
+   si_check_render_feedback_texture(sctx, tex,
+view->u.tex.level,
+view->u.tex.level,
+view->u.tex.first_layer,
+view->u.tex.last_layer);
+   }
+}
+
 static void si_check_render_feedback(struct si_context *sctx)
 {
 
@@ -621,6 +669,10 @@ static void si_check_render_feedback(struct si_context 
*sctx)
si_check_render_feedback_images(sctx, >images[i]);
si_check_render_feedback_textures(sctx, >samplers[i]);
}
+
+   si_check_render_feedback_resident_images(sctx);
+   si_check_render_feedback_resident_textures(sctx);
+
sctx->need_check_render_feedback = false;
 }
 
diff --git a/src/gallium/drivers/radeonsi/si_descriptors.c 
b/src/gallium/drivers/radeonsi/si_descriptors.c
index 810dd8e89a..e459f19d66 100644
--- a/src/gallium/drivers/radeonsi/si_descriptors.c
+++ b/src/gallium/drivers/radeonsi/si_descriptors.c
@@ -2416,6 +2416,13 @@ static void si_make_texture_handle_resident(struct 
pipe_context *ctx,
sview = tex_handle->view;
 
if (resident) {
+   if (sview->base.texture->target != PIPE_BUFFER) {
+   struct r600_texture *rtex =
+   (struct r600_texture *)sview->base.texture;
+
+   si_update_check_render_feedback(sctx, rtex);
+   }
+
si_add_resident_tex_handle(sctx, tex_handle);
 
/* Add the buffers to the current CS in case si_begin_new_cs()
@@ -2511,6 +2518,15 @@ static void si_make_image_handle_resident(struct 
pipe_context *ctx,
view = _handle->view;
 
if (resident) {
+   struct r600_resource *res =
+   (struct r600_resource *)view->resource;
+
+   if (res->b.b.target != PIPE_BUFFER) {
+   struct r600_texture *rtex = (struct r600_texture *)res;
+
+   si_update_check_render_feedback(sctx, rtex);
+   }
+
si_add_resident_img_handle(sctx, img_handle);
 
/* Add the buffers to the current CS in case si_begin_new_cs()
-- 
2.13.0

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


[Mesa-dev] [RFC PATCH 55/65] radeonsi: add si_update_check_render_feedback() helper

2017-05-19 Thread Samuel Pitoiset
Signed-off-by: Samuel Pitoiset 
---
 src/gallium/drivers/radeonsi/si_descriptors.c | 15 +--
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_descriptors.c 
b/src/gallium/drivers/radeonsi/si_descriptors.c
index 44a4b16712..810dd8e89a 100644
--- a/src/gallium/drivers/radeonsi/si_descriptors.c
+++ b/src/gallium/drivers/radeonsi/si_descriptors.c
@@ -613,6 +613,13 @@ static void si_update_compressed_tex_shader_mask(struct 
si_context *sctx,
sctx->compressed_tex_shader_mask &= ~shader_bit;
 }
 
+static void si_update_check_render_feedback(struct si_context *sctx,
+   struct r600_texture *rtex)
+{
+   if (rtex->dcc_offset && p_atomic_read(>framebuffers_bound))
+   sctx->need_check_render_feedback = true;
+}
+
 static void si_set_sampler_views(struct pipe_context *ctx,
 enum pipe_shader_type shader, unsigned start,
  unsigned count,
@@ -653,9 +660,7 @@ static void si_set_sampler_views(struct pipe_context *ctx,
samplers->compressed_colortex_mask &= ~(1u << 
slot);
}
 
-   if (rtex->dcc_offset &&
-   p_atomic_read(>framebuffers_bound))
-   sctx->need_check_render_feedback = true;
+   si_update_check_render_feedback(sctx, rtex);
} else {
samplers->depth_texture_mask &= ~(1u << slot);
samplers->compressed_colortex_mask &= ~(1u << slot);
@@ -861,9 +866,7 @@ static void si_set_shader_image(struct si_context *ctx,
images->compressed_colortex_mask &= ~(1 << slot);
}
 
-   if (tex->dcc_offset &&
-   p_atomic_read(>framebuffers_bound))
-   ctx->need_check_render_feedback = true;
+   si_update_check_render_feedback(ctx, tex);
}
 
images->enabled_mask |= 1u << slot;
-- 
2.13.0

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


[Mesa-dev] [RFC PATCH 58/65] radeonsi: isolate real framebuffer changes from the decompression passes

2017-05-19 Thread Samuel Pitoiset
When a stencil buffer is part of the framebuffer state, it is
decompressed but because it's bindles, all draw calls set
stencil_dirty_level_mask to 1.

Signed-off-by: Samuel Pitoiset 
---
 src/gallium/drivers/radeonsi/si_blit.c  |  8 
 src/gallium/drivers/radeonsi/si_pipe.h  |  1 +
 src/gallium/drivers/radeonsi/si_state.c | 10 --
 3 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_blit.c 
b/src/gallium/drivers/radeonsi/si_blit.c
index 32041695e2..0cf3ea79b9 100644
--- a/src/gallium/drivers/radeonsi/si_blit.c
+++ b/src/gallium/drivers/radeonsi/si_blit.c
@@ -235,12 +235,16 @@ si_blit_decompress_zs_planes_in_place(struct si_context 
*sctx,
 
zsurf = sctx->b.b.create_surface(>b.b, 
>resource.b.b, _tmpl);
 
+   sctx->decompression_enabled = true;
+
si_blitter_begin(>b.b, SI_DECOMPRESS);
util_blitter_custom_depth_stencil(sctx->blitter, zsurf, 
NULL, ~0,
  
sctx->custom_dsa_flush,
  1.0f);
si_blitter_end(>b.b);
 
+   sctx->decompression_enabled = false;
+
pipe_surface_reference(, NULL);
}
 
@@ -454,10 +458,14 @@ static void si_blit_decompress_color(struct pipe_context 
*ctx,
surf_tmpl.u.tex.last_layer = layer;
cbsurf = ctx->create_surface(ctx, >resource.b.b, 
_tmpl);
 
+   sctx->decompression_enabled = true;
+
si_blitter_begin(ctx, SI_DECOMPRESS);
util_blitter_custom_color(sctx->blitter, cbsurf, 
custom_blend);
si_blitter_end(ctx);
 
+   sctx->decompression_enabled = false;
+
pipe_surface_reference(, NULL);
}
 
diff --git a/src/gallium/drivers/radeonsi/si_pipe.h 
b/src/gallium/drivers/radeonsi/si_pipe.h
index 7dafa77c37..8d8efbda1f 100644
--- a/src/gallium/drivers/radeonsi/si_pipe.h
+++ b/src/gallium/drivers/radeonsi/si_pipe.h
@@ -402,6 +402,7 @@ struct si_context {
 
/* Other state */
bool need_check_render_feedback;
+   booldecompression_enabled;
 
/* Precomputed IA_MULTI_VGT_PARAM */
union si_vgt_param_key  ia_multi_vgt_param_key;
diff --git a/src/gallium/drivers/radeonsi/si_state.c 
b/src/gallium/drivers/radeonsi/si_state.c
index 363f32170a..7256ec0c62 100644
--- a/src/gallium/drivers/radeonsi/si_state.c
+++ b/src/gallium/drivers/radeonsi/si_state.c
@@ -2611,9 +2611,15 @@ static void si_set_framebuffer_state(struct pipe_context 
*ctx,
si_mark_atom_dirty(sctx, >msaa_sample_locs.atom);
}
 
-   sctx->need_check_render_feedback = true;
sctx->do_update_shaders = true;
-   sctx->framebuffer.do_update_surf_dirtiness = true;
+
+   if (!sctx->decompression_enabled) {
+   /* Prevent textures decompression when the framebuffer state
+* changes come from the decompression passes themselves.
+*/
+   sctx->need_check_render_feedback = true;
+   sctx->framebuffer.do_update_surf_dirtiness = true;
+   }
 }
 
 static void si_emit_framebuffer_state(struct si_context *sctx, struct 
r600_atom *atom)
-- 
2.13.0

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


[Mesa-dev] [RFC PATCH 27/65] trace: add ARB_bindless_texture support

2017-05-19 Thread Samuel Pitoiset
Signed-off-by: Samuel Pitoiset 
---
 src/gallium/drivers/trace/tr_context.c | 114 +
 1 file changed, 114 insertions(+)

diff --git a/src/gallium/drivers/trace/tr_context.c 
b/src/gallium/drivers/trace/tr_context.c
index c5563a4844..6639f783a5 100644
--- a/src/gallium/drivers/trace/tr_context.c
+++ b/src/gallium/drivers/trace/tr_context.c
@@ -1704,6 +1704,114 @@ static void trace_context_launch_grid(struct 
pipe_context *_pipe,
trace_dump_call_end();
 }
 
+static uint64_t trace_context_create_texture_handle(struct pipe_context *_pipe,
+struct pipe_resource *res,
+struct pipe_sampler_view 
*view,
+const struct 
pipe_sampler_state *state)
+{
+   struct trace_context *tr_ctx = trace_context(_pipe);
+   struct pipe_context *pipe = tr_ctx->pipe;
+   uint64_t handle;
+
+   trace_dump_call_begin("pipe_context", "create_texture_handle");
+   trace_dump_arg(ptr, pipe);
+   trace_dump_arg(ptr, res);
+   trace_dump_arg(ptr, view);
+   trace_dump_arg_begin("state");
+   trace_dump_arg(sampler_state, state);
+   trace_dump_arg_end();
+
+   handle = pipe->create_texture_handle(pipe, res, view, state);
+
+   trace_dump_ret(uint, handle);
+   trace_dump_call_end();
+
+   return handle;
+}
+
+static void trace_context_delete_texture_handle(struct pipe_context *_pipe,
+uint64_t handle)
+{
+   struct trace_context *tr_ctx = trace_context(_pipe);
+   struct pipe_context *pipe = tr_ctx->pipe;
+
+   trace_dump_call_begin("pipe_context", "delete_texture_handle");
+   trace_dump_arg(ptr, pipe);
+   trace_dump_arg(uint, handle);
+   trace_dump_call_end();
+
+   pipe->delete_texture_handle(pipe, handle);
+}
+
+static void trace_context_make_texture_handle_resident(struct pipe_context 
*_pipe,
+   uint64_t handle,
+   bool resident)
+{
+   struct trace_context *tr_ctx = trace_context(_pipe);
+   struct pipe_context *pipe = tr_ctx->pipe;
+
+   trace_dump_call_begin("pipe_context", "make_texture_handle_resident");
+   trace_dump_arg(ptr, pipe);
+   trace_dump_arg(uint, handle);
+   trace_dump_arg(bool, resident);
+   trace_dump_call_end();
+
+   pipe->make_texture_handle_resident(pipe, handle, resident);
+}
+
+static uint64_t trace_context_create_image_handle(struct pipe_context *_pipe,
+  const struct pipe_image_view 
*image)
+{
+   struct trace_context *tr_ctx = trace_context(_pipe);
+   struct pipe_context *pipe = tr_ctx->pipe;
+   uint64_t handle;
+
+   trace_dump_call_begin("pipe_context", "create_image_handle");
+   trace_dump_arg(ptr, pipe);
+   trace_dump_arg_begin("image");
+   trace_dump_image_view(image);
+   trace_dump_arg_end();
+
+   handle = pipe->create_image_handle(pipe, image);
+
+   trace_dump_ret(uint, handle);
+   trace_dump_call_end();
+
+   return handle;
+}
+
+static void trace_context_delete_image_handle(struct pipe_context *_pipe,
+  uint64_t handle)
+{
+   struct trace_context *tr_ctx = trace_context(_pipe);
+   struct pipe_context *pipe = tr_ctx->pipe;
+
+   trace_dump_call_begin("pipe_context", "delete_image_handle");
+   trace_dump_arg(ptr, pipe);
+   trace_dump_arg(uint, handle);
+   trace_dump_call_end();
+
+   pipe->delete_image_handle(pipe, handle);
+}
+
+static void trace_context_make_image_handle_resident(struct pipe_context 
*_pipe,
+uint64_t handle,
+unsigned access,
+bool resident)
+{
+   struct trace_context *tr_ctx = trace_context(_pipe);
+   struct pipe_context *pipe = tr_ctx->pipe;
+
+   trace_dump_call_begin("pipe_context", "make_image_handle_resident");
+   trace_dump_arg(ptr, pipe);
+   trace_dump_arg(uint, handle);
+   trace_dump_arg(uint, access);
+   trace_dump_arg(bool, resident);
+   trace_dump_call_end();
+
+   pipe->make_image_handle_resident(pipe, handle, access, resident);
+}
+
 struct pipe_context *
 trace_context_create(struct trace_screen *tr_scr,
  struct pipe_context *pipe)
@@ -1805,6 +1913,12 @@ trace_context_create(struct trace_screen *tr_scr,
TR_CTX_INIT(set_shader_buffers);
TR_CTX_INIT(launch_grid);
TR_CTX_INIT(set_shader_images);
+   TR_CTX_INIT(create_texture_handle);
+   TR_CTX_INIT(delete_texture_handle);
+   TR_CTX_INIT(make_texture_handle_resident);
+   TR_CTX_INIT(create_image_handle);
+   TR_CTX_INIT(delete_image_handle);
+   TR_CTX_INIT(make_image_handle_resident);
 
TR_CTX_INIT(transfer_map);
TR_CTX_INIT(transfer_unmap);
-- 
2.13.0

___
mesa-dev mailing list

[Mesa-dev] [RFC PATCH 42/65] st/mesa: add st_create_{texture, image}_handle_from_unit() helper

2017-05-19 Thread Samuel Pitoiset
Signed-off-by: Samuel Pitoiset 
---
 src/mesa/state_tracker/st_texture.c | 42 +
 1 file changed, 42 insertions(+)

diff --git a/src/mesa/state_tracker/st_texture.c 
b/src/mesa/state_tracker/st_texture.c
index 2e9856dcdf..65f86f2b4f 100644
--- a/src/mesa/state_tracker/st_texture.c
+++ b/src/mesa/state_tracker/st_texture.c
@@ -420,3 +420,45 @@ st_create_color_map_texture(struct gl_context *ctx)
   texSize, texSize, 1, 1, 0, PIPE_BIND_SAMPLER_VIEW);
return pt;
 }
+
+
+/**
+ * Create a texture handle from a texture unit.
+ */
+static GLuint64
+st_create_texture_handle_from_unit(struct st_context *st,
+   struct gl_program *prog, GLuint texUnit)
+{
+   struct gl_context *ctx = st->ctx;
+   struct gl_texture_object *texObj;
+   struct pipe_context *pipe = st->pipe;
+   struct pipe_sampler_view *view;
+   struct pipe_sampler_state sampler;
+
+   if (!st_update_single_texture(st, , texUnit, prog->sh.data->Version))
+  return 0;
+
+   st_convert_sampler_from_unit(st, , texUnit);
+
+   texObj = ctx->Texture.Unit[texUnit]._Current;
+   assert(texObj);
+
+   return pipe->create_texture_handle(pipe, st_texture_object(texObj)->pt,
+  view, );
+}
+
+
+/**
+ * Create an image handle from an image unit.
+ */
+static GLuint64
+st_create_image_handle_from_unit(struct st_context *st,
+ struct gl_program *prog, GLuint imgUnit)
+{
+   struct pipe_context *pipe = st->pipe;
+   struct pipe_image_view img;
+
+   st_convert_image_from_unit(st, , imgUnit);
+
+   return pipe->create_image_handle(pipe, );
+}
-- 
2.13.0

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


[Mesa-dev] [RFC PATCH 41/65] st/mesa: add st_convert_image_from_unit() helper

2017-05-19 Thread Samuel Pitoiset
Signed-off-by: Samuel Pitoiset 
---
 src/mesa/state_tracker/st_atom_image.c | 33 ++---
 src/mesa/state_tracker/st_texture.h|  5 +
 2 files changed, 27 insertions(+), 11 deletions(-)

diff --git a/src/mesa/state_tracker/st_atom_image.c 
b/src/mesa/state_tracker/st_atom_image.c
index 381eca191a..5b914637a2 100644
--- a/src/mesa/state_tracker/st_atom_image.c
+++ b/src/mesa/state_tracker/st_atom_image.c
@@ -102,6 +102,27 @@ st_convert_image(const struct st_context *st, const struct 
gl_image_unit *u,
}
 }
 
+/**
+ * Get a pipe_image_view object from an image unit.
+ */
+void
+st_convert_image_from_unit(const struct st_context *st,
+   struct pipe_image_view *img,
+   GLuint imgUnit)
+{
+   struct gl_image_unit *u = >ctx->ImageUnits[imgUnit];
+   struct st_texture_object *stObj = st_texture_object(u->TexObj);
+
+   if (!_mesa_is_image_unit_valid(st->ctx, u) ||
+   !st_finalize_texture(st->ctx, st->pipe, u->TexObj, 0) ||
+   !stObj->pt) {
+  memset(img, 0, sizeof(*img));
+  return;
+   }
+
+   st_convert_image(st, u, img);
+}
+
 static void
 st_bind_images(struct st_context *st, struct gl_program *prog,
enum pipe_shader_type shader_type)
@@ -116,19 +137,9 @@ st_bind_images(struct st_context *st, struct gl_program 
*prog,
c = >ctx->Const.Program[prog->info.stage];
 
for (i = 0; i < prog->info.num_images; i++) {
-  struct gl_image_unit *u =
- >ctx->ImageUnits[prog->sh.ImageUnits[i]];
-  struct st_texture_object *stObj = st_texture_object(u->TexObj);
   struct pipe_image_view *img = [i];
 
-  if (!_mesa_is_image_unit_valid(st->ctx, u) ||
-  !st_finalize_texture(st->ctx, st->pipe, u->TexObj, 0) ||
-  !stObj->pt) {
- memset(img, 0, sizeof(*img));
- continue;
-  }
-
-  st_convert_image(st, u, img);
+  st_convert_image_from_unit(st, img, prog->sh.ImageUnits[i]);
}
cso_set_shader_images(st->cso_context, shader_type, 0,
  prog->info.num_images, images);
diff --git a/src/mesa/state_tracker/st_texture.h 
b/src/mesa/state_tracker/st_texture.h
index e73de2f1d3..7f8a0cb841 100644
--- a/src/mesa/state_tracker/st_texture.h
+++ b/src/mesa/state_tracker/st_texture.h
@@ -259,6 +259,11 @@ st_convert_image(const struct st_context *st, const struct 
gl_image_unit *u,
  struct pipe_image_view *img);
 
 void
+st_convert_image_from_unit(const struct st_context *st,
+   struct pipe_image_view *img,
+   GLuint imgUnit);
+
+void
 st_convert_sampler(const struct st_context *st,
const struct gl_texture_object *texobj,
const struct gl_sampler_object *msamp,
-- 
2.13.0

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


[Mesa-dev] [RFC PATCH 38/65] st/mesa: implement ARB_bindless_texture

2017-05-19 Thread Samuel Pitoiset
Signed-off-by: Samuel Pitoiset 
---
 src/mesa/state_tracker/st_cb_texture.c | 84 ++
 1 file changed, 84 insertions(+)

diff --git a/src/mesa/state_tracker/st_cb_texture.c 
b/src/mesa/state_tracker/st_cb_texture.c
index 99c59f77a3..fabf78e7a7 100644
--- a/src/mesa/state_tracker/st_cb_texture.c
+++ b/src/mesa/state_tracker/st_cb_texture.c
@@ -2880,6 +2880,82 @@ st_TexParameter(struct gl_context *ctx,
 }
 
 
+static GLuint64
+st_NewTextureHandle(struct gl_context *ctx, struct gl_texture_object *texObj,
+struct gl_sampler_object *sampObj)
+{
+   struct st_context *st = st_context(ctx);
+   struct st_texture_object *stObj = st_texture_object(texObj);
+   struct pipe_context *pipe = st->pipe;
+   struct pipe_sampler_view *view;
+   struct pipe_sampler_state sampler;
+
+   if (!st_finalize_texture(ctx, pipe, texObj, 0))
+  return 0;
+
+   st_convert_sampler(st, texObj, sampObj, );
+
+   view = st_get_texture_sampler_view_from_stobj(st, stObj, sampObj, 0);
+
+   return pipe->create_texture_handle(pipe, stObj->pt, view, );
+}
+
+
+static void
+st_DeleteTextureHandle(struct gl_context *ctx, GLuint64 handle)
+{
+   struct st_context *st = st_context(ctx);
+   struct pipe_context *pipe = st->pipe;
+
+   pipe->delete_texture_handle(pipe, handle);
+}
+
+
+static void
+st_MakeTextureHandleResident(struct gl_context *ctx, GLuint64 handle,
+ bool resident)
+{
+   struct st_context *st = st_context(ctx);
+   struct pipe_context *pipe = st->pipe;
+
+   pipe->make_texture_handle_resident(pipe, handle, resident);
+}
+
+
+static GLuint64
+st_NewImageHandle(struct gl_context *ctx, struct gl_image_unit *imgObj)
+{
+   struct st_context *st = st_context(ctx);
+   struct pipe_context *pipe = st->pipe;
+   struct pipe_image_view image;
+
+   st_convert_image(st, imgObj, );
+
+   return pipe->create_image_handle(pipe, );
+}
+
+
+static void
+st_DeleteImageHandle(struct gl_context *ctx, GLuint64 handle)
+{
+   struct st_context *st = st_context(ctx);
+   struct pipe_context *pipe = st->pipe;
+
+   pipe->delete_image_handle(pipe, handle);
+}
+
+
+static void
+st_MakeImageHandleResident(struct gl_context *ctx, GLuint64 handle,
+   GLenum access, bool resident)
+{
+   struct st_context *st = st_context(ctx);
+   struct pipe_context *pipe = st->pipe;
+
+   pipe->make_image_handle_resident(pipe, handle, access, resident);
+}
+
+
 void
 st_init_texture_functions(struct dd_function_table *functions)
 {
@@ -2914,4 +2990,12 @@ st_init_texture_functions(struct dd_function_table 
*functions)
functions->ClearTexSubImage = st_ClearTexSubImage;
 
functions->TexParameter = st_TexParameter;
+
+   /* bindless functions */
+   functions->NewTextureHandle = st_NewTextureHandle;
+   functions->DeleteTextureHandle = st_DeleteTextureHandle;
+   functions->MakeTextureHandleResident = st_MakeTextureHandleResident;
+   functions->NewImageHandle = st_NewImageHandle;
+   functions->DeleteImageHandle = st_DeleteImageHandle;
+   functions->MakeImageHandleResident = st_MakeImageHandleResident;
 }
-- 
2.13.0

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


[Mesa-dev] [RFC PATCH 47/65] st/mesa: enable ARB_bindless_texture

2017-05-19 Thread Samuel Pitoiset
Signed-off-by: Samuel Pitoiset 
---
 src/mesa/state_tracker/st_extensions.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/mesa/state_tracker/st_extensions.c 
b/src/mesa/state_tracker/st_extensions.c
index 2fa7ba7797..80695580cb 100644
--- a/src/mesa/state_tracker/st_extensions.c
+++ b/src/mesa/state_tracker/st_extensions.c
@@ -577,6 +577,7 @@ void st_init_extensions(struct pipe_screen *screen,
 
static const struct st_extension_cap_mapping cap_mapping[] = {
   { o(ARB_base_instance),PIPE_CAP_START_INSTANCE   
},
+  { o(ARB_bindless_texture), PIPE_CAP_BINDLESS_TEXTURE 
},
   { o(ARB_buffer_storage),   
PIPE_CAP_BUFFER_MAP_PERSISTENT_COHERENT   },
   { o(ARB_clear_texture),PIPE_CAP_CLEAR_TEXTURE
},
   { o(ARB_clip_control), PIPE_CAP_CLIP_HALFZ   
},
-- 
2.13.0

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


[Mesa-dev] [RFC PATCH 43/65] st/mesa: add infrastructure for storing bound texture/image handles

2017-05-19 Thread Samuel Pitoiset
Signed-off-by: Samuel Pitoiset 
---
 src/mesa/state_tracker/st_context.c |  2 +
 src/mesa/state_tracker/st_context.h | 11 ++
 src/mesa/state_tracker/st_texture.c | 77 +
 src/mesa/state_tracker/st_texture.h |  5 +++
 4 files changed, 95 insertions(+)

diff --git a/src/mesa/state_tracker/st_context.c 
b/src/mesa/state_tracker/st_context.c
index c901764668..4dcc160b50 100644
--- a/src/mesa/state_tracker/st_context.c
+++ b/src/mesa/state_tracker/st_context.c
@@ -292,6 +292,8 @@ st_destroy_context_priv(struct st_context *st, bool 
destroy_pipe)
st_destroy_drawtex(st);
st_destroy_perfmon(st);
st_destroy_pbo_helpers(st);
+   st_destroy_bound_texture_handles(st);
+   st_destroy_bound_image_handles(st);
 
for (shader = 0; shader < ARRAY_SIZE(st->state.sampler_views); shader++) {
   for (i = 0; i < ARRAY_SIZE(st->state.sampler_views[0]); i++) {
diff --git a/src/mesa/state_tracker/st_context.h 
b/src/mesa/state_tracker/st_context.h
index 520cd8d462..16f29669be 100644
--- a/src/mesa/state_tracker/st_context.h
+++ b/src/mesa/state_tracker/st_context.h
@@ -79,6 +79,12 @@ struct st_bitmap_cache
ubyte *buffer;
 };
 
+struct st_bound_handle
+{
+   unsigned num_handles;
+   uint64_t *handles;
+};
+
 struct st_context
 {
struct st_context_iface iface;
@@ -271,6 +277,11 @@ struct st_context
struct st_perf_monitor_group *perfmon;
 
enum pipe_reset_status reset_status;
+
+   /* Array of bound texture/image handles which are resident in the context.
+*/
+   struct st_bound_handle bound_texture_handles[PIPE_SHADER_TYPES];
+   struct st_bound_handle bound_image_handles[PIPE_SHADER_TYPES];
 };
 
 
diff --git a/src/mesa/state_tracker/st_texture.c 
b/src/mesa/state_tracker/st_texture.c
index 65f86f2b4f..cde7759a61 100644
--- a/src/mesa/state_tracker/st_texture.c
+++ b/src/mesa/state_tracker/st_texture.c
@@ -421,6 +421,83 @@ st_create_color_map_texture(struct gl_context *ctx)
return pt;
 }
 
+/**
+ * Destroy bound texture handles for the given stage.
+ */
+static void
+st_destroy_bound_texture_handles_per_stage(struct st_context *st,
+   enum pipe_shader_type shader)
+{
+   struct st_bound_handle *bound_handles = >bound_texture_handles[shader];
+   struct pipe_context *pipe = st->pipe;
+   unsigned i;
+
+   if (likely(!bound_handles->num_handles))
+  return;
+
+   for (i = 0; i < bound_handles->num_handles; i++) {
+  uint64_t handle = bound_handles->handles[i];
+
+  pipe->make_texture_handle_resident(pipe, handle, false);
+  pipe->delete_texture_handle(pipe, handle);
+   }
+   free(bound_handles->handles);
+   bound_handles->num_handles = 0;
+}
+
+
+/**
+ * Destroy all bound texture handles in the context.
+ */
+void
+st_destroy_bound_texture_handles(struct st_context *st)
+{
+   unsigned i;
+
+   for (i = 0; i < PIPE_SHADER_TYPES; i++) {
+  st_destroy_bound_texture_handles_per_stage(st, i);
+   }
+}
+
+
+/**
+ * Destroy bound image handles for the given stage.
+ */
+static void
+st_destroy_bound_image_handles_per_stage(struct st_context *st,
+ enum pipe_shader_type shader)
+{
+   struct st_bound_handle *bound_handles = >bound_image_handles[shader];
+   struct pipe_context *pipe = st->pipe;
+   unsigned i;
+
+   if (likely(!bound_handles->num_handles))
+  return;
+
+   for (i = 0; i < bound_handles->num_handles; i++) {
+  uint64_t handle = bound_handles->handles[i];
+
+  pipe->make_image_handle_resident(pipe, handle, GL_READ_WRITE, false);
+  pipe->delete_image_handle(pipe, handle);
+   }
+   free(bound_handles->handles);
+   bound_handles->num_handles = 0;
+}
+
+
+/**
+ * Destroy all bound image handles in the context.
+ */
+void
+st_destroy_bound_image_handles(struct st_context *st)
+{
+   unsigned i;
+
+   for (i = 0; i < PIPE_SHADER_TYPES; i++) {
+  st_destroy_bound_image_handles_per_stage(st, i);
+   }
+}
+
 
 /**
  * Create a texture handle from a texture unit.
diff --git a/src/mesa/state_tracker/st_texture.h 
b/src/mesa/state_tracker/st_texture.h
index 7f8a0cb841..b97814cb16 100644
--- a/src/mesa/state_tracker/st_texture.h
+++ b/src/mesa/state_tracker/st_texture.h
@@ -250,6 +250,11 @@ st_texture_image_copy(struct pipe_context *pipe,
 extern struct pipe_resource *
 st_create_color_map_texture(struct gl_context *ctx);
 
+void
+st_destroy_bound_texture_handles(struct st_context *st);
+
+void
+st_destroy_bound_image_handles(struct st_context *st);
 
 bool
 st_etc_fallback(struct st_context *st, struct gl_texture_image *texImage);
-- 
2.13.0

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


[Mesa-dev] [RFC PATCH 40/65] st/mesa: make convert_sampler_from_unit() non-static

2017-05-19 Thread Samuel Pitoiset
Signed-off-by: Samuel Pitoiset 
---
 src/mesa/state_tracker/st_atom_sampler.c | 14 --
 src/mesa/state_tracker/st_texture.h  |  5 +
 2 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/src/mesa/state_tracker/st_atom_sampler.c 
b/src/mesa/state_tracker/st_atom_sampler.c
index f33e334bb9..c6d992fbb0 100644
--- a/src/mesa/state_tracker/st_atom_sampler.c
+++ b/src/mesa/state_tracker/st_atom_sampler.c
@@ -230,11 +230,13 @@ st_convert_sampler(const struct st_context *st,
   ctx->Texture.CubeMapSeamless || msamp->CubeMapSeamless;
 }
 
-
-static void
-convert_sampler_from_unit(const struct st_context *st,
-  struct pipe_sampler_state *sampler,
-  GLuint texUnit)
+/**
+ * Get a pipe_sampler_state object from a texture unit.
+ */
+void
+st_convert_sampler_from_unit(const struct st_context *st,
+ struct pipe_sampler_state *sampler,
+ GLuint texUnit)
 {
const struct gl_texture_object *texobj;
struct gl_context *ctx = st->ctx;
@@ -282,7 +284,7 @@ update_shader_samplers(struct st_context *st,
   if (samplers_used & 1) {
  const GLuint texUnit = prog->SamplerUnits[unit];
 
- convert_sampler_from_unit(st, sampler, texUnit);
+ st_convert_sampler_from_unit(st, sampler, texUnit);
  states[unit] = sampler;
  *num_samplers = unit + 1;
   }
diff --git a/src/mesa/state_tracker/st_texture.h 
b/src/mesa/state_tracker/st_texture.h
index 8eb0b4be47..e73de2f1d3 100644
--- a/src/mesa/state_tracker/st_texture.h
+++ b/src/mesa/state_tracker/st_texture.h
@@ -264,6 +264,11 @@ st_convert_sampler(const struct st_context *st,
const struct gl_sampler_object *msamp,
struct pipe_sampler_state *sampler);
 
+void
+st_convert_sampler_from_unit(const struct st_context *st,
+ struct pipe_sampler_state *sampler,
+ GLuint texUnit);
+
 GLboolean
 st_update_single_texture(struct st_context *st,
  struct pipe_sampler_view **sampler_view,
-- 
2.13.0

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


Re: [Mesa-dev] [PATCH 1/9] mesa: Handle common extension checks with more compact code

2017-05-19 Thread Nanley Chery
On Fri, May 19, 2017 at 06:38:03AM -0700, Ian Romanick wrote:
> From: Ian Romanick 
> 
> The previous code handled everything with the general case.  I noticed
> that every time I converted an open-coded check to use a
> _mesa_has_EXT_foo() function, the text size of the driver increased.
> 
> Almost all extensions only care what the current context API is, and
> the version does not matter.  Handle those using more compact checks.
> 
>text  data bss dec hex filename
> 7037675235248   37280 7310203  6f8b7b 32-bit i965_dri.so before
> 7034307235248   37280 7306835  6f7e53 32-bit i965_dri.so after
> 6679695303400   50608 7033703  6b5367 64-bit i965_dri.so before
> 6676143303400   50608 7030151  6b4587 64-bit i965_dri.so after
> 

Hi Ian,

I wrote a patch some time ago that reduces the cost of the extension
checks by a lot more with less code. The only thing I think may need
addressing is endianness. Would you consider using it instead if I
reworked it and sent it out to the list? You can find it here:
https://cgit.freedesktop.org/~nchery/mesa/commit/?h=1/ext/optimize=a02d88eba1d3129b27d3b5e6aaa976c3ca20cf79

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


Re: [Mesa-dev] Bug in 17.1.0-rc4 source packaging for swr?

2017-05-19 Thread Emil Velikov
On 19 May 2017 at 17:46, Rowley, Timothy O  wrote:
>
> > On May 19, 2017, at 10:26 AM, Emil Velikov  wrote:

> > The original idea by Tim sounds OK imho and I'm actually giving it a try.
> Are you referring to using a llvm-3.9 generated version?
Yes. Unless I've completely misinterpret and you had something else in mind.

> Did you envision
> me checking that in a gen_builder.h file,
Not sure where/how I hinted that - there should be no need for that.

> or removing the logic that omitted
> it from the tarball and somehow enforcing that a packaging build needs
> llvm-3.9?
>
This one here - patch is on the list. It should work until we can
think of a better solution.

> > FWIW the diff between 3.9 and 4.0 seems quite trivial - see below.
> > It should be possible to update the python scripts to handle most/all of
> > those.
> > Perhaps we can have this as a long term solution?
>
>
> At this point llvm seems to be stable in just having intrinsics being added;
> for a while there was some churn.  Unless/until the swr driver/rasterizer
> starts to take advantage of new llvm intrinsics, we should be fine using the
> 3.9 version.
>
What I was thinking is:
 - Parse through for required intrinsics/other and do not generate any
that are unused.

Perhaps it's too much hassle or even not possible? In that case,
forget I even mentioned it.

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


Re: [Mesa-dev] [PATCH v13 03/36] dri: support DRIimage creation from dmabufs with modifiers

2017-05-19 Thread Jason Ekstrand
On Fri, May 19, 2017 at 2:37 AM, Daniel Stone  wrote:

> From: Pekka Paalanen 
>
> add createImageFromDmaBufs2 function which accepts per-plane dmabuf
> format modifiers.
>
> Signed-off-by: Pekka Paalanen 
> Signed-off-by: Varad Gautam 
> Reviewed-by: Daniel Stone 
> Signed-off-by: Daniel Stone 
> ---
>  include/GL/internal/dri_interface.h | 21 -
>  1 file changed, 20 insertions(+), 1 deletion(-)
>
> diff --git a/include/GL/internal/dri_interface.h
> b/include/GL/internal/dri_interface.h
> index c83056aa70..53b95dd93d 100644
> --- a/include/GL/internal/dri_interface.h
> +++ b/include/GL/internal/dri_interface.h
> @@ -1137,7 +1137,7 @@ struct __DRIdri2ExtensionRec {
>   * extensions.
>   */
>  #define __DRI_IMAGE "DRI_IMAGE"
> -#define __DRI_IMAGE_VERSION 14
> +#define __DRI_IMAGE_VERSION 15
>
>  /**
>   * These formats correspond to the similarly named MESA_FORMAT_*
> @@ -1494,6 +1494,25 @@ struct __DRIimageExtensionRec {
> const uint64_t *modifiers,
> const unsigned int
> modifier_count,
> void *loaderPrivate);
> +
> +   /*
> +* Like createImageFromDmaBufs, but takes also format modifiers.
> +*
> +* For EGL_EXT_image_dma_buf_import_modifiers.
> +*
> +* \since 15
> +*/
> +   __DRIimage *(*createImageFromDmaBufs2)(__DRIscreen *screen,
> +  int width, int height, int
> fourcc,
> +  int *fds, int num_fds,
> +  int *strides, int *offsets,
> +  uint64_t *modifiers,
>

As mentioned on IRC, modifiers are per-image so this doesn't need to be a
pointer.  Let's not make it one.  Also, would it make sense to move this up
by 2 lines and put it next to the fourcc format?


> +  enum __DRIYUVColorSpace
> color_space,
> +  enum __DRISampleRange
> sample_range,
> +  enum __DRIChromaSiting
> horiz_siting,
> +  enum __DRIChromaSiting
> vert_siting,
> +  unsigned *error,
> +  void *loaderPrivate);
>  };
>
>
> --
> 2.13.0
>
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH v13 04/36] egl/dri2: Create EGLImages with dmabuf modifiers

2017-05-19 Thread Jason Ekstrand
On Fri, May 19, 2017 at 2:37 AM, Daniel Stone  wrote:

> From: Varad Gautam 
>
> Allow creating EGLImages with dmabuf format modifiers when target is
> EGL_LINUX_DMA_BUF_EXT for EGL_EXT_image_dma_buf_import_modifiers.
>
> v2:
>  - clear modifier assembling and error label name (Eric Engestrom)
> v3:
>  - remove goto jumps within switch-case (Emil Velikov)
>  - treat zero as valid modifier (Daniel Stone)
>  - ensure same modifier across all dmabuf planes (Emil Velikov)
> v4:
>  - allow modifiers to add extra planes (Louis-Francis Ratté-Boulianne)
>
> Signed-off-by: Pekka Paalanen 
> Signed-off-by: Varad Gautam 
> Signed-off-by: Louis-Francis Ratté-Boulianne 
> Reviewed-by: Eric Engestrom 
> Reviewed-by: Daniel Stone 
> Signed-off-by: Daniel Stone 
> ---
>  src/egl/drivers/dri2/egl_dri2.c | 95 ++
> ++-
>  src/egl/main/eglimage.c | 48 +
>  src/egl/main/eglimage.h |  2 +
>  3 files changed, 134 insertions(+), 11 deletions(-)
>
> diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_
> dri2.c
> index ceffd281d5..f06b5535c7 100644
> --- a/src/egl/drivers/dri2/egl_dri2.c
> +++ b/src/egl/drivers/dri2/egl_dri2.c
> @@ -1949,6 +1949,33 @@ dri2_check_dma_buf_attribs(const _EGLImageAttribs
> *attrs)
>}
> }
>
> +   /**
> +* If  is EGL_LINUX_DMA_BUF_EXT, both or neither of the
> following
> +* attribute values may be given.
> +*
> +* This is referring to EGL_DMA_BUF_PLANE0_MODIFIER_LO_EXT and
> +* EGL_DMA_BUF_PLANE0_MODIFIER_HI_EXT, and the same for other planes.
> +*/
> +   for (i = 0; i < DMA_BUF_MAX_PLANES; ++i) {
> +  if (attrs->DMABufPlaneModifiersLo[i].IsPresent !=
> +  attrs->DMABufPlaneModifiersHi[i].IsPresent) {
> + _eglError(EGL_BAD_PARAMETER, "modifier attribute lo or hi
> missing");
> + return EGL_FALSE;
> +  }
> +   }
> +
> +   for (i = 0; i < DMA_BUF_MAX_PLANES; ++i) {
>

This loop could start at 1 instead of 0.  Also, you're checking that they
all match but you aren't checking that they're all present if the 0th is
present.  This also means that if 0 isn't present but 1 is, then you'll be
checking 1 against uninitialized data in 0.  I think we want to fail if
[0].IsPresent != [i].IsPresent.


> +  if (attrs->DMABufPlaneModifiersLo[i].IsPresent) {
> + if ((attrs->DMABufPlaneModifiersLo[0].Value !=
> + attrs->DMABufPlaneModifiersLo[i].Value) ||
> + (attrs->DMABufPlaneModifiersHi[0].Value !=
> + attrs->DMABufPlaneModifiersHi[i].Value)) {
> +_eglError(EGL_BAD_PARAMETER, "modifier attributes not equal");
> +return EGL_FALSE;
> + }
> +  }
> +   }
> +
> return EGL_TRUE;
>  }
>
> @@ -2057,7 +2084,25 @@ dri2_check_dma_buf_format(const _EGLImageAttribs
> *attrs)
> for (i = plane_n; i < DMA_BUF_MAX_PLANES; ++i) {
>if (attrs->DMABufPlaneFds[i].IsPresent ||
>attrs->DMABufPlaneOffsets[i].IsPresent ||
> -  attrs->DMABufPlanePitches[i].IsPresent) {
> +  attrs->DMABufPlanePitches[i].IsPresent ||
> +  attrs->DMABufPlaneModifiersLo[i].IsPresent ||
> +  attrs->DMABufPlaneModifiersHi[i].IsPresent) {
> +
> + /**
> +  * The modifiers extension spec says:
> +  *
> +  * "Modifiers may modify any attribute of a buffer import,
> including
> +  *  but not limited to adding extra planes to a format which
> +  *  otherwise does not have those planes. As an example, a
> modifier
> +  *  may add a plane for an external compression buffer to a
> +  *  single-plane format. The exact meaning and effect of any
> +  *  modifier is canonically defined by drm_fourcc.h, not as part
> of
> +  *  this extension."
> +  */
> + if (attrs->DMABufPlaneModifiersLo[i].IsPresent &&
> + attrs->DMABufPlaneModifiersHi[i].IsPresent)
> +continue;
> +
>   _eglError(EGL_BAD_ATTRIBUTE, "too many plane attributes");
>   return 0;
>}
> @@ -2090,6 +2135,8 @@ dri2_create_image_dma_buf(_EGLDisplay *disp,
> _EGLContext *ctx,
> int fds[DMA_BUF_MAX_PLANES];
> int pitches[DMA_BUF_MAX_PLANES];
> int offsets[DMA_BUF_MAX_PLANES];
> +   uint64_t modifiers[DMA_BUF_MAX_PLANES];
> +   bool has_modifier = false;
> unsigned error;
>
> /**
> @@ -2120,18 +2167,44 @@ dri2_create_image_dma_buf(_EGLDisplay *disp,
> _EGLContext *ctx,
>fds[i] = attrs.DMABufPlaneFds[i].Value;
>pitches[i] = attrs.DMABufPlanePitches[i].Value;
>offsets[i] = attrs.DMABufPlaneOffsets[i].Value;
> +  if (attrs.DMABufPlaneModifiersLo[i].IsPresent) {
> + modifiers[i] =
> +((uint64_t) 

Re: [Mesa-dev] [PATCH v13 05/36] dri: add queryDmaBufFormats and queryDmaBufModifiers to DRIimage

2017-05-19 Thread Jason Ekstrand
On Fri, May 19, 2017 at 2:37 AM, Daniel Stone  wrote:

> From: Varad Gautam 
>
> these allow querying the driver for supported dmabuf formats and
> modifiers.
>
> v2: move to __DRIimageExtension version 16.
> v3: return GLBoolean for error reporting, document params better.
>
> Signed-off-by: Varad Gautam 
> Reviewed-by: Daniel Stone 
> Signed-off-by: Daniel Stone 
> ---
>  include/GL/internal/dri_interface.h | 42 ++
> ++-
>  1 file changed, 41 insertions(+), 1 deletion(-)
>
> diff --git a/include/GL/internal/dri_interface.h
> b/include/GL/internal/dri_interface.h
> index 53b95dd93d..37bd48b0b6 100644
> --- a/include/GL/internal/dri_interface.h
> +++ b/include/GL/internal/dri_interface.h
> @@ -1137,7 +1137,7 @@ struct __DRIdri2ExtensionRec {
>   * extensions.
>   */
>  #define __DRI_IMAGE "DRI_IMAGE"
> -#define __DRI_IMAGE_VERSION 15
> +#define __DRI_IMAGE_VERSION 16
>

Do we really need to bump the extension version twice in one patch series?
Seems like we could just as easily merge this into patch 3.  Not that it
matters...


>
>  /**
>   * These formats correspond to the similarly named MESA_FORMAT_*
> @@ -1513,6 +1513,46 @@ struct __DRIimageExtensionRec {
>enum __DRIChromaSiting
> vert_siting,
>unsigned *error,
>void *loaderPrivate);
> +
> +   /*
> +* dmabuf format query to support EGL_EXT_image_dma_buf_import_
> modifiers.
> +*
> +* \param max  Maximum number of formats that can be accomodated
> into
> +* \param formats. If zero, no formats are returned -
> +* instead, the driver returns the total number of
> +* supported dmabuf formats in \param count.
> +* \param formats  Buffer to fill formats into.
> +* \param countCount of formats returned, or, total number of
> +* supported formats in case \param max is zero.
> +*
> +* Returns true on success.
> +*
> +* \since 16
> +*/
> +   GLboolean (*queryDmaBufFormats)(__DRIscreen *screen, int max, int
> *formats,
> +  int *count);
> +
> +   /*
> +* dmabuf format modifier query for a given format to support
> +* EGL_EXT_image_dma_buf_import_modifiers.
> +*
> +* \param fourccThe format to query modifiers for. If this format
> +*  is not supported by the driver, return false.
> +* \param max   Maximum number of modifiers that can be
> accomodated in
> +*  \param modifiers. If zero, no modifiers are
> returned -
> +*  instead, the driver returns the total number of
> +*  modifiers for \param format in \param count.
> +* \param modifiers Buffer to fill modifiers into.
> +* \param count Count of the modifiers returned, or, total number
> of
> +*  supported modifiers for \param fourcc in case
> +*  \param max is zero.
> +*
> +* Returns true upon success.
> +*
> +* \since 16
> +*/
> +   GLboolean (*queryDmaBufModifiers)(__DRIscreen *screen, int fourcc,
> int max,
> +uint64_t *modifiers, int *count);
>  };
>
>
> --
> 2.13.0
>
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH v13 16/36] i965: Remove same-FD restriction for imports

2017-05-19 Thread Jason Ekstrand
On Fri, May 19, 2017 at 2:37 AM, Daniel Stone  wrote:

> Intel hardware requires that all planes of an image come from the same
> buffer, which is currently implemented by testing that all FDs are
> numerically the same.
>
> However, when going through a winsys (e.g.) or anything which transits
> FDs individually, the FDs may be different even if the underlying buffer
> is the same.
>
> Since there is nothing we can do to detect this properly, just remove
> the test for now.
>

That's not actually true.  If two FDs point to the same underlying GEM bo,
then brw_bo_gem_create_from_prime (called below) will return the same
pointers for both of them.  What we really want to do is call that on all
of the FDs (or maybe all of the unique FDs?) and check that they're all the
same.


> Signed-off-by: Daniel Stone 
> ---
>  src/mesa/drivers/dri/i965/intel_screen.c | 5 -
>  1 file changed, 5 deletions(-)
>
> diff --git a/src/mesa/drivers/dri/i965/intel_screen.c
> b/src/mesa/drivers/dri/i965/intel_screen.c
> index 91ed128f83..69c450a431 100644
> --- a/src/mesa/drivers/dri/i965/intel_screen.c
> +++ b/src/mesa/drivers/dri/i965/intel_screen.c
> @@ -819,11 +819,6 @@ intel_create_image_from_fds(__DRIscreen *dri_screen,
> if (fds == NULL || num_fds < 1)
>return NULL;
>
> -   /* We only support all planes from the same bo */
> -   for (i = 0; i < num_fds; i++)
> -  if (fds[0] != fds[i])
> - return NULL;
> -
> f = intel_image_format_lookup(fourcc);
> if (f == NULL)
>return NULL;
> --
> 2.13.0
>
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 1/9] mesa: Handle common extension checks with more compact code

2017-05-19 Thread Ilia Mirkin
On Fri, May 19, 2017 at 1:28 PM, Nanley Chery  wrote:
> The only thing I think may need
> addressing is endianness.

FYI, I'm happy to provide BE support, both reviewing code and testing.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 2/2] i965: Enable ASTC HDR for Broxton

2017-05-19 Thread Anuj Phogat
On Thu, May 18, 2017 at 3:53 PM, Nanley Chery  wrote:
> This platform passes the following GLES3 tests:
> ES3-CTS.functional.texture.compressed.astc.endpoint_value_hdr_cem_*
>
We've hdr tests in piglit as well. With those passing, both patches are:
Reviewed-by: Anuj Phogat 

> Signed-off-by: Nanley Chery 
> ---
>  src/mesa/drivers/dri/i965/intel_extensions.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/src/mesa/drivers/dri/i965/intel_extensions.c 
> b/src/mesa/drivers/dri/i965/intel_extensions.c
> index 26c074638e..e76f61de1d 100644
> --- a/src/mesa/drivers/dri/i965/intel_extensions.c
> +++ b/src/mesa/drivers/dri/i965/intel_extensions.c
> @@ -285,6 +285,9 @@ intelInitExtensions(struct gl_context *ctx)
>ctx->Extensions.ARB_post_depth_coverage = true;
> }
>
> +   if (brw->is_broxton)
> +  ctx->Extensions.KHR_texture_compression_astc_hdr = true;
> +
> if (brw->gen >= 6)
>ctx->Extensions.INTEL_performance_query = true;
>
> --
> 2.12.2
>
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 1/2] anv: automake: list shared libraries after the static ones

2017-05-19 Thread Emil Velikov
From: Emil Velikov 

The compiler can discard the shared ones from the link chain, since
there is no user (the static libraries) before it on the command line.

Cc: mesa-sta...@lists.freedesktop.org
Reported-by: Laurent Carlier 
Signed-off-by: Emil Velikov 
---
 src/intel/Makefile.vulkan.am | 31 +++
 1 file changed, 15 insertions(+), 16 deletions(-)

diff --git a/src/intel/Makefile.vulkan.am b/src/intel/Makefile.vulkan.am
index ba6ab4fc93f..33cdc782d26 100644
--- a/src/intel/Makefile.vulkan.am
+++ b/src/intel/Makefile.vulkan.am
@@ -111,7 +111,21 @@ VULKAN_SOURCES = \
$(VULKAN_GENERATED_FILES) \
$(VULKAN_FILES)
 
-VULKAN_LIB_DEPS = $(LIBDRM_LIBS)
+VULKAN_LIB_DEPS = \
+   vulkan/libvulkan_common.la \
+   $(VULKAN_PER_GEN_LIBS) \
+   compiler/libintel_compiler.la \
+   common/libintel_common.la \
+   isl/libisl.la \
+   blorp/libblorp.la \
+   $(top_builddir)/src/vulkan/libvulkan_util.la \
+   $(top_builddir)/src/vulkan/libvulkan_wsi.la \
+   $(top_builddir)/src/compiler/nir/libnir.la \
+   $(top_builddir)/src/util/libmesautil.la \
+   $(LIBDRM_LIBS) \
+   $(PTHREAD_LIBS) \
+   $(DLOPEN_LIBS) \
+   -lm
 
 if HAVE_PLATFORM_X11
 VULKAN_CPPFLAGS += \
@@ -141,21 +155,6 @@ vulkan_libvulkan_common_la_SOURCES = $(VULKAN_SOURCES)
 vulkan_libvulkan_common_la_CFLAGS = $(VULKAN_CFLAGS)
 vulkan_libvulkan_common_la_CPPFLAGS = $(VULKAN_CPPFLAGS)
 
-VULKAN_LIB_DEPS += \
-   vulkan/libvulkan_common.la \
-   $(VULKAN_PER_GEN_LIBS) \
-   compiler/libintel_compiler.la \
-   common/libintel_common.la \
-   isl/libisl.la \
-   blorp/libblorp.la \
-   $(top_builddir)/src/vulkan/libvulkan_util.la \
-   $(top_builddir)/src/vulkan/libvulkan_wsi.la \
-   $(top_builddir)/src/compiler/nir/libnir.la \
-   $(top_builddir)/src/util/libmesautil.la \
-   $(PTHREAD_LIBS) \
-   $(DLOPEN_LIBS) \
-   -lm
-
 nodist_EXTRA_vulkan_libvulkan_intel_la_SOURCES = dummy.cpp
 vulkan_libvulkan_intel_la_SOURCES = $(VULKAN_GEM_FILES)
 vulkan_libvulkan_intel_la_LIBADD = $(VULKAN_LIB_DEPS)
-- 
2.12.2

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


[Mesa-dev] [PATCH 2/2] radv: automake: list shared libraries after the static ones

2017-05-19 Thread Emil Velikov
From: Emil Velikov 

Analogous to previous commit - the compiler can discard xcb + wayland
libs, since there is no user (the static libraries) before it on the
command line.

Cc: mesa-sta...@lists.freedesktop.org
Signed-off-by: Emil Velikov 
---
 src/amd/vulkan/Makefile.am | 35 ---
 1 file changed, 16 insertions(+), 19 deletions(-)

diff --git a/src/amd/vulkan/Makefile.am b/src/amd/vulkan/Makefile.am
index fbd9f5a0305..76a886dd79f 100644
--- a/src/amd/vulkan/Makefile.am
+++ b/src/amd/vulkan/Makefile.am
@@ -59,8 +59,22 @@ VULKAN_SOURCES = \
$(VULKAN_GENERATED_FILES) \
$(VULKAN_FILES)
 
-VULKAN_LIB_DEPS =
-
+VULKAN_LIB_DEPS = \
+   libvulkan_common.la \
+   $(top_builddir)/src/vulkan/libvulkan_util.la \
+   $(top_builddir)/src/vulkan/libvulkan_wsi.la \
+   $(top_builddir)/src/amd/common/libamd_common.la \
+   $(top_builddir)/src/amd/addrlib/libamdgpu_addrlib.la \
+   $(top_builddir)/src/compiler/nir/libnir.la \
+   $(top_builddir)/src/util/libmesautil.la \
+   $(LLVM_LIBS) \
+   $(LIBELF_LIBS) \
+   $(PTHREAD_LIBS) \
+   $(AMDGPU_LIBS) \
+   $(LIBDRM_LIBS) \
+   $(PTHREAD_LIBS) \
+   $(DLOPEN_LIBS) \
+   -lm
 
 if HAVE_PLATFORM_X11
 AM_CPPFLAGS += \
@@ -89,23 +103,6 @@ endif
 noinst_LTLIBRARIES = libvulkan_common.la
 libvulkan_common_la_SOURCES = $(VULKAN_SOURCES)
 
-VULKAN_LIB_DEPS += \
-   libvulkan_common.la \
-   $(top_builddir)/src/vulkan/libvulkan_util.la \
-   $(top_builddir)/src/vulkan/libvulkan_wsi.la \
-   $(top_builddir)/src/amd/common/libamd_common.la \
-   $(top_builddir)/src/amd/addrlib/libamdgpu_addrlib.la \
-   $(top_builddir)/src/compiler/nir/libnir.la \
-   $(top_builddir)/src/util/libmesautil.la \
-   $(LLVM_LIBS) \
-   $(LIBELF_LIBS) \
-   $(PTHREAD_LIBS) \
-   $(AMDGPU_LIBS) \
-   $(LIBDRM_LIBS) \
-   $(PTHREAD_LIBS) \
-   $(DLOPEN_LIBS) \
-   -lm
-
 nodist_EXTRA_libvulkan_radeon_la_SOURCES = dummy.cpp
 libvulkan_radeon_la_SOURCES = $(VULKAN_GEM_FILES)
 
-- 
2.12.2

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


Re: [Mesa-dev] [PATCH 14/16] anv: Advertise both 32-bit and 48-bit heaps when we have enough memory

2017-05-19 Thread Jason Ekstrand
On Thu, May 18, 2017 at 2:01 PM, Jason Ekstrand 
wrote:

> ---
>  src/intel/vulkan/anv_device.c | 42 ++
> ++--
>  1 file changed, 36 insertions(+), 6 deletions(-)
>
> diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c
> index 6ea8dfe..8eed7f3 100644
> --- a/src/intel/vulkan/anv_device.c
> +++ b/src/intel/vulkan/anv_device.c
> @@ -112,12 +112,42 @@ anv_physical_device_init_heaps(struct
> anv_physical_device *device, int fd)
> if (result != VK_SUCCESS)
>return result;
>
> -   device->memory.heap_count = 1;
> -   device->memory.heaps[0] = (struct anv_memory_heap) {
> -  .size = heap_size,
> -  .flags = VK_MEMORY_HEAP_DEVICE_LOCAL_BIT,
> -  .supports_48bit_addresses = device->supports_48bit_addresses,
> -   };
> +   if (heap_size <= 3ull * (1ull << 30)) {
> +  /* In this case, everything fits nicely into the 32-bit address
> space,
> +   * so there's no need for supporting 48bit addresses on
> clinet-allocated
> +   * memory objects.
> +   */
> +  device->memory.heap_count = 1;
> +  device->memory.heaps[0] = (struct anv_memory_heap) {
> + .size = heap_size,
> + .flags = VK_MEMORY_HEAP_DEVICE_LOCAL_BIT,
> + .supports_48bit_addresses = false,
> +  };
> +   } else {
> +  /* Not everything will fit nicely into a 32-bit address space.  In
> this
> +   * case we need a 64-bit heap.  Advertise a small 32-bit heap and a
> +   * larger 48-bit heap.  If we're in this case, then we have a total
> heap
> +   * size larger than 3GiB which most likely means they have 8 GiB of
> +   * video memory and so carving off 2 GiB for the 32-bit heap should
> be
> +   * reasonable.
> +   */
> +  const uint32_t heap_size_32bit = 2ull * (1ull << 30);
>

FYI: I keep waflling on whether the 32-bit carve-out should be 2 GiB or 1
GiB.  No one should need more than 1 GiB for vertex buffers and it means
that, on my laptop, the space is split roughly in half (2 GiB and ~3 GiB)
which is a bit awkward.  I'm kind-of inclined to decrease it.  Opinions?


> +  const uint32_t heap_size_48bit = heap_size - heap_size_32bit;
> +
> +  assert(device->supports_48bit_addresses);
> +
> +  device->memory.heap_count = 2;
> +  device->memory.heaps[0] = (struct anv_memory_heap) {
> + .size = heap_size_48bit,
> + .flags = VK_MEMORY_HEAP_DEVICE_LOCAL_BIT,
> + .supports_48bit_addresses = true,
> +  };
> +  device->memory.heaps[1] = (struct anv_memory_heap) {
> + .size = heap_size_32bit,
> + .flags = VK_MEMORY_HEAP_DEVICE_LOCAL_BIT,
> + .supports_48bit_addresses = false,
> +  };
> +   }
>
> uint32_t type_count = 0;
> for (uint32_t heap = 0; heap < device->memory.heap_count; heap++) {
> --
> 2.5.0.400.gff86faf
>
>
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] i965: Add RGBX8888 and RGBA8888 to EGL configure and reorder the list

2017-05-19 Thread Emil Velikov
On 18 May 2017 at 23:01, Rob Herring  wrote:
> On Thu, May 18, 2017 at 5:25 AM, Emil Velikov  
> wrote:
>> On 18 May 2017 at 05:10, Chih-Wei Huang  wrote:
>>> 2017-05-18 12:01 GMT+08:00 Xu, Randy :

> -Original Message-
> From: Palli, Tapani
> >
> > It's just applied. Isn't it?
> > Yesterday without this patch
> > the color format is mismatch apparently.
>
> Yeah we do need this. TBH I don't quite understand why but will try to 
> figure
> it out. I remember we used to have a patch in Surfaceflinger at one point
> because visual was hardcoded there and this might be related.
>
> // Tapani

 Sorry, that's for different issue, I mix it with RGB565 blending one.
 This patch is required because some Android GLES test apps, like 
 gl2_basic, need to create RGBA surface.
>>>
>>> Indeed it is.
>>>
>>> As Emil pointed out, the patch was merged before
>>> but reverted later since it broke desktop.
>>>
>>> So what's the current upstreaming plan?
>>>
>> No idea about a plan, but how you can fix it once and for all:
>>
>> Extend the loader extension(s) to have a get_caps() callback,
>> analogous to __DRIimageExtension::getCapabilities.
>> Then the DRI module will query [the loader] and advertise the
>> RGBX/RGBA visuals when possible.
>
> Could we do something compile time instead to enable just for Android?
> Seems like a lot of complexity when the platform needing these pixel
> formats doesn't need the backwards compatibility. Or maybe there are
> other things needing this interface?
>
Having a short/mid term ifdef ANDROID is perfectly fine.

Can we address some of the existing ones before/alongside the newly added ones?
Afacit the nouveau bits are no longer applicable. While for the
gbm/egl 'use "gallium_dri.so"' one can either use your latest build
rework or MESA_LOADER_DRIVER_OVERRIDE.

Thanks
Emil
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] Android: r600: fix build when LLVM is disabled

2017-05-19 Thread Emil Velikov
Jfyi: feel free to add Fixes tag as you see fit. We parse though and
automatically nominate patches for -stable :-)
On 19 May 2017 at 13:04, Rob Herring  wrote:
> On Fri, May 12, 2017 at 11:55 AM, Rob Herring  wrote:
>> There's still an error after my recent clean-up if LLVM is not patched to
>> enable AMDGPU target:
>>
>> external/mesa3d/src/amd/common/ac_llvm_util.c:38:2: error: implicit 
>> declaration of function 'LLVMInitializeAMDGPUTargetInfo' is invalid in C99 
>> [-Werror,-Wimplicit-function-declaration]
>> LLVMInitializeAMDGPUTargetInfo();
>> ^
>> external/mesa3d/src/amd/common/ac_llvm_util.c:39:2: error: implicit 
>> declaration of function 'LLVMInitializeAMDGPUTarget' is invalid in C99 
>> [-Werror,-Wimplicit-function-declaration]
>> LLVMInitializeAMDGPUTarget();
>> ^
>> external/mesa3d/src/amd/common/ac_llvm_util.c:40:2: error: implicit 
>> declaration of function 'LLVMInitializeAMDGPUTargetMC' is invalid in C99 
>> [-Werror,-Wimplicit-function-declaration]
>> LLVMInitializeAMDGPUTargetMC();
>> ^
>> external/mesa3d/src/amd/common/ac_llvm_util.c:41:2: error: implicit 
>> declaration of function 'LLVMInitializeAMDGPUAsmPrinter' is invalid in C99 
>> [-Werror,-Wimplicit-function-declaration]
>> LLVMInitializeAMDGPUAsmPrinter();
>> ^
>>
>> We need to drop libmesa_amd_common when LLVM is disabled, however there's
>> still a dependency on include paths for ac_binary.h. So explicitly add the
>> include path when LLVM is disabled.
>
> Emil, can you please apply.
>
Done, alongside the virgl patch.
Might be worth getting a fd.o account [1] if you don't have one already.

Jfyi: feel free to add Fixes tag as you see fit. We parse though and
automatically nominate patches for -stable :-)

Thanks
Emil

[1] https://www.freedesktop.org/wiki/AccountRequests/
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH v13 07/36] egl: implement eglQueryDmaBufModifiersEXT

2017-05-19 Thread Jason Ekstrand
Just FYI: I'm not checking that you implement the EGL API correctly.  I'm
mostly checking for whether or not it's using DRI correctly.

On Fri, May 19, 2017 at 2:37 AM, Daniel Stone  wrote:

> From: Varad Gautam 
>
> query and return supported dmabuf format modifiers for
> EGL_EXT_image_dma_buf_import_modifiers.
>
> v2: move format check to the driver instead of making format queries
> here and then checking.
> v3: Check DRIimageExtension version before query (Daniel Stone)
>
> Signed-off-by: Varad Gautam 
> Reviewed-by: Daniel Stone 
> Signed-off-by: Daniel Stone 
> ---
>  src/egl/drivers/dri2/egl_dri2.c | 36 
>  src/egl/main/eglapi.c   | 20 
>  src/egl/main/eglapi.h   |  5 +
>  src/egl/main/eglentrypoint.h|  1 +
>  4 files changed, 62 insertions(+)
>
> diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_
> dri2.c
> index 55b6fcf1fc..1e0302359f 100644
> --- a/src/egl/drivers/dri2/egl_dri2.c
> +++ b/src/egl/drivers/dri2/egl_dri2.c
> @@ -2131,6 +2131,41 @@ dri2_query_dma_buf_formats(_EGLDriver *drv,
> _EGLDisplay *disp,
> return EGL_TRUE;
>  }
>
> +static EGLBoolean
> +dri2_query_dma_buf_modifiers(_EGLDriver *drv, _EGLDisplay *disp, EGLint
> format,
> + EGLint max, EGLuint64KHR *modifiers,
> + EGLBoolean *external_only, EGLint *count)
> +{
> +   struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
> +   EGLint i;
> +
> +   if (max < 0) {
> +  _eglError(EGL_BAD_PARAMETER, "invalid value for max count of
> formats");
> +  return EGL_FALSE;
> +   }
> +
> +   if (max > 0 && modifiers == NULL) {
> +  _eglError(EGL_BAD_PARAMETER, "invalid modifiers array");
> +  return EGL_FALSE;
> +   }
> +
> +   if (dri2_dpy->image->base.version < 16)
>

Check for the function pointer...


> +  return EGL_FALSE;
> +
> +   if (dri2_dpy->image->queryDmaBufModifiers(dri2_dpy->dri_screen,
> format,
> + max, modifiers,
> + count) == false) {
> +  _eglError(EGL_BAD_PARAMETER, "invalid format");
> +  return EGL_FALSE;
> +   }
> +   if (external_only != NULL) {
> +  for (i = 0; i < *count && i < max; i++)
> + external_only[i] = EGL_TRUE;
> +   }
> +
> +   return EGL_TRUE;
> +}
> +
>  /**
>   * The spec says:
>   *
> @@ -3064,6 +3099,7 @@ _eglBuiltInDriverDRI2(const char *args)
> dri2_drv->base.API.ExportDMABUFImageQueryMESA =
> dri2_export_dma_buf_image_query_mesa;
> dri2_drv->base.API.ExportDMABUFImageMESA = dri2_export_dma_buf_image_
> mesa;
> dri2_drv->base.API.QueryDmaBufFormatsEXT = dri2_query_dma_buf_formats;
> +   dri2_drv->base.API.QueryDmaBufModifiersEXT =
> dri2_query_dma_buf_modifiers;
>  #endif
>  #ifdef HAVE_WAYLAND_PLATFORM
> dri2_drv->base.API.BindWaylandDisplayWL =
> dri2_bind_wayland_display_wl;
> diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c
> index e83e3a414e..d0755ec652 100644
> --- a/src/egl/main/eglapi.c
> +++ b/src/egl/main/eglapi.c
> @@ -2403,6 +2403,26 @@ eglQueryDmaBufFormatsEXT(EGLDisplay dpy, EGLint
> max_formats,
> RETURN_EGL_EVAL(disp, ret);
>  }
>
> +static EGLBoolean EGLAPIENTRY
> +eglQueryDmaBufModifiersEXT(EGLDisplay dpy, EGLint format, EGLint
> max_modifiers,
> +   EGLuint64KHR *modifiers, EGLBoolean
> *external_only,
> +   EGLint *num_modifiers)
> +{
> +   _EGLDisplay *disp = _eglLockDisplay(dpy);
> +   _EGLDriver *drv;
> +   EGLBoolean ret;
> +
> +   _EGL_FUNC_START(NULL, EGL_NONE, NULL, EGL_FALSE);
> +
> +   _EGL_CHECK_DISPLAY(disp, EGL_FALSE, drv);
> +
> +   ret = drv->API.QueryDmaBufModifiersEXT(drv, disp, format,
> max_modifiers,
> +  modifiers, external_only,
> +  num_modifiers);
> +
> +   RETURN_EGL_EVAL(disp, ret);
> +}
> +
>  __eglMustCastToProperFunctionPointerType EGLAPIENTRY
>  eglGetProcAddress(const char *procname)
>  {
> diff --git a/src/egl/main/eglapi.h b/src/egl/main/eglapi.h
> index c9f98963db..cab3e9605a 100644
> --- a/src/egl/main/eglapi.h
> +++ b/src/egl/main/eglapi.h
> @@ -202,6 +202,11 @@ struct _egl_api
> EGLBoolean (*QueryDmaBufFormatsEXT)(_EGLDriver *drv, _EGLDisplay *dpy,
> EGLint max_formats, EGLint
> *formats,
> EGLint *num_formats);
> +   EGLBoolean (*QueryDmaBufModifiersEXT) (_EGLDriver *drv, _EGLDisplay
> *dpy,
> +  EGLint format, EGLint
> max_modifiers,
> +  EGLuint64KHR *modifiers,
> +  EGLBoolean *external_only,
> +  EGLint *num_modifiers);
>  };
>
>  

[Mesa-dev] [PATCH] automake: add SWR LLVM gen_builder.hpp workaround

2017-05-19 Thread Emil Velikov
From: Emil Velikov 

As gen_builder.hpp file is generated, it contains information that is
specific to the LLVM version it originates from.

As suggested by Tim, the file seems to be forwards compatible. So in
order to produce ship a file which will work everywhere we should be
using earlies supported LLVM - 3.9.

With this we're back on track and can build all of mesa without
python/mako/flex and friends.

In the long term we might want to see if the python generators can be
updated to produce LLVM version agnostic files. At least within the
range supported by SWR.

Cc: 
Cc: Chuck Atkins 
Cc: Tim Rowley 
Signed-off-by: Emil Velikov 
---
 configure.ac|  4 
 src/gallium/drivers/swr/Makefile.am | 41 ++---
 2 files changed, 15 insertions(+), 30 deletions(-)

diff --git a/configure.ac b/configure.ac
index ce5301f3e45..3d10a4b8935 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2472,6 +2472,10 @@ if test -n "$with_gallium_drivers"; then
 done
 fi
 
+# XXX: Keep in sync with LLVM_REQUIRED_SWR
+AM_CONDITIONAL(SWR_INVALID_LLVM_VERSION, test "x$LLVM_VERSION" != x3.9.0 -a \
+  "x$LLVM_VERSION" != x3.9.1)
+
 if test "x$enable_llvm" = "xyes" -a "$with_gallium_drivers"; then
 llvm_require_version $LLVM_REQUIRED_GALLIUM "gallium"
 llvm_add_default_components "gallium"
diff --git a/src/gallium/drivers/swr/Makefile.am 
b/src/gallium/drivers/swr/Makefile.am
index 0d71f52b1e6..7b2da074162 100644
--- a/src/gallium/drivers/swr/Makefile.am
+++ b/src/gallium/drivers/swr/Makefile.am
@@ -56,6 +56,7 @@ BUILT_SOURCES = \
rasterizer/codegen/gen_knobs.cpp \
rasterizer/codegen/gen_knobs.h \
rasterizer/jitter/gen_state_llvm.h \
+   rasterizer/jitter/gen_builder.hpp \
rasterizer/jitter/gen_builder_x86.hpp \
rasterizer/archrast/gen_ar_event.hpp \
rasterizer/archrast/gen_ar_event.cpp \
@@ -168,20 +169,6 @@ COMMON_LDFLAGS = \
$(LLVM_LDFLAGS)
 
 
-# XXX: As we cannot use BUILT_SOURCES (the files will end up in the dist
-# tarball) just annotate the dependency directly.
-# As the single direct user of gen_builder.hpp is a header (builder.h) trace 
all
-# the translusive users (one that use the latter header).
-rasterizer/jitter/blend_jit.cpp: rasterizer/jitter/gen_builder.hpp
-rasterizer/jitter/builder.cpp: rasterizer/jitter/gen_builder.hpp
-rasterizer/jitter/builder_misc.cpp: rasterizer/jitter/gen_builder.hpp
-rasterizer/jitter/fetch_jit.cpp: rasterizer/jitter/gen_builder.hpp
-rasterizer/jitter/streamout_jit.cpp: rasterizer/jitter/gen_builder.hpp
-swr_shader.cpp: rasterizer/jitter/gen_builder.hpp
-
-CLEANFILES = \
-   rasterizer/jitter/gen_builder.hpp
-
 lib_LTLIBRARIES = libswrAVX.la libswrAVX2.la
 
 libswrAVX_la_CXXFLAGS = \
@@ -192,14 +179,6 @@ libswrAVX_la_CXXFLAGS = \
 libswrAVX_la_SOURCES = \
$(COMMON_SOURCES)
 
-# XXX: Don't ship these generated sources for now, since they are specific
-# to the LLVM version they are generated from. Thus a release tarball
-# containing the said files, generated against eg. LLVM 3.8 will fail to build
-# on systems with other versions of LLVM eg. 3.7 or 3.6.
-# Move these back to BUILT_SOURCES once that is resolved.
-nodist_libswrAVX_la_SOURCES = \
-   rasterizer/jitter/gen_builder.hpp
-
 libswrAVX_la_LIBADD = \
$(COMMON_LIBADD)
 
@@ -214,14 +193,6 @@ libswrAVX2_la_CXXFLAGS = \
 libswrAVX2_la_SOURCES = \
$(COMMON_SOURCES)
 
-# XXX: Don't ship these generated sources for now, since they are specific
-# to the LLVM version they are generated from. Thus a release tarball
-# containing the said files, generated against eg. LLVM 3.8 will fail to build
-# on systems with other versions of LLVM eg. 3.7 or 3.6.
-# Move these back to BUILT_SOURCES once that is resolved.
-nodist_libswrAVX2_la_SOURCES = \
-   rasterizer/jitter/gen_builder.hpp
-
 libswrAVX2_la_LIBADD = \
$(COMMON_LIBADD)
 
@@ -230,6 +201,16 @@ libswrAVX2_la_LDFLAGS = \
 
 include $(top_srcdir)/install-gallium-links.mk
 
+# Generated gen_builder.hpp is not backwards compatible. So ship only one
+# created with the oldest supported version of LLVM.
+dist-hook:
+if SWR_INVALID_LLVM_VERSION
+   @echo "***"
+   @echo "LLVM 3.9.0 or LLVM 3.9.1 required to create the tarball"
+   @echo "***"
+   @test
+endif
+
 EXTRA_DIST = \
SConscript \
rasterizer/archrast/events.proto \
-- 
2.12.2

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


Re: [Mesa-dev] [PATCH] android: add -Wl, --build-id=sha1 to LDFLAGS for libvulkan_intel

2017-05-19 Thread Jason Ekstrand
Reviewed-by: Jason Ekstrand 

On Fri, May 19, 2017 at 4:25 AM, Tapani Pälli 
wrote:

> Just like is done on desktop and what is expected by the build-id code.
>
> Signed-off-by: Tapani Pälli 
> ---
>
> Jason, I commented before that this did not work but it seems I had other
> changes when testing that screwed up things, sorry for that, this works
> just fine!
>
>  src/intel/Android.vulkan.mk | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/src/intel/Android.vulkan.mk b/src/intel/Android.vulkan.mk
> index adb2a93..be23a00 100644
> --- a/src/intel/Android.vulkan.mk
> +++ b/src/intel/Android.vulkan.mk
> @@ -209,6 +209,8 @@ include $(CLEAR_VARS)
>  LOCAL_MODULE := libvulkan_intel
>  LOCAL_MODULE_CLASS := SHARED_LIBRARIES
>
> +LOCAL_LDFLAGS += -Wl,--build-id=sha1
> +
>  LOCAL_SRC_FILES := \
> $(VULKAN_GEM_FILES)
>
> --
> 2.9.3
>
>
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH v13 06/36] egl: implement eglQueryDmaBufFormatsEXT

2017-05-19 Thread Jason Ekstrand
On Fri, May 19, 2017 at 2:37 AM, Daniel Stone  wrote:

> From: Varad Gautam 
>
> allow egl clients to query the dmabuf formats supported on this platform.
>
> v2: return EGLBoolean.
> v3: Check DRIimageExtension version before querying (Daniel Stone)
>
> Signed-off-by: Louis-Francis Ratté-Boulianne 
> Signed-off-by: Varad Gautam 
> Reviewed-by: Daniel Stone 
> Signed-off-by: Daniel Stone 
> ---
>  src/egl/drivers/dri2/egl_dri2.c | 21 +
>  src/egl/main/eglapi.c   | 18 ++
>  src/egl/main/eglapi.h   |  4 
>  src/egl/main/eglentrypoint.h|  1 +
>  4 files changed, 44 insertions(+)
>
> diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_
> dri2.c
> index f06b5535c7..55b6fcf1fc 100644
> --- a/src/egl/drivers/dri2/egl_dri2.c
> +++ b/src/egl/drivers/dri2/egl_dri2.c
> @@ -2111,6 +2111,26 @@ dri2_check_dma_buf_format(const _EGLImageAttribs
> *attrs)
> return plane_n;
>  }
>
> +static EGLBoolean
> +dri2_query_dma_buf_formats(_EGLDriver *drv, _EGLDisplay *disp,
> +EGLint max, EGLint *formats, EGLint *count)
> +{
> +   struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
> +   if (max < 0 || (max > 0 && formats == NULL)) {
> +  _eglError(EGL_BAD_PARAMETER, "invalid value for max count of
> formats");
> +  return EGL_FALSE;
> +   }
> +
> +   if (dri2_dpy->image->base.version < 16)
>

I think you need to also check for the existance of the function pointer.


> +  return EGL_FALSE;
> +
> +   if (!dri2_dpy->image->queryDmaBufFormats(dri2_dpy->dri_screen, max,
> +formats, count))
> +  return EGL_FALSE;
> +
> +   return EGL_TRUE;
> +}
> +
>  /**
>   * The spec says:
>   *
> @@ -3043,6 +3063,7 @@ _eglBuiltInDriverDRI2(const char *args)
> dri2_drv->base.API.ExportDRMImageMESA = dri2_export_drm_image_mesa;
> dri2_drv->base.API.ExportDMABUFImageQueryMESA =
> dri2_export_dma_buf_image_query_mesa;
> dri2_drv->base.API.ExportDMABUFImageMESA = dri2_export_dma_buf_image_
> mesa;
> +   dri2_drv->base.API.QueryDmaBufFormatsEXT = dri2_query_dma_buf_formats;
>  #endif
>  #ifdef HAVE_WAYLAND_PLATFORM
> dri2_drv->base.API.BindWaylandDisplayWL =
> dri2_bind_wayland_display_wl;
> diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c
> index 9cea2f41ff..e83e3a414e 100644
> --- a/src/egl/main/eglapi.c
> +++ b/src/egl/main/eglapi.c
> @@ -2385,6 +2385,24 @@ _eglFunctionCompare(const void *key, const void
> *elem)
> return strcmp(procname, entrypoint->name);
>  }
>
> +static EGLBoolean EGLAPIENTRY
> +eglQueryDmaBufFormatsEXT(EGLDisplay dpy, EGLint max_formats,
> + EGLint *formats, EGLint *num_formats)
> +{
> +   _EGLDisplay *disp = _eglLockDisplay(dpy);
> +   _EGLDriver *drv;
> +   EGLBoolean ret;
> +
> +   _EGL_FUNC_START(NULL, EGL_NONE, NULL, EGL_FALSE);
> +
> +   _EGL_CHECK_DISPLAY(disp, EGL_FALSE, drv);
> +
> +   ret = drv->API.QueryDmaBufFormatsEXT(drv, disp, max_formats, formats,
> +num_formats);
> +
> +   RETURN_EGL_EVAL(disp, ret);
> +}
> +
>  __eglMustCastToProperFunctionPointerType EGLAPIENTRY
>  eglGetProcAddress(const char *procname)
>  {
> diff --git a/src/egl/main/eglapi.h b/src/egl/main/eglapi.h
> index 710c5d860a..c9f98963db 100644
> --- a/src/egl/main/eglapi.h
> +++ b/src/egl/main/eglapi.h
> @@ -198,6 +198,10 @@ struct _egl_api
> int (*GLInteropExportObject)(_EGLDisplay *dpy, _EGLContext *ctx,
>  struct mesa_glinterop_export_in *in,
>  struct mesa_glinterop_export_out *out);
> +
> +   EGLBoolean (*QueryDmaBufFormatsEXT)(_EGLDriver *drv, _EGLDisplay *dpy,
> +   EGLint max_formats, EGLint
> *formats,
> +   EGLint *num_formats);
>  };
>
>  #ifdef __cplusplus
> diff --git a/src/egl/main/eglentrypoint.h b/src/egl/main/eglentrypoint.h
> index e6318b9311..91536239e9 100644
> --- a/src/egl/main/eglentrypoint.h
> +++ b/src/egl/main/eglentrypoint.h
> @@ -56,6 +56,7 @@ EGL_ENTRYPOINT(eglPostSubBufferNV)
>  EGL_ENTRYPOINT(eglQueryAPI)
>  EGL_ENTRYPOINT(eglQueryContext)
>  EGL_ENTRYPOINT(eglQueryDebugKHR)
> +EGL_ENTRYPOINT(eglQueryDmaBufFormatsEXT)
>  EGL_ENTRYPOINT(eglQueryString)
>  EGL_ENTRYPOINT(eglQuerySurface)
>  EGL_ENTRYPOINT(eglQueryWaylandBufferWL)
> --
> 2.13.0
>
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH v13 24/36] i965/miptree: Add a return for updating of winsys

2017-05-19 Thread Jason Ekstrand
It's a bit annoying, but I think this would all make more sense if we moved
23 and 24 to before 19.  Then we could drop no_aux from 21.  Then again,
I'm sure Ben has some good reason why that's not practical and I'm fine
with leaving the order as-is.  It's hard to review but there's a lot of
detangling going on so I think that's somewhat expected.

On Fri, May 19, 2017 at 2:38 AM, Daniel Stone  wrote:

> From: Ben Widawsky 
>
> There is nothing particularly useful to do currently if the update
> fails, but there is no point carrying on either. As a result, this has a
> behavior change.
>
> v2: Make the return type a bool (Topi)
>
> v3: Don't leak the bo if update_winsys_renderbuffer fails. (Jason)
>
> Signed-off-by: Ben Widawsky 
> Acked-by: Daniel Stone 
> Reviewed-by: Topi Pohjolainen  (v2)
> Signed-off-by: Daniel Stone 
> ---
>  src/mesa/drivers/dri/i965/brw_context.c   | 16 ++--
>  src/mesa/drivers/dri/i965/intel_mipmap_tree.c |  6 +++---
>  src/mesa/drivers/dri/i965/intel_mipmap_tree.h |  2 +-
>  3 files changed, 14 insertions(+), 10 deletions(-)
>
> diff --git a/src/mesa/drivers/dri/i965/brw_context.c
> b/src/mesa/drivers/dri/i965/brw_context.c
> index 1a2b64f73e..3ae84fd332 100644
> --- a/src/mesa/drivers/dri/i965/brw_context.c
> +++ b/src/mesa/drivers/dri/i965/brw_context.c
> @@ -1660,9 +1660,12 @@ intel_process_dri2_buffer(struct brw_context *brw,
>return;
> }
>
> -   intel_update_winsys_renderbuffer_miptree(brw, rb, bo,
> -drawable->w, drawable->h,
> -buffer->pitch);
> +   if (!intel_update_winsys_renderbuffer_miptree(brw, rb, bo,
> + drawable->w, drawable->h,
> + buffer->pitch)) {
> +  brw_bo_unreference(bo);
> +  return;
> +   }
>
> if (_mesa_is_front_buffer_drawing(fb) &&
> (buffer->attachment == __DRI_BUFFER_FRONT_LEFT ||
> @@ -1721,9 +1724,10 @@ intel_update_image_buffer(struct brw_context
> *intel,
> if (!buffer->aux_offset)
>rb->no_aux = true;
>
> -   intel_update_winsys_renderbuffer_miptree(intel, rb, buffer->bo,
> -buffer->width, buffer->height,
> -buffer->pitch);
> +   if (!intel_update_winsys_renderbuffer_miptree(intel, rb, buffer->bo,
> + buffer->width,
> buffer->height,
> + buffer->pitch))
> +  return;
>
> if (_mesa_is_front_buffer_drawing(fb) &&
> buffer_type == __DRI_IMAGE_BUFFER_FRONT &&
> diff --git a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
> b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
> index 9dca5cc435..edda132f7b 100644
> --- a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
> +++ b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
> @@ -870,7 +870,7 @@ intel_miptree_create_for_image(struct brw_context
> *intel,
>   * that will contain the actual rendering (which is lazily resolved to
>   * irb->singlesample_mt).
>   */
> -void
> +bool
>  intel_update_winsys_renderbuffer_miptree(struct brw_context *intel,
>   struct intel_renderbuffer *irb,
>   struct brw_bo *bo,
> @@ -937,12 +937,12 @@ intel_update_winsys_renderbuffer_miptree(struct
> brw_context *intel,
>   irb->mt = multisample_mt;
>}
> }
> -   return;
> +   return true;
>
>  fail:
> intel_miptree_release(>singlesample_mt);
> intel_miptree_release(>mt);
> -   return;
> +   return false;
>  }
>
>  struct intel_mipmap_tree*
> diff --git a/src/mesa/drivers/dri/i965/intel_mipmap_tree.h
> b/src/mesa/drivers/dri/i965/intel_mipmap_tree.h
> index 8ec1278d0b..15e81300a2 100644
> --- a/src/mesa/drivers/dri/i965/intel_mipmap_tree.h
> +++ b/src/mesa/drivers/dri/i965/intel_mipmap_tree.h
> @@ -717,7 +717,7 @@ intel_miptree_create_for_image(struct brw_context
> *intel,
> uint32_t pitch,
> uint32_t layout_flags);
>
> -void
> +bool
>  intel_update_winsys_renderbuffer_miptree(struct brw_context *intel,
>   struct intel_renderbuffer *irb,
>   struct brw_bo *bo,
> --
> 2.13.0
>
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 9/9] nouveau: s/nv04_surface_/nouveau_surface_/

2017-05-19 Thread Francisco Jerez
Ilia Mirkin  writes:

> I kinda see it both ways - yeah, the functions are the same and it's
> all shared, so your patch makes sense. OTOH, all of these functions
> (which do anything) have a nv04/nv10/nv20 prefix, which makes it
> easier to separate stuff out by generation if need be. So I think in a
> perfect world, the actual copy/fill functions would stay, while the
> helpers would move up to nouveau_surface (esp if one were to grow a
> nv10-specific impl). But this extends the API considerably, for
> basically silly reasons. But the current state of the driver is that
> there are no instances of BEGIN_NV04 or any pushbuf stuff in the
> nouveau_* files.
>
> Curro, since you're the original author of the driver, what do you
> think about this and the previous patch?
>

My intention here (and in most of the dri/nouveau driver codebase) was
to reserve the nouveau_ prefix for source files and functions managing
driver-wide hardware-independent data structures, and the nvXX_ prefixes
for the source files doing the actual hardware poking for generation
nvXX and later.  Does this explanation make the current split between
nv04_ and nouveau_surface seem more reasonable to you, Ian?

> On Fri, May 19, 2017 at 9:38 AM, Ian Romanick  wrote:
>> From: Ian Romanick 
>>
>> After moving the contents of nv04_surface.c to nouveau_surface.c, rename
>> all the functions.
>>
>> Signed-off-by: Ian Romanick 
>> Cc: Ilia Mirkin 
>> ---
>>  src/mesa/drivers/dri/nouveau/nouveau_surface.c | 60 
>> +-
>>  src/mesa/drivers/dri/nouveau/nouveau_surface.h | 18 
>>  src/mesa/drivers/dri/nouveau/nv04_context.c|  8 ++--
>>  src/mesa/drivers/dri/nouveau/nv10_context.c|  8 ++--
>>  src/mesa/drivers/dri/nouveau/nv20_context.c|  8 ++--
>>  5 files changed, 51 insertions(+), 51 deletions(-)
>>
>> diff --git a/src/mesa/drivers/dri/nouveau/nouveau_surface.c 
>> b/src/mesa/drivers/dri/nouveau/nouveau_surface.c
>> index af5c924..e3cd3c3 100644
>> --- a/src/mesa/drivers/dri/nouveau/nouveau_surface.c
>> +++ b/src/mesa/drivers/dri/nouveau/nouveau_surface.c
>> @@ -253,11 +253,11 @@ sifm_format(mesa_format format)
>>  }
>>
>>  static void
>> -nv04_surface_copy_swizzle(struct gl_context *ctx,
>> - struct nouveau_surface *dst,
>> - struct nouveau_surface *src,
>> - int dx, int dy, int sx, int sy,
>> - int w, int h)
>> +nouveau_surface_copy_swizzle(struct gl_context *ctx,
>> +struct nouveau_surface *dst,
>> +struct nouveau_surface *src,
>> +int dx, int dy, int sx, int sy,
>> +int w, int h)
>>  {
>> struct nouveau_pushbuf_refn refs[] = {
>> { src->bo, NOUVEAU_BO_RD | NOUVEAU_BO_VRAM | NOUVEAU_BO_GART 
>> },
>> @@ -334,11 +334,11 @@ nv04_surface_copy_swizzle(struct gl_context *ctx,
>>  }
>>
>>  static void
>> -nv04_surface_copy_m2mf(struct gl_context *ctx,
>> -  struct nouveau_surface *dst,
>> -  struct nouveau_surface *src,
>> -  int dx, int dy, int sx, int sy,
>> -  int w, int h)
>> +nouveau_surface_copy_m2mf(struct gl_context *ctx,
>> + struct nouveau_surface *dst,
>> + struct nouveau_surface *src,
>> + int dx, int dy, int sx, int sy,
>> + int w, int h)
>>  {
>> struct nouveau_pushbuf_refn refs[] = {
>> { src->bo, NOUVEAU_BO_RD | NOUVEAU_BO_VRAM | NOUVEAU_BO_GART 
>> },
>> @@ -422,11 +422,11 @@ get_swizzled_offset(struct nouveau_surface *s, 
>> unsigned x, unsigned y)
>>  }
>>
>>  static void
>> -nv04_surface_copy_cpu(struct gl_context *ctx,
>> - struct nouveau_surface *dst,
>> - struct nouveau_surface *src,
>> - int dx, int dy, int sx, int sy,
>> - int w, int h)
>> +nouveau_surface_copy_cpu(struct gl_context *ctx,
>> +struct nouveau_surface *dst,
>> +struct nouveau_surface *src,
>> +int dx, int dy, int sx, int sy,
>> +int w, int h)
>>  {
>> int x, y;
>> get_offset_t get_dst = (dst->layout == SWIZZLED ?
>> @@ -450,11 +450,11 @@ nv04_surface_copy_cpu(struct gl_context *ctx,
>>  }
>>
>>  void
>> -nv04_surface_copy(struct gl_context *ctx,
>> - struct nouveau_surface *dst,
>> - struct nouveau_surface *src,
>> - int dx, int dy, int sx, int sy,
>> - int w, int h)
>> +nouveau_surface_copy(struct gl_context *ctx,
>> +struct nouveau_surface *dst,
>> +struct nouveau_surface *src,
>> + 

Re: [Mesa-dev] Bug in 17.1.0-rc4 source packaging for swr?

2017-05-19 Thread Chuck Atkins
Would it be feasible for packaging purposes to generate multiple headers,
i.e. gen_builder._llvm38.hpp, gen_builder_llvm39.hpp,
gen_builder_llvm40.hpp, etc. and then have gen_builder.hpp be a stub that
just has something like:

#include 
#if llvm_version >= 4.0
#include "gen_builder_llvm40.hpp"
#elif llvm_version >= 3.9
#include "gen_builder_llvm39.hpp"
#elif llvm_version >= 3.8
#include "gen_builder_llvm38.hpp"
#else
#error llvm version >= 3.8 is required
#elif

Using the appropriate version checks of course (this is just pseudo code to
show the concept)


--
Chuck Atkins
Staff R Engineer, Scientific Computing
Kitware, Inc.


On Thu, May 18, 2017 at 2:06 PM, Kai Wasserbäch 
wrote:

> Hey,
> Emil Velikov wrote on 18.05.2017 18:17:
> > On 18 May 2017 at 16:34, Rowley, Timothy O 
> wrote:
> >> We could use a gen_builder.h generated from llvm-3.9 for all current
> >> versions of llvm at this time (as the changes are now just llvm IR
> >> additions), but I’m not sure how to enforce that the person creating the
> >> tarball has a particular version of llvm installed.
> >>
> > Must admit that I don't know much about LLVM or SWR, so I hope you've
> > thoroughly tested LLVM 3.9 generated files built with LLVM 4.0 or
> > later.
> > Using LLVM 3.9 should be doable, but I'm curious if we can avoid such
> > 'acrobatics' in the long run.
> >
> > Any ideas, if that's at all possible?
>
> how about the SWR maintainers provide a "golden" fallback file, that is
> pre-generated and known good for all supported LLVM (right now I would
> guess
> that to be 3.9 and 4.0) versions? That file is always shipped in the
> tarball.
>
> During build there's a rule, that checks if $generator is there. If not,
> the
> fallback file is copied to the correct name, otherwise the regular
> generation
> takes place.
>
> Cheers,
> Kai
>
>
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
>
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH v13 21/36] i965: Restructure CCS disabling

2017-05-19 Thread Jason Ekstrand
On Fri, May 19, 2017 at 2:38 AM, Daniel Stone  wrote:

> From: Ben Widawsky 
>
> Make the code only disable CCS when it has to, unlike before where it
> disabled CCS and enabled it when it could. This is much more inline with
> how it should work in a few patches, where we have fewer restrictions as
> to when we disable CCS.
>
> v2: Change CCS disabling to an assertion in layout creation (Topi)
>
> v3: Make sure to disable aux buffers when creating a miptree from a BO.
> Today, this only happens via intel_update_image_buffer. At the end of
> the modifier series, we should be able to undo this. Some fixes from
> Topi in here as well.
>
> Cc: "Pohjolainen, Topi" 
> Signed-off-by: Ben Widawsky 
>
> Topi's changes
>
> Signed-off-by: Daniel Stone 
> ---
>  src/mesa/drivers/dri/i965/brw_context.c   |  3 +++
>  src/mesa/drivers/dri/i965/intel_fbo.h |  7 +++
>  src/mesa/drivers/dri/i965/intel_mipmap_tree.c | 22 +-
>  3 files changed, 23 insertions(+), 9 deletions(-)
>
> diff --git a/src/mesa/drivers/dri/i965/brw_context.c
> b/src/mesa/drivers/dri/i965/brw_context.c
> index 5055dd76a8..1a2b64f73e 100644
> --- a/src/mesa/drivers/dri/i965/brw_context.c
> +++ b/src/mesa/drivers/dri/i965/brw_context.c
> @@ -1718,6 +1718,9 @@ intel_update_image_buffer(struct brw_context *intel,
> if (last_mt && last_mt->bo == buffer->bo)
>return;
>
> +   if (!buffer->aux_offset)
> +  rb->no_aux = true;
> +
> intel_update_winsys_renderbuffer_miptree(intel, rb, buffer->bo,
>  buffer->width, buffer->height,
>  buffer->pitch);
> diff --git a/src/mesa/drivers/dri/i965/intel_fbo.h
> b/src/mesa/drivers/dri/i965/intel_fbo.h
> index 08b82e8934..9265aab2e2 100644
> --- a/src/mesa/drivers/dri/i965/intel_fbo.h
> +++ b/src/mesa/drivers/dri/i965/intel_fbo.h
> @@ -111,6 +111,13 @@ struct intel_renderbuffer
>  * for the duration of a mapping.
>  */
> bool singlesample_mt_is_tmp;
> +
> +   /**
> +* Set to true if this buffer definitely does not have auxiliary data,
> like
> +* CCS, associated with it. It's generally to be used when importing a
> +* DRIimage, where that DRIimage had no modifier.
> +*/
> +   bool no_aux;
>

I think I would mildly prefer the stuff having to do with this bool to be
its own patch right after this one.


>  };
>
>
> diff --git a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
> b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
> index a8564d9573..9dca5cc435 100644
> --- a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
> +++ b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
> @@ -328,7 +328,6 @@ intel_miptree_create_layout(struct brw_context *brw,
> mt->logical_depth0 = depth0;
> mt->aux_disable = (layout_flags & MIPTREE_LAYOUT_DISABLE_AUX) != 0 ?
>INTEL_AUX_DISABLE_ALL : INTEL_AUX_DISABLE_NONE;
> -   mt->aux_disable |= INTEL_AUX_DISABLE_CCS;
> mt->is_scanout = (layout_flags & MIPTREE_LAYOUT_FOR_SCANOUT) != 0;
> exec_list_make_empty(>hiz_map);
> exec_list_make_empty(>color_resolve_map);
> @@ -521,6 +520,8 @@ intel_miptree_create_layout(struct brw_context *brw,
> } else if (brw->gen >= 9 && num_samples > 1) {
>layout_flags |= MIPTREE_LAYOUT_FORCE_HALIGN16;
> } else {
> +  mt->aux_disable |= INTEL_AUX_DISABLE_CCS;
> +
>const UNUSED bool is_lossless_compressed_aux =
>   brw->gen >= 9 && num_samples == 1 &&
>   mt->format == MESA_FORMAT_R_UINT32;
> @@ -696,7 +697,6 @@ intel_miptree_create(struct brw_context *brw,
>  */
> if (intel_tiling_supports_non_msrt_mcs(brw, mt->tiling) &&
> intel_miptree_supports_non_msrt_fast_clear(brw, mt)) {
> -  mt->aux_disable &= ~INTEL_AUX_DISABLE_CCS;
>assert(brw->gen < 8 || mt->halign == 16 || num_samples <= 1);
>
>/* On Gen9+ clients are not currently capable of consuming
> compressed
> @@ -710,8 +710,11 @@ intel_miptree_create(struct brw_context *brw,
>   intel_miptree_supports_lossless_compressed(brw, mt);
>
>if (is_lossless_compressed) {
> + assert((mt->aux_disable & INTEL_AUX_DISABLE_CCS) == 0);
>

Mind making this assert(!(thing)) rather than assert((thing) == 0)?  That
would match the one a few lines below.


>   intel_miptree_alloc_non_msrt_mcs(brw, mt,
> is_lossless_compressed);
>}
> +   } else {
> +  mt->aux_disable |= INTEL_AUX_DISABLE_CCS;
> }
>
> return mt;
> @@ -803,7 +806,7 @@ create_ccs_buf_for_image(struct brw_context *intel,
> mt->mcs_buf->qpitch = isl_surf_get_array_pitch_sa_
> rows(_ccs_surf);
>
> intel_miptree_init_mcs(intel, mt, 0);
> -   mt->aux_disable &= ~INTEL_AUX_DISABLE_CCS;
> +   assert(!(mt->aux_disable & INTEL_AUX_DISABLE_CCS));
> mt->msaa_layout = INTEL_MSAA_LAYOUT_CMS;
>
> return true;
> @@ -894,18 +897,19 @@ 

Re: [Mesa-dev] [PATCH 2/2] i965: Enable ASTC HDR for Broxton

2017-05-19 Thread Nanley Chery
On Fri, May 19, 2017 at 10:41:22AM -0700, Anuj Phogat wrote:
> On Thu, May 18, 2017 at 3:53 PM, Nanley Chery  wrote:
> > This platform passes the following GLES3 tests:
> > ES3-CTS.functional.texture.compressed.astc.endpoint_value_hdr_cem_*
> >
> We've hdr tests in piglit as well. With those passing, both patches are:
> Reviewed-by: Anuj Phogat 
> 

I've confirmed the piglit tests to be passing as well. Thanks!

> > Signed-off-by: Nanley Chery 
> > ---
> >  src/mesa/drivers/dri/i965/intel_extensions.c | 3 +++
> >  1 file changed, 3 insertions(+)
> >
> > diff --git a/src/mesa/drivers/dri/i965/intel_extensions.c 
> > b/src/mesa/drivers/dri/i965/intel_extensions.c
> > index 26c074638e..e76f61de1d 100644
> > --- a/src/mesa/drivers/dri/i965/intel_extensions.c
> > +++ b/src/mesa/drivers/dri/i965/intel_extensions.c
> > @@ -285,6 +285,9 @@ intelInitExtensions(struct gl_context *ctx)
> >ctx->Extensions.ARB_post_depth_coverage = true;
> > }
> >
> > +   if (brw->is_broxton)
> > +  ctx->Extensions.KHR_texture_compression_astc_hdr = true;
> > +
> > if (brw->gen >= 6)
> >ctx->Extensions.INTEL_performance_query = true;
> >
> > --
> > 2.12.2
> >
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [Mesa-stable] [PATCH] automake: add SWR LLVM gen_builder.hpp workaround

2017-05-19 Thread Rowley, Timothy O
Thanks for doing this; I would have been hunting for the dist-hook: magic for a 
while.

Tested “make dist” on llvm-3.9.0 (works) and llvm-4.0/llvm-svn (fails, expected 
desired behavior).

Built result of llvm-3.9.0 “make dist” with llvm-4.0 and llvm-svn and it 
compiles/works.

Reviewed-by: Tim Rowley 
>

On May 19, 2017, at 12:31 PM, Emil Velikov 
> wrote:

From: Emil Velikov 
>

As gen_builder.hpp file is generated, it contains information that is
specific to the LLVM version it originates from.

As suggested by Tim, the file seems to be forwards compatible. So in
order to produce ship a file which will work everywhere we should be
using earlies supported LLVM - 3.9.

With this we're back on track and can build all of mesa without
python/mako/flex and friends.

In the long term we might want to see if the python generators can be
updated to produce LLVM version agnostic files. At least within the
range supported by SWR.

Cc: 
>
Cc: Chuck Atkins >
Cc: Tim Rowley >
Signed-off-by: Emil Velikov 
>
---
configure.ac|  4 
src/gallium/drivers/swr/Makefile.am | 41 ++---
2 files changed, 15 insertions(+), 30 deletions(-)

diff --git a/configure.ac b/configure.ac
index ce5301f3e45..3d10a4b8935 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2472,6 +2472,10 @@ if test -n "$with_gallium_drivers"; then
done
fi

+# XXX: Keep in sync with LLVM_REQUIRED_SWR
+AM_CONDITIONAL(SWR_INVALID_LLVM_VERSION, test "x$LLVM_VERSION" != x3.9.0 -a \
+  "x$LLVM_VERSION" != x3.9.1)
+
if test "x$enable_llvm" = "xyes" -a "$with_gallium_drivers"; then
llvm_require_version $LLVM_REQUIRED_GALLIUM "gallium"
llvm_add_default_components "gallium"
diff --git a/src/gallium/drivers/swr/Makefile.am 
b/src/gallium/drivers/swr/Makefile.am
index 0d71f52b1e6..7b2da074162 100644
--- a/src/gallium/drivers/swr/Makefile.am
+++ b/src/gallium/drivers/swr/Makefile.am
@@ -56,6 +56,7 @@ BUILT_SOURCES = \
rasterizer/codegen/gen_knobs.cpp \
rasterizer/codegen/gen_knobs.h \
rasterizer/jitter/gen_state_llvm.h \
+ rasterizer/jitter/gen_builder.hpp \
rasterizer/jitter/gen_builder_x86.hpp \
rasterizer/archrast/gen_ar_event.hpp \
rasterizer/archrast/gen_ar_event.cpp \
@@ -168,20 +169,6 @@ COMMON_LDFLAGS = \
$(LLVM_LDFLAGS)


-# XXX: As we cannot use BUILT_SOURCES (the files will end up in the dist
-# tarball) just annotate the dependency directly.
-# As the single direct user of gen_builder.hpp is a header (builder.h) trace 
all
-# the translusive users (one that use the latter header).
-rasterizer/jitter/blend_jit.cpp: rasterizer/jitter/gen_builder.hpp
-rasterizer/jitter/builder.cpp: rasterizer/jitter/gen_builder.hpp
-rasterizer/jitter/builder_misc.cpp: rasterizer/jitter/gen_builder.hpp
-rasterizer/jitter/fetch_jit.cpp: rasterizer/jitter/gen_builder.hpp
-rasterizer/jitter/streamout_jit.cpp: rasterizer/jitter/gen_builder.hpp
-swr_shader.cpp: rasterizer/jitter/gen_builder.hpp
-
-CLEANFILES = \
- rasterizer/jitter/gen_builder.hpp
-
lib_LTLIBRARIES = libswrAVX.la 
libswrAVX2.la

libswrAVX_la_CXXFLAGS = \
@@ -192,14 +179,6 @@ libswrAVX_la_CXXFLAGS = \
libswrAVX_la_SOURCES = \
$(COMMON_SOURCES)

-# XXX: Don't ship these generated sources for now, since they are specific
-# to the LLVM version they are generated from. Thus a release tarball
-# containing the said files, generated against eg. LLVM 3.8 will fail to build
-# on systems with other versions of LLVM eg. 3.7 or 3.6.
-# Move these back to BUILT_SOURCES once that is resolved.
-nodist_libswrAVX_la_SOURCES = \
- rasterizer/jitter/gen_builder.hpp
-
libswrAVX_la_LIBADD = \
$(COMMON_LIBADD)

@@ -214,14 +193,6 @@ libswrAVX2_la_CXXFLAGS = \
libswrAVX2_la_SOURCES = \
$(COMMON_SOURCES)

-# XXX: Don't ship these generated sources for now, since they are specific
-# to the LLVM version they are generated from. Thus a release tarball
-# containing the said files, generated against eg. LLVM 3.8 will fail to build
-# on systems with other versions of LLVM eg. 3.7 or 3.6.
-# Move these back to BUILT_SOURCES once that is resolved.
-nodist_libswrAVX2_la_SOURCES = \
- rasterizer/jitter/gen_builder.hpp
-
libswrAVX2_la_LIBADD = \
$(COMMON_LIBADD)

@@ -230,6 +201,16 @@ libswrAVX2_la_LDFLAGS = \

include $(top_srcdir)/install-gallium-links.mk

+# Generated gen_builder.hpp is not backwards compatible. So ship only one
+# created with the oldest supported version of LLVM.
+dist-hook:
+if SWR_INVALID_LLVM_VERSION
+ @echo 

Re: [Mesa-dev] [PATCH 14/16] anv: Advertise both 32-bit and 48-bit heaps when we have enough memory

2017-05-19 Thread Gustaw Smolarczyk
2017-05-18 23:01 GMT+02:00 Jason Ekstrand :
> ---
>  src/intel/vulkan/anv_device.c | 42 --
>  1 file changed, 36 insertions(+), 6 deletions(-)
>
> diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c
> index 6ea8dfe..8eed7f3 100644
> --- a/src/intel/vulkan/anv_device.c
> +++ b/src/intel/vulkan/anv_device.c
> @@ -112,12 +112,42 @@ anv_physical_device_init_heaps(struct 
> anv_physical_device *device, int fd)
> if (result != VK_SUCCESS)
>return result;
>
> -   device->memory.heap_count = 1;
> -   device->memory.heaps[0] = (struct anv_memory_heap) {
> -  .size = heap_size,
> -  .flags = VK_MEMORY_HEAP_DEVICE_LOCAL_BIT,
> -  .supports_48bit_addresses = device->supports_48bit_addresses,
> -   };
> +   if (heap_size <= 3ull * (1ull << 30)) {
> +  /* In this case, everything fits nicely into the 32-bit address space,
> +   * so there's no need for supporting 48bit addresses on 
> clinet-allocated

Probably a typo: s/clinet/client/

> +   * memory objects.
> +   */
> +  device->memory.heap_count = 1;
> +  device->memory.heaps[0] = (struct anv_memory_heap) {
> + .size = heap_size,
> + .flags = VK_MEMORY_HEAP_DEVICE_LOCAL_BIT,
> + .supports_48bit_addresses = false,
> +  };
> +   } else {
> +  /* Not everything will fit nicely into a 32-bit address space.  In this
> +   * case we need a 64-bit heap.  Advertise a small 32-bit heap and a
> +   * larger 48-bit heap.  If we're in this case, then we have a total 
> heap
> +   * size larger than 3GiB which most likely means they have 8 GiB of
> +   * video memory and so carving off 2 GiB for the 32-bit heap should be
> +   * reasonable.
> +   */
> +  const uint32_t heap_size_32bit = 2ull * (1ull << 30);
> +  const uint32_t heap_size_48bit = heap_size - heap_size_32bit;

Is it really a good idea for these variables to be only 32-bit?
Especially the second one.

Regards,
Gustaw
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH] vulkan/wsi/wayland: Fix proxy wrappers for swapchain recreation

2017-05-19 Thread Philipp Zabel
Before the swapchain event queue is destroyed, all proxy objects that reference
it must be dropped. Otherwise we risk a use-after-free if a frame callback event
or buffer release events are received afterwards.
This happens when an application destroys and recreates a swapchain in FIFO
mode between two frames without using the VkSwapchainCreateInfoKHR::oldSwapchain
mechanism to keep the old swapchain until after the next redraw.

Fixes: 5034c615582a ("vulkan/wsi/wayland: Use proxy wrappers for swapchain")
Signed-off-by: Philipp Zabel 
Cc: mesa-sta...@lists.freedesktop.org
---
 src/vulkan/wsi/wsi_common_wayland.c | 13 ++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/src/vulkan/wsi/wsi_common_wayland.c 
b/src/vulkan/wsi/wsi_common_wayland.c
index 8950798882..644ed62b41 100644
--- a/src/vulkan/wsi/wsi_common_wayland.c
+++ b/src/vulkan/wsi/wsi_common_wayland.c
@@ -537,6 +537,7 @@ struct wsi_wl_swapchain {
struct wl_surface *  surface;
uint32_t surface_version;
struct wl_drm *  drm_wrapper;
+   struct wl_callback * frame;
 
VkExtent2D   extent;
VkFormat vk_format;
@@ -616,6 +617,7 @@ frame_handle_done(void *data, struct wl_callback *callback, 
uint32_t serial)
 {
struct wsi_wl_swapchain *chain = data;
 
+   chain->frame = NULL;
chain->fifo_ready = true;
 
wl_callback_destroy(callback);
@@ -658,8 +660,8 @@ wsi_wl_swapchain_queue_present(struct wsi_swapchain 
*wsi_chain,
}
 
if (chain->base.present_mode == VK_PRESENT_MODE_FIFO_KHR) {
-  struct wl_callback *frame = wl_surface_frame(chain->surface);
-  wl_callback_add_listener(frame, _listener, chain);
+  chain->frame = wl_surface_frame(chain->surface);
+  wl_callback_add_listener(chain->frame, _listener, chain);
   chain->fifo_ready = false;
}
 
@@ -741,12 +743,16 @@ wsi_wl_swapchain_destroy(struct wsi_swapchain *wsi_chain,
struct wsi_wl_swapchain *chain = (struct wsi_wl_swapchain *)wsi_chain;
 
for (uint32_t i = 0; i < chain->base.image_count; i++) {
-  if (chain->images[i].buffer)
+  if (chain->images[i].buffer) {
+ wl_buffer_destroy(chain->images[i].buffer);
  chain->base.image_fns->free_wsi_image(chain->base.device, pAllocator,
chain->images[i].image,
chain->images[i].memory);
+  }
}
 
+   if (chain->frame)
+  wl_callback_destroy(chain->frame);
if (chain->surface)
   wl_proxy_wrapper_destroy(chain->surface);
if (chain->drm_wrapper)
@@ -791,6 +797,7 @@ wsi_wl_surface_create_swapchain(VkIcdSurfaceBase 
*icd_surface,
chain->queue = NULL;
chain->surface = NULL;
chain->drm_wrapper = NULL;
+   chain->frame = NULL;
 
bool alpha = pCreateInfo->compositeAlpha ==
   VK_COMPOSITE_ALPHA_PRE_MULTIPLIED_BIT_KHR;
-- 
2.11.0

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


Re: [Mesa-dev] [PATCH 2/2] gallium: Add renderonly-based support for pl111+vc4.

2017-05-19 Thread Eric Anholt
Emil Velikov  writes:

> On 17 May 2017 at 20:13, Emil Velikov  wrote:
>> On 17 May 2017 at 18:53, Eric Anholt  wrote:
>>> Emil Velikov  writes:
>>>
 Hi Eric,

 On 11 May 2017 at 00:06, Eric Anholt  wrote:
> This follows the model of imx (display) and etnaviv (render): pl111 is a
> display-only device, so when asked to do GL for it, we see if we have a
> vc4 renderer, make the vc4 screen, and have vc4 call back to pl111 to do
> scanout allocations.
>
> The difference from etnaviv is that we share the same BO between vc4 and
> pl111, rather than having a vc4 bo and a pl11 bo and copies between the
> two.  The only mismatch between their requirements is that vc4 requires
> 4-pixel (at 32bpp) stride alignment, while pl111 requires that stride
> match width.  The kernel will reject any modesets to an incorrect stride,
> so the 3D driver doesn't need to worry about that.
> ---
 I'm not familiar with the hardware itself so I cannot comment on those.
 There's a couple of small notes within, but overall the patch looks good.

>  .travis.yml|  2 +-
>  Makefile.am|  2 +-
 Yes, thank you!


> --- a/Android.mk
> +++ b/Android.mk

>  classic_drivers := i915 i965
> -gallium_drivers := swrast freedreno i915g nouveau r300g r600g radeonsi 
> vmwgfx vc4 virgl
> +gallium_drivers := swrast freedreno i915g nouveau pl111 r300g r600g 
> radeonsi vmwgfx vc4 virgl
>
 The recent Android cleanups by RobH which will cause a clash. The gist
 is below, but feel free to skim through commit
 3f097396a1642bb7033002d0bdd37e194afce06a.
  - rework for the new gallium_drivers format
  - add a couple of lines in src/gallium/drivers/pl111/Android.mk
 analogous to the vc4 - the "ifneq $HAVE_foo" hunk
  - drop the guard in src/gallium/Android.mk


> +++ b/src/gallium/winsys/pl111/drm/pl111_drm_winsys.c

> -#include 
>  #include 
> +#include 
>
> -#include "vc4_drm_public.h"
> +#include "pl111_drm_public.h"
> +#include "vc4/drm/vc4_drm_public.h"
> +#include "xf86drm.h"
>
> -#include "vc4/vc4_screen.h"
> +#include "pipe/p_screen.h"
> +#include "renderonly/renderonly.h"

> +#include "util/u_format.h"
 Seems unused.

>
> -struct pipe_screen *
> -vc4_drm_screen_create(int fd)
> +struct pipe_screen *pl111_drm_screen_create(int fd)
>  {
> -   return vc4_screen_create(fcntl(fd, F_DUPFD_CLOEXEC, 3));
> +   struct renderonly ro = {
> +  /* Passes the vc4-allocated BO through to the pl111 DRM device 
> using
> +   * PRIME buffer sharing.  The VC4 BO must be linear, which the 
> SCANOUT
> +   * flag on allocation will have ensured.
> +   */
> +  .create_for_resource = renderonly_create_gpu_import_for_resource,
> +  .kms_fd = fd,
> +  .gpu_fd = drmOpenWithType("vc4", NULL, DRM_NODE_RENDER),
 Please don't use the drmOpen* API. It's a legacy dragon with very
 subtle and inner workings.
 Using drmGetDevice[s] should provide any information that you need.
 Alternatively please let us know what's missing so we can address it.
>>>
>>> One this platform, there are exactly two devices, one is vc4 and the
>>> other is pl111.  drmOpenWithType is exactly the API we want, and if you
>>> want something else, then you should probably replace its insides
>>> instead of telling people to use a different API.
>>
>> Changing the insides also changes the behaviour, which could break users :-\
>>
> A couple of things from our IRC chat last night:
>
> - My suggestion was never meant as requirement or a blocker. Let along
> "exerting control" as you call it :-\
> It's aimed to save you/others time since the drmOpen* API
> implementation is aimed for UMS and broken for KMS drivers.
>
> - You asked a couple of times "how this can break", despite my pointer
> to DanielV's summary [1] and some encouragement to skim through the
> drmOpen* code yourself.
> Now a bit less tired, here it is the exact scenario how/why things are broken.
>
> A) User opens the vc4 device and calls drmSetInterfaceVersion
> effectively populating the "unique name"
> Plymouth, modesetting ddx, Xserver itself and others can easily do so.
> B) Consecutive calls to  drmOpenWithType("vc4", NULL..) will fail
> since the drmGetBusid/GET_UNIQUE return the non-zero "unique name".
> That happens in drmOpenByName which considers the latter as "device
> already opened".

According to LIBGL_DEBUG=verbose, drmGetBusid is returning NULL on this
platform.  drm_getunique() is banned on render nodes, resulting in an
EACCES and drmGetBusid returns NULL.

Thanks for *finally* explaining your 

[Mesa-dev] [Bug 101110] Build failure in GNOME Continuous

2017-05-19 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=101110

Bug ID: 101110
   Summary: Build failure in GNOME Continuous
   Product: Mesa
   Version: git
  Hardware: Other
OS: All
Status: NEW
  Severity: normal
  Priority: medium
 Component: Other
  Assignee: mesa-dev@lists.freedesktop.org
  Reporter: eba...@gmail.com
QA Contact: mesa-dev@lists.freedesktop.org

Mesa compilation is failing in the GNOME Continuous integration builder:

script=../../../../../src/gallium/targets/xvmc/xvmc.sym   -Wl,-soname
-Wl,libXvMCgallium.so.1 -o .libs/libXvMCgallium.so.1.0.0
../../../../src/gallium/auxiliary/.libs/libgalliumvlwinsys.a(libgalliumvlwinsys_la-vl_winsys_dri3.o):
In function `vl_dri3_flush_frontbuffer':
/ostbuild/source/mesa/_build/src/gallium/auxiliary/../../../../src/gallium/auxiliary/vl/vl_winsys_dri3.c:571:
undefined reference to `xcb_xfixes_create_region'
../../../../src/gallium/auxiliary/.libs/libgalliumvlwinsys.a(libgalliumvlwinsys_la-vl_winsys_dri3.o):
In function `vl_dri3_screen_create':
/ostbuild/source/mesa/_build/src/gallium/auxiliary/../../../../src/gallium/auxiliary/vl/vl_winsys_dri3.c:768:
undefined reference to `xcb_xfixes_id'
/ostbuild/source/mesa/_build/src/gallium/auxiliary/../../../../src/gallium/auxiliary/vl/vl_winsys_dri3.c:775:
undefined reference to `xcb_xfixes_id'
/ostbuild/source/mesa/_build/src/gallium/auxiliary/../../../../src/gallium/auxiliary/vl/vl_winsys_dri3.c:779:
undefined reference to `xcb_xfixes_query_version'
/ostbuild/source/mesa/_build/src/gallium/auxiliary/../../../../src/gallium/auxiliary/vl/vl_winsys_dri3.c:781:
undefined reference to `xcb_xfixes_query_version_reply'

Full build log:
http://build.gnome.org/continuous/buildmaster/builds/2017/05/19/40/build/log-mesa.txt

Configuration options:

  "--disable-asm",
  "--enable-osmesa",
  "--with-dri-driverdir=/usr/lib/dri",
  "--enable-egl",
  "--enable-gles1",
  "--enable-gles2",
  "--with-egl-platforms=wayland,x11,drm",
  "--enable-shared-glapi",
  "--enable-gbm",
  "--enable-xa",
  "--with-llvm-config-dir=/usr/bin/llvm3.3",
  "--with-gallium-drivers=svga,r300,nouveau,swrast,virgl",
  "--enable-llvm",
  "--with-vulkan-drivers=intel",
  "--with-dri-drivers=nouveau,radeon,r200,i915,i965,swrast"

Configuration summary:

prefix:  /usr
exec_prefix: ${prefix}
libdir:  /usr/lib
includedir:  /usr/include

OpenGL:  yes (ES1: yes ES2: yes)

OSMesa:  libOSMesa

DRI platform:drm
DRI drivers: i915 i965 nouveau r200 radeon swrast 
DRI driver dir:  /usr/lib/dri
GLX: DRI-based

EGL: yes
EGL drivers: builtin:egl_dri2 builtin:egl_dri3
GBM: yes
EGL/Vulkan/VL platforms:   wayland x11 drm

Vulkan drivers:  intel 
Vulkan ICD dir:  ${datarootdir}/vulkan/icd.d

llvm:yes
llvm-config: /usr/bin/llvm3.3/x86_64-gnomeostree-linux-llvm-config
llvm-version:3.3

Gallium drivers: svga r300 nouveau swrast virgl
Gallium st:  mesa xa xvmc

HUD extra stats: no
HUD lmsensors:   no

Shared libs: yes
Static libs: no
Shared-glapi:yes

CFLAGS:  -g -m64 -mtune=generic -Wall -std=c99
-Werror=implicit-function-declaration -Werror=missing-prototypes
-fno-math-errno -fno-trapping-math
CXXFLAGS:-g -m64 -mtune=generic -Wall -fno-math-errno
-fno-trapping-math
LDFLAGS: 
Macros:  -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS
-D__STDC_LIMIT_MACROS -D_GNU_SOURCE -DUSE_SSE41 -DUSE_GCC_ATOMIC_BUILTINS
-DNDEBUG -DHAVE_XLOCALE_H -DHAVE_SYS_SYSCTL_H -DHAVE_STRTOF -DHAVE_MKOSTEMP
-DHAVE_DLOPEN -DHAVE_DL_ITERATE_PHDR -DHAVE_POSIX_MEMALIGN -DHAVE_LIBDRM
-DGLX_USE_DRM -DGLX_INDIRECT_RENDERING -DGLX_DIRECT_RENDERING -DGLX_USE_TLS
-DHAVE_WAYLAND_PLATFORM -DHAVE_X11_PLATFORM -DHAVE_DRM_PLATFORM -DHAVE_DRI3
-DENABLE_SHADER_CACHE -DHAVE_MINCORE -DHAVE_LLVM=0x0303
-DMESA_LLVM_VERSION_PATCH=0

LLVM_CFLAGS: -I/usr/include/llvm3.3 -D__STDC_CONSTANT_MACROS
-D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
LLVM_CXXFLAGS:   -I/usr/include/llvm3.3 -D__STDC_CONSTANT_MACROS
-D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
LLVM_CPPFLAGS:   -I/usr/include/llvm3.3 -D__STDC_CONSTANT_MACROS
-D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
LLVM_LDFLAGS:-L/usr/lib/llvm3.3  -lz -lpthread -lffi -ldl -lm 

PYTHON2: python2.7

-- 
You are receiving this mail because:
You are the QA Contact for the bug.
You are the assignee for the bug.___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 2/2] gallium: Add renderonly-based support for pl111+vc4.

2017-05-19 Thread Emil Velikov
On 19 May 2017 at 23:21, Eric Anholt  wrote:
> Emil Velikov  writes:
>
>> On 17 May 2017 at 20:13, Emil Velikov  wrote:
>>> On 17 May 2017 at 18:53, Eric Anholt  wrote:
 Emil Velikov  writes:

> Hi Eric,
>
> On 11 May 2017 at 00:06, Eric Anholt  wrote:
>> This follows the model of imx (display) and etnaviv (render): pl111 is a
>> display-only device, so when asked to do GL for it, we see if we have a
>> vc4 renderer, make the vc4 screen, and have vc4 call back to pl111 to do
>> scanout allocations.
>>
>> The difference from etnaviv is that we share the same BO between vc4 and
>> pl111, rather than having a vc4 bo and a pl11 bo and copies between the
>> two.  The only mismatch between their requirements is that vc4 requires
>> 4-pixel (at 32bpp) stride alignment, while pl111 requires that stride
>> match width.  The kernel will reject any modesets to an incorrect stride,
>> so the 3D driver doesn't need to worry about that.
>> ---
> I'm not familiar with the hardware itself so I cannot comment on those.
> There's a couple of small notes within, but overall the patch looks good.
>
>>  .travis.yml|  2 +-
>>  Makefile.am|  2 +-
> Yes, thank you!
>
>
>> --- a/Android.mk
>> +++ b/Android.mk
>
>>  classic_drivers := i915 i965
>> -gallium_drivers := swrast freedreno i915g nouveau r300g r600g radeonsi 
>> vmwgfx vc4 virgl
>> +gallium_drivers := swrast freedreno i915g nouveau pl111 r300g r600g 
>> radeonsi vmwgfx vc4 virgl
>>
> The recent Android cleanups by RobH which will cause a clash. The gist
> is below, but feel free to skim through commit
> 3f097396a1642bb7033002d0bdd37e194afce06a.
>  - rework for the new gallium_drivers format
>  - add a couple of lines in src/gallium/drivers/pl111/Android.mk
> analogous to the vc4 - the "ifneq $HAVE_foo" hunk
>  - drop the guard in src/gallium/Android.mk
>
>
>> +++ b/src/gallium/winsys/pl111/drm/pl111_drm_winsys.c
>
>> -#include 
>>  #include 
>> +#include 
>>
>> -#include "vc4_drm_public.h"
>> +#include "pl111_drm_public.h"
>> +#include "vc4/drm/vc4_drm_public.h"
>> +#include "xf86drm.h"
>>
>> -#include "vc4/vc4_screen.h"
>> +#include "pipe/p_screen.h"
>> +#include "renderonly/renderonly.h"
>
>> +#include "util/u_format.h"
> Seems unused.
>
>>
>> -struct pipe_screen *
>> -vc4_drm_screen_create(int fd)
>> +struct pipe_screen *pl111_drm_screen_create(int fd)
>>  {
>> -   return vc4_screen_create(fcntl(fd, F_DUPFD_CLOEXEC, 3));
>> +   struct renderonly ro = {
>> +  /* Passes the vc4-allocated BO through to the pl111 DRM device 
>> using
>> +   * PRIME buffer sharing.  The VC4 BO must be linear, which the 
>> SCANOUT
>> +   * flag on allocation will have ensured.
>> +   */
>> +  .create_for_resource = renderonly_create_gpu_import_for_resource,
>> +  .kms_fd = fd,
>> +  .gpu_fd = drmOpenWithType("vc4", NULL, DRM_NODE_RENDER),
> Please don't use the drmOpen* API. It's a legacy dragon with very
> subtle and inner workings.
> Using drmGetDevice[s] should provide any information that you need.
> Alternatively please let us know what's missing so we can address it.

 One this platform, there are exactly two devices, one is vc4 and the
 other is pl111.  drmOpenWithType is exactly the API we want, and if you
 want something else, then you should probably replace its insides
 instead of telling people to use a different API.
>>>
>>> Changing the insides also changes the behaviour, which could break users :-\
>>>
>> A couple of things from our IRC chat last night:
>>
>> - My suggestion was never meant as requirement or a blocker. Let along
>> "exerting control" as you call it :-\
>> It's aimed to save you/others time since the drmOpen* API
>> implementation is aimed for UMS and broken for KMS drivers.
>>
>> - You asked a couple of times "how this can break", despite my pointer
>> to DanielV's summary [1] and some encouragement to skim through the
>> drmOpen* code yourself.
>> Now a bit less tired, here it is the exact scenario how/why things are 
>> broken.
>>
>> A) User opens the vc4 device and calls drmSetInterfaceVersion
>> effectively populating the "unique name"
>> Plymouth, modesetting ddx, Xserver itself and others can easily do so.
>> B) Consecutive calls to  drmOpenWithType("vc4", NULL..) will fail
>> since the drmGetBusid/GET_UNIQUE return the non-zero "unique name".
>> That happens in drmOpenByName which considers the latter as "device
>> already opened".
>
> According to LIBGL_DEBUG=verbose, 

[Mesa-dev] [Bug 98833] [REGRESSION, bisected] Wayland revert commit breaks non-Vsync fullscreen frame updates

2017-05-19 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=98833

--- Comment #20 from Eero Tamminen  ---
(In reply to Daniel Stone from comment #19)
> (In reply to Daniel Stone from comment #18)
> > Right, here we are:
> > https://lists.freedesktop.org/archives/mesa-dev/2017-May/155791.html
> 
> Eero, are you able to test this?

I may have again time for this next month, not currently.

-- 
You are receiving this mail because:
You are the QA Contact for the bug.___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 2/2] gallium: Add renderonly-based support for pl111+vc4.

2017-05-19 Thread Emil Velikov
On 19 May 2017 at 23:41, Emil Velikov  wrote:
> On 19 May 2017 at 23:21, Eric Anholt  wrote:
>> Emil Velikov  writes:
>>
>>> On 17 May 2017 at 20:13, Emil Velikov  wrote:
 On 17 May 2017 at 18:53, Eric Anholt  wrote:
> Emil Velikov  writes:
>
>> Hi Eric,
>>
>> On 11 May 2017 at 00:06, Eric Anholt  wrote:
>>> This follows the model of imx (display) and etnaviv (render): pl111 is a
>>> display-only device, so when asked to do GL for it, we see if we have a
>>> vc4 renderer, make the vc4 screen, and have vc4 call back to pl111 to do
>>> scanout allocations.
>>>
>>> The difference from etnaviv is that we share the same BO between vc4 and
>>> pl111, rather than having a vc4 bo and a pl11 bo and copies between the
>>> two.  The only mismatch between their requirements is that vc4 requires
>>> 4-pixel (at 32bpp) stride alignment, while pl111 requires that stride
>>> match width.  The kernel will reject any modesets to an incorrect 
>>> stride,
>>> so the 3D driver doesn't need to worry about that.
>>> ---
>> I'm not familiar with the hardware itself so I cannot comment on those.
>> There's a couple of small notes within, but overall the patch looks good.
>>
>>>  .travis.yml|  2 +-
>>>  Makefile.am|  2 +-
>> Yes, thank you!
>>
>>
>>> --- a/Android.mk
>>> +++ b/Android.mk
>>
>>>  classic_drivers := i915 i965
>>> -gallium_drivers := swrast freedreno i915g nouveau r300g r600g radeonsi 
>>> vmwgfx vc4 virgl
>>> +gallium_drivers := swrast freedreno i915g nouveau pl111 r300g r600g 
>>> radeonsi vmwgfx vc4 virgl
>>>
>> The recent Android cleanups by RobH which will cause a clash. The gist
>> is below, but feel free to skim through commit
>> 3f097396a1642bb7033002d0bdd37e194afce06a.
>>  - rework for the new gallium_drivers format
>>  - add a couple of lines in src/gallium/drivers/pl111/Android.mk
>> analogous to the vc4 - the "ifneq $HAVE_foo" hunk
>>  - drop the guard in src/gallium/Android.mk
>>
>>
>>> +++ b/src/gallium/winsys/pl111/drm/pl111_drm_winsys.c
>>
>>> -#include 
>>>  #include 
>>> +#include 
>>>
>>> -#include "vc4_drm_public.h"
>>> +#include "pl111_drm_public.h"
>>> +#include "vc4/drm/vc4_drm_public.h"
>>> +#include "xf86drm.h"
>>>
>>> -#include "vc4/vc4_screen.h"
>>> +#include "pipe/p_screen.h"
>>> +#include "renderonly/renderonly.h"
>>
>>> +#include "util/u_format.h"
>> Seems unused.
>>
>>>
>>> -struct pipe_screen *
>>> -vc4_drm_screen_create(int fd)
>>> +struct pipe_screen *pl111_drm_screen_create(int fd)
>>>  {
>>> -   return vc4_screen_create(fcntl(fd, F_DUPFD_CLOEXEC, 3));
>>> +   struct renderonly ro = {
>>> +  /* Passes the vc4-allocated BO through to the pl111 DRM device 
>>> using
>>> +   * PRIME buffer sharing.  The VC4 BO must be linear, which the 
>>> SCANOUT
>>> +   * flag on allocation will have ensured.
>>> +   */
>>> +  .create_for_resource = renderonly_create_gpu_import_for_resource,
>>> +  .kms_fd = fd,
>>> +  .gpu_fd = drmOpenWithType("vc4", NULL, DRM_NODE_RENDER),
>> Please don't use the drmOpen* API. It's a legacy dragon with very
>> subtle and inner workings.
>> Using drmGetDevice[s] should provide any information that you need.
>> Alternatively please let us know what's missing so we can address it.
>
> One this platform, there are exactly two devices, one is vc4 and the
> other is pl111.  drmOpenWithType is exactly the API we want, and if you
> want something else, then you should probably replace its insides
> instead of telling people to use a different API.

 Changing the insides also changes the behaviour, which could break users 
 :-\

>>> A couple of things from our IRC chat last night:
>>>
>>> - My suggestion was never meant as requirement or a blocker. Let along
>>> "exerting control" as you call it :-\
>>> It's aimed to save you/others time since the drmOpen* API
>>> implementation is aimed for UMS and broken for KMS drivers.
>>>
>>> - You asked a couple of times "how this can break", despite my pointer
>>> to DanielV's summary [1] and some encouragement to skim through the
>>> drmOpen* code yourself.
>>> Now a bit less tired, here it is the exact scenario how/why things are 
>>> broken.
>>>
>>> A) User opens the vc4 device and calls drmSetInterfaceVersion
>>> effectively populating the "unique name"
>>> Plymouth, modesetting ddx, Xserver itself and others can easily do so.
>>> B) Consecutive calls to  drmOpenWithType("vc4", NULL..) will fail
>>> since 

[Mesa-dev] [Bug 101110] Build failure in GNOME Continuous

2017-05-19 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=101110

--- Comment #1 from Emil Velikov  ---
Seems like I've missed some corner case - I'm looking into it.

-- 
You are receiving this mail because:
You are the QA Contact for the bug.
You are the assignee for the bug.___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH v13 27/36] i965: Change resolve flags to enum

2017-05-19 Thread Jason Ekstrand
So, I think I'm going to end up doing a fairly significant rework of
resolves over the course of the next couple of weeks.  Carry on with the
branch as is and I'll figure out how to rebase it on top of whatever
changes I do later.  But it'll probably be significant.  Just a heads up.

--Jason

On Fri, May 19, 2017 at 2:38 AM, Daniel Stone  wrote:

> From: Ben Widawsky 
>
> In the foreseeable future it doesn't seem to make sense to have multiple
> resolve flags. What does make sense is to have the caller give an
> indication to the lower layers what it things should be done for
> resolve. The enum change distinguishes this binary selection.
>
> v2: Make setting the hint more concise (Topi)
>
> Signed-off-by: Ben Widawsky 
> Acked-by: Daniel Stone 
> Reviewed-by: Topi Pohjolainen 
> Signed-off-by: Daniel Stone 
> ---
>  src/mesa/drivers/dri/i965/brw_blorp.c |  8 
>  src/mesa/drivers/dri/i965/brw_context.c   | 13 +++--
>  src/mesa/drivers/dri/i965/intel_mipmap_tree.c | 12 ++--
>  src/mesa/drivers/dri/i965/intel_mipmap_tree.h | 13 -
>  4 files changed, 25 insertions(+), 21 deletions(-)
>
> diff --git a/src/mesa/drivers/dri/i965/brw_blorp.c
> b/src/mesa/drivers/dri/i965/brw_blorp.c
> index b69cb4fc7b..938600875e 100644
> --- a/src/mesa/drivers/dri/i965/brw_blorp.c
> +++ b/src/mesa/drivers/dri/i965/brw_blorp.c
> @@ -210,12 +210,12 @@ blorp_surf_for_miptree(struct brw_context *brw,
>  surf->aux_usage = ISL_AUX_USAGE_NONE;
>   }
>} else if (!(safe_aux_usage & (1 << surf->aux_usage))) {
> - uint32_t flags = 0;
> - if (safe_aux_usage & (1 << ISL_AUX_USAGE_CCS_E))
> -flags |= INTEL_MIPTREE_IGNORE_CCS_E;
> + const enum intel_resolve_hint hint =
> +safe_aux_usage & (1 << ISL_AUX_USAGE_CCS_E) ?
> +INTEL_RESOLVE_HINT_IGNORE_CCS_E : 0;
>
>   intel_miptree_resolve_color(brw, mt,
> - *level, start_layer, num_layers,
> flags);
> + *level, start_layer, num_layers,
> hint);
>
>   assert(!intel_miptree_has_color_unresolved(mt, *level, 1,
>  start_layer,
> num_layers));
> diff --git a/src/mesa/drivers/dri/i965/brw_context.c
> b/src/mesa/drivers/dri/i965/brw_context.c
> index f0e08b9874..5e446abb1f 100644
> --- a/src/mesa/drivers/dri/i965/brw_context.c
> +++ b/src/mesa/drivers/dri/i965/brw_context.c
> @@ -259,9 +259,10 @@ intel_update_state(struct gl_context * ctx, GLuint
> new_state)
>/* Sampling engine understands lossless compression and resolving
> * those surfaces should be skipped for performance reasons.
> */
> -  const int flags = intel_texture_view_requires_resolve(brw,
> tex_obj) ?
> -   0 : INTEL_MIPTREE_IGNORE_CCS_E;
> -  intel_miptree_all_slices_resolve_color(brw, tex_obj->mt, flags);
> +  const enum intel_resolve_hint hint =
> + intel_texture_view_requires_resolve(brw, tex_obj) ? 0 :
> + INTEL_RESOLVE_HINT_IGNORE_CCS_E;
> +  intel_miptree_all_slices_resolve_color(brw, tex_obj->mt, hint);
>brw_render_cache_set_check_flush(brw, tex_obj->mt->bo);
>
>if (tex_obj->base.StencilSampling ||
> @@ -313,9 +314,9 @@ intel_update_state(struct gl_context * ctx, GLuint
> new_state)
>  intel_renderbuffer(fb->_ColorDrawBuffers[i]);
>
>   if (irb &&
> - intel_miptree_resolve_color(
> -brw, irb->mt, irb->mt_level, irb->mt_layer,
> irb->layer_count,
> -INTEL_MIPTREE_IGNORE_CCS_E))
> + intel_miptree_resolve_color(brw, irb->mt, irb->mt_level,
> + irb->mt_layer, irb->layer_count,
> + INTEL_RESOLVE_HINT_IGNORE_CCS_
> E))
>  brw_render_cache_set_check_flush(brw, irb->mt->bo);
>}
> }
> diff --git a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
> b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
> index b33afdeb3f..8a33010543 100644
> --- a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
> +++ b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
> @@ -2234,7 +2234,7 @@ intel_miptree_used_for_rendering(const struct
> brw_context *brw,
>  static bool
>  intel_miptree_needs_color_resolve(const struct brw_context *brw,
>const struct intel_mipmap_tree *mt,
> -  int flags)
> +  enum intel_resolve_hint hint)
>  {
> if (mt->aux_disable & INTEL_AUX_DISABLE_CCS)
>return false;
> @@ -2246,7 +2246,7 @@ intel_miptree_needs_color_resolve(const struct
> brw_context *brw,
>  * surfaces called "lossless compressed". These don't need to be always
>  * resolved.
>  */
> -   

Re: [Mesa-dev] [PATCH 14/16] anv: Advertise both 32-bit and 48-bit heaps when we have enough memory

2017-05-19 Thread Jason Ekstrand
On Fri, May 19, 2017 at 2:53 PM, Gustaw Smolarczyk 
wrote:

> 2017-05-18 23:01 GMT+02:00 Jason Ekstrand :
> > ---
> >  src/intel/vulkan/anv_device.c | 42 ++
> ++--
> >  1 file changed, 36 insertions(+), 6 deletions(-)
> >
> > diff --git a/src/intel/vulkan/anv_device.c
> b/src/intel/vulkan/anv_device.c
> > index 6ea8dfe..8eed7f3 100644
> > --- a/src/intel/vulkan/anv_device.c
> > +++ b/src/intel/vulkan/anv_device.c
> > @@ -112,12 +112,42 @@ anv_physical_device_init_heaps(struct
> anv_physical_device *device, int fd)
> > if (result != VK_SUCCESS)
> >return result;
> >
> > -   device->memory.heap_count = 1;
> > -   device->memory.heaps[0] = (struct anv_memory_heap) {
> > -  .size = heap_size,
> > -  .flags = VK_MEMORY_HEAP_DEVICE_LOCAL_BIT,
> > -  .supports_48bit_addresses = device->supports_48bit_addresses,
> > -   };
> > +   if (heap_size <= 3ull * (1ull << 30)) {
> > +  /* In this case, everything fits nicely into the 32-bit address
> space,
> > +   * so there's no need for supporting 48bit addresses on
> clinet-allocated
>
> Probably a typo: s/clinet/client/
>

Thanks.


> > +   * memory objects.
> > +   */
> > +  device->memory.heap_count = 1;
> > +  device->memory.heaps[0] = (struct anv_memory_heap) {
> > + .size = heap_size,
> > + .flags = VK_MEMORY_HEAP_DEVICE_LOCAL_BIT,
> > + .supports_48bit_addresses = false,
> > +  };
> > +   } else {
> > +  /* Not everything will fit nicely into a 32-bit address space.
> In this
> > +   * case we need a 64-bit heap.  Advertise a small 32-bit heap and
> a
> > +   * larger 48-bit heap.  If we're in this case, then we have a
> total heap
> > +   * size larger than 3GiB which most likely means they have 8 GiB
> of
> > +   * video memory and so carving off 2 GiB for the 32-bit heap
> should be
> > +   * reasonable.
> > +   */
> > +  const uint32_t heap_size_32bit = 2ull * (1ull << 30);
> > +  const uint32_t heap_size_48bit = heap_size - heap_size_32bit;
>
> Is it really a good idea for these variables to be only 32-bit?
> Especially the second one.
>

Ugh... Good catch.  I've fixed both locally.  Thanks!
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [Bug 101110] Build failure in GNOME Continuous

2017-05-19 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=101110

Emil Velikov  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |FIXED

--- Comment #2 from Emil Velikov  ---
Should be fixes with the following. Thanks for the report.

commit 2100c5f7bef6b47bf96b026e689e835ca436a59b
Author: Emil Velikov 
Date:   Sat May 20 00:04:33 2017 +0100

configure.ac: add xcb-fixes to the XCB DRI3 list

The XCB module is used by the VL targets. Thus omitting it can lead to
link-time errors due to unresolved symbols.

Other DRI3 users such as the Vulkan WSI and the dri3 loader helper do
not use an update region in their xcb_present_pixmap() call. We will
look into that at a later stage.

Fixes: acf3d2afab0 ("configure: check once for DRI3 dependencies")
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=101110
Signed-off-by: Emil Velikov 

-- 
You are receiving this mail because:
You are the assignee for the bug.
You are the QA Contact for the bug.___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [Mesa-stable] [PATCH] automake: add SWR LLVM gen_builder.hpp workaround

2017-05-19 Thread Emil Velikov
On 19 May 2017 at 20:50, Rowley, Timothy O  wrote:
> Thanks for doing this; I would have been hunting for the dist-hook: magic
> for a while.
>
> Tested “make dist” on llvm-3.9.0 (works) and llvm-4.0/llvm-svn (fails,
> expected desired behavior).
>
> Built result of llvm-3.9.0 “make dist” with llvm-4.0 and llvm-svn and it
> compiles/works.
>
Perfect, thanks for testing! Pushed in master + picked for 17.1.

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


Re: [Mesa-dev] [PATCH 1/9] mesa: Handle common extension checks with more compact code

2017-05-19 Thread Ian Romanick
On 05/19/2017 10:28 AM, Nanley Chery wrote:
> On Fri, May 19, 2017 at 06:38:03AM -0700, Ian Romanick wrote:
>> From: Ian Romanick 
>>
>> The previous code handled everything with the general case.  I noticed
>> that every time I converted an open-coded check to use a
>> _mesa_has_EXT_foo() function, the text size of the driver increased.
>>
>> Almost all extensions only care what the current context API is, and
>> the version does not matter.  Handle those using more compact checks.
>>
>>text data bss dec hex filename
>> 7037675   235248   37280 7310203  6f8b7b 32-bit i965_dri.so before
>> 7034307   235248   37280 7306835  6f7e53 32-bit i965_dri.so after
>> 6679695   303400   50608 7033703  6b5367 64-bit i965_dri.so before
>> 6676143   303400   50608 7030151  6b4587 64-bit i965_dri.so after
> 
> Hi Ian,
> 
> I wrote a patch some time ago that reduces the cost of the extension
> checks by a lot more with less code. The only thing I think may need
> addressing is endianness. Would you consider using it instead if I
> reworked it and sent it out to the list? You can find it here:
> https://cgit.freedesktop.org/~nchery/mesa/commit/?h=1/ext/optimize=a02d88eba1d3129b27d3b5e6aaa976c3ca20cf79

I was not able to reproduce that result on current Mesa.  I had a lot
of trouble believing that more than 18% of our driver binary was
extension check code.  I also had a sick feeling that may have just
been the first stage of grief talking... :)  Are you able to reproduce
your original result?

I also tried a similar patch to yours that wouldn't have endianness
problems:

#define EXT(name_str, driver_cap, gll, glc, es1, es2, ...) \
static inline bool \
_mesa_has_##name_str(const struct gl_context *ctx) \
{  \
   static const uint8_t ver[4] = { (uint8_t)gll, (uint8_t)es1, (uint8_t)es2, 
(uint8_t)glc }; \
   return ctx->Extensions.driver_cap &&\
  (ctx->Extensions.Version >= ver[ctx->API]);  \
}

Here's what I got for all four methods:

7037675  235248   37280 7310203  6f8b7b 32-bit i965_dri.so before
7034307  235248   37280 7306835  6f7e53 32-bit i965_dri.so after idr
7038343  235248   37280 7310871  6f8e17 32-bit i965_dri.so after Nanley
7036271  235248   37280 7308799  6f85ff 32-bit i965_dri.so w/arrays

6679695  303400   50608 7033703  6b5367 64-bit i965_dri.so before
6676143  303400   50608 7030151  6b4587 64-bit i965_dri.so after idr
6684767  303400   50608 7038775  6b6737 64-bit i965_dri.so after Nanley
6678567  303400   50608 7032575  6b4eff 64-bit i965_dri.so w/arrays

For reference, I build with the same flags that Fedora 23 (I think?)
used for release builds:

-O2 -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong 
--param=ssp-buffer-size=4 -grecord-gcc-switches

And either "-m64 -mtune=generic" or "-m32 -march=i686 -mtune=atom
-fasynchronous-unwind-tables" depending on the platform.
--enable-debug is not passed to configure.

Even if I were able to reproduce your original result, there are still
two cases where your approach may generate more code than is necessary:

1. All of the APIs that support the extension use dummy_true.  There
are many examples of this, but I don't think there are many matching
users of _mesa_has_XXX_foo().

2. All of the APIs support the extension in any version.
GL_EXT_polygon_offset_clamp is an example.

I think we can blend the strengths to get something even better.

I missed that glsl_parser_extras.cpp has its own implementation of the
has_XXX_foo() functions that take the API and version as explicit
parameters.  Your patch predates that change.  There's room for some
modest savings there too.

I'll send a couple follow-up patches soon.

> Thanks,
> Nanley

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


[Mesa-dev] [PATCH] docs: Document ASTC extension support for SKL and BXT

2017-05-19 Thread Nanley Chery
Cc: Anuj Phogat 
Signed-off-by: Nanley Chery 
---
 docs/features.txt | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/docs/features.txt b/docs/features.txt
index e18bf54a48..05d776be08 100644
--- a/docs/features.txt
+++ b/docs/features.txt
@@ -306,8 +306,8 @@ Khronos, ARB, and OES extensions that are not part of any 
OpenGL or OpenGL ES ve
   GL_ARB_transform_feedback_overflow_query  DONE (i965/gen6+)
   GL_KHR_blend_equation_advanced_coherent   DONE (i965/gen9+)
   GL_KHR_no_error   started (Timothy 
Arceri)
-  GL_KHR_texture_compression_astc_hdr   DONE (core only)
-  GL_KHR_texture_compression_astc_sliced_3d not started
+  GL_KHR_texture_compression_astc_hdr   DONE (i965/bxt+)
+  GL_KHR_texture_compression_astc_sliced_3d DONE (i965/gen9+)
   GL_OES_depth_texture_cube_map DONE (all drivers that 
support GLSL 1.30+)
   GL_OES_EGL_image  DONE (all drivers)
   GL_OES_EGL_image_external_essl3   not started
-- 
2.12.2

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


Re: [Mesa-dev] [PATCH 03/16] anv: Handle color layout transitions from the UNINITIALIZED layout

2017-05-19 Thread Nanley Chery
On Thu, May 18, 2017 at 02:00:50PM -0700, Jason Ekstrand wrote:
> This causes dEQP-VK.api.copy_and_blit.resolve_image.partial.* to start
> failing due to test bugs.  See CL 1031 for a test fix.
> ---
>  src/intel/vulkan/anv_blorp.c   | 40 
> ++
>  src/intel/vulkan/anv_private.h |  5 +
>  src/intel/vulkan/genX_cmd_buffer.c | 25 
>  3 files changed, 70 insertions(+)
> 
> diff --git a/src/intel/vulkan/anv_blorp.c b/src/intel/vulkan/anv_blorp.c
> index 7b6944a..51964c5 100644
> --- a/src/intel/vulkan/anv_blorp.c
> +++ b/src/intel/vulkan/anv_blorp.c
> @@ -1373,6 +1373,46 @@ void anv_CmdResolveImage(
> blorp_batch_finish();
>  }
>  
> +void
> +anv_image_ccs_ambiguate(struct anv_cmd_buffer *cmd_buffer,
> +const struct anv_image *image,
> +const VkImageSubresourceRange *subresourceRange)
> +{
> +   assert(image->type == VK_IMAGE_TYPE_3D || image->extent.depth == 1);
> +
> +   struct blorp_batch batch;
> +   blorp_batch_init(_buffer->device->blorp, , cmd_buffer, 0);
> +
> +   struct blorp_surf surf;
> +   get_blorp_surf_for_anv_image(image, VK_IMAGE_ASPECT_COLOR_BIT,
> +image->aux_usage, );
> +
> +   /* We're about to bind a CCS surface and render to it.  Who knows what 
> will
> +* happen to caching at that point.  It's probably best if we don't let
> +* this happen at the same time as other rendering.  Flush the render 
> cache
> +* and stall prior to this operation.
> +*/
> +   cmd_buffer->state.pending_pipe_bits |=
> +  ANV_PIPE_RENDER_TARGET_CACHE_FLUSH_BIT | ANV_PIPE_CS_STALL_BIT;
> +
> +   const uint32_t level_count = anv_get_levelCount(image, subresourceRange);
> +   const uint32_t layer_count = anv_get_layerCount(image, subresourceRange);
> +   for (uint32_t l = 0; l < level_count; l++) {
> +  const uint32_t level = subresourceRange->baseMipLevel + l;
> +
> +  for (uint32_t a = 0; a < layer_count; a++) {
> + const uint32_t layer = subresourceRange->baseArrayLayer + a;
> + const uint32_t depth = anv_minify(image->extent.depth, level);
> +
> + for (uint32_t z = 0; z < depth; z++)
> +blorp_ccs_ambiguate(, , level, layer, z);

This triple for loop is a cool way to think about 3D textures.

> +  }
> +   }
> +
> +   cmd_buffer->state.pending_pipe_bits |=
> +  ANV_PIPE_RENDER_TARGET_CACHE_FLUSH_BIT | ANV_PIPE_CS_STALL_BIT;
> +}
> +
>  static void
>  ccs_resolve_attachment(struct anv_cmd_buffer *cmd_buffer,
> struct blorp_batch *batch,
> diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h
> index 9b0dd67..10ad247 100644
> --- a/src/intel/vulkan/anv_private.h
> +++ b/src/intel/vulkan/anv_private.h
> @@ -2064,6 +2064,11 @@ anv_gen8_hiz_op_resolve(struct anv_cmd_buffer 
> *cmd_buffer,
>  const struct anv_image *image,
>  enum blorp_hiz_op op);
>  
> +void
> +anv_image_ccs_ambiguate(struct anv_cmd_buffer *cmd_buffer,
> +const struct anv_image *image,
> +const VkImageSubresourceRange *subresourceRange);
> +
>  enum isl_aux_usage
>  anv_layout_to_aux_usage(const struct gen_device_info * const devinfo,
>  const struct anv_image *image,
> diff --git a/src/intel/vulkan/genX_cmd_buffer.c 
> b/src/intel/vulkan/genX_cmd_buffer.c
> index ef9b7d0..1f30a12 100644
> --- a/src/intel/vulkan/genX_cmd_buffer.c
> +++ b/src/intel/vulkan/genX_cmd_buffer.c
> @@ -388,6 +388,24 @@ transition_depth_buffer(struct anv_cmd_buffer 
> *cmd_buffer,
>anv_gen8_hiz_op_resolve(cmd_buffer, image, hiz_op);
>  }
>  
> +static void
> +transition_color_buffer(struct anv_cmd_buffer *cmd_buffer,
> +const struct anv_image *image,
> +VkImageLayout initial_layout,
> +VkImageLayout final_layout,
> +const VkImageSubresourceRange *subresourceRange)
> +{
> +   if (image->aux_usage != ISL_AUX_USAGE_CCS_E)
> +  return;
> +
> +   if (initial_layout != VK_IMAGE_LAYOUT_UNDEFINED &&
> +   initial_layout != VK_IMAGE_LAYOUT_PREINITIALIZED)
> +  return;
> +
> +#if GEN_GEN >= 9
> +   anv_image_ccs_ambiguate(cmd_buffer, image, subresourceRange);
> +#endif
> +}
>  
>  /**
>   * Setup anv_cmd_state::attachments for vkCmdBeginRenderPass.
> @@ -976,6 +994,13 @@ void genX(CmdPipelineBarrier)(
>   pImageMemoryBarriers[i].oldLayout,
>   pImageMemoryBarriers[i].newLayout);
>}
> +  if (pImageMemoryBarriers[i].subresourceRange.aspectMask &
> +  VK_IMAGE_ASPECT_COLOR_BIT) {
> + transition_color_buffer(cmd_buffer, image,
> + pImageMemoryBarriers[i].oldLayout,
> + pImageMemoryBarriers[i].newLayout,
> +  

Re: [Mesa-dev] [PATCH 04/16] anv: Handle transitioning depth from UNDEFINED to other layouts

2017-05-19 Thread Nanley Chery
On Thu, May 18, 2017 at 02:00:51PM -0700, Jason Ekstrand wrote:
> ---
>  src/intel/vulkan/anv_image.c   | 12 ++--
>  src/intel/vulkan/genX_cmd_buffer.c |  9 +
>  2 files changed, 11 insertions(+), 10 deletions(-)
> 
> diff --git a/src/intel/vulkan/anv_image.c b/src/intel/vulkan/anv_image.c
> index d21e055..d65ef47 100644
> --- a/src/intel/vulkan/anv_image.c
> +++ b/src/intel/vulkan/anv_image.c
> @@ -488,12 +488,20 @@ anv_layout_to_aux_usage(const struct gen_device_info * 
> const devinfo,
> /* According to the Vulkan Spec, the following layouts are valid only as
>  * initial layouts in a layout transition and don't support device access.
>  */
> -   case VK_IMAGE_LAYOUT_UNDEFINED:
> -   case VK_IMAGE_LAYOUT_PREINITIALIZED:
> case VK_IMAGE_LAYOUT_RANGE_SIZE:
> case VK_IMAGE_LAYOUT_MAX_ENUM:
>unreachable("Invalid image layout for device access.");
>  
> +   /* Undefined layouts
> +*
> +* The pre-initialized layout is equivalent to the undefined layout for
> +* optimally-tiled images.  We can only do color compression (CCS or HiZ)
> +* on tiled images.
> +*/
> +   case VK_IMAGE_LAYOUT_UNDEFINED:
> +   case VK_IMAGE_LAYOUT_PREINITIALIZED:
> +  return ISL_AUX_USAGE_NONE;
> +
>  

This function is defined to return the isl_aux_usage for "device access"
as described by the Vulkan spec. The user is not allowed to perform
device accesses in either of those layouts (11.4. Image Layouts). My
suggestion for dealing with this can be found below.

> /* Transfer Layouts
>  *
> diff --git a/src/intel/vulkan/genX_cmd_buffer.c 
> b/src/intel/vulkan/genX_cmd_buffer.c
> index 1f30a12..8d5f61b 100644
> --- a/src/intel/vulkan/genX_cmd_buffer.c
> +++ b/src/intel/vulkan/genX_cmd_buffer.c
> @@ -355,15 +355,8 @@ transition_depth_buffer(struct anv_cmd_buffer 
> *cmd_buffer,
>  * The undefined layout indicates that the user doesn't care about the 
> data
>  * that's currently in the buffer. Therefore, a data-preserving resolve
>  * operation is not needed.
> -*
> -* The pre-initialized layout is equivalent to the undefined layout for
> -* optimally-tiled images. Anv only exposes support for optimally-tiled
> -* depth buffers.
>  */
> -   if (image->aux_usage != ISL_AUX_USAGE_HIZ ||
> -   initial_layout == final_layout ||
> -   initial_layout == VK_IMAGE_LAYOUT_UNDEFINED ||
> -   initial_layout == VK_IMAGE_LAYOUT_PREINITIALIZED)
> +   if (image->aux_usage != ISL_AUX_USAGE_HIZ || initial_layout == 
> final_layout)
>return;
>  

I think we should keep this new condition and add another one below for
UNDEFINED and PREINITIALIZED in which we do the resolve early and
return.

I don't mind adding a new condition because the original idea I had of
only comparing hiz_enabled and enable_hiz isn't optimal - for example,
we unnecessarily perform a resolve when going from a read-only
hiz-enabled layout to a hiz-disabled layout. (Thankfully, I haven't yet
found any apps that make such a transition.)

-Nanley

> const bool hiz_enabled = ISL_AUX_USAGE_HIZ ==
> -- 
> 2.5.0.400.gff86faf
> 
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] Android: r600: fix build when LLVM is disabled

2017-05-19 Thread Rob Herring
On Fri, May 12, 2017 at 11:55 AM, Rob Herring  wrote:
> There's still an error after my recent clean-up if LLVM is not patched to
> enable AMDGPU target:
>
> external/mesa3d/src/amd/common/ac_llvm_util.c:38:2: error: implicit 
> declaration of function 'LLVMInitializeAMDGPUTargetInfo' is invalid in C99 
> [-Werror,-Wimplicit-function-declaration]
> LLVMInitializeAMDGPUTargetInfo();
> ^
> external/mesa3d/src/amd/common/ac_llvm_util.c:39:2: error: implicit 
> declaration of function 'LLVMInitializeAMDGPUTarget' is invalid in C99 
> [-Werror,-Wimplicit-function-declaration]
> LLVMInitializeAMDGPUTarget();
> ^
> external/mesa3d/src/amd/common/ac_llvm_util.c:40:2: error: implicit 
> declaration of function 'LLVMInitializeAMDGPUTargetMC' is invalid in C99 
> [-Werror,-Wimplicit-function-declaration]
> LLVMInitializeAMDGPUTargetMC();
> ^
> external/mesa3d/src/amd/common/ac_llvm_util.c:41:2: error: implicit 
> declaration of function 'LLVMInitializeAMDGPUAsmPrinter' is invalid in C99 
> [-Werror,-Wimplicit-function-declaration]
> LLVMInitializeAMDGPUAsmPrinter();
> ^
>
> We need to drop libmesa_amd_common when LLVM is disabled, however there's
> still a dependency on include paths for ac_binary.h. So explicitly add the
> include path when LLVM is disabled.

Emil, can you please apply.

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


<    1   2   3   >