Mesa (master): glsl: invalidate float suffixes for GLSL 1.10 and GLSL ES 1.00

2016-03-29 Thread Kenneth Graunke
Module: Mesa
Branch: master
Commit: 6773128bbf8703663ed1a4d6c1c3308b3c002a35
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=6773128bbf8703663ed1a4d6c1c3308b3c002a35

Author: Lars Hamre 
Date:   Mon Mar 28 20:42:14 2016 -0400

glsl: invalidate float suffixes for GLSL 1.10 and GLSL ES 1.00

Float suffixes are not allowed in GLSL 1.10 nor GLSL ES 1.00.

Fixes the following piglit tests:
tests/spec/glsl-1.10/compiler/literals/invalid-float-suffix-capital-f.vert
tests/spec/glsl-1.10/compiler/literals/invalid-float-suffix-f.vert`

v2: modify error message
v3: parse the float instead of returning an ERROR_TOK
v4: (by Ken) Change to is_version(120, 300) to avoid breaking ES3
shaders; update commit message accordingly.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=81585
Signed-off-by: Lars Hamre 
Reviewed-by: Timothy Arceri 
Reviewed-by: Kenneth Graunke 

---

 src/compiler/glsl/glsl_lexer.ll | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/src/compiler/glsl/glsl_lexer.ll b/src/compiler/glsl/glsl_lexer.ll
index 883c58f..5492045 100644
--- a/src/compiler/glsl/glsl_lexer.ll
+++ b/src/compiler/glsl/glsl_lexer.ll
@@ -472,6 +472,13 @@ layout {
 \.[0-9]+([eE][+-]?[0-9]+)?[fF]?|
 [0-9]+\.([eE][+-]?[0-9]+)?[fF]?|
 [0-9]+[eE][+-]?[0-9]+[fF]? {
+   struct _mesa_glsl_parse_state *state = yyextra;
+   char suffix = yytext[strlen(yytext) - 1];
+   if (!state->is_version(120, 300) &&
+   (suffix == 'f' || suffix == 'F')) {
+   _mesa_glsl_error(yylloc, state,
+"Float suffixes are invalid in 
GLSL 1.10");
+   }
yylval->real = _mesa_strtof(yytext, NULL);
return FLOATCONSTANT;
}

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


Mesa (vulkan): nir/spirv: Set a default number of invocations for geometry shaders

2016-03-29 Thread Jason Ekstrand
Module: Mesa
Branch: vulkan
Commit: cf2257069cbde19fd177a02c079206914aac5d14
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=cf2257069cbde19fd177a02c079206914aac5d14

Author: Jason Ekstrand 
Date:   Tue Mar 29 20:29:07 2016 -0700

nir/spirv: Set a default number of invocations for geometry shaders

The SPIR-V spec says geometry shaders are supposed to have one invocation
by default.  The execution mode is only required if there are multiple
invocations.

---

 src/compiler/nir/spirv/spirv_to_nir.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/compiler/nir/spirv/spirv_to_nir.c 
b/src/compiler/nir/spirv/spirv_to_nir.c
index 663f41f..9484544 100644
--- a/src/compiler/nir/spirv/spirv_to_nir.c
+++ b/src/compiler/nir/spirv/spirv_to_nir.c
@@ -2676,6 +2676,9 @@ spirv_to_nir(const uint32_t *words, size_t word_count,
 
b->shader = nir_shader_create(NULL, stage, options);
 
+   /* Set shader info defaults */
+   b->shader->info.gs.invocations = 1;
+
/* Parse execution modes */
vtn_foreach_execution_mode(b, b->entry_point,
   vtn_handle_execution_mode, NULL);

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


Mesa (master): tgsi: (trivial) only verify target for is_tex instructions

2016-03-29 Thread Roland Scheidegger
Module: Mesa
Branch: master
Commit: 2d3b8aefda1df66ef43c11c66e95ecb9a19c9137
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=2d3b8aefda1df66ef43c11c66e95ecb9a19c9137

Author: Roland Scheidegger 
Date:   Wed Mar 30 04:25:45 2016 +0200

tgsi: (trivial) only verify target for is_tex instructions

d3d10 state tracker does not encode (valid) target (only offsets are
really used from the texture bits), since that information always comes
from the sview dcl, and not the instruction (note the meaning of target
is actually slightly different between gl and d3d10 in any case, because
d3d10 target does never include shadow bit).
Also move the msaa sampler identification as well - would need to set that
on the sview not sampler, so while this does not fix it make it at least
obvious it won't work with sample instructions.

---

 src/gallium/auxiliary/tgsi/tgsi_scan.c | 15 +++
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/src/gallium/auxiliary/tgsi/tgsi_scan.c 
b/src/gallium/auxiliary/tgsi/tgsi_scan.c
index c71c777..76a6fef 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_scan.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_scan.c
@@ -184,14 +184,14 @@ scan_instruction(struct tgsi_shader_info *info,
   /* Texture samplers */
   if (src->Register.File == TGSI_FILE_SAMPLER) {
  const unsigned index = src->Register.Index;
- const unsigned target = fullinst->Texture.Texture;
 
  assert(fullinst->Instruction.Texture);
  assert(index < Elements(info->is_msaa_sampler));
  assert(index < PIPE_MAX_SAMPLERS);
- assert(target < TGSI_TEXTURE_UNKNOWN);
 
  if (tgsi_get_opcode_info(fullinst->Instruction.Opcode)->is_tex) {
+const unsigned target = fullinst->Texture.Texture;
+assert(target < TGSI_TEXTURE_UNKNOWN);
 /* for texture instructions, check that the texture instruction
  * target matches the previous sampler view declaration (if there
  * was one.)
@@ -205,12 +205,11 @@ scan_instruction(struct tgsi_shader_info *info,
 */
assert(info->sampler_targets[index] == target);
 }
- }
-
- /* MSAA samplers */
- if (target == TGSI_TEXTURE_2D_MSAA ||
- target == TGSI_TEXTURE_2D_ARRAY_MSAA) {
-info->is_msaa_sampler[src->Register.Index] = TRUE;
+/* MSAA samplers */
+if (target == TGSI_TEXTURE_2D_MSAA ||
+target == TGSI_TEXTURE_2D_ARRAY_MSAA) {
+   info->is_msaa_sampler[src->Register.Index] = TRUE;
+}
  }
   }
 

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


Mesa (master): mesa: allow mutable buffer textures to back GL ES images

2016-03-29 Thread Ilia Mirkin
Module: Mesa
Branch: master
Commit: 553e37aa337783d468f218291f6de6a74e49289b
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=553e37aa337783d468f218291f6de6a74e49289b

Author: Ilia Mirkin 
Date:   Tue Mar 29 15:31:05 2016 -0400

mesa: allow mutable buffer textures to back GL ES images

Since there is no way to create immutable texture buffers in GL ES,
mutable buffer textures are allowed to back images. See issue 7 of the
GL_OES_texture_buffer specification.

Signed-off-by: Ilia Mirkin 
Reviewed-by: Samuel Pitoiset 

---

 src/mesa/main/shaderimage.c | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/mesa/main/shaderimage.c b/src/mesa/main/shaderimage.c
index fd5934f..90643c4 100644
--- a/src/mesa/main/shaderimage.c
+++ b/src/mesa/main/shaderimage.c
@@ -583,8 +583,13 @@ _mesa_BindImageTexture(GLuint unit, GLuint texture, GLint 
level,
*
* "An INVALID_OPERATION error is generated if texture is not the name
*  of an immutable texture object."
+   *
+   * However note that issue 7 of the GL_OES_texture_buffer spec
+   * recognizes that there is no way to create immutable buffer textures,
+   * so those are excluded from this requirement.
*/
-  if (_mesa_is_gles(ctx) && !t->Immutable) {
+  if (_mesa_is_gles(ctx) && !t->Immutable &&
+  t->Target != GL_TEXTURE_BUFFER) {
  _mesa_error(ctx, GL_INVALID_OPERATION,
  "glBindImageTexture(!immutable)");
  return;

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


Mesa: tag mesa-11.2.0-rc4: Mesa 11.2.0-rc4 release candidate

2016-03-29 Thread Emil Velikov
Module: Mesa
Branch: refs/tags/mesa-11.2.0-rc4
Tag:afac7d1e4c91693ea448537647e295780e0d59ce
URL:
http://cgit.freedesktop.org/mesa/mesa/tag/?id=afac7d1e4c91693ea448537647e295780e0d59ce

Tagger: Emil Velikov 
Date:   Wed Mar 30 00:10:44 2016 +0100

Mesa 11.2.0-rc4 release candidate
___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (11.2): 44 new commits

2016-03-29 Thread Emil Velikov
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=bcb7e8b084f334e101d3a95c8f1d78bc77d653c2
Author: Emil Velikov 
Date:   Wed Mar 30 00:10:07 2016 +0100

Update version to 11.2.0-rc4

Signed-off-by: Emil Velikov 

URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=0efb7fb803f49b358a7976eba2d8b9f4956ab052
Author: Kenneth Graunke 
Date:   Fri Mar 25 15:33:35 2016 -0700

i965: Fix brw_render_cache_set_check_flush's PIPE_CONTROLs.

Our driver uses the brw_render_cache mechanism to track buffers we've
rendered to and are about to sample from.

Previously, we did a single PIPE_CONTROL with the following bits set:
- Render Target Flush
- Depth Cache Flush
- Texture Cache Invalidate
- VF Cache Invalidate
- Instruction Cache Invalidate
- CS Stall

This combined both "top of pipe" invalidations and "bottom of pipe"
flushes, which isn't how the hardware is intended to be programmed.

The "top of pipe" invalidations may happen right away, without any
guarantees that rendering using those caches has completed.  That
rendering may continue altering the caches.  The "bottom of pipe"
flushes do wait for the rendering to complete.  The CS stall also
prevents further work from happening until data is flushed out.

What we wanted to do was wait for rendering complete, flush the new
data out of the render and depth caches, wait, then invalidate any
stale data in read-only caches.  We can accomplish this by doing the
"bottom of pipe" flushes with a CS stall, then the "top of pipe"
flushes as a second PIPE_CONTROL.  The flushes will wait until the
rendering is complete, and the CS stall will prevent the second
PIPE_CONTROL with the invalidations from executing until the first
is done.

Fixes dEQP-GLES3.functional.texture.specification.teximage2d_pbo
subtests on Braswell and Skylake.  These tests hit the meta PBO
texture upload path, which binds the PBO as a texture and samples
from it, while rendering to the destination texture.  The tests
then sample from the texture.

For now, we leave Gen4-5 alone.  It probably needs work too, but
apparently it hasn't even been setting the (G45+) TC invalidation
bit at all...

v2: Add Sandybridge post-sync non-zero workaround, for safety.

Cc: mesa-sta...@lists.freedesktop.org
Suggested-by: Francisco Jerez 
Signed-off-by: Kenneth Graunke 
Reviewed-by: Jason Ekstrand 
Reviewed-by: Francisco Jerez 
(cherry picked from commit 72473658c51d5e074ce219c1e6385a4cce29f467)

URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=11654dda562188ba3cc743bcc286e7e48dde43e0
Author: Ilia Mirkin 
Date:   Sat Mar 26 22:32:43 2016 -0400

nvc0: disable primitive restart and index bias during blits

Back in the dawn of time, we used to do immediate uploads for the vertex
data, and all was well. However Maxwell dropped support for immediate
vertex data, so we started feeding in a VBO (in all cases). But we
forgot to disable some things that apply in such cases, specifically
primitive restart and index bias. The latter was causing WoW and other
Blizzard games trouble as they use a pattern where they draw with a base
vertex (aka index bias), followed by texture uploads (aka blits,
internally).

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=91526
Cc: "11.1 11.2" 
Signed-off-by: Ilia Mirkin 
Tested-by: Karol Herbst 
(cherry picked from commit 41100b6b44e747b9003937f123fce571fd3dec46)

URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=a715e4f40f4b2359cdd9712601a069e6e0f95607
Author: Ilia Mirkin 
Date:   Sun Mar 20 17:26:13 2016 -0400

nvc0/ir: fix picking of coordinates from tex instruction for textureGrad

On Fermi, there's an argument in front of the coords that combines array
and indirect handle, while on Kepler the array and the indirect handle
are separate (and in front of the coords). We were previously only
accounting for the array bit of it, if there were an indirect access it
wouldn't be counted in the formula.

Signed-off-by: Ilia Mirkin 
Cc: "11.1 11.2" 
(cherry picked from commit f667d15561820ee9dd8e836d43cce3ee52a4780e)

URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=afd477472120b2c0646a59525dd717dac9dee80c
Author: Anuj Phogat 
Date:   Fri Mar 11 15:24:36 2016 -0800

i965: Fix assert conditions for src/dst x/y offsets

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

Mesa (master): xlib: add support for GLX_ARB_create_context

2016-03-29 Thread Brian Paul
Module: Mesa
Branch: master
Commit: 75b713455c77931e5e90c30e65ac99d74dfb17f0
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=75b713455c77931e5e90c30e65ac99d74dfb17f0

Author: Brian Paul 
Date:   Sat Mar 26 11:35:00 2016 -0600

xlib: add support for GLX_ARB_create_context

This adds the glXCreateContextAttribsARB() function for the xlib/swrast
driver.  This allows more piglit tests to run with this driver.

For example, without this patch we get:
$ bin/fbo-generatemipmap-1d -auto
piglit: error: waffle_config_choose failed due to WAFFLE_ERROR_UNSUPPORTED_
ON_PLATFORM: GLX_ARB_create_context is required in order to request an OpenGL
version not equal to the default value 1.0
piglit: error: Failed to create waffle_config for OpenGL 2.0 Compatibility 
Context
piglit: info: Failed to create any GL context
PIGLIT: {"result": "skip" }

Reviewed-by: Jose Fonseca 
Acked-by: Roland Scheidegger 

---

 src/mesa/drivers/x11/fakeglx.c | 52 ++
 src/mesa/drivers/x11/glxapi.c  | 20 
 src/mesa/drivers/x11/glxapi.h  |  5 
 3 files changed, 77 insertions(+)

diff --git a/src/mesa/drivers/x11/fakeglx.c b/src/mesa/drivers/x11/fakeglx.c
index 9286f71..80b7176 100644
--- a/src/mesa/drivers/x11/fakeglx.c
+++ b/src/mesa/drivers/x11/fakeglx.c
@@ -74,6 +74,7 @@
"GLX_MESA_copy_sub_buffer " \
"GLX_MESA_pixmap_colormap " \
"GLX_MESA_release_buffers " \
+   "GLX_ARB_create_context " \
"GLX_ARB_get_proc_address " \
"GLX_EXT_texture_from_pixmap " \
"GLX_EXT_visual_info " \
@@ -2831,6 +2832,56 @@ Fake_glXReleaseTexImageEXT(Display *dpy, GLXDrawable 
drawable, int buffer)
 }
 
 
+static GLXContext
+Fake_glXCreateContextAttribs(Display *dpy, GLXFBConfig config,
+ GLXContext share_context, Bool direct,
+ const int *attrib_list)
+{
+   XMesaContext xmCtx;
+   XMesaVisual xmvis = (XMesaVisual) config;
+   int i;
+   int major = 0, minor = 0, ctxFlags = 0, profileFlags = 0;
+
+   for (i = 0; attrib_list[i]; i += 2) {
+  switch (attrib_list[i]) {
+  case GLX_CONTEXT_MAJOR_VERSION_ARB:
+ major = attrib_list[i + 1];
+ break;
+  case GLX_CONTEXT_MINOR_VERSION_ARB:
+ minor = attrib_list[i + 1];
+ break;
+  case GLX_CONTEXT_FLAGS_ARB:
+ ctxFlags = attrib_list[i + 1];
+ break;
+  case GLX_CONTEXT_PROFILE_MASK_ARB:
+ profileFlags = attrib_list[i + 1];
+ break;
+  default:
+ fprintf(stderr, "Bad attribute in glXCreateContextAttribs()\n");
+ return 0;
+  }
+   }
+
+   if (major * 10 + minor > 21) {
+  /* swrast only supports GL 2.1 and earlier */
+  return 0;
+   }
+
+   /* These are ignored for now.  We'd have to enhance XMesaCreateContext
+* to take these flags and the version, at least.
+*/
+   (void) ctxFlags;
+   (void) profileFlags;
+
+   /* deallocate unused windows/buffers */
+   XMesaGarbageCollect(dpy);
+
+   xmCtx = XMesaCreateContext(xmvis, (XMesaContext) share_context);
+
+   return (GLXContext) xmCtx;
+}
+
+
 /* silence warning */
 extern struct _glxapi_table *_mesa_GetGLXDispatchTable(void);
 
@@ -2990,5 +3041,6 @@ _mesa_GetGLXDispatchTable(void)
glx.BindTexImageEXT = Fake_glXBindTexImageEXT;
glx.ReleaseTexImageEXT = Fake_glXReleaseTexImageEXT;
 
+   glx.CreateContextAttribs = Fake_glXCreateContextAttribs;
return 
 }
diff --git a/src/mesa/drivers/x11/glxapi.c b/src/mesa/drivers/x11/glxapi.c
index a870e94..cc1bb2a 100644
--- a/src/mesa/drivers/x11/glxapi.c
+++ b/src/mesa/drivers/x11/glxapi.c
@@ -1319,6 +1319,9 @@ static struct name_address_pair GLX_functions[] = {
{ "glXBindTexImageEXT", (__GLXextFuncPtr) glXBindTexImageEXT },
{ "glXReleaseTexImageEXT", (__GLXextFuncPtr) glXReleaseTexImageEXT },
 
+   /*** GLX_ARB_create_context ***/
+   { "glXCreateContextAttribsARB", (__GLXextFuncPtr) 
glXCreateContextAttribsARB },
+
{ NULL, NULL }   /* end of list */
 };
 
@@ -1370,3 +1373,20 @@ void PUBLIC
 {
return glXGetProcAddressARB(procName);
 }
+
+
+/**
+ * Added in GLX_ARB_create_context.
+ */
+GLXContext PUBLIC
+glXCreateContextAttribsARB(Display *dpy, GLXFBConfig config,
+   GLXContext share_context, Bool direct,
+   const int *attrib_list)
+{
+   struct _glxapi_table *t;
+   GET_DISPATCH(dpy, t);
+   if (!t)
+  return 0;
+   return (t->CreateContextAttribs)(dpy, config, share_context, direct,
+attrib_list);
+}
diff --git a/src/mesa/drivers/x11/glxapi.h b/src/mesa/drivers/x11/glxapi.h
index bd6e970..aff38f7 100644
--- a/src/mesa/drivers/x11/glxapi.h
+++ b/src/mesa/drivers/x11/glxapi.h
@@ -201,6 +201,11 @@ struct _glxapi_table {
void (*BindTexImageEXT)(Display *dpy, GLXDrawable drawable, int buffer,
const int *attrib_list);
void (*ReleaseTexImageEXT)(Display *dpy, 

Mesa (master): gallium/docs: s/gven/given/

2016-03-29 Thread Brian Paul
Module: Mesa
Branch: master
Commit: 6775268b61b1943c85f5a1a30ce330d34003e328
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=6775268b61b1943c85f5a1a30ce330d34003e328

Author: Brian Paul 
Date:   Tue Mar 29 11:32:24 2016 -0600

gallium/docs: s/gven/given/

---

 src/gallium/docs/source/tgsi.rst | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/gallium/docs/source/tgsi.rst b/src/gallium/docs/source/tgsi.rst
index 6366f7e..3ac6ba3 100644
--- a/src/gallium/docs/source/tgsi.rst
+++ b/src/gallium/docs/source/tgsi.rst
@@ -2095,7 +2095,7 @@ after lookup.
 .. opcode:: SAMPLE
 
   Using provided address, sample data from the specified texture using the
-  filtering mode identified by the gven sampler. The source data may come from
+  filtering mode identified by the given sampler. The source data may come from
   any resource type other than buffers.
 
   Syntax: ``SAMPLE dst, address, sampler_view, sampler``

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


Mesa (master): mesa: make _mesa_prepare_mipmap_level() static

2016-03-29 Thread Brian Paul
Module: Mesa
Branch: master
Commit: 513384d7e8db294d54a910f40c90492c211abc54
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=513384d7e8db294d54a910f40c90492c211abc54

Author: Brian Paul 
Date:   Mon Mar 28 17:27:27 2016 -0600

mesa: make _mesa_prepare_mipmap_level() static

No longer called from any other file.

Reviewed-by: José Fonseca 
Reviewed-by: Roland Scheidegger 
Reviewed-by: Ian Romanick 
Tested-by: Ian Romanick 

---

 src/mesa/main/mipmap.c | 16 
 src/mesa/main/mipmap.h |  7 ---
 2 files changed, 8 insertions(+), 15 deletions(-)

diff --git a/src/mesa/main/mipmap.c b/src/mesa/main/mipmap.c
index cb9afde..5ff53f4 100644
--- a/src/mesa/main/mipmap.c
+++ b/src/mesa/main/mipmap.c
@@ -1810,11 +1810,11 @@ _mesa_next_mipmap_level_size(GLenum target, GLint 
border,
  * for mipmap generation.  If not, (re) allocate it.
  * \return GL_TRUE if successful, GL_FALSE if mipmap generation should stop
  */
-GLboolean
-_mesa_prepare_mipmap_level(struct gl_context *ctx,
-   struct gl_texture_object *texObj, GLuint level,
-   GLsizei width, GLsizei height, GLsizei depth,
-   GLsizei border, GLenum intFormat, mesa_format 
format)
+static GLboolean
+prepare_mipmap_level(struct gl_context *ctx,
+ struct gl_texture_object *texObj, GLuint level,
+ GLsizei width, GLsizei height, GLsizei depth,
+ GLsizei border, GLenum intFormat, mesa_format format)
 {
const GLuint numFaces = _mesa_num_tex_faces(texObj->Target);
GLuint face;
@@ -1902,9 +1902,9 @@ _mesa_prepare_mipmap_levels(struct gl_context *ctx,
  break;
   }
 
-  if (!_mesa_prepare_mipmap_level(ctx, texObj, level,
-  newWidth, newHeight, newDepth,
-  border, intFormat, texFormat)) {
+  if (!prepare_mipmap_level(ctx, texObj, level,
+newWidth, newHeight, newDepth,
+border, intFormat, texFormat)) {
  break;
   }
 
diff --git a/src/mesa/main/mipmap.h b/src/mesa/main/mipmap.h
index 33913e8..d11c7fa 100644
--- a/src/mesa/main/mipmap.h
+++ b/src/mesa/main/mipmap.h
@@ -40,13 +40,6 @@ _mesa_generate_mipmap_level(GLenum target,
 GLubyte **dstData,
 GLint dstRowStride);
 
-
-extern GLboolean
-_mesa_prepare_mipmap_level(struct gl_context *ctx,
-   struct gl_texture_object *texObj, GLuint level,
-   GLsizei width, GLsizei height, GLsizei depth,
-   GLsizei border, GLenum intFormat, mesa_format 
format);
-
 void
 _mesa_prepare_mipmap_levels(struct gl_context *ctx,
 struct gl_texture_object *texObj,

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


Mesa (master): st/mesa: simplify st_generate_mipmap()

2016-03-29 Thread Brian Paul
Module: Mesa
Branch: master
Commit: d8d029f22bcb49c26ddb11d0bb968d24f2a5fb7e
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=d8d029f22bcb49c26ddb11d0bb968d24f2a5fb7e

Author: Brian Paul 
Date:   Thu Mar 24 14:09:24 2016 -0600

st/mesa: simplify st_generate_mipmap()

The whole st_generate_mipmap() function was overly complicated.  Now
we just call the new _mesa_prepare_mipmap_levels() function to prepare
the texture mipmap memory, then call the generate function which fills
in the texture images.

This fixes a failed assertion in llvmpipe/softpipe which is hit with the
new piglit generatemipmap-base-change test.  Also fixes some device errors
(format mismatches) with the VMware svga driver.

v2: fix a comment typo, per Sinclair

Reviewed-by: Sinclair Yeh 
Reviewed-by: Jose Fonseca 
Reviewed-by: Roland Scheidegger 

---

 src/mesa/state_tracker/st_gen_mipmap.c | 102 -
 1 file changed, 24 insertions(+), 78 deletions(-)

diff --git a/src/mesa/state_tracker/st_gen_mipmap.c 
b/src/mesa/state_tracker/st_gen_mipmap.c
index c4b3492..a14bbfa 100644
--- a/src/mesa/state_tracker/st_gen_mipmap.c
+++ b/src/mesa/state_tracker/st_gen_mipmap.c
@@ -82,7 +82,6 @@ st_generate_mipmap(struct gl_context *ctx, GLenum target,
const uint baseLevel = texObj->BaseLevel;
enum pipe_format format;
uint lastLevel, first_layer, last_layer;
-   uint dstLevel;
 
if (!pt)
   return;
@@ -103,42 +102,33 @@ st_generate_mipmap(struct gl_context *ctx, GLenum target,
stObj->lastLevel = lastLevel;
 
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);
-  }
+  const GLboolean genSave = texObj->GenerateMipmap;
+
+  /* Temporarily set GenerateMipmap to true so that allocate_full_mipmap()
+   * makes the right decision about full mipmap allocation.
+   */
+  texObj->GenerateMipmap = GL_TRUE;
+
+  _mesa_prepare_mipmap_levels(ctx, texObj, baseLevel, lastLevel);
+
+  texObj->GenerateMipmap = genSave;
+
+  /* At this point, memory for all the texture levels has been
+   * allocated.  However, the base level image may be in one resource
+   * while the subsequent/smaller levels may be in another resource.
+   * Finalizing the texture will copy the base images from the former
+   * resource to the latter.
+   *
+   * After this, we'll have all mipmap levels in one resource.
+   */
+  st_finalize_texture(ctx, st->pipe, texObj);
}
 
pt = stObj->pt;
+   if (!pt) {
+  _mesa_error(ctx, GL_OUT_OF_MEMORY, "mipmap generation");
+  return;
+   }
 
assert(pt->last_level >= lastLevel);
 
@@ -169,48 +159,4 @@ st_generate_mipmap(struct gl_context *ctx, GLenum target,
  _mesa_generate_mipmap(ctx, target, texObj);
   }
}
-
-   /* Fill in the Mesa gl_texture_image fields */
-   for (dstLevel = baseLevel + 1; dstLevel <= lastLevel; dstLevel++) {
-  const uint srcLevel = dstLevel - 1;
-  const struct gl_texture_image *srcImage
- = _mesa_get_tex_image(ctx, texObj, target, srcLevel);
-  struct gl_texture_image *dstImage;
-  struct st_texture_image *stImage;
-  uint border = srcImage->Border;
-  uint dstWidth, dstHeight, dstDepth;
-
-  dstWidth = u_minify(pt->width0, dstLevel);
-  if (texObj->Target == GL_TEXTURE_1D_ARRAY) {
- dstHeight = pt->array_size;
-  }
-  else {
- dstHeight = u_minify(pt->height0, dstLevel);
-  }
-  if (texObj->Target == GL_TEXTURE_2D_ARRAY ||
-  texObj->Target == 

Mesa (master): mesa: new _mesa_prepare_mipmap_levels() function for mipmap generation

2016-03-29 Thread Brian Paul
Module: Mesa
Branch: master
Commit: 105fe527840ed5fc55e78c4561915fbe1fded76c
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=105fe527840ed5fc55e78c4561915fbe1fded76c

Author: Brian Paul 
Date:   Thu Mar 24 11:24:33 2016 -0600

mesa: new _mesa_prepare_mipmap_levels() function for mipmap generation

Simplifies the loops in generate_mipmap_uncompressed() and
generate_mipmap_compressed().  Will be used in the state tracker too.
Could probably be used in the meta code.  If so, some additional
clean-ups can be done after that.

v2: use unsigned types instead of GLuint, per Ian

Reviewed-by: Roland Scheidegger 
Reviewed-by: Jose Fonseca 

---

 src/mesa/main/mipmap.c | 88 --
 src/mesa/main/mipmap.h |  5 +++
 2 files changed, 62 insertions(+), 31 deletions(-)

diff --git a/src/mesa/main/mipmap.c b/src/mesa/main/mipmap.c
index 5a02780..cb9afde 100644
--- a/src/mesa/main/mipmap.c
+++ b/src/mesa/main/mipmap.c
@@ -1872,6 +1872,49 @@ _mesa_prepare_mipmap_level(struct gl_context *ctx,
 }
 
 
+/**
+ * Prepare all mipmap levels beyond 'baseLevel' for mipmap generation.
+ * When finished, all the gl_texture_image structures for the smaller
+ * mipmap levels will be consistent with the base level (in terms of
+ * dimensions, format, etc).
+ */
+void
+_mesa_prepare_mipmap_levels(struct gl_context *ctx,
+struct gl_texture_object *texObj,
+unsigned baseLevel, unsigned maxLevel)
+{
+   const struct gl_texture_image *baseImage =
+  _mesa_select_tex_image(texObj, texObj->Target, baseLevel);
+   const GLint border = 0;
+   GLint width = baseImage->Width;
+   GLint height = baseImage->Height;
+   GLint depth = baseImage->Depth;
+   const GLenum intFormat = baseImage->InternalFormat;
+   const mesa_format texFormat = baseImage->TexFormat;
+   GLint newWidth, newHeight, newDepth;
+
+   /* Prepare baseLevel + 1, baseLevel + 2, ... */
+   for (unsigned level = baseLevel + 1; level <= maxLevel; level++) {
+  if (!_mesa_next_mipmap_level_size(texObj->Target, border,
+width, height, depth,
+, , )) {
+ /* all done */
+ break;
+  }
+
+  if (!_mesa_prepare_mipmap_level(ctx, texObj, level,
+  newWidth, newHeight, newDepth,
+  border, intFormat, texFormat)) {
+ break;
+  }
+
+  width = newWidth;
+  height = newHeight;
+  depth = newDepth;
+   }
+}
+
+
 static void
 generate_mipmap_uncompressed(struct gl_context *ctx, GLenum target,
 struct gl_texture_object *texObj,
@@ -1892,7 +1935,6 @@ generate_mipmap_uncompressed(struct gl_context *ctx, 
GLenum target,
   GLint dstWidth, dstHeight, dstDepth;
   GLint border;
   GLint slice;
-  GLboolean nextLevel;
   GLubyte **srcMaps, **dstMaps;
   GLboolean success = GL_TRUE;
 
@@ -1904,22 +1946,14 @@ generate_mipmap_uncompressed(struct gl_context *ctx, 
GLenum target,
   srcDepth = srcImage->Depth;
   border = srcImage->Border;
 
-  nextLevel = _mesa_next_mipmap_level_size(target, border,
- srcWidth, srcHeight, srcDepth,
- , , );
-  if (!nextLevel)
- return;
-
-  if (!_mesa_prepare_mipmap_level(ctx, texObj, level + 1,
-  dstWidth, dstHeight, dstDepth,
-  border, srcImage->InternalFormat,
-  srcImage->TexFormat)) {
- return;
-  }
-
   /* get dest gl_texture_image */
   dstImage = _mesa_select_tex_image(texObj, target, level + 1);
-  assert(dstImage);
+  if (!dstImage) {
+ break;
+  }
+  dstWidth = dstImage->Width;
+  dstHeight = dstImage->Height;
+  dstDepth = dstImage->Depth;
 
   if (target == GL_TEXTURE_1D_ARRAY) {
 srcDepth = srcHeight;
@@ -2087,7 +2121,6 @@ generate_mipmap_compressed(struct gl_context *ctx, GLenum 
target,
   GLint srcWidth, srcHeight, srcDepth;
   GLint dstWidth, dstHeight, dstDepth;
   GLint border;
-  GLboolean nextLevel;
   GLuint temp_dst_row_stride, temp_dst_img_stride; /* in bytes */
   GLint i;
 
@@ -2099,23 +2132,14 @@ generate_mipmap_compressed(struct gl_context *ctx, 
GLenum target,
   srcDepth = srcImage->Depth;
   border = srcImage->Border;
 
-  nextLevel = _mesa_next_mipmap_level_size(target, border,
- srcWidth, srcHeight, srcDepth,
- , , );
-  if (!nextLevel)
-goto end;
-
-  if (!_mesa_prepare_mipmap_level(ctx, texObj, level + 1,
-  dstWidth, dstHeight, dstDepth,
-  

Mesa (master): meta: use _mesa_prepare_mipmap_levels()

2016-03-29 Thread Brian Paul
Module: Mesa
Branch: master
Commit: ed39de90f1cd209b10baeed8ae98b1f56127c8de
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=ed39de90f1cd209b10baeed8ae98b1f56127c8de

Author: Brian Paul 
Date:   Tue Mar 29 17:44:00 2016 -0600

meta: use _mesa_prepare_mipmap_levels()

The prepare_mipmap_level() wrapper for _mesa_prepare_mipmap_level() is
not needed.  It only served to undo the GL_TEXTURE_1D_ARRAY height/depth
change was was made before the call to prepare_mipmap_level()

Said another way, regardless of how the meta code manipulates the height/
depth dims for GL_TEXTURE_1D_ARRAY, the gl_texture_image dimensions are
correctly set up by _mesa_prepare_mipmap_levels().

Tested by plugging _mesa_meta_GenerateMipmap() into the swrast driver
and testing with piglit.

v2 (idr): Early out of the mipmap generation loop with dstImage is NULL.
This can occur for immutable textures that have a limited range of
levels or in the presense of memory allocation failures.  Fixes
arb_texture_view-mipgen on Intel platforms.

Reviewed-by: José Fonseca 
Reviewed-by: Roland Scheidegger 
Reviewed-by: Ian Romanick 
Tested-by: Ian Romanick 
Reviewed-by: Brian Paul 

---

 src/mesa/drivers/common/meta_generate_mipmap.c | 32 +++---
 1 file changed, 8 insertions(+), 24 deletions(-)

diff --git a/src/mesa/drivers/common/meta_generate_mipmap.c 
b/src/mesa/drivers/common/meta_generate_mipmap.c
index d4b7539..b81e179 100644
--- a/src/mesa/drivers/common/meta_generate_mipmap.c
+++ b/src/mesa/drivers/common/meta_generate_mipmap.c
@@ -137,21 +137,6 @@ _mesa_meta_glsl_generate_mipmap_cleanup(struct gl_context 
*ctx,
_mesa_meta_blit_shader_table_cleanup(ctx, >shaders);
 }
 
-static GLboolean
-prepare_mipmap_level(struct gl_context *ctx,
- struct gl_texture_object *texObj, GLuint level,
- GLsizei width, GLsizei height, GLsizei depth,
- GLenum intFormat, mesa_format format)
-{
-   if (texObj->Target == GL_TEXTURE_1D_ARRAY) {
-  /* Work around Mesa expecting the number of array slices in "height". */
-  height = depth;
-  depth = 1;
-   }
-
-   return _mesa_prepare_mipmap_level(ctx, texObj, level, width, height, depth,
- 0, intFormat, format);
-}
 
 /**
  * Called via ctx->Driver.GenerateMipmap()
@@ -270,6 +255,8 @@ _mesa_meta_GenerateMipmap(struct gl_context *ctx, GLenum 
target,
/* texture is already locked, unlock now */
_mesa_unlock_texture(ctx, texObj);
 
+   _mesa_prepare_mipmap_levels(ctx, texObj, baseLevel, maxLevel);
+
for (dstLevel = baseLevel + 1; dstLevel <= maxLevel; dstLevel++) {
   const struct gl_texture_image *srcImage;
   struct gl_texture_image *dstImage;
@@ -309,17 +296,14 @@ _mesa_meta_GenerateMipmap(struct gl_context *ctx, GLenum 
target,
   _mesa_texture_parameteriv(ctx, texObj, GL_TEXTURE_MAX_LEVEL,
 (GLint *) , false);
 
-  if (!prepare_mipmap_level(ctx, texObj, dstLevel,
-dstWidth, dstHeight, dstDepth,
-srcImage->InternalFormat,
-srcImage->TexFormat)) {
- /* All done.  We either ran out of memory or we would go beyond the
-  * last valid level of an immutable texture if we continued.
-  */
- break;
-  }
   dstImage = _mesa_select_tex_image(texObj, faceTarget, dstLevel);
 
+  /* All done.  We either ran out of memory or we would go beyond the last
+   * valid level of an immutable texture if we continued.
+   */
+  if (dstImage == NULL)
+ break;
+
   /* limit minification to src level */
   _mesa_texture_parameteriv(ctx, texObj, GL_TEXTURE_MAX_LEVEL,
 (GLint *) , false);

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


Mesa (master): tgsi: simplify tgsi_shader_info::is_msaa_sampler checking

2016-03-29 Thread Brian Paul
Module: Mesa
Branch: master
Commit: 5c85c3be26566711a3bdf27df4f9fb07b126882d
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=5c85c3be26566711a3bdf27df4f9fb07b126882d

Author: Brian Paul 
Date:   Tue Mar 29 11:43:02 2016 -0600

tgsi: simplify tgsi_shader_info::is_msaa_sampler checking

We assert that fullinst->Instruction.Texture != 0 above so no need to
check it in the conditional.  We also have the fullinst->Texture.Texture
value in a local variable, so use it.

Reviewed-by: José Fonseca 
Reviewed-by: Roland Scheidegger 

---

 src/gallium/auxiliary/tgsi/tgsi_scan.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/src/gallium/auxiliary/tgsi/tgsi_scan.c 
b/src/gallium/auxiliary/tgsi/tgsi_scan.c
index 6d4b00d..c71c777 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_scan.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_scan.c
@@ -208,9 +208,8 @@ scan_instruction(struct tgsi_shader_info *info,
  }
 
  /* MSAA samplers */
- if (fullinst->Instruction.Texture &&
- (fullinst->Texture.Texture == TGSI_TEXTURE_2D_MSAA ||
-  fullinst->Texture.Texture == TGSI_TEXTURE_2D_ARRAY_MSAA)) {
+ if (target == TGSI_TEXTURE_2D_MSAA ||
+ target == TGSI_TEXTURE_2D_ARRAY_MSAA) {
 info->is_msaa_sampler[src->Register.Index] = TRUE;
  }
   }

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


Mesa (master): docs: add HTTP link for Mesa downloads

2016-03-29 Thread Brian Paul
Module: Mesa
Branch: master
Commit: bab0752a805214645af92aec7ca692f723640c36
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=bab0752a805214645af92aec7ca692f723640c36

Author: Brian Paul 
Date:   Tue Mar 29 12:54:10 2016 -0600

docs: add HTTP link for Mesa downloads

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=92628
Reviewed-by: Jose Fonseca 
Reviewed-by: Ian Romanick 

---

 docs/download.html | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/docs/download.html b/docs/download.html
index 856c2a5..e90c1bb 100644
--- a/docs/download.html
+++ b/docs/download.html
@@ -18,7 +18,9 @@
 
 
 Primary Mesa download site:
-ftp://ftp.freedesktop.org/pub/mesa/;>freedesktop.org (FTP)
+ftp://ftp.freedesktop.org/pub/mesa/;>ftp.freedesktop.org (FTP)
+or https://mesa.freedesktop.org/archive/;>mesa.freedesktop.org
+(HTTP).
 
 
 

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


Mesa (master): tgsi: collect texture sampler target info in tgsi_scan_shader()

2016-03-29 Thread Brian Paul
Module: Mesa
Branch: master
Commit: 86e1768c13d67945f4a9549820e711b70ff2aba7
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=86e1768c13d67945f4a9549820e711b70ff2aba7

Author: Brian Paul 
Date:   Sat Mar 26 11:46:53 2016 -0600

tgsi: collect texture sampler target info in tgsi_scan_shader()

Texture sample instructions specify a sampler unit and texture target
such as "1D", "2D", "CUBE", etc.  Sampler view declarations also specify
the sampler unit and texture target.

This patch checks that the texture instructions agree with the declarations
and collects the texture target type for each sampler unit.

v2: only compare instruction's texture target to the sampler view declaration
target if the instruction is a TEX instruction, not a SAMPLE instruction.

Reviewed-by: José Fonseca 
Reviewed-by: Roland Scheidegger 

---

 src/gallium/auxiliary/tgsi/tgsi_scan.c | 38 --
 src/gallium/auxiliary/tgsi/tgsi_scan.h |  1 +
 2 files changed, 37 insertions(+), 2 deletions(-)

diff --git a/src/gallium/auxiliary/tgsi/tgsi_scan.c 
b/src/gallium/auxiliary/tgsi/tgsi_scan.c
index d32c3a1..6d4b00d 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_scan.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_scan.c
@@ -181,11 +181,33 @@ scan_instruction(struct tgsi_shader_info *info,
  info->indirect_files_read |= (1 << src->Register.File);
   }
 
-  /* MSAA samplers */
+  /* Texture samplers */
   if (src->Register.File == TGSI_FILE_SAMPLER) {
+ const unsigned index = src->Register.Index;
+ const unsigned target = fullinst->Texture.Texture;
+
  assert(fullinst->Instruction.Texture);
- assert(src->Register.Index < Elements(info->is_msaa_sampler));
+ assert(index < Elements(info->is_msaa_sampler));
+ assert(index < PIPE_MAX_SAMPLERS);
+ assert(target < TGSI_TEXTURE_UNKNOWN);
+
+ if (tgsi_get_opcode_info(fullinst->Instruction.Opcode)->is_tex) {
+/* for texture instructions, check that the texture instruction
+ * target matches the previous sampler view declaration (if there
+ * was one.)
+ */
+if (info->sampler_targets[index] == TGSI_TEXTURE_UNKNOWN) {
+   /* probably no sampler view declaration */
+   info->sampler_targets[index] = target;
+} else {
+   /* Make sure the texture instruction's sampler/target info
+* agrees with the sampler view declaration.
+*/
+   assert(info->sampler_targets[index] == target);
+}
+ }
 
+ /* MSAA samplers */
  if (fullinst->Instruction.Texture &&
  (fullinst->Texture.Texture == TGSI_TEXTURE_2D_MSAA ||
   fullinst->Texture.Texture == TGSI_TEXTURE_2D_ARRAY_MSAA)) {
@@ -431,6 +453,16 @@ scan_declaration(struct tgsi_shader_info *info,
  }
   } else if (file == TGSI_FILE_SAMPLER) {
  info->samplers_declared |= 1 << reg;
+  } else if (file == TGSI_FILE_SAMPLER_VIEW) {
+ unsigned target = fulldecl->SamplerView.Resource;
+ assert(target < TGSI_TEXTURE_UNKNOWN);
+ if (info->sampler_targets[reg] == TGSI_TEXTURE_UNKNOWN) {
+/* Save sampler target for this sampler index */
+info->sampler_targets[reg] = target;
+ } else {
+/* if previously declared, make sure targets agree */
+assert(info->sampler_targets[reg] == target);
+ }
   } else if (file == TGSI_FILE_IMAGE) {
  if (fulldecl->Image.Resource == TGSI_TEXTURE_BUFFER)
 info->images_buffers |= 1 << reg;
@@ -493,6 +525,8 @@ tgsi_scan_shader(const struct tgsi_token *tokens,
for (i = 0; i < Elements(info->const_file_max); i++)
   info->const_file_max[i] = -1;
info->properties[TGSI_PROPERTY_GS_INVOCATIONS] = 1;
+   for (i = 0; i < Elements(info->sampler_targets); i++)
+  info->sampler_targets[i] = TGSI_TEXTURE_UNKNOWN;
 
/**
 ** Setup to begin parsing input shader
diff --git a/src/gallium/auxiliary/tgsi/tgsi_scan.h 
b/src/gallium/auxiliary/tgsi/tgsi_scan.h
index 76d8925..31adce7 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_scan.h
+++ b/src/gallium/auxiliary/tgsi/tgsi_scan.h
@@ -65,6 +65,7 @@ struct tgsi_shader_info
int file_max[TGSI_FILE_COUNT];  /**< highest index of declared registers */
int const_file_max[PIPE_MAX_CONSTANT_BUFFERS];
unsigned samplers_declared; /**< bitmask of declared samplers */
+   ubyte sampler_targets[PIPE_MAX_SHADER_SAMPLER_VIEWS];  /**< TGSI_TEXTURE_x 
values */
 
ubyte input_array_first[PIPE_MAX_SHADER_INPUTS];
ubyte input_array_last[PIPE_MAX_SHADER_INPUTS];

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


Mesa (master): Revert "i965: Set address rounding bits for GL_NEAREST filtering as well."

2016-03-29 Thread Kenneth Graunke
Module: Mesa
Branch: master
Commit: f8c69fbb5491c8790dd3bcf991f06151d15d92b9
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=f8c69fbb5491c8790dd3bcf991f06151d15d92b9

Author: Kenneth Graunke 
Date:   Tue Mar 29 15:35:07 2016 -0700

Revert "i965: Set address rounding bits for GL_NEAREST filtering as well."

This reverts commit 60d6a8989ab44cf47accee6bc692ba6fb98f6a9f.

It's pretty sketchy, and apparently regressed a bunch of dEQP tests
on Sandybridge.

---

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

diff --git a/src/mesa/drivers/dri/i965/brw_sampler_state.c 
b/src/mesa/drivers/dri/i965/brw_sampler_state.c
index 7bd21f7..3bd22c7 100644
--- a/src/mesa/drivers/dri/i965/brw_sampler_state.c
+++ b/src/mesa/drivers/dri/i965/brw_sampler_state.c
@@ -436,17 +436,14 @@ brw_update_sampler_state(struct brw_context *brw,
   }
}
 
-   /* Set address rounding bits.  The conditions are empirically
-* derived in order to pass test cases.
-*/
-   bool round_nearest = brw->gen >= 6 && target != GL_TEXTURE_3D;
+   /* Set address rounding bits if not using nearest filtering. */
unsigned address_rounding = 0;
-   if (min_filter != BRW_MAPFILTER_NEAREST || round_nearest) {
+   if (min_filter != BRW_MAPFILTER_NEAREST) {
   address_rounding |= BRW_ADDRESS_ROUNDING_ENABLE_U_MIN |
   BRW_ADDRESS_ROUNDING_ENABLE_V_MIN |
   BRW_ADDRESS_ROUNDING_ENABLE_R_MIN;
}
-   if (mag_filter != BRW_MAPFILTER_NEAREST || round_nearest) {
+   if (mag_filter != BRW_MAPFILTER_NEAREST) {
   address_rounding |= BRW_ADDRESS_ROUNDING_ENABLE_U_MAG |
   BRW_ADDRESS_ROUNDING_ENABLE_V_MAG |
   BRW_ADDRESS_ROUNDING_ENABLE_R_MAG;

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


Mesa (master): i965: Don't use CUBE wrap modes for integer formats on IVB/ BYT.

2016-03-29 Thread Kenneth Graunke
Module: Mesa
Branch: master
Commit: d4a5a61d445e683c20de00c1febe847b4c2db910
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=d4a5a61d445e683c20de00c1febe847b4c2db910

Author: Kenneth Graunke 
Date:   Mon Mar 28 20:07:13 2016 -0700

i965: Don't use CUBE wrap modes for integer formats on IVB/BYT.

There is no linear filtering for integer formats, so we should always
be using CLAMP_TO_EDGE mode.

Fixes 46 dEQP cases on Ivybridge (which were likely broken by commit
0faf26e6a0a34c3544644852802484f2404cc83e).

This workaround doesn't appear to be necessary on any other hardware;
I haven't found any documentation mentioning errata in this area.

v2: Only apply on Ivybridge/Baytrail to avoid regressing GLES3.1 tests.

Signed-off-by: Kenneth Graunke 
Reviewed-by: Jason Ekstrand  [v1]

---

 src/mesa/drivers/dri/i965/brw_sampler_state.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/mesa/drivers/dri/i965/brw_sampler_state.c 
b/src/mesa/drivers/dri/i965/brw_sampler_state.c
index 3bd22c7..1dc7d71 100644
--- a/src/mesa/drivers/dri/i965/brw_sampler_state.c
+++ b/src/mesa/drivers/dri/i965/brw_sampler_state.c
@@ -459,8 +459,12 @@ brw_update_sampler_state(struct brw_context *brw,
target == GL_TEXTURE_CUBE_MAP_ARRAY) {
   /* Cube maps must use the same wrap mode for all three coordinate
* dimensions.  Prior to Haswell, only CUBE and CLAMP are valid.
+   *
+   * Ivybridge and Baytrail seem to have problems with CUBE mode and
+   * integer formats.  Fall back to CLAMP for now.
*/
-  if (tex_cube_map_seamless || sampler->CubeMapSeamless) {
+  if ((tex_cube_map_seamless || sampler->CubeMapSeamless) &&
+  !(brw->gen == 7 && !brw->is_haswell && is_integer_format)) {
 wrap_s = BRW_TEXCOORDMODE_CUBE;
 wrap_t = BRW_TEXCOORDMODE_CUBE;
 wrap_r = BRW_TEXCOORDMODE_CUBE;

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


Mesa (master): gallium: Format code in pb_buffer_fenced.c according to style guide.

2016-03-29 Thread Brian Paul
Module: Mesa
Branch: master
Commit: 7087e0ab27da5eaad10a18ddba3234960a2b5524
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=7087e0ab27da5eaad10a18ddba3234960a2b5524

Author: Rovanion Luckey 
Date:   Tue Mar 29 13:43:00 2016 -0600

gallium: Format code in pb_buffer_fenced.c according to style guide.

This is a tiny housekeeping patch which does the following:

  * Replaced tabs with three spaces.
  * Formatted oneline and multiline code comments. Some doxygen
comments weren't marked as such and some code comments were marked
as doxygen comments.
  * Spaces between if- and while-statements and their parenthesis.

According to the mesa coding style guidelines.

Reviewed-by: Brian Paul 

---

 .../auxiliary/pipebuffer/pb_buffer_fenced.c| 226 +
 1 file changed, 97 insertions(+), 129 deletions(-)

diff --git a/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c 
b/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c
index 2678268..fbbe8d1 100644
--- a/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c
+++ b/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c
@@ -108,14 +108,14 @@ struct fenced_manager
  */
 struct fenced_buffer
 {
-   /*
+   /**
 * Immutable members.
 */
 
struct pb_buffer base;
struct fenced_manager *mgr;
 
-   /*
+   /**
 * Following members are mutable and protected by fenced_manager::mutex.
 */
 
@@ -205,7 +205,7 @@ fenced_manager_dump_locked(struct fenced_manager 
*fenced_mgr)
 
curr = fenced_mgr->unfenced.next;
next = curr->next;
-   while(curr != _mgr->unfenced) {
+   while (curr != _mgr->unfenced) {
   fenced_buf = LIST_ENTRY(struct fenced_buffer, curr, head);
   assert(!fenced_buf->fence);
   debug_printf("%10p %7u %8u %7s\n",
@@ -219,7 +219,7 @@ fenced_manager_dump_locked(struct fenced_manager 
*fenced_mgr)
 
curr = fenced_mgr->fenced.next;
next = curr->next;
-   while(curr != _mgr->fenced) {
+   while (curr != _mgr->fenced) {
   int signaled;
   fenced_buf = LIST_ENTRY(struct fenced_buffer, curr, head);
   assert(fenced_buf->buffer);
@@ -340,7 +340,7 @@ fenced_buffer_finish_locked(struct fenced_manager 
*fenced_mgr,
assert(pipe_is_referenced(_buf->base.reference));
assert(fenced_buf->fence);
 
-   if(fenced_buf->fence) {
+   if (fenced_buf->fence) {
   struct pipe_fence_handle *fence = NULL;
   int finished;
   boolean proceed;
@@ -355,8 +355,7 @@ fenced_buffer_finish_locked(struct fenced_manager 
*fenced_mgr,
 
   assert(pipe_is_referenced(_buf->base.reference));
 
-  /*
-   * Only proceed if the fence object didn't change in the meanwhile.
+  /* Only proceed if the fence object didn't change in the meanwhile.
* Otherwise assume the work has been already carried out by another
* thread that re-aquired the lock before us.
*/
@@ -364,14 +363,9 @@ fenced_buffer_finish_locked(struct fenced_manager 
*fenced_mgr,
 
   ops->fence_reference(ops, , NULL);
 
-  if(proceed && finished == 0) {
- /*
-  * Remove from the fenced list
-  */
-
- boolean destroyed;
-
- destroyed = fenced_buffer_remove_locked(fenced_mgr, fenced_buf);
+  if (proceed && finished == 0) {
+ /* Remove from the fenced list. */
+ boolean destroyed = fenced_buffer_remove_locked(fenced_mgr, 
fenced_buf);
 
  /* TODO: remove consequents buffers with the same fence? */
 
@@ -405,36 +399,33 @@ fenced_manager_check_signalled_locked(struct 
fenced_manager *fenced_mgr,
 
curr = fenced_mgr->fenced.next;
next = curr->next;
-   while(curr != _mgr->fenced) {
+   while (curr != _mgr->fenced) {
   fenced_buf = LIST_ENTRY(struct fenced_buffer, curr, head);
 
-  if(fenced_buf->fence != prev_fence) {
-int signaled;
+  if (fenced_buf->fence != prev_fence) {
+ int signaled;
 
-if (wait) {
-   signaled = ops->fence_finish(ops, fenced_buf->fence, 0);
+ if (wait) {
+signaled = ops->fence_finish(ops, fenced_buf->fence, 0);
 
-   /*
-* Don't return just now. Instead preemptively check if the
-* following buffers' fences already expired, without further waits.
-*/
-   wait = FALSE;
-}
-else {
-   signaled = ops->fence_signalled(ops, fenced_buf->fence, 0);
-}
+/* Don't return just now. Instead preemptively check if the
+ * following buffers' fences already expired, without further 
waits.
+ */
+wait = FALSE;
+ } else {
+signaled = ops->fence_signalled(ops, fenced_buf->fence, 0);
+ }
 
-if (signaled != 0) {
-   return ret;
+ if (signaled != 0) {
+return ret;
  }
 
-prev_fence = fenced_buf->fence;
-  }
-  else {
+ prev_fence = fenced_buf->fence;
+  } else {
  

Mesa (master): svga: avoid freeing non-malloced memory

2016-03-29 Thread Brian Paul
Module: Mesa
Branch: master
Commit: 96e0894106b25eec2bab4545566d832846e99034
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=96e0894106b25eec2bab4545566d832846e99034

Author: Brian Paul 
Date:   Tue Mar 29 13:34:36 2016 -0600

svga: avoid freeing non-malloced memory

svga_shader_expand() will fall back to using non-malloced memory for
emit.buf if malloc fails. We should check if the memory is malloced
before freeing it in the error path of svga_tgsi_vgpu9_translate.

Original patch by Thomas Hindoe Paaboel Andersen .
Remove trivial svga_destroy_shader_emitter() function, by BrianP.

Signed-off-by: Brian Paul 

---

 src/gallium/drivers/svga/svga_tgsi.c | 12 ++--
 1 file changed, 2 insertions(+), 10 deletions(-)

diff --git a/src/gallium/drivers/svga/svga_tgsi.c 
b/src/gallium/drivers/svga/svga_tgsi.c
index c62d4d6..7396ad0 100644
--- a/src/gallium/drivers/svga/svga_tgsi.c
+++ b/src/gallium/drivers/svga/svga_tgsi.c
@@ -50,15 +50,6 @@
  */
 static char err_buf[128];
 
-#if 0
-static void
-svga_destroy_shader_emitter(struct svga_shader_emitter *emit)
-{
-   if (emit->buf != err_buf)
-  FREE(emit->buf);
-}
-#endif
-
 
 static boolean
 svga_shader_expand(struct svga_shader_emitter *emit)
@@ -265,6 +256,7 @@ svga_tgsi_vgpu9_translate(struct svga_context *svga,
 
  fail:
FREE(variant);
-   FREE(emit.buf);
+   if (emit.buf != err_buf)
+  FREE(emit.buf);
return NULL;
 }

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


Mesa (master): svga: emit sampler declarations in the helper function for non vgpu10

2016-03-29 Thread Brian Paul
Module: Mesa
Branch: master
Commit: 2d8df0306b45163eede94421948e9b1ae05e47bd
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=2d8df0306b45163eede94421948e9b1ae05e47bd

Author: Charmaine Lee 
Date:   Tue Mar 29 13:34:36 2016 -0600

svga: emit sampler declarations in the helper function for non vgpu10

With commit dc9ecf58c0c5c8a97cd41362e78c2fcd9f6e3b80,
we are now getting the sampler target from the sampler view
declaration. But since a sampler view declaration can be defined
after a sampler declaration, we need to emit the
sampler declarations in the pre-helpers function, otherwise,
the sampler target might not have defined yet for the sampler declaration.

Fixes viewperf maya-03 and various gl trace regressions in hwv11.

Reviewed-by: Brian Paul 

---

 src/gallium/drivers/svga/svga_tgsi_decl_sm30.c | 19 ---
 src/gallium/drivers/svga/svga_tgsi_emit.h  |  4 
 src/gallium/drivers/svga/svga_tgsi_insn.c  |  3 +++
 3 files changed, 23 insertions(+), 3 deletions(-)

diff --git a/src/gallium/drivers/svga/svga_tgsi_decl_sm30.c 
b/src/gallium/drivers/svga/svga_tgsi_decl_sm30.c
index 204b814..418f898 100644
--- a/src/gallium/drivers/svga/svga_tgsi_decl_sm30.c
+++ b/src/gallium/drivers/svga/svga_tgsi_decl_sm30.c
@@ -535,7 +535,6 @@ svga_tgsi_sampler_type(const struct svga_shader_emitter 
*emit, int idx)
 
 static boolean
 ps30_sampler( struct svga_shader_emitter *emit,
-  struct tgsi_declaration_semantic semantic,
   unsigned idx )
 {
SVGA3DOpDclArgs dcl;
@@ -553,6 +552,17 @@ ps30_sampler( struct svga_shader_emitter *emit,
svga_shader_emit_dwords( emit, dcl.values, Elements(dcl.values)));
 }
 
+boolean
+svga_shader_emit_samplers_decl( struct svga_shader_emitter *emit )
+{
+   unsigned i;
+
+   for (i = 0; i < emit->num_samplers; i++) {
+  if (!ps30_sampler(emit, i))
+ return FALSE;
+   }
+   return TRUE;
+}
 
 boolean
 svga_translate_decl_sm30( struct svga_shader_emitter *emit,
@@ -563,12 +573,15 @@ svga_translate_decl_sm30( struct svga_shader_emitter 
*emit,
unsigned idx;
 
for( idx = first; idx <= last; idx++ ) {
-  boolean ok;
+  boolean ok = TRUE;
 
   switch (decl->Declaration.File) {
   case TGSI_FILE_SAMPLER:
  assert (emit->unit == PIPE_SHADER_FRAGMENT);
- ok = ps30_sampler( emit, decl->Semantic, idx );
+ /* just keep track of the number of samplers here.
+  * Will emit the declaration in the helpers function.
+  */
+ emit->num_samplers = MAX2(emit->num_samplers, decl->Range.Last + 1);
  break;
 
   case TGSI_FILE_INPUT:
diff --git a/src/gallium/drivers/svga/svga_tgsi_emit.h 
b/src/gallium/drivers/svga/svga_tgsi_emit.h
index 7a593ba..114c956 100644
--- a/src/gallium/drivers/svga/svga_tgsi_emit.h
+++ b/src/gallium/drivers/svga/svga_tgsi_emit.h
@@ -137,6 +137,7 @@ struct svga_shader_emitter
 
unsigned pstipple_sampler_unit;
 
+   int num_samplers;
uint8_t sampler_target[PIPE_MAX_SAMPLERS];
 };
 
@@ -157,6 +158,9 @@ svga_shader_emit_instructions(struct svga_shader_emitter 
*emit,
   const struct tgsi_token *tokens);
 
 boolean
+svga_shader_emit_samplers_decl(struct svga_shader_emitter *emit);
+
+boolean
 svga_translate_decl_sm30(struct svga_shader_emitter *emit,
  const struct tgsi_full_declaration *decl);
 
diff --git a/src/gallium/drivers/svga/svga_tgsi_insn.c 
b/src/gallium/drivers/svga/svga_tgsi_insn.c
index 3188c41..bedda2e 100644
--- a/src/gallium/drivers/svga/svga_tgsi_insn.c
+++ b/src/gallium/drivers/svga/svga_tgsi_insn.c
@@ -3797,6 +3797,9 @@ svga_shader_emit_helpers(struct svga_shader_emitter *emit)
}
 
if (emit->unit == PIPE_SHADER_FRAGMENT) {
+  if (!svga_shader_emit_samplers_decl( emit ))
+ return FALSE;
+
   if (!emit_ps_preamble( emit ))
  return FALSE;
 

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


Mesa (master): nvc0/ir: move load/store lowering pass to handleLDST()

2016-03-29 Thread Samuel Pitoiset
Module: Mesa
Branch: master
Commit: 9d57c84994abe45133382cf72ae617570bfe89da
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=9d57c84994abe45133382cf72ae617570bfe89da

Author: Samuel Pitoiset 
Date:   Tue Mar 29 19:27:49 2016 +0200

nvc0/ir: move load/store lowering pass to handleLDST()

Having all this code in a big switch is not really a good pratice.

Signed-off-by: Samuel Pitoiset 
Reviewed-by: Ilia Mirkin 

---

 .../nouveau/codegen/nv50_ir_lowering_nvc0.cpp  | 114 +++--
 .../nouveau/codegen/nv50_ir_lowering_nvc0.h|   1 +
 2 files changed, 61 insertions(+), 54 deletions(-)

diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_nvc0.cpp 
b/src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_nvc0.cpp
index 68a30ec..850147b 100644
--- a/src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_nvc0.cpp
+++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_nvc0.cpp
@@ -1692,6 +1692,65 @@ NVC0LoweringPass::handleWRSV(Instruction *i)
 }
 
 void
+NVC0LoweringPass::handleLDST(Instruction *i)
+{
+   if (i->src(0).getFile() == FILE_SHADER_INPUT) {
+  if (prog->getType() == Program::TYPE_COMPUTE) {
+ i->getSrc(0)->reg.file = FILE_MEMORY_CONST;
+ i->getSrc(0)->reg.fileIndex = 0;
+  } else
+  if (prog->getType() == Program::TYPE_GEOMETRY &&
+  i->src(0).isIndirect(0)) {
+ // XXX: this assumes vec4 units
+ Value *ptr = bld.mkOp2v(OP_SHL, TYPE_U32, bld.getSSA(),
+ i->getIndirect(0, 0), bld.mkImm(4));
+ i->setIndirect(0, 0, ptr);
+ i->op = OP_VFETCH;
+  } else {
+ i->op = OP_VFETCH;
+ assert(prog->getType() != Program::TYPE_FRAGMENT); // INTERP
+  }
+   } else if (i->src(0).getFile() == FILE_MEMORY_CONST) {
+  if (i->src(0).isIndirect(1)) {
+ Value *ptr;
+ if (i->src(0).isIndirect(0))
+ptr = bld.mkOp3v(OP_INSBF, TYPE_U32, bld.getSSA(),
+ i->getIndirect(0, 1), bld.mkImm(0x1010),
+ i->getIndirect(0, 0));
+ else
+ptr = bld.mkOp2v(OP_SHL, TYPE_U32, bld.getSSA(),
+ i->getIndirect(0, 1), bld.mkImm(16));
+ i->setIndirect(0, 1, NULL);
+ i->setIndirect(0, 0, ptr);
+ i->subOp = NV50_IR_SUBOP_LDC_IS;
+  }
+   } else if (i->src(0).getFile() == FILE_SHADER_OUTPUT) {
+  assert(prog->getType() == Program::TYPE_TESSELLATION_CONTROL);
+  i->op = OP_VFETCH;
+   } else if (i->src(0).getFile() == FILE_MEMORY_GLOBAL) {
+  Value *ind = i->getIndirect(0, 1);
+  Value *ptr = loadBufInfo64(ind, i->getSrc(0)->reg.fileIndex * 16);
+  // XXX come up with a way not to do this for EVERY little access but
+  // rather to batch these up somehow. Unfortunately we've lost the
+  // information about the field width by the time we get here.
+  Value *offset = bld.loadImm(NULL, i->getSrc(0)->reg.data.offset + 
typeSizeof(i->sType));
+  Value *length = loadBufLength32(ind, i->getSrc(0)->reg.fileIndex * 16);
+  Value *pred = new_LValue(func, FILE_PREDICATE);
+  if (i->src(0).isIndirect(0)) {
+ bld.mkOp2(OP_ADD, TYPE_U64, ptr, ptr, i->getIndirect(0, 0));
+ bld.mkOp2(OP_ADD, TYPE_U32, offset, offset, i->getIndirect(0, 0));
+  }
+  i->setIndirect(0, 1, NULL);
+  i->setIndirect(0, 0, ptr);
+  bld.mkCmp(OP_SET, CC_GT, TYPE_U32, pred, TYPE_U32, offset, length);
+  i->setPredicate(CC_NOT_P, pred);
+  if (i->defExists(0)) {
+ bld.mkMov(i->getDef(0), bld.mkImm(0));
+  }
+   }
+}
+
+void
 NVC0LoweringPass::readTessCoord(LValue *dst, int c)
 {
Value *laneid = bld.getSSA();
@@ -2016,60 +2075,7 @@ NVC0LoweringPass::visit(Instruction *i)
   return handleWRSV(i);
case OP_STORE:
case OP_LOAD:
-  if (i->src(0).getFile() == FILE_SHADER_INPUT) {
- if (prog->getType() == Program::TYPE_COMPUTE) {
-i->getSrc(0)->reg.file = FILE_MEMORY_CONST;
-i->getSrc(0)->reg.fileIndex = 0;
- } else
- if (prog->getType() == Program::TYPE_GEOMETRY &&
- i->src(0).isIndirect(0)) {
-// XXX: this assumes vec4 units
-Value *ptr = bld.mkOp2v(OP_SHL, TYPE_U32, bld.getSSA(),
-i->getIndirect(0, 0), bld.mkImm(4));
-i->setIndirect(0, 0, ptr);
-i->op = OP_VFETCH;
- } else {
-i->op = OP_VFETCH;
-assert(prog->getType() != Program::TYPE_FRAGMENT); // INTERP
- }
-  } else if (i->src(0).getFile() == FILE_MEMORY_CONST) {
- if (i->src(0).isIndirect(1)) {
-Value *ptr;
-if (i->src(0).isIndirect(0))
-   ptr = bld.mkOp3v(OP_INSBF, TYPE_U32, bld.getSSA(),
-i->getIndirect(0, 1), bld.mkImm(0x1010),
-

Mesa (master): st/vdpau: add new interop interface

2016-03-29 Thread Christian König
Module: Mesa
Branch: master
Commit: faba96bc60bfcf28678781f20ee0a42eb1950018
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=faba96bc60bfcf28678781f20ee0a42eb1950018

Author: Christian König 
Date:   Tue Jan 12 16:07:58 2016 +0100

st/vdpau: add new interop interface

Use DMA-buf for the VDPAU interop interface instead of using
internal structures.

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

---

 src/gallium/include/state_tracker/vdpau_dmabuf.h  | 94 +++
 src/gallium/include/state_tracker/vdpau_interop.h |  7 +-
 2 files changed, 100 insertions(+), 1 deletion(-)

diff --git a/src/gallium/include/state_tracker/vdpau_dmabuf.h 
b/src/gallium/include/state_tracker/vdpau_dmabuf.h
new file mode 100644
index 000..886c344
--- /dev/null
+++ b/src/gallium/include/state_tracker/vdpau_dmabuf.h
@@ -0,0 +1,94 @@
+/**
+ *
+ * Copyright 2016 Advanced Micro Devices, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **/
+
+/*
+ * Authors:
+ *  Christian König 
+ *
+ */
+
+#ifndef _VDPAU_DMABUF_H_
+#define _VDPAU_DMABUF_H_
+
+#include 
+
+/* driver specific functions for NV_vdpau_interop */
+#ifndef VDP_FUNC_ID_BASE_DRIVER
+#define VDP_FUNC_ID_BASE_DRIVER 0x2000
+#endif
+
+/* New DMA-buf based implementation */
+#define VDP_FUNC_ID_VIDEO_SURFACE_DMA_BUF (VDP_FUNC_ID_BASE_DRIVER + 2)
+#define VDP_FUNC_ID_OUTPUT_SURFACE_DMA_BUF (VDP_FUNC_ID_BASE_DRIVER + 3)
+
+/* Define some more internal RGBA formats for more
+ * robust handling of Video Surfaces
+ */
+#define VDP_RGBA_FORMAT_R8  (-1)
+#define VDP_RGBA_FORMAT_R8G8(-2)
+
+struct VdpSurfaceDMABufDesc {
+   /* DMA-buf file descriptor */
+   uint32_t handle;
+   /* Width in pixel */
+   uint32_t width;
+   /* Height in pixel */
+   uint32_t height;
+   /* Offset in bytes */
+   uint32_t offset;
+   /* Stride in bytes */
+   uint32_t stride;
+   /* VDP_RGBA_FORMAT_* as defined in the VDPAU spec and above. */
+   uint32_t format;
+};
+
+/**
+ * \brief Video surface planes
+ */
+typedef uint32_t VdpVideoSurfacePlane;
+
+/** \hideinitializer \brief Luma top field */
+#define VDP_VIDEO_SURFACE_PLANE_LUMA_TOP  ((VdpVideoSurfacePlane)0)
+/** \hideinitializer \brief Luma bottom field */
+#define VDP_VIDEO_SURFACE_PLANE_LUMA_BOTTOM   ((VdpVideoSurfacePlane)1)
+/** \hideinitializer \brief Chroma top field */
+#define VDP_VIDEO_SURFACE_PLANE_CHROMA_TOP((VdpVideoSurfacePlane)2)
+/** \hideinitializer \brief Chroma bottom field */
+#define VDP_VIDEO_SURFACE_PLANE_CHROMA_BOTTOM ((VdpVideoSurfacePlane)3)
+
+typedef VdpStatus VdpVideoSurfaceDMABuf(
+   VdpVideoSurface   surface,
+   VdpVideoSurfacePlane  plane,
+   struct VdpSurfaceDMABufDesc * result
+);
+
+typedef VdpStatus VdpOutputSurfaceDMABuf(
+   VdpVideoSurface   surface,
+   struct VdpSurfaceDMABufDesc * result
+);
+
+#endif /* _VDPAU_DMABUF_H_ */
diff --git a/src/gallium/include/state_tracker/vdpau_interop.h 
b/src/gallium/include/state_tracker/vdpau_interop.h
index 3ca7c9d..04d455a 100644
--- a/src/gallium/include/state_tracker/vdpau_interop.h
+++ b/src/gallium/include/state_tracker/vdpau_interop.h
@@ -35,8 +35,13 @@
 #define _VDPAU_INTEROP_H_
 
 /* driver specific functions for NV_vdpau_interop */
-
+#ifndef VDP_FUNC_ID_BASE_DRIVER
 #define VDP_FUNC_ID_BASE_DRIVER 0x2000
+#endif
+
+/* Older implementation relying on passing pipe_video_buffer and
+ * pipe_resources around. Deprecated and shouldn't be used for new things.
+ */
 #define VDP_FUNC_ID_VIDEO_SURFACE_GALLIUM (VDP_FUNC_ID_BASE_DRIVER + 0)
 #define VDP_FUNC_ID_OUTPUT_SURFACE_GALLIUM (VDP_FUNC_ID_BASE_DRIVER + 1)
 


Mesa (master): st/mesa: implement new DMA-buf based VDPAU interop v2

2016-03-29 Thread Christian König
Module: Mesa
Branch: master
Commit: cc68dc2b5e3c603580f70d682b0772d179b28ce3
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=cc68dc2b5e3c603580f70d682b0772d179b28ce3

Author: Christian König 
Date:   Thu Jan 14 16:46:57 2016 +0100

st/mesa: implement new DMA-buf based VDPAU interop v2

Avoid using internal structures from another API.

v2: rebase and moved includes so they don't cause problem when VDPAU isn't 
installed.

Signed-off-by: Christian König 
Reviewed-by: Marek Olšák  (v1)
Reviewed-by: Leo Liu 

---

 src/mesa/state_tracker/st_vdpau.c | 181 +++---
 1 file changed, 132 insertions(+), 49 deletions(-)

diff --git a/src/mesa/state_tracker/st_vdpau.c 
b/src/mesa/state_tracker/st_vdpau.c
index 71dd15b..b9abebf 100644
--- a/src/mesa/state_tracker/st_vdpau.c
+++ b/src/mesa/state_tracker/st_vdpau.c
@@ -39,8 +39,6 @@
 #include "pipe/p_state.h"
 #include "pipe/p_video_codec.h"
 
-#include "state_tracker/vdpau_interop.h"
-
 #include "util/u_inlines.h"
 
 #include "st_vdpau.h"
@@ -51,70 +49,155 @@
 
 #ifdef HAVE_ST_VDPAU
 
+#include "state_tracker/vdpau_interop.h"
+#include "state_tracker/vdpau_dmabuf.h"
+#include "state_tracker/vdpau_funcs.h"
+#include "state_tracker/drm_driver.h"
+
+static struct pipe_resource *
+st_vdpau_video_surface_gallium(struct gl_context *ctx, const GLvoid 
*vdpSurface,
+   GLuint index)
+{
+   int (*getProcAddr)(uint32_t device, uint32_t id, void **ptr);
+   uint32_t device = (uintptr_t)ctx->vdpDevice;
+   struct pipe_sampler_view *sv;
+   VdpVideoSurfaceGallium *f;
+
+   struct pipe_video_buffer *buffer;
+   struct pipe_sampler_view **samplers;
+
+   getProcAddr = (void *)ctx->vdpGetProcAddress;
+   if (getProcAddr(device, VDP_FUNC_ID_VIDEO_SURFACE_GALLIUM, (void**)))
+  return NULL;
+
+   buffer = f((uintptr_t)vdpSurface);
+   if (!buffer)
+  return NULL;
+
+   samplers = buffer->get_sampler_view_planes(buffer);
+   if (!samplers)
+  return NULL;
+
+   sv = samplers[index >> 1];
+   if (!sv)
+  return NULL;
+
+   return sv->texture;
+}
+
+static struct pipe_resource *
+st_vdpau_output_surface_gallium(struct gl_context *ctx, const GLvoid 
*vdpSurface)
+{
+   int (*getProcAddr)(uint32_t device, uint32_t id, void **ptr);
+   uint32_t device = (uintptr_t)ctx->vdpDevice;
+   VdpOutputSurfaceGallium *f;
+
+   getProcAddr = (void *)ctx->vdpGetProcAddress;
+   if (getProcAddr(device, VDP_FUNC_ID_OUTPUT_SURFACE_GALLIUM, (void**)))
+  return NULL;
+
+   return f((uintptr_t)vdpSurface);
+}
+
+static struct pipe_resource *
+st_vdpau_resource_from_description(struct gl_context *ctx,
+   const struct VdpSurfaceDMABufDesc *desc)
+{
+   struct st_context *st = st_context(ctx);
+   struct pipe_resource templ, *res;
+   struct winsys_handle whandle;
+
+   if (desc->handle == -1)
+  return NULL;
+
+   memset(, 0, sizeof(templ));
+   templ.target = PIPE_TEXTURE_2D;
+   templ.last_level = 0;
+   templ.depth0 = 1;
+   templ.array_size = 1;
+   templ.width0 = desc->width;
+   templ.height0 = desc->height;
+   templ.format = VdpFormatRGBAToPipe(desc->format);
+   templ.bind = PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_RENDER_TARGET;
+   templ.usage = PIPE_USAGE_DEFAULT;
+
+   memset(, 0, sizeof(whandle));
+   whandle.type = DRM_API_HANDLE_TYPE_FD;
+   whandle.handle = desc->handle;
+   whandle.offset = desc->offset;
+   whandle.stride = desc->stride;
+
+   res = st->pipe->screen->resource_from_handle(st->pipe->screen, , 
,
+   PIPE_HANDLE_USAGE_READ_WRITE);
+   close(desc->handle);
+
+   return res;
+}
+
+static struct pipe_resource *
+st_vdpau_output_surface_dma_buf(struct gl_context *ctx, const GLvoid 
*vdpSurface)
+{
+   int (*getProcAddr)(uint32_t device, uint32_t id, void **ptr);
+   uint32_t device = (uintptr_t)ctx->vdpDevice;
+
+   struct VdpSurfaceDMABufDesc desc;
+   VdpOutputSurfaceDMABuf *f;
+
+   getProcAddr = (void *)ctx->vdpGetProcAddress;
+   if (getProcAddr(device, VDP_FUNC_ID_OUTPUT_SURFACE_DMA_BUF, (void**)))
+  return NULL;
+
+   if (f((uintptr_t)vdpSurface, ) != VDP_STATUS_OK)
+  return NULL;
+
+   return st_vdpau_resource_from_description(ctx, );
+}
+
+static struct pipe_resource *
+st_vdpau_video_surface_dma_buf(struct gl_context *ctx, const GLvoid 
*vdpSurface,
+   GLuint index)
+{
+   int (*getProcAddr)(uint32_t device, uint32_t id, void **ptr);
+   uint32_t device = (uintptr_t)ctx->vdpDevice;
+
+   struct VdpSurfaceDMABufDesc desc;
+   VdpVideoSurfaceDMABuf *f;
+
+   getProcAddr = (void *)ctx->vdpGetProcAddress;
+   if (getProcAddr(device, VDP_FUNC_ID_VIDEO_SURFACE_DMA_BUF, (void**)))
+  return NULL;
+
+   if (f((uintptr_t)vdpSurface, index, ) != VDP_STATUS_OK)
+  return NULL;
+
+   return st_vdpau_resource_from_description(ctx, );
+}
+
 static void
 st_vdpau_map_surface(struct 

Mesa (master): st/vdpau: move FormatRGBAToPipe into the interop

2016-03-29 Thread Christian König
Module: Mesa
Branch: master
Commit: 0042aa508e19bb920d0ab385894cd3e03b9eafde
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=0042aa508e19bb920d0ab385894cd3e03b9eafde

Author: Christian König 
Date:   Wed Jan 13 16:42:44 2016 +0100

st/vdpau: move FormatRGBAToPipe into the interop

We are going to need that in the Mesa state tracker as well.

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

---

 src/gallium/include/state_tracker/vdpau_funcs.h  | 65 
 src/gallium/state_trackers/vdpau/bitmap.c|  2 +-
 src/gallium/state_trackers/vdpau/output.c|  2 +-
 src/gallium/state_trackers/vdpau/query.c | 10 ++--
 src/gallium/state_trackers/vdpau/vdpau_private.h | 22 +---
 5 files changed, 73 insertions(+), 28 deletions(-)

diff --git a/src/gallium/include/state_tracker/vdpau_funcs.h 
b/src/gallium/include/state_tracker/vdpau_funcs.h
new file mode 100644
index 000..66e3c23
--- /dev/null
+++ b/src/gallium/include/state_tracker/vdpau_funcs.h
@@ -0,0 +1,65 @@
+/**
+ *
+ * Copyright 2016 Advanced Micro Devices, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **/
+
+/*
+ * Authors:
+ *  Christian König 
+ *
+ */
+
+#ifndef _VDPAU_FUNCS_H_
+#define _VDPAU_FUNCS_H_
+
+#include "vdpau_dmabuf.h"
+
+/* Used for implementing NV_vdpau_interop */
+static inline enum pipe_format
+VdpFormatRGBAToPipe(uint32_t vdpau_format)
+{
+   switch (vdpau_format) {
+   case VDP_RGBA_FORMAT_R8:
+  return PIPE_FORMAT_R8_UNORM;
+   case VDP_RGBA_FORMAT_R8G8:
+  return PIPE_FORMAT_R8G8_UNORM;
+   case VDP_RGBA_FORMAT_A8:
+  return PIPE_FORMAT_A8_UNORM;
+   case VDP_RGBA_FORMAT_B10G10R10A2:
+  return PIPE_FORMAT_B10G10R10A2_UNORM;
+   case VDP_RGBA_FORMAT_B8G8R8A8:
+  return PIPE_FORMAT_B8G8R8A8_UNORM;
+   case VDP_RGBA_FORMAT_R10G10B10A2:
+  return PIPE_FORMAT_R10G10B10A2_UNORM;
+   case VDP_RGBA_FORMAT_R8G8B8A8:
+  return PIPE_FORMAT_R8G8B8A8_UNORM;
+   default:
+  assert(0);
+   }
+
+   return PIPE_FORMAT_NONE;
+}
+
+#endif /* _VDPAU_FUNCS_H_ */
diff --git a/src/gallium/state_trackers/vdpau/bitmap.c 
b/src/gallium/state_trackers/vdpau/bitmap.c
index 97a4287..35c8820 100644
--- a/src/gallium/state_trackers/vdpau/bitmap.c
+++ b/src/gallium/state_trackers/vdpau/bitmap.c
@@ -71,7 +71,7 @@ vlVdpBitmapSurfaceCreate(VdpDevice device,
 
memset(_tmpl, 0, sizeof(res_tmpl));
res_tmpl.target = PIPE_TEXTURE_2D;
-   res_tmpl.format = FormatRGBAToPipe(rgba_format);
+   res_tmpl.format = VdpFormatRGBAToPipe(rgba_format);
res_tmpl.width0 = width;
res_tmpl.height0 = height;
res_tmpl.depth0 = 1;
diff --git a/src/gallium/state_trackers/vdpau/output.c 
b/src/gallium/state_trackers/vdpau/output.c
index 95f15cb..738e7c7 100644
--- a/src/gallium/state_trackers/vdpau/output.c
+++ b/src/gallium/state_trackers/vdpau/output.c
@@ -74,7 +74,7 @@ vlVdpOutputSurfaceCreate(VdpDevice device,
memset(_tmpl, 0, sizeof(res_tmpl));
 
res_tmpl.target = PIPE_TEXTURE_2D;
-   res_tmpl.format = FormatRGBAToPipe(rgba_format);
+   res_tmpl.format = VdpFormatRGBAToPipe(rgba_format);
res_tmpl.width0 = width;
res_tmpl.height0 = height;
res_tmpl.depth0 = 1;
diff --git a/src/gallium/state_trackers/vdpau/query.c 
b/src/gallium/state_trackers/vdpau/query.c
index d41e6d9..a279ad3 100644
--- a/src/gallium/state_trackers/vdpau/query.c
+++ b/src/gallium/state_trackers/vdpau/query.c
@@ -224,7 +224,7 @@ vlVdpOutputSurfaceQueryCapabilities(VdpDevice device, 
VdpRGBAFormat surface_rgba
if (!pscreen)
   return VDP_STATUS_RESOURCES;
 
-   format = FormatRGBAToPipe(surface_rgba_format);
+   format = 

Mesa (master): st/vdpau: use linear layout for output surfaces

2016-03-29 Thread Christian König
Module: Mesa
Branch: master
Commit: d180de35320eafa3df3d76f0e82b332656530126
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=d180de35320eafa3df3d76f0e82b332656530126

Author: Christian König 
Date:   Thu Jan 14 13:40:25 2016 +0100

st/vdpau: use linear layout for output surfaces

Works around a bug in radeonsi and tiling is actually
not very beneficial in this use case.

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

---

 src/gallium/state_trackers/vdpau/output.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/gallium/state_trackers/vdpau/output.c 
b/src/gallium/state_trackers/vdpau/output.c
index 3248f76..95f15cb 100644
--- a/src/gallium/state_trackers/vdpau/output.c
+++ b/src/gallium/state_trackers/vdpau/output.c
@@ -79,7 +79,8 @@ vlVdpOutputSurfaceCreate(VdpDevice device,
res_tmpl.height0 = height;
res_tmpl.depth0 = 1;
res_tmpl.array_size = 1;
-   res_tmpl.bind = PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_RENDER_TARGET;
+   res_tmpl.bind = PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_RENDER_TARGET |
+   PIPE_BIND_LINEAR;
res_tmpl.usage = PIPE_USAGE_DEFAULT;
 
pipe_mutex_lock(dev->mutex);

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


Mesa (master): st/vdpau: implement the new DMA-buf based interop v2

2016-03-29 Thread Christian König
Module: Mesa
Branch: master
Commit: bdeb22b7b6204cf7a0eaab123118e2522a9abcd7
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=bdeb22b7b6204cf7a0eaab123118e2522a9abcd7

Author: Christian König 
Date:   Thu Jan 14 16:45:29 2016 +0100

st/vdpau: implement the new DMA-buf based interop v2

That should allow us to get away from passing internal structures around.

v2: rebased

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

---

 src/gallium/state_trackers/vdpau/ftab.c  |  6 ++-
 src/gallium/state_trackers/vdpau/output.c| 41 +-
 src/gallium/state_trackers/vdpau/surface.c   | 69 
 src/gallium/state_trackers/vdpau/vdpau_private.h |  3 ++
 4 files changed, 116 insertions(+), 3 deletions(-)

diff --git a/src/gallium/state_trackers/vdpau/ftab.c 
b/src/gallium/state_trackers/vdpau/ftab.c
index add4659..901a444 100644
--- a/src/gallium/state_trackers/vdpau/ftab.c
+++ b/src/gallium/state_trackers/vdpau/ftab.c
@@ -107,10 +107,12 @@ static void* ftab_winsys[1] =
  /* 
VDP_FUNC_ID_PRESENTATION_QUEUE_TARGET_CREATE_X11 */
 };
 
-static void* ftab_driver[2] =
+static void* ftab_driver[4] =
 {
, /* VDP_FUNC_ID_SURFACE_GALLIUM */
-/* VDP_FUNC_ID_OUTPUT_SURFACE_GALLIUM */
+   , /* VDP_FUNC_ID_OUTPUT_SURFACE_GALLIUM */
+   , /* VDP_FUNC_ID_VIDEO_SURFACE_DMA_BUF */
+/* VDP_FUNC_ID_OUTPUT_SURFACE_DMA_BUF */
 };
 
 boolean vlGetFuncFTAB(VdpFuncId function_id, void **func)
diff --git a/src/gallium/state_trackers/vdpau/output.c 
b/src/gallium/state_trackers/vdpau/output.c
index 738e7c7..c644cc8 100644
--- a/src/gallium/state_trackers/vdpau/output.c
+++ b/src/gallium/state_trackers/vdpau/output.c
@@ -36,6 +36,8 @@
 
 #include "vl/vl_csc.h"
 
+#include "state_tracker/drm_driver.h"
+
 #include "vdpau_private.h"
 
 /**
@@ -80,7 +82,7 @@ vlVdpOutputSurfaceCreate(VdpDevice device,
res_tmpl.depth0 = 1;
res_tmpl.array_size = 1;
res_tmpl.bind = PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_RENDER_TARGET |
-   PIPE_BIND_LINEAR;
+   PIPE_BIND_LINEAR | PIPE_BIND_SHARED;
res_tmpl.usage = PIPE_USAGE_DEFAULT;
 
pipe_mutex_lock(dev->mutex);
@@ -764,3 +766,40 @@ struct pipe_resource 
*vlVdpOutputSurfaceGallium(VdpOutputSurface surface)
 
return vlsurface->surface->texture;
 }
+
+VdpStatus vlVdpOutputSurfaceDMABuf(VdpVideoSurface surface,
+   struct VdpSurfaceDMABufDesc *result)
+{
+   vlVdpOutputSurface *vlsurface;
+   struct pipe_screen *pscreen;
+   struct winsys_handle whandle;
+
+   memset(result, 0, sizeof(*result));
+   result->handle = -1;
+
+   vlsurface = vlGetDataHTAB(surface);
+   if (!vlsurface || !vlsurface->surface)
+  return VDP_STATUS_INVALID_HANDLE;
+
+   pipe_mutex_lock(vlsurface->device->mutex);
+   vlVdpResolveDelayedRendering(vlsurface->device, NULL, NULL);
+   vlsurface->device->context->flush(vlsurface->device->context, NULL, 0);
+   pipe_mutex_unlock(vlsurface->device->mutex);
+
+   memset(, 0, sizeof(struct winsys_handle));
+   whandle.type = DRM_API_HANDLE_TYPE_FD;
+
+   pscreen = vlsurface->surface->texture->screen;
+   if (!pscreen->resource_get_handle(pscreen, vlsurface->surface->texture, 
,
+PIPE_HANDLE_USAGE_READ_WRITE))
+  return VDP_STATUS_NO_IMPLEMENTATION;
+
+   result->handle = whandle.handle;
+   result->width = vlsurface->surface->width;
+   result->height = vlsurface->surface->height;
+   result->offset = whandle.offset;
+   result->stride = whandle.stride;
+   result->format = PipeToFormatRGBA(vlsurface->surface->format);
+
+   return VDP_STATUS_OK;
+}
diff --git a/src/gallium/state_trackers/vdpau/surface.c 
b/src/gallium/state_trackers/vdpau/surface.c
index ffcedc1..0550141 100644
--- a/src/gallium/state_trackers/vdpau/surface.c
+++ b/src/gallium/state_trackers/vdpau/surface.c
@@ -37,6 +37,8 @@
 #include "util/u_video.h"
 #include "vl/vl_defines.h"
 
+#include "state_tracker/drm_driver.h"
+
 #include "vdpau_private.h"
 
 enum getbits_conversion {
@@ -412,3 +414,70 @@ struct pipe_video_buffer 
*vlVdpVideoSurfaceGallium(VdpVideoSurface surface)
 
return p_surf->video_buffer;
 }
+
+VdpStatus vlVdpVideoSurfaceDMABuf(VdpVideoSurface surface,
+  VdpVideoSurfacePlane plane,
+  struct VdpSurfaceDMABufDesc *result)
+{
+   vlVdpSurface *p_surf = vlGetDataHTAB(surface);
+
+   struct pipe_screen *pscreen;
+   struct winsys_handle whandle;
+
+   struct pipe_surface *surf;
+
+   memset(result, 0, sizeof(*result));
+   result->handle = -1;
+
+   if (!p_surf)
+  return VDP_STATUS_INVALID_HANDLE;
+
+   if (plane > 3)
+  return VDP_STATUS_INVALID_VALUE;
+
+   if (result)
+  return VDP_STATUS_INVALID_POINTER;
+
+   pipe_mutex_lock(p_surf->device->mutex);
+   if (p_surf->video_buffer == NULL) {
+  struct pipe_context *pipe = p_surf->device->context;
+
+  /* try to 

Mesa (master): radeonsi: ignore PIPE_BIND_LINEAR in si_is_format_supported v2

2016-03-29 Thread Christian König
Module: Mesa
Branch: master
Commit: 7eb5e5b8b4ae51be367050df48d3a9398694d3bc
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=7eb5e5b8b4ae51be367050df48d3a9398694d3bc

Author: Christian König 
Date:   Thu Jan 14 13:38:10 2016 +0100

radeonsi: ignore PIPE_BIND_LINEAR in si_is_format_supported v2

Linear layout should work for all not compressed or depth/stencil formats.

v2: restrict it a bit more

Signed-off-by: Christian König 
Reviewed-by: Marek Olšák 

---

 src/gallium/drivers/radeonsi/si_state.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/src/gallium/drivers/radeonsi/si_state.c 
b/src/gallium/drivers/radeonsi/si_state.c
index a2b0da9..10d691a 100644
--- a/src/gallium/drivers/radeonsi/si_state.c
+++ b/src/gallium/drivers/radeonsi/si_state.c
@@ -2046,6 +2046,11 @@ boolean si_is_format_supported(struct pipe_screen 
*screen,
if (usage & PIPE_BIND_TRANSFER_WRITE)
retval |= PIPE_BIND_TRANSFER_WRITE;
 
+   if ((usage & PIPE_BIND_LINEAR) &&
+   !util_format_is_compressed(format) &&
+   !(usage & PIPE_BIND_DEPTH_STENCIL))
+   retval |= PIPE_BIND_LINEAR;
+
return retval == usage;
 }
 

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


Mesa (master): st/mesa: enable OES_texture_buffer when all components available

2016-03-29 Thread Ilia Mirkin
Module: Mesa
Branch: master
Commit: 9286cbdd1e2b0ef32db61f0fb4915ea2948ad4cd
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=9286cbdd1e2b0ef32db61f0fb4915ea2948ad4cd

Author: Ilia Mirkin 
Date:   Mon Mar 28 20:59:13 2016 -0400

st/mesa: enable OES_texture_buffer when all components available

OES_texture_buffer combines bits from a number of desktop extensions.
When they're all available, turn it on.

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

---

 src/mesa/state_tracker/st_extensions.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/src/mesa/state_tracker/st_extensions.c 
b/src/mesa/state_tracker/st_extensions.c
index 44d93e3..36a1201 100644
--- a/src/mesa/state_tracker/st_extensions.c
+++ b/src/mesa/state_tracker/st_extensions.c
@@ -1016,6 +1016,12 @@ void st_init_extensions(struct pipe_screen *screen,
  PIPE_BIND_SAMPLER_VIEW);
}
 
+   extensions->OES_texture_buffer =
+  extensions->ARB_texture_buffer_object &&
+  extensions->ARB_texture_buffer_range &&
+  extensions->ARB_texture_buffer_object_rgb32 &&
+  extensions->ARB_shader_image_load_store;
+
/* Unpacking a varying in the fragment shader costs 1 texture indirection.
 * If the number of available texture indirections is very limited, then we
 * prefer to disable varying packing rather than run the risk of varying

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


Mesa (master): glapi/glx: Sync some additional error checking from xserver

2016-03-29 Thread Adam Jackson
Module: Mesa
Branch: master
Commit: ea0f62e45eab39a8957f933325a1e16ace5c9e8c
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=ea0f62e45eab39a8957f933325a1e16ace5c9e8c

Author: Adam Jackson 
Date:   Thu Mar 24 13:57:58 2016 -0400

glapi/glx: Sync some additional error checking from xserver

Reviewed-by: Ian Romanick 
Signed-off-by: Adam Jackson 

---

 src/mapi/glapi/gen/glX_proto_recv.py | 4 
 1 file changed, 4 insertions(+)

diff --git a/src/mapi/glapi/gen/glX_proto_recv.py 
b/src/mapi/glapi/gen/glX_proto_recv.py
index 1cfa8c5..cf5b59c 100644
--- a/src/mapi/glapi/gen/glX_proto_recv.py
+++ b/src/mapi/glapi/gen/glX_proto_recv.py
@@ -437,6 +437,10 @@ class 
PrintGlxDispatchFunctions(glX_proto_common.glx_print_proto):
 print '%s %s = __glXGetAnswerBuffer(cl, %s%s, 
answerBuffer, sizeof(answerBuffer), %u);' % (param.type_string(), param.name, 
param.counter, size_scale, type_size)
 answer_string = param.name
 answer_count = param.counter
+print ''
+print 'if (%s == NULL) return BadAlloc;' % (param.name)
+print '__glXClearErrorOccured();'
+print ''
 elif c >= 1:
 print '%s %s[%u];' % (answer_type, param.name, c)
 answer_string = param.name

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


Mesa (master): glapi/glx: Mark the indirect swapped dispatch functions _X_COLD

2016-03-29 Thread Adam Jackson
Module: Mesa
Branch: master
Commit: 5e1aec6db073416ae6ddf0eeaaea4964b489af8e
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=5e1aec6db073416ae6ddf0eeaaea4964b489af8e

Author: Adam Jackson 
Date:   Thu Mar 24 13:57:58 2016 -0400

glapi/glx: Mark the indirect swapped dispatch functions _X_COLD

A modest size savings:

   textdata bss dec hex filename
 264143   15608 232  279983   445af libglx.so.before
 254303   15608 232  270143   41f3f libglx.so.after

Reviewed-by: Ian Romanick 
Signed-off-by: Adam Jackson 

---

 src/mapi/glapi/gen/glX_proto_recv.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/mapi/glapi/gen/glX_proto_recv.py 
b/src/mapi/glapi/gen/glX_proto_recv.py
index cf5b59c..afee388 100644
--- a/src/mapi/glapi/gen/glX_proto_recv.py
+++ b/src/mapi/glapi/gen/glX_proto_recv.py
@@ -55,15 +55,15 @@ class PrintGlxDispatch_h(gl_XML.gl_print_base):
 if not func.ignore and not func.vectorequiv:
 if func.glx_rop:
 print 'extern _X_HIDDEN void __glXDisp_%s(GLbyte * pc);' % 
(func.name)
-print 'extern _X_HIDDEN void __glXDispSwap_%s(GLbyte * 
pc);' % (func.name)
+print 'extern _X_HIDDEN _X_COLD void 
__glXDispSwap_%s(GLbyte * pc);' % (func.name)
 elif func.glx_sop or func.glx_vendorpriv:
 print 'extern _X_HIDDEN int __glXDisp_%s(struct 
__GLXclientStateRec *, GLbyte *);' % (func.name)
-print 'extern _X_HIDDEN int __glXDispSwap_%s(struct 
__GLXclientStateRec *, GLbyte *);' % (func.name)
+print 'extern _X_HIDDEN _X_COLD int 
__glXDispSwap_%s(struct __GLXclientStateRec *, GLbyte *);' % (func.name)
 
 if func.glx_sop and func.glx_vendorpriv:
 n = func.glx_vendorpriv_names[0]
 print 'extern _X_HIDDEN int __glXDisp_%s(struct 
__GLXclientStateRec *, GLbyte *);' % (n)
-print 'extern _X_HIDDEN int __glXDispSwap_%s(struct 
__GLXclientStateRec *, GLbyte *);' % (n)
+print 'extern _X_HIDDEN _X_COLD int 
__glXDispSwap_%s(struct __GLXclientStateRec *, GLbyte *);' % (n)
 
 return
 

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


Mesa (master): glsl: add is_lhs bool on ast_expression

2016-03-29 Thread Alejandro Pinheiro
Module: Mesa
Branch: master
Commit: 8568d02498d12ebde6a6245056eebfbfe18aaf8f
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=8568d02498d12ebde6a6245056eebfbfe18aaf8f

Author: Alejandro Piñeiro 
Date:   Thu Feb 25 11:11:54 2016 +0100

glsl: add is_lhs bool on ast_expression

Useful to know if a expression is the recipient of an assignment
or not, that would be used to (for example) raise warnings of
"use of uninitialized variable" without getting a false positive
when assigning first a variable.

By default the value is false, and it is assigned to true on
the following cases:
 * The lhs assignments subexpression
 * At ast_array_index, on the array itself.
 * While handling the method on an array, to avoid the warning
   calling array.length
 * When computed the cached test expression at test_to_hir, to
   avoid a duplicate warning on the test expression of a switch.

set_is_lhs setter is added, because in some cases (like ast_field_selection)
the value need to be propagated on the expression tree. To avoid doing the
propatagion if not needed, it skips if no primary_expression.identifier is
available.

v2: use a new bool on ast_expression, instead of a new parameter
on ast_expression::hir (Timothy Arceri)

v3: fix style and some typos on comments, initialize is_lhs default value
on constructor, to avoid a c++11 feature (Ian Romanick)

v4: some tweaks on comments (Timothy Arceri)

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=94129

Reviewed-by: Timothy Arceri 

---

 src/compiler/glsl/ast.h  |  6 ++
 src/compiler/glsl/ast_function.cpp   |  4 
 src/compiler/glsl/ast_to_hir.cpp | 33 
 src/compiler/glsl/glsl_parser_extras.cpp |  1 +
 4 files changed, 44 insertions(+)

diff --git a/src/compiler/glsl/ast.h b/src/compiler/glsl/ast.h
index 727aa43..9f46340 100644
--- a/src/compiler/glsl/ast.h
+++ b/src/compiler/glsl/ast.h
@@ -214,6 +214,7 @@ public:
   subexpressions[2] = NULL;
   primary_expression.identifier = identifier;
   this->non_lvalue_description = NULL;
+  this->is_lhs = false;
}
 
static const char *operator_string(enum ast_operators op);
@@ -263,6 +264,11 @@ public:
 * This pointer may be \c NULL.
 */
const char *non_lvalue_description;
+
+   void set_is_lhs(bool new_value);
+
+private:
+   bool is_lhs;
 };
 
 class ast_expression_bin : public ast_expression {
diff --git a/src/compiler/glsl/ast_function.cpp 
b/src/compiler/glsl/ast_function.cpp
index 1a44020..db68d5d 100644
--- a/src/compiler/glsl/ast_function.cpp
+++ b/src/compiler/glsl/ast_function.cpp
@@ -1727,6 +1727,10 @@ ast_function_expression::handle_method(exec_list 
*instructions,
const char *method;
method = field->primary_expression.identifier;
 
+   /* This would prevent to raise "uninitialized variable" warnings when
+* calling array.length.
+*/
+   field->subexpressions[0]->set_is_lhs(true);
op = field->subexpressions[0]->hir(instructions, state);
if (strcmp(method, "length") == 0) {
   if (!this->expressions.is_empty()) {
diff --git a/src/compiler/glsl/ast_to_hir.cpp b/src/compiler/glsl/ast_to_hir.cpp
index 35def8e..e162203 100644
--- a/src/compiler/glsl/ast_to_hir.cpp
+++ b/src/compiler/glsl/ast_to_hir.cpp
@@ -1248,6 +1248,24 @@ ast_expression::hir_no_rvalue(exec_list *instructions,
do_hir(instructions, state, false);
 }
 
+void
+ast_expression::set_is_lhs(bool new_value)
+{
+   /* is_lhs is tracked only to print "variable used uninitialized" warnings,
+* if we lack a identifier we can just skip it.
+*/
+   if (this->primary_expression.identifier == NULL)
+  return;
+
+   this->is_lhs = new_value;
+
+   /* We need to go through the subexpressions tree to cover cases like
+* ast_field_selection
+*/
+   if (this->subexpressions[0] != NULL)
+  this->subexpressions[0]->set_is_lhs(new_value);
+}
+
 ir_rvalue *
 ast_expression::do_hir(exec_list *instructions,
struct _mesa_glsl_parse_state *state,
@@ -1323,6 +1341,7 @@ ast_expression::do_hir(exec_list *instructions,
   break;
 
case ast_assign: {
+  this->subexpressions[0]->set_is_lhs(true);
   op[0] = this->subexpressions[0]->hir(instructions, state);
   op[1] = this->subexpressions[1]->hir(instructions, state);
 
@@ -1592,6 +1611,7 @@ ast_expression::do_hir(exec_list *instructions,
case ast_div_assign:
case ast_add_assign:
case ast_sub_assign: {
+  this->subexpressions[0]->set_is_lhs(true);
   op[0] = this->subexpressions[0]->hir(instructions, state);
   op[1] = this->subexpressions[1]->hir(instructions, state);
 
@@ -1618,6 +1638,7 @@ ast_expression::do_hir(exec_list *instructions,
}
 
case ast_mod_assign: {
+  this->subexpressions[0]->set_is_lhs(true);
   op[0] = this->subexpressions[0]->hir(instructions, state);
   op[1] = this->subexpressions[1]->hir(instructions, 

Mesa (master): glsl: raise warning when using uninitialized variables

2016-03-29 Thread Alejandro Pinheiro
Module: Mesa
Branch: master
Commit: dcd41ca87a06199184eb8ada654aec985185189c
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=dcd41ca87a06199184eb8ada654aec985185189c

Author: Alejandro Piñeiro 
Date:   Tue Feb 23 11:48:52 2016 +0100

glsl: raise warning when using uninitialized variables

v2:
 * Take into account out varyings too (Timothy Arceri)
 * Fix style (Timothy Arceri)
 * Use a new ast_expression variable, instead of an
   ast_expression::hir new parameter (Timothy Arceri)

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=94129

Reviewed-by: Timothy Arceri 

---

 src/compiler/glsl/ast_to_hir.cpp | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/src/compiler/glsl/ast_to_hir.cpp b/src/compiler/glsl/ast_to_hir.cpp
index e162203..29a4642 100644
--- a/src/compiler/glsl/ast_to_hir.cpp
+++ b/src/compiler/glsl/ast_to_hir.cpp
@@ -1901,6 +1901,13 @@ ast_expression::do_hir(exec_list *instructions,
   if (var != NULL) {
  var->data.used = true;
  result = new(ctx) ir_dereference_variable(var);
+
+ if ((var->data.mode == ir_var_auto || var->data.mode == 
ir_var_shader_out)
+ && !this->is_lhs
+ && result->variable_referenced()->data.assigned != true) {
+_mesa_glsl_warning(, state, "`%s' used uninitialized",
+   this->primary_expression.identifier);
+ }
   } else {
  _mesa_glsl_error(& loc, state, "`%s' undeclared",
   this->primary_expression.identifier);

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