[Mesa-dev] [PATCH] mesa/extensions: Fix NVX_gpu_memory_info lexicographical order.

2016-02-05 Thread Vinson Lee
Fixes MesaExtensionsTest.AlphabeticallySorted.

Fixes: 1d79b9958090 ("mesa: implement GL_NVX_gpu_memory_info (v2)")
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=94016
Signed-off-by: Vinson Lee 
---
 src/mesa/main/extensions_table.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/mesa/main/extensions_table.h b/src/mesa/main/extensions_table.h
index ded6f2c..d1e3a99 100644
--- a/src/mesa/main/extensions_table.h
+++ b/src/mesa/main/extensions_table.h
@@ -273,6 +273,8 @@ EXT(MESA_texture_signed_rgba, 
EXT_texture_snorm
 EXT(MESA_window_pos , dummy_true   
  , GLL,  x ,  x ,  x , 2000)
 EXT(MESA_ycbcr_texture  , MESA_ycbcr_texture   
  , GLL, GLC,  x ,  x , 2002)
 
+EXT(NVX_gpu_memory_info , NVX_gpu_memory_info  
  , GLL, GLC,  x ,  x , 2013)
+
 EXT(NV_blend_square , dummy_true   
  , GLL,  x ,  x ,  x , 1999)
 EXT(NV_conditional_render   , NV_conditional_render
  , GLL, GLC,  x ,  x , 2008)
 EXT(NV_depth_clamp  , ARB_depth_clamp  
  , GLL, GLC,  x ,  x , 2001)
@@ -293,7 +295,6 @@ EXT(NV_texture_barrier  , 
NV_texture_barrier
 EXT(NV_texture_env_combine4 , NV_texture_env_combine4  
  , GLL,  x ,  x ,  x , 1999)
 EXT(NV_texture_rectangle, NV_texture_rectangle 
  , GLL,  x ,  x ,  x , 2000)
 EXT(NV_vdpau_interop, NV_vdpau_interop 
  , GLL, GLC,  x ,  x , 2010)
-EXT(NVX_gpu_memory_info , NVX_gpu_memory_info  
  , GLL, GLC,  x ,  x , 2013)
 
 EXT(OES_EGL_image   , OES_EGL_image
  , GLL, GLC, ES1, ES2, 2006) /* FIXME: Mesa expects GL_OES_EGL_image to be 
available in OpenGL contexts. */
 EXT(OES_EGL_image_external  , OES_EGL_image_external   
  ,  x ,  x , ES1, ES2, 2010)
-- 
2.7.0

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


Re: [Mesa-dev] [PATCH 1/4] tgsi: break gigantic tgsi_scan_shader() function into pieces

2016-02-05 Thread eocallaghan

This series is,

Reviewed-by: Edward O'Callaghan 

On 2016-02-06 11:56, Brian Paul wrote:

New functions for examining instructions, declarations, etc.
---
 src/gallium/auxiliary/tgsi/tgsi_scan.c | 739 
+

 1 file changed, 375 insertions(+), 364 deletions(-)

diff --git a/src/gallium/auxiliary/tgsi/tgsi_scan.c
b/src/gallium/auxiliary/tgsi/tgsi_scan.c
index 687fb54..4199dbe 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_scan.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_scan.c
@@ -44,6 +44,375 @@



+static void
+scan_instruction(struct tgsi_shader_info *info,
+ const struct tgsi_full_instruction *fullinst,
+ unsigned *current_depth)
+{
+   unsigned i;
+
+   assert(fullinst->Instruction.Opcode < TGSI_OPCODE_LAST);
+   info->opcode_count[fullinst->Instruction.Opcode]++;
+
+   switch (fullinst->Instruction.Opcode) {
+   case TGSI_OPCODE_IF:
+   case TGSI_OPCODE_UIF:
+   case TGSI_OPCODE_BGNLOOP:
+  (*current_depth)++;
+  info->max_depth = MAX2(info->max_depth, *current_depth);
+  break;
+   case TGSI_OPCODE_ENDIF:
+   case TGSI_OPCODE_ENDLOOP:
+  (*current_depth)--;
+  break;
+   default:
+  break;
+   }
+
+   if (fullinst->Instruction.Opcode == TGSI_OPCODE_INTERP_CENTROID ||
+   fullinst->Instruction.Opcode == TGSI_OPCODE_INTERP_OFFSET ||
+   fullinst->Instruction.Opcode == TGSI_OPCODE_INTERP_SAMPLE) {
+  const struct tgsi_full_src_register *src0 = &fullinst->Src[0];
+  unsigned input;
+
+  if (src0->Register.Indirect && src0->Indirect.ArrayID)
+ input = info->input_array_first[src0->Indirect.ArrayID];
+  else
+ input = src0->Register.Index;
+
+  /* For the INTERP opcodes, the interpolation is always
+   * PERSPECTIVE unless LINEAR is specified.
+   */
+  switch (info->input_interpolate[input]) {
+  case TGSI_INTERPOLATE_COLOR:
+  case TGSI_INTERPOLATE_CONSTANT:
+  case TGSI_INTERPOLATE_PERSPECTIVE:
+ switch (fullinst->Instruction.Opcode) {
+ case TGSI_OPCODE_INTERP_CENTROID:
+info->uses_persp_opcode_interp_centroid = true;
+break;
+ case TGSI_OPCODE_INTERP_OFFSET:
+info->uses_persp_opcode_interp_offset = true;
+break;
+ case TGSI_OPCODE_INTERP_SAMPLE:
+info->uses_persp_opcode_interp_sample = true;
+break;
+ }
+ break;
+
+  case TGSI_INTERPOLATE_LINEAR:
+ switch (fullinst->Instruction.Opcode) {
+ case TGSI_OPCODE_INTERP_CENTROID:
+info->uses_linear_opcode_interp_centroid = true;
+break;
+ case TGSI_OPCODE_INTERP_OFFSET:
+info->uses_linear_opcode_interp_offset = true;
+break;
+ case TGSI_OPCODE_INTERP_SAMPLE:
+info->uses_linear_opcode_interp_sample = true;
+break;
+ }
+ break;
+  }
+   }
+
+   if (fullinst->Instruction.Opcode >= TGSI_OPCODE_F2D &&
+   fullinst->Instruction.Opcode <= TGSI_OPCODE_DSSG)
+  info->uses_doubles = true;
+
+   for (i = 0; i < fullinst->Instruction.NumSrcRegs; i++) {
+  const struct tgsi_full_src_register *src = &fullinst->Src[i];
+  int ind = src->Register.Index;
+
+  /* Mark which inputs are effectively used */
+  if (src->Register.File == TGSI_FILE_INPUT) {
+ unsigned usage_mask;
+ usage_mask = tgsi_util_get_inst_usage_mask(fullinst, i);
+ if (src->Register.Indirect) {
+for (ind = 0; ind < info->num_inputs; ++ind) {
+   info->input_usage_mask[ind] |= usage_mask;
+}
+ } else {
+assert(ind >= 0);
+assert(ind < PIPE_MAX_SHADER_INPUTS);
+info->input_usage_mask[ind] |= usage_mask;
+ }
+
+ if (info->processor == TGSI_PROCESSOR_FRAGMENT &&
+ !src->Register.Indirect) {
+unsigned name =
+   info->input_semantic_name[src->Register.Index];
+unsigned index =
+   info->input_semantic_index[src->Register.Index];
+
+if (name == TGSI_SEMANTIC_POSITION &&
+(src->Register.SwizzleX == TGSI_SWIZZLE_Z ||
+ src->Register.SwizzleY == TGSI_SWIZZLE_Z ||
+ src->Register.SwizzleZ == TGSI_SWIZZLE_Z ||
+ src->Register.SwizzleW == TGSI_SWIZZLE_Z))
+   info->reads_z = TRUE;
+
+if (name == TGSI_SEMANTIC_COLOR) {
+   unsigned mask =
+  (1 << src->Register.SwizzleX) |
+  (1 << src->Register.SwizzleY) |
+  (1 << src->Register.SwizzleZ) |
+  (1 << src->Register.SwizzleW);
+
+   info->colors_read |= mask << (index * 4);
+}
+ }
+  }
+
+  /* check for indirect register reads */
+  if (src->Register.Indirect) {
+ info->indirect_files |= (1 << src->Register.File);
+ info->indirect_files_read |= (1 << 

[Mesa-dev] [PATCH 4/6] i965/fs: Plumb separate surfaces and samplers through from NIR

2016-02-05 Thread Jason Ekstrand
---
 src/mesa/drivers/dri/i965/brw_blorp_blit_eu.cpp |  2 +-
 src/mesa/drivers/dri/i965/brw_fs.cpp| 29 -
 src/mesa/drivers/dri/i965/brw_fs.h  |  3 +++
 src/mesa/drivers/dri/i965/brw_fs_generator.cpp  |  2 +-
 src/mesa/drivers/dri/i965/brw_fs_nir.cpp| 26 +++---
 src/mesa/drivers/dri/i965/brw_fs_visitor.cpp| 11 ++
 6 files changed, 49 insertions(+), 24 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_blorp_blit_eu.cpp 
b/src/mesa/drivers/dri/i965/brw_blorp_blit_eu.cpp
index c6ae3d8..fd23e23 100644
--- a/src/mesa/drivers/dri/i965/brw_blorp_blit_eu.cpp
+++ b/src/mesa/drivers/dri/i965/brw_blorp_blit_eu.cpp
@@ -85,7 +85,7 @@ brw_blorp_eu_emitter::emit_texture_lookup(const struct 
brw_reg &dst,
   unsigned msg_length)
 {
fs_inst *inst = new (mem_ctx) fs_inst(op, 16, dst, 
brw_message_reg(base_mrf),
- brw_imm_ud(0u));
+ brw_imm_ud(0u), brw_imm_ud(0u));
 
inst->base_mrf = base_mrf;
inst->mlen = msg_length;
diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp 
b/src/mesa/drivers/dri/i965/brw_fs.cpp
index 8f4a7c1..72fe472 100644
--- a/src/mesa/drivers/dri/i965/brw_fs.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs.cpp
@@ -3653,6 +3653,7 @@ lower_sampler_logical_send_gen4(const fs_builder &bld, 
fs_inst *inst, opcode op,
 const fs_reg &coordinate,
 const fs_reg &shadow_c,
 const fs_reg &lod, const fs_reg &lod2,
+const fs_reg &surface,
 const fs_reg &sampler,
 unsigned coord_components,
 unsigned grad_components)
@@ -3745,8 +3746,9 @@ lower_sampler_logical_send_gen4(const fs_builder &bld, 
fs_inst *inst, opcode op,
 
inst->opcode = op;
inst->src[0] = reg_undef;
-   inst->src[1] = sampler;
-   inst->resize_sources(2);
+   inst->src[1] = surface;
+   inst->src[2] = sampler;
+   inst->resize_sources(3);
inst->base_mrf = msg_begin.nr;
inst->mlen = msg_end.nr - msg_begin.nr;
inst->header_size = 1;
@@ -3758,6 +3760,7 @@ lower_sampler_logical_send_gen5(const fs_builder &bld, 
fs_inst *inst, opcode op,
 const fs_reg &shadow_c,
 fs_reg lod, fs_reg lod2,
 const fs_reg &sample_index,
+const fs_reg &surface,
 const fs_reg &sampler,
 const fs_reg &offset_value,
 unsigned coord_components,
@@ -3840,8 +3843,9 @@ lower_sampler_logical_send_gen5(const fs_builder &bld, 
fs_inst *inst, opcode op,
 
inst->opcode = op;
inst->src[0] = reg_undef;
-   inst->src[1] = sampler;
-   inst->resize_sources(2);
+   inst->src[1] = surface;
+   inst->src[2] = sampler;
+   inst->resize_sources(3);
inst->base_mrf = message.nr;
inst->mlen = msg_end.nr - message.nr;
inst->header_size = header_size;
@@ -3865,7 +3869,9 @@ lower_sampler_logical_send_gen7(const fs_builder &bld, 
fs_inst *inst, opcode op,
 const fs_reg &shadow_c,
 fs_reg lod, fs_reg lod2,
 const fs_reg &sample_index,
-const fs_reg &mcs, const fs_reg &sampler,
+const fs_reg &mcs,
+const fs_reg &surface,
+const fs_reg &sampler,
 fs_reg offset_value,
 unsigned coord_components,
 unsigned grad_components)
@@ -4068,8 +4074,9 @@ lower_sampler_logical_send_gen7(const fs_builder &bld, 
fs_inst *inst, opcode op,
/* Generate the SEND. */
inst->opcode = op;
inst->src[0] = src_payload;
-   inst->src[1] = sampler;
-   inst->resize_sources(2);
+   inst->src[1] = surface;
+   inst->src[2] = sampler;
+   inst->resize_sources(3);
inst->base_mrf = -1;
inst->mlen = mlen;
inst->header_size = header_size;
@@ -4088,6 +4095,7 @@ lower_sampler_logical_send(const fs_builder &bld, fs_inst 
*inst, opcode op)
const fs_reg &lod2 = inst->src[FS_TEX_SRC_LOD2];
const fs_reg &sample_index = inst->src[FS_TEX_SRC_SAMPLE_INDEX];
const fs_reg &mcs = inst->src[FS_TEX_SRC_MCS];
+   const fs_reg &surface = inst->src[FS_TEX_SRC_SAMPLER];
const fs_reg &sampler = inst->src[FS_TEX_SRC_SAMPLER];
const fs_reg &offset_value = inst->src[FS_TEX_SRC_OFFSET_VALUE];
assert(inst->src[FS_TEX_SRC_COORD_COMPONENTS].file == IMM);
@@ -4098,16 +4106,17 @@ lower_sampler_logical_send(const fs_builder &bld, 
fs_inst *inst, opcode op)
if (devinfo->gen >= 7) {
   lower_sampler_logical_send_gen7(bld

[Mesa-dev] [PATCH 0/6] nir/i965: Separate samplers and textures

2016-02-05 Thread Jason Ekstrand
This is my second series in praparation for SPIR-V.  I sent it out some
time ago as an RFC.  At the time I got a conditional review from Ken but I
thought it was worth sending out again.  The original can be found here:

http://lists.freedesktop.org/archives/mesa-dev/2015-November/099103.html

There are two primary differences between this version and the previous:

 1) The addition of patch 2 which adds an enum for keeping track of
texture sources in the FS backend as requested by Ken.

 2) I fixed a bug in the vec4 code where we didn't actually pass both the
sampler and the texture to the generator.

Jason Ekstrand (6):
  nir: Separate texture from sampler in nir_tex_instr
  i965/fs: Add an enum for keeping track of texture instruciton sources
  i965/fs: Separate the sampler from the surface in generate_tex
  i965/fs: Plumb separate surfaces and samplers through from NIR
  i965/vec4: Separate the sampler from the surface in generate_tex
  i965/vec4: Plumb separate surfaces and samplers through from NIR

 src/compiler/nir/nir.c   |  8 ++-
 src/compiler/nir/nir.h   | 26 ++--
 src/compiler/nir/nir_clone.c |  7 ++-
 src/compiler/nir/nir_instr_set.c | 13 ++--
 src/compiler/nir/nir_lower_samplers.c| 15 -
 src/compiler/nir/nir_lower_tex.c |  4 +-
 src/compiler/nir/nir_print.c | 14 -
 src/mesa/drivers/dri/i965/brw_blorp_blit_eu.cpp  |  2 +-
 src/mesa/drivers/dri/i965/brw_fs.cpp | 75 ++--
 src/mesa/drivers/dri/i965/brw_fs.h   | 18 ++
 src/mesa/drivers/dri/i965/brw_fs_generator.cpp   | 20 +--
 src/mesa/drivers/dri/i965/brw_fs_nir.cpp | 26 +---
 src/mesa/drivers/dri/i965/brw_fs_visitor.cpp | 30 ++
 src/mesa/drivers/dri/i965/brw_vec4.h |  3 +-
 src/mesa/drivers/dri/i965/brw_vec4_generator.cpp | 18 --
 src/mesa/drivers/dri/i965/brw_vec4_nir.cpp   | 25 +---
 src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp   | 12 ++--
 src/mesa/program/prog_to_nir.c   |  1 +
 18 files changed, 226 insertions(+), 91 deletions(-)

-- 
2.5.0.400.gff86faf

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


[Mesa-dev] [PATCH 2/6] i965/fs: Add an enum for keeping track of texture instruciton sources

2016-02-05 Thread Jason Ekstrand
These logical texture instructions can have a *lot* of sources.  It's much
safer if we have symbolic names for them.
---
 src/mesa/drivers/dri/i965/brw_fs.cpp | 46 +++-
 src/mesa/drivers/dri/i965/brw_fs.h   | 14 +
 src/mesa/drivers/dri/i965/brw_fs_visitor.cpp | 19 
 3 files changed, 52 insertions(+), 27 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp 
b/src/mesa/drivers/dri/i965/brw_fs.cpp
index 41a3f81..8f4a7c1 100644
--- a/src/mesa/drivers/dri/i965/brw_fs.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs.cpp
@@ -739,18 +739,20 @@ fs_inst::components_read(unsigned i) const
case SHADER_OPCODE_LOD_LOGICAL:
case SHADER_OPCODE_TG4_LOGICAL:
case SHADER_OPCODE_TG4_OFFSET_LOGICAL:
-  assert(src[8].file == IMM && src[9].file == IMM);
+  assert(src[FS_TEX_SRC_COORD_COMPONENTS].file == IMM &&
+ src[FS_TEX_SRC_GRAD_COMPONENTS].file == IMM);
   /* Texture coordinates. */
-  if (i == 0)
- return src[8].ud;
+  if (i == FS_TEX_SRC_COORDINATE)
+ return src[FS_TEX_SRC_COORD_COMPONENTS].ud;
   /* Texture derivatives. */
-  else if ((i == 2 || i == 3) && opcode == SHADER_OPCODE_TXD_LOGICAL)
- return src[9].ud;
+  else if ((i == FS_TEX_SRC_LOD || i == FS_TEX_SRC_LOD2) &&
+   opcode == SHADER_OPCODE_TXD_LOGICAL)
+ return src[FS_TEX_SRC_GRAD_COMPONENTS].ud;
   /* Texture offset. */
-  else if (i == 7)
+  else if (i == FS_TEX_SRC_OFFSET_VALUE)
  return 2;
   /* MCS */
-  else if (i == 5 && opcode == SHADER_OPCODE_TXF_CMS_W_LOGICAL)
+  else if (i == FS_TEX_SRC_MCS && opcode == 
SHADER_OPCODE_TXF_CMS_W_LOGICAL)
  return 2;
   else
  return 1;
@@ -4080,17 +4082,18 @@ static void
 lower_sampler_logical_send(const fs_builder &bld, fs_inst *inst, opcode op)
 {
const brw_device_info *devinfo = bld.shader->devinfo;
-   const fs_reg &coordinate = inst->src[0];
-   const fs_reg &shadow_c = inst->src[1];
-   const fs_reg &lod = inst->src[2];
-   const fs_reg &lod2 = inst->src[3];
-   const fs_reg &sample_index = inst->src[4];
-   const fs_reg &mcs = inst->src[5];
-   const fs_reg &sampler = inst->src[6];
-   const fs_reg &offset_value = inst->src[7];
-   assert(inst->src[8].file == IMM && inst->src[9].file == IMM);
-   const unsigned coord_components = inst->src[8].ud;
-   const unsigned grad_components = inst->src[9].ud;
+   const fs_reg &coordinate = inst->src[FS_TEX_SRC_COORDINATE];
+   const fs_reg &shadow_c = inst->src[FS_TEX_SRC_SHADOW_C];
+   const fs_reg &lod = inst->src[FS_TEX_SRC_LOD];
+   const fs_reg &lod2 = inst->src[FS_TEX_SRC_LOD2];
+   const fs_reg &sample_index = inst->src[FS_TEX_SRC_SAMPLE_INDEX];
+   const fs_reg &mcs = inst->src[FS_TEX_SRC_MCS];
+   const fs_reg &sampler = inst->src[FS_TEX_SRC_SAMPLER];
+   const fs_reg &offset_value = inst->src[FS_TEX_SRC_OFFSET_VALUE];
+   assert(inst->src[FS_TEX_SRC_COORD_COMPONENTS].file == IMM);
+   const unsigned coord_components = inst->src[FS_TEX_SRC_COORD_COMPONENTS].ud;
+   assert(inst->src[FS_TEX_SRC_GRAD_COMPONENTS].file == IMM);
+   const unsigned grad_components = inst->src[FS_TEX_SRC_GRAD_COMPONENTS].ud;
 
if (devinfo->gen >= 7) {
   lower_sampler_logical_send_gen7(bld, inst, op, coordinate,
@@ -4384,7 +4387,7 @@ get_lowered_simd_width(const struct brw_device_info 
*devinfo,
 
case SHADER_OPCODE_TG4_OFFSET_LOGICAL: {
   /* gather4_po_c is unsupported in SIMD16 mode. */
-  const fs_reg &shadow_c = inst->src[1];
+  const fs_reg &shadow_c = inst->src[FS_TEX_SRC_SHADOW_C];
   return (shadow_c.file != BAD_FILE ? 8 : inst->exec_size);
}
case SHADER_OPCODE_TXL_LOGICAL:
@@ -4393,7 +4396,7 @@ get_lowered_simd_width(const struct brw_device_info 
*devinfo,
* Gen4-6 can't support TXL and TXB with shadow comparison in SIMD16
* mode because the message exceeds the maximum length of 11.
*/
-  const fs_reg &shadow_c = inst->src[1];
+  const fs_reg &shadow_c = inst->src[FS_TEX_SRC_SHADOW_C];
   if (devinfo->gen == 4 && shadow_c.file == BAD_FILE)
  return 16;
   else if (devinfo->gen < 7 && shadow_c.file != BAD_FILE)
@@ -4416,7 +4419,8 @@ get_lowered_simd_width(const struct brw_device_info 
*devinfo,
* circumstances it can end up with a message that is too long in SIMD16
* mode.
*/
-  const unsigned coord_components = inst->src[8].ud;
+  const unsigned coord_components =
+ inst->src[FS_TEX_SRC_COORD_COMPONENTS].ud;
   /* First three arguments are the sample index and the two arguments for
* the MCS data.
*/
diff --git a/src/mesa/drivers/dri/i965/brw_fs.h 
b/src/mesa/drivers/dri/i965/brw_fs.h
index 4612a28..4a38f80 100644
--- a/src/mesa/drivers/dri/i965/brw_fs.h
+++ b/src/mesa/drivers/dri/i965/brw_fs.h
@@ -66,6 +66,20 @@ offset(fs_reg reg, const brw::fs_builder& bld, unsigned 
delta)
return reg;
 }
 
+enum fs_tex_src_type {

[Mesa-dev] [PATCH 1/6] nir: Separate texture from sampler in nir_tex_instr

2016-02-05 Thread Jason Ekstrand
This commit adds the capability to NIR to support separate textures and
samplers.  As it currently stands, glsl_to_nir only sets the sampler and
leaves the texture alone as it did before and nir_lower_samplers assumes
this.  However, backends can, if they wish, assume that they are separate
because nir_lower_samplers sets both texture and sampler index (they are
the same in this case).
---
 src/compiler/nir/nir.c |  8 +++-
 src/compiler/nir/nir.h | 26 ++
 src/compiler/nir/nir_clone.c   |  7 ++-
 src/compiler/nir/nir_instr_set.c   | 13 -
 src/compiler/nir/nir_lower_samplers.c  | 15 +--
 src/compiler/nir/nir_lower_tex.c   |  4 ++--
 src/compiler/nir/nir_print.c   | 14 +++---
 src/mesa/drivers/dri/i965/brw_fs_nir.cpp   |  2 +-
 src/mesa/drivers/dri/i965/brw_vec4_nir.cpp |  2 +-
 src/mesa/program/prog_to_nir.c |  1 +
 10 files changed, 72 insertions(+), 20 deletions(-)

diff --git a/src/compiler/nir/nir.c b/src/compiler/nir/nir.c
index 21bf678..cd22a5c 100644
--- a/src/compiler/nir/nir.c
+++ b/src/compiler/nir/nir.c
@@ -486,8 +486,10 @@ nir_tex_instr_create(nir_shader *shader, unsigned num_srcs)
for (unsigned i = 0; i < num_srcs; i++)
   src_init(&instr->src[i].src);
 
+   instr->texture_index = 0;
+   instr->texture_array_size = 0;
+   instr->texture = NULL;
instr->sampler_index = 0;
-   instr->sampler_array_size = 0;
instr->sampler = NULL;
 
return instr;
@@ -1005,6 +1007,10 @@ visit_tex_src(nir_tex_instr *instr, nir_foreach_src_cb 
cb, void *state)
   if (!visit_src(&instr->src[i].src, cb, state))
  return false;
 
+   if (instr->texture != NULL)
+  if (!visit_deref_src(instr->texture, cb, state))
+ return false;
+
if (instr->sampler != NULL)
   if (!visit_deref_src(instr->sampler, cb, state))
  return false;
diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
index 4968460..6d660d8 100644
--- a/src/compiler/nir/nir.h
+++ b/src/compiler/nir/nir.h
@@ -923,6 +923,7 @@ typedef enum {
nir_tex_src_ms_index, /* MSAA sample index */
nir_tex_src_ddx,
nir_tex_src_ddy,
+   nir_tex_src_texture_offset, /* < dynamically uniform indirect offset */
nir_tex_src_sampler_offset, /* < dynamically uniform indirect offset */
nir_num_tex_src_types
 } nir_tex_src_type;
@@ -973,6 +974,22 @@ typedef struct {
/* gather component selector */
unsigned component : 2;
 
+   /** The texture index
+*
+* If this texture instruction has a nir_tex_src_texture_offset source,
+* then the texture index is given by texture_index + texture_offset.
+*/
+   unsigned texture_index;
+
+   /** The size of the texture array or 0 if it's not an array */
+   unsigned texture_array_size;
+
+   /** The texture deref
+*
+* If this is null, use texture_index instead.
+*/
+   nir_deref_var *texture;
+
/** The sampler index
 *
 * If this texture instruction has a nir_tex_src_sampler_offset source,
@@ -980,10 +997,11 @@ typedef struct {
 */
unsigned sampler_index;
 
-   /** The size of the sampler array or 0 if it's not an array */
-   unsigned sampler_array_size;
-
-   nir_deref_var *sampler; /* if this is NULL, use sampler_index instead */
+   /** The sampler deref
+*
+* If this is null, use sampler_index instead.
+*/
+   nir_deref_var *sampler;
 } nir_tex_instr;
 
 static inline unsigned
diff --git a/src/compiler/nir/nir_clone.c b/src/compiler/nir/nir_clone.c
index 5eff743..a666d8e 100644
--- a/src/compiler/nir/nir_clone.c
+++ b/src/compiler/nir/nir_clone.c
@@ -357,8 +357,13 @@ clone_tex(clone_state *state, const nir_tex_instr *tex)
ntex->is_new_style_shadow = tex->is_new_style_shadow;
memcpy(ntex->const_offset, tex->const_offset, sizeof(ntex->const_offset));
ntex->component = tex->component;
+
+   ntex->texture_index = tex->texture_index;
+   if (tex->texture)
+  ntex->texture = clone_deref_var(state, tex->texture, &ntex->instr);
+   ntex->texture_array_size = tex->texture_array_size;
+
ntex->sampler_index = tex->sampler_index;
-   ntex->sampler_array_size = tex->sampler_array_size;
if (tex->sampler)
   ntex->sampler = clone_deref_var(state, tex->sampler, &ntex->instr);
 
diff --git a/src/compiler/nir/nir_instr_set.c b/src/compiler/nir/nir_instr_set.c
index d3f939f..eb02132 100644
--- a/src/compiler/nir/nir_instr_set.c
+++ b/src/compiler/nir/nir_instr_set.c
@@ -155,8 +155,9 @@ hash_tex(uint32_t hash, const nir_tex_instr *instr)
hash = HASH(hash, instr->const_offset);
unsigned component = instr->component;
hash = HASH(hash, component);
+   hash = HASH(hash, instr->texture_index);
+   hash = HASH(hash, instr->texture_array_size);
hash = HASH(hash, instr->sampler_index);
-   hash = HASH(hash, instr->sampler_array_size);
 
assert(!instr->sampler);
 
@@ -305,13 +306,15 @@ nir_instrs_equal(const nir_instr

[Mesa-dev] [PATCH 3/6] i965/fs: Separate the sampler from the surface in generate_tex

2016-02-05 Thread Jason Ekstrand
---
 src/mesa/drivers/dri/i965/brw_fs.h |  1 +
 src/mesa/drivers/dri/i965/brw_fs_generator.cpp | 20 ++--
 2 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_fs.h 
b/src/mesa/drivers/dri/i965/brw_fs.h
index 4a38f80..600ce70 100644
--- a/src/mesa/drivers/dri/i965/brw_fs.h
+++ b/src/mesa/drivers/dri/i965/brw_fs.h
@@ -462,6 +462,7 @@ private:
void generate_linterp(fs_inst *inst, struct brw_reg dst,
 struct brw_reg *src);
void generate_tex(fs_inst *inst, struct brw_reg dst, struct brw_reg src,
+ struct brw_reg surface_index,
  struct brw_reg sampler_index);
void generate_get_buffer_size(fs_inst *inst, struct brw_reg dst,
  struct brw_reg src,
diff --git a/src/mesa/drivers/dri/i965/brw_fs_generator.cpp 
b/src/mesa/drivers/dri/i965/brw_fs_generator.cpp
index 1916a99..15155c2 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_generator.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_generator.cpp
@@ -678,6 +678,7 @@ fs_generator::generate_get_buffer_size(fs_inst *inst,
 
 void
 fs_generator::generate_tex(fs_inst *inst, struct brw_reg dst, struct brw_reg 
src,
+   struct brw_reg surface_index,
struct brw_reg sampler_index)
 {
int msg_type = -1;
@@ -933,14 +934,16 @@ fs_generator::generate_tex(fs_inst *inst, struct brw_reg 
dst, struct brw_reg src
  ? prog_data->binding_table.gather_texture_start
  : prog_data->binding_table.texture_start;
 
-   if (sampler_index.file == BRW_IMMEDIATE_VALUE) {
+   if (surface_index.file == BRW_IMMEDIATE_VALUE &&
+   sampler_index.file == BRW_IMMEDIATE_VALUE) {
+  uint32_t surface = surface_index.ud;
   uint32_t sampler = sampler_index.ud;
 
   brw_SAMPLE(p,
  retype(dst, BRW_REGISTER_TYPE_UW),
  inst->base_mrf,
  src,
- sampler + base_binding_table_index,
+ surface + base_binding_table_index,
  sampler % 16,
  msg_type,
  rlen,
@@ -949,19 +952,24 @@ fs_generator::generate_tex(fs_inst *inst, struct brw_reg 
dst, struct brw_reg src
  simd_mode,
  return_format);
 
-  brw_mark_surface_used(prog_data, sampler + base_binding_table_index);
+  brw_mark_surface_used(prog_data, surface + base_binding_table_index);
} else {
   /* Non-const sampler index */
 
   struct brw_reg addr = vec1(retype(brw_address_reg(0), 
BRW_REGISTER_TYPE_UD));
+  struct brw_reg surface_reg = vec1(retype(surface_index, 
BRW_REGISTER_TYPE_UD));
   struct brw_reg sampler_reg = vec1(retype(sampler_index, 
BRW_REGISTER_TYPE_UD));
 
   brw_push_insn_state(p);
   brw_set_default_mask_control(p, BRW_MASK_DISABLE);
   brw_set_default_access_mode(p, BRW_ALIGN_1);
 
-  /* addr = ((sampler * 0x101) + base_binding_table_index) & 0xfff */
-  brw_MUL(p, addr, sampler_reg, brw_imm_uw(0x101));
+  if (memcmp(&surface_reg, &sampler_reg, sizeof(surface_reg)) == 0) {
+ brw_MUL(p, addr, sampler_reg, brw_imm_uw(0x101));
+  } else {
+ brw_SHL(p, addr, sampler_reg, brw_imm_ud(8));
+ brw_OR(p, addr, addr, surface_reg);
+  }
   if (base_binding_table_index)
  brw_ADD(p, addr, addr, brw_imm_ud(base_binding_table_index));
   brw_AND(p, addr, addr, brw_imm_ud(0xfff));
@@ -2070,7 +2078,7 @@ fs_generator::generate_code(const cfg_t *cfg, int 
dispatch_width)
   case SHADER_OPCODE_TG4:
   case SHADER_OPCODE_TG4_OFFSET:
   case SHADER_OPCODE_SAMPLEINFO:
-generate_tex(inst, dst, src[0], src[1]);
+generate_tex(inst, dst, src[0], src[1], src[1]);
 break;
   case FS_OPCODE_DDX_COARSE:
   case FS_OPCODE_DDX_FINE:
-- 
2.5.0.400.gff86faf

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


[Mesa-dev] [PATCH 6/6] i965/vec4: Plumb separate surfaces and samplers through from NIR

2016-02-05 Thread Jason Ekstrand
---
 src/mesa/drivers/dri/i965/brw_vec4.h |  3 ++-
 src/mesa/drivers/dri/i965/brw_vec4_generator.cpp |  2 +-
 src/mesa/drivers/dri/i965/brw_vec4_nir.cpp   | 25 +---
 src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp   | 12 
 4 files changed, 29 insertions(+), 13 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_vec4.h 
b/src/mesa/drivers/dri/i965/brw_vec4.h
index 1460f45..14a5f0e 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4.h
+++ b/src/mesa/drivers/dri/i965/brw_vec4.h
@@ -260,10 +260,11 @@ public:
  src_reg offset_value,
  src_reg mcs,
  bool is_cube_array,
+ uint32_t surface, src_reg surface_reg,
  uint32_t sampler, src_reg sampler_reg);
 
src_reg emit_mcs_fetch(const glsl_type *coordinate_type, src_reg coordinate,
-  src_reg sampler);
+  src_reg surface);
void emit_gen6_gather_wa(uint8_t wa, dst_reg dst);
 
void emit_ndc_computation();
diff --git a/src/mesa/drivers/dri/i965/brw_vec4_generator.cpp 
b/src/mesa/drivers/dri/i965/brw_vec4_generator.cpp
index 2d0aca4..19c4024 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4_generator.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4_generator.cpp
@@ -1672,7 +1672,7 @@ generate_code(struct brw_codegen *p,
   case SHADER_OPCODE_TG4:
   case SHADER_OPCODE_TG4_OFFSET:
   case SHADER_OPCODE_SAMPLEINFO:
- generate_tex(p, prog_data, inst, dst, src[0], src[1], src[1]);
+ generate_tex(p, prog_data, inst, dst, src[0], src[1], src[2]);
  break;
 
   case VS_OPCODE_URB_WRITE:
diff --git a/src/mesa/drivers/dri/i965/brw_vec4_nir.cpp 
b/src/mesa/drivers/dri/i965/brw_vec4_nir.cpp
index f3f361c..8e84ae9 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4_nir.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4_nir.cpp
@@ -1639,7 +1639,9 @@ glsl_type_for_nir_alu_type(nir_alu_type alu_type,
 void
 vec4_visitor::nir_emit_texture(nir_tex_instr *instr)
 {
+   unsigned texture = instr->texture_index;
unsigned sampler = instr->sampler_index;
+   src_reg texture_reg = brw_imm_ud(texture);
src_reg sampler_reg = brw_imm_ud(sampler);
src_reg coordinate;
const glsl_type *coord_type = NULL;
@@ -1715,13 +1717,12 @@ vec4_visitor::nir_emit_texture(nir_tex_instr *instr)
  offset_value = get_nir_src(instr->src[i].src, BRW_REGISTER_TYPE_D, 2);
  break;
 
-  case nir_tex_src_sampler_offset: {
- /* The highest sampler which may be used by this operation is
+  case nir_tex_src_texture_offset: {
+ /* The highest texture which may be used by this operation is
   * the last element of the array. Mark it here, because the generator
   * doesn't have enough information to determine the bound.
   */
- uint32_t array_size = instr->texture_array_size;
- uint32_t max_used = sampler + array_size - 1;
+ uint32_t max_used = texture + instr->texture_array_size - 1;
  if (instr->op == nir_texop_tg4) {
 max_used += prog_data->base.binding_table.gather_texture_start;
  } else {
@@ -1733,6 +1734,15 @@ vec4_visitor::nir_emit_texture(nir_tex_instr *instr)
  /* Emit code to evaluate the actual indexing expression */
  src_reg src = get_nir_src(instr->src[i].src, 1);
  src_reg temp(this, glsl_type::uint_type);
+ emit(ADD(dst_reg(temp), src, brw_imm_ud(texture)));
+ texture_reg = emit_uniformize(temp);
+ break;
+  }
+
+  case nir_tex_src_sampler_offset: {
+ /* Emit code to evaluate the actual indexing expression */
+ src_reg src = get_nir_src(instr->src[i].src, 1);
+ src_reg temp(this, glsl_type::uint_type);
  emit(ADD(dst_reg(temp), src, brw_imm_ud(sampler)));
  sampler_reg = emit_uniformize(temp);
  break;
@@ -1754,7 +1764,7 @@ vec4_visitor::nir_emit_texture(nir_tex_instr *instr)
   assert(coord_type != NULL);
   if (devinfo->gen >= 7 &&
   key_tex->compressed_multisample_layout_mask & (1 << sampler)) {
- mcs = emit_mcs_fetch(coord_type, coordinate, sampler_reg);
+ mcs = emit_mcs_fetch(coord_type, coordinate, texture_reg);
   } else {
  mcs = brw_imm_ud(0u);
   }
@@ -1771,7 +1781,7 @@ vec4_visitor::nir_emit_texture(nir_tex_instr *instr)
/* Stuff the channel select bits in the top of the texture offset */
if (instr->op == nir_texop_tg4) {
   if (instr->component == 1 &&
-  (key_tex->gather_channel_quirk_mask & (1 << sampler))) {
+  (key_tex->gather_channel_quirk_mask & (1 << texture))) {
  /* gather4 sampler is broken for green channel on RG32F --
   * we must ask for blue instead.
   */
@@ -1792,7 +1802,8 @@ vec4_visitor::nir_emit_texture(nir_tex_instr *instr)
 shadow_comparitor,
 lod, lod2, sample_index,
 co

[Mesa-dev] [PATCH 5/6] i965/vec4: Separate the sampler from the surface in generate_tex

2016-02-05 Thread Jason Ekstrand
---
 src/mesa/drivers/dri/i965/brw_vec4_generator.cpp | 18 +-
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_vec4_generator.cpp 
b/src/mesa/drivers/dri/i965/brw_vec4_generator.cpp
index 730be21..2d0aca4 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4_generator.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4_generator.cpp
@@ -109,6 +109,7 @@ generate_tex(struct brw_codegen *p,
  vec4_instruction *inst,
  struct brw_reg dst,
  struct brw_reg src,
+ struct brw_reg surface_index,
  struct brw_reg sampler_index)
 {
const struct brw_device_info *devinfo = p->devinfo;
@@ -264,14 +265,16 @@ generate_tex(struct brw_codegen *p,
  ? prog_data->base.binding_table.gather_texture_start
  : prog_data->base.binding_table.texture_start;
 
-   if (sampler_index.file == BRW_IMMEDIATE_VALUE) {
+   if (surface_index.file == BRW_IMMEDIATE_VALUE &&
+   sampler_index.file == BRW_IMMEDIATE_VALUE) {
+  uint32_t surface = surface_index.ud;
   uint32_t sampler = sampler_index.ud;
 
   brw_SAMPLE(p,
  dst,
  inst->base_mrf,
  src,
- sampler + base_binding_table_index,
+ surface + base_binding_table_index,
  sampler % 16,
  msg_type,
  1, /* response length */
@@ -285,14 +288,19 @@ generate_tex(struct brw_codegen *p,
   /* Non-constant sampler index. */
 
   struct brw_reg addr = vec1(retype(brw_address_reg(0), 
BRW_REGISTER_TYPE_UD));
+  struct brw_reg surface_reg = vec1(retype(surface_index, 
BRW_REGISTER_TYPE_UD));
   struct brw_reg sampler_reg = vec1(retype(sampler_index, 
BRW_REGISTER_TYPE_UD));
 
   brw_push_insn_state(p);
   brw_set_default_mask_control(p, BRW_MASK_DISABLE);
   brw_set_default_access_mode(p, BRW_ALIGN_1);
 
-  /* addr = ((sampler * 0x101) + base_binding_table_index) & 0xfff */
-  brw_MUL(p, addr, sampler_reg, brw_imm_uw(0x101));
+  if (memcmp(&surface_reg, &sampler_reg, sizeof(surface_reg)) == 0) {
+ brw_MUL(p, addr, sampler_reg, brw_imm_uw(0x101));
+  } else {
+ brw_SHL(p, addr, sampler_reg, brw_imm_ud(8));
+ brw_OR(p, addr, addr, surface_reg);
+  }
   if (base_binding_table_index)
  brw_ADD(p, addr, addr, brw_imm_ud(base_binding_table_index));
   brw_AND(p, addr, addr, brw_imm_ud(0xfff));
@@ -1664,7 +1672,7 @@ generate_code(struct brw_codegen *p,
   case SHADER_OPCODE_TG4:
   case SHADER_OPCODE_TG4_OFFSET:
   case SHADER_OPCODE_SAMPLEINFO:
- generate_tex(p, prog_data, inst, dst, src[0], src[1]);
+ generate_tex(p, prog_data, inst, dst, src[0], src[1], src[1]);
  break;
 
   case VS_OPCODE_URB_WRITE:
-- 
2.5.0.400.gff86faf

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


[Mesa-dev] [RFC 0/6] nir: Rework the way texture instructions reference samplers

2016-02-05 Thread Jason Ekstrand
This patch series is the first of many that I will be sending out in the
next few weeks in an attempt to land SPIR-V support.  While the SPIR-V code
to test said patches does not exist in mesa yet, they will be piglited and
most of said patches have been baking, in one for or another, for quite
some time in my SPIR-V branch which is working rather well.  This series is
a notable exception in that rule; hence the RFC status.  I only just cooked
it up today but I believe it will solve one of the fundamental problems in
my current SPIR-V implementation: that of passing textures into functions.
I also think it cleans some things up in NIR rather nicely.

The fundamental idea is to allow for load_var intrinsics to be used on
sampler types.  The result of the load_var is defined to be the sampler
index which is passed directly into the sampler_offset source of the tex
innstruction.  This also has the advantage of getting rid of all of the
special-casing of texture instructions and their sampler parameters.

But does it work?  What happens if someone tries to do something algebraic
with that value?  Well, they can't.  There's nothing that, following the
GLSL rules, will introduce such a thing.  If, for instance, we're in the
case where someone passes it through a couple of layers of functions then,
after function inlining and copy-propagation, the texture instruction will
source from the load_var directly again and off we go.

As one more side-note, I would eventually like to get rid of the awkward
index+offset thing that we're using in texture instructions with just an
index field like we have for other loads.  Unfortunately, we need the base
index for state-based shader recompiles.  One of these days, on my very
long list of things to do, I'd like to make recompiles safe for indirects
on array textures and then, maybe, we can just have an index.

Cc: Connor Abbott 

Jason Ekstrand (6):
  nir: Add a helper for copying a deref_var
  nir/builder: Add a helper for loading from a deref_var
  nir/types: Advertise 1 vector component for sampler types
  i965/nir: Lower samplers before uniforms
  nir: Replace tex_instr.array_size with max_sampler_index
  nir: Rework the way texture instructions reference samplers

 src/compiler/nir/glsl_to_nir.cpp   | 35 ---
 src/compiler/nir/nir.c | 13 ++
 src/compiler/nir/nir.h |  7 ++-
 src/compiler/nir/nir_builder.h | 15 +++
 src/compiler/nir/nir_clone.c   |  4 +-
 src/compiler/nir/nir_instr_set.c   | 19 ++--
 src/compiler/nir/nir_lower_samplers.c  | 61 +-
 src/compiler/nir/nir_lower_var_copies.c|  4 +-
 src/compiler/nir/nir_opt_constant_folding.c|  5 +--
 src/compiler/nir/nir_print.c   |  6 +--
 src/compiler/nir/nir_remove_dead_variables.c   | 13 --
 src/compiler/nir/nir_validate.c|  7 +--
 src/compiler/nir_types.cpp |  5 ++-
 src/gallium/drivers/vc4/vc4_nir_lower_txf_ms.c |  1 -
 src/mesa/drivers/dri/i965/brw_fs_nir.cpp   |  2 +-
 src/mesa/drivers/dri/i965/brw_nir.c|  6 +--
 src/mesa/drivers/dri/i965/brw_vec4_nir.cpp |  3 +-
 17 files changed, 90 insertions(+), 116 deletions(-)

-- 
2.5.0.400.gff86faf

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


[Mesa-dev] [RFC 4/6] i965/nir: Lower samplers before uniforms

2016-02-05 Thread Jason Ekstrand
We are about to start doing load_var of a sampler to get the binding table
index.  If we're going to do this, then we need to have the load_var
instructions when we run lower_samplers.  If we let lower_io run on
uniforms first, then they will get replaced with bogus load_uniform
intrinsics which we don't want.
---
 src/mesa/drivers/dri/i965/brw_nir.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_nir.c 
b/src/mesa/drivers/dri/i965/brw_nir.c
index 287f935..9817391 100644
--- a/src/mesa/drivers/dri/i965/brw_nir.c
+++ b/src/mesa/drivers/dri/i965/brw_nir.c
@@ -605,14 +605,14 @@ brw_create_nir(struct brw_context *brw,
 
nir = brw_preprocess_nir(nir, is_scalar);
 
-   OPT(nir_lower_system_values);
-   OPT_V(brw_nir_lower_uniforms, is_scalar);
-
if (shader_prog) {
   OPT_V(nir_lower_samplers, shader_prog);
   OPT_V(nir_lower_atomics, shader_prog);
}
 
+   OPT(nir_lower_system_values);
+   OPT_V(brw_nir_lower_uniforms, is_scalar);
+
if (nir->stage != MESA_SHADER_TESS_CTRL &&
nir->stage != MESA_SHADER_TESS_EVAL) {
   nir = brw_nir_lower_io(nir, devinfo, is_scalar);
-- 
2.5.0.400.gff86faf

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


[Mesa-dev] [RFC 1/6] nir: Add a helper for copying a deref_var

2016-02-05 Thread Jason Ekstrand
---
 src/compiler/nir/nir.c  | 6 +++---
 src/compiler/nir/nir.h  | 1 +
 src/compiler/nir/nir_lower_var_copies.c | 4 ++--
 3 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/src/compiler/nir/nir.c b/src/compiler/nir/nir.c
index 21bf678..2247a98 100644
--- a/src/compiler/nir/nir.c
+++ b/src/compiler/nir/nir.c
@@ -559,8 +559,8 @@ nir_deref_struct_create(void *mem_ctx, unsigned field_index)
return deref;
 }
 
-static nir_deref_var *
-copy_deref_var(void *mem_ctx, nir_deref_var *deref)
+nir_deref_var *
+nir_copy_deref_var(void *mem_ctx, nir_deref_var *deref)
 {
nir_deref_var *ret = nir_deref_var_create(mem_ctx, deref->var);
ret->deref.type = deref->deref.type;
@@ -599,7 +599,7 @@ nir_copy_deref(void *mem_ctx, nir_deref *deref)
 {
switch (deref->deref_type) {
case nir_deref_type_var:
-  return ©_deref_var(mem_ctx, nir_deref_as_var(deref))->deref;
+  return &nir_copy_deref_var(mem_ctx, nir_deref_as_var(deref))->deref;
case nir_deref_type_array:
   return ©_deref_array(mem_ctx, nir_deref_as_array(deref))->deref;
case nir_deref_type_struct:
diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
index 4968460..3b85bf5 100644
--- a/src/compiler/nir/nir.h
+++ b/src/compiler/nir/nir.h
@@ -1697,6 +1697,7 @@ nir_deref_array *nir_deref_array_create(void *mem_ctx);
 nir_deref_struct *nir_deref_struct_create(void *mem_ctx, unsigned field_index);
 
 nir_deref *nir_copy_deref(void *mem_ctx, nir_deref *deref);
+nir_deref_var *nir_copy_deref_var(void *mem_ctx, nir_deref_var *deref);
 
 nir_load_const_instr *
 nir_deref_get_const_initializer_load(nir_shader *shader, nir_deref_var *deref);
diff --git a/src/compiler/nir/nir_lower_var_copies.c 
b/src/compiler/nir/nir_lower_var_copies.c
index 8cb3edd..aef5f5e 100644
--- a/src/compiler/nir/nir_lower_var_copies.c
+++ b/src/compiler/nir/nir_lower_var_copies.c
@@ -120,7 +120,7 @@ emit_copy_load_store(nir_intrinsic_instr *copy_instr,
   nir_intrinsic_instr *load =
  nir_intrinsic_instr_create(mem_ctx, nir_intrinsic_load_var);
   load->num_components = num_components;
-  load->variables[0] = nir_deref_as_var(nir_copy_deref(load, 
&src_head->deref));
+  load->variables[0] = nir_copy_deref_var(load, src_head);
   nir_ssa_dest_init(&load->instr, &load->dest, num_components, NULL);
 
   nir_instr_insert_before(©_instr->instr, &load->instr);
@@ -129,7 +129,7 @@ emit_copy_load_store(nir_intrinsic_instr *copy_instr,
  nir_intrinsic_instr_create(mem_ctx, nir_intrinsic_store_var);
   store->num_components = num_components;
   store->const_index[0] = (1 << num_components) - 1;
-  store->variables[0] = nir_deref_as_var(nir_copy_deref(store, 
&dest_head->deref));
+  store->variables[0] = nir_copy_deref_var(store, dest_head);
 
   store->src[0].is_ssa = true;
   store->src[0].ssa = &load->dest.ssa;
-- 
2.5.0.400.gff86faf

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


[Mesa-dev] [RFC 6/6] nir: Rework the way texture instructions reference samplers

2016-02-05 Thread Jason Ekstrand
Originally, NIR texture instructions had a pointer to a deref chain that
represented the sampler.  This commit changes that.  Instead, we now use a
load_var to get the sampler index and then pass that directly into the
sampler_offset source of the instruction.  This mechanism has a couple of
advantages:  First, it gets rid of a bunch of special-casing around handling
variable derefs.  Second, it means that we can now pass samplers into
functions because the load of a sampler is just an integer.  This will make
things a bit easier for SPIR-V.
---
 src/compiler/nir/glsl_to_nir.cpp   | 35 ---
 src/compiler/nir/nir.c |  5 ---
 src/compiler/nir/nir.h |  2 -
 src/compiler/nir/nir_clone.c   |  2 -
 src/compiler/nir/nir_instr_set.c   | 15 +--
 src/compiler/nir/nir_lower_samplers.c  | 59 +-
 src/compiler/nir/nir_opt_constant_folding.c|  5 +--
 src/compiler/nir/nir_print.c   |  6 +--
 src/compiler/nir/nir_remove_dead_variables.c   | 13 --
 src/compiler/nir/nir_validate.c|  7 +--
 src/gallium/drivers/vc4/vc4_nir_lower_txf_ms.c |  1 -
 11 files changed, 53 insertions(+), 97 deletions(-)

diff --git a/src/compiler/nir/glsl_to_nir.cpp b/src/compiler/nir/glsl_to_nir.cpp
index 365fd4d..7ddf8d2 100644
--- a/src/compiler/nir/glsl_to_nir.cpp
+++ b/src/compiler/nir/glsl_to_nir.cpp
@@ -1753,69 +1753,69 @@ nir_visitor::visit(ir_swizzle *ir)
 void
 nir_visitor::visit(ir_texture *ir)
 {
-   unsigned num_srcs;
+   unsigned num_srcs = 1 /* Texture index */;
nir_texop op;
switch (ir->op) {
case ir_tex:
   op = nir_texop_tex;
-  num_srcs = 1; /* coordinate */
+  num_srcs += 1; /* coordinate */
   break;
 
case ir_txb:
case ir_txl:
   op = (ir->op == ir_txb) ? nir_texop_txb : nir_texop_txl;
-  num_srcs = 2; /* coordinate, bias/lod */
+  num_srcs += 2; /* coordinate, bias/lod */
   break;
 
case ir_txd:
   op = nir_texop_txd; /* coordinate, dPdx, dPdy */
-  num_srcs = 3;
+  num_srcs += 3;
   break;
 
case ir_txf:
   op = nir_texop_txf;
   if (ir->lod_info.lod != NULL)
- num_srcs = 2; /* coordinate, lod */
+ num_srcs += 2; /* coordinate, lod */
   else
- num_srcs = 1; /* coordinate */
+ num_srcs += 1; /* coordinate */
   break;
 
case ir_txf_ms:
   op = nir_texop_txf_ms;
-  num_srcs = 2; /* coordinate, sample_index */
+  num_srcs += 2; /* coordinate, sample_index */
   break;
 
case ir_txs:
   op = nir_texop_txs;
   if (ir->lod_info.lod != NULL)
- num_srcs = 1; /* lod */
+ num_srcs += 1; /* lod */
   else
- num_srcs = 0;
+ num_srcs += 0;
   break;
 
case ir_lod:
   op = nir_texop_lod;
-  num_srcs = 1; /* coordinate */
+  num_srcs += 1; /* coordinate */
   break;
 
case ir_tg4:
   op = nir_texop_tg4;
-  num_srcs = 1; /* coordinate */
+  num_srcs += 1; /* coordinate */
   break;
 
case ir_query_levels:
   op = nir_texop_query_levels;
-  num_srcs = 0;
+  num_srcs += 0;
   break;
 
case ir_texture_samples:
   op = nir_texop_texture_samples;
-  num_srcs = 0;
+  num_srcs += 0;
   break;
 
case ir_samples_identical:
   op = nir_texop_samples_identical;
-  num_srcs = 1; /* coordinate */
+  num_srcs += 1; /* coordinate */
   break;
 
default:
@@ -1853,9 +1853,12 @@ nir_visitor::visit(ir_texture *ir)
   unreachable("not reached");
}
 
-   instr->sampler = evaluate_deref(&instr->instr, ir->sampler);
+   nir_deref_var *sampler_deref = evaluate_deref(&instr->instr, ir->sampler);
+   instr->src[0].src = nir_src_for_ssa(nir_load_deref_var(&b, sampler_deref));
+   instr->src[0].src_type = nir_tex_src_sampler_offset;
+   instr->sampler_index = 0;
 
-   unsigned src_number = 0;
+   unsigned src_number = 1;
 
if (ir->coordinate != NULL) {
   instr->coord_components = ir->coordinate->type->vector_elements;
diff --git a/src/compiler/nir/nir.c b/src/compiler/nir/nir.c
index 805c72d..f10fe6a 100644
--- a/src/compiler/nir/nir.c
+++ b/src/compiler/nir/nir.c
@@ -488,7 +488,6 @@ nir_tex_instr_create(nir_shader *shader, unsigned num_srcs)
 
instr->sampler_index = 0;
instr->max_sampler_index = 0;
-   instr->sampler = NULL;
 
return instr;
 }
@@ -1005,10 +1004,6 @@ visit_tex_src(nir_tex_instr *instr, nir_foreach_src_cb 
cb, void *state)
   if (!visit_src(&instr->src[i].src, cb, state))
  return false;
 
-   if (instr->sampler != NULL)
-  if (!visit_deref_src(instr->sampler, cb, state))
- return false;
-
return true;
 }
 
diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
index b077f5a..645f71d 100644
--- a/src/compiler/nir/nir.h
+++ b/src/compiler/nir/nir.h
@@ -982,8 +982,6 @@ typedef struct {
 
/** The maximum total sampler index

[Mesa-dev] [RFC 3/6] nir/types: Advertise 1 vector component for sampler types

2016-02-05 Thread Jason Ekstrand
Soon we are going to start doing loads of sampler variables.  When this
happens, we will define the semantics of such a load to be that it returns
the binding table index which is a 1-component integer.
---
 src/compiler/nir_types.cpp | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/compiler/nir_types.cpp b/src/compiler/nir_types.cpp
index a87dcd8..b93ffa3 100644
--- a/src/compiler/nir_types.cpp
+++ b/src/compiler/nir_types.cpp
@@ -85,7 +85,10 @@ glsl_get_base_type(const struct glsl_type *type)
 unsigned
 glsl_get_vector_elements(const struct glsl_type *type)
 {
-   return type->vector_elements;
+   if (type->base_type == GLSL_TYPE_SAMPLER)
+  return 1;
+   else
+  return type->vector_elements;
 }
 
 unsigned
-- 
2.5.0.400.gff86faf

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


[Mesa-dev] [RFC 2/6] nir/builder: Add a helper for loading from a deref_var

2016-02-05 Thread Jason Ekstrand
---
 src/compiler/nir/nir_builder.h | 15 +++
 1 file changed, 15 insertions(+)

diff --git a/src/compiler/nir/nir_builder.h b/src/compiler/nir/nir_builder.h
index 88ba3a1..1252301 100644
--- a/src/compiler/nir/nir_builder.h
+++ b/src/compiler/nir/nir_builder.h
@@ -334,6 +334,21 @@ nir_load_var(nir_builder *build, nir_variable *var)
return &load->dest.ssa;
 }
 
+static inline nir_ssa_def *
+nir_load_deref_var(nir_builder *build, nir_deref_var *deref)
+{
+   const struct nir_deref *deref_tail = nir_deref_tail(&deref->deref);
+   const unsigned num_components = glsl_get_vector_elements(deref_tail->type);
+
+   nir_intrinsic_instr *load =
+  nir_intrinsic_instr_create(build->shader, nir_intrinsic_load_var);
+   load->num_components = num_components;
+   load->variables[0] = nir_copy_deref_var(load, deref);
+   nir_ssa_dest_init(&load->instr, &load->dest, num_components, NULL);
+   nir_builder_instr_insert(build, &load->instr);
+   return &load->dest.ssa;
+}
+
 static inline void
 nir_store_var(nir_builder *build, nir_variable *var, nir_ssa_def *value,
   unsigned writemask)
-- 
2.5.0.400.gff86faf

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


[Mesa-dev] [RFC 5/6] nir: Replace tex_instr.array_size with max_sampler_index

2016-02-05 Thread Jason Ekstrand
---
 src/compiler/nir/nir.c | 2 +-
 src/compiler/nir/nir.h | 4 ++--
 src/compiler/nir/nir_clone.c   | 2 +-
 src/compiler/nir/nir_instr_set.c   | 4 ++--
 src/compiler/nir/nir_lower_samplers.c  | 4 ++--
 src/mesa/drivers/dri/i965/brw_fs_nir.cpp   | 2 +-
 src/mesa/drivers/dri/i965/brw_vec4_nir.cpp | 3 +--
 7 files changed, 10 insertions(+), 11 deletions(-)

diff --git a/src/compiler/nir/nir.c b/src/compiler/nir/nir.c
index 2247a98..805c72d 100644
--- a/src/compiler/nir/nir.c
+++ b/src/compiler/nir/nir.c
@@ -487,7 +487,7 @@ nir_tex_instr_create(nir_shader *shader, unsigned num_srcs)
   src_init(&instr->src[i].src);
 
instr->sampler_index = 0;
-   instr->sampler_array_size = 0;
+   instr->max_sampler_index = 0;
instr->sampler = NULL;
 
return instr;
diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
index 3b85bf5..b077f5a 100644
--- a/src/compiler/nir/nir.h
+++ b/src/compiler/nir/nir.h
@@ -980,8 +980,8 @@ typedef struct {
 */
unsigned sampler_index;
 
-   /** The size of the sampler array or 0 if it's not an array */
-   unsigned sampler_array_size;
+   /** The maximum total sampler index including base and indirect*/
+   unsigned max_sampler_index;
 
nir_deref_var *sampler; /* if this is NULL, use sampler_index instead */
 } nir_tex_instr;
diff --git a/src/compiler/nir/nir_clone.c b/src/compiler/nir/nir_clone.c
index 5eff743..fc2e2d1 100644
--- a/src/compiler/nir/nir_clone.c
+++ b/src/compiler/nir/nir_clone.c
@@ -358,7 +358,7 @@ clone_tex(clone_state *state, const nir_tex_instr *tex)
memcpy(ntex->const_offset, tex->const_offset, sizeof(ntex->const_offset));
ntex->component = tex->component;
ntex->sampler_index = tex->sampler_index;
-   ntex->sampler_array_size = tex->sampler_array_size;
+   ntex->max_sampler_index = tex->max_sampler_index;
if (tex->sampler)
   ntex->sampler = clone_deref_var(state, tex->sampler, &ntex->instr);
 
diff --git a/src/compiler/nir/nir_instr_set.c b/src/compiler/nir/nir_instr_set.c
index d3f939f..32c7318 100644
--- a/src/compiler/nir/nir_instr_set.c
+++ b/src/compiler/nir/nir_instr_set.c
@@ -156,7 +156,7 @@ hash_tex(uint32_t hash, const nir_tex_instr *instr)
unsigned component = instr->component;
hash = HASH(hash, component);
hash = HASH(hash, instr->sampler_index);
-   hash = HASH(hash, instr->sampler_array_size);
+   hash = HASH(hash, instr->max_sampler_index);
 
assert(!instr->sampler);
 
@@ -306,7 +306,7 @@ nir_instrs_equal(const nir_instr *instr1, const nir_instr 
*instr2)
  sizeof(tex1->const_offset)) != 0 ||
   tex1->component != tex2->component ||
  tex1->sampler_index != tex2->sampler_index ||
- tex1->sampler_array_size != tex2->sampler_array_size) {
+ tex1->max_sampler_index != tex2->max_sampler_index) {
  return false;
   }
 
diff --git a/src/compiler/nir/nir_lower_samplers.c 
b/src/compiler/nir/nir_lower_samplers.c
index 96e8291..c889df0 100644
--- a/src/compiler/nir/nir_lower_samplers.c
+++ b/src/compiler/nir/nir_lower_samplers.c
@@ -125,8 +125,6 @@ lower_sampler(nir_tex_instr *instr, const struct 
gl_shader_program *shader_progr
   nir_instr_rewrite_src(&instr->instr,
 &instr->src[instr->num_srcs - 1].src,
 nir_src_for_ssa(indirect));
-
-  instr->sampler_array_size = array_elements;
}
 
if (location > shader_program->NumUniformStorage - 1 ||
@@ -138,6 +136,8 @@ lower_sampler(nir_tex_instr *instr, const struct 
gl_shader_program *shader_progr
instr->sampler_index +=
   shader_program->UniformStorage[location].opaque[stage].index;
 
+   instr->max_sampler_index = instr->sampler_index + array_elements - 1;
+
instr->sampler = NULL;
 }
 
diff --git a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp 
b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp
index 0efb2fa..159561a 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp
@@ -3009,7 +3009,7 @@ fs_visitor::nir_emit_texture(const fs_builder &bld, 
nir_tex_instr *instr)
 
   case nir_tex_src_sampler_offset: {
  /* Figure out the highest possible sampler index and mark it as used 
*/
- uint32_t max_used = sampler + instr->sampler_array_size - 1;
+ uint32_t max_used = instr->max_sampler_index;
  if (instr->op == nir_texop_tg4 && devinfo->gen < 8) {
 max_used += stage_prog_data->binding_table.gather_texture_start;
  } else {
diff --git a/src/mesa/drivers/dri/i965/brw_vec4_nir.cpp 
b/src/mesa/drivers/dri/i965/brw_vec4_nir.cpp
index d3ac7ab..747263e 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4_nir.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4_nir.cpp
@@ -1720,8 +1720,7 @@ vec4_visitor::nir_emit_texture(nir_tex_instr *instr)
   * the last element of the array. Mark it here, because the generator
   * doesn't have enough information to determine the bo

Re: [Mesa-dev] [PATCH 1/2] glsl: replace unreachable code with an assert()

2016-02-05 Thread Kenneth Graunke
On Wednesday, February 3, 2016 10:26:07 AM PST Timothy Arceri wrote:
> All interface blocks will have been lowered by this point so just
> use an assert. Returning false would have caused all sorts of
> problems if they were not lowered yet and there is an assert to
> catch this later anyway.
> 
> We also update the tests to reflect this change.
> ---
>  src/compiler/glsl/link_varyings.cpp   | 25 --
>  src/compiler/glsl/tests/varyings_test.cpp | 78
> --- 2 files changed, 38 insertions(+), 65
> deletions(-)

Both are:
Reviewed-by: Kenneth Graunke 


signature.asc
Description: This is a digitally signed message part.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 2/7] st/mesa: implement GL_ATI_fragment_shader

2016-02-05 Thread Ian Romanick
On 02/05/2016 01:11 PM, Miklós Máté wrote:
> v2: fix arithmetic for special opcodes
>  (based on comments from Marek and Ilia),
>  fix fog state, cleanup
> ---
>  src/mesa/Makefile.sources |   1 +
>  src/mesa/program/program.h|   2 +
>  src/mesa/state_tracker/st_atifs_to_tgsi.c | 734 
> ++
>  src/mesa/state_tracker/st_atifs_to_tgsi.h |  65 +++
>  src/mesa/state_tracker/st_atom_constbuf.c |  14 +
>  src/mesa/state_tracker/st_atom_shader.c   |   5 +-
>  src/mesa/state_tracker/st_cb_drawpixels.c |   1 +
>  src/mesa/state_tracker/st_cb_program.c|  36 +-
>  src/mesa/state_tracker/st_program.c   |  30 +-
>  src/mesa/state_tracker/st_program.h   |   4 +
>  10 files changed, 889 insertions(+), 3 deletions(-)
>  create mode 100644 src/mesa/state_tracker/st_atifs_to_tgsi.c
>  create mode 100644 src/mesa/state_tracker/st_atifs_to_tgsi.h
> 
> diff --git a/src/mesa/Makefile.sources b/src/mesa/Makefile.sources
> index ffe560f..23fe42a 100644
> --- a/src/mesa/Makefile.sources
> +++ b/src/mesa/Makefile.sources
> @@ -393,6 +393,7 @@ VBO_FILES = \
>   vbo/vbo_split_inplace.c
>  
>  STATETRACKER_FILES = \
> + state_tracker/st_atifs_to_tgsi.c \
>   state_tracker/st_atom_array.c \
>   state_tracker/st_atom_atomicbuf.c \
>   state_tracker/st_atom_blend.c \
> diff --git a/src/mesa/program/program.h b/src/mesa/program/program.h
> index 24e0597..09e6928 100644
> --- a/src/mesa/program/program.h
> +++ b/src/mesa/program/program.h
> @@ -172,6 +172,8 @@ _mesa_program_enum_to_shader_stage(GLenum v)
>return MESA_SHADER_VERTEX;
> case GL_FRAGMENT_PROGRAM_ARB:
>return MESA_SHADER_FRAGMENT;
> +   case GL_FRAGMENT_SHADER_ATI:
> +  return MESA_SHADER_FRAGMENT;
> case GL_GEOMETRY_PROGRAM_NV:
>return MESA_SHADER_GEOMETRY;
> case GL_TESS_CONTROL_PROGRAM_NV:
> diff --git a/src/mesa/state_tracker/st_atifs_to_tgsi.c 
> b/src/mesa/state_tracker/st_atifs_to_tgsi.c
> new file mode 100644
> index 000..fe303f6
> --- /dev/null
> +++ b/src/mesa/state_tracker/st_atifs_to_tgsi.c
> @@ -0,0 +1,734 @@
> +/*
> + * Copyright (C) 2016 Miklós Máté
> + *
> + * Permission is hereby granted, free of charge, to any person obtaining a
> + * copy of this software and associated documentation files (the "Software"),
> + * to deal in the Software without restriction, including without limitation
> + * the rights to use, copy, modify, merge, publish, distribute, sublicense,
> + * and/or sell copies of the Software, and to permit persons to whom the
> + * Software is furnished to do so, subject to the following conditions:
> + *
> + * The above copyright notice and this permission notice shall be included in
> + * all copies or substantial portions of the Software.
> + *
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
> + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
> + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
> + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
> + * OTHER DEALINGS IN THE SOFTWARE.
> + */
> +
> +#include "main/mtypes.h"
> +#include "main/atifragshader.h"
> +#include "main/texobj.h"
> +#include "main/errors.h"
> +#include "program/prog_parameter.h"
> +
> +#include "tgsi/tgsi_transform.h"
> +#include "tgsi/tgsi_ureg.h"
> +#include "util/u_math.h"
> +#include "util/u_memory.h"
> +
> +#include "st_program.h"
> +#include "st_atifs_to_tgsi.h"
> +
> +/**
> + * Intermediate state used during shader translation.
> + */
> +struct st_translate {
> +   struct ureg_program *ureg;
> +   struct gl_context *ctx;
> +   struct ati_fragment_shader *atifs;
> +
> +   struct ureg_dst temps[MAX_PROGRAM_TEMPS];
> +   struct ureg_src *constants;
> +   struct ureg_dst outputs[PIPE_MAX_SHADER_OUTPUTS];
> +   struct ureg_src inputs[PIPE_MAX_SHADER_INPUTS];
> +   struct ureg_src samplers[PIPE_MAX_SAMPLERS];
> +
> +   const GLuint *inputMapping;
> +   const GLuint *outputMapping;
> +
> +   unsigned current_pass;
> +
> +   bool regs_written[MAX_NUM_PASSES_ATI][MAX_NUM_FRAGMENT_REGISTERS_ATI];
> +
> +   boolean error;
> +};
> +
> +struct instruction_desc {
> +   unsigned TGSI_opcode;
> +   const char *name;
> +   unsigned char arg_count;
> +   unsigned char special; /* no 1:1 corresponding TGSI instruction */
> +};
> +
> +static struct instruction_desc inst_desc[] = {
> +   {TGSI_OPCODE_MOV, "MOV", 1, 0},
> +   {TGSI_OPCODE_NOP, "UND", 0, 0}, /* unused */
> +   {TGSI_OPCODE_ADD, "ADD", 2, 0},
> +   {TGSI_OPCODE_MUL, "MUL", 2, 0},
> +   {TGSI_OPCODE_SUB, "SUB", 2, 0},
> +   {TGSI_OPCODE_DP3, "DOT3", 2, 0},
> +   {TGSI_OPCODE_DP4, "DOT4", 2, 0},
> +   {TGSI_OPCODE_MAD, "MAD", 3, 0},
> +   {TGSI_OPCODE_LRP, "LERP", 3, 0},
> +   {TGSI_OPCODE_NOP, "CND", 3, 1},
> +   {TGSI_OPCODE_NOP, "CND0"

[Mesa-dev] GLSL IR is no longer cool where to from here?

2016-02-05 Thread Timothy Arceri
For the past couple of months I've been working away solely in the
wasteland that is GLSL IR and one things seems clear. No one wants to
review this code anymore. A lot of the original developers have either
moved on or are busy with other things.

The difference between sending a patch with nir: ... vs glsl: ... is
very noticable.

Its not impossible to get reviews for patches, especially if they are a
small part of a bigger series not just confined to GLSL IR, but
anything involving a refactoring can be difficult as no-one wants to
relearn how this code works, step up to the ast code and things are
even worse.

So I guess the discussion I'm trying to kick off is, with the CTS, dEPQ
and piglit all saying no regressions (or even reporting fixes \0/).
Should one still be forced to go around hassling people for a rubber
stamped r-b? Or can we relax the criteria for pushing bug-fix/refactor
type patches for GLSL-IR?

The other thing I've consider is maybe this I just don't review enough
patches for people to reciprocate, although I've made an effort to
review patches where I feel I can since being employed to work on Mesa
so hopefully thats not it. Maybe it's time for Ken to run his script
again :-P

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


Re: [Mesa-dev] [PATCH 1/1] r600, compute: Do not overwrite pipe_resource.screen

2016-02-05 Thread Nicolai Hähnle

On 05.02.2016 17:54, Jan Vesely wrote:

found by inspection.

Signed-off-by: Jan Vesely 


Pushed, thanks!


---
  src/gallium/drivers/r600/evergreen_compute.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/gallium/drivers/r600/evergreen_compute.c 
b/src/gallium/drivers/r600/evergreen_compute.c
index bc27333..3b4f139 100644
--- a/src/gallium/drivers/r600/evergreen_compute.c
+++ b/src/gallium/drivers/r600/evergreen_compute.c
@@ -967,8 +967,8 @@ struct pipe_resource *r600_compute_global_buffer_create(
templ->array_size);

result->base.b.vtbl = &r600_global_buffer_vtbl;
-   result->base.b.b.screen = screen;
result->base.b.b = *templ;
+   result->base.b.b.screen = screen;
pipe_reference_init(&result->base.b.b.reference, 1);

size_in_dw = (templ->width0+3) / 4;


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


Re: [Mesa-dev] [PATCH] radeonsi: don't emit unnecessary NULL exports for unbound targets (v2)

2016-02-05 Thread Nicolai Hähnle

Reviewed-by: Nicolai Hähnle 

On 05.02.2016 17:51, Marek Olšák wrote:

From: Marek Olšák 

v2: remove semantic index == 0 checks
 add the else statement to remove shadowing of args
---
  src/gallium/drivers/radeonsi/si_shader.c | 88 ++--
  1 file changed, 62 insertions(+), 26 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_shader.c 
b/src/gallium/drivers/radeonsi/si_shader.c
index bd45d4a..63a2908 100644
--- a/src/gallium/drivers/radeonsi/si_shader.c
+++ b/src/gallium/drivers/radeonsi/si_shader.c
@@ -2274,7 +2274,6 @@ static void si_export_mrt_color(struct 
lp_build_tgsi_context *bld_base,
  {
struct si_shader_context *si_shader_ctx = si_shader_context(bld_base);
struct lp_build_context *base = &bld_base->base;
-   LLVMValueRef args[9];
int i;

/* Clamp color */
@@ -2296,27 +2295,46 @@ static void si_export_mrt_color(struct 
lp_build_tgsi_context *bld_base,
color[3] = si_scale_alpha_by_sample_mask(bld_base, color[3]);

/* If last_cbuf > 0, FS_COLOR0_WRITES_ALL_CBUFS is true. */
-   if (index == 0 &&
-   si_shader_ctx->shader->key.ps.last_cbuf > 0) {
-   for (int c = 1; c <= si_shader_ctx->shader->key.ps.last_cbuf; 
c++) {
+   if (si_shader_ctx->shader->key.ps.last_cbuf > 0) {
+   LLVMValueRef args[8][9];
+   int c, last = -1;
+
+   /* Get the export arguments, also find out what the last one 
is. */
+   for (c = 0; c <= si_shader_ctx->shader->key.ps.last_cbuf; c++) {
si_llvm_init_export_args(bld_base, color,
-V_008DFC_SQ_EXP_MRT + c, args);
+V_008DFC_SQ_EXP_MRT + c, 
args[c]);
+   if (args[c][0] != bld_base->uint_bld.zero)
+   last = c;
+   }
+
+   /* Emit all exports. */
+   for (c = 0; c <= si_shader_ctx->shader->key.ps.last_cbuf; c++) {
+   if (is_last && last == c) {
+   args[c][1] = bld_base->uint_bld.one; /* whether 
the EXEC mask is valid */
+   args[c][2] = bld_base->uint_bld.one; /* DONE 
bit */
+   } else if (args[c][0] == bld_base->uint_bld.zero)
+   continue; /* unnecessary NULL export */
+
lp_build_intrinsic(base->gallivm->builder, 
"llvm.SI.export",
   
LLVMVoidTypeInContext(base->gallivm->context),
-  args, 9, 0);
+  args[c], 9, 0);
}
+   } else {
+   LLVMValueRef args[9];
+
+   /* Export */
+   si_llvm_init_export_args(bld_base, color, V_008DFC_SQ_EXP_MRT + 
index,
+args);
+   if (is_last) {
+   args[1] = bld_base->uint_bld.one; /* whether the EXEC 
mask is valid */
+   args[2] = bld_base->uint_bld.one; /* DONE bit */
+   } else if (args[0] == bld_base->uint_bld.zero)
+   return; /* unnecessary NULL export */
+
+   lp_build_intrinsic(base->gallivm->builder, "llvm.SI.export",
+  
LLVMVoidTypeInContext(base->gallivm->context),
+  args, 9, 0);
}
-
-   /* Export */
-   si_llvm_init_export_args(bld_base, color, V_008DFC_SQ_EXP_MRT + index,
-args);
-   if (is_last) {
-   args[1] = bld_base->uint_bld.one; /* whether the EXEC mask is 
valid */
-   args[2] = bld_base->uint_bld.one; /* DONE bit */
-   }
-   lp_build_intrinsic(base->gallivm->builder, "llvm.SI.export",
-  LLVMVoidTypeInContext(base->gallivm->context),
-  args, 9, 0);
  }

  static void si_export_null(struct lp_build_tgsi_context *bld_base)
@@ -2351,19 +2369,37 @@ static void si_llvm_emit_fs_epilogue(struct 
lp_build_tgsi_context * bld_base)
int last_color_export = -1;
int i;

-   /* If there are no outputs, add a dummy export. */
-   if (!info->num_outputs) {
-   si_export_null(bld_base);
-   return;
-   }
-
/* Determine the last export. If MRTZ is present, it's always last.
 * Otherwise, find the last color export.
 */
-   if (!info->writes_z && !info->writes_stencil && 
!info->writes_samplemask)
-   for (i = 0; i < info->num_outputs; i++)
-   if (info->output_semantic_name[i] == 
TGSI_SEMANTIC_COLOR)
+   if (!info->writes_z && !info->writes_stencil && 
!info->writes_samplemask) {
+   unsigned spi_format = shader->key.ps.spi_shader_col_format;
+
+   for (i = 0; i < info->num_ou

Re: [Mesa-dev] [PATCH] mesa: move GL_ARB_debug_output code into new debug_output.c file

2016-02-05 Thread Timothy Arceri
On Fri, 2016-02-05 at 17:54 -0700, Brian Paul wrote:
> The errors.c file had grown quite large so split off this extension
> code into its own file.  This involved making a handful of functions
> non-static.

I was going to do this when I added KHR_debug but was too new at the
time and didn't want to make such a big change.

Acked-by: Timothy Arceri 

I guess we could also move the object labels suff in there but probably
not worth the effort.

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


Re: [Mesa-dev] [PATCH 26/28] glsl: lower tessellation varyings packed with component layout qualifier

2016-02-05 Thread Timothy Arceri
Hi Anuj/anyone who feels like reviewing,

As this is the last remaining patch in the series that I'd like to get
addtional feedback on please let me know what I can do to speed things
up.

I originally assumed that the code comments would help make reviewing
easy despite the size of the patch. However if you would like me to
break it down just let me know. I'm keen to land this as I'm starting
to get a bunch of patches queuing up behind it :)

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


[Mesa-dev] [PATCH 1/4] tgsi: break gigantic tgsi_scan_shader() function into pieces

2016-02-05 Thread Brian Paul
New functions for examining instructions, declarations, etc.
---
 src/gallium/auxiliary/tgsi/tgsi_scan.c | 739 +
 1 file changed, 375 insertions(+), 364 deletions(-)

diff --git a/src/gallium/auxiliary/tgsi/tgsi_scan.c 
b/src/gallium/auxiliary/tgsi/tgsi_scan.c
index 687fb54..4199dbe 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_scan.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_scan.c
@@ -44,6 +44,375 @@
 
 
 
+static void
+scan_instruction(struct tgsi_shader_info *info,
+ const struct tgsi_full_instruction *fullinst,
+ unsigned *current_depth)
+{
+   unsigned i;
+
+   assert(fullinst->Instruction.Opcode < TGSI_OPCODE_LAST);
+   info->opcode_count[fullinst->Instruction.Opcode]++;
+
+   switch (fullinst->Instruction.Opcode) {
+   case TGSI_OPCODE_IF:
+   case TGSI_OPCODE_UIF:
+   case TGSI_OPCODE_BGNLOOP:
+  (*current_depth)++;
+  info->max_depth = MAX2(info->max_depth, *current_depth);
+  break;
+   case TGSI_OPCODE_ENDIF:
+   case TGSI_OPCODE_ENDLOOP:
+  (*current_depth)--;
+  break;
+   default:
+  break;
+   }
+
+   if (fullinst->Instruction.Opcode == TGSI_OPCODE_INTERP_CENTROID ||
+   fullinst->Instruction.Opcode == TGSI_OPCODE_INTERP_OFFSET ||
+   fullinst->Instruction.Opcode == TGSI_OPCODE_INTERP_SAMPLE) {
+  const struct tgsi_full_src_register *src0 = &fullinst->Src[0];
+  unsigned input;
+
+  if (src0->Register.Indirect && src0->Indirect.ArrayID)
+ input = info->input_array_first[src0->Indirect.ArrayID];
+  else
+ input = src0->Register.Index;
+
+  /* For the INTERP opcodes, the interpolation is always
+   * PERSPECTIVE unless LINEAR is specified.
+   */
+  switch (info->input_interpolate[input]) {
+  case TGSI_INTERPOLATE_COLOR:
+  case TGSI_INTERPOLATE_CONSTANT:
+  case TGSI_INTERPOLATE_PERSPECTIVE:
+ switch (fullinst->Instruction.Opcode) {
+ case TGSI_OPCODE_INTERP_CENTROID:
+info->uses_persp_opcode_interp_centroid = true;
+break;
+ case TGSI_OPCODE_INTERP_OFFSET:
+info->uses_persp_opcode_interp_offset = true;
+break;
+ case TGSI_OPCODE_INTERP_SAMPLE:
+info->uses_persp_opcode_interp_sample = true;
+break;
+ }
+ break;
+
+  case TGSI_INTERPOLATE_LINEAR:
+ switch (fullinst->Instruction.Opcode) {
+ case TGSI_OPCODE_INTERP_CENTROID:
+info->uses_linear_opcode_interp_centroid = true;
+break;
+ case TGSI_OPCODE_INTERP_OFFSET:
+info->uses_linear_opcode_interp_offset = true;
+break;
+ case TGSI_OPCODE_INTERP_SAMPLE:
+info->uses_linear_opcode_interp_sample = true;
+break;
+ }
+ break;
+  }
+   }
+
+   if (fullinst->Instruction.Opcode >= TGSI_OPCODE_F2D &&
+   fullinst->Instruction.Opcode <= TGSI_OPCODE_DSSG)
+  info->uses_doubles = true;
+
+   for (i = 0; i < fullinst->Instruction.NumSrcRegs; i++) {
+  const struct tgsi_full_src_register *src = &fullinst->Src[i];
+  int ind = src->Register.Index;
+
+  /* Mark which inputs are effectively used */
+  if (src->Register.File == TGSI_FILE_INPUT) {
+ unsigned usage_mask;
+ usage_mask = tgsi_util_get_inst_usage_mask(fullinst, i);
+ if (src->Register.Indirect) {
+for (ind = 0; ind < info->num_inputs; ++ind) {
+   info->input_usage_mask[ind] |= usage_mask;
+}
+ } else {
+assert(ind >= 0);
+assert(ind < PIPE_MAX_SHADER_INPUTS);
+info->input_usage_mask[ind] |= usage_mask;
+ }
+
+ if (info->processor == TGSI_PROCESSOR_FRAGMENT &&
+ !src->Register.Indirect) {
+unsigned name =
+   info->input_semantic_name[src->Register.Index];
+unsigned index =
+   info->input_semantic_index[src->Register.Index];
+
+if (name == TGSI_SEMANTIC_POSITION &&
+(src->Register.SwizzleX == TGSI_SWIZZLE_Z ||
+ src->Register.SwizzleY == TGSI_SWIZZLE_Z ||
+ src->Register.SwizzleZ == TGSI_SWIZZLE_Z ||
+ src->Register.SwizzleW == TGSI_SWIZZLE_Z))
+   info->reads_z = TRUE;
+
+if (name == TGSI_SEMANTIC_COLOR) {
+   unsigned mask =
+  (1 << src->Register.SwizzleX) |
+  (1 << src->Register.SwizzleY) |
+  (1 << src->Register.SwizzleZ) |
+  (1 << src->Register.SwizzleW);
+
+   info->colors_read |= mask << (index * 4);
+}
+ }
+  }
+
+  /* check for indirect register reads */
+  if (src->Register.Indirect) {
+ info->indirect_files |= (1 << src->Register.File);
+ info->indirect_files_read |= (1 << src->Register.File);
+  }
+
+  /* MSAA samplers */
+  if (src->Register.File =

[Mesa-dev] [PATCH 4/4] tgsi: minor whitespace fixes in tgsi_scan.c

2016-02-05 Thread Brian Paul
---
 src/gallium/auxiliary/tgsi/tgsi_scan.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/src/gallium/auxiliary/tgsi/tgsi_scan.c 
b/src/gallium/auxiliary/tgsi/tgsi_scan.c
index 42b62aa..489423d 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_scan.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_scan.c
@@ -462,12 +462,10 @@ tgsi_scan_shader(const struct tgsi_token *tokens,
   procType == TGSI_PROCESSOR_COMPUTE);
info->processor = procType;
 
-
/**
 ** Loop over incoming program tokens/instructions
 */
-   while( !tgsi_parse_end_of_tokens( &parse ) ) {
-
+   while (!tgsi_parse_end_of_tokens(&parse)) {
   info->num_tokens++;
 
   tgsi_parse_token( &parse );
@@ -510,7 +508,7 @@ tgsi_scan_shader(const struct tgsi_token *tokens,
   }
}
 
-   tgsi_parse_free (&parse);
+   tgsi_parse_free(&parse);
 }
 
 
-- 
1.9.1

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


[Mesa-dev] [PATCH 3/4] tgsi: s/true/TRUE/ in tgsi_scan.c

2016-02-05 Thread Brian Paul
Just to be consistent.
---
 src/gallium/auxiliary/tgsi/tgsi_scan.c | 26 +-
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/src/gallium/auxiliary/tgsi/tgsi_scan.c 
b/src/gallium/auxiliary/tgsi/tgsi_scan.c
index a7d4b0c..42b62aa 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_scan.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_scan.c
@@ -89,13 +89,13 @@ scan_instruction(struct tgsi_shader_info *info,
   case TGSI_INTERPOLATE_PERSPECTIVE:
  switch (fullinst->Instruction.Opcode) {
  case TGSI_OPCODE_INTERP_CENTROID:
-info->uses_persp_opcode_interp_centroid = true;
+info->uses_persp_opcode_interp_centroid = TRUE;
 break;
  case TGSI_OPCODE_INTERP_OFFSET:
-info->uses_persp_opcode_interp_offset = true;
+info->uses_persp_opcode_interp_offset = TRUE;
 break;
  case TGSI_OPCODE_INTERP_SAMPLE:
-info->uses_persp_opcode_interp_sample = true;
+info->uses_persp_opcode_interp_sample = TRUE;
 break;
  }
  break;
@@ -103,13 +103,13 @@ scan_instruction(struct tgsi_shader_info *info,
   case TGSI_INTERPOLATE_LINEAR:
  switch (fullinst->Instruction.Opcode) {
  case TGSI_OPCODE_INTERP_CENTROID:
-info->uses_linear_opcode_interp_centroid = true;
+info->uses_linear_opcode_interp_centroid = TRUE;
 break;
  case TGSI_OPCODE_INTERP_OFFSET:
-info->uses_linear_opcode_interp_offset = true;
+info->uses_linear_opcode_interp_offset = TRUE;
 break;
  case TGSI_OPCODE_INTERP_SAMPLE:
-info->uses_linear_opcode_interp_sample = true;
+info->uses_linear_opcode_interp_sample = TRUE;
 break;
  }
  break;
@@ -118,7 +118,7 @@ scan_instruction(struct tgsi_shader_info *info,
 
if (fullinst->Instruction.Opcode >= TGSI_OPCODE_F2D &&
fullinst->Instruction.Opcode <= TGSI_OPCODE_DSSG)
-  info->uses_doubles = true;
+  info->uses_doubles = TRUE;
 
for (i = 0; i < fullinst->Instruction.NumSrcRegs; i++) {
   const struct tgsi_full_src_register *src = &fullinst->Src[i];
@@ -265,26 +265,26 @@ scan_declaration(struct tgsi_shader_info *info,
 case TGSI_INTERPOLATE_PERSPECTIVE:
switch (fulldecl->Interp.Location) {
case TGSI_INTERPOLATE_LOC_CENTER:
-  info->uses_persp_center = true;
+  info->uses_persp_center = TRUE;
   break;
case TGSI_INTERPOLATE_LOC_CENTROID:
-  info->uses_persp_centroid = true;
+  info->uses_persp_centroid = TRUE;
   break;
case TGSI_INTERPOLATE_LOC_SAMPLE:
-  info->uses_persp_sample = true;
+  info->uses_persp_sample = TRUE;
   break;
}
break;
 case TGSI_INTERPOLATE_LINEAR:
switch (fulldecl->Interp.Location) {
case TGSI_INTERPOLATE_LOC_CENTER:
-  info->uses_linear_center = true;
+  info->uses_linear_center = TRUE;
   break;
case TGSI_INTERPOLATE_LOC_CENTROID:
-  info->uses_linear_centroid = true;
+  info->uses_linear_centroid = TRUE;
   break;
case TGSI_INTERPOLATE_LOC_SAMPLE:
-  info->uses_linear_sample = true;
+  info->uses_linear_sample = TRUE;
   break;
}
break;
-- 
1.9.1

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


[Mesa-dev] [PATCH 2/4] tgsi: use switches instead of big if/else ifs

2016-02-05 Thread Brian Paul
---
 src/gallium/auxiliary/tgsi/tgsi_scan.c | 60 --
 1 file changed, 36 insertions(+), 24 deletions(-)

diff --git a/src/gallium/auxiliary/tgsi/tgsi_scan.c 
b/src/gallium/auxiliary/tgsi/tgsi_scan.c
index 4199dbe..a7d4b0c 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_scan.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_scan.c
@@ -307,28 +307,35 @@ scan_declaration(struct tgsi_shader_info *info,
  info->system_value_semantic_name[index] = semName;
  info->num_system_values = MAX2(info->num_system_values, index + 1);
 
- if (semName == TGSI_SEMANTIC_INSTANCEID) {
+ switch (semName) {
+ case TGSI_SEMANTIC_INSTANCEID:
 info->uses_instanceid = TRUE;
- }
- else if (semName == TGSI_SEMANTIC_VERTEXID) {
+break;
+ case TGSI_SEMANTIC_VERTEXID:
 info->uses_vertexid = TRUE;
- }
- else if (semName == TGSI_SEMANTIC_VERTEXID_NOBASE) {
+break;
+ case TGSI_SEMANTIC_VERTEXID_NOBASE:
 info->uses_vertexid_nobase = TRUE;
- }
- else if (semName == TGSI_SEMANTIC_BASEVERTEX) {
+break;
+ case TGSI_SEMANTIC_BASEVERTEX:
 info->uses_basevertex = TRUE;
- }
- else if (semName == TGSI_SEMANTIC_PRIMID) {
+break;
+ case TGSI_SEMANTIC_PRIMID:
 info->uses_primid = TRUE;
- } else if (semName == TGSI_SEMANTIC_INVOCATIONID) {
+break;
+ case TGSI_SEMANTIC_INVOCATIONID:
 info->uses_invocationid = TRUE;
- } else if (semName == TGSI_SEMANTIC_POSITION)
+break;
+ case TGSI_SEMANTIC_POSITION:
 info->reads_position = TRUE;
- else if (semName == TGSI_SEMANTIC_FACE)
+break;
+ case TGSI_SEMANTIC_FACE:
 info->uses_frontface = TRUE;
- else if (semName == TGSI_SEMANTIC_SAMPLEMASK)
+break;
+ case TGSI_SEMANTIC_SAMPLEMASK:
 info->reads_samplemask = TRUE;
+break;
+ }
   }
   else if (file == TGSI_FILE_OUTPUT) {
  info->output_semantic_name[reg] = (ubyte) semName;
@@ -342,28 +349,33 @@ scan_declaration(struct tgsi_shader_info *info,
  procType == TGSI_PROCESSOR_GEOMETRY ||
  procType == TGSI_PROCESSOR_TESS_CTRL ||
  procType == TGSI_PROCESSOR_TESS_EVAL) {
-if (semName == TGSI_SEMANTIC_VIEWPORT_INDEX) {
+switch (semName) {
+case TGSI_SEMANTIC_VIEWPORT_INDEX:
info->writes_viewport_index = TRUE;
-}
-else if (semName == TGSI_SEMANTIC_LAYER) {
+   break;
+case TGSI_SEMANTIC_LAYER:
info->writes_layer = TRUE;
-}
-else if (semName == TGSI_SEMANTIC_PSIZE) {
+   break;
+case TGSI_SEMANTIC_PSIZE:
info->writes_psize = TRUE;
-}
-else if (semName == TGSI_SEMANTIC_CLIPVERTEX) {
+   break;
+case TGSI_SEMANTIC_CLIPVERTEX:
info->writes_clipvertex = TRUE;
+   break;
 }
  }
 
  if (procType == TGSI_PROCESSOR_FRAGMENT) {
-if (semName == TGSI_SEMANTIC_POSITION) {
+switch (semName) {
+case TGSI_SEMANTIC_POSITION:
info->writes_z = TRUE;
-}
-else if (semName == TGSI_SEMANTIC_STENCIL) {
+   break;
+case TGSI_SEMANTIC_STENCIL:
info->writes_stencil = TRUE;
-} else if (semName == TGSI_SEMANTIC_SAMPLEMASK) {
+   break;
+case TGSI_SEMANTIC_SAMPLEMASK:
info->writes_samplemask = TRUE;
+   break;
 }
  }
 
-- 
1.9.1

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


[Mesa-dev] [PATCH] st/mesa: move VS creation in bitmap code

2016-02-05 Thread Brian Paul
Do this one-time init with the other on-time inits.
---
 src/mesa/state_tracker/st_cb_bitmap.c | 26 +-
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/src/mesa/state_tracker/st_cb_bitmap.c 
b/src/mesa/state_tracker/st_cb_bitmap.c
index d8c3dbd..f39d956 100644
--- a/src/mesa/state_tracker/st_cb_bitmap.c
+++ b/src/mesa/state_tracker/st_cb_bitmap.c
@@ -631,19 +631,6 @@ st_Bitmap(struct gl_context *ctx, GLint x, GLint y,
   st_validate_state(st);
}
 
-   if (!st->bitmap.vs) {
-  /* create pass-through vertex shader now */
-  const uint semantic_names[] = { TGSI_SEMANTIC_POSITION,
-  TGSI_SEMANTIC_COLOR,
-st->needs_texcoord_semantic ? TGSI_SEMANTIC_TEXCOORD :
-  TGSI_SEMANTIC_GENERIC };
-  const uint semantic_indexes[] = { 0, 0, 0 };
-  st->bitmap.vs = util_make_vertex_passthrough_shader(st->pipe, 3,
-  semantic_names,
-  semantic_indexes,
-  FALSE);
-   }
-
if (UseBitmapCache && accum_bitmap(ctx, x, y, width, height, unpack, 
bitmap))
   return;
 
@@ -722,6 +709,19 @@ st_init_bitmap(struct st_context *st)
   assert(0);
}
 
+   /* Create VS for rendering bitmaps */
+   {
+  const uint semantic_names[] = { TGSI_SEMANTIC_POSITION,
+  TGSI_SEMANTIC_COLOR,
+st->needs_texcoord_semantic ? TGSI_SEMANTIC_TEXCOORD :
+  TGSI_SEMANTIC_GENERIC };
+  const uint semantic_indexes[] = { 0, 0, 0 };
+  st->bitmap.vs = util_make_vertex_passthrough_shader(st->pipe, 3,
+  semantic_names,
+  semantic_indexes,
+  FALSE);
+   }
+
/* alloc bitmap cache object */
st->bitmap.cache = ST_CALLOC_STRUCT(bitmap_cache);
 
-- 
1.9.1

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


[Mesa-dev] [PATCH 1/3] gallium/util: whitespace, formatting fixes in u_debug.c

2016-02-05 Thread Brian Paul
---
 src/gallium/auxiliary/util/u_debug.c | 201 ++-
 1 file changed, 106 insertions(+), 95 deletions(-)

diff --git a/src/gallium/auxiliary/util/u_debug.c 
b/src/gallium/auxiliary/util/u_debug.c
index 2b60559..7a3d51f 100644
--- a/src/gallium/auxiliary/util/u_debug.c
+++ b/src/gallium/auxiliary/util/u_debug.c
@@ -1,9 +1,9 @@
 /**
- * 
+ *
  * Copyright 2008 VMware, Inc.
  * Copyright (c) 2008 VMware, Inc.
  * All Rights Reserved.
- * 
+ *
  * 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
@@ -11,11 +11,11 @@
  * distribute, sub license, 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 NON-INFRINGEMENT.
@@ -23,22 +23,22 @@
  * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- * 
+ *
  **/
 
 
-#include "pipe/p_config.h" 
+#include "pipe/p_config.h"
 
 #include "pipe/p_compiler.h"
-#include "util/u_debug.h" 
-#include "pipe/p_format.h" 
-#include "pipe/p_state.h" 
-#include "util/u_inlines.h" 
+#include "util/u_debug.h"
+#include "pipe/p_format.h"
+#include "pipe/p_state.h"
+#include "util/u_inlines.h"
 #include "util/u_format.h"
-#include "util/u_memory.h" 
-#include "util/u_string.h" 
-#include "util/u_math.h" 
-#include "util/u_tile.h" 
+#include "util/u_memory.h"
+#include "util/u_string.h"
+#include "util/u_math.h"
+#include "util/u_tile.h"
 #include "util/u_prim.h"
 #include "util/u_surface.h"
 #include 
@@ -53,14 +53,15 @@
 #endif
 
 
-void _debug_vprintf(const char *format, va_list ap)
+void
+_debug_vprintf(const char *format, va_list ap)
 {
static char buf[4096] = {'\0'};
 #if defined(PIPE_OS_WINDOWS) || defined(PIPE_SUBSYSTEM_EMBEDDED)
/* We buffer until we find a newline. */
size_t len = strlen(buf);
int ret = util_vsnprintf(buf + len, sizeof(buf) - len, format, ap);
-   if(ret > (int)(sizeof(buf) - len - 1) || util_strchr(buf + len, '\n')) {
+   if (ret > (int)(sizeof(buf) - len - 1) || util_strchr(buf + len, '\n')) {
   os_log_message(buf);
   buf[0] = '\0';
}
@@ -70,12 +71,12 @@ void _debug_vprintf(const char *format, va_list ap)
 #endif
 }
 
+
 void
-_pipe_debug_message(
-   struct pipe_debug_callback *cb,
-   unsigned *id,
-   enum pipe_debug_type type,
-   const char *fmt, ...)
+_pipe_debug_message(struct pipe_debug_callback *cb,
+unsigned *id,
+enum pipe_debug_type type,
+const char *fmt, ...)
 {
va_list args;
va_start(args, fmt);
@@ -112,9 +113,8 @@ debug_disable_error_message_boxes(void)
 
 
 #ifdef DEBUG
-void debug_print_blob( const char *name,
-   const void *blob,
-   unsigned size )
+void
+debug_print_blob(const char *name, const void *blob, unsigned size)
 {
const unsigned *ublob = (const unsigned *)blob;
unsigned i;
@@ -147,6 +147,7 @@ debug_get_option_should_print(void)
return value;
 }
 
+
 const char *
 debug_get_option(const char *name, const char *dfault)
 {
@@ -157,39 +158,42 @@ debug_get_option(const char *name, const char *dfault)
   result = dfault;
 
if (debug_get_option_should_print())
-  debug_printf("%s: %s = %s\n", __FUNCTION__, name, result ? result : 
"(null)");
-   
+  debug_printf("%s: %s = %s\n", __FUNCTION__, name,
+   result ? result : "(null)");
+
return result;
 }
 
+
 boolean
 debug_get_bool_option(const char *name, boolean dfault)
 {
const char *str = os_get_option(name);
boolean result;
-   
-   if(str == NULL)
+
+   if (str == NULL)
   result = dfault;
-   else if(!util_strcmp(str, "n"))
+   else if (!util_strcmp(str, "n"))
   result = FALSE;
-   else if(!util_strcmp(str, "no"))
+   else if (!util_strcmp(str, "no"))
   result = FALSE;
-   else if(!util_strcmp(str, "0"))
+   else if (!util_strcmp(str, "0"))
   result = FALSE;
-   else if(!util_strcmp(str, "f"))
+   else if (!util_strcmp(str, "f"))
   result = FALSE;
-   else if(!util_strcmp(str, "F"))
+   else if (!util_strcmp(str, "F"))
   result = FALSE;
-   else if(!util_strcmp(str, "false"))
+   else if (!util_strcmp(str, "false"))
 

[Mesa-dev] [PATCH 3/3] gallium/util: switch over to new u_debug_image.[ch] code

2016-02-05 Thread Brian Paul
---
 src/gallium/auxiliary/Makefile.sources |   4 +-
 src/gallium/auxiliary/util/u_debug.c   | 313 +
 src/gallium/auxiliary/util/u_debug.h   |  39 
 src/gallium/drivers/llvmpipe/lp_flush.c|   1 +
 src/gallium/drivers/softpipe/sp_flush.c|   1 +
 src/gallium/drivers/svga/svga_pipe_flush.c |   1 +
 src/gallium/targets/graw-null/graw_util.c  |   1 +
 src/gallium/tests/graw/graw_util.h |   1 +
 src/gallium/tests/trivial/quad-tex.c   |   2 +-
 src/gallium/tests/trivial/tri.c|   2 +-
 10 files changed, 12 insertions(+), 353 deletions(-)

diff --git a/src/gallium/auxiliary/Makefile.sources 
b/src/gallium/auxiliary/Makefile.sources
index 6f50f71..84da85c 100644
--- a/src/gallium/auxiliary/Makefile.sources
+++ b/src/gallium/auxiliary/Makefile.sources
@@ -191,11 +191,13 @@ C_SOURCES := \
util/u_cpu_detect.c \
util/u_cpu_detect.h \
util/u_debug.c \
+   util/u_debug.h \
util/u_debug_describe.c \
util/u_debug_describe.h \
util/u_debug_flush.c \
util/u_debug_flush.h \
-   util/u_debug.h \
+   util/u_debug_image.c \
+   util/u_debug_image.h \
util/u_debug_memory.c \
util/u_debug_refcnt.c \
util/u_debug_refcnt.h \
diff --git a/src/gallium/auxiliary/util/u_debug.c 
b/src/gallium/auxiliary/util/u_debug.c
index 7a3d51f..f378415 100644
--- a/src/gallium/auxiliary/util/u_debug.c
+++ b/src/gallium/auxiliary/util/u_debug.c
@@ -38,9 +38,9 @@
 #include "util/u_memory.h"
 #include "util/u_string.h"
 #include "util/u_math.h"
-#include "util/u_tile.h"
+//#include "util/u_tile.h"
 #include "util/u_prim.h"
-#include "util/u_surface.h"
+//#include "util/u_surface.h"
 #include 
 
 #include 
@@ -490,315 +490,6 @@ debug_funclog_enter_exit(const char* f, const int line, 
const char* file)
 
 #ifdef DEBUG
 /**
- * Dump an image to .ppm file.
- * \param format  PIPE_FORMAT_x
- * \param cpp  bytes per pixel
- * \param width  width in pixels
- * \param height height in pixels
- * \param stride  row stride in bytes
- */
-void
-debug_dump_image(const char *prefix,
- enum pipe_format format, unsigned cpp,
- unsigned width, unsigned height,
- unsigned stride,
- const void *data)
-{
-   /* write a ppm file */
-   char filename[256];
-   unsigned char *rgb8;
-   FILE *f;
-
-   util_snprintf(filename, sizeof(filename), "%s.ppm", prefix);
-
-   rgb8 = MALLOC(height * width * 3);
-   if (!rgb8) {
-  return;
-   }
-
-   util_format_translate(
- PIPE_FORMAT_R8G8B8_UNORM,
- rgb8, width * 3,
- 0, 0,
- format,
- data, stride,
- 0, 0, width, height);
-
-   /* Must be opened in binary mode or DOS line ending causes data
-* to be read with one byte offset.
-*/
-   f = fopen(filename, "wb");
-   if (f) {
-  fprintf(f, "P6\n");
-  fprintf(f, "# ppm-file created by gallium\n");
-  fprintf(f, "%i %i\n", width, height);
-  fprintf(f, "255\n");
-  fwrite(rgb8, 1, height * width * 3, f);
-  fclose(f);
-   }
-   else {
-  fprintf(stderr, "Can't open %s for writing\n", filename);
-   }
-
-   FREE(rgb8);
-}
-
-
-/* FIXME: dump resources, not surfaces... */
-void
-debug_dump_surface(struct pipe_context *pipe,
-   const char *prefix,
-   struct pipe_surface *surface)
-{
-   struct pipe_resource *texture;
-   struct pipe_transfer *transfer;
-   void *data;
-
-   if (!surface)
-  return;
-
-   /* XXX: this doesn't necessarily work, as the driver may be using
-* temporary storage for the surface which hasn't been propagated
-* back into the texture.  Need to nail down the semantics of views
-* and transfers a bit better before we can say if extra work needs
-* to be done here:
-*/
-   texture = surface->texture;
-
-   data = pipe_transfer_map(pipe, texture, surface->u.tex.level,
-surface->u.tex.first_layer,
-PIPE_TRANSFER_READ,
-0, 0, surface->width, surface->height, &transfer);
-   if (!data)
-  return;
-
-   debug_dump_image(prefix,
-texture->format,
-util_format_get_blocksize(texture->format),
-util_format_get_nblocksx(texture->format, surface->width),
-util_format_get_nblocksy(texture->format, surface->height),
-transfer->stride,
-data);
-
-   pipe->transfer_unmap(pipe, transfer);
-}
-
-
-void
-debug_dump_texture(struct pipe_context *pipe,
-   const char *prefix,
-   struct pipe_resource *texture)
-{
-   struct pipe_surface *surface, surf_tmpl;
-
-   if (!texture)
-  return;
-
-   /* XXX for now, just dump image for layer=0, level=0 */
-   u_surface_default_template(&surf_tmpl, texture);
-   surface = pipe->create_surface(pipe, texture, &surf_tmpl);
-   if (sur

[Mesa-dev] [PATCH] mesa: move GL_ARB_debug_output code into new debug_output.c file

2016-02-05 Thread Brian Paul
The errors.c file had grown quite large so split off this extension
code into its own file.  This involved making a handful of functions
non-static.
---
 src/compiler/glsl/glsl_parser_extras.cpp |1 +
 src/mapi/glapi/gen/gl_genexec.py |1 +
 src/mesa/Makefile.sources|2 +
 src/mesa/main/context.c  |3 +-
 src/mesa/main/debug_output.c | 1301 ++
 src/mesa/main/debug_output.h |  107 +++
 src/mesa/main/enable.c   |1 +
 src/mesa/main/errors.c   | 1286 +
 src/mesa/main/errors.h   |   48 +-
 src/mesa/main/get.c  |1 +
 src/mesa/main/getstring.c|1 +
 src/mesa/state_tracker/st_manager.c  |1 +
 12 files changed, 1435 insertions(+), 1318 deletions(-)
 create mode 100644 src/mesa/main/debug_output.c
 create mode 100644 src/mesa/main/debug_output.h

diff --git a/src/compiler/glsl/glsl_parser_extras.cpp 
b/src/compiler/glsl/glsl_parser_extras.cpp
index b635d99..20ec89d 100644
--- a/src/compiler/glsl/glsl_parser_extras.cpp
+++ b/src/compiler/glsl/glsl_parser_extras.cpp
@@ -27,6 +27,7 @@
 
 #include "main/core.h" /* for struct gl_context */
 #include "main/context.h"
+#include "main/debug_output.h"
 #include "main/shaderobj.h"
 #include "util/u_atomic.h" /* for p_atomic_cmpxchg */
 #include "util/ralloc.h"
diff --git a/src/mapi/glapi/gen/gl_genexec.py b/src/mapi/glapi/gen/gl_genexec.py
index 6c66779..72d7b6f 100644
--- a/src/mapi/glapi/gen/gl_genexec.py
+++ b/src/mapi/glapi/gen/gl_genexec.py
@@ -66,6 +66,7 @@ header = """/**
 #include "main/convolve.h"
 #include "main/copyimage.h"
 #include "main/depth.h"
+#include "main/debug_output.h"
 #include "main/dlist.h"
 #include "main/drawpix.h"
 #include "main/drawtex.h"
diff --git a/src/mesa/Makefile.sources b/src/mesa/Makefile.sources
index ffe560f..35405e7 100644
--- a/src/mesa/Makefile.sources
+++ b/src/mesa/Makefile.sources
@@ -57,6 +57,8 @@ MAIN_FILES = \
main/dd.h \
main/debug.c \
main/debug.h \
+   main/debug_output.c \
+   main/debug_output.h \
main/depth.c \
main/depth.h \
main/dlist.c \
diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c
index 8b415ed..9388a1c 100644
--- a/src/mesa/main/context.c
+++ b/src/mesa/main/context.c
@@ -89,6 +89,7 @@
 #include "context.h"
 #include "cpuinfo.h"
 #include "debug.h"
+#include "debug_output.h"
 #include "depth.h"
 #include "dlist.h"
 #include "eval.h"
@@ -814,8 +815,8 @@ init_attrib_groups(struct gl_context *ctx)
_mesa_init_current( ctx );
_mesa_init_depth( ctx );
_mesa_init_debug( ctx );
+   _mesa_init_debug_output( ctx );
_mesa_init_display_list( ctx );
-   _mesa_init_errors( ctx );
_mesa_init_eval( ctx );
_mesa_init_fbobjects( ctx );
_mesa_init_feedback( ctx );
diff --git a/src/mesa/main/debug_output.c b/src/mesa/main/debug_output.c
new file mode 100644
index 000..10ee675
--- /dev/null
+++ b/src/mesa/main/debug_output.c
@@ -0,0 +1,1301 @@
+/*
+ * Mesa 3-D graphics library
+ *
+ * Copyright (C) 1999-2016  Brian Paul, et al   All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+#include 
+#include 
+#include "context.h"
+#include "debug_output.h"
+#include "dispatch.h"
+#include "enums.h"
+#include "imports.h"
+#include "hash.h"
+#include "mtypes.h"
+#include "version.h"
+#include "util/hash_table.h"
+#include "util/simple_list.h"
+
+
+static mtx_t DynamicIDMutex = _MTX_INITIALIZER_NP;
+static GLuint NextDynamicID = 1;
+
+
+/**
+ * A namespace element.
+ */
+struct gl_debug_element
+{
+   struct simple_node link;
+
+   GLuint ID;
+   /* at which severity levels (mesa_debug_severity) is the message enabled */
+   GLbitfield State;
+};
+
+
+struct gl_debug_namespace
+{
+   struct simple_node Elements;
+   GLbitfield DefaultState;
+};
+
+
+struct gl_de

[Mesa-dev] [PATCH 2/3] gallium/util: put image dumping functions into separate file

2016-02-05 Thread Brian Paul
To try to reduce the clutter in u_debug.[ch]
---
 src/gallium/auxiliary/util/u_debug_image.c | 348 +
 src/gallium/auxiliary/util/u_debug_image.h |  74 ++
 2 files changed, 422 insertions(+)
 create mode 100644 src/gallium/auxiliary/util/u_debug_image.c
 create mode 100644 src/gallium/auxiliary/util/u_debug_image.h

diff --git a/src/gallium/auxiliary/util/u_debug_image.c 
b/src/gallium/auxiliary/util/u_debug_image.c
new file mode 100644
index 000..98d73a6
--- /dev/null
+++ b/src/gallium/auxiliary/util/u_debug_image.c
@@ -0,0 +1,348 @@
+/*
+ * Copyright (c) 2008-2016 VMware, Inc.
+ * All Rights Reserved.
+ *
+ * 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, sub license, 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 NON-INFRINGEMENT.
+ * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+#include "util/u_debug_image.h"
+#include "util/u_format.h"
+#include "util/u_inlines.h"
+#include "util/u_memory.h"
+#include "util/u_string.h"
+#include "util/u_surface.h"
+#include "util/u_tile.h"
+
+#include 
+
+
+#ifdef DEBUG
+
+/**
+ * Dump an image to .ppm file.
+ * \param format  PIPE_FORMAT_x
+ * \param cpp  bytes per pixel
+ * \param width  width in pixels
+ * \param height height in pixels
+ * \param stride  row stride in bytes
+ */
+void
+debug_dump_image(const char *prefix,
+ enum pipe_format format, unsigned cpp,
+ unsigned width, unsigned height,
+ unsigned stride,
+ const void *data)
+{
+   /* write a ppm file */
+   char filename[256];
+   unsigned char *rgb8;
+   FILE *f;
+
+   util_snprintf(filename, sizeof(filename), "%s.ppm", prefix);
+
+   rgb8 = MALLOC(height * width * 3);
+   if (!rgb8) {
+  return;
+   }
+
+   util_format_translate(
+ PIPE_FORMAT_R8G8B8_UNORM,
+ rgb8, width * 3,
+ 0, 0,
+ format,
+ data, stride,
+ 0, 0, width, height);
+
+   /* Must be opened in binary mode or DOS line ending causes data
+* to be read with one byte offset.
+*/
+   f = fopen(filename, "wb");
+   if (f) {
+  fprintf(f, "P6\n");
+  fprintf(f, "# ppm-file created by gallium\n");
+  fprintf(f, "%i %i\n", width, height);
+  fprintf(f, "255\n");
+  fwrite(rgb8, 1, height * width * 3, f);
+  fclose(f);
+   }
+   else {
+  fprintf(stderr, "Can't open %s for writing\n", filename);
+   }
+
+   FREE(rgb8);
+}
+
+
+/* FIXME: dump resources, not surfaces... */
+void
+debug_dump_surface(struct pipe_context *pipe,
+   const char *prefix,
+   struct pipe_surface *surface)
+{
+   struct pipe_resource *texture;
+   struct pipe_transfer *transfer;
+   void *data;
+
+   if (!surface)
+  return;
+
+   /* XXX: this doesn't necessarily work, as the driver may be using
+* temporary storage for the surface which hasn't been propagated
+* back into the texture.  Need to nail down the semantics of views
+* and transfers a bit better before we can say if extra work needs
+* to be done here:
+*/
+   texture = surface->texture;
+
+   data = pipe_transfer_map(pipe, texture, surface->u.tex.level,
+surface->u.tex.first_layer,
+PIPE_TRANSFER_READ,
+0, 0, surface->width, surface->height, &transfer);
+   if (!data)
+  return;
+
+   debug_dump_image(prefix,
+texture->format,
+util_format_get_blocksize(texture->format),
+util_format_get_nblocksx(texture->format, surface->width),
+util_format_get_nblocksy(texture->format, surface->height),
+transfer->stride,
+data);
+
+   pipe->transfer_unmap(pipe, transfer);
+}
+
+
+void
+debug_dump_texture(struct pipe_context *pipe,
+   const char *prefix,
+   struct pipe_resource *texture)
+{
+   struct pipe_surface *surface, surf_tmpl;
+
+   if (!texture)
+  return;
+
+   /* XXX for now, just dump image for

[Mesa-dev] [Bug 94016] make check MesaExtensionsTest.AlphabeticallySorted regression

2016-02-05 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=94016

Bug ID: 94016
   Summary: make check MesaExtensionsTest.AlphabeticallySorted
regression
   Product: Mesa
   Version: git
  Hardware: x86-64 (AMD64)
OS: All
Status: NEW
  Keywords: bisected, regression
  Severity: normal
  Priority: medium
 Component: Mesa core
  Assignee: mesa-dev@lists.freedesktop.org
  Reporter: v...@freedesktop.org
QA Contact: mesa-dev@lists.freedesktop.org
CC: imir...@alum.mit.edu, mar...@gmail.com

mesa: 5b51b2e00013af70072106e9d34905326fc357fc (master 11.2.0-devel)

[--] 1 test from MesaExtensionsTest
[ RUN  ] MesaExtensionsTest.AlphabeticallySorted
mesa_extensions.cpp:49: Failure
Expected: (strcmp(current_str, next_str)) < (0), actual: 7 vs 0
[  FAILED  ] MesaExtensionsTest.AlphabeticallySorted (0 ms)
[--] 1 test from MesaExtensionsTest (0 ms total)


1d79b9958090d5606212a56c2173626519f00ca8 is the first bad commit
commit 1d79b9958090d5606212a56c2173626519f00ca8
Author: Marek Olšák 
Date:   Tue Feb 2 01:22:52 2016 +0100

mesa: implement GL_NVX_gpu_memory_info (v2)

v2: implement eviction queries properly
add gl_memory_info structure

Reviewed-by: Ilia Mirkin 
Reviewed-by: Alex Deucher 

:04 04 a506dae6847240f6f6900651862ec58dbb1d106e
9b679b62127f7ac673698eeb0d96b973621ceb09 Msrc
bisect run success

-- 
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
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH v2 i-g-t] igt/list-workarounds: Extend the script to Mesa

2016-02-05 Thread Dylan Baker
Quoting Damien Lespiau (2016-02-05 15:46:51)
> On Fri, Feb 05, 2016 at 01:55:19PM -0800, Sameer Kibey wrote:
> > Updated the list-workarounds script so that it
> > can parse Mesa directory if provided. Moved the
> > common code to a separate function to allow
> > reuse for both kernel and mesa.
> > 
> > The new command line is:
> > Usage: list-workarounds [options] path-to-kernel
> >-k path-to-kernel -m path-to-mesa
> > 
> > The legacy usage is retained to avoid breaking
> > backwards compatibility. New parameters -k and
> > -m are added for the new behavior.
> > 
> > Either kernel or mesa or both paths can be specified.
> > If path-to-mesa is invalid, error is reported.
> > 
> > Signed-off-by: Sameer Kibey 
> 
> Pushed thanks for the patch.
> 
> -- 
> Damien
> 
> > ---
> >  scripts/list-workarounds | 74 
> > ++--
> >  1 file changed, 53 insertions(+), 21 deletions(-)
> > 
> > diff --git a/scripts/list-workarounds b/scripts/list-workarounds
> > index d11b6a9..8b41ae5 100755
> > --- a/scripts/list-workarounds
> > +++ b/scripts/list-workarounds
> > @@ -18,7 +18,7 @@ def find_nth(haystack, needle, n):
> >   return start
> >  
> >  valid_platforms = ('ctg', 'elk', 'ilk', 'snb', 'ivb', 'vlv', 'hsw', 'bdw',
> > -'chv', 'skl', 'bxt')
> > +'chv', 'skl', 'bxt', 'kbl')
> >  def parse_platforms(line, p):
> >   l =  p.split(',')
> >   for p in l:
> > @@ -65,9 +65,15 @@ def execute(cmd):
> >   return out, err
> >  
> >  def parse_options(args):
> > - usage = "Usage: list-workarounds [options] path-to-kernel"
> > + usage = "Usage: list-workarounds [options] path-to-kernel -k 
> > path-to-kernel -m path-to-mesa"
> >   parser = optparse.OptionParser(usage, version=1.0)
> >  
> > + parser.add_option("-k", "--kernel-path", dest="kernel_path", 
> > default=None,
> > +   help="path to kernel")
> > +
> > + parser.add_option("-m", "--mesa-path", dest="mesa_path", default=None,
> > +   help="path to mesa")
> > +
> >   parser.add_option("-v", "--verbose", action="store_true",
> > dest="verbose", default=False,
> > help="be more verbose")
> > @@ -76,38 +82,64 @@ def parse_options(args):
> > help="List workarounds for the specified platform")
> >  
> >   (options, args) = parser.parse_args()
> > -
> >   return (options, args)
> >  
> > -if __name__ == '__main__':
> > - (options, args) = parse_options(sys.argv[1:])
> > - verbose = options.verbose
> > -
> > - if not len(args):
> > - sys.stderr.write("error: A path to a kernel tree is 
> > required\n")
> > - sys.exit(1)
> > -
> > - kernel_path = args[0]
> > - kconfig = os.path.join(kernel_path, 'Kconfig')
> > - if not os.path.isfile(kconfig):
> > - sys.stderr.write("error: %s does not point to a kernel tree 
> > \n"
> > -  % kernel_path)
> > - sys.exit(1)
> > -
> > - i915_dir = os.path.join('drivers', 'gpu', 'drm', 'i915')
> > +def print_workarounds(project_root, driver_dir, project):
> >   olddir = os.getcwd()
> > - os.chdir(kernel_path)
> > + os.chdir(project_root)
> >   work_arounds, err = execute(['git', 'grep', '-n',
> >'-e', 'W[aA][A-Z0-9][a-zA-Z0-9_]\+',
> > -  i915_dir])
> > +  driver_dir])
> >   os.chdir(olddir)
> >   if err:
> >   print(err)
> >   sys.exit(1)
> >  
> >   parse(work_arounds)
> > + print "\nList of workarounds found in %s:" % project

Hey Damien, the script says it's python 3, and this ^^^ is broken syntax
in python 3 (but not in 2).

> >   for wa in sorted(workarounds.keys()):
> >   if not options.platform:
> >   print("%s: %s" % (wa, ', '.join(workarounds[wa])))
> >   elif options.platform in workarounds[wa]:
> >   print(wa)
> > +
> > +
> > +if __name__ == '__main__':
> > + (options, args) = parse_options(sys.argv)
> > + verbose = options.verbose
> > + kernel_path = None
> > +
> > + if not len(args) and options.kernel_path == None and 
> > options.mesa_path == None:
> > + sys.stderr.write("error: A path to either a kernel tree or 
> > Mesa is required\n")
> > + sys.exit(1)
> > +
> > + if len(args):
> > + kernel_path = args[0]
> > + elif options.kernel_path != None:
> > + kernel_path = options.kernel_path
> > +
> > + if kernel_path != None:
> > + # --- list Kernel workarounds if path is provided ---
> > + kconfig = os.path.join(kernel_path, 'Kconfig')
> > + if not os.path.isfile(kconfig):
> > + sys.stderr.write("error: %s does not point to a 
> > kernel tree \n"
> > + 

Re: [Mesa-dev] [PATCH v2 i-g-t] igt/list-workarounds: Extend the script to Mesa

2016-02-05 Thread Damien Lespiau
On Fri, Feb 05, 2016 at 01:55:19PM -0800, Sameer Kibey wrote:
> Updated the list-workarounds script so that it
> can parse Mesa directory if provided. Moved the
> common code to a separate function to allow
> reuse for both kernel and mesa.
> 
> The new command line is:
> Usage: list-workarounds [options] path-to-kernel
>-k path-to-kernel -m path-to-mesa
> 
> The legacy usage is retained to avoid breaking
> backwards compatibility. New parameters -k and
> -m are added for the new behavior.
> 
> Either kernel or mesa or both paths can be specified.
> If path-to-mesa is invalid, error is reported.
> 
> Signed-off-by: Sameer Kibey 

Pushed thanks for the patch.

-- 
Damien

> ---
>  scripts/list-workarounds | 74 
> ++--
>  1 file changed, 53 insertions(+), 21 deletions(-)
> 
> diff --git a/scripts/list-workarounds b/scripts/list-workarounds
> index d11b6a9..8b41ae5 100755
> --- a/scripts/list-workarounds
> +++ b/scripts/list-workarounds
> @@ -18,7 +18,7 @@ def find_nth(haystack, needle, n):
>   return start
>  
>  valid_platforms = ('ctg', 'elk', 'ilk', 'snb', 'ivb', 'vlv', 'hsw', 'bdw',
> -'chv', 'skl', 'bxt')
> +'chv', 'skl', 'bxt', 'kbl')
>  def parse_platforms(line, p):
>   l =  p.split(',')
>   for p in l:
> @@ -65,9 +65,15 @@ def execute(cmd):
>   return out, err
>  
>  def parse_options(args):
> - usage = "Usage: list-workarounds [options] path-to-kernel"
> + usage = "Usage: list-workarounds [options] path-to-kernel -k 
> path-to-kernel -m path-to-mesa"
>   parser = optparse.OptionParser(usage, version=1.0)
>  
> + parser.add_option("-k", "--kernel-path", dest="kernel_path", 
> default=None,
> +   help="path to kernel")
> +
> + parser.add_option("-m", "--mesa-path", dest="mesa_path", default=None,
> +   help="path to mesa")
> +
>   parser.add_option("-v", "--verbose", action="store_true",
> dest="verbose", default=False,
> help="be more verbose")
> @@ -76,38 +82,64 @@ def parse_options(args):
> help="List workarounds for the specified platform")
>  
>   (options, args) = parser.parse_args()
> -
>   return (options, args)
>  
> -if __name__ == '__main__':
> - (options, args) = parse_options(sys.argv[1:])
> - verbose = options.verbose
> -
> - if not len(args):
> - sys.stderr.write("error: A path to a kernel tree is required\n")
> - sys.exit(1)
> -
> - kernel_path = args[0]
> - kconfig = os.path.join(kernel_path, 'Kconfig')
> - if not os.path.isfile(kconfig):
> - sys.stderr.write("error: %s does not point to a kernel tree \n"
> -  % kernel_path)
> - sys.exit(1)
> -
> - i915_dir = os.path.join('drivers', 'gpu', 'drm', 'i915')
> +def print_workarounds(project_root, driver_dir, project):
>   olddir = os.getcwd()
> - os.chdir(kernel_path)
> + os.chdir(project_root)
>   work_arounds, err = execute(['git', 'grep', '-n',
>'-e', 'W[aA][A-Z0-9][a-zA-Z0-9_]\+',
> -  i915_dir])
> +  driver_dir])
>   os.chdir(olddir)
>   if err:
>   print(err)
>   sys.exit(1)
>  
>   parse(work_arounds)
> + print "\nList of workarounds found in %s:" % project
>   for wa in sorted(workarounds.keys()):
>   if not options.platform:
>   print("%s: %s" % (wa, ', '.join(workarounds[wa])))
>   elif options.platform in workarounds[wa]:
>   print(wa)
> +
> +
> +if __name__ == '__main__':
> + (options, args) = parse_options(sys.argv)
> + verbose = options.verbose
> + kernel_path = None
> +
> + if not len(args) and options.kernel_path == None and options.mesa_path 
> == None:
> + sys.stderr.write("error: A path to either a kernel tree or Mesa 
> is required\n")
> + sys.exit(1)
> +
> + if len(args):
> + kernel_path = args[0]
> + elif options.kernel_path != None:
> + kernel_path = options.kernel_path
> +
> + if kernel_path != None:
> + # --- list Kernel workarounds if path is provided ---
> + kconfig = os.path.join(kernel_path, 'Kconfig')
> + if not os.path.isfile(kconfig):
> + sys.stderr.write("error: %s does not point to a kernel 
> tree \n"
> + % kernel_path)
> + sys.exit(1)
> +
> + i915_dir = os.path.join('drivers', 'gpu', 'drm', 'i915')
> + print_workarounds(kernel_path, i915_dir, "kernel")
> +
> + # --- list mesa workarounds if path is provided ---
> + if options.mesa_path != None:
> + # reset workarounds array
> + workarounds = {}

Re: [Mesa-dev] [PATCH 01/11] mesa: Refactor _mesa_framebuffer_renderbuffer

2016-02-05 Thread Anuj Phogat
On Fri, Feb 5, 2016 at 3:04 PM, Anuj Phogat  wrote:
> On Fri, Feb 5, 2016 at 1:04 PM, Ian Romanick  wrote:
>> From: Ian Romanick 
>>
>> This function previously was only used in fbobject.c and contained a
>> bunch of API validation.  Split the function into
>> framebuffer_renderbuffer that is static and contains the validation, and
>> _mesa_framebuffer_renderbuffer that is suitable for calling from
>> elsewhere in Mesa (e.g., meta).
>>
>> Signed-off-by: Ian Romanick 
>> ---
>>  src/mesa/main/fbobject.c | 42 ++
>>  src/mesa/main/fbobject.h |  3 +--
>>  2 files changed, 27 insertions(+), 18 deletions(-)
>>
>> diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
>> index 2d4acb3..0b0653d 100644
>> --- a/src/mesa/main/fbobject.c
>> +++ b/src/mesa/main/fbobject.c
>> @@ -3413,8 +3413,27 @@ void
>>  _mesa_framebuffer_renderbuffer(struct gl_context *ctx,
>> struct gl_framebuffer *fb,
>> GLenum attachment,
>> -   struct gl_renderbuffer *rb,
>> -   const char *func)
>> +   struct gl_renderbuffer *rb)
>> +{
>> +   assert(!_mesa_is_winsys_fbo(fb));
>> +
>> +   FLUSH_VERTICES(ctx, _NEW_BUFFERS);
>> +
>> +   assert(ctx->Driver.FramebufferRenderbuffer);
>> +   ctx->Driver.FramebufferRenderbuffer(ctx, fb, attachment, rb);
>> +
>> +   /* Some subsequent GL commands may depend on the framebuffer's visual
>> +* after the binding is updated.  Update visual info now.
>> +*/
>> +   _mesa_update_framebuffer_visual(ctx, fb);
>> +}
>> +
>> +static void
>> +framebuffer_renderbuffer(struct gl_context *ctx,
>> + struct gl_framebuffer *fb,
>> + GLenum attachment,
>> + struct gl_renderbuffer *rb,
>> + const char *func)
>>  {
>> struct gl_renderbuffer_attachment *att;
>>
>> @@ -3444,18 +3463,9 @@ _mesa_framebuffer_renderbuffer(struct gl_context *ctx,
>>}
>> }
>>
>> -   FLUSH_VERTICES(ctx, _NEW_BUFFERS);
>> -
>> -   assert(ctx->Driver.FramebufferRenderbuffer);
>> -   ctx->Driver.FramebufferRenderbuffer(ctx, fb, attachment, rb);
>> -
>> -   /* Some subsequent GL commands may depend on the framebuffer's visual
>> -* after the binding is updated.  Update visual info now.
>> -*/
>> -   _mesa_update_framebuffer_visual(ctx, fb);
>> +   _mesa_framebuffer_renderbuffer(ctx, fb, attachment, rb);
>>  }
>>
>> -
>>  void GLAPIENTRY
>>  _mesa_FramebufferRenderbuffer(GLenum target, GLenum attachment,
>>GLenum renderbuffertarget,
>> @@ -3491,8 +3501,8 @@ _mesa_FramebufferRenderbuffer(GLenum target, GLenum 
>> attachment,
>>rb = NULL;
>> }
>>
>> -   _mesa_framebuffer_renderbuffer(ctx, fb, attachment, rb,
>> -  "glFramebufferRenderbuffer");
>> +   framebuffer_renderbuffer(ctx, fb, attachment, rb,
>> +"glFramebufferRenderbuffer");
>>  }
>>
>>
>> @@ -3528,8 +3538,8 @@ _mesa_NamedFramebufferRenderbuffer(GLuint framebuffer, 
>> GLenum attachment,
>>rb = NULL;
>> }
>>
>> -   _mesa_framebuffer_renderbuffer(ctx, fb, attachment, rb,
>> -  "glNamedFramebufferRenderbuffer");
>> +   framebuffer_renderbuffer(ctx, fb, attachment, rb,
>> +"glNamedFramebufferRenderbuffer");
>>  }
>>
>>
>> diff --git a/src/mesa/main/fbobject.h b/src/mesa/main/fbobject.h
>> index 8dad0ff..458e440 100644
>> --- a/src/mesa/main/fbobject.h
>> +++ b/src/mesa/main/fbobject.h
>> @@ -91,8 +91,7 @@ extern void
>>  _mesa_framebuffer_renderbuffer(struct gl_context *ctx,
>> struct gl_framebuffer *fb,
>> GLenum attachment,
>> -   struct gl_renderbuffer *rb,
>> -   const char *func);
>> +   struct gl_renderbuffer *rb);
>>
>>  extern void
>>  _mesa_validate_framebuffer(struct gl_context *ctx, struct gl_framebuffer 
>> *fb);
>> --
>> 2.5.0
>>
>> ___
>> mesa-dev mailing list
>> mesa-dev@lists.freedesktop.org
>> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
> Patches 1-5 are:
> Reviewed-by: Anuj Phogat 
>
> I'll continue reviewing rest of the series.
and 6-11 are:
Reviewed-by: Anuj Phogat 
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 1/4] st/mesa: handle indirect samplers in arrays/structs properly (v3)

2016-02-05 Thread Timothy Arceri
On Fri, 2016-02-05 at 13:40 +1000, Dave Airlie wrote:
> From: Dave Airlie 
> 
> The state tracker never handled this properly, and it finally
> annoyed me for the second time so I decided to fix it properly.
> 
> This is inspired by the NIR sampler lowering code and I only realised
> NIR seems to do its deref ordering different to GLSL at the last
> minute, once I got that things got much easier.
> 
> it fixes a bunch of tests in
> tests/spec/arb_gpu_shader5/execution/sampler_array_indexing/
> 
> v2: fix AoA tests when forced on.
> I was right I didn't need all that code, fixing the AoA code
> meant cleaning up a chunk of code I didn't like in the array
> handling.
> 
> v3: start generalising the code a bit more for atomics.
> 
> Signed-off-by: Dave Airlie 
> ---
>  src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 145
> +
>  1 file changed, 127 insertions(+), 18 deletions(-)
> 
> diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
> b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
> index b8182de..c36edc9 100644
> --- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
> +++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
> @@ -40,7 +40,6 @@
>  #include "main/uniforms.h"
>  #include "main/shaderapi.h"
>  #include "program/prog_instruction.h"
> -#include "program/sampler.h"
>  
>  #include "pipe/p_context.h"
>  #include "pipe/p_screen.h"
> @@ -257,6 +256,7 @@ public:
> GLboolean cond_update;
> bool saturate;
> st_src_reg sampler; /**< sampler register */
> +   int sampler_base;
> int sampler_array_size; /**< 1-based size of sampler array, 1 if
> not array */
> int tex_target; /**< One of TEXTURE_*_INDEX */
> glsl_base_type tex_type;
> @@ -502,6 +502,18 @@ public:
>  
> void emit_arl(ir_instruction *ir, st_dst_reg dst, st_src_reg
> src0);
>  
> +   void get_deref_offsets(ir_dereference *ir,
> +  unsigned *array_size,
> +  unsigned *base,
> +  unsigned *index,
> +  st_src_reg *reladdr);
> +  void calc_deref_offsets(ir_dereference *head,
> +  ir_dereference *tail,
> +  unsigned *array_elements,
> +  unsigned *index,
> +  st_src_reg *indirect,
> +  unsigned *location);
> +
> bool try_emit_mad(ir_expression *ir,
>    int mul_operand);
> bool try_emit_mad_for_and_not(ir_expression *ir,
> @@ -3436,18 +3448,118 @@ glsl_to_tgsi_visitor::visit(ir_call *ir)
> this->result = entry->return_reg;
>  }
>  
> +static unsigned
> +glsl_get_length(const struct glsl_type *type)
> +{
> +   return type->is_matrix() ? type->matrix_columns : type->length;
> +}

This isn't needed the type should always be an array unless something
has gone horribly wrong. Nir uses this because it needs a wrapper for
cpp. I don't think the matrix stuff was even there when I added nir
support originally.

> +
> +void
> +glsl_to_tgsi_visitor::calc_deref_offsets(ir_dereference *head,
> + ir_dereference *tail,
> + unsigned *array_elements,
> + unsigned *index,
> + st_src_reg *indirect,
> + unsigned *location)
> +{
> +   switch (tail->ir_type) {
> +   case ir_type_dereference_record: {
> +  ir_dereference_record *deref_record = tail-
> >as_dereference_record();
> +  const glsl_type *struct_type = deref_record->record->type;
> +  int tmp = 0;
> +  unsigned i;
> +
> +  calc_deref_offsets(head, deref_record->record-
> >as_dereference(), array_elements, index, indirect, location);
> +
> +  for (i = 0; i < struct_type->length; i++) {
> + if (strcmp(struct_type->fields.structure[i].name,
> deref_record->field) == 0)
> +break;
> +  }

Rather than doing this you can used do:

i = deref_record->record->type->field_index(deref_record->field);

> +  if (i < struct_type->length)
> + tmp = struct_type->record_location_offset(i);
> +
> +  *location += tmp;

As pointed out on irc location needs to be initialised to the base
struct location currently this is always starting at 0. Solution
further down.

> +  break;
> +   }
> +
> +   case ir_type_dereference_array: {
> +  ir_dereference_array *deref_arr = tail-
> >as_dereference_array();
> +  ir_constant *array_index = deref_arr->array_index-
> >constant_expression_value();
> +
> +  if (deref_arr->array->ir_type == ir_type_dereference_variable
> && head == tail) {
> + ir_dereference_variable *deref_var = deref_arr->array-
> >as_dereference_variable();
> + *location += deref_var->var->data.location;
> +  }
> +
> +  if (!array_index) {
> + st_src_reg temp_reg;
> + st_dst_reg temp_dst;
> +
> + temp_reg = get_temp(glsl_type::ui

Re: [Mesa-dev] [PATCH 0/7] Fixes for SW:KotOR (v2)

2016-02-05 Thread Matt Turner
Thanks a ton for contributing this. This is really cool.

I've replied to a couple of patches with a lot of style comments.
These issues appear in a lot of places I didn't point out (it was
getting a bit repetitive). A summary is

 - Use spaces around operators
 - Use BSD-style function declarations, with qualifiers and return
type on their own line
 - Align line-wrapped arguments and parameters with the open paranthesis
 - Use braces in nested if-statements
 - Don't indent case/default labels past switch()
 - Don't add code that is commented out
 - Use spaces, not tabs

Thanks. I look forward to porting this to NIR and adding i965 support
at some point. :)
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 2/7] st/mesa: implement GL_ATI_fragment_shader

2016-02-05 Thread Matt Turner
On Fri, Feb 5, 2016 at 1:11 PM, Miklós Máté  wrote:
> v2: fix arithmetic for special opcodes
>  (based on comments from Marek and Ilia),
>  fix fog state, cleanup
> ---
>  src/mesa/Makefile.sources |   1 +
>  src/mesa/program/program.h|   2 +
>  src/mesa/state_tracker/st_atifs_to_tgsi.c | 734 
> ++
>  src/mesa/state_tracker/st_atifs_to_tgsi.h |  65 +++
>  src/mesa/state_tracker/st_atom_constbuf.c |  14 +
>  src/mesa/state_tracker/st_atom_shader.c   |   5 +-
>  src/mesa/state_tracker/st_cb_drawpixels.c |   1 +
>  src/mesa/state_tracker/st_cb_program.c|  36 +-
>  src/mesa/state_tracker/st_program.c   |  30 +-
>  src/mesa/state_tracker/st_program.h   |   4 +
>  10 files changed, 889 insertions(+), 3 deletions(-)
>  create mode 100644 src/mesa/state_tracker/st_atifs_to_tgsi.c
>  create mode 100644 src/mesa/state_tracker/st_atifs_to_tgsi.h
>
> diff --git a/src/mesa/Makefile.sources b/src/mesa/Makefile.sources
> index ffe560f..23fe42a 100644
> --- a/src/mesa/Makefile.sources
> +++ b/src/mesa/Makefile.sources
> @@ -393,6 +393,7 @@ VBO_FILES = \
> vbo/vbo_split_inplace.c
>
>  STATETRACKER_FILES = \
> +   state_tracker/st_atifs_to_tgsi.c \
> state_tracker/st_atom_array.c \
> state_tracker/st_atom_atomicbuf.c \
> state_tracker/st_atom_blend.c \
> diff --git a/src/mesa/program/program.h b/src/mesa/program/program.h
> index 24e0597..09e6928 100644
> --- a/src/mesa/program/program.h
> +++ b/src/mesa/program/program.h
> @@ -172,6 +172,8 @@ _mesa_program_enum_to_shader_stage(GLenum v)
>return MESA_SHADER_VERTEX;
> case GL_FRAGMENT_PROGRAM_ARB:
>return MESA_SHADER_FRAGMENT;
> +   case GL_FRAGMENT_SHADER_ATI:
> +  return MESA_SHADER_FRAGMENT;
> case GL_GEOMETRY_PROGRAM_NV:
>return MESA_SHADER_GEOMETRY;
> case GL_TESS_CONTROL_PROGRAM_NV:
> diff --git a/src/mesa/state_tracker/st_atifs_to_tgsi.c 
> b/src/mesa/state_tracker/st_atifs_to_tgsi.c
> new file mode 100644
> index 000..fe303f6
> --- /dev/null
> +++ b/src/mesa/state_tracker/st_atifs_to_tgsi.c
> @@ -0,0 +1,734 @@
> +/*
> + * Copyright (C) 2016 Miklós Máté
> + *
> + * Permission is hereby granted, free of charge, to any person obtaining a
> + * copy of this software and associated documentation files (the "Software"),
> + * to deal in the Software without restriction, including without limitation
> + * the rights to use, copy, modify, merge, publish, distribute, sublicense,
> + * and/or sell copies of the Software, and to permit persons to whom the
> + * Software is furnished to do so, subject to the following conditions:
> + *
> + * The above copyright notice and this permission notice shall be included in
> + * all copies or substantial portions of the Software.
> + *
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
> + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
> + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
> + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
> + * OTHER DEALINGS IN THE SOFTWARE.
> + */
> +
> +#include "main/mtypes.h"
> +#include "main/atifragshader.h"
> +#include "main/texobj.h"
> +#include "main/errors.h"
> +#include "program/prog_parameter.h"
> +
> +#include "tgsi/tgsi_transform.h"
> +#include "tgsi/tgsi_ureg.h"
> +#include "util/u_math.h"
> +#include "util/u_memory.h"
> +
> +#include "st_program.h"
> +#include "st_atifs_to_tgsi.h"
> +
> +/**
> + * Intermediate state used during shader translation.
> + */
> +struct st_translate {
> +   struct ureg_program *ureg;
> +   struct gl_context *ctx;
> +   struct ati_fragment_shader *atifs;
> +
> +   struct ureg_dst temps[MAX_PROGRAM_TEMPS];
> +   struct ureg_src *constants;
> +   struct ureg_dst outputs[PIPE_MAX_SHADER_OUTPUTS];
> +   struct ureg_src inputs[PIPE_MAX_SHADER_INPUTS];
> +   struct ureg_src samplers[PIPE_MAX_SAMPLERS];
> +
> +   const GLuint *inputMapping;
> +   const GLuint *outputMapping;
> +
> +   unsigned current_pass;
> +
> +   bool regs_written[MAX_NUM_PASSES_ATI][MAX_NUM_FRAGMENT_REGISTERS_ATI];
> +
> +   boolean error;
> +};
> +
> +struct instruction_desc {
> +   unsigned TGSI_opcode;
> +   const char *name;
> +   unsigned char arg_count;
> +   unsigned char special; /* no 1:1 corresponding TGSI instruction */
> +};
> +
> +static struct instruction_desc inst_desc[] = {

const

> +   {TGSI_OPCODE_MOV, "MOV", 1, 0},
> +   {TGSI_OPCODE_NOP, "UND", 0, 0}, /* unused */
> +   {TGSI_OPCODE_ADD, "ADD", 2, 0},
> +   {TGSI_OPCODE_MUL, "MUL", 2, 0},
> +   {TGSI_OPCODE_SUB, "SUB", 2, 0},
> +   {TGSI_OPCODE_DP3, "DOT3", 2, 0},
> +   {TGSI_OPCODE_DP4, "DOT4", 2, 0},
> +   {TGSI_OPCODE_MAD, "MAD", 3, 0},
> +   {TGSI_OPCODE_LRP, "LERP", 3, 0},
> +   {TGSI_OPCODE_NOP, "CND", 3, 1},
> +   

Re: [Mesa-dev] [PATCH 01/11] mesa: Refactor _mesa_framebuffer_renderbuffer

2016-02-05 Thread Anuj Phogat
On Fri, Feb 5, 2016 at 1:04 PM, Ian Romanick  wrote:
> From: Ian Romanick 
>
> This function previously was only used in fbobject.c and contained a
> bunch of API validation.  Split the function into
> framebuffer_renderbuffer that is static and contains the validation, and
> _mesa_framebuffer_renderbuffer that is suitable for calling from
> elsewhere in Mesa (e.g., meta).
>
> Signed-off-by: Ian Romanick 
> ---
>  src/mesa/main/fbobject.c | 42 ++
>  src/mesa/main/fbobject.h |  3 +--
>  2 files changed, 27 insertions(+), 18 deletions(-)
>
> diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
> index 2d4acb3..0b0653d 100644
> --- a/src/mesa/main/fbobject.c
> +++ b/src/mesa/main/fbobject.c
> @@ -3413,8 +3413,27 @@ void
>  _mesa_framebuffer_renderbuffer(struct gl_context *ctx,
> struct gl_framebuffer *fb,
> GLenum attachment,
> -   struct gl_renderbuffer *rb,
> -   const char *func)
> +   struct gl_renderbuffer *rb)
> +{
> +   assert(!_mesa_is_winsys_fbo(fb));
> +
> +   FLUSH_VERTICES(ctx, _NEW_BUFFERS);
> +
> +   assert(ctx->Driver.FramebufferRenderbuffer);
> +   ctx->Driver.FramebufferRenderbuffer(ctx, fb, attachment, rb);
> +
> +   /* Some subsequent GL commands may depend on the framebuffer's visual
> +* after the binding is updated.  Update visual info now.
> +*/
> +   _mesa_update_framebuffer_visual(ctx, fb);
> +}
> +
> +static void
> +framebuffer_renderbuffer(struct gl_context *ctx,
> + struct gl_framebuffer *fb,
> + GLenum attachment,
> + struct gl_renderbuffer *rb,
> + const char *func)
>  {
> struct gl_renderbuffer_attachment *att;
>
> @@ -3444,18 +3463,9 @@ _mesa_framebuffer_renderbuffer(struct gl_context *ctx,
>}
> }
>
> -   FLUSH_VERTICES(ctx, _NEW_BUFFERS);
> -
> -   assert(ctx->Driver.FramebufferRenderbuffer);
> -   ctx->Driver.FramebufferRenderbuffer(ctx, fb, attachment, rb);
> -
> -   /* Some subsequent GL commands may depend on the framebuffer's visual
> -* after the binding is updated.  Update visual info now.
> -*/
> -   _mesa_update_framebuffer_visual(ctx, fb);
> +   _mesa_framebuffer_renderbuffer(ctx, fb, attachment, rb);
>  }
>
> -
>  void GLAPIENTRY
>  _mesa_FramebufferRenderbuffer(GLenum target, GLenum attachment,
>GLenum renderbuffertarget,
> @@ -3491,8 +3501,8 @@ _mesa_FramebufferRenderbuffer(GLenum target, GLenum 
> attachment,
>rb = NULL;
> }
>
> -   _mesa_framebuffer_renderbuffer(ctx, fb, attachment, rb,
> -  "glFramebufferRenderbuffer");
> +   framebuffer_renderbuffer(ctx, fb, attachment, rb,
> +"glFramebufferRenderbuffer");
>  }
>
>
> @@ -3528,8 +3538,8 @@ _mesa_NamedFramebufferRenderbuffer(GLuint framebuffer, 
> GLenum attachment,
>rb = NULL;
> }
>
> -   _mesa_framebuffer_renderbuffer(ctx, fb, attachment, rb,
> -  "glNamedFramebufferRenderbuffer");
> +   framebuffer_renderbuffer(ctx, fb, attachment, rb,
> +"glNamedFramebufferRenderbuffer");
>  }
>
>
> diff --git a/src/mesa/main/fbobject.h b/src/mesa/main/fbobject.h
> index 8dad0ff..458e440 100644
> --- a/src/mesa/main/fbobject.h
> +++ b/src/mesa/main/fbobject.h
> @@ -91,8 +91,7 @@ extern void
>  _mesa_framebuffer_renderbuffer(struct gl_context *ctx,
> struct gl_framebuffer *fb,
> GLenum attachment,
> -   struct gl_renderbuffer *rb,
> -   const char *func);
> +   struct gl_renderbuffer *rb);
>
>  extern void
>  _mesa_validate_framebuffer(struct gl_context *ctx, struct gl_framebuffer 
> *fb);
> --
> 2.5.0
>
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev

Patches 1-5 are:
Reviewed-by: Anuj Phogat 

I'll continue reviewing rest of the series.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 1/1] r600, compute: Do not overwrite pipe_resource.screen

2016-02-05 Thread Jan Vesely
found by inspection.

Signed-off-by: Jan Vesely 
---
 src/gallium/drivers/r600/evergreen_compute.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/gallium/drivers/r600/evergreen_compute.c 
b/src/gallium/drivers/r600/evergreen_compute.c
index bc27333..3b4f139 100644
--- a/src/gallium/drivers/r600/evergreen_compute.c
+++ b/src/gallium/drivers/r600/evergreen_compute.c
@@ -967,8 +967,8 @@ struct pipe_resource *r600_compute_global_buffer_create(
templ->array_size);
 
result->base.b.vtbl = &r600_global_buffer_vtbl;
-   result->base.b.b.screen = screen;
result->base.b.b = *templ;
+   result->base.b.b.screen = screen;
pipe_reference_init(&result->base.b.b.reference, 1);
 
size_in_dw = (templ->width0+3) / 4;
-- 
2.5.0

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


[Mesa-dev] [PATCH] radeonsi: don't emit unnecessary NULL exports for unbound targets (v2)

2016-02-05 Thread Marek Olšák
From: Marek Olšák 

v2: remove semantic index == 0 checks
add the else statement to remove shadowing of args
---
 src/gallium/drivers/radeonsi/si_shader.c | 88 ++--
 1 file changed, 62 insertions(+), 26 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_shader.c 
b/src/gallium/drivers/radeonsi/si_shader.c
index bd45d4a..63a2908 100644
--- a/src/gallium/drivers/radeonsi/si_shader.c
+++ b/src/gallium/drivers/radeonsi/si_shader.c
@@ -2274,7 +2274,6 @@ static void si_export_mrt_color(struct 
lp_build_tgsi_context *bld_base,
 {
struct si_shader_context *si_shader_ctx = si_shader_context(bld_base);
struct lp_build_context *base = &bld_base->base;
-   LLVMValueRef args[9];
int i;
 
/* Clamp color */
@@ -2296,27 +2295,46 @@ static void si_export_mrt_color(struct 
lp_build_tgsi_context *bld_base,
color[3] = si_scale_alpha_by_sample_mask(bld_base, color[3]);
 
/* If last_cbuf > 0, FS_COLOR0_WRITES_ALL_CBUFS is true. */
-   if (index == 0 &&
-   si_shader_ctx->shader->key.ps.last_cbuf > 0) {
-   for (int c = 1; c <= si_shader_ctx->shader->key.ps.last_cbuf; 
c++) {
+   if (si_shader_ctx->shader->key.ps.last_cbuf > 0) {
+   LLVMValueRef args[8][9];
+   int c, last = -1;
+
+   /* Get the export arguments, also find out what the last one 
is. */
+   for (c = 0; c <= si_shader_ctx->shader->key.ps.last_cbuf; c++) {
si_llvm_init_export_args(bld_base, color,
-V_008DFC_SQ_EXP_MRT + c, args);
+V_008DFC_SQ_EXP_MRT + c, 
args[c]);
+   if (args[c][0] != bld_base->uint_bld.zero)
+   last = c;
+   }
+
+   /* Emit all exports. */
+   for (c = 0; c <= si_shader_ctx->shader->key.ps.last_cbuf; c++) {
+   if (is_last && last == c) {
+   args[c][1] = bld_base->uint_bld.one; /* whether 
the EXEC mask is valid */
+   args[c][2] = bld_base->uint_bld.one; /* DONE 
bit */
+   } else if (args[c][0] == bld_base->uint_bld.zero)
+   continue; /* unnecessary NULL export */
+
lp_build_intrinsic(base->gallivm->builder, 
"llvm.SI.export",
   
LLVMVoidTypeInContext(base->gallivm->context),
-  args, 9, 0);
+  args[c], 9, 0);
}
+   } else {
+   LLVMValueRef args[9];
+
+   /* Export */
+   si_llvm_init_export_args(bld_base, color, V_008DFC_SQ_EXP_MRT + 
index,
+args);
+   if (is_last) {
+   args[1] = bld_base->uint_bld.one; /* whether the EXEC 
mask is valid */
+   args[2] = bld_base->uint_bld.one; /* DONE bit */
+   } else if (args[0] == bld_base->uint_bld.zero)
+   return; /* unnecessary NULL export */
+
+   lp_build_intrinsic(base->gallivm->builder, "llvm.SI.export",
+  
LLVMVoidTypeInContext(base->gallivm->context),
+  args, 9, 0);
}
-
-   /* Export */
-   si_llvm_init_export_args(bld_base, color, V_008DFC_SQ_EXP_MRT + index,
-args);
-   if (is_last) {
-   args[1] = bld_base->uint_bld.one; /* whether the EXEC mask is 
valid */
-   args[2] = bld_base->uint_bld.one; /* DONE bit */
-   }
-   lp_build_intrinsic(base->gallivm->builder, "llvm.SI.export",
-  LLVMVoidTypeInContext(base->gallivm->context),
-  args, 9, 0);
 }
 
 static void si_export_null(struct lp_build_tgsi_context *bld_base)
@@ -2351,19 +2369,37 @@ static void si_llvm_emit_fs_epilogue(struct 
lp_build_tgsi_context * bld_base)
int last_color_export = -1;
int i;
 
-   /* If there are no outputs, add a dummy export. */
-   if (!info->num_outputs) {
-   si_export_null(bld_base);
-   return;
-   }
-
/* Determine the last export. If MRTZ is present, it's always last.
 * Otherwise, find the last color export.
 */
-   if (!info->writes_z && !info->writes_stencil && 
!info->writes_samplemask)
-   for (i = 0; i < info->num_outputs; i++)
-   if (info->output_semantic_name[i] == 
TGSI_SEMANTIC_COLOR)
+   if (!info->writes_z && !info->writes_stencil && 
!info->writes_samplemask) {
+   unsigned spi_format = shader->key.ps.spi_shader_col_format;
+
+   for (i = 0; i < info->num_outputs; i++) {
+   unsigned index = info->output_semant

Re: [Mesa-dev] [PATCH 1/7] mesa: optionally associate a gl_program to ati_fragment_shader

2016-02-05 Thread Matt Turner
On Fri, Feb 5, 2016 at 1:11 PM, Miklós Máté  wrote:
> the state tracker will use it
> ---
>  src/mesa/drivers/common/driverfuncs.c |  3 +++
>  src/mesa/main/atifragshader.c | 13 -
>  src/mesa/main/dd.h|  7 ++-
>  src/mesa/main/mtypes.h|  1 +
>  src/mesa/main/state.c | 14 +-
>  5 files changed, 35 insertions(+), 3 deletions(-)
>
> diff --git a/src/mesa/drivers/common/driverfuncs.c 
> b/src/mesa/drivers/common/driverfuncs.c
> index 752aaf6..65a0cf8 100644
> --- a/src/mesa/drivers/common/driverfuncs.c
> +++ b/src/mesa/drivers/common/driverfuncs.c
> @@ -117,6 +117,9 @@ _mesa_init_driver_functions(struct dd_function_table 
> *driver)
> driver->NewProgram = _mesa_new_program;
> driver->DeleteProgram = _mesa_delete_program;
>
> +   /* ATI_fragment_shader */
> +   driver->NewATIfs = NULL;
> +
> /* simple state commands */
> driver->AlphaFunc = NULL;
> driver->BlendColor = NULL;
> diff --git a/src/mesa/main/atifragshader.c b/src/mesa/main/atifragshader.c
> index 8fcbff6..9308ea7 100644
> --- a/src/mesa/main/atifragshader.c
> +++ b/src/mesa/main/atifragshader.c
> @@ -30,6 +30,7 @@
>  #include "main/mtypes.h"
>  #include "main/dispatch.h"
>  #include "main/atifragshader.h"
> +#include "program/program.h"
>
>  #define MESA_DEBUG_ATI_FS 0
>
> @@ -63,6 +64,7 @@ _mesa_delete_ati_fragment_shader(struct gl_context *ctx, 
> struct ati_fragment_sha
>free(s->Instructions[i]);
>free(s->SetupInst[i]);
> }
> +   _mesa_reference_program(ctx, &s->Program, NULL);
> free(s);
>  }
>
> @@ -321,6 +323,8 @@ _mesa_BeginFragmentShaderATI(void)
>   free(ctx->ATIFragmentShader.Current->SetupInst[i]);
> }
>
> +   _mesa_reference_program(ctx, &ctx->ATIFragmentShader.Current->Program, 
> NULL);
> +
> /* malloc the instructions here - not sure if the best place but its
>a start */
> for (i = 0; i < MAX_NUM_PASSES_ATI; i++) {
> @@ -405,7 +409,14 @@ _mesa_EndFragmentShaderATI(void)
> }
>  #endif
>
> -   if (!ctx->Driver.ProgramStringNotify(ctx, GL_FRAGMENT_SHADER_ATI, NULL)) {
> +   if (ctx->Driver.NewATIfs) {
> +  struct gl_program *prog = ctx->Driver.NewATIfs(ctx,
> +ctx->ATIFragmentShader.Current);

Line-wrapped arguments (and parameters in function declarations)
should be aligned with the ( on the next line. See elsewhere for
examples. This same problem appears throughout this series.

> +  _mesa_reference_program(ctx, &ctx->ATIFragmentShader.Current->Program, 
> prog);
> +   }
> +
> +   if (!ctx->Driver.ProgramStringNotify(ctx, GL_FRAGMENT_SHADER_ATI,
> +curProg->Program)) {
>ctx->ATIFragmentShader.Current->isValid = GL_FALSE;
>/* XXX is this the right error? */
>_mesa_error(ctx, GL_INVALID_OPERATION,
> diff --git a/src/mesa/main/dd.h b/src/mesa/main/dd.h
> index 19ef304..0bdef9c 100644
> --- a/src/mesa/main/dd.h
> +++ b/src/mesa/main/dd.h
> @@ -464,7 +464,12 @@ struct dd_function_table {
> struct gl_program * (*NewProgram)(struct gl_context *ctx, GLenum target,
>   GLuint id);
> /** Delete a program */
> -   void (*DeleteProgram)(struct gl_context *ctx, struct gl_program *prog);
> +   void (*DeleteProgram)(struct gl_context *ctx, struct gl_program *prog);
> +   /**
> +* Allocate a program to associate with the new ATI fragment shader 
> (optional)
> +*/
> +   struct gl_program * (*NewATIfs)(struct gl_context *ctx,
> + struct ati_fragment_shader *curProg);
> /**
>  * Notify driver that a program string (and GPU code) has been specified
>  * or modified.  Return GL_TRUE or GL_FALSE to indicate if the program is
> diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
> index e987177..4d29d6a 100644
> --- a/src/mesa/main/mtypes.h
> +++ b/src/mesa/main/mtypes.h
> @@ -2189,6 +2189,7 @@ struct ati_fragment_shader
> GLboolean interpinp1;
> GLboolean isValid;
> GLuint swizzlerq;
> +   struct gl_program *Program;
>  };
>
>  /**
> diff --git a/src/mesa/main/state.c b/src/mesa/main/state.c
> index 57f1341..bc48d5a 100644
> --- a/src/mesa/main/state.c
> +++ b/src/mesa/main/state.c
> @@ -124,7 +124,8 @@ update_program(struct gl_context *ctx)
>  * follows:
>  *   1. OpenGL 2.0/ARB vertex/fragment shaders
>  *   2. ARB/NV vertex/fragment programs
> -*   3. Programs derived from fixed-function state.
> +*   3. ATI fragment shader
> +*   4. Programs derived from fixed-function state.
>  *
>  * Note: it's possible for a vertex shader to get used with a fragment
>  * program (and vice versa) here, but in practice that shouldn't ever
> @@ -152,6 +153,17 @@ update_program(struct gl_context *ctx)
>_mesa_reference_fragprog(ctx, &ctx->FragmentProgram._TexEnvProgram,
>NULL);
> }
> +   else if (ctx->ATIFragmentShader._Enabled
> +&& ctx->ATIFragmentShader.Current->Program)

Re: [Mesa-dev] [PATCH] meta: Fix the pbo usage in meta for GLES{1, 2} contexts

2016-02-05 Thread Anuj Phogat
On Fri, Feb 5, 2016 at 11:30 AM, Ian Romanick  wrote:
>
> On 12/24/2015 01:04 PM, Anuj Phogat wrote:
> > OpenGL ES 1.0 doesn't support using GL_STREAM_DRAW and both
> > ES 1.0 and 2.0 don't support GL_STREAM_READ in glBufferData().
> > So, handle it correctly by calling the _mesa_meta_begin()
> > before create_texture_for_pbo().
> >
> > Cc: "11.1" 
> > Signed-off-by: Anuj Phogat 
> > ---
> >  src/mesa/drivers/common/meta_tex_subimage.c | 27 
> > ---
> >  1 file changed, 16 insertions(+), 11 deletions(-)
> >
> > diff --git a/src/mesa/drivers/common/meta_tex_subimage.c 
> > b/src/mesa/drivers/common/meta_tex_subimage.c
> > index 4adaad7..8ef306e 100644
> > --- a/src/mesa/drivers/common/meta_tex_subimage.c
> > +++ b/src/mesa/drivers/common/meta_tex_subimage.c
> > @@ -211,19 +211,21 @@ _mesa_meta_pbo_TexSubImage(struct gl_context *ctx, 
> > GLuint dims,
> >  */
> > image_height = packing->ImageHeight == 0 ? height : 
> > packing->ImageHeight;
> >
> > +   if (allocate_storage)
> > +  ctx->Driver.AllocTextureImageBuffer(ctx, tex_image);
> > +
> > +   _mesa_meta_begin(ctx, ~(MESA_META_PIXEL_TRANSFER |
> > +   MESA_META_PIXEL_STORE));
> > +
>
> Moving the call to _mesa_meta_begin makes sense from the commit message.
>  It's not obvious to me why the call to AllocTextureImageBuffer was also
> moved.
>
I wasn't sure if the state changes in  _mesa_meta_begin() will affect the
AllocTextureImageBuffer(), so I chose to keep the sequence of calls same.
I'll drop the changes for AllocTextureImageBuffer() because 'allocate_storage'
passed to this function is anyways always false. I'll send out a separate patch
to remove this parameter.

> Also... is there a test case that hits this?  I think some of the
> patches in my meta-cannot-use-Gen series might also fix this.
>
One of the piglit test hit this on my 'tile_resource_mode' branch. I had changes
which forced the driver to always use meta pbo path and create a temporary
pbo to read from / write to textures using meta path. Currently, we create a
temporary pbo in meta only when 'tex_busy' is true.

> > pbo_tex_image = create_texture_for_pbo(ctx, create_pbo,
> >GL_PIXEL_UNPACK_BUFFER,
> >dims, width, height, depth,
> >format, type, pixels, packing,
> >&pbo, &pbo_tex);
> > -   if (!pbo_tex_image)
> > +   if (!pbo_tex_image) {
> > +  _mesa_meta_end(ctx);
> >return false;
> > -
> > -   if (allocate_storage)
> > -  ctx->Driver.AllocTextureImageBuffer(ctx, tex_image);
> > -
> > -   _mesa_meta_begin(ctx, ~(MESA_META_PIXEL_TRANSFER |
> > -   MESA_META_PIXEL_STORE));
> > +   }
> >
> > _mesa_GenFramebuffers(2, fbos);
> > _mesa_BindFramebuffer(GL_READ_FRAMEBUFFER, fbos[0]);
> > @@ -346,15 +348,18 @@ _mesa_meta_pbo_GetTexSubImage(struct gl_context *ctx, 
> > GLuint dims,
> >  */
> > image_height = packing->ImageHeight == 0 ? height : 
> > packing->ImageHeight;
> >
> > +   _mesa_meta_begin(ctx, ~(MESA_META_PIXEL_TRANSFER |
> > +   MESA_META_PIXEL_STORE));
> > +
> > pbo_tex_image = create_texture_for_pbo(ctx, false, GL_PIXEL_PACK_BUFFER,
> >dims, width, height, depth,
> >format, type, pixels, packing,
> >&pbo, &pbo_tex);
> > -   if (!pbo_tex_image)
> > -  return false;
> >
> > -   _mesa_meta_begin(ctx, ~(MESA_META_PIXEL_TRANSFER |
> > -   MESA_META_PIXEL_STORE));
> > +   if (!pbo_tex_image) {
> > +  _mesa_meta_end(ctx);
> > +  return false;
> > +   }
> >
> > /* GL_CLAMP_FRAGMENT_COLOR doesn't affect ReadPixels and GettexImage */
> > if (ctx->Extensions.ARB_color_buffer_float)
> >
>
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH v2] workarounds: Update workaround names and platforms

2016-02-05 Thread Sameer Kibey
Update the format in which workarounds are documented
in the source code. This allows mesa to be parsed
by the list-workarounds utility in intel-gpu-tools.

Signed-off-by: Sameer Kibey 
---
changed byt to vlv for consistency.
 src/mesa/drivers/dri/i965/brw_binding_tables.c | 2 +-
 src/mesa/drivers/dri/i965/brw_blorp.cpp| 2 ++
 src/mesa/drivers/dri/i965/brw_defines.h| 3 ++-
 src/mesa/drivers/dri/i965/brw_eu_emit.c| 3 ++-
 src/mesa/drivers/dri/i965/brw_fs_generator.cpp | 9 ++---
 src/mesa/drivers/dri/i965/brw_pipe_control.c   | 4 +++-
 src/mesa/drivers/dri/i965/gen6_queryobj.c  | 2 +-
 src/mesa/drivers/dri/i965/gen8_depth_state.c   | 3 ++-
 src/mesa/drivers/dri/i965/intel_batchbuffer.c  | 2 +-
 9 files changed, 20 insertions(+), 10 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_binding_tables.c 
b/src/mesa/drivers/dri/i965/brw_binding_tables.c
index f3a0310..bcf6422 100644
--- a/src/mesa/drivers/dri/i965/brw_binding_tables.c
+++ b/src/mesa/drivers/dri/i965/brw_binding_tables.c
@@ -54,7 +54,7 @@ static uint32_t
 reserve_hw_bt_space(struct brw_context *brw, unsigned bytes)
 {
/* From the Broadwell PRM, Volume 16, "Workarounds",
-* WaStateBindingTableOverfetch:
+* WaStateBindingTableOverfetch:hsw,bdw,chv,bxt
 * "HW over-fetches two cache lines of binding table indices.  When
 *  using the resource streamer, SW needs to pad binding table pointer
 *  updates with an additional two cache lines."
diff --git a/src/mesa/drivers/dri/i965/brw_blorp.cpp 
b/src/mesa/drivers/dri/i965/brw_blorp.cpp
index 1bc6d15..dd01ea8 100644
--- a/src/mesa/drivers/dri/i965/brw_blorp.cpp
+++ b/src/mesa/drivers/dri/i965/brw_blorp.cpp
@@ -304,6 +304,8 @@ brw_hiz_op_params::brw_hiz_op_params(struct 
intel_mipmap_tree *mt,
 * aligned to an 8x4 pixel block relative to the upper left corner
 * of the depth buffer [...]
 *
+* WaHizAmbiguate8x4Aligned:hsw
+*
 * For hiz resolves, the rectangle must also be 8x4 aligned. Item
 * WaHizAmbiguate8x4Aligned from the Haswell workarounds page and the
 * Ivybridge simulator require the alignment.
diff --git a/src/mesa/drivers/dri/i965/brw_defines.h 
b/src/mesa/drivers/dri/i965/brw_defines.h
index 01e0c99..5410a1d 100644
--- a/src/mesa/drivers/dri/i965/brw_defines.h
+++ b/src/mesa/drivers/dri/i965/brw_defines.h
@@ -1756,7 +1756,8 @@ enum brw_message_target {
 /* Dataport special binding table indices: */
 #define BRW_BTI_STATELESS255
 #define GEN7_BTI_SLM 254
-/* Note that on Gen8+ BTI 255 was redefined to be IA-coherent according to the
+/* WaForceEnableNonCoherent:bdw,chv,skl,kbl
+ * Note that on Gen8+ BTI 255 was redefined to be IA-coherent according to the
  * hardware spec, however because the DRM sets bit 4 of HDC_CHICKEN0 on BDW,
  * CHV and at least some pre-production steppings of SKL due to
  * WaForceEnableNonCoherent, HDC memory access may have been overridden by the
diff --git a/src/mesa/drivers/dri/i965/brw_eu_emit.c 
b/src/mesa/drivers/dri/i965/brw_eu_emit.c
index 35d8039..918d69e 100644
--- a/src/mesa/drivers/dri/i965/brw_eu_emit.c
+++ b/src/mesa/drivers/dri/i965/brw_eu_emit.c
@@ -1885,7 +1885,8 @@ void brw_CMP(struct brw_codegen *p,
brw_set_src0(p, insn, src0);
brw_set_src1(p, insn, src1);
 
-   /* Item WaCMPInstNullDstForcesThreadSwitch in the Haswell Bspec workarounds
+   /* WaCMPInstNullDstForcesThreadSwitch:ivb,hsw,vlv
+* Item WaCMPInstNullDstForcesThreadSwitch in the Haswell Bspec workarounds
 * page says:
 *"Any CMP instruction with a null destination must use a {switch}."
 *
diff --git a/src/mesa/drivers/dri/i965/brw_fs_generator.cpp 
b/src/mesa/drivers/dri/i965/brw_fs_generator.cpp
index 1916a99..24d4a9d 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_generator.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_generator.cpp
@@ -1836,7 +1836,8 @@ fs_generator::generate_code(const cfg_t *cfg, int 
dispatch_width)
  brw_F16TO32(p, dst, src[0]);
  break;
   case BRW_OPCODE_CMP:
- /* The Ivybridge/BayTrail WaCMPInstFlagDepClearedEarly workaround says
+ /* WaCMPInstFlagDepClearedEarly:ivb,hsw,vlv
+  * The Ivybridge/BayTrail WaCMPInstFlagDepClearedEarly workaround says
   * that when the destination is a GRF that the dependency-clear bit on
   * the flag register is cleared early.
   *
@@ -1928,7 +1929,8 @@ fs_generator::generate_code(const cfg_t *cfg, int 
dispatch_width)
 
   case BRW_OPCODE_BFI1:
  assert(devinfo->gen >= 7);
- /* The Haswell WaForceSIMD8ForBFIInstruction workaround says that we
+ /* WaForceSIMD8ForBFIInstruction:hsw
+  * The Haswell WaForceSIMD8ForBFIInstruction workaround says that we
   * should
   *
   *"Force BFI instructions to be executed always in SIMD8."
@@ -1947,7 +1949,8 @@ fs_generator::generate_code(const cfg_t *cfg, int 
dispatch_width)
   case BRW_OPCODE_BFI2:
   

[Mesa-dev] [PATCH v2 i-g-t] igt/list-workarounds: Extend the script to Mesa

2016-02-05 Thread Sameer Kibey
Updated the list-workarounds script so that it
can parse Mesa directory if provided. Moved the
common code to a separate function to allow
reuse for both kernel and mesa.

The new command line is:
Usage: list-workarounds [options] path-to-kernel
   -k path-to-kernel -m path-to-mesa

The legacy usage is retained to avoid breaking
backwards compatibility. New parameters -k and
-m are added for the new behavior.

Either kernel or mesa or both paths can be specified.
If path-to-mesa is invalid, error is reported.

Signed-off-by: Sameer Kibey 
---
 scripts/list-workarounds | 74 ++--
 1 file changed, 53 insertions(+), 21 deletions(-)

diff --git a/scripts/list-workarounds b/scripts/list-workarounds
index d11b6a9..8b41ae5 100755
--- a/scripts/list-workarounds
+++ b/scripts/list-workarounds
@@ -18,7 +18,7 @@ def find_nth(haystack, needle, n):
return start
 
 valid_platforms = ('ctg', 'elk', 'ilk', 'snb', 'ivb', 'vlv', 'hsw', 'bdw',
-  'chv', 'skl', 'bxt')
+  'chv', 'skl', 'bxt', 'kbl')
 def parse_platforms(line, p):
l =  p.split(',')
for p in l:
@@ -65,9 +65,15 @@ def execute(cmd):
return out, err
 
 def parse_options(args):
-   usage = "Usage: list-workarounds [options] path-to-kernel"
+   usage = "Usage: list-workarounds [options] path-to-kernel -k 
path-to-kernel -m path-to-mesa"
parser = optparse.OptionParser(usage, version=1.0)
 
+   parser.add_option("-k", "--kernel-path", dest="kernel_path", 
default=None,
+ help="path to kernel")
+
+   parser.add_option("-m", "--mesa-path", dest="mesa_path", default=None,
+ help="path to mesa")
+
parser.add_option("-v", "--verbose", action="store_true",
  dest="verbose", default=False,
  help="be more verbose")
@@ -76,38 +82,64 @@ def parse_options(args):
  help="List workarounds for the specified platform")
 
(options, args) = parser.parse_args()
-
return (options, args)
 
-if __name__ == '__main__':
-   (options, args) = parse_options(sys.argv[1:])
-   verbose = options.verbose
-
-   if not len(args):
-   sys.stderr.write("error: A path to a kernel tree is required\n")
-   sys.exit(1)
-
-   kernel_path = args[0]
-   kconfig = os.path.join(kernel_path, 'Kconfig')
-   if not os.path.isfile(kconfig):
-   sys.stderr.write("error: %s does not point to a kernel tree \n"
-% kernel_path)
-   sys.exit(1)
-
-   i915_dir = os.path.join('drivers', 'gpu', 'drm', 'i915')
+def print_workarounds(project_root, driver_dir, project):
olddir = os.getcwd()
-   os.chdir(kernel_path)
+   os.chdir(project_root)
work_arounds, err = execute(['git', 'grep', '-n',
 '-e', 'W[aA][A-Z0-9][a-zA-Z0-9_]\+',
-i915_dir])
+driver_dir])
os.chdir(olddir)
if err:
print(err)
sys.exit(1)
 
parse(work_arounds)
+   print "\nList of workarounds found in %s:" % project
for wa in sorted(workarounds.keys()):
if not options.platform:
print("%s: %s" % (wa, ', '.join(workarounds[wa])))
elif options.platform in workarounds[wa]:
print(wa)
+
+
+if __name__ == '__main__':
+   (options, args) = parse_options(sys.argv)
+   verbose = options.verbose
+   kernel_path = None
+
+   if not len(args) and options.kernel_path == None and options.mesa_path 
== None:
+   sys.stderr.write("error: A path to either a kernel tree or Mesa 
is required\n")
+   sys.exit(1)
+
+   if len(args):
+   kernel_path = args[0]
+   elif options.kernel_path != None:
+   kernel_path = options.kernel_path
+
+   if kernel_path != None:
+   # --- list Kernel workarounds if path is provided ---
+   kconfig = os.path.join(kernel_path, 'Kconfig')
+   if not os.path.isfile(kconfig):
+   sys.stderr.write("error: %s does not point to a kernel 
tree \n"
+   % kernel_path)
+   sys.exit(1)
+
+   i915_dir = os.path.join('drivers', 'gpu', 'drm', 'i915')
+   print_workarounds(kernel_path, i915_dir, "kernel")
+
+   # --- list mesa workarounds if path is provided ---
+   if options.mesa_path != None:
+   # reset workarounds array
+   workarounds = {}
+
+   mesa_path = options.mesa_path
+   i965_dir = os.path.join('src', 'mesa', 'drivers', 'dri', 'i965')
+   mesa_dir = os.path.join(mesa_path, i965_dir)
+   if not os.path.exi

Re: [Mesa-dev] MesaGL <-> non-Mesa OpenCL interop interface

2016-02-05 Thread Marek Olšák
On Fri, Feb 5, 2016 at 8:31 PM, Nicolai Hähnle  wrote:
> Hi,
>
>
> On 04.02.2016 17:25, Marek Olšák wrote:
>>
>> I would like to start a discussion about an OpenGL-OpenCL interop
>> interface where OpenCL is not part of Mesa.
>>
>> I think the only way to do this is to have Mesa export functions that
>> convert Mesa OpenGL objects into DMABUF handles. Such functions can be
>> exported by DRI driver modules or libGL & libEGL, however, it's
>> possible that the OpenCL stack won't link against libGL & libEGL,
>> therefore it's not required to expose the interface as GLX/EGL
>> extensions.
>>
>> The existing EGL extension for DMABUF exports only works with EGL
>> images, whereas this needs to work with OpenGL handles directly.
>>
>> All functions should accept a context pointer, because that's what
>> OpenCL receives from the user and the context might not be current.
>>
>> This is the proposed interface for sharing OpenGL buffers and
>> textures. This is just a draft and will most likely be changed. The
>> OpenCL stack is expected to obtain there via dlsym(RTLD_DEFAULT):
>>
>> int glXBufferExportDMABUFHandle(GLXContext context, GLuint bufferObj,
>> unsigned flags);
>> int eglBufferExportDMABUFHandle(EGLContext context, GLuint bufferObj,
>> unsigned flags);
>> int glXTextureExportDMABUFHandle(GLXContext context, GLuint
>> textureObj, GLenum textureTarget, unsigned flags);
>> int eglTextureExportDMABUFHandle(EGLContext context, GLuint
>> textureObj, GLenum textureTarget, unsigned flags);
>>
>> #define FLAG_CL_USAGE_READ_ONLY (1 << 0)
>>
>> Mesa should return a value <= 0 if bufferObj, textureObj, or
>> textureTarget is invalid. (TBD)
>>
>> The information about the texture format, texture layout (2D, 3D,
>> array, mipmap, ...), texture sizes, and hw-specific tiling parameters
>> is expected to be attached to the DMABUF handle using a
>> driver-specific ioctl (done by the Mesa driver), and likewise, the
>> OpenCL stack is expected to query it using a similar ioctl. Right now,
>> the DMABUF handle is the only piece of information that is publicly
>> returned to the OpenCL stack.
>
>
> Some thoughts: if this information must be queried via a driver-specific
> ioctl anyway, then does it really make sense to define a generic exporting
> interface for textures?

Yes, because the radeonsi driver can't translate a GL texture object
into a pipe_resource. This must be done in a component that has access
to struct gl_context.

Also, libGL is the only library that can convert GLXContext to
__DRIcontext. On the other hand, the *_dri.so module is the only one
that can convert __DRIcontext to gl_context, so multiple components
will have to be touched, most probably these:
- libGL (GLXContext -> __DRIcontext)
- libEGL (EGLContext -> __DRIcontext)
- dri_interface.h (receives __DRIcontext regardless of API)
- st/dri (__DRIcontext -> gl_context & pipe_context; GL handle ->
pipe_resource; call resource_get_handle)
- gallium interface (passing the "flags" parameter to resource_get_handle)
- radeonsi (set buffer metadata via libdrm; eliminate CMASK; eliminate
DCC if flags != read-only, etc.)

>
> If the consensus is yes, then I'd say the interface looks pretty reasonable.
> Having the textureTarget as a parameter seems to be redundant if the layout
> is attached to the DMABUF. I notice the OpenCL interface exposes it though,
> so I don't feel strongly about it.

The reason for that is that OpenCL can't check if the target is valid,
so Mesa has to do it and return an error accordingly.

>
> If OpenCL lives outside of Mesa but still calls into the kernel via libdrm,
> then it could potentially be more efficient to do the sharing via libdrm
> structures. Should that be done with an additional interface? Since they are
> hw-specific, wiring up such an interface might end up being awkward. I think
> it'd nicer to have these functions return a void* which is interpreted
> depending on the flags.

We can't do that, because libdrm doesn't understand GL texture handles.

>
> What's the error handling story? It seems most errors checked by these
> functions would result in CL_INVALID_GL_OBJECT, but perhaps some
> implementations want to signal CL_OUT_OF_HOST_MEMORY. How to distinguish
> between them?

Only ~1024 open DMABUF handles are allowed per process, which means we
can simply use all negative values for errors. The exact errors
returned by the functions are still to be determined.

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


Re: [Mesa-dev] [PATCH 7/7] mesa: optimize out the realloc from glCopyTexImagexD()

2016-02-05 Thread Ilia Mirkin
On Fri, Feb 5, 2016 at 4:11 PM, Miklós Máté  wrote:
> v2: comment about the purpose of the code
> ---
>  src/mesa/main/teximage.c | 32 
>  1 file changed, 32 insertions(+)
>
> diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
> index 50141be..cac05d5 100644
> --- a/src/mesa/main/teximage.c
> +++ b/src/mesa/main/teximage.c
> @@ -3486,6 +3486,21 @@ formats_differ_in_component_sizes(mesa_format f1, 
> mesa_format f2)
> return GL_FALSE;
>  }
>
> +static GLboolean
> +canAvoidRealloc(struct gl_texture_image *texImage, GLenum internalFormat,
> +  GLint x, GLint y, GLsizei width, GLsizei height, GLint border)
> +{
> +   if (texImage->InternalFormat != internalFormat)
> +  return false;
> +   if (texImage->Border != border)
> +  return false;
> +   if (texImage->Width2 != width)
> +  return false;
> +   if (texImage->Height2 != height)
> +  return false;
> +   return true;

Also need to compare the texFormat no?

> +}
> +
>  /**
>   * Implement the glCopyTexImage1/2D() functions.
>   */
> @@ -3526,6 +3541,23 @@ copyteximage(struct gl_context *ctx, GLuint dims,
> texObj = _mesa_get_current_tex_object(ctx, target);
> assert(texObj);
>
> +   /* First check if reallocating the texture buffer can be avoided.
> +* Without the realloc the copy can be 20x faster.
> +*/
> +   _mesa_lock_texture(ctx, texObj);
> +   {
> +  texImage = _mesa_select_tex_image(texObj, target, level);
> +  if (texImage && canAvoidRealloc(texImage, internalFormat,
> +   x, y, width, height, border)) {
> + _mesa_unlock_texture(ctx, texObj);
> + /*_mesa_debug(ctx, "using shortcut\n");*/
> + return _mesa_copy_texture_sub_image(ctx, dims, texObj, target, 
> level,
> +   0, 0, 0, x, y, width, height, "CopyTexImage");
> +  }
> +  /*_mesa_debug(ctx, "can't shortcut\n");*/
> +   }
> +   _mesa_unlock_texture(ctx, texObj);
> +
> texFormat = _mesa_choose_texture_format(ctx, texObj, target, level,
> internalFormat, GL_NONE, GL_NONE);
>
> --
> 2.7.0
>
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 2/7] st/mesa: implement GL_ATI_fragment_shader

2016-02-05 Thread Ilia Mirkin
On Fri, Feb 5, 2016 at 4:11 PM, Miklós Máté  wrote:
> v2: fix arithmetic for special opcodes
>  (based on comments from Marek and Ilia),
>  fix fog state, cleanup
> ---
>  src/mesa/Makefile.sources |   1 +
>  src/mesa/program/program.h|   2 +
>  src/mesa/state_tracker/st_atifs_to_tgsi.c | 734 
> ++
>  src/mesa/state_tracker/st_atifs_to_tgsi.h |  65 +++
>  src/mesa/state_tracker/st_atom_constbuf.c |  14 +
>  src/mesa/state_tracker/st_atom_shader.c   |   5 +-
>  src/mesa/state_tracker/st_cb_drawpixels.c |   1 +
>  src/mesa/state_tracker/st_cb_program.c|  36 +-
>  src/mesa/state_tracker/st_program.c   |  30 +-
>  src/mesa/state_tracker/st_program.h   |   4 +
>  10 files changed, 889 insertions(+), 3 deletions(-)
>  create mode 100644 src/mesa/state_tracker/st_atifs_to_tgsi.c
>  create mode 100644 src/mesa/state_tracker/st_atifs_to_tgsi.h
>
> diff --git a/src/mesa/Makefile.sources b/src/mesa/Makefile.sources
> index ffe560f..23fe42a 100644
> --- a/src/mesa/Makefile.sources
> +++ b/src/mesa/Makefile.sources
> @@ -393,6 +393,7 @@ VBO_FILES = \
> vbo/vbo_split_inplace.c
>
>  STATETRACKER_FILES = \
> +   state_tracker/st_atifs_to_tgsi.c \
> state_tracker/st_atom_array.c \
> state_tracker/st_atom_atomicbuf.c \
> state_tracker/st_atom_blend.c \
> diff --git a/src/mesa/program/program.h b/src/mesa/program/program.h
> index 24e0597..09e6928 100644
> --- a/src/mesa/program/program.h
> +++ b/src/mesa/program/program.h
> @@ -172,6 +172,8 @@ _mesa_program_enum_to_shader_stage(GLenum v)
>return MESA_SHADER_VERTEX;
> case GL_FRAGMENT_PROGRAM_ARB:
>return MESA_SHADER_FRAGMENT;
> +   case GL_FRAGMENT_SHADER_ATI:
> +  return MESA_SHADER_FRAGMENT;
> case GL_GEOMETRY_PROGRAM_NV:
>return MESA_SHADER_GEOMETRY;
> case GL_TESS_CONTROL_PROGRAM_NV:
> diff --git a/src/mesa/state_tracker/st_atifs_to_tgsi.c 
> b/src/mesa/state_tracker/st_atifs_to_tgsi.c
> new file mode 100644
> index 000..fe303f6
> --- /dev/null
> +++ b/src/mesa/state_tracker/st_atifs_to_tgsi.c
> @@ -0,0 +1,734 @@
> +/*
> + * Copyright (C) 2016 Miklós Máté
> + *
> + * Permission is hereby granted, free of charge, to any person obtaining a
> + * copy of this software and associated documentation files (the "Software"),
> + * to deal in the Software without restriction, including without limitation
> + * the rights to use, copy, modify, merge, publish, distribute, sublicense,
> + * and/or sell copies of the Software, and to permit persons to whom the
> + * Software is furnished to do so, subject to the following conditions:
> + *
> + * The above copyright notice and this permission notice shall be included in
> + * all copies or substantial portions of the Software.
> + *
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
> + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
> + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
> + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
> + * OTHER DEALINGS IN THE SOFTWARE.
> + */
> +
> +#include "main/mtypes.h"
> +#include "main/atifragshader.h"
> +#include "main/texobj.h"
> +#include "main/errors.h"
> +#include "program/prog_parameter.h"
> +
> +#include "tgsi/tgsi_transform.h"
> +#include "tgsi/tgsi_ureg.h"
> +#include "util/u_math.h"
> +#include "util/u_memory.h"
> +
> +#include "st_program.h"
> +#include "st_atifs_to_tgsi.h"
> +
> +/**
> + * Intermediate state used during shader translation.
> + */
> +struct st_translate {
> +   struct ureg_program *ureg;
> +   struct gl_context *ctx;
> +   struct ati_fragment_shader *atifs;
> +
> +   struct ureg_dst temps[MAX_PROGRAM_TEMPS];
> +   struct ureg_src *constants;
> +   struct ureg_dst outputs[PIPE_MAX_SHADER_OUTPUTS];
> +   struct ureg_src inputs[PIPE_MAX_SHADER_INPUTS];
> +   struct ureg_src samplers[PIPE_MAX_SAMPLERS];
> +
> +   const GLuint *inputMapping;
> +   const GLuint *outputMapping;
> +
> +   unsigned current_pass;
> +
> +   bool regs_written[MAX_NUM_PASSES_ATI][MAX_NUM_FRAGMENT_REGISTERS_ATI];
> +
> +   boolean error;
> +};
> +
> +struct instruction_desc {
> +   unsigned TGSI_opcode;
> +   const char *name;
> +   unsigned char arg_count;
> +   unsigned char special; /* no 1:1 corresponding TGSI instruction */
> +};
> +
> +static struct instruction_desc inst_desc[] = {
> +   {TGSI_OPCODE_MOV, "MOV", 1, 0},
> +   {TGSI_OPCODE_NOP, "UND", 0, 0}, /* unused */
> +   {TGSI_OPCODE_ADD, "ADD", 2, 0},
> +   {TGSI_OPCODE_MUL, "MUL", 2, 0},
> +   {TGSI_OPCODE_SUB, "SUB", 2, 0},
> +   {TGSI_OPCODE_DP3, "DOT3", 2, 0},
> +   {TGSI_OPCODE_DP4, "DOT4", 2, 0},
> +   {TGSI_OPCODE_MAD, "MAD", 3, 0},
> +   {TGSI_OPCODE_LRP, "LERP", 3, 0},
> +   {TGSI_OPCODE_NOP, "CND", 3, 1},
> +   {TGSI_OP

Re: [Mesa-dev] [PATCH 00/18] RadeonSI: Restructuring shader codegen part 3

2016-02-05 Thread Nicolai Hähnle

Patches 4-10 and 12-18 are also

Reviewed-by: Nicolai Hähnle 

On 05.02.2016 14:20, Marek Olšák wrote:

Hi,

This is the last part of restructuring needed for having one shader variant per 
shader.

Summary:
- a lot of changes are about PS inputs and interpolation
- code movements, cleanups

Behavior changes:
- removed unnecessary MRT_NULL exports
- geometry shaders aren't compiled on demand

Please review.

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


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


[Mesa-dev] [PATCH 4/7] mesa: remove check_compatible() in make_current

2016-02-05 Thread Miklós Máté
this was marked for removal since 2007
ctx::Visual is also removed, since this was its only legit user
---
 .../drivers/dri/radeon/radeon_common_context.c |  2 +-
 src/mesa/main/blend.c  |  4 +-
 src/mesa/main/blend.h  |  4 +-
 src/mesa/main/context.c| 89 ++
 src/mesa/main/mtypes.h |  7 --
 src/mesa/main/pixel.c  |  4 +-
 src/mesa/main/pixel.h  |  4 +-
 7 files changed, 15 insertions(+), 99 deletions(-)

diff --git a/src/mesa/drivers/dri/radeon/radeon_common_context.c 
b/src/mesa/drivers/dri/radeon/radeon_common_context.c
index 4660d98..2989f63 100644
--- a/src/mesa/drivers/dri/radeon/radeon_common_context.c
+++ b/src/mesa/drivers/dri/radeon/radeon_common_context.c
@@ -604,7 +604,7 @@ GLboolean radeonMakeCurrent(__DRIcontext * driContextPriv,
}
 
if(driDrawPriv == NULL && driReadPriv == NULL) {
-   drfb = _mesa_create_framebuffer(&radeon->glCtx.Visual);
+   drfb = _mesa_get_incomplete_framebuffer();
readfb = drfb;
}
else {
diff --git a/src/mesa/main/blend.c b/src/mesa/main/blend.c
index 2ae22e9..28e2dbf 100644
--- a/src/mesa/main/blend.c
+++ b/src/mesa/main/blend.c
@@ -921,7 +921,7 @@ _mesa_get_render_format(const struct gl_context *ctx, 
mesa_format format)
  * Initializes the related fields in the context color attribute group,
  * __struct gl_contextRec::Color.
  */
-void _mesa_init_color( struct gl_context * ctx )
+void _mesa_init_color( struct gl_context * ctx, GLuint doubleBufferMode )
 {
GLuint i;
 
@@ -951,7 +951,7 @@ void _mesa_init_color( struct gl_context * ctx )
 
/* GL_FRONT is not possible on GLES. Instead GL_BACK will render to either
 * the front or the back buffer depending on the config */
-   if (ctx->Visual.doubleBufferMode || _mesa_is_gles(ctx)) {
+   if (doubleBufferMode || _mesa_is_gles(ctx)) {
   ctx->Color.DrawBuffer[0] = GL_BACK;
}
else {
diff --git a/src/mesa/main/blend.h b/src/mesa/main/blend.h
index 8ab9e02..f4854a6 100644
--- a/src/mesa/main/blend.h
+++ b/src/mesa/main/blend.h
@@ -124,7 +124,7 @@ _mesa_update_clamp_vertex_color(struct gl_context *ctx,
 extern mesa_format
 _mesa_get_render_format(const struct gl_context *ctx, mesa_format format);
 
-extern void  
-_mesa_init_color( struct gl_context * ctx );
+extern void
+_mesa_init_color( struct gl_context * ctx, GLuint doubleBufferMode );
 
 #endif
diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c
index 8b415ed..2a512c6 100644
--- a/src/mesa/main/context.c
+++ b/src/mesa/main/context.c
@@ -796,7 +796,7 @@ check_context_limits(struct gl_context *ctx)
  * functions for the more complex data structures.
  */
 static GLboolean
-init_attrib_groups(struct gl_context *ctx)
+init_attrib_groups(struct gl_context *ctx, GLuint doubleBufferMode)
 {
assert(ctx);
 
@@ -810,7 +810,7 @@ init_attrib_groups(struct gl_context *ctx)
_mesa_init_accum( ctx );
_mesa_init_attrib( ctx );
_mesa_init_buffer_objects( ctx );
-   _mesa_init_color( ctx );
+   _mesa_init_color( ctx, doubleBufferMode );
_mesa_init_current( ctx );
_mesa_init_depth( ctx );
_mesa_init_debug( ctx );
@@ -828,7 +828,7 @@ init_attrib_groups(struct gl_context *ctx)
_mesa_init_multisample( ctx );
_mesa_init_performance_monitors( ctx );
_mesa_init_pipeline( ctx );
-   _mesa_init_pixel( ctx );
+   _mesa_init_pixel( ctx, doubleBufferMode );
_mesa_init_pixelstore( ctx );
_mesa_init_point( ctx );
_mesa_init_polygon( ctx );
@@ -1159,15 +1159,6 @@ _mesa_initialize_context(struct gl_context *ctx,
ctx->WinSysDrawBuffer = NULL;
ctx->WinSysReadBuffer = NULL;
 
-   if (visual) {
-  ctx->Visual = *visual;
-  ctx->HasConfig = GL_TRUE;
-   }
-   else {
-  memset(&ctx->Visual, 0, sizeof ctx->Visual);
-  ctx->HasConfig = GL_FALSE;
-   }
-
_mesa_override_gl_version(ctx);
 
/* misc one-time initializations */
@@ -1193,7 +1184,7 @@ _mesa_initialize_context(struct gl_context *ctx,
 
_mesa_reference_shared_state(ctx, &ctx->Shared, shared);
 
-   if (!init_attrib_groups( ctx ))
+   if (!init_attrib_groups( ctx, visual->doubleBufferMode ))
   goto fail;
 
/* setup the API dispatch tables with all nop functions */
@@ -1521,57 +1512,6 @@ _mesa_copy_context( const struct gl_context *src, struct 
gl_context *dst,
 
 
 /**
- * Check if the given context can render into the given framebuffer
- * by checking visual attributes.
- *
- * Most of these tests could go away because Mesa is now pretty flexible
- * in terms of mixing rendering contexts with framebuffers.  As long
- * as RGB vs. CI mode agree, we're probably good.
- *
- * \return GL_TRUE if compatible, GL_FALSE otherwise.
- */
-static GLboolean 
-check_compatible(const struct gl_context *ctx,
- const struct gl_framebuffer *buffer)
-{
-   const struct 

[Mesa-dev] [PATCH 3/7] st/mesa: enable GL_ATI_fragment_shader

2016-02-05 Thread Miklós Máté
---
 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 f25bd74..a2caa11 100644
--- a/src/mesa/state_tracker/st_extensions.c
+++ b/src/mesa/state_tracker/st_extensions.c
@@ -728,6 +728,7 @@ void st_init_extensions(struct pipe_screen *screen,
extensions->EXT_texture_env_dot3 = GL_TRUE;
extensions->EXT_vertex_array_bgra = GL_TRUE;
 
+   extensions->ATI_fragment_shader = GL_TRUE;
extensions->ATI_texture_env_combine3 = GL_TRUE;
 
extensions->MESA_pack_invert = GL_TRUE;
-- 
2.7.0

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


Re: [Mesa-dev] [PATCH 11/18] radeonsi: don't emit unnecessary NULL exports for unbound targets

2016-02-05 Thread Nicolai Hähnle

On 05.02.2016 14:20, Marek Olšák wrote:

From: Marek Olšák 

---
  src/gallium/drivers/radeonsi/si_shader.c | 63 +---
  1 file changed, 50 insertions(+), 13 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_shader.c 
b/src/gallium/drivers/radeonsi/si_shader.c
index bd45d4a..18e4ab9 100644
--- a/src/gallium/drivers/radeonsi/si_shader.c
+++ b/src/gallium/drivers/radeonsi/si_shader.c
@@ -2298,13 +2298,30 @@ static void si_export_mrt_color(struct 
lp_build_tgsi_context *bld_base,
/* If last_cbuf > 0, FS_COLOR0_WRITES_ALL_CBUFS is true. */
if (index == 0 &&
si_shader_ctx->shader->key.ps.last_cbuf > 0) {
-   for (int c = 1; c <= si_shader_ctx->shader->key.ps.last_cbuf; 
c++) {
+   LLVMValueRef args[8][9];


This declaration shadows the top-level args array. I suggest to turn 
this into an if-else where the else part covers the last_cbuf == 0 case. 
IMHO that also makes the control flow clearer.


Also, while we're at it, I believe that the index == 0 is not needed 
when last_cbuf > 0, and it could be clearer to omit it. At least in 
GLSL, gl_FragColor and gl_FragData are mutually exclusive. I don't feel 
strongly about it though.



+   int c, last = -1;
+
+   /* Get the export arguments, also find out what the last one 
is. */
+   for (c = 0; c <= si_shader_ctx->shader->key.ps.last_cbuf; c++) {
si_llvm_init_export_args(bld_base, color,
-V_008DFC_SQ_EXP_MRT + c, args);
+V_008DFC_SQ_EXP_MRT + c, 
args[c]);
+   if (args[c][0] != bld_base->uint_bld.zero)
+   last = c;
+   }
+
+   /* Emit all exports. */
+   for (c = 0; c <= si_shader_ctx->shader->key.ps.last_cbuf; c++) {
+   if (is_last && last == c) {
+   args[c][1] = bld_base->uint_bld.one; /* whether 
the EXEC mask is valid */
+   args[c][2] = bld_base->uint_bld.one; /* DONE 
bit */
+   } else if (args[c][0] == bld_base->uint_bld.zero)
+   continue; /* unnecessary NULL export */
+
lp_build_intrinsic(base->gallivm->builder, 
"llvm.SI.export",
   
LLVMVoidTypeInContext(base->gallivm->context),
-  args, 9, 0);
+  args[c], 9, 0);
}
+   return;
}

/* Export */
@@ -2313,7 +2330,9 @@ static void si_export_mrt_color(struct 
lp_build_tgsi_context *bld_base,
if (is_last) {
args[1] = bld_base->uint_bld.one; /* whether the EXEC mask is 
valid */
args[2] = bld_base->uint_bld.one; /* DONE bit */
-   }
+   } else if (args[0] == bld_base->uint_bld.zero)
+   return; /* unnecessary NULL export */
+
lp_build_intrinsic(base->gallivm->builder, "llvm.SI.export",
   LLVMVoidTypeInContext(base->gallivm->context),
   args, 9, 0);
@@ -2351,19 +2370,37 @@ static void si_llvm_emit_fs_epilogue(struct 
lp_build_tgsi_context * bld_base)
int last_color_export = -1;
int i;

-   /* If there are no outputs, add a dummy export. */
-   if (!info->num_outputs) {
-   si_export_null(bld_base);
-   return;
-   }
-
/* Determine the last export. If MRTZ is present, it's always last.
 * Otherwise, find the last color export.
 */
-   if (!info->writes_z && !info->writes_stencil && 
!info->writes_samplemask)
-   for (i = 0; i < info->num_outputs; i++)
-   if (info->output_semantic_name[i] == 
TGSI_SEMANTIC_COLOR)
+   if (!info->writes_z && !info->writes_stencil && 
!info->writes_samplemask) {
+   unsigned spi_format = shader->key.ps.spi_shader_col_format;
+
+   for (i = 0; i < info->num_outputs; i++) {
+   unsigned index = info->output_semantic_index[i];
+
+   if (info->output_semantic_name[i] != 
TGSI_SEMANTIC_COLOR)
+   continue;
+
+   /* If last_cbuf > 0, FS_COLOR0_WRITES_ALL_CBUFS is 
true. */
+   if (index == 0 && shader->key.ps.last_cbuf > 0) {
+   /* Just set this if any of the colorbuffers are 
enabled. */
+   if (spi_format &
+   ((1llu << (4 * (shader->key.ps.last_cbuf + 
1))) - 1))
+   last_color_export = i;
+   continue;
+   }


Another index == 0 that is probably redundant.

Cheers,
Nicolai


+
+   if ((spi_format >> (i

[Mesa-dev] [PATCH 2/7] st/mesa: implement GL_ATI_fragment_shader

2016-02-05 Thread Miklós Máté
v2: fix arithmetic for special opcodes
 (based on comments from Marek and Ilia),
 fix fog state, cleanup
---
 src/mesa/Makefile.sources |   1 +
 src/mesa/program/program.h|   2 +
 src/mesa/state_tracker/st_atifs_to_tgsi.c | 734 ++
 src/mesa/state_tracker/st_atifs_to_tgsi.h |  65 +++
 src/mesa/state_tracker/st_atom_constbuf.c |  14 +
 src/mesa/state_tracker/st_atom_shader.c   |   5 +-
 src/mesa/state_tracker/st_cb_drawpixels.c |   1 +
 src/mesa/state_tracker/st_cb_program.c|  36 +-
 src/mesa/state_tracker/st_program.c   |  30 +-
 src/mesa/state_tracker/st_program.h   |   4 +
 10 files changed, 889 insertions(+), 3 deletions(-)
 create mode 100644 src/mesa/state_tracker/st_atifs_to_tgsi.c
 create mode 100644 src/mesa/state_tracker/st_atifs_to_tgsi.h

diff --git a/src/mesa/Makefile.sources b/src/mesa/Makefile.sources
index ffe560f..23fe42a 100644
--- a/src/mesa/Makefile.sources
+++ b/src/mesa/Makefile.sources
@@ -393,6 +393,7 @@ VBO_FILES = \
vbo/vbo_split_inplace.c
 
 STATETRACKER_FILES = \
+   state_tracker/st_atifs_to_tgsi.c \
state_tracker/st_atom_array.c \
state_tracker/st_atom_atomicbuf.c \
state_tracker/st_atom_blend.c \
diff --git a/src/mesa/program/program.h b/src/mesa/program/program.h
index 24e0597..09e6928 100644
--- a/src/mesa/program/program.h
+++ b/src/mesa/program/program.h
@@ -172,6 +172,8 @@ _mesa_program_enum_to_shader_stage(GLenum v)
   return MESA_SHADER_VERTEX;
case GL_FRAGMENT_PROGRAM_ARB:
   return MESA_SHADER_FRAGMENT;
+   case GL_FRAGMENT_SHADER_ATI:
+  return MESA_SHADER_FRAGMENT;
case GL_GEOMETRY_PROGRAM_NV:
   return MESA_SHADER_GEOMETRY;
case GL_TESS_CONTROL_PROGRAM_NV:
diff --git a/src/mesa/state_tracker/st_atifs_to_tgsi.c 
b/src/mesa/state_tracker/st_atifs_to_tgsi.c
new file mode 100644
index 000..fe303f6
--- /dev/null
+++ b/src/mesa/state_tracker/st_atifs_to_tgsi.c
@@ -0,0 +1,734 @@
+/*
+ * Copyright (C) 2016 Miklós Máté
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#include "main/mtypes.h"
+#include "main/atifragshader.h"
+#include "main/texobj.h"
+#include "main/errors.h"
+#include "program/prog_parameter.h"
+
+#include "tgsi/tgsi_transform.h"
+#include "tgsi/tgsi_ureg.h"
+#include "util/u_math.h"
+#include "util/u_memory.h"
+
+#include "st_program.h"
+#include "st_atifs_to_tgsi.h"
+
+/**
+ * Intermediate state used during shader translation.
+ */
+struct st_translate {
+   struct ureg_program *ureg;
+   struct gl_context *ctx;
+   struct ati_fragment_shader *atifs;
+
+   struct ureg_dst temps[MAX_PROGRAM_TEMPS];
+   struct ureg_src *constants;
+   struct ureg_dst outputs[PIPE_MAX_SHADER_OUTPUTS];
+   struct ureg_src inputs[PIPE_MAX_SHADER_INPUTS];
+   struct ureg_src samplers[PIPE_MAX_SAMPLERS];
+
+   const GLuint *inputMapping;
+   const GLuint *outputMapping;
+
+   unsigned current_pass;
+
+   bool regs_written[MAX_NUM_PASSES_ATI][MAX_NUM_FRAGMENT_REGISTERS_ATI];
+
+   boolean error;
+};
+
+struct instruction_desc {
+   unsigned TGSI_opcode;
+   const char *name;
+   unsigned char arg_count;
+   unsigned char special; /* no 1:1 corresponding TGSI instruction */
+};
+
+static struct instruction_desc inst_desc[] = {
+   {TGSI_OPCODE_MOV, "MOV", 1, 0},
+   {TGSI_OPCODE_NOP, "UND", 0, 0}, /* unused */
+   {TGSI_OPCODE_ADD, "ADD", 2, 0},
+   {TGSI_OPCODE_MUL, "MUL", 2, 0},
+   {TGSI_OPCODE_SUB, "SUB", 2, 0},
+   {TGSI_OPCODE_DP3, "DOT3", 2, 0},
+   {TGSI_OPCODE_DP4, "DOT4", 2, 0},
+   {TGSI_OPCODE_MAD, "MAD", 3, 0},
+   {TGSI_OPCODE_LRP, "LERP", 3, 0},
+   {TGSI_OPCODE_NOP, "CND", 3, 1},
+   {TGSI_OPCODE_NOP, "CND0", 3, 2},
+   {TGSI_OPCODE_NOP, "DOT2_ADD", 3, 3}
+};
+
+static struct ureg_dst get_temp(struct st_translate *t, unsigned index)
+{
+   if (ureg_dst_is_undef(t->temps[index]))
+  t->temps[index] = ureg_DECL_temporary(t->ureg);
+   return t->temps[index];
+}
+
+static struct ureg_src apply_s

[Mesa-dev] [PATCH 6/7] glx: remove incorrect refcounting of DRIdrawable

2016-02-05 Thread Miklós Máté
dri drawables must never be released when unbound from a context
as long as their corresponding glx objects (window, pixmap, pbuffer)
still exist

this fixes fd.o bug #93955 and disappearing characters in KotOR when
soft shadows are enabled
---
 src/glx/dri2_glx.c   |  4 
 src/glx/dri3_glx.c   |  4 
 src/glx/dri_common.c | 38 --
 src/glx/dri_glx.c|  4 
 src/glx/drisw_glx.c  |  4 
 src/glx/glxclient.h  |  1 -
 6 files changed, 55 deletions(-)

diff --git a/src/glx/dri2_glx.c b/src/glx/dri2_glx.c
index 7710349..ebc878f 100644
--- a/src/glx/dri2_glx.c
+++ b/src/glx/dri2_glx.c
@@ -122,8 +122,6 @@ dri2_destroy_context(struct glx_context *context)
struct dri2_context *pcp = (struct dri2_context *) context;
struct dri2_screen *psc = (struct dri2_screen *) context->psc;
 
-   driReleaseDrawables(&pcp->base);
-
free((char *) context->extensions);
 
(*psc->core->destroyContext) (pcp->driContext);
@@ -145,8 +143,6 @@ dri2_bind_context(struct glx_context *context, struct 
glx_context *old,
pdraw = (struct dri2_drawable *) driFetchDrawable(context, draw);
pread = (struct dri2_drawable *) driFetchDrawable(context, read);
 
-   driReleaseDrawables(&pcp->base);
-
if (pdraw)
   dri_draw = pdraw->driDrawable;
else if (draw != None)
diff --git a/src/glx/dri3_glx.c b/src/glx/dri3_glx.c
index 6054ffc..38f5799 100644
--- a/src/glx/dri3_glx.c
+++ b/src/glx/dri3_glx.c
@@ -186,8 +186,6 @@ dri3_destroy_context(struct glx_context *context)
struct dri3_context *pcp = (struct dri3_context *) context;
struct dri3_screen *psc = (struct dri3_screen *) context->psc;
 
-   driReleaseDrawables(&pcp->base);
-
free((char *) context->extensions);
 
(*psc->core->destroyContext) (pcp->driContext);
@@ -206,8 +204,6 @@ dri3_bind_context(struct glx_context *context, struct 
glx_context *old,
pdraw = (struct dri3_drawable *) driFetchDrawable(context, draw);
pread = (struct dri3_drawable *) driFetchDrawable(context, read);
 
-   driReleaseDrawables(&pcp->base);
-
if (pdraw == NULL || pread == NULL)
   return GLXBadDrawable;
 
diff --git a/src/glx/dri_common.c b/src/glx/dri_common.c
index 6728d38..2d334ab 100644
--- a/src/glx/dri_common.c
+++ b/src/glx/dri_common.c
@@ -404,7 +404,6 @@ driFetchDrawable(struct glx_context *gc, GLXDrawable 
glxDrawable)
   return NULL;
 
if (__glxHashLookup(priv->drawHash, glxDrawable, (void *) &pdraw) == 0) {
-  pdraw->refcount ++;
   return pdraw;
}
 
@@ -420,47 +419,10 @@ driFetchDrawable(struct glx_context *gc, GLXDrawable 
glxDrawable)
   (*pdraw->destroyDrawable) (pdraw);
   return NULL;
}
-   pdraw->refcount = 1;
 
return pdraw;
 }
 
-_X_HIDDEN void
-driReleaseDrawables(struct glx_context *gc)
-{
-   const struct glx_display *priv = gc->psc->display;
-   __GLXDRIdrawable *pdraw;
-
-   if (priv == NULL)
-  return;
-
-   if (__glxHashLookup(priv->drawHash,
-  gc->currentDrawable, (void *) &pdraw) == 0) {
-  if (pdraw->drawable == pdraw->xDrawable) {
-pdraw->refcount --;
-if (pdraw->refcount == 0) {
-   (*pdraw->destroyDrawable)(pdraw);
-   __glxHashDelete(priv->drawHash, gc->currentDrawable);
-}
-  }
-   }
-
-   if (__glxHashLookup(priv->drawHash,
-  gc->currentReadable, (void *) &pdraw) == 0) {
-  if (pdraw->drawable == pdraw->xDrawable) {
-pdraw->refcount --;
-if (pdraw->refcount == 0) {
-   (*pdraw->destroyDrawable)(pdraw);
-   __glxHashDelete(priv->drawHash, gc->currentReadable);
-}
-  }
-   }
-
-   gc->currentDrawable = None;
-   gc->currentReadable = None;
-
-}
-
 _X_HIDDEN bool
 dri2_convert_glx_attribs(unsigned num_attribs, const uint32_t *attribs,
  unsigned *major_ver, unsigned *minor_ver,
diff --git a/src/glx/dri_glx.c b/src/glx/dri_glx.c
index d087751..69d7502 100644
--- a/src/glx/dri_glx.c
+++ b/src/glx/dri_glx.c
@@ -526,8 +526,6 @@ dri_destroy_context(struct glx_context * context)
struct dri_context *pcp = (struct dri_context *) context;
struct dri_screen *psc = (struct dri_screen *) context->psc;
 
-   driReleaseDrawables(&pcp->base);
-
free((char *) context->extensions);
 
(*psc->core->destroyContext) (pcp->driContext);
@@ -547,8 +545,6 @@ dri_bind_context(struct glx_context *context, struct 
glx_context *old,
pdraw = (struct dri_drawable *) driFetchDrawable(context, draw);
pread = (struct dri_drawable *) driFetchDrawable(context, read);
 
-   driReleaseDrawables(&pcp->base);
-
if (pdraw == NULL || pread == NULL)
   return GLXBadDrawable;
 
diff --git a/src/glx/drisw_glx.c b/src/glx/drisw_glx.c
index 241ac7f..2350292 100644
--- a/src/glx/drisw_glx.c
+++ b/src/glx/drisw_glx.c
@@ -234,8 +234,6 @@ drisw_destroy_context(struct glx_context *context)
struct drisw_context *pcp = (struct drisw_context *) context;
struct drisw_screen *psc = (struct dri

[Mesa-dev] [PATCH 0/7] Fixes for SW:KotOR (v2)

2016-02-05 Thread Miklós Máté
Hi,

this series is the second version of my patch set, which aims to improve the 
looks of Star Wars: Knights of the Old Republic (via Wine). The main feature is 
the implementation of GL_ATI_fragment_shader for all Gallium divers (though I 
could only test it with radeonsi, llvmpipe, and softpipe). If this extension is 
available, the game uses it quite extensively: perhaps the most notable effect 
is the animated water ripples, but it also fixes the grass, improves the 
specular on wet characters (e.g. the Selkath) and it is used for regular 
texturing almost everywhere. The game has two optional post-process effects 
that also depend on this extension: framebuffer effects (light bloom, 
distortion), and soft shadows.

See the screenshot gallery in 
http://lists.freedesktop.org/archives/mesa-dev/2015-December/103263.html

AFAIK there are 4 games that can use ATI_fs: KotOR 1&2, Doom 3, Quake 4.

Patches 1-3 implement ATI_fragment_shader, 4-7 are fixes for post-processing in 
KotOR

After this series the following issues remain with post-processing in KotOR 
that I've been unable to fix yet:

1. Enabling MSAA results in black screen when post-process is enabled, only the 
light bloom is visible. I don't know how to debug this.

2. Post-process filters are extremely slow. Normally the game runs at around 
80fps (cpu-bound), but drops to 15fps with framebuffer effects, 20fps with soft 
shadows, 9fps with both. I've tried to profile this with apitrace, and found a 
bottleneck (see patch 07) that cost 5ms per call, but it turned out that it's 
not the real bottleneck. Both capturing and replaying are very slow compared to 
the game (15fps), so the profiler basically measures its own latency. I've 
tried to find the real culprit by adding time measurement to the calls made 
when drawing the post-process effects, but haven't found anything yet.

MM

Miklós Máté (7):
  mesa: optionally associate a gl_program to ati_fragment_shader
  st/mesa: implement GL_ATI_fragment_shader
  st/mesa: enable GL_ATI_fragment_shader
  mesa: remove check_compatible() in make_current
  st/mesa: fix handling the fallback texture
  glx: remove incorrect refcounting of DRIdrawable
  mesa: optimize out the realloc from glCopyTexImagexD()

 src/glx/dri2_glx.c |   4 -
 src/glx/dri3_glx.c |   4 -
 src/glx/dri_common.c   |  38 --
 src/glx/dri_glx.c  |   4 -
 src/glx/drisw_glx.c|   4 -
 src/glx/glxclient.h|   1 -
 src/mesa/Makefile.sources  |   1 +
 src/mesa/drivers/common/driverfuncs.c  |   3 +
 .../drivers/dri/radeon/radeon_common_context.c |   2 +-
 src/mesa/main/atifragshader.c  |  13 +-
 src/mesa/main/blend.c  |   4 +-
 src/mesa/main/blend.h  |   4 +-
 src/mesa/main/context.c|  89 +--
 src/mesa/main/dd.h |   7 +-
 src/mesa/main/mtypes.h |   8 +-
 src/mesa/main/pixel.c  |   4 +-
 src/mesa/main/pixel.h  |   4 +-
 src/mesa/main/state.c  |  14 +-
 src/mesa/main/teximage.c   |  32 +
 src/mesa/program/program.h |   2 +
 src/mesa/state_tracker/st_atifs_to_tgsi.c  | 734 +
 src/mesa/state_tracker/st_atifs_to_tgsi.h  |  65 ++
 src/mesa/state_tracker/st_atom_constbuf.c  |  14 +
 src/mesa/state_tracker/st_atom_sampler.c   |   6 +-
 src/mesa/state_tracker/st_atom_shader.c|   5 +-
 src/mesa/state_tracker/st_cb_drawpixels.c  |   1 +
 src/mesa/state_tracker/st_cb_program.c |  36 +-
 src/mesa/state_tracker/st_extensions.c |   1 +
 src/mesa/state_tracker/st_program.c|  30 +-
 src/mesa/state_tracker/st_program.h|   4 +
 30 files changed, 977 insertions(+), 161 deletions(-)
 create mode 100644 src/mesa/state_tracker/st_atifs_to_tgsi.c
 create mode 100644 src/mesa/state_tracker/st_atifs_to_tgsi.h

-- 
2.7.0

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


[Mesa-dev] [PATCH 5/7] st/mesa: fix handling the fallback texture

2016-02-05 Thread Miklós Máté
v2: fix const-ness
---
 src/mesa/state_tracker/st_atom_sampler.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/mesa/state_tracker/st_atom_sampler.c 
b/src/mesa/state_tracker/st_atom_sampler.c
index 94231cf..7c8fa13 100644
--- a/src/mesa/state_tracker/st_atom_sampler.c
+++ b/src/mesa/state_tracker/st_atom_sampler.c
@@ -133,7 +133,7 @@ convert_sampler(struct st_context *st,
 {
const struct gl_texture_object *texobj;
struct gl_context *ctx = st->ctx;
-   struct gl_sampler_object *msamp;
+   const struct gl_sampler_object *msamp;
GLenum texBaseFormat;
 
texobj = ctx->Texture.Unit[texUnit]._Current;
@@ -144,6 +144,10 @@ convert_sampler(struct st_context *st,
texBaseFormat = _mesa_texture_base_format(texobj);
 
msamp = _mesa_get_samplerobj(ctx, texUnit);
+   if (!msamp) {
+  /* handle the fallback texture */
+  msamp = &texobj->Sampler;
+   }
 
memset(sampler, 0, sizeof(*sampler));
sampler->wrap_s = gl_wrap_xlate(msamp->WrapS);
-- 
2.7.0

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


[Mesa-dev] [PATCH 1/7] mesa: optionally associate a gl_program to ati_fragment_shader

2016-02-05 Thread Miklós Máté
the state tracker will use it
---
 src/mesa/drivers/common/driverfuncs.c |  3 +++
 src/mesa/main/atifragshader.c | 13 -
 src/mesa/main/dd.h|  7 ++-
 src/mesa/main/mtypes.h|  1 +
 src/mesa/main/state.c | 14 +-
 5 files changed, 35 insertions(+), 3 deletions(-)

diff --git a/src/mesa/drivers/common/driverfuncs.c 
b/src/mesa/drivers/common/driverfuncs.c
index 752aaf6..65a0cf8 100644
--- a/src/mesa/drivers/common/driverfuncs.c
+++ b/src/mesa/drivers/common/driverfuncs.c
@@ -117,6 +117,9 @@ _mesa_init_driver_functions(struct dd_function_table 
*driver)
driver->NewProgram = _mesa_new_program;
driver->DeleteProgram = _mesa_delete_program;
 
+   /* ATI_fragment_shader */
+   driver->NewATIfs = NULL;
+
/* simple state commands */
driver->AlphaFunc = NULL;
driver->BlendColor = NULL;
diff --git a/src/mesa/main/atifragshader.c b/src/mesa/main/atifragshader.c
index 8fcbff6..9308ea7 100644
--- a/src/mesa/main/atifragshader.c
+++ b/src/mesa/main/atifragshader.c
@@ -30,6 +30,7 @@
 #include "main/mtypes.h"
 #include "main/dispatch.h"
 #include "main/atifragshader.h"
+#include "program/program.h"
 
 #define MESA_DEBUG_ATI_FS 0
 
@@ -63,6 +64,7 @@ _mesa_delete_ati_fragment_shader(struct gl_context *ctx, 
struct ati_fragment_sha
   free(s->Instructions[i]);
   free(s->SetupInst[i]);
}
+   _mesa_reference_program(ctx, &s->Program, NULL);
free(s);
 }
 
@@ -321,6 +323,8 @@ _mesa_BeginFragmentShaderATI(void)
  free(ctx->ATIFragmentShader.Current->SetupInst[i]);
}
 
+   _mesa_reference_program(ctx, &ctx->ATIFragmentShader.Current->Program, 
NULL);
+
/* malloc the instructions here - not sure if the best place but its
   a start */
for (i = 0; i < MAX_NUM_PASSES_ATI; i++) {
@@ -405,7 +409,14 @@ _mesa_EndFragmentShaderATI(void)
}
 #endif
 
-   if (!ctx->Driver.ProgramStringNotify(ctx, GL_FRAGMENT_SHADER_ATI, NULL)) {
+   if (ctx->Driver.NewATIfs) {
+  struct gl_program *prog = ctx->Driver.NewATIfs(ctx,
+ctx->ATIFragmentShader.Current);
+  _mesa_reference_program(ctx, &ctx->ATIFragmentShader.Current->Program, 
prog);
+   }
+
+   if (!ctx->Driver.ProgramStringNotify(ctx, GL_FRAGMENT_SHADER_ATI,
+curProg->Program)) {
   ctx->ATIFragmentShader.Current->isValid = GL_FALSE;
   /* XXX is this the right error? */
   _mesa_error(ctx, GL_INVALID_OPERATION,
diff --git a/src/mesa/main/dd.h b/src/mesa/main/dd.h
index 19ef304..0bdef9c 100644
--- a/src/mesa/main/dd.h
+++ b/src/mesa/main/dd.h
@@ -464,7 +464,12 @@ struct dd_function_table {
struct gl_program * (*NewProgram)(struct gl_context *ctx, GLenum target,
  GLuint id);
/** Delete a program */
-   void (*DeleteProgram)(struct gl_context *ctx, struct gl_program *prog);   
+   void (*DeleteProgram)(struct gl_context *ctx, struct gl_program *prog);
+   /**
+* Allocate a program to associate with the new ATI fragment shader 
(optional)
+*/
+   struct gl_program * (*NewATIfs)(struct gl_context *ctx,
+ struct ati_fragment_shader *curProg);
/**
 * Notify driver that a program string (and GPU code) has been specified
 * or modified.  Return GL_TRUE or GL_FALSE to indicate if the program is
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index e987177..4d29d6a 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -2189,6 +2189,7 @@ struct ati_fragment_shader
GLboolean interpinp1;
GLboolean isValid;
GLuint swizzlerq;
+   struct gl_program *Program;
 };
 
 /**
diff --git a/src/mesa/main/state.c b/src/mesa/main/state.c
index 57f1341..bc48d5a 100644
--- a/src/mesa/main/state.c
+++ b/src/mesa/main/state.c
@@ -124,7 +124,8 @@ update_program(struct gl_context *ctx)
 * follows:
 *   1. OpenGL 2.0/ARB vertex/fragment shaders
 *   2. ARB/NV vertex/fragment programs
-*   3. Programs derived from fixed-function state.
+*   3. ATI fragment shader
+*   4. Programs derived from fixed-function state.
 *
 * Note: it's possible for a vertex shader to get used with a fragment
 * program (and vice versa) here, but in practice that shouldn't ever
@@ -152,6 +153,17 @@ update_program(struct gl_context *ctx)
   _mesa_reference_fragprog(ctx, &ctx->FragmentProgram._TexEnvProgram,
   NULL);
}
+   else if (ctx->ATIFragmentShader._Enabled
+&& ctx->ATIFragmentShader.Current->Program) {
+   /* Use the enabled ATI fragment shader's associated program */
+  _mesa_reference_shader_program(ctx,
+ &ctx->_Shader->_CurrentFragmentProgram,
+NULL);
+  _mesa_reference_fragprog(ctx, &ctx->FragmentProgram._Current,
+   
gl_fragment_program(ctx->ATIFragmentShader.Current->Program));
+  _mesa_reference_fragprog(ctx, &ctx->FragmentProgram._TexEnvProg

[Mesa-dev] [PATCH 7/7] mesa: optimize out the realloc from glCopyTexImagexD()

2016-02-05 Thread Miklós Máté
v2: comment about the purpose of the code
---
 src/mesa/main/teximage.c | 32 
 1 file changed, 32 insertions(+)

diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
index 50141be..cac05d5 100644
--- a/src/mesa/main/teximage.c
+++ b/src/mesa/main/teximage.c
@@ -3486,6 +3486,21 @@ formats_differ_in_component_sizes(mesa_format f1, 
mesa_format f2)
return GL_FALSE;
 }
 
+static GLboolean
+canAvoidRealloc(struct gl_texture_image *texImage, GLenum internalFormat,
+  GLint x, GLint y, GLsizei width, GLsizei height, GLint border)
+{
+   if (texImage->InternalFormat != internalFormat)
+  return false;
+   if (texImage->Border != border)
+  return false;
+   if (texImage->Width2 != width)
+  return false;
+   if (texImage->Height2 != height)
+  return false;
+   return true;
+}
+
 /**
  * Implement the glCopyTexImage1/2D() functions.
  */
@@ -3526,6 +3541,23 @@ copyteximage(struct gl_context *ctx, GLuint dims,
texObj = _mesa_get_current_tex_object(ctx, target);
assert(texObj);
 
+   /* First check if reallocating the texture buffer can be avoided.
+* Without the realloc the copy can be 20x faster.
+*/
+   _mesa_lock_texture(ctx, texObj);
+   {
+  texImage = _mesa_select_tex_image(texObj, target, level);
+  if (texImage && canAvoidRealloc(texImage, internalFormat,
+   x, y, width, height, border)) {
+ _mesa_unlock_texture(ctx, texObj);
+ /*_mesa_debug(ctx, "using shortcut\n");*/
+ return _mesa_copy_texture_sub_image(ctx, dims, texObj, target, level,
+   0, 0, 0, x, y, width, height, "CopyTexImage");
+  }
+  /*_mesa_debug(ctx, "can't shortcut\n");*/
+   }
+   _mesa_unlock_texture(ctx, texObj);
+
texFormat = _mesa_choose_texture_format(ctx, texObj, target, level,
internalFormat, GL_NONE, GL_NONE);
 
-- 
2.7.0

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


[Mesa-dev] [PATCH 07/11] i965/meta: Use internal functions for renderbuffer access

2016-02-05 Thread Ian Romanick
From: Ian Romanick 

Signed-off-by: Ian Romanick 
---
 src/mesa/drivers/dri/i965/brw_meta_fast_clear.c   | 5 ++---
 src/mesa/drivers/dri/i965/brw_meta_stencil_blit.c | 8 
 src/mesa/drivers/dri/i965/brw_meta_updownsample.c | 6 ++
 3 files changed, 8 insertions(+), 11 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_meta_fast_clear.c 
b/src/mesa/drivers/dri/i965/brw_meta_fast_clear.c
index 51dbd00..38a505a 100644
--- a/src/mesa/drivers/dri/i965/brw_meta_fast_clear.c
+++ b/src/mesa/drivers/dri/i965/brw_meta_fast_clear.c
@@ -857,9 +857,8 @@ brw_meta_resolve_color(struct brw_context *brw,
rb = brw_get_rb_for_slice(brw, mt, 0, 0, false);
 
_mesa_BindFramebuffer(GL_DRAW_FRAMEBUFFER, fbo);
-   _mesa_FramebufferRenderbuffer(GL_DRAW_FRAMEBUFFER,
- GL_COLOR_ATTACHMENT0,
- GL_RENDERBUFFER, rb->Name);
+   _mesa_framebuffer_renderbuffer(ctx, ctx->DrawBuffer, GL_COLOR_ATTACHMENT0,
+  rb);
_mesa_DrawBuffer(GL_COLOR_ATTACHMENT0);
 
brw_fast_clear_init(brw);
diff --git a/src/mesa/drivers/dri/i965/brw_meta_stencil_blit.c 
b/src/mesa/drivers/dri/i965/brw_meta_stencil_blit.c
index 4f3f7db..16412ad 100644
--- a/src/mesa/drivers/dri/i965/brw_meta_stencil_blit.c
+++ b/src/mesa/drivers/dri/i965/brw_meta_stencil_blit.c
@@ -442,8 +442,8 @@ brw_meta_stencil_blit(struct brw_context *brw,
adjust_tiling(&dims, dst_mt->num_samples);
 
_mesa_BindFramebuffer(GL_DRAW_FRAMEBUFFER, fbo);
-   _mesa_FramebufferRenderbuffer(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
- GL_RENDERBUFFER, rb->Name);
+   _mesa_framebuffer_renderbuffer(ctx, ctx->DrawBuffer, GL_COLOR_ATTACHMENT0,
+  rb);
_mesa_DrawBuffer(GL_COLOR_ATTACHMENT0);
ctx->DrawBuffer->_Status = GL_FRAMEBUFFER_COMPLETE;
 
@@ -546,8 +546,8 @@ brw_meta_stencil_updownsample(struct brw_context *brw,
rb = brw_get_rb_for_slice(brw, src, 0, 0, false);
 
_mesa_BindFramebuffer(GL_READ_FRAMEBUFFER, fbo);
-   _mesa_FramebufferRenderbuffer(GL_READ_FRAMEBUFFER, GL_STENCIL_ATTACHMENT,
- GL_RENDERBUFFER, rb->Name);
+   _mesa_framebuffer_renderbuffer(ctx, ctx->ReadBuffer, GL_STENCIL_ATTACHMENT,
+  rb);
 
brw_meta_stencil_blit(brw, dst, 0, 0, &dims);
brw_emit_mi_flush(brw);
diff --git a/src/mesa/drivers/dri/i965/brw_meta_updownsample.c 
b/src/mesa/drivers/dri/i965/brw_meta_updownsample.c
index c1631ae..149f4bc 100644
--- a/src/mesa/drivers/dri/i965/brw_meta_updownsample.c
+++ b/src/mesa/drivers/dri/i965/brw_meta_updownsample.c
@@ -127,13 +127,11 @@ brw_meta_updownsample(struct brw_context *brw,
dst_fbo = fbos[1];
 
_mesa_BindFramebuffer(GL_READ_FRAMEBUFFER, src_fbo);
-   _mesa_FramebufferRenderbuffer(GL_READ_FRAMEBUFFER, attachment,
- GL_RENDERBUFFER, src_rb->Name);
+   _mesa_framebuffer_renderbuffer(ctx, ctx->ReadBuffer, attachment, src_rb);
_mesa_ReadBuffer(drawbuffer);
 
_mesa_BindFramebuffer(GL_DRAW_FRAMEBUFFER, dst_fbo);
-   _mesa_FramebufferRenderbuffer(GL_DRAW_FRAMEBUFFER, attachment,
- GL_RENDERBUFFER, dst_rb->Name);
+   _mesa_framebuffer_renderbuffer(ctx, ctx->DrawBuffer, attachment, dst_rb);
_mesa_DrawBuffer(drawbuffer);
 
_mesa_BlitFramebuffer(0, 0,
-- 
2.5.0

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


[Mesa-dev] [PATCH 06/11] i965/meta: Return struct gl_renderbuffer* from brw_get_rb_for_slice instead of GL API handle

2016-02-05 Thread Ian Romanick
From: Ian Romanick 

Signed-off-by: Ian Romanick 
---
 src/mesa/drivers/dri/i965/brw_context.h   |  7 ---
 src/mesa/drivers/dri/i965/brw_meta_fast_clear.c   |  9 +
 src/mesa/drivers/dri/i965/brw_meta_stencil_blit.c | 18 ++
 src/mesa/drivers/dri/i965/brw_meta_updownsample.c | 20 +++-
 4 files changed, 30 insertions(+), 24 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_context.h 
b/src/mesa/drivers/dri/i965/brw_context.h
index 55d6723..1bcd7b0 100644
--- a/src/mesa/drivers/dri/i965/brw_context.h
+++ b/src/mesa/drivers/dri/i965/brw_context.h
@@ -1368,9 +1368,10 @@ GLboolean brwCreateContext(gl_api api,
 /*==
  * brw_misc_state.c
  */
-GLuint brw_get_rb_for_slice(struct brw_context *brw,
-struct intel_mipmap_tree *mt,
-unsigned level, unsigned layer, bool flat);
+struct gl_renderbuffer *brw_get_rb_for_slice(struct brw_context *brw,
+ struct intel_mipmap_tree *mt,
+ unsigned level, unsigned layer,
+ bool flat);
 
 void brw_meta_updownsample(struct brw_context *brw,
struct intel_mipmap_tree *src,
diff --git a/src/mesa/drivers/dri/i965/brw_meta_fast_clear.c 
b/src/mesa/drivers/dri/i965/brw_meta_fast_clear.c
index 735d824..51dbd00 100644
--- a/src/mesa/drivers/dri/i965/brw_meta_fast_clear.c
+++ b/src/mesa/drivers/dri/i965/brw_meta_fast_clear.c
@@ -845,7 +845,8 @@ brw_meta_resolve_color(struct brw_context *brw,
struct intel_mipmap_tree *mt)
 {
struct gl_context *ctx = &brw->ctx;
-   GLuint fbo, rbo;
+   GLuint fbo;
+   struct gl_renderbuffer *rb;
struct rect rect;
 
brw_emit_mi_flush(brw);
@@ -853,12 +854,12 @@ brw_meta_resolve_color(struct brw_context *brw,
_mesa_meta_begin(ctx, MESA_META_ALL);
 
_mesa_GenFramebuffers(1, &fbo);
-   rbo = brw_get_rb_for_slice(brw, mt, 0, 0, false);
+   rb = brw_get_rb_for_slice(brw, mt, 0, 0, false);
 
_mesa_BindFramebuffer(GL_DRAW_FRAMEBUFFER, fbo);
_mesa_FramebufferRenderbuffer(GL_DRAW_FRAMEBUFFER,
  GL_COLOR_ATTACHMENT0,
- GL_RENDERBUFFER, rbo);
+ GL_RENDERBUFFER, rb->Name);
_mesa_DrawBuffer(GL_COLOR_ATTACHMENT0);
 
brw_fast_clear_init(brw);
@@ -881,7 +882,7 @@ brw_meta_resolve_color(struct brw_context *brw,
set_fast_clear_op(brw, 0);
use_rectlist(brw, false);
 
-   _mesa_DeleteRenderbuffers(1, &rbo);
+   _mesa_DeleteRenderbuffers(1, &rb->Name);
_mesa_DeleteFramebuffers(1, &fbo);
 
_mesa_meta_end(ctx);
diff --git a/src/mesa/drivers/dri/i965/brw_meta_stencil_blit.c 
b/src/mesa/drivers/dri/i965/brw_meta_stencil_blit.c
index c5f6c4f..4f3f7db 100644
--- a/src/mesa/drivers/dri/i965/brw_meta_stencil_blit.c
+++ b/src/mesa/drivers/dri/i965/brw_meta_stencil_blit.c
@@ -423,7 +423,8 @@ brw_meta_stencil_blit(struct brw_context *brw,
struct gl_context *ctx = &brw->ctx;
struct blit_dims dims = *orig_dims;
struct fb_tex_blit_state blit;
-   GLuint prog, fbo, rbo;
+   GLuint prog, fbo;
+   struct gl_renderbuffer *rb;
GLenum target;
 
_mesa_meta_fb_tex_blit_begin(ctx, &blit);
@@ -436,13 +437,13 @@ brw_meta_stencil_blit(struct brw_context *brw,
 
_mesa_GenFramebuffers(1, &fbo);
/* Force the surface to be configured for level zero. */
-   rbo = brw_get_rb_for_slice(brw, dst_mt, 0, dst_layer, true);
+   rb = brw_get_rb_for_slice(brw, dst_mt, 0, dst_layer, true);
adjust_msaa(&dims, dst_mt->num_samples);
adjust_tiling(&dims, dst_mt->num_samples);
 
_mesa_BindFramebuffer(GL_DRAW_FRAMEBUFFER, fbo);
_mesa_FramebufferRenderbuffer(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
- GL_RENDERBUFFER, rbo);
+ GL_RENDERBUFFER, rb->Name);
_mesa_DrawBuffer(GL_COLOR_ATTACHMENT0);
ctx->DrawBuffer->_Status = GL_FRAMEBUFFER_COMPLETE;
 
@@ -474,7 +475,7 @@ error:
_mesa_meta_fb_tex_blit_end(ctx, target, &blit);
_mesa_meta_end(ctx);
 
-   _mesa_DeleteRenderbuffers(1, &rbo);
+   _mesa_DeleteRenderbuffers(1, &rb->Name);
_mesa_DeleteFramebuffers(1, &fbo);
 }
 
@@ -532,7 +533,8 @@ brw_meta_stencil_updownsample(struct brw_context *brw,
   .dst_x0 = 0, .dst_y0 = 0,
   .dst_x1 = dst->logical_width0, .dst_y1 = dst->logical_height0,
   .mirror_x = 0, .mirror_y = 0 };
-   GLuint fbo, rbo;
+   GLuint fbo;
+   struct gl_renderbuffer *rb;
 
if (dst->stencil_mt)
   dst = dst->stencil_mt;
@@ -541,15 +543,15 @@ brw_meta_stencil_updownsample(struct brw_context *brw,
_mesa_meta_begin(ctx, MESA_META_ALL);
 
_mesa_GenFramebuffers(1, &fbo);
-   rbo = brw_get_rb_for_slice(brw, src, 0, 0, false);
+   rb = brw_get_rb_for_slice(brw, src, 0, 0, false);
 
_mesa_BindFramebuffer(GL_READ_F

[Mesa-dev] [PATCH 02/11] mesa: Refactor renderbuffer_storage to make _mesa_renderbuffer_storage

2016-02-05 Thread Ian Romanick
From: Ian Romanick 

Pulls the parts of renderbuffer_storage that aren't just parameter
validation out into a function that can be called from other parts of
Mesa (e.g., meta).

Signed-off-by: Ian Romanick 
---
 src/mesa/main/fbobject.c | 97 +---
 src/mesa/main/fbobject.h |  5 +++
 2 files changed, 63 insertions(+), 39 deletions(-)

diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
index 0b0653d..1b9b692 100644
--- a/src/mesa/main/fbobject.c
+++ b/src/mesa/main/fbobject.c
@@ -2008,6 +2008,63 @@ invalidate_rb(GLuint key, void *data, void *userData)
 /** sentinal value, see below */
 #define NO_SAMPLES 1000
 
+void
+_mesa_renderbuffer_storage(struct gl_context *ctx, struct gl_renderbuffer *rb,
+   GLenum internalFormat, GLsizei width,
+   GLsizei height, GLsizei samples)
+{
+   const GLenum baseFormat = _mesa_base_fbo_format(ctx, internalFormat);
+
+   assert(baseFormat != 0);
+   assert(width >= 0 && width <= (GLsizei) ctx->Const.MaxRenderbufferSize);
+   assert(height >= 0 && height <= (GLsizei) ctx->Const.MaxRenderbufferSize);
+   assert(samples != NO_SAMPLES);
+   if (samples != 0) {
+  assert(samples > 0);
+  assert(_mesa_check_sample_count(ctx, GL_RENDERBUFFER,
+  internalFormat, samples) == GL_NO_ERROR);
+   }
+
+   FLUSH_VERTICES(ctx, _NEW_BUFFERS);
+
+   if (rb->InternalFormat == internalFormat &&
+   rb->Width == (GLuint) width &&
+   rb->Height == (GLuint) height &&
+   rb->NumSamples == samples) {
+  /* no change in allocation needed */
+  return;
+   }
+
+   /* These MUST get set by the AllocStorage func */
+   rb->Format = MESA_FORMAT_NONE;
+   rb->NumSamples = samples;
+
+   /* Now allocate the storage */
+   assert(rb->AllocStorage);
+   if (rb->AllocStorage(ctx, rb, internalFormat, width, height)) {
+  /* No error - check/set fields now */
+  /* If rb->Format == MESA_FORMAT_NONE, the format is unsupported. */
+  assert(rb->Width == (GLuint) width);
+  assert(rb->Height == (GLuint) height);
+  rb->InternalFormat = internalFormat;
+  rb->_BaseFormat = baseFormat;
+  assert(rb->_BaseFormat != 0);
+   }
+   else {
+  /* Probably ran out of memory - clear the fields */
+  rb->Width = 0;
+  rb->Height = 0;
+  rb->Format = MESA_FORMAT_NONE;
+  rb->InternalFormat = GL_NONE;
+  rb->_BaseFormat = GL_NONE;
+  rb->NumSamples = 0;
+   }
+
+   /* Invalidate the framebuffers the renderbuffer is attached in. */
+   if (rb->AttachedAnytime) {
+  _mesa_HashWalk(ctx->Shared->FrameBuffers, invalidate_rb, rb);
+   }
+}
 
 /**
  * Helper function used by renderbuffer_storage_direct() and
@@ -2067,45 +2124,7 @@ renderbuffer_storage(struct gl_context *ctx, struct 
gl_renderbuffer *rb,
   }
}
 
-   FLUSH_VERTICES(ctx, _NEW_BUFFERS);
-
-   if (rb->InternalFormat == internalFormat &&
-   rb->Width == (GLuint) width &&
-   rb->Height == (GLuint) height &&
-   rb->NumSamples == samples) {
-  /* no change in allocation needed */
-  return;
-   }
-
-   /* These MUST get set by the AllocStorage func */
-   rb->Format = MESA_FORMAT_NONE;
-   rb->NumSamples = samples;
-
-   /* Now allocate the storage */
-   assert(rb->AllocStorage);
-   if (rb->AllocStorage(ctx, rb, internalFormat, width, height)) {
-  /* No error - check/set fields now */
-  /* If rb->Format == MESA_FORMAT_NONE, the format is unsupported. */
-  assert(rb->Width == (GLuint) width);
-  assert(rb->Height == (GLuint) height);
-  rb->InternalFormat = internalFormat;
-  rb->_BaseFormat = baseFormat;
-  assert(rb->_BaseFormat != 0);
-   }
-   else {
-  /* Probably ran out of memory - clear the fields */
-  rb->Width = 0;
-  rb->Height = 0;
-  rb->Format = MESA_FORMAT_NONE;
-  rb->InternalFormat = GL_NONE;
-  rb->_BaseFormat = GL_NONE;
-  rb->NumSamples = 0;
-   }
-
-   /* Invalidate the framebuffers the renderbuffer is attached in. */
-   if (rb->AttachedAnytime) {
-  _mesa_HashWalk(ctx->Shared->FrameBuffers, invalidate_rb, rb);
-   }
+   _mesa_renderbuffer_storage(ctx, rb, internalFormat, width, height, samples);
 }
 
 /**
diff --git a/src/mesa/main/fbobject.h b/src/mesa/main/fbobject.h
index 458e440..f9a6060 100644
--- a/src/mesa/main/fbobject.h
+++ b/src/mesa/main/fbobject.h
@@ -94,6 +94,11 @@ _mesa_framebuffer_renderbuffer(struct gl_context *ctx,
struct gl_renderbuffer *rb);
 
 extern void
+_mesa_renderbuffer_storage(struct gl_context *ctx, struct gl_renderbuffer *rb,
+   GLenum internalFormat, GLsizei width,
+   GLsizei height, GLsizei samples);
+
+extern void
 _mesa_validate_framebuffer(struct gl_context *ctx, struct gl_framebuffer *fb);
 
 extern GLboolean
-- 
2.5.0

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.or

[Mesa-dev] [PATCH 09/11] meta/decompress: Track renderbuffer using gl_renderbuffer instead of GL API object handle

2016-02-05 Thread Ian Romanick
From: Ian Romanick 

Signed-off-by: Ian Romanick 
---
 src/mesa/drivers/common/meta.c | 13 +
 src/mesa/drivers/common/meta.h |  3 ++-
 2 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c
index b42a3cf..217d376 100644
--- a/src/mesa/drivers/common/meta.c
+++ b/src/mesa/drivers/common/meta.c
@@ -2962,7 +2962,7 @@ meta_decompress_fbo_cleanup(struct decompress_fbo_state 
*decompress_fbo)
 {
if (decompress_fbo->FBO != 0) {
   _mesa_DeleteFramebuffers(1, &decompress_fbo->FBO);
-  _mesa_DeleteRenderbuffers(1, &decompress_fbo->RBO);
+  _mesa_DeleteRenderbuffers(1, &decompress_fbo->rb->Name);
}
 
memset(decompress_fbo, 0, sizeof(*decompress_fbo));
@@ -3065,14 +3065,19 @@ decompress_texture_image(struct gl_context *ctx,
 
/* Create/bind FBO/renderbuffer */
if (decompress_fbo->FBO == 0) {
-  _mesa_CreateRenderbuffers(1, &decompress_fbo->RBO);
+  GLuint RBO;
+
+  _mesa_CreateRenderbuffers(1, &RBO);
+
+  decompress_fbo->rb = _mesa_lookup_renderbuffer(ctx, RBO);
+  assert(decompress_fbo->rb != NULL && decompress_fbo->rb->Name == RBO);
 
   _mesa_GenFramebuffers(1, &decompress_fbo->FBO);
   _mesa_BindFramebuffer(GL_FRAMEBUFFER_EXT, decompress_fbo->FBO);
   _mesa_FramebufferRenderbuffer(GL_FRAMEBUFFER_EXT,
GL_COLOR_ATTACHMENT0_EXT,
GL_RENDERBUFFER_EXT,
-   decompress_fbo->RBO);
+   decompress_fbo->rb->Name);
}
else {
   _mesa_BindFramebuffer(GL_FRAMEBUFFER_EXT, decompress_fbo->FBO);
@@ -3080,7 +3085,7 @@ decompress_texture_image(struct gl_context *ctx,
 
/* alloc dest surface */
if (width > decompress_fbo->Width || height > decompress_fbo->Height) {
-  _mesa_NamedRenderbufferStorage(decompress_fbo->RBO, rbFormat,
+  _mesa_NamedRenderbufferStorage(decompress_fbo->rb->Name, rbFormat,
  width, height);
   status = _mesa_CheckFramebufferStatus(GL_DRAW_FRAMEBUFFER);
   if (status != GL_FRAMEBUFFER_COMPLETE) {
diff --git a/src/mesa/drivers/common/meta.h b/src/mesa/drivers/common/meta.h
index 3ff0fdd..7a120b6 100644
--- a/src/mesa/drivers/common/meta.h
+++ b/src/mesa/drivers/common/meta.h
@@ -380,7 +380,8 @@ struct gen_mipmap_state
  */
 struct decompress_fbo_state
 {
-   GLuint FBO, RBO;
+   struct gl_renderbuffer *rb;
+   GLuint FBO;
GLint Width, Height;
 };
 
-- 
2.5.0

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


[Mesa-dev] [PATCH 04/11] meta: Use _mesa_CreateRenderbuffers instead of _mesa_GenRenderbuffers and _mesa_BindRenderbuffer

2016-02-05 Thread Ian Romanick
From: Ian Romanick 

This has the advantage that it does not pollute the global binding
state.  It also enables later patches that will stop calling
_mesa_GenRenderbuffers / _mesa_CreateRenderbuffers which pollute the
renderbuffer namespace.

Signed-off-by: Ian Romanick 
---
 src/mesa/drivers/common/meta.c | 9 -
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c
index 5f2e796..26867d3 100644
--- a/src/mesa/drivers/common/meta.c
+++ b/src/mesa/drivers/common/meta.c
@@ -3071,10 +3071,10 @@ decompress_texture_image(struct gl_context *ctx,
 
/* Create/bind FBO/renderbuffer */
if (decompress_fbo->FBO == 0) {
+  _mesa_CreateRenderbuffers(1, &decompress_fbo->RBO);
+
   _mesa_GenFramebuffers(1, &decompress_fbo->FBO);
-  _mesa_GenRenderbuffers(1, &decompress_fbo->RBO);
   _mesa_BindFramebuffer(GL_FRAMEBUFFER_EXT, decompress_fbo->FBO);
-  _mesa_BindRenderbuffer(GL_RENDERBUFFER_EXT, decompress_fbo->RBO);
   _mesa_FramebufferRenderbuffer(GL_FRAMEBUFFER_EXT,
GL_COLOR_ATTACHMENT0_EXT,
GL_RENDERBUFFER_EXT,
@@ -3086,9 +3086,8 @@ decompress_texture_image(struct gl_context *ctx,
 
/* alloc dest surface */
if (width > decompress_fbo->Width || height > decompress_fbo->Height) {
-  _mesa_BindRenderbuffer(GL_RENDERBUFFER_EXT, decompress_fbo->RBO);
-  _mesa_RenderbufferStorage(GL_RENDERBUFFER_EXT, rbFormat,
-width, height);
+  _mesa_NamedRenderbufferStorage(decompress_fbo->RBO, rbFormat,
+ width, height);
   status = _mesa_CheckFramebufferStatus(GL_DRAW_FRAMEBUFFER);
   if (status != GL_FRAMEBUFFER_COMPLETE) {
  /* If the framebuffer isn't complete then we'll leave
-- 
2.5.0

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


[Mesa-dev] [PATCH 08/11] i965/meta: Don't pollute the renderbuffer namespace

2016-02-05 Thread Ian Romanick
From: Ian Romanick 

tl;dr: For many types of GL object, we can *NEVER* use the Gen function.

In OpenGL ES (all versions!) and OpenGL compatibility profile,
applications don't have to call Gen functions.  The GL spec is very
clear about how you can mix-and-match generated names and non-generated
names: you can use any name you want for a particular object type until
you call the Gen function for that object type.

Here's the problem scenario:

 - Application calls a meta function that generates a name.  The first
   Gen will probably return 1.

 - Application decides to use the same name for an object of the same
   type without calling Gen.  Many demo programs use names 1, 2, 3,
   etc. without calling Gen.

 - Application calls the meta function again, and the meta function
   replaces the data.  The application's data is lost, and the app
   fails.  Have fun debugging that.

Signed-off-by: Ian Romanick 
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=92363
---
 src/mesa/drivers/dri/i965/brw_meta_fast_clear.c   |  3 ++-
 src/mesa/drivers/dri/i965/brw_meta_stencil_blit.c |  5 +++--
 src/mesa/drivers/dri/i965/brw_meta_updownsample.c | 19 ++-
 3 files changed, 11 insertions(+), 16 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_meta_fast_clear.c 
b/src/mesa/drivers/dri/i965/brw_meta_fast_clear.c
index 38a505a..b2b07e7 100644
--- a/src/mesa/drivers/dri/i965/brw_meta_fast_clear.c
+++ b/src/mesa/drivers/dri/i965/brw_meta_fast_clear.c
@@ -36,6 +36,7 @@
 #include "main/varray.h"
 #include "main/uniforms.h"
 #include "main/fbobject.h"
+#include "main/renderbuffer.h"
 #include "main/texobj.h"
 
 #include "main/api_validate.h"
@@ -881,7 +882,7 @@ brw_meta_resolve_color(struct brw_context *brw,
set_fast_clear_op(brw, 0);
use_rectlist(brw, false);
 
-   _mesa_DeleteRenderbuffers(1, &rb->Name);
+   _mesa_reference_renderbuffer(&rb, NULL);
_mesa_DeleteFramebuffers(1, &fbo);
 
_mesa_meta_end(ctx);
diff --git a/src/mesa/drivers/dri/i965/brw_meta_stencil_blit.c 
b/src/mesa/drivers/dri/i965/brw_meta_stencil_blit.c
index 16412ad..5cfaec6 100644
--- a/src/mesa/drivers/dri/i965/brw_meta_stencil_blit.c
+++ b/src/mesa/drivers/dri/i965/brw_meta_stencil_blit.c
@@ -57,6 +57,7 @@
 #include "main/blend.h"
 #include "main/varray.h"
 #include "main/shaderapi.h"
+#include "main/renderbuffer.h"
 #include "util/ralloc.h"
 
 #include "drivers/common/meta.h"
@@ -475,7 +476,7 @@ error:
_mesa_meta_fb_tex_blit_end(ctx, target, &blit);
_mesa_meta_end(ctx);
 
-   _mesa_DeleteRenderbuffers(1, &rb->Name);
+   _mesa_reference_renderbuffer(&rb, NULL);
_mesa_DeleteFramebuffers(1, &fbo);
 }
 
@@ -552,6 +553,6 @@ brw_meta_stencil_updownsample(struct brw_context *brw,
brw_meta_stencil_blit(brw, dst, 0, 0, &dims);
brw_emit_mi_flush(brw);
 
-   _mesa_DeleteRenderbuffers(1, &rb->Name);
+   _mesa_reference_renderbuffer(&rb, NULL);
_mesa_DeleteFramebuffers(1, &fbo);
 }
diff --git a/src/mesa/drivers/dri/i965/brw_meta_updownsample.c 
b/src/mesa/drivers/dri/i965/brw_meta_updownsample.c
index 149f4bc..e90e6b1 100644
--- a/src/mesa/drivers/dri/i965/brw_meta_updownsample.c
+++ b/src/mesa/drivers/dri/i965/brw_meta_updownsample.c
@@ -29,6 +29,7 @@
 #include "main/buffers.h"
 #include "main/enums.h"
 #include "main/fbobject.h"
+#include "main/renderbuffer.h"
 
 #include "drivers/common/meta.h"
 
@@ -51,18 +52,10 @@ brw_get_rb_for_slice(struct brw_context *brw,
  unsigned level, unsigned layer, bool flat)
 {
struct gl_context *ctx = &brw->ctx;
-   GLuint rbo;
-   struct gl_renderbuffer *rb;
-   struct intel_renderbuffer *irb;
-
-   /* This turns the CreateRenderbuffers name into an actual struct
-* intel_renderbuffer.
-*/
-   _mesa_CreateRenderbuffers(1, &rbo);
-
-   rb = _mesa_lookup_renderbuffer(ctx, rbo);
-   irb = intel_renderbuffer(rb);
+   struct gl_renderbuffer *rb = ctx->Driver.NewRenderbuffer(ctx, 0xDEADBEEF);
+   struct intel_renderbuffer *irb = intel_renderbuffer(rb);
 
+   rb->RefCount = 1;
rb->Format = mt->format;
rb->_BaseFormat = _mesa_get_format_base_format(mt->format);
 
@@ -140,8 +133,8 @@ brw_meta_updownsample(struct brw_context *brw,
  dst_mt->logical_width0, dst_mt->logical_height0,
  blit_bit, GL_NEAREST);
 
-   _mesa_DeleteRenderbuffers(1, &src_rb->Name);
-   _mesa_DeleteRenderbuffers(1, &dst_rb->Name);
+   _mesa_reference_renderbuffer(&src_rb, NULL);
+   _mesa_reference_renderbuffer(&dst_rb, NULL);
_mesa_DeleteFramebuffers(2, fbos);
 
_mesa_meta_end(ctx);
-- 
2.5.0

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


[Mesa-dev] [PATCH 11/11] meta/decompress: Don't pollute the renderbuffer namespace

2016-02-05 Thread Ian Romanick
From: Ian Romanick 

tl;dr: For many types of GL object, we can *NEVER* use the Gen function.

In OpenGL ES (all versions!) and OpenGL compatibility profile,
applications don't have to call Gen functions.  The GL spec is very
clear about how you can mix-and-match generated names and non-generated
names: you can use any name you want for a particular object type until
you call the Gen function for that object type.

Here's the problem scenario:

 - Application calls a meta function that generates a name.  The first
   Gen will probably return 1.

 - Application decides to use the same name for an object of the same
   type without calling Gen.  Many demo programs use names 1, 2, 3,
   etc. without calling Gen.

 - Application calls the meta function again, and the meta function
   replaces the data.  The application's data is lost, and the app
   fails.  Have fun debugging that.

Fixes piglit 'object-namespace-pollution glGetTexImage-compressed
renderbuffer' test.

Signed-off-by: Ian Romanick 
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=92363
---
 src/mesa/drivers/common/meta.c | 14 --
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c
index 9fc7bc6..329e48f 100644
--- a/src/mesa/drivers/common/meta.c
+++ b/src/mesa/drivers/common/meta.c
@@ -61,6 +61,7 @@
 #include "main/polygon.h"
 #include "main/queryobj.h"
 #include "main/readpix.h"
+#include "main/renderbuffer.h"
 #include "main/scissor.h"
 #include "main/shaderapi.h"
 #include "main/shaderobj.h"
@@ -2962,7 +2963,7 @@ meta_decompress_fbo_cleanup(struct decompress_fbo_state 
*decompress_fbo)
 {
if (decompress_fbo->FBO != 0) {
   _mesa_DeleteFramebuffers(1, &decompress_fbo->FBO);
-  _mesa_DeleteRenderbuffers(1, &decompress_fbo->rb->Name);
+  _mesa_reference_renderbuffer(&decompress_fbo->rb, NULL);
}
 
memset(decompress_fbo, 0, sizeof(*decompress_fbo));
@@ -3065,12 +3066,13 @@ decompress_texture_image(struct gl_context *ctx,
 
/* Create/bind FBO/renderbuffer */
if (decompress_fbo->FBO == 0) {
-  GLuint RBO;
-
-  _mesa_CreateRenderbuffers(1, &RBO);
+  decompress_fbo->rb = ctx->Driver.NewRenderbuffer(ctx, 0xDEADBEEF);
+  if (decompress_fbo->rb == NULL) {
+ _mesa_meta_end(ctx);
+ return false;
+  }
 
-  decompress_fbo->rb = _mesa_lookup_renderbuffer(ctx, RBO);
-  assert(decompress_fbo->rb != NULL && decompress_fbo->rb->Name == RBO);
+  decompress_fbo->rb->RefCount = 1;
 
   _mesa_GenFramebuffers(1, &decompress_fbo->FBO);
   _mesa_BindFramebuffer(GL_FRAMEBUFFER_EXT, decompress_fbo->FBO);
-- 
2.5.0

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


[Mesa-dev] [PATCH 10/11] meta: Use internal functions for renderbuffer access

2016-02-05 Thread Ian Romanick
From: Ian Romanick 

Signed-off-by: Ian Romanick 
---
 src/mesa/drivers/common/meta.c| 10 --
 src/mesa/drivers/common/meta_copy_image.c | 12 
 2 files changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c
index 217d376..9fc7bc6 100644
--- a/src/mesa/drivers/common/meta.c
+++ b/src/mesa/drivers/common/meta.c
@@ -3074,10 +3074,8 @@ decompress_texture_image(struct gl_context *ctx,
 
   _mesa_GenFramebuffers(1, &decompress_fbo->FBO);
   _mesa_BindFramebuffer(GL_FRAMEBUFFER_EXT, decompress_fbo->FBO);
-  _mesa_FramebufferRenderbuffer(GL_FRAMEBUFFER_EXT,
-   GL_COLOR_ATTACHMENT0_EXT,
-   GL_RENDERBUFFER_EXT,
-   decompress_fbo->rb->Name);
+  _mesa_framebuffer_renderbuffer(ctx, ctx->DrawBuffer, 
GL_COLOR_ATTACHMENT0,
+ decompress_fbo->rb);
}
else {
   _mesa_BindFramebuffer(GL_FRAMEBUFFER_EXT, decompress_fbo->FBO);
@@ -3085,8 +3083,8 @@ decompress_texture_image(struct gl_context *ctx,
 
/* alloc dest surface */
if (width > decompress_fbo->Width || height > decompress_fbo->Height) {
-  _mesa_NamedRenderbufferStorage(decompress_fbo->rb->Name, rbFormat,
- width, height);
+  _mesa_renderbuffer_storage(ctx, decompress_fbo->rb, rbFormat,
+ width, height, 0);
   status = _mesa_CheckFramebufferStatus(GL_DRAW_FRAMEBUFFER);
   if (status != GL_FRAMEBUFFER_COMPLETE) {
  /* If the framebuffer isn't complete then we'll leave
diff --git a/src/mesa/drivers/common/meta_copy_image.c 
b/src/mesa/drivers/common/meta_copy_image.c
index 2c2b7ba..6534d43 100644
--- a/src/mesa/drivers/common/meta_copy_image.c
+++ b/src/mesa/drivers/common/meta_copy_image.c
@@ -241,10 +241,8 @@ _mesa_meta_CopyImageSubData_uncompressed(struct gl_context 
*ctx,
   _mesa_meta_bind_fbo_image(GL_READ_FRAMEBUFFER, attachment,
 src_view_tex_image, src_z);
} else {
-  _mesa_FramebufferRenderbuffer(GL_READ_FRAMEBUFFER,
-attachment,
-GL_RENDERBUFFER,
-src_renderbuffer->Name);
+  _mesa_framebuffer_renderbuffer(ctx, ctx->ReadBuffer, attachment,
+ src_renderbuffer);
}
 
status = _mesa_CheckFramebufferStatus(GL_READ_FRAMEBUFFER);
@@ -252,10 +250,8 @@ _mesa_meta_CopyImageSubData_uncompressed(struct gl_context 
*ctx,
   goto meta_end;
 
if (dst_renderbuffer) {
-  _mesa_FramebufferRenderbuffer(GL_DRAW_FRAMEBUFFER,
-attachment,
-GL_RENDERBUFFER,
-dst_renderbuffer->Name);
+  _mesa_framebuffer_renderbuffer(ctx, ctx->DrawBuffer, attachment,
+ dst_renderbuffer);
} else {
   _mesa_meta_bind_fbo_image(GL_DRAW_FRAMEBUFFER, attachment,
 dst_tex_image, dst_z);
-- 
2.5.0

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


[Mesa-dev] [PATCH 03/11] i965/meta: Use _mesa_CreateRenderbuffers instead of _mesa_GenRenderbuffers and _mesa_BindRenderbuffer

2016-02-05 Thread Ian Romanick
From: Ian Romanick 

This has the advantage that it does not pollute the global binding
state.  It also enables later patches that will stop calling
_mesa_GenRenderbuffers / _mesa_CreateRenderbuffers which pollute the
renderbuffer namespace.

Signed-off-by: Ian Romanick 
---
 src/mesa/drivers/dri/i965/brw_meta_updownsample.c | 7 +++
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_meta_updownsample.c 
b/src/mesa/drivers/dri/i965/brw_meta_updownsample.c
index f39d50a..563160e 100644
--- a/src/mesa/drivers/dri/i965/brw_meta_updownsample.c
+++ b/src/mesa/drivers/dri/i965/brw_meta_updownsample.c
@@ -55,13 +55,12 @@ brw_get_rb_for_slice(struct brw_context *brw,
struct gl_renderbuffer *rb;
struct intel_renderbuffer *irb;
 
-   /* This turns the GenRenderbuffers name into an actual struct
+   /* This turns the CreateRenderbuffers name into an actual struct
 * intel_renderbuffer.
 */
-   _mesa_GenRenderbuffers(1, &rbo);
-   _mesa_BindRenderbuffer(GL_RENDERBUFFER, rbo);
+   _mesa_CreateRenderbuffers(1, &rbo);
 
-   rb = ctx->CurrentRenderbuffer;
+   rb = _mesa_lookup_renderbuffer(ctx, rbo);
irb = intel_renderbuffer(rb);
 
rb->Format = mt->format;
-- 
2.5.0

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


[Mesa-dev] [PATCH 01/11] mesa: Refactor _mesa_framebuffer_renderbuffer

2016-02-05 Thread Ian Romanick
From: Ian Romanick 

This function previously was only used in fbobject.c and contained a
bunch of API validation.  Split the function into
framebuffer_renderbuffer that is static and contains the validation, and
_mesa_framebuffer_renderbuffer that is suitable for calling from
elsewhere in Mesa (e.g., meta).

Signed-off-by: Ian Romanick 
---
 src/mesa/main/fbobject.c | 42 ++
 src/mesa/main/fbobject.h |  3 +--
 2 files changed, 27 insertions(+), 18 deletions(-)

diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
index 2d4acb3..0b0653d 100644
--- a/src/mesa/main/fbobject.c
+++ b/src/mesa/main/fbobject.c
@@ -3413,8 +3413,27 @@ void
 _mesa_framebuffer_renderbuffer(struct gl_context *ctx,
struct gl_framebuffer *fb,
GLenum attachment,
-   struct gl_renderbuffer *rb,
-   const char *func)
+   struct gl_renderbuffer *rb)
+{
+   assert(!_mesa_is_winsys_fbo(fb));
+
+   FLUSH_VERTICES(ctx, _NEW_BUFFERS);
+
+   assert(ctx->Driver.FramebufferRenderbuffer);
+   ctx->Driver.FramebufferRenderbuffer(ctx, fb, attachment, rb);
+
+   /* Some subsequent GL commands may depend on the framebuffer's visual
+* after the binding is updated.  Update visual info now.
+*/
+   _mesa_update_framebuffer_visual(ctx, fb);
+}
+
+static void
+framebuffer_renderbuffer(struct gl_context *ctx,
+ struct gl_framebuffer *fb,
+ GLenum attachment,
+ struct gl_renderbuffer *rb,
+ const char *func)
 {
struct gl_renderbuffer_attachment *att;
 
@@ -3444,18 +3463,9 @@ _mesa_framebuffer_renderbuffer(struct gl_context *ctx,
   }
}
 
-   FLUSH_VERTICES(ctx, _NEW_BUFFERS);
-
-   assert(ctx->Driver.FramebufferRenderbuffer);
-   ctx->Driver.FramebufferRenderbuffer(ctx, fb, attachment, rb);
-
-   /* Some subsequent GL commands may depend on the framebuffer's visual
-* after the binding is updated.  Update visual info now.
-*/
-   _mesa_update_framebuffer_visual(ctx, fb);
+   _mesa_framebuffer_renderbuffer(ctx, fb, attachment, rb);
 }
 
-
 void GLAPIENTRY
 _mesa_FramebufferRenderbuffer(GLenum target, GLenum attachment,
   GLenum renderbuffertarget,
@@ -3491,8 +3501,8 @@ _mesa_FramebufferRenderbuffer(GLenum target, GLenum 
attachment,
   rb = NULL;
}
 
-   _mesa_framebuffer_renderbuffer(ctx, fb, attachment, rb,
-  "glFramebufferRenderbuffer");
+   framebuffer_renderbuffer(ctx, fb, attachment, rb,
+"glFramebufferRenderbuffer");
 }
 
 
@@ -3528,8 +3538,8 @@ _mesa_NamedFramebufferRenderbuffer(GLuint framebuffer, 
GLenum attachment,
   rb = NULL;
}
 
-   _mesa_framebuffer_renderbuffer(ctx, fb, attachment, rb,
-  "glNamedFramebufferRenderbuffer");
+   framebuffer_renderbuffer(ctx, fb, attachment, rb,
+"glNamedFramebufferRenderbuffer");
 }
 
 
diff --git a/src/mesa/main/fbobject.h b/src/mesa/main/fbobject.h
index 8dad0ff..458e440 100644
--- a/src/mesa/main/fbobject.h
+++ b/src/mesa/main/fbobject.h
@@ -91,8 +91,7 @@ extern void
 _mesa_framebuffer_renderbuffer(struct gl_context *ctx,
struct gl_framebuffer *fb,
GLenum attachment,
-   struct gl_renderbuffer *rb,
-   const char *func);
+   struct gl_renderbuffer *rb);
 
 extern void
 _mesa_validate_framebuffer(struct gl_context *ctx, struct gl_framebuffer *fb);
-- 
2.5.0

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


[Mesa-dev] [PATCH 05/11] meta: Don't save or restore the renderbuffer binding

2016-02-05 Thread Ian Romanick
From: Ian Romanick 

Nothing left in meta does anything with the RBO binding, so we don't
need to save or restore it.  The FBO binding is still modified.

Signed-off-by: Ian Romanick 
---
 src/mesa/drivers/common/meta.c | 6 --
 src/mesa/drivers/common/meta.h | 2 +-
 2 files changed, 1 insertion(+), 7 deletions(-)

diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c
index 26867d3..b42a3cf 100644
--- a/src/mesa/drivers/common/meta.c
+++ b/src/mesa/drivers/common/meta.c
@@ -848,8 +848,6 @@ _mesa_meta_begin(struct gl_context *ctx, GLbitfield state)
 
   save->DrawBufferName = ctx->DrawBuffer->Name;
   save->ReadBufferName = ctx->ReadBuffer->Name;
-  save->RenderbufferName = (ctx->CurrentRenderbuffer ?
-ctx->CurrentRenderbuffer->Name : 0);
}
 }
 
@@ -1241,10 +1239,6 @@ _mesa_meta_end(struct gl_context *ctx)
if (ctx->ReadBuffer->Name != save->ReadBufferName)
   _mesa_BindFramebuffer(GL_READ_FRAMEBUFFER, save->ReadBufferName);
 
-   if (!ctx->CurrentRenderbuffer ||
-   ctx->CurrentRenderbuffer->Name != save->RenderbufferName)
-  _mesa_BindRenderbuffer(GL_RENDERBUFFER, save->RenderbufferName);
-
if (state & MESA_META_DRAW_BUFFERS) {
   _mesa_drawbuffers(ctx, ctx->DrawBuffer, ctx->Const.MaxDrawBuffers,
 save->ColorDrawBuffers, NULL);
diff --git a/src/mesa/drivers/common/meta.h b/src/mesa/drivers/common/meta.h
index 074f70d..3ff0fdd 100644
--- a/src/mesa/drivers/common/meta.h
+++ b/src/mesa/drivers/common/meta.h
@@ -186,7 +186,7 @@ struct save_state
GLboolean RasterDiscard;
GLboolean TransformFeedbackNeedsResume;
 
-   GLuint DrawBufferName, ReadBufferName, RenderbufferName;
+   GLuint DrawBufferName, ReadBufferName;
 
/** MESA_META_DRAW_BUFFERS */
GLenum ColorDrawBuffers[MAX_DRAW_BUFFERS];
-- 
2.5.0

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


Re: [Mesa-dev] [PATCH 03/18] radeonsi: move SPI_PS_INPUT_CNTL value computation to a separate function

2016-02-05 Thread Nicolai Hähnle

On 05.02.2016 14:20, Marek Olšák wrote:

From: Marek Olšák 

---
  src/gallium/drivers/radeonsi/si_state_shaders.c | 74 +
  1 file changed, 40 insertions(+), 34 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_state_shaders.c 
b/src/gallium/drivers/radeonsi/si_state_shaders.c
index 8613af2..fbe0e37 100644
--- a/src/gallium/drivers/radeonsi/si_state_shaders.c
+++ b/src/gallium/drivers/radeonsi/si_state_shaders.c
@@ -1087,14 +1087,50 @@ static void si_delete_shader_selector(struct 
pipe_context *ctx, void *state)
free(sel);
  }

+static unsigned si_get_ps_input_cntl(struct si_context *sctx,
+struct si_shader *vs, unsigned name,
+unsigned index, unsigned interpolate)
+{
+   struct tgsi_shader_info *vsinfo = &vs->selector->info;
+   unsigned j, tmp = 0;


Instead of tmp, it would be nicer to call this variable ps_input_cntl. 
Either way, patches 1-3 are


Reviewed-by: Nicolai Hähnle 


+   if (interpolate == TGSI_INTERPOLATE_CONSTANT ||
+   (interpolate == TGSI_INTERPOLATE_COLOR && sctx->flatshade))
+   tmp |= S_028644_FLAT_SHADE(1);
+
+   if (name == TGSI_SEMANTIC_PCOORD ||
+   (name == TGSI_SEMANTIC_TEXCOORD &&
+sctx->sprite_coord_enable & (1 << index))) {
+   tmp |= S_028644_PT_SPRITE_TEX(1);
+   }
+
+   for (j = 0; j < vsinfo->num_outputs; j++) {
+   if (name == vsinfo->output_semantic_name[j] &&
+   index == vsinfo->output_semantic_index[j]) {
+   tmp |= S_028644_OFFSET(vs->vs_output_param_offset[j]);
+   break;
+   }
+   }
+
+   if (name == TGSI_SEMANTIC_PRIMID)
+   /* PrimID is written after the last output. */
+   tmp |= 
S_028644_OFFSET(vs->vs_output_param_offset[vsinfo->num_outputs]);
+   else if (j == vsinfo->num_outputs && !G_028644_PT_SPRITE_TEX(tmp)) {
+   /* No corresponding output found, load defaults into input.
+* Don't set any other bits.
+* (FLAT_SHADE=1 completely changes behavior) */
+   tmp = S_028644_OFFSET(0x20);
+   }
+   return tmp;
+}
+
  static void si_emit_spi_map(struct si_context *sctx, struct r600_atom *atom)
  {
struct radeon_winsys_cs *cs = sctx->b.gfx.cs;
struct si_shader *ps = sctx->ps_shader.current;
struct si_shader *vs = si_get_vs_state(sctx);
struct tgsi_shader_info *psinfo;
-   struct tgsi_shader_info *vsinfo = &vs->selector->info;
-   unsigned i, j, tmp, num_written = 0;
+   unsigned i, num_written = 0;

if (!ps || !ps->nparam)
return;
@@ -1109,38 +1145,8 @@ static void si_emit_spi_map(struct si_context *sctx, 
struct r600_atom *atom)
unsigned interpolate = psinfo->input_interpolate[i];
unsigned param_offset = ps->ps_input_param_offset[i];
  bcolor:
-   tmp = 0;
-
-   if (interpolate == TGSI_INTERPOLATE_CONSTANT ||
-   (interpolate == TGSI_INTERPOLATE_COLOR && sctx->flatshade))
-   tmp |= S_028644_FLAT_SHADE(1);
-
-   if (name == TGSI_SEMANTIC_PCOORD ||
-   (name == TGSI_SEMANTIC_TEXCOORD &&
-sctx->sprite_coord_enable & (1 << index))) {
-   tmp |= S_028644_PT_SPRITE_TEX(1);
-   }
-
-   for (j = 0; j < vsinfo->num_outputs; j++) {
-   if (name == vsinfo->output_semantic_name[j] &&
-   index == vsinfo->output_semantic_index[j]) {
-   tmp |= 
S_028644_OFFSET(vs->vs_output_param_offset[j]);
-   break;
-   }
-   }
-
-   if (name == TGSI_SEMANTIC_PRIMID)
-   /* PrimID is written after the last output. */
-   tmp |= 
S_028644_OFFSET(vs->vs_output_param_offset[vsinfo->num_outputs]);
-   else if (j == vsinfo->num_outputs && 
!G_028644_PT_SPRITE_TEX(tmp)) {
-   /* No corresponding output found, load defaults into 
input.
-* Don't set any other bits.
-* (FLAT_SHADE=1 completely changes behavior) */
-   tmp = S_028644_OFFSET(0x20);
-   }
-
-   assert(param_offset == num_written);
-   radeon_emit(cs, tmp);
+   radeon_emit(cs, si_get_ps_input_cntl(sctx, vs, name, index,
+interpolate));
num_written++;

if (name == TGSI_SEMANTIC_COLOR &&


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


Re: [Mesa-dev] [PATCH 2/2] st/mesa: release GLSL IR in LinkShader after it's not needed

2016-02-05 Thread Marek Olšák
On Fri, Feb 5, 2016 at 8:46 PM, Ian Romanick  wrote:
> On 01/30/2016 06:48 AM, Marek Olšák wrote:
>> From: Marek Olšák 
>>
>> ---
>>  src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 4 
>>  1 file changed, 4 insertions(+)
>>
>> diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp 
>> b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
>> index d98627f..8a194c0 100644
>> --- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
>> +++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
>> @@ -5692,6 +5692,10 @@ get_mesa_program(struct gl_context *ctx,
>>   prog->OutputsWritten, 0ULL, 
>> prog->PatchOutputsWritten);
>> count_resources(v, prog);
>>
>> +   /* The GLSL IR won't be needed anymore. */
>> +   ralloc_free(shader->ir);
>> +   shader->ir = NULL;
>> +
>> /* This must be done before the uniform storage is associated. */
>> if (shader->Type == GL_FRAGMENT_SHADER &&
>> (prog->InputsRead & VARYING_BIT_POS ||
>>
>
> After the call to get_mesa_program is a call to
> st_dump_program_for_shader_db.  Will that try to use the IR?

No, that only dumps the source code string.

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


Re: [Mesa-dev] [Mesa-stable] [PATCH v3] glx: update to updated version of EXT_create_context_es2_profile

2016-02-05 Thread Ian Romanick
On 02/04/2016 07:54 AM, Ilia Mirkin wrote:
> On Thu, Feb 4, 2016 at 10:50 AM, Emil Velikov  
> wrote:
>> Hi Ilia,
>>
>> On 3 February 2016 at 14:52, Ilia Mirkin  wrote:
>>> The EXT spec has been updated to:
>>>  - logically combine the es2_profile and es_profile exts
>>>  - allow any legal version to be requested
>>>
>>> dEQP tests request a specific ES version when using GLX, so this allows
>>> dEQP upstream to run against GLX with the appropriate X server patch
>>> (which had similar disabling logic).
>>>
>>> Signed-off-by: Ilia Mirkin 
>>> Reviewed-by: Matt Turner  (v1)
>>>
>>> v1 -> v2:
>>>  - distinguish between DRI_API_GLES{,2,3}
>>>  - add GLX_EXT_create_context_es_profile client-side support
>>> v2 -> v3:
>>>  - fix error in computing mask
>>> ---
>>>  src/glx/dri2_glx.c  | 11 ---
>>>  src/glx/dri3_glx.c  |  7 ++-
>>>  src/glx/dri_common.c| 28 
>>>  src/glx/drisw_glx.c |  4 +++-
>>>  src/glx/glxextensions.c |  1 +
>>>  src/glx/glxextensions.h |  1 +
>>>  6 files changed, 31 insertions(+), 21 deletions(-)
>>>
>> Any objections if we pull this for mesa-stable ?
> 
> None from me, but it seems to overstep the mark of backports. If
> you're comfortable with it, go for it. Do note that it requires a
> patched X server in order to have any effect. The X server patch
> appears to be targeted for 1.18 backport, but not sure if there will
> be another 1.17 release (or whether that patch would be included
> there).

I think it should be fine for 11.1.  We're deviating from the spec, and
that causes at least one application to fail.  The X server dependency
makes it a little bit moot, but *shrug*.

>   -ilia
> ___
> mesa-stable mailing list
> mesa-sta...@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-stable

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


Re: [Mesa-dev] [Piglit] [PATCH] Add (un)packHalf tests which don't fail on GCN

2016-02-05 Thread Ian Romanick
On 02/05/2016 08:04 AM, Marek Olšák wrote:
> On Fri, Feb 5, 2016 at 4:48 PM, Roland Scheidegger  wrote:
>> Am 05.02.2016 um 16:08 schrieb Marek Olšák:
>>> On Fri, Feb 5, 2016 at 3:56 PM, Roland Scheidegger  
>>> wrote:
 Am 05.02.2016 um 15:44 schrieb Marek Olšák:
> On Fri, Feb 5, 2016 at 10:57 AM, Marek Olšák  wrote:
>> On Fri, Feb 5, 2016 at 1:55 AM, Matt Turner  wrote:
>>> On Thu, Feb 4, 2016 at 10:50 AM, Marek Olšák  wrote:
 From: Marek Olšák 

 This is a subset of the generated tests which are known to fail
 on everything except CPU emulation (AFAIK).
 ---
>>>
>>> This is really awful. Committing a generated test, but with unknown
>>> bits chopped out is gross.
>>>
>>> If it were me, I'd want to understand why my hardware behaved
>>> differently -- not just hack up *different* tests and claim victory.
>>>
>>> FWIW, the generated tests pass on all Intel hardware exposing
>>> ARB_shading_language_packing. Gen7+ has native half-float support, and
>>> Gen6 uses the lowering code in lower_packing_builtins.cpp to turn the
>>> built-ins into a pile of instructions.
>>>
>>> If you can identify how AMD hardware behaves differently and can prove
>>> that the generator needs to be relaxed or something, that's cool. But
>>> as is, I hate this patch.
>>>
>>> I can't find anything in the AMD docs (I looked at GCN3) about
>>> half-precision support, so I can't check my theory that AMD hardware
>>> rounds towards zero instead of to-nearest/even like Intel.
>>
>> Since the tests only fail with very small numbers, I think the problem
>> is that denorms are disabled by radeonsi. I can try to confirm that.
>>
>> The hardware rounds to nearest even. The hw precision is:
>> - unpack functions - 0 ULP
>> - pack functions = 0.5 ULP
>> - input and output denorms are flushed to 0
>
> Hey Matt,
>
> I have just confirmed that I was right. After I enable denormals in
> hw, the original tests pass. This means that this patch tests the
> packing functions but skips denormals.
>
> Not so awful now, is it? :)
>
> Sadly, I can't enable denormals on all chips, because they are slow.
>
> So if I add "-no-denormals" suffix into the test names, I can push this, 
> right?
>

 Can't you hack up the generator instead? By the looks of it
 (gen_builtin_packing_tests.py) it has a list of values which result in
 denorm f16 values (make_inputs_for_pack_half_2x16). Presumably you could
 add a test there which uses a different list, not including them.

 (That said, I'm a bit surprised for conversion to/from fp16 your hw
 doesn't do fp16 denorms - they'd be required by d3d(11) as well.)
>>>
>>> The hardware can do denormals, they are just slow on all chips except VI.
>>>
>>> GLSL 4.50 doesn't require denormals, thus piglit shouldn't even contain
>>> tests for them.
>>
>> I'm not asking about denormals for ordinary operations, just conversion
>> to fp16 (any fp16 denorm is a fp32 normal). That would be along similar
>> lines what d3d10 already required - forbids fp32 denorms, but for
>> instance sampling fp16 surfaces requires you to handle the fp16 denorms
>> without flushing to zero (that's at least what the docs say - maybe you
>> can get away without it...). FWIW x86 half-float conversion instructions
>> (vcvtph2ps, vcvtps2ph) work that way too - even if you have denorms
>> disabled, that instruction will still produce fp16 denorms (and convert
>> fp16 denorms to fp32 normals), you can configure rounding mode but
>> there's no way to disable fp16 denorms.
>> Albeit gcn3 supports fp16 natively (that is it has actual operations
>> using them not just conversion), so I suppose it makes sense it would
>> flush them on conversion too...
>> But I think you're right glsl shouldn't require them (albeit it is
>> pretty silent on that topic as far as I can tell - certainly doesn't
>> require them for fp32).
> 
> There is no point in enabling denormals for the conversion
> instructions if all previous FP instructions flush denormals to 0 and
> so do the following FP instructions. If the conversion instructions

Sure there is.  It is very common for applications to load fp16 values
from textures, buffers, etc. to reduce bandwidth, then convert the fp16
to fp32.  That is, after all, the entire reason these intrinsics were
added to GLSL.  That's also the reason for the DX requirements.

Or to put this another way... do you really want to debug an application
rendering bug related to this? :)

> were the only FP instructions manipulating with the source data in the
> shader, it would make sense, but this is a very rare use case of GLSL
> intrinsics that, to my knowledge, aren't used by any app. The least
> important topics seem to get the most attention, apparently.
> 
> I think the right course of action is to nu

Re: [Mesa-dev] [PATCH 1/2] mesa: call build_program_resource_list inside Driver.LinkShader

2016-02-05 Thread Ian Romanick
On 01/30/2016 06:48 AM, Marek Olšák wrote:
> From: Marek Olšák 
> 
> to allow LinkShader to free the GLSL IR.
> ---
>  src/compiler/glsl/program.h| 5 -
>  src/mesa/drivers/dri/i965/brw_link.cpp | 2 ++

I think i915 should get the same treatment, right?  Or does it pick it
up via the first hunk in the patch to ir_to_mesa?

>  src/mesa/program/ir_to_mesa.cpp| 4 ++--
>  src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 3 +++
>  4 files changed, 11 insertions(+), 3 deletions(-)
> 
> diff --git a/src/compiler/glsl/program.h b/src/compiler/glsl/program.h
> index 64f5463..31bb9aa 100644
> --- a/src/compiler/glsl/program.h
> +++ b/src/compiler/glsl/program.h
> @@ -22,12 +22,15 @@
>   * OTHER DEALINGS IN THE SOFTWARE.
>   */
>  
> -#include "main/core.h"
>  
>  #ifdef __cplusplus
>  extern "C" {
>  #endif
>  
> +struct gl_context;
> +struct gl_shader;
> +struct gl_shader_program;
> +

This hunk seems spurious, but should be fine.  Did you build all the
drivers to be sure this doesn't break someone?

>  extern void
>  _mesa_glsl_compile_shader(struct gl_context *ctx, struct gl_shader *shader,
> bool dump_ast, bool dump_hir);
> diff --git a/src/mesa/drivers/dri/i965/brw_link.cpp 
> b/src/mesa/drivers/dri/i965/brw_link.cpp
> index db4ba88..66520a4 100644
> --- a/src/mesa/drivers/dri/i965/brw_link.cpp
> +++ b/src/mesa/drivers/dri/i965/brw_link.cpp
> @@ -27,6 +27,7 @@
>  #include "brw_nir.h"
>  #include "brw_program.h"
>  #include "compiler/glsl/ir_optimization.h"
> +#include "compiler/glsl/program.h"
>  #include "program/program.h"
>  #include "main/shaderapi.h"
>  #include "main/uniforms.h"
> @@ -282,5 +283,6 @@ brw_link_shader(struct gl_context *ctx, struct 
> gl_shader_program *shProg)
> if (brw->precompile && !brw_shader_precompile(ctx, shProg))
>return false;
>  
> +   build_program_resource_list(shProg);
> return true;
>  }
> diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp
> index c9c3044..403803b 100644
> --- a/src/mesa/program/ir_to_mesa.cpp
> +++ b/src/mesa/program/ir_to_mesa.cpp
> @@ -31,6 +31,7 @@
>  
>  #include 
>  #include "main/compiler.h"
> +#include "main/macros.h"
>  #include "main/mtypes.h"
>  #include "main/shaderapi.h"
>  #include "main/shaderobj.h"
> @@ -2933,6 +2934,7 @@ _mesa_ir_link_shader(struct gl_context *ctx, struct 
> gl_shader_program *prog)
>_mesa_reference_program(ctx, &linked_prog, NULL);
> }
>  
> +   build_program_resource_list(prog);
> return prog->LinkStatus;
>  }
>  
> @@ -2961,8 +2963,6 @@ _mesa_glsl_link_shader(struct gl_context *ctx, struct 
> gl_shader_program *prog)
> if (prog->LinkStatus) {
>if (!ctx->Driver.LinkShader(ctx, prog)) {
>prog->LinkStatus = GL_FALSE;
> -  } else {
> - build_program_resource_list(prog);
>}
> }
>  
> diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp 
> b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
> index f5b8c33..d98627f 100644
> --- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
> +++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
> @@ -34,6 +34,7 @@
>  
>  #include "compiler/glsl/glsl_parser_extras.h"
>  #include "compiler/glsl/ir_optimization.h"
> +#include "compiler/glsl/program.h"
>  
>  #include "main/errors.h"
>  #include "main/shaderobj.h"
> @@ -5923,6 +5924,8 @@ st_link_shader(struct gl_context *ctx, struct 
> gl_shader_program *prog)
>validate_ir_tree(ir);
> }
>  
> +   build_program_resource_list(prog);
> +
> for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) {
>struct gl_program *linked_prog;
>  
> 

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


Re: [Mesa-dev] [PATCH v2 1/9] gallium: Add PIPE_CAP_FRAMEBUFFER_LAYERS

2016-02-05 Thread Nicolai Hähnle

On 05.02.2016 10:31, Brian Paul wrote:

On 02/05/2016 04:44 AM, Edward O'Callaghan wrote:

Add PIPE_CAP to determine the number of layers for
a framebuffer for GL_ARB_framebuffer_no_attachments.

Signed-off-by: Edward O'Callaghan 
---
  src/gallium/docs/source/screen.rst   |  2 ++
  src/gallium/drivers/freedreno/freedreno_screen.c |  1 +
  src/gallium/drivers/i915/i915_screen.c   |  1 +
  src/gallium/drivers/ilo/ilo_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/vc4/vc4_screen.c |  1 +
  src/gallium/drivers/virgl/virgl_screen.c |  1 +
  src/gallium/include/pipe/p_defines.h |  1 +
  src/mesa/state_tracker/st_extensions.c   | 13 +
  17 files changed, 30 insertions(+)

diff --git a/src/gallium/docs/source/screen.rst
b/src/gallium/docs/source/screen.rst
index 3324bcc..d0d8aef 100644
--- a/src/gallium/docs/source/screen.rst
+++ b/src/gallium/docs/source/screen.rst
@@ -319,6 +319,8 @@ The integer capabilities:
adjusted appropriately.
  * ``PIPE_CAP_QUERY_BUFFER_OBJECT``: Driver supports
context::get_query_result_resource callback.
+* ``PIPE_CAP_MAX_FRAMEBUFFER_LAYERS``: Whether
`framebuffer_no_attachments`
+  will be available in contexts.


Perhaps you didn't see my comment about this the first time.

The PIPE_CAP name and the description don't really agree (uint vs.
boolean) and, at face value, don't even seem related.

I think a better description would be "maximum number of layers
supported for shader load/store instructions when operating on layered
resources (such as array textures).  If non-zero, rendering to
framebuffers with no surface attachments is supported."


I'm not so sure that that's the meaning of the corresponding GL constant.

The way I understood the extension language was that it's unrelated to 
what shader load/store can do, and simply means that via a no-attachment 
framebuffer, you might be able to rasterize a primitive on a layer that 
is larger than the number of layers supported by either rendering or 
textures.


In any case, this description does need to be fixed.

Cheers,
Nicolai



-Brian





  .. _pipe_capf:
diff --git a/src/gallium/drivers/freedreno/freedreno_screen.c
b/src/gallium/drivers/freedreno/freedreno_screen.c
index f67c160..5b63d03 100644
--- a/src/gallium/drivers/freedreno/freedreno_screen.c
+++ b/src/gallium/drivers/freedreno/freedreno_screen.c
@@ -251,6 +251,7 @@ fd_screen_get_param(struct pipe_screen *pscreen,
enum pipe_cap param)
  case PIPE_CAP_INVALIDATE_BUFFER:
  case PIPE_CAP_GENERATE_MIPMAP:
  case PIPE_CAP_SURFACE_REINTERPRET_BLOCKS:
+case PIPE_CAP_MAX_FRAMEBUFFER_LAYERS:
  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 31856ad..a32a6f4 100644
--- a/src/gallium/drivers/i915/i915_screen.c
+++ b/src/gallium/drivers/i915/i915_screen.c
@@ -264,6 +264,7 @@ i915_get_param(struct pipe_screen *screen, enum
pipe_cap cap)
 case PIPE_CAP_STRING_MARKER:
 case PIPE_CAP_BUFFER_SAMPLER_VIEW_RGBA_ONLY:
 case PIPE_CAP_SURFACE_REINTERPRET_BLOCKS:
+   case PIPE_CAP_MAX_FRAMEBUFFER_LAYERS:
return 0;

 case PIPE_CAP_MAX_DUAL_SOURCE_RENDER_TARGETS:
diff --git a/src/gallium/drivers/ilo/ilo_screen.c
b/src/gallium/drivers/ilo/ilo_screen.c
index 7c77197..ea6d85b 100644
--- a/src/gallium/drivers/ilo/ilo_screen.c
+++ b/src/gallium/drivers/ilo/ilo_screen.c
@@ -490,6 +490,7 @@ ilo_get_param(struct pipe_screen *screen, enum
pipe_cap param)
 case PIPE_CAP_STRING_MARKER:
 case PIPE_CAP_SURFACE_REINTERPRET_BLOCKS:
 case PIPE_CAP_QUERY_BUFFER_OBJECT:
+   case PIPE_CAP_MAX_FRAMEBUFFER_LAYERS:
return 0;

 case PIPE_CAP_VENDOR_ID:
diff --git a/src/gallium/drivers/llvmpipe/lp_screen.c
b/src/gallium/drivers/llvmpipe/lp_screen.c
index 1731681..24456ef 100644
--- a/src/gallium/drivers/llvmpipe/lp_screen.c
+++ b/src/gallium/drivers/llvmpipe/lp_screen.c
@@ -314,6 +314,7 @@ llvmpipe_get_param(struct pipe_screen *screen,
enum pipe_cap param)
 case PIPE_CAP_BUFFER_SAMPLER_VIEW_RGBA_ONLY:
 case PIPE_CAP_SURFACE_REINTERPRET_BLOCKS:
 case PIPE_CAP_QUERY_BUFFER_OBJECT:
+   case PIPE_CAP_MAX_FRAMEBUFFER_LAYERS:
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 4f09b74..f46c4cc 100644
--- a/src/gall

Re: [Mesa-dev] [PATCH 2/2] st/mesa: release GLSL IR in LinkShader after it's not needed

2016-02-05 Thread Ian Romanick
On 01/30/2016 06:48 AM, Marek Olšák wrote:
> From: Marek Olšák 
> 
> ---
>  src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 4 
>  1 file changed, 4 insertions(+)
> 
> diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp 
> b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
> index d98627f..8a194c0 100644
> --- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
> +++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
> @@ -5692,6 +5692,10 @@ get_mesa_program(struct gl_context *ctx,
>   prog->OutputsWritten, 0ULL, 
> prog->PatchOutputsWritten);
> count_resources(v, prog);
>  
> +   /* The GLSL IR won't be needed anymore. */
> +   ralloc_free(shader->ir);
> +   shader->ir = NULL;
> +
> /* This must be done before the uniform storage is associated. */
> if (shader->Type == GL_FRAGMENT_SHADER &&
> (prog->InputsRead & VARYING_BIT_POS ||
> 

After the call to get_mesa_program is a call to
st_dump_program_for_shader_db.  Will that try to use the IR?
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] MesaGL <-> non-Mesa OpenCL interop interface

2016-02-05 Thread Nicolai Hähnle

Hi,

On 04.02.2016 17:25, Marek Olšák wrote:

I would like to start a discussion about an OpenGL-OpenCL interop
interface where OpenCL is not part of Mesa.

I think the only way to do this is to have Mesa export functions that
convert Mesa OpenGL objects into DMABUF handles. Such functions can be
exported by DRI driver modules or libGL & libEGL, however, it's
possible that the OpenCL stack won't link against libGL & libEGL,
therefore it's not required to expose the interface as GLX/EGL
extensions.

The existing EGL extension for DMABUF exports only works with EGL
images, whereas this needs to work with OpenGL handles directly.

All functions should accept a context pointer, because that's what
OpenCL receives from the user and the context might not be current.

This is the proposed interface for sharing OpenGL buffers and
textures. This is just a draft and will most likely be changed. The
OpenCL stack is expected to obtain there via dlsym(RTLD_DEFAULT):

int glXBufferExportDMABUFHandle(GLXContext context, GLuint bufferObj,
unsigned flags);
int eglBufferExportDMABUFHandle(EGLContext context, GLuint bufferObj,
unsigned flags);
int glXTextureExportDMABUFHandle(GLXContext context, GLuint
textureObj, GLenum textureTarget, unsigned flags);
int eglTextureExportDMABUFHandle(EGLContext context, GLuint
textureObj, GLenum textureTarget, unsigned flags);

#define FLAG_CL_USAGE_READ_ONLY (1 << 0)

Mesa should return a value <= 0 if bufferObj, textureObj, or
textureTarget is invalid. (TBD)

The information about the texture format, texture layout (2D, 3D,
array, mipmap, ...), texture sizes, and hw-specific tiling parameters
is expected to be attached to the DMABUF handle using a
driver-specific ioctl (done by the Mesa driver), and likewise, the
OpenCL stack is expected to query it using a similar ioctl. Right now,
the DMABUF handle is the only piece of information that is publicly
returned to the OpenCL stack.


Some thoughts: if this information must be queried via a driver-specific 
ioctl anyway, then does it really make sense to define a generic 
exporting interface for textures?


If the consensus is yes, then I'd say the interface looks pretty 
reasonable. Having the textureTarget as a parameter seems to be 
redundant if the layout is attached to the DMABUF. I notice the OpenCL 
interface exposes it though, so I don't feel strongly about it.


If OpenCL lives outside of Mesa but still calls into the kernel via 
libdrm, then it could potentially be more efficient to do the sharing 
via libdrm structures. Should that be done with an additional interface? 
Since they are hw-specific, wiring up such an interface might end up 
being awkward. I think it'd nicer to have these functions return a void* 
which is interpreted depending on the flags.


What's the error handling story? It seems most errors checked by these 
functions would result in CL_INVALID_GL_OBJECT, but perhaps some 
implementations want to signal CL_OUT_OF_HOST_MEMORY. How to distinguish 
between them?


So how about something like this:

int glXBufferExport(GLXContext context, GLuint bufferObj, unsigned 
flags, void **phandle);

... the others analogously ...

#define FLAG_USAGE_READ_ONLY (1 << 0)
#define FLAG_DMABUF (1 << 1)

... and a negative return value indicates an error code.

Cheers,
Nicolai


Comments welcome.

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


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


Re: [Mesa-dev] [PATCH] meta: Fix the pbo usage in meta for GLES{1, 2} contexts

2016-02-05 Thread Ian Romanick
On 12/24/2015 01:04 PM, Anuj Phogat wrote:
> OpenGL ES 1.0 doesn't support using GL_STREAM_DRAW and both
> ES 1.0 and 2.0 don't support GL_STREAM_READ in glBufferData().
> So, handle it correctly by calling the _mesa_meta_begin()
> before create_texture_for_pbo().
> 
> Cc: "11.1" 
> Signed-off-by: Anuj Phogat 
> ---
>  src/mesa/drivers/common/meta_tex_subimage.c | 27 ---
>  1 file changed, 16 insertions(+), 11 deletions(-)
> 
> diff --git a/src/mesa/drivers/common/meta_tex_subimage.c 
> b/src/mesa/drivers/common/meta_tex_subimage.c
> index 4adaad7..8ef306e 100644
> --- a/src/mesa/drivers/common/meta_tex_subimage.c
> +++ b/src/mesa/drivers/common/meta_tex_subimage.c
> @@ -211,19 +211,21 @@ _mesa_meta_pbo_TexSubImage(struct gl_context *ctx, 
> GLuint dims,
>  */
> image_height = packing->ImageHeight == 0 ? height : packing->ImageHeight;
>  
> +   if (allocate_storage)
> +  ctx->Driver.AllocTextureImageBuffer(ctx, tex_image);
> +
> +   _mesa_meta_begin(ctx, ~(MESA_META_PIXEL_TRANSFER |
> +   MESA_META_PIXEL_STORE));
> +

Moving the call to _mesa_meta_begin makes sense from the commit message.
 It's not obvious to me why the call to AllocTextureImageBuffer was also
moved.

Also... is there a test case that hits this?  I think some of the
patches in my meta-cannot-use-Gen series might also fix this.

> pbo_tex_image = create_texture_for_pbo(ctx, create_pbo,
>GL_PIXEL_UNPACK_BUFFER,
>dims, width, height, depth,
>format, type, pixels, packing,
>&pbo, &pbo_tex);
> -   if (!pbo_tex_image)
> +   if (!pbo_tex_image) {
> +  _mesa_meta_end(ctx);
>return false;
> -
> -   if (allocate_storage)
> -  ctx->Driver.AllocTextureImageBuffer(ctx, tex_image);
> -
> -   _mesa_meta_begin(ctx, ~(MESA_META_PIXEL_TRANSFER |
> -   MESA_META_PIXEL_STORE));
> +   }
>  
> _mesa_GenFramebuffers(2, fbos);
> _mesa_BindFramebuffer(GL_READ_FRAMEBUFFER, fbos[0]);
> @@ -346,15 +348,18 @@ _mesa_meta_pbo_GetTexSubImage(struct gl_context *ctx, 
> GLuint dims,
>  */
> image_height = packing->ImageHeight == 0 ? height : packing->ImageHeight;
>  
> +   _mesa_meta_begin(ctx, ~(MESA_META_PIXEL_TRANSFER |
> +   MESA_META_PIXEL_STORE));
> +
> pbo_tex_image = create_texture_for_pbo(ctx, false, GL_PIXEL_PACK_BUFFER,
>dims, width, height, depth,
>format, type, pixels, packing,
>&pbo, &pbo_tex);
> -   if (!pbo_tex_image)
> -  return false;
>  
> -   _mesa_meta_begin(ctx, ~(MESA_META_PIXEL_TRANSFER |
> -   MESA_META_PIXEL_STORE));
> +   if (!pbo_tex_image) {
> +  _mesa_meta_end(ctx);
> +  return false;
> +   }
>  
> /* GL_CLAMP_FRAGMENT_COLOR doesn't affect ReadPixels and GettexImage */
> if (ctx->Extensions.ARB_color_buffer_float)
> 

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


Re: [Mesa-dev] [PATCH 1/1] r600g: Ignore format for PIPE_BUFFER targets

2016-02-05 Thread Marek Olšák
Pushed, thanks.

Marek

On Fri, Feb 5, 2016 at 6:01 PM, Jan Vesely  wrote:
> Fixes compute since 7dd31b81fee7fe40bd09cf3fbc324fcc32782479
> gallium/radeon: support PIPE_CAP_SURFACE_REINTERPRET_BLOCKS
>
> Signed-off-by: Jan Vesely 
> ---
>  src/gallium/drivers/radeon/r600_texture.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/gallium/drivers/radeon/r600_texture.c 
> b/src/gallium/drivers/radeon/r600_texture.c
> index ebafe3e..c2fd018 100644
> --- a/src/gallium/drivers/radeon/r600_texture.c
> +++ b/src/gallium/drivers/radeon/r600_texture.c
> @@ -1219,7 +1219,7 @@ static struct pipe_surface *r600_create_surface(struct 
> pipe_context *pipe,
> unsigned width = u_minify(tex->width0, level);
> unsigned height = u_minify(tex->height0, level);
>
> -   if (templ->format != tex->format) {
> +   if (tex->target != PIPE_BUFFER && templ->format != tex->format) {
> const struct util_format_description *tex_desc
> = util_format_description(tex->format);
> const struct util_format_description *templ_desc
> --
> 2.5.0
>
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 16/18] radeonsi: split out code for deleting si_shader

2016-02-05 Thread Marek Olšák
From: Marek Olšák 

---
 src/gallium/drivers/radeonsi/si_state_shaders.c | 65 ++---
 1 file changed, 36 insertions(+), 29 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_state_shaders.c 
b/src/gallium/drivers/radeonsi/si_state_shaders.c
index 802225c..8d7ceaa 100644
--- a/src/gallium/drivers/radeonsi/si_state_shaders.c
+++ b/src/gallium/drivers/radeonsi/si_state_shaders.c
@@ -1053,6 +1053,41 @@ static void si_bind_ps_shader(struct pipe_context *ctx, 
void *state)
si_mark_atom_dirty(sctx, &sctx->cb_render_state);
 }
 
+static void si_delete_shader(struct si_context *sctx, struct si_shader *shader)
+{
+   if (shader->pm4) {
+   switch (shader->selector->type) {
+   case PIPE_SHADER_VERTEX:
+   if (shader->key.vs.as_ls)
+   si_pm4_delete_state(sctx, ls, shader->pm4);
+   else if (shader->key.vs.as_es)
+   si_pm4_delete_state(sctx, es, shader->pm4);
+   else
+   si_pm4_delete_state(sctx, vs, shader->pm4);
+   break;
+   case PIPE_SHADER_TESS_CTRL:
+   si_pm4_delete_state(sctx, hs, shader->pm4);
+   break;
+   case PIPE_SHADER_TESS_EVAL:
+   if (shader->key.tes.as_es)
+   si_pm4_delete_state(sctx, es, shader->pm4);
+   else
+   si_pm4_delete_state(sctx, vs, shader->pm4);
+   break;
+   case PIPE_SHADER_GEOMETRY:
+   si_pm4_delete_state(sctx, gs, shader->pm4);
+   si_pm4_delete_state(sctx, vs, 
shader->gs_copy_shader->pm4);
+   break;
+   case PIPE_SHADER_FRAGMENT:
+   si_pm4_delete_state(sctx, ps, shader->pm4);
+   break;
+   }
+   }
+
+   si_shader_destroy(shader);
+   free(shader);
+}
+
 static void si_delete_shader_selector(struct pipe_context *ctx, void *state)
 {
struct si_context *sctx = (struct si_context *)ctx;
@@ -1073,35 +1108,7 @@ static void si_delete_shader_selector(struct 
pipe_context *ctx, void *state)
 
while (p) {
c = p->next_variant;
-   switch (sel->type) {
-   case PIPE_SHADER_VERTEX:
-   if (p->key.vs.as_ls)
-   si_pm4_delete_state(sctx, ls, p->pm4);
-   else if (p->key.vs.as_es)
-   si_pm4_delete_state(sctx, es, p->pm4);
-   else
-   si_pm4_delete_state(sctx, vs, p->pm4);
-   break;
-   case PIPE_SHADER_TESS_CTRL:
-   si_pm4_delete_state(sctx, hs, p->pm4);
-   break;
-   case PIPE_SHADER_TESS_EVAL:
-   if (p->key.tes.as_es)
-   si_pm4_delete_state(sctx, es, p->pm4);
-   else
-   si_pm4_delete_state(sctx, vs, p->pm4);
-   break;
-   case PIPE_SHADER_GEOMETRY:
-   si_pm4_delete_state(sctx, gs, p->pm4);
-   si_pm4_delete_state(sctx, vs, p->gs_copy_shader->pm4);
-   break;
-   case PIPE_SHADER_FRAGMENT:
-   si_pm4_delete_state(sctx, ps, p->pm4);
-   break;
-   }
-
-   si_shader_destroy(p);
-   free(p);
+   si_delete_shader(sctx, p);
p = c;
}
 
-- 
2.1.4

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


[Mesa-dev] [PATCH 15/18] radeonsi: move code writing tess factors into a separate function

2016-02-05 Thread Marek Olšák
From: Marek Olšák 

---
 src/gallium/drivers/radeonsi/si_shader.c | 30 +-
 1 file changed, 21 insertions(+), 9 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_shader.c 
b/src/gallium/drivers/radeonsi/si_shader.c
index 6379ba4..0f10460 100644
--- a/src/gallium/drivers/radeonsi/si_shader.c
+++ b/src/gallium/drivers/radeonsi/si_shader.c
@@ -1959,21 +1959,20 @@ handle_semantic:
}
 }
 
-/* This only writes the tessellation factor levels. */
-static void si_llvm_emit_tcs_epilogue(struct lp_build_tgsi_context *bld_base)
+static void si_write_tess_factors(struct lp_build_tgsi_context *bld_base,
+ LLVMValueRef rel_patch_id,
+ LLVMValueRef invocation_id,
+ LLVMValueRef 
tcs_out_current_patch_data_offset)
 {
struct si_shader_context *si_shader_ctx = si_shader_context(bld_base);
struct gallivm_state *gallivm = bld_base->base.gallivm;
struct si_shader *shader = si_shader_ctx->shader;
unsigned tess_inner_index, tess_outer_index;
-   LLVMValueRef lds_base, lds_inner, lds_outer;
-   LLVMValueRef tf_base, rel_patch_id, byteoffset, buffer, rw_buffers;
-   LLVMValueRef out[6], vec0, vec1, invocation_id;
+   LLVMValueRef lds_base, lds_inner, lds_outer, byteoffset, buffer;
+   LLVMValueRef out[6], vec0, vec1, rw_buffers, tf_base;
unsigned stride, outer_comps, inner_comps, i;
struct lp_build_if_state if_ctx;
 
-   invocation_id = unpack_param(si_shader_ctx, SI_PARAM_REL_IDS, 8, 5);
-
/* Do this only for invocation 0, because the tess levels are per-patch,
 * not per-vertex.
 *
@@ -2012,7 +2011,7 @@ static void si_llvm_emit_tcs_epilogue(struct 
lp_build_tgsi_context *bld_base)
tess_inner_index = 
si_shader_io_get_unique_index(TGSI_SEMANTIC_TESSINNER, 0);
tess_outer_index = 
si_shader_io_get_unique_index(TGSI_SEMANTIC_TESSOUTER, 0);
 
-   lds_base = get_tcs_out_current_patch_data_offset(si_shader_ctx);
+   lds_base = tcs_out_current_patch_data_offset;
lds_inner = LLVMBuildAdd(gallivm->builder, lds_base,
 lp_build_const_int32(gallivm,
  tess_inner_index * 4), 
"");
@@ -2041,7 +2040,6 @@ static void si_llvm_emit_tcs_epilogue(struct 
lp_build_tgsi_context *bld_base)
/* Get the offset. */
tf_base = LLVMGetParam(si_shader_ctx->radeon_bld.main_fn,
   SI_PARAM_TESS_FACTOR_OFFSET);
-   rel_patch_id = get_rel_patch_id(si_shader_ctx);
byteoffset = LLVMBuildMul(gallivm->builder, rel_patch_id,
  lp_build_const_int32(gallivm, 4 * stride), 
"");
 
@@ -2054,6 +2052,20 @@ static void si_llvm_emit_tcs_epilogue(struct 
lp_build_tgsi_context *bld_base)
lp_build_endif(&if_ctx);
 }
 
+/* This only writes the tessellation factor levels. */
+static void si_llvm_emit_tcs_epilogue(struct lp_build_tgsi_context *bld_base)
+{
+   struct si_shader_context *si_shader_ctx = si_shader_context(bld_base);
+   LLVMValueRef invocation_id;
+
+   invocation_id = unpack_param(si_shader_ctx, SI_PARAM_REL_IDS, 8, 5);
+
+   si_write_tess_factors(bld_base,
+ get_rel_patch_id(si_shader_ctx),
+ invocation_id,
+ 
get_tcs_out_current_patch_data_offset(si_shader_ctx));
+}
+
 static void si_llvm_emit_ls_epilogue(struct lp_build_tgsi_context * bld_base)
 {
struct si_shader_context *si_shader_ctx = si_shader_context(bld_base);
-- 
2.1.4

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


[Mesa-dev] [PATCH 17/18] radeonsi: compile geometry shaders immediately

2016-02-05 Thread Marek Olšák
From: Marek Olšák 

they have only 1 variant
---
 src/gallium/drivers/radeonsi/si_state_shaders.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/gallium/drivers/radeonsi/si_state_shaders.c 
b/src/gallium/drivers/radeonsi/si_state_shaders.c
index 8d7ceaa..bc00ec2 100644
--- a/src/gallium/drivers/radeonsi/si_state_shaders.c
+++ b/src/gallium/drivers/radeonsi/si_state_shaders.c
@@ -916,7 +916,8 @@ static void *si_create_shader_selector(struct pipe_context 
*ctx,
}
 
/* Pre-compilation. */
-   if (sscreen->b.debug_flags & DBG_PRECOMPILE) {
+   if (sel->type == PIPE_SHADER_GEOMETRY ||
+   sscreen->b.debug_flags & DBG_PRECOMPILE) {
struct si_shader_ctx_state state = {sel};
union si_shader_key key;
 
-- 
2.1.4

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


[Mesa-dev] [PATCH 18/18] gallium/radeon: add a function for adding llvm function attributes

2016-02-05 Thread Marek Olšák
From: Marek Olšák 

This will be used for setting the new InitialPSInputAddr attribute.
---
 src/gallium/drivers/radeon/radeon_llvm_emit.c | 13 +
 src/gallium/drivers/radeon/radeon_llvm_emit.h |  1 +
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/src/gallium/drivers/radeon/radeon_llvm_emit.c 
b/src/gallium/drivers/radeon/radeon_llvm_emit.c
index 3d09876..474154e 100644
--- a/src/gallium/drivers/radeon/radeon_llvm_emit.c
+++ b/src/gallium/drivers/radeon/radeon_llvm_emit.c
@@ -55,6 +55,14 @@ enum radeon_llvm_shader_type {
RADEON_LLVM_SHADER_CS = 3,
 };
 
+void radeon_llvm_add_attribute(LLVMValueRef F, const char *name, int value)
+{
+   char str[16];
+
+   snprintf(str, sizeof(str), "%i", value);
+   LLVMAddTargetDependentFunctionAttr(F, name, str);
+}
+
 /**
  * Set the shader type we want to compile
  *
@@ -62,7 +70,6 @@ enum radeon_llvm_shader_type {
  */
 void radeon_llvm_shader_type(LLVMValueRef F, unsigned type)
 {
-   char Str[2];
enum radeon_llvm_shader_type llvm_type;
 
switch (type) {
@@ -84,9 +91,7 @@ void radeon_llvm_shader_type(LLVMValueRef F, unsigned type)
assert(0);
}
 
-   sprintf(Str, "%1d", llvm_type);
-
-   LLVMAddTargetDependentFunctionAttr(F, "ShaderType", Str);
+   radeon_llvm_add_attribute(F, "ShaderType", llvm_type);
 }
 
 static void init_r600_target()
diff --git a/src/gallium/drivers/radeon/radeon_llvm_emit.h 
b/src/gallium/drivers/radeon/radeon_llvm_emit.h
index 45f05a9..84dbd25 100644
--- a/src/gallium/drivers/radeon/radeon_llvm_emit.h
+++ b/src/gallium/drivers/radeon/radeon_llvm_emit.h
@@ -34,6 +34,7 @@
 struct pipe_debug_callback;
 struct radeon_shader_binary;
 
+void radeon_llvm_add_attribute(LLVMValueRef F, const char *name, int value);
 void radeon_llvm_shader_type(LLVMValueRef F, unsigned type);
 
 LLVMTargetRef radeon_llvm_get_r600_target(const char *triple);
-- 
2.1.4

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


[Mesa-dev] [PATCH 02/18] radeonsi: generate a color_two_side variant only if the shader reads colors

2016-02-05 Thread Marek Olšák
From: Marek Olšák 

---
 src/gallium/drivers/radeonsi/si_state_shaders.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/gallium/drivers/radeonsi/si_state_shaders.c 
b/src/gallium/drivers/radeonsi/si_state_shaders.c
index bbef429..8613af2 100644
--- a/src/gallium/drivers/radeonsi/si_state_shaders.c
+++ b/src/gallium/drivers/radeonsi/si_state_shaders.c
@@ -681,7 +681,7 @@ static inline void si_shader_selector_key(struct 
pipe_context *ctx,
   sctx->current_rast_prim >= 
PIPE_PRIM_TRIANGLES_ADJACENCY;
bool is_line = !is_poly && sctx->current_rast_prim != 
PIPE_PRIM_POINTS;
 
-   key->ps.color_two_side = rs->two_side;
+   key->ps.color_two_side = rs->two_side && 
sel->info.colors_read;
 
if (sctx->queued.named.blend) {
key->ps.alpha_to_one = 
sctx->queued.named.blend->alpha_to_one &&
-- 
2.1.4

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


[Mesa-dev] [PATCH 12/18] radeonsi: remove useless code that handles dx10_clamp_mode

2016-02-05 Thread Marek Olšák
From: Marek Olšák 

"enable-no-nans-fp-math" is a wrong string and there was a disagreement
about fixing it.
---
 src/gallium/drivers/radeonsi/si_shader.c|  7 ---
 src/gallium/drivers/radeonsi/si_shader.h|  1 -
 src/gallium/drivers/radeonsi/si_state_shaders.c | 12 ++--
 3 files changed, 6 insertions(+), 14 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_shader.c 
b/src/gallium/drivers/radeonsi/si_shader.c
index 18e4ab9..b28e1d7 100644
--- a/src/gallium/drivers/radeonsi/si_shader.c
+++ b/src/gallium/drivers/radeonsi/si_shader.c
@@ -3691,10 +3691,6 @@ static void create_function(struct si_shader_context 
*si_shader_ctx)
radeon_llvm_create_func(&si_shader_ctx->radeon_bld, params, num_params);
radeon_llvm_shader_type(si_shader_ctx->radeon_bld.main_fn, 
si_shader_ctx->type);
 
-   if (shader->dx10_clamp_mode)
-   
LLVMAddTargetDependentFunctionAttr(si_shader_ctx->radeon_bld.main_fn,
-  "enable-no-nans-fp-math", 
"true");
-
for (i = 0; i <= last_sgpr; ++i) {
LLVMValueRef P = 
LLVMGetParam(si_shader_ctx->radeon_bld.main_fn, i);
 
@@ -4378,9 +4374,6 @@ int si_shader_create(struct si_screen *sscreen, 
LLVMTargetMachineRef tm,
si_init_shader_ctx(&si_shader_ctx, sscreen, shader, tm,
   poly_stipple ? &stipple_shader_info : &sel->info);
 
-   if (sel->type != PIPE_SHADER_COMPUTE)
-   shader->dx10_clamp_mode = true;
-
shader->uses_instanceid = sel->info.uses_instanceid;
 
bld_base = &si_shader_ctx.radeon_bld.soa.bld_base;
diff --git a/src/gallium/drivers/radeonsi/si_shader.h 
b/src/gallium/drivers/radeonsi/si_shader.h
index 04b977a..e3d1f4f 100644
--- a/src/gallium/drivers/radeonsi/si_shader.h
+++ b/src/gallium/drivers/radeonsi/si_shader.h
@@ -283,7 +283,6 @@ struct si_shader {
booluses_instanceid;
unsignednr_pos_exports;
unsignednr_param_exports;
-   booldx10_clamp_mode; /* convert NaNs to 0 */
 };
 
 static inline struct tgsi_shader_info *si_get_vs_info(struct si_context *sctx)
diff --git a/src/gallium/drivers/radeonsi/si_state_shaders.c 
b/src/gallium/drivers/radeonsi/si_state_shaders.c
index fdaa3f3..802225c 100644
--- a/src/gallium/drivers/radeonsi/si_state_shaders.c
+++ b/src/gallium/drivers/radeonsi/si_state_shaders.c
@@ -124,7 +124,7 @@ static void si_shader_ls(struct si_shader *shader)
shader->config.rsrc1 = S_00B528_VGPRS((shader->config.num_vgprs - 1) / 
4) |
   S_00B528_SGPRS((num_sgprs - 1) / 8) |
   S_00B528_VGPR_COMP_CNT(vgpr_comp_cnt) |
-  S_00B528_DX10_CLAMP(shader->dx10_clamp_mode);
+  S_00B528_DX10_CLAMP(1);
shader->config.rsrc2 = S_00B52C_USER_SGPR(num_user_sgprs) |
   
S_00B52C_SCRATCH_EN(shader->config.scratch_bytes_per_wave > 0);
 }
@@ -157,7 +157,7 @@ static void si_shader_hs(struct si_shader *shader)
si_pm4_set_reg(pm4, R_00B428_SPI_SHADER_PGM_RSRC1_HS,
   S_00B428_VGPRS((shader->config.num_vgprs - 1) / 4) |
   S_00B428_SGPRS((num_sgprs - 1) / 8) |
-  S_00B428_DX10_CLAMP(shader->dx10_clamp_mode));
+  S_00B428_DX10_CLAMP(1));
si_pm4_set_reg(pm4, R_00B42C_SPI_SHADER_PGM_RSRC2_HS,
   S_00B42C_USER_SGPR(num_user_sgprs) |
   
S_00B42C_SCRATCH_EN(shader->config.scratch_bytes_per_wave > 0));
@@ -203,7 +203,7 @@ static void si_shader_es(struct si_shader *shader)
   S_00B328_VGPRS((shader->config.num_vgprs - 1) / 4) |
   S_00B328_SGPRS((num_sgprs - 1) / 8) |
   S_00B328_VGPR_COMP_CNT(vgpr_comp_cnt) |
-  S_00B328_DX10_CLAMP(shader->dx10_clamp_mode));
+  S_00B328_DX10_CLAMP(1));
si_pm4_set_reg(pm4, R_00B32C_SPI_SHADER_PGM_RSRC2_ES,
   S_00B32C_USER_SGPR(num_user_sgprs) |
   
S_00B32C_SCRATCH_EN(shader->config.scratch_bytes_per_wave > 0));
@@ -292,7 +292,7 @@ static void si_shader_gs(struct si_shader *shader)
si_pm4_set_reg(pm4, R_00B228_SPI_SHADER_PGM_RSRC1_GS,
   S_00B228_VGPRS((shader->config.num_vgprs - 1) / 4) |
   S_00B228_SGPRS((num_sgprs - 1) / 8) |
-  S_00B228_DX10_CLAMP(shader->dx10_clamp_mode));
+  S_00B228_DX10_CLAMP(1));
si_pm4_set_reg(pm4, R_00B22C_SPI_SHADER_PGM_RSRC2_GS,
   S_00B22C_USER_SGPR(num_user_sgprs) |
   
S_00B22C_SCRATCH_EN(shader->config.scratch_bytes_per_wave > 0));
@@ -381,7 +381,7 @@ static void si_shader_vs(struct si_shader *shader, struct 
si_shader *gs)
   S_00B128_VGPRS((shader->config.num_vgprs - 1) / 4) |

[Mesa-dev] [PATCH 10/18] radeonsi: dump SPI_PS_INPUT values along with shader stats

2016-02-05 Thread Marek Olšák
From: Marek Olšák 

---
 src/gallium/drivers/radeonsi/si_shader.c | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/src/gallium/drivers/radeonsi/si_shader.c 
b/src/gallium/drivers/radeonsi/si_shader.c
index 85203e0..bd45d4a 100644
--- a/src/gallium/drivers/radeonsi/si_shader.c
+++ b/src/gallium/drivers/radeonsi/si_shader.c
@@ -4039,6 +4039,13 @@ static void si_shader_dump_stats(struct si_screen 
*sscreen,
max_simd_waves = MIN2(max_simd_waves, 16384 / lds_per_wave);
 
if (r600_can_dump_shader(&sscreen->b, processor)) {
+   if (processor == TGSI_PROCESSOR_FRAGMENT) {
+   fprintf(stderr, "*** SHADER CONFIG ***\n"
+   "SPI_PS_INPUT_ADDR = 0x%04x\n"
+   "SPI_PS_INPUT_ENA  = 0x%04x\n",
+   conf->spi_ps_input_addr, 
conf->spi_ps_input_ena);
+   }
+
fprintf(stderr, "*** SHADER STATS ***\n"
"SGPRS: %d\n"
"VGPRS: %d\n"
-- 
2.1.4

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


[Mesa-dev] [PATCH 11/18] radeonsi: don't emit unnecessary NULL exports for unbound targets

2016-02-05 Thread Marek Olšák
From: Marek Olšák 

---
 src/gallium/drivers/radeonsi/si_shader.c | 63 +---
 1 file changed, 50 insertions(+), 13 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_shader.c 
b/src/gallium/drivers/radeonsi/si_shader.c
index bd45d4a..18e4ab9 100644
--- a/src/gallium/drivers/radeonsi/si_shader.c
+++ b/src/gallium/drivers/radeonsi/si_shader.c
@@ -2298,13 +2298,30 @@ static void si_export_mrt_color(struct 
lp_build_tgsi_context *bld_base,
/* If last_cbuf > 0, FS_COLOR0_WRITES_ALL_CBUFS is true. */
if (index == 0 &&
si_shader_ctx->shader->key.ps.last_cbuf > 0) {
-   for (int c = 1; c <= si_shader_ctx->shader->key.ps.last_cbuf; 
c++) {
+   LLVMValueRef args[8][9];
+   int c, last = -1;
+
+   /* Get the export arguments, also find out what the last one 
is. */
+   for (c = 0; c <= si_shader_ctx->shader->key.ps.last_cbuf; c++) {
si_llvm_init_export_args(bld_base, color,
-V_008DFC_SQ_EXP_MRT + c, args);
+V_008DFC_SQ_EXP_MRT + c, 
args[c]);
+   if (args[c][0] != bld_base->uint_bld.zero)
+   last = c;
+   }
+
+   /* Emit all exports. */
+   for (c = 0; c <= si_shader_ctx->shader->key.ps.last_cbuf; c++) {
+   if (is_last && last == c) {
+   args[c][1] = bld_base->uint_bld.one; /* whether 
the EXEC mask is valid */
+   args[c][2] = bld_base->uint_bld.one; /* DONE 
bit */
+   } else if (args[c][0] == bld_base->uint_bld.zero)
+   continue; /* unnecessary NULL export */
+
lp_build_intrinsic(base->gallivm->builder, 
"llvm.SI.export",
   
LLVMVoidTypeInContext(base->gallivm->context),
-  args, 9, 0);
+  args[c], 9, 0);
}
+   return;
}
 
/* Export */
@@ -2313,7 +2330,9 @@ static void si_export_mrt_color(struct 
lp_build_tgsi_context *bld_base,
if (is_last) {
args[1] = bld_base->uint_bld.one; /* whether the EXEC mask is 
valid */
args[2] = bld_base->uint_bld.one; /* DONE bit */
-   }
+   } else if (args[0] == bld_base->uint_bld.zero)
+   return; /* unnecessary NULL export */
+
lp_build_intrinsic(base->gallivm->builder, "llvm.SI.export",
   LLVMVoidTypeInContext(base->gallivm->context),
   args, 9, 0);
@@ -2351,19 +2370,37 @@ static void si_llvm_emit_fs_epilogue(struct 
lp_build_tgsi_context * bld_base)
int last_color_export = -1;
int i;
 
-   /* If there are no outputs, add a dummy export. */
-   if (!info->num_outputs) {
-   si_export_null(bld_base);
-   return;
-   }
-
/* Determine the last export. If MRTZ is present, it's always last.
 * Otherwise, find the last color export.
 */
-   if (!info->writes_z && !info->writes_stencil && 
!info->writes_samplemask)
-   for (i = 0; i < info->num_outputs; i++)
-   if (info->output_semantic_name[i] == 
TGSI_SEMANTIC_COLOR)
+   if (!info->writes_z && !info->writes_stencil && 
!info->writes_samplemask) {
+   unsigned spi_format = shader->key.ps.spi_shader_col_format;
+
+   for (i = 0; i < info->num_outputs; i++) {
+   unsigned index = info->output_semantic_index[i];
+
+   if (info->output_semantic_name[i] != 
TGSI_SEMANTIC_COLOR)
+   continue;
+
+   /* If last_cbuf > 0, FS_COLOR0_WRITES_ALL_CBUFS is 
true. */
+   if (index == 0 && shader->key.ps.last_cbuf > 0) {
+   /* Just set this if any of the colorbuffers are 
enabled. */
+   if (spi_format &
+   ((1llu << (4 * (shader->key.ps.last_cbuf + 
1))) - 1))
+   last_color_export = i;
+   continue;
+   }
+
+   if ((spi_format >> (index * 4)) & 0xf)
last_color_export = i;
+   }
+
+   /* If there are no outputs, export NULL. */
+   if (last_color_export == -1) {
+   si_export_null(bld_base);
+   return;
+   }
+   }
 
for (i = 0; i < info->num_outputs; i++) {
unsigned semantic_name = info->output_semantic_name[i];
-- 
2.1.4

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org

[Mesa-dev] [PATCH 14/18] radeonsi: make LLVM IR dumping less messy

2016-02-05 Thread Marek Olšák
From: Marek Olšák 

---
 src/gallium/drivers/radeonsi/si_compute.c |  3 ++-
 src/gallium/drivers/radeonsi/si_shader.c  | 18 +++---
 src/gallium/drivers/radeonsi/si_shader.h  |  3 ++-
 3 files changed, 15 insertions(+), 9 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_compute.c 
b/src/gallium/drivers/radeonsi/si_compute.c
index 825fbb1..4d27e86 100644
--- a/src/gallium/drivers/radeonsi/si_compute.c
+++ b/src/gallium/drivers/radeonsi/si_compute.c
@@ -124,7 +124,8 @@ static void *si_create_compute_state(
 code, 
header->num_bytes);
si_compile_llvm(sctx->screen, 
&program->kernels[i].binary,
&program->kernels[i].config, sctx->tm,
-   mod, &sctx->b.debug, 
TGSI_PROCESSOR_COMPUTE);
+   mod, &sctx->b.debug, 
TGSI_PROCESSOR_COMPUTE,
+   "Compute Shader");
si_shader_dump(sctx->screen, &program->kernels[i],
   &sctx->b.debug, TGSI_PROCESSOR_COMPUTE);
si_shader_binary_upload(sctx->screen, 
&program->kernels[i]);
diff --git a/src/gallium/drivers/radeonsi/si_shader.c 
b/src/gallium/drivers/radeonsi/si_shader.c
index c19e4a9..6379ba4 100644
--- a/src/gallium/drivers/radeonsi/si_shader.c
+++ b/src/gallium/drivers/radeonsi/si_shader.c
@@ -4118,7 +4118,8 @@ int si_compile_llvm(struct si_screen *sscreen,
LLVMTargetMachineRef tm,
LLVMModuleRef mod,
struct pipe_debug_callback *debug,
-   unsigned processor)
+   unsigned processor,
+   const char *name)
 {
int r = 0;
unsigned count = p_atomic_inc_return(&sscreen->b.num_compilations);
@@ -4126,8 +4127,11 @@ int si_compile_llvm(struct si_screen *sscreen,
if (r600_can_dump_shader(&sscreen->b, processor)) {
fprintf(stderr, "radeonsi: Compiling shader %d\n", count);
 
-   if (!(sscreen->b.debug_flags & (DBG_NO_IR | DBG_PREOPT_IR)))
+   if (!(sscreen->b.debug_flags & (DBG_NO_IR | DBG_PREOPT_IR))) {
+   fprintf(stderr, "%s LLVM IR:\n\n", name);
LLVMDumpModule(mod);
+   fprintf(stderr, "\n");
+   }
}
 
if (!si_replace_shader(count, binary)) {
@@ -4220,14 +4224,14 @@ static int si_generate_gs_copy_shader(struct si_screen 
*sscreen,
 
radeon_llvm_finalize_module(&si_shader_ctx->radeon_bld);
 
-   if (r600_can_dump_shader(&sscreen->b, TGSI_PROCESSOR_GEOMETRY))
-   fprintf(stderr, "Copy Vertex Shader for Geometry Shader:\n\n");
-
r = si_compile_llvm(sscreen, &si_shader_ctx->shader->binary,
&si_shader_ctx->shader->config, si_shader_ctx->tm,
bld_base->base.gallivm->module,
-   debug, TGSI_PROCESSOR_GEOMETRY);
+   debug, TGSI_PROCESSOR_GEOMETRY,
+   "GS Copy Shader");
if (!r) {
+   if (r600_can_dump_shader(&sscreen->b, TGSI_PROCESSOR_GEOMETRY))
+   fprintf(stderr, "GS Copy Shader:\n");
si_shader_dump(sscreen, si_shader_ctx->shader, debug,
   TGSI_PROCESSOR_GEOMETRY);
r = si_shader_binary_upload(sscreen, si_shader_ctx->shader);
@@ -4447,7 +4451,7 @@ int si_shader_create(struct si_screen *sscreen, 
LLVMTargetMachineRef tm,
radeon_llvm_finalize_module(&si_shader_ctx.radeon_bld);
 
r = si_compile_llvm(sscreen, &shader->binary, &shader->config, tm,
-   mod, debug, si_shader_ctx.type);
+   mod, debug, si_shader_ctx.type, "TGSI shader");
if (r) {
fprintf(stderr, "LLVM failed to compile shader\n");
goto out;
diff --git a/src/gallium/drivers/radeonsi/si_shader.h 
b/src/gallium/drivers/radeonsi/si_shader.h
index e3d1f4f..c42c51e 100644
--- a/src/gallium/drivers/radeonsi/si_shader.h
+++ b/src/gallium/drivers/radeonsi/si_shader.h
@@ -328,7 +328,8 @@ int si_compile_llvm(struct si_screen *sscreen,
LLVMTargetMachineRef tm,
LLVMModuleRef mod,
struct pipe_debug_callback *debug,
-   unsigned processor);
+   unsigned processor,
+   const char *name);
 void si_shader_destroy(struct si_shader *shader);
 unsigned si_shader_io_get_unique_index(unsigned semantic_name, unsigned index);
 int si_shader_binary_upload(struct si_screen *sscreen, struct si_shader 
*shader);
-- 
2.1.4

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


[Mesa-dev] [PATCH 13/18] radeonsi: move a few r600_can_dump_shader calls to where they're needed

2016-02-05 Thread Marek Olšák
From: Marek Olšák 

---
 src/gallium/drivers/radeonsi/si_shader.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_shader.c 
b/src/gallium/drivers/radeonsi/si_shader.c
index b28e1d7..c19e4a9 100644
--- a/src/gallium/drivers/radeonsi/si_shader.c
+++ b/src/gallium/drivers/radeonsi/si_shader.c
@@ -4150,7 +4150,7 @@ int si_compile_llvm(struct si_screen *sscreen,
 /* Generate code for the hardware VS shader stage to go with a geometry shader 
*/
 static int si_generate_gs_copy_shader(struct si_screen *sscreen,
  struct si_shader_context *si_shader_ctx,
- struct si_shader *gs, bool dump,
+ struct si_shader *gs,
  struct pipe_debug_callback *debug)
 {
struct gallivm_state *gallivm = &si_shader_ctx->radeon_bld.gallivm;
@@ -4220,7 +4220,7 @@ static int si_generate_gs_copy_shader(struct si_screen 
*sscreen,
 
radeon_llvm_finalize_module(&si_shader_ctx->radeon_bld);
 
-   if (dump)
+   if (r600_can_dump_shader(&sscreen->b, TGSI_PROCESSOR_GEOMETRY))
fprintf(stderr, "Copy Vertex Shader for Geometry Shader:\n\n");
 
r = si_compile_llvm(sscreen, &si_shader_ctx->shader->binary,
@@ -4354,7 +4354,6 @@ int si_shader_create(struct si_screen *sscreen, 
LLVMTargetMachineRef tm,
int r = 0;
bool poly_stipple = sel->type == PIPE_SHADER_FRAGMENT &&
shader->key.ps.poly_stipple;
-   bool dump = r600_can_dump_shader(&sscreen->b, sel->info.processor);
 
if (poly_stipple) {
tokens = util_pstipple_create_fragment_shader(tokens, NULL,
@@ -4365,7 +4364,8 @@ int si_shader_create(struct si_screen *sscreen, 
LLVMTargetMachineRef tm,
 
/* Dump TGSI code before doing TGSI->LLVM conversion in case the
 * conversion fails. */
-   if (dump && !(sscreen->b.debug_flags & DBG_NO_TGSI)) {
+   if (r600_can_dump_shader(&sscreen->b, sel->info.processor) &&
+   !(sscreen->b.debug_flags & DBG_NO_TGSI)) {
si_dump_shader_key(sel->type, &shader->key, stderr);
tgsi_dump(tokens, 0);
si_dump_streamout(&sel->so);
@@ -4468,7 +4468,7 @@ int si_shader_create(struct si_screen *sscreen, 
LLVMTargetMachineRef tm,
shader->gs_copy_shader->selector = shader->selector;
si_shader_ctx.shader = shader->gs_copy_shader;
if ((r = si_generate_gs_copy_shader(sscreen, &si_shader_ctx,
-   shader, dump, debug))) {
+   shader, debug))) {
free(shader->gs_copy_shader);
shader->gs_copy_shader = NULL;
goto out;
-- 
2.1.4

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


[Mesa-dev] [PATCH 08/18] radeonsi: don't force gl_SampleMaskIn to 1 for smoothing

2016-02-05 Thread Marek Olšák
From: Marek Olšák 

---
 src/gallium/drivers/radeonsi/si_shader.c | 11 ---
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_shader.c 
b/src/gallium/drivers/radeonsi/si_shader.c
index d9006bc..68ce387 100644
--- a/src/gallium/drivers/radeonsi/si_shader.c
+++ b/src/gallium/drivers/radeonsi/si_shader.c
@@ -1057,7 +1057,6 @@ static void declare_system_value(
struct si_shader_context *si_shader_ctx =
si_shader_context(&radeon_bld->soa.bld_base);
struct lp_build_context *bld = &radeon_bld->soa.bld_base.base;
-   struct lp_build_context *uint_bld = &radeon_bld->soa.bld_base.uint_bld;
struct gallivm_state *gallivm = &radeon_bld->gallivm;
LLVMValueRef value = 0;
 
@@ -1133,12 +1132,10 @@ static void declare_system_value(
}
 
case TGSI_SEMANTIC_SAMPLEMASK:
-   /* Smoothing isn't MSAA in GL, but it's MSAA in hardware.
-* Therefore, force gl_SampleMaskIn to 1 for GL. */
-   if (si_shader_ctx->shader->key.ps.poly_line_smoothing)
-   value = uint_bld->one;
-   else
-   value = LLVMGetParam(radeon_bld->main_fn, 
SI_PARAM_SAMPLE_COVERAGE);
+   /* This can only occur with the OpenGL Core profile, which
+* doesn't support smoothing.
+*/
+   value = LLVMGetParam(radeon_bld->main_fn, 
SI_PARAM_SAMPLE_COVERAGE);
break;
 
case TGSI_SEMANTIC_TESSCOORD:
-- 
2.1.4

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


[Mesa-dev] [PATCH 05/18] radeonsi: remove si_shader::ps_input_interpolate

2016-02-05 Thread Marek Olšák
From: Marek Olšák 

tgsi_shader_info has this too.
---
 src/gallium/drivers/radeonsi/si_shader.c | 8 +++-
 src/gallium/drivers/radeonsi/si_shader.h | 1 -
 2 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_shader.c 
b/src/gallium/drivers/radeonsi/si_shader.c
index 7925500..c595f20 100644
--- a/src/gallium/drivers/radeonsi/si_shader.c
+++ b/src/gallium/drivers/radeonsi/si_shader.c
@@ -914,7 +914,6 @@ static void declare_input_fs(
 
attr_number = lp_build_const_int32(gallivm, input_index);
 
-   shader->ps_input_interpolate[input_index] = decl->Interp.Interpolate;
interp_param_idx = lookup_interp_param_index(decl->Interp.Interpolate,
 decl->Interp.Location);
if (interp_param_idx == -1)
@@ -3257,17 +3256,17 @@ static void build_interp_intrinsic(const struct 
lp_build_tgsi_action *action,
LLVMValueRef interp_param;
const struct tgsi_full_instruction *inst = emit_data->inst;
const char *intr_name;
-   int input_index;
+   int input_index = inst->Src[0].Register.Index;
int chan;
int i;
LLVMValueRef attr_number;
LLVMTypeRef input_type = LLVMFloatTypeInContext(gallivm->context);
LLVMValueRef params = LLVMGetParam(si_shader_ctx->radeon_bld.main_fn, 
SI_PARAM_PRIM_MASK);
int interp_param_idx;
+   unsigned interp = shader->selector->info.input_interpolate[input_index];
unsigned location;
 
assert(inst->Src[0].Register.File == TGSI_FILE_INPUT);
-   input_index = inst->Src[0].Register.Index;
 
if (inst->Instruction.Opcode == TGSI_OPCODE_INTERP_OFFSET ||
inst->Instruction.Opcode == TGSI_OPCODE_INTERP_SAMPLE)
@@ -3275,8 +3274,7 @@ static void build_interp_intrinsic(const struct 
lp_build_tgsi_action *action,
else
location = TGSI_INTERPOLATE_LOC_CENTROID;
 
-   interp_param_idx = 
lookup_interp_param_index(shader->ps_input_interpolate[input_index],
-location);
+   interp_param_idx = lookup_interp_param_index(interp, location);
if (interp_param_idx == -1)
return;
else if (interp_param_idx)
diff --git a/src/gallium/drivers/radeonsi/si_shader.h 
b/src/gallium/drivers/radeonsi/si_shader.h
index 86d8f72..d3609d4 100644
--- a/src/gallium/drivers/radeonsi/si_shader.h
+++ b/src/gallium/drivers/radeonsi/si_shader.h
@@ -291,7 +291,6 @@ struct si_shader {
struct si_shader_config config;
 
unsignedvs_output_param_offset[PIPE_MAX_SHADER_OUTPUTS];
-   unsignedps_input_interpolate[PIPE_MAX_SHADER_INPUTS];
booluses_instanceid;
unsignednr_pos_exports;
unsignednr_param_exports;
-- 
2.1.4

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


[Mesa-dev] [PATCH 07/18] radeonsi: split PS input interpolation code into its own function

2016-02-05 Thread Marek Olšák
From: Marek Olšák 

This will be used by the fragment shader prolog.
---
 src/gallium/drivers/radeonsi/si_shader.c | 127 +--
 1 file changed, 71 insertions(+), 56 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_shader.c 
b/src/gallium/drivers/radeonsi/si_shader.c
index 0a92a7b..d9006bc 100644
--- a/src/gallium/drivers/radeonsi/si_shader.c
+++ b/src/gallium/drivers/radeonsi/si_shader.c
@@ -858,48 +858,42 @@ static unsigned select_interp_param(struct 
si_shader_context *si_shader_ctx,
}
 }
 
-static void declare_input_fs(
-   struct radeon_llvm_context *radeon_bld,
-   unsigned input_index,
-   const struct tgsi_full_declaration *decl)
+/**
+ * Interpolate a fragment shader input.
+ *
+ * @param si_shader_ctxcontext
+ * @param input_index  index of the input in hardware
+ * @param semantic_nameTGSI_SEMANTIC_*
+ * @param semantic_index   semantic index
+ * @param num_interp_inputsnumber of all interpolated inputs (= BCOLOR 
offset)
+ * @param colors_read_mask color components read (4 bits for each color, 8 
bits in total)
+ * @param interp_param interpolation weights (i,j)
+ * @param prim_maskSI_PARAM_PRIM_MASK
+ * @param face SI_PARAM_FRONT_FACE
+ * @param result   the return value (4 components)
+ */
+static void interp_fs_input(struct si_shader_context *si_shader_ctx,
+   unsigned input_index,
+   unsigned semantic_name,
+   unsigned semantic_index,
+   unsigned num_interp_inputs,
+   unsigned colors_read_mask,
+   LLVMValueRef interp_param,
+   LLVMValueRef prim_mask,
+   LLVMValueRef face,
+   LLVMValueRef result[4])
 {
-   struct lp_build_context *base = &radeon_bld->soa.bld_base.base;
-   struct si_shader_context *si_shader_ctx =
-   si_shader_context(&radeon_bld->soa.bld_base);
-   struct si_shader *shader = si_shader_ctx->shader;
-   struct lp_build_context *uint = &radeon_bld->soa.bld_base.uint_bld;
+   struct lp_build_context *base = 
&si_shader_ctx->radeon_bld.soa.bld_base.base;
+   struct lp_build_context *uint = 
&si_shader_ctx->radeon_bld.soa.bld_base.uint_bld;
struct gallivm_state *gallivm = base->gallivm;
LLVMTypeRef input_type = LLVMFloatTypeInContext(gallivm->context);
-   LLVMValueRef main_fn = radeon_bld->main_fn;
-
-   LLVMValueRef interp_param = NULL;
-   int interp_param_idx;
const char * intr_name;
-
-   /* This value is:
-* [15:0] NewPrimMask (Bit mask for each quad.  It is set it the
-* quad begins a new primitive.  Bit 0 always needs
-* to be unset)
-* [32:16] ParamOffset
-*
-*/
-   LLVMValueRef params = LLVMGetParam(main_fn, SI_PARAM_PRIM_MASK);
LLVMValueRef attr_number;
 
unsigned chan;
 
attr_number = lp_build_const_int32(gallivm, input_index);
 
-   interp_param_idx = lookup_interp_param_index(decl->Interp.Interpolate,
-decl->Interp.Location);
-   if (interp_param_idx == -1)
-   return;
-   else if (interp_param_idx) {
-   interp_param_idx = select_interp_param(si_shader_ctx,
-  interp_param_idx);
-   interp_param = LLVMGetParam(main_fn, interp_param_idx);
-   }
-
/* fs.constant returns the param from the middle vertex, so it's not
 * really useful for flat shading. It's meant to be used for custom
 * interpolation (but the intrinsic can't fetch from the other two
@@ -912,32 +906,28 @@ static void declare_input_fs(
 */
intr_name = interp_param ? "llvm.SI.fs.interp" : "llvm.SI.fs.constant";
 
-   if (decl->Semantic.Name == TGSI_SEMANTIC_COLOR &&
+   if (semantic_name == TGSI_SEMANTIC_COLOR &&
si_shader_ctx->shader->key.ps.color_two_side) {
-   struct tgsi_shader_info *info = &shader->selector->info;
LLVMValueRef args[4];
-   LLVMValueRef face, is_face_positive;
+   LLVMValueRef is_face_positive;
LLVMValueRef back_attr_number;
 
/* If BCOLOR0 is used, BCOLOR1 is at offset "num_inputs + 1",
 * otherwise it's at offset "num_inputs".
 */
-   unsigned back_attr_offset = shader->selector->info.num_inputs;
-   if (decl->Semantic.Index == 1 && info->colors_read & 0xf)
+   unsigned back_attr_offset = num_interp_inputs;
+   if (semantic_index == 1 && colors_read_mask & 0xf)
back_attr_offset += 1;
 
back_attr_number = lp_

[Mesa-dev] [PATCH 09/18] radeonsi: read SPI_PS_INPUT_ADDR from LLVM if it returns it

2016-02-05 Thread Marek Olšák
From: Marek Olšák 

---
 src/gallium/drivers/radeonsi/si_shader.c| 5 -
 src/gallium/drivers/radeonsi/si_shader.h| 1 +
 src/gallium/drivers/radeonsi/si_state_shaders.c | 3 ++-
 3 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_shader.c 
b/src/gallium/drivers/radeonsi/si_shader.c
index 68ce387..85203e0 100644
--- a/src/gallium/drivers/radeonsi/si_shader.c
+++ b/src/gallium/drivers/radeonsi/si_shader.c
@@ -3875,7 +3875,7 @@ void si_shader_binary_read_config(struct 
radeon_shader_binary *binary,
conf->spi_ps_input_ena = value;
break;
case R_0286D0_SPI_PS_INPUT_ADDR:
-   /* Not used yet, but will be in the future */
+   conf->spi_ps_input_addr = value;
break;
case R_0286E8_SPI_TMPRING_SIZE:
case R_00B860_COMPUTE_TMPRING_SIZE:
@@ -3895,6 +3895,9 @@ void si_shader_binary_read_config(struct 
radeon_shader_binary *binary,
}
break;
}
+
+   if (!conf->spi_ps_input_addr)
+   conf->spi_ps_input_addr = conf->spi_ps_input_ena;
}
 }
 
diff --git a/src/gallium/drivers/radeonsi/si_shader.h 
b/src/gallium/drivers/radeonsi/si_shader.h
index 0d6a45a..04b977a 100644
--- a/src/gallium/drivers/radeonsi/si_shader.h
+++ b/src/gallium/drivers/radeonsi/si_shader.h
@@ -260,6 +260,7 @@ struct si_shader_config {
unsignednum_vgprs;
unsignedlds_size;
unsignedspi_ps_input_ena;
+   unsignedspi_ps_input_addr;
unsignedfloat_mode;
unsignedscratch_bytes_per_wave;
unsignedrsrc1;
diff --git a/src/gallium/drivers/radeonsi/si_state_shaders.c 
b/src/gallium/drivers/radeonsi/si_state_shaders.c
index f1be9b7..fdaa3f3 100644
--- a/src/gallium/drivers/radeonsi/si_state_shaders.c
+++ b/src/gallium/drivers/radeonsi/si_state_shaders.c
@@ -527,7 +527,8 @@ static void si_shader_ps(struct si_shader *shader)
spi_shader_col_format = V_028714_SPI_SHADER_32_R;
 
si_pm4_set_reg(pm4, R_0286CC_SPI_PS_INPUT_ENA, input_ena);
-   si_pm4_set_reg(pm4, R_0286D0_SPI_PS_INPUT_ADDR, input_ena);
+   si_pm4_set_reg(pm4, R_0286D0_SPI_PS_INPUT_ADDR,
+  shader->config.spi_ps_input_addr);
 
/* Set interpolation controls. */
has_centroid = 
G_0286CC_PERSP_CENTROID_ENA(shader->config.spi_ps_input_ena) ||
-- 
2.1.4

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


[Mesa-dev] [PATCH 04/18] radeonsi: move BCOLOR PS input locations after all other inputs

2016-02-05 Thread Marek Olšák
From: Marek Olšák 

BCOLOR inputs were immediately after COLOR inputs. Thus, all following inputs
were offset by 1 if color_two_side was enabled, and not offset if it was not
enabled, which is a variation that's problematic if we want to have 1 variant
per shader and the variant doesn't care about color_two_side (that should be
handled by other bytecode attached at the beginning).

Instead, move BCOLOR inputs after all other inputs, so BCOLOR0 is at location
"num_inputs" if it's present. BCOLOR1 is next.

This also allows removing si_shader::nparam and
si_shader::ps_input_param_offset, which are useless now.
---
 src/gallium/drivers/radeonsi/si_shader.c| 25 ++--
 src/gallium/drivers/radeonsi/si_shader.h|  2 -
 src/gallium/drivers/radeonsi/si_state_shaders.c | 52 ++---
 3 files changed, 50 insertions(+), 29 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_shader.c 
b/src/gallium/drivers/radeonsi/si_shader.c
index d7f4f46..7925500 100644
--- a/src/gallium/drivers/radeonsi/si_shader.c
+++ b/src/gallium/drivers/radeonsi/si_shader.c
@@ -912,9 +912,7 @@ static void declare_input_fs(
 
unsigned chan;
 
-   shader->ps_input_param_offset[input_index] = shader->nparam++;
-   attr_number = lp_build_const_int32(gallivm,
-  
shader->ps_input_param_offset[input_index]);
+   attr_number = lp_build_const_int32(gallivm, input_index);
 
shader->ps_input_interpolate[input_index] = decl->Interp.Interpolate;
interp_param_idx = lookup_interp_param_index(decl->Interp.Interpolate,
@@ -938,11 +936,19 @@ static void declare_input_fs(
 
if (decl->Semantic.Name == TGSI_SEMANTIC_COLOR &&
si_shader_ctx->shader->key.ps.color_two_side) {
+   struct tgsi_shader_info *info = &shader->selector->info;
LLVMValueRef args[4];
LLVMValueRef face, is_face_positive;
-   LLVMValueRef back_attr_number =
-   lp_build_const_int32(gallivm,
-
shader->ps_input_param_offset[input_index] + 1);
+   LLVMValueRef back_attr_number;
+
+   /* If BCOLOR0 is used, BCOLOR1 is at offset "num_inputs + 1",
+* otherwise it's at offset "num_inputs".
+*/
+   unsigned back_attr_offset = shader->selector->info.num_inputs;
+   if (decl->Semantic.Index == 1 && info->colors_read & 0xf)
+   back_attr_offset += 1;
+
+   back_attr_number = lp_build_const_int32(gallivm, 
back_attr_offset);
 
face = LLVMGetParam(main_fn, SI_PARAM_FRONT_FACE);
 
@@ -974,8 +980,6 @@ static void declare_input_fs(
back,
"");
}
-
-   shader->nparam++;
} else if (decl->Semantic.Name == TGSI_SEMANTIC_FOG) {
LLVMValueRef args[4];
 
@@ -3280,8 +3284,7 @@ static void build_interp_intrinsic(const struct 
lp_build_tgsi_action *action,
else
interp_param = NULL;
 
-   attr_number = lp_build_const_int32(gallivm,
-  
shader->ps_input_param_offset[input_index]);
+   attr_number = lp_build_const_int32(gallivm, input_index);
 
if (inst->Instruction.Opcode == TGSI_OPCODE_INTERP_OFFSET ||
inst->Instruction.Opcode == TGSI_OPCODE_INTERP_SAMPLE) {
@@ -4337,8 +4340,6 @@ int si_shader_create(struct si_screen *sscreen, 
LLVMTargetMachineRef tm,
si_dump_streamout(&sel->so);
}
 
-   assert(shader->nparam == 0);
-
si_init_shader_ctx(&si_shader_ctx, sscreen, shader, tm,
   poly_stipple ? &stipple_shader_info : &sel->info);
 
diff --git a/src/gallium/drivers/radeonsi/si_shader.h 
b/src/gallium/drivers/radeonsi/si_shader.h
index 98bdb89..86d8f72 100644
--- a/src/gallium/drivers/radeonsi/si_shader.h
+++ b/src/gallium/drivers/radeonsi/si_shader.h
@@ -290,9 +290,7 @@ struct si_shader {
struct radeon_shader_binary binary;
struct si_shader_config config;
 
-   unsignednparam;
unsignedvs_output_param_offset[PIPE_MAX_SHADER_OUTPUTS];
-   unsignedps_input_param_offset[PIPE_MAX_SHADER_INPUTS];
unsignedps_input_interpolate[PIPE_MAX_SHADER_INPUTS];
booluses_instanceid;
unsignednr_pos_exports;
diff --git a/src/gallium/drivers/radeonsi/si_state_shaders.c 
b/src/gallium/drivers/radeonsi/si_state_shaders.c
index fbe0e37..d4ff1db 100644
--- a/src/gallium/drivers/radeonsi/si_state_shaders.c
+++ b/src/gallium/drivers/radeonsi/si_state_shaders.c
@@ -404,6 +404,18 @@ static void si_shader_vs(struct si_shader *shader, struct 
si_shader *gs)
si_set_tesseval_regs(shader, pm4);
 }
 
+stati

[Mesa-dev] [PATCH 03/18] radeonsi: move SPI_PS_INPUT_CNTL value computation to a separate function

2016-02-05 Thread Marek Olšák
From: Marek Olšák 

---
 src/gallium/drivers/radeonsi/si_state_shaders.c | 74 +
 1 file changed, 40 insertions(+), 34 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_state_shaders.c 
b/src/gallium/drivers/radeonsi/si_state_shaders.c
index 8613af2..fbe0e37 100644
--- a/src/gallium/drivers/radeonsi/si_state_shaders.c
+++ b/src/gallium/drivers/radeonsi/si_state_shaders.c
@@ -1087,14 +1087,50 @@ static void si_delete_shader_selector(struct 
pipe_context *ctx, void *state)
free(sel);
 }
 
+static unsigned si_get_ps_input_cntl(struct si_context *sctx,
+struct si_shader *vs, unsigned name,
+unsigned index, unsigned interpolate)
+{
+   struct tgsi_shader_info *vsinfo = &vs->selector->info;
+   unsigned j, tmp = 0;
+
+   if (interpolate == TGSI_INTERPOLATE_CONSTANT ||
+   (interpolate == TGSI_INTERPOLATE_COLOR && sctx->flatshade))
+   tmp |= S_028644_FLAT_SHADE(1);
+
+   if (name == TGSI_SEMANTIC_PCOORD ||
+   (name == TGSI_SEMANTIC_TEXCOORD &&
+sctx->sprite_coord_enable & (1 << index))) {
+   tmp |= S_028644_PT_SPRITE_TEX(1);
+   }
+
+   for (j = 0; j < vsinfo->num_outputs; j++) {
+   if (name == vsinfo->output_semantic_name[j] &&
+   index == vsinfo->output_semantic_index[j]) {
+   tmp |= S_028644_OFFSET(vs->vs_output_param_offset[j]);
+   break;
+   }
+   }
+
+   if (name == TGSI_SEMANTIC_PRIMID)
+   /* PrimID is written after the last output. */
+   tmp |= 
S_028644_OFFSET(vs->vs_output_param_offset[vsinfo->num_outputs]);
+   else if (j == vsinfo->num_outputs && !G_028644_PT_SPRITE_TEX(tmp)) {
+   /* No corresponding output found, load defaults into input.
+* Don't set any other bits.
+* (FLAT_SHADE=1 completely changes behavior) */
+   tmp = S_028644_OFFSET(0x20);
+   }
+   return tmp;
+}
+
 static void si_emit_spi_map(struct si_context *sctx, struct r600_atom *atom)
 {
struct radeon_winsys_cs *cs = sctx->b.gfx.cs;
struct si_shader *ps = sctx->ps_shader.current;
struct si_shader *vs = si_get_vs_state(sctx);
struct tgsi_shader_info *psinfo;
-   struct tgsi_shader_info *vsinfo = &vs->selector->info;
-   unsigned i, j, tmp, num_written = 0;
+   unsigned i, num_written = 0;
 
if (!ps || !ps->nparam)
return;
@@ -1109,38 +1145,8 @@ static void si_emit_spi_map(struct si_context *sctx, 
struct r600_atom *atom)
unsigned interpolate = psinfo->input_interpolate[i];
unsigned param_offset = ps->ps_input_param_offset[i];
 bcolor:
-   tmp = 0;
-
-   if (interpolate == TGSI_INTERPOLATE_CONSTANT ||
-   (interpolate == TGSI_INTERPOLATE_COLOR && sctx->flatshade))
-   tmp |= S_028644_FLAT_SHADE(1);
-
-   if (name == TGSI_SEMANTIC_PCOORD ||
-   (name == TGSI_SEMANTIC_TEXCOORD &&
-sctx->sprite_coord_enable & (1 << index))) {
-   tmp |= S_028644_PT_SPRITE_TEX(1);
-   }
-
-   for (j = 0; j < vsinfo->num_outputs; j++) {
-   if (name == vsinfo->output_semantic_name[j] &&
-   index == vsinfo->output_semantic_index[j]) {
-   tmp |= 
S_028644_OFFSET(vs->vs_output_param_offset[j]);
-   break;
-   }
-   }
-
-   if (name == TGSI_SEMANTIC_PRIMID)
-   /* PrimID is written after the last output. */
-   tmp |= 
S_028644_OFFSET(vs->vs_output_param_offset[vsinfo->num_outputs]);
-   else if (j == vsinfo->num_outputs && 
!G_028644_PT_SPRITE_TEX(tmp)) {
-   /* No corresponding output found, load defaults into 
input.
-* Don't set any other bits.
-* (FLAT_SHADE=1 completely changes behavior) */
-   tmp = S_028644_OFFSET(0x20);
-   }
-
-   assert(param_offset == num_written);
-   radeon_emit(cs, tmp);
+   radeon_emit(cs, si_get_ps_input_cntl(sctx, vs, name, index,
+interpolate));
num_written++;
 
if (name == TGSI_SEMANTIC_COLOR &&
-- 
2.1.4

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


[Mesa-dev] [PATCH 06/18] radeonsi: implement forcing per-sample_interpolation using the shader key only

2016-02-05 Thread Marek Olšák
From: Marek Olšák 

It was partly a state and partly emulated by shader code, but since we want
to do this in a fragment shader prolog, we need to put it into the shader
key, which will be used to generate the prolog.

This also removes the spi_ps_input states and moves the registers
to the PS state.
---
 src/gallium/drivers/radeonsi/si_hw_context.c|   1 -
 src/gallium/drivers/radeonsi/si_pipe.h  |   2 -
 src/gallium/drivers/radeonsi/si_shader.c|  46 +++---
 src/gallium/drivers/radeonsi/si_shader.h|  50 +--
 src/gallium/drivers/radeonsi/si_state.h |   1 -
 src/gallium/drivers/radeonsi/si_state_shaders.c | 107 ++--
 6 files changed, 55 insertions(+), 152 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_hw_context.c 
b/src/gallium/drivers/radeonsi/si_hw_context.c
index d60c451..b5a4034 100644
--- a/src/gallium/drivers/radeonsi/si_hw_context.c
+++ b/src/gallium/drivers/radeonsi/si_hw_context.c
@@ -182,7 +182,6 @@ void si_begin_new_cs(struct si_context *ctx)
si_mark_atom_dirty(ctx, &ctx->db_render_state);
si_mark_atom_dirty(ctx, &ctx->stencil_ref.atom);
si_mark_atom_dirty(ctx, &ctx->spi_map);
-   si_mark_atom_dirty(ctx, &ctx->spi_ps_input);
si_mark_atom_dirty(ctx, &ctx->b.streamout.enable_atom);
si_mark_atom_dirty(ctx, &ctx->b.render_cond_atom);
si_all_descriptors_begin_new_cs(ctx);
diff --git a/src/gallium/drivers/radeonsi/si_pipe.h 
b/src/gallium/drivers/radeonsi/si_pipe.h
index 4894744..3c963db 100644
--- a/src/gallium/drivers/radeonsi/si_pipe.h
+++ b/src/gallium/drivers/radeonsi/si_pipe.h
@@ -202,7 +202,6 @@ struct si_context {
struct si_viewports viewports;
struct si_stencil_ref   stencil_ref;
struct r600_atomspi_map;
-   struct r600_atomspi_ps_input;
 
/* Precomputed states. */
struct si_pm4_state *init_config;
@@ -222,7 +221,6 @@ struct si_context {
struct si_vertex_element*vertex_elements;
unsignedsprite_coord_enable;
boolflatshade;
-   boolforce_persample_interp;
 
/* shader descriptors */
struct si_descriptors   vertex_buffers;
diff --git a/src/gallium/drivers/radeonsi/si_shader.c 
b/src/gallium/drivers/radeonsi/si_shader.c
index c595f20..0a92a7b 100644
--- a/src/gallium/drivers/radeonsi/si_shader.c
+++ b/src/gallium/drivers/radeonsi/si_shader.c
@@ -833,14 +833,11 @@ static int lookup_interp_param_index(unsigned 
interpolate, unsigned location)
 }
 
 /* This shouldn't be used by explicit INTERP opcodes. */
-static LLVMValueRef get_interp_param(struct si_shader_context *si_shader_ctx,
-unsigned param)
+static unsigned select_interp_param(struct si_shader_context *si_shader_ctx,
+   unsigned param)
 {
-   struct gallivm_state *gallivm = &si_shader_ctx->radeon_bld.gallivm;
-   unsigned sample_param = 0;
-   LLVMValueRef default_ij, sample_ij, force_sample;
-
-   default_ij = LLVMGetParam(si_shader_ctx->radeon_bld.main_fn, param);
+   if (!si_shader_ctx->shader->key.ps.force_persample_interp)
+   return param;
 
/* If the shader doesn't use center/centroid, just return the parameter.
 *
@@ -850,36 +847,15 @@ static LLVMValueRef get_interp_param(struct 
si_shader_context *si_shader_ctx,
switch (param) {
case SI_PARAM_PERSP_CENTROID:
case SI_PARAM_PERSP_CENTER:
-   if 
(!si_shader_ctx->shader->selector->forces_persample_interp_for_persp)
-   return default_ij;
-
-   sample_param = SI_PARAM_PERSP_SAMPLE;
-   break;
+   return SI_PARAM_PERSP_SAMPLE;
 
case SI_PARAM_LINEAR_CENTROID:
case SI_PARAM_LINEAR_CENTER:
-   if 
(!si_shader_ctx->shader->selector->forces_persample_interp_for_linear)
-   return default_ij;
-
-   sample_param = SI_PARAM_LINEAR_SAMPLE;
-   break;
+   return SI_PARAM_LINEAR_SAMPLE;
 
default:
-   return default_ij;
+   return param;
}
-
-   /* Otherwise, we have to select (i,j) based on a user data SGPR. */
-   sample_ij = LLVMGetParam(si_shader_ctx->radeon_bld.main_fn, 
sample_param);
-
-   /* TODO: this can be done more efficiently by switching between
-* 2 prologs.
-*/
-   force_sample = LLVMGetParam(si_shader_ctx->radeon_bld.main_fn,
-   SI_PARAM_PS_STATE_BITS);
-   force_sample = LLVMBuildTrunc(gallivm->builder, force_sample,
- LLVMInt1TypeInContext(gallivm->context), 
"");
-   return LLVMBuildSelect(gallivm->builder, force_sample,
-  sample_ij, default_ij

[Mesa-dev] [PATCH 01/18] radeonsi: move si_shader_context initialization into a separate function

2016-02-05 Thread Marek Olšák
From: Marek Olšák 

This will be re-used later.
---
 src/gallium/drivers/radeonsi/si_shader.c | 103 ++-
 1 file changed, 60 insertions(+), 43 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_shader.c 
b/src/gallium/drivers/radeonsi/si_shader.c
index d9ed6b2..d7f4f46 100644
--- a/src/gallium/drivers/radeonsi/si_shader.c
+++ b/src/gallium/drivers/radeonsi/si_shader.c
@@ -4250,47 +4250,26 @@ void si_dump_shader_key(unsigned shader, union 
si_shader_key *key, FILE *f)
}
 }
 
-int si_shader_create(struct si_screen *sscreen, LLVMTargetMachineRef tm,
-struct si_shader *shader,
-struct pipe_debug_callback *debug)
+static void si_init_shader_ctx(struct si_shader_context *ctx,
+  struct si_screen *sscreen,
+  struct si_shader *shader,
+  LLVMTargetMachineRef tm,
+  struct tgsi_shader_info *info)
 {
-   struct si_shader_selector *sel = shader->selector;
-   struct tgsi_token *tokens = sel->tokens;
-   struct si_shader_context si_shader_ctx;
-   struct lp_build_tgsi_context * bld_base;
-   struct tgsi_shader_info stipple_shader_info;
-   LLVMModuleRef mod;
-   int r = 0;
-   bool poly_stipple = sel->type == PIPE_SHADER_FRAGMENT &&
-   shader->key.ps.poly_stipple;
-   bool dump = r600_can_dump_shader(&sscreen->b, sel->info.processor);
-
-   if (poly_stipple) {
-   tokens = util_pstipple_create_fragment_shader(tokens, NULL,
-   SI_POLY_STIPPLE_SAMPLER,
-   TGSI_FILE_SYSTEM_VALUE);
-   tgsi_scan_shader(tokens, &stipple_shader_info);
-   }
-
-   /* Dump TGSI code before doing TGSI->LLVM conversion in case the
-* conversion fails. */
-   if (dump && !(sscreen->b.debug_flags & DBG_NO_TGSI)) {
-   si_dump_shader_key(sel->type, &shader->key, stderr);
-   tgsi_dump(tokens, 0);
-   si_dump_streamout(&sel->so);
-   }
-
-   assert(shader->nparam == 0);
-
-   memset(&si_shader_ctx, 0, sizeof(si_shader_ctx));
-   radeon_llvm_context_init(&si_shader_ctx.radeon_bld);
-   bld_base = &si_shader_ctx.radeon_bld.soa.bld_base;
-
-   if (sel->type != PIPE_SHADER_COMPUTE)
-   shader->dx10_clamp_mode = true;
+   struct lp_build_tgsi_context *bld_base;
+
+   memset(ctx, 0, sizeof(*ctx));
+   radeon_llvm_context_init(&ctx->radeon_bld);
+   ctx->tm = tm;
+   ctx->screen = sscreen;
+   if (shader && shader->selector)
+   ctx->type = shader->selector->info.processor;
+   else
+   ctx->type = -1;
+   ctx->shader = shader;
 
-   shader->uses_instanceid = sel->info.uses_instanceid;
-   bld_base->info = poly_stipple ? &stipple_shader_info : &sel->info;
+   bld_base = &ctx->radeon_bld.soa.bld_base;
+   bld_base->info = info;
bld_base->emit_fetch_funcs[TGSI_FILE_CONSTANT] = fetch_constant;
 
bld_base->op_actions[TGSI_OPCODE_INTERP_CENTROID] = interp_action;
@@ -4326,12 +4305,50 @@ int si_shader_create(struct si_screen *sscreen, 
LLVMTargetMachineRef tm,
bld_base->op_actions[TGSI_OPCODE_MIN].emit = 
build_tgsi_intrinsic_nomem;
bld_base->op_actions[TGSI_OPCODE_MIN].intr_name = 
"llvm.minnum.f32";
}
+}
 
+int si_shader_create(struct si_screen *sscreen, LLVMTargetMachineRef tm,
+struct si_shader *shader,
+struct pipe_debug_callback *debug)
+{
+   struct si_shader_selector *sel = shader->selector;
+   struct tgsi_token *tokens = sel->tokens;
+   struct si_shader_context si_shader_ctx;
+   struct lp_build_tgsi_context * bld_base;
+   struct tgsi_shader_info stipple_shader_info;
+   LLVMModuleRef mod;
+   int r = 0;
+   bool poly_stipple = sel->type == PIPE_SHADER_FRAGMENT &&
+   shader->key.ps.poly_stipple;
+   bool dump = r600_can_dump_shader(&sscreen->b, sel->info.processor);
+
+   if (poly_stipple) {
+   tokens = util_pstipple_create_fragment_shader(tokens, NULL,
+   SI_POLY_STIPPLE_SAMPLER,
+   TGSI_FILE_SYSTEM_VALUE);
+   tgsi_scan_shader(tokens, &stipple_shader_info);
+   }
+
+   /* Dump TGSI code before doing TGSI->LLVM conversion in case the
+* conversion fails. */
+   if (dump && !(sscreen->b.debug_flags & DBG_NO_TGSI)) {
+   si_dump_shader_key(sel->type, &shader->key, stderr);
+   tgsi_dump(tokens, 0);
+   si_dump_streamout(&sel->so);
+   }
+
+   assert(shader->nparam == 0);
+
+   si_init_shader_ctx(&si_shader_ctx, sscreen, shader, tm,
+  poly_stipple ? &stipple_sh

[Mesa-dev] [PATCH 00/18] RadeonSI: Restructuring shader codegen part 3

2016-02-05 Thread Marek Olšák
Hi,

This is the last part of restructuring needed for having one shader variant per 
shader.

Summary:
- a lot of changes are about PS inputs and interpolation
- code movements, cleanups

Behavior changes:
- removed unnecessary MRT_NULL exports
- geometry shaders aren't compiled on demand

Please review.

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


Re: [Mesa-dev] [PATCH] list-workarounds: Extend the script to Mesa

2016-02-05 Thread Kibey, Sameer

> -Original Message-
> From: Lespiau, Damien
> Sent: Friday, February 05, 2016 4:16 AM
> To: Kibey, Sameer
> Cc: intel-...@lists.freedesktop.org; mesa-dev@lists.freedesktop.org; Sharp,
> Sarah A; Widawsky, Benjamin
> Subject: Re: [PATCH] list-workarounds: Extend the script to Mesa
> 
> On Thu, Feb 04, 2016 at 06:14:02PM +, Kibey, Sameer wrote:
> > Updated the list-workarounds script so that it can parse Mesa
> > directory if provided. Moved the common code to a separate function to
> > allow reuse for both kernel and mesa.
> >
> > The new command line is:
> > Usage: list-workarounds [options] path-to-kernel
> >-k path-to-kernel -m path-to-mesa
> >
> > The legacy usage is retained to avoid breaking backwards
> > compatibility. New parameters -k and -m are added for the new
> > behavior.
> >
> > Either kernel or mesa or both paths can be specified.
> > If path-to-mesa is invalid, error is reported.
> >
> > Signed-off-by: Sameer Kibey 
> 
> Out of curiosity, how did you send the email? It doesn't seem to have been
> sent with git send-email and so the patch isn't picked up by our patchwork
> instance.

I sent the email manually, but will use git send-email next time. 

> Out of the comments below, I guess the only serious one is allowing both
> byt/vlv, but maybe mesa only uses one of the two? I wouldn't mind landing
> the patch with that answered.

I will replace byt with vlv to keep it consistent. 

> > ---
> >  scripts/list-workarounds | 75
> > ++--
> >  1 file changed, 54 insertions(+), 21 deletions(-)
> >
> > diff --git a/scripts/list-workarounds b/scripts/list-workarounds index
> > d11b6a9..0b63541 100755
> > --- a/scripts/list-workarounds
> > +++ b/scripts/list-workarounds
> > @@ -18,7 +18,7 @@ def find_nth(haystack, needle, n):
> > return start
> >
> >  valid_platforms = ('ctg', 'elk', 'ilk', 'snb', 'ivb', 'vlv', 'hsw', 'bdw',
> > -  'chv', 'skl', 'bxt')
> > +  'chv', 'skl', 'bxt', 'kbl', 'byt')
> 
> Do we really need both byt and vlv? that creates two different names for the
> same platform, which sounds like a recipe to have the actual set of W/As for
> this platform be the union of vlv and byt ones.

Agree, will remove byt. 

> >  def parse_platforms(line, p):
> > l =  p.split(',')
> > for p in l:
> > @@ -65,9 +65,15 @@ def execute(cmd):
> > return out, err
> >
> >  def parse_options(args):
> > -   usage = "Usage: list-workarounds [options] path-to-kernel"
> > +   usage = "Usage: list-workarounds [options] path-to-kernel -k path-
> to-kernel -m path-to-mesa"
> > parser = optparse.OptionParser(usage, version=1.0)
> 
> Quite frankly, I'd just remove the old behaviour.

Originally I had removed the old behavior. Ben suggested keeping it in case 
some people have it in other scripts. 

> > +   parser.add_option("-k", "--kernel-path", dest="kernel_path",
> default=None,
> > + help="path to kernel")
> > +
> > +   parser.add_option("-m", "--mesa-path", dest="mesa_path",
> default=None,
> > + help="path to mesa")
> > +
> > parser.add_option("-v", "--verbose", action="store_true",
> >   dest="verbose", default=False,
> >   help="be more verbose")
> > @@ -76,30 +82,14 @@ def parse_options(args):
> >   help="List workarounds for the specified platform")
> >
> > (options, args) = parser.parse_args()
> > -
> > return (options, args)
> >
> > -if __name__ == '__main__':
> > -   (options, args) = parse_options(sys.argv[1:])
> > -   verbose = options.verbose
> > -
> > -   if not len(args):
> > -   sys.stderr.write("error: A path to a kernel tree is
> required\n")
> > -   sys.exit(1)
> > -
> > -   kernel_path = args[0]
> > -   kconfig = os.path.join(kernel_path, 'Kconfig')
> > -   if not os.path.isfile(kconfig):
> > -   sys.stderr.write("error: %s does not point to a kernel tree \n"
> > -% kernel_path)
> > -   sys.exit(1)
> > -
> > -   i915_dir = os.path.join('drivers', 'gpu', 'drm', 'i915')
> > +def print_workarounds(code_path, driver_dir):
> > olddir = os.getcwd()
> > -   os.chdir(kernel_path)
> > +   os.chdir(code_path)
> 
> project_root?

Will change to project_root

> > work_arounds, err = execute(['git', 'grep', '-n',
> >  '-e', 'W[aA][A-Z0-9][a-zA-Z0-9_]\+',
> > -i915_dir])
> > +driver_dir])
> > os.chdir(olddir)
> > if err:
> > print(err)
> > @@ -111,3 +101,46 @@ if __name__ == '__main__':
> > print("%s: %s" % (wa, ', '.join(workarounds[wa])))
> > elif options.platform in workarounds[wa]:
> > print(wa)
> > +
> > +
> > +if __name__ == '__main__':
> > +   (options, args) = parse_options(sys.argv)
> > +   verbose = options.verbose
> > +   kernel_path = None
> > +

  1   2   >