Re: [Mesa-dev] [PATCH 00/32] i965/blorp: Use genxml for state setup

2016-08-14 Thread Kenneth Graunke
On Thursday, August 11, 2016 2:14:57 PM PDT Jason Ekstrand wrote:
> This patch series is the next on the way towards generalizing blorp for
> usin in Vulkan.  At this point, I'd say the project is about 80% complete.
> This series only applies on top of the last two blorp isl series which are
> still undergoing review.
> 
> Patches 1-11 make minor genxml improvements.  Some of this is to make gen6
> better and more like gen7-9.  The others are just general improvements that
> made converting blorp easier.
> 
> Patches 12-14 make a few minor changes to i965 so that we can include
> brw_state.h and brw_context.h without brw_defines.h.
> 
> Patches 15-23 re-arrange the state setup code in blorp to make the
> different gens emit the packets more-or-less in the same order.  This was
> very helpful when trying to debug problems when switching to genxml because
> there should not be substantial changes in the batch between patch 23 and
> the end of the series.
> 
> Patches 24-32 convert all of the blorp state setup to using genxml in a
> single file that gets recompiled 5 times, one for each gen.  I'm extremely
> happy with the end result where almost all of the code is shared across
> gens.  The one exception is WM and SF setup which is so different that we
> really need different code for gen6, gen7, and gen8.
> 
> This series can be found here:
> 
> https://cgit.freedesktop.org/~jekstrand/mesa/log/?h=review/blorp-genxml
> 
> Cc: Topi Pohjolainen 
> 
> Jason Ekstrand (32):
>   genxml/gen6: Add uint MOCS fields for most things
>   genxml/gen6: Add a Surface Base Address field to HIER_DEPTH_BUFFER
>   genxml/gen6: Fix the length of 3DSTATE_WM
>   genxml/gen6: Add the 3D_Prim_Topo_Type enum
>   genxml/gen6: Make "Depth Clear Value" a uint
>   genxml: Add a uint MOCS field to DEPTH_BUFFER packets
>   genxml/gen6: Make SAMPLER_STATE look a bit more like gen7
>   genxml: Make VERTEX_ELEMENT_STATE::Valid a bool
>   genxml: Make a couple of VERTEX_BUFFER_STATE fields boolean
>   genxml: Add a uint MOCS field to VERTEX_BUFFER_STATE
>   genxml/gen9: Make 3DSTATE_SBE::AttributeActiveComponentFormat an array
>   i965/state: Move is_drawing_lines/points to gen6_clip_state.c
>   i965: Stop including brw_defines.h in brw_state.h
>   i965: Roll intel_reg.h into brw_defines.h
>   i965/blorp: Make gen6 VS and GS disable helpers static

Patches 1-15 (the above) are:
Reviewed-by: Kenneth Graunke 


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


Re: [Mesa-dev] [PATCH 1/2] llvmpipe: fix depth clamping wrt reversed near/far values

2016-08-14 Thread Ilia Mirkin
Reviewed-by: Ilia Mirkin 

On Sun, Aug 14, 2016 at 11:41 PM,   wrote:
> From: Roland Scheidegger 
>
> This wasn't handled before (the result was that no matter what value got
> clamped, it always ended up as the near value in this case) (if clamping
> actually happened).
> Fix this by using the util helper for that (the math is otherwise "mostly"
> the same, mostly because there could actually be differences due to float
> rounding, but I don't even know which one would be more correct).
> ---
>  src/gallium/drivers/llvmpipe/lp_setup.c | 12 +++-
>  1 file changed, 3 insertions(+), 9 deletions(-)
>
> diff --git a/src/gallium/drivers/llvmpipe/lp_setup.c 
> b/src/gallium/drivers/llvmpipe/lp_setup.c
> index 0a45db9..7cb4f7b 100644
> --- a/src/gallium/drivers/llvmpipe/lp_setup.c
> +++ b/src/gallium/drivers/llvmpipe/lp_setup.c
> @@ -39,6 +39,7 @@
>  #include "util/u_inlines.h"
>  #include "util/u_memory.h"
>  #include "util/u_pack_color.h"
> +#include "util/u_viewport.h"
>  #include "draw/draw_pipe.h"
>  #include "os/os_time.h"
>  #include "lp_context.h"
> @@ -771,15 +772,8 @@ lp_setup_set_viewports(struct lp_setup_context *setup,
> for (i = 0; i < num_viewports; i++) {
>float min_depth;
>float max_depth;
> -
> -  if (lp->rasterizer->clip_halfz == 0) {
> - float half_depth = viewports[i].scale[2];
> - min_depth = viewports[i].translate[2] - half_depth;
> - max_depth = min_depth + half_depth * 2.0f;
> -  } else {
> - min_depth = viewports[i].translate[2];
> - max_depth = min_depth + viewports[i].scale[2];
> -  }
> +  util_viewport_zmin_zmax(&viewports[i], lp->rasterizer->clip_halfz,
> +  &min_depth, &max_depth);
>
>if (setup->viewports[i].min_depth != min_depth ||
>setup->viewports[i].max_depth != max_depth) {
> --
> 2.7.4
>
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 0/5] Move check for mapped buffers into api_validate.

2016-08-14 Thread Mathias Fröhlich
Hi,

On Sunday, 14 August 2016 12:50:58 CEST Eric Anholt wrote:
> Very nice!  I've always been bothered by this validation being in vbo.
> 
> Reviewed-by: Eric Anholt 
> 
Thanks!

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


[Mesa-dev] [Bug 97307] glsl/glcpp/tests/glcpp-test regression

2016-08-14 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=97307

Kenneth Graunke  changed:

   What|Removed |Added

  Component|Mesa core   |glsl-compiler
   Assignee|mesa-dev@lists.freedesktop. |kenn...@whitecape.org
   |org |

--- Comment #2 from Kenneth Graunke  ---
https://lists.freedesktop.org/archives/mesa-dev/2016-August/125993.html

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


[Mesa-dev] [PATCH] glcpp: Update tests for new #undef of built-in macro rules.

2016-08-14 Thread Kenneth Graunke
Ian recently changed the preprocessor to allow this in most GLSL
versions, but not GLSL ES 3.00+.  This patch converts the existing
test that expects a failure to a #version 300 es shader, and adds
a #version 110 shader to make sure that it's allowed.

Fixes 'make check'.

Cc: i...@freedesktop.org
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=97307
Signed-off-by: Kenneth Graunke 
---
 src/compiler/glsl/glcpp/tests/120-undef-builtin.c  | 1 +
 src/compiler/glsl/glcpp/tests/120-undef-builtin.c.expected | 3 ++-
 src/compiler/glsl/glcpp/tests/147-undef-builtin-allowed.c  | 4 
 src/compiler/glsl/glcpp/tests/147-undef-builtin-allowed.c.expected | 4 
 4 files changed, 11 insertions(+), 1 deletion(-)
 create mode 100644 src/compiler/glsl/glcpp/tests/147-undef-builtin-allowed.c
 create mode 100644 
src/compiler/glsl/glcpp/tests/147-undef-builtin-allowed.c.expected

diff --git a/src/compiler/glsl/glcpp/tests/120-undef-builtin.c 
b/src/compiler/glsl/glcpp/tests/120-undef-builtin.c
index 49e7696..f8ade19 100644
--- a/src/compiler/glsl/glcpp/tests/120-undef-builtin.c
+++ b/src/compiler/glsl/glcpp/tests/120-undef-builtin.c
@@ -1,3 +1,4 @@
+#version 300 es
 #undef __LINE__
 #undef __FILE__
 #undef __VERSION__
diff --git a/src/compiler/glsl/glcpp/tests/120-undef-builtin.c.expected 
b/src/compiler/glsl/glcpp/tests/120-undef-builtin.c.expected
index 3b736df..498dc0f 100644
--- a/src/compiler/glsl/glcpp/tests/120-undef-builtin.c.expected
+++ b/src/compiler/glsl/glcpp/tests/120-undef-builtin.c.expected
@@ -1,6 +1,7 @@
-0:1(1): preprocessor error: Built-in (pre-defined) macro names cannot be 
undefined.
 0:2(1): preprocessor error: Built-in (pre-defined) macro names cannot be 
undefined.
 0:3(1): preprocessor error: Built-in (pre-defined) macro names cannot be 
undefined.
+0:4(1): preprocessor error: Built-in (pre-defined) macro names cannot be 
undefined.
+#version 300 es
 
 
 
diff --git a/src/compiler/glsl/glcpp/tests/147-undef-builtin-allowed.c 
b/src/compiler/glsl/glcpp/tests/147-undef-builtin-allowed.c
new file mode 100644
index 000..e3af10d
--- /dev/null
+++ b/src/compiler/glsl/glcpp/tests/147-undef-builtin-allowed.c
@@ -0,0 +1,4 @@
+#version 110
+#undef __LINE__
+#undef __FILE__
+#undef __VERSION__
diff --git a/src/compiler/glsl/glcpp/tests/147-undef-builtin-allowed.c.expected 
b/src/compiler/glsl/glcpp/tests/147-undef-builtin-allowed.c.expected
new file mode 100644
index 000..cd0071f
--- /dev/null
+++ b/src/compiler/glsl/glcpp/tests/147-undef-builtin-allowed.c.expected
@@ -0,0 +1,4 @@
+#version 110
+
+
+
-- 
2.9.3

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


[Mesa-dev] [PATCH] freedreno: fix depth clamping on a3xx/a4xx

2016-08-14 Thread Ilia Mirkin
We were previously ... not clamping. I guess this meant that everything
got clamped to 1/0, which was enough to pass the existing tests. Or
perhaps the clamping would only happen to the rasterized depth value and
not the frag shader's output depth value. Either way, this broke
dolphin's new depth implementation, which seems to work better with
this patch.

Tested on a4xx but not a3xx.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=97231
Signed-off-by: Ilia Mirkin 
---
 src/gallium/drivers/freedreno/a3xx/a3xx.xml.h |  2 +-
 src/gallium/drivers/freedreno/a3xx/fd3_emit.c | 30 ++-
 src/gallium/drivers/freedreno/a4xx/a4xx.xml.h |  2 +-
 src/gallium/drivers/freedreno/a4xx/fd4_emit.c | 29 +-
 4 files changed, 59 insertions(+), 4 deletions(-)

diff --git a/src/gallium/drivers/freedreno/a3xx/a3xx.xml.h 
b/src/gallium/drivers/freedreno/a3xx/a3xx.xml.h
index dcb6dfb..bf787d1 100644
--- a/src/gallium/drivers/freedreno/a3xx/a3xx.xml.h
+++ b/src/gallium/drivers/freedreno/a3xx/a3xx.xml.h
@@ -1472,7 +1472,7 @@ static inline uint32_t A3XX_RB_DEPTH_CONTROL_ZFUNC(enum 
adreno_compare_func val)
 {
return ((val) << A3XX_RB_DEPTH_CONTROL_ZFUNC__SHIFT) & 
A3XX_RB_DEPTH_CONTROL_ZFUNC__MASK;
 }
-#define A3XX_RB_DEPTH_CONTROL_BF_ENABLE
0x0080
+#define A3XX_RB_DEPTH_CONTROL_Z_CLAMP_ENABLE   0x0080
 #define A3XX_RB_DEPTH_CONTROL_Z_TEST_ENABLE0x8000
 
 #define REG_A3XX_RB_DEPTH_CLEAR
0x2101
diff --git a/src/gallium/drivers/freedreno/a3xx/fd3_emit.c 
b/src/gallium/drivers/freedreno/a3xx/fd3_emit.c
index 0fb2ee1..130223c 100644
--- a/src/gallium/drivers/freedreno/a3xx/fd3_emit.c
+++ b/src/gallium/drivers/freedreno/a3xx/fd3_emit.c
@@ -31,6 +31,7 @@
 #include "util/u_memory.h"
 #include "util/u_helpers.h"
 #include "util/u_format.h"
+#include "util/u_viewport.h"
 
 #include "freedreno_resource.h"
 #include "freedreno_query_hw.h"
@@ -536,7 +537,7 @@ fd3_emit_state(struct fd_context *ctx, struct fd_ringbuffer 
*ring,

A3XX_RB_STENCILREFMASK_BF_STENCILREF(sr->ref_value[1]));
}
 
-   if (dirty & (FD_DIRTY_ZSA | FD_DIRTY_PROG)) {
+   if (dirty & (FD_DIRTY_ZSA | FD_DIRTY_RASTERIZER | FD_DIRTY_PROG)) {
uint32_t val = fd3_zsa_stateobj(ctx->zsa)->rb_depth_control;
if (fp->writes_pos) {
val |= A3XX_RB_DEPTH_CONTROL_FRAG_WRITES_Z;
@@ -545,6 +546,9 @@ fd3_emit_state(struct fd_context *ctx, struct fd_ringbuffer 
*ring,
if (fp->has_kill) {
val |= A3XX_RB_DEPTH_CONTROL_EARLY_Z_DISABLE;
}
+   if (!ctx->rasterizer->depth_clip) {
+   val |= A3XX_RB_DEPTH_CONTROL_Z_CLAMP_ENABLE;
+   }
OUT_PKT0(ring, REG_A3XX_RB_DEPTH_CONTROL, 1);
OUT_RING(ring, val);
}
@@ -648,6 +652,30 @@ fd3_emit_state(struct fd_context *ctx, struct 
fd_ringbuffer *ring,
OUT_RING(ring, 
A3XX_GRAS_CL_VPORT_ZSCALE(ctx->viewport.scale[2]));
}
 
+   if (dirty & (FD_DIRTY_VIEWPORT | FD_DIRTY_RASTERIZER | 
FD_DIRTY_FRAMEBUFFER)) {
+   float zmin, zmax;
+   int depth = 24;
+   if (ctx->batch->framebuffer.zsbuf) {
+   depth = util_format_get_component_bits(
+   
pipe_surface_format(ctx->batch->framebuffer.zsbuf),
+   UTIL_FORMAT_COLORSPACE_ZS, 0);
+   }
+   util_viewport_zmin_zmax(&ctx->viewport, 
ctx->rasterizer->clip_halfz,
+   &zmin, &zmax);
+
+   OUT_PKT0(ring, REG_A3XX_RB_Z_CLAMP_MIN, 2);
+   if (depth == 32) {
+   OUT_RING(ring, fui(zmin));
+   OUT_RING(ring, fui(zmax));
+   } else if (depth == 16) {
+   OUT_RING(ring, (uint32_t)(zmin * 0x));
+   OUT_RING(ring, (uint32_t)(zmax * 0x));
+   } else {
+   OUT_RING(ring, (uint32_t)(zmin * 0xff));
+   OUT_RING(ring, (uint32_t)(zmax * 0xff));
+   }
+   }
+
if (dirty & (FD_DIRTY_PROG | FD_DIRTY_FRAMEBUFFER | 
FD_DIRTY_BLEND_DUAL)) {
struct pipe_framebuffer_state *pfb = &ctx->batch->framebuffer;
int nr_cbufs = pfb->nr_cbufs;
diff --git a/src/gallium/drivers/freedreno/a4xx/a4xx.xml.h 
b/src/gallium/drivers/freedreno/a4xx/a4xx.xml.h
index d9a7bb5..8e8fedb 100644
--- a/src/gallium/drivers/freedreno/a4xx/a4xx.xml.h
+++ b/src/gallium/drivers/freedreno/a4xx/a4xx.xml.h
@@ -1376,7 +1376,7 @@ static inline uint32_t A4XX_RB_DEPTH_CONTROL_ZFUNC(enum 
adreno_compare_func val)
 {
return ((val) << A4XX_RB_DEPTH_CONTROL_ZFUNC__SHIFT) & 
A4XX_RB_DEPTH_CONTROL_ZF

[Mesa-dev] [PATCH] llvmpipe: fix issues with depth clamp

2016-08-14 Thread sroland
From: Roland Scheidegger 

We only did depth clamp when the value was written from the fs.
This is very wrong both for d3d10 and GL, and only passed the
corresponding piglit test due to pure luck (it no longer does
with the enhanced test).
Also, interpolation clamped values to 1.0 always, which can legitimately
happen if depth clip is disabled, so fix that as well (untested).
There is one unresolved issue left, d3d10 always does depth clamping,
whereas GL does not (but does [0,1] clamp instead for fs depth outputs)
- this information isn't in any gallium state object, leave it as-is
for now (though it looks like llvmpipe misses the [0,1] clamp as well).
This (with the previous patch) fixes piglit depth-clamp-range test.
---
 src/gallium/drivers/llvmpipe/lp_bld_interp.c |  20 -
 src/gallium/drivers/llvmpipe/lp_bld_interp.h |   2 +
 src/gallium/drivers/llvmpipe/lp_state_fs.c   | 115 ---
 3 files changed, 88 insertions(+), 49 deletions(-)

diff --git a/src/gallium/drivers/llvmpipe/lp_bld_interp.c 
b/src/gallium/drivers/llvmpipe/lp_bld_interp.c
index 8e4f029..87a5417 100644
--- a/src/gallium/drivers/llvmpipe/lp_bld_interp.c
+++ b/src/gallium/drivers/llvmpipe/lp_bld_interp.c
@@ -338,10 +338,15 @@ attribs_update_simple(struct lp_build_interp_soa_context 
*bld,
break;
 }
 
-if ((attrib == 0) && (chan == 2)){
+if ((attrib == 0) && (chan == 2) && !bld->depth_clamp){
/* FIXME: Depth values can exceed 1.0, due to the fact that
 * setup interpolation coefficients refer to (0,0) which causes
-* precision loss. So we must clamp to 1.0 here to avoid 
artifacts
+* precision loss. So we must clamp to 1.0 here to avoid 
artifacts.
+* Note though values outside [0,1] are perfectly valid with
+* depth clip disabled.
+* XXX: If depth clip is disabled but we force depth clamp
+* we may get values larger than 1.0 in the fs (but not in
+* depth test). Not sure if that's an issue...
 */
a = lp_build_min(coeff_bld, a, coeff_bld->one);
 }
@@ -633,10 +638,15 @@ attribs_update(struct lp_build_interp_soa_context *bld,
}
 #endif
 
-   if (attrib == 0 && chan == 2) {
+   if (attrib == 0 && chan == 2 && !bld->depth_clamp) {
   /* FIXME: Depth values can exceed 1.0, due to the fact that
* setup interpolation coefficients refer to (0,0) which 
causes
-   * precision loss. So we must clamp to 1.0 here to avoid 
artifacts
+   * precision loss. So we must clamp to 1.0 here to avoid 
artifacts.
+   * Note though values outside [0,1] are perfectly valid with
+   * depth clip disabled..
+   * XXX: If depth clip is disabled but we force depth clamp
+   * we may get values larger than 1.0 in the fs (but not in
+   * depth test). Not sure if that's an issue...
*/
   a = lp_build_min(coeff_bld, a, coeff_bld->one);
}
@@ -677,6 +687,7 @@ lp_build_interp_soa_init(struct lp_build_interp_soa_context 
*bld,
  unsigned num_inputs,
  const struct lp_shader_input *inputs,
  boolean pixel_center_integer,
+ boolean depth_clamp,
  LLVMBuilderRef builder,
  struct lp_type type,
  LLVMValueRef a0_ptr,
@@ -738,6 +749,7 @@ lp_build_interp_soa_init(struct lp_build_interp_soa_context 
*bld,
} else {
   bld->pos_offset = 0.5;
}
+   bld->depth_clamp = depth_clamp;
 
pos_init(bld, x0, y0);
 
diff --git a/src/gallium/drivers/llvmpipe/lp_bld_interp.h 
b/src/gallium/drivers/llvmpipe/lp_bld_interp.h
index 9029d2a..1b9ef5e 100644
--- a/src/gallium/drivers/llvmpipe/lp_bld_interp.h
+++ b/src/gallium/drivers/llvmpipe/lp_bld_interp.h
@@ -85,6 +85,7 @@ struct lp_build_interp_soa_context
unsigned mask[1 + PIPE_MAX_SHADER_INPUTS]; /**< TGSI_WRITE_MASK_x */
enum lp_interp interp[1 + PIPE_MAX_SHADER_INPUTS];
boolean simple_interp;
+   boolean depth_clamp;
 
double pos_offset;
 
@@ -116,6 +117,7 @@ lp_build_interp_soa_init(struct lp_build_interp_soa_context 
*bld,
  unsigned num_inputs,
  const struct lp_shader_input *inputs,
  boolean pixel_center_integer,
+ boolean depth_clamp,
  LLVMBuilderRef builder,
  struct lp_type type,
  LLVMValueRef a0_ptr,
diff --git a/src/gallium/drivers/llvmpipe/lp_state_fs.c 
b/src/gallium/drivers/llvmpipe/lp_state_fs.c
index b110202..3428eed 100644
--- a/src/gallium/drivers/llvmpipe/lp_state_fs.

[Mesa-dev] [PATCH 1/2] llvmpipe: fix depth clamping wrt reversed near/far values

2016-08-14 Thread sroland
From: Roland Scheidegger 

This wasn't handled before (the result was that no matter what value got
clamped, it always ended up as the near value in this case) (if clamping
actually happened).
Fix this by using the util helper for that (the math is otherwise "mostly"
the same, mostly because there could actually be differences due to float
rounding, but I don't even know which one would be more correct).
---
 src/gallium/drivers/llvmpipe/lp_setup.c | 12 +++-
 1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/src/gallium/drivers/llvmpipe/lp_setup.c 
b/src/gallium/drivers/llvmpipe/lp_setup.c
index 0a45db9..7cb4f7b 100644
--- a/src/gallium/drivers/llvmpipe/lp_setup.c
+++ b/src/gallium/drivers/llvmpipe/lp_setup.c
@@ -39,6 +39,7 @@
 #include "util/u_inlines.h"
 #include "util/u_memory.h"
 #include "util/u_pack_color.h"
+#include "util/u_viewport.h"
 #include "draw/draw_pipe.h"
 #include "os/os_time.h"
 #include "lp_context.h"
@@ -771,15 +772,8 @@ lp_setup_set_viewports(struct lp_setup_context *setup,
for (i = 0; i < num_viewports; i++) {
   float min_depth;
   float max_depth;
-
-  if (lp->rasterizer->clip_halfz == 0) {
- float half_depth = viewports[i].scale[2];
- min_depth = viewports[i].translate[2] - half_depth;
- max_depth = min_depth + half_depth * 2.0f;
-  } else {
- min_depth = viewports[i].translate[2];
- max_depth = min_depth + viewports[i].scale[2];
-  }
+  util_viewport_zmin_zmax(&viewports[i], lp->rasterizer->clip_halfz,
+  &min_depth, &max_depth);
 
   if (setup->viewports[i].min_depth != min_depth ||
   setup->viewports[i].max_depth != max_depth) {
-- 
2.7.4

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


Re: [Mesa-dev] [PATCH v2] egl/dri2: dri2_make_current: Release previous context's display

2016-08-14 Thread Александр



On 11.08.2016 11:43, Nicolas Boichat wrote:

eglMakeCurrent can also be used to change the active display. In that
case, we need to decrement ref_count of the previous display (possibly
destroying it), and increment it on the next display.

Also, old_dsurf/old_rsurf cannot be non-NULL if old_ctx is NULL, so
we only need to test if old_ctx is non-NULL.

v2: Save the old display before destroying the context.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=97214
Fixes: 9ee683f877 (egl/dri2: Add reference count for dri2_egl_display)
Cc: "12.0" 
Reported-by: Alexandr Zelinsky 
Tested-by: Alexandr Zelinsky 
Signed-off-by: Nicolas Boichat 
---

Alexandr: Can you give this one another try? Thanks!

  src/egl/drivers/dri2/egl_dri2.c | 9 +
  1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index 1ad6855..dde9804 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -1269,13 +1269,14 @@ dri2_make_current(_EGLDriver *drv, _EGLDisplay *disp, 
_EGLSurface *dsurf,
   drv->API.DestroySurface(drv, disp, old_dsurf);
if (old_rsurf)
   drv->API.DestroySurface(drv, disp, old_rsurf);
-  if (old_ctx)
- drv->API.DestroyContext(drv, disp, old_ctx);
  
if (!unbind)

   dri2_dpy->ref_count++;
-  if (old_dsurf || old_rsurf || old_ctx)
- dri2_display_release(disp);
+  if (old_ctx) {
+ EGLDisplay old_disp = _eglGetDisplayHandle(old_ctx->Resource.Display);
+ drv->API.DestroyContext(drv, disp, old_ctx);
+ dri2_display_release(old_disp);
+  }
  
return EGL_TRUE;

 } else {

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


Re: [Mesa-dev] [PATCH 1/3] gallium: change pipe_sampler_view::first_element/last_element -> offset/size

2016-08-14 Thread Marek Olšák
On Aug 12, 2016 8:49 PM, "Roland Scheidegger"  wrote:
>
> I can't say I'm a big fan of this.
> From an "api cleanness" point of view, defining things in elements makes
> more sense imho.
> This is due to the GL api though which uses generic buffer api to turn
> buffers into textures which can be sampled (somewhat different to what
> d3d10 does).
> Can't you just say you require 16 bytes alignment and call it a day? I
> don't think all hw can do 4 bytes anyway (actually though to satisfy
> d3d10 requirements, your hw would still need to be able to even support
> 1-byte alignment, if the format is r8).
>
> It also makes things asymmetric wrt pipe_surface (granted that's
> something gl can't do IIRC).
>
> But I guess we could live with this if necessary... Maybe hw does work
> more like that and not what d3d10 wants anyway...

I'd like to expose what our hw can do and this is the only way.

Marek

>
> Roland
>
>
>
> Am 12.08.2016 um 18:46 schrieb Marek Olšák:
> > From: Marek Olšák 
> >
> > This is required by OpenGL. Our hardware supports this.
> >
> > Example: Bind RGBA32F with offset = 4 bytes.
> >
> > Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=97305
> > ---
> >  src/gallium/auxiliary/util/u_dump_state.c|  4 ++--
> >  src/gallium/docs/source/screen.rst   |  4 ++--
> >  src/gallium/drivers/freedreno/a3xx/fd3_emit.c|  3 +--
> >  src/gallium/drivers/freedreno/a3xx/fd3_texture.c |  3 +--
> >  src/gallium/drivers/freedreno/a4xx/fd4_texture.c |  7 +++
> >  src/gallium/drivers/ilo/ilo_state.c  |  5 ++---
> >  src/gallium/drivers/llvmpipe/lp_setup.c  | 12 +---
> >  src/gallium/drivers/llvmpipe/lp_state_sampler.c  |  8 +++-
> >  src/gallium/drivers/nouveau/nv50/nv50_tex.c  |  7 +++
> >  src/gallium/drivers/nouveau/nvc0/nvc0_tex.c  | 18
++
> >  src/gallium/drivers/r600/evergreen_state.c   |  4 ++--
> >  src/gallium/drivers/r600/r600_state.c|  4 ++--
> >  src/gallium/drivers/r600/r600_state_common.c |  3 +--
> >  src/gallium/drivers/radeonsi/si_descriptors.c|  7 +--
> >  src/gallium/drivers/radeonsi/si_state.c  | 10 +-
> >  src/gallium/drivers/radeonsi/si_state.h  |  2 +-
> >  src/gallium/drivers/softpipe/sp_state_sampler.c  |  8 +++-
> >  src/gallium/drivers/softpipe/sp_tex_sample.c | 13 +
> >  src/gallium/drivers/svga/svga_state_sampler.c|  8 +---
> >  src/gallium/drivers/trace/tr_dump_state.c|  4 ++--
> >  src/gallium/drivers/virgl/virgl_encode.c |  7 +--
> >  src/gallium/include/pipe/p_state.h   |  4 ++--
> >  src/mesa/state_tracker/st_atom_texture.c | 13 -
> >  src/mesa/state_tracker/st_cb_texture.c   |  5 +++--
> >  24 files changed, 81 insertions(+), 82 deletions(-)
> >
> > diff --git a/src/gallium/auxiliary/util/u_dump_state.c
b/src/gallium/auxiliary/util/u_dump_state.c
> > index bad38fb..4568dc6 100644
> > --- a/src/gallium/auxiliary/util/u_dump_state.c
> > +++ b/src/gallium/auxiliary/util/u_dump_state.c
> > @@ -743,22 +743,22 @@ util_dump_sampler_view(FILE *stream, const struct
pipe_sampler_view *state)
> >return;
> > }
> >
> > util_dump_struct_begin(stream, "pipe_sampler_view");
> >
> > util_dump_member(stream, enum_tex_target, state, target);
> > util_dump_member(stream, format, state, format);
> > util_dump_member(stream, ptr, state, texture);
> >
> > if (state->target == PIPE_BUFFER) {
> > -  util_dump_member(stream, uint, state, u.buf.first_element);
> > -  util_dump_member(stream, uint, state, u.buf.last_element);
> > +  util_dump_member(stream, uint, state, u.buf.offset);
> > +  util_dump_member(stream, uint, state, u.buf.size);
> > }
> > else {
> >util_dump_member(stream, uint, state, u.tex.first_layer);
> >util_dump_member(stream, uint, state, u.tex.last_layer);
> >util_dump_member(stream, uint, state, u.tex.last_level);
> >util_dump_member(stream, uint, state, u.tex.last_level);
> > }
> >
> > util_dump_member(stream, uint, state, swizzle_r);
> > util_dump_member(stream, uint, state, swizzle_g);
> > diff --git a/src/gallium/docs/source/screen.rst
b/src/gallium/docs/source/screen.rst
> > index 34f2e72..3199e3c 100644
> > --- a/src/gallium/docs/source/screen.rst
> > +++ b/src/gallium/docs/source/screen.rst
> > @@ -129,22 +129,22 @@ The integer capabilities:
> >pipe_draw_info::start_instance.
> >  * ``PIPE_CAP_QUERY_TIMESTAMP``: Whether PIPE_QUERY_TIMESTAMP and
> >the pipe_screen::get_timestamp hook are implemented.
> >  * ``PIPE_CAP_TEXTURE_MULTISAMPLE``: Whether all MSAA resources
supported
> >for rendering are also supported for texturing.
> >  * ``PIPE_CAP_MIN_MAP_BUFFER_ALIGNMENT``: The minimum alignment that
should be
> >expected for a pointer returned by transfer_map if the resource is
> >PIPE_BUFFER. In other words, the pointer returned by t

[Mesa-dev] [PATCH] anv/x11: Add support for Xlib platform

2016-08-14 Thread Kevin Strasser
Some applications continue to use the Xlib client library and expect that
VK_KHR_xlib_surface will be available in the driver. Service these
applications by converting the Display pointer to xcb_connection_t and use
the existing xcb code in the driver.

Signed-off-by: Kevin Strasser 
Cc: Jason Ekstrand 
---
 src/intel/vulkan/Makefile.am   |  7 ++--
 src/intel/vulkan/anv_device.c  |  6 +++
 src/intel/vulkan/anv_wsi_x11.c | 87 --
 3 files changed, 86 insertions(+), 14 deletions(-)

diff --git a/src/intel/vulkan/Makefile.am b/src/intel/vulkan/Makefile.am
index fe7371e..73db8f5 100644
--- a/src/intel/vulkan/Makefile.am
+++ b/src/intel/vulkan/Makefile.am
@@ -85,7 +85,8 @@ VULKAN_LIB_DEPS =
 if HAVE_PLATFORM_X11
 AM_CPPFLAGS += \
$(XCB_DRI3_CFLAGS) \
-   -DVK_USE_PLATFORM_XCB_KHR
+   -DVK_USE_PLATFORM_XCB_KHR \
+   -DVK_USE_PLATFORM_XLIB_KHR
 
 VULKAN_SOURCES += $(VULKAN_WSI_X11_FILES)
 VULKAN_LIB_DEPS += $(XCB_DRI3_LIBS)
@@ -145,7 +146,7 @@ EXTRA_DIST = \
dev_icd.json.in \
intel_icd.json
 
-libvulkan_intel_la_LIBADD = $(VULKAN_LIB_DEPS)
+libvulkan_intel_la_LIBADD = $(VULKAN_LIB_DEPS) -lX11-xcb
 
 libvulkan_intel_la_LDFLAGS = \
-shared \
@@ -168,7 +169,7 @@ dev_icd.json : dev_icd.json.in
 
 # Libvulkan with dummy gem. Used for unit tests.
 libvulkan_test_la_SOURCES = $(VULKAN_GEM_STUB_FILES)
-libvulkan_test_la_LIBADD = $(VULKAN_LIB_DEPS)
+libvulkan_test_la_LIBADD = $(VULKAN_LIB_DEPS) -lX11-xcb
 
 include $(top_srcdir)/install-lib-links.mk
 
diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c
index aae925d..3546682 100644
--- a/src/intel/vulkan/anv_device.c
+++ b/src/intel/vulkan/anv_device.c
@@ -182,6 +182,12 @@ static const VkExtensionProperties global_extensions[] = {
   .specVersion = 5,
},
 #endif
+#ifdef VK_USE_PLATFORM_XLIB_KHR
+   {
+  .extensionName = VK_KHR_XLIB_SURFACE_EXTENSION_NAME,
+  .specVersion = 5,
+   },
+#endif
 #ifdef VK_USE_PLATFORM_WAYLAND_KHR
{
   .extensionName = VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME,
diff --git a/src/intel/vulkan/anv_wsi_x11.c b/src/intel/vulkan/anv_wsi_x11.c
index 2895d6b..2d50fff 100644
--- a/src/intel/vulkan/anv_wsi_x11.c
+++ b/src/intel/vulkan/anv_wsi_x11.c
@@ -21,6 +21,7 @@
  * IN THE SOFTWARE.
  */
 
+#include 
 #include 
 #include 
 #include 
@@ -256,18 +257,52 @@ VkBool32 anv_GetPhysicalDeviceXcbPresentationSupportKHR(
return true;
 }
 
+#ifdef VK_USE_PLATFORM_XLIB_KHR
+VkBool32 anv_GetPhysicalDeviceXlibPresentationSupportKHR(
+VkPhysicalDevicephysicalDevice,
+uint32_tqueueFamilyIndex,
+Display*dpy,
+VisualIDvisualID)
+{
+   return anv_GetPhysicalDeviceXcbPresentationSupportKHR(physicalDevice,
+ queueFamilyIndex,
+ 
XGetXCBConnection(dpy),
+ visualID);
+}
+#endif
+
+static xcb_connection_t*
+x11_surface_get_connection(VkIcdSurfaceBase *icd_surface)
+{
+   if (icd_surface->platform == VK_ICD_WSI_PLATFORM_XLIB)
+  return XGetXCBConnection(((VkIcdSurfaceXlib *)icd_surface)->dpy);
+   else
+  return ((VkIcdSurfaceXcb *)icd_surface)->connection;
+}
+
+static xcb_window_t
+x11_surface_get_window(VkIcdSurfaceBase *icd_surface)
+{
+   if (icd_surface->platform == VK_ICD_WSI_PLATFORM_XLIB)
+  return ((VkIcdSurfaceXlib *)icd_surface)->window;
+   else
+  return ((VkIcdSurfaceXcb *)icd_surface)->window;
+}
+
 static VkResult
 x11_surface_get_support(VkIcdSurfaceBase *icd_surface,
 struct anv_physical_device *device,
 uint32_t queueFamilyIndex,
 VkBool32* pSupported)
 {
-   VkIcdSurfaceXcb *surface = (VkIcdSurfaceXcb *)icd_surface;
+   xcb_connection_t *conn = x11_surface_get_connection(icd_surface);
+   xcb_window_t window = x11_surface_get_window(icd_surface);
 
struct wsi_x11_connection *wsi_conn =
-  wsi_x11_get_connection(device, surface->connection);
-   if (!wsi_conn)
+  wsi_x11_get_connection(device, conn);
+   if (!wsi_conn) {
   return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
+   }
 
if (!wsi_conn->has_dri3) {
   fprintf(stderr, "vulkan: No DRI3 support\n");
@@ -276,7 +311,7 @@ x11_surface_get_support(VkIcdSurfaceBase *icd_surface,
}
 
unsigned visual_depth;
-   if (!get_visualtype_for_window(surface->connection, surface->window,
+   if (!get_visualtype_for_window(conn, window,
   &visual_depth)) {
   *pSupported = false;
   return VK_SUCCESS;
@@ -296,22 +331,23 @@ x11_surface_get_capabilities(VkIcdSurfaceBase 
*icd_surface,
  struct anv_physical_device *device,
  VkSurfaceCapabilitiesKHR *caps)
 {
-   VkIcdS

Re: [Mesa-dev] [PATCH] egl/dri2: dri2_make_current: Release previous context's display

2016-08-14 Thread Александр



On 10.08.2016 10:44, Michel Dänzer wrote:

On 10/08/16 03:00 PM, Nicolas Boichat wrote:

eglMakeCurrent can also be used to change the active display. In that
case, we need to decrement ref_count of the previous display (possibly
destroying it), and increment it on the next display.

Also, old_dsurf/old_rsurf cannot be non-NULL if old_ctx is NULL, so
we only need to test if old_ctx is non-NULL.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=97214
Fixes: 9ee683f877 (egl/dri2: Add reference count for dri2_egl_display)
Cc: "12.0" 
Reported-by: Alexandr Zelinsky 
Tested-by: Alexandr Zelinsky 
Signed-off-by: Nicolas Boichat 
---
  src/egl/drivers/dri2/egl_dri2.c | 6 --
  1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index 3205a36..701e42a 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -1285,8 +1285,10 @@ dri2_make_current(_EGLDriver *drv, _EGLDisplay *disp, 
_EGLSurface *dsurf,
  
if (!unbind)

   dri2_dpy->ref_count++;
-  if (old_dsurf || old_rsurf || old_ctx)
- dri2_display_release(disp);
+  if (old_ctx) {
+ EGLDisplay old_disp = _eglGetDisplayHandle(old_ctx->Resource.Display);
+ dri2_display_release(old_disp);
+  }

Unfortunately, this change breaks the piglit test "spec@egl
1.4@eglterminate then unbind context", because old_ctx != NULL but
old_ctx->Resource.Display == NULL. Modifying the test to

   if (old_ctx && old_ctx->Resource.Display) {

fixes the regression and doesn't seem to cause any other problems.
Alexandr, does the patch still fix your problem with that modification?


Nicolas, this regression is also reproducible with
LIBGL_ALWAYS_SOFTWARE=1 . Please get used to testing your changes like
that and only send out changes for review which don't cause any regressions.



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


Re: [Mesa-dev] [PATCH 5/5] mesa: Remove duplicate include.

2016-08-14 Thread Brian Paul
Series LGTM.  Reviewed-by: Brian Paul 


On Sun, Aug 14, 2016 at 12:12 PM,  wrote:

> From: Mathias Fröhlich 
>
> In api_validate.c stdbool.h was included twice.
>
> Signed-off-by: Mathias Fröhlich 
> ---
>  src/mesa/main/api_validate.c | 1 -
>  1 file changed, 1 deletion(-)
>
> diff --git a/src/mesa/main/api_validate.c b/src/mesa/main/api_validate.c
> index ae3e118..384a8858 100644
> --- a/src/mesa/main/api_validate.c
> +++ b/src/mesa/main/api_validate.c
> @@ -33,7 +33,6 @@
>  #include "enums.h"
>  #include "vbo/vbo.h"
>  #include "transformfeedback.h"
> -#include 
>
>
>  /**
> --
> 2.7.4
>
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH v2 1/2] gallium/util: add helper to compute zmin/zmax for a viewport state

2016-08-14 Thread Brian Paul
On Sun, Aug 14, 2016 at 11:09 AM, Ilia Mirkin  wrote:

> Signed-off-by: Ilia Mirkin 
> Cc: "11.2 12.0" 
> ---
>  src/gallium/auxiliary/Makefile.sources  |  3 +-
>  src/gallium/auxiliary/util/u_viewport.h | 59
> +
>  2 files changed, 61 insertions(+), 1 deletion(-)
>  create mode 100644 src/gallium/auxiliary/util/u_viewport.h
>
> diff --git a/src/gallium/auxiliary/Makefile.sources
> b/src/gallium/auxiliary/Makefile.sources
> index 586f057..2a4919b 100644
> --- a/src/gallium/auxiliary/Makefile.sources
> +++ b/src/gallium/auxiliary/Makefile.sources
> @@ -309,7 +309,8 @@ C_SOURCES := \
> util/u_upload_mgr.h \
> util/u_vbuf.c \
> util/u_vbuf.h \
> -   util/u_video.h
> +   util/u_video.h \
> +   util/u_viewport.h
>
>  NIR_SOURCES := \
> nir/tgsi_to_nir.c \
> diff --git a/src/gallium/auxiliary/util/u_viewport.h
> b/src/gallium/auxiliary/util/u_viewport.h
> new file mode 100644
> index 000..a731b34
> --- /dev/null
> +++ b/src/gallium/auxiliary/util/u_viewport.h
> @@ -0,0 +1,59 @@
> +/**
> 
> + *
> + * Copyright 2016 Ilia Mirkin.
> + * 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.
> + *
> + 
> **/
> +
> +#ifndef U_VIEWPORT_H
> +#define U_VIEWPORT_H
> +
> +#include "c99_compat.h"
> +#include "pipe/p_state.h"
> +
> +#ifdef __cplusplus
> +extern "C" {
> +#endif
> +
> +static inline void
> +util_viewport_zmin_zmax(const struct pipe_viewport_state *vp, bool halfz,
> +float *zmin, float *zmax)
> +{
> +   float a, b;
> +   if (halfz) {
> +  a = vp->translate[2];
> +  b = vp->translate[2] + vp->scale[2];
> +   } else {
> +  a = vp->translate[2] - vp->scale[2];
> +  b = vp->translate[2] + vp->scale[2];
> +   }
> +
> +   *zmin = a < b ? a : b;
> +   *zmax = a < b ? b : a;
>

or, *zmin = MIN2(a, b);  *zmax = MAX2(a, b);

-Brian


> +}
> +
> +#ifdef __cplusplus
> +}
> +#endif
> +
> +#endif
> --
> 2.7.3
>
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [Bug 97231] GL_DEPTH_CLAMP doesn't clamp to the far plane

2016-08-14 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=97231

--- Comment #22 from Ilia Mirkin  ---
Like Roland said, if multiple drivers are affected, it's by independent bugs.
However for nv50 and nvc0, this is fixed by:

commit 5c1ccd8053412b6a42098481d2fde3d483208c33
Author: Ilia Mirkin 
Date:   Fri Aug 12 21:40:52 2016 -0400

nv50,nvc0: fix depth range when halfz is enabled

I'll leave this bug open for now though.

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


Re: [Mesa-dev] [PATCH v2 1/2] gallium/util: add helper to compute zmin/zmax for a viewport state

2016-08-14 Thread Roland Scheidegger
Reviewed-by: Roland Scheidegger 

Am 14.08.2016 um 19:09 schrieb Ilia Mirkin:
> Signed-off-by: Ilia Mirkin 
> Cc: "11.2 12.0" 
> ---
>  src/gallium/auxiliary/Makefile.sources  |  3 +-
>  src/gallium/auxiliary/util/u_viewport.h | 59 
> +
>  2 files changed, 61 insertions(+), 1 deletion(-)
>  create mode 100644 src/gallium/auxiliary/util/u_viewport.h
> 
> diff --git a/src/gallium/auxiliary/Makefile.sources 
> b/src/gallium/auxiliary/Makefile.sources
> index 586f057..2a4919b 100644
> --- a/src/gallium/auxiliary/Makefile.sources
> +++ b/src/gallium/auxiliary/Makefile.sources
> @@ -309,7 +309,8 @@ C_SOURCES := \
>   util/u_upload_mgr.h \
>   util/u_vbuf.c \
>   util/u_vbuf.h \
> - util/u_video.h
> + util/u_video.h \
> + util/u_viewport.h
>  
>  NIR_SOURCES := \
>   nir/tgsi_to_nir.c \
> diff --git a/src/gallium/auxiliary/util/u_viewport.h 
> b/src/gallium/auxiliary/util/u_viewport.h
> new file mode 100644
> index 000..a731b34
> --- /dev/null
> +++ b/src/gallium/auxiliary/util/u_viewport.h
> @@ -0,0 +1,59 @@
> +/**
> + *
> + * Copyright 2016 Ilia Mirkin.
> + * 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.
> + *
> + **/
> +
> +#ifndef U_VIEWPORT_H
> +#define U_VIEWPORT_H
> +
> +#include "c99_compat.h"
> +#include "pipe/p_state.h"
> +
> +#ifdef __cplusplus
> +extern "C" {
> +#endif
> +
> +static inline void
> +util_viewport_zmin_zmax(const struct pipe_viewport_state *vp, bool halfz,
> +float *zmin, float *zmax)
> +{
> +   float a, b;
> +   if (halfz) {
> +  a = vp->translate[2];
> +  b = vp->translate[2] + vp->scale[2];
> +   } else {
> +  a = vp->translate[2] - vp->scale[2];
> +  b = vp->translate[2] + vp->scale[2];
> +   }
> +
> +   *zmin = a < b ? a : b;
> +   *zmax = a < b ? b : a;
> +}
> +
> +#ifdef __cplusplus
> +}
> +#endif
> +
> +#endif
> 

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


Re: [Mesa-dev] [PATCH 0/5] Move check for mapped buffers into api_validate.

2016-08-14 Thread Eric Anholt
mathias.froehl...@gmx.net writes:

> From: Mathias Fröhlich 
>
> Hi all,
>
> This series moves the call to check for mapped vertex
> buffer objects on draw from the vbo code into api_validate.c.
> There we already check for various conditions to validate the
> current draw call. Some cleanups in that area are included.
>
> Please review!

Very nice!  I've always been bothered by this validation being in vbo.

Reviewed-by: Eric Anholt 


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


[Mesa-dev] [PATCH 5/5] mesa: Remove duplicate include.

2016-08-14 Thread Mathias . Froehlich
From: Mathias Fröhlich 

In api_validate.c stdbool.h was included twice.

Signed-off-by: Mathias Fröhlich 
---
 src/mesa/main/api_validate.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/src/mesa/main/api_validate.c b/src/mesa/main/api_validate.c
index ae3e118..384a8858 100644
--- a/src/mesa/main/api_validate.c
+++ b/src/mesa/main/api_validate.c
@@ -33,7 +33,6 @@
 #include "enums.h"
 #include "vbo/vbo.h"
 #include "transformfeedback.h"
-#include 
 
 
 /**
-- 
2.7.4

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


[Mesa-dev] [PATCH 2/5] mesa: Move _mesa_all_buffers_are_unmapped to arrayobj.c.

2016-08-14 Thread Mathias . Froehlich
From: Mathias Fröhlich 

Move the function to check if all vao buffers are
unmapped into the vao implementation file.
Rename the function to _mesa_all_buffers_are_unmapped.

Signed-off-by: Mathias Fröhlich 
---
 src/mesa/main/arrayobj.c  | 28 
 src/mesa/main/arrayobj.h  |  4 
 src/mesa/vbo/vbo_exec_array.c | 36 +---
 3 files changed, 33 insertions(+), 35 deletions(-)

diff --git a/src/mesa/main/arrayobj.c b/src/mesa/main/arrayobj.c
index becf32f..13f2dd7 100644
--- a/src/mesa/main/arrayobj.c
+++ b/src/mesa/main/arrayobj.c
@@ -393,6 +393,34 @@ _mesa_all_varyings_in_vbos(const struct 
gl_vertex_array_object *vao)
return true;
 }
 
+bool
+_mesa_all_buffers_are_unmapped(const struct gl_vertex_array_object *vao)
+{
+   /* Walk the enabled arrays that have a vbo attached */
+   GLbitfield64 mask = vao->_Enabled & vao->VertexAttribBufferMask;
+
+   while (mask) {
+  const int i = ffsll(mask) - 1;
+  const struct gl_vertex_attrib_array *attrib_array =
+ &vao->VertexAttrib[i];
+  const struct gl_vertex_buffer_binding *buffer_binding =
+ &vao->VertexBinding[attrib_array->VertexBinding];
+
+  /* Only enabled arrays shall appear in the _Enabled bitmask */
+  assert(attrib_array->Enabled);
+  /* We have already masked with vao->VertexAttribBufferMask  */
+  assert(_mesa_is_bufferobj(buffer_binding->BufferObj));
+
+  /* Bail out once we find the first disallowed mapping */
+  if (_mesa_check_disallowed_mapping(buffer_binding->BufferObj))
+ return false;
+
+  /* We have handled everything that is bound to this buffer_binding. */
+  mask &= ~buffer_binding->_BoundArrays;
+   }
+
+   return true;
+}
 
 /**/
 /* API Functions  */
diff --git a/src/mesa/main/arrayobj.h b/src/mesa/main/arrayobj.h
index d30c85c..830502e 100644
--- a/src/mesa/main/arrayobj.h
+++ b/src/mesa/main/arrayobj.h
@@ -85,6 +85,10 @@ _mesa_update_vao_client_arrays(struct gl_context *ctx,
 extern bool
 _mesa_all_varyings_in_vbos(const struct gl_vertex_array_object *vao);
 
+/* Returns true if all vbos are unmapped */
+extern bool
+_mesa_all_buffers_are_unmapped(const struct gl_vertex_array_object *vao);
+
 /*
  * API functions
  */
diff --git a/src/mesa/vbo/vbo_exec_array.c b/src/mesa/vbo/vbo_exec_array.c
index 8789837..e1aa3ac 100644
--- a/src/mesa/vbo/vbo_exec_array.c
+++ b/src/mesa/vbo/vbo_exec_array.c
@@ -43,40 +43,6 @@
 
 
 /**
- * All vertex buffers should be in an unmapped state when we're about
- * to draw.
- */
-static bool
-check_input_buffers_are_unmapped(const struct gl_vertex_array_object *vao)
-{
-   /* Walk the enabled arrays that have a vbo attached */
-   GLbitfield64 mask = vao->_Enabled & vao->VertexAttribBufferMask;
-
-   while (mask) {
-  int i = ffsll(mask) - 1;
-  const struct gl_vertex_attrib_array *attrib_array =
- &vao->VertexAttrib[i];
-  const struct gl_vertex_buffer_binding *buffer_binding =
- &vao->VertexBinding[attrib_array->VertexBinding];
-
-  /* Only enabled arrays shall appear in the _Enabled bitmask */
-  assert(attrib_array->Enabled);
-  /* We have already masked with vao->VertexAttribBufferMask  */
-  assert(_mesa_is_bufferobj(buffer_binding->BufferObj));
-
-  /* Bail out once we find the first disallowed mapping */
-  if (_mesa_check_disallowed_mapping(buffer_binding->BufferObj))
- return false;
-
-  /* We have handled everything that is bound to this buffer_binding. */
-  mask &= ~buffer_binding->_BoundArrays;
-   }
-
-   return true;
-}
-
-
-/**
  * Check that element 'j' of the array has reasonable data.
  * Map VBO if needed.
  * For debugging purposes; not normally used.
@@ -430,7 +396,7 @@ vbo_bind_arrays(struct gl_context *ctx)
   }
}
 
-   if (!check_input_buffers_are_unmapped(ctx->Array.VAO)) {
+   if (!_mesa_all_buffers_are_unmapped(ctx->Array.VAO)) {
   _mesa_error(ctx, GL_INVALID_OPERATION,
   "draw call (vertex buffers are mapped)");
   return false;
-- 
2.7.4

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


[Mesa-dev] [PATCH 4/5] vbo: Remove allways true return from vbo_bind_arrays.

2016-08-14 Thread Mathias . Froehlich
From: Mathias Fröhlich 

Signed-off-by: Mathias Fröhlich 
---
 src/mesa/vbo/vbo.h|  2 +-
 src/mesa/vbo/vbo_exec_array.c | 36 +++-
 2 files changed, 12 insertions(+), 26 deletions(-)

diff --git a/src/mesa/vbo/vbo.h b/src/mesa/vbo/vbo.h
index 939a3a6..73478e6 100644
--- a/src/mesa/vbo/vbo.h
+++ b/src/mesa/vbo/vbo.h
@@ -197,7 +197,7 @@ void vbo_set_draw_func(struct gl_context *ctx, 
vbo_draw_func func);
 void vbo_set_indirect_draw_func(struct gl_context *ctx,
 vbo_indirect_draw_func func);
 
-bool vbo_bind_arrays(struct gl_context *ctx);
+void vbo_bind_arrays(struct gl_context *ctx);
 
 size_t
 vbo_count_tessellated_primitives(GLenum mode, GLuint count,
diff --git a/src/mesa/vbo/vbo_exec_array.c b/src/mesa/vbo/vbo_exec_array.c
index bfa9cd6..2fee50b 100644
--- a/src/mesa/vbo/vbo_exec_array.c
+++ b/src/mesa/vbo/vbo_exec_array.c
@@ -369,7 +369,7 @@ recalculate_input_bindings(struct gl_context *ctx)
  * Note that this might set the _NEW_VARYING_VP_INPUTS dirty flag so state
  * validation must be done after this call.
  */
-bool
+void
 vbo_bind_arrays(struct gl_context *ctx)
 {
struct vbo_context *vbo = vbo_context(ctx);
@@ -395,8 +395,6 @@ vbo_bind_arrays(struct gl_context *ctx)
  exec->validating = GL_FALSE;
   }
}
-
-   return true;
 }
 
 /**
@@ -412,8 +410,7 @@ vbo_draw_arrays(struct gl_context *ctx, GLenum mode, GLint 
start,
struct vbo_context *vbo = vbo_context(ctx);
struct _mesa_prim prim[2];
 
-   if (!vbo_bind_arrays(ctx))
-  return;
+   vbo_bind_arrays(ctx);
 
/* init most fields to zero */
memset(prim, 0, sizeof(prim));
@@ -762,8 +759,7 @@ vbo_validated_drawrangeelements(struct gl_context *ctx, 
GLenum mode,
struct _mesa_index_buffer ib;
struct _mesa_prim prim[1];
 
-   if (!vbo_bind_arrays(ctx))
-  return;
+   vbo_bind_arrays(ctx);
 
ib.count = count;
ib.type = type;
@@ -1106,10 +1102,7 @@ vbo_validated_multidrawelements(struct gl_context *ctx, 
GLenum mode,
   return;
}
 
-   if (!vbo_bind_arrays(ctx)) {
-  free(prim);
-  return;
-   }
+   vbo_bind_arrays(ctx);
 
min_index_ptr = (uintptr_t)indices[0];
max_index_ptr = 0;
@@ -1273,8 +1266,7 @@ vbo_draw_transform_feedback(struct gl_context *ctx, 
GLenum mode,
   return;
}
 
-   if (!vbo_bind_arrays(ctx))
-  return;
+   vbo_bind_arrays(ctx);
 
/* init most fields to zero */
memset(prim, 0, sizeof(prim));
@@ -1370,8 +1362,7 @@ vbo_validated_drawarraysindirect(struct gl_context *ctx,
 {
struct vbo_context *vbo = vbo_context(ctx);
 
-   if (!vbo_bind_arrays(ctx))
-  return;
+   vbo_bind_arrays(ctx);
 
vbo->draw_indirect_prims(ctx, mode,
 ctx->DrawIndirectBuffer, (GLsizeiptr)indirect,
@@ -1394,8 +1385,7 @@ vbo_validated_multidrawarraysindirect(struct gl_context 
*ctx,
if (primcount == 0)
   return;
 
-   if (!vbo_bind_arrays(ctx))
-  return;
+   vbo_bind_arrays(ctx);
 
vbo->draw_indirect_prims(ctx, mode,
 ctx->DrawIndirectBuffer, offset,
@@ -1414,8 +1404,7 @@ vbo_validated_drawelementsindirect(struct gl_context *ctx,
struct vbo_context *vbo = vbo_context(ctx);
struct _mesa_index_buffer ib;
 
-   if (!vbo_bind_arrays(ctx))
-  return;
+   vbo_bind_arrays(ctx);
 
ib.count = 0; /* unknown */
ib.type = type;
@@ -1445,8 +1434,7 @@ vbo_validated_multidrawelementsindirect(struct gl_context 
*ctx,
if (primcount == 0)
   return;
 
-   if (!vbo_bind_arrays(ctx))
-  return;
+   vbo_bind_arrays(ctx);
 
/* NOTE: IndexBufferObj is guaranteed to be a VBO. */
 
@@ -1566,8 +1554,7 @@ vbo_validated_multidrawarraysindirectcount(struct 
gl_context *ctx,
if (maxdrawcount == 0)
   return;
 
-   if (!vbo_bind_arrays(ctx))
-  return;
+   vbo_bind_arrays(ctx);
 
vbo->draw_indirect_prims(ctx, mode,
 ctx->DrawIndirectBuffer, offset,
@@ -1594,8 +1581,7 @@ vbo_validated_multidrawelementsindirectcount(struct 
gl_context *ctx,
if (maxdrawcount == 0)
   return;
 
-   if (!vbo_bind_arrays(ctx))
-  return;
+   vbo_bind_arrays(ctx);
 
/* NOTE: IndexBufferObj is guaranteed to be a VBO. */
 
-- 
2.7.4

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


[Mesa-dev] [PATCH 3/5] mesa: Move check for vbo mapping into api_validate.c.

2016-08-14 Thread Mathias . Froehlich
From: Mathias Fröhlich 

Instead of checking for mapped buffers in vbo_bind_arrays
do this check in api_validate.c. This additionally
enables printing the draw calls name into the error
string.

Signed-off-by: Mathias Fröhlich 
---
 src/mesa/main/api_validate.c  | 7 +++
 src/mesa/vbo/vbo_exec_array.c | 8 +---
 2 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/src/mesa/main/api_validate.c b/src/mesa/main/api_validate.c
index ec3cc1b..ae3e118 100644
--- a/src/mesa/main/api_validate.c
+++ b/src/mesa/main/api_validate.c
@@ -25,6 +25,7 @@
 #include 
 #include "glheader.h"
 #include "api_validate.h"
+#include "arrayobj.h"
 #include "bufferobj.h"
 #include "context.h"
 #include "imports.h"
@@ -119,6 +120,12 @@ check_valid_to_render(struct gl_context *ctx, const char 
*function)
   unreachable("Invalid API value in check_valid_to_render()");
}
 
+   if (!_mesa_all_buffers_are_unmapped(ctx->Array.VAO)) {
+  _mesa_error(ctx, GL_INVALID_OPERATION,
+  "%s(vertex buffers are mapped)", function);
+  return false;
+   }
+
return true;
 }
 
diff --git a/src/mesa/vbo/vbo_exec_array.c b/src/mesa/vbo/vbo_exec_array.c
index e1aa3ac..bfa9cd6 100644
--- a/src/mesa/vbo/vbo_exec_array.c
+++ b/src/mesa/vbo/vbo_exec_array.c
@@ -396,13 +396,7 @@ vbo_bind_arrays(struct gl_context *ctx)
   }
}
 
-   if (!_mesa_all_buffers_are_unmapped(ctx->Array.VAO)) {
-  _mesa_error(ctx, GL_INVALID_OPERATION,
-  "draw call (vertex buffers are mapped)");
-  return false;
-   } else {
-  return true;
-   }
+   return true;
 }
 
 /**
-- 
2.7.4

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


[Mesa-dev] [PATCH 1/5] vbo: Array draw must not care about glBegin/glEnd vbo mapping.

2016-08-14 Thread Mathias . Froehlich
From: Mathias Fröhlich 

In array draw do not check if the vertex buffer object that
is used to implement immediate mode glBegin/glEnd is mapped.

Signed-off-by: Mathias Fröhlich 
---
 src/mesa/vbo/vbo_exec_array.c | 18 +-
 1 file changed, 1 insertion(+), 17 deletions(-)

diff --git a/src/mesa/vbo/vbo_exec_array.c b/src/mesa/vbo/vbo_exec_array.c
index f371890..8789837 100644
--- a/src/mesa/vbo/vbo_exec_array.c
+++ b/src/mesa/vbo/vbo_exec_array.c
@@ -77,22 +77,6 @@ check_input_buffers_are_unmapped(const struct 
gl_vertex_array_object *vao)
 
 
 /**
- * A debug function that may be called from other parts of Mesa as
- * needed during debugging.
- */
-static bool
-check_buffers_are_unmapped(struct gl_context *ctx)
-{
-   struct vbo_context *vbo = vbo_context(ctx);
-   struct vbo_exec_context *exec = &vbo->exec;
-
-   /* check the current vertex arrays */
-   return !_mesa_check_disallowed_mapping(exec->vtx.bufferobj) &&
-  check_input_buffers_are_unmapped(ctx->Array.VAO);
-}
-
-
-/**
  * Check that element 'j' of the array has reasonable data.
  * Map VBO if needed.
  * For debugging purposes; not normally used.
@@ -446,7 +430,7 @@ vbo_bind_arrays(struct gl_context *ctx)
   }
}
 
-   if (!check_buffers_are_unmapped(ctx)) {
+   if (!check_input_buffers_are_unmapped(ctx->Array.VAO)) {
   _mesa_error(ctx, GL_INVALID_OPERATION,
   "draw call (vertex buffers are mapped)");
   return false;
-- 
2.7.4

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


[Mesa-dev] [PATCH 0/5] Move check for mapped buffers into api_validate.

2016-08-14 Thread Mathias . Froehlich
From: Mathias Fröhlich 

Hi all,

This series moves the call to check for mapped vertex
buffer objects on draw from the vbo code into api_validate.c.
There we already check for various conditions to validate the
current draw call. Some cleanups in that area are included.

Please review!
Thanks

Mathias



Mathias Fröhlich (5):
  vbo: Array draw must not care about glBegin/glEnd vbo mapping.
  mesa: Move _mesa_all_buffers_are_unmapped to arrayobj.c.
  mesa: Move check for vbo mapping into api_validate.c.
  vbo: Remove allways true return from vbo_bind_arrays.
  mesa: Remove duplicate include.

 src/mesa/main/api_validate.c  |  8 +++-
 src/mesa/main/arrayobj.c  | 28 +
 src/mesa/main/arrayobj.h  |  4 ++
 src/mesa/vbo/vbo.h|  2 +-
 src/mesa/vbo/vbo_exec_array.c | 92 ++-
 5 files changed, 51 insertions(+), 83 deletions(-)

-- 
2.7.4

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


[Mesa-dev] [PATCH v2 1/2] gallium/util: add helper to compute zmin/zmax for a viewport state

2016-08-14 Thread Ilia Mirkin
Signed-off-by: Ilia Mirkin 
Cc: "11.2 12.0" 
---
 src/gallium/auxiliary/Makefile.sources  |  3 +-
 src/gallium/auxiliary/util/u_viewport.h | 59 +
 2 files changed, 61 insertions(+), 1 deletion(-)
 create mode 100644 src/gallium/auxiliary/util/u_viewport.h

diff --git a/src/gallium/auxiliary/Makefile.sources 
b/src/gallium/auxiliary/Makefile.sources
index 586f057..2a4919b 100644
--- a/src/gallium/auxiliary/Makefile.sources
+++ b/src/gallium/auxiliary/Makefile.sources
@@ -309,7 +309,8 @@ C_SOURCES := \
util/u_upload_mgr.h \
util/u_vbuf.c \
util/u_vbuf.h \
-   util/u_video.h
+   util/u_video.h \
+   util/u_viewport.h
 
 NIR_SOURCES := \
nir/tgsi_to_nir.c \
diff --git a/src/gallium/auxiliary/util/u_viewport.h 
b/src/gallium/auxiliary/util/u_viewport.h
new file mode 100644
index 000..a731b34
--- /dev/null
+++ b/src/gallium/auxiliary/util/u_viewport.h
@@ -0,0 +1,59 @@
+/**
+ *
+ * Copyright 2016 Ilia Mirkin.
+ * 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.
+ *
+ **/
+
+#ifndef U_VIEWPORT_H
+#define U_VIEWPORT_H
+
+#include "c99_compat.h"
+#include "pipe/p_state.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+static inline void
+util_viewport_zmin_zmax(const struct pipe_viewport_state *vp, bool halfz,
+float *zmin, float *zmax)
+{
+   float a, b;
+   if (halfz) {
+  a = vp->translate[2];
+  b = vp->translate[2] + vp->scale[2];
+   } else {
+  a = vp->translate[2] - vp->scale[2];
+  b = vp->translate[2] + vp->scale[2];
+   }
+
+   *zmin = a < b ? a : b;
+   *zmax = a < b ? b : a;
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
-- 
2.7.3

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


[Mesa-dev] [PATCH v2 2/2] nv50, nvc0: fix depth range when halfz is enabled

2016-08-14 Thread Ilia Mirkin
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=97231
Signed-off-by: Ilia Mirkin 
Cc: "11.2 12.0" 
---

v1 -> v2: make use of the new helper to compute min/max

 src/gallium/drivers/nouveau/nv50/nv50_state_validate.c | 9 +++--
 src/gallium/drivers/nouveau/nvc0/nvc0_state_validate.c | 9 +++--
 2 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/src/gallium/drivers/nouveau/nv50/nv50_state_validate.c 
b/src/gallium/drivers/nouveau/nv50/nv50_state_validate.c
index 19181a9..5a3bb3e 100644
--- a/src/gallium/drivers/nouveau/nv50/nv50_state_validate.c
+++ b/src/gallium/drivers/nouveau/nv50/nv50_state_validate.c
@@ -1,5 +1,6 @@
 
 #include "util/u_format.h"
+#include "util/u_viewport.h"
 
 #include "nv50/nv50_context.h"
 
@@ -265,8 +266,12 @@ nv50_validate_viewport(struct nv50_context *nv50)
   PUSH_DATAf(push, vpt->scale[1]);
   PUSH_DATAf(push, vpt->scale[2]);
 
-  zmin = vpt->translate[2] - fabsf(vpt->scale[2]);
-  zmax = vpt->translate[2] + fabsf(vpt->scale[2]);
+  /* If the halfz setting ever changes, the viewports will also get
+   * updated. The rast will get updated before the validate function has a
+   * chance to hit, so we can just use it directly without an atom
+   * dependency.
+   */
+  util_viewport_zmin_zmax(vpt, nv50->rast->pipe.clip_halfz, &zmin, &zmax);
 
 #ifdef NV50_SCISSORS_CLIPPING
   BEGIN_NV04(push, NV50_3D(DEPTH_RANGE_NEAR(i)), 2);
diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_state_validate.c 
b/src/gallium/drivers/nouveau/nvc0/nvc0_state_validate.c
index 160abae..e69463e 100644
--- a/src/gallium/drivers/nouveau/nvc0/nvc0_state_validate.c
+++ b/src/gallium/drivers/nouveau/nvc0/nvc0_state_validate.c
@@ -2,6 +2,7 @@
 #include "util/u_format.h"
 #include "util/u_framebuffer.h"
 #include "util/u_math.h"
+#include "util/u_viewport.h"
 
 #include "nvc0/nvc0_context.h"
 
@@ -329,8 +330,12 @@ nvc0_validate_viewport(struct nvc0_context *nvc0)
   PUSH_DATA (push, (w << 16) | x);
   PUSH_DATA (push, (h << 16) | y);
 
-  zmin = vp->translate[2] - fabsf(vp->scale[2]);
-  zmax = vp->translate[2] + fabsf(vp->scale[2]);
+  /* If the halfz setting ever changes, the viewports will also get
+   * updated. The rast will get updated before the validate function has a
+   * chance to hit, so we can just use it directly without an atom
+   * dependency.
+   */
+  util_viewport_zmin_zmax(vp, nvc0->rast->pipe.clip_halfz, &zmin, &zmax);
 
   BEGIN_NVC0(push, NVC0_3D(DEPTH_RANGE_NEAR(i)), 2);
   PUSH_DATAf(push, zmin);
-- 
2.7.3

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


Re: [Mesa-dev] [PATCH 3/3] i965/fs: Estimate maximum sampler message execution size more accurately.

2016-08-14 Thread Kenneth Graunke
On Friday, August 12, 2016 10:06:29 PM PDT Francisco Jerez wrote:
> The current logic used to determine the execution size of sampler
> messages was based on special-casing several argument and opcode
> combinations, which unsurprisingly missed the possibility that some
> messages could exceed the payload size limit or not depending on the
> number of coordinate components present.  In particular:
> 
>  - The TXL, TXB and TEX messages (the latter on non-FS stages only)
>would attempt to use SIMD16 on Gen7+ hardware even if a shadow
>reference was present and the texture was a cubemap array, causing
>it to overflow the maximum supported sampler payload size and
>crash.
> 
>  - The TG4_OFFSET message with shadow comparison was falling back to
>SIMD8 regardless of the number of coordinate components, which is
>unnecessary when two coordinates or less are present.
> 
> Both cases have been handled incorrectly ever since cubemap arrays and
> texture gather were respectively enabled (the current logic used by
> the SIMD lowering pass is almost unchanged from the previous no16
> fall-back logic used pre-SIMD lowering times).
> 
> Fixes the following GL4.5 conformance test on Gen7-8 (the bug also
> affects Gen9+ in principle, but SKL passes the test by luck because it
> manages to use the TXL_LZ message instead of TXL):
> 
>  GL45-CTS.texture_cube_map_array.sampling
> 
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=97267
> ---
>  src/mesa/drivers/dri/i965/brw_fs.cpp | 108 
> ---
>  1 file changed, 74 insertions(+), 34 deletions(-)
> 
> diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp 
> b/src/mesa/drivers/dri/i965/brw_fs.cpp
> index 1842d56..b816d24 100644
> --- a/src/mesa/drivers/dri/i965/brw_fs.cpp
> +++ b/src/mesa/drivers/dri/i965/brw_fs.cpp
> @@ -4687,6 +4687,68 @@ get_fpu_lowered_simd_width(const struct 
> brw_device_info *devinfo,
>  }
>  
>  /**
> + * Get the maximum allowed SIMD width for instruction \p inst accounting for
> + * various payload size restrictions that apply to sampler message
> + * instructions.
> + *
> + * This is only intended to provide a maximum theoretical bound for the
> + * execution size of the message based on the number of argument components
> + * alone, which in most cases will determine whether the SIMD8 or SIMD16
> + * variant of the message can be used, though some messages may have
> + * additional restrictions not accounted for here (e.g. pre-ILK hardware uses
> + * the message length to determine the exact SIMD width and argument count,
> + * which makes a number of sampler message combinations impossible to
> + * represent).
> + */
> +static unsigned
> +get_sampler_lowered_simd_width(const struct brw_device_info *devinfo,
> +   const fs_inst *inst)
> +{
> +   /* Calculate the number of coordinate components that have to be present
> +* assuming that additional arguments follow the texel coordinates in the
> +* message payload.  On Gen7+ there is no need for padding, on Gen5-6 we
> +* need to pad to four or three components depending on the message, on
> +* Gen4 we need to pad to at most three components.
> +*/
> +   const unsigned req_coord_components =
> +  (devinfo->gen >= 7 ||
> +   !inst->components_read(TEX_LOGICAL_SRC_COORDINATE)) ? 0 :
> +  (devinfo->gen >= 5 && inst->opcode != SHADER_OPCODE_TXF_LOGICAL &&
> +inst->opcode != SHADER_OPCODE_TXF_CMS_LOGICAL) ? 
> 4 :
> +  3;
> +
> +   /* On Gen9+ the LOD argument is for free if we're able to use the LZ
> +* variant of the TXL or TXF message.
> +*/
> +   const bool implicit_lod = devinfo->gen >= 9 &&
> + (inst->opcode == SHADER_OPCODE_TXL ||
> +  inst->opcode == SHADER_OPCODE_TXF) &&
> + inst->src[TEX_LOGICAL_SRC_LOD].is_zero();
> +
> +   /* Calculate the total number of argument components that need to be 
> passed
> +* to the sampler unit.
> +*/
> +   const unsigned num_payload_components =
> +  MAX2(inst->components_read(TEX_LOGICAL_SRC_COORDINATE),
> +   req_coord_components) +
> +  inst->components_read(TEX_LOGICAL_SRC_SHADOW_C) +
> +  (implicit_lod ? 0 : inst->components_read(TEX_LOGICAL_SRC_LOD)) +
> +  inst->components_read(TEX_LOGICAL_SRC_LOD2) +
> +  inst->components_read(TEX_LOGICAL_SRC_SAMPLE_INDEX) +
> +  (inst->opcode == SHADER_OPCODE_TG4_OFFSET_LOGICAL ?
> +   inst->components_read(TEX_LOGICAL_SRC_OFFSET_VALUE) : 0) +
> +  inst->components_read(TEX_LOGICAL_SRC_MCS);
> +
> +   /*

Bonus line here ^ can be dropped.

> +* SIMD16 messages with more than five arguments exceed the maximum 
> message
> +* size supported by the sampler, regardless of whether a header is
> +* provided or not.
> +*/
> +   return MIN2(inst->exec_size,
> +   num_payload_components > MAX_SAMPLER_MESSAGE_SIZE / 2 

[Mesa-dev] [Bug 97285] Darkness in Dota 2 after Patch "Make Gallium's BlitFramebuffer follow the GL 4.4 sRGB rules"

2016-08-14 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=97285

LoneVVolf  changed:

   What|Removed |Added

 CC||lonew...@xs4all.nl

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


Re: [Mesa-dev] [PATCH] vbo: allow DrawElementsBaseVertex in display lists

2016-08-14 Thread Marek Olšák
Reviewed-by: Marek Olšák 

Marek

On Sun, Aug 14, 2016 at 8:30 AM, Ilia Mirkin  wrote:
> Looks like it was missed originally. The multi version is there somehow.
>
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=97331
> Signed-off-by: Ilia Mirkin 
> Cc: mesa-sta...@lists.freedesktop.org
> ---
>  src/mesa/vbo/vbo_save_api.c | 18 +-
>  1 file changed, 13 insertions(+), 5 deletions(-)
>
> diff --git a/src/mesa/vbo/vbo_save_api.c b/src/mesa/vbo/vbo_save_api.c
> index 650c9b6..f648ccc 100644
> --- a/src/mesa/vbo/vbo_save_api.c
> +++ b/src/mesa/vbo/vbo_save_api.c
> @@ -1176,8 +1176,8 @@ _save_OBE_DrawArrays(GLenum mode, GLint start, GLsizei 
> count)
>   * then emitting an indexed prim at runtime.
>   */
>  static void GLAPIENTRY
> -_save_OBE_DrawElements(GLenum mode, GLsizei count, GLenum type,
> -   const GLvoid * indices)
> +_save_OBE_DrawElementsBaseVertex(GLenum mode, GLsizei count, GLenum type,
> + const GLvoid * indices, GLint basevertex)
>  {
> GET_CURRENT_CONTEXT(ctx);
> struct vbo_save_context *save = &vbo_context(ctx)->save;
> @@ -1214,15 +1214,15 @@ _save_OBE_DrawElements(GLenum mode, GLsizei count, 
> GLenum type,
> switch (type) {
> case GL_UNSIGNED_BYTE:
>for (i = 0; i < count; i++)
> - CALL_ArrayElement(GET_DISPATCH(), (((GLubyte *) indices)[i]));
> + CALL_ArrayElement(GET_DISPATCH(), (basevertex + ((GLubyte *) 
> indices)[i]));
>break;
> case GL_UNSIGNED_SHORT:
>for (i = 0; i < count; i++)
> - CALL_ArrayElement(GET_DISPATCH(), (((GLushort *) indices)[i]));
> + CALL_ArrayElement(GET_DISPATCH(), (basevertex + ((GLushort *) 
> indices)[i]));
>break;
> case GL_UNSIGNED_INT:
>for (i = 0; i < count; i++)
> - CALL_ArrayElement(GET_DISPATCH(), (((GLuint *) indices)[i]));
> + CALL_ArrayElement(GET_DISPATCH(), (basevertex + ((GLuint *) 
> indices)[i]));
>break;
> default:
>_mesa_error(ctx, GL_INVALID_ENUM, "glDrawElements(type)");
> @@ -1234,6 +1234,13 @@ _save_OBE_DrawElements(GLenum mode, GLsizei count, 
> GLenum type,
> _ae_unmap_vbos(ctx);
>  }
>
> +static void GLAPIENTRY
> +_save_OBE_DrawElements(GLenum mode, GLsizei count, GLenum type,
> +   const GLvoid * indices)
> +{
> +   _save_OBE_DrawElementsBaseVertex(mode, count, type, indices, 0);
> +}
> +
>
>  static void GLAPIENTRY
>  _save_OBE_DrawRangeElements(GLenum mode, GLuint start, GLuint end,
> @@ -1471,6 +1478,7 @@ vbo_initialize_save_dispatch(const struct gl_context 
> *ctx,
>  {
> SET_DrawArrays(exec, _save_OBE_DrawArrays);
> SET_DrawElements(exec, _save_OBE_DrawElements);
> +   SET_DrawElementsBaseVertex(exec, _save_OBE_DrawElementsBaseVertex);
> SET_DrawRangeElements(exec, _save_OBE_DrawRangeElements);
> SET_MultiDrawElementsEXT(exec, _save_OBE_MultiDrawElements);
> SET_MultiDrawElementsBaseVertex(exec, 
> _save_OBE_MultiDrawElementsBaseVertex);
> --
> 2.7.3
>
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev