[Mesa-dev] [PATCH 2/2] anv: do not subtract the base layer to copute depth in 3DSTATE_DEPTH_BUFFER

2017-02-23 Thread Iago Toral Quiroga
According to the PRM description of the Depth field:

  "This field specifies the total number of levels for a volume texture
   or the number of array elements allowed to be accessed starting at the
   Minimum Array Element for arrayed surfaces"

However, ISL defines array_len as the length of the range
[base_array_layer, base_array_layer + array_len], so it already represents
a value relative to the base array layer like the hardware expects.

This fixes a number of new CTS tests that would crash otherwise:
dEQP-VK.pipeline.render_to_image.*
---
 src/intel/vulkan/genX_cmd_buffer.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/src/intel/vulkan/genX_cmd_buffer.c 
b/src/intel/vulkan/genX_cmd_buffer.c
index 40a72f4..3c7b544 100644
--- a/src/intel/vulkan/genX_cmd_buffer.c
+++ b/src/intel/vulkan/genX_cmd_buffer.c
@@ -2269,8 +2269,7 @@ cmd_buffer_emit_depth_stencil(struct anv_cmd_buffer 
*cmd_buffer)
 
  assert(image->depth_surface.isl.dim != ISL_SURF_DIM_3D);
  db.Depth =
- db.RenderTargetViewExtent =
-iview->isl.array_len - iview->isl.base_array_layer - 1;
+ db.RenderTargetViewExtent = iview->isl.array_len;
 
 #if GEN_GEN >= 8
  db.SurfaceQPitch =
-- 
2.7.4

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


[Mesa-dev] [PATCH 1/2] isl: document the meaning of the array_len field in isl_view

2017-02-23 Thread Iago Toral Quiroga
---
 src/intel/isl/isl.h | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/src/intel/isl/isl.h b/src/intel/isl/isl.h
index c340e6a..e6e9459 100644
--- a/src/intel/isl/isl.h
+++ b/src/intel/isl/isl.h
@@ -934,6 +934,12 @@ struct isl_view {
 * for texturing, they are ignored.
 */
uint32_t base_array_layer;
+
+   /**
+* Array Length
+*
+* Indicates the number of array elements starting at  Base Array Layer.
+*/
uint32_t array_len;
 
struct isl_swizzle swizzle;
-- 
2.7.4

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


[Mesa-dev] [PATCH v2 6/8] nir: Add a simple int64 lowering pass

2017-02-23 Thread Jason Ekstrand
The algorithms used by this pass, especially for division, are heavily
based on the work Ian Romanick did for the similar int64 lowering pass
in the GLSL compiler.
---
 src/compiler/Makefile.sources  |   1 +
 src/compiler/nir/nir.h |  11 ++
 src/compiler/nir/nir_lower_int64.c | 284 +
 3 files changed, 296 insertions(+)
 create mode 100644 src/compiler/nir/nir_lower_int64.c

diff --git a/src/compiler/Makefile.sources b/src/compiler/Makefile.sources
index 643a018..2455d4e 100644
--- a/src/compiler/Makefile.sources
+++ b/src/compiler/Makefile.sources
@@ -221,6 +221,7 @@ NIR_FILES = \
nir/nir_lower_locals_to_regs.c \
nir/nir_lower_idiv.c \
nir/nir_lower_indirect_derefs.c \
+   nir/nir_lower_int64.c \
nir/nir_lower_io.c \
nir/nir_lower_io_to_temporaries.c \
nir/nir_lower_io_to_scalar.c \
diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
index 5243a9e..1a23e19 100644
--- a/src/compiler/nir/nir.h
+++ b/src/compiler/nir/nir.h
@@ -2540,6 +2540,17 @@ void nir_lower_to_source_mods(nir_shader *shader);
 bool nir_lower_gs_intrinsics(nir_shader *shader);
 
 typedef enum {
+   nir_lower_imul64 = (1 << 0),
+   nir_lower_isign64 = (1 << 1),
+   nir_lower_udiv64 = (1 << 2),
+   nir_lower_idiv64 = (1 << 3),
+   nir_lower_umod64 = (1 << 4),
+   nir_lower_imod64 = (1 << 5),
+} nir_lower_int64_options;
+
+bool nir_lower_int64(nir_shader *shader, nir_lower_int64_options options);
+
+typedef enum {
nir_lower_drcp = (1 << 0),
nir_lower_dsqrt = (1 << 1),
nir_lower_drsq = (1 << 2),
diff --git a/src/compiler/nir/nir_lower_int64.c 
b/src/compiler/nir/nir_lower_int64.c
new file mode 100644
index 000..32a7dae
--- /dev/null
+++ b/src/compiler/nir/nir_lower_int64.c
@@ -0,0 +1,284 @@
+/*
+ * Copyright © 2016 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#include "nir.h"
+#include "nir_builder.h"
+
+static nir_ssa_def *
+lower_umul64(nir_builder *b, nir_ssa_def *x, nir_ssa_def *y)
+{
+   nir_ssa_def *x_lo = nir_unpack_64_2x32_split_x(b, x);
+   nir_ssa_def *x_hi = nir_unpack_64_2x32_split_y(b, x);
+   nir_ssa_def *y_lo = nir_unpack_64_2x32_split_x(b, y);
+   nir_ssa_def *y_hi = nir_unpack_64_2x32_split_y(b, y);
+
+   nir_ssa_def *res_lo = nir_imul(b, x_lo, y_lo);
+   nir_ssa_def *res_hi = nir_iadd(b, nir_umul_high(b, x_lo, y_lo),
+ nir_iadd(b, nir_imul(b, x_lo, y_hi),
+ nir_imul(b, x_hi, y_lo)));
+
+   return nir_pack_64_2x32_split(b, res_lo, res_hi);
+}
+
+static nir_ssa_def *
+lower_isign64(nir_builder *b, nir_ssa_def *x)
+{
+   nir_ssa_def *x_lo = nir_unpack_64_2x32_split_x(b, x);
+   nir_ssa_def *x_hi = nir_unpack_64_2x32_split_y(b, x);
+
+   nir_ssa_def *is_non_zero = nir_i2b(b, nir_ior(b, x_lo, x_hi));
+   nir_ssa_def *res_hi = nir_ishr(b, x_hi, nir_imm_int(b, 31));
+   nir_ssa_def *res_lo = nir_ior(b, res_hi, nir_b2i(b, is_non_zero));
+
+   return nir_pack_64_2x32_split(b, res_lo, res_hi);
+}
+
+static void
+lower_udiv64_mod64(nir_builder *b, nir_ssa_def *n, nir_ssa_def *d,
+   nir_ssa_def **q, nir_ssa_def **r)
+{
+   /* TODO: We should specially handle the case where the denominator is a
+* constant.  In that case, we should be able to reduce it to a multiply by
+* a constant, some shifts, and an add.
+*/
+   nir_ssa_def *n_lo = nir_unpack_64_2x32_split_x(b, n);
+   nir_ssa_def *n_hi = nir_unpack_64_2x32_split_y(b, n);
+   nir_ssa_def *d_lo = nir_unpack_64_2x32_split_x(b, d);
+   nir_ssa_def *d_hi = nir_unpack_64_2x32_split_y(b, d);
+
+   nir_const_value v = { .u32 = { 0, 0, 0, 0 } };
+   nir_ssa_def *q_lo = nir_build_imm(b, n->num_components, 32, v);
+   nir_ssa_def *q_hi = nir_build_imm(b, n->num_components, 32, v);
+
+   nir_ssa_def *n_hi_before_if = n_hi;
+   nir_ssa_def *q_hi_before_if = q_hi;
+
+   /* If the upper 32 bits 

Re: [Mesa-dev] [PATCH] radv/ac: enable loop unrolling.

2017-02-23 Thread Matt Arsenault

> On Feb 23, 2017, at 19:44, Dave Airlie  wrote:
> 
> On 24 February 2017 at 13:36, Matt Arsenault  > wrote:
>> 
>> On Feb 23, 2017, at 19:27, Dave Airlie  wrote:
>> 
>> +static void set_unroll_metadata(struct nir_to_llvm_context *ctx,
>> +LLVMValueRef br)
>> +{
>> + unsigned kind = LLVMGetMDKindIDInContext(ctx->context, "llvm.loop", 9);
>> + LLVMValueRef md_unroll;
>> + LLVMValueRef full_arg = LLVMMDStringInContext(ctx->context,
>> "llvm.loop.unroll.full", 21);
>> + LLVMValueRef full = LLVMMDNodeInContext(ctx->context, _arg, 1);
>> +
>> + LLVMValueRef md_args[] = {NULL, full};
>> + md_unroll = LLVMMDNodeInContext(ctx->context, md_args, 2);
>> + ac_metadata_point_op0_to_itself(md_unroll);
>> +
>> + LLVMSetMetadata(br, kind, md_unroll);
>> +}
>> +
>> 
>> 
>> Why are you forcing full unrolling of all loops?
> 
> Because I copied Marek's code with little idea of what llvm does.
> 
> Should I just drop the full bits, perhaps set a llvm.loop.unroll.count = 32?
> 
> Dave.

The question is more why are you using the unroll metadata at all? It’s for 
implementing user hints like pragma unroll. By default the backend heuristics 
should be making these decisions. If this is helping benchmarks then that’s a 
datapoint that we need to play with those and increase the thresholds or 
something.

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


[Mesa-dev] [PATCH 4/4] Revert "glsl: Switch to disable-by-default for the GLSL shader cache"

2017-02-23 Thread Timothy Arceri
This reverts commit 0f60c6616e93cba72bff4fbfedb72a753ef78e05.

Piglit and all games tested so far seem to be working without
issue. This change will allow wide user testing and we can decided
before the next release if we need to turn it off again.

Reviewed-by: Marek Olšák 
Tested-by: Michel Dänzer 
---
 src/compiler/glsl/tests/cache_test.c | 5 -
 src/util/disk_cache.c| 7 ---
 2 files changed, 12 deletions(-)

diff --git a/src/compiler/glsl/tests/cache_test.c 
b/src/compiler/glsl/tests/cache_test.c
index c4e6e36..de92e5a 100644
--- a/src/compiler/glsl/tests/cache_test.c
+++ b/src/compiler/glsl/tests/cache_test.c
@@ -421,25 +421,20 @@ test_put_key_and_get_key(void)
disk_cache_destroy(cache);
 }
 #endif /* ENABLE_SHADER_CACHE */
 
 int
 main(void)
 {
 #ifdef ENABLE_SHADER_CACHE
int err;
 
-   /* While the shader cache is still experimental, this variable must
-* be set or the cache does nothing.
-*/
-   setenv("MESA_GLSL_CACHE_ENABLE", "1", 1);
-
test_disk_cache_create();
 
test_put_and_get();
 
test_put_key_and_get_key();
 
err = rmrf_local(CACHE_TEST_TMP);
expect_equal(err, 0, "Removing " CACHE_TEST_TMP " again");
 #endif /* ENABLE_SHADER_CACHE */
 
diff --git a/src/util/disk_cache.c b/src/util/disk_cache.c
index 2a0edca..7c881ed 100644
--- a/src/util/disk_cache.c
+++ b/src/util/disk_cache.c
@@ -207,27 +207,20 @@ disk_cache_create(const char *gpu_name, const char 
*timestamp)
 
/* A ralloc context for transient data during this invocation. */
local = ralloc_context(NULL);
if (local == NULL)
   goto fail;
 
/* At user request, disable shader cache entirely. */
if (getenv("MESA_GLSL_CACHE_DISABLE"))
   goto fail;
 
-   /* As a temporary measure, (while the shader cache is under
-* development, and known to not be fully functional), also require
-* the MESA_GLSL_CACHE_ENABLE variable to be set.
-*/
-   if (!getenv("MESA_GLSL_CACHE_ENABLE"))
-  goto fail;
-
/* Determine path for cache based on the first defined name as follows:
 *
 *   $MESA_GLSL_CACHE_DIR
 *   $XDG_CACHE_HOME/mesa
 *   /.cache/mesa
 */
path = getenv("MESA_GLSL_CACHE_DIR");
if (path) {
   if (mkdir_if_needed(path) == -1)
  goto fail;
-- 
2.9.3

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


[Mesa-dev] [PATCH 1/4] compiler: style clean-ups in blob.h

2017-02-23 Thread Timothy Arceri
---
 src/compiler/glsl/blob.h | 42 +-
 1 file changed, 21 insertions(+), 21 deletions(-)

diff --git a/src/compiler/glsl/blob.h b/src/compiler/glsl/blob.h
index 81b9917..21fa43d 100644
--- a/src/compiler/glsl/blob.h
+++ b/src/compiler/glsl/blob.h
@@ -71,81 +71,81 @@ struct blob_reader {
uint8_t *current;
bool overrun;
 };
 
 /**
  * Create a new, empty blob, belonging to \mem_ctx.
  *
  * \return The new blob, (or NULL in case of allocation failure).
  */
 struct blob *
-blob_create (void *mem_ctx);
+blob_create(void *mem_ctx);
 
 /**
  * Add some unstructured, fixed-size data to a blob.
  *
  * \return True unless allocation failed.
  */
 bool
-blob_write_bytes (struct blob *blob, const void *bytes, size_t to_write);
+blob_write_bytes(struct blob *blob, const void *bytes, size_t to_write);
 
 /**
  * Reserve space in \blob for a number of bytes.
  *
  * Space will be allocated within the blob for these byes, but the bytes will
  * be left uninitialized. The caller is expected to use the return value to
  * write directly (and immediately) to these bytes.
  *
  * \note The return value is valid immediately upon return, but can be
  * invalidated by any other call to a blob function. So the caller should call
  * blob_reserve_byes immediately before writing through the returned pointer.
  *
  * This function is intended to be used when interfacing with an existing API
  * that is not aware of the blob API, (so that blob_write_bytes cannot be
  * called).
  *
  * \return A pointer to space allocated within \blob to which \to_write bytes
  * can be written, (or NULL in case of any allocation error).
  */
 uint8_t *
-blob_reserve_bytes (struct blob *blob, size_t to_write);
+blob_reserve_bytes(struct blob *blob, size_t to_write);
 
 /**
  * Overwrite some data previously written to the blob.
  *
  * Writes data to an existing portion of the blob at an offset of \offset.
  * This data range must have previously been written to the blob by one of the
  * blob_write_* calls.
  *
  * For example usage, see blob_overwrite_uint32
  *
  * \return True unless the requested offset or offset+to_write lie outside
  * the current blob's size.
  */
 bool
-blob_overwrite_bytes (struct blob *blob,
-  size_t offset,
-  const void *bytes,
-  size_t to_write);
+blob_overwrite_bytes(struct blob *blob,
+ size_t offset,
+ const void *bytes,
+ size_t to_write);
 
 /**
  * Add a uint32_t to a blob.
  *
  * \note This function will only write to a uint32_t-aligned offset from the
  * beginning of the blob's data, so some padding bytes may be added to the
  * blob if this write follows some unaligned write (such as
  * blob_write_string).
  *
  * \return True unless allocation failed.
  */
 bool
-blob_write_uint32 (struct blob *blob, uint32_t value);
+blob_write_uint32(struct blob *blob, uint32_t value);
 
 /**
  * Overwrite a uint32_t previously written to the blob.
  *
  * Writes a uint32_t value to an existing portion of the blob at an offset of
  * \offset.  This data range must have previously been written to the blob by
  * one of the blob_write_* calls.
  *
  *
  * The expected usage is something like the following pattern:
@@ -154,138 +154,138 @@ blob_write_uint32 (struct blob *blob, uint32_t value);
  *
  * offset = blob->size;
  * blob_write_uint32 (blob, 0); // placeholder
  * ... various blob write calls, writing N items ...
  * blob_overwrite_uint32 (blob, offset, N);
  *
  * \return True unless the requested position or position+to_write lie outside
  * the current blob's size.
  */
 bool
-blob_overwrite_uint32 (struct blob *blob,
-   size_t offset,
-   uint32_t value);
+blob_overwrite_uint32(struct blob *blob,
+  size_t offset,
+  uint32_t value);
 
 /**
  * Add a uint64_t to a blob.
  *
  * \note This function will only write to a uint64_t-aligned offset from the
  * beginning of the blob's data, so some padding bytes may be added to the
  * blob if this write follows some unaligned write (such as
  * blob_write_string).
  *
  * \return True unless allocation failed.
  */
 bool
-blob_write_uint64 (struct blob *blob, uint64_t value);
+blob_write_uint64(struct blob *blob, uint64_t value);
 
 /**
  * Add an intptr_t to a blob.
  *
  * \note This function will only write to an intptr_t-aligned offset from the
  * beginning of the blob's data, so some padding bytes may be added to the
  * blob if this write follows some unaligned write (such as
  * blob_write_string).
  *
  * \return True unless allocation failed.
  */
 bool
-blob_write_intptr (struct blob *blob, intptr_t value);
+blob_write_intptr(struct blob *blob, intptr_t value);
 
 /**
  * Add a NULL-terminated string to a blob, (including the NULL terminator).
  *
  * \return True unless allocation failed.
  

[Mesa-dev] [PATCH 2/4] util/disk_cache: add support for detecting corrupt cache entries

2017-02-23 Thread Timothy Arceri
---
 src/util/disk_cache.c | 37 ++---
 1 file changed, 34 insertions(+), 3 deletions(-)

diff --git a/src/util/disk_cache.c b/src/util/disk_cache.c
index f5e1145..2a0edca 100644
--- a/src/util/disk_cache.c
+++ b/src/util/disk_cache.c
@@ -31,20 +31,21 @@
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 
+#include "util/crc32.h"
 #include "util/u_atomic.h"
 #include "util/mesa-sha1.h"
 #include "util/ralloc.h"
 #include "main/errors.h"
 
 #include "disk_cache.h"
 
 /* Number of bits to mask off from a cache key to get an index. */
 #define CACHE_INDEX_KEY_BITS 16
 
@@ -702,34 +703,48 @@ disk_cache_put(struct disk_cache *cache,
/* OK, we're now on the hook to write out a file that we know is
 * not in the cache, and is also not being written out to the cache
 * by some other process.
 *
 * Before we do that, if the cache is too large, evict something
 * else first.
 */
if (*cache->size + size > cache->max_size)
   evict_random_item(cache);
 
+   /* Create CRC of the data and store at the start of the file. We will
+* read this when restoring the cache and use it to check for corruption.
+*/
+   uint32_t crc32 = util_hash_crc32(data, size);
+   size_t crc_size = sizeof(crc32);
+   for (len = 0; len < crc_size; len += ret) {
+  ret = write(fd, , crc_size - len);
+  if (ret == -1) {
+ unlink(filename_tmp);
+ goto done;
+  }
+   }
+
/* Now, finally, write out the contents to the temporary file, then
 * rename them atomically to the destination filename, and also
 * perform an atomic increment of the total cache size.
 */
for (len = 0; len < size; len += ret) {
   ret = write(fd, p + len, size - len);
   if (ret == -1) {
  unlink(filename_tmp);
  goto done;
   }
}
 
rename(filename_tmp, filename);
 
+   size += crc_size;
p_atomic_add(cache->size, size);
 
  done:
if (fd_final != -1)
   close(fd_final);
/* This close finally releases the flock, (now that the final dile
 * has been renamed into place and the size has been added).
 */
if (fd != -1)
   close(fd);
@@ -758,31 +773,47 @@ disk_cache_get(struct disk_cache *cache, cache_key key, 
size_t *size)
if (fd == -1)
   goto fail;
 
if (fstat(fd, ) == -1)
   goto fail;
 
data = malloc(sb.st_size);
if (data == NULL)
   goto fail;
 
-   for (len = 0; len < sb.st_size; len += ret) {
-  ret = read(fd, data + len, sb.st_size - len);
+   /* Load the CRC that was created when the file was written. */
+   uint32_t crc32;
+   size_t crc_size = sizeof(crc32);
+   assert(sb.st_size > crc_size);
+   for (len = 0; len < crc_size; len += ret) {
+  ret = read(fd,  + len, crc_size - len);
   if (ret == -1)
  goto fail;
}
 
+   /* Load the actual cache data. */
+   size_t cache_data_size = sb.st_size - crc_size;
+   for (len = 0; len < cache_data_size; len += ret) {
+  ret = read(fd, data + len, cache_data_size - len);
+  if (ret == -1)
+ goto fail;
+   }
+
+   /* Check the data for corruption */
+   if (crc32 != util_hash_crc32(data, cache_data_size))
+  goto fail;
+
free(filename);
close(fd);
 
if (size)
-  *size = sb.st_size;
+  *size = cache_data_size;
 
return data;
 
  fail:
if (data)
   free(data);
if (filename)
   free(filename);
if (fd != -1)
   close(fd);
-- 
2.9.3

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


[Mesa-dev] [PATCH V3 3/4] radeonsi: add support for an on-disk shader cache

2017-02-23 Thread Timothy Arceri
V2:
- when loading from disk cache also binary insert into memory cache.
- check that the binary loaded from disk is the correct size. If not
  delete the cache item and skip loading from cache.

V3:
- remove unrequired variable

Tested-by: Michel Dänzer 
---
 src/gallium/drivers/radeonsi/si_state_shaders.c | 67 ++---
 1 file changed, 60 insertions(+), 7 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_state_shaders.c 
b/src/gallium/drivers/radeonsi/si_state_shaders.c
index f615aa8..9353c37 100644
--- a/src/gallium/drivers/radeonsi/si_state_shaders.c
+++ b/src/gallium/drivers/radeonsi/si_state_shaders.c
@@ -29,20 +29,23 @@
 #include "sid.h"
 #include "radeon/r600_cs.h"
 
 #include "tgsi/tgsi_parse.h"
 #include "tgsi/tgsi_ureg.h"
 #include "util/hash_table.h"
 #include "util/crc32.h"
 #include "util/u_memory.h"
 #include "util/u_prim.h"
 
+#include "util/disk_cache.h"
+#include "util/mesa-sha1.h"
+
 /* SHADER_CACHE */
 
 /**
  * Return the TGSI binary in a buffer. The first 4 bytes contain its size as
  * integer.
  */
 static void *si_get_tgsi_binary(struct si_shader_selector *sel)
 {
unsigned tgsi_size = tgsi_num_tokens(sel->tokens) *
 sizeof(struct tgsi_token);
@@ -175,54 +178,104 @@ static bool si_load_shader_binary(struct si_shader 
*shader, void *binary)
 }
 
 /**
  * Insert a shader into the cache. It's assumed the shader is not in the cache.
  * Use si_shader_cache_load_shader before calling this.
  *
  * Returns false on failure, in which case the tgsi_binary should be freed.
  */
 static bool si_shader_cache_insert_shader(struct si_screen *sscreen,
  void *tgsi_binary,
- struct si_shader *shader)
+ struct si_shader *shader,
+ bool insert_into_disk_cache)
 {
void *hw_binary;
struct hash_entry *entry;
+   uint8_t key[CACHE_KEY_SIZE];
 
entry = _mesa_hash_table_search(sscreen->shader_cache, tgsi_binary);
if (entry)
return false; /* already added */
 
hw_binary = si_get_shader_binary(shader);
if (!hw_binary)
return false;
 
if (_mesa_hash_table_insert(sscreen->shader_cache, tgsi_binary,
hw_binary) == NULL) {
FREE(hw_binary);
return false;
}
 
+   if (sscreen->b.disk_shader_cache && insert_into_disk_cache) {
+   _mesa_sha1_compute(tgsi_binary, *((uint32_t *)tgsi_binary), 
key);
+   disk_cache_put(sscreen->b.disk_shader_cache, key, hw_binary,
+  *((uint32_t *) hw_binary));
+   }
+
return true;
 }
 
 static bool si_shader_cache_load_shader(struct si_screen *sscreen,
void *tgsi_binary,
struct si_shader *shader)
 {
struct hash_entry *entry =
_mesa_hash_table_search(sscreen->shader_cache, tgsi_binary);
-   if (!entry)
-   return false;
+   if (!entry) {
+   if (sscreen->b.disk_shader_cache) {
+   unsigned char sha1[CACHE_KEY_SIZE];
+   size_t tg_size = *((uint32_t *) tgsi_binary);
+
+   _mesa_sha1_compute(tgsi_binary, tg_size, sha1);
+
+   size_t binary_size;
+   uint8_t *buffer =
+   disk_cache_get(sscreen->b.disk_shader_cache,
+  sha1, _size);
+   if (!buffer)
+   return false;
 
-   if (!si_load_shader_binary(shader, entry->data))
-   return false;
+   if (binary_size < sizeof(uint32_t) ||
+   *((uint32_t*)buffer) != binary_size) {
+/* Something has gone wrong discard the item
+ * from the cache and rebuild/link from
+ * source.
+ */
+   assert(!"Invalid radeonsi shader disk cache "
+  "item!");
+
+   disk_cache_remove(sscreen->b.disk_shader_cache,
+ sha1);
+   free(buffer);
+
+   return false;
+   }
+
+   if (!si_load_shader_binary(shader, buffer)) {
+   free(buffer);
+   return false;
+   }
+   free(buffer);
 
+   if (!si_shader_cache_insert_shader(sscreen, tgsi_binary,
+  shader, false))
+  

[Mesa-dev] [PATCH] radv/ac: enable loop unrolling. (v2)

2017-02-23 Thread Dave Airlie
From: Dave Airlie 

This enables LLVM loop unrolling.

v2: limit unroll count to 32, don't fully unroll. (arsenm)

Signed-off-by: Dave Airlie 
---
 src/amd/common/ac_llvm_helper.cpp | 22 ++
 src/amd/common/ac_llvm_util.h |  1 +
 src/amd/common/ac_nir_to_llvm.c   | 26 --
 3 files changed, 47 insertions(+), 2 deletions(-)

diff --git a/src/amd/common/ac_llvm_helper.cpp 
b/src/amd/common/ac_llvm_helper.cpp
index 594339e..85b0cbf 100644
--- a/src/amd/common/ac_llvm_helper.cpp
+++ b/src/amd/common/ac_llvm_helper.cpp
@@ -36,7 +36,9 @@
 #include 
 #include 
 #include 
+#include 
 
+using namespace llvm;
 void ac_add_attr_dereferenceable(LLVMValueRef val, uint64_t bytes)
 {
llvm::Argument *A = llvm::unwrap(val);
@@ -53,3 +55,23 @@ bool ac_is_sgpr_param(LLVMValueRef arg)
return AS.hasAttribute(ArgNo + 1, llvm::Attribute::ByVal) ||
   AS.hasAttribute(ArgNo + 1, llvm::Attribute::InReg);
 }
+
+// MetadataAsValue uses a canonical format which strips the actual MDNode for
+// MDNode with just a single constant value, storing just a ConstantAsMetadata
+// This undoes this canonicalization, reconstructing the MDNode.
+static MDNode *extractMDNode(MetadataAsValue *MAV) {
+   Metadata *MD = MAV->getMetadata();
+   assert((isa(MD) || isa(MD)) &&
+  "Expected a metadata node or a canonicalized constant");
+
+   if (MDNode *N = dyn_cast(MD))
+   return N;
+   assert(0);
+   return MDNode::get(MAV->getContext(), MD);
+}
+
+void ac_metadata_point_op0_to_itself(LLVMValueRef v)
+{
+   MDNode *node = extractMDNode(unwrap(v));
+   node->replaceOperandWith(0, node);
+}
diff --git a/src/amd/common/ac_llvm_util.h b/src/amd/common/ac_llvm_util.h
index 1f37a12..0d6c53c 100644
--- a/src/amd/common/ac_llvm_util.h
+++ b/src/amd/common/ac_llvm_util.h
@@ -48,6 +48,7 @@ LLVMTargetMachineRef ac_create_target_machine(enum 
radeon_family family, bool su
 
 void ac_add_attr_dereferenceable(LLVMValueRef val, uint64_t bytes);
 bool ac_is_sgpr_param(LLVMValueRef param);
+void ac_metadata_point_op0_to_itself(LLVMValueRef v);
 
 void
 ac_add_function_attr(LLVMValueRef function,
diff --git a/src/amd/common/ac_nir_to_llvm.c b/src/amd/common/ac_nir_to_llvm.c
index 9778581..d7a9a7b 100644
--- a/src/amd/common/ac_nir_to_llvm.c
+++ b/src/amd/common/ac_nir_to_llvm.c
@@ -3950,6 +3950,23 @@ static void visit_if(struct nir_to_llvm_context *ctx, 
nir_if *if_stmt)
LLVMPositionBuilderAtEnd(ctx->builder, merge_block);
 }
 
+static void set_unroll_metadata(struct nir_to_llvm_context *ctx,
+  LLVMValueRef br)
+{
+   unsigned kind = LLVMGetMDKindIDInContext(ctx->context, "llvm.loop", 9);
+   LLVMValueRef md_unroll;
+   LLVMValueRef part_arg = LLVMMDStringInContext(ctx->context, 
"llvm.loop.unroll.count", 22);
+   LLVMValueRef count_arg = LLVMConstInt(ctx->i32, 32, false);
+   LLVMValueRef args[2] = {part_arg, count_arg};
+   LLVMValueRef count = LLVMMDNodeInContext(ctx->context, args, 2);
+
+   LLVMValueRef md_args[] = {NULL, count};
+   md_unroll = LLVMMDNodeInContext(ctx->context, md_args, 2);
+   ac_metadata_point_op0_to_itself(md_unroll);
+
+   LLVMSetMetadata(br, kind, md_unroll);
+}
+
 static void visit_loop(struct nir_to_llvm_context *ctx, nir_loop *loop)
 {
LLVMBasicBlockRef continue_parent = ctx->continue_block;
@@ -3964,8 +3981,10 @@ static void visit_loop(struct nir_to_llvm_context *ctx, 
nir_loop *loop)
LLVMPositionBuilderAtEnd(ctx->builder, ctx->continue_block);
visit_cf_list(ctx, >body);
 
-   if (LLVMGetInsertBlock(ctx->builder))
-   LLVMBuildBr(ctx->builder, ctx->continue_block);
+   if (LLVMGetInsertBlock(ctx->builder)) {
+   LLVMValueRef loop = LLVMBuildBr(ctx->builder, 
ctx->continue_block);
+   set_unroll_metadata(ctx, loop);
+   }
LLVMPositionBuilderAtEnd(ctx->builder, ctx->break_block);
 
ctx->continue_block = continue_parent;
@@ -4827,10 +4846,13 @@ static void ac_llvm_finalize_module(struct 
nir_to_llvm_context * ctx)
 
/* Add some optimization passes */
LLVMAddScalarReplAggregatesPass(passmgr);
+   LLVMAddLoopRotatePass(passmgr);
LLVMAddLICMPass(passmgr);
LLVMAddAggressiveDCEPass(passmgr);
LLVMAddCFGSimplificationPass(passmgr);
LLVMAddInstructionCombiningPass(passmgr);
+   LLVMAddIndVarSimplifyPass(passmgr);
+   LLVMAddLoopUnrollPass(passmgr);
 
/* Run the pass */
LLVMInitializeFunctionPassManager(passmgr);
-- 
2.9.3

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


Re: [Mesa-dev] [PATCH] radv/ac: enable loop unrolling.

2017-02-23 Thread Dave Airlie
On 24 February 2017 at 13:36, Matt Arsenault  wrote:
>
> On Feb 23, 2017, at 19:27, Dave Airlie  wrote:
>
> +static void set_unroll_metadata(struct nir_to_llvm_context *ctx,
> +LLVMValueRef br)
> +{
> + unsigned kind = LLVMGetMDKindIDInContext(ctx->context, "llvm.loop", 9);
> + LLVMValueRef md_unroll;
> + LLVMValueRef full_arg = LLVMMDStringInContext(ctx->context,
> "llvm.loop.unroll.full", 21);
> + LLVMValueRef full = LLVMMDNodeInContext(ctx->context, _arg, 1);
> +
> + LLVMValueRef md_args[] = {NULL, full};
> + md_unroll = LLVMMDNodeInContext(ctx->context, md_args, 2);
> + ac_metadata_point_op0_to_itself(md_unroll);
> +
> + LLVMSetMetadata(br, kind, md_unroll);
> +}
> +
>
>
> Why are you forcing full unrolling of all loops?

Because I copied Marek's code with little idea of what llvm does.

Should I just drop the full bits, perhaps set a llvm.loop.unroll.count = 32?

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


Re: [Mesa-dev] [PATCH] radv/ac: enable loop unrolling.

2017-02-23 Thread Matt Arsenault

> On Feb 23, 2017, at 19:27, Dave Airlie  wrote:
> 
> +static void set_unroll_metadata(struct nir_to_llvm_context *ctx,
> +LLVMValueRef br)
> +{
> + unsigned kind = LLVMGetMDKindIDInContext(ctx->context, "llvm.loop", 9);
> + LLVMValueRef md_unroll;
> + LLVMValueRef full_arg = LLVMMDStringInContext(ctx->context, 
> "llvm.loop.unroll.full", 21);
> + LLVMValueRef full = LLVMMDNodeInContext(ctx->context, _arg, 1);
> +
> + LLVMValueRef md_args[] = {NULL, full};
> + md_unroll = LLVMMDNodeInContext(ctx->context, md_args, 2);
> + ac_metadata_point_op0_to_itself(md_unroll);
> +
> + LLVMSetMetadata(br, kind, md_unroll);
> +}
> +

Why are you forcing full unrolling of all loops?

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


Re: [Mesa-dev] [PATCH] radv/ac: enable loop unrolling.

2017-02-23 Thread Dave Airlie
On 24 February 2017 at 13:27, Dave Airlie  wrote:
> From: Dave Airlie 
>
> This enables LLVM loop unrolling.

Meant to also say it's based on a radeonsi patch Marek wrote.

Dave.
>
> Signed-off-by: Dave Airlie 
> ---
>  src/amd/common/ac_llvm_helper.cpp | 22 ++
>  src/amd/common/ac_llvm_util.h |  1 +
>  src/amd/common/ac_nir_to_llvm.c   | 24 ++--
>  3 files changed, 45 insertions(+), 2 deletions(-)
>
> diff --git a/src/amd/common/ac_llvm_helper.cpp 
> b/src/amd/common/ac_llvm_helper.cpp
> index 594339e..85b0cbf 100644
> --- a/src/amd/common/ac_llvm_helper.cpp
> +++ b/src/amd/common/ac_llvm_helper.cpp
> @@ -36,7 +36,9 @@
>  #include 
>  #include 
>  #include 
> +#include 
>
> +using namespace llvm;
>  void ac_add_attr_dereferenceable(LLVMValueRef val, uint64_t bytes)
>  {
> llvm::Argument *A = llvm::unwrap(val);
> @@ -53,3 +55,23 @@ bool ac_is_sgpr_param(LLVMValueRef arg)
> return AS.hasAttribute(ArgNo + 1, llvm::Attribute::ByVal) ||
>AS.hasAttribute(ArgNo + 1, llvm::Attribute::InReg);
>  }
> +
> +// MetadataAsValue uses a canonical format which strips the actual MDNode for
> +// MDNode with just a single constant value, storing just a 
> ConstantAsMetadata
> +// This undoes this canonicalization, reconstructing the MDNode.
> +static MDNode *extractMDNode(MetadataAsValue *MAV) {
> +   Metadata *MD = MAV->getMetadata();
> +   assert((isa(MD) || isa(MD)) &&
> +  "Expected a metadata node or a canonicalized constant");
> +
> +   if (MDNode *N = dyn_cast(MD))
> +   return N;
> +   assert(0);
> +   return MDNode::get(MAV->getContext(), MD);
> +}
> +
> +void ac_metadata_point_op0_to_itself(LLVMValueRef v)
> +{
> +   MDNode *node = extractMDNode(unwrap(v));
> +   node->replaceOperandWith(0, node);
> +}
> diff --git a/src/amd/common/ac_llvm_util.h b/src/amd/common/ac_llvm_util.h
> index 1f37a12..0d6c53c 100644
> --- a/src/amd/common/ac_llvm_util.h
> +++ b/src/amd/common/ac_llvm_util.h
> @@ -48,6 +48,7 @@ LLVMTargetMachineRef ac_create_target_machine(enum 
> radeon_family family, bool su
>
>  void ac_add_attr_dereferenceable(LLVMValueRef val, uint64_t bytes);
>  bool ac_is_sgpr_param(LLVMValueRef param);
> +void ac_metadata_point_op0_to_itself(LLVMValueRef v);
>
>  void
>  ac_add_function_attr(LLVMValueRef function,
> diff --git a/src/amd/common/ac_nir_to_llvm.c b/src/amd/common/ac_nir_to_llvm.c
> index 9778581..0e20aa1 100644
> --- a/src/amd/common/ac_nir_to_llvm.c
> +++ b/src/amd/common/ac_nir_to_llvm.c
> @@ -3950,6 +3950,21 @@ static void visit_if(struct nir_to_llvm_context *ctx, 
> nir_if *if_stmt)
> LLVMPositionBuilderAtEnd(ctx->builder, merge_block);
>  }
>
> +static void set_unroll_metadata(struct nir_to_llvm_context *ctx,
> +  LLVMValueRef br)
> +{
> +   unsigned kind = LLVMGetMDKindIDInContext(ctx->context, "llvm.loop", 
> 9);
> +   LLVMValueRef md_unroll;
> +   LLVMValueRef full_arg = LLVMMDStringInContext(ctx->context, 
> "llvm.loop.unroll.full", 21);
> +   LLVMValueRef full = LLVMMDNodeInContext(ctx->context, _arg, 1);
> +
> +   LLVMValueRef md_args[] = {NULL, full};
> +   md_unroll = LLVMMDNodeInContext(ctx->context, md_args, 2);
> +   ac_metadata_point_op0_to_itself(md_unroll);
> +
> +   LLVMSetMetadata(br, kind, md_unroll);
> +}
> +
>  static void visit_loop(struct nir_to_llvm_context *ctx, nir_loop *loop)
>  {
> LLVMBasicBlockRef continue_parent = ctx->continue_block;
> @@ -3964,8 +3979,10 @@ static void visit_loop(struct nir_to_llvm_context 
> *ctx, nir_loop *loop)
> LLVMPositionBuilderAtEnd(ctx->builder, ctx->continue_block);
> visit_cf_list(ctx, >body);
>
> -   if (LLVMGetInsertBlock(ctx->builder))
> -   LLVMBuildBr(ctx->builder, ctx->continue_block);
> +   if (LLVMGetInsertBlock(ctx->builder)) {
> +   LLVMValueRef loop = LLVMBuildBr(ctx->builder, 
> ctx->continue_block);
> +   set_unroll_metadata(ctx, loop);
> +   }
> LLVMPositionBuilderAtEnd(ctx->builder, ctx->break_block);
>
> ctx->continue_block = continue_parent;
> @@ -4827,10 +4844,13 @@ static void ac_llvm_finalize_module(struct 
> nir_to_llvm_context * ctx)
>
> /* Add some optimization passes */
> LLVMAddScalarReplAggregatesPass(passmgr);
> +   LLVMAddLoopRotatePass(passmgr);
> LLVMAddLICMPass(passmgr);
> LLVMAddAggressiveDCEPass(passmgr);
> LLVMAddCFGSimplificationPass(passmgr);
> LLVMAddInstructionCombiningPass(passmgr);
> +   LLVMAddIndVarSimplifyPass(passmgr);
> +   LLVMAddLoopUnrollPass(passmgr);
>
> /* Run the pass */
> LLVMInitializeFunctionPassManager(passmgr);
> --
> 2.9.3
>
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> 

[Mesa-dev] [PATCH] radv/ac: enable loop unrolling.

2017-02-23 Thread Dave Airlie
From: Dave Airlie 

This enables LLVM loop unrolling.

Signed-off-by: Dave Airlie 
---
 src/amd/common/ac_llvm_helper.cpp | 22 ++
 src/amd/common/ac_llvm_util.h |  1 +
 src/amd/common/ac_nir_to_llvm.c   | 24 ++--
 3 files changed, 45 insertions(+), 2 deletions(-)

diff --git a/src/amd/common/ac_llvm_helper.cpp 
b/src/amd/common/ac_llvm_helper.cpp
index 594339e..85b0cbf 100644
--- a/src/amd/common/ac_llvm_helper.cpp
+++ b/src/amd/common/ac_llvm_helper.cpp
@@ -36,7 +36,9 @@
 #include 
 #include 
 #include 
+#include 
 
+using namespace llvm;
 void ac_add_attr_dereferenceable(LLVMValueRef val, uint64_t bytes)
 {
llvm::Argument *A = llvm::unwrap(val);
@@ -53,3 +55,23 @@ bool ac_is_sgpr_param(LLVMValueRef arg)
return AS.hasAttribute(ArgNo + 1, llvm::Attribute::ByVal) ||
   AS.hasAttribute(ArgNo + 1, llvm::Attribute::InReg);
 }
+
+// MetadataAsValue uses a canonical format which strips the actual MDNode for
+// MDNode with just a single constant value, storing just a ConstantAsMetadata
+// This undoes this canonicalization, reconstructing the MDNode.
+static MDNode *extractMDNode(MetadataAsValue *MAV) {
+   Metadata *MD = MAV->getMetadata();
+   assert((isa(MD) || isa(MD)) &&
+  "Expected a metadata node or a canonicalized constant");
+
+   if (MDNode *N = dyn_cast(MD))
+   return N;
+   assert(0);
+   return MDNode::get(MAV->getContext(), MD);
+}
+
+void ac_metadata_point_op0_to_itself(LLVMValueRef v)
+{
+   MDNode *node = extractMDNode(unwrap(v));
+   node->replaceOperandWith(0, node);
+}
diff --git a/src/amd/common/ac_llvm_util.h b/src/amd/common/ac_llvm_util.h
index 1f37a12..0d6c53c 100644
--- a/src/amd/common/ac_llvm_util.h
+++ b/src/amd/common/ac_llvm_util.h
@@ -48,6 +48,7 @@ LLVMTargetMachineRef ac_create_target_machine(enum 
radeon_family family, bool su
 
 void ac_add_attr_dereferenceable(LLVMValueRef val, uint64_t bytes);
 bool ac_is_sgpr_param(LLVMValueRef param);
+void ac_metadata_point_op0_to_itself(LLVMValueRef v);
 
 void
 ac_add_function_attr(LLVMValueRef function,
diff --git a/src/amd/common/ac_nir_to_llvm.c b/src/amd/common/ac_nir_to_llvm.c
index 9778581..0e20aa1 100644
--- a/src/amd/common/ac_nir_to_llvm.c
+++ b/src/amd/common/ac_nir_to_llvm.c
@@ -3950,6 +3950,21 @@ static void visit_if(struct nir_to_llvm_context *ctx, 
nir_if *if_stmt)
LLVMPositionBuilderAtEnd(ctx->builder, merge_block);
 }
 
+static void set_unroll_metadata(struct nir_to_llvm_context *ctx,
+  LLVMValueRef br)
+{
+   unsigned kind = LLVMGetMDKindIDInContext(ctx->context, "llvm.loop", 9);
+   LLVMValueRef md_unroll;
+   LLVMValueRef full_arg = LLVMMDStringInContext(ctx->context, 
"llvm.loop.unroll.full", 21);
+   LLVMValueRef full = LLVMMDNodeInContext(ctx->context, _arg, 1);
+
+   LLVMValueRef md_args[] = {NULL, full};
+   md_unroll = LLVMMDNodeInContext(ctx->context, md_args, 2);
+   ac_metadata_point_op0_to_itself(md_unroll);
+
+   LLVMSetMetadata(br, kind, md_unroll);
+}
+
 static void visit_loop(struct nir_to_llvm_context *ctx, nir_loop *loop)
 {
LLVMBasicBlockRef continue_parent = ctx->continue_block;
@@ -3964,8 +3979,10 @@ static void visit_loop(struct nir_to_llvm_context *ctx, 
nir_loop *loop)
LLVMPositionBuilderAtEnd(ctx->builder, ctx->continue_block);
visit_cf_list(ctx, >body);
 
-   if (LLVMGetInsertBlock(ctx->builder))
-   LLVMBuildBr(ctx->builder, ctx->continue_block);
+   if (LLVMGetInsertBlock(ctx->builder)) {
+   LLVMValueRef loop = LLVMBuildBr(ctx->builder, 
ctx->continue_block);
+   set_unroll_metadata(ctx, loop);
+   }
LLVMPositionBuilderAtEnd(ctx->builder, ctx->break_block);
 
ctx->continue_block = continue_parent;
@@ -4827,10 +4844,13 @@ static void ac_llvm_finalize_module(struct 
nir_to_llvm_context * ctx)
 
/* Add some optimization passes */
LLVMAddScalarReplAggregatesPass(passmgr);
+   LLVMAddLoopRotatePass(passmgr);
LLVMAddLICMPass(passmgr);
LLVMAddAggressiveDCEPass(passmgr);
LLVMAddCFGSimplificationPass(passmgr);
LLVMAddInstructionCombiningPass(passmgr);
+   LLVMAddIndVarSimplifyPass(passmgr);
+   LLVMAddLoopUnrollPass(passmgr);
 
/* Run the pass */
LLVMInitializeFunctionPassManager(passmgr);
-- 
2.9.3

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


Re: [Mesa-dev] [PATCH 1/2] radeonsi: add support for an on-disk shader cache

2017-02-23 Thread Timothy Arceri



On 24/02/17 08:49, Timothy Arceri wrote:



On 24/02/17 05:12, Marek Olšák wrote:

On Thu, Feb 23, 2017 at 3:09 AM, Timothy Arceri
 wrote:

From: kdj0c 

V2 (Timothy Arceri):
- when loading from disk cache also binary insert into memory cache.
- check that the binary loaded from disk is the correct size. If not
  delete the cache item and skip loading from cache.
---
 src/gallium/drivers/radeonsi/si_state_shaders.c | 69
++---
 1 file changed, 62 insertions(+), 7 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_state_shaders.c
b/src/gallium/drivers/radeonsi/si_state_shaders.c
index f615aa8..71556f9 100644
--- a/src/gallium/drivers/radeonsi/si_state_shaders.c
+++ b/src/gallium/drivers/radeonsi/si_state_shaders.c
@@ -36,6 +36,9 @@
 #include "util/u_memory.h"
 #include "util/u_prim.h"

+#include "util/disk_cache.h"
+#include "util/mesa-sha1.h"
+
 /* SHADER_CACHE */

 /**
@@ -182,10 +185,12 @@ static bool si_load_shader_binary(struct
si_shader *shader, void *binary)
  */
 static bool si_shader_cache_insert_shader(struct si_screen *sscreen,
  void *tgsi_binary,
- struct si_shader *shader)
+ struct si_shader *shader,
+ bool insert_into_disk_cache)
 {
void *hw_binary;
struct hash_entry *entry;
+   uint8_t key[CACHE_KEY_SIZE];

entry = _mesa_hash_table_search(sscreen->shader_cache,
tgsi_binary);
if (entry)
@@ -201,6 +206,12 @@ static bool si_shader_cache_insert_shader(struct
si_screen *sscreen,
return false;
}

+   if (sscreen->b.disk_shader_cache && insert_into_disk_cache) {
+   _mesa_sha1_compute(tgsi_binary, *((uint32_t
*)tgsi_binary), key);


What happens if we randomly get a sha1 collision?


You should stop playing your game which will be rendering incorrectly
and by a lotto ticket.


Shouldn't we store the whole key as well?


Sure I can add that, its cheap to check here anyway. Although the other
cache stages rely on a collision being improbable.



For some reason I thought the key was simpler than it is. It seems 
excessive to store and compare the tgsi again. I don't think git even 
worries about the possibility of a collision and we will be dealing with 
much smaller amounts of cache items then commits in a git repository.


Thoughts?






+   disk_cache_put(sscreen->b.disk_shader_cache, key,
hw_binary,
+  *((uint32_t *) hw_binary));
+   }
+
return true;
 }

@@ -210,12 +221,56 @@ static bool si_shader_cache_load_shader(struct
si_screen *sscreen,
 {
struct hash_entry *entry =
_mesa_hash_table_search(sscreen->shader_cache,
tgsi_binary);
-   if (!entry)
-   return false;
+   if (!entry) {
+   if (sscreen->b.disk_shader_cache) {
+   unsigned char sha1[CACHE_KEY_SIZE];
+   size_t tg_size = *((uint32_t *) tgsi_binary);
+
+   _mesa_sha1_compute(tgsi_binary, tg_size, sha1);
+
+   size_t binary_size;
+   uint8_t *buffer =
+
disk_cache_get(sscreen->b.disk_shader_cache,
+  sha1, _size);
+   if (!buffer)
+   return false;

-   if (!si_load_shader_binary(shader, entry->data))
-   return false;
+   uint32_t stored_binary_size;


It looks like you don't need this variable.



Right, I'll tidy that up thanks.



Marek


___
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 8/8] anv: Advertise shaderInt64 on Broadwell and above

2017-02-23 Thread Jason Ekstrand
---
 src/intel/vulkan/anv_device.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c
index 6f570d8..5857ae2 100644
--- a/src/intel/vulkan/anv_device.c
+++ b/src/intel/vulkan/anv_device.c
@@ -478,7 +478,7 @@ void anv_GetPhysicalDeviceFeatures(
   .shaderClipDistance   = true,
   .shaderCullDistance   = true,
   .shaderFloat64= pdevice->info.gen >= 8,
-  .shaderInt64  = false,
+  .shaderInt64  = pdevice->info.gen >= 8,
   .shaderInt16  = false,
   .shaderResourceMinLod = false,
   .variableMultisampleRate  = false,
-- 
2.5.0.400.gff86faf

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


[Mesa-dev] [PATCH 7/8] i965: Do int64 lowering in NIR

2017-02-23 Thread Jason Ekstrand
---
 src/mesa/drivers/dri/i965/brw_link.cpp | 5 -
 src/mesa/drivers/dri/i965/brw_nir.c| 7 +++
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_link.cpp 
b/src/mesa/drivers/dri/i965/brw_link.cpp
index 977feb3..4159756 100644
--- a/src/mesa/drivers/dri/i965/brw_link.cpp
+++ b/src/mesa/drivers/dri/i965/brw_link.cpp
@@ -120,11 +120,6 @@ process_glsl_ir(struct brw_context *brw,
}
 
lower_instructions(shader->ir, instructions_to_lower);
-   lower_64bit_integer_instructions(shader->ir,
-MUL64 |
-DIV64 |
-MOD64 |
-SIGN64);
 
/* Pre-gen6 HW can only nest if-statements 16 deep.  Beyond this,
 * if-statements need to be flattened.
diff --git a/src/mesa/drivers/dri/i965/brw_nir.c 
b/src/mesa/drivers/dri/i965/brw_nir.c
index 7470349..314adcb 100644
--- a/src/mesa/drivers/dri/i965/brw_nir.c
+++ b/src/mesa/drivers/dri/i965/brw_nir.c
@@ -578,6 +578,13 @@ brw_preprocess_nir(const struct brw_compiler *compiler, 
nir_shader *nir)
 
nir_lower_indirect_derefs(nir, indirect_mask);
 
+   nir_lower_int64(nir, nir_lower_imul64 |
+nir_lower_isign64 |
+nir_lower_udiv64 |
+nir_lower_idiv64 |
+nir_lower_umod64 |
+nir_lower_imod64);
+
/* Get rid of split copies */
nir = nir_optimize(nir, compiler, is_scalar);
 
-- 
2.5.0.400.gff86faf

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


[Mesa-dev] [PATCH 6/8] nir: Add a simple int64 lowering pass

2017-02-23 Thread Jason Ekstrand
---
 src/compiler/Makefile.sources  |   1 +
 src/compiler/nir/nir.h |  11 ++
 src/compiler/nir/nir_lower_int64.c | 275 +
 3 files changed, 287 insertions(+)
 create mode 100644 src/compiler/nir/nir_lower_int64.c

diff --git a/src/compiler/Makefile.sources b/src/compiler/Makefile.sources
index 643a018..2455d4e 100644
--- a/src/compiler/Makefile.sources
+++ b/src/compiler/Makefile.sources
@@ -221,6 +221,7 @@ NIR_FILES = \
nir/nir_lower_locals_to_regs.c \
nir/nir_lower_idiv.c \
nir/nir_lower_indirect_derefs.c \
+   nir/nir_lower_int64.c \
nir/nir_lower_io.c \
nir/nir_lower_io_to_temporaries.c \
nir/nir_lower_io_to_scalar.c \
diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
index 5243a9e..1a23e19 100644
--- a/src/compiler/nir/nir.h
+++ b/src/compiler/nir/nir.h
@@ -2540,6 +2540,17 @@ void nir_lower_to_source_mods(nir_shader *shader);
 bool nir_lower_gs_intrinsics(nir_shader *shader);
 
 typedef enum {
+   nir_lower_imul64 = (1 << 0),
+   nir_lower_isign64 = (1 << 1),
+   nir_lower_udiv64 = (1 << 2),
+   nir_lower_idiv64 = (1 << 3),
+   nir_lower_umod64 = (1 << 4),
+   nir_lower_imod64 = (1 << 5),
+} nir_lower_int64_options;
+
+bool nir_lower_int64(nir_shader *shader, nir_lower_int64_options options);
+
+typedef enum {
nir_lower_drcp = (1 << 0),
nir_lower_dsqrt = (1 << 1),
nir_lower_drsq = (1 << 2),
diff --git a/src/compiler/nir/nir_lower_int64.c 
b/src/compiler/nir/nir_lower_int64.c
new file mode 100644
index 000..35a3fa5
--- /dev/null
+++ b/src/compiler/nir/nir_lower_int64.c
@@ -0,0 +1,275 @@
+/*
+ * Copyright © 2016 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#include "nir.h"
+#include "nir_builder.h"
+
+static nir_ssa_def *
+lower_umul64(nir_builder *b, nir_ssa_def *x, nir_ssa_def *y)
+{
+   nir_ssa_def *x_lo = nir_unpack_64_2x32_split_x(b, x);
+   nir_ssa_def *x_hi = nir_unpack_64_2x32_split_y(b, x);
+   nir_ssa_def *y_lo = nir_unpack_64_2x32_split_x(b, y);
+   nir_ssa_def *y_hi = nir_unpack_64_2x32_split_y(b, y);
+
+   nir_ssa_def *res_lo = nir_imul(b, x_lo, y_lo);
+   nir_ssa_def *res_hi = nir_iadd(b, nir_umul_high(b, x_lo, y_lo),
+ nir_iadd(b, nir_imul(b, x_lo, y_hi),
+ nir_imul(b, x_hi, y_lo)));
+
+   return nir_pack_64_2x32_split(b, res_lo, res_hi);
+}
+
+static nir_ssa_def *
+lower_isign64(nir_builder *b, nir_ssa_def *x)
+{
+   nir_ssa_def *x_lo = nir_unpack_64_2x32_split_x(b, x);
+   nir_ssa_def *x_hi = nir_unpack_64_2x32_split_y(b, x);
+
+   nir_ssa_def *is_non_zero = nir_i2b(b, nir_ior(b, x_lo, x_hi));
+   nir_ssa_def *res_hi = nir_ishr(b, x_hi, nir_imm_int(b, 31));
+   nir_ssa_def *res_lo = nir_ior(b, res_hi, nir_b2i(b, is_non_zero));
+
+   return nir_pack_64_2x32_split(b, res_lo, res_hi);
+}
+
+static void
+lower_udiv64_mod64(nir_builder *b, nir_ssa_def *n, nir_ssa_def *d,
+   nir_ssa_def **q, nir_ssa_def **r)
+{
+   /* TODO: We should specially handle the case where the denominator is a
+* constant.  In that case, we should be able to reduce it to a multiply by
+* a constant, some shifts, and an add.
+*/
+   nir_ssa_def *n_lo = nir_unpack_64_2x32_split_x(b, n);
+   nir_ssa_def *n_hi = nir_unpack_64_2x32_split_y(b, n);
+   nir_ssa_def *d_lo = nir_unpack_64_2x32_split_x(b, d);
+   nir_ssa_def *d_hi = nir_unpack_64_2x32_split_y(b, d);
+
+   nir_ssa_def *q_lo = nir_imm_int(b, 0);
+   nir_ssa_def *q_hi = nir_imm_int(b, 0);
+
+   nir_ssa_def *n_hi_before_if = n_hi;
+   nir_ssa_def *q_hi_before_if = q_hi;
+
+   /* If the upper 32 bits of denom are non-zero, it is impossible for shifts
+* greater than 32 bits to occur.  If the upper 32 bits of the numerator
+* are zero, it is impossible for (denom << [63, 32]) <= numer unless
+* denom == 0.
+*/
+   nir_push_if(b, nir_iand(b, 

[Mesa-dev] [PATCH 5/8] spirv: Use nir_builder for control flow

2017-02-23 Thread Jason Ekstrand
---
 src/compiler/spirv/vtn_cfg.c | 45 ++--
 1 file changed, 14 insertions(+), 31 deletions(-)

diff --git a/src/compiler/spirv/vtn_cfg.c b/src/compiler/spirv/vtn_cfg.c
index 3a31657..54248b1 100644
--- a/src/compiler/spirv/vtn_cfg.c
+++ b/src/compiler/spirv/vtn_cfg.c
@@ -610,15 +610,10 @@ vtn_emit_cf_list(struct vtn_builder *b, struct list_head 
*cf_list,
 
   case vtn_cf_node_type_if: {
  struct vtn_if *vtn_if = (struct vtn_if *)node;
-
- nir_if *if_stmt = nir_if_create(b->shader);
- if_stmt->condition =
-nir_src_for_ssa(vtn_ssa_value(b, vtn_if->condition)->def);
- nir_cf_node_insert(b->nb.cursor, _stmt->cf_node);
-
  bool sw_break = false;
 
- b->nb.cursor = nir_after_cf_list(_stmt->then_list);
+ nir_if *nif =
+nir_push_if(>nb, vtn_ssa_value(b, vtn_if->condition)->def);
  if (vtn_if->then_type == vtn_branch_type_none) {
 vtn_emit_cf_list(b, _if->then_body,
  switch_fall_var, _break, handler);
@@ -626,7 +621,7 @@ vtn_emit_cf_list(struct vtn_builder *b, struct list_head 
*cf_list,
 vtn_emit_branch(b, vtn_if->then_type, switch_fall_var, _break);
  }
 
- b->nb.cursor = nir_after_cf_list(_stmt->else_list);
+ nir_push_else(>nb, nif);
  if (vtn_if->else_type == vtn_branch_type_none) {
 vtn_emit_cf_list(b, _if->else_body,
  switch_fall_var, _break, handler);
@@ -634,7 +629,7 @@ vtn_emit_cf_list(struct vtn_builder *b, struct list_head 
*cf_list,
 vtn_emit_branch(b, vtn_if->else_type, switch_fall_var, _break);
  }
 
- b->nb.cursor = nir_after_cf_node(_stmt->cf_node);
+ nir_pop_if(>nb, nif);
 
  /* If we encountered a switch break somewhere inside of the if,
   * then it would have been handled correctly by calling
@@ -644,13 +639,7 @@ vtn_emit_cf_list(struct vtn_builder *b, struct list_head 
*cf_list,
   */
  if (sw_break) {
 *has_switch_break = true;
-
-nir_if *switch_if = nir_if_create(b->shader);
-switch_if->condition =
-   nir_src_for_ssa(nir_load_var(>nb, switch_fall_var));
-nir_cf_node_insert(b->nb.cursor, _if->cf_node);
-
-b->nb.cursor = nir_after_cf_list(_stmt->then_list);
+nir_push_if(>nb, nir_load_var(>nb, switch_fall_var));
  }
  break;
   }
@@ -658,10 +647,7 @@ vtn_emit_cf_list(struct vtn_builder *b, struct list_head 
*cf_list,
   case vtn_cf_node_type_loop: {
  struct vtn_loop *vtn_loop = (struct vtn_loop *)node;
 
- nir_loop *loop = nir_loop_create(b->shader);
- nir_cf_node_insert(b->nb.cursor, >cf_node);
-
- b->nb.cursor = nir_after_cf_list(>body);
+ nir_loop *loop = nir_push_loop(>nb);
  vtn_emit_cf_list(b, _loop->body, NULL, NULL, handler);
 
  if (!list_empty(_loop->cont_body)) {
@@ -676,20 +662,20 @@ vtn_emit_cf_list(struct vtn_builder *b, struct list_head 
*cf_list,
 nir_store_var(>nb, do_cont, nir_imm_int(>nb, NIR_FALSE), 1);
 
 b->nb.cursor = nir_before_cf_list(>body);
-nir_if *cont_if = nir_if_create(b->shader);
-cont_if->condition = nir_src_for_ssa(nir_load_var(>nb, 
do_cont));
-nir_cf_node_insert(b->nb.cursor, _if->cf_node);
 
-b->nb.cursor = nir_after_cf_list(_if->then_list);
+nir_if *cont_if =
+   nir_push_if(>nb, nir_load_var(>nb, do_cont));
+
 vtn_emit_cf_list(b, _loop->cont_body, NULL, NULL, handler);
 
-b->nb.cursor = nir_after_cf_node(_if->cf_node);
+nir_pop_if(>nb, cont_if);
+
 nir_store_var(>nb, do_cont, nir_imm_int(>nb, NIR_TRUE), 1);
 
 b->has_loop_continue = true;
  }
 
- b->nb.cursor = nir_after_cf_node(>cf_node);
+ nir_pop_loop(>nb, loop);
  break;
   }
 
@@ -747,17 +733,14 @@ vtn_emit_cf_list(struct vtn_builder *b, struct list_head 
*cf_list,
 /* Take fallthrough into account */
 cond = nir_ior(>nb, cond, nir_load_var(>nb, fall_var));
 
-nir_if *case_if = nir_if_create(b->nb.shader);
-case_if->condition = nir_src_for_ssa(cond);
-nir_cf_node_insert(b->nb.cursor, _if->cf_node);
+nir_if *case_if = nir_push_if(>nb, cond);
 
 bool has_break = false;
-b->nb.cursor = nir_after_cf_list(_if->then_list);
 nir_store_var(>nb, fall_var, nir_imm_int(>nb, NIR_TRUE), 1);
 vtn_emit_cf_list(b, >body, fall_var, _break, handler);
 (void)has_break; /* We don't care */
 
-b->nb.cursor = nir_after_cf_node(_if->cf_node);
+nir_pop_if(>nb, case_if);
  }
  assert(i == num_cases);
 
-- 
2.5.0.400.gff86faf

___
mesa-dev 

[Mesa-dev] [PATCH 3/8] nir/lower_gs_intrinsics: Use nir_builder control-flow helpers

2017-02-23 Thread Jason Ekstrand
---
 src/compiler/nir/nir_lower_gs_intrinsics.c | 9 +++--
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/src/compiler/nir/nir_lower_gs_intrinsics.c 
b/src/compiler/nir/nir_lower_gs_intrinsics.c
index 3acb742..68e20dd 100644
--- a/src/compiler/nir/nir_lower_gs_intrinsics.c
+++ b/src/compiler/nir/nir_lower_gs_intrinsics.c
@@ -84,12 +84,7 @@ rewrite_emit_vertex(nir_intrinsic_instr *intrin, struct 
state *state)
 * The new if statement needs to be hooked up to the control flow graph
 * before we start inserting instructions into it.
 */
-   nir_if *if_stmt = nir_if_create(b->shader);
-   if_stmt->condition = nir_src_for_ssa(nir_ilt(b, count, max_vertices));
-   nir_builder_cf_insert(b, _stmt->cf_node);
-
-   /* Fill out the new then-block */
-   b->cursor = nir_after_cf_list(_stmt->then_list);
+   nir_push_if(b, nir_ilt(b, count, max_vertices));
 
nir_intrinsic_instr *lowered =
   nir_intrinsic_instr_create(b->shader,
@@ -103,6 +98,8 @@ rewrite_emit_vertex(nir_intrinsic_instr *intrin, struct 
state *state)
  nir_iadd(b, count, nir_imm_int(b, 1)),
  0x1); /* .x */
 
+   nir_pop_if(b, NULL);
+
nir_instr_remove(>instr);
 
state->progress = true;
-- 
2.5.0.400.gff86faf

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


[Mesa-dev] [PATCH 1/8] nir/builder: Add support for easily building control-flow

2017-02-23 Thread Jason Ekstrand
Each of the pop functions (and push_else) take a control flow parameter as
their second argument.  If NULL, it assumes that the builder is in a block
that's a direct child of the control-flow node you want to pop off the
virtual stack.  This is what 90% of consumers will want.  The SPIR-V pass,
however, is a bit more "creative" about how it walks the CFG and it needs
to be able to pop multiple levels at a time, hence the argument.
---
 src/compiler/nir/nir_builder.h | 95 ++
 1 file changed, 95 insertions(+)

diff --git a/src/compiler/nir/nir_builder.h b/src/compiler/nir/nir_builder.h
index 194d327..2eaa025 100644
--- a/src/compiler/nir/nir_builder.h
+++ b/src/compiler/nir/nir_builder.h
@@ -81,6 +81,101 @@ nir_builder_cf_insert(nir_builder *build, nir_cf_node *cf)
nir_cf_node_insert(build->cursor, cf);
 }
 
+static inline bool
+nir_builder_is_inside_cf(nir_builder *build, nir_cf_node *cf_node)
+{
+   nir_block *block = nir_cursor_current_block(build->cursor);
+   for (nir_cf_node *n = >cf_node; n; n = n->parent) {
+  if (n == cf_node)
+ return true;
+   }
+   return false;
+}
+
+static inline nir_if *
+nir_push_if(nir_builder *build, nir_ssa_def *condition)
+{
+   nir_if *nif = nir_if_create(build->shader);
+   nif->condition = nir_src_for_ssa(condition);
+   nir_builder_cf_insert(build, >cf_node);
+   build->cursor = nir_before_cf_list(>then_list);
+   return nif;
+}
+
+static inline nir_if *
+nir_push_else(nir_builder *build, nir_if *nif)
+{
+   if (nif) {
+  assert(nir_builder_is_inside_cf(build, >cf_node));
+   } else {
+  nir_block *block = nir_cursor_current_block(build->cursor);
+  nif = nir_cf_node_as_if(block->cf_node.parent);
+   }
+   build->cursor = nir_before_cf_list(>else_list);
+   return nif;
+}
+
+static inline void
+nir_pop_if(nir_builder *build, nir_if *nif)
+{
+   if (nif) {
+  assert(nir_builder_is_inside_cf(build, >cf_node));
+   } else {
+  nir_block *block = nir_cursor_current_block(build->cursor);
+  nif = nir_cf_node_as_if(block->cf_node.parent);
+   }
+   build->cursor = nir_after_cf_node(>cf_node);
+}
+
+static inline nir_ssa_def *
+nir_if_phi(nir_builder *build, nir_ssa_def *then_def, nir_ssa_def *else_def)
+{
+   nir_block *block = nir_cursor_current_block(build->cursor);
+   nir_if *nif = nir_cf_node_as_if(nir_cf_node_prev(>cf_node));
+
+   nir_phi_instr *phi = nir_phi_instr_create(build->shader);
+
+   nir_phi_src *src = ralloc(phi, nir_phi_src);
+   src->pred = nir_if_last_then_block(nif);
+   src->src = nir_src_for_ssa(then_def);
+   exec_list_push_tail(>srcs, >node);
+
+   src = ralloc(phi, nir_phi_src);
+   src->pred = nir_if_last_else_block(nif);
+   src->src = nir_src_for_ssa(else_def);
+   exec_list_push_tail(>srcs, >node);
+
+   assert(then_def->num_components == else_def->num_components);
+   assert(then_def->bit_size == else_def->bit_size);
+   nir_ssa_dest_init(>instr, >dest,
+ then_def->num_components, then_def->bit_size, NULL);
+
+   nir_builder_instr_insert(build, >instr);
+
+   return >dest.ssa;
+}
+
+static inline nir_loop *
+nir_push_loop(nir_builder *build)
+{
+   nir_loop *loop = nir_loop_create(build->shader);
+   nir_builder_cf_insert(build, >cf_node);
+   build->cursor = nir_before_cf_list(>body);
+   return loop;
+}
+
+static inline void
+nir_pop_loop(nir_builder *build, nir_loop *loop)
+{
+   if (loop) {
+  assert(nir_builder_is_inside_cf(build, >cf_node));
+   } else {
+  nir_block *block = nir_cursor_current_block(build->cursor);
+  loop = nir_cf_node_as_loop(block->cf_node.parent);
+   }
+   build->cursor = nir_after_cf_node(>cf_node);
+}
+
 static inline nir_ssa_def *
 nir_ssa_undef(nir_builder *build, unsigned num_components, unsigned bit_size)
 {
-- 
2.5.0.400.gff86faf

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


[Mesa-dev] [PATCH 4/8] nir/lower_indirect: Use nir_builder control-flow helpers

2017-02-23 Thread Jason Ekstrand
---
 src/compiler/nir/nir_lower_indirect_derefs.c | 35 
 1 file changed, 5 insertions(+), 30 deletions(-)

diff --git a/src/compiler/nir/nir_lower_indirect_derefs.c 
b/src/compiler/nir/nir_lower_indirect_derefs.c
index 09cc9a3..c949224 100644
--- a/src/compiler/nir/nir_lower_indirect_derefs.c
+++ b/src/compiler/nir/nir_lower_indirect_derefs.c
@@ -55,41 +55,16 @@ emit_indirect_load_store(nir_builder *b, 
nir_intrinsic_instr *orig_instr,
 
   nir_ssa_def *then_dest, *else_dest;
 
-  nir_if *if_stmt = nir_if_create(b->shader);
-  if_stmt->condition = nir_src_for_ssa(nir_ilt(b, arr->indirect.ssa,
-  nir_imm_int(b, mid)));
-  nir_cf_node_insert(b->cursor, _stmt->cf_node);
-
-  b->cursor = nir_after_cf_list(_stmt->then_list);
+  nir_push_if(b, nir_ilt(b, arr->indirect.ssa, nir_imm_int(b, mid)));
   emit_indirect_load_store(b, orig_instr, deref, arr_parent,
start, mid, _dest, src);
-
-  b->cursor = nir_after_cf_list(_stmt->else_list);
+  nir_push_else(b, NULL);
   emit_indirect_load_store(b, orig_instr, deref, arr_parent,
mid, end, _dest, src);
+  nir_pop_if(b, NULL);
 
-  b->cursor = nir_after_cf_node(_stmt->cf_node);
-
-  if (src == NULL) {
- /* We're a load.  We need to insert a phi node */
- nir_phi_instr *phi = nir_phi_instr_create(b->shader);
- unsigned bit_size = then_dest->bit_size;
- nir_ssa_dest_init(>instr, >dest,
-   then_dest->num_components, bit_size, NULL);
-
- nir_phi_src *src0 = ralloc(phi, nir_phi_src);
- src0->pred = nir_if_last_then_block(if_stmt);
- src0->src = nir_src_for_ssa(then_dest);
- exec_list_push_tail(>srcs, >node);
-
- nir_phi_src *src1 = ralloc(phi, nir_phi_src);
- src1->pred = nir_if_last_else_block(if_stmt);
- src1->src = nir_src_for_ssa(else_dest);
- exec_list_push_tail(>srcs, >node);
-
- nir_builder_instr_insert(b, >instr);
- *dest = >dest.ssa;
-  }
+  if (src == NULL)
+ *dest = nir_if_phi(b, then_dest, else_dest);
}
 }
 
-- 
2.5.0.400.gff86faf

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


[Mesa-dev] [PATCH 2/8] glsl/nir: Use nir_builder's new control-flow helpers

2017-02-23 Thread Jason Ekstrand
---
 src/compiler/glsl/glsl_to_nir.cpp | 38 +++---
 1 file changed, 11 insertions(+), 27 deletions(-)

diff --git a/src/compiler/glsl/glsl_to_nir.cpp 
b/src/compiler/glsl/glsl_to_nir.cpp
index 00f20da..fc2a2c4 100644
--- a/src/compiler/glsl/glsl_to_nir.cpp
+++ b/src/compiler/glsl/glsl_to_nir.cpp
@@ -520,31 +520,19 @@ nir_visitor::visit(ir_function_signature *ir)
 void
 nir_visitor::visit(ir_loop *ir)
 {
-   nir_loop *loop = nir_loop_create(this->shader);
-   nir_builder_cf_insert(, >cf_node);
-
-   b.cursor = nir_after_cf_list(>body);
+   nir_push_loop();
visit_exec_list(>body_instructions, this);
-   b.cursor = nir_after_cf_node(>cf_node);
+   nir_pop_loop(, NULL);
 }
 
 void
 nir_visitor::visit(ir_if *ir)
 {
-   nir_src condition =
-  nir_src_for_ssa(evaluate_rvalue(ir->condition));
-
-   nir_if *if_stmt = nir_if_create(this->shader);
-   if_stmt->condition = condition;
-   nir_builder_cf_insert(, _stmt->cf_node);
-
-   b.cursor = nir_after_cf_list(_stmt->then_list);
+   nir_push_if(, evaluate_rvalue(ir->condition));
visit_exec_list(>then_instructions, this);
-
-   b.cursor = nir_after_cf_list(_stmt->else_list);
+   nir_push_else(, NULL);
visit_exec_list(>else_instructions, this);
-
-   b.cursor = nir_after_cf_node(_stmt->cf_node);
+   nir_pop_if(, NULL);
 }
 
 void
@@ -1193,11 +1181,9 @@ nir_visitor::visit(ir_assignment *ir)
   copy->variables[1] = evaluate_deref(>instr, ir->rhs);
 
   if (ir->condition) {
- nir_if *if_stmt = nir_if_create(this->shader);
- if_stmt->condition = nir_src_for_ssa(evaluate_rvalue(ir->condition));
- nir_builder_cf_insert(, _stmt->cf_node);
- nir_instr_insert_after_cf_list(_stmt->then_list, >instr);
- b.cursor = nir_after_cf_node(_stmt->cf_node);
+ nir_push_if(, evaluate_rvalue(ir->condition));
+ nir_builder_instr_insert(, >instr);
+ nir_pop_if(, NULL);
   } else {
  nir_builder_instr_insert(, >instr);
   }
@@ -1232,11 +1218,9 @@ nir_visitor::visit(ir_assignment *ir)
store->src[0] = nir_src_for_ssa(src);
 
if (ir->condition) {
-  nir_if *if_stmt = nir_if_create(this->shader);
-  if_stmt->condition = nir_src_for_ssa(evaluate_rvalue(ir->condition));
-  nir_builder_cf_insert(, _stmt->cf_node);
-  nir_instr_insert_after_cf_list(_stmt->then_list, >instr);
-  b.cursor = nir_after_cf_node(_stmt->cf_node);
+  nir_push_if(, evaluate_rvalue(ir->condition));
+  nir_builder_instr_insert(, >instr);
+  nir_pop_if(, NULL);
} else {
   nir_builder_instr_insert(, >instr);
}
-- 
2.5.0.400.gff86faf

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


[Mesa-dev] [PATCH 0/8] anv: Add int64 support for gen8+

2017-02-23 Thread Jason Ekstrand
This little series adds int64 support to Vulkan on Broadwell and newer
hardware.  In theory, we could also support it on gen7 but that requires
more lowering code to be written.

Most of this series is the nir_builder control-flow stuff that I sent out
earlier with a small addition to make it easy to add phi instructions after
an if statement.  Next comes an int64 lowering pass in NIR that mirrors the
GLSL IR pass written by Ian.

The second-to-last patch makes i965 use the new NIR pass rather than the
GLSL IR one.  There are two reasons for this.  First, is that GL gets
better int64 test coverage than Vulkan does at the moment.  Second, this
means that we get at least one run of the NIR optimization loop (including
nir_opt_algebraic) before we do 64-bit integer lowering and we may be able
to get rid of some instructions instead of having to lower them.

Finally, it turns it in in the Vulkan driver for gen8+.  Once the lowering
pass gets expanded to handle the rest of the integer operations (maybe a
good noob task?), we can turn it on for gen7.

Jason Ekstrand (8):
  nir/builder: Add support for easily building control-flow
  glsl/nir: Use nir_builder's new control-flow helpers
  nir/lower_gs_intrinsics: Use nir_builder control-flow helpers
  nir/lower_indirect: Use nir_builder control-flow helpers
  spirv: Use nir_builder for control flow
  nir: Add a simple int64 lowering pass
  i965: Do int64 lowering in NIR
  anv: Advertise shaderInt64 on Broadwell and above

 src/compiler/Makefile.sources|   1 +
 src/compiler/glsl/glsl_to_nir.cpp|  38 ++--
 src/compiler/nir/nir.h   |  11 ++
 src/compiler/nir/nir_builder.h   |  95 +
 src/compiler/nir/nir_lower_gs_intrinsics.c   |   9 +-
 src/compiler/nir/nir_lower_indirect_derefs.c |  35 +---
 src/compiler/nir/nir_lower_int64.c   | 275 +++
 src/compiler/spirv/vtn_cfg.c |  45 ++---
 src/intel/vulkan/anv_device.c|   2 +-
 src/mesa/drivers/dri/i965/brw_link.cpp   |   5 -
 src/mesa/drivers/dri/i965/brw_nir.c  |   7 +
 11 files changed, 423 insertions(+), 100 deletions(-)
 create mode 100644 src/compiler/nir/nir_lower_int64.c

-- 
2.5.0.400.gff86faf

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


[Mesa-dev] [PATCH] builtin_functions: Add more 64-bit integers

2017-02-23 Thread Jason Ekstrand
Seriously, 1000 is not the only 64-bit integer.  We should test
a few more of them.

These new integers trigger a bug in the GLSL IR int64 lowering code.

Cc: Ian Romanick 
---
 generated_tests/builtin_function.py | 24 ++--
 1 file changed, 22 insertions(+), 2 deletions(-)

diff --git a/generated_tests/builtin_function.py 
b/generated_tests/builtin_function.py
index 663d9d8..a5eafb2 100644
--- a/generated_tests/builtin_function.py
+++ b/generated_tests/builtin_function.py
@@ -1309,8 +1309,28 @@ def _make_vector_or_matrix_test_vectors(test_suite_dict):
   [ 0.14,  0.18, -0.56],
   [ 0.40, -0.77,  1.76]]),  # mat3x4
 ]
-int64s = [np.int64(x) for x in [0, -1000, 1000]]
-uint64s = [np.uint64(x) for x in [0,  10, 1000]]
+
+int64s = [np.int64(x) for x in [
+   0,
+   3,
+   -1192,
+   1048576,
+   4251475,
+   29852643761,
+   -4398046511104,
+   -3948976685146,
+   -135763469567146206]]
+uint64s = [np.uint64(x) for x in [
+   0,
+   3,
+   1192,
+   1048576,
+   4251475,
+   29852643761,
+   4398046511104,
+   3948976685146,
+   135763469567146206,
+   11654173250180970009]]
 
 int64vecs = [
 np.array([-10, -12], dtype=np.int64),
-- 
2.5.0.400.gff86faf

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


Re: [Mesa-dev] [PATCH] mesa: Use _mesa_has_OES_geometry_shader() when validating draws

2017-02-23 Thread Tomasz Figa
On Fri, Feb 24, 2017 at 5:00 AM, Kenneth Graunke 
wrote:

> On Thursday, February 23, 2017 10:46:54 AM PST Ilia Mirkin wrote:
> > The assumption was that if you're setting that ext, you can do gles31. Is
> > there a driver/hw combo where that's not the case? If so, we should fix
> > that instead...
>
> ChromeOS/ARC++ currently disables GLES 3.1 on i965 because we haven't
> passed all the dEQP tests for it.  So, we support the functionality,
> but they're using GLES 3.0 contexts.  I'm guessing that's why they hit
> this and I haven't.
>
> They could probably disable the bit too, but checking whether the
> feature is actually exposed seems pretty reasonable.
>

Correct me if I'm wrong, but I think one can also create a context with
exact version by using EGL_KHR_create_context.

In any case, there are more checks for this extension in this file and they
either call this helper or explicitly check context version.

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


Re: [Mesa-dev] [PATCH 6/6] radv: add sample mask output support

2017-02-23 Thread Bas Nieuwenhuizen
For the series:

Reviewed-by: Bas Nieuwenhuizen 

On Thu, Feb 23, 2017 at 7:09 AM, Dave Airlie  wrote:
> From: Dave Airlie 
>
> This adds support to write to sample mask from the fragment shader.
>
> We can optimise this later like radeonsi.
>
> Signed-off-by: Dave Airlie 
> ---
>  src/amd/common/ac_nir_to_llvm.c  | 8 ++--
>  src/amd/common/ac_nir_to_llvm.h  | 1 +
>  src/amd/vulkan/radv_cmd_buffer.c | 2 ++
>  3 files changed, 9 insertions(+), 2 deletions(-)
>
> diff --git a/src/amd/common/ac_nir_to_llvm.c b/src/amd/common/ac_nir_to_llvm.c
> index 6021647..9778581 100644
> --- a/src/amd/common/ac_nir_to_llvm.c
> +++ b/src/amd/common/ac_nir_to_llvm.c
> @@ -4753,13 +4753,17 @@ handle_fs_outputs_post(struct nir_to_llvm_context 
> *ctx)
> ctx->shader_info->fs.writes_stencil = true;
> stencil = to_float(ctx, LLVMBuildLoad(ctx->builder,
>   
> ctx->outputs[radeon_llvm_reg_index_soa(i, 0)], ""));
> +   } else if (i == FRAG_RESULT_SAMPLE_MASK) {
> +   ctx->shader_info->fs.writes_sample_mask = true;
> +   samplemask = to_float(ctx, LLVMBuildLoad(ctx->builder,
> + 
> ctx->outputs[radeon_llvm_reg_index_soa(i, 0)], ""));
> } else {
> bool last = false;
> for (unsigned j = 0; j < 4; j++)
> values[j] = to_float(ctx, 
> LLVMBuildLoad(ctx->builder,
> 
> ctx->outputs[radeon_llvm_reg_index_soa(i, j)], ""));
>
> -   if (!ctx->shader_info->fs.writes_z && 
> !ctx->shader_info->fs.writes_stencil)
> +   if (!ctx->shader_info->fs.writes_z && 
> !ctx->shader_info->fs.writes_stencil && 
> !ctx->shader_info->fs.writes_sample_mask)
> last = ctx->output_mask <= ((1ull << (i + 1)) 
> - 1);
>
> si_export_mrt_color(ctx, values, V_008DFC_SQ_EXP_MRT 
> + index, last);
> @@ -4767,7 +4771,7 @@ handle_fs_outputs_post(struct nir_to_llvm_context *ctx)
> }
> }
>
> -   if (depth || stencil)
> +   if (depth || stencil || samplemask)
> si_export_mrt_z(ctx, depth, stencil, samplemask);
> else if (!index)
> si_export_mrt_color(ctx, NULL, V_008DFC_SQ_EXP_NULL, true);
> diff --git a/src/amd/common/ac_nir_to_llvm.h b/src/amd/common/ac_nir_to_llvm.h
> index c2662e2..6c2b78b 100644
> --- a/src/amd/common/ac_nir_to_llvm.h
> +++ b/src/amd/common/ac_nir_to_llvm.h
> @@ -118,6 +118,7 @@ struct ac_shader_variant_info {
> bool can_discard;
> bool writes_z;
> bool writes_stencil;
> +   bool writes_sample_mask;
> bool early_fragment_test;
> bool writes_memory;
> bool force_persample;
> diff --git a/src/amd/vulkan/radv_cmd_buffer.c 
> b/src/amd/vulkan/radv_cmd_buffer.c
> index 5b7564c..1e38cbe 100644
> --- a/src/amd/vulkan/radv_cmd_buffer.c
> +++ b/src/amd/vulkan/radv_cmd_buffer.c
> @@ -674,6 +674,7 @@ radv_emit_fragment_shader(struct radv_cmd_buffer 
> *cmd_buffer,
>S_02880C_Z_EXPORT_ENABLE(ps->info.fs.writes_z) 
> |
>
> S_02880C_STENCIL_TEST_VAL_EXPORT_ENABLE(ps->info.fs.writes_stencil) |
>
> S_02880C_KILL_ENABLE(!!ps->info.fs.can_discard) |
> +  
> S_02880C_MASK_EXPORT_ENABLE(ps->info.fs.writes_sample_mask) |
>S_02880C_Z_ORDER(z_order) |
>
> S_02880C_DEPTH_BEFORE_SHADER(ps->info.fs.early_fragment_test) |
>
> S_02880C_EXEC_ON_HIER_FAIL(ps->info.fs.writes_memory) |
> @@ -694,6 +695,7 @@ radv_emit_fragment_shader(struct radv_cmd_buffer 
> *cmd_buffer,
> radeon_set_context_reg(cmd_buffer->cs, R_0286E0_SPI_BARYC_CNTL, 
> spi_baryc_cntl);
>
> radeon_set_context_reg(cmd_buffer->cs, R_028710_SPI_SHADER_Z_FORMAT,
> +  ps->info.fs.writes_sample_mask ? 
> V_028710_SPI_SHADER_32_ABGR :
>ps->info.fs.writes_stencil ? 
> V_028710_SPI_SHADER_32_GR :
>ps->info.fs.writes_z ? 
> V_028710_SPI_SHADER_32_R :
>V_028710_SPI_SHADER_ZERO);
> --
> 2.9.3
>
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org

Re: [Mesa-dev] [PATCH] util/disk_cache: Use backward compatible st_mtime.

2017-02-23 Thread Timothy Arceri

Reviewed-by: Timothy Arceri 

On 24/02/17 09:29, Vinson Lee wrote:

Fix Mac OS X build error.

  CC   libmesautil_la-disk_cache.lo
In file included from disk_cache.c:46:
./disk_cache.h:57:20: error: no member named 'st_mtim' in 'struct stat'
   *timestamp = st.st_mtim.tv_sec;
~~ ^

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=99918
Fixes: 207e3a6e4b ("util/radv: move *_get_function_timestamp() to utils")
Signed-off-by: Vinson Lee 
---
 src/util/disk_cache.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/util/disk_cache.h b/src/util/disk_cache.h
index 7f4da809cc..b7c0df25dd 100644
--- a/src/util/disk_cache.h
+++ b/src/util/disk_cache.h
@@ -54,7 +54,7 @@ disk_cache_get_function_timestamp(void *ptr, uint32_t* 
timestamp)
if (stat(info.dli_fname, )) {
   return false;
}
-   *timestamp = st.st_mtim.tv_sec;
+   *timestamp = st.st_mtime;
return true;
 #else
return false;


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


[Mesa-dev] [PATCH] configure.ac: check require_basic_egl only if egl enabled

2017-02-23 Thread Leo Liu
Otherwise the configuration fails when building independant libs
like vdpau, vaapi or omx

Signed-off-by: Leo Liu 
---
 configure.ac | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index 44c7883..890a379 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2310,7 +2310,9 @@ if test -n "$with_gallium_drivers"; then
 PKG_CHECK_MODULES([AMDGPU], [libdrm >= $LIBDRM_AMDGPU_REQUIRED 
libdrm_amdgpu >= $LIBDRM_AMDGPU_REQUIRED])
 require_libdrm "radeonsi"
 radeon_llvm_check $LLVM_REQUIRED_RADEONSI "radeonsi"
-require_basic_egl "radeonsi"
+if test "x$enable_egl" = xyes; then
+require_basic_egl "radeonsi"
+fi
 ;;
 xnouveau)
 HAVE_GALLIUM_NOUVEAU=yes
-- 
2.9.3

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


Re: [Mesa-dev] [PATCH 02/37] mapi/glapi: remove unused next_available_offset.sh

2017-02-23 Thread Ian Romanick
On 02/23/2017 09:13 AM, Emil Velikov wrote:
> Afaict there was no [documented] users since it was introduced.

Back in the old days, some functions would get entry points assigned
statically.  Just looking at all the XML, it was difficult to tell what
the next available offset was.  This script was used by hand to
determine that.  I don't think it has been useful for a very, very long
time.

This patch is

Reviewed-by: Ian Romanick 

> Cc: Ian Romanick 
> Signed-off-by: Emil Velikov 
> ---
>  src/mapi/glapi/gen/next_available_offset.sh | 39 
> -
>  1 file changed, 39 deletions(-)
>  delete mode 100755 src/mapi/glapi/gen/next_available_offset.sh
> 
> diff --git a/src/mapi/glapi/gen/next_available_offset.sh 
> b/src/mapi/glapi/gen/next_available_offset.sh
> deleted file mode 100755
> index e7d6c2f4af..00
> --- a/src/mapi/glapi/gen/next_available_offset.sh
> +++ /dev/null
> @@ -1,39 +0,0 @@
> -#!/usr/bin/env bash
> -#
> -# (C) Copyright IBM Corporation 2004
> -# All Rights Reserved.
> -#
> -# Permission is hereby granted, free of charge, to any person obtaining a
> -# copy of this software and associated documentation files (the "Software"),
> -# to deal in the Software without restriction, including without limitation
> -# on the rights to use, copy, modify, merge, publish, distribute, sub
> -# license, and/or sell copies of the Software, and to permit persons to whom
> -# the Software is furnished to do so, subject to the following conditions:
> -#
> -# The above copyright notice and this permission notice (including the next
> -# paragraph) shall be included in all copies or substantial portions of the
> -# Software.
> -#
> -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> -# FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.  IN NO EVENT SHALL
> -# IBM AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
> -# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
> DEALINGS
> -# IN THE SOFTWARE.
> -#
> -# Authors:
> -#Ian Romanick 
> -
> -# Trivial shell script to search the API definition file and print out the
> -# next numerically available API entry-point offset.  This could probably
> -# be made smarter, but it would be better to use the existin Python
> -# framework to do that.  This is just a quick-and-dirty hack.
> -
> -num=$(grep 'offset="' gl_API.xml |\
> -sed 's/.\+ offset="//g;s/".*$//g' |\
> -grep -v '?' |\
> -sort -rn |\
> -head -1)
> -
> -echo $((num + 1))
> 

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


[Mesa-dev] [PATCH] glsl: Fix missing-braces warning.

2017-02-23 Thread Vinson Lee
  CXXglsl/ast_to_hir.lo
glsl/ast_to_hir.cpp: In member function 'virtual ir_rvalue* 
ast_declarator_list::hir(exec_list*, _mesa_glsl_parse_state*)':
glsl/ast_to_hir.cpp:4846:42: warning: missing braces around initializer for 
'unsigned int [16]' [-Wmissing-braces]

Signed-off-by: Vinson Lee 
---
 src/compiler/glsl/ast_to_hir.cpp |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/compiler/glsl/ast_to_hir.cpp b/src/compiler/glsl/ast_to_hir.cpp
index b90ad97b1de4..f148db8617d6 100644
--- a/src/compiler/glsl/ast_to_hir.cpp
+++ b/src/compiler/glsl/ast_to_hir.cpp
@@ -4843,7 +4843,7 @@ ast_declarator_list::hir(exec_list *instructions,
   if ((var->data.mode == ir_var_auto || var->data.mode == ir_var_temporary)
   && (var->type->is_numeric() || var->type->is_boolean())
   && state->zero_init) {
- const ir_constant_data data = {0};
+ const ir_constant_data data = { { 0 } };
  var->data.has_initializer = true;
  var->constant_initializer = new(var) ir_constant(var->type, );
   }
-- 
1.7.9.5

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


[Mesa-dev] [PATCH] util/disk_cache: Use backward compatible st_mtime.

2017-02-23 Thread Vinson Lee
Fix Mac OS X build error.

  CC   libmesautil_la-disk_cache.lo
In file included from disk_cache.c:46:
./disk_cache.h:57:20: error: no member named 'st_mtim' in 'struct stat'
   *timestamp = st.st_mtim.tv_sec;
~~ ^

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=99918
Fixes: 207e3a6e4b ("util/radv: move *_get_function_timestamp() to utils")
Signed-off-by: Vinson Lee 
---
 src/util/disk_cache.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/util/disk_cache.h b/src/util/disk_cache.h
index 7f4da809cc..b7c0df25dd 100644
--- a/src/util/disk_cache.h
+++ b/src/util/disk_cache.h
@@ -54,7 +54,7 @@ disk_cache_get_function_timestamp(void *ptr, uint32_t* 
timestamp)
if (stat(info.dli_fname, )) {
   return false;
}
-   *timestamp = st.st_mtim.tv_sec;
+   *timestamp = st.st_mtime;
return true;
 #else
return false;
-- 
2.11.1

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


Re: [Mesa-dev] X test suite regression due to gallivm change

2017-02-23 Thread Adam Jackson
On Thu, 2017-02-23 at 21:59 +0100, Roland Scheidegger wrote:

> So, what does the failing test do?

Not much, curiously. There are five that fail and they're all fairly
trivial, although the xts harness makes that hard to see.

XClearArea/6 and XClearWindow/4 set the window background pixmap to
None and calls XClearArea. This should not change any pixels;
apparently it does.

XClearArea/7 and XClearWindow/5 create a parent window, then a child,
sets the parent bg to None, the child to ParentRelative, and clears the
child. Again, this should not change anything, but does.

XCopyArea/1 creates two windows, tiles the background of the first one
(equivalent to ClearWindow), copies from one window to the other, and
verifies that the second one has the right content.

The first four there are a little strange because, in principle, the
thing they're testing is that no rendering happens. Presumably what's
being measured is that some _other_ rendering prior to the action under
test is being done incorrectly. The CopyArea test is probably closest
to the root cause. I'll drill down a bit on exactly what that turns
into in terms of GL draws.

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


Re: [Mesa-dev] [PATCH 1/2] radeonsi: add support for an on-disk shader cache

2017-02-23 Thread Timothy Arceri



On 24/02/17 05:12, Marek Olšák wrote:

On Thu, Feb 23, 2017 at 3:09 AM, Timothy Arceri  wrote:

From: kdj0c 

V2 (Timothy Arceri):
- when loading from disk cache also binary insert into memory cache.
- check that the binary loaded from disk is the correct size. If not
  delete the cache item and skip loading from cache.
---
 src/gallium/drivers/radeonsi/si_state_shaders.c | 69 ++---
 1 file changed, 62 insertions(+), 7 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_state_shaders.c 
b/src/gallium/drivers/radeonsi/si_state_shaders.c
index f615aa8..71556f9 100644
--- a/src/gallium/drivers/radeonsi/si_state_shaders.c
+++ b/src/gallium/drivers/radeonsi/si_state_shaders.c
@@ -36,6 +36,9 @@
 #include "util/u_memory.h"
 #include "util/u_prim.h"

+#include "util/disk_cache.h"
+#include "util/mesa-sha1.h"
+
 /* SHADER_CACHE */

 /**
@@ -182,10 +185,12 @@ static bool si_load_shader_binary(struct si_shader 
*shader, void *binary)
  */
 static bool si_shader_cache_insert_shader(struct si_screen *sscreen,
  void *tgsi_binary,
- struct si_shader *shader)
+ struct si_shader *shader,
+ bool insert_into_disk_cache)
 {
void *hw_binary;
struct hash_entry *entry;
+   uint8_t key[CACHE_KEY_SIZE];

entry = _mesa_hash_table_search(sscreen->shader_cache, tgsi_binary);
if (entry)
@@ -201,6 +206,12 @@ static bool si_shader_cache_insert_shader(struct si_screen 
*sscreen,
return false;
}

+   if (sscreen->b.disk_shader_cache && insert_into_disk_cache) {
+   _mesa_sha1_compute(tgsi_binary, *((uint32_t *)tgsi_binary), 
key);


What happens if we randomly get a sha1 collision?


You should stop playing your game which will be rendering incorrectly 
and by a lotto ticket.



Shouldn't we store the whole key as well?


Sure I can add that, its cheap to check here anyway. Although the other 
cache stages rely on a collision being improbable.





+   disk_cache_put(sscreen->b.disk_shader_cache, key, hw_binary,
+  *((uint32_t *) hw_binary));
+   }
+
return true;
 }

@@ -210,12 +221,56 @@ static bool si_shader_cache_load_shader(struct si_screen 
*sscreen,
 {
struct hash_entry *entry =
_mesa_hash_table_search(sscreen->shader_cache, tgsi_binary);
-   if (!entry)
-   return false;
+   if (!entry) {
+   if (sscreen->b.disk_shader_cache) {
+   unsigned char sha1[CACHE_KEY_SIZE];
+   size_t tg_size = *((uint32_t *) tgsi_binary);
+
+   _mesa_sha1_compute(tgsi_binary, tg_size, sha1);
+
+   size_t binary_size;
+   uint8_t *buffer =
+   disk_cache_get(sscreen->b.disk_shader_cache,
+  sha1, _size);
+   if (!buffer)
+   return false;

-   if (!si_load_shader_binary(shader, entry->data))
-   return false;
+   uint32_t stored_binary_size;


It looks like you don't need this variable.



Right, I'll tidy that up thanks.



Marek


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


Re: [Mesa-dev] X test suite regression due to gallivm change

2017-02-23 Thread Roland Scheidegger
Am 23.02.2017 um 19:51 schrieb Adam Jackson:
> Starting from:
> 
>> commit 320d1191c61a0a82444605c12e5c4b2ee0b241eb
>> Author: Jose Fonseca 
>> Date:   Mon Apr 4 00:05:33 2016 +0100
>>
>> gallivm: Use llvm.fmuladd.*.
>> 
>> Reviewed-by: Roland Scheidegger 
> 
> 'make check' in xserver no longer passes on Xephyr+glamor+llvmpipe. At
> least, not on my Skylake. Setting LP_NATIVE_VECTOR_WIDTH=128 fixes it,
> so I assume this is a difference in generated code between AVX2 and
> non-AVX. I haven't dug much further into it yet, just wondering if
> there's any obvious reason AVX would generate noticably different
> rendering after this change, or if this change had been seen to cause
> trouble on other AVX machines.
> 

So, what does the failing test do?
Using fmuladd can generate different output (of course due to using fma
instead of mul+add on cpus supporting it - and indeed we will only use
that with 256bit vectors when we emit avx2 code). Typically, the
difference should be unnoticeable (and in particular we should not do
anything which isn't allowed by apis). But if you do strange things
(like forgetting about half-pixel offsets or such) and then relying on
rounding always falling on the same side there might be some surprises.
It is of course possible there's a genuine llvmpipe/gallivm/draw bug
somewhere...

Roland

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


[Mesa-dev] [PATCH] r600g/sb: Fix memory leak by reworking uses list (rebased)

2017-02-23 Thread Constantine Charlamov
The author is Heiko Przybyl(CC'ing), the patch is rebased on top of Bartosz 
Tomczyk's one per Dieter Nützel's comment.
Tested-by: Constantine Charlamov 

--
When fixing the stalls on evergreen I introduced leaking of the useinfo
structure(s). Sorry. Instead of allocating a new object to hold 3 values
where only one is actually used, rework the list to just store the node
pointer. Thus no allocating and deallocation is needed. Since use_info
and use_kind aren't used anywhere, drop them and reduce code complexity.
This might also save some small amount of cycles.

Thanks to Bartosz Tomczyk for finding the bug.

Reported-by: Bartosz Tomczyk https://lists.freedesktop.org/mailman/listinfo/mesa-dev>>
Signed-off-by: Heiko Przybyl https://lists.freedesktop.org/mailman/listinfo/mesa-dev>>
Supersedes: https://patchwork.freedesktop.org/patch/135852

---
 src/gallium/drivers/r600/sb/sb_def_use.cpp  | 29 +++--
 src/gallium/drivers/r600/sb/sb_gcm.cpp  | 16 
 src/gallium/drivers/r600/sb/sb_ir.h | 23 ++-
 src/gallium/drivers/r600/sb/sb_valtable.cpp | 21 +++--
 4 files changed, 28 insertions(+), 61 deletions(-)

diff --git a/src/gallium/drivers/r600/sb/sb_def_use.cpp 
b/src/gallium/drivers/r600/sb/sb_def_use.cpp
index a512d92086..68ab4ca26c 100644
--- a/src/gallium/drivers/r600/sb/sb_def_use.cpp
+++ b/src/gallium/drivers/r600/sb/sb_def_use.cpp
@@ -106,58 +106,51 @@ void def_use::process_defs(node *n, vvec , bool 
arr_def) {
 }
 
 void def_use::process_uses(node* n) {
-unsigned k = 0;
-
-for (vvec::iterator I = n->src.begin(), E = n->src.end(); I != E;
-++I, ++k) {
+for (vvec::iterator I = n->src.begin(), E = n->src.end(); I != E; ++I) {
 value *v = *I;
 if (!v || v->is_readonly())
 continue;
 
 if (v->is_rel()) {
 if (!v->rel->is_readonly())
-v->rel->add_use(n, UK_SRC_REL, k);
+v->rel->add_use(n);
 
-unsigned k2 = 0;
 for (vvec::iterator I = v->muse.begin(), E = v->muse.end();
-I != E; ++I, ++k2) {
+I != E; ++I) {
 value *v = *I;
 if (!v)
 continue;
 
-v->add_use(n, UK_MAYUSE, k2);
+v->add_use(n);
 }
 } else
-v->add_use(n, UK_SRC, k);
+v->add_use(n);
 }
 
-k = 0;
-for (vvec::iterator I = n->dst.begin(), E = n->dst.end(); I != E;
-++I, ++k) {
+for (vvec::iterator I = n->dst.begin(), E = n->dst.end(); I != E; ++I) {
 value *v = *I;
 if (!v || !v->is_rel())
 continue;
 
 if (!v->rel->is_readonly())
-v->rel->add_use(n, UK_DST_REL, k);
-unsigned k2 = 0;
+v->rel->add_use(n);
 for (vvec::iterator I = v->muse.begin(), E = v->muse.end();
-I != E; ++I, ++k2) {
+I != E; ++I) {
 value *v = *I;
 if (!v)
 continue;
 
-v->add_use(n, UK_MAYDEF, k2);
+v->add_use(n);
 }
 }
 
 if (n->pred)
-n->pred->add_use(n, UK_PRED, 0);
+n->pred->add_use(n);
 
 if (n->type == NT_IF) {
 if_node *i = static_cast(n);
 if (i->cond)
-i->cond->add_use(i, UK_COND, 0);
+i->cond->add_use(i);
 }
 }
 
diff --git a/src/gallium/drivers/r600/sb/sb_gcm.cpp 
b/src/gallium/drivers/r600/sb/sb_gcm.cpp
index 9c75389ada..7b43a32818 100644
--- a/src/gallium/drivers/r600/sb/sb_gcm.cpp
+++ b/src/gallium/drivers/r600/sb/sb_gcm.cpp
@@ -200,27 +200,27 @@ void gcm::td_release_val(value *v) {
 );
 
 for (uselist::iterator I = v->uses.begin(), E = v->uses.end(); I != E; 
++I) {
-use_info *u = *I;
-if (u->op->parent != ) {
+node *op = *I;
+if (op->parent != ) {
 continue;
 }
 
 GCM_DUMP(
 sblog << "tdused in ";
-dump::dump_op(u->op);
+dump::dump_op(op);
 sblog << "\n";
 );
 
-assert(uses[u->op] > 0);
-if (--uses[u->op] == 0) {
+assert(uses[op] > 0);
+if (--uses[op] == 0) {
 GCM_DUMP(
 sblog << "tdreleased : ";
-dump::dump_op(u->op);
+dump::dump_op(op);
 sblog << "\n";
 );
 
-pending.remove_node(u->op);
-ready.push_back(u->op);
+pending.remove_node(op);
+ready.push_back(op);
 }
 }
 
diff --git a/src/gallium/drivers/r600/sb/sb_ir.h 
b/src/gallium/drivers/r600/sb/sb_ir.h
index 74c0549a81..ec973e7bfc 100644
--- a/src/gallium/drivers/r600/sb/sb_ir.h
+++ b/src/gallium/drivers/r600/sb/sb_ir.h
@@ -435,26 +435,7 @@ sb_ostream& operator << (sb_ostream , value );
 
 typedef uint32_t 

Re: [Mesa-dev] [PATCH] mesa: Use _mesa_has_OES_geometry_shader() when validating draws

2017-02-23 Thread Kenneth Graunke
On Thursday, February 23, 2017 10:46:54 AM PST Ilia Mirkin wrote:
> The assumption was that if you're setting that ext, you can do gles31. Is
> there a driver/hw combo where that's not the case? If so, we should fix
> that instead...

ChromeOS/ARC++ currently disables GLES 3.1 on i965 because we haven't
passed all the dEQP tests for it.  So, we support the functionality,
but they're using GLES 3.0 contexts.  I'm guessing that's why they hit
this and I haven't.

They could probably disable the bit too, but checking whether the
feature is actually exposed seems pretty reasonable.


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


Re: [Mesa-dev] [PATCH] Revert "i915: Always enable GL 2.0 support."

2017-02-23 Thread Matt Turner
On Thu, Feb 23, 2017 at 11:41 AM, Emil Velikov  wrote:
> On 30 January 2017 at 02:20, Matt Turner  wrote:
>> This partially reverts commit 97217a40f97cdeae0304798b607f704deb0c3558.
>> It leaves ES 2.0 support in place per Ian's suggestion, because ES 2.0
>> is designed to work on hardware like i915.
>>
>> The piglit results look like:
>>
>>name: before-revert-i915 after-revert-i915
>>  -- -
>>pass:   7171  2169
>>fail:933   201
>>   crash:  8 7
>>skip:  32997 38676
>> timeout:  0 0
>>warn:  3 1
>>  incomplete:  0 0
>>  dmesg-warn:  0 0
>>  dmesg-fail:  0 0
>> changes:  0  6040
>>   fixes:  0   292
>> regressions:  0 2
>>   total:  41112 41054
>>
>> Cc: "17.0" 
> Friendly FYI:
>
> The commit seems to be self-rejected by dropping the nomination tag,
> prior to commiting to master.
> Please let me know if that's incorrect and you'd like this in stable -
> personally, I'm split if it's a good idea to merge it or not.

Yeah, I forgot about the patch and caused it to miss the 17.0 release.
I wanted the change to first be available in a major release, so since
17.0 is already out, I dropped the stable tag.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] Revert "i915: Always enable GL 2.0 support."

2017-02-23 Thread Emil Velikov
On 30 January 2017 at 02:20, Matt Turner  wrote:
> This partially reverts commit 97217a40f97cdeae0304798b607f704deb0c3558.
> It leaves ES 2.0 support in place per Ian's suggestion, because ES 2.0
> is designed to work on hardware like i915.
>
> The piglit results look like:
>
>name: before-revert-i915 after-revert-i915
>  -- -
>pass:   7171  2169
>fail:933   201
>   crash:  8 7
>skip:  32997 38676
> timeout:  0 0
>warn:  3 1
>  incomplete:  0 0
>  dmesg-warn:  0 0
>  dmesg-fail:  0 0
> changes:  0  6040
>   fixes:  0   292
> regressions:  0 2
>   total:  41112 41054
>
> Cc: "17.0" 
Friendly FYI:

The commit seems to be self-rejected by dropping the nomination tag,
prior to commiting to master.
Please let me know if that's incorrect and you'd like this in stable -
personally, I'm split if it's a good idea to merge it or not.

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


[Mesa-dev] Question: How to handle 64-bit sampler/image handles added by ARB_bindless_texture?

2017-02-23 Thread Samuel Pitoiset

Hi there,

I started to work on ARB_bindless_texture which is an important missing 
feature in Mesa. Some games, at least Deus Ex: Mankind Divided, would 
benefit of this extension. As the spec says:


"The ability to access textures without having to bind and/or
re-bind them is similar to the capability provided by the
NV_shader_buffer_load extension that allows shaders to access buffer
objects without binding them.  In both cases, these extensions
significantly reduce the amount of API and internal GL driver overhead
needed to manage resource bindings."[1]

I wonder if "significantly" is the right term there, but 
ARB_bindless_texture should definitely reduce CPU usage in some 
scenarios. I would be happy to provide numbers when the extension is 
done, hopefully a good news is going to happen. Anyways, that not the 
main topic.


Basically, ARB_bindless_texture allows to access texture objects in 
shaders without first binding each texture to one of a limited number of
texture image units. A texture like this is called 'resident'. The steps 
are pretty simple:


1) create a texture object
2) get a texture handle which references the object
3) make the texture handle resident
4) use it directly in your shaders

The problem is: texture handles are 64-bit and sampler/image uniforms 
are considered 64-bit as well. But the extension doesn't introduce any 
new data types to GLSL.


Also note that GLSL 440 added restrictions about opaque types (samplers, 
images, atomic counters) but ARB_bindless_texture allows to declare 
sampler/image types as temporary variables, as inputs/outputs, inside 
interface blocks and more.


Now, the question: how to implement this in our GLSL compiler? :)

I wonder if introducing GLSL_TYPE_SAMPLER64 and GLSL_TYPE_IMAGE64 (to be 
used only if ARB_bindless_texture is enabled) is the right solution, but 
it has some advantages.


- easy to make GLSL_TYPE_SAMPLER64/GLSL_TYPE_IMAGE64 64-bit types
- easy to mark GLSL_TYPE_SAMPLER64/GLSL_TYPE_IMAGE64 as non-opaque types
- should not break anything if bindless is not enabled/supported

To sump up, the general idea would be to use the "old" 
GLSL_TYPE_SAMPLER/IMAGE types by default and only the 64-bit variants 
for bindless.


Does it make sense? Any thoughts?

Thanks!
Samuel.

[1] 
https://www.khronos.org/registry/OpenGL/extensions/ARB/ARB_bindless_texture.txt

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


Re: [Mesa-dev] [v2 22/27] intel/isl: Apply render target alignment constraints for MCS

2017-02-23 Thread Jason Ekstrand
Reviewed-by: Jason Ekstrand 

I also pushed it because I need it for my little series to implement MCS in
the Vulkan driver.

--Jason

On Thu, Feb 23, 2017 at 5:31 AM, Topi Pohjolainen <
topi.pohjolai...@gmail.com> wrote:

> v2: Instead of having the same block in isl_gen7,8,9.c add it
> once into isl.c::isl_choose_image_alignment_el() instead.
>
> CC: Jason Ekstrand 
> Signed-off-by: Topi Pohjolainen 
> ---
>  src/intel/isl/isl.c | 17 -
>  1 file changed, 16 insertions(+), 1 deletion(-)
>
> diff --git a/src/intel/isl/isl.c b/src/intel/isl/isl.c
> index 82ab68d..957ffd5 100644
> --- a/src/intel/isl/isl.c
> +++ b/src/intel/isl/isl.c
> @@ -480,7 +480,22 @@ isl_choose_image_alignment_el(const struct
> isl_device *dev,
>enum isl_msaa_layout msaa_layout,
>struct isl_extent3d *image_align_el)
>  {
> -   if (info->format == ISL_FORMAT_HIZ) {
> +   const struct isl_format_layout *fmtl = isl_format_get_layout(info->
> format);
> +   if (fmtl->txc == ISL_TXC_MCS) {
> +  assert(tiling == ISL_TILING_Y0);
> +
> +  /*
> +   * IvyBrigde PRM Vol 2, Part 1, "11.7 MCS Buffer for Render
> Target(s)":
> +   *
> +   * Height, width, and layout of MCS buffer in this case must match
> with
> +   * Render Target height, width, and layout. MCS buffer is tiledY.
> +   *
> +   * To avoid wasting memory, choose the smallest alignment possible:
> +   * HALIGN_4 and VALIGN_4.
> +   */
> +  *image_align_el = isl_extent3d(4, 4, 1);
> +  return;
> +   } else if (info->format == ISL_FORMAT_HIZ) {
>assert(ISL_DEV_GEN(dev) >= 6);
>/* HiZ surfaces are always aligned to 16x8 pixels in the primary
> surface
> * which works out to 2x2 HiZ elments.
> --
> 2.9.3
>
>
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] glsl: Raise a link error for non-SSO ES programs with a TES but no TCS.

2017-02-23 Thread Kenneth Graunke
On Thursday, February 23, 2017 4:03:36 AM PST Andres Gomez wrote:
> I would welcome a reference to the text in Secption 7.3 of the OpenGL
> ES 3.2 specs as a code comment and commit text but, other than that,
> this is:
> 
> Reviewed-by: Andres Gomez 

I'll add it to the commit message.  I wasn't sure about adding it to the
code since the block above quotes the very same section, so it seemed
like it was already cited (although the particular sentence isn't).

Of course, that didn't show up in the patch...sorry :(

Thanks for the review!


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


Re: [Mesa-dev] [PATCH] mesa: Use _mesa_has_OES_geometry_shader() when validating draws

2017-02-23 Thread Ilia Mirkin
The assumption was that if you're setting that ext, you can do gles31. Is
there a driver/hw combo where that's not the case? If so, we should fix
that instead...

On Feb 23, 2017 3:05 AM, "Tomasz Figa"  wrote:

> In validate_DrawElements_common() we need to check for OES_geometry_shader
> extension to determine if we should fail if transform feedback is
> unpaused. However current code reads ctx->Extensions.OES_geometry_shader
> directly, which does not take context version into account. This means
> that if the context is GLES 3.0, which makes the OES_geometry_shader
> inapplicable, we would not validate the draw properly. To fix it, let's
> replace the check with a call to _mesa_has_OES_geometry_shader().
>
> Fixes following dEQP tests on i965 with a GLES 3.0 context:
>
> dEQP-GLES3.functional.negative_api.vertex_array#draw_elements
> dEQP-GLES3.functional.negative_api.vertex_array#draw_elements_incomplete_
> primitive
> dEQP-GLES3.functional.negative_api.vertex_array#draw_elements_instanced
> dEQP-GLES3.functional.negative_api.vertex_array#draw_elements_instanced_
> incomplete_primitive
> dEQP-GLES3.functional.negative_api.vertex_array#draw_range_elements
> dEQP-GLES3.functional.negative_api.vertex_array#draw_range_elements_
> incomplete_primitive
>
> Change-Id: Iebc960b479fcd5f6c2b1501cb3e7798b575e6c4d
> Signed-off-by: Tomasz Figa 
> ---
>  src/mesa/main/api_validate.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/src/mesa/main/api_validate.c b/src/mesa/main/api_validate.c
> index 1e8a714067..184bf143ed 100644
> --- a/src/mesa/main/api_validate.c
> +++ b/src/mesa/main/api_validate.c
> @@ -664,7 +664,8 @@ validate_DrawElements_common(struct gl_context *ctx,
>  * to have been overlooked.  The body of the spec only explicitly
> allows
>  * the indirect versions.
>  */
> -   if (_mesa_is_gles3(ctx) && !ctx->Extensions.OES_geometry_shader &&
> +   if (_mesa_is_gles3(ctx) &&
> +   !_mesa_has_OES_geometry_shader(ctx) &&
> _mesa_is_xfb_active_and_unpaused(ctx)) {
>_mesa_error(ctx, GL_INVALID_OPERATION,
>"%s(transform feedback active)", caller);
> --
> 2.11.0.483.g087da7b7c-goog
>
>
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH v2 12/14] anv: don't use Element.get in anv_entrypoints_gen.py

2017-02-23 Thread Dylan Baker
This has the potential to mask errors, since Element.get works like
dict.get, returning None if the element isn't found. I think the reason
that Element.get was used is that vulkan has one extension that isn't
really an extension, and thus is missing the 'protect' field.

This patch changes the behavior slightly by replacing get with explicit
lookup in the Element.attrib dictionary, and using xpath to only iterate
over extensions with a "protect" attribute.

Signed-off-by: Dylan Baker 
---
 src/intel/vulkan/anv_entrypoints_gen.py | 13 +++--
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/src/intel/vulkan/anv_entrypoints_gen.py 
b/src/intel/vulkan/anv_entrypoints_gen.py
index e619ad5..7018262 100644
--- a/src/intel/vulkan/anv_entrypoints_gen.py
+++ b/src/intel/vulkan/anv_entrypoints_gen.py
@@ -303,13 +303,14 @@ def get_entrypoints(doc, entrypoints_to_defines):
 def get_entrypoints_defines(doc):
 """Maps entry points to extension defines."""
 entrypoints_to_defines = {}
-extensions = doc.findall('./extensions/extension')
-for extension in extensions:
-define = extension.get('protect')
-entrypoints = extension.findall('./require/command')
-for entrypoint in entrypoints:
-fullname = entrypoint.get('name')
+
+for extension in doc.findall('./extensions/extension[@protect]'):
+define = extension.attrib['protect']
+
+for entrypoint in extension.findall('./require/command'):
+fullname = entrypoint.attrib['name']
 entrypoints_to_defines[fullname] = define
+
 return entrypoints_to_defines
 
 
-- 
git-series 0.9.0
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] radeonsi: fix broken tessellation on Carrizo and Stoney

2017-02-23 Thread Samuel Pitoiset



On 02/23/2017 07:48 PM, Marek Olšák wrote:

From: Marek Olšák 



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


Cc: 13.0 17.0 
---
 src/gallium/drivers/radeonsi/si_state_shaders.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/gallium/drivers/radeonsi/si_state_shaders.c 
b/src/gallium/drivers/radeonsi/si_state_shaders.c
index f615aa8..750cdd6 100644
--- a/src/gallium/drivers/radeonsi/si_state_shaders.c
+++ b/src/gallium/drivers/radeonsi/si_state_shaders.c
@@ -2305,21 +2305,23 @@ static bool si_update_spi_tmpring_size(struct 
si_context *sctx)
   S_0286E8_WAVESIZE(scratch_bytes_per_wave >> 10);
if (spi_tmpring_size != sctx->spi_tmpring_size) {
sctx->spi_tmpring_size = spi_tmpring_size;
si_mark_atom_dirty(sctx, >scratch_state);
}
return true;
 }

 static void si_init_tess_factor_ring(struct si_context *sctx)
 {
-   bool double_offchip_buffers = sctx->b.chip_class >= CIK;
+   bool double_offchip_buffers = sctx->b.chip_class >= CIK &&
+ sctx->b.family != CHIP_CARRIZO &&
+ sctx->b.family != CHIP_STONEY;
unsigned max_offchip_buffers_per_se = double_offchip_buffers ? 128 : 64;
unsigned max_offchip_buffers = max_offchip_buffers_per_se *
   sctx->screen->b.info.max_se;
unsigned offchip_granularity;

switch (sctx->screen->tess_offchip_block_dw_size) {
default:
assert(0);
/* fall through */
case 8192:


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


[Mesa-dev] X test suite regression due to gallivm change

2017-02-23 Thread Adam Jackson
Starting from:

> commit 320d1191c61a0a82444605c12e5c4b2ee0b241eb
> Author: Jose Fonseca 
> Date:   Mon Apr 4 00:05:33 2016 +0100
> 
> gallivm: Use llvm.fmuladd.*.
> 
> Reviewed-by: Roland Scheidegger 

'make check' in xserver no longer passes on Xephyr+glamor+llvmpipe. At
least, not on my Skylake. Setting LP_NATIVE_VECTOR_WIDTH=128 fixes it,
so I assume this is a difference in generated code between AVX2 and
non-AVX. I haven't dug much further into it yet, just wondering if
there's any obvious reason AVX would generate noticably different
rendering after this change, or if this change had been seen to cause
trouble on other AVX machines.

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


Re: [Mesa-dev] [PATCH] radeonsi: fix broken tessellation on Carrizo and Stoney

2017-02-23 Thread Alex Deucher
On Thu, Feb 23, 2017 at 1:48 PM, Marek Olšák  wrote:
> From: Marek Olšák 
>
> Cc: 13.0 17.0 

Reviewed-by: Alex Deucher 

> ---
>  src/gallium/drivers/radeonsi/si_state_shaders.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/src/gallium/drivers/radeonsi/si_state_shaders.c 
> b/src/gallium/drivers/radeonsi/si_state_shaders.c
> index f615aa8..750cdd6 100644
> --- a/src/gallium/drivers/radeonsi/si_state_shaders.c
> +++ b/src/gallium/drivers/radeonsi/si_state_shaders.c
> @@ -2305,21 +2305,23 @@ static bool si_update_spi_tmpring_size(struct 
> si_context *sctx)
>S_0286E8_WAVESIZE(scratch_bytes_per_wave >> 10);
> if (spi_tmpring_size != sctx->spi_tmpring_size) {
> sctx->spi_tmpring_size = spi_tmpring_size;
> si_mark_atom_dirty(sctx, >scratch_state);
> }
> return true;
>  }
>
>  static void si_init_tess_factor_ring(struct si_context *sctx)
>  {
> -   bool double_offchip_buffers = sctx->b.chip_class >= CIK;
> +   bool double_offchip_buffers = sctx->b.chip_class >= CIK &&
> + sctx->b.family != CHIP_CARRIZO &&
> + sctx->b.family != CHIP_STONEY;
> unsigned max_offchip_buffers_per_se = double_offchip_buffers ? 128 : 
> 64;
> unsigned max_offchip_buffers = max_offchip_buffers_per_se *
>sctx->screen->b.info.max_se;
> unsigned offchip_granularity;
>
> switch (sctx->screen->tess_offchip_block_dw_size) {
> default:
> assert(0);
> /* fall through */
> case 8192:
> --
> 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: fix broken tessellation on Carrizo and Stoney

2017-02-23 Thread Marek Olšák
From: Marek Olšák 

Cc: 13.0 17.0 
---
 src/gallium/drivers/radeonsi/si_state_shaders.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/gallium/drivers/radeonsi/si_state_shaders.c 
b/src/gallium/drivers/radeonsi/si_state_shaders.c
index f615aa8..750cdd6 100644
--- a/src/gallium/drivers/radeonsi/si_state_shaders.c
+++ b/src/gallium/drivers/radeonsi/si_state_shaders.c
@@ -2305,21 +2305,23 @@ static bool si_update_spi_tmpring_size(struct 
si_context *sctx)
   S_0286E8_WAVESIZE(scratch_bytes_per_wave >> 10);
if (spi_tmpring_size != sctx->spi_tmpring_size) {
sctx->spi_tmpring_size = spi_tmpring_size;
si_mark_atom_dirty(sctx, >scratch_state);
}
return true;
 }
 
 static void si_init_tess_factor_ring(struct si_context *sctx)
 {
-   bool double_offchip_buffers = sctx->b.chip_class >= CIK;
+   bool double_offchip_buffers = sctx->b.chip_class >= CIK &&
+ sctx->b.family != CHIP_CARRIZO &&
+ sctx->b.family != CHIP_STONEY;
unsigned max_offchip_buffers_per_se = double_offchip_buffers ? 128 : 64;
unsigned max_offchip_buffers = max_offchip_buffers_per_se *
   sctx->screen->b.info.max_se;
unsigned offchip_granularity;
 
switch (sctx->screen->tess_offchip_block_dw_size) {
default:
assert(0);
/* fall through */
case 8192:
-- 
2.7.4

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


[Mesa-dev] [PATCH v2 10/14] anv: anv_entrypoints_gen.py: use reduce function.

2017-02-23 Thread Dylan Baker
Reduce is it's own reward.

Signed-off-by: Dylan Baker 
---
 src/intel/vulkan/anv_entrypoints_gen.py | 8 +++-
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/src/intel/vulkan/anv_entrypoints_gen.py 
b/src/intel/vulkan/anv_entrypoints_gen.py
index 7386b1d..cb28050 100644
--- a/src/intel/vulkan/anv_entrypoints_gen.py
+++ b/src/intel/vulkan/anv_entrypoints_gen.py
@@ -23,6 +23,7 @@
 #
 
 import argparse
+import functools
 import os
 import textwrap
 import xml.etree.ElementTree as et
@@ -256,11 +257,8 @@ PRIME_STEP = 19
 
 def cal_hash(name):
 """Calculate the same hash value that Mesa will calculate in C."""
-h = 0
-for c in name:
-h = (h * PRIME_FACTOR + ord(c)) & U32_MASK
-
-return h
+return functools.reduce(
+lambda h, c: (h * PRIME_FACTOR + ord(c)) & U32_MASK, name, 0)
 
 
 def get_entrypoints(doc, entrypoints_to_defines):
-- 
git-series 0.9.0
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH v2 8/14] anv: generate anv_entrypoints.{h, c} in one command

2017-02-23 Thread Dylan Baker
This changes the python generator to write the files itself, rather than
piping them out. This has a couple of advantages: first, it encapsulates
the encoding. Second, it ensures that the header file and code file are
generated at the same time with the same data.

v2: - Update Android.mk

Signed-off-by: Dylan Baker 
---
 src/intel/vulkan/Android.mk |  7 +-
 src/intel/vulkan/Makefile.am|  8 ++
 src/intel/vulkan/anv_entrypoints_gen.py | 33 +-
 3 files changed, 22 insertions(+), 26 deletions(-)

diff --git a/src/intel/vulkan/Android.mk b/src/intel/vulkan/Android.mk
index 9dabf1c..df10141 100644
--- a/src/intel/vulkan/Android.mk
+++ b/src/intel/vulkan/Android.mk
@@ -60,8 +60,8 @@ $(intermediates)/dummy.c:
@echo "Gen Dummy: $(PRIVATE_MODULE) <= $(notdir $(@))"
$(hide) touch $@
 
-$(intermediates)/anv_entrypoints.h:
-   $(VK_ENTRYPOINTS_SCRIPT) header --xml 
$(MESA_TOP)/src/vulkan/registry/vk.xml > $@
+$(intermediates)/anv_entrypoints.h $(intermediates)/anv_entrypoints.c:
+   $(VK_ENTRYPOINTS_SCRIPT) --xml $(MESA_TOP)/src/vulkan/registry/vk.xml
 
 LOCAL_EXPORT_C_INCLUDE_DIRS := \
 $(intermediates)
@@ -176,9 +176,6 @@ LOCAL_WHOLE_STATIC_LIBRARIES := libmesa_anv_entrypoints 
libmesa_genxml
 
 LOCAL_GENERATED_SOURCES += $(intermediates)/anv_entrypoints.c
 
-$(intermediates)/anv_entrypoints.c:
-   $(VK_ENTRYPOINTS_SCRIPT) code --xml 
$(MESA_TOP)/src/vulkan/registry/vk.xml > $@
-
 LOCAL_SHARED_LIBRARIES := libdrm_intel
 
 include $(MESA_COMMON_MK)
diff --git a/src/intel/vulkan/Makefile.am b/src/intel/vulkan/Makefile.am
index 565559c..38a50c9 100644
--- a/src/intel/vulkan/Makefile.am
+++ b/src/intel/vulkan/Makefile.am
@@ -145,11 +145,9 @@ libvulkan_intel_la_SOURCES = $(VULKAN_GEM_FILES)
 
 vulkan_api_xml = $(top_srcdir)/src/vulkan/registry/vk.xml
 
-anv_entrypoints.h : anv_entrypoints_gen.py $(vulkan_api_xml)
-   $(AM_V_GEN)$(PYTHON2) $(srcdir)/anv_entrypoints_gen.py header --xml 
$(vulkan_api_xml) > $@
-
-anv_entrypoints.c : anv_entrypoints_gen.py $(vulkan_api_xml)
-   $(AM_V_GEN)$(PYTHON2) $(srcdir)/anv_entrypoints_gen.py code --xml 
$(vulkan_api_xml) > $@
+anv_entrypoints.h anv_entrypoints.c: anv_entrypoints_gen.py $(vulkan_api_xml)
+   $(AM_V_GEN)$(PYTHON2) $(srcdir)/anv_entrypoints_gen.py \
+   --xml $(vulkan_api_xml) --outdir $(builddir)
 
 BUILT_SOURCES = $(VULKAN_GENERATED_FILES)
 CLEANFILES = $(BUILT_SOURCES) dev_icd.json intel_icd.@host_cpu@.json
diff --git a/src/intel/vulkan/anv_entrypoints_gen.py 
b/src/intel/vulkan/anv_entrypoints_gen.py
index 45a463c..5066195 100644
--- a/src/intel/vulkan/anv_entrypoints_gen.py
+++ b/src/intel/vulkan/anv_entrypoints_gen.py
@@ -23,6 +23,7 @@
 #
 
 import argparse
+import os
 import textwrap
 import xml.etree.ElementTree as et
 
@@ -83,7 +84,7 @@ TEMPLATE_H = Template(textwrap.dedent("""\
 #endif // ${guard}
   % endif
 % endfor
-"""))
+"""), output_encoding='utf-8')
 
 TEMPLATE_C = Template(textwrap.dedent(u"""\
 /*
@@ -337,22 +338,22 @@ def gen_code(entrypoints):
 collisions[level] += 1
 mapping[h & HASH_MASK] = num
 
-print TEMPLATE_C.render(entrypoints=entrypoints,
-offsets=offsets,
-collisions=collisions,
-mapping=mapping,
-hash_mask=HASH_MASK,
-prime_step=PRIME_STEP,
-prime_factor=PRIME_FACTOR,
-none=NONE,
-hash_size=HASH_SIZE)
+return TEMPLATE_C.render(entrypoints=entrypoints,
+ offsets=offsets,
+ collisions=collisions,
+ mapping=mapping,
+ hash_mask=HASH_MASK,
+ prime_step=PRIME_STEP,
+ prime_factor=PRIME_FACTOR,
+ none=NONE,
+ hash_size=HASH_SIZE)
 
 
 def main():
 parser = argparse.ArgumentParser()
-parser.add_argument('target', choices=['header', 'code'],
-help='Which file to generate.')
 parser.add_argument('--xml', help='Vulkan API XML file.')
+parser.add_argument('--outdir',
+help='Directory to put the generated files in')
 args = parser.parse_args()
 
 doc = et.parse(args.xml)
@@ -370,10 +371,10 @@ def main():
 
 # For outputting entrypoints.h we generate a anv_EntryPoint() prototype
 # per entry point.
-if args.target == 'header':
-print TEMPLATE_H.render(entrypoints=entrypoints)
-else:
-gen_code(entrypoints)
+with open(os.path.join(args.outdir, 'anv_entrypoints.h'), 'wb') as f:
+f.write(TEMPLATE_H.render(entrypoints=entrypoints))
+with open(os.path.join(args.outdir, 'anv_entrypoints.c'), 'wb') as f:
+   

[Mesa-dev] [PATCH v2 13/14] anv: use cElementTree in anv_entrypoints_gen.py

2017-02-23 Thread Dylan Baker
It's written in C rather than pure python and is strictly faster, the
only reason not to use it that it's classes cannot be subclassed.

Signed-off-by: Dylan Baker 
---
 src/intel/vulkan/anv_entrypoints_gen.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/intel/vulkan/anv_entrypoints_gen.py 
b/src/intel/vulkan/anv_entrypoints_gen.py
index 7018262..b498176 100644
--- a/src/intel/vulkan/anv_entrypoints_gen.py
+++ b/src/intel/vulkan/anv_entrypoints_gen.py
@@ -26,7 +26,7 @@ import argparse
 import functools
 import os
 import textwrap
-import xml.etree.ElementTree as et
+import xml.etree.cElementTree as et
 
 from mako.template import Template
 
-- 
git-series 0.9.0
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH v2 7/14] anv: convert C generation to template in anv_entrypoints_gen.py

2017-02-23 Thread Dylan Baker
This produces a file that is identical except for whitespace, there is a
table that has 8 columns in the original and is easy to do with prints,
but is ugly using mako, so it doesn't have columns; the data is not
inherently tabular.

Signed-off-by: Dylan Baker 
---
 src/intel/vulkan/anv_entrypoints_gen.py | 333 -
 1 file changed, 163 insertions(+), 170 deletions(-)

diff --git a/src/intel/vulkan/anv_entrypoints_gen.py 
b/src/intel/vulkan/anv_entrypoints_gen.py
index 7493fb6..45a463c 100644
--- a/src/intel/vulkan/anv_entrypoints_gen.py
+++ b/src/intel/vulkan/anv_entrypoints_gen.py
@@ -85,93 +85,7 @@ TEMPLATE_H = Template(textwrap.dedent("""\
 % endfor
 """))
 
-NONE = 0x
-HASH_SIZE = 256
-U32_MASK = 2**32 - 1
-HASH_MASK = HASH_SIZE - 1
-
-PRIME_FACTOR = 5024183
-PRIME_STEP = 19
-
-opt_header = False
-opt_code = False
-
-
-def hash(name):
-h = 0
-for c in name:
-h = (h * PRIME_FACTOR + ord(c)) & U32_MASK
-
-return h
-
-
-def print_guard_start(guard):
-if guard is not None:
-print "#ifdef {0}".format(guard)
-
-
-def print_guard_end(guard):
-if guard is not None:
-print "#endif // {0}".format(guard)
-
-
-def get_entrypoints(doc, entrypoints_to_defines):
-"""Extract the entry points from the registry."""
-entrypoints = []
-
-enabled_commands = set()
-for feature in doc.findall('./feature'):
-assert feature.attrib['api'] == 'vulkan'
-if float(feature.attrib['number']) > MAX_API_VERSION:
-continue
-
-for command in feature.findall('./require/command'):
-enabled_commands.add(command.attrib['name'])
-
-for extension in doc.findall('.extensions/extension'):
-if extension.attrib['name'] not in SUPPORTED_EXTENSIONS:
-continue
-
-assert extension.attrib['supported'] == 'vulkan'
-for command in extension.findall('./require/command'):
-enabled_commands.add(command.attrib['name'])
-
-index = 0
-for command in doc.findall('./commands/command'):
-type = command.find('./proto/type').text
-fullname = command.find('./proto/name').text
-
-if fullname not in enabled_commands:
-continue
-
-shortname = fullname[2:]
-params = (''.join(p.itertext()) for p in command.findall('./param'))
-params = ', '.join(params)
-if fullname in entrypoints_to_defines:
-guard = entrypoints_to_defines[fullname]
-else:
-guard = None
-entrypoints.append((type, shortname, params, index, hash(fullname), 
guard))
-index += 1
-
-return entrypoints
-
-
-def get_entrypoints_defines(doc):
-"""Maps entry points to extension defines."""
-entrypoints_to_defines = {}
-extensions = doc.findall('./extensions/extension')
-for extension in extensions:
-define = extension.get('protect')
-entrypoints = extension.findall('./require/command')
-for entrypoint in entrypoints:
-fullname = entrypoint.get('name')
-entrypoints_to_defines[fullname] = define
-return entrypoints_to_defines
-
-
-def gen_code(entrypoints):
-print textwrap.dedent("""\
+TEMPLATE_C = Template(textwrap.dedent(u"""\
 /*
  * Copyright ?? 2015 Intel Corporation
  *
@@ -209,44 +123,47 @@ def gen_code(entrypoints):
  * store the index into this big string.
  */
 
-static const char strings[] =""")
-
-offsets = []
-i = 0
-for type, name, args, num, h, guard in entrypoints:
-print "   \"vk%s\\0\"" % name
-offsets.append(i)
-i += 2 + len(name) + 1
-print "   ;"
-
-# Now generate the table of all entry points
-
-print "\nstatic const struct anv_entrypoint entrypoints[] = {"
-for type, name, args, num, h, guard in entrypoints:
-print "   { %5d, 0x%08x }," % (offsets[num], h)
-print "};\n"
+static const char strings[] =
+% for _, name, _, _, _, _ in entrypoints:
+"vk${name}\\0"
+% endfor
+;
 
-print textwrap.dedent("""
+static const struct anv_entrypoint entrypoints[] = {
+% for _, _, _, num, h, _ in entrypoints:
+{ ${offsets[num]}, ${'{:0=#8x}'.format(h)} },
+% endfor
+};
 
 /* Weak aliases for all potential implementations. These will resolve to
  * NULL if they're not defined, which lets the resolve_entrypoint() 
function
  * either pick the correct entry point.
  */
-""")
-
-for layer in ["anv", "gen7", "gen75", "gen8", "gen9"]:
-for type, name, args, num, h, guard in entrypoints:
-print_guard_start(guard)
-print "%s %s_%s(%s) __attribute__ ((weak));" % (type, layer, name, 
args)
-print_guard_end(guard)
-print "\nconst struct anv_dispatch_table %s_layer = {" % layer
-for type, name, args, num, h, guard in entrypoints:
-print_guard_start(guard)
-print 

[Mesa-dev] [PATCH v2 6/14] anv: convert header generation in anv_entrypoints_gen.py to mako

2017-02-23 Thread Dylan Baker
This produces an identical file except for whitespace.

Signed-off-by: Dylan Baker 
---
 src/intel/vulkan/anv_entrypoints_gen.py | 75 ++
 1 file changed, 41 insertions(+), 34 deletions(-)

diff --git a/src/intel/vulkan/anv_entrypoints_gen.py 
b/src/intel/vulkan/anv_entrypoints_gen.py
index 772f3e6..7493fb6 100644
--- a/src/intel/vulkan/anv_entrypoints_gen.py
+++ b/src/intel/vulkan/anv_entrypoints_gen.py
@@ -26,6 +26,8 @@ import argparse
 import textwrap
 import xml.etree.ElementTree as et
 
+from mako.template import Template
+
 MAX_API_VERSION = 1.0
 
 SUPPORTED_EXTENSIONS = [
@@ -45,6 +47,44 @@ SUPPORTED_EXTENSIONS = [
 # function and a power-of-two size table. The prime numbers are determined
 # experimentally.
 
+TEMPLATE_H = Template(textwrap.dedent("""\
+/* This file generated from vk_gen.py, don't edit directly. */
+
+struct anv_dispatch_table {
+   union {
+  void *entrypoints[${len(entrypoints)}];
+  struct {
+  % for _, name, _, _, _, guard in entrypoints:
+% if guard is not None:
+#ifdef ${guard}
+  PFN_vk${name} ${name};
+#else
+  void *${name};
+# endif
+% else:
+  PFN_vk${name} ${name};
+% endif
+  % endfor
+  };
+   };
+};
+
+void anv_set_dispatch_devinfo(const struct gen_device_info *info);
+% for type_, name, args, num, h, guard in entrypoints:
+  % if guard is not None:
+#ifdef ${guard}
+  % endif
+  ${type_} anv_${name}(${args});
+  ${type_} gen7_${name}(${args});
+  ${type_} gen75_${name}(${args});
+  ${type_} gen8_${name}(${args});
+  ${type_} gen9_${name}(${args});
+  % if guard is not None:
+#endif // ${guard}
+  % endif
+% endfor
+"""))
+
 NONE = 0x
 HASH_SIZE = 256
 U32_MASK = 2**32 - 1
@@ -130,39 +170,6 @@ def get_entrypoints_defines(doc):
 return entrypoints_to_defines
 
 
-def gen_header(entrypoints):
-print "/* This file generated from vk_gen.py, don't edit directly. */\n"
-
-print "struct anv_dispatch_table {"
-print "   union {"
-print "  void *entrypoints[%d];" % len(entrypoints)
-print "  struct {"
-
-for type, name, args, num, h, guard in entrypoints:
-if guard is not None:
-print "#ifdef {0}".format(guard)
-print " PFN_vk{0} {0};".format(name)
-print "#else"
-print " void *{0};".format(name)
-print "#endif"
-else:
-print " PFN_vk{0} {0};".format(name)
-print "  };\n"
-print "   };\n"
-print "};\n"
-
-print "void anv_set_dispatch_devinfo(const struct gen_device_info 
*info);\n"
-
-for type, name, args, num, h, guard in entrypoints:
-print_guard_start(guard)
-print "%s anv_%s(%s);" % (type, name, args)
-print "%s gen7_%s(%s);" % (type, name, args)
-print "%s gen75_%s(%s);" % (type, name, args)
-print "%s gen8_%s(%s);" % (type, name, args)
-print "%s gen9_%s(%s);" % (type, name, args)
-print_guard_end(guard)
-
-
 def gen_code(entrypoints):
 print textwrap.dedent("""\
 /*
@@ -371,7 +378,7 @@ def main():
 # For outputting entrypoints.h we generate a anv_EntryPoint() prototype
 # per entry point.
 if args.target == 'header':
-gen_header(entrypoints)
+print TEMPLATE_H.render(entrypoints=entrypoints)
 else:
 gen_code(entrypoints)
 
-- 
git-series 0.9.0
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH v2 9/14] anv: anv-entrypoints_gen.py: rename hash to cal_hash.

2017-02-23 Thread Dylan Baker
hash is reserved name in python, it's the interface to access an
object's hash protocol.

Signed-off-by: Dylan Baker 
---
 src/intel/vulkan/anv_entrypoints_gen.py | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/intel/vulkan/anv_entrypoints_gen.py 
b/src/intel/vulkan/anv_entrypoints_gen.py
index 5066195..7386b1d 100644
--- a/src/intel/vulkan/anv_entrypoints_gen.py
+++ b/src/intel/vulkan/anv_entrypoints_gen.py
@@ -254,7 +254,8 @@ PRIME_FACTOR = 5024183
 PRIME_STEP = 19
 
 
-def hash(name):
+def cal_hash(name):
+"""Calculate the same hash value that Mesa will calculate in C."""
 h = 0
 for c in name:
 h = (h * PRIME_FACTOR + ord(c)) & U32_MASK
@@ -298,7 +299,7 @@ def get_entrypoints(doc, entrypoints_to_defines):
 guard = entrypoints_to_defines[fullname]
 else:
 guard = None
-entrypoints.append((type, shortname, params, index, hash(fullname), 
guard))
+entrypoints.append((type, shortname, params, index, 
cal_hash(fullname), guard))
 index += 1
 
 return entrypoints
@@ -367,7 +368,7 @@ def main():
 'const VkAllocationCallbacks* pAllocator,' +
 'VkDeviceMemory* pMem,' +
 'VkImage* pImage', len(entrypoints),
-hash('vkCreateDmaBufImageINTEL'), None))
+cal_hash('vkCreateDmaBufImageINTEL'), None))
 
 # For outputting entrypoints.h we generate a anv_EntryPoint() prototype
 # per entry point.
-- 
git-series 0.9.0
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH v2 14/14] anv: Remove dead prototype from entrypoints

2017-02-23 Thread Dylan Baker
Spotted by Emil.

v2: - Add this patch

Signed-off-by: Dylan Baker 
---
 src/intel/vulkan/anv_entrypoints_gen.py | 1 -
 1 file changed, 1 deletion(-)

diff --git a/src/intel/vulkan/anv_entrypoints_gen.py 
b/src/intel/vulkan/anv_entrypoints_gen.py
index b498176..44b6d2c 100644
--- a/src/intel/vulkan/anv_entrypoints_gen.py
+++ b/src/intel/vulkan/anv_entrypoints_gen.py
@@ -71,7 +71,6 @@ TEMPLATE_H = Template(textwrap.dedent("""\
};
 };
 
-void anv_set_dispatch_devinfo(const struct gen_device_info *info);
 % for type_, name, args, num, h, guard in entrypoints:
   % if guard is not None:
 #ifdef ${guard}
-- 
git-series 0.9.0
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH v2 2/14] anv: Use python style in anv_entrypoints_gen.py

2017-02-23 Thread Dylan Baker
These are all fairly small cleanups/tweaks that don't really deserve
their own patch.

- Prefer comprehensions to map() and filter(), since they're faster
- replace unused variables with _
- Use 4 spaces of indent
- drop semicolons from the end of lines
- Don't use parens around if conditions
- don't put spaces around brackets
- don't import modules as caps (ET -> et)
- Use docstrings instead of comments

v2: - Replace comprehensions with multiplication

Signed-off-by: Dylan Baker 
---
 src/intel/vulkan/anv_entrypoints_gen.py | 63 ++
 1 file changed, 34 insertions(+), 29 deletions(-)

diff --git a/src/intel/vulkan/anv_entrypoints_gen.py 
b/src/intel/vulkan/anv_entrypoints_gen.py
index 3f7a1ce..b4cead9 100644
--- a/src/intel/vulkan/anv_entrypoints_gen.py
+++ b/src/intel/vulkan/anv_entrypoints_gen.py
@@ -24,20 +24,20 @@
 
 import sys
 import textwrap
-import xml.etree.ElementTree as ET
+import xml.etree.ElementTree as et
 
 max_api_version = 1.0
 
 supported_extensions = [
-   'VK_KHR_get_physical_device_properties2',
-   'VK_KHR_maintenance1',
-   'VK_KHR_sampler_mirror_clamp_to_edge',
-   'VK_KHR_shader_draw_parameters',
-   'VK_KHR_surface',
-   'VK_KHR_swapchain',
-   'VK_KHR_wayland_surface',
-   'VK_KHR_xcb_surface',
-   'VK_KHR_xlib_surface',
+'VK_KHR_get_physical_device_properties2',
+'VK_KHR_maintenance1',
+'VK_KHR_sampler_mirror_clamp_to_edge',
+'VK_KHR_shader_draw_parameters',
+'VK_KHR_surface',
+'VK_KHR_swapchain',
+'VK_KHR_wayland_surface',
+'VK_KHR_xcb_surface',
+'VK_KHR_xlib_surface',
 ]
 
 # We generate a static hash table for entry point lookup
@@ -53,33 +53,37 @@ hash_mask = hash_size - 1
 prime_factor = 5024183
 prime_step = 19
 
+opt_header = False
+opt_code = False
+
+if sys.argv[1] == "header":
+opt_header = True
+sys.argv.pop()
+elif sys.argv[1] == "code":
+opt_code = True
+sys.argv.pop()
+
+
 def hash(name):
-h = 0;
+h = 0
 for c in name:
 h = (h * prime_factor + ord(c)) & u32_mask
 
 return h
 
+
 def print_guard_start(guard):
 if guard is not None:
 print "#ifdef {0}".format(guard)
 
+
 def print_guard_end(guard):
 if guard is not None:
 print "#endif // {0}".format(guard)
 
-opt_header = False
-opt_code = False
 
-if (sys.argv[1] == "header"):
-opt_header = True
-sys.argv.pop()
-elif (sys.argv[1] == "code"):
-opt_code = True
-sys.argv.pop()
-
-# Extract the entry points from the registry
 def get_entrypoints(doc, entrypoints_to_defines):
+"""Extract the entry points from the registry."""
 entrypoints = []
 
 enabled_commands = set()
@@ -108,7 +112,7 @@ def get_entrypoints(doc, entrypoints_to_defines):
 continue
 
 shortname = fullname[2:]
-params = map(lambda p: "".join(p.itertext()), 
command.findall('./param'))
+params = (''.join(p.itertext()) for p in command.findall('./param'))
 params = ', '.join(params)
 if fullname in entrypoints_to_defines:
 guard = entrypoints_to_defines[fullname]
@@ -119,8 +123,9 @@ def get_entrypoints(doc, entrypoints_to_defines):
 
 return entrypoints
 
-# Maps entry points to extension defines
+
 def get_entrypoints_defines(doc):
+"""Maps entry points to extension defines."""
 entrypoints_to_defines = {}
 extensions = doc.findall('./extensions/extension')
 for extension in extensions:
@@ -133,7 +138,7 @@ def get_entrypoints_defines(doc):
 
 
 def main():
-doc = ET.parse(sys.stdin)
+doc = et.parse(sys.stdin)
 entrypoints = get_entrypoints(doc, get_entrypoints_defines(doc))
 
 # Manually add CreateDmaBufImageINTEL for which we don't have an extension
@@ -225,7 +230,7 @@ def main():
 static const char strings[] =""")
 
 offsets = []
-i = 0;
+i = 0
 for type, name, args, num, h, guard in entrypoints:
 print "   \"vk%s\\0\"" % name
 offsets.append(i)
@@ -247,7 +252,7 @@ def main():
  */
 """)
 
-for layer in [ "anv", "gen7", "gen75", "gen8", "gen9" ]:
+for layer in ["anv", "gen7", "gen75", "gen8", "gen9"]:
 for type, name, args, num, h, guard in entrypoints:
 print_guard_start(guard)
 print "%s %s_%s(%s) __attribute__ ((weak));" % (type, layer, name, 
args)
@@ -295,8 +300,8 @@ def main():
 # uint16_t table of entry point indices. We use 0x to indicate an entry
 # in the hash table is empty.
 
-map = [none for f in xrange(hash_size)]
-collisions = [0 for f in xrange(10)]
+map = [none] * hash_size
+collisions = [0] * 10
 for type, name, args, num, h, guard in entrypoints:
 level = 0
 while map[h & hash_mask] != none:
@@ -312,7 +317,7 @@ def main():
 print " * size %d entries" % hash_size
 print " * collisions  entries"
 for i in xrange(10):
-if (i == 9):
+if i == 9:
 plus = "+"
 else:
 plus = " "

[Mesa-dev] [PATCH v2 11/14] anv: use dict.get in anv_entrypoints_gen.py

2017-02-23 Thread Dylan Baker
Instead of using an if and a check, use dict.get, which does the same
thing, but more succinctly.

Signed-off-by: Dylan Baker 
---
 src/intel/vulkan/anv_entrypoints_gen.py | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/src/intel/vulkan/anv_entrypoints_gen.py 
b/src/intel/vulkan/anv_entrypoints_gen.py
index cb28050..e619ad5 100644
--- a/src/intel/vulkan/anv_entrypoints_gen.py
+++ b/src/intel/vulkan/anv_entrypoints_gen.py
@@ -293,10 +293,7 @@ def get_entrypoints(doc, entrypoints_to_defines):
 shortname = fullname[2:]
 params = (''.join(p.itertext()) for p in command.findall('./param'))
 params = ', '.join(params)
-if fullname in entrypoints_to_defines:
-guard = entrypoints_to_defines[fullname]
-else:
-guard = None
+guard = entrypoints_to_defines.get(fullname)
 entrypoints.append((type, shortname, params, index, 
cal_hash(fullname), guard))
 index += 1
 
-- 
git-series 0.9.0
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH v2 5/14] anv: split main into two functions in anv_entrypoints_gen.py

2017-02-23 Thread Dylan Baker
This is groundwork for the next patches, it will allows porting the
header and the code to mako separately, and will also allow both to be
run simultaneously.

Signed-off-by: Dylan Baker 
---
 src/intel/vulkan/anv_entrypoints_gen.py | 108 -
 1 file changed, 56 insertions(+), 52 deletions(-)

diff --git a/src/intel/vulkan/anv_entrypoints_gen.py 
b/src/intel/vulkan/anv_entrypoints_gen.py
index ea15065..772f3e6 100644
--- a/src/intel/vulkan/anv_entrypoints_gen.py
+++ b/src/intel/vulkan/anv_entrypoints_gen.py
@@ -130,64 +130,40 @@ def get_entrypoints_defines(doc):
 return entrypoints_to_defines
 
 
-def main():
-parser = argparse.ArgumentParser()
-parser.add_argument('target', choices=['header', 'code'],
-help='Which file to generate.')
-parser.add_argument('--xml', help='Vulkan API XML file.')
-args = parser.parse_args()
-
-doc = et.parse(args.xml)
-entrypoints = get_entrypoints(doc, get_entrypoints_defines(doc))
-
-# Manually add CreateDmaBufImageINTEL for which we don't have an extension
-# defined.
-entrypoints.append(('VkResult', 'CreateDmaBufImageINTEL',
-'VkDevice device, ' +
-'const VkDmaBufImageCreateInfo* pCreateInfo, ' +
-'const VkAllocationCallbacks* pAllocator,' +
-'VkDeviceMemory* pMem,' +
-'VkImage* pImage', len(entrypoints),
-hash('vkCreateDmaBufImageINTEL'), None))
+def gen_header(entrypoints):
+print "/* This file generated from vk_gen.py, don't edit directly. */\n"
 
-# For outputting entrypoints.h we generate a anv_EntryPoint() prototype
-# per entry point.
-
-if args.target == 'header':
-print "/* This file generated from vk_gen.py, don't edit directly. 
*/\n"
+print "struct anv_dispatch_table {"
+print "   union {"
+print "  void *entrypoints[%d];" % len(entrypoints)
+print "  struct {"
 
-print "struct anv_dispatch_table {"
-print "   union {"
-print "  void *entrypoints[%d];" % len(entrypoints)
-print "  struct {"
-
-for type, name, args, num, h, guard in entrypoints:
-if guard is not None:
-print "#ifdef {0}".format(guard)
-print " PFN_vk{0} {0};".format(name)
-print "#else"
-print " void *{0};".format(name)
-print "#endif"
-else:
-print " PFN_vk{0} {0};".format(name)
-print "  };\n"
-print "   };\n"
-print "};\n"
-
-print "void anv_set_dispatch_devinfo(const struct gen_device_info 
*info);\n"
+for type, name, args, num, h, guard in entrypoints:
+if guard is not None:
+print "#ifdef {0}".format(guard)
+print " PFN_vk{0} {0};".format(name)
+print "#else"
+print " void *{0};".format(name)
+print "#endif"
+else:
+print " PFN_vk{0} {0};".format(name)
+print "  };\n"
+print "   };\n"
+print "};\n"
 
-for type, name, args, num, h, guard in entrypoints:
-print_guard_start(guard)
-print "%s anv_%s(%s);" % (type, name, args)
-print "%s gen7_%s(%s);" % (type, name, args)
-print "%s gen75_%s(%s);" % (type, name, args)
-print "%s gen8_%s(%s);" % (type, name, args)
-print "%s gen9_%s(%s);" % (type, name, args)
-print_guard_end(guard)
-exit()
+print "void anv_set_dispatch_devinfo(const struct gen_device_info 
*info);\n"
 
+for type, name, args, num, h, guard in entrypoints:
+print_guard_start(guard)
+print "%s anv_%s(%s);" % (type, name, args)
+print "%s gen7_%s(%s);" % (type, name, args)
+print "%s gen75_%s(%s);" % (type, name, args)
+print "%s gen8_%s(%s);" % (type, name, args)
+print "%s gen9_%s(%s);" % (type, name, args)
+print_guard_end(guard)
 
 
+def gen_code(entrypoints):
 print textwrap.dedent("""\
 /*
  * Copyright ?? 2015 Intel Corporation
@@ -372,5 +348,33 @@ def main():
 """) % (PRIME_FACTOR, PRIME_STEP, HASH_MASK)
 
 
+def main():
+parser = argparse.ArgumentParser()
+parser.add_argument('target', choices=['header', 'code'],
+help='Which file to generate.')
+parser.add_argument('--xml', help='Vulkan API XML file.')
+args = parser.parse_args()
+
+doc = et.parse(args.xml)
+entrypoints = get_entrypoints(doc, get_entrypoints_defines(doc))
+
+# Manually add CreateDmaBufImageINTEL for which we don't have an extension
+# defined.
+entrypoints.append(('VkResult', 'CreateDmaBufImageINTEL',
+'VkDevice device, ' +
+'const VkDmaBufImageCreateInfo* pCreateInfo, ' 

[Mesa-dev] [PATCH v2 4/14] anv: don't pass xmlfile via stdin anv_entrypoints_gen.py

2017-02-23 Thread Dylan Baker
It's slow, and has the potential for encoding issues.

v2: - pass xml file location via argument
- update Android.mk

Signed-off-by: Dylan Baker 
---
 src/intel/vulkan/Android.mk |  4 ++--
 src/intel/vulkan/Makefile.am|  6 ++
 src/intel/vulkan/anv_entrypoints_gen.py | 19 +--
 3 files changed, 13 insertions(+), 16 deletions(-)

diff --git a/src/intel/vulkan/Android.mk b/src/intel/vulkan/Android.mk
index 1e53970..9dabf1c 100644
--- a/src/intel/vulkan/Android.mk
+++ b/src/intel/vulkan/Android.mk
@@ -61,7 +61,7 @@ $(intermediates)/dummy.c:
$(hide) touch $@
 
 $(intermediates)/anv_entrypoints.h:
-   $(hide) cat $(MESA_TOP)/src/vulkan/registry/vk.xml | 
$(VK_ENTRYPOINTS_SCRIPT) header > $@
+   $(VK_ENTRYPOINTS_SCRIPT) header --xml 
$(MESA_TOP)/src/vulkan/registry/vk.xml > $@
 
 LOCAL_EXPORT_C_INCLUDE_DIRS := \
 $(intermediates)
@@ -177,7 +177,7 @@ LOCAL_WHOLE_STATIC_LIBRARIES := libmesa_anv_entrypoints 
libmesa_genxml
 LOCAL_GENERATED_SOURCES += $(intermediates)/anv_entrypoints.c
 
 $(intermediates)/anv_entrypoints.c:
-   $(hide) cat $(MESA_TOP)/src/vulkan/registry/vk.xml | 
$(VK_ENTRYPOINTS_SCRIPT) code > $@
+   $(VK_ENTRYPOINTS_SCRIPT) code --xml 
$(MESA_TOP)/src/vulkan/registry/vk.xml > $@
 
 LOCAL_SHARED_LIBRARIES := libdrm_intel
 
diff --git a/src/intel/vulkan/Makefile.am b/src/intel/vulkan/Makefile.am
index 449188f..565559c 100644
--- a/src/intel/vulkan/Makefile.am
+++ b/src/intel/vulkan/Makefile.am
@@ -146,12 +146,10 @@ libvulkan_intel_la_SOURCES = $(VULKAN_GEM_FILES)
 vulkan_api_xml = $(top_srcdir)/src/vulkan/registry/vk.xml
 
 anv_entrypoints.h : anv_entrypoints_gen.py $(vulkan_api_xml)
-   $(AM_V_GEN) cat $(vulkan_api_xml) |\
-   $(PYTHON2) $(srcdir)/anv_entrypoints_gen.py header > $@
+   $(AM_V_GEN)$(PYTHON2) $(srcdir)/anv_entrypoints_gen.py header --xml 
$(vulkan_api_xml) > $@
 
 anv_entrypoints.c : anv_entrypoints_gen.py $(vulkan_api_xml)
-   $(AM_V_GEN) cat $(vulkan_api_xml) |\
-   $(PYTHON2) $(srcdir)/anv_entrypoints_gen.py code > $@
+   $(AM_V_GEN)$(PYTHON2) $(srcdir)/anv_entrypoints_gen.py code --xml 
$(vulkan_api_xml) > $@
 
 BUILT_SOURCES = $(VULKAN_GENERATED_FILES)
 CLEANFILES = $(BUILT_SOURCES) dev_icd.json intel_icd.@host_cpu@.json
diff --git a/src/intel/vulkan/anv_entrypoints_gen.py 
b/src/intel/vulkan/anv_entrypoints_gen.py
index d3f028e..ea15065 100644
--- a/src/intel/vulkan/anv_entrypoints_gen.py
+++ b/src/intel/vulkan/anv_entrypoints_gen.py
@@ -22,7 +22,7 @@
 # IN THE SOFTWARE.
 #
 
-import sys
+import argparse
 import textwrap
 import xml.etree.ElementTree as et
 
@@ -56,13 +56,6 @@ PRIME_STEP = 19
 opt_header = False
 opt_code = False
 
-if sys.argv[1] == "header":
-opt_header = True
-sys.argv.pop()
-elif sys.argv[1] == "code":
-opt_code = True
-sys.argv.pop()
-
 
 def hash(name):
 h = 0
@@ -138,7 +131,13 @@ def get_entrypoints_defines(doc):
 
 
 def main():
-doc = et.parse(sys.stdin)
+parser = argparse.ArgumentParser()
+parser.add_argument('target', choices=['header', 'code'],
+help='Which file to generate.')
+parser.add_argument('--xml', help='Vulkan API XML file.')
+args = parser.parse_args()
+
+doc = et.parse(args.xml)
 entrypoints = get_entrypoints(doc, get_entrypoints_defines(doc))
 
 # Manually add CreateDmaBufImageINTEL for which we don't have an extension
@@ -154,7 +153,7 @@ def main():
 # For outputting entrypoints.h we generate a anv_EntryPoint() prototype
 # per entry point.
 
-if opt_header:
+if args.target == 'header':
 print "/* This file generated from vk_gen.py, don't edit directly. 
*/\n"
 
 print "struct anv_dispatch_table {"
-- 
git-series 0.9.0
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH v2 1/14] anv: anv_entrypoints_gen.py: use a main function

2017-02-23 Thread Dylan Baker
This is just good practice.

Signed-off-by: Dylan Baker 
---
 src/intel/vulkan/anv_entrypoints_gen.py | 458 -
 1 file changed, 233 insertions(+), 225 deletions(-)

diff --git a/src/intel/vulkan/anv_entrypoints_gen.py 
b/src/intel/vulkan/anv_entrypoints_gen.py
index 93511ec..3f7a1ce 100644
--- a/src/intel/vulkan/anv_entrypoints_gen.py
+++ b/src/intel/vulkan/anv_entrypoints_gen.py
@@ -1,6 +1,6 @@
 # coding=utf-8
 #
-# Copyright ?? 2015 Intel Corporation
+# Copyright ?? 2015, 2017 Intel Corporation
 #
 # Permission is hereby granted, free of charge, to any person obtaining a
 # copy of this software and associated documentation files (the "Software"),
@@ -23,6 +23,7 @@
 #
 
 import sys
+import textwrap
 import xml.etree.ElementTree as ET
 
 max_api_version = 1.0
@@ -130,235 +131,242 @@ def get_entrypoints_defines(doc):
 entrypoints_to_defines[fullname] = define
 return entrypoints_to_defines
 
-doc = ET.parse(sys.stdin)
-entrypoints = get_entrypoints(doc, get_entrypoints_defines(doc))
-
-# Manually add CreateDmaBufImageINTEL for which we don't have an extension
-# defined.
-entrypoints.append(('VkResult', 'CreateDmaBufImageINTEL',
-'VkDevice device, ' +
-'const VkDmaBufImageCreateInfo* pCreateInfo, ' +
-'const VkAllocationCallbacks* pAllocator,' +
-'VkDeviceMemory* pMem,' +
-'VkImage* pImage', len(entrypoints),
-hash('vkCreateDmaBufImageINTEL'), None))
-
-# For outputting entrypoints.h we generate a anv_EntryPoint() prototype
-# per entry point.
-
-if opt_header:
-print "/* This file generated from vk_gen.py, don't edit directly. */\n"
-
-print "struct anv_dispatch_table {"
-print "   union {"
-print "  void *entrypoints[%d];" % len(entrypoints)
-print "  struct {"
 
+def main():
+doc = ET.parse(sys.stdin)
+entrypoints = get_entrypoints(doc, get_entrypoints_defines(doc))
+
+# Manually add CreateDmaBufImageINTEL for which we don't have an extension
+# defined.
+entrypoints.append(('VkResult', 'CreateDmaBufImageINTEL',
+'VkDevice device, ' +
+'const VkDmaBufImageCreateInfo* pCreateInfo, ' +
+'const VkAllocationCallbacks* pAllocator,' +
+'VkDeviceMemory* pMem,' +
+'VkImage* pImage', len(entrypoints),
+hash('vkCreateDmaBufImageINTEL'), None))
+
+# For outputting entrypoints.h we generate a anv_EntryPoint() prototype
+# per entry point.
+
+if opt_header:
+print "/* This file generated from vk_gen.py, don't edit directly. 
*/\n"
+
+print "struct anv_dispatch_table {"
+print "   union {"
+print "  void *entrypoints[%d];" % len(entrypoints)
+print "  struct {"
+
+for type, name, args, num, h, guard in entrypoints:
+if guard is not None:
+print "#ifdef {0}".format(guard)
+print " PFN_vk{0} {0};".format(name)
+print "#else"
+print " void *{0};".format(name)
+print "#endif"
+else:
+print " PFN_vk{0} {0};".format(name)
+print "  };\n"
+print "   };\n"
+print "};\n"
+
+print "void anv_set_dispatch_devinfo(const struct gen_device_info 
*info);\n"
+
+for type, name, args, num, h, guard in entrypoints:
+print_guard_start(guard)
+print "%s anv_%s(%s);" % (type, name, args)
+print "%s gen7_%s(%s);" % (type, name, args)
+print "%s gen75_%s(%s);" % (type, name, args)
+print "%s gen8_%s(%s);" % (type, name, args)
+print "%s gen9_%s(%s);" % (type, name, args)
+print_guard_end(guard)
+exit()
+
+
+
+print textwrap.dedent("""\
+/*
+ * Copyright ?? 2015 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the 
"Software"),
+ * to deal in the Software without restriction, including without 
limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the 
next
+ * paragraph) shall be included in all copies or substantial portions of 
the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 
OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS 

[Mesa-dev] [PATCH v2 0/14] cleanup anv_entrpoints_gen.py

2017-02-23 Thread Dylan Baker
There are a number of small style cleanups and simplifications in this series,
but the main changes are:
 - use a mako template to generate the header and code rather than prints
 - be python 3.x ready (the goal isn't to write python 3 code, but to write code
   that is easy to port or hybridize)
 - generate the header and the code in one go

I've put emphasis on the readability of the template rather than the readability
of the output code, it's relatively easy to pipe the code through 'indent' to
make it more readable.

Notable changes in Version 2:
- Pass XML file via an argument
- add flag to control output directory
- Attempt to update android makefiles

Dylan Baker (14):
  anv: anv_entrypoints_gen.py: use a main function
  anv: Use python style in anv_entrypoints_gen.py
  anv: make constants capitals in anv_entrypoints_gen.py
  anv: don't pass xmlfile via stdin anv_entrypoints_gen.py
  anv: split main into two functions in anv_entrypoints_gen.py
  anv: convert header generation in anv_entrypoints_gen.py to mako
  anv: convert C generation to template in anv_entrypoints_gen.py
  anv: generate anv_entrypoints.{h,c} in one command
  anv: anv-entrypoints_gen.py: rename hash to cal_hash.
  anv: anv_entrypoints_gen.py: use reduce function.
  anv: use dict.get in anv_entrypoints_gen.py
  anv: don't use Element.get in anv_entrypoints_gen.py
  anv: use cElementTree in anv_entrypoints_gen.py
  anv: Remove dead prototype from entrypoints

 src/intel/vulkan/Android.mk |   7 +-
 src/intel/vulkan/Makefile.am|  10 +-
 src/intel/vulkan/anv_entrypoints_gen.py | 601 -
 3 files changed, 312 insertions(+), 306 deletions(-)

base-commit: a9c488f2858f8a383dd50e557ec8a832bcb35f47
-- 
git-series 0.9.0
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH v2 3/14] anv: make constants capitals in anv_entrypoints_gen.py

2017-02-23 Thread Dylan Baker
Again, it's standard python style.

Signed-off-by: Dylan Baker 
---
 src/intel/vulkan/anv_entrypoints_gen.py | 38 +-
 1 file changed, 19 insertions(+), 19 deletions(-)

diff --git a/src/intel/vulkan/anv_entrypoints_gen.py 
b/src/intel/vulkan/anv_entrypoints_gen.py
index b4cead9..d3f028e 100644
--- a/src/intel/vulkan/anv_entrypoints_gen.py
+++ b/src/intel/vulkan/anv_entrypoints_gen.py
@@ -26,9 +26,9 @@ import sys
 import textwrap
 import xml.etree.ElementTree as et
 
-max_api_version = 1.0
+MAX_API_VERSION = 1.0
 
-supported_extensions = [
+SUPPORTED_EXTENSIONS = [
 'VK_KHR_get_physical_device_properties2',
 'VK_KHR_maintenance1',
 'VK_KHR_sampler_mirror_clamp_to_edge',
@@ -45,13 +45,13 @@ supported_extensions = [
 # function and a power-of-two size table. The prime numbers are determined
 # experimentally.
 
-none = 0x
-hash_size = 256
-u32_mask = 2**32 - 1
-hash_mask = hash_size - 1
+NONE = 0x
+HASH_SIZE = 256
+U32_MASK = 2**32 - 1
+HASH_MASK = HASH_SIZE - 1
 
-prime_factor = 5024183
-prime_step = 19
+PRIME_FACTOR = 5024183
+PRIME_STEP = 19
 
 opt_header = False
 opt_code = False
@@ -67,7 +67,7 @@ elif sys.argv[1] == "code":
 def hash(name):
 h = 0
 for c in name:
-h = (h * prime_factor + ord(c)) & u32_mask
+h = (h * PRIME_FACTOR + ord(c)) & U32_MASK
 
 return h
 
@@ -89,14 +89,14 @@ def get_entrypoints(doc, entrypoints_to_defines):
 enabled_commands = set()
 for feature in doc.findall('./feature'):
 assert feature.attrib['api'] == 'vulkan'
-if float(feature.attrib['number']) > max_api_version:
+if float(feature.attrib['number']) > MAX_API_VERSION:
 continue
 
 for command in feature.findall('./require/command'):
 enabled_commands.add(command.attrib['name'])
 
 for extension in doc.findall('.extensions/extension'):
-if extension.attrib['name'] not in supported_extensions:
+if extension.attrib['name'] not in SUPPORTED_EXTENSIONS:
 continue
 
 assert extension.attrib['supported'] == 'vulkan'
@@ -300,21 +300,21 @@ def main():
 # uint16_t table of entry point indices. We use 0x to indicate an entry
 # in the hash table is empty.
 
-map = [none] * hash_size
+map = [NONE] * HASH_SIZE
 collisions = [0] * 10
 for type, name, args, num, h, guard in entrypoints:
 level = 0
-while map[h & hash_mask] != none:
-h = h + prime_step
+while map[h & HASH_MASK] != NONE:
+h = h + PRIME_STEP
 level = level + 1
 if level > 9:
 collisions[9] += 1
 else:
 collisions[level] += 1
-map[h & hash_mask] = num
+map[h & HASH_MASK] = num
 
 print "/* Hash table stats:"
-print " * size %d entries" % hash_size
+print " * size %d entries" % HASH_SIZE
 print " * collisions  entries"
 for i in xrange(10):
 if i == 9:
@@ -325,10 +325,10 @@ def main():
 print " * %2d%s %4d" % (i, plus, collisions[i])
 print " */\n"
 
-print "#define none 0x%04x\n" % none
+print "#define none 0x%04x\n" % NONE
 
 print "static const uint16_t map[] = {"
-for i in xrange(0, hash_size, 8):
+for i in xrange(0, HASH_SIZE, 8):
 print "   ",
 for j in xrange(i, i + 8):
 if map[j] & 0x == 0x:
@@ -370,7 +370,7 @@ def main():
 
return anv_resolve_entrypoint(devinfo, i);
 }
-""") % (prime_factor, prime_step, hash_mask)
+""") % (PRIME_FACTOR, PRIME_STEP, HASH_MASK)
 
 
 if __name__ == '__main__':
-- 
git-series 0.9.0
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [RESEND 08/13] anv: generate anv_entrypoints.{h, c} in one command

2017-02-23 Thread Emil Velikov
On 23 February 2017 at 17:54, Matt Turner  wrote:
> On Thu, Feb 23, 2017 at 9:29 AM, Emil Velikov  
> wrote:
>> On 23 February 2017 at 17:22, Dylan Baker  wrote:
>>> Quoting Emil Velikov (2017-02-23 02:32:17)
 On 22 February 2017 at 23:35, Dylan Baker  wrote:
 > This changes the python generator to write the files itself, rather than
 > piping them out. This has a couple of advantages: first, it encapsulates
 > the encoding. Second, it ensures that the header file and code file are
 > generated at the same time with the same data.
 >
 Last time there were some serious objections to doing this. Glad that
 you got those covered ;-)

 > Signed-off-by: Dylan Baker 
 > ---
 >  src/intel/vulkan/Makefile.am|  7 ++
 >  src/intel/vulkan/anv_entrypoints_gen.py | 38 
 > -
 >  2 files changed, 16 insertions(+), 29 deletions(-)
 >
 > diff --git a/src/intel/vulkan/Makefile.am b/src/intel/vulkan/Makefile.am
 > index 5a0e4ef4ff..68bc5ccf86 100644
 > --- a/src/intel/vulkan/Makefile.am
 > +++ b/src/intel/vulkan/Makefile.am
 > @@ -145,11 +145,8 @@ libvulkan_intel_la_SOURCES = $(VULKAN_GEM_FILES)
 >
 >  vulkan_api_xml = $(top_srcdir)/src/vulkan/registry/vk.xml
 >
 > -anv_entrypoints.h : anv_entrypoints_gen.py $(vulkan_api_xml)
 > -   $(AM_V_GEN)$(PYTHON2) $(srcdir)/anv_entrypoints_gen.py header > 
 > $@
 > -
 > -anv_entrypoints.c : anv_entrypoints_gen.py $(vulkan_api_xml)
 > -   $(AM_V_GEN)$(PYTHON2) $(srcdir)/anv_entrypoints_gen.py code > $@
 > +anv_entrypoints.h anv_entrypoints.c: anv_entrypoints_gen.py 
 > $(vulkan_api_xml)
 > +   $(AM_V_GEN)$(PYTHON2) $(srcdir)/anv_entrypoints_gen.py
 >
 Please pass a "-o $dst_dir" type of argument. It will be/is broken 
 otherwise.
>>>
>>> So you want an option for where the output files are going to be placed?
>>>
>> Precisely. To elaborate a bit - as-is (if I'm reading it properly)
>> you'll end up generating the files to srcdir.
>> srcdir should be considered immutable and this will fail a bunch of tests.
>>
>> Generated files should be stored in $builddir.
>
> The scripts are executed with a current-working-directory inside
> $builddir. The files are definitely written to $builddir.
Hmm some earlier testing (unrelated) suggested something else - may
have butchered something :-\

Afaict other scripts [in mesa] that produce multiple output files do
take the path as an argument. There's also the argument that having
the path/location information split/duplicated across code and build
system is not nice - see my glsl/tests thread for how things can get
wrong.

Personally, unless the extra -o $foo makes things noticeably
complex/slow I'll go for it.

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


[Mesa-dev] [PATCH] glsl: add missing blend_support qualifier in validate_flags()

2017-02-23 Thread Samuel Pitoiset
Signed-off-by: Samuel Pitoiset 
---
 src/compiler/glsl/ast_type.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/compiler/glsl/ast_type.cpp b/src/compiler/glsl/ast_type.cpp
index 580d216b30..96d20c10af 100644
--- a/src/compiler/glsl/ast_type.cpp
+++ b/src/compiler/glsl/ast_type.cpp
@@ -715,7 +715,7 @@ ast_type_qualifier::validate_flags(YYLTYPE *loc,
 "%s '%s':"
 "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s"
 "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s"
-"%s%s%s%s%s%s%s%s%s%s%s%s%s\n",
+"%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n",
 message, name,
 bad.flags.q.invariant ? " invariant" : "",
 bad.flags.q.precise ? " precise" : "",
@@ -773,6 +773,7 @@ ast_type_qualifier::validate_flags(YYLTYPE *loc,
 bad.flags.q.vertices ? " vertices" : "",
 bad.flags.q.subroutine ? " subroutine" : "",
 bad.flags.q.subroutine_def ? " subroutine_def" : "",
+bad.flags.q.blend_support ? " blend_support" : "",
 bad.flags.q.inner_coverage ? " inner_coverage" : "",
 bad.flags.q.post_depth_coverage ? " post_depth_coverage" : 
"");
return false;
-- 
2.11.1

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


Re: [Mesa-dev] [PATCH] glsl: add has_shader_image_load_store()

2017-02-23 Thread Anuj Phogat
On Thu, Feb 23, 2017 at 10:04 AM, Samuel Pitoiset
 wrote:
> Preliminary work for ARB_bindless_texture which can interact
> with ARB_shader_image_load_store.
>
> Signed-off-by: Samuel Pitoiset 
> ---
>  src/compiler/glsl/builtin_variables.cpp | 3 +--
>  src/compiler/glsl/glsl_parser.yy| 3 +--
>  src/compiler/glsl/glsl_parser_extras.h  | 5 +
>  3 files changed, 7 insertions(+), 4 deletions(-)
>
> diff --git a/src/compiler/glsl/builtin_variables.cpp 
> b/src/compiler/glsl/builtin_variables.cpp
> index db8418bbc7..fc0443e715 100644
> --- a/src/compiler/glsl/builtin_variables.cpp
> +++ b/src/compiler/glsl/builtin_variables.cpp
> @@ -840,8 +840,7 @@ builtin_variable_generator::generate_constants()
>  state->Const.MaxTransformFeedbackInterleavedComponents);
> }
>
> -   if (state->is_version(420, 310) ||
> -   state->ARB_shader_image_load_store_enable) {
> +   if (state->has_shader_image_load_store()) {
>add_const("gl_MaxImageUnits",
>  state->Const.MaxImageUnits);
>add_const("gl_MaxVertexImageUniforms",
> diff --git a/src/compiler/glsl/glsl_parser.yy 
> b/src/compiler/glsl/glsl_parser.yy
> index fd7edb28e7..d703f8 100644
> --- a/src/compiler/glsl/glsl_parser.yy
> +++ b/src/compiler/glsl/glsl_parser.yy
> @@ -1322,8 +1322,7 @@ layout_qualifier_id:
>}
>
>/* Layout qualifiers for ARB_shader_image_load_store. */
> -  if (state->ARB_shader_image_load_store_enable ||
> -  state->is_version(420, 310)) {
> +  if (state->has_shader_image_load_store()) {
>   if (!$$.flags.i) {
>  static const struct {
> const char *name;
> diff --git a/src/compiler/glsl/glsl_parser_extras.h 
> b/src/compiler/glsl/glsl_parser_extras.h
> index 8feef8cbcd..01acbb62e3 100644
> --- a/src/compiler/glsl/glsl_parser_extras.h
> +++ b/src/compiler/glsl/glsl_parser_extras.h
> @@ -330,6 +330,11 @@ struct _mesa_glsl_parse_state {
>   is_version(400, 320);
> }
>
> +   bool has_shader_image_load_store() const
> +   {
> +  return ARB_shader_image_load_store_enable || is_version(420, 310);
> +   }
> +
> void process_version_directive(YYLTYPE *locp, int version,
>const char *ident);
>
> --
> 2.11.1
>
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev

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


Re: [Mesa-dev] [PATCH 2/2] Revert "glsl: Switch to disable-by-default for the GLSL shader cache"

2017-02-23 Thread Marek Olšák
On Thu, Feb 23, 2017 at 5:55 PM, Timothy Arceri  wrote:
> On 24/02/17 02:09, Marek Olšák wrote:
>>
>> On Thu, Feb 23, 2017 at 3:09 AM, Timothy Arceri 
>> wrote:
>>>
>>> This reverts commit 0f60c6616e93cba72bff4fbfedb72a753ef78e05.
>>>
>>> Piglit and all games tested so far seem to be working without
>>> issue. This change will allow wide user testing and we can decided
>>> before the next release if we need to turn it off again.
>>> ---
>>>
>>> I'm in the process of doing some CTS testing. I can hold this
>>> patch back if there are any issues.
>>>
>>>  src/compiler/glsl/tests/cache_test.c | 5 -
>>>  src/util/disk_cache.c| 7 ---
>>>  2 files changed, 12 deletions(-)
>>>
>>> diff --git a/src/compiler/glsl/tests/cache_test.c
>>> b/src/compiler/glsl/tests/cache_test.c
>>> index c4e6e36..de92e5a 100644
>>> --- a/src/compiler/glsl/tests/cache_test.c
>>> +++ b/src/compiler/glsl/tests/cache_test.c
>>> @@ -428,11 +428,6 @@ main(void)
>>>  #ifdef ENABLE_SHADER_CACHE
>>> int err;
>>>
>>> -   /* While the shader cache is still experimental, this variable must
>>> -* be set or the cache does nothing.
>>> -*/
>>> -   setenv("MESA_GLSL_CACHE_ENABLE", "1", 1);
>>> -
>>> test_disk_cache_create();
>>>
>>> test_put_and_get();
>>> diff --git a/src/util/disk_cache.c b/src/util/disk_cache.c
>>> index f5e1145..f280f1b 100644
>>> --- a/src/util/disk_cache.c
>>> +++ b/src/util/disk_cache.c
>>> @@ -213,13 +213,6 @@ disk_cache_create(const char *gpu_name, const char
>>> *timestamp)
>>> if (getenv("MESA_GLSL_CACHE_DISABLE"))
>>>goto fail;
>>>
>>> -   /* As a temporary measure, (while the shader cache is under
>>> -* development, and known to not be fully functional), also require
>>> -* the MESA_GLSL_CACHE_ENABLE variable to be set.
>>> -*/
>>> -   if (!getenv("MESA_GLSL_CACHE_ENABLE"))
>>> -  goto fail;
>>
>>
>> Maybe keep the variable, but default to 1?
>
>
> Yeah there is already a MESA_GLSL_CACHE_DISABLE, so I don't think we need to
> keep it. Karl wrote this patch to be reverted at some point.
>
> I'm thinking that we should probably be disabling per driver anyway, a
> global disable isn't going to work if we want to enable this in radeonsi but
> i965 still wants to have it disabled by default.

Sounds good.

Reviewed-by: Marek Olšák 

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


Re: [Mesa-dev] [PATCH 1/2] radeonsi: add support for an on-disk shader cache

2017-02-23 Thread Marek Olšák
On Thu, Feb 23, 2017 at 3:09 AM, Timothy Arceri  wrote:
> From: kdj0c 
>
> V2 (Timothy Arceri):
> - when loading from disk cache also binary insert into memory cache.
> - check that the binary loaded from disk is the correct size. If not
>   delete the cache item and skip loading from cache.
> ---
>  src/gallium/drivers/radeonsi/si_state_shaders.c | 69 
> ++---
>  1 file changed, 62 insertions(+), 7 deletions(-)
>
> diff --git a/src/gallium/drivers/radeonsi/si_state_shaders.c 
> b/src/gallium/drivers/radeonsi/si_state_shaders.c
> index f615aa8..71556f9 100644
> --- a/src/gallium/drivers/radeonsi/si_state_shaders.c
> +++ b/src/gallium/drivers/radeonsi/si_state_shaders.c
> @@ -36,6 +36,9 @@
>  #include "util/u_memory.h"
>  #include "util/u_prim.h"
>
> +#include "util/disk_cache.h"
> +#include "util/mesa-sha1.h"
> +
>  /* SHADER_CACHE */
>
>  /**
> @@ -182,10 +185,12 @@ static bool si_load_shader_binary(struct si_shader 
> *shader, void *binary)
>   */
>  static bool si_shader_cache_insert_shader(struct si_screen *sscreen,
>   void *tgsi_binary,
> - struct si_shader *shader)
> + struct si_shader *shader,
> + bool insert_into_disk_cache)
>  {
> void *hw_binary;
> struct hash_entry *entry;
> +   uint8_t key[CACHE_KEY_SIZE];
>
> entry = _mesa_hash_table_search(sscreen->shader_cache, tgsi_binary);
> if (entry)
> @@ -201,6 +206,12 @@ static bool si_shader_cache_insert_shader(struct 
> si_screen *sscreen,
> return false;
> }
>
> +   if (sscreen->b.disk_shader_cache && insert_into_disk_cache) {
> +   _mesa_sha1_compute(tgsi_binary, *((uint32_t *)tgsi_binary), 
> key);

What happens if we randomly get a sha1 collision? Shouldn't we store
the whole key as well?

> +   disk_cache_put(sscreen->b.disk_shader_cache, key, hw_binary,
> +  *((uint32_t *) hw_binary));
> +   }
> +
> return true;
>  }
>
> @@ -210,12 +221,56 @@ static bool si_shader_cache_load_shader(struct 
> si_screen *sscreen,
>  {
> struct hash_entry *entry =
> _mesa_hash_table_search(sscreen->shader_cache, tgsi_binary);
> -   if (!entry)
> -   return false;
> +   if (!entry) {
> +   if (sscreen->b.disk_shader_cache) {
> +   unsigned char sha1[CACHE_KEY_SIZE];
> +   size_t tg_size = *((uint32_t *) tgsi_binary);
> +
> +   _mesa_sha1_compute(tgsi_binary, tg_size, sha1);
> +
> +   size_t binary_size;
> +   uint8_t *buffer =
> +   disk_cache_get(sscreen->b.disk_shader_cache,
> +  sha1, _size);
> +   if (!buffer)
> +   return false;
>
> -   if (!si_load_shader_binary(shader, entry->data))
> -   return false;
> +   uint32_t stored_binary_size;

It looks like you don't need this variable.

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


Re: [Mesa-dev] [PATCH 01/37] ABI-check: add a note that checking only T symbols is flacky

2017-02-23 Thread Emil Velikov
On 23 February 2017 at 17:34, Matt Turner  wrote:
> s/flacky/flakey/ in the title.
>
> On Thu, Feb 23, 2017 at 9:13 AM, Emil Velikov  
> wrote:
>> From: Emil Velikov 
>>
>> Note that all the symbols/ABI checks in tree do so :-\
>>
>> Signed-off-by: Emil Velikov 
>> ---
>> Mostly an RFC since the es*api code might be going soon.
>
> Tell me more :)
>
Should have said "soon (tm)" ;-)

GLVND effectively makes these dead code/deprecated/unwanted. I've got
the EGL one locally, but I need to do some testing on it.

>> ---
>>  src/mapi/es2api/ABI-check | 4 
>>  1 file changed, 4 insertions(+)
>>
>> diff --git a/src/mapi/es2api/ABI-check b/src/mapi/es2api/ABI-check
>> index e0bf3c8314..e338408c7e 100755
>> --- a/src/mapi/es2api/ABI-check
>> +++ b/src/mapi/es2api/ABI-check
>> @@ -5,6 +5,10 @@
>>  # GL_EXT_multi_draw_arrays
>>  # GL_OES_EGL_image
>>
>> +# FIXME: checking only for T symbols in incomplete/wrong.
>
> s/in/is/ ?
>
> What's wrong with checking for T symbols? I don't know, and I think it
> should be in the commit message.

In general we want to track all symbols (but the platform specific
_edata and friends) since those are the ABI we expose. For example:
The DRI modules expose "B __driDriverExtensions", while glapi "B
_glapi_tls_Context" and "D _glapi_tls_Dispatch" amongst others.

Not to mention that libEGL/libgbm provides fluid ABI based on the
configure toggles. I.e. wl_drm_interface is always exposed by libgbm,
for libEGL things vary. That has some Wayland roots which I'm also
trying to resolve as well, just need some convincing.

Obviously special casing libGLES* doesn't bring much, even if they
expose only T (barring the platform specific of course) symbols.

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


Re: [Mesa-dev] [PATCH] mesa: Use _mesa_has_OES_geometry_shader() when validating draws

2017-02-23 Thread Anuj Phogat
On Thu, Feb 23, 2017 at 12:05 AM, Tomasz Figa  wrote:
> In validate_DrawElements_common() we need to check for OES_geometry_shader
> extension to determine if we should fail if transform feedback is
> unpaused. However current code reads ctx->Extensions.OES_geometry_shader
> directly, which does not take context version into account. This means
> that if the context is GLES 3.0, which makes the OES_geometry_shader
> inapplicable, we would not validate the draw properly. To fix it, let's
> replace the check with a call to _mesa_has_OES_geometry_shader().
>
> Fixes following dEQP tests on i965 with a GLES 3.0 context:
>
> dEQP-GLES3.functional.negative_api.vertex_array#draw_elements
> dEQP-GLES3.functional.negative_api.vertex_array#draw_elements_incomplete_primitive
> dEQP-GLES3.functional.negative_api.vertex_array#draw_elements_instanced
> dEQP-GLES3.functional.negative_api.vertex_array#draw_elements_instanced_incomplete_primitive
> dEQP-GLES3.functional.negative_api.vertex_array#draw_range_elements
> dEQP-GLES3.functional.negative_api.vertex_array#draw_range_elements_incomplete_primitive
>
> Change-Id: Iebc960b479fcd5f6c2b1501cb3e7798b575e6c4d
> Signed-off-by: Tomasz Figa 
> ---
>  src/mesa/main/api_validate.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/src/mesa/main/api_validate.c b/src/mesa/main/api_validate.c
> index 1e8a714067..184bf143ed 100644
> --- a/src/mesa/main/api_validate.c
> +++ b/src/mesa/main/api_validate.c
> @@ -664,7 +664,8 @@ validate_DrawElements_common(struct gl_context *ctx,
>  * to have been overlooked.  The body of the spec only explicitly allows
>  * the indirect versions.
>  */
> -   if (_mesa_is_gles3(ctx) && !ctx->Extensions.OES_geometry_shader &&
> +   if (_mesa_is_gles3(ctx) &&
> +   !_mesa_has_OES_geometry_shader(ctx) &&
> _mesa_is_xfb_active_and_unpaused(ctx)) {
>_mesa_error(ctx, GL_INVALID_OPERATION,
>"%s(transform feedback active)", caller);
> --
> 2.11.0.483.g087da7b7c-goog
>
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Reviewed-by: Anuj Phogat 
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH] glsl: add has_shader_image_load_store()

2017-02-23 Thread Samuel Pitoiset
Preliminary work for ARB_bindless_texture which can interact
with ARB_shader_image_load_store.

Signed-off-by: Samuel Pitoiset 
---
 src/compiler/glsl/builtin_variables.cpp | 3 +--
 src/compiler/glsl/glsl_parser.yy| 3 +--
 src/compiler/glsl/glsl_parser_extras.h  | 5 +
 3 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/src/compiler/glsl/builtin_variables.cpp 
b/src/compiler/glsl/builtin_variables.cpp
index db8418bbc7..fc0443e715 100644
--- a/src/compiler/glsl/builtin_variables.cpp
+++ b/src/compiler/glsl/builtin_variables.cpp
@@ -840,8 +840,7 @@ builtin_variable_generator::generate_constants()
 state->Const.MaxTransformFeedbackInterleavedComponents);
}
 
-   if (state->is_version(420, 310) ||
-   state->ARB_shader_image_load_store_enable) {
+   if (state->has_shader_image_load_store()) {
   add_const("gl_MaxImageUnits",
 state->Const.MaxImageUnits);
   add_const("gl_MaxVertexImageUniforms",
diff --git a/src/compiler/glsl/glsl_parser.yy b/src/compiler/glsl/glsl_parser.yy
index fd7edb28e7..d703f8 100644
--- a/src/compiler/glsl/glsl_parser.yy
+++ b/src/compiler/glsl/glsl_parser.yy
@@ -1322,8 +1322,7 @@ layout_qualifier_id:
   }
 
   /* Layout qualifiers for ARB_shader_image_load_store. */
-  if (state->ARB_shader_image_load_store_enable ||
-  state->is_version(420, 310)) {
+  if (state->has_shader_image_load_store()) {
  if (!$$.flags.i) {
 static const struct {
const char *name;
diff --git a/src/compiler/glsl/glsl_parser_extras.h 
b/src/compiler/glsl/glsl_parser_extras.h
index 8feef8cbcd..01acbb62e3 100644
--- a/src/compiler/glsl/glsl_parser_extras.h
+++ b/src/compiler/glsl/glsl_parser_extras.h
@@ -330,6 +330,11 @@ struct _mesa_glsl_parse_state {
  is_version(400, 320);
}
 
+   bool has_shader_image_load_store() const
+   {
+  return ARB_shader_image_load_store_enable || is_version(420, 310);
+   }
+
void process_version_directive(YYLTYPE *locp, int version,
   const char *ident);
 
-- 
2.11.1

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


Re: [Mesa-dev] [RESEND 08/13] anv: generate anv_entrypoints.{h, c} in one command

2017-02-23 Thread Matt Turner
On Thu, Feb 23, 2017 at 9:29 AM, Emil Velikov  wrote:
> On 23 February 2017 at 17:22, Dylan Baker  wrote:
>> Quoting Emil Velikov (2017-02-23 02:32:17)
>>> On 22 February 2017 at 23:35, Dylan Baker  wrote:
>>> > This changes the python generator to write the files itself, rather than
>>> > piping them out. This has a couple of advantages: first, it encapsulates
>>> > the encoding. Second, it ensures that the header file and code file are
>>> > generated at the same time with the same data.
>>> >
>>> Last time there were some serious objections to doing this. Glad that
>>> you got those covered ;-)
>>>
>>> > Signed-off-by: Dylan Baker 
>>> > ---
>>> >  src/intel/vulkan/Makefile.am|  7 ++
>>> >  src/intel/vulkan/anv_entrypoints_gen.py | 38 
>>> > -
>>> >  2 files changed, 16 insertions(+), 29 deletions(-)
>>> >
>>> > diff --git a/src/intel/vulkan/Makefile.am b/src/intel/vulkan/Makefile.am
>>> > index 5a0e4ef4ff..68bc5ccf86 100644
>>> > --- a/src/intel/vulkan/Makefile.am
>>> > +++ b/src/intel/vulkan/Makefile.am
>>> > @@ -145,11 +145,8 @@ libvulkan_intel_la_SOURCES = $(VULKAN_GEM_FILES)
>>> >
>>> >  vulkan_api_xml = $(top_srcdir)/src/vulkan/registry/vk.xml
>>> >
>>> > -anv_entrypoints.h : anv_entrypoints_gen.py $(vulkan_api_xml)
>>> > -   $(AM_V_GEN)$(PYTHON2) $(srcdir)/anv_entrypoints_gen.py header > $@
>>> > -
>>> > -anv_entrypoints.c : anv_entrypoints_gen.py $(vulkan_api_xml)
>>> > -   $(AM_V_GEN)$(PYTHON2) $(srcdir)/anv_entrypoints_gen.py code > $@
>>> > +anv_entrypoints.h anv_entrypoints.c: anv_entrypoints_gen.py 
>>> > $(vulkan_api_xml)
>>> > +   $(AM_V_GEN)$(PYTHON2) $(srcdir)/anv_entrypoints_gen.py
>>> >
>>> Please pass a "-o $dst_dir" type of argument. It will be/is broken 
>>> otherwise.
>>
>> So you want an option for where the output files are going to be placed?
>>
> Precisely. To elaborate a bit - as-is (if I'm reading it properly)
> you'll end up generating the files to srcdir.
> srcdir should be considered immutable and this will fail a bunch of tests.
>
> Generated files should be stored in $builddir.

The scripts are executed with a current-working-directory inside
$builddir. The files are definitely written to $builddir.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [RESEND 08/13] anv: generate anv_entrypoints.{h, c} in one command

2017-02-23 Thread Dylan Baker
Quoting Emil Velikov (2017-02-23 09:29:40)
> On 23 February 2017 at 17:22, Dylan Baker  wrote:
> > Quoting Emil Velikov (2017-02-23 02:32:17)
> >> On 22 February 2017 at 23:35, Dylan Baker  wrote:
> >> > This changes the python generator to write the files itself, rather than
> >> > piping them out. This has a couple of advantages: first, it encapsulates
> >> > the encoding. Second, it ensures that the header file and code file are
> >> > generated at the same time with the same data.
> >> >
> >> Last time there were some serious objections to doing this. Glad that
> >> you got those covered ;-)
> >>
> >> > Signed-off-by: Dylan Baker 
> >> > ---
> >> >  src/intel/vulkan/Makefile.am|  7 ++
> >> >  src/intel/vulkan/anv_entrypoints_gen.py | 38 
> >> > -
> >> >  2 files changed, 16 insertions(+), 29 deletions(-)
> >> >
> >> > diff --git a/src/intel/vulkan/Makefile.am b/src/intel/vulkan/Makefile.am
> >> > index 5a0e4ef4ff..68bc5ccf86 100644
> >> > --- a/src/intel/vulkan/Makefile.am
> >> > +++ b/src/intel/vulkan/Makefile.am
> >> > @@ -145,11 +145,8 @@ libvulkan_intel_la_SOURCES = $(VULKAN_GEM_FILES)
> >> >
> >> >  vulkan_api_xml = $(top_srcdir)/src/vulkan/registry/vk.xml
> >> >
> >> > -anv_entrypoints.h : anv_entrypoints_gen.py $(vulkan_api_xml)
> >> > -   $(AM_V_GEN)$(PYTHON2) $(srcdir)/anv_entrypoints_gen.py header > 
> >> > $@
> >> > -
> >> > -anv_entrypoints.c : anv_entrypoints_gen.py $(vulkan_api_xml)
> >> > -   $(AM_V_GEN)$(PYTHON2) $(srcdir)/anv_entrypoints_gen.py code > $@
> >> > +anv_entrypoints.h anv_entrypoints.c: anv_entrypoints_gen.py 
> >> > $(vulkan_api_xml)
> >> > +   $(AM_V_GEN)$(PYTHON2) $(srcdir)/anv_entrypoints_gen.py
> >> >
> >> Please pass a "-o $dst_dir" type of argument. It will be/is broken 
> >> otherwise.
> >
> > So you want an option for where the output files are going to be placed?
> >
> Precisely. To elaborate a bit - as-is (if I'm reading it properly)
> you'll end up generating the files to srcdir.
> srcdir should be considered immutable and this will fail a bunch of tests.
> 
> Generated files should be stored in $builddir.

On my system as-is they end up in $builddir, however, we discovered yesterday
that some out-of-tree builds work on my system, but fail on everybody else's, so
I'll go ahead and add that switch.

> 
> Thanks
> Emil


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


Re: [Mesa-dev] [RESEND 06/13] anv: convert header generation in anv_entrypoints_gen.py to mako

2017-02-23 Thread Dylan Baker
Sure, I'll add a patch for v2

Quoting Emil Velikov (2017-02-23 03:14:49)
> On 22 February 2017 at 23:36, Dylan Baker  wrote:
> 
> > +void anv_set_dispatch_devinfo(const struct gen_device_info *info);
> Dead declaration since commit 6d557ae4032adafc85a4cb5a76d8653bf0cf6639.
> 
> Worth fixing before, with or after this patch/series ?
> 
> -Emil


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


Re: [Mesa-dev] [RESEND 04/13] anv: don't pass xmlfile via stdin anv_entrypoints_gen.py

2017-02-23 Thread Dylan Baker
Quoting Emil Velikov (2017-02-23 02:24:21)
> Hi Dylan,
> 
> General question - have you considered porting the series to the radv ?
> Alternatively - Bas, Dave you might find these interesting/useful ;-)

Yeah, I'm getting there. My goal is mako + python3 readiness for all of mesa.

> 
> On 22 February 2017 at 23:36, Dylan Baker  wrote:
> > It's slow, and has the potential for encoding issues.
> >
> > Signed-off-by: Dylan Baker 
> > ---
> >  src/intel/vulkan/Makefile.am| 6 ++
> >  src/intel/vulkan/anv_entrypoints_gen.py | 6 +-
> >  2 files changed, 7 insertions(+), 5 deletions(-)
> >
> > diff --git a/src/intel/vulkan/Makefile.am b/src/intel/vulkan/Makefile.am
> > index 449188fe1e..5a0e4ef4ff 100644
> > --- a/src/intel/vulkan/Makefile.am
> > +++ b/src/intel/vulkan/Makefile.am
> > @@ -146,12 +146,10 @@ libvulkan_intel_la_SOURCES = $(VULKAN_GEM_FILES)
> >  vulkan_api_xml = $(top_srcdir)/src/vulkan/registry/vk.xml
> >
> >  anv_entrypoints.h : anv_entrypoints_gen.py $(vulkan_api_xml)
> > -   $(AM_V_GEN) cat $(vulkan_api_xml) |\
> > -   $(PYTHON2) $(srcdir)/anv_entrypoints_gen.py header > $@
> > +   $(AM_V_GEN)$(PYTHON2) $(srcdir)/anv_entrypoints_gen.py header > $@
> >
> >  anv_entrypoints.c : anv_entrypoints_gen.py $(vulkan_api_xml)
> > -   $(AM_V_GEN) cat $(vulkan_api_xml) |\
> > -   $(PYTHON2) $(srcdir)/anv_entrypoints_gen.py code > $@
> > +   $(AM_V_GEN)$(PYTHON2) $(srcdir)/anv_entrypoints_gen.py code > $@
> >
> Can you please apply similar [trivial] fix for Android.mk ?

Sure

> 
> >  BUILT_SOURCES = $(VULKAN_GENERATED_FILES)
> >  CLEANFILES = $(BUILT_SOURCES) dev_icd.json intel_icd.@host_cpu@.json
> > diff --git a/src/intel/vulkan/anv_entrypoints_gen.py 
> > b/src/intel/vulkan/anv_entrypoints_gen.py
> > index 40b8c805d5..5403bcb4bc 100644
> > --- a/src/intel/vulkan/anv_entrypoints_gen.py
> > +++ b/src/intel/vulkan/anv_entrypoints_gen.py
> > @@ -22,10 +22,14 @@
> >  # IN THE SOFTWARE.
> >  #
> >
> > +import os
> >  import sys
> >  import textwrap
> >  import xml.etree.ElementTree as et
> >
> > +VK_XML = os.path.join(
> > +os.path.dirname(__file__), '..', '..', 'vulkan', 'registry', 'vk.xml')
> Hard-coded paths is very, very bad idea. Please feed it in as argument.

Well, technically it's hard-coded no matter where we do it, but I'll hard-code 
it
in the build systems instead ;)

> 
> Thanks
> Emil


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


Re: [Mesa-dev] [PATCH 01/37] ABI-check: add a note that checking only T symbols is flacky

2017-02-23 Thread Matt Turner
s/flacky/flakey/ in the title.

On Thu, Feb 23, 2017 at 9:13 AM, Emil Velikov  wrote:
> From: Emil Velikov 
>
> Note that all the symbols/ABI checks in tree do so :-\
>
> Signed-off-by: Emil Velikov 
> ---
> Mostly an RFC since the es*api code might be going soon.

Tell me more :)

> ---
>  src/mapi/es2api/ABI-check | 4 
>  1 file changed, 4 insertions(+)
>
> diff --git a/src/mapi/es2api/ABI-check b/src/mapi/es2api/ABI-check
> index e0bf3c8314..e338408c7e 100755
> --- a/src/mapi/es2api/ABI-check
> +++ b/src/mapi/es2api/ABI-check
> @@ -5,6 +5,10 @@
>  # GL_EXT_multi_draw_arrays
>  # GL_OES_EGL_image
>
> +# FIXME: checking only for T symbols in incomplete/wrong.

s/in/is/ ?

What's wrong with checking for T symbols? I don't know, and I think it
should be in the commit message.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [RESEND 08/13] anv: generate anv_entrypoints.{h, c} in one command

2017-02-23 Thread Emil Velikov
On 23 February 2017 at 17:22, Dylan Baker  wrote:
> Quoting Emil Velikov (2017-02-23 02:32:17)
>> On 22 February 2017 at 23:35, Dylan Baker  wrote:
>> > This changes the python generator to write the files itself, rather than
>> > piping them out. This has a couple of advantages: first, it encapsulates
>> > the encoding. Second, it ensures that the header file and code file are
>> > generated at the same time with the same data.
>> >
>> Last time there were some serious objections to doing this. Glad that
>> you got those covered ;-)
>>
>> > Signed-off-by: Dylan Baker 
>> > ---
>> >  src/intel/vulkan/Makefile.am|  7 ++
>> >  src/intel/vulkan/anv_entrypoints_gen.py | 38 
>> > -
>> >  2 files changed, 16 insertions(+), 29 deletions(-)
>> >
>> > diff --git a/src/intel/vulkan/Makefile.am b/src/intel/vulkan/Makefile.am
>> > index 5a0e4ef4ff..68bc5ccf86 100644
>> > --- a/src/intel/vulkan/Makefile.am
>> > +++ b/src/intel/vulkan/Makefile.am
>> > @@ -145,11 +145,8 @@ libvulkan_intel_la_SOURCES = $(VULKAN_GEM_FILES)
>> >
>> >  vulkan_api_xml = $(top_srcdir)/src/vulkan/registry/vk.xml
>> >
>> > -anv_entrypoints.h : anv_entrypoints_gen.py $(vulkan_api_xml)
>> > -   $(AM_V_GEN)$(PYTHON2) $(srcdir)/anv_entrypoints_gen.py header > $@
>> > -
>> > -anv_entrypoints.c : anv_entrypoints_gen.py $(vulkan_api_xml)
>> > -   $(AM_V_GEN)$(PYTHON2) $(srcdir)/anv_entrypoints_gen.py code > $@
>> > +anv_entrypoints.h anv_entrypoints.c: anv_entrypoints_gen.py 
>> > $(vulkan_api_xml)
>> > +   $(AM_V_GEN)$(PYTHON2) $(srcdir)/anv_entrypoints_gen.py
>> >
>> Please pass a "-o $dst_dir" type of argument. It will be/is broken otherwise.
>
> So you want an option for where the output files are going to be placed?
>
Precisely. To elaborate a bit - as-is (if I'm reading it properly)
you'll end up generating the files to srcdir.
srcdir should be considered immutable and this will fail a bunch of tests.

Generated files should be stored in $builddir.

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


[Mesa-dev] [PATCH 25/37] st/xa: suffix xa-indent{, .sh} and add a shebang line

2017-02-23 Thread Emil Velikov
From: Emil Velikov 

Signed-off-by: Emil Velikov 
---
Is this still used ? Running it produces some some 250+ diff stat.
---
 src/gallium/state_trackers/xa/Makefile.am | 2 +-
 src/gallium/state_trackers/xa/{xa-indent => xa-indent.sh} | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
 rename src/gallium/state_trackers/xa/{xa-indent => xa-indent.sh} (83%)

diff --git a/src/gallium/state_trackers/xa/Makefile.am 
b/src/gallium/state_trackers/xa/Makefile.am
index 21c7c000ea..1e51ec9cb8 100644
--- a/src/gallium/state_trackers/xa/Makefile.am
+++ b/src/gallium/state_trackers/xa/Makefile.am
@@ -38,4 +38,4 @@ noinst_LTLIBRARIES = libxatracker.la
 
 libxatracker_la_SOURCES = $(C_SOURCES)
 
-EXTRA_DIST = README xa-indent
+EXTRA_DIST = README xa-indent.sh
diff --git a/src/gallium/state_trackers/xa/xa-indent 
b/src/gallium/state_trackers/xa/xa-indent.sh
similarity index 83%
rename from src/gallium/state_trackers/xa/xa-indent
rename to src/gallium/state_trackers/xa/xa-indent.sh
index 1972e53226..90241a3772 100755
--- a/src/gallium/state_trackers/xa/xa-indent
+++ b/src/gallium/state_trackers/xa/xa-indent.sh
@@ -1,3 +1,3 @@
-#
+#!/bin/sh
 indent --linux-style -i4 -ip4 -bad -bap -psl $*
 
-- 
2.11.0

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


[Mesa-dev] [PATCH 34/37] wayland-egl/wayland-egl-symbols-check: do not mandate bash

2017-02-23 Thread Emil Velikov
From: Emil Velikov 

Signed-off-by: Emil Velikov 
---
 src/egl/wayland/wayland-egl/wayland-egl-symbols-check | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/egl/wayland/wayland-egl/wayland-egl-symbols-check 
b/src/egl/wayland/wayland-egl/wayland-egl-symbols-check
index 0c5fd09a01..e7105ea579 100755
--- a/src/egl/wayland/wayland-egl/wayland-egl-symbols-check
+++ b/src/egl/wayland/wayland-egl/wayland-egl-symbols-check
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
 
 FUNCS=$(nm -D --defined-only ${1-.libs/libwayland-egl.so} | grep -o "T .*" | 
cut -c 3- | while read func; do
 ( grep -q "^$func$" || echo $func )  

[Mesa-dev] [PATCH 21/37] mapi/gen: remove shebang from python scripts

2017-02-23 Thread Emil Velikov
From: Emil Velikov 

All of those should be executed $PYTHON2/python2 [or equivalent] hence
why they are missing the execute bit.

Signed-off-by: Emil Velikov 
---
 src/mapi/glapi/gen/glX_XML.py  | 1 -
 src/mapi/glapi/gen/glX_proto_common.py | 1 -
 src/mapi/glapi/gen/glX_proto_recv.py   | 1 -
 src/mapi/glapi/gen/glX_proto_send.py   | 1 -
 src/mapi/glapi/gen/glX_proto_size.py   | 1 -
 src/mapi/glapi/gen/glX_server_table.py | 1 -
 src/mapi/glapi/gen/gl_SPARC_asm.py | 1 -
 src/mapi/glapi/gen/gl_XML.py   | 1 -
 src/mapi/glapi/gen/gl_apitemp.py   | 1 -
 src/mapi/glapi/gen/gl_enums.py | 1 -
 src/mapi/glapi/gen/gl_genexec.py   | 1 -
 src/mapi/glapi/gen/gl_gentable.py  | 1 -
 src/mapi/glapi/gen/gl_procs.py | 1 -
 src/mapi/glapi/gen/gl_table.py | 1 -
 src/mapi/glapi/gen/gl_x86-64_asm.py| 1 -
 src/mapi/glapi/gen/gl_x86_asm.py   | 1 -
 src/mapi/glapi/gen/remap_helper.py | 1 -
 src/mapi/glapi/gen/static_data.py  | 1 -
 src/mapi/glapi/gen/typeexpr.py | 1 -
 19 files changed, 19 deletions(-)

diff --git a/src/mapi/glapi/gen/glX_XML.py b/src/mapi/glapi/gen/glX_XML.py
index c659e931b4..b6d305c879 100644
--- a/src/mapi/glapi/gen/glX_XML.py
+++ b/src/mapi/glapi/gen/glX_XML.py
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
 
 # (C) Copyright IBM Corporation 2004, 2005
 # All Rights Reserved.
diff --git a/src/mapi/glapi/gen/glX_proto_common.py 
b/src/mapi/glapi/gen/glX_proto_common.py
index ae2c2d5811..bd1192cb47 100644
--- a/src/mapi/glapi/gen/glX_proto_common.py
+++ b/src/mapi/glapi/gen/glX_proto_common.py
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
 
 # (C) Copyright IBM Corporation 2004, 2005
 # All Rights Reserved.
diff --git a/src/mapi/glapi/gen/glX_proto_recv.py 
b/src/mapi/glapi/gen/glX_proto_recv.py
index 54332882ac..946f011818 100644
--- a/src/mapi/glapi/gen/glX_proto_recv.py
+++ b/src/mapi/glapi/gen/glX_proto_recv.py
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
 
 # (C) Copyright IBM Corporation 2005
 # All Rights Reserved.
diff --git a/src/mapi/glapi/gen/glX_proto_send.py 
b/src/mapi/glapi/gen/glX_proto_send.py
index b534cd4e5c..6115c9b1d8 100644
--- a/src/mapi/glapi/gen/glX_proto_send.py
+++ b/src/mapi/glapi/gen/glX_proto_send.py
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
 
 # (C) Copyright IBM Corporation 2004, 2005
 # All Rights Reserved.
diff --git a/src/mapi/glapi/gen/glX_proto_size.py 
b/src/mapi/glapi/gen/glX_proto_size.py
index d9f95a31d8..e16dbab3e0 100644
--- a/src/mapi/glapi/gen/glX_proto_size.py
+++ b/src/mapi/glapi/gen/glX_proto_size.py
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
 
 # (C) Copyright IBM Corporation 2004, 2005
 # All Rights Reserved.
diff --git a/src/mapi/glapi/gen/glX_server_table.py 
b/src/mapi/glapi/gen/glX_server_table.py
index 2d21f4e4ee..f2e6642647 100644
--- a/src/mapi/glapi/gen/glX_server_table.py
+++ b/src/mapi/glapi/gen/glX_server_table.py
@@ -1,4 +1,3 @@
-#!/bin/env python
 
 # (C) Copyright IBM Corporation 2005, 2006
 # All Rights Reserved.
diff --git a/src/mapi/glapi/gen/gl_SPARC_asm.py 
b/src/mapi/glapi/gen/gl_SPARC_asm.py
index fa6217e1b8..7b5714effd 100644
--- a/src/mapi/glapi/gen/gl_SPARC_asm.py
+++ b/src/mapi/glapi/gen/gl_SPARC_asm.py
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
 
 # (C) Copyright IBM Corporation 2004
 # All Rights Reserved.
diff --git a/src/mapi/glapi/gen/gl_XML.py b/src/mapi/glapi/gen/gl_XML.py
index 8036a0281f..c688906e88 100644
--- a/src/mapi/glapi/gen/gl_XML.py
+++ b/src/mapi/glapi/gen/gl_XML.py
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
 
 # (C) Copyright IBM Corporation 2004, 2005
 # All Rights Reserved.
diff --git a/src/mapi/glapi/gen/gl_apitemp.py b/src/mapi/glapi/gen/gl_apitemp.py
index 5e985a2eca..e1b94f5025 100644
--- a/src/mapi/glapi/gen/gl_apitemp.py
+++ b/src/mapi/glapi/gen/gl_apitemp.py
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
 
 # (C) Copyright IBM Corporation 2004, 2005
 # All Rights Reserved.
diff --git a/src/mapi/glapi/gen/gl_enums.py b/src/mapi/glapi/gen/gl_enums.py
index 2eb9e1642c..768a54a3a6 100644
--- a/src/mapi/glapi/gen/gl_enums.py
+++ b/src/mapi/glapi/gen/gl_enums.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python2
 
 # (C) Copyright Zack Rusin 2005. All Rights Reserved.
 # Copyright (C) 2015 Intel Corporation
diff --git a/src/mapi/glapi/gen/gl_genexec.py b/src/mapi/glapi/gen/gl_genexec.py
index e63393d26a..3a75419a75 100644
--- a/src/mapi/glapi/gen/gl_genexec.py
+++ b/src/mapi/glapi/gen/gl_genexec.py
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
 
 # Copyright (C) 2012 Intel Corporation
 #
diff --git a/src/mapi/glapi/gen/gl_gentable.py 
b/src/mapi/glapi/gen/gl_gentable.py
index 7cd475aa2b..2f54d1d579 100644
--- a/src/mapi/glapi/gen/gl_gentable.py
+++ b/src/mapi/glapi/gen/gl_gentable.py
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
 
 # (C) Copyright IBM Corporation 2004, 2005
 # (C) Copyright Apple Inc. 2011
diff --git a/src/mapi/glapi/gen/gl_procs.py b/src/mapi/glapi/gen/gl_procs.py
index 685e2fac34..d9ea1ab074 100644
--- a/src/mapi/glapi/gen/gl_procs.py

Re: [Mesa-dev] [RESEND 08/13] anv: generate anv_entrypoints.{h, c} in one command

2017-02-23 Thread Dylan Baker
Quoting Emil Velikov (2017-02-23 02:32:17)
> On 22 February 2017 at 23:35, Dylan Baker  wrote:
> > This changes the python generator to write the files itself, rather than
> > piping them out. This has a couple of advantages: first, it encapsulates
> > the encoding. Second, it ensures that the header file and code file are
> > generated at the same time with the same data.
> >
> Last time there were some serious objections to doing this. Glad that
> you got those covered ;-)
> 
> > Signed-off-by: Dylan Baker 
> > ---
> >  src/intel/vulkan/Makefile.am|  7 ++
> >  src/intel/vulkan/anv_entrypoints_gen.py | 38 
> > -
> >  2 files changed, 16 insertions(+), 29 deletions(-)
> >
> > diff --git a/src/intel/vulkan/Makefile.am b/src/intel/vulkan/Makefile.am
> > index 5a0e4ef4ff..68bc5ccf86 100644
> > --- a/src/intel/vulkan/Makefile.am
> > +++ b/src/intel/vulkan/Makefile.am
> > @@ -145,11 +145,8 @@ libvulkan_intel_la_SOURCES = $(VULKAN_GEM_FILES)
> >
> >  vulkan_api_xml = $(top_srcdir)/src/vulkan/registry/vk.xml
> >
> > -anv_entrypoints.h : anv_entrypoints_gen.py $(vulkan_api_xml)
> > -   $(AM_V_GEN)$(PYTHON2) $(srcdir)/anv_entrypoints_gen.py header > $@
> > -
> > -anv_entrypoints.c : anv_entrypoints_gen.py $(vulkan_api_xml)
> > -   $(AM_V_GEN)$(PYTHON2) $(srcdir)/anv_entrypoints_gen.py code > $@
> > +anv_entrypoints.h anv_entrypoints.c: anv_entrypoints_gen.py 
> > $(vulkan_api_xml)
> > +   $(AM_V_GEN)$(PYTHON2) $(srcdir)/anv_entrypoints_gen.py
> >
> Please pass a "-o $dst_dir" type of argument. It will be/is broken otherwise.

So you want an option for where the output files are going to be placed?

> 
> Small suggestion to update the Android.mk file. Feel free to Cc
> Tapani/Mauro so that they can test/address any concerns.
> 
> Mauro, Tapani,
> Afaict earlier series [1] have broken things on your end, but do
> suggest some fixes that one can squash with this batch.
> 
> Thanks
> Emil
> 
> [1]
> e9dcb17962f7e58a81c93bae7bd33885675b1043
> 8e03250fcf4fc5de31e92ca4919959d932888a69


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


[Mesa-dev] [PATCH 17/37] i965: remove execute bit from brw_nir_trig_workarounds.py

2017-02-23 Thread Emil Velikov
From: Emil Velikov 

Analogous to earlier commit(s).

Signed-off-by: Emil Velikov 
---
 src/mesa/drivers/dri/i965/brw_nir_trig_workarounds.py | 0
 1 file changed, 0 insertions(+), 0 deletions(-)
 mode change 100755 => 100644 
src/mesa/drivers/dri/i965/brw_nir_trig_workarounds.py

diff --git a/src/mesa/drivers/dri/i965/brw_nir_trig_workarounds.py 
b/src/mesa/drivers/dri/i965/brw_nir_trig_workarounds.py
old mode 100755
new mode 100644
-- 
2.11.0

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


[Mesa-dev] [PATCH 22/37] gallium/tests: remove execute bit from TGSI shader - vert-uadd.sh

2017-02-23 Thread Emil Velikov
From: Emil Velikov 

Just like the the dozens of other shaders, the file is parsed by
separate tool and not executed.

Cc: José Fonseca 
Signed-off-by: Emil Velikov 
---
Jose, please double-check since I've got no idea how there are used.

Out of curiosity - do you guys still use these ? Afaict TGSI has evolved
since those are added yet new opcodes are not covered. Perhaps they
should ?
---
 src/gallium/tests/graw/vertex-shader/vert-uadd.sh | 0
 1 file changed, 0 insertions(+), 0 deletions(-)
 mode change 100755 => 100644 src/gallium/tests/graw/vertex-shader/vert-uadd.sh

diff --git a/src/gallium/tests/graw/vertex-shader/vert-uadd.sh 
b/src/gallium/tests/graw/vertex-shader/vert-uadd.sh
old mode 100755
new mode 100644
-- 
2.11.0

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


[Mesa-dev] [PATCH 37/37] bin/get-fixes-pick-list.sh: do not mandate bash

2017-02-23 Thread Emil Velikov
From: Emil Velikov 

Silly thinko on my end, as I was writing the script. There is nothing
bash specific in there.

Signed-off-by: Emil Velikov 
---
 bin/get-fixes-pick-list.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/bin/get-fixes-pick-list.sh b/bin/get-fixes-pick-list.sh
index 4ce9c92f8a..59bcae4f2d 100755
--- a/bin/get-fixes-pick-list.sh
+++ b/bin/get-fixes-pick-list.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
 
 # Script for generating a list of candidates [referenced by a Fixes tag] for
 # cherry-picking to a stable branch
-- 
2.11.0

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


[Mesa-dev] [PATCH 33/37] gbm/gbm-symbols-check: do not mandate bash

2017-02-23 Thread Emil Velikov
From: Emil Velikov 

Analogous to previous commit.

Signed-off-by: Emil Velikov 
---
 src/gbm/gbm-symbols-check | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/gbm/gbm-symbols-check b/src/gbm/gbm-symbols-check
index 5a333ffcda..34fe11b874 100755
--- a/src/gbm/gbm-symbols-check
+++ b/src/gbm/gbm-symbols-check
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
 
 FUNCS=$(nm -D --defined-only ${1-.libs/libgbm.so} | grep -o "T .*" | cut -c 3- 
| while read func; do
 ( grep -q "^$func$" || echo $func )  

[Mesa-dev] [PATCH 36/37] in/shortlog_mesa.sh: remove the final bashism

2017-02-23 Thread Emil Velikov
From: Emil Velikov 

Remove the typeset built-in and toggle to /bin/sh

Signed-off-by: Emil Velikov 
---
Sidenote: seems like there is something in the script which causes bash
to trip in the odd occasion while zsh works like a charm.

Namely "[rasterizer]" would become "z" while "[rasterizer foo]" will
remain as-is.

But that for another day ;-)
---
 bin/shortlog_mesa.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/bin/shortlog_mesa.sh b/bin/shortlog_mesa.sh
index 2ba0815de7..c9a4297236 100755
--- a/bin/shortlog_mesa.sh
+++ b/bin/shortlog_mesa.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
 
 # This script is used to generate the list of changes that
 # appears in the release notes files, with HTML formatting.
@@ -10,7 +10,7 @@
 # $ bin/shortlog_mesa.sh mesa-9.0.2..mesa-9.0.3 | tee changes
 
 
-typeset -i in_log=0
+in_log=0
 
 git shortlog $* | while read l
 do
-- 
2.11.0

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


[Mesa-dev] [PATCH 19/37] bin/perf-annotate-jit: add .py suffix

2017-02-23 Thread Emil Velikov
From: Emil Velikov 

To provide direct feedback about the file in question.

Cc: José Fonseca 
Signed-off-by: Emil Velikov 
---
Jose, I sincerely hope this doesn't cause issues on your end.
---
 bin/{perf-annotate-jit => perf-annotate-jit.py} | 0
 docs/llvmpipe.html  | 2 +-
 2 files changed, 1 insertion(+), 1 deletion(-)
 rename bin/{perf-annotate-jit => perf-annotate-jit.py} (100%)

diff --git a/bin/perf-annotate-jit b/bin/perf-annotate-jit.py
similarity index 100%
rename from bin/perf-annotate-jit
rename to bin/perf-annotate-jit.py
diff --git a/docs/llvmpipe.html b/docs/llvmpipe.html
index 5fb3b7aa22..2163d2ec19 100644
--- a/docs/llvmpipe.html
+++ b/docs/llvmpipe.html
@@ -206,7 +206,7 @@ On Linux, it is possible to have symbol resolution of JIT 
code with https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 35/37] bin/bugzilla_mesa.sh: rework the looping method

2017-02-23 Thread Emil Velikov
From: Emil Velikov 

We don't use DRYRUN (and no others scripts have one) so just drop it.

This allows us to rework the loop to the more commonly used "git  |
while read foo; do ... done"

That in itself gets rid of the only remaining bashism and we can toggle
the shebang to /bin/sh.

Signed-off-by: Emil Velikov 
---
 bin/bugzilla_mesa.sh | 38 --
 1 file changed, 12 insertions(+), 26 deletions(-)

diff --git a/bin/bugzilla_mesa.sh b/bin/bugzilla_mesa.sh
index 49b9ce9c75..a8f5305844 100755
--- a/bin/bugzilla_mesa.sh
+++ b/bin/bugzilla_mesa.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
 
 # This script is used to generate the list of fixed bugs that
 # appears in the release notes files, with HTML formatting.
@@ -11,8 +11,6 @@
 # $ bin/bugzilla_mesa.sh mesa-9.0.2..mesa-9.0.3
 # $ bin/bugzilla_mesa.sh mesa-9.0.2..mesa-9.0.3 > bugfixes
 # $ bin/bugzilla_mesa.sh mesa-9.0.2..mesa-9.0.3 | tee bugfixes
-# $ DRYRUN=yes bin/bugzilla_mesa.sh mesa-9.0.2..mesa-9.0.3
-# $ DRYRUN=yes bin/bugzilla_mesa.sh mesa-9.0.2..mesa-9.0.3 | wc -l
 
 
 # regex pattern: trim before bug number
@@ -21,29 +19,17 @@ trim_before='s/.*show_bug.cgi?id=\([0-9]*\).*/\1/'
 # regex pattern: reconstruct the url
 use_after='s,^,https://bugs.freedesktop.org/show_bug.cgi?id=,'
 
-# extract fdo urls from commit log
-urls=$(git log $* | grep 'bugs.freedesktop.org/show_bug' | sed -e $trim_before 
| sort -n -u | sed -e $use_after)
-
-# if DRYRUN is set to "yes", simply print the URLs and don't fetch the
-# details from fdo bugzilla.
-#DRYRUN=yes
+echo ""
+echo ""
 
-if [ "x$DRYRUN" = xyes ]; then
-   for i in $urls
-   do
-   echo $i
-   done
-else
-   echo ""
+# extract fdo urls from commit log
+git log $* | grep 'bugs.freedesktop.org/show_bug' | sed -e $trim_before | sort 
-n -u | sed -e $use_after |\
+while read url
+do
+   id=$(echo $url | cut -d'=' -f2)
+   summary=$(wget --quiet -O - $url | grep -e '.*' | sed -e 
's/ *[0-9]\+  \(.*\)<\/title>/\1/')
+   echo "Bug $id - $summary"
echo ""
+done
 
-   for i in $urls
-   do
-   id=$(echo $i | cut -d'=' -f2)
-   summary=$(wget --quiet -O - $i | grep -e '.*' | 
sed -e 's/ *[0-9]\+  \(.*\)<\/title>/\1/')
-   echo "Bug $id - $summary"
-   echo ""
-   done
-
-   echo ""
-fi
+echo ""
-- 
2.11.0

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


[Mesa-dev] [PATCH 23/37] gallium/tools: do not hardcode bash location

2017-02-23 Thread Emil Velikov
It is not guaranteed to be in /bin

Signed-off-by: Emil Velikov 
---
 src/gallium/tools/addr2line.sh   | 2 +-
 src/gallium/tools/trace/tracediff.sh | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/gallium/tools/addr2line.sh b/src/gallium/tools/addr2line.sh
index 34dec14271..8d7b9cb9d9 100755
--- a/src/gallium/tools/addr2line.sh
+++ b/src/gallium/tools/addr2line.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
 # This script processes symbols output by Gallium using glibc to 
human-readable function names
 
 lastbin=
diff --git a/src/gallium/tools/trace/tracediff.sh 
b/src/gallium/tools/trace/tracediff.sh
index c7827c0ff1..dccb7a3d51 100755
--- a/src/gallium/tools/trace/tracediff.sh
+++ b/src/gallium/tools/trace/tracediff.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
 ##
 #
 # Copyright 2011 Jose Fonseca
-- 
2.11.0

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


[Mesa-dev] [PATCH 32/37] egl/egl-symbols-check: do not mandate bash

2017-02-23 Thread Emil Velikov
From: Emil Velikov 

There's nothing bash specific in the script.

Signed-off-by: Emil Velikov 
---
 src/egl/egl-symbols-check | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/egl/egl-symbols-check b/src/egl/egl-symbols-check
index 409867fab6..4c5232cb6c 100755
--- a/src/egl/egl-symbols-check
+++ b/src/egl/egl-symbols-check
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
 
 FUNCS=$(nm -D --defined-only ${1-.libs/libEGL.so} | grep -o "T .*" | cut -c 3- 
| while read func; do
 ( grep -q "^$func$" || echo $func )  

[Mesa-dev] [PATCH 29/37] util: remove shebang from format_srgb.py

2017-02-23 Thread Emil Velikov
From: Emil Velikov 

Analogous to earlier commit(s).

Signed-off-by: Emil Velikov 
---
 src/util/format_srgb.py | 1 -
 1 file changed, 1 deletion(-)

diff --git a/src/util/format_srgb.py b/src/util/format_srgb.py
index d5cbcf7646..44b35a061d 100644
--- a/src/util/format_srgb.py
+++ b/src/util/format_srgb.py
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
 
 CopyRight = '''
 /**
-- 
2.11.0

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


[Mesa-dev] [PATCH 31/37] glsl/tests: remove any bashisms

2017-02-23 Thread Emil Velikov
From: Emil Velikov 

Signed-off-by: Emil Velikov 
---
 src/compiler/glsl/tests/optimization-test.sh | 4 ++--
 src/compiler/glsl/tests/warnings-test.sh | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/compiler/glsl/tests/optimization-test.sh 
b/src/compiler/glsl/tests/optimization-test.sh
index 9cc3cae3a3..dc9740f69f 100755
--- a/src/compiler/glsl/tests/optimization-test.sh
+++ b/src/compiler/glsl/tests/optimization-test.sh
@@ -1,4 +1,4 @@
-#!/usr/bin/env bash
+#!/bin/sh
 
 if [ ! -z "$srcdir" ]; then
compare_ir=`pwd`/tests/compare_ir.py
@@ -35,7 +35,7 @@ echo ""
 echo "$pass/$total tests returned correct results"
 echo ""
 
-if [[ $pass == $total ]]; then
+if [ $pass = $total ]; then
 exit 0
 else
 exit 1
diff --git a/src/compiler/glsl/tests/warnings-test.sh 
b/src/compiler/glsl/tests/warnings-test.sh
index 1bea466539..6a52d4064f 100755
--- a/src/compiler/glsl/tests/warnings-test.sh
+++ b/src/compiler/glsl/tests/warnings-test.sh
@@ -1,4 +1,4 @@
-#!/usr/bin/env bash
+#!/bin/sh
 
 # Execute several shaders, and check that the InfoLog outcome is the expected.
 
@@ -24,7 +24,7 @@ echo ""
 echo "$pass/$total tests returned correct results"
 echo ""
 
-if [[ $pass == $total ]]; then
+if [ $pass = $total ]; then
 exit 0
 else
 exit 1
-- 
2.11.0

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


[Mesa-dev] [PATCH 26/37] nir: remove shebang from python scripts

2017-02-23 Thread Emil Velikov
From: Emil Velikov 

Analogous to earlier commit(s).

Signed-off-by: Emil Velikov 
---
 src/compiler/nir/nir_algebraic.py| 1 -
 src/compiler/nir/nir_builder_opcodes_h.py| 1 -
 src/compiler/nir/nir_constant_expressions.py | 1 -
 src/compiler/nir/nir_opcodes.py  | 1 -
 src/compiler/nir/nir_opcodes_c.py| 1 -
 src/compiler/nir/nir_opcodes_h.py| 1 -
 src/compiler/nir/nir_opt_algebraic.py| 1 -
 src/mapi/mapi_abi.py | 1 -
 8 files changed, 8 deletions(-)

diff --git a/src/compiler/nir/nir_algebraic.py 
b/src/compiler/nir/nir_algebraic.py
index 8c7fbc8194..d6784df004 100644
--- a/src/compiler/nir/nir_algebraic.py
+++ b/src/compiler/nir/nir_algebraic.py
@@ -1,4 +1,3 @@
-#! /usr/bin/env python
 #
 # Copyright (C) 2014 Intel Corporation
 #
diff --git a/src/compiler/nir/nir_builder_opcodes_h.py 
b/src/compiler/nir/nir_builder_opcodes_h.py
index 42eb6e0b09..bdabe578ce 100644
--- a/src/compiler/nir/nir_builder_opcodes_h.py
+++ b/src/compiler/nir/nir_builder_opcodes_h.py
@@ -1,4 +1,3 @@
-#! /usr/bin/env python
 
 template = """\
 /* Copyright (C) 2015 Broadcom
diff --git a/src/compiler/nir/nir_constant_expressions.py 
b/src/compiler/nir/nir_constant_expressions.py
index 273d6ce6a7..3da20fd503 100644
--- a/src/compiler/nir/nir_constant_expressions.py
+++ b/src/compiler/nir/nir_constant_expressions.py
@@ -1,4 +1,3 @@
-#! /usr/bin/python2
 
 def type_has_size(type_):
 return type_[-1:].isdigit()
diff --git a/src/compiler/nir/nir_opcodes.py b/src/compiler/nir/nir_opcodes.py
index b116fcffcc..8cad74832a 100644
--- a/src/compiler/nir/nir_opcodes.py
+++ b/src/compiler/nir/nir_opcodes.py
@@ -1,4 +1,3 @@
-#! /usr/bin/env python
 #
 # Copyright (C) 2014 Connor Abbott
 #
diff --git a/src/compiler/nir/nir_opcodes_c.py 
b/src/compiler/nir/nir_opcodes_c.py
index 7049c5be67..5f8bdc12a0 100644
--- a/src/compiler/nir/nir_opcodes_c.py
+++ b/src/compiler/nir/nir_opcodes_c.py
@@ -1,4 +1,3 @@
-#! /usr/bin/env python
 #
 # Copyright (C) 2014 Connor Abbott
 #
diff --git a/src/compiler/nir/nir_opcodes_h.py 
b/src/compiler/nir/nir_opcodes_h.py
index be15a96d23..c9538e4e95 100644
--- a/src/compiler/nir/nir_opcodes_h.py
+++ b/src/compiler/nir/nir_opcodes_h.py
@@ -1,4 +1,3 @@
-#! /usr/bin/env python
 
 template = """\
 /* Copyright (C) 2014 Connor Abbott
diff --git a/src/compiler/nir/nir_opt_algebraic.py 
b/src/compiler/nir/nir_opt_algebraic.py
index d3eaa1f1f2..f60c338b62 100644
--- a/src/compiler/nir/nir_opt_algebraic.py
+++ b/src/compiler/nir/nir_opt_algebraic.py
@@ -1,4 +1,3 @@
-#! /usr/bin/env python
 #
 # Copyright (C) 2014 Intel Corporation
 #
diff --git a/src/mapi/mapi_abi.py b/src/mapi/mapi_abi.py
index 012a5c3f44..2343182d11 100644
--- a/src/mapi/mapi_abi.py
+++ b/src/mapi/mapi_abi.py
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
 
 # Mesa 3-D graphics library
 #
-- 
2.11.0

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


[Mesa-dev] [PATCH 24/37] gallium/tools: use correct shebang for python scripts

2017-02-23 Thread Emil Velikov
From: Emil Velikov 

These are python2 scripts and the generic "python" may point to
python3.

Signed-off-by: Emil Velikov 
---
 src/gallium/tools/trace/diff_state.py | 2 +-
 src/gallium/tools/trace/dump.py   | 2 +-
 src/gallium/tools/trace/dump_state.py | 2 +-
 src/gallium/tools/trace/format.py | 2 +-
 src/gallium/tools/trace/model.py  | 2 +-
 src/gallium/tools/trace/parse.py  | 2 +-
 6 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/gallium/tools/trace/diff_state.py 
b/src/gallium/tools/trace/diff_state.py
index 00853bacbf..877dc388a8 100755
--- a/src/gallium/tools/trace/diff_state.py
+++ b/src/gallium/tools/trace/diff_state.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python2
 ##
 #
 # Copyright 2011 Jose Fonseca
diff --git a/src/gallium/tools/trace/dump.py b/src/gallium/tools/trace/dump.py
index 4a8ce863cf..10211c87c5 100755
--- a/src/gallium/tools/trace/dump.py
+++ b/src/gallium/tools/trace/dump.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python2
 ##
 # 
 # Copyright 2008 VMware, Inc.
diff --git a/src/gallium/tools/trace/dump_state.py 
b/src/gallium/tools/trace/dump_state.py
index e726f7b2ad..4531843279 100755
--- a/src/gallium/tools/trace/dump_state.py
+++ b/src/gallium/tools/trace/dump_state.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python2
 ##
 # 
 # Copyright 2008-2013, VMware, Inc.
diff --git a/src/gallium/tools/trace/format.py 
b/src/gallium/tools/trace/format.py
index e50f61299f..de6f402159 100755
--- a/src/gallium/tools/trace/format.py
+++ b/src/gallium/tools/trace/format.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python2
 ##
 #
 # Copyright 2008 VMware, Inc.
diff --git a/src/gallium/tools/trace/model.py b/src/gallium/tools/trace/model.py
index fb56701bf4..6a42184711 100755
--- a/src/gallium/tools/trace/model.py
+++ b/src/gallium/tools/trace/model.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python2
 ##
 # 
 # Copyright 2008 VMware, Inc.
diff --git a/src/gallium/tools/trace/parse.py b/src/gallium/tools/trace/parse.py
index 25482c8899..004b585f95 100755
--- a/src/gallium/tools/trace/parse.py
+++ b/src/gallium/tools/trace/parse.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python2
 ##
 # 
 # Copyright 2008 VMware, Inc.
-- 
2.11.0

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


[Mesa-dev] [PATCH 18/37] i965: remove shebang from brw_nir_trig_workarounds.py

2017-02-23 Thread Emil Velikov
From: Emil Velikov 

Analogous to earlier commit(s).

Signed-off-by: Emil Velikov 
---
 src/mesa/drivers/dri/i965/brw_nir_trig_workarounds.py | 1 -
 1 file changed, 1 deletion(-)

diff --git a/src/mesa/drivers/dri/i965/brw_nir_trig_workarounds.py 
b/src/mesa/drivers/dri/i965/brw_nir_trig_workarounds.py
index 3b8d0ce2b3..6a77d64dbd 100644
--- a/src/mesa/drivers/dri/i965/brw_nir_trig_workarounds.py
+++ b/src/mesa/drivers/dri/i965/brw_nir_trig_workarounds.py
@@ -1,4 +1,3 @@
-#! /usr/bin/env python
 #
 # Copyright (C) 2016 Intel Corporation
 #
-- 
2.11.0

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


[Mesa-dev] [PATCH 30/37] dri: use correct shebang for gen-symbol-redefs.py

2017-02-23 Thread Emil Velikov
From: Emil Velikov 

This is a python2 script and the generic "python" may point to python3.

Cc: Andreas Boll 
Signed-off-by: Emil Velikov 
---
We really want to prune/rename all the conflicting entrypoints.

In the radeon/r200 case we could even:
 - fold the common code to a simple place
 - drop the symlinks
 - get smaller binary size and 'compatibilty' with SVN
 - purge the script
 - ...
 - profit

Andreas, any interest in tackling this ? It will drop a couple of
extend-diff-ignore cases in the Debian packaging :-P
---
 src/mesa/drivers/dri/gen-symbol-redefs.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/mesa/drivers/dri/gen-symbol-redefs.py 
b/src/mesa/drivers/dri/gen-symbol-redefs.py
index ebe4aaa650..c1e443467e 100755
--- a/src/mesa/drivers/dri/gen-symbol-redefs.py
+++ b/src/mesa/drivers/dri/gen-symbol-redefs.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python2
 # -*- coding: utf-8 -*-
 
 # Copyright © 2013 Intel Corporation
-- 
2.11.0

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


[Mesa-dev] [PATCH 20/37] mapi: do not mandate bash for es*api/ABI-check

2017-02-23 Thread Emil Velikov
From: Emil Velikov 

Seemingly there is nothing bash specific in these. The Debian
checkbashisms does not spot neither run in zsh.

Signed-off-by: Emil Velikov 
---
 src/mapi/es1api/ABI-check | 2 +-
 src/mapi/es2api/ABI-check | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/mapi/es1api/ABI-check b/src/mapi/es1api/ABI-check
index 819568f6d1..223658b32e 100755
--- a/src/mapi/es1api/ABI-check
+++ b/src/mapi/es1api/ABI-check
@@ -1,4 +1,4 @@
-#!/usr/bin/env bash
+#!/bin/sh
 
 # Print defined gl.* functions not in GL ES 1.1 or in
 # (FIXME, none of these should be part of the ABI)
diff --git a/src/mapi/es2api/ABI-check b/src/mapi/es2api/ABI-check
index e338408c7e..11c95ced64 100755
--- a/src/mapi/es2api/ABI-check
+++ b/src/mapi/es2api/ABI-check
@@ -1,4 +1,4 @@
-#!/usr/bin/env bash
+#!/bin/sh
 
 # Print defined gl.* functions not in GL ES 3.0 or in
 # (FIXME, none of these should be part of the ABI)
-- 
2.11.0

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


[Mesa-dev] [PATCH 15/37] mesa: remove execute bit from main/format_parser.py

2017-02-23 Thread Emil Velikov
From: Emil Velikov 

Analogous to earlier commit(s).

Signed-off-by: Emil Velikov 
---
 src/mesa/main/format_parser.py | 0
 1 file changed, 0 insertions(+), 0 deletions(-)
 mode change 100755 => 100644 src/mesa/main/format_parser.py

diff --git a/src/mesa/main/format_parser.py b/src/mesa/main/format_parser.py
old mode 100755
new mode 100644
-- 
2.11.0

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


[Mesa-dev] [PATCH 27/37] genxml: remove shebang from gen_pack_header.py

2017-02-23 Thread Emil Velikov
From: Emil Velikov 

Analogous to earlier commit(s).

Signed-off-by: Emil Velikov 
---
 src/intel/genxml/gen_pack_header.py | 1 -
 1 file changed, 1 deletion(-)

diff --git a/src/intel/genxml/gen_pack_header.py 
b/src/intel/genxml/gen_pack_header.py
index 1024745bfb..a1befaf45e 100644
--- a/src/intel/genxml/gen_pack_header.py
+++ b/src/intel/genxml/gen_pack_header.py
@@ -1,4 +1,3 @@
-#!/usr/bin/env python2
 #encoding=utf-8
 
 from __future__ import (
-- 
2.11.0

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


[Mesa-dev] [PATCH 14/37] amd: remove shebang from python scripts

2017-02-23 Thread Emil Velikov
From: Emil Velikov 

Analogous to earlier commit(s).

Signed-off-by: Emil Velikov 
---
 src/amd/common/sid_tables.py  | 1 -
 src/amd/vulkan/vk_format_parse.py | 1 -
 src/amd/vulkan/vk_format_table.py | 1 -
 3 files changed, 3 deletions(-)

diff --git a/src/amd/common/sid_tables.py b/src/amd/common/sid_tables.py
index 7ba021544b..df2d7ec5b0 100644
--- a/src/amd/common/sid_tables.py
+++ b/src/amd/common/sid_tables.py
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
 
 CopyRight = '''
 /*
diff --git a/src/amd/vulkan/vk_format_parse.py 
b/src/amd/vulkan/vk_format_parse.py
index b743fc2bdb..00cf1adf5a 100644
--- a/src/amd/vulkan/vk_format_parse.py
+++ b/src/amd/vulkan/vk_format_parse.py
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
 
 '''
 /**
diff --git a/src/amd/vulkan/vk_format_table.py 
b/src/amd/vulkan/vk_format_table.py
index 06b98e568b..36352b108d 100644
--- a/src/amd/vulkan/vk_format_table.py
+++ b/src/amd/vulkan/vk_format_table.py
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
 
 CopyRight = '''
 /**
-- 
2.11.0

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


[Mesa-dev] [PATCH 28/37] xmlpool: remove shebang from gen_xmlpool.py

2017-02-23 Thread Emil Velikov
From: Emil Velikov 

Analogous to earlier commit(s).

Signed-off-by: Emil Velikov 
---
 src/mesa/drivers/dri/common/xmlpool/gen_xmlpool.py | 1 -
 1 file changed, 1 deletion(-)

diff --git a/src/mesa/drivers/dri/common/xmlpool/gen_xmlpool.py 
b/src/mesa/drivers/dri/common/xmlpool/gen_xmlpool.py
index acfdcf48a1..eb68a65174 100644
--- a/src/mesa/drivers/dri/common/xmlpool/gen_xmlpool.py
+++ b/src/mesa/drivers/dri/common/xmlpool/gen_xmlpool.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
 
 #
 # Usage:
-- 
2.11.0

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


[Mesa-dev] [PATCH 16/37] mesa: remove shebang from python scripts

2017-02-23 Thread Emil Velikov
From: Emil Velikov 

Analogous to earlier commit(s).

Signed-off-by: Emil Velikov 
---
 src/mesa/main/format_info.py| 1 -
 src/mesa/main/format_pack.py| 1 -
 src/mesa/main/format_parser.py  | 1 -
 src/mesa/main/format_unpack.py  | 1 -
 src/mesa/main/get_hash_generator.py | 1 -
 5 files changed, 5 deletions(-)

diff --git a/src/mesa/main/format_info.py b/src/mesa/main/format_info.py
index 729edbb324..780dc0bec7 100644
--- a/src/mesa/main/format_info.py
+++ b/src/mesa/main/format_info.py
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
 #
 # Copyright 2014 Intel Corporation
 #
diff --git a/src/mesa/main/format_pack.py b/src/mesa/main/format_pack.py
index 6f2b37368d..71c467f7e9 100644
--- a/src/mesa/main/format_pack.py
+++ b/src/mesa/main/format_pack.py
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
 
 from mako.template import Template
 from sys import argv
diff --git a/src/mesa/main/format_parser.py b/src/mesa/main/format_parser.py
index 6cd2fbca0e..4c36c3cee2 100644
--- a/src/mesa/main/format_parser.py
+++ b/src/mesa/main/format_parser.py
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
 #
 # Copyright 2009 VMware, Inc.
 # Copyright 2014 Intel Corporation
diff --git a/src/mesa/main/format_unpack.py b/src/mesa/main/format_unpack.py
index b7fc4c3fc8..c8b1b24d16 100644
--- a/src/mesa/main/format_unpack.py
+++ b/src/mesa/main/format_unpack.py
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
 
 from mako.template import Template
 from sys import argv
diff --git a/src/mesa/main/get_hash_generator.py 
b/src/mesa/main/get_hash_generator.py
index d7460c8e4e..ddd498fee4 100644
--- a/src/mesa/main/get_hash_generator.py
+++ b/src/mesa/main/get_hash_generator.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python2
 # coding=utf-8
 # -*- Mode: Python; py-indent-offset: 4 -*-
 #
-- 
2.11.0

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


  1   2   >