[Mesa-dev] [PATCH 67/65] glsl: disable on disk shader cache when running as root

2016-04-29 Thread Timothy Arceri
---
 src/compiler/glsl/cache.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/src/compiler/glsl/cache.c b/src/compiler/glsl/cache.c
index a6a9e47..dd53f4e 100644
--- a/src/compiler/glsl/cache.c
+++ b/src/compiler/glsl/cache.c
@@ -141,6 +141,10 @@ cache_create(void)
struct stat sb;
size_t size;
 
+   /* If running as root disable cache */
+   if (geteuid() == 0)
+  return NULL;
+
/* A ralloc context for transient data during this invocation. */
local = ralloc_context(NULL);
if (local == NULL)
-- 
2.5.5

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


Re: [Mesa-dev] [PATCH 1/3] nir/opt_dead_cf: correction of side effect check

2016-04-29 Thread Thomas H.P. Andersen
On Fri, Apr 29, 2016 at 8:39 PM, Jason Ekstrand 
wrote:

>
>
> On Fri, Apr 29, 2016 at 11:31 AM, Thomas Hindoe Paaboel Andersen <
> pho...@gmail.com> wrote:
>
>> Parenthesis are needed here as ! takes precedence over the &. The
>> check had the opposite effect than intended.
>> ---
>> Not tested as I do not own the neccesary hardware.
>>
>>  src/compiler/nir/nir_opt_dead_cf.c | 4 ++--
>>  1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/src/compiler/nir/nir_opt_dead_cf.c
>> b/src/compiler/nir/nir_opt_dead_cf.c
>> index 2e04c17..7450b1c 100644
>> --- a/src/compiler/nir/nir_opt_dead_cf.c
>> +++ b/src/compiler/nir/nir_opt_dead_cf.c
>> @@ -155,8 +155,8 @@ cf_node_has_side_effects(nir_cf_node *node)
>>  continue;
>>
>>   nir_intrinsic_instr *intrin = nir_instr_as_intrinsic(instr);
>> - if (!nir_intrinsic_infos[intrin->intrinsic].flags &
>> - NIR_INTRINSIC_CAN_ELIMINATE)
>> + if (!(nir_intrinsic_infos[intrin->intrinsic].flags &
>> + NIR_INTRINSIC_CAN_ELIMINATE))
>>
>
> Good catch!  All three patches are
>
> Reviewed-by: Jason Ekstrand 
>

Thanks Jason! Can I ask you to push it? I do not have commit access.

>
>
>>  return true;
>>}
>> }
>> --
>> 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


[Mesa-dev] [PATCH V2] glsl: track mesa version shader cache items were created with

2016-04-29 Thread Timothy Arceri
Also remove cache item and fallback to full recompile if current Mesa
version differs.

V2: don't leak buffer
---
 src/compiler/glsl/shader_cache.cpp | 13 +
 1 file changed, 13 insertions(+)

diff --git a/src/compiler/glsl/shader_cache.cpp 
b/src/compiler/glsl/shader_cache.cpp
index d3eec83..1278207 100644
--- a/src/compiler/glsl/shader_cache.cpp
+++ b/src/compiler/glsl/shader_cache.cpp
@@ -1033,6 +1033,8 @@ shader_cache_write_program_metadata(struct gl_context 
*ctx,
 
metadata = blob_create(NULL);
 
+   blob_write_string(metadata, ctx->VersionString);
+
write_uniforms(metadata, prog);
 
write_hash_tables(metadata, prog);
@@ -1134,6 +1136,17 @@ shader_cache_read_program_metadata(struct gl_context 
*ctx,
 
blob_reader_init(&metadata, buffer, size);
 
+   char *version_string = blob_read_string(&metadata);
+   if (strcmp(ctx->VersionString, version_string) != 0) {
+  /* The cached version of the program was created with a different
+   * version of Mesa so remove it and fallback to full recompile.
+   */
+  cache_remove(cache, prog->sha1);
+  compile_shaders(ctx, prog);
+  free(buffer);
+  return false;
+   }
+
assert(prog->UniformStorage == NULL);
 
read_uniforms(&metadata, prog);
-- 
2.5.5

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


[Mesa-dev] [PATCH V2] glsl: add cache to ctx and add sha1 string fields

2016-04-29 Thread Timothy Arceri
From: Carl Worth 

V2: dont leak cache

Signed-off-by: Timothy Arceri 
---
 src/mesa/main/context.c | 6 ++
 src/mesa/main/mtypes.h  | 5 +
 2 files changed, 11 insertions(+)

diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c
index 6af02d1..48e4e74 100644
--- a/src/mesa/main/context.c
+++ b/src/mesa/main/context.c
@@ -143,6 +143,7 @@
 #include "sparc/sparc.h"
 #endif
 
+#include "compiler/glsl/cache.h"
 #include "compiler/glsl/glsl_parser_extras.h"
 #include 
 
@@ -1222,6 +1223,8 @@ _mesa_initialize_context(struct gl_context *ctx,
memset(&ctx->TextureFormatSupported, GL_TRUE,
  sizeof(ctx->TextureFormatSupported));
 
+   ctx->Cache = cache_create();
+
switch (ctx->API) {
case API_OPENGL_COMPAT:
   ctx->BeginEnd = create_beginend_table(ctx);
@@ -1262,6 +1265,7 @@ fail:
free(ctx->BeginEnd);
free(ctx->OutsideBeginEnd);
free(ctx->Save);
+   ralloc_free(ctx->Cache);
return GL_FALSE;
 }
 
@@ -1366,6 +1370,8 @@ _mesa_free_context_data( struct gl_context *ctx )
free(ctx->OutsideBeginEnd);
free(ctx->Save);
 
+   ralloc_free(ctx->Cache);
+
/* Shared context state (display lists, textures, etc) */
_mesa_reference_shared_state(ctx, &ctx->Shared, NULL);
 
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 17100e4..3eced51 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -2246,6 +2246,7 @@ struct gl_shader
GLuint Name;  /**< AKA the handle */
GLint RefCount;  /**< Reference count */
GLchar *Label;   /**< GL_KHR_debug */
+   unsigned char sha1[20]; /**< SHA1 hash of pre-processed source */
GLboolean DeletePending;
GLboolean CompileStatus;
bool IsES;  /**< True if this shader uses GLSL ES */
@@ -2619,6 +2620,8 @@ struct gl_shader_program
 * Is the application intending to glGetProgramBinary this program?
 */
GLboolean BinaryRetreivableHint;
+   unsigned char sha1[20]; /**< SHA1 hash of linked program */
+   bool program_written_to_cache;
 
/**
 * Indicates whether program can be bound for individual pipeline stages
@@ -4565,6 +4568,8 @@ struct gl_context
 * Once this field becomes true, it is never reset to false.
 */
GLboolean ShareGroupReset;
+
+   struct program_cache *Cache;
 };
 
 /**
-- 
2.5.5

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


Re: [Mesa-dev] On disk shader cache for i965

2016-04-29 Thread Timothy Arceri
Here are the shader-db times after fixing the buffer overflow with
patch 66/65.

Cache disabled:

Thread 1 took 1360.47 seconds and compiled 13015 shaders (not including
SIMD16) with 50 GL context switches
Thread 3 took 1349.85 seconds and compiled 12848 shaders (not including
SIMD16) with 40 GL context switches
Thread 2 took 1362.94 seconds and compiled 12637 shaders (not including
SIMD16) with 36 GL context switches
Thread 0 took 1352.41 seconds and compiled 12593 shaders (not including
SIMD16) with 46 GL context switches

Cache enabled first run:

Thread 1 took 1410.30 seconds and compiled 12678 shaders (not including
SIMD16) with 34 GL context switches
Thread 2 took 1421.35 seconds and compiled 12822 shaders (not including
SIMD16) with 50 GL context switches
Thread 0 took 1410.49 seconds and compiled 12999 shaders (not including
SIMD16) with 40 GL context switches
Thread 3 took 1426.67 seconds and compiled 12594 shaders (not including
SIMD16) with 48 GL context switches

Cache enabled second run:

Thread 0 took 259.84 seconds and compiled 12817 shaders (not including
SIMD16) with 40 GL context switches
Thread 3 took 257.03 seconds and compiled 12533 shaders (not including
SIMD16) with 50 GL context switches
Thread 1 took 256.18 seconds and compiled 12828 shaders (not including
SIMD16) with 40 GL context switches
Thread 2 took 261.31 seconds and compiled 12915 shaders (not including
SIMD16) with 39 GL context switches
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 66/65] glsl: avoid buffer overflow in cache sha creation

2016-04-29 Thread Timothy Arceri
A program may contain multiple shaders from each stage so use
ralloc to avoid buffer overflow.
---

 This fixes the issue I was having running shader-db it now successfully
 finishes compiling all programs.

 src/compiler/glsl/shader_cache.cpp | 19 +--
 1 file changed, 9 insertions(+), 10 deletions(-)

diff --git a/src/compiler/glsl/shader_cache.cpp 
b/src/compiler/glsl/shader_cache.cpp
index 52301b7..8c07885 100644
--- a/src/compiler/glsl/shader_cache.cpp
+++ b/src/compiler/glsl/shader_cache.cpp
@@ -1071,9 +1071,8 @@ shader_cache_read_program_metadata(struct gl_context *ctx,
struct gl_shader_program *prog)
 {
const char *stage_name[] = { "vs", "tcs", "tes", "gs", "fs", "cs" };
-   char buf[256], sha1buf[41];
+   char *buf, sha1buf[41];
unsigned char sha1[20];
-   int offset = 0;
uint8_t *buffer;
struct program_cache *cache;
size_t size;
@@ -1107,21 +1106,21 @@ shader_cache_read_program_metadata(struct gl_context 
*ctx,
_mesa_sha1_compute(bindings_str, strlen(bindings_str), sha1);
ralloc_free(bindings_str);
 
-   offset += snprintf(buf + offset, sizeof(buf) - offset,
-  "bindings: %s\n",
-  _mesa_sha1_format(sha1buf, sha1));
+   buf = ralloc_strdup(NULL, "bindings: ");
+   ralloc_asprintf_append(&buf, "%s\n", _mesa_sha1_format(sha1buf, sha1));
 
for (unsigned i = 0; i < prog->NumShaders; i++) {
   if (prog->Shaders[i]->Source == NULL)
  return false;
 
-  offset += snprintf(buf + offset, sizeof(buf) - offset,
- "%s: %s\n",
- stage_name[prog->Shaders[i]->Stage],
- _mesa_sha1_format(sha1buf, prog->Shaders[i]->sha1));
+  ralloc_asprintf_append(&buf, "%s: %s\n",
+ stage_name[prog->Shaders[i]->Stage],
+ _mesa_sha1_format(sha1buf,
+   prog->Shaders[i]->sha1));
}
+   _mesa_sha1_compute(buf, strlen(buf), prog->sha1);
+   ralloc_free(buf);
 
-   _mesa_sha1_compute(buf, offset, prog->sha1);
buffer = (uint8_t *) cache_get(cache, prog->sha1, &size);
if (buffer == NULL) {
   /* Cached program not found. Fall back to linking shaders but first
-- 
2.5.5

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


Re: [Mesa-dev] [PATCH 54/59] i965/fs/lower_simd_width: Fix registers written for split instructions

2016-04-29 Thread Francisco Jerez
Samuel Iglesias Gonsálvez  writes:

> From: Iago Toral Quiroga 
>
> When the original instruction had a stride > 1, the combined registers
> written by the split instructions won't amount to the same register space
> written by the original instruction because the split instructions will
> use a stride of 1. The current code assumed otherwise and computed the
> number of registers written by split instructions as an equal share based
> on the relation between the lowered width and the original execution size
> of the instruction.
>
> It is only after the split, when we interleave the components of the result
> from the lowered instructions back into the original dst register, that the
> original stride takes effect and we write all the registers specified by
> the original instruction.
>
> Just make the number of register written the same as the vgrf space we
> allocate for the dst of the split instruction.
>
> Fixes crashes in fp64 tests produced as a result of assigning incorrectly the
> number of registers written by split instructions, which led to incorrect
> validation of the size of the writes against the allocated vgrf space.
> ---
>  src/mesa/drivers/dri/i965/brw_fs.cpp | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp 
> b/src/mesa/drivers/dri/i965/brw_fs.cpp
> index fbdd802..a5caafb 100644
> --- a/src/mesa/drivers/dri/i965/brw_fs.cpp
> +++ b/src/mesa/drivers/dri/i965/brw_fs.cpp
> @@ -4709,8 +4709,8 @@ fs_visitor::lower_simd_width()
> split_inst.dst = dsts[i] =
>lbld.vgrf(inst->dst.type, dst_size);
> split_inst.regs_written =
> -  DIV_ROUND_UP(inst->regs_written * lower_width,
> -   inst->exec_size);
> +  DIV_ROUND_UP(type_sz(inst->dst.type) * dst_size * 
> lower_width,
> +   REG_SIZE);

LGTM -- Though if you used the component_size() helper instead of
'type_sz(...) * lower_width' you'd make sure things still work if we
have to preserve the original strides at some point in the future.
Either way the patch is:

Reviewed-by: Francisco Jerez 

>  }
>  
>  lbld.emit(split_inst);
> -- 
> 2.5.0
>
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev


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


[Mesa-dev] [Bug 95211] scons TypeError: 'tuple' object is not callable

2016-04-29 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=95211

Bug ID: 95211
   Summary: scons TypeError: 'tuple' object is not callable
   Product: Mesa
   Version: git
  Hardware: x86-64 (AMD64)
OS: Linux (All)
Status: NEW
  Severity: normal
  Priority: medium
 Component: Mesa core
  Assignee: mesa-dev@lists.freedesktop.org
  Reporter: v...@freedesktop.org
QA Contact: mesa-dev@lists.freedesktop.org
CC: jfons...@vmware.com

mesa: 750c38fad1f19e2403b4960674006c5f932075ad (master 11.3.0-devel)

$ scons
scons: Reading SConscript files ...
Checking for GCC ...  yes
Checking for Clang ...  no
scons: Found LLVM version 3.8.0
Checking for X11 (x11 xext xdamage xfixes glproto >= 1.4.13)... yes
Checking for XCB (x11-xcb xcb-glx >= 1.8.1 xcb-dri2 >= 1.8)... yes
Checking for XF86VIDMODE (xxf86vm)... yes
Checking for DRM (libdrm >= 2.4.38)... yes
Checking for UDEV (libudev >= 151)... yes
TypeError: 'tuple' object is not callable:
  File "mesa/SConstruct", line 143:
duplicate = 0 # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html
  File "/usr/lib/scons/SCons/Script/SConscript.py", line 604:
return method(*args, **kw)
  File "/usr/lib/scons/SCons/Script/SConscript.py", line 541:
return _SConscript(self.fs, *files, **subst_kw)
  File "/usr/lib/scons/SCons/Script/SConscript.py", line 250:
exec _file_ in call_stack[-1].globals
  File "mesa/src/SConscript", line 7:
SConscript('util/SConscript')
  File "/usr/lib/scons/SCons/Script/SConscript.py", line 604:
return method(*args, **kw)
  File "/usr/lib/scons/SCons/Script/SConscript.py", line 541:
return _SConscript(self.fs, *files, **subst_kw)
  File "/usr/lib/scons/SCons/Script/SConscript.py", line 250:
exec _file_ in call_stack[-1].globals
  File "mesa/src/util/SConscript", line 25:
command = python_cmd + ' $SCRIPT > $TARGET'
  File "/usr/lib/scons/SCons/Environment.py", line 224:
return self.method(*nargs, **kwargs)
  File "mesa/scons/custom.py", line 143:
deps += script_src.get_implicit_deps(env, python_scanner, path)
  File "/usr/lib/scons/SCons/Node/__init__.py", line 941:
path = path_func(scanner)

$ scons --version
SCons by Steven Knight et al.:
script: v2.5.0.rel_2.5.0:3544:95d356f188a3[MODIFIED], 2016/04/09 14:38:50,
by bdbaddog on ubuntu1404-32bit
engine: v2.5.0.rel_2.5.0:3544:95d356f188a3[MODIFIED], 2016/04/09 14:38:50,
by bdbaddog on ubuntu1404-32bit
engine path: ['/usr/lib/scons/SCons']
Copyright (c) 2001 - 2016 The SCons Foundation

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


[Mesa-dev] [Bug 95180] rasterizer/memory/Convert.h:170:9: error: ‘__builtin_isnan’ is not a member of ‘std’

2016-04-29 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=95180

--- Comment #4 from Vinson Lee  ---
I am building with GCC 5.3 on Ubuntu 16.10.

$ gcc --version
gcc (Ubuntu 5.3.1-16ubuntu2) 5.3.1 20160424
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ ldd --version
ldd (Ubuntu GLIBC 2.23-0ubuntu3) 2.23
Copyright (C) 2016 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Written by Roland McGrath and Ulrich Drepper.

-- 
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] [Bug 95085] Invalid sampling of second texture in fragment shader that have two samplers with different parameters.

2016-04-29 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=95085

Nicolai Hähnle  changed:

   What|Removed |Added

 Status|REOPENED|RESOLVED
 Resolution|--- |NOTOURBUG

--- Comment #16 from Nicolai Hähnle  ---
The shader only tests for non-zeroness, so it's possible that the difference
between radeonsi and the other drivers is that a denorm flush happens somewhere
with radeonsi and not the other drivers.

Anyway, I'm feeling lucky and closing this as NOTOURBUG for the second time
today :)

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


[Mesa-dev] [Bug 95085] Invalid sampling of second texture in fragment shader that have two samplers with different parameters.

2016-04-29 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=95085

--- Comment #15 from Roland Scheidegger  ---
(In reply to Nicolai Hähnle from comment #14)

> The trace uses glVertexAttribPointer instead of glVertexAttribIPointer to
> set up a vertex element that will consumed by an uint GLSL variable. I kind
> of suspect that that should be undefined behaviour, but I haven't found a
> corresponding spec reference.

I can't see how that could work (I don't understand how that could work with
some drivers even). glVertexAttribPointer() means the data is really floats -
if you'd use a non-float type to specify it, it will implicitly get converted
to floats. So ok you could cheat there which would leave the data untouched (I
haven't looked at the trace), and rely on the uint input to just read that data
as-is maybe. Not sure if that could work even if you could trick the
implementation to do this - integers as floats have some bad habits, namely all
your negative numbers tend to change their value (as they are NaNs), and your
positive numbers may have some attraction to zero (as they are denorms...).
In any case, just don't do this - these different attrib pointers exist for a
reason. Also see
http://stackoverflow.com/questions/28014864/why-different-variations-of-glvertexattribpointer-do-exist

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


[Mesa-dev] [PATCH] anv: Fix make check build error.

2016-04-29 Thread Vinson Lee
  CC   block_pool_no_free.o
In file included from ../../../../src/intel/vulkan/anv_private.h:60:0,
 from block_pool_no_free.c:26:
../../../../src/intel/vulkan/anv_entrypoints.h:162:69: error: unknown type name 
‘VkXcbSurfaceCreateInfoKHR’
  VkResult (*CreateXcbSurfaceKHR)(VkInstance instance, const 
VkXcbSurfaceCreateInfoKHR* pCreateInfo, const VkAllocationCallbacks* 
pAllocator, VkSurfaceKHR* pSurface);
 ^

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=95088
Signed-off-by: Vinson Lee 
---
 src/intel/vulkan/tests/Makefile.am | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/src/intel/vulkan/tests/Makefile.am 
b/src/intel/vulkan/tests/Makefile.am
index ddff73c..ce2ae8f 100644
--- a/src/intel/vulkan/tests/Makefile.am
+++ b/src/intel/vulkan/tests/Makefile.am
@@ -18,10 +18,16 @@
 #  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.
 
+VULKAN_ENTRYPOINT_CPPFLAGS = -DVK_USE_PLATFORM_XCB_KHR
+if HAVE_EGL_PLATFORM_WAYLAND
+VULKAN_ENTRYPOINT_CPPFLAGS += -DVK_USE_PLATFORM_WAYLAND_KHR
+endif
+
 AM_CPPFLAGS = \
$(INTEL_CFLAGS) \
$(VALGRIND_CFLAGS) \
$(DEFINES) \
+   $(VULKAN_ENTRYPOINT_CPPFLAGS) \
-I$(top_srcdir)/include \
-I$(top_srcdir)/src \
-I$(top_srcdir)/src/mapi \
-- 
2.7.4

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


[Mesa-dev] [Bug 95085] Invalid sampling of second texture in fragment shader that have two samplers with different parameters.

2016-04-29 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=95085

--- Comment #14 from Nicolai Hähnle  ---
I think I understand now where the bug is coming from, and I'm not sure if it's
a driver or an application bug :)

The trace uses glVertexAttribPointer instead of glVertexAttribIPointer to set
up a vertex element that will consumed by an uint GLSL variable. I kind of
suspect that that should be undefined behaviour, but I haven't found a
corresponding spec reference.

In any case, it looks like this causes different parts of the driver and the
various auxiliary tools to disagree about whether the element should be treated
as an int or as a float, and some conversion happens somewhere that makes it
all go wrong...

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


Re: [Mesa-dev] [PATCH 4/7] i965/disasm: Split opcode tables by the generation they were introduced in.

2016-04-29 Thread Francisco Jerez
Matt Turner  writes:

> On Thu, Apr 28, 2016 at 12:46 PM, Francisco Jerez  
> wrote:
>> Matt Turner  writes:
>>
>>> On Thu, Apr 28, 2016 at 12:19 AM, Francisco Jerez  
>>> wrote:
 ---
  src/mesa/drivers/dri/i965/brw_disasm.c | 90 
 ++
  1 file changed, 69 insertions(+), 21 deletions(-)

 diff --git a/src/mesa/drivers/dri/i965/brw_disasm.c 
 b/src/mesa/drivers/dri/i965/brw_disasm.c
 index 15d9383..0125434 100644
 --- a/src/mesa/drivers/dri/i965/brw_disasm.c
 +++ b/src/mesa/drivers/dri/i965/brw_disasm.c
 @@ -30,9 +30,8 @@
  #include "brw_inst.h"
  #include "brw_eu.h"

 -static const struct opcode_desc opcode_descs[128] = {
 +static const struct opcode_desc gen4_opcode_descs[128] = {
 [BRW_OPCODE_MOV]  = { .name = "mov", .nsrc = 1, .ndst = 1 },
 -   [BRW_OPCODE_MOVI] = { .name = "movi",.nsrc = 2, .ndst = 1 },
 [BRW_OPCODE_FRC]  = { .name = "frc", .nsrc = 1, .ndst = 1 },
 [BRW_OPCODE_RNDU] = { .name = "rndu",.nsrc = 1, .ndst = 1 },
 [BRW_OPCODE_RNDD] = { .name = "rndd",.nsrc = 1, .ndst = 1 },
 @@ -40,27 +39,17 @@ static const struct opcode_desc opcode_descs[128] = {
 [BRW_OPCODE_RNDZ] = { .name = "rndz",.nsrc = 1, .ndst = 1 },
 [BRW_OPCODE_NOT]  = { .name = "not", .nsrc = 1, .ndst = 1 },
 [BRW_OPCODE_LZD]  = { .name = "lzd", .nsrc = 1, .ndst = 1 },
 -   [BRW_OPCODE_F32TO16]  = { .name = "f32to16", .nsrc = 1, .ndst = 1 },
 -   [BRW_OPCODE_F16TO32]  = { .name = "f16to32", .nsrc = 1, .ndst = 1 },
 -   [BRW_OPCODE_BFREV]= { .name = "bfrev",   .nsrc = 1, .ndst = 1 },
 -   [BRW_OPCODE_FBH]  = { .name = "fbh", .nsrc = 1, .ndst = 1 },
 -   [BRW_OPCODE_FBL]  = { .name = "fbl", .nsrc = 1, .ndst = 1 },
 -   [BRW_OPCODE_CBIT] = { .name = "cbit",.nsrc = 1, .ndst = 1 },

 [BRW_OPCODE_MUL]  = { .name = "mul", .nsrc = 2, .ndst = 1 },
 [BRW_OPCODE_MAC]  = { .name = "mac", .nsrc = 2, .ndst = 1 },
 [BRW_OPCODE_MACH] = { .name = "mach",.nsrc = 2, .ndst = 1 },
 [BRW_OPCODE_LINE] = { .name = "line",.nsrc = 2, .ndst = 1 },
 -   [BRW_OPCODE_PLN]  = { .name = "pln", .nsrc = 2, .ndst = 1 },
 -   [BRW_OPCODE_MAD]  = { .name = "mad", .nsrc = 3, .ndst = 1 },
 -   [BRW_OPCODE_LRP]  = { .name = "lrp", .nsrc = 3, .ndst = 1 },
 [BRW_OPCODE_SAD2] = { .name = "sad2",.nsrc = 2, .ndst = 1 },
 [BRW_OPCODE_SADA2]= { .name = "sada2",   .nsrc = 2, .ndst = 1 },
 [BRW_OPCODE_DP4]  = { .name = "dp4", .nsrc = 2, .ndst = 1 },
 [BRW_OPCODE_DPH]  = { .name = "dph", .nsrc = 2, .ndst = 1 },
 [BRW_OPCODE_DP3]  = { .name = "dp3", .nsrc = 2, .ndst = 1 },
 [BRW_OPCODE_DP2]  = { .name = "dp2", .nsrc = 2, .ndst = 1 },
 -   [BRW_OPCODE_MATH] = { .name = "math",.nsrc = 2, .ndst = 1 },

 [BRW_OPCODE_AVG]  = { .name = "avg", .nsrc = 2, .ndst = 1 },
 [BRW_OPCODE_ADD]  = { .name = "add", .nsrc = 2, .ndst = 1 },
 @@ -73,17 +62,9 @@ static const struct opcode_desc opcode_descs[128] = {
 [BRW_OPCODE_ASR]  = { .name = "asr", .nsrc = 2, .ndst = 1 },
 [BRW_OPCODE_CMP]  = { .name = "cmp", .nsrc = 2, .ndst = 1 },
 [BRW_OPCODE_CMPN] = { .name = "cmpn",.nsrc = 2, .ndst = 1 },
 -   [BRW_OPCODE_CSEL] = { .name = "csel",.nsrc = 3, .ndst = 1 },
 -   [BRW_OPCODE_BFE]  = { .name = "bfe", .nsrc = 3, .ndst = 1 },
 -   [BRW_OPCODE_BFI1] = { .name = "bfi1",.nsrc = 2, .ndst = 1 },
 -   [BRW_OPCODE_BFI2] = { .name = "bfi2",.nsrc = 3, .ndst = 1 },
 -   [BRW_OPCODE_ADDC] = { .name = "addc",.nsrc = 2, .ndst = 1 },
 -   [BRW_OPCODE_SUBB] = { .name = "subb",.nsrc = 2, .ndst = 1 },

 [BRW_OPCODE_SEND] = { .name = "send",.nsrc = 1, .ndst = 1 },
 [BRW_OPCODE_SENDC]= { .name = "sendc",   .nsrc = 1, .ndst = 1 },
 -   [BRW_OPCODE_SENDS]= { .name = "sends",   .nsrc = 2, .ndst = 1 },
 -   [BRW_OPCODE_SENDSC]   = { .name = "sendsc",  .nsrc = 2, .ndst = 1 },
 [BRW_OPCODE_ILLEGAL]  = { .name = "illegal", .nsrc = 0, .ndst = 0 },
 [BRW_OPCODE_NOP]  = { .name = "nop", .nsrc = 0, .ndst = 0 },
 [BRW_OPCODE_NENOP]= { .name = "nenop",   .nsrc = 0, .ndst = 0 },
 @@ -104,6 +85,70 @@ static const struct opcode_desc opcode_descs[128] = {
 [BRW_OPCODE_ENDIF]= { .name = "endif",   .nsrc = 0, .ndst = 0 },
  };

 +static const struct opcode_desc g45_opcode_descs[128] = {
 +   [BRW_OPCODE_MOVI] = { .name = "movi",.nsrc = 2, .ndst = 1 },
 +   [BRW_OPCODE_PLN]  = { .name = "pln", .nsrc = 2, .ndst = 1 },
 +};
 +
 +static const struct opcode_desc gen6_opc

Re: [Mesa-dev] [PATCH] radeonsi: fix PIPE_FORMAT_R11G11B10_FLOAT handling

2016-04-29 Thread Jakob Sinclair

On 2016-04-29 23:21, Nicolai Hähnle wrote:

From: Nicolai Hähnle 

That format has first_non_void < 0. This fixes a regression in piglit
arb_shader_image_load_store-semantics that was introduced by commit 
76b8c5cc602,
while hopefully still shutting Coverity up (and failing in a more 
obvious way

if a similar error should re-appear).
---
 src/gallium/drivers/radeonsi/si_state.c | 18 ++
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_state.c
b/src/gallium/drivers/radeonsi/si_state.c
index 1dd468b..16c941e 100644
--- a/src/gallium/drivers/radeonsi/si_state.c
+++ b/src/gallium/drivers/radeonsi/si_state.c
@@ -1760,18 +1760,18 @@ static uint32_t
si_translate_buffer_dataformat(struct pipe_screen *screen,
   const struct 
util_format_description *desc,
   int first_non_void)
 {
-   if (first_non_void < 0)
-   return V_008F0C_BUF_DATA_FORMAT_INVALID;
-
-   unsigned type = desc->channel[first_non_void].type;
+   unsigned type;
int i;

-   if (type == UTIL_FORMAT_TYPE_FIXED)
-   return V_008F0C_BUF_DATA_FORMAT_INVALID;
-
if (desc->format == PIPE_FORMAT_R11G11B10_FLOAT)
return V_008F0C_BUF_DATA_FORMAT_10_11_11;

+   assert(first_non_void >= 0);
+   type = desc->channel[first_non_void].type;
+
+   if (type == UTIL_FORMAT_TYPE_FIXED)
+   return V_008F0C_BUF_DATA_FORMAT_INVALID;
+
if (desc->nr_channels == 4 &&
desc->channel[0].size == 10 &&
desc->channel[1].size == 10 &&
@@ -1837,9 +1837,11 @@ static uint32_t
si_translate_buffer_numformat(struct pipe_screen *screen,
  const struct 
util_format_description *desc,
  int first_non_void)
 {
-	if (desc->format == PIPE_FORMAT_R11G11B10_FLOAT || first_non_void < 
0)

+   if (desc->format == PIPE_FORMAT_R11G11B10_FLOAT)
return V_008F0C_BUF_NUM_FORMAT_FLOAT;

+   assert(first_non_void >= 0);
+
switch (desc->channel[first_non_void].type) {
case UTIL_FORMAT_TYPE_SIGNED:
if (desc->channel[first_non_void].normalized)


Ahh, I should have been more careful with testing the patch. Anyways 
this looks all good to me. By the fact that you are using assert I'm 
guessing that first_non_void shouldn't be negative very often and that 
when it is negative something has gone horribly wrong. If that's the 
case then:


Reviewed-by: Jakob Sinclair 
--
Mvh Jakob Sinclair
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH] radeonsi: fix PIPE_FORMAT_R11G11B10_FLOAT handling

2016-04-29 Thread Nicolai Hähnle
From: Nicolai Hähnle 

That format has first_non_void < 0. This fixes a regression in piglit
arb_shader_image_load_store-semantics that was introduced by commit 76b8c5cc602,
while hopefully still shutting Coverity up (and failing in a more obvious way
if a similar error should re-appear).
---
 src/gallium/drivers/radeonsi/si_state.c | 18 ++
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_state.c 
b/src/gallium/drivers/radeonsi/si_state.c
index 1dd468b..16c941e 100644
--- a/src/gallium/drivers/radeonsi/si_state.c
+++ b/src/gallium/drivers/radeonsi/si_state.c
@@ -1760,18 +1760,18 @@ static uint32_t si_translate_buffer_dataformat(struct 
pipe_screen *screen,
   const struct 
util_format_description *desc,
   int first_non_void)
 {
-   if (first_non_void < 0)
-   return V_008F0C_BUF_DATA_FORMAT_INVALID;
-
-   unsigned type = desc->channel[first_non_void].type;
+   unsigned type;
int i;
 
-   if (type == UTIL_FORMAT_TYPE_FIXED)
-   return V_008F0C_BUF_DATA_FORMAT_INVALID;
-
if (desc->format == PIPE_FORMAT_R11G11B10_FLOAT)
return V_008F0C_BUF_DATA_FORMAT_10_11_11;
 
+   assert(first_non_void >= 0);
+   type = desc->channel[first_non_void].type;
+
+   if (type == UTIL_FORMAT_TYPE_FIXED)
+   return V_008F0C_BUF_DATA_FORMAT_INVALID;
+
if (desc->nr_channels == 4 &&
desc->channel[0].size == 10 &&
desc->channel[1].size == 10 &&
@@ -1837,9 +1837,11 @@ static uint32_t si_translate_buffer_numformat(struct 
pipe_screen *screen,
  const struct 
util_format_description *desc,
  int first_non_void)
 {
-   if (desc->format == PIPE_FORMAT_R11G11B10_FLOAT || first_non_void < 0)
+   if (desc->format == PIPE_FORMAT_R11G11B10_FLOAT)
return V_008F0C_BUF_NUM_FORMAT_FLOAT;
 
+   assert(first_non_void >= 0);
+
switch (desc->channel[first_non_void].type) {
case UTIL_FORMAT_TYPE_SIGNED:
if (desc->channel[first_non_void].normalized)
-- 
2.7.4

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


Re: [Mesa-dev] [PATCH] radeonsi: fix synchronization of shader images

2016-04-29 Thread Nicolai Hähnle

Good catch!

Reviewed-by: Nicolai Hähnle 

On 29.04.2016 15:32, Marek Olšák wrote:

From: Marek Olšák 

This fixes the winsys->cs_is_buffer_referenced query, which is used for
synchronization before buffers are mapped.
---
  src/gallium/drivers/radeonsi/si_descriptors.c | 18 +++---
  1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_descriptors.c 
b/src/gallium/drivers/radeonsi/si_descriptors.c
index fbaf804..27f2a74 100644
--- a/src/gallium/drivers/radeonsi/si_descriptors.c
+++ b/src/gallium/drivers/radeonsi/si_descriptors.c
@@ -261,15 +261,15 @@ static void si_release_sampler_views(struct 
si_sampler_views *views)
  }

  static void si_sampler_view_add_buffer(struct si_context *sctx,
-  struct pipe_resource *resource)
+  struct pipe_resource *resource,
+  enum radeon_bo_usage usage)
  {
struct r600_resource *rres = (struct r600_resource*)resource;

if (!resource)
return;

-   radeon_add_to_buffer_list(&sctx->b, &sctx->b.gfx, rres,
- RADEON_USAGE_READ,
+   radeon_add_to_buffer_list(&sctx->b, &sctx->b.gfx, rres, usage,
  r600_get_sampler_view_priority(rres));
  }

@@ -282,7 +282,8 @@ static void si_sampler_views_begin_new_cs(struct si_context 
*sctx,
while (mask) {
int i = u_bit_scan(&mask);

-   si_sampler_view_add_buffer(sctx, views->views[i]->texture);
+   si_sampler_view_add_buffer(sctx, views->views[i]->texture,
+  RADEON_USAGE_READ);
}

views->desc.ce_ram_dirty = true;
@@ -310,7 +311,8 @@ static void si_set_sampler_view(struct si_context *sctx,
if (view) {
struct r600_texture *rtex = (struct r600_texture 
*)view->texture;

-   si_sampler_view_add_buffer(sctx, view->texture);
+   si_sampler_view_add_buffer(sctx, view->texture,
+  RADEON_USAGE_READ);

pipe_sampler_view_reference(&views->views[slot], view);
memcpy(views->desc.list + slot * 16, rview->state, 8*4);
@@ -441,7 +443,8 @@ si_image_views_begin_new_cs(struct si_context *sctx, struct 
si_images_info *imag

assert(view->resource);

-   si_sampler_view_add_buffer(sctx, view->resource);
+   si_sampler_view_add_buffer(sctx, view->resource,
+  RADEON_USAGE_READWRITE);
}

images->desc.ce_ram_dirty = true;
@@ -495,7 +498,8 @@ si_set_shader_images(struct pipe_context *pipe, unsigned 
shader,
res = (struct r600_resource *)views[i].resource;
util_copy_image_view(&images->views[slot], &views[i]);

-   si_sampler_view_add_buffer(ctx, &res->b.b);
+   si_sampler_view_add_buffer(ctx, &res->b.b,
+  RADEON_USAGE_READWRITE);

if (res->b.b.target == PIPE_BUFFER) {
si_make_buffer_descriptor(screen, res,


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


[Mesa-dev] [Bug 95085] Invalid sampling of second texture in fragment shader that have two samplers with different parameters.

2016-04-29 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=95085

Nicolai Hähnle  changed:

   What|Removed |Added

 Resolution|NOTOURBUG   |---
 Status|RESOLVED|REOPENED

--- Comment #13 from Nicolai Hähnle  ---
I spoke too soon. There seem to be several bugs here (one pointed out by Bas
Nieuwenhuizen), I'm going to investigate this again in more detail.

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


[Mesa-dev] [PATCH] radeonsi: fix synchronization of shader images

2016-04-29 Thread Marek Olšák
From: Marek Olšák 

This fixes the winsys->cs_is_buffer_referenced query, which is used for
synchronization before buffers are mapped.
---
 src/gallium/drivers/radeonsi/si_descriptors.c | 18 +++---
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_descriptors.c 
b/src/gallium/drivers/radeonsi/si_descriptors.c
index fbaf804..27f2a74 100644
--- a/src/gallium/drivers/radeonsi/si_descriptors.c
+++ b/src/gallium/drivers/radeonsi/si_descriptors.c
@@ -261,15 +261,15 @@ static void si_release_sampler_views(struct 
si_sampler_views *views)
 }
 
 static void si_sampler_view_add_buffer(struct si_context *sctx,
-  struct pipe_resource *resource)
+  struct pipe_resource *resource,
+  enum radeon_bo_usage usage)
 {
struct r600_resource *rres = (struct r600_resource*)resource;
 
if (!resource)
return;
 
-   radeon_add_to_buffer_list(&sctx->b, &sctx->b.gfx, rres,
- RADEON_USAGE_READ,
+   radeon_add_to_buffer_list(&sctx->b, &sctx->b.gfx, rres, usage,
  r600_get_sampler_view_priority(rres));
 }
 
@@ -282,7 +282,8 @@ static void si_sampler_views_begin_new_cs(struct si_context 
*sctx,
while (mask) {
int i = u_bit_scan(&mask);
 
-   si_sampler_view_add_buffer(sctx, views->views[i]->texture);
+   si_sampler_view_add_buffer(sctx, views->views[i]->texture,
+  RADEON_USAGE_READ);
}
 
views->desc.ce_ram_dirty = true;
@@ -310,7 +311,8 @@ static void si_set_sampler_view(struct si_context *sctx,
if (view) {
struct r600_texture *rtex = (struct r600_texture 
*)view->texture;
 
-   si_sampler_view_add_buffer(sctx, view->texture);
+   si_sampler_view_add_buffer(sctx, view->texture,
+  RADEON_USAGE_READ);
 
pipe_sampler_view_reference(&views->views[slot], view);
memcpy(views->desc.list + slot * 16, rview->state, 8*4);
@@ -441,7 +443,8 @@ si_image_views_begin_new_cs(struct si_context *sctx, struct 
si_images_info *imag
 
assert(view->resource);
 
-   si_sampler_view_add_buffer(sctx, view->resource);
+   si_sampler_view_add_buffer(sctx, view->resource,
+  RADEON_USAGE_READWRITE);
}
 
images->desc.ce_ram_dirty = true;
@@ -495,7 +498,8 @@ si_set_shader_images(struct pipe_context *pipe, unsigned 
shader,
res = (struct r600_resource *)views[i].resource;
util_copy_image_view(&images->views[slot], &views[i]);
 
-   si_sampler_view_add_buffer(ctx, &res->b.b);
+   si_sampler_view_add_buffer(ctx, &res->b.b,
+  RADEON_USAGE_READWRITE);
 
if (res->b.b.target == PIPE_BUFFER) {
si_make_buffer_descriptor(screen, res,
-- 
2.5.0

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


[Mesa-dev] [Bug 94168] Incorrect rendering when running Populous 3 on wine using DDraw->WineD3D->OpenGL wrapper [apitrace]

2016-04-29 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=94168

--- Comment #8 from almos  ---
(In reply to Nicolai Hähnle from comment #7)
> When you open the trace with qapitrace, you'll see that appears as one
> single big frame. This is a big clue as to what's going on. Somehow, the
> game/Wine doesn't trigger the usual swap buffers logic, which means screen
> refreshes don't happen reliably. Seems most likely to be a Wine bug, to be
> honest.

Doesn't that mean frontbuffer rendering?

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


Re: [Mesa-dev] [PATCH 4/7] i965/disasm: Split opcode tables by the generation they were introduced in.

2016-04-29 Thread Matt Turner
On Thu, Apr 28, 2016 at 12:46 PM, Francisco Jerez  wrote:
> Matt Turner  writes:
>
>> On Thu, Apr 28, 2016 at 12:19 AM, Francisco Jerez  
>> wrote:
>>> ---
>>>  src/mesa/drivers/dri/i965/brw_disasm.c | 90 
>>> ++
>>>  1 file changed, 69 insertions(+), 21 deletions(-)
>>>
>>> diff --git a/src/mesa/drivers/dri/i965/brw_disasm.c 
>>> b/src/mesa/drivers/dri/i965/brw_disasm.c
>>> index 15d9383..0125434 100644
>>> --- a/src/mesa/drivers/dri/i965/brw_disasm.c
>>> +++ b/src/mesa/drivers/dri/i965/brw_disasm.c
>>> @@ -30,9 +30,8 @@
>>>  #include "brw_inst.h"
>>>  #include "brw_eu.h"
>>>
>>> -static const struct opcode_desc opcode_descs[128] = {
>>> +static const struct opcode_desc gen4_opcode_descs[128] = {
>>> [BRW_OPCODE_MOV]  = { .name = "mov", .nsrc = 1, .ndst = 1 },
>>> -   [BRW_OPCODE_MOVI] = { .name = "movi",.nsrc = 2, .ndst = 1 },
>>> [BRW_OPCODE_FRC]  = { .name = "frc", .nsrc = 1, .ndst = 1 },
>>> [BRW_OPCODE_RNDU] = { .name = "rndu",.nsrc = 1, .ndst = 1 },
>>> [BRW_OPCODE_RNDD] = { .name = "rndd",.nsrc = 1, .ndst = 1 },
>>> @@ -40,27 +39,17 @@ static const struct opcode_desc opcode_descs[128] = {
>>> [BRW_OPCODE_RNDZ] = { .name = "rndz",.nsrc = 1, .ndst = 1 },
>>> [BRW_OPCODE_NOT]  = { .name = "not", .nsrc = 1, .ndst = 1 },
>>> [BRW_OPCODE_LZD]  = { .name = "lzd", .nsrc = 1, .ndst = 1 },
>>> -   [BRW_OPCODE_F32TO16]  = { .name = "f32to16", .nsrc = 1, .ndst = 1 },
>>> -   [BRW_OPCODE_F16TO32]  = { .name = "f16to32", .nsrc = 1, .ndst = 1 },
>>> -   [BRW_OPCODE_BFREV]= { .name = "bfrev",   .nsrc = 1, .ndst = 1 },
>>> -   [BRW_OPCODE_FBH]  = { .name = "fbh", .nsrc = 1, .ndst = 1 },
>>> -   [BRW_OPCODE_FBL]  = { .name = "fbl", .nsrc = 1, .ndst = 1 },
>>> -   [BRW_OPCODE_CBIT] = { .name = "cbit",.nsrc = 1, .ndst = 1 },
>>>
>>> [BRW_OPCODE_MUL]  = { .name = "mul", .nsrc = 2, .ndst = 1 },
>>> [BRW_OPCODE_MAC]  = { .name = "mac", .nsrc = 2, .ndst = 1 },
>>> [BRW_OPCODE_MACH] = { .name = "mach",.nsrc = 2, .ndst = 1 },
>>> [BRW_OPCODE_LINE] = { .name = "line",.nsrc = 2, .ndst = 1 },
>>> -   [BRW_OPCODE_PLN]  = { .name = "pln", .nsrc = 2, .ndst = 1 },
>>> -   [BRW_OPCODE_MAD]  = { .name = "mad", .nsrc = 3, .ndst = 1 },
>>> -   [BRW_OPCODE_LRP]  = { .name = "lrp", .nsrc = 3, .ndst = 1 },
>>> [BRW_OPCODE_SAD2] = { .name = "sad2",.nsrc = 2, .ndst = 1 },
>>> [BRW_OPCODE_SADA2]= { .name = "sada2",   .nsrc = 2, .ndst = 1 },
>>> [BRW_OPCODE_DP4]  = { .name = "dp4", .nsrc = 2, .ndst = 1 },
>>> [BRW_OPCODE_DPH]  = { .name = "dph", .nsrc = 2, .ndst = 1 },
>>> [BRW_OPCODE_DP3]  = { .name = "dp3", .nsrc = 2, .ndst = 1 },
>>> [BRW_OPCODE_DP2]  = { .name = "dp2", .nsrc = 2, .ndst = 1 },
>>> -   [BRW_OPCODE_MATH] = { .name = "math",.nsrc = 2, .ndst = 1 },
>>>
>>> [BRW_OPCODE_AVG]  = { .name = "avg", .nsrc = 2, .ndst = 1 },
>>> [BRW_OPCODE_ADD]  = { .name = "add", .nsrc = 2, .ndst = 1 },
>>> @@ -73,17 +62,9 @@ static const struct opcode_desc opcode_descs[128] = {
>>> [BRW_OPCODE_ASR]  = { .name = "asr", .nsrc = 2, .ndst = 1 },
>>> [BRW_OPCODE_CMP]  = { .name = "cmp", .nsrc = 2, .ndst = 1 },
>>> [BRW_OPCODE_CMPN] = { .name = "cmpn",.nsrc = 2, .ndst = 1 },
>>> -   [BRW_OPCODE_CSEL] = { .name = "csel",.nsrc = 3, .ndst = 1 },
>>> -   [BRW_OPCODE_BFE]  = { .name = "bfe", .nsrc = 3, .ndst = 1 },
>>> -   [BRW_OPCODE_BFI1] = { .name = "bfi1",.nsrc = 2, .ndst = 1 },
>>> -   [BRW_OPCODE_BFI2] = { .name = "bfi2",.nsrc = 3, .ndst = 1 },
>>> -   [BRW_OPCODE_ADDC] = { .name = "addc",.nsrc = 2, .ndst = 1 },
>>> -   [BRW_OPCODE_SUBB] = { .name = "subb",.nsrc = 2, .ndst = 1 },
>>>
>>> [BRW_OPCODE_SEND] = { .name = "send",.nsrc = 1, .ndst = 1 },
>>> [BRW_OPCODE_SENDC]= { .name = "sendc",   .nsrc = 1, .ndst = 1 },
>>> -   [BRW_OPCODE_SENDS]= { .name = "sends",   .nsrc = 2, .ndst = 1 },
>>> -   [BRW_OPCODE_SENDSC]   = { .name = "sendsc",  .nsrc = 2, .ndst = 1 },
>>> [BRW_OPCODE_ILLEGAL]  = { .name = "illegal", .nsrc = 0, .ndst = 0 },
>>> [BRW_OPCODE_NOP]  = { .name = "nop", .nsrc = 0, .ndst = 0 },
>>> [BRW_OPCODE_NENOP]= { .name = "nenop",   .nsrc = 0, .ndst = 0 },
>>> @@ -104,6 +85,70 @@ static const struct opcode_desc opcode_descs[128] = {
>>> [BRW_OPCODE_ENDIF]= { .name = "endif",   .nsrc = 0, .ndst = 0 },
>>>  };
>>>
>>> +static const struct opcode_desc g45_opcode_descs[128] = {
>>> +   [BRW_OPCODE_MOVI] = { .name = "movi",.nsrc = 2, .ndst = 1 },
>>> +   [BRW_OPCODE_PLN]  = { .name = "pln", .nsrc = 2, .ndst = 1 },
>>> +};
>>> +
>>> +static const struct opcode_desc gen6_opcode_descs[128] = {
>>> +   [BRW_OPCODE_MATH] = { .name = "math",.nsrc = 2, .ndst = 1 },
>>> +   [BRW

Re: [Mesa-dev] [PATCH 4/7] i965/disasm: Split opcode tables by the generation they were introduced in.

2016-04-29 Thread Francisco Jerez
Ian Romanick  writes:

> On 04/28/2016 09:46 PM, Francisco Jerez wrote:
>> Matt Turner  writes:
>> 
>>> On Thu, Apr 28, 2016 at 12:19 AM, Francisco Jerez  
>>> wrote:
 ---
  src/mesa/drivers/dri/i965/brw_disasm.c | 90 
 ++
  1 file changed, 69 insertions(+), 21 deletions(-)

 diff --git a/src/mesa/drivers/dri/i965/brw_disasm.c 
 b/src/mesa/drivers/dri/i965/brw_disasm.c
 index 15d9383..0125434 100644
 --- a/src/mesa/drivers/dri/i965/brw_disasm.c
 +++ b/src/mesa/drivers/dri/i965/brw_disasm.c
 @@ -30,9 +30,8 @@
  #include "brw_inst.h"
  #include "brw_eu.h"

 -static const struct opcode_desc opcode_descs[128] = {
 +static const struct opcode_desc gen4_opcode_descs[128] = {
 [BRW_OPCODE_MOV]  = { .name = "mov", .nsrc = 1, .ndst = 1 },
 -   [BRW_OPCODE_MOVI] = { .name = "movi",.nsrc = 2, .ndst = 1 },
 [BRW_OPCODE_FRC]  = { .name = "frc", .nsrc = 1, .ndst = 1 },
 [BRW_OPCODE_RNDU] = { .name = "rndu",.nsrc = 1, .ndst = 1 },
 [BRW_OPCODE_RNDD] = { .name = "rndd",.nsrc = 1, .ndst = 1 },
 @@ -40,27 +39,17 @@ static const struct opcode_desc opcode_descs[128] = {
 [BRW_OPCODE_RNDZ] = { .name = "rndz",.nsrc = 1, .ndst = 1 },
 [BRW_OPCODE_NOT]  = { .name = "not", .nsrc = 1, .ndst = 1 },
 [BRW_OPCODE_LZD]  = { .name = "lzd", .nsrc = 1, .ndst = 1 },
 -   [BRW_OPCODE_F32TO16]  = { .name = "f32to16", .nsrc = 1, .ndst = 1 },
 -   [BRW_OPCODE_F16TO32]  = { .name = "f16to32", .nsrc = 1, .ndst = 1 },
 -   [BRW_OPCODE_BFREV]= { .name = "bfrev",   .nsrc = 1, .ndst = 1 },
 -   [BRW_OPCODE_FBH]  = { .name = "fbh", .nsrc = 1, .ndst = 1 },
 -   [BRW_OPCODE_FBL]  = { .name = "fbl", .nsrc = 1, .ndst = 1 },
 -   [BRW_OPCODE_CBIT] = { .name = "cbit",.nsrc = 1, .ndst = 1 },

 [BRW_OPCODE_MUL]  = { .name = "mul", .nsrc = 2, .ndst = 1 },
 [BRW_OPCODE_MAC]  = { .name = "mac", .nsrc = 2, .ndst = 1 },
 [BRW_OPCODE_MACH] = { .name = "mach",.nsrc = 2, .ndst = 1 },
 [BRW_OPCODE_LINE] = { .name = "line",.nsrc = 2, .ndst = 1 },
 -   [BRW_OPCODE_PLN]  = { .name = "pln", .nsrc = 2, .ndst = 1 },
 -   [BRW_OPCODE_MAD]  = { .name = "mad", .nsrc = 3, .ndst = 1 },
 -   [BRW_OPCODE_LRP]  = { .name = "lrp", .nsrc = 3, .ndst = 1 },
 [BRW_OPCODE_SAD2] = { .name = "sad2",.nsrc = 2, .ndst = 1 },
 [BRW_OPCODE_SADA2]= { .name = "sada2",   .nsrc = 2, .ndst = 1 },
 [BRW_OPCODE_DP4]  = { .name = "dp4", .nsrc = 2, .ndst = 1 },
 [BRW_OPCODE_DPH]  = { .name = "dph", .nsrc = 2, .ndst = 1 },
 [BRW_OPCODE_DP3]  = { .name = "dp3", .nsrc = 2, .ndst = 1 },
 [BRW_OPCODE_DP2]  = { .name = "dp2", .nsrc = 2, .ndst = 1 },
 -   [BRW_OPCODE_MATH] = { .name = "math",.nsrc = 2, .ndst = 1 },

 [BRW_OPCODE_AVG]  = { .name = "avg", .nsrc = 2, .ndst = 1 },
 [BRW_OPCODE_ADD]  = { .name = "add", .nsrc = 2, .ndst = 1 },
 @@ -73,17 +62,9 @@ static const struct opcode_desc opcode_descs[128] = {
 [BRW_OPCODE_ASR]  = { .name = "asr", .nsrc = 2, .ndst = 1 },
 [BRW_OPCODE_CMP]  = { .name = "cmp", .nsrc = 2, .ndst = 1 },
 [BRW_OPCODE_CMPN] = { .name = "cmpn",.nsrc = 2, .ndst = 1 },
 -   [BRW_OPCODE_CSEL] = { .name = "csel",.nsrc = 3, .ndst = 1 },
 -   [BRW_OPCODE_BFE]  = { .name = "bfe", .nsrc = 3, .ndst = 1 },
 -   [BRW_OPCODE_BFI1] = { .name = "bfi1",.nsrc = 2, .ndst = 1 },
 -   [BRW_OPCODE_BFI2] = { .name = "bfi2",.nsrc = 3, .ndst = 1 },
 -   [BRW_OPCODE_ADDC] = { .name = "addc",.nsrc = 2, .ndst = 1 },
 -   [BRW_OPCODE_SUBB] = { .name = "subb",.nsrc = 2, .ndst = 1 },

 [BRW_OPCODE_SEND] = { .name = "send",.nsrc = 1, .ndst = 1 },
 [BRW_OPCODE_SENDC]= { .name = "sendc",   .nsrc = 1, .ndst = 1 },
 -   [BRW_OPCODE_SENDS]= { .name = "sends",   .nsrc = 2, .ndst = 1 },
 -   [BRW_OPCODE_SENDSC]   = { .name = "sendsc",  .nsrc = 2, .ndst = 1 },
 [BRW_OPCODE_ILLEGAL]  = { .name = "illegal", .nsrc = 0, .ndst = 0 },
 [BRW_OPCODE_NOP]  = { .name = "nop", .nsrc = 0, .ndst = 0 },
 [BRW_OPCODE_NENOP]= { .name = "nenop",   .nsrc = 0, .ndst = 0 },
 @@ -104,6 +85,70 @@ static const struct opcode_desc opcode_descs[128] = {
 [BRW_OPCODE_ENDIF]= { .name = "endif",   .nsrc = 0, .ndst = 0 },
  };

 +static const struct opcode_desc g45_opcode_descs[128] = {
 +   [BRW_OPCODE_MOVI] = { .name = "movi",.nsrc = 2, .ndst = 1 },
 +   [BRW_OPCODE_PLN]  = { .name = "pln", .nsrc = 2, .ndst = 1 },
 +};
 +
 +static const struct opcode_desc gen6_opcode_descs[12

[Mesa-dev] [Bug 95085] Invalid sampling of second texture in fragment shader that have two samplers with different parameters.

2016-04-29 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=95085

Nicolai Hähnle  changed:

   What|Removed |Added

 Resolution|--- |NOTOURBUG
 Status|NEW |RESOLVED

--- Comment #12 from Nicolai Hähnle  ---
Frankly, I don't see how your sample is supposed to render text. The fragment
shader only accesses the font texture when nModeOut != 0u, and the value is
just passed through from the vertex buffer. According to qapitrace, nModeIn is
equal to 0 for all vertices in the final glDrawArrays call... at least based on
the apitrace, I'm pretty sure that this is not a driver bug.

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


[Mesa-dev] [PATCH] st/nine: clean up WINAPI definition

2016-04-29 Thread Christian Schmidbauer
As Emil pointed out, only gcc, clang and MSVC compatibility is required.
Hence the check for GNUC can be skipped, as __i386__ and __x86_64__ are
only defined for gcc/clang, not for MSVC.

Remove the #undef which has been there for historic reasons, when wine
dlls for nine have been built inside mesa. Instead use #ifndef in order
to avoid redefining WINAPI from MSVC's headers.
---
 include/D3D9/d3d9types.h | 16 +---
 1 file changed, 5 insertions(+), 11 deletions(-)

diff --git a/include/D3D9/d3d9types.h b/include/D3D9/d3d9types.h
index e0b8652..88f22b9 100644
--- a/include/D3D9/d3d9types.h
+++ b/include/D3D9/d3d9types.h
@@ -173,22 +173,16 @@ typedef struct _RGNDATA {
 #define D3DPRESENTFLAG_RESTRICTED_CONTENT  0x0400
 #define D3DPRESENTFLAG_RESTRICT_SHARED_RESOURCE_DRIVER 0x0800
 
-
-#ifdef WINAPI
-#undef WINAPI
-#endif /* WINAPI*/
-
-#ifdef __GNUC__
-  #if (defined(__x86_64__) && !defined(__ILP32__)) || defined(_M_X64)
+/* Windows calling convention */
+#ifndef WINAPI
+  #if defined(__x86_64__) && !defined(__ILP32__)
 #define WINAPI __attribute__((ms_abi))
-  #elif defined(__i386) || defined(_M_IX86)
+  #elif defined(__i386__)
 #define WINAPI __attribute__((__stdcall__))
   #else /* neither amd64 nor i386 */
 #define WINAPI
   #endif
-#else /* __GNUC__ */
-  #define WINAPI
-#endif
+#endif /* WINAPI */
 
 /* Implementation caps */
 #define D3DPRESENT_BACK_BUFFERS_MAX3
-- 
2.7.3

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


Re: [Mesa-dev] [PATCH 2/3] mesa: rename lower_fmod to lower_fmod32

2016-04-29 Thread Jason Ekstrand
Why not just squash 2 and 3 and call it "Separate 32 and 64-bit fmod
lowering" or something like that.


On Thu, Apr 28, 2016 at 4:19 AM, Samuel Iglesias Gonsálvez <
sigles...@igalia.com> wrote:

> A later patch will add lower_fmod64 option to NIR.
>
> Signed-off-by: Samuel Iglesias Gonsálvez 
> ---
>  src/compiler/nir/nir.h   | 2 +-
>  src/compiler/nir/nir_opt_algebraic.py| 4 ++--
>  src/mesa/drivers/dri/i965/brw_compiler.c | 2 +-
>  3 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
> index 2e89bc5..a478124 100644
> --- a/src/compiler/nir/nir.h
> +++ b/src/compiler/nir/nir.h
> @@ -1630,7 +1630,7 @@ typedef struct nir_shader_compiler_options {
> bool lower_fpow;
> bool lower_fsat;
> bool lower_fsqrt;
> -   bool lower_fmod;
> +   bool lower_fmod32;
> bool lower_bitfield_extract;
> bool lower_bitfield_insert;
> bool lower_uadd_carry;
> diff --git a/src/compiler/nir/nir_opt_algebraic.py
> b/src/compiler/nir/nir_opt_algebraic.py
> index 60ee170..afe653e 100644
> --- a/src/compiler/nir/nir_opt_algebraic.py
> +++ b/src/compiler/nir/nir_opt_algebraic.py
> @@ -296,8 +296,8 @@ optimizations = [
> (('iadd', '#a', ('iadd', b, '#c')), ('iadd', ('iadd', a, c), b)),
>
> # Misc. lowering
> -   (('fmod', a, b), ('fsub', a, ('fmul', b, ('ffloor', ('fdiv', a, b,
> 'options->lower_fmod'),
> -   (('frem', a, b), ('fsub', a, ('fmul', b, ('ftrunc', ('fdiv', a, b,
> 'options->lower_fmod'),
> +   (('fmod', a, b), ('fsub', a, ('fmul', b, ('ffloor', ('fdiv', a, b,
> 'options->lower_fmod32'),
> +   (('frem', a, b), ('fsub', a, ('fmul', b, ('ftrunc', ('fdiv', a, b,
> 'options->lower_fmod32'),
> (('uadd_carry@32', a, b), ('b2i', ('ult', ('iadd', a, b), a)),
> 'options->lower_uadd_carry'),
> (('usub_borrow@32', a, b), ('b2i', ('ult', a, b)),
> 'options->lower_usub_borrow'),
>
> diff --git a/src/mesa/drivers/dri/i965/brw_compiler.c
> b/src/mesa/drivers/dri/i965/brw_compiler.c
> index c8a38e3..5ff1a61 100644
> --- a/src/mesa/drivers/dri/i965/brw_compiler.c
> +++ b/src/mesa/drivers/dri/i965/brw_compiler.c
> @@ -76,7 +76,7 @@ shader_perf_log_mesa(void *data, const char *fmt, ...)
> .lower_sub = true,
>  \
> .lower_fdiv = true,
> \
> .lower_scmp = true,
> \
> -   .lower_fmod = true,
> \
> +   .lower_fmod32 = true,
> \
> .lower_bitfield_extract = true,
> \
> .lower_bitfield_insert = true,
>  \
> .lower_uadd_carry = true,
> \
> --
> 2.5.0
>
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 1/3] nir/opt_dead_cf: correction of side effect check

2016-04-29 Thread Jason Ekstrand
On Fri, Apr 29, 2016 at 11:31 AM, Thomas Hindoe Paaboel Andersen <
pho...@gmail.com> wrote:

> Parenthesis are needed here as ! takes precedence over the &. The
> check had the opposite effect than intended.
> ---
> Not tested as I do not own the neccesary hardware.
>
>  src/compiler/nir/nir_opt_dead_cf.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/src/compiler/nir/nir_opt_dead_cf.c
> b/src/compiler/nir/nir_opt_dead_cf.c
> index 2e04c17..7450b1c 100644
> --- a/src/compiler/nir/nir_opt_dead_cf.c
> +++ b/src/compiler/nir/nir_opt_dead_cf.c
> @@ -155,8 +155,8 @@ cf_node_has_side_effects(nir_cf_node *node)
>  continue;
>
>   nir_intrinsic_instr *intrin = nir_instr_as_intrinsic(instr);
> - if (!nir_intrinsic_infos[intrin->intrinsic].flags &
> - NIR_INTRINSIC_CAN_ELIMINATE)
> + if (!(nir_intrinsic_infos[intrin->intrinsic].flags &
> + NIR_INTRINSIC_CAN_ELIMINATE))
>

Good catch!  All three patches are

Reviewed-by: Jason Ekstrand 


>  return true;
>}
> }
> --
> 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


[Mesa-dev] [Bug 94168] Incorrect rendering when running Populous 3 on wine using DDraw->WineD3D->OpenGL wrapper [apitrace]

2016-04-29 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=94168

--- Comment #7 from Nicolai Hähnle  ---
When you open the trace with qapitrace, you'll see that appears as one single
big frame. This is a big clue as to what's going on. Somehow, the game/Wine
doesn't trigger the usual swap buffers logic, which means screen refreshes
don't happen reliably. Seems most likely to be a Wine bug, to be honest.

-- 
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 3/3] nir/lower_double_ops: fix indentation

2016-04-29 Thread Thomas Hindoe Paaboel Andersen
---
 src/compiler/nir/nir_lower_double_ops.c | 60 -
 1 file changed, 30 insertions(+), 30 deletions(-)

diff --git a/src/compiler/nir/nir_lower_double_ops.c 
b/src/compiler/nir/nir_lower_double_ops.c
index e5cf094..3f831dc 100644
--- a/src/compiler/nir/nir_lower_double_ops.c
+++ b/src/compiler/nir/nir_lower_double_ops.c
@@ -267,36 +267,36 @@ lower_sqrt_rsq(nir_builder *b, nir_ssa_def *src, bool 
sqrt)
 * (https://en.wikipedia.org/wiki/Methods_of_computing_square_roots).
 */
 
-nir_ssa_def *one_half = nir_imm_double(b, 0.5);
-nir_ssa_def *h_0 = nir_fmul(b, one_half, ra);
-nir_ssa_def *g_0 = nir_fmul(b, src, ra);
-nir_ssa_def *r_0 = nir_ffma(b, nir_fneg(b, h_0), g_0, one_half);
-nir_ssa_def *h_1 = nir_ffma(b, h_0, r_0, h_0);
-nir_ssa_def *res;
-if (sqrt) {
-   nir_ssa_def *g_1 = nir_ffma(b, g_0, r_0, g_0);
-   nir_ssa_def *r_1 = nir_ffma(b, nir_fneg(b, g_1), g_1, src);
-   res = nir_ffma(b, h_1, r_1, g_1);
-} else {
-   nir_ssa_def *y_1 = nir_fmul(b, nir_imm_double(b, 2.0), h_1);
-   nir_ssa_def *r_1 = nir_ffma(b, nir_fneg(b, y_1), nir_fmul(b, h_1, src),
-   one_half);
-   res = nir_ffma(b, y_1, r_1, y_1);
-}
-
-if (sqrt) {
-   /* Here, the special cases we need to handle are
-* 0 -> 0 and
-* +inf -> +inf
-*/
-   res = nir_bcsel(b, nir_ior(b, nir_feq(b, src, nir_imm_double(b, 0.0)),
-  nir_feq(b, src, nir_imm_double(b, 
INFINITY))),
-   src, res);
-} else {
-   res = fix_inv_result(b, res, src, new_exp);
-}
-
-return res;
+   nir_ssa_def *one_half = nir_imm_double(b, 0.5);
+   nir_ssa_def *h_0 = nir_fmul(b, one_half, ra);
+   nir_ssa_def *g_0 = nir_fmul(b, src, ra);
+   nir_ssa_def *r_0 = nir_ffma(b, nir_fneg(b, h_0), g_0, one_half);
+   nir_ssa_def *h_1 = nir_ffma(b, h_0, r_0, h_0);
+   nir_ssa_def *res;
+   if (sqrt) {
+  nir_ssa_def *g_1 = nir_ffma(b, g_0, r_0, g_0);
+  nir_ssa_def *r_1 = nir_ffma(b, nir_fneg(b, g_1), g_1, src);
+  res = nir_ffma(b, h_1, r_1, g_1);
+   } else {
+  nir_ssa_def *y_1 = nir_fmul(b, nir_imm_double(b, 2.0), h_1);
+  nir_ssa_def *r_1 = nir_ffma(b, nir_fneg(b, y_1), nir_fmul(b, h_1, src),
+  one_half);
+  res = nir_ffma(b, y_1, r_1, y_1);
+   }
+
+   if (sqrt) {
+  /* Here, the special cases we need to handle are
+   * 0 -> 0 and
+   * +inf -> +inf
+   */
+  res = nir_bcsel(b, nir_ior(b, nir_feq(b, src, nir_imm_double(b, 0.0)),
+ nir_feq(b, src, nir_imm_double(b, INFINITY))),
+ src, res);
+   } else {
+  res = fix_inv_result(b, res, src, new_exp);
+   }
+
+   return res;
 }
 
 static nir_ssa_def *
-- 
2.7.4

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


[Mesa-dev] [PATCH 2/3] nir/opt_dead_cf: fix indentation

2016-04-29 Thread Thomas Hindoe Paaboel Andersen
---
 src/compiler/nir/nir_opt_dead_cf.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/compiler/nir/nir_opt_dead_cf.c 
b/src/compiler/nir/nir_opt_dead_cf.c
index 7450b1c..74af19b 100644
--- a/src/compiler/nir/nir_opt_dead_cf.c
+++ b/src/compiler/nir/nir_opt_dead_cf.c
@@ -221,11 +221,11 @@ dead_cf_block(nir_block *block)
 {
nir_if *following_if = nir_block_get_following_if(block);
if (following_if) {
- nir_const_value *const_value =
-nir_src_as_const_value(following_if->condition);
+  nir_const_value *const_value =
+ nir_src_as_const_value(following_if->condition);
 
- if (!const_value)
-return false;
+  if (!const_value)
+ return false;
 
   opt_constant_if(following_if, const_value->u32[0] != 0);
   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/3] nir/opt_dead_cf: correction of side effect check

2016-04-29 Thread Thomas Hindoe Paaboel Andersen
Parenthesis are needed here as ! takes precedence over the &. The
check had the opposite effect than intended.
---
Not tested as I do not own the neccesary hardware.

 src/compiler/nir/nir_opt_dead_cf.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/compiler/nir/nir_opt_dead_cf.c 
b/src/compiler/nir/nir_opt_dead_cf.c
index 2e04c17..7450b1c 100644
--- a/src/compiler/nir/nir_opt_dead_cf.c
+++ b/src/compiler/nir/nir_opt_dead_cf.c
@@ -155,8 +155,8 @@ cf_node_has_side_effects(nir_cf_node *node)
 continue;
 
  nir_intrinsic_instr *intrin = nir_instr_as_intrinsic(instr);
- if (!nir_intrinsic_infos[intrin->intrinsic].flags &
- NIR_INTRINSIC_CAN_ELIMINATE)
+ if (!(nir_intrinsic_infos[intrin->intrinsic].flags &
+ NIR_INTRINSIC_CAN_ELIMINATE))
 return true;
   }
}
-- 
2.7.4

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


Re: [Mesa-dev] [PATCH 3/3] nir/opt_algebraic: lower mod() with doubles operands if lower_fmod64 is enabled

2016-04-29 Thread Jordan Justen
On 2016-04-28 04:19:18, Samuel Iglesias Gonsálvez wrote:
> Make this distintion as the drivers might need to lower it inside NIR.
> 
> Signed-off-by: Samuel Iglesias Gonsálvez 
> ---
>  src/compiler/nir/nir.h| 2 ++
>  src/compiler/nir/nir_opt_algebraic.py | 3 ++-
>  2 files changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
> index a478124..83a8cae 100644
> --- a/src/compiler/nir/nir.h
> +++ b/src/compiler/nir/nir.h
> @@ -1631,6 +1631,8 @@ typedef struct nir_shader_compiler_options {
> bool lower_fsat;
> bool lower_fsqrt;
> bool lower_fmod32;
> +   /** Lowers fmod when it does not support doubles */

This comment seems out of place compared to the other options here.
Maybe it is not necessary?

Series Reviewed-by: Jordan Justen 

> +   bool lower_fmod64;
> bool lower_bitfield_extract;
> bool lower_bitfield_insert;
> bool lower_uadd_carry;
> diff --git a/src/compiler/nir/nir_opt_algebraic.py 
> b/src/compiler/nir/nir_opt_algebraic.py
> index afe653e..f81416b 100644
> --- a/src/compiler/nir/nir_opt_algebraic.py
> +++ b/src/compiler/nir/nir_opt_algebraic.py
> @@ -296,7 +296,8 @@ optimizations = [
> (('iadd', '#a', ('iadd', b, '#c')), ('iadd', ('iadd', a, c), b)),
>  
> # Misc. lowering
> -   (('fmod', a, b), ('fsub', a, ('fmul', b, ('ffloor', ('fdiv', a, b, 
> 'options->lower_fmod32'),
> +   (('fmod@32', a, b), ('fsub', a, ('fmul', b, ('ffloor', ('fdiv', a, b, 
> 'options->lower_fmod32'),
> +   (('fmod@64', a, b), ('fsub', a, ('fmul', b, ('ffloor', ('fdiv', a, b, 
> 'options->lower_fmod64'),
> (('frem', a, b), ('fsub', a, ('fmul', b, ('ftrunc', ('fdiv', a, b, 
> 'options->lower_fmod32'),
> (('uadd_carry@32', a, b), ('b2i', ('ult', ('iadd', a, b), a)), 
> 'options->lower_uadd_carry'),
> (('usub_borrow@32', a, b), ('b2i', ('ult', a, b)), 
> 'options->lower_usub_borrow'),
> -- 
> 2.5.0
> 
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] glx: Refactor the configure options for glx implementation choice (v3)

2016-04-29 Thread Emil Velikov
Hi Chuck,

Considering that lack of comments it seems like pretty much everyone
is happy or that no-one is interested/has time.
I'm just giving your patch a few last tests and I'll push it to master.

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


Re: [Mesa-dev] [PATCH] radeonsi: correct NULL-pointer check in si_upload_const_buffer

2016-04-29 Thread Marek Olšák
Reviewed-by: Marek Olšák 

Marek

On Fri, Apr 29, 2016 at 7:13 PM, Nicolai Hähnle  wrote:
> From: Nicolai Hähnle 
>
> Cc: "11.1 11.2" 
> ---
>  src/gallium/drivers/radeonsi/si_descriptors.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/gallium/drivers/radeonsi/si_descriptors.c 
> b/src/gallium/drivers/radeonsi/si_descriptors.c
> index fbaf804..0b32045 100644
> --- a/src/gallium/drivers/radeonsi/si_descriptors.c
> +++ b/src/gallium/drivers/radeonsi/si_descriptors.c
> @@ -779,7 +779,7 @@ void si_upload_const_buffer(struct si_context *sctx, 
> struct r600_resource **rbuf
>
> u_upload_alloc(sctx->b.uploader, 0, size, 256, const_offset,
>(struct pipe_resource**)rbuffer, &tmp);
> -   if (rbuffer)
> +   if (*rbuffer)
> util_memcpy_cpu_to_le32(tmp, ptr, size);
>  }
>
> --
> 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] radeonsi: correct NULL-pointer check in si_upload_const_buffer

2016-04-29 Thread Bas Nieuwenhuizen
Reviewed-by: Bas Nieuwenhuizen 

On Fri, Apr 29, 2016 at 7:13 PM, Nicolai Hähnle  wrote:
> From: Nicolai Hähnle 
>
> Cc: "11.1 11.2" 
> ---
>  src/gallium/drivers/radeonsi/si_descriptors.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/gallium/drivers/radeonsi/si_descriptors.c 
> b/src/gallium/drivers/radeonsi/si_descriptors.c
> index fbaf804..0b32045 100644
> --- a/src/gallium/drivers/radeonsi/si_descriptors.c
> +++ b/src/gallium/drivers/radeonsi/si_descriptors.c
> @@ -779,7 +779,7 @@ void si_upload_const_buffer(struct si_context *sctx, 
> struct r600_resource **rbuf
>
> u_upload_alloc(sctx->b.uploader, 0, size, 256, const_offset,
>(struct pipe_resource**)rbuffer, &tmp);
> -   if (rbuffer)
> +   if (*rbuffer)
> util_memcpy_cpu_to_le32(tmp, ptr, size);
>  }
>
> --
> 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


[Mesa-dev] [PATCH] radeonsi: correct NULL-pointer check in si_upload_const_buffer

2016-04-29 Thread Nicolai Hähnle
From: Nicolai Hähnle 

Cc: "11.1 11.2" 
---
 src/gallium/drivers/radeonsi/si_descriptors.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/gallium/drivers/radeonsi/si_descriptors.c 
b/src/gallium/drivers/radeonsi/si_descriptors.c
index fbaf804..0b32045 100644
--- a/src/gallium/drivers/radeonsi/si_descriptors.c
+++ b/src/gallium/drivers/radeonsi/si_descriptors.c
@@ -779,7 +779,7 @@ void si_upload_const_buffer(struct si_context *sctx, struct 
r600_resource **rbuf
 
u_upload_alloc(sctx->b.uploader, 0, size, 256, const_offset,
   (struct pipe_resource**)rbuffer, &tmp);
-   if (rbuffer)
+   if (*rbuffer)
util_memcpy_cpu_to_le32(tmp, ptr, size);
 }
 
-- 
2.7.4

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


[Mesa-dev] [Bug 92850] Segfault loading War Thunder

2016-04-29 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=92850

Nicolai Hähnle  changed:

   What|Removed |Added

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

--- Comment #71 from Nicolai Hähnle  ---
commit 98c348d26b28a662d093543ecb7ca839e7883e8e

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


Re: [Mesa-dev] [PATCH 11/59] i965/eu: allow doubles in math instructions

2016-04-29 Thread Connor Abbott
IIRC this is wrong. I think I added it in the beginning before I
tested to see if the spec was lying about math instructions not being
supported on doubles (it wasn't) and we can delete it now that we
lower away all the possible math operations on doubles.

On Fri, Apr 29, 2016 at 7:29 AM, Samuel Iglesias Gonsálvez
 wrote:
> From: Connor Abbott 
>
> ---
>  src/mesa/drivers/dri/i965/brw_eu_emit.c | 6 --
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/src/mesa/drivers/dri/i965/brw_eu_emit.c 
> b/src/mesa/drivers/dri/i965/brw_eu_emit.c
> index e5057a0..4c08883 100644
> --- a/src/mesa/drivers/dri/i965/brw_eu_emit.c
> +++ b/src/mesa/drivers/dri/i965/brw_eu_emit.c
> @@ -1995,8 +1995,10 @@ void gen6_math(struct brw_codegen *p,
>assert(src1.file == BRW_GENERAL_REGISTER_FILE ||
>   (devinfo->gen >= 8 && src1.file == BRW_IMMEDIATE_VALUE));
> } else {
> -  assert(src0.type == BRW_REGISTER_TYPE_F);
> -  assert(src1.type == BRW_REGISTER_TYPE_F);
> +  assert(src0.type == BRW_REGISTER_TYPE_F ||
> + src0.type == BRW_REGISTER_TYPE_DF);
> +  assert(src1.type == BRW_REGISTER_TYPE_F ||
> + src1.type == BRW_REGISTER_TYPE_DF);
>if (function == BRW_MATH_FUNCTION_POW) {
>   assert(src1.file == BRW_GENERAL_REGISTER_FILE ||
>  (devinfo->gen >= 8 && src1.file == BRW_IMMEDIATE_VALUE));
> --
> 2.5.0
>
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] anv: remove description about GENX_FUNC macro

2016-04-29 Thread Jason Ekstrand
LGTM fell free to push
On Apr 29, 2016 8:39 AM, "Emil Velikov"  wrote:

> Ping ?
> Considering to trivial this is I'm inclined to push it later on today.
>
> On 21 April 2016 at 13:20, Emil Velikov  wrote:
> > From: Emil Velikov 
> >
> > The macro has been gone since commit 1f1cf6fcb0e "anv: Get rid of
> > GENX_FUNC"
> >
> > Signed-off-by: Emil Velikov 
> > ---
> >  src/intel/genxml/gen_macros.h | 14 --
> >  1 file changed, 14 deletions(-)
> >
> > diff --git a/src/intel/genxml/gen_macros.h
> b/src/intel/genxml/gen_macros.h
> > index 052c57f..868bc22 100644
> > --- a/src/intel/genxml/gen_macros.h
> > +++ b/src/intel/genxml/gen_macros.h
> > @@ -28,20 +28,6 @@
> >   * The prefixing macros GENX() and genX() automatically prefix whatever
> you
> >   * give them by GENX_ or genX_  where X is the gen number.
> >   *
> > - * You can declare a function to be used on some range of gens like
> this:
> > - *
> > - * GENX_FUNC(GEN7, GEN75) void
> > - * genX(my_function_name)(args...)
> > - * {
> > - *// Do stuff
> > - * }
> > - *
> > - * If the file is compiled for any set of gens containing gen7 and
> gen75,
> > - * the function will effectively only get compiled twice as
> > - * gen7_my_function_nmae and gen75_my_function_name.  The function has
> to
> > - * be compilable on all gens, but it will become a static inline that
> gets
> > - * discarded by the compiler on all gens not in range.
> > - *
> >   * You can do pseudo-runtime checks in your function such as
> >   *
> >   * if (GEN_GEN > 8 || GEN_IS_HASWELL) {
> > --
> > 2.8.0
> >
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] mesa: simplify _mesa_Lightfv

2016-04-29 Thread Thomas Faller

Am 29.04.2016 um 18:34 schrieb Brian Paul:

On 04/29/2016 08:24 AM, Thomas Faller wrote:

Signed-off-by: Thomas Faller 
---
  src/mesa/main/light.c | 10 --
  1 file changed, 10 deletions(-)

diff --git a/src/mesa/main/light.c b/src/mesa/main/light.c
index 14b4b04..4a8dee3 100644
--- a/src/mesa/main/light.c
+++ b/src/mesa/main/light.c
@@ -250,17 +250,7 @@ _mesa_Lightfv( GLenum light, GLenum pname, const
GLfloat *params )
}
break;
 case GL_CONSTANT_ATTENUATION:
-  if (params[0] < 0.0F) {
- _mesa_error(ctx, GL_INVALID_VALUE, "glLight");
- return;
-  }
-  break;
 case GL_LINEAR_ATTENUATION:
-  if (params[0] < 0.0F) {
- _mesa_error(ctx, GL_INVALID_VALUE, "glLight");
- return;
-  }
-  break;
 case GL_QUADRATIC_ATTENUATION:
if (params[0] < 0.0F) {
   _mesa_error(ctx, GL_INVALID_VALUE, "glLight");


Reviewed-by: Brian Paul 

Need me to commit/push this for you?

-Brian


Hello Brian,

yes, please commit this for me.
Thank you.

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


Re: [Mesa-dev] [PATCH] mesa: simplify _mesa_Lightfv

2016-04-29 Thread Brian Paul

On 04/29/2016 08:24 AM, Thomas Faller wrote:

Signed-off-by: Thomas Faller 
---
  src/mesa/main/light.c | 10 --
  1 file changed, 10 deletions(-)

diff --git a/src/mesa/main/light.c b/src/mesa/main/light.c
index 14b4b04..4a8dee3 100644
--- a/src/mesa/main/light.c
+++ b/src/mesa/main/light.c
@@ -250,17 +250,7 @@ _mesa_Lightfv( GLenum light, GLenum pname, const
GLfloat *params )
}
break;
 case GL_CONSTANT_ATTENUATION:
-  if (params[0] < 0.0F) {
- _mesa_error(ctx, GL_INVALID_VALUE, "glLight");
- return;
-  }
-  break;
 case GL_LINEAR_ATTENUATION:
-  if (params[0] < 0.0F) {
- _mesa_error(ctx, GL_INVALID_VALUE, "glLight");
- return;
-  }
-  break;
 case GL_QUADRATIC_ATTENUATION:
if (params[0] < 0.0F) {
   _mesa_error(ctx, GL_INVALID_VALUE, "glLight");


Reviewed-by: Brian Paul 

Need me to commit/push this for you?

-Brian

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


Re: [Mesa-dev] [PATCH] anv: remove description about GENX_FUNC macro

2016-04-29 Thread Eduardo Lima Mitev
Reviewed-by: Eduardo Lima Mitev 

On 04/29/2016 05:39 PM, Emil Velikov wrote:
> Ping ?
> Considering to trivial this is I'm inclined to push it later on today.
> 
> On 21 April 2016 at 13:20, Emil Velikov  wrote:
>> From: Emil Velikov 
>>
>> The macro has been gone since commit 1f1cf6fcb0e "anv: Get rid of
>> GENX_FUNC"
>>
>> Signed-off-by: Emil Velikov 
>> ---
>>  src/intel/genxml/gen_macros.h | 14 --
>>  1 file changed, 14 deletions(-)
>>
>> diff --git a/src/intel/genxml/gen_macros.h b/src/intel/genxml/gen_macros.h
>> index 052c57f..868bc22 100644
>> --- a/src/intel/genxml/gen_macros.h
>> +++ b/src/intel/genxml/gen_macros.h
>> @@ -28,20 +28,6 @@
>>   * The prefixing macros GENX() and genX() automatically prefix whatever you
>>   * give them by GENX_ or genX_  where X is the gen number.
>>   *
>> - * You can declare a function to be used on some range of gens like this:
>> - *
>> - * GENX_FUNC(GEN7, GEN75) void
>> - * genX(my_function_name)(args...)
>> - * {
>> - *// Do stuff
>> - * }
>> - *
>> - * If the file is compiled for any set of gens containing gen7 and gen75,
>> - * the function will effectively only get compiled twice as
>> - * gen7_my_function_nmae and gen75_my_function_name.  The function has to
>> - * be compilable on all gens, but it will become a static inline that gets
>> - * discarded by the compiler on all gens not in range.
>> - *
>>   * You can do pseudo-runtime checks in your function such as
>>   *
>>   * if (GEN_GEN > 8 || GEN_IS_HASWELL) {
>> --
>> 2.8.0
>>
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
> 

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


[Mesa-dev] [PATCH] GL3: remove radeonsi occurrences in GL 4.2, already specified as "all DONE"

2016-04-29 Thread Fabio Pedretti
---
 docs/GL3.txt | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/docs/GL3.txt b/docs/GL3.txt
index bb2bb6e..5a6be41 100644
--- a/docs/GL3.txt
+++ b/docs/GL3.txt
@@ -148,17 +148,17 @@ GL 4.1, GLSL 4.10 --- all DONE: nvc0, r600, radeonsi
 
 GL 4.2, GLSL 4.20 -- all DONE: radeonsi
 
-  GL_ARB_texture_compression_bptc   DONE (i965, nvc0, 
r600, radeonsi)
+  GL_ARB_texture_compression_bptc   DONE (i965, nvc0, r600)
   GL_ARB_compressed_texture_pixel_storage   DONE (all drivers)
-  GL_ARB_shader_atomic_counters DONE (i965, nvc0, 
radeonsi, softpipe)
+  GL_ARB_shader_atomic_counters DONE (i965, nvc0, 
softpipe)
   GL_ARB_texture_storageDONE (all drivers)
-  GL_ARB_transform_feedback_instanced   DONE (i965, nv50, 
nvc0, r600, radeonsi, llvmpipe, softpipe)
-  GL_ARB_base_instance  DONE (i965, nv50, 
nvc0, r600, radeonsi, llvmpipe, softpipe)
-  GL_ARB_shader_image_load_storeDONE (i965, radeonsi, 
softpipe)
+  GL_ARB_transform_feedback_instanced   DONE (i965, nv50, 
nvc0, r600, llvmpipe, softpipe)
+  GL_ARB_base_instance  DONE (i965, nv50, 
nvc0, r600, llvmpipe, softpipe)
+  GL_ARB_shader_image_load_storeDONE (i965, softpipe)
   GL_ARB_conservative_depth DONE (all drivers that 
support GLSL 1.30)
   GL_ARB_shading_language_420pack   DONE (all drivers that 
support GLSL 1.30)
   GL_ARB_shading_language_packing   DONE (all drivers)
-  GL_ARB_internalformat_query   DONE (i965, nv50, 
nvc0, r600, radeonsi, llvmpipe, softpipe)
+  GL_ARB_internalformat_query   DONE (i965, nv50, 
nvc0, r600, llvmpipe, softpipe)
   GL_ARB_map_buffer_alignment   DONE (all drivers)
 
 
-- 
2.5.0

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


Re: [Mesa-dev] [PATCH] anv: remove description about GENX_FUNC macro

2016-04-29 Thread Emil Velikov
Ping ?
Considering to trivial this is I'm inclined to push it later on today.

On 21 April 2016 at 13:20, Emil Velikov  wrote:
> From: Emil Velikov 
>
> The macro has been gone since commit 1f1cf6fcb0e "anv: Get rid of
> GENX_FUNC"
>
> Signed-off-by: Emil Velikov 
> ---
>  src/intel/genxml/gen_macros.h | 14 --
>  1 file changed, 14 deletions(-)
>
> diff --git a/src/intel/genxml/gen_macros.h b/src/intel/genxml/gen_macros.h
> index 052c57f..868bc22 100644
> --- a/src/intel/genxml/gen_macros.h
> +++ b/src/intel/genxml/gen_macros.h
> @@ -28,20 +28,6 @@
>   * The prefixing macros GENX() and genX() automatically prefix whatever you
>   * give them by GENX_ or genX_  where X is the gen number.
>   *
> - * You can declare a function to be used on some range of gens like this:
> - *
> - * GENX_FUNC(GEN7, GEN75) void
> - * genX(my_function_name)(args...)
> - * {
> - *// Do stuff
> - * }
> - *
> - * If the file is compiled for any set of gens containing gen7 and gen75,
> - * the function will effectively only get compiled twice as
> - * gen7_my_function_nmae and gen75_my_function_name.  The function has to
> - * be compilable on all gens, but it will become a static inline that gets
> - * discarded by the compiler on all gens not in range.
> - *
>   * You can do pseudo-runtime checks in your function such as
>   *
>   * if (GEN_GEN > 8 || GEN_IS_HASWELL) {
> --
> 2.8.0
>
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] st/omx: don't return early in vid_enc_EncodeFrame()

2016-04-29 Thread Emil Velikov
Hi Alex,

On 29 April 2016 at 15:30, Alex Deucher  wrote:
> On Fri, Apr 29, 2016 at 8:56 AM, Emil Velikov  
> wrote:
>> From: Emil Velikov 
>>
>> Earlier commit plugged a memory leak, although it missed a pair of
>> brackets. Thus we unconditionally returned even in the case of no error.
>>
>> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=95203
>> Fixes: b87856d25d1 ("st/omx: Fix resource leak on OMX_ErrorNone")
>> Cc: Andy Furniss 
>> Cc: Robert Foss 
>> Signed-off-by: Emil Velikov 
>> ---
>> What an embarassing bug - missing brackets. Andy can you confirm that it
>> resolves the issue ?
>
> Reviewed-by: Alex Deucher 
>
Sorry I've missed your review and pushed the fix with Andy and Rob's tags.

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


Re: [Mesa-dev] [PATCH] gallium/radeon: fix crash in r600_set_streamout_targets

2016-04-29 Thread Marek Olšák
Reviewed-by: Marek Olšák 

Marek

On Fri, Apr 29, 2016 at 1:58 AM, Nicolai Hähnle  wrote:
> From: Nicolai Hähnle 
>
> Protect against dereferencing a gap in the targets array. This was triggered
> by a test in the Khronos CTS.
>
> Cc: "11.1 11.2" 
> ---
>  src/gallium/drivers/r600/r600_state_common.c |  3 ++-
>  src/gallium/drivers/radeon/r600_streamout.c  | 13 +++--
>  2 files changed, 9 insertions(+), 7 deletions(-)
>
> diff --git a/src/gallium/drivers/r600/r600_state_common.c 
> b/src/gallium/drivers/r600/r600_state_common.c
> index 5317de0..cac240e 100644
> --- a/src/gallium/drivers/r600/r600_state_common.c
> +++ b/src/gallium/drivers/r600/r600_state_common.c
> @@ -2802,7 +2802,8 @@ static void r600_invalidate_buffer(struct pipe_context 
> *ctx, struct pipe_resourc
> }
> /* Streamout buffers. */
> for (i = 0; i < rctx->b.streamout.num_targets; i++) {
> -   if (rctx->b.streamout.targets[i]->b.buffer == &rbuffer->b.b) {
> +   if (rctx->b.streamout.targets[i] &&
> +   rctx->b.streamout.targets[i]->b.buffer == &rbuffer->b.b) {
> if (rctx->b.streamout.begin_emitted) {
> r600_emit_streamout_end(&rctx->b);
> }
> diff --git a/src/gallium/drivers/radeon/r600_streamout.c 
> b/src/gallium/drivers/radeon/r600_streamout.c
> index fc9ec48..a001700 100644
> --- a/src/gallium/drivers/radeon/r600_streamout.c
> +++ b/src/gallium/drivers/radeon/r600_streamout.c
> @@ -116,7 +116,7 @@ void r600_set_streamout_targets(struct pipe_context *ctx,
>  {
> struct r600_common_context *rctx = (struct r600_common_context *)ctx;
> unsigned i;
> -unsigned append_bitmask = 0;
> +unsigned enabled_mask = 0, append_bitmask = 0;
>
> /* Stop streamout. */
> if (rctx->streamout.num_targets && rctx->streamout.begin_emitted) {
> @@ -126,18 +126,19 @@ void r600_set_streamout_targets(struct pipe_context 
> *ctx,
> /* Set the new targets. */
> for (i = 0; i < num_targets; i++) {
> pipe_so_target_reference((struct 
> pipe_stream_output_target**)&rctx->streamout.targets[i], targets[i]);
> +   if (!targets[i])
> +   continue;
> +
> r600_context_add_resource_size(ctx, targets[i]->buffer);
> +   enabled_mask |= 1 << i;
> if (offsets[i] == ((unsigned)-1))
> -   append_bitmask |=  1 << i;
> +   append_bitmask |= 1 << i;
> }
> for (; i < rctx->streamout.num_targets; i++) {
> pipe_so_target_reference((struct 
> pipe_stream_output_target**)&rctx->streamout.targets[i], NULL);
> }
>
> -   rctx->streamout.enabled_mask = (num_targets >= 1 && targets[0] ? 1 : 
> 0) |
> -  (num_targets >= 2 && targets[1] ? 2 : 
> 0) |
> -  (num_targets >= 3 && targets[2] ? 4 : 
> 0) |
> -  (num_targets >= 4 && targets[3] ? 8 : 
> 0);
> +   rctx->streamout.enabled_mask = enabled_mask;
>
> rctx->streamout.num_targets = num_targets;
> rctx->streamout.append_bitmask = append_bitmask;
> --
> 2.5.0
>
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] st/omx: don't return early in vid_enc_EncodeFrame()

2016-04-29 Thread Alex Deucher
On Fri, Apr 29, 2016 at 8:56 AM, Emil Velikov  wrote:
> From: Emil Velikov 
>
> Earlier commit plugged a memory leak, although it missed a pair of
> brackets. Thus we unconditionally returned even in the case of no error.
>
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=95203
> Fixes: b87856d25d1 ("st/omx: Fix resource leak on OMX_ErrorNone")
> Cc: Andy Furniss 
> Cc: Robert Foss 
> Signed-off-by: Emil Velikov 
> ---
> What an embarassing bug - missing brackets. Andy can you confirm that it
> resolves the issue ?

Reviewed-by: Alex Deucher 


> ---
>  src/gallium/state_trackers/omx/vid_enc.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/src/gallium/state_trackers/omx/vid_enc.c 
> b/src/gallium/state_trackers/omx/vid_enc.c
> index de62166..5565241 100644
> --- a/src/gallium/state_trackers/omx/vid_enc.c
> +++ b/src/gallium/state_trackers/omx/vid_enc.c
> @@ -1151,9 +1151,10 @@ static OMX_ERRORTYPE 
> vid_enc_EncodeFrame(omx_base_PortType *port, OMX_BUFFERHEAD
> } else {
>/* --- load input image into video buffer  */
>err = enc_LoadImage(port, buf, task->buf);
> -  if (err != OMX_ErrorNone)
> +  if (err != OMX_ErrorNone) {
>   FREE(task);
>   return err;
> +  }
> }
>
> /* -- determine picture type - */
> --
> 2.6.2
>
> ___
> 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] [android-x86-devel] [RFC 7/7] android: support swrast

2016-04-29 Thread Emil Velikov
[Adding Mauro]

On 29 April 2016 at 14:25, Rob Herring  wrote:
> On Thu, Apr 28, 2016 at 2:35 AM, Chih-Wei Huang  
> wrote:
>> From: WuZhen 
>>
>> System boots up with gles_mesa/softpipe/llvmpipe.
>>
>> NO_REF_TASK
>> tested: local run
>>
>> Change-Id: I629ed0ca9fad12e32270eb8e8bfa9f7681b68474
>> Signed-off-by: Chih-Wei Huang 
>> ---
>>  Android.mk |   2 +-
>>  include/GL/internal/dri_interface.h|   9 +-
>>  src/egl/Android.mk |   1 +
>>  src/egl/drivers/dri2/egl_dri2.c|   1 +
>>  src/egl/drivers/dri2/platform_android.c| 386 
>> -
>>  src/gallium/Android.mk |   2 +-
>>  src/gallium/drivers/llvmpipe/Android.mk|  37 +++
>>  src/gallium/include/state_tracker/drm_driver.h |  10 +-
>>  src/gallium/state_trackers/dri/dri2.c  |   6 +-
>>  src/gallium/state_trackers/dri/drisw.c |  46 +++
>>  src/gallium/targets/dri/Android.mk |   8 +-
>>  src/gallium/winsys/sw/dri/Android.mk   |   2 +
>>  src/gallium/winsys/sw/dri/dri_sw_winsys.c  |  64 
>>  src/mesa/drivers/dri/common/dri_util.c |   4 +-
>>  src/mesa/drivers/dri/common/dri_util.h |   2 +-
>>  15 files changed, 555 insertions(+), 25 deletions(-)
>>  create mode 100644 src/gallium/drivers/llvmpipe/Android.mk
>
> I had started some work on this and needed some changes I don't see
> here. I didn't get beyond getting r600 to build though.
>
> I'm on AOSP master which probably means a different LLVM version.
> First, I had to enable several LLVM libs to build for the target and
> not just the host. In mesa, I had to set the LLVM version to 3.7 from
> 3.5, add libLLVMExecutionEngine to libmesa_nir and use libLLVM shared
> lib instead of r600 static libraries. I'm surprised similar changes
> aren't needed.
>
From memory Android-x86 (and/or Mauro) did have some LLVM and mesa (?)
changes to get LLVM and radeon(s) working. I think that most/all of
this work is over at github - https://github.com/maurossi

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


[Mesa-dev] [PATCH] mesa: simplify _mesa_Lightfv

2016-04-29 Thread Thomas Faller

Signed-off-by: Thomas Faller 
---
 src/mesa/main/light.c | 10 --
 1 file changed, 10 deletions(-)

diff --git a/src/mesa/main/light.c b/src/mesa/main/light.c
index 14b4b04..4a8dee3 100644
--- a/src/mesa/main/light.c
+++ b/src/mesa/main/light.c
@@ -250,17 +250,7 @@ _mesa_Lightfv( GLenum light, GLenum pname, const GLfloat 
*params )
   }
   break;
case GL_CONSTANT_ATTENUATION:
-  if (params[0] < 0.0F) {
-_mesa_error(ctx, GL_INVALID_VALUE, "glLight");
-return;
-  }
-  break;
case GL_LINEAR_ATTENUATION:
-  if (params[0] < 0.0F) {
-_mesa_error(ctx, GL_INVALID_VALUE, "glLight");
-return;
-  }
-  break;
case GL_QUADRATIC_ATTENUATION:
   if (params[0] < 0.0F) {
 _mesa_error(ctx, GL_INVALID_VALUE, "glLight");
--
2.5.0

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


Re: [Mesa-dev] [android-x86-devel] [RFC 0/7] android: enable llvmpipe for software rendering

2016-04-29 Thread Zhen Wu
Hi, Chih-Wei, Emil,
These series of patches was originally developed on the 11.0 branch,
and later ported to 11.2. I don't think softpipe was working when I worked
on this, Actually the first few patches is from when I tried to make
softpipe work. There are some memory issue in mesa that cause
softpipe/llvmpipe to crash when booting. I assumed it was due to jemalloc
and ptmalloc difference.
Regarding the TASK and Change-Id sections in the comment, sorry about
that. I should have removed them when I send out the patches, you can just
remove them.

2016-04-28 23:52 GMT+08:00 Chih-Wei Huang :

> 2016-04-28 22:22 GMT+08:00 Emil Velikov :
> > Hi Chih-Wei,
> >
> > Thanks for getting these out to the community.
> >
> > On 28 April 2016 at 08:34, Chih-Wei Huang 
> wrote:
> >> This is a series of patches developed by Jide Technolody to enable
> >> the llvmpipe for software rendering of Android.
> >> It makes a device without a Mesa supported GPU could run most modern
> >> Android apps.
> >>
> > Afaict one should only need the extra Android.mk files to get llvmpipe
> > considering that softpipe already works.
> > Have you/the Jide folks tried the latter already ? Does it work
> > without these patches ?
>
> Hmm, interesting point.
> Did you mean just adding Android.mk for llvmpipe
> is enough?
>
> >> These patches are mainly developed and tested on the 11.0 and 11.2
> >> branches. They might not work with the Mesa master branch.
> >>
> > Humble request - please always aim for master. Doing this will get you
> > the latest stable branch for free.
> > If you're targeting some old stable branch then you'll will have to
> > duplicate the effort to land things in master. And new functionality
> > goes _only_ in master
>
> I clearly understand this point.
> Actually I've spent several days to try to
> make it work on the master branch.
> That's why it was delayed -- I supposed to send them
> in the last week.
>
> However, the master branch is always broken for android.
> There are a lot of build break I need to fix and workaround
> or I can't test it. After fixed all the errors and built it OK,
> however, it didn't work as expected.
> The system boots to Home but all display is garbled.
> I'm not sure if I made some mistakes on
> fixing the building errors or there are some changes
> that really broke these patches.
> (the latest commit I've tried in the master is 32cb7d61)
> I finally decide to give it up and send them as the current status.
> (otherwise it will take too much of my time and delay
> my other pending tasks)
>
> Unfortunately the situation is most mesa developers
> don't care android so they usually break android build
> or functions. Unless the situation is changed it's very hard
> for us to follow the master branch closely.
>
> >> The patches depend on some patches developed by Varad Gautam which
> >> have not been merged in Mesa master yet, say
> >>
> >> fc40946 egl: fixup: define droid_image_loader_extension
> >> d15901d egl: android: populate dri2_surf->window early
> >> cff1928 egl: android: use __DRI_IMAGE_LOADER to get color buffers
> >> b556be4 egl: android: experimental dma-buf fd support
> >>
> >> The dependency may be removed but we haven't tested that yet.
> >>
> > Afaict none of Varad's work should be required here. It adds an
> > alternative (better) method of the already existing functionality.
>
> I also guess that but it need more time to verify that.
>
> > Related: iirc things have gone wrong during the rebase of Varad's work
> > in Android-x86. Rob H recently sent some patches (based of Android-x86
> > ?) which has some strange/extra code in them.
>
> Yes I notice that but again it need time
> to figure what patches are really needed.
> However due to the master branch status is horrible
> for android so I gave up.
>
> If possible, I'll ask Mauro to follow the master branch
> and work with others to fix android stuff
> for future android release (i.e., N).
> For marshmallow-x86 we will stay in mesa 11.2
> and I'll move my time to other pending tasks
> for a stable release.
>
> >> WuZhen (7):
> >>   st/dri: fix double free of dri_drawable
> >>   tgsi: fix stack allocated struct may not be initialized
> >>   gallium/swrast: fix dri_sw_dt->data free func not matching alloc func
> >>   android: print debug info to logcat
> >>   android: enable dlopen
> >>   android: enable x86 asm and sse4 for x86 and x86_64
> >>   android: support swrast
> >
> > A couple of high level suggestions:
> >  - Please split patches appropriately (more). Some patches are great
> > while others should become 3-4 separate ones.
>
> Actually I think the first 6 patches are already good.
> The 7th patch is bigger and could probably be split.
> Could you suggest how to do it?
>
> >  - Drop the NO_REF_TASK, tested and Change-Id tags. Sadly these don't
> > bring much, plus non-Jide people are unlikely to have access to the
> > Gerrit and other instances where these are used.
>
> These are Jide's internal comments 

Re: [Mesa-dev] [android-x86-devel] [RFC 0/7] android: enable llvmpipe for software rendering

2016-04-29 Thread Zhen Wu
Thanks for taking the time to review, Emil. We're happy to contribute to
the community, I'll will work with Chih-Wei and try to incorporate the
comments.

2016-04-29 19:16 GMT+08:00 Emil Velikov :

> Hi Zhen Wu, all,
>
> On 29 April 2016 at 04:12, Zhen Wu  wrote:
> > Hi, Chih-Wei, Emil,
> > These series of patches was originally developed on the 11.0 branch,
> and
> > later ported to 11.2. I don't think softpipe was working when I worked on
> > this, Actually the first few patches is from when I tried to make
> softpipe
> > work. There are some memory issue in mesa that cause softpipe/llvmpipe to
> > crash when booting. I assumed it was due to jemalloc and ptmalloc
> > difference.
> Was that on a 32bit platform with SSE enabled ? If so take a look the
> -mstackrealign suggestion.
>
> > Regarding the TASK and Change-Id sections in the comment, sorry about
> > that. I should have removed them when I send out the patches, you can
> just
> > remove them.
> >
> Ack. Thanks. I'll drop them from the patches that don't need to be
> respinned.
>
> Note that we do encourage references to public discussions though -
> bugzilla and/or mailing-list ones.
>
>
> > 2016-04-28 23:52 GMT+08:00 Chih-Wei Huang :
> >>
> >> 2016-04-28 22:22 GMT+08:00 Emil Velikov :
> >> > Hi Chih-Wei,
> >> >
> >> > Thanks for getting these out to the community.
> >> >
> >> > On 28 April 2016 at 08:34, Chih-Wei Huang 
> >> > wrote:
> >> >> This is a series of patches developed by Jide Technolody to enable
> >> >> the llvmpipe for software rendering of Android.
> >> >> It makes a device without a Mesa supported GPU could run most modern
> >> >> Android apps.
> >> >>
> >> > Afaict one should only need the extra Android.mk files to get llvmpipe
> >> > considering that softpipe already works.
> >> > Have you/the Jide folks tried the latter already ? Does it work
> >> > without these patches ?
> >>
> >> Hmm, interesting point.
> >> Did you mean just adding Android.mk for llvmpipe
> >> is enough?
> >>
> In theory at least. I've not seen anything that should be Android
> specific in there - we only have a very small set of windows
> specifics.
>
> >> >> These patches are mainly developed and tested on the 11.0 and 11.2
> >> >> branches. They might not work with the Mesa master branch.
> >> >>
> >> > Humble request - please always aim for master. Doing this will get you
> >> > the latest stable branch for free.
> >> > If you're targeting some old stable branch then you'll will have to
> >> > duplicate the effort to land things in master. And new functionality
> >> > goes _only_ in master
> >>
> >> I clearly understand this point.
> >> Actually I've spent several days to try to
> >> make it work on the master branch.
> >> That's why it was delayed -- I supposed to send them
> >> in the last week.
> >>
> >> However, the master branch is always broken for android.
> >> There are a lot of build break I need to fix and workaround
> >> or I can't test it. After fixed all the errors and built it OK,
> >> however, it didn't work as expected.
> >> The system boots to Home but all display is garbled.
> >> I'm not sure if I made some mistakes on
> >> fixing the building errors or there are some changes
> >> that really broke these patches.
> >> (the latest commit I've tried in the master is 32cb7d61)
> >> I finally decide to give it up and send them as the current status.
> >> (otherwise it will take too much of my time and delay
> >> my other pending tasks)
> >>
> As voiced by others - if there's a bot that tests (build and/or
> runtime) things that would be really good and appreciated.
> Although by the sounds of it the issues are mostly run-time ones,
> correct ? In this case I'd suggest bisecting and/or fleshing out
> sample program(s). This way devs will spend time fixing the issues and
> not setting up Android build setup, VM or alike.
>
> >> Unfortunately the situation is most mesa developers
> >> don't care android so they usually break android build
> >> or functions. Unless the situation is changed it's very hard
> >> for us to follow the master branch closely.
> >>
> Linux is the major player here thus people prioritise for it. It's not
> that they don't care about bugs - they do. They rarely have time for
> the extra setup required for Android development.
>
> >> >> The patches depend on some patches developed by Varad Gautam which
> >> >> have not been merged in Mesa master yet, say
> >> >>
> >> >> fc40946 egl: fixup: define droid_image_loader_extension
> >> >> d15901d egl: android: populate dri2_surf->window early
> >> >> cff1928 egl: android: use __DRI_IMAGE_LOADER to get color buffers
> >> >> b556be4 egl: android: experimental dma-buf fd support
> >> >>
> >> >> The dependency may be removed but we haven't tested that yet.
> >> >>
> >> > Afaict none of Varad's work should be required here. It adds an
> >> > alternative (better) method of the already existing functionality.
> >>
> >> I also guess that but it need more time to verify that.
> >

[Mesa-dev] [PATCH 35/65] glsl: add support for serialising image types

2016-04-29 Thread Timothy Arceri
---
 src/compiler/glsl/shader_cache.cpp | 8 
 1 file changed, 8 insertions(+)

diff --git a/src/compiler/glsl/shader_cache.cpp 
b/src/compiler/glsl/shader_cache.cpp
index 747df78..ee90157 100644
--- a/src/compiler/glsl/shader_cache.cpp
+++ b/src/compiler/glsl/shader_cache.cpp
@@ -85,6 +85,11 @@ encode_type_to_blob(struct blob *blob, const glsl_type *type)
   blob_write_string(blob, type->name);
   return;
case GLSL_TYPE_IMAGE:
+  encoding = (type->base_type) << 24 |
+ (type->sampler_dimensionality << 3) |
+ (type->sampler_array << 2) |
+ (type->sampled_type);
+  break;
case GLSL_TYPE_ATOMIC_UINT:
case GLSL_TYPE_STRUCT:
case GLSL_TYPE_INTERFACE:
@@ -120,6 +125,9 @@ decode_type_from_blob(struct blob_reader *blob)
case GLSL_TYPE_SUBROUTINE:
   return glsl_type::get_subroutine_instance(blob_read_string(blob));
case GLSL_TYPE_IMAGE:
+  return glsl_type::get_image_instance((enum glsl_sampler_dim) ((u >> 3) & 
0x07),
+ (u >> 2) & 0x01,
+ (glsl_base_type) ((u >> 0) & 
0x03));
case GLSL_TYPE_ATOMIC_UINT:
case GLSL_TYPE_STRUCT:
case GLSL_TYPE_INTERFACE:
-- 
2.5.5

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


[Mesa-dev] [PATCH 36/65] glsl: add support for serialising atomic and array types

2016-04-29 Thread Timothy Arceri
---
 src/compiler/glsl/shader_cache.cpp | 15 +--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/src/compiler/glsl/shader_cache.cpp 
b/src/compiler/glsl/shader_cache.cpp
index ee90157..ce23642 100644
--- a/src/compiler/glsl/shader_cache.cpp
+++ b/src/compiler/glsl/shader_cache.cpp
@@ -91,9 +91,15 @@ encode_type_to_blob(struct blob *blob, const glsl_type *type)
  (type->sampled_type);
   break;
case GLSL_TYPE_ATOMIC_UINT:
+  encoding = (type->base_type << 24);
+  break;
+   case GLSL_TYPE_ARRAY:
+  blob_write_uint32(blob, (type->base_type) << 24);
+  blob_write_uint32(blob, type->length);
+  encode_type_to_blob(blob, type->fields.array);
+  return;
case GLSL_TYPE_STRUCT:
case GLSL_TYPE_INTERFACE:
-   case GLSL_TYPE_ARRAY:
case GLSL_TYPE_VOID:
case GLSL_TYPE_ERROR:
default:
@@ -129,9 +135,14 @@ decode_type_from_blob(struct blob_reader *blob)
  (u >> 2) & 0x01,
  (glsl_base_type) ((u >> 0) & 
0x03));
case GLSL_TYPE_ATOMIC_UINT:
+  return glsl_type::atomic_uint_type;
+   case GLSL_TYPE_ARRAY: {
+  unsigned length = blob_read_uint32(blob);
+  return glsl_type::get_array_instance(decode_type_from_blob(blob),
+   length);
+   }
case GLSL_TYPE_STRUCT:
case GLSL_TYPE_INTERFACE:
-   case GLSL_TYPE_ARRAY:
case GLSL_TYPE_VOID:
case GLSL_TYPE_ERROR:
   assert(!"Cannot decode type!");
-- 
2.5.5

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


[Mesa-dev] [PATCH 42/65] glsl: don't cache shader if linking fails

2016-04-29 Thread Timothy Arceri
Fixes crash in piglit tests. The assumption is that linking was successful
if we see the linked program in the cache.
---
 src/mesa/program/ir_to_mesa.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp
index e950f9e..fa034ab 100644
--- a/src/mesa/program/ir_to_mesa.cpp
+++ b/src/mesa/program/ir_to_mesa.cpp
@@ -3032,7 +3032,8 @@ _mesa_glsl_link_shader(struct gl_context *ctx, struct 
gl_shader_program *prog,
}
 
 #ifdef ENABLE_SHADER_CACHE
-   shader_cache_write_program_metadata(ctx, prog);
+   if (prog->LinkStatus)
+  shader_cache_write_program_metadata(ctx, prog);
 #endif
 }
 
-- 
2.5.5

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


[Mesa-dev] [PATCH 38/65] glsl: cache interpolation qualifier for frag shader

2016-04-29 Thread Timothy Arceri
---
 src/compiler/glsl/shader_cache.cpp | 14 ++
 1 file changed, 14 insertions(+)

diff --git a/src/compiler/glsl/shader_cache.cpp 
b/src/compiler/glsl/shader_cache.cpp
index 6f09c17..ff94dbf 100644
--- a/src/compiler/glsl/shader_cache.cpp
+++ b/src/compiler/glsl/shader_cache.cpp
@@ -898,6 +898,13 @@ write_shader_metadata(struct blob *metadata, gl_shader 
*shader)
   blob_write_uint32(metadata, shader->num_samplers);
   blob_write_uint32(metadata, shader->active_samplers);
 
+  if (shader->Stage == MESA_SHADER_FRAGMENT) {
+ struct gl_fragment_program *fprog =
+(struct gl_fragment_program *) glprog;
+ blob_write_bytes(metadata, fprog->InterpQualifier,
+  sizeof(fprog->InterpQualifier));
+  }
+
   write_shader_parameters(metadata, glprog->Parameters);
 
} else {
@@ -928,6 +935,13 @@ read_shader_metadata(struct blob_reader *metadata,
   linked->num_samplers = blob_read_uint32(metadata);
   linked->active_samplers = blob_read_uint32(metadata);
 
+  if (linked->Stage == MESA_SHADER_FRAGMENT) {
+ struct gl_fragment_program *fprog =
+(struct gl_fragment_program *) glprog;
+ blob_copy_bytes(metadata, (uint8_t *) fprog->InterpQualifier,
+ sizeof(fprog->InterpQualifier));
+  }
+
   glprog->Parameters = _mesa_new_parameter_list();
 
   read_shader_parameters(metadata, glprog->Parameters);
-- 
2.5.5

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


[Mesa-dev] [PATCH 43/65] glsl: make uniform values helper available for use elsewhere

2016-04-29 Thread Timothy Arceri
---
 src/compiler/glsl/link_uniforms.cpp | 2 +-
 src/compiler/glsl/linker.h  | 3 +++
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/compiler/glsl/link_uniforms.cpp 
b/src/compiler/glsl/link_uniforms.cpp
index 8180d10..8c27030 100644
--- a/src/compiler/glsl/link_uniforms.cpp
+++ b/src/compiler/glsl/link_uniforms.cpp
@@ -45,7 +45,7 @@
 /**
  * Count the backing storage requirements for a type
  */
-static unsigned
+unsigned
 values_for_type(const glsl_type *type)
 {
if (type->is_sampler()) {
diff --git a/src/compiler/glsl/linker.h b/src/compiler/glsl/linker.h
index 3a0ec8b..f026732 100644
--- a/src/compiler/glsl/linker.h
+++ b/src/compiler/glsl/linker.h
@@ -83,6 +83,9 @@ void
 validate_interstage_uniform_blocks(struct gl_shader_program *prog,
gl_shader **stages, int num_stages);
 
+unsigned
+values_for_type(const glsl_type *type);
+
 extern void
 link_assign_atomic_counter_resources(struct gl_context *ctx,
  struct gl_shader_program *prog);
-- 
2.5.5

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


[Mesa-dev] [PATCH 32/65] glsl: add support for caching subroutines

2016-04-29 Thread Timothy Arceri
---
 src/compiler/glsl/shader_cache.cpp | 118 +
 1 file changed, 108 insertions(+), 10 deletions(-)

diff --git a/src/compiler/glsl/shader_cache.cpp 
b/src/compiler/glsl/shader_cache.cpp
index d2d1381..4599e5a 100644
--- a/src/compiler/glsl/shader_cache.cpp
+++ b/src/compiler/glsl/shader_cache.cpp
@@ -133,6 +133,60 @@ decode_type_from_blob(struct blob_reader *blob)
 }
 
 static void
+write_subroutines(struct blob *metadata, struct gl_shader_program *prog)
+{
+   for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) {
+  struct gl_shader *sh = prog->_LinkedShaders[i];
+  if (!sh)
+ continue;
+
+  blob_write_uint32(metadata, sh->NumSubroutineFunctions);
+  for (unsigned j = 0; j < sh->NumSubroutineFunctions; j++) {
+ int num_types = sh->SubroutineFunctions[j].num_compat_types;
+
+ blob_write_string(metadata, sh->SubroutineFunctions[j].name);
+ blob_write_uint32(metadata, sh->SubroutineFunctions[j].index);
+ blob_write_uint32(metadata, num_types);
+
+ for (int k = 0; k < num_types; k++) {
+encode_type_to_blob(metadata,
+sh->SubroutineFunctions[j].types[k]);
+ }
+  }
+   }
+}
+
+static void
+read_subroutines(struct blob_reader *metadata, struct gl_shader_program *prog)
+{
+   struct gl_subroutine_function *subs;
+
+   for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) {
+  struct gl_shader *sh = prog->_LinkedShaders[i];
+  if (!sh)
+ continue;
+
+  sh->NumSubroutineFunctions = blob_read_uint32(metadata);
+
+  subs = rzalloc_array(prog, struct gl_subroutine_function,
+   sh->NumSubroutineFunctions);
+  sh->SubroutineFunctions = subs;
+
+  for (unsigned j = 0; j < sh->NumSubroutineFunctions; j++) {
+ subs[j].name = ralloc_strdup(prog, blob_read_string (metadata));
+ subs[j].index = (int) blob_read_uint32(metadata);
+ subs[j].num_compat_types = (int) blob_read_uint32(metadata);
+
+ subs[j].types = rzalloc_array(prog, const struct glsl_type *,
+   subs[j].num_compat_types);
+ for (int k = 0; k < subs[j].num_compat_types; k++) {
+subs[j].types[k] = decode_type_from_blob(metadata);
+ }
+  }
+   }
+}
+
+static void
 write_uniforms(struct blob *metadata, struct gl_shader_program *prog)
 {
uint32_t i;
@@ -145,6 +199,8 @@ write_uniforms(struct blob *metadata, struct 
gl_shader_program *prog)
   printf("uniform %s %s\n",
  prog->UniformStorage[i].type->name,
  prog->UniformStorage[i].name);
+  encode_type_to_blob(metadata, prog->UniformStorage[i].type);
+
   blob_write_uint32(metadata, prog->UniformStorage[i].array_elements);
   blob_write_string(metadata, prog->UniformStorage[i].name);
   blob_write_uint32(metadata, prog->UniformStorage[i].storage -
@@ -164,8 +220,6 @@ write_uniforms(struct blob *metadata, struct 
gl_shader_program *prog)
   blob_write_uint32(metadata,
 prog->UniformStorage[i].top_level_array_stride);
 
-  encode_type_to_blob(metadata, prog->UniformStorage[i].type);
-
   blob_write_bytes(metadata, prog->UniformStorage[i].opaque,
sizeof(prog->UniformStorage[i].opaque));
}
@@ -193,6 +247,7 @@ read_uniforms(struct blob_reader *metadata, struct 
gl_shader_program *prog)
prog->UniformHash = new string_to_uint_map;
 
for (i = 0; i < prog->NumUniformStorage; i++) {
+  uniforms[i].type = decode_type_from_blob(metadata);
   uniforms[i].array_elements = blob_read_uint32(metadata);
   uniforms[i].name = ralloc_strdup(prog, blob_read_string (metadata));
   uniforms[i].storage = data + blob_read_uint32(metadata);
@@ -206,7 +261,6 @@ read_uniforms(struct blob_reader *metadata, struct 
gl_shader_program *prog)
   uniforms[i].num_compatible_subroutines = blob_read_uint32(metadata);
   uniforms[i].top_level_array_size = blob_read_uint32(metadata);
   uniforms[i].top_level_array_stride = blob_read_uint32(metadata);
-  uniforms[i].type = decode_type_from_blob(metadata);
 
   prog->UniformHash->put(i, uniforms[i].name);
 
@@ -326,10 +380,27 @@ read_hash_tables(struct blob_reader *metadata, struct 
gl_shader_program *prog)
 }
 
 static void
+write_shader_subroutine_index(struct blob *metadata, struct gl_shader *sh,
+  struct gl_program_resource *res)
+{
+   assert(sh);
+
+   for (unsigned j = 0; j < sh->NumSubroutineFunctions; j++) {
+  if (strcmp(((gl_subroutine_function *)res->Data)->name,
+ sh->SubroutineFunctions[j].name) == 0) {
+ blob_write_uint32(metadata, j);
+ break;
+  }
+   }
+}
+
+static void
 write_program_resource_data(struct blob *metadata,
 struct gl_shader_program *prog,
 struct gl_program_resource *res)
 {
+   struct gl_shader *sh

[Mesa-dev] [PATCH 44/65] glsl: cache uniform values

2016-04-29 Thread Timothy Arceri
These may be lowered constant arrays or uniform values that we set before 
linking
so we need to cache the actual uniform values.
---
 src/compiler/glsl/shader_cache.cpp | 31 +++
 1 file changed, 31 insertions(+)

diff --git a/src/compiler/glsl/shader_cache.cpp 
b/src/compiler/glsl/shader_cache.cpp
index f8c56ce..6fe89a7 100644
--- a/src/compiler/glsl/shader_cache.cpp
+++ b/src/compiler/glsl/shader_cache.cpp
@@ -419,12 +419,14 @@ write_uniforms(struct blob *metadata, struct 
gl_shader_program *prog)
   blob_write_string(metadata, prog->UniformStorage[i].name);
   blob_write_uint32(metadata, prog->UniformStorage[i].storage -
   prog->UniformDataSlots);
+  blob_write_uint32(metadata, prog->UniformStorage[i].builtin);
   blob_write_uint32(metadata, prog->UniformStorage[i].remap_location);
 
   blob_write_uint32(metadata, prog->UniformStorage[i].block_index);
   blob_write_uint32(metadata, prog->UniformStorage[i].atomic_buffer_index);
   blob_write_uint32(metadata, prog->UniformStorage[i].offset);
   blob_write_uint32(metadata, prog->UniformStorage[i].array_stride);
+  blob_write_uint32(metadata, prog->UniformStorage[i].hidden);
   blob_write_uint32(metadata, prog->UniformStorage[i].matrix_stride);
   blob_write_uint32(metadata, prog->UniformStorage[i].row_major);
   blob_write_uint32(metadata,
@@ -437,6 +439,21 @@ write_uniforms(struct blob *metadata, struct 
gl_shader_program *prog)
   blob_write_bytes(metadata, prog->UniformStorage[i].opaque,
sizeof(prog->UniformStorage[i].opaque));
}
+
+   /* Here we cache all uniform values. We do this to retain values for
+* uniforms with initialisers and also hidden uniforms that may be lowered
+* constant arrays. We could possibly just store the values we need but for
+* now we just store everything.
+*/
+   blob_write_uint32(metadata, prog->NumHiddenUniforms);
+   for (i = 0; i < prog->NumUniformStorage; i++) {
+  if (!prog->UniformStorage[i].builtin) {
+ unsigned vec_size = values_for_type(prog->UniformStorage[i].type) *
+MAX2(prog->UniformStorage[i].array_elements, 1);
+ blob_write_bytes(metadata, prog->UniformStorage[i].storage,
+  sizeof(union gl_constant_value) * vec_size);
+  }
+   }
 }
 
 static void
@@ -465,11 +482,13 @@ read_uniforms(struct blob_reader *metadata, struct 
gl_shader_program *prog)
   uniforms[i].array_elements = blob_read_uint32(metadata);
   uniforms[i].name = ralloc_strdup(prog, blob_read_string (metadata));
   uniforms[i].storage = data + blob_read_uint32(metadata);
+  uniforms[i].builtin = blob_read_uint32(metadata);
   uniforms[i].remap_location = blob_read_uint32(metadata);
   uniforms[i].block_index = blob_read_uint32(metadata);
   uniforms[i].atomic_buffer_index = blob_read_uint32(metadata);
   uniforms[i].offset = blob_read_uint32(metadata);
   uniforms[i].array_stride = blob_read_uint32(metadata);
+  uniforms[i].hidden = blob_read_uint32(metadata);
   uniforms[i].matrix_stride = blob_read_uint32(metadata);
   uniforms[i].row_major = blob_read_uint32(metadata);
   uniforms[i].num_compatible_subroutines = blob_read_uint32(metadata);
@@ -485,6 +504,18 @@ read_uniforms(struct blob_reader *metadata, struct 
gl_shader_program *prog)
   printf("uniform %d: %s %s\n",
  i, uniforms[i].type->name, uniforms[i].name);
}
+
+   /* Restore uniform values. */
+   prog->NumHiddenUniforms = blob_read_uint32(metadata);
+   for (i = 0; i < prog->NumUniformStorage; i++) {
+  if (!prog->UniformStorage[i].builtin) {
+ unsigned vec_size = values_for_type(prog->UniformStorage[i].type) *
+MAX2(prog->UniformStorage[i].array_elements, 1);
+ blob_copy_bytes(metadata,
+ (uint8_t *) prog->UniformStorage[i].storage,
+ sizeof(union gl_constant_value) * vec_size);
+  }
+   }
 }
 
 
-- 
2.5.5

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


[Mesa-dev] [PATCH 37/65] glsl: add support for caching atomic buffers

2016-04-29 Thread Timothy Arceri
---
 src/compiler/glsl/shader_cache.cpp | 87 ++
 1 file changed, 87 insertions(+)

diff --git a/src/compiler/glsl/shader_cache.cpp 
b/src/compiler/glsl/shader_cache.cpp
index ce23642..6f09c17 100644
--- a/src/compiler/glsl/shader_cache.cpp
+++ b/src/compiler/glsl/shader_cache.cpp
@@ -330,6 +330,77 @@ read_buffer_blocks(struct blob_reader *metadata,
 }
 
 static void
+write_atomic_buffers(struct blob *metadata, struct gl_shader_program *prog)
+{
+   blob_write_uint32(metadata, prog->NumAtomicBuffers);
+
+   for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) {
+  if (prog->_LinkedShaders[i]) {
+ blob_write_uint32(metadata,
+   prog->_LinkedShaders[i]->NumAtomicBuffers);
+  }
+   }
+
+   for (unsigned i = 0; i < prog->NumAtomicBuffers; i++) {
+  blob_write_uint32(metadata, prog->AtomicBuffers[i].Binding);
+  blob_write_uint32(metadata, prog->AtomicBuffers[i].MinimumSize);
+  blob_write_uint32(metadata, prog->AtomicBuffers[i].NumUniforms);
+
+  blob_write_bytes(metadata, prog->AtomicBuffers[i].StageReferences,
+   sizeof(prog->AtomicBuffers[i].StageReferences));
+
+  for (unsigned j = 0; j < prog->AtomicBuffers[i].NumUniforms; j++) {
+ blob_write_uint32(metadata, prog->AtomicBuffers[i].Uniforms[j]);
+  }
+   }
+}
+
+static void
+read_atomic_buffers(struct blob_reader *metadata,
+ struct gl_shader_program *prog)
+{
+   prog->NumAtomicBuffers = blob_read_uint32(metadata);
+   prog->AtomicBuffers =
+  rzalloc_array(prog, gl_active_atomic_buffer, prog->NumAtomicBuffers);
+
+   struct gl_active_atomic_buffer **stage_buff_list[MESA_SHADER_STAGES];
+   for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) {
+  if (prog->_LinkedShaders[i]) {
+ prog->_LinkedShaders[i]->NumAtomicBuffers =
+blob_read_uint32(metadata);
+ prog->_LinkedShaders[i]->AtomicBuffers =
+rzalloc_array(prog, gl_active_atomic_buffer *,
+  prog->_LinkedShaders[i]->NumAtomicBuffers);
+ stage_buff_list[i] = prog->_LinkedShaders[i]->AtomicBuffers;
+  }
+   }
+
+   for (unsigned i = 0; i < prog->NumAtomicBuffers; i++) {
+  prog->AtomicBuffers[i].Binding = blob_read_uint32(metadata);
+  prog->AtomicBuffers[i].MinimumSize = blob_read_uint32(metadata);
+  prog->AtomicBuffers[i].NumUniforms = blob_read_uint32(metadata);
+
+  blob_copy_bytes(metadata,
+  (uint8_t *) &prog->AtomicBuffers[i].StageReferences,
+  sizeof(prog->AtomicBuffers[i].StageReferences));
+
+  prog->AtomicBuffers[i].Uniforms =
+ rzalloc_array(prog, unsigned, prog->AtomicBuffers[i].NumUniforms);
+
+  for (unsigned j = 0; j < prog->AtomicBuffers[i].NumUniforms; j++) {
+ prog->AtomicBuffers[i].Uniforms[j] = blob_read_uint32(metadata);
+  }
+
+  for (unsigned j = 0; j < MESA_SHADER_STAGES; j++) {
+ if (prog->AtomicBuffers[i].StageReferences[j]) {
+*stage_buff_list[j] = &prog->AtomicBuffers[i];
+stage_buff_list[j]++;
+ }
+  }
+   }
+}
+
+static void
 write_uniforms(struct blob *metadata, struct gl_shader_program *prog)
 {
uint32_t i;
@@ -629,6 +700,15 @@ write_program_resource_data(struct blob *metadata,
  }
   }
   break;
+   case GL_ATOMIC_COUNTER_BUFFER:
+  for (unsigned i = 0; i < prog->NumAtomicBuffers; i++) {
+ if (((gl_active_atomic_buffer *)res->Data)->Binding ==
+ prog->AtomicBuffers[i].Binding) {
+blob_write_uint32(metadata, i);
+break;
+ }
+  }
+  break;
case GL_TRANSFORM_FEEDBACK_BUFFER:
case GL_TRANSFORM_FEEDBACK_VARYING:
   /* Don't bother caching transform feedback varyings/buffers as we will
@@ -692,6 +772,9 @@ read_program_resource_data(struct blob_reader *metadata,
case GL_UNIFORM:
   res->Data = &prog->UniformStorage[blob_read_uint32(metadata)];
   break;
+   case GL_ATOMIC_COUNTER_BUFFER:
+  res->Data = &prog->AtomicBuffers[blob_read_uint32(metadata)];
+  break;
case GL_VERTEX_SUBROUTINE:
   sh = prog->_LinkedShaders[MESA_SHADER_VERTEX];
   res->Data = &sh->SubroutineFunctions[blob_read_uint32(metadata)];
@@ -896,6 +979,8 @@ shader_cache_write_program_metadata(struct gl_context *ctx,
 
write_uniform_remap_tables(metadata, prog);
 
+   write_atomic_buffers(metadata, prog);
+
write_buffer_blocks(metadata, prog);
 
write_subroutines(metadata, prog);
@@ -1008,6 +1093,8 @@ shader_cache_read_program_metadata(struct gl_context *ctx,
 
read_uniform_remap_tables(&metadata, prog);
 
+   read_atomic_buffers(&metadata, prog);
+
read_buffer_blocks(&metadata, prog);
 
read_subroutines(&metadata, prog);
-- 
2.5.5

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


[Mesa-dev] [PATCH 31/65] glsl: add cache support for encoding subroutine type

2016-04-29 Thread Timothy Arceri
---
 src/compiler/glsl/shader_cache.cpp | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/src/compiler/glsl/shader_cache.cpp 
b/src/compiler/glsl/shader_cache.cpp
index 9c7b18d..d2d1381 100644
--- a/src/compiler/glsl/shader_cache.cpp
+++ b/src/compiler/glsl/shader_cache.cpp
@@ -79,6 +79,11 @@ encode_type_to_blob(struct blob *blob, const glsl_type *type)
  (type->sampler_array << 2) |
  (type->sampled_type);
   break;
+   case GLSL_TYPE_SUBROUTINE:
+  encoding = type->base_type << 24;
+  blob_write_uint32(blob, encoding);
+  blob_write_string(blob, type->name);
+  return;
case GLSL_TYPE_IMAGE:
case GLSL_TYPE_ATOMIC_UINT:
case GLSL_TYPE_STRUCT:
@@ -112,6 +117,8 @@ decode_type_from_blob(struct blob_reader *blob)
  (u >> 3) & 0x01,
  (u >> 2) & 0x01,
  (glsl_base_type) ((u >> 0) & 
0x03));
+   case GLSL_TYPE_SUBROUTINE:
+  return glsl_type::get_subroutine_instance(blob_read_string(blob));
case GLSL_TYPE_IMAGE:
case GLSL_TYPE_ATOMIC_UINT:
case GLSL_TYPE_STRUCT:
-- 
2.5.5

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


[Mesa-dev] [PATCH 34/65] glsl: add shader cache support for buffer blocks

2016-04-29 Thread Timothy Arceri
---
 src/compiler/glsl/shader_cache.cpp | 152 +
 1 file changed, 152 insertions(+)

diff --git a/src/compiler/glsl/shader_cache.cpp 
b/src/compiler/glsl/shader_cache.cpp
index f9b2157..747df78 100644
--- a/src/compiler/glsl/shader_cache.cpp
+++ b/src/compiler/glsl/shader_cache.cpp
@@ -187,6 +187,130 @@ read_subroutines(struct blob_reader *metadata, struct 
gl_shader_program *prog)
 }
 
 static void
+write_buffer_block(struct blob *metadata, struct gl_uniform_block *b)
+{
+   blob_write_string(metadata, b->Name);
+   blob_write_uint32(metadata, b->NumUniforms);
+   blob_write_uint32(metadata, b->Binding);
+   blob_write_uint32(metadata, b->UniformBufferSize);
+   blob_write_uint32(metadata, b->stageref);
+
+   for (unsigned j = 0; j < b->NumUniforms; j++) {
+  blob_write_string(metadata, b->Uniforms[j].Name);
+  blob_write_string(metadata, b->Uniforms[j].IndexName);
+  encode_type_to_blob(metadata, b->Uniforms[j].Type);
+  blob_write_uint32(metadata, b->Uniforms[j].Offset);
+   }
+}
+
+static void
+write_buffer_blocks(struct blob *metadata, struct gl_shader_program *prog)
+{
+   blob_write_uint32(metadata, prog->NumUniformBlocks);
+   blob_write_uint32(metadata, prog->NumShaderStorageBlocks);
+
+   for (unsigned i = 0; i < prog->NumUniformBlocks; i++) {
+  write_buffer_block(metadata, &prog->UniformBlocks[i]);
+   }
+
+   for (unsigned i = 0; i < prog->NumShaderStorageBlocks; i++) {
+  write_buffer_block(metadata, &prog->ShaderStorageBlocks[i]);
+   }
+
+   for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) {
+  struct gl_shader *sh = prog->_LinkedShaders[i];
+  if (!sh)
+ continue;
+
+  blob_write_uint32(metadata, sh->NumUniformBlocks);
+  blob_write_uint32(metadata, sh->NumShaderStorageBlocks);
+   }
+}
+
+static void
+read_buffer_block(struct blob_reader *metadata, struct gl_uniform_block *b,
+  struct gl_shader_program *prog)
+{
+  b->Name = ralloc_strdup(prog, blob_read_string (metadata));
+  b->NumUniforms = blob_read_uint32(metadata);
+  b->Binding = blob_read_uint32(metadata);
+  b->UniformBufferSize = blob_read_uint32(metadata);
+  b->stageref = blob_read_uint32(metadata);
+
+  b->Uniforms = rzalloc_array(prog, struct gl_uniform_buffer_variable,
+  b->NumUniforms);
+  for (unsigned j = 0; j < b->NumUniforms; j++) {
+ b->Uniforms[j].Name = ralloc_strdup(prog,
+ blob_read_string (metadata));
+
+ char *index_name = blob_read_string(metadata);
+ if (strcmp(b->Uniforms[j].Name, index_name) == 0) {
+b->Uniforms[j].IndexName = b->Uniforms[j].Name;
+ } else {
+b->Uniforms[j].IndexName = ralloc_strdup(prog, index_name);
+ }
+
+ b->Uniforms[j].Type = decode_type_from_blob(metadata);
+ b->Uniforms[j].Offset = blob_read_uint32(metadata);
+  }
+}
+
+static void
+read_buffer_blocks(struct blob_reader *metadata,
+   struct gl_shader_program *prog)
+{
+   prog->NumUniformBlocks = blob_read_uint32(metadata);
+   prog->NumShaderStorageBlocks = blob_read_uint32(metadata);
+
+   prog->UniformBlocks = rzalloc_array(prog, struct gl_uniform_block,
+   prog->NumUniformBlocks);
+
+   prog->ShaderStorageBlocks = rzalloc_array(prog, struct gl_uniform_block,
+ prog->NumShaderStorageBlocks);
+
+   for (unsigned i = 0; i < prog->NumUniformBlocks; i++) {
+  read_buffer_block(metadata, &prog->UniformBlocks[i], prog);
+   }
+
+   for (unsigned i = 0; i < prog->NumShaderStorageBlocks; i++) {
+  read_buffer_block(metadata, &prog->ShaderStorageBlocks[i], prog);
+   }
+
+   for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) {
+  struct gl_shader *sh = prog->_LinkedShaders[i];
+  if (!sh)
+ continue;
+
+  sh->NumUniformBlocks = blob_read_uint32(metadata);
+  sh->NumShaderStorageBlocks = blob_read_uint32(metadata);
+
+  sh->UniformBlocks =
+ rzalloc_array(prog, gl_uniform_block *, sh->NumUniformBlocks);
+  sh->ShaderStorageBlocks =
+ rzalloc_array(prog, gl_uniform_block *, sh->NumShaderStorageBlocks);
+
+  unsigned ubo_count = 0;
+  for (unsigned j = 0; j < prog->NumUniformBlocks; j++) {
+ if (prog->UniformBlocks[j].stageref & 1 << i) {
+sh->UniformBlocks[ubo_count] = &prog->UniformBlocks[j];
+ubo_count++;
+ }
+  }
+  assert(sh->NumUniformBlocks == ubo_count);
+
+  unsigned ssbo_count = 0;
+  for (unsigned j = 0; j < prog->NumShaderStorageBlocks; j++) {
+ if (prog->ShaderStorageBlocks[j].stageref & 1 << i) {
+sh->ShaderStorageBlocks[ssbo_count] =
+   &prog->ShaderStorageBlocks[j];
+ssbo_count++;
+ }
+  }
+  assert(sh->NumShaderStorageBlocks == ssbo_count);
+   }
+}
+
+static void
 writ

[Mesa-dev] [PATCH 33/65] glsl: store subroutine remap table in shader cache

2016-04-29 Thread Timothy Arceri
---
 src/compiler/glsl/shader_cache.cpp | 53 --
 1 file changed, 45 insertions(+), 8 deletions(-)

diff --git a/src/compiler/glsl/shader_cache.cpp 
b/src/compiler/glsl/shader_cache.cpp
index 4599e5a..f9b2157 100644
--- a/src/compiler/glsl/shader_cache.cpp
+++ b/src/compiler/glsl/shader_cache.cpp
@@ -275,8 +275,8 @@ read_uniforms(struct blob_reader *metadata, struct 
gl_shader_program *prog)
 
 
 static void
-write_uniform_remap_table(struct blob *metadata,
-  struct gl_shader_program *prog)
+write_uniform_remap_tables(struct blob *metadata,
+   struct gl_shader_program *prog)
 {
blob_write_intptr(metadata, (intptr_t) prog->UniformStorage);
blob_write_uint32(metadata, prog->NumUniformRemapTable);
@@ -284,11 +284,23 @@ write_uniform_remap_table(struct blob *metadata,
for (unsigned i = 0; i < prog->NumUniformRemapTable; i++) {
   blob_write_intptr(metadata, (intptr_t) prog->UniformRemapTable[i]);
}
+
+   for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) {
+  struct gl_shader *sh = prog->_LinkedShaders[i];
+  if (sh) {
+ blob_write_uint32(metadata, sh->NumSubroutineUniformRemapTable);
+
+ for (unsigned j = 0; j < sh->NumSubroutineUniformRemapTable; j++) {
+blob_write_intptr(metadata,
+  (intptr_t) sh->SubroutineUniformRemapTable[j]);
+ }
+  }
+   }
 }
 
 static void
-read_uniform_remap_table(struct blob_reader *metadata,
- struct gl_shader_program *prog)
+read_uniform_remap_tables(struct blob_reader *metadata,
+  struct gl_shader_program *prog)
 {
intptr_t uni_store_base = blob_read_intptr(metadata);
prog->NumUniformRemapTable = blob_read_uint32(metadata);
@@ -307,6 +319,31 @@ read_uniform_remap_table(struct blob_reader *metadata,
  prog->UniformRemapTable[i] = prog->UniformStorage + uni_offset;
   }
}
+
+   for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) {
+  struct gl_shader *sh = prog->_LinkedShaders[i];
+  if (sh) {
+ sh->NumSubroutineUniformRemapTable = blob_read_uint32(metadata);
+
+ sh->SubroutineUniformRemapTable =
+rzalloc_array(sh, struct gl_uniform_storage *,
+  sh->NumSubroutineUniformRemapTable);
+
+ for (unsigned j = 0; j < sh->NumSubroutineUniformRemapTable; j++) {
+intptr_t uni_ptr = blob_read_intptr(metadata);
+if (uni_ptr == (intptr_t) INACTIVE_UNIFORM_EXPLICIT_LOCATION ||
+uni_ptr == (intptr_t) NULL) {
+   sh->SubroutineUniformRemapTable[j] =
+  (gl_uniform_storage *) uni_ptr;
+} else {
+   intptr_t uni_offset =
+  (uni_ptr - uni_store_base) / sizeof(gl_uniform_storage);
+   sh->SubroutineUniformRemapTable[j] =
+  prog->UniformStorage + uni_offset;
+}
+ }
+  }
+   }
 }
 
 struct whte_closure
@@ -687,11 +724,11 @@ shader_cache_write_program_metadata(struct gl_context 
*ctx,
 
write_hash_tables(metadata, prog);
 
-   write_uniform_remap_table(metadata, prog);
-
write_shader_metadata(metadata, prog->_LinkedShaders[MESA_SHADER_VERTEX]);
write_shader_metadata(metadata, prog->_LinkedShaders[MESA_SHADER_FRAGMENT]);
 
+   write_uniform_remap_tables(metadata, prog);
+
write_subroutines(metadata, prog);
 
write_program_resource_list(metadata, prog);
@@ -786,8 +823,6 @@ shader_cache_read_program_metadata(struct gl_context *ctx,
 
read_hash_tables(&metadata, prog);
 
-   read_uniform_remap_table(&metadata, prog);
-
linked = ctx->Driver.NewShader(NULL, 0, GL_VERTEX_SHADER);
glprog = ctx->Driver.NewProgram(ctx, GL_VERTEX_PROGRAM_ARB, prog->Name);
read_shader_metadata(&metadata, glprog, linked);
@@ -802,6 +837,8 @@ shader_cache_read_program_metadata(struct gl_context *ctx,
_mesa_reference_shader(ctx, &prog->_LinkedShaders[MESA_SHADER_FRAGMENT],
   linked);
 
+   read_uniform_remap_tables(&metadata, prog);
+
read_subroutines(&metadata, prog);
 
read_program_resource_list(&metadata, prog);
-- 
2.5.5

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


Re: [Mesa-dev] gstreamer: v4l2videodec plugin

2016-04-29 Thread Stanimir Varbanov
cc: mesa-dev ML

On 04/28/2016 02:33 PM, Stanimir Varbanov wrote:
> On 04/15/2016 07:09 PM, Nicolas Dufresne wrote:
>> Le vendredi 15 avril 2016 à 11:58 -0400, Rob Clark a écrit :
>>> The issue is probably the YUV format, which we cannot really deal
>>> with
>>> properly in gallium..  it's a similar issue to multi-planer even if
>>> it
>>> is in a single buffer.
>>>
>>> The best way to handle this would be to import the same dmabuf fd
>>> twice, with appropriate offsets, to create one GL_RED eglimage for Y
>>> and one GL_RG eglimage for UV, and then combine them in shader in a
>>> similar way to how you'd handle separate Y and UV planes..
>>
>> That's the strategy we use in GStreamer, as very few GL stack support
>> implicit color conversions. For that to work you need to implement the
>> "offset" field in winsys_handle, that was added recently, and make sure
>> you have R8 and RG88 support (usually this is just mapping).
> 
> Thanks,
> 
> OK, I have made the relevant changes in Mesa and now I have image but
> the U and V components are swapped (the format is NV12, the UV plane is
> at the same buffer but at offset). Digging further and tracing gstreamer
> with apitrace I'm observing something weird.
> 
> The gst import dmabuf with following call:
> 
> eglCreateImageKHR(dpy = 0x7fa8013030, ctx = NULL, target =
> EGL_LINUX_DMA_BUF_EXT, buffer = NULL, attrib_list = {EGL_WIDTH, 640,
> EGL_HEIGHT, 360, EGL_LINUX_DRM_FOURCC_EXT, 943215175,
> EGL_DMA_BUF_PLANE0_FD_EXT, 29, EGL_DMA_BUF_PLANE0_OFFSET_EXT, 942080,
> EGL_DMA_BUF_PLANE0_PITCH_EXT, 1280, EGL_NONE}) = 0x7f980027d0
> 
> the fourcc format is DRM_FORMAT_GR88 (943215175 decimal).
> 
> after that:
> 
> glTexImage2D(target = GL_TEXTURE_2D, level = 0, internalformat = GL_RG8,
> width = 640, height = 360, border = 0, format = GL_RG, type =
> GL_UNSIGNED_BYTE, pixels = NULL)
> 
> and finally on the fragment shader we have:
> 
> yuv.x=texture2D(Ytex, texcoord * tex_scale0).r;
> yuv.yz=texture2D(UVtex, texcoord * tex_scale1).rg;
> 
> I was expecting to see DRM_FORMAT_RG88 / GL_RG and shader sampling
> y <- r
> z <- g
> 
> or DRM_FORMAT_GR88 / GL_RG and shader sampling
> y <- g
> z <- r
> 
> Also, browsing the code in Mesa for Intel i965 dri driver I found where
> the __DRI_IMAGE_FORMAT_GR88 becomes MESA_FORMAT_R8G8_UNORM [1].
> 
> So I'm wondering is that intensional?
> 
> Depending on the answer I should make the same in the Gallium dri2 in
> dri2_from_dma_bufs().
> 
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 63/65] i965: get scratch on cache restore

2016-04-29 Thread Timothy Arceri
---
 src/mesa/drivers/dri/i965/brw_shader_cache.c | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/src/mesa/drivers/dri/i965/brw_shader_cache.c 
b/src/mesa/drivers/dri/i965/brw_shader_cache.c
index ac381d1..5d47122 100644
--- a/src/mesa/drivers/dri/i965/brw_shader_cache.c
+++ b/src/mesa/drivers/dri/i965/brw_shader_cache.c
@@ -239,6 +239,11 @@ upload_cached_program(struct brw_context *brw)
 
vs_key.program_string_id = vp->id;
 
+   if (prog_data->total_scratch) {
+  brw_get_scratch_bo(brw, &brw->vs.base.scratch_bo,
+ prog_data->total_scratch * brw->max_vs_threads);
+   }
+
brw_upload_cache(&brw->cache, BRW_CACHE_VS_PROG,
 &vs_key, sizeof(struct brw_vs_prog_key),
 vs_program, vs_program_size,
@@ -343,6 +348,11 @@ upload_cached_program(struct brw_context *brw)
 
wm_key.program_string_id = wp->id;
 
+   if (prog_data->total_scratch) {
+  brw_get_scratch_bo(brw, &brw->wm.base.scratch_bo,
+ prog_data->total_scratch * brw->max_vs_threads);
+   }
+
brw_upload_cache(&brw->cache, BRW_CACHE_FS_PROG,
 &wm_key, sizeof(struct brw_wm_prog_key),
 wm_program, wm_program_size,
-- 
2.5.5

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


[Mesa-dev] [PATCH 65/65] i965: track mesa version shader cache items were created with

2016-04-29 Thread Timothy Arceri
Also remove cache item and fallback to full recompile if current Mesa
version differs.
---
 src/mesa/drivers/dri/i965/brw_shader_cache.c | 12 
 1 file changed, 12 insertions(+)

diff --git a/src/mesa/drivers/dri/i965/brw_shader_cache.c 
b/src/mesa/drivers/dri/i965/brw_shader_cache.c
index 105b8ef..5258f04 100644
--- a/src/mesa/drivers/dri/i965/brw_shader_cache.c
+++ b/src/mesa/drivers/dri/i965/brw_shader_cache.c
@@ -133,6 +133,16 @@ upload_cached_program(struct brw_context *brw)
 
blob_reader_init(&binary, buffer, size);
 
+   char *version_string = blob_read_string(&binary);
+   if (strcmp(brw->ctx.VersionString, version_string) != 0) {
+  /* The cached version of the program was created with a different
+   * version of Mesa so remove it and fallback to full recompile.
+   */
+  printf("binary was created with incompatible mesa version\n");
+  cache_remove(cache, brw->binary_sha1);
+  goto FAIL;
+   }
+
/* Read VS program from blob. */
vs_program_size = blob_read_uint32(&binary);
 
@@ -469,6 +479,8 @@ write_cached_program(struct brw_context *brw)
struct brw_wm_prog_key wm_key;
gen_binary_sha1(brw, prog, &vs_key, &wm_key);
 
+   blob_write_string(binary, brw->ctx.VersionString);
+
/* Write VS program to blob. */
vs_program_size = brw->vs.prog_data->program_size;
 
-- 
2.5.5

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


[Mesa-dev] [PATCH 62/65] i965: generate outputs written for use in fs key

2016-04-29 Thread Timothy Arceri
This is normally generated at link time so we need to do it ourselves
for use with the shader cache.
---
 src/mesa/drivers/dri/i965/brw_shader_cache.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/src/mesa/drivers/dri/i965/brw_shader_cache.c 
b/src/mesa/drivers/dri/i965/brw_shader_cache.c
index 5de261c..ac381d1 100644
--- a/src/mesa/drivers/dri/i965/brw_shader_cache.c
+++ b/src/mesa/drivers/dri/i965/brw_shader_cache.c
@@ -47,6 +47,7 @@ gen_binary_sha1(struct brw_context *brw, struct 
gl_shader_program *prog,
unsigned char sha1[20];
char manifest[256];
int offset = 0;
+   struct gl_program *vs = (struct gl_program *) brw->vertex_program;
 
offset += snprintf(manifest + offset, sizeof(manifest) - offset,
   "program: %s\n", _mesa_sha1_format(sha1_buf, 
prog->sha1));
@@ -57,12 +58,19 @@ gen_binary_sha1(struct brw_context *brw, struct 
gl_shader_program *prog,
offset += snprintf(manifest + offset, sizeof(manifest) - offset,
   "vs_key: %s\n", _mesa_sha1_format(sha1_buf, sha1));
 
+   GLbitfield64 current_valid = brw->vue_map_geom_out.slots_valid;
+   GLbitfield64 outputs_written =
+  brw_vs_outputs_written(brw, vs_key, vs->OutputsWritten);
+   brw->vue_map_geom_out.slots_valid = outputs_written;
+
brw_wm_populate_key(brw, wm_key);
wm_key->program_string_id = 0;
_mesa_sha1_compute(wm_key, sizeof *wm_key, sha1);
offset += snprintf(manifest + offset, sizeof(manifest) - offset,
   "wm_key: %s\n", _mesa_sha1_format(sha1_buf, sha1));
 
+   brw->vue_map_geom_out.slots_valid = current_valid;
+
_mesa_sha1_compute(manifest, strlen(manifest), brw->binary_sha1);
 
 }
-- 
2.5.5

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


[Mesa-dev] [PATCH 64/65] i965: copy and restore sampler units when doing full relink

2016-04-29 Thread Timothy Arceri
If we don't find the program in the cache we need to make sure to
store the current sampler units and restore them after falling back
to relinking.

In this change we also avoid reseting the sampler and image units
stored in gl_shader back to 0 during relinking.
---
 src/compiler/glsl/link_uniforms.cpp  |  6 --
 src/mesa/drivers/dri/i965/brw_shader_cache.c | 24 
 2 files changed, 28 insertions(+), 2 deletions(-)

diff --git a/src/compiler/glsl/link_uniforms.cpp 
b/src/compiler/glsl/link_uniforms.cpp
index fc566ac..c791eea 100644
--- a/src/compiler/glsl/link_uniforms.cpp
+++ b/src/compiler/glsl/link_uniforms.cpp
@@ -1033,8 +1033,10 @@ link_assign_uniform_locations(struct gl_shader_program 
*prog,
* initializer, if present, or 0 if no initializer is present. 
Sampler
* types cannot have initializers."
*/
-  memset(sh->SamplerUnits, 0, sizeof(sh->SamplerUnits));
-  memset(sh->ImageUnits, 0, sizeof(sh->ImageUnits));
+  if (!skip_cache) {
+ memset(sh->SamplerUnits, 0, sizeof(sh->SamplerUnits));
+ memset(sh->ImageUnits, 0, sizeof(sh->ImageUnits));
+  }
 
   link_update_uniform_buffer_variables(sh);
 
diff --git a/src/mesa/drivers/dri/i965/brw_shader_cache.c 
b/src/mesa/drivers/dri/i965/brw_shader_cache.c
index 5d47122..105b8ef 100644
--- a/src/mesa/drivers/dri/i965/brw_shader_cache.c
+++ b/src/mesa/drivers/dri/i965/brw_shader_cache.c
@@ -39,6 +39,14 @@
 #include "brw_context.h"
 
 static void
+copy_sampler_units(struct gl_shader_program *shProg, unsigned stage,
+   GLubyte *SamplerUnits)
+{
+  struct gl_program *prog = shProg->_LinkedShaders[stage]->Program;
+  memcpy(SamplerUnits, prog->SamplerUnits, sizeof(prog->SamplerUnits));
+}
+
+static void
 gen_binary_sha1(struct brw_context *brw, struct gl_shader_program *prog,
 struct brw_vs_prog_key *vs_key,
 struct brw_wm_prog_key *wm_key)
@@ -381,6 +389,13 @@ FAIL:
if (brw->vertex_program->Base.nir == NULL) {
   struct gl_shader_program *prog =
  brw->ctx._Shader->CurrentProgram[MESA_SHADER_VERTEX];
+
+  /* Make a copy of the current sampler units */
+  GLubyte vSamplerUnits[MAX_SAMPLERS];
+  GLubyte fSamplerUnits[MAX_SAMPLERS];
+  copy_sampler_units(prog, MESA_SHADER_VERTEX, vSamplerUnits);
+  copy_sampler_units(prog, MESA_SHADER_FRAGMENT, fSamplerUnits);
+
   for (unsigned i = 0; i < prog->NumShaders; i++) {
  _mesa_glsl_compile_shader(&brw->ctx, prog->Shaders[i], false, false,
true);
@@ -394,12 +409,19 @@ FAIL:
   struct gl_program *fp =
  prog->_LinkedShaders[MESA_SHADER_FRAGMENT]->Program;
   brw->fragment_program = gl_fragment_program(fp);
+
+  memcpy(vp->SamplerUnits, vSamplerUnits, sizeof(vp->SamplerUnits));
+  memcpy(fp->SamplerUnits, fSamplerUnits, sizeof(fp->SamplerUnits));
}
 
if (brw->fragment_program->Base.nir == NULL) {
   struct gl_shader_program *prog =
  brw->ctx._Shader->_CurrentFragmentProgram;
 
+  /* Make a copy of the current sampler units */
+  GLubyte fSamplerUnits[MAX_SAMPLERS];
+  copy_sampler_units(prog, MESA_SHADER_FRAGMENT, fSamplerUnits);
+
   for (unsigned i = 0; i < prog->NumShaders; i++) {
  _mesa_glsl_compile_shader(&brw->ctx, prog->Shaders[i], false, false,
true);
@@ -409,6 +431,8 @@ FAIL:
   struct gl_program *fp =
  prog->_LinkedShaders[MESA_SHADER_FRAGMENT]->Program;
   brw->fragment_program = gl_fragment_program(fp);
+
+  memcpy(fp->SamplerUnits, fSamplerUnits, sizeof(fp->SamplerUnits));
}
 
free(buffer);
-- 
2.5.5

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


[Mesa-dev] [PATCH 49/65] i965: add image param shader cache support

2016-04-29 Thread Timothy Arceri
---
 src/mesa/drivers/dri/i965/brw_shader_cache.c | 60 +---
 1 file changed, 55 insertions(+), 5 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_shader_cache.c 
b/src/mesa/drivers/dri/i965/brw_shader_cache.c
index 7945b16..850e1e8 100644
--- a/src/mesa/drivers/dri/i965/brw_shader_cache.c
+++ b/src/mesa/drivers/dri/i965/brw_shader_cache.c
@@ -28,6 +28,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "brw_state.h"
 #include "brw_wm.h"
@@ -56,7 +57,8 @@ upload_cached_program(struct brw_context *brw)
size_t vs_prog_data_size, wm_prog_data_size;
intptr_t parameter_values_base;
intptr_t uniform_data_slots_base;
-   uint32_t nr_params, nr_pull_params;
+   intptr_t image_params_base;
+   uint32_t nr_params, nr_pull_params, nr_image_params;
 
cache = brw->ctx.Cache;
if (cache == NULL)
@@ -121,9 +123,31 @@ upload_cached_program(struct brw_context *brw)
printf("Allocating %d prog_data->params (%p)\n",
   prog_data->nr_params, prog_data->param);
 
+   nr_image_params = blob_read_uint32(&binary);
+   assert(nr_image_params == prog_data->nr_image_params);
+
+   prog_data->image_param = rzalloc_array(NULL, struct brw_image_param,
+  nr_image_params);
+
+   image_params_base = blob_read_intptr(&binary);
+
+   /* calculate image bounds */
+   unsigned image_upper_boundary = 0;
+   for (unsigned u = 0; u < prog->NumUniformStorage; u++) {
+  struct gl_uniform_storage *storage = &prog->UniformStorage[u];
+
+  if (storage->builtin)
+ continue;
+
+  if (glsl_get_base_type(storage->type) == GLSL_TYPE_IMAGE) {
+ image_upper_boundary +=
+BRW_IMAGE_PARAM_SIZE * MAX2(storage->array_elements, 1);
+  }
+   }
+
for (i = 0; i < nr_params; i++) {
   intptr_t param = blob_read_intptr(&binary);
-  ptrdiff_t p_offset, u_offset;
+  ptrdiff_t p_offset, u_offset, i_offset;
   struct gl_program_parameter_list *param_list =
  prog->_LinkedShaders[MESA_SHADER_VERTEX] ?
 prog->_LinkedShaders[MESA_SHADER_VERTEX]->Program->Parameters :
@@ -131,6 +155,7 @@ upload_cached_program(struct brw_context *brw)
 
   p_offset = (param - parameter_values_base) / sizeof(gl_constant_value);
   u_offset = (param - uniform_data_slots_base) / sizeof(gl_constant_value);
+  i_offset = (param - image_params_base) / sizeof(gl_constant_value);
   
   if (param_list && p_offset >= 0 &&
   p_offset < 4 * param_list->NumParameters) {
@@ -138,6 +163,9 @@ upload_cached_program(struct brw_context *brw)
 ((gl_constant_value *) param_list->ParameterValues) + p_offset;
   } else if (u_offset >= 0 && u_offset < prog->NumUniformDataSlots) {
  prog_data->param[i] = prog->UniformDataSlots + u_offset;
+  } else if (i_offset >= 0 && i_offset < image_upper_boundary) {
+ prog_data->param[i] =
+((gl_constant_value *) prog_data->image_param) + i_offset;
   } else {
  printf("Error: Failed to fixup vs pointer value %p\n", (void *) 
param);
  ralloc_free(prog_data->param);
@@ -160,6 +188,7 @@ upload_cached_program(struct brw_context *brw)
 
struct brw_vertex_program *vp =
   (struct brw_vertex_program *)brw->vertex_program;
+
brw_upload_cache(&brw->cache, BRW_CACHE_VS_PROG,
 &vs_key, sizeof(struct brw_vs_prog_key),
 vs_program, vs_program_size,
@@ -188,9 +217,17 @@ upload_cached_program(struct brw_context *brw)
printf("Allocating %d prog_data->params (%p)\n",
   prog_data->nr_params, prog_data->param);
 
+   nr_image_params = blob_read_uint32(&binary);
+   assert(nr_image_params == prog_data->nr_image_params);
+
+   prog_data->image_param = rzalloc_array(NULL, struct brw_image_param,
+  nr_image_params);
+
+   image_params_base = blob_read_intptr(&binary);
+
for (i = 0; i < nr_params; i++) {
   intptr_t param = blob_read_intptr(&binary);
-  ptrdiff_t p_offset, u_offset;
+  ptrdiff_t p_offset, u_offset, i_offset;
   struct gl_program_parameter_list *param_list =
  prog->_LinkedShaders[MESA_SHADER_FRAGMENT] ?
 prog->_LinkedShaders[MESA_SHADER_FRAGMENT]->Program->Parameters :
@@ -198,6 +235,7 @@ upload_cached_program(struct brw_context *brw)
 
   p_offset = (param - parameter_values_base) / sizeof(gl_constant_value);
   u_offset = (param - uniform_data_slots_base) / sizeof(gl_constant_value);
+  i_offset = (param - image_params_base) / sizeof(gl_constant_value);
   
   if (param_list && p_offset >= 0 &&
   p_offset < 4 * param_list->NumParameters) {
@@ -205,6 +243,9 @@ upload_cached_program(struct brw_context *brw)
 ((gl_constant_value *) param_list->ParameterValues) + p_offset;
   } else if (u_offset >= 0 && u_offset < prog->NumUniformDataSlots) {
  prog_data->param[i] = prog->UniformDataSlots + u_offset;
+   

[Mesa-dev] [PATCH 54/65] glsl: don't lose uniform values when falling back to full compile

2016-04-29 Thread Timothy Arceri
Here we skip the recreation of uniform storage if we are relinking
after a cache miss.
---
 src/compiler/glsl/link_uniforms.cpp  | 32 +---
 src/compiler/glsl/linker.cpp |  3 ++-
 src/compiler/glsl/linker.h   |  2 +-
 src/compiler/glsl/main.cpp   |  2 +-
 src/compiler/glsl/standalone_scaffolding.cpp |  3 ++-
 src/compiler/glsl/standalone_scaffolding.h   |  2 +-
 src/mesa/main/shaderobj.c|  9 
 src/mesa/main/shaderobj.h|  3 ++-
 src/mesa/program/ir_to_mesa.cpp  |  2 +-
 9 files changed, 39 insertions(+), 19 deletions(-)

diff --git a/src/compiler/glsl/link_uniforms.cpp 
b/src/compiler/glsl/link_uniforms.cpp
index 8c27030..fc566ac 100644
--- a/src/compiler/glsl/link_uniforms.cpp
+++ b/src/compiler/glsl/link_uniforms.cpp
@@ -995,11 +995,13 @@ void
 link_assign_uniform_locations(struct gl_shader_program *prog,
   unsigned int boolean_true,
   unsigned int num_explicit_uniform_locs,
-  unsigned int max_uniform_locs)
+  unsigned int max_uniform_locs, bool skip_cache)
 {
-   ralloc_free(prog->UniformStorage);
-   prog->UniformStorage = NULL;
-   prog->NumUniformStorage = 0;
+   if (!skip_cache) {
+  ralloc_free(prog->UniformStorage);
+  prog->UniformStorage = NULL;
+  prog->NumUniformStorage = 0;
+   }
 
if (prog->UniformHash != NULL) {
   prog->UniformHash->clear();
@@ -1074,10 +1076,17 @@ link_assign_uniform_locations(struct gl_shader_program 
*prog,
if (num_uniforms == 0)
   return;
 
-   struct gl_uniform_storage *uniforms =
-  rzalloc_array(prog, struct gl_uniform_storage, num_uniforms);
-   union gl_constant_value *data =
-  rzalloc_array(uniforms, union gl_constant_value, num_data_slots);
+   struct gl_uniform_storage *uniforms;
+   union gl_constant_value *data;
+
+   if (prog->UniformStorage == NULL) {
+  uniforms = rzalloc_array(prog, struct gl_uniform_storage, num_uniforms);
+  data = rzalloc_array(uniforms, union gl_constant_value, num_data_slots);
+   } else {
+  uniforms = prog->UniformStorage;
+  data = prog->UniformDataSlots;
+   }
+
 #ifndef NDEBUG
union gl_constant_value *data_end = &data[num_data_slots];
 #endif
@@ -1112,6 +1121,13 @@ link_assign_uniform_locations(struct gl_shader_program 
*prog,
  sizeof(prog->_LinkedShaders[i]->SamplerTargets));
}
 
+   /* If this is a fallback compile for a cache miss we already have the
+* correct uniform mappings and we don't want to reinitialise uniforms so
+* just return now.
+*/
+   if (skip_cache && prog->UniformStorage)
+  return;
+
/* Reserve all the explicit locations of the active uniforms. */
for (unsigned i = 0; i < num_uniforms; i++) {
   if (uniforms[i].type->is_subroutine() ||
diff --git a/src/compiler/glsl/linker.cpp b/src/compiler/glsl/linker.cpp
index c493de2..45b8e46 100644
--- a/src/compiler/glsl/linker.cpp
+++ b/src/compiler/glsl/linker.cpp
@@ -4773,7 +4773,8 @@ link_shaders(struct gl_context *ctx, struct 
gl_shader_program *prog,
update_array_sizes(prog);
link_assign_uniform_locations(prog, ctx->Const.UniformBooleanTrue,
  num_explicit_uniform_locs,
- ctx->Const.MaxUserAssignableUniformLocations);
+ ctx->Const.MaxUserAssignableUniformLocations,
+ skip_cache);
link_assign_atomic_counter_resources(ctx, prog);
store_fragdepth_layout(prog);
 
diff --git a/src/compiler/glsl/linker.h b/src/compiler/glsl/linker.h
index f026732..6b68c41 100644
--- a/src/compiler/glsl/linker.h
+++ b/src/compiler/glsl/linker.h
@@ -37,7 +37,7 @@ extern void
 link_assign_uniform_locations(struct gl_shader_program *prog,
   unsigned int boolean_true,
   unsigned int num_explicit_uniform_locs,
-  unsigned int max_uniform_locs);
+  unsigned int max_uniform_locs, bool skip_cache);
 
 extern void
 link_set_uniform_initializers(struct gl_shader_program *prog,
diff --git a/src/compiler/glsl/main.cpp b/src/compiler/glsl/main.cpp
index 97cedb5..1d3c5a3 100644
--- a/src/compiler/glsl/main.cpp
+++ b/src/compiler/glsl/main.cpp
@@ -424,7 +424,7 @@ main(int argc, char **argv)
}
 
if ((status == EXIT_SUCCESS) && do_link)  {
-  _mesa_clear_shader_program_data(whole_program);
+  _mesa_clear_shader_program_data(whole_program, false);
 
   link_shaders(ctx, whole_program, true);
   status = (whole_program->LinkStatus) ? EXIT_SUCCESS : EXIT_FAILURE;
diff --git a/src/compiler/glsl/standalone_scaffolding.cpp 
b/src/compiler/glsl/standalone_scaffolding.cpp
index fffe6cc..886a1bb 100644
--- a/src/compiler/glsl/standalone_scaffolding.cpp
+++ b/src/compiler/glsl/standalon

[Mesa-dev] [PATCH 52/65] i965: always set program id to 0 for on disk cache

2016-04-29 Thread Timothy Arceri
We don't care what instance of the program it is we only care if
its the correct binary to load so ignore program id for on disk cache
---
 src/mesa/drivers/dri/i965/brw_shader_cache.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/mesa/drivers/dri/i965/brw_shader_cache.c 
b/src/mesa/drivers/dri/i965/brw_shader_cache.c
index 625ad3f..9104057 100644
--- a/src/mesa/drivers/dri/i965/brw_shader_cache.c
+++ b/src/mesa/drivers/dri/i965/brw_shader_cache.c
@@ -83,11 +83,13 @@ upload_cached_program(struct brw_context *brw)
   "program: %s\n", _mesa_sha1_format(sha1_buf, 
prog->sha1));
 
brw_wm_populate_key(brw, &wm_key);
+   wm_key.program_string_id = 0;
_mesa_sha1_compute(&wm_key, sizeof wm_key, sha1);
offset += snprintf(manifest + offset, sizeof(manifest) - offset,
   "wm_key: %s\n", _mesa_sha1_format(sha1_buf, sha1));
 
brw_vs_populate_key(brw, &vs_key);
+   vs_key.program_string_id = 0;
_mesa_sha1_compute(&vs_key, sizeof vs_key, sha1);
offset += snprintf(manifest + offset, sizeof(manifest) - offset,
   "vs_key: %s\n", _mesa_sha1_format(sha1_buf, sha1));
-- 
2.5.5

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


[Mesa-dev] [PATCH 53/65] i965: check memory cache before disk cache

2016-04-29 Thread Timothy Arceri
---
 src/mesa/drivers/dri/i965/brw_state_upload.c |  4 
 src/mesa/drivers/dri/i965/brw_vs.c   | 21 -
 src/mesa/drivers/dri/i965/brw_wm.c   | 17 ++---
 3 files changed, 30 insertions(+), 12 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_state_upload.c 
b/src/mesa/drivers/dri/i965/brw_state_upload.c
index 556c9d1..ba9e098 100644
--- a/src/mesa/drivers/dri/i965/brw_state_upload.c
+++ b/src/mesa/drivers/dri/i965/brw_state_upload.c
@@ -724,10 +724,6 @@ brw_upload_programs(struct brw_context *brw,
 enum brw_pipeline pipeline)
 {
if (pipeline == BRW_RENDER_PIPELINE) {
-#ifdef ENABLE_SHADER_CACHE
-  upload_cached_program(brw);
-#endif
-
   brw_upload_vs_prog(brw);
   brw_upload_tess_programs(brw);
 
diff --git a/src/mesa/drivers/dri/i965/brw_vs.c 
b/src/mesa/drivers/dri/i965/brw_vs.c
index d16d825..f12545a 100644
--- a/src/mesa/drivers/dri/i965/brw_vs.c
+++ b/src/mesa/drivers/dri/i965/brw_vs.c
@@ -353,7 +353,6 @@ brw_upload_vs_prog(struct brw_context *brw)
struct gl_context *ctx = &brw->ctx;
struct gl_shader_program **current = ctx->_Shader->CurrentProgram;
struct brw_vs_prog_key key;
-   /* BRW_NEW_VERTEX_PROGRAM */
struct brw_vertex_program *vp =
   (struct brw_vertex_program *)brw->vertex_program;
 
@@ -365,10 +364,22 @@ brw_upload_vs_prog(struct brw_context *brw)
if (!brw_search_cache(&brw->cache, BRW_CACHE_VS_PROG,
 &key, sizeof(key),
 &brw->vs.base.prog_offset, &brw->vs.prog_data)) {
-  bool success = brw_codegen_vs_prog(brw, current[MESA_SHADER_VERTEX],
- vp, &key);
-  (void) success;
-  assert(success);
+#ifdef ENABLE_SHADER_CACHE
+  upload_cached_program(brw);
+
+  /* If upload from disk cache failed call codegen */
+  if (!current[MESA_SHADER_VERTEX] ||
+  !current[MESA_SHADER_VERTEX]->program_written_to_cache) {
+ vp = (struct brw_vertex_program *) brw->vertex_program;
+ vp->id = key.program_string_id;
+#endif
+ bool success = brw_codegen_vs_prog(brw, current[MESA_SHADER_VERTEX],
+vp, &key);
+ (void) success;
+ assert(success);
+#ifdef ENABLE_SHADER_CACHE
+  }
+#endif
}
brw->vs.base.prog_data = &brw->vs.prog_data->base.base;
 }
diff --git a/src/mesa/drivers/dri/i965/brw_wm.c 
b/src/mesa/drivers/dri/i965/brw_wm.c
index daebb48..46e1955 100644
--- a/src/mesa/drivers/dri/i965/brw_wm.c
+++ b/src/mesa/drivers/dri/i965/brw_wm.c
@@ -575,9 +575,20 @@ brw_upload_wm_prog(struct brw_context *brw)
if (!brw_search_cache(&brw->cache, BRW_CACHE_FS_PROG,
 &key, sizeof(key),
 &brw->wm.base.prog_offset, &brw->wm.prog_data)) {
-  bool success = brw_codegen_wm_prog(brw, current, fp, &key);
-  (void) success;
-  assert(success);
+#ifdef ENABLE_SHADER_CACHE
+  upload_cached_program(brw);
+
+  /* If upload from disk cache failed call codegen */
+  if (!current || !current->program_written_to_cache) {
+ fp = (struct brw_fragment_program *) brw->fragment_program;
+ fp->id = key.program_string_id;
+#endif
+ bool success = brw_codegen_wm_prog(brw, current, fp, &key);
+ (void) success;
+ assert(success);
+#ifdef ENABLE_SHADER_CACHE
+  }
+#endif
}
brw->wm.base.prog_data = &brw->wm.prog_data->base;
 }
-- 
2.5.5

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


[Mesa-dev] [PATCH 58/65] i965: copy program id to key before upload

2016-04-29 Thread Timothy Arceri
On the off chance the program has already been assigned an id
---
 src/mesa/drivers/dri/i965/brw_shader_cache.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/src/mesa/drivers/dri/i965/brw_shader_cache.c 
b/src/mesa/drivers/dri/i965/brw_shader_cache.c
index 08d43e7..5de261c 100644
--- a/src/mesa/drivers/dri/i965/brw_shader_cache.c
+++ b/src/mesa/drivers/dri/i965/brw_shader_cache.c
@@ -229,6 +229,8 @@ upload_cached_program(struct brw_context *brw)
struct brw_vertex_program *vp =
   (struct brw_vertex_program *)brw->vertex_program;
 
+   vs_key.program_string_id = vp->id;
+
brw_upload_cache(&brw->cache, BRW_CACHE_VS_PROG,
 &vs_key, sizeof(struct brw_vs_prog_key),
 vs_program, vs_program_size,
@@ -331,6 +333,8 @@ upload_cached_program(struct brw_context *brw)
struct brw_fragment_program *wp =
   (struct brw_fragment_program *)brw->fragment_program;
 
+   wm_key.program_string_id = wp->id;
+
brw_upload_cache(&brw->cache, BRW_CACHE_FS_PROG,
 &wm_key, sizeof(struct brw_wm_prog_key),
 wm_program, wm_program_size,
-- 
2.5.5

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


[Mesa-dev] [PATCH 56/65] i965: move binary sha1 gen into its own helper

2016-04-29 Thread Timothy Arceri
And call it from write cache as its possible that read cache hasn't
been called at this point or the current sha is the wrong one so we
need to make sure a fresh sha is generated before writting.
---
 src/mesa/drivers/dri/i965/brw_shader_cache.c | 54 ++--
 1 file changed, 35 insertions(+), 19 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_shader_cache.c 
b/src/mesa/drivers/dri/i965/brw_shader_cache.c
index 9104057..07f3a64 100644
--- a/src/mesa/drivers/dri/i965/brw_shader_cache.c
+++ b/src/mesa/drivers/dri/i965/brw_shader_cache.c
@@ -38,6 +38,35 @@
 #include "brw_vs.h"
 #include "brw_context.h"
 
+static void
+gen_binary_sha1(struct brw_context *brw, struct gl_shader_program *prog,
+struct brw_vs_prog_key *vs_key,
+struct brw_wm_prog_key *wm_key)
+{
+   char sha1_buf[41];
+   unsigned char sha1[20];
+   char manifest[256];
+   int offset = 0;
+
+   offset += snprintf(manifest + offset, sizeof(manifest) - offset,
+  "program: %s\n", _mesa_sha1_format(sha1_buf, 
prog->sha1));
+
+   brw_vs_populate_key(brw, vs_key);
+   vs_key->program_string_id = 0;
+   _mesa_sha1_compute(vs_key, sizeof *vs_key, sha1);
+   offset += snprintf(manifest + offset, sizeof(manifest) - offset,
+  "vs_key: %s\n", _mesa_sha1_format(sha1_buf, sha1));
+
+   brw_wm_populate_key(brw, wm_key);
+   wm_key->program_string_id = 0;
+   _mesa_sha1_compute(wm_key, sizeof *wm_key, sha1);
+   offset += snprintf(manifest + offset, sizeof(manifest) - offset,
+  "wm_key: %s\n", _mesa_sha1_format(sha1_buf, sha1));
+
+   _mesa_sha1_compute(manifest, strlen(manifest), brw->binary_sha1);
+
+}
+
 void
 upload_cached_program(struct brw_context *brw)
 {
@@ -48,9 +77,7 @@ upload_cached_program(struct brw_context *brw)
struct gl_shader_program *prog;
struct brw_wm_prog_key wm_key;
struct brw_vs_prog_key vs_key;
-   unsigned char sha1[20];
-   char manifest[256];
-   int i, offset = 0;
+   int i;
struct program_cache *cache;
uint8_t *vs_program, *wm_program;
size_t vs_program_size, wm_program_size;
@@ -79,22 +106,7 @@ upload_cached_program(struct brw_context *brw)
if (prog->TransformFeedback.NumVarying > 0)
   return;
 
-   offset += snprintf(manifest + offset, sizeof(manifest) - offset,
-  "program: %s\n", _mesa_sha1_format(sha1_buf, 
prog->sha1));
-
-   brw_wm_populate_key(brw, &wm_key);
-   wm_key.program_string_id = 0;
-   _mesa_sha1_compute(&wm_key, sizeof wm_key, sha1);
-   offset += snprintf(manifest + offset, sizeof(manifest) - offset,
-  "wm_key: %s\n", _mesa_sha1_format(sha1_buf, sha1));
-
-   brw_vs_populate_key(brw, &vs_key);
-   vs_key.program_string_id = 0;
-   _mesa_sha1_compute(&vs_key, sizeof vs_key, sha1);
-   offset += snprintf(manifest + offset, sizeof(manifest) - offset,
-  "vs_key: %s\n", _mesa_sha1_format(sha1_buf, sha1));
-
-   _mesa_sha1_compute(manifest, strlen(manifest), brw->binary_sha1);
+   gen_binary_sha1(brw, prog, &vs_key, &wm_key);
 
buffer = cache_get(cache, brw->binary_sha1, &size);
if (buffer == NULL)
@@ -407,6 +419,10 @@ write_cached_program(struct brw_context *brw)
if (binary == NULL)
   return;
 
+   struct brw_vs_prog_key vs_key;
+   struct brw_wm_prog_key wm_key;
+   gen_binary_sha1(brw, prog, &vs_key, &wm_key);
+
/* Write VS program to blob. */
vs_program_size = brw->vs.prog_data->program_size;
 
-- 
2.5.5

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


[Mesa-dev] [PATCH 59/65] mesa: extend LinkShader function to include cache fallback param

2016-04-29 Thread Timothy Arceri
This allows up to skip certain linking tasks such as building the
resource list when we are falling back to a full compile after a
cache miss.
---
 src/mesa/drivers/dri/i965/brw_link.cpp | 3 ++-
 src/mesa/drivers/dri/i965/brw_shader.h | 4 +++-
 src/mesa/main/dd.h | 3 ++-
 src/mesa/program/ir_to_mesa.cpp| 5 +++--
 src/mesa/program/ir_to_mesa.h  | 4 +++-
 src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 3 ++-
 src/mesa/state_tracker/st_glsl_to_tgsi.h   | 4 +++-
 7 files changed, 18 insertions(+), 8 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_link.cpp 
b/src/mesa/drivers/dri/i965/brw_link.cpp
index 7809b4c..97bee3b 100644
--- a/src/mesa/drivers/dri/i965/brw_link.cpp
+++ b/src/mesa/drivers/dri/i965/brw_link.cpp
@@ -186,7 +186,8 @@ process_glsl_ir(gl_shader_stage stage,
 }
 
 extern "C" GLboolean
-brw_link_shader(struct gl_context *ctx, struct gl_shader_program *shProg)
+brw_link_shader(struct gl_context *ctx, struct gl_shader_program *shProg,
+bool is_cache_fallback)
 {
struct brw_context *brw = brw_context(ctx);
const struct brw_compiler *compiler = brw->intelScreen->compiler;
diff --git a/src/mesa/drivers/dri/i965/brw_shader.h 
b/src/mesa/drivers/dri/i965/brw_shader.h
index fc228f6..e7d062e 100644
--- a/src/mesa/drivers/dri/i965/brw_shader.h
+++ b/src/mesa/drivers/dri/i965/brw_shader.h
@@ -285,7 +285,9 @@ bool brw_cs_precompile(struct gl_context *ctx,
struct gl_shader_program *shader_prog,
struct gl_program *prog);
 
-GLboolean brw_link_shader(struct gl_context *ctx, struct gl_shader_program 
*prog);
+GLboolean
+brw_link_shader(struct gl_context *ctx, struct gl_shader_program *prog,
+bool is_cache_fallback);
 struct gl_shader *brw_new_shader(struct gl_context *ctx, GLuint name, GLuint 
type);
 
 int type_size_scalar(const struct glsl_type *type);
diff --git a/src/mesa/main/dd.h b/src/mesa/main/dd.h
index d62fee6..625f898 100644
--- a/src/mesa/main/dd.h
+++ b/src/mesa/main/dd.h
@@ -513,7 +513,8 @@ struct dd_function_table {
 * own transformations on it for the purposes of code generation.
 */
GLboolean (*LinkShader)(struct gl_context *ctx,
-   struct gl_shader_program *shader);
+   struct gl_shader_program *shader,
+   bool is_cache_fallback);
/*@}*/
 
/**
diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp
index 4f4cbaf..62d647f 100644
--- a/src/mesa/program/ir_to_mesa.cpp
+++ b/src/mesa/program/ir_to_mesa.cpp
@@ -2900,7 +2900,8 @@ extern "C" {
  * code lowering and other optimizations.
  */
 GLboolean
-_mesa_ir_link_shader(struct gl_context *ctx, struct gl_shader_program *prog)
+_mesa_ir_link_shader(struct gl_context *ctx, struct gl_shader_program *prog,
+ bool is_cache_fallback)
 {
assert(prog->LinkStatus);
 
@@ -3015,7 +3016,7 @@ _mesa_glsl_link_shader(struct gl_context *ctx, struct 
gl_shader_program *prog,
   return;
 
if (prog->LinkStatus) {
-  if (!ctx->Driver.LinkShader(ctx, prog)) {
+  if (!ctx->Driver.LinkShader(ctx, prog, skip_cache)) {
 prog->LinkStatus = GL_FALSE;
   }
}
diff --git a/src/mesa/program/ir_to_mesa.h b/src/mesa/program/ir_to_mesa.h
index abc628a..6584bee 100644
--- a/src/mesa/program/ir_to_mesa.h
+++ b/src/mesa/program/ir_to_mesa.h
@@ -36,7 +36,9 @@ struct gl_shader_program;
 void _mesa_glsl_link_shader(struct gl_context *ctx,
 struct gl_shader_program *prog,
 bool skip_cache);
-GLboolean _mesa_ir_link_shader(struct gl_context *ctx, struct 
gl_shader_program *prog);
+GLboolean
+_mesa_ir_link_shader(struct gl_context *ctx, struct gl_shader_program *prog,
+ bool is_cache_fallback);
 
 void
 _mesa_generate_parameters_list_for_uniforms(struct gl_shader_program
diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp 
b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index ad818a8..cb71da6 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -6738,7 +6738,8 @@ st_dump_program_for_shader_db(struct gl_context *ctx,
  * with code lowering and other optimizations.
  */
 GLboolean
-st_link_shader(struct gl_context *ctx, struct gl_shader_program *prog)
+st_link_shader(struct gl_context *ctx, struct gl_shader_program *prog,
+   bool is_cache_fallback)
 {
struct pipe_screen *pscreen = ctx->st->pipe->screen;
assert(prog->LinkStatus);
diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.h 
b/src/mesa/state_tracker/st_glsl_to_tgsi.h
index 774588a..17ba6cf 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi.h
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi.h
@@ -56,7 +56,9 @@ enum pipe_error st_translate_program(
 
 void free_glsl_to_tgsi_visitor(struct glsl_to_tgsi_visitor *v);
 
-GLboolean st_link_shader(struct gl_context *ctx, struct gl

[Mesa-dev] [PATCH 61/65] i965: move vs outputs written into a helper

2016-04-29 Thread Timothy Arceri
We will reuse this for fs key generation for the on disk shader
cache.
---
 src/mesa/drivers/dri/i965/brw_vs.c | 72 ++
 src/mesa/drivers/dri/i965/brw_vs.h |  4 +++
 2 files changed, 45 insertions(+), 31 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_vs.c 
b/src/mesa/drivers/dri/i965/brw_vs.c
index f12545a..9e3bb2c 100644
--- a/src/mesa/drivers/dri/i965/brw_vs.c
+++ b/src/mesa/drivers/dri/i965/brw_vs.c
@@ -43,6 +43,45 @@
 
 #include "util/ralloc.h"
 
+GLbitfield64
+brw_vs_outputs_written(struct brw_context *brw, struct brw_vs_prog_key *key,
+   GLbitfield64 outputs_written)
+{
+   if (key->copy_edgeflag) {
+  outputs_written |= BITFIELD64_BIT(VARYING_SLOT_EDGE);
+   }
+
+   if (brw->gen < 6) {
+  /* Put dummy slots into the VUE for the SF to put the replaced
+   * point sprite coords in.  We shouldn't need these dummy slots,
+   * which take up precious URB space, but it would mean that the SF
+   * doesn't get nice aligned pairs of input coords into output
+   * coords, which would be a pain to handle.
+   */
+  for (unsigned i = 0; i < 8; i++) {
+ if (key->point_coord_replace & (1 << i))
+outputs_written |= BITFIELD64_BIT(VARYING_SLOT_TEX0 + i);
+  }
+
+  /* if back colors are written, allocate slots for front colors too */
+  if (outputs_written & BITFIELD64_BIT(VARYING_SLOT_BFC0))
+ outputs_written |= BITFIELD64_BIT(VARYING_SLOT_COL0);
+  if (outputs_written & BITFIELD64_BIT(VARYING_SLOT_BFC1))
+ outputs_written |= BITFIELD64_BIT(VARYING_SLOT_COL1);
+   }
+
+   /* In order for legacy clipping to work, we need to populate the clip
+* distance varying slots whenever clipping is enabled, even if the vertex
+* shader doesn't write to gl_ClipDistance.
+*/
+   if (key->nr_userclip_plane_consts > 0) {
+  outputs_written |= BITFIELD64_BIT(VARYING_SLOT_CLIP_DIST0);
+  outputs_written |= BITFIELD64_BIT(VARYING_SLOT_CLIP_DIST1);
+   }
+
+   return outputs_written;
+}
+
 bool
 brw_codegen_vs_prog(struct brw_context *brw,
 struct gl_shader_program *prog,
@@ -55,7 +94,6 @@ brw_codegen_vs_prog(struct brw_context *brw,
struct brw_vs_prog_data prog_data;
struct brw_stage_prog_data *stage_prog_data = &prog_data.base.base;
void *mem_ctx;
-   int i;
struct brw_shader *vs = NULL;
bool start_busy = false;
double start_time = 0;
@@ -110,42 +148,14 @@ brw_codegen_vs_prog(struct brw_context *brw,
  &prog_data.base.base);
}
 
-   GLbitfield64 outputs_written = vp->program.Base.OutputsWritten;
+   GLbitfield64 outputs_written =
+  brw_vs_outputs_written(brw, key, vp->program.Base.OutputsWritten);
prog_data.inputs_read = vp->program.Base.InputsRead;
 
if (key->copy_edgeflag) {
-  outputs_written |= BITFIELD64_BIT(VARYING_SLOT_EDGE);
   prog_data.inputs_read |= VERT_BIT_EDGEFLAG;
}
 
-   if (brw->gen < 6) {
-  /* Put dummy slots into the VUE for the SF to put the replaced
-   * point sprite coords in.  We shouldn't need these dummy slots,
-   * which take up precious URB space, but it would mean that the SF
-   * doesn't get nice aligned pairs of input coords into output
-   * coords, which would be a pain to handle.
-   */
-  for (i = 0; i < 8; i++) {
- if (key->point_coord_replace & (1 << i))
-outputs_written |= BITFIELD64_BIT(VARYING_SLOT_TEX0 + i);
-  }
-
-  /* if back colors are written, allocate slots for front colors too */
-  if (outputs_written & BITFIELD64_BIT(VARYING_SLOT_BFC0))
- outputs_written |= BITFIELD64_BIT(VARYING_SLOT_COL0);
-  if (outputs_written & BITFIELD64_BIT(VARYING_SLOT_BFC1))
- outputs_written |= BITFIELD64_BIT(VARYING_SLOT_COL1);
-   }
-
-   /* In order for legacy clipping to work, we need to populate the clip
-* distance varying slots whenever clipping is enabled, even if the vertex
-* shader doesn't write to gl_ClipDistance.
-*/
-   if (key->nr_userclip_plane_consts > 0) {
-  outputs_written |= BITFIELD64_BIT(VARYING_SLOT_CLIP_DIST0);
-  outputs_written |= BITFIELD64_BIT(VARYING_SLOT_CLIP_DIST1);
-   }
-
brw_compute_vue_map(brw->intelScreen->devinfo,
&prog_data.base.vue_map, outputs_written,
prog ? prog->SeparateShader ||
diff --git a/src/mesa/drivers/dri/i965/brw_vs.h 
b/src/mesa/drivers/dri/i965/brw_vs.h
index 8a12d3b..adee1c2 100644
--- a/src/mesa/drivers/dri/i965/brw_vs.h
+++ b/src/mesa/drivers/dri/i965/brw_vs.h
@@ -51,6 +51,10 @@
 extern "C" {
 #endif
 
+GLbitfield64
+brw_vs_outputs_written(struct brw_context *brw, struct brw_vs_prog_key *key,
+   GLbitfield64 outputs_written);
+
 void brw_vs_debug_recompile(struct brw_context *brw,
 struct gl_shader_program *prog,
 const struct brw_vs_prog_key *key);
--

[Mesa-dev] [PATCH 50/65] i965: add shader cache support for pull param pointers

2016-04-29 Thread Timothy Arceri
---
 src/mesa/drivers/dri/i965/brw_shader_cache.c | 52 ++--
 1 file changed, 49 insertions(+), 3 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_shader_cache.c 
b/src/mesa/drivers/dri/i965/brw_shader_cache.c
index 850e1e8..d1336d7 100644
--- a/src/mesa/drivers/dri/i965/brw_shader_cache.c
+++ b/src/mesa/drivers/dri/i965/brw_shader_cache.c
@@ -59,6 +59,7 @@ upload_cached_program(struct brw_context *brw)
intptr_t uniform_data_slots_base;
intptr_t image_params_base;
uint32_t nr_params, nr_pull_params, nr_image_params;
+   static const gl_constant_value zero = { 0 };
 
cache = brw->ctx.Cache;
if (cache == NULL)
@@ -180,10 +181,32 @@ upload_cached_program(struct brw_context *brw)
prog_data->pull_param = rzalloc_array(NULL, const gl_constant_value *,
  nr_pull_params);
 
-
for (i = 0; i < nr_pull_params; i++) {
   intptr_t pull_param = blob_read_intptr(&binary);
-  /* FIXME: We need to fixup pull_params pointers here. */
+  struct gl_program_parameter_list *param_list =
+ prog->_LinkedShaders[MESA_SHADER_VERTEX] ?
+prog->_LinkedShaders[MESA_SHADER_VERTEX]->Program->Parameters :
+NULL;
+
+  ptrdiff_t u_offset =
+ (pull_param - uniform_data_slots_base) / sizeof(gl_constant_value);
+  ptrdiff_t i_offset =
+ (pull_param - image_params_base) / sizeof(gl_constant_value);
+  ptrdiff_t p_offset =
+ (pull_param - parameter_values_base) / sizeof(gl_constant_value);
+
+  if (param_list && p_offset >= 0 &&
+  p_offset < 4 * param_list->NumParameters) {
+ prog_data->pull_param[i] =
+((gl_constant_value *) param_list->ParameterValues) + p_offset;
+  } else if (u_offset >= 0 && u_offset < prog->NumUniformDataSlots) {
+ prog_data->pull_param[i] = prog->UniformDataSlots + u_offset;
+  } else if (i_offset >= 0 && i_offset < image_upper_boundary) {
+ prog_data->pull_param[i] =
+((gl_constant_value *) prog_data->image_param) + i_offset;
+  } else {
+ prog_data->pull_param[i] = &zero;
+  }
}
 
struct brw_vertex_program *vp =
@@ -262,7 +285,30 @@ upload_cached_program(struct brw_context *brw)
 
for (i = 0; i < nr_pull_params; i++) {
   intptr_t pull_param = blob_read_intptr(&binary);
-  /* FIXME: We need to fixup pull_params pointers here. */
+  struct gl_program_parameter_list *param_list =
+ prog->_LinkedShaders[MESA_SHADER_FRAGMENT] ?
+prog->_LinkedShaders[MESA_SHADER_FRAGMENT]->Program->Parameters :
+NULL;
+
+  ptrdiff_t u_offset =
+ (pull_param - uniform_data_slots_base) / sizeof(gl_constant_value);
+  ptrdiff_t i_offset =
+ (pull_param - image_params_base) / sizeof(gl_constant_value);
+  ptrdiff_t p_offset =
+ (pull_param - parameter_values_base) / sizeof(gl_constant_value);
+
+  if (param_list && p_offset >= 0 &&
+  p_offset < 4 * param_list->NumParameters) {
+ prog_data->pull_param[i] =
+((gl_constant_value *) param_list->ParameterValues) + p_offset;
+  } else if (u_offset >= 0 && u_offset < prog->NumUniformDataSlots) {
+ prog_data->pull_param[i] = prog->UniformDataSlots + u_offset;
+  } else if (i_offset >= 0 && i_offset < image_upper_boundary) {
+ prog_data->pull_param[i] =
+((gl_constant_value *) prog_data->image_param) + i_offset;
+  }  else {
+ prog_data->pull_param[i] = &zero;
+  }
}
 
struct brw_fragment_program *wp =
-- 
2.5.5

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


[Mesa-dev] [PATCH 47/65] glsl: add a cache_remove() function

2016-04-29 Thread Timothy Arceri
This will be used to remove cache items created with an old version
of Mesa from the cache.
---
 src/compiler/glsl/cache.c | 22 ++
 src/compiler/glsl/cache.h |  6 ++
 2 files changed, 28 insertions(+)

diff --git a/src/compiler/glsl/cache.c b/src/compiler/glsl/cache.c
index 22c4ee1..a6a9e47 100644
--- a/src/compiler/glsl/cache.c
+++ b/src/compiler/glsl/cache.c
@@ -537,6 +537,28 @@ evict_random_item(struct program_cache *cache)
 }
 
 void
+cache_remove(struct program_cache *cache, cache_key key)
+{
+   struct stat sb;
+
+   char *filename = get_cache_file(cache, key);
+   if (filename == NULL) {
+  return;
+   }
+
+   if (stat(filename, &sb) == -1) {
+  ralloc_free(filename);
+  return;
+   }
+
+   unlink(filename);
+   ralloc_free(filename);
+
+   if (sb.st_size)
+  p_atomic_add(cache->size, - sb.st_size);
+}
+
+void
 cache_put(struct program_cache *cache,
   cache_key key,
   const void *data,
diff --git a/src/compiler/glsl/cache.h b/src/compiler/glsl/cache.h
index 78df32b..4878a78 100644
--- a/src/compiler/glsl/cache.h
+++ b/src/compiler/glsl/cache.h
@@ -77,6 +77,12 @@ void
 cache_destroy(struct program_cache *cache);
 
 /**
+ * Remove the item in the cache under the name \key.
+ */
+void
+cache_remove(struct program_cache *cache, cache_key key);
+
+/**
  * Store an item in the cache under the name \key.
  *
  * The item can be retrieved later with cache_get(), (unless the item has
-- 
2.5.5

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


[Mesa-dev] [PATCH 45/65] glsl: cache system values read bitfield

2016-04-29 Thread Timothy Arceri
---
 src/compiler/glsl/shader_cache.cpp | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/compiler/glsl/shader_cache.cpp 
b/src/compiler/glsl/shader_cache.cpp
index 6fe89a7..d3eec83 100644
--- a/src/compiler/glsl/shader_cache.cpp
+++ b/src/compiler/glsl/shader_cache.cpp
@@ -919,6 +919,7 @@ write_shader_metadata(struct blob *metadata, gl_shader 
*shader)
   /* Use the lowest bit to indicate that there is shader_metadata here. */
   blob_write_uint64(metadata, glprog->InputsRead << 1 | 1);
   blob_write_uint64(metadata, glprog->OutputsWritten);
+  blob_write_uint32(metadata, glprog->SystemValuesRead);
   blob_write_bytes(metadata, glprog->TexturesUsed,
sizeof(glprog->TexturesUsed));
   blob_write_bytes(metadata, glprog->SamplerUnits,
@@ -964,6 +965,7 @@ read_shader_metadata(struct blob_reader *metadata,
if (has_shader) {
   glprog->InputsRead = has_shader >> 1;
   glprog->OutputsWritten = blob_read_uint64(metadata);
+  glprog->SystemValuesRead = blob_read_uint32(metadata);
   blob_copy_bytes(metadata, (uint8_t *) glprog->TexturesUsed,
   sizeof(glprog->TexturesUsed));
   blob_copy_bytes(metadata, (uint8_t *) glprog->SamplerUnits,
-- 
2.5.5

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


[Mesa-dev] [PATCH 48/65] glsl: track mesa version shader cache items were created with

2016-04-29 Thread Timothy Arceri
Also remove cache item and fallback to full recompile if current Mesa
version differs.
---
 src/compiler/glsl/shader_cache.cpp | 12 
 1 file changed, 12 insertions(+)

diff --git a/src/compiler/glsl/shader_cache.cpp 
b/src/compiler/glsl/shader_cache.cpp
index d3eec83..52301b7 100644
--- a/src/compiler/glsl/shader_cache.cpp
+++ b/src/compiler/glsl/shader_cache.cpp
@@ -1033,6 +1033,8 @@ shader_cache_write_program_metadata(struct gl_context 
*ctx,
 
metadata = blob_create(NULL);
 
+   blob_write_string(metadata, ctx->VersionString);
+
write_uniforms(metadata, prog);
 
write_hash_tables(metadata, prog);
@@ -1134,6 +1136,16 @@ shader_cache_read_program_metadata(struct gl_context 
*ctx,
 
blob_reader_init(&metadata, buffer, size);
 
+   char *version_string = blob_read_string(&metadata);
+   if (strcmp(ctx->VersionString, version_string) != 0) {
+  /* The cached version of the program was created with a different
+   * version of Mesa so remove it and fallback to full recompile.
+   */
+  cache_remove(cache, prog->sha1);
+  compile_shaders(ctx, prog);
+  return false;
+   }
+
assert(prog->UniformStorage == NULL);
 
read_uniforms(&metadata, prog);
-- 
2.5.5

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


[Mesa-dev] [PATCH 55/65] glsl: skip more uniform initialisation when doing fallback linking

2016-04-29 Thread Timothy Arceri
We already pull these values from the metadata cache so no need to
recreate them.
---
 src/compiler/glsl/linker.cpp | 22 ++
 src/mesa/main/shaderobj.c|  8 +---
 2 files changed, 19 insertions(+), 11 deletions(-)

diff --git a/src/compiler/glsl/linker.cpp b/src/compiler/glsl/linker.cpp
index 45b8e46..1f8350c 100644
--- a/src/compiler/glsl/linker.cpp
+++ b/src/compiler/glsl/linker.cpp
@@ -4331,6 +4331,8 @@ link_shaders(struct gl_context *ctx, struct 
gl_shader_program *prog,
   return;
 #endif
 
+   bool create_program_metadata = !skip_cache || !prog->UniformStorage;
+
void *mem_ctx = ralloc_context(NULL); // temporary linker context
 
prog->ARB_fragment_coord_conventions_enable = false;
@@ -4511,8 +4513,10 @@ link_shaders(struct gl_context *ctx, struct 
gl_shader_program *prog,
   last = i;
}
 
-   num_explicit_uniform_locs = check_explicit_uniform_locations(ctx, prog);
-   link_assign_subroutine_types(prog);
+   if (create_program_metadata) {
+  num_explicit_uniform_locs = check_explicit_uniform_locations(ctx, prog);
+  link_assign_subroutine_types(prog);
+   }
 
if (!prog->LinkStatus)
   goto done;
@@ -4775,14 +4779,16 @@ link_shaders(struct gl_context *ctx, struct 
gl_shader_program *prog,
  num_explicit_uniform_locs,
  ctx->Const.MaxUserAssignableUniformLocations,
  skip_cache);
-   link_assign_atomic_counter_resources(ctx, prog);
store_fragdepth_layout(prog);
 
-   link_calculate_subroutine_compat(prog);
-   check_resources(ctx, prog);
-   check_subroutine_resources(prog);
-   check_image_resources(ctx, prog);
-   link_check_atomic_counter_resources(ctx, prog);
+   if (create_program_metadata) {
+  link_assign_atomic_counter_resources(ctx, prog);
+  link_calculate_subroutine_compat(prog);
+  check_resources(ctx, prog);
+  check_subroutine_resources(prog);
+  check_image_resources(ctx, prog);
+  link_check_atomic_counter_resources(ctx, prog);
+   }
 
if (!prog->LinkStatus)
   goto done;
diff --git a/src/mesa/main/shaderobj.c b/src/mesa/main/shaderobj.c
index 49a155c..5bf155e 100644
--- a/src/mesa/main/shaderobj.c
+++ b/src/mesa/main/shaderobj.c
@@ -301,9 +301,11 @@ _mesa_clear_shader_program_data(struct gl_shader_program 
*shProg,
shProg->ShaderStorageBlocks = NULL;
shProg->NumShaderStorageBlocks = 0;
 
-   ralloc_free(shProg->AtomicBuffers);
-   shProg->AtomicBuffers = NULL;
-   shProg->NumAtomicBuffers = 0;
+   if (shProg->AtomicBuffers && !skip_cache) {
+  ralloc_free(shProg->AtomicBuffers);
+  shProg->AtomicBuffers = NULL;
+  shProg->NumAtomicBuffers = 0;
+   }
 
if (shProg->ProgramResourceList) {
   ralloc_free(shProg->ProgramResourceList);
-- 
2.5.5

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


[Mesa-dev] [PATCH 60/65] i965: don't precompile or rebuild resource list on cache fallback

2016-04-29 Thread Timothy Arceri
---
 src/mesa/drivers/dri/i965/brw_link.cpp | 8 +---
 src/mesa/main/shaderobj.c  | 2 +-
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_link.cpp 
b/src/mesa/drivers/dri/i965/brw_link.cpp
index 97bee3b..240e2db 100644
--- a/src/mesa/drivers/dri/i965/brw_link.cpp
+++ b/src/mesa/drivers/dri/i965/brw_link.cpp
@@ -262,9 +262,11 @@ brw_link_shader(struct gl_context *ctx, struct 
gl_shader_program *shProg,
   }
}
 
-   if (brw->precompile && !brw_shader_precompile(ctx, shProg))
-  return false;
+   if (!is_cache_fallback) {
+  if (brw->precompile && !brw_shader_precompile(ctx, shProg))
+ return false;
 
-   build_program_resource_list(ctx, shProg);
+  build_program_resource_list(ctx, shProg);
+   }
return true;
 }
diff --git a/src/mesa/main/shaderobj.c b/src/mesa/main/shaderobj.c
index 5bf155e..b05cc82 100644
--- a/src/mesa/main/shaderobj.c
+++ b/src/mesa/main/shaderobj.c
@@ -307,7 +307,7 @@ _mesa_clear_shader_program_data(struct gl_shader_program 
*shProg,
   shProg->NumAtomicBuffers = 0;
}
 
-   if (shProg->ProgramResourceList) {
+   if (shProg->ProgramResourceList && !skip_cache) {
   ralloc_free(shProg->ProgramResourceList);
   shProg->ProgramResourceList = NULL;
   shProg->NumProgramResourceList = 0;
-- 
2.5.5

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


[Mesa-dev] [PATCH 51/65] i965: add cache fallback support

2016-04-29 Thread Timothy Arceri
---
 src/mesa/drivers/dri/i965/brw_shader_cache.c | 43 ++--
 1 file changed, 41 insertions(+), 2 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_shader_cache.c 
b/src/mesa/drivers/dri/i965/brw_shader_cache.c
index d1336d7..625ad3f 100644
--- a/src/mesa/drivers/dri/i965/brw_shader_cache.c
+++ b/src/mesa/drivers/dri/i965/brw_shader_cache.c
@@ -28,7 +28,10 @@
 #include 
 #include 
 #include 
+#include 
 #include 
+#include 
+#include 
 
 #include "brw_state.h"
 #include "brw_wm.h"
@@ -333,9 +336,45 @@ upload_cached_program(struct brw_context *brw)
return;
 
 FAIL:
-   /* Fall back and compile from source here. */
prog->program_written_to_cache = false;
-   printf("FIXME: May need to fallback to compile from source here...\n");
+   printf("Falling back to compile from source.\n");
+
+   /* Cached program not found. Fall back to linking shaders but first
+* compile any shaders we didn't compile earlier.
+*/
+   if (brw->vertex_program->Base.nir == NULL) {
+  struct gl_shader_program *prog =
+ brw->ctx._Shader->CurrentProgram[MESA_SHADER_VERTEX];
+  for (unsigned i = 0; i < prog->NumShaders; i++) {
+ _mesa_glsl_compile_shader(&brw->ctx, prog->Shaders[i], false, false,
+   true);
+  }
+  _mesa_glsl_link_shader(&brw->ctx, prog, true);
+
+  struct gl_program *vp =
+ prog->_LinkedShaders[MESA_SHADER_VERTEX]->Program;
+  brw->vertex_program = gl_vertex_program(vp);
+
+  struct gl_program *fp =
+ prog->_LinkedShaders[MESA_SHADER_FRAGMENT]->Program;
+  brw->fragment_program = gl_fragment_program(fp);
+   }
+
+   if (brw->fragment_program->Base.nir == NULL) {
+  struct gl_shader_program *prog =
+ brw->ctx._Shader->_CurrentFragmentProgram;
+
+  for (unsigned i = 0; i < prog->NumShaders; i++) {
+ _mesa_glsl_compile_shader(&brw->ctx, prog->Shaders[i], false, false,
+   true);
+  }
+  _mesa_glsl_link_shader(&brw->ctx, prog, true);
+
+  struct gl_program *fp =
+ prog->_LinkedShaders[MESA_SHADER_FRAGMENT]->Program;
+  brw->fragment_program = gl_fragment_program(fp);
+   }
+
free(buffer);
 }
 
-- 
2.5.5

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


[Mesa-dev] [PATCH 46/65] glsl: use reproducible name for lowered const arrays

2016-04-29 Thread Timothy Arceri
Otherwise we can end up with mismatching names between the cached
binary and the cached metadata.
---
 src/compiler/glsl/ir_optimization.h  |  2 +-
 src/compiler/glsl/linker.cpp |  2 +-
 src/compiler/glsl/lower_const_arrays_to_uniforms.cpp | 16 
 3 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/src/compiler/glsl/ir_optimization.h 
b/src/compiler/glsl/ir_optimization.h
index f9599a3..3313128 100644
--- a/src/compiler/glsl/ir_optimization.h
+++ b/src/compiler/glsl/ir_optimization.h
@@ -116,7 +116,7 @@ bool lower_variable_index_to_cond_assign(gl_shader_stage 
stage,
 exec_list *instructions, bool lower_input, bool lower_output,
 bool lower_temp, bool lower_uniform);
 bool lower_quadop_vector(exec_list *instructions, bool dont_lower_swz);
-bool lower_const_arrays_to_uniforms(exec_list *instructions);
+bool lower_const_arrays_to_uniforms(exec_list *instructions, unsigned stage);
 bool lower_clip_distance(gl_shader *shader);
 void lower_output_reads(unsigned stage, exec_list *instructions);
 bool lower_packing_builtins(exec_list *instructions, int op_mask);
diff --git a/src/compiler/glsl/linker.cpp b/src/compiler/glsl/linker.cpp
index 979dbb5..c493de2 100644
--- a/src/compiler/glsl/linker.cpp
+++ b/src/compiler/glsl/linker.cpp
@@ -4601,7 +4601,7 @@ link_shaders(struct gl_context *ctx, struct 
gl_shader_program *prog,
 ctx->Const.NativeIntegers))
 ;
 
-  lower_const_arrays_to_uniforms(prog->_LinkedShaders[i]->ir);
+  lower_const_arrays_to_uniforms(prog->_LinkedShaders[i]->ir, i);
}
 
/* Validation for special cases where we allow sampler array indexing
diff --git a/src/compiler/glsl/lower_const_arrays_to_uniforms.cpp 
b/src/compiler/glsl/lower_const_arrays_to_uniforms.cpp
index 2d024d4..bd374e2 100644
--- a/src/compiler/glsl/lower_const_arrays_to_uniforms.cpp
+++ b/src/compiler/glsl/lower_const_arrays_to_uniforms.cpp
@@ -45,9 +45,11 @@
 namespace {
 class lower_const_array_visitor : public ir_rvalue_visitor {
 public:
-   lower_const_array_visitor(exec_list *insts)
+   lower_const_array_visitor(exec_list *insts, unsigned s)
{
   instructions = insts;
+  stage = s;
+  const_count = 0;
   progress = false;
}
 
@@ -61,6 +63,8 @@ public:
 
 private:
exec_list *instructions;
+   unsigned stage;
+   unsigned const_count;
bool progress;
 };
 
@@ -80,7 +84,11 @@ lower_const_array_visitor::handle_rvalue(ir_rvalue **rvalue)
 
void *mem_ctx = ralloc_parent(con);
 
-   char *uniform_name = ralloc_asprintf(mem_ctx, "constarray__%p", dra);
+   char *uniform_name = ralloc_asprintf(mem_ctx, "constarray_%x_%u",
+const_count, stage);
+   unsigned limit = ~0;
+   assert(const_count != limit);
+   const_count++;
 
ir_variable *uni =
   new(mem_ctx) ir_variable(con->type, uniform_name, ir_var_uniform);
@@ -102,8 +110,8 @@ lower_const_array_visitor::handle_rvalue(ir_rvalue **rvalue)
 } /* anonymous namespace */
 
 bool
-lower_const_arrays_to_uniforms(exec_list *instructions)
+lower_const_arrays_to_uniforms(exec_list *instructions, unsigned stage)
 {
-   lower_const_array_visitor v(instructions);
+   lower_const_array_visitor v(instructions, stage);
return v.run();
 }
-- 
2.5.5

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


[Mesa-dev] [PATCH 40/65] glsl: cache clip distance array size

2016-04-29 Thread Timothy Arceri
---
 src/compiler/glsl/shader_cache.cpp | 4 
 1 file changed, 4 insertions(+)

diff --git a/src/compiler/glsl/shader_cache.cpp 
b/src/compiler/glsl/shader_cache.cpp
index ff94dbf..d3d329c 100644
--- a/src/compiler/glsl/shader_cache.cpp
+++ b/src/compiler/glsl/shader_cache.cpp
@@ -898,6 +898,8 @@ write_shader_metadata(struct blob *metadata, gl_shader 
*shader)
   blob_write_uint32(metadata, shader->num_samplers);
   blob_write_uint32(metadata, shader->active_samplers);
 
+  blob_write_uint32(metadata, glprog->ClipDistanceArraySize);
+
   if (shader->Stage == MESA_SHADER_FRAGMENT) {
  struct gl_fragment_program *fprog =
 (struct gl_fragment_program *) glprog;
@@ -935,6 +937,8 @@ read_shader_metadata(struct blob_reader *metadata,
   linked->num_samplers = blob_read_uint32(metadata);
   linked->active_samplers = blob_read_uint32(metadata);
 
+  glprog->ClipDistanceArraySize = blob_read_uint32(metadata);
+
   if (linked->Stage == MESA_SHADER_FRAGMENT) {
  struct gl_fragment_program *fprog =
 (struct gl_fragment_program *) glprog;
-- 
2.5.5

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


[Mesa-dev] [PATCH 57/65] glsl,i965: disable shader cache for SSO

2016-04-29 Thread Timothy Arceri
Caching SSO requires us to be a little more careful so disable
it for now.
---
 src/compiler/glsl/linker.cpp | 2 +-
 src/mesa/drivers/dri/i965/brw_shader_cache.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/compiler/glsl/linker.cpp b/src/compiler/glsl/linker.cpp
index 1f8350c..5bc7337 100644
--- a/src/compiler/glsl/linker.cpp
+++ b/src/compiler/glsl/linker.cpp
@@ -4317,7 +4317,7 @@ link_shaders(struct gl_context *ctx, struct 
gl_shader_program *prog,
 
 #ifdef ENABLE_SHADER_CACHE
/* If transform feedback used on the program then compile all shaders. */
-   if (prog->TransformFeedback.NumVarying > 0) {
+   if (prog->TransformFeedback.NumVarying > 0 || prog->SeparateShader) {
   for (unsigned i = 0; i < prog->NumShaders; i++) {
  if (prog->Shaders[i]->ir) {
 continue;
diff --git a/src/mesa/drivers/dri/i965/brw_shader_cache.c 
b/src/mesa/drivers/dri/i965/brw_shader_cache.c
index 07f3a64..08d43e7 100644
--- a/src/mesa/drivers/dri/i965/brw_shader_cache.c
+++ b/src/mesa/drivers/dri/i965/brw_shader_cache.c
@@ -103,7 +103,7 @@ upload_cached_program(struct brw_context *brw)
 * enabled. However we should be able to use cached shaders when the xfb_*
 * qualifiers were used to enable transform feedback.
 */
-   if (prog->TransformFeedback.NumVarying > 0)
+   if (prog->TransformFeedback.NumVarying > 0 || prog->SeparateShader)
   return;
 
gen_binary_sha1(brw, prog, &vs_key, &wm_key);
-- 
2.5.5

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


[Mesa-dev] [PATCH 41/65] glsl: cache some more image metadata

2016-04-29 Thread Timothy Arceri
---
 src/compiler/glsl/shader_cache.cpp | 12 
 1 file changed, 12 insertions(+)

diff --git a/src/compiler/glsl/shader_cache.cpp 
b/src/compiler/glsl/shader_cache.cpp
index d3d329c..f8c56ce 100644
--- a/src/compiler/glsl/shader_cache.cpp
+++ b/src/compiler/glsl/shader_cache.cpp
@@ -900,6 +900,12 @@ write_shader_metadata(struct blob *metadata, gl_shader 
*shader)
 
   blob_write_uint32(metadata, glprog->ClipDistanceArraySize);
 
+  blob_write_uint32(metadata, shader->NumImages);
+  blob_write_bytes(metadata, shader->ImageAccess,
+   sizeof(shader->ImageAccess));
+  blob_write_bytes(metadata, shader->ImageUnits,
+   sizeof(shader->ImageUnits));
+
   if (shader->Stage == MESA_SHADER_FRAGMENT) {
  struct gl_fragment_program *fprog =
 (struct gl_fragment_program *) glprog;
@@ -939,6 +945,12 @@ read_shader_metadata(struct blob_reader *metadata,
 
   glprog->ClipDistanceArraySize = blob_read_uint32(metadata);
 
+  linked->NumImages  = blob_read_uint32(metadata);
+  blob_copy_bytes(metadata, (uint8_t *) linked->ImageAccess,
+  sizeof(linked->ImageAccess));
+  blob_copy_bytes(metadata, (uint8_t *) linked->ImageUnits,
+  sizeof(linked->ImageUnits));
+
   if (linked->Stage == MESA_SHADER_FRAGMENT) {
  struct gl_fragment_program *fprog =
 (struct gl_fragment_program *) glprog;
-- 
2.5.5

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


[Mesa-dev] [PATCH 16/65] i965: don't crash when there is no shader and there are uniforms

2016-04-29 Thread Timothy Arceri
---
 src/mesa/drivers/dri/i965/brw_shader_cache.c | 35 
 1 file changed, 25 insertions(+), 10 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_shader_cache.c 
b/src/mesa/drivers/dri/i965/brw_shader_cache.c
index c565e5a..e5aa022 100644
--- a/src/mesa/drivers/dri/i965/brw_shader_cache.c
+++ b/src/mesa/drivers/dri/i965/brw_shader_cache.c
@@ -118,12 +118,15 @@ upload_cached_program(struct brw_context *brw)
   intptr_t param = blob_read_intptr(&binary);
   ptrdiff_t p_offset, u_offset;
   struct gl_program_parameter_list *param_list =
- prog->_LinkedShaders[MESA_SHADER_VERTEX]->Program->Parameters;
+ prog->_LinkedShaders[MESA_SHADER_VERTEX] ?
+prog->_LinkedShaders[MESA_SHADER_VERTEX]->Program->Parameters :
+NULL;
 
   p_offset = (param - parameter_values_base) / sizeof(gl_constant_value);
   u_offset = (param - uniform_data_slots_base) / sizeof(gl_constant_value);
   
-  if (p_offset >= 0 && p_offset < 4 * param_list->NumParameters) {
+  if (param_list && p_offset >= 0 &&
+  p_offset < 4 * param_list->NumParameters) {
  prog_data->param[i] =
 ((gl_constant_value *) param_list->ParameterValues) + p_offset;
   } else if (u_offset >= 0 && u_offset < prog->NumUniformDataSlots) {
@@ -182,12 +185,15 @@ upload_cached_program(struct brw_context *brw)
   intptr_t param = blob_read_intptr(&binary);
   ptrdiff_t p_offset, u_offset;
   struct gl_program_parameter_list *param_list =
- prog->_LinkedShaders[MESA_SHADER_FRAGMENT]->Program->Parameters;
+ prog->_LinkedShaders[MESA_SHADER_FRAGMENT] ?
+prog->_LinkedShaders[MESA_SHADER_FRAGMENT]->Program->Parameters :
+NULL;
 
   p_offset = (param - parameter_values_base) / sizeof(gl_constant_value);
   u_offset = (param - uniform_data_slots_base) / sizeof(gl_constant_value);
   
-  if (p_offset >= 0 && p_offset < 4 * param_list->NumParameters) {
+  if (param_list && p_offset >= 0 &&
+  p_offset < 4 * param_list->NumParameters) {
  prog_data->param[i] =
 ((gl_constant_value *) param_list->ParameterValues) + p_offset;
   } else if (u_offset >= 0 && u_offset < prog->NumUniformDataSlots) {
@@ -288,9 +294,14 @@ write_cached_program(struct brw_context *brw)
 * together with the pointer values to correctly construct pointers to the
 * actual storage when the program data is loaded from the cache.
 */
-   blob_write_intptr(binary,
- (intptr_t) prog->_LinkedShaders[MESA_SHADER_VERTEX]->
-  Program->Parameters->ParameterValues);
+   if (prog->_LinkedShaders[MESA_SHADER_VERTEX]) {
+  blob_write_intptr(binary,
+(intptr_t) prog->_LinkedShaders[MESA_SHADER_VERTEX]->
+ Program->Parameters->ParameterValues);
+   } else {
+  blob_write_intptr(binary, 0);
+   }
+
blob_write_intptr(binary, (intptr_t) prog->UniformDataSlots);
 
nr_params = brw->vs.prog_data->base.base.nr_params;
@@ -325,9 +336,13 @@ write_cached_program(struct brw_context *brw)
/* Include variable-length params, (don't need to rewrite UniformDataSlots
 * pointer).
 */
-   blob_write_intptr(binary,
- (intptr_t) prog->_LinkedShaders[MESA_SHADER_FRAGMENT]->
- Program->Parameters->ParameterValues);
+   if (prog->_LinkedShaders[MESA_SHADER_FRAGMENT]) {
+  blob_write_intptr(binary,
+(intptr_t) prog->_LinkedShaders[MESA_SHADER_FRAGMENT]->
+Program->Parameters->ParameterValues);
+   } else {
+  blob_write_intptr(binary, 0);
+   }
 
nr_params = brw->wm.prog_data->base.nr_params;
blob_write_uint32(binary, nr_params);
-- 
2.5.5

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


[Mesa-dev] [PATCH 27/65] glsl: compile shaders when program not found in cache

2016-04-29 Thread Timothy Arceri
We may have seen the individual shaders before and skipped compiling
but they may not have been used together in this combination before.

We could probably only compile the shaders which were skipped here
but we need to be careful because the source may also have been
changed since the last compile so for now we just recompile
everything.
---
 src/compiler/glsl/shader_cache.cpp | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/compiler/glsl/shader_cache.cpp 
b/src/compiler/glsl/shader_cache.cpp
index 6d979ad..8b8a28c 100644
--- a/src/compiler/glsl/shader_cache.cpp
+++ b/src/compiler/glsl/shader_cache.cpp
@@ -658,9 +658,10 @@ shader_cache_read_program_metadata(struct gl_context *ctx,
_mesa_sha1_compute(buf, offset, prog->sha1);
buffer = (uint8_t *) cache_get(cache, prog->sha1, &size);
if (buffer == NULL) {
-  /* FIXME: Fall back and link shaders here, if necessary, compile any
-   * shaders we didn't compile earlier.
+  /* Cached program not found. Fall back to linking shaders but first
+   * compile any shaders we didn't compile earlier.
*/
+  compile_shaders(ctx, prog);
   return false;
}
 
-- 
2.5.5

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


[Mesa-dev] [PATCH 39/65] glsl: don't crash when dumping shaders if some come from cache

2016-04-29 Thread Timothy Arceri
---
 src/mesa/drivers/dri/i965/brw_link.cpp | 6 +-
 src/mesa/main/shaderapi.c  | 6 +-
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_link.cpp 
b/src/mesa/drivers/dri/i965/brw_link.cpp
index d4bbd8b..7809b4c 100644
--- a/src/mesa/drivers/dri/i965/brw_link.cpp
+++ b/src/mesa/drivers/dri/i965/brw_link.cpp
@@ -176,7 +176,11 @@ process_glsl_ir(gl_shader_stage stage,
   fprintf(stderr, "GLSL IR for linked %s program %d:\n",
   _mesa_shader_stage_to_string(shader->Stage),
   shader_prog->Name);
-  _mesa_print_ir(stderr, shader->ir, NULL);
+  if (shader->ir) {
+ _mesa_print_ir(stderr, shader->ir, NULL);
+  } else {
+ fprintf(stderr, "No IR to print shader may be from cache\n");
+  }
   fprintf(stderr, "\n");
}
 }
diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c
index 3e54709..9857bbc 100644
--- a/src/mesa/main/shaderapi.c
+++ b/src/mesa/main/shaderapi.c
@@ -989,7 +989,11 @@ _mesa_compile_shader(struct gl_context *ctx, struct 
gl_shader *sh)
   if (ctx->_Shader->Flags & GLSL_DUMP) {
  if (sh->CompileStatus) {
 _mesa_log("GLSL IR for shader %d:\n", sh->Name);
-_mesa_print_ir(_mesa_get_log_file(), sh->ir, NULL);
+if (sh->ir) {
+   _mesa_print_ir(_mesa_get_log_file(), sh->ir, NULL);
+} else {
+   _mesa_log("No IR to print shader may be from cache\n");
+}
 _mesa_log("\n\n");
  } else {
 _mesa_log("GLSL shader %d failed to compile.\n", sh->Name);
-- 
2.5.5

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


[Mesa-dev] [PATCH 30/65] glsl, i965: don't used shader cache when transform feedback enabled

2016-04-29 Thread Timothy Arceri
Note in future we may want to use the cache when in shader xfb
qualifiers override the API.
---
 src/compiler/glsl/linker.cpp | 11 +++
 src/compiler/glsl/shader_cache.cpp   |  7 +++
 src/mesa/drivers/dri/i965/brw_shader_cache.c |  7 +++
 3 files changed, 25 insertions(+)

diff --git a/src/compiler/glsl/linker.cpp b/src/compiler/glsl/linker.cpp
index 4477768..979dbb5 100644
--- a/src/compiler/glsl/linker.cpp
+++ b/src/compiler/glsl/linker.cpp
@@ -4316,6 +4316,17 @@ link_shaders(struct gl_context *ctx, struct 
gl_shader_program *prog,
tfeedback_decl *tfeedback_decls = NULL;
 
 #ifdef ENABLE_SHADER_CACHE
+   /* If transform feedback used on the program then compile all shaders. */
+   if (prog->TransformFeedback.NumVarying > 0) {
+  for (unsigned i = 0; i < prog->NumShaders; i++) {
+ if (prog->Shaders[i]->ir) {
+continue;
+ }
+ _mesa_glsl_compile_shader(ctx, prog->Shaders[i], false, false, true);
+  }
+  skip_cache = true;
+   }
+
if (!skip_cache && shader_cache_read_program_metadata(ctx, prog))
   return;
 #endif
diff --git a/src/compiler/glsl/shader_cache.cpp 
b/src/compiler/glsl/shader_cache.cpp
index 333b262..9c7b18d 100644
--- a/src/compiler/glsl/shader_cache.cpp
+++ b/src/compiler/glsl/shader_cache.cpp
@@ -356,6 +356,13 @@ write_program_resource_data(struct blob *metadata,
  }
   }
   break;
+   case GL_TRANSFORM_FEEDBACK_BUFFER:
+   case GL_TRANSFORM_FEEDBACK_VARYING:
+  /* Don't bother caching transform feedback varyings/buffers as we will
+   * always relink a program which enables transform feedback.
+   * TODO: We may want to this for shaders that use the xfb_* qualifiers.
+   */
+  break;
default:
   assert(!"Support for writting resource not yet implemneted.");
}
diff --git a/src/mesa/drivers/dri/i965/brw_shader_cache.c 
b/src/mesa/drivers/dri/i965/brw_shader_cache.c
index e5aa022..7945b16 100644
--- a/src/mesa/drivers/dri/i965/brw_shader_cache.c
+++ b/src/mesa/drivers/dri/i965/brw_shader_cache.c
@@ -66,6 +66,13 @@ upload_cached_program(struct brw_context *brw)
if (prog == NULL)
   return;
 
+   /* FIXME: For now we don't read from the cache if transform feedback is
+* enabled. However we should be able to use cached shaders when the xfb_*
+* qualifiers were used to enable transform feedback.
+*/
+   if (prog->TransformFeedback.NumVarying > 0)
+  return;
+
offset += snprintf(manifest + offset, sizeof(manifest) - offset,
   "program: %s\n", _mesa_sha1_format(sha1_buf, 
prog->sha1));
 
-- 
2.5.5

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


[Mesa-dev] [PATCH 25/65] glsl: add basic support for resource list to shader cache

2016-04-29 Thread Timothy Arceri
This initially adds support for simple uniforms and varyings.
---
 src/compiler/glsl/shader_cache.cpp | 117 +
 1 file changed, 117 insertions(+)

diff --git a/src/compiler/glsl/shader_cache.cpp 
b/src/compiler/glsl/shader_cache.cpp
index fae90ae..63aa450 100644
--- a/src/compiler/glsl/shader_cache.cpp
+++ b/src/compiler/glsl/shader_cache.cpp
@@ -312,6 +312,119 @@ read_hash_tables(struct blob_reader *metadata, struct 
gl_shader_program *prog)
 }
 
 static void
+write_program_resource_data(struct blob *metadata,
+struct gl_shader_program *prog,
+struct gl_program_resource *res)
+{
+   switch(res->Type) {
+   case GL_PROGRAM_INPUT:
+   case GL_PROGRAM_OUTPUT: {
+  const gl_shader_variable *var = (gl_shader_variable *)res->Data;
+  encode_type_to_blob(metadata, var->type);
+  blob_write_string(metadata, var->name);
+  blob_write_uint32(metadata, var->location);
+
+  unsigned data = var->index;
+  data |= var->patch << 1;
+  data |= var->mode << 2;
+  blob_write_uint32(metadata, data);
+  break;
+   }
+   case GL_BUFFER_VARIABLE:
+   case GL_VERTEX_SUBROUTINE_UNIFORM:
+   case GL_GEOMETRY_SUBROUTINE_UNIFORM:
+   case GL_FRAGMENT_SUBROUTINE_UNIFORM:
+   case GL_COMPUTE_SUBROUTINE_UNIFORM:
+   case GL_TESS_CONTROL_SUBROUTINE_UNIFORM:
+   case GL_TESS_EVALUATION_SUBROUTINE_UNIFORM:
+   case GL_UNIFORM:
+  for (unsigned i = 0; i < prog->NumUniformStorage; i++) {
+ if (prog->UniformStorage[i].hidden)
+break; /* No more user defined uniforms */
+
+ if (strcmp(((gl_uniform_storage *)res->Data)->name,
+prog->UniformStorage[i].name) == 0) {
+blob_write_uint32(metadata, i);
+break;
+ }
+  }
+  break;
+   default:
+  assert(!"Support for writting resource not yet implemneted.");
+   }
+}
+
+static void
+read_program_resource_data(struct blob_reader *metadata,
+   struct gl_shader_program *prog,
+   struct gl_program_resource *res)
+{
+   switch(res->Type) {
+   case GL_PROGRAM_INPUT:
+   case GL_PROGRAM_OUTPUT: {
+  gl_shader_variable *var = ralloc(prog, struct gl_shader_variable);
+  var->type = decode_type_from_blob(metadata);
+  var->name = ralloc_strdup(prog, blob_read_string(metadata));
+  var->location = blob_read_uint32(metadata);
+
+  unsigned data = blob_read_uint32(metadata);
+  var->index = data & 1;
+  var->patch = data >> 1 & 1;
+  var->mode = data >> 2;
+
+  res->Data = var;
+  break;
+   }
+   case GL_BUFFER_VARIABLE:
+   case GL_VERTEX_SUBROUTINE_UNIFORM:
+   case GL_GEOMETRY_SUBROUTINE_UNIFORM:
+   case GL_FRAGMENT_SUBROUTINE_UNIFORM:
+   case GL_COMPUTE_SUBROUTINE_UNIFORM:
+   case GL_TESS_CONTROL_SUBROUTINE_UNIFORM:
+   case GL_TESS_EVALUATION_SUBROUTINE_UNIFORM:
+   case GL_UNIFORM:
+  res->Data = &prog->UniformStorage[blob_read_uint32(metadata)];
+  break;
+   default:
+  assert(!"Support for reading resource not yet implemneted.");
+   }
+}
+
+static void
+write_program_resource_list(struct blob *metadata,
+struct gl_shader_program *prog)
+{
+   blob_write_uint32(metadata, prog->NumProgramResourceList);
+
+   for (unsigned i = 0; i < prog->NumProgramResourceList; i++) {
+  blob_write_uint32(metadata, prog->ProgramResourceList[i].Type);
+  write_program_resource_data(metadata, prog,
+  &prog->ProgramResourceList[i]);
+  blob_write_bytes(metadata, &prog->ProgramResourceList[i].StageReferences,
+   sizeof(prog->ProgramResourceList[i].StageReferences));
+   }
+}
+
+static void
+read_program_resource_list(struct blob_reader *metadata,
+   struct gl_shader_program *prog)
+{
+   prog->NumProgramResourceList = blob_read_uint32(metadata);
+
+   prog->ProgramResourceList = ralloc_array(prog, gl_program_resource,
+prog->NumProgramResourceList);
+
+   for (unsigned i = 0; i < prog->NumProgramResourceList; i++) {
+  prog->ProgramResourceList[i].Type = blob_read_uint32(metadata);
+  read_program_resource_data(metadata, prog,
+ &prog->ProgramResourceList[i]);
+  blob_copy_bytes(metadata,
+  (uint8_t *) 
&prog->ProgramResourceList[i].StageReferences,
+  sizeof(prog->ProgramResourceList[i].StageReferences));
+   }
+}
+
+static void
 write_shader_parameters(struct blob *metadata,
 struct gl_program_parameter_list *params)
 {
@@ -451,6 +564,8 @@ shader_cache_write_program_metadata(struct gl_context *ctx,
 
write_uniform_remap_table(metadata, prog);
 
+   write_program_resource_list(metadata, prog);
+
write_shader_metadata(metadata, prog->_LinkedShaders[MESA_SHADER_VERTEX]);
write_shader_metadata(metadata, prog->_LinkedShaders[

[Mesa-dev] [PATCH 17/65] glsl: fix uniform remap table cache when explicit locations used

2016-04-29 Thread Timothy Arceri
---
 src/compiler/glsl/shader_cache.cpp | 24 +++-
 1 file changed, 15 insertions(+), 9 deletions(-)

diff --git a/src/compiler/glsl/shader_cache.cpp 
b/src/compiler/glsl/shader_cache.cpp
index 98015c4..0c9ae9f 100644
--- a/src/compiler/glsl/shader_cache.cpp
+++ b/src/compiler/glsl/shader_cache.cpp
@@ -179,11 +179,11 @@ static void
 write_uniform_remap_table(struct blob *metadata,
   struct gl_shader_program *prog)
 {
+   blob_write_intptr(metadata, (intptr_t) prog->UniformStorage);
blob_write_uint32(metadata, prog->NumUniformRemapTable);
 
for (unsigned i = 0; i < prog->NumUniformRemapTable; i++) {
-  blob_write_uint32(metadata,
-prog->UniformRemapTable[i] - prog->UniformStorage);
+  blob_write_intptr(metadata, (intptr_t) prog->UniformRemapTable[i]);
}
 }
 
@@ -191,16 +191,22 @@ static void
 read_uniform_remap_table(struct blob_reader *metadata,
  struct gl_shader_program *prog)
 {
-   unsigned i;
-
+   intptr_t uni_store_base = blob_read_intptr(metadata);
prog->NumUniformRemapTable = blob_read_uint32(metadata);
 
-   prog->UniformRemapTable =rzalloc_array(prog, struct gl_uniform_storage *,
-  prog->NumUniformRemapTable);
+   prog->UniformRemapTable = rzalloc_array(prog, struct gl_uniform_storage *,
+   prog->NumUniformRemapTable);
 
-   for (i = 0; i < prog->NumUniformRemapTable; i++) {
-  prog->UniformRemapTable[i] =
- prog->UniformStorage + blob_read_uint32(metadata);
+   for (unsigned i = 0; i < prog->NumUniformRemapTable; i++) {
+  intptr_t uni_ptr = blob_read_intptr(metadata);
+  if (uni_ptr == (intptr_t) INACTIVE_UNIFORM_EXPLICIT_LOCATION ||
+  uni_ptr == (intptr_t) NULL) {
+ prog->UniformRemapTable[i] = (gl_uniform_storage *) uni_ptr;
+  } else {
+ intptr_t uni_offset =
+(uni_ptr - uni_store_base) / sizeof(gl_uniform_storage);
+ prog->UniformRemapTable[i] = prog->UniformStorage + uni_offset;
+  }
}
 }
 
-- 
2.5.5

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


[Mesa-dev] [PATCH 29/65] glsl: skip linking when current program has been retrieved from cache

2016-04-29 Thread Timothy Arceri
The scenario is a program has been linked for the first time and we
cache the program metadata, then glLinkProgram() is called for a second
time. Since we will now retrieve the program metadata from cache we need
to skip linking.
---
 src/compiler/glsl/shader_cache.cpp | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/compiler/glsl/shader_cache.cpp 
b/src/compiler/glsl/shader_cache.cpp
index 8b8a28c..333b262 100644
--- a/src/compiler/glsl/shader_cache.cpp
+++ b/src/compiler/glsl/shader_cache.cpp
@@ -699,6 +699,7 @@ shader_cache_read_program_metadata(struct gl_context *ctx,
   "discard the item from the cache and rebuild from source.\n");
}
 
+   prog->Version = 0; /* This is used to flag a shader retrieved from cache */
prog->LinkStatus = true;
 
free (buffer);
-- 
2.5.5

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


[Mesa-dev] [PATCH 09/65] i965: add new sha1 field to context struct

2016-04-29 Thread Timothy Arceri
From: Carl Worth 

Signed-off-by: Timothy Arceri 
---
 src/mesa/drivers/dri/i965/brw_context.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/mesa/drivers/dri/i965/brw_context.h 
b/src/mesa/drivers/dri/i965/brw_context.h
index e449982..d46a63b 100644
--- a/src/mesa/drivers/dri/i965/brw_context.h
+++ b/src/mesa/drivers/dri/i965/brw_context.h
@@ -1006,6 +1006,8 @@ struct brw_context
const struct gl_fragment_program *fragment_program;
const struct gl_compute_program *compute_program;
 
+   unsigned char binary_sha1[20];
+
/**
 * Number of samples in ctx->DrawBuffer, updated by BRW_NEW_NUM_SAMPLES so
 * that we don't have to reemit that state every time we change FBOs.
-- 
2.5.5

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


[Mesa-dev] [PATCH 22/65] glsl: cache more uniform storage values

2016-04-29 Thread Timothy Arceri
---
 src/compiler/glsl/shader_cache.cpp | 18 --
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/src/compiler/glsl/shader_cache.cpp 
b/src/compiler/glsl/shader_cache.cpp
index 8f2e1ef..092e6e3 100644
--- a/src/compiler/glsl/shader_cache.cpp
+++ b/src/compiler/glsl/shader_cache.cpp
@@ -138,10 +138,19 @@ write_uniforms(struct blob *metadata, struct 
gl_shader_program *prog)
   printf("uniform %s %s\n",
  prog->UniformStorage[i].type->name,
  prog->UniformStorage[i].name);
+  blob_write_uint32(metadata, prog->UniformStorage[i].array_elements);
   blob_write_string(metadata, prog->UniformStorage[i].name);
   blob_write_uint32(metadata, prog->UniformStorage[i].storage -
   prog->UniformDataSlots);
   blob_write_uint32(metadata, prog->UniformStorage[i].remap_location);
+
+  blob_write_uint32(metadata, prog->UniformStorage[i].block_index);
+  blob_write_uint32(metadata, prog->UniformStorage[i].atomic_buffer_index);
+  blob_write_uint32(metadata, prog->UniformStorage[i].offset);
+  blob_write_uint32(metadata, prog->UniformStorage[i].array_stride);
+  blob_write_uint32(metadata, prog->UniformStorage[i].matrix_stride);
+  blob_write_uint32(metadata, prog->UniformStorage[i].row_major);
+
   encode_type_to_blob(metadata, prog->UniformStorage[i].type);
}
 }
@@ -168,11 +177,16 @@ read_uniforms(struct blob_reader *metadata, struct 
gl_shader_program *prog)
prog->UniformHash = new string_to_uint_map;
 
for (i = 0; i < prog->NumUniformStorage; i++) {
+  uniforms[i].array_elements = blob_read_uint32(metadata);
   uniforms[i].name = ralloc_strdup(prog, blob_read_string (metadata));
   uniforms[i].storage = data + blob_read_uint32(metadata);
   uniforms[i].remap_location = blob_read_uint32(metadata);
-  uniforms[i].block_index = -1;
-  uniforms[i].atomic_buffer_index = -1;
+  uniforms[i].block_index = blob_read_uint32(metadata);
+  uniforms[i].atomic_buffer_index = blob_read_uint32(metadata);
+  uniforms[i].offset = blob_read_uint32(metadata);
+  uniforms[i].array_stride = blob_read_uint32(metadata);
+  uniforms[i].matrix_stride = blob_read_uint32(metadata);
+  uniforms[i].row_major = blob_read_uint32(metadata);
   uniforms[i].type = decode_type_from_blob(metadata);
   prog->UniformHash->put(i, uniforms[i].name);
 
-- 
2.5.5

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


[Mesa-dev] [PATCH 20/65] glsl: include bindings when creating sha1 for metadata

2016-04-29 Thread Timothy Arceri
These bindings change the resulting binary so they are just as
important as the shader source.
---
 src/compiler/glsl/shader_cache.cpp | 21 +
 1 file changed, 21 insertions(+)

diff --git a/src/compiler/glsl/shader_cache.cpp 
b/src/compiler/glsl/shader_cache.cpp
index 9c5095c..575c518 100644
--- a/src/compiler/glsl/shader_cache.cpp
+++ b/src/compiler/glsl/shader_cache.cpp
@@ -389,6 +389,13 @@ read_shader_metadata(struct blob_reader *metadata,
}
 }
 
+static void
+create_binding_str(const char *key, unsigned value, void *closure)
+{
+   char **bindings_str = (char **) closure;
+   ralloc_asprintf_append(bindings_str, "%s:%u,", key, value);
+}
+
 void
 shader_cache_write_program_metadata(struct gl_context *ctx,
 struct gl_shader_program *prog)
@@ -443,6 +450,7 @@ shader_cache_read_program_metadata(struct gl_context *ctx,
 {
const char *stage_name[] = { "vs", "tcs", "tes", "gs", "fs", "cs" };
char buf[256], sha1buf[41];
+   unsigned char sha1[20];
int offset = 0;
uint8_t *buffer;
struct program_cache *cache;
@@ -463,6 +471,19 @@ shader_cache_read_program_metadata(struct gl_context *ctx,
   }
}
 
+   char *bindings_str = ralloc_strdup(NULL, "vb: ");
+   prog->AttributeBindings->iterate(create_binding_str, &bindings_str);
+   ralloc_strcat(&bindings_str, "fb: ");
+   prog->FragDataBindings->iterate(create_binding_str, &bindings_str);
+   ralloc_strcat(&bindings_str, "fbi: ");
+   prog->FragDataIndexBindings->iterate(create_binding_str, &bindings_str);
+   _mesa_sha1_compute(bindings_str, strlen(bindings_str), sha1);
+   ralloc_free(bindings_str);
+
+   offset += snprintf(buf + offset, sizeof(buf) - offset,
+  "bindings: %s\n",
+  _mesa_sha1_format(sha1buf, sha1));
+
for (unsigned i = 0; i < prog->NumShaders; i++) {
   if (prog->Shaders[i]->Source == NULL)
  return false;
-- 
2.5.5

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


[Mesa-dev] [PATCH 21/65] glsl: don't support caching single vs or fs shaders

2016-04-29 Thread Timothy Arceri
We can add support for this later for now skip these programs.
---
 src/compiler/glsl/shader_cache.cpp | 5 +
 1 file changed, 5 insertions(+)

diff --git a/src/compiler/glsl/shader_cache.cpp 
b/src/compiler/glsl/shader_cache.cpp
index 575c518..8f2e1ef 100644
--- a/src/compiler/glsl/shader_cache.cpp
+++ b/src/compiler/glsl/shader_cache.cpp
@@ -463,6 +463,11 @@ shader_cache_read_program_metadata(struct gl_context *ctx,
if (!cache)
   return false;
 
+   if (prog->NumShaders == 1) {
+  compile_shaders(ctx, prog);
+  return false;
+   }
+
for (unsigned i = 0; i < prog->NumShaders; i++) {
   if (prog->Shaders[i]->Stage != MESA_SHADER_VERTEX &&
   prog->Shaders[i]->Stage != MESA_SHADER_FRAGMENT) {
-- 
2.5.5

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


[Mesa-dev] [PATCH 26/65] glsl: add shader cache support for samplers

2016-04-29 Thread Timothy Arceri
---
 src/compiler/glsl/shader_cache.cpp | 25 +
 1 file changed, 21 insertions(+), 4 deletions(-)

diff --git a/src/compiler/glsl/shader_cache.cpp 
b/src/compiler/glsl/shader_cache.cpp
index 63aa450..6d979ad 100644
--- a/src/compiler/glsl/shader_cache.cpp
+++ b/src/compiler/glsl/shader_cache.cpp
@@ -158,6 +158,9 @@ write_uniforms(struct blob *metadata, struct 
gl_shader_program *prog)
 prog->UniformStorage[i].top_level_array_stride);
 
   encode_type_to_blob(metadata, prog->UniformStorage[i].type);
+
+  blob_write_bytes(metadata, prog->UniformStorage[i].opaque,
+   sizeof(prog->UniformStorage[i].opaque));
}
 }
 
@@ -200,6 +203,10 @@ read_uniforms(struct blob_reader *metadata, struct 
gl_shader_program *prog)
 
   prog->UniformHash->put(i, uniforms[i].name);
 
+  memcpy(uniforms[i].opaque,
+ blob_read_bytes(metadata, sizeof(uniforms[i].opaque)),
+ sizeof(uniforms[i].opaque));
+
   printf("uniform %d: %s %s\n",
  i, uniforms[i].type->name, uniforms[i].name);
}
@@ -488,8 +495,13 @@ write_shader_metadata(struct blob *metadata, gl_shader 
*shader)
   blob_write_uint64(metadata, glprog->OutputsWritten);
   blob_write_bytes(metadata, glprog->TexturesUsed,
sizeof(glprog->TexturesUsed));
-  blob_write_uint64(metadata, glprog->SamplersUsed);
-  blob_write_uint64(metadata, shader->num_samplers);
+  blob_write_bytes(metadata, glprog->SamplerUnits,
+   sizeof(glprog->SamplerUnits));
+  blob_write_bytes(metadata, shader->SamplerTargets,
+   sizeof(shader->SamplerTargets));
+  blob_write_uint32(metadata, glprog->SamplersUsed);
+  blob_write_uint32(metadata, shader->num_samplers);
+  blob_write_uint32(metadata, shader->active_samplers);
 
   write_shader_parameters(metadata, glprog->Parameters);
 
@@ -513,8 +525,13 @@ read_shader_metadata(struct blob_reader *metadata,
   glprog->OutputsWritten = blob_read_uint64(metadata);
   blob_copy_bytes(metadata, (uint8_t *) glprog->TexturesUsed,
   sizeof(glprog->TexturesUsed));
-  glprog->SamplersUsed = blob_read_uint64(metadata);
-  linked->num_samplers = blob_read_uint64(metadata);
+  blob_copy_bytes(metadata, (uint8_t *) glprog->SamplerUnits,
+  sizeof(glprog->SamplerUnits));
+  blob_copy_bytes(metadata, (uint8_t *) linked->SamplerTargets,
+  sizeof(linked->SamplerTargets));
+  glprog->SamplersUsed = blob_read_uint32(metadata);
+  linked->num_samplers = blob_read_uint32(metadata);
+  linked->active_samplers = blob_read_uint32(metadata);
 
   glprog->Parameters = _mesa_new_parameter_list();
 
-- 
2.5.5

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


[Mesa-dev] [PATCH 19/65] glsl: skip shader cache unless program is a vs+fs

2016-04-29 Thread Timothy Arceri
---
 src/compiler/glsl/shader_cache.cpp | 20 +++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/src/compiler/glsl/shader_cache.cpp 
b/src/compiler/glsl/shader_cache.cpp
index 0c9ae9f..9c5095c 100644
--- a/src/compiler/glsl/shader_cache.cpp
+++ b/src/compiler/glsl/shader_cache.cpp
@@ -52,6 +52,13 @@ extern "C" {
 }
 
 static void
+compile_shaders(struct gl_context *ctx, struct gl_shader_program *prog) {
+   for (unsigned i = 0; i < prog->NumShaders; i++) {
+  _mesa_glsl_compile_shader(ctx, prog->Shaders[i], false, false, true);
+   }
+}
+
+static void
 encode_type_to_blob(struct blob *blob, const glsl_type *type)
 {
uint32_t encoding;
@@ -399,7 +406,10 @@ shader_cache_write_program_metadata(struct gl_context *ctx,
 */
if (!prog->_LinkedShaders[MESA_SHADER_VERTEX] ||
!prog->_LinkedShaders[MESA_SHADER_FRAGMENT] ||
-   prog->_LinkedShaders[MESA_SHADER_GEOMETRY])
+   prog->_LinkedShaders[MESA_SHADER_GEOMETRY] ||
+   prog->_LinkedShaders[MESA_SHADER_TESS_EVAL] ||
+   prog->_LinkedShaders[MESA_SHADER_TESS_CTRL] ||
+   prog->_LinkedShaders[MESA_SHADER_COMPUTE])
   return;
 
metadata = blob_create(NULL);
@@ -446,6 +456,14 @@ shader_cache_read_program_metadata(struct gl_context *ctx,
   return false;
 
for (unsigned i = 0; i < prog->NumShaders; i++) {
+  if (prog->Shaders[i]->Stage != MESA_SHADER_VERTEX &&
+  prog->Shaders[i]->Stage != MESA_SHADER_FRAGMENT) {
+ compile_shaders(ctx, prog);
+ return false;
+  }
+   }
+
+   for (unsigned i = 0; i < prog->NumShaders; i++) {
   if (prog->Shaders[i]->Source == NULL)
  return false;
 
-- 
2.5.5

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


[Mesa-dev] [PATCH 28/65] glsl: add support for skipping shader cache to compiler and linker

2016-04-29 Thread Timothy Arceri
---
 src/compiler/glsl/linker.cpp | 5 +++--
 src/compiler/glsl/main.cpp   | 2 +-
 src/compiler/glsl/program.h  | 3 ++-
 src/mesa/main/ff_fragment_shader.cpp | 2 +-
 src/mesa/main/shaderapi.c| 2 +-
 src/mesa/program/ir_to_mesa.cpp  | 5 +++--
 src/mesa/program/ir_to_mesa.h| 4 +++-
 7 files changed, 14 insertions(+), 9 deletions(-)

diff --git a/src/compiler/glsl/linker.cpp b/src/compiler/glsl/linker.cpp
index 2e30dae..4477768 100644
--- a/src/compiler/glsl/linker.cpp
+++ b/src/compiler/glsl/linker.cpp
@@ -4283,7 +4283,8 @@ disable_varying_optimizations_for_sso(struct 
gl_shader_program *prog)
 }
 
 void
-link_shaders(struct gl_context *ctx, struct gl_shader_program *prog)
+link_shaders(struct gl_context *ctx, struct gl_shader_program *prog,
+ bool skip_cache)
 {
prog->LinkStatus = true; /* All error paths will set this to false */
prog->Validated = false;
@@ -4315,7 +4316,7 @@ link_shaders(struct gl_context *ctx, struct 
gl_shader_program *prog)
tfeedback_decl *tfeedback_decls = NULL;
 
 #ifdef ENABLE_SHADER_CACHE
-   if (shader_cache_read_program_metadata(ctx, prog))
+   if (!skip_cache && shader_cache_read_program_metadata(ctx, prog))
   return;
 #endif
 
diff --git a/src/compiler/glsl/main.cpp b/src/compiler/glsl/main.cpp
index 56d44a9..97cedb5 100644
--- a/src/compiler/glsl/main.cpp
+++ b/src/compiler/glsl/main.cpp
@@ -426,7 +426,7 @@ main(int argc, char **argv)
if ((status == EXIT_SUCCESS) && do_link)  {
   _mesa_clear_shader_program_data(whole_program);
 
-  link_shaders(ctx, whole_program);
+  link_shaders(ctx, whole_program, true);
   status = (whole_program->LinkStatus) ? EXIT_SUCCESS : EXIT_FAILURE;
 
   if (strlen(whole_program->InfoLog) > 0)
diff --git a/src/compiler/glsl/program.h b/src/compiler/glsl/program.h
index 58a7069..1bf4ec4 100644
--- a/src/compiler/glsl/program.h
+++ b/src/compiler/glsl/program.h
@@ -40,7 +40,8 @@ _mesa_glsl_compile_shader(struct gl_context *ctx, struct 
gl_shader *shader,
 #endif
 
 extern void
-link_shaders(struct gl_context *ctx, struct gl_shader_program *prog);
+link_shaders(struct gl_context *ctx, struct gl_shader_program *prog,
+ bool skip_cache);
 
 extern void
 build_program_resource_list(struct gl_context *ctx,
diff --git a/src/mesa/main/ff_fragment_shader.cpp 
b/src/mesa/main/ff_fragment_shader.cpp
index b0ce8c4..201d49a 100644
--- a/src/mesa/main/ff_fragment_shader.cpp
+++ b/src/mesa/main/ff_fragment_shader.cpp
@@ -1262,7 +1262,7 @@ create_new_program(struct gl_context *ctx, struct 
state_key *key)
p.shader_program->Shaders[0] = p.shader;
p.shader_program->NumShaders = 1;
 
-   _mesa_glsl_link_shader(ctx, p.shader_program);
+   _mesa_glsl_link_shader(ctx, p.shader_program, false);
 
if (!p.shader_program->LinkStatus)
   _mesa_problem(ctx, "Failed to link fixed function fragment shader: %s\n",
diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c
index 5aaf043..3e54709 100644
--- a/src/mesa/main/shaderapi.c
+++ b/src/mesa/main/shaderapi.c
@@ -1039,7 +1039,7 @@ _mesa_link_program(struct gl_context *ctx, struct 
gl_shader_program *shProg)
 
FLUSH_VERTICES(ctx, _NEW_PROGRAM);
 
-   _mesa_glsl_link_shader(ctx, shProg);
+   _mesa_glsl_link_shader(ctx, shProg, false);
 
if (shProg->LinkStatus == GL_FALSE &&
(ctx->_Shader->Flags & GLSL_REPORT_ERRORS)) {
diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp
index c061dce..e950f9e 100644
--- a/src/mesa/program/ir_to_mesa.cpp
+++ b/src/mesa/program/ir_to_mesa.cpp
@@ -2987,7 +2987,8 @@ _mesa_ir_link_shader(struct gl_context *ctx, struct 
gl_shader_program *prog)
  * Link a GLSL shader program.  Called via glLinkProgram().
  */
 void
-_mesa_glsl_link_shader(struct gl_context *ctx, struct gl_shader_program *prog)
+_mesa_glsl_link_shader(struct gl_context *ctx, struct gl_shader_program *prog,
+   bool skip_cache)
 {
unsigned int i;
 
@@ -3002,7 +3003,7 @@ _mesa_glsl_link_shader(struct gl_context *ctx, struct 
gl_shader_program *prog)
}
 
if (prog->LinkStatus) {
-  link_shaders(ctx, prog);
+  link_shaders(ctx, prog, skip_cache);
}
 
/* FIXME: We look at prog->Version to determine whether we actually linked
diff --git a/src/mesa/program/ir_to_mesa.h b/src/mesa/program/ir_to_mesa.h
index a70f575..abc628a 100644
--- a/src/mesa/program/ir_to_mesa.h
+++ b/src/mesa/program/ir_to_mesa.h
@@ -33,7 +33,9 @@ struct gl_context;
 struct gl_shader;
 struct gl_shader_program;
 
-void _mesa_glsl_link_shader(struct gl_context *ctx, struct gl_shader_program 
*prog);
+void _mesa_glsl_link_shader(struct gl_context *ctx,
+struct gl_shader_program *prog,
+bool skip_cache);
 GLboolean _mesa_ir_link_shader(struct gl_context *ctx, struct 
gl_shader_program *prog);
 
 void
-- 
2.5.5

___
mesa-dev mailing list
mesa-dev@lists.f

[Mesa-dev] [PATCH 23/65] glsl: cache SSBO uniform storage values

2016-04-29 Thread Timothy Arceri
---
 src/compiler/glsl/shader_cache.cpp | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/src/compiler/glsl/shader_cache.cpp 
b/src/compiler/glsl/shader_cache.cpp
index 092e6e3..daa9056 100644
--- a/src/compiler/glsl/shader_cache.cpp
+++ b/src/compiler/glsl/shader_cache.cpp
@@ -150,6 +150,10 @@ write_uniforms(struct blob *metadata, struct 
gl_shader_program *prog)
   blob_write_uint32(metadata, prog->UniformStorage[i].array_stride);
   blob_write_uint32(metadata, prog->UniformStorage[i].matrix_stride);
   blob_write_uint32(metadata, prog->UniformStorage[i].row_major);
+  blob_write_uint32(metadata,
+prog->UniformStorage[i].top_level_array_size);
+  blob_write_uint32(metadata,
+prog->UniformStorage[i].top_level_array_stride);
 
   encode_type_to_blob(metadata, prog->UniformStorage[i].type);
}
@@ -187,7 +191,10 @@ read_uniforms(struct blob_reader *metadata, struct 
gl_shader_program *prog)
   uniforms[i].array_stride = blob_read_uint32(metadata);
   uniforms[i].matrix_stride = blob_read_uint32(metadata);
   uniforms[i].row_major = blob_read_uint32(metadata);
+  uniforms[i].top_level_array_size = blob_read_uint32(metadata);
+  uniforms[i].top_level_array_stride = blob_read_uint32(metadata);
   uniforms[i].type = decode_type_from_blob(metadata);
+
   prog->UniformHash->put(i, uniforms[i].name);
 
   printf("uniform %d: %s %s\n",
-- 
2.5.5

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


  1   2   3   >