Mesa (master): mesa: add fragdata_arrays list to gl_shader

2015-10-29 Thread Tapani Pälli
Module: Mesa
Branch: master
Commit: 6ce0857e30a8484f1b190ccf37631d64e629a468
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=6ce0857e30a8484f1b190ccf37631d64e629a468

Author: Tapani Pälli 
Date:   Tue Oct 27 13:18:41 2015 +0200

mesa: add fragdata_arrays list to gl_shader

This is required to store information about fragdata arrays, currently
these variables get lost and cannot be retrieved later in sensible way
for program interface queries. List will be utilized by next patch.

Patch also modifies opt_dead_builtin_varyings pass to build list when
lowering fragdata arrays. This is identical approach as taken with
packed varyings pass.

Signed-off-by: Tapani Pälli 
Reviewed-by: Marta Lofstedt 

---

 src/glsl/opt_dead_builtin_varyings.cpp |   42 
 src/mesa/main/mtypes.h |1 +
 2 files changed, 27 insertions(+), 16 deletions(-)

diff --git a/src/glsl/opt_dead_builtin_varyings.cpp 
b/src/glsl/opt_dead_builtin_varyings.cpp
index 31719d2..68b70ee 100644
--- a/src/glsl/opt_dead_builtin_varyings.cpp
+++ b/src/glsl/opt_dead_builtin_varyings.cpp
@@ -269,14 +269,14 @@ public:
  */
 class replace_varyings_visitor : public ir_rvalue_visitor {
 public:
-   replace_varyings_visitor(exec_list *ir,
+   replace_varyings_visitor(struct gl_shader *sha,
 const varying_info_visitor *info,
 unsigned external_texcoord_usage,
 unsigned external_color_usage,
 bool external_has_fog)
-  : info(info), new_fog(NULL)
+  : shader(sha), info(info), new_fog(NULL)
{
-  void *const ctx = ir;
+  void *const ctx = shader->ir;
 
   memset(this->new_fragdata, 0, sizeof(this->new_fragdata));
   memset(this->new_texcoord, 0, sizeof(this->new_texcoord));
@@ -293,14 +293,16 @@ public:
* occurrences of gl_TexCoord will be replaced with.
*/
   if (info->lower_texcoord_array) {
- prepare_array(ir, this->new_texcoord, ARRAY_SIZE(this->new_texcoord),
+ prepare_array(shader->ir, this->new_texcoord,
+   ARRAY_SIZE(this->new_texcoord),
VARYING_SLOT_TEX0, "TexCoord", mode_str,
info->texcoord_usage, external_texcoord_usage);
   }
 
   /* Handle gl_FragData in the same way like gl_TexCoord. */
   if (info->lower_fragdata_array) {
- prepare_array(ir, this->new_fragdata, ARRAY_SIZE(this->new_fragdata),
+ prepare_array(shader->ir, this->new_fragdata,
+   ARRAY_SIZE(this->new_fragdata),
FRAG_RESULT_DATA0, "FragData", mode_str,
info->fragdata_usage, (1 << MAX_DRAW_BUFFERS) - 1);
   }
@@ -340,7 +342,7 @@ public:
   }
 
   /* Now do the replacing. */
-  visit_list_elements(this, ir);
+  visit_list_elements(this, shader->ir);
}
 
void prepare_array(exec_list *ir,
@@ -389,6 +391,13 @@ public:
   /* Remove the gl_FragData array. */
   if (this->info->lower_fragdata_array &&
   var == this->info->fragdata_array) {
+
+ /* Clone variable for program resource list before it is removed. */
+ if (!shader->fragdata_arrays)
+shader->fragdata_arrays = new (shader) exec_list;
+
+ shader->fragdata_arrays->push_tail(var->clone(shader, NULL));
+
  var->remove();
   }
 
@@ -487,6 +496,7 @@ public:
}
 
 private:
+   struct gl_shader *shader;
const varying_info_visitor *info;
ir_variable *new_fragdata[MAX_DRAW_BUFFERS];
ir_variable *new_texcoord[MAX_TEXTURE_COORD_UNITS];
@@ -498,20 +508,20 @@ private:
 } /* anonymous namespace */
 
 static void
-lower_texcoord_array(exec_list *ir, const varying_info_visitor *info)
+lower_texcoord_array(struct gl_shader *shader, const varying_info_visitor 
*info)
 {
-   replace_varyings_visitor(ir, info,
+   replace_varyings_visitor(shader, info,
 (1 << MAX_TEXTURE_COORD_UNITS) - 1,
 1 | 2, true);
 }
 
 static void
-lower_fragdata_array(exec_list *ir)
+lower_fragdata_array(struct gl_shader *shader)
 {
varying_info_visitor info(ir_var_shader_out, true);
-   info.get(ir, 0, NULL);
+   info.get(shader->ir, 0, NULL);
 
-   replace_varyings_visitor(ir, , 0, 0, 0);
+   replace_varyings_visitor(shader, , 0, 0, 0);
 }
 
 
@@ -523,7 +533,7 @@ do_dead_builtin_varyings(struct gl_context *ctx,
 {
/* Lower the gl_FragData array to separate variables. */
if (consumer && consumer->Stage == MESA_SHADER_FRAGMENT) {
-  lower_fragdata_array(consumer->ir);
+  lower_fragdata_array(consumer);
}
 
/* Lowering of built-in varyings has no effect with the core context and
@@ -544,7 +554,7 @@ do_dead_builtin_varyings(struct gl_context *ctx,
   if (!consumer) {
  /* At least eliminate unused gl_TexCoord 

Mesa (master): glsl: add fragdata arrays to program resource list

2015-10-29 Thread Tapani Pälli
Module: Mesa
Branch: master
Commit: afbe8b6085c4761c25b7bc49a051a08e10a87805
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=afbe8b6085c4761c25b7bc49a051a08e10a87805

Author: Tapani Pälli 
Date:   Tue Oct 27 13:18:42 2015 +0200

glsl: add fragdata arrays to program resource list

This makes sure that user is still able to query properties about
variables that have gotten removed by opt_dead_builtin_varyings pass.

Fixes following OpenGL ES 3.1 test:
   ES31-CTS.program_interface_query.output-layout

No Piglit regressions.

v2: cleanup, drop extra parenthesis (Topi)

Signed-off-by: Tapani Pälli 
Reviewed-by: Marta Lofstedt 

---

 src/glsl/linker.cpp |   29 +
 1 file changed, 29 insertions(+)

diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp
index cfd8f81..48dd2d3 100644
--- a/src/glsl/linker.cpp
+++ b/src/glsl/linker.cpp
@@ -3386,6 +3386,12 @@ add_interface_variables(struct gl_shader_program *shProg,
   if (strncmp(var->name, "packed:", 7) == 0)
  continue;
 
+  /* Skip fragdata arrays, these are handled separately
+   * by add_fragdata_arrays.
+   */
+  if (strncmp(var->name, "gl_out_FragData", 15) == 0)
+ continue;
+
   if (!add_program_resource(shProg, programInterface, var,
 build_stageref(shProg, var->name,
var->data.mode) | mask))
@@ -3425,6 +3431,26 @@ add_packed_varyings(struct gl_shader_program *shProg, 
int stage)
return true;
 }
 
+static bool
+add_fragdata_arrays(struct gl_shader_program *shProg)
+{
+   struct gl_shader *sh = shProg->_LinkedShaders[MESA_SHADER_FRAGMENT];
+
+   if (!sh || !sh->fragdata_arrays)
+  return true;
+
+   foreach_in_list(ir_instruction, node, sh->fragdata_arrays) {
+  ir_variable *var = node->as_variable();
+  if (var) {
+ assert(var->data.mode == ir_var_shader_out);
+ if (!add_program_resource(shProg, GL_PROGRAM_OUTPUT, var,
+   1 << MESA_SHADER_FRAGMENT))
+return false;
+  }
+   }
+   return true;
+}
+
 static char*
 get_top_level_name(const char *name)
 {
@@ -3701,6 +3727,9 @@ build_program_resource_list(struct gl_shader_program 
*shProg)
  return;
}
 
+   if (!add_fragdata_arrays(shProg))
+  return;
+
/* Add inputs and outputs to the resource list. */
if (!add_interface_variables(shProg, 
shProg->_LinkedShaders[input_stage]->ir,
 GL_PROGRAM_INPUT))

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


Mesa (master): st/mesa: create temporary textures with the same nr_samples as source

2015-10-29 Thread Ilia Mirkin
Module: Mesa
Branch: master
Commit: 6166a8e369b86395ffec7229257f797662f9d1aa
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=6166a8e369b86395ffec7229257f797662f9d1aa

Author: Ilia Mirkin 
Date:   Wed Oct 28 15:38:53 2015 -0400

st/mesa: create temporary textures with the same nr_samples as source

Not sure if this is actually reachable in practice (to have a complex
copy with MS textures).

Signed-off-by: Ilia Mirkin 
Reviewed-by: Marek Olšák 

---

 src/mesa/state_tracker/st_cb_copyimage.c |8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/mesa/state_tracker/st_cb_copyimage.c 
b/src/mesa/state_tracker/st_cb_copyimage.c
index c94a0b2..75114cd 100644
--- a/src/mesa/state_tracker/st_cb_copyimage.c
+++ b/src/mesa/state_tracker/st_cb_copyimage.c
@@ -359,6 +359,7 @@ same_size_and_swizzle(const struct util_format_description 
*d1,
 
 static struct pipe_resource *
 create_texture(struct pipe_screen *screen, enum pipe_format format,
+   unsigned nr_samples,
unsigned width, unsigned height, unsigned depth)
 {
struct pipe_resource templ;
@@ -369,6 +370,7 @@ create_texture(struct pipe_screen *screen, enum pipe_format 
format,
templ.height0 = height;
templ.depth0 = 1;
templ.array_size = depth;
+   templ.nr_samples = nr_samples;
templ.usage = PIPE_USAGE_DEFAULT;
templ.bind = PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_RENDER_TARGET;
 
@@ -439,7 +441,8 @@ handle_complex_copy(struct pipe_context *pipe,
   /* Use the temporary texture. Src is converted to a canonical format,
* then proceed the generic swizzled_copy.
*/
-  temp = create_texture(pipe->screen, canon_format, src_box->width,
+  temp = create_texture(pipe->screen, canon_format, src->nr_samples,
+src_box->width,
 src_box->height, src_box->depth);
 
   u_box_3d(0, 0, 0, src_box->width, src_box->height, src_box->depth,
@@ -463,7 +466,8 @@ handle_complex_copy(struct pipe_context *pipe,
 
   /* Use the temporary texture. First, use the generic copy, but use
* a canonical format in the destination. Then convert */
-  temp = create_texture(pipe->screen, canon_format, src_box->width,
+  temp = create_texture(pipe->screen, canon_format, dst->nr_samples,
+src_box->width,
 src_box->height, src_box->depth);
 
   u_box_3d(0, 0, 0, src_box->width, src_box->height, src_box->depth,

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


Mesa (master): mesa: Enable ASTC in GLES' [NUM_] COMPRESSED_TEXTURE_FORMATS queries

2015-10-29 Thread Nanley Chery
Module: Mesa
Branch: master
Commit: 65f6caf43e8bbea7c8a0d4e146ad7186c276ff9a
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=65f6caf43e8bbea7c8a0d4e146ad7186c276ff9a

Author: Nanley Chery 
Date:   Wed Oct 14 14:32:43 2015 -0700

mesa: Enable ASTC in GLES' [NUM_]COMPRESSED_TEXTURE_FORMATS queries

In OpenGL ES, the COMPRESSED_TEXTURE_FORMATS query returns the set of
supported specific compressed formats. Since ASTC formats fit within
that category, include them in the set and update the
NUM_COMPRESSED_TEXTURE_FORMATS query as well.

This enables GLES2-based ASTC dEQP tests to run. See the Bugzilla for
more info.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=92193
Reported-by: Tapani Pälli 
Suggested-by: Ian Romanick 
Signed-off-by: Nanley Chery 
Reviewed-by: Ian Romanick 

---

 src/mesa/main/texcompress.c |   85 ---
 1 file changed, 63 insertions(+), 22 deletions(-)

diff --git a/src/mesa/main/texcompress.c b/src/mesa/main/texcompress.c
index 7fcaa42..a8ac19e 100644
--- a/src/mesa/main/texcompress.c
+++ b/src/mesa/main/texcompress.c
@@ -243,28 +243,6 @@ _mesa_gl_compressed_format_base_format(GLenum format)
  *what GL_NUM_COMPRESSED_TEXTURE_FORMATS and
  *GL_COMPRESSED_TEXTURE_FORMATS return."
  *
- * The KHR_texture_compression_astc_hdr spec says:
- *
- *"Interactions with OpenGL 4.2
- *
- *OpenGL 4.2 supports the feature that compressed textures can be
- *compressed online, by passing the compressed texture format enum as
- *the internal format when uploading a texture using TexImage1D,
- *TexImage2D or TexImage3D (see Section 3.9.3, Texture Image
- *Specification, subsection Encoding of Special Internal Formats).
- *
- *Due to the complexity of the ASTC compression algorithm, it is not
- *usually suitable for online use, and therefore ASTC support will be
- *limited to pre-compressed textures only. Where on-device compression
- *is required, a domain-specific limited compressor will typically
- *be used, and this is therefore not suitable for implementation in
- *the driver.
- *
- *In particular, the ASTC format specifiers will not be added to
- *Table 3.14, and thus will not be accepted by the TexImage*D
- *functions, and will not be returned by the (already deprecated)
- *COMPRESSED_TEXTURE_FORMATS query."
- *
  * There is no formal spec for GL_ATI_texture_compression_3dc.  Since the
  * formats added by this extension are luminance-alpha formats, it is
  * reasonable to expect them to follow the same rules as
@@ -397,6 +375,69 @@ _mesa_get_compressed_formats(struct gl_context *ctx, GLint 
*formats)
  n += 10;
   }
}
+
+   /* The KHR_texture_compression_astc_hdr spec says:
+*
+*"Interactions with OpenGL 4.2
+*
+*OpenGL 4.2 supports the feature that compressed textures can be
+*compressed online, by passing the compressed texture format enum 
as
+*the internal format when uploading a texture using TexImage1D,
+*TexImage2D or TexImage3D (see Section 3.9.3, Texture Image
+*Specification, subsection Encoding of Special Internal Formats).
+*
+*Due to the complexity of the ASTC compression algorithm, it is not
+*usually suitable for online use, and therefore ASTC support will 
be
+*limited to pre-compressed textures only. Where on-device 
compression
+*is required, a domain-specific limited compressor will typically
+*be used, and this is therefore not suitable for implementation in
+*the driver.
+*
+*In particular, the ASTC format specifiers will not be added to
+*Table 3.14, and thus will not be accepted by the TexImage*D
+*functions, and will not be returned by the (already deprecated)
+*COMPRESSED_TEXTURE_FORMATS query."
+*
+* The ES and the desktop specs diverge here. In OpenGL ES, the 
COMPRESSED_TEXTURE_FORMATS
+* query returns the set of supported specific compressed formats.
+*/
+   if (ctx->API == API_OPENGLES2 &&
+   ctx->Extensions.KHR_texture_compression_astc_ldr) {
+  if (formats) {
+ formats[n++] = GL_COMPRESSED_RGBA_ASTC_4x4_KHR;
+ formats[n++] = GL_COMPRESSED_RGBA_ASTC_5x4_KHR;
+ formats[n++] = GL_COMPRESSED_RGBA_ASTC_5x5_KHR;
+ formats[n++] = GL_COMPRESSED_RGBA_ASTC_6x5_KHR;
+ formats[n++] = GL_COMPRESSED_RGBA_ASTC_6x6_KHR;
+ formats[n++] = GL_COMPRESSED_RGBA_ASTC_8x5_KHR;
+ formats[n++] = GL_COMPRESSED_RGBA_ASTC_8x6_KHR;
+ formats[n++] = GL_COMPRESSED_RGBA_ASTC_8x8_KHR;
+ formats[n++] = GL_COMPRESSED_RGBA_ASTC_10x5_KHR;
+ formats[n++] = 

Mesa (master): r600g: Fix special negative immediate constants when using ABS modifier.

2015-10-29 Thread Nicolai Hähnle
Module: Mesa
Branch: master
Commit: f75f21a24ae2dd83507f3d4d8007f0fcfe6db802
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=f75f21a24ae2dd83507f3d4d8007f0fcfe6db802

Author: Ivan Kalvachev 
Date:   Sun Oct 25 01:16:58 2015 +0300

r600g: Fix special negative immediate constants when using ABS modifier.

Some constants (like 1.0 and 0.5) could be inlined as immediate inputs
without using their literal value. The r600_bytecode_special_constants()
function emulates the negative of these constants by using NEG modifier.

However some shaders define -1.0 constant and want to use it as 1.0.
They do so by using ABS modifier. But r600_bytecode_special_constants()
set NEG in addition to ABS. Since NEG modifier have priority over ABS one,
we get -|1.0| as result, instead of |1.0|.

The patch simply prevents the additional switching of NEG when ABS is set.

[According to Ivan Kalvachev, this bug was fond via
https://github.com/iXit/Mesa-3D/issues/126 and
https://github.com/iXit/Mesa-3D/issues/127]

Signed-off-by: Ivan Kalvachev 
Reviewed-by: Nicolai Hähnle 
CC: 

---

 src/gallium/drivers/r600/r600_asm.c|8 
 src/gallium/drivers/r600/r600_asm.h|2 +-
 src/gallium/drivers/r600/r600_shader.c |2 +-
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/gallium/drivers/r600/r600_asm.c 
b/src/gallium/drivers/r600/r600_asm.c
index bc69806..ee7beee 100644
--- a/src/gallium/drivers/r600/r600_asm.c
+++ b/src/gallium/drivers/r600/r600_asm.c
@@ -635,7 +635,7 @@ static int replace_gpr_with_pv_ps(struct r600_bytecode *bc,
return 0;
 }
 
-void r600_bytecode_special_constants(uint32_t value, unsigned *sel, unsigned 
*neg)
+void r600_bytecode_special_constants(uint32_t value, unsigned *sel, unsigned 
*neg, unsigned abs)
 {
switch(value) {
case 0:
@@ -655,11 +655,11 @@ void r600_bytecode_special_constants(uint32_t value, 
unsigned *sel, unsigned *ne
break;
case 0xBF80: /* -1.0f */
*sel = V_SQ_ALU_SRC_1;
-   *neg ^= 1;
+   *neg ^= !abs;
break;
case 0xBF00: /* -0.5f */
*sel = V_SQ_ALU_SRC_0_5;
-   *neg ^= 1;
+   *neg ^= !abs;
break;
default:
*sel = V_SQ_ALU_SRC_LITERAL;
@@ -1208,7 +1208,7 @@ int r600_bytecode_add_alu_type(struct r600_bytecode *bc,
}
if (nalu->src[i].sel == V_SQ_ALU_SRC_LITERAL)
r600_bytecode_special_constants(nalu->src[i].value,
-   >src[i].sel, >src[i].neg);
+   >src[i].sel, >src[i].neg, 
nalu->src[i].abs);
}
if (nalu->dst.sel >= bc->ngpr) {
bc->ngpr = nalu->dst.sel + 1;
diff --git a/src/gallium/drivers/r600/r600_asm.h 
b/src/gallium/drivers/r600/r600_asm.h
index 7cf3a09..d48ad1e 100644
--- a/src/gallium/drivers/r600/r600_asm.h
+++ b/src/gallium/drivers/r600/r600_asm.h
@@ -255,7 +255,7 @@ int r600_bytecode_add_cfinst(struct r600_bytecode *bc,
 int r600_bytecode_add_alu_type(struct r600_bytecode *bc,
const struct r600_bytecode_alu *alu, unsigned type);
 void r600_bytecode_special_constants(uint32_t value,
-   unsigned *sel, unsigned *neg);
+   unsigned *sel, unsigned *neg, unsigned abs);
 void r600_bytecode_disasm(struct r600_bytecode *bc);
 void r600_bytecode_alu_read(struct r600_bytecode *bc,
struct r600_bytecode_alu *alu, uint32_t word0, uint32_t word1);
diff --git a/src/gallium/drivers/r600/r600_shader.c 
b/src/gallium/drivers/r600/r600_shader.c
index 8efe902..50c0329 100644
--- a/src/gallium/drivers/r600/r600_shader.c
+++ b/src/gallium/drivers/r600/r600_shader.c
@@ -1008,7 +1008,7 @@ static void tgsi_src(struct r600_shader_ctx *ctx,
(tgsi_src->Register.SwizzleX == 
tgsi_src->Register.SwizzleW)) {
 
index = tgsi_src->Register.Index * 4 + 
tgsi_src->Register.SwizzleX;
-   r600_bytecode_special_constants(ctx->literals[index], 
_src->sel, _src->neg);
+   r600_bytecode_special_constants(ctx->literals[index], 
_src->sel, _src->neg, r600_src->abs);
if (r600_src->sel != V_SQ_ALU_SRC_LITERAL)
return;
}

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


Mesa (master): st/mesa: fix mipmap generation for immutable textures with incomplete pyramids

2015-10-29 Thread Nicolai Hähnle
Module: Mesa
Branch: master
Commit: 24c90888aeaf90b13700389b91b74bf63ee9f28d
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=24c90888aeaf90b13700389b91b74bf63ee9f28d

Author: Nicolai Hähnle 
Date:   Fri Oct 23 01:06:15 2015 +0200

st/mesa: fix mipmap generation for immutable textures with incomplete pyramids

Without the clamping by NumLevels, the state tracker would reallocate the
texture storage (incorrect) and even fail to copy the base level image
after reallocation, leading to the graphical glitch of
https://bugs.freedesktop.org/show_bug.cgi?id=91993 .

A piglit test has been submitted for review as well (subtest of
arb_texture_storage-texture-storage).

v2: also bypass all calls to st_finalize_texture (suggested by Marek Olšák)

Cc: mesa-sta...@lists.freedesktop.org
Reviewed-by: Marek Olšák 

---

 src/mesa/state_tracker/st_gen_mipmap.c |   68 +---
 1 file changed, 36 insertions(+), 32 deletions(-)

diff --git a/src/mesa/state_tracker/st_gen_mipmap.c 
b/src/mesa/state_tracker/st_gen_mipmap.c
index 26e1c21..b370040 100644
--- a/src/mesa/state_tracker/st_gen_mipmap.c
+++ b/src/mesa/state_tracker/st_gen_mipmap.c
@@ -61,6 +61,8 @@ compute_num_levels(struct gl_context *ctx,
 
numLevels = texObj->BaseLevel + baseImage->MaxNumLevels;
numLevels = MIN2(numLevels, (GLuint) texObj->MaxLevel + 1);
+   if (texObj->Immutable)
+  numLevels = MIN2(numLevels, texObj->NumLevels);
assert(numLevels >= 1);
 
return numLevels;
@@ -99,38 +101,40 @@ st_generate_mipmap(struct gl_context *ctx, GLenum target,
 */
stObj->lastLevel = lastLevel;
 
-   if (pt->last_level < lastLevel) {
-  /* The current gallium texture doesn't have space for all the
-   * mipmap levels we need to generate.  So allocate a new texture.
-   */
-  struct pipe_resource *oldTex = stObj->pt;
-
-  /* create new texture with space for more levels */
-  stObj->pt = st_texture_create(st,
-oldTex->target,
-oldTex->format,
-lastLevel,
-oldTex->width0,
-oldTex->height0,
-oldTex->depth0,
-oldTex->array_size,
-0,
-oldTex->bind);
-
-  /* This will copy the old texture's base image into the new texture
-   * which we just allocated.
-   */
-  st_finalize_texture(ctx, st->pipe, texObj);
-
-  /* release the old tex (will likely be freed too) */
-  pipe_resource_reference(, NULL);
-  st_texture_release_all_sampler_views(st, stObj);
-   }
-   else {
-  /* Make sure that the base texture image data is present in the
-   * texture buffer.
-   */
-  st_finalize_texture(ctx, st->pipe, texObj);
+   if (!texObj->Immutable) {
+  if (pt->last_level < lastLevel) {
+ /* The current gallium texture doesn't have space for all the
+ * mipmap levels we need to generate.  So allocate a new texture.
+ */
+ struct pipe_resource *oldTex = stObj->pt;
+
+ /* create new texture with space for more levels */
+ stObj->pt = st_texture_create(st,
+   oldTex->target,
+   oldTex->format,
+   lastLevel,
+   oldTex->width0,
+   oldTex->height0,
+   oldTex->depth0,
+   oldTex->array_size,
+   0,
+   oldTex->bind);
+
+ /* This will copy the old texture's base image into the new texture
+ * which we just allocated.
+ */
+ st_finalize_texture(ctx, st->pipe, texObj);
+
+ /* release the old tex (will likely be freed too) */
+ pipe_resource_reference(, NULL);
+ st_texture_release_all_sampler_views(st, stObj);
+  }
+  else {
+ /* Make sure that the base texture image data is present in the
+ * texture buffer.
+ */
+ st_finalize_texture(ctx, st->pipe, texObj);
+  }
}
 
pt = stObj->pt;

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


Mesa (master): nvc0: expose a group of performance metrics on Fermi

2015-10-29 Thread Samuel Pitoiset
Module: Mesa
Branch: master
Commit: 0260620ab35615838a76bf218788adc957212934
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=0260620ab35615838a76bf218788adc957212934

Author: Samuel Pitoiset 
Date:   Wed Oct 28 11:20:36 2015 +0100

nvc0: expose a group of performance metrics on Fermi

This allows to monitor those performance metrics through
GL_AMD_performance_monitor.

Signed-off-by: Samuel Pitoiset 

---

 src/gallium/drivers/nouveau/nvc0/nvc0_query.c   |   14 +-
 src/gallium/drivers/nouveau/nvc0/nvc0_query.h   |3 ++-
 src/gallium/drivers/nouveau/nvc0/nvc0_query_hw_metric.c |2 +-
 3 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_query.c 
b/src/gallium/drivers/nouveau/nvc0/nvc0_query.c
index e4752e2..f539210 100644
--- a/src/gallium/drivers/nouveau/nvc0/nvc0_query.c
+++ b/src/gallium/drivers/nouveau/nvc0/nvc0_query.c
@@ -28,6 +28,7 @@
 #include "nvc0/nvc0_query.h"
 #include "nvc0/nvc0_query_sw.h"
 #include "nvc0/nvc0_query_hw.h"
+#include "nvc0/nvc0_query_hw_metric.h"
 #include "nvc0/nvc0_query_hw_sm.h"
 
 static struct pipe_query *
@@ -188,7 +189,7 @@ nvc0_screen_get_driver_query_group_info(struct pipe_screen 
*pscreen,
 count++;
  } else
  if (screen->base.class_3d < NVE4_3D_CLASS) {
-count++;
+count += 2;
  }
   }
}
@@ -218,6 +219,17 @@ nvc0_screen_get_driver_query_group_info(struct pipe_screen 
*pscreen,
 return 1;
  }
   }
+   } else
+   if (id == NVC0_HW_METRIC_QUERY_GROUP) {
+  if (screen->compute) {
+ if (screen->base.class_3d < NVE4_3D_CLASS) {
+info->name = "Performance metrics";
+info->type = PIPE_DRIVER_QUERY_GROUP_TYPE_GPU;
+info->max_active_queries = 1;
+info->num_queries = NVC0_HW_METRIC_QUERY_COUNT;
+return 1;
+ }
+  }
}
 #ifdef NOUVEAU_ENABLE_DRIVER_STATISTICS
else if (id == NVC0_SW_QUERY_DRV_STAT_GROUP) {
diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_query.h 
b/src/gallium/drivers/nouveau/nvc0/nvc0_query.h
index 6883ab6..c46361c 100644
--- a/src/gallium/drivers/nouveau/nvc0/nvc0_query.h
+++ b/src/gallium/drivers/nouveau/nvc0/nvc0_query.h
@@ -32,7 +32,8 @@ nvc0_query(struct pipe_query *pipe)
  * Driver queries groups:
  */
 #define NVC0_HW_SM_QUERY_GROUP   0
-#define NVC0_SW_QUERY_DRV_STAT_GROUP 1
+#define NVC0_HW_METRIC_QUERY_GROUP   1
+#define NVC0_SW_QUERY_DRV_STAT_GROUP 2
 
 void nvc0_init_query_functions(struct nvc0_context *);
 
diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_query_hw_metric.c 
b/src/gallium/drivers/nouveau/nvc0/nvc0_query_hw_metric.c
index 25aa09b..fb2806a 100644
--- a/src/gallium/drivers/nouveau/nvc0/nvc0_query_hw_metric.c
+++ b/src/gallium/drivers/nouveau/nvc0/nvc0_query_hw_metric.c
@@ -431,7 +431,7 @@ nvc0_hw_metric_get_driver_query_info(struct nvc0_screen 
*screen, unsigned id,
 id = nvc0_hw_metric_get_next_query_id(queries, id);
 info->name = nvc0_hw_metric_names[id];
 info->query_type = NVC0_HW_METRIC_QUERY(id);
-info->group_id = -1;
+info->group_id = NVC0_HW_METRIC_QUERY_GROUP;
 return 1;
  }
   }

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


Mesa (master): mesa/texcompress: Restrict FXT1 format to desktop GL subset

2015-10-29 Thread Nanley Chery
Module: Mesa
Branch: master
Commit: 8090a1c32692e89b79d89f4dc959a26532dd2f91
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=8090a1c32692e89b79d89f4dc959a26532dd2f91

Author: Nanley Chery 
Date:   Tue Oct 13 21:05:07 2015 -0700

mesa/texcompress: Restrict FXT1 format to desktop GL subset

In agreement with the extension spec and commit
dd0eb004874645135b9aaac3ebbd0aaf274079ea, filter FXT1 formats to the
desktop GL profiles. Now we no longer advertise such formats as supported
in an ES context and then throw an INVALID_ENUM error when the client
tries to use such formats with CompressedTexImage2D.

Fixes the following 26 dEQP tests:
* dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_invalid_border
* 
dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_invalid_border_cube_neg_x
* 
dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_invalid_border_cube_neg_y
* 
dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_invalid_border_cube_neg_z
* 
dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_invalid_border_cube_pos_x
* 
dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_invalid_border_cube_pos_y
* 
dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_invalid_border_cube_pos_z
* dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_invalid_size
* 
dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_level_max_cube_pos
* 
dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_level_max_tex2d
* dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_neg_level_cube
* 
dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_neg_level_tex2d
* 
dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_neg_width_height_cube_neg_x
* 
dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_neg_width_height_cube_neg_y
* 
dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_neg_width_height_cube_neg_z
* 
dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_neg_width_height_cube_pos_x
* 
dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_neg_width_height_cube_pos_y
* 
dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_neg_width_height_cube_pos_z
* 
dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_neg_width_height_tex2d
* 
dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_width_height_max_cube_neg_x
* 
dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_width_height_max_cube_neg_y
* 
dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_width_height_max_cube_neg_z
* 
dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_width_height_max_cube_pos_x
* 
dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_width_height_max_cube_pos_y
* 
dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_width_height_max_cube_pos_z
* 
dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_width_height_max_tex2d

v2. Use _mesa_is_desktop_gl() (Ilia, Ian)

Reviewed-by: Ian Romanick 
Signed-off-by: Nanley Chery 

---

 src/mesa/main/texcompress.c |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/mesa/main/texcompress.c b/src/mesa/main/texcompress.c
index 84973d3..7fcaa42 100644
--- a/src/mesa/main/texcompress.c
+++ b/src/mesa/main/texcompress.c
@@ -286,7 +286,8 @@ GLuint
 _mesa_get_compressed_formats(struct gl_context *ctx, GLint *formats)
 {
GLuint n = 0;
-   if (ctx->Extensions.TDFX_texture_compression_FXT1) {
+   if (_mesa_is_desktop_gl(ctx) &&
+   ctx->Extensions.TDFX_texture_compression_FXT1) {
   if (formats) {
  formats[n++] = GL_COMPRESSED_RGB_FXT1_3DFX;
  formats[n++] = GL_COMPRESSED_RGBA_FXT1_3DFX;

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


Mesa (master): glsl: fix GL_BUFFER_DATA_SIZE value for shader storage blocks with unsize arrays

2015-10-29 Thread Samuel Iglesias Gonsálvez
Module: Mesa
Branch: master
Commit: 85f1f0441326ef3f49a4edeac474599db471ef7f
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=85f1f0441326ef3f49a4edeac474599db471ef7f

Author: Samuel Iglesias Gonsalvez 
Date:   Thu Oct 22 10:07:54 2015 +0200

glsl: fix GL_BUFFER_DATA_SIZE value for shader storage blocks with unsize arrays

From ARB_program_interface_query:

"For the property of BUFFER_DATA_SIZE, then the implementation-dependent
 minimum total buffer object size, in basic machine units, required to hold
 all active variables associated with an active uniform block, shader
 storage block, or atomic counter buffer is written to .  If the
 final member of an active shader storage block is array with no declared
 size, the minimum buffer size is computed assuming the array was declared
 as an array with one element."

Fixes the following dEQP-GLES31 tests:

dEQP-GLES31.functional.program_interface_query.shader_storage_block.buffer_data_size.named_block
dEQP-GLES31.functional.program_interface_query.shader_storage_block.buffer_data_size.unnamed_block
dEQP-GLES31.functional.program_interface_query.shader_storage_block.buffer_data_size.block_array

v2:
- Fix comment's indentation and explain that the parser already
  checked that unsized array is in last element of a shader
  storage block (Iago).
- Add assert (Iago).

Signed-off-by: Samuel Iglesias Gonsalvez 
Reviewed-by: Iago Toral Quiroga 

---

 src/glsl/link_uniform_blocks.cpp |   22 +++---
 1 file changed, 19 insertions(+), 3 deletions(-)

diff --git a/src/glsl/link_uniform_blocks.cpp b/src/glsl/link_uniform_blocks.cpp
index 5285d8d..d5d30bb 100644
--- a/src/glsl/link_uniform_blocks.cpp
+++ b/src/glsl/link_uniform_blocks.cpp
@@ -100,7 +100,7 @@ private:
virtual void visit_field(const glsl_type *type, const char *name,
 bool row_major, const glsl_type *,
 const unsigned packing,
-bool /* last_field */)
+bool last_field)
{
   assert(this->index < this->num_variables);
 
@@ -131,12 +131,28 @@ private:
   unsigned alignment = 0;
   unsigned size = 0;
 
+  /* From ARB_program_interface_query:
+   *
+   * "If the final member of an active shader storage block is array
+   *  with no declared size, the minimum buffer size is computed
+   *  assuming the array was declared as an array with one element."
+   *
+   * For that reason, we use the base type of the unsized array to 
calculate
+   * its size. We don't need to check if the unsized array is the last 
member
+   * of a shader storage block (that check was already done by the parser).
+   */
+  const glsl_type *type_for_size = type;
+  if (type->is_unsized_array()) {
+ assert(last_field);
+ type_for_size = type->without_array();
+  }
+
   if (packing == GLSL_INTERFACE_PACKING_STD430) {
  alignment = type->std430_base_alignment(v->RowMajor);
- size = type->std430_size(v->RowMajor);
+ size = type_for_size->std430_size(v->RowMajor);
   } else {
  alignment = type->std140_base_alignment(v->RowMajor);
- size = type->std140_size(v->RowMajor);
+ size = type_for_size->std140_size(v->RowMajor);
   }
 
   this->offset = glsl_align(this->offset, alignment);

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