Re: [Mesa-dev] [PATCH] anv: correct a duplicate check in an assert

2018-01-23 Thread Tapani Pälli

Reviewed-by: Tapani Pälli 

On 23.01.2018 00:57, Grazvydas Ignotas wrote:

Looks like checking both sources was intended, instead of the first one
twice. Found with Coccinelle, coccinellery/xand/xand.cocci semantic patch.

Signed-off-by: Grazvydas Ignotas 
---
  src/intel/vulkan/anv_nir_apply_pipeline_layout.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/intel/vulkan/anv_nir_apply_pipeline_layout.c 
b/src/intel/vulkan/anv_nir_apply_pipeline_layout.c
index 978a8a5..6775f9b 100644
--- a/src/intel/vulkan/anv_nir_apply_pipeline_layout.c
+++ b/src/intel/vulkan/anv_nir_apply_pipeline_layout.c
@@ -145,11 +145,11 @@ lower_res_reindex_intrinsic(nir_intrinsic_instr *intrin,
  
 /* For us, the resource indices are just indices into the binding table and

  * array elements are sequential.  A resource_reindex just turns into an
  * add of the two indices.
  */
-   assert(intrin->src[0].is_ssa && intrin->src[0].is_ssa);
+   assert(intrin->src[0].is_ssa && intrin->src[1].is_ssa);
 nir_ssa_def *new_index = nir_iadd(b, intrin->src[0].ssa,
  intrin->src[1].ssa);
  
 assert(intrin->dest.is_ssa);

 nir_ssa_def_rewrite_uses(&intrin->dest.ssa, nir_src_for_ssa(new_index));


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


Re: [Mesa-dev] [PATCH 2/7] egl: add support for EGL_ANDROID_blob_cache

2018-01-23 Thread Tapani Pälli



On 01/22/2018 04:05 PM, Emil Velikov wrote:

On 19 January 2018 at 06:53, Tapani Pälli  wrote:



On 01/18/2018 04:55 PM, Emil Velikov wrote:


On 17 January 2018 at 16:11, Tapani Pälli  wrote:




On 17.01.2018 13:28, Nicolai Hähnle wrote:



On 16.01.2018 18:45, Emil Velikov wrote:



Hi Tapani,

On 15 January 2018 at 12:31, Tapani Pälli 
wrote:


+static void
+update_blob_cache_functions(struct dri2_egl_display *dri2_dpy,
+struct dri2_egl_context *dri2_ctx)
+{
+   if (!dri2_dpy || !dri2_ctx)
+  return;



AFAICT dri2_dpy can never be NULL.


+
+   /* No blob support. */
+   if (!dri2_dpy->blob)
+  return;
+
+   /* No functions to set. */
+   if (!dri2_dpy->blob_cache_set)
+  return;
+
+   dri2_dpy->blob->set_cache_funcs(dri2_ctx->dri_context,
+   dri2_dpy->blob_cache_set,
+   dri2_dpy->blob_cache_get);
+}
+



I'm wondering why you opted to make set_cache_funcs dri_context
specific as opposed to dri_screen.
The latter seems to align better to EGLDisplay.

Plus doing so will simplify the existing code - no hunk in
dri2_make_current, no dri2_dpy->blob/blob_cache_set checks, etc.




Yes, please make it a screen thing. It just makes more sense, and
there's
precedent in Gallium, where the disk-cache is a per-pipe_screen object
as
well.




I chose context because eventually I need to access disk_cache which is
part
of gl_context. I'm not sure how would I propagate the set/get there from
dri_screen?


Gallium does the following during create_context. I'm not sure if
there's any particular reason why i965 cannot do the same.
Tim, you've worked a fair bit in the area do you see any drawbacks?

ctx->Cache = pipe->screen->det_dist_shader_cache(pipe->screen);



One problem is that client might set the callbacks only after context
creation so we need to be able to do this during set_cache_funcs(). Now it
works fine because we pass context there.


I don't see why that would be an issue. Both ctx::cache and
screen::cache are pointer to a single instance.
Hence, as we deref. screen::cache and update the callbacks, everything
will be fine from ctx POV - no need to update for each make_current
call/etc.

Am I having a dull moment here?


I was confused since that is not how it works with i965. We create cache 
during context creation and store it in context (gl_context::Cache). 
This happens for each context and they get a unique disk_cache pointer.


I understand your proposal would be to move Cache to screen structure 
and utilize this same disk_cache instance from each context. I guess it 
should be possible and could be done separately before blob cache 
implementation.


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


Re: [Mesa-dev] [PATCH v3 3/3] anv: implement VK_EXT_global_priority extension

2018-01-22 Thread Tapani Pälli



On 01/22/2018 09:01 PM, Jason Ekstrand wrote:
On Mon, Jan 22, 2018 at 4:29 AM, Tapani Pälli <mailto:tapani.pa...@intel.com>> wrote:


v2: add ANV_CONTEXT_REALTIME_PRIORITY (Chris)
     use unreachable with unknown priority (Samuel)

v3: add stubs in gem_stubs.c (Emil)
     use priority defines from gen_defines.h

Signed-off-by: Tapani Pälli mailto:tapani.pa...@intel.com>>
Reviewed-by: Samuel Iglesias Gonsálvez mailto:sigles...@igalia.com>> (v2)
Reviewed-by: Chris Wilson mailto:ch...@chris-wilson.co.uk>> (v2)
---
  src/intel/vulkan/anv_device.c      | 25 +++
  src/intel/vulkan/anv_extensions.py |  2 ++
  src/intel/vulkan/anv_gem.c         | 51
++
  src/intel/vulkan/anv_gem_stubs.c   | 10 
  src/intel/vulkan/anv_private.h     |  3 +++
  5 files changed, 91 insertions(+)

diff --git a/src/intel/vulkan/anv_device.c
b/src/intel/vulkan/anv_device.c
index 777abd8757..42ebc19f2b 100644
--- a/src/intel/vulkan/anv_device.c
+++ b/src/intel/vulkan/anv_device.c
@@ -369,6 +369,9 @@ anv_physical_device_init(struct
anv_physical_device *device,
     device->has_syncobj_wait = device->has_syncobj &&
                                anv_gem_supports_syncobj_wait(fd);

+   if (anv_gem_has_context_priority(fd))
+      device->has_context_priority = true;
+
     bool swizzled = anv_gem_get_bit6_swizzle(fd, I915_TILING_X);

     /* Starting with Gen10, the timestamp frequency of the command
streamer may
@@ -1205,6 +1208,15 @@ VkResult anv_CreateDevice(
        }
     }

+   /* Check if client specified queue priority. */
+   const VkDeviceQueueGlobalPriorityCreateInfoEXT *queue_priority =
+      vk_find_struct_const(pCreateInfo->pQueueCreateInfos[0].pNext,
+ 
  DEVICE_QUEUE_GLOBAL_PRIORITY_CREATE_INFO_EXT);

+
+   VkQueueGlobalPriorityEXT priority =
+      queue_priority ? queue_priority->globalPriority :
+         VK_QUEUE_GLOBAL_PRIORITY_MEDIUM_EXT;
+
     device = vk_alloc2(&physical_device->instance->alloc, pAllocator,
                         sizeof(*device), 8,
                         VK_SYSTEM_ALLOCATION_SCOPE_DEVICE);
@@ -1234,6 +1246,19 @@ VkResult anv_CreateDevice(
        goto fail_fd;
     }

+   /* As per spec, the driver implementation may deny requests to
acquire
+    * a priority above the default priority (MEDIUM) if the caller
does not
+    * have sufficient privileges. In this scenario
VK_ERROR_NOT_PERMITTED_EXT
+    * is returned.
+    */
+   if (physical_device->has_context_priority) {
+      int err = anv_gem_set_context_priority(device, priority);
+      if (err != 0 && priority > VK_QUEUE_GLOBAL_PRIORITY_MEDIUM_EXT) {
+         result = vk_error(VK_ERROR_NOT_PERMITTED_EXT);
+         goto fail_fd;
+      }
+   }
+
     device->info = physical_device->info;
     device->isl_dev = physical_device->isl_dev;

diff --git a/src/intel/vulkan/anv_extensions.py
b/src/intel/vulkan/anv_extensions.py
index adfebca985..aacf39248f 100644
--- a/src/intel/vulkan/anv_extensions.py
+++ b/src/intel/vulkan/anv_extensions.py
@@ -86,6 +86,8 @@ EXTENSIONS = [
      Extension('VK_KHX_multiview',                         1, True),
      Extension('VK_EXT_debug_report',                      8, True),
      Extension('VK_EXT_external_memory_dma_buf',           1, True),
+    Extension('VK_EXT_global_priority',                   1,
+              'device->has_context_priority'),
  ]

  class VkVersion:
diff --git a/src/intel/vulkan/anv_gem.c b/src/intel/vulkan/anv_gem.c
index 34c0989108..7f83820429 100644
--- a/src/intel/vulkan/anv_gem.c
+++ b/src/intel/vulkan/anv_gem.c
@@ -30,6 +30,7 @@
  #include 

  #include "anv_private.h"
+#include "common/gen_defines.h"

  static int
  anv_ioctl(int fd, unsigned long request, void *arg)
@@ -302,6 +303,56 @@ close_and_return:
     return swizzled;
  }

+static int
+vk_priority_to_anv(int priority)
+{
+   switch (priority) {
+   case VK_QUEUE_GLOBAL_PRIORITY_LOW_EXT:
+      return GEN_CONTEXT_LOW_PRIORITY;
+   case VK_QUEUE_GLOBAL_PRIORITY_MEDIUM_EXT:
+      return GEN_CONTEXT_MEDIUM_PRIORITY;
+   case VK_QUEUE_GLOBAL_PRIORITY_HIGH_EXT:
+      return GEN_CONTEXT_HIGH_PRIORITY;
+   case VK_QUEUE_GLOBAL_PRIORITY_REALTIME_EXT:
+      return GEN_CONTEXT_REALTIME_PRIORITY;
+   default:
+      unreachable("Invalid priority");
+   }
+}


I think I'd rather have the conversion in anv_device.c and just make the 
anv_g

Re: [Mesa-dev] [PATCH 0/7] EGL_ANDROID_blob_cache

2018-01-22 Thread Tapani Pälli



On 22.01.2018 15:16, Nicolai Hähnle wrote:

On 19.01.2018 07:05, Tapani Pälli wrote:



On 01/18/2018 05:49 PM, Nicolai Hähnle wrote:

On 17.01.2018 17:10, Tapani Pälli wrote:



On 17.01.2018 13:34, Nicolai Hähnle wrote:

On 15.01.2018 13:31, Tapani Pälli wrote:

Hello;

Here's a refactored series of EGL_ANDROID_blob_cache. Now cache
functions are stored in disk_cache struct and the functionality
called within existing disk_cache put/get code. Problems/errors
that existed with earlier series are gone.

On Android cache index file is created to MESA_GLSL_CACHE_DIR
and blobs are  generated under '/data/user_de/0' in application
specific paths:


Can't we let the "cache index" be managed by the ANDROID_blob_cache 
as well? That seems to me more in the spirit of what that extension 
is about, and would avoid polluting stuff like /sdcard.


The cache index file is used for two purposes:

- Keeping track of the size of the cache. This use is obsoleted 
enterely by ANDROID_blob_cache.


- Keeping track of keys where only their presence is relevant and 
no data is associated. These could easily be treated as empty (0 
byte sized) blobs.


I guess it could be possible, for every app we would create index 
when disk_cache gets created. I guess only issue could be that 
Android might go and remove the index from cache when it decides to 
resize it and then we would loose it even though there would be 
items in cache. I can try how this would work.


Entries can be kicked out of the on-disk index (which is really a bit 
of a misnomer) as well if there's a hash collision.


I believe this functionality is only used as a marker to indicate 
that the GLSL compile step can be skipped. So losing an entry in 
there shouldn't cause any damage.


What I meant is that if we would store index by using set() function, 
the index itself would be just another entry for Android's cache, it 
can decide to remove it when it manages cache size.


Not sure if we're talking about the same thing, then? What I meant was 
that every call to disk_cache_put_key becomes a call to the 
Android-provided set() function, and every call to disk_cache_has_key 
becomes a call to the get() function.


Sorry for the confusion, this is how I implemented it now for the 
current new set I sent.


Although storing the index itself in the blob cache is also an 
interesting idea.


Cheers,
Nicolai





Cheers,
Nicolai






Cheers,
Nicolai





androidia_64:/ # find /data/user_de/0/ -name *shader*
/data/user_de/0/com.android.settings/code_cache/com.android.opengl.shaders_cache 

/data/user_de/0/com.android.gallery3d/code_cache/com.android.opengl.shaders_cache 

/data/user_de/0/com.android.systemui/code_cache/com.android.opengl.shaders_cache 

/data/user_de/0/com.rovio.angrybirdsspace.ads/code_cache/com.android.opengl.shaders_cache 



(this part is managed by Android but may be interesting to know).

Also SurfaceFlinger manages its own cache as seen in the log output:
01-15 07:40:26.329  2129  2129 D SurfaceFlinger: shader cache 
generated - 24 shaders in 57.687504 ms


I'm not sure if /sdcard is sane default but I've tried everything
else (/cache, /data/cache) and failed because of permission errors.

Thanks;

Tapani Pälli (7):
   dri: add interface for EGL_ANDROID_blob_cache extension
   egl: add support for EGL_ANDROID_blob_cache
   disk cache: add callback functionality
   disk cache: support setting MESA_GLSL_CACHE_DIR at compile time
   i965: add __DRI2_BLOB support and set cache functions
   android: ignore MESA_GLSL_CACHE_DISABLE setting
   android: set '/sdcard/' as MESA_GLSL_CACHE_DIR by default

  Android.common.mk  |  1 +
  include/GL/internal/dri_interface.h    | 26 +-
  src/egl/drivers/dri2/egl_dri2.c    | 43 


  src/egl/drivers/dri2/egl_dri2.h    |  4 +++
  src/egl/main/eglapi.c  | 29 
  src/egl/main/eglapi.h  |  4 +++
  src/egl/main/egldisplay.h  |  3 ++
  src/egl/main/eglentrypoint.h   |  1 +
  src/mesa/drivers/dri/i965/brw_disk_cache.c |  2 ++
  src/mesa/drivers/dri/i965/intel_screen.c   | 21 
  src/util/disk_cache.c  | 54 
+-

  src/util/disk_cache.h  | 19 +++
  12 files changed, 205 insertions(+), 2 deletions(-)











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


Re: [Mesa-dev] [PATCH 1/3] intel: add new common header gen_defines.h

2018-01-22 Thread Tapani Pälli



On 22.01.2018 17:10, Emil Velikov wrote:

On 22 January 2018 at 12:29, Tapani Pälli  wrote:

Signed-off-by: Tapani Pälli 
---
  src/intel/common/gen_defines.h | 52 ++
  1 file changed, 52 insertions(+)
  create mode 100644 src/intel/common/gen_defines.h


Please add the file to the src/intel/Makefile.sources COMMON_FILES list.


ok




diff --git a/src/intel/common/gen_defines.h b/src/intel/common/gen_defines.h
new file mode 100644
index 00..f8daa84431
--- /dev/null
+++ b/src/intel/common/gen_defines.h
@@ -0,0 +1,52 @@
+/*
+ * Copyright © 2018 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 COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef GEN_DEFINES_H
+#define GEN_DEFINES_H
+

#include "i915_drm.h"

^^ is where the I915_CONTEXT*PRIORITY symbols are defined, so let's
include that.


Will do, thanks Emil!


With the two nitpicks, the series is:
Reviewed-by: Emil Velikov 

-Emil



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


[Mesa-dev] [PATCH v2 4/5] disk cache: add callback functionality

2018-01-22 Thread Tapani Pälli
v2: add disk_cache_has_key, disk_cache_put_key support
using blob cache (Nicolai, Jordan)

Signed-off-by: Tapani Pälli 
---
 src/util/disk_cache.c | 49 +
 src/util/disk_cache.h | 19 +++
 2 files changed, 68 insertions(+)

diff --git a/src/util/disk_cache.c b/src/util/disk_cache.c
index 2fb07699b5..ba98f3bba5 100644
--- a/src/util/disk_cache.c
+++ b/src/util/disk_cache.c
@@ -101,6 +101,9 @@ struct disk_cache {
/* Driver cache keys. */
uint8_t *driver_keys_blob;
size_t driver_keys_blob_size;
+
+   disk_cache_set_cb blob_set_cb;
+   disk_cache_get_cb blob_get_cb;
 };
 
 struct disk_cache_put_job {
@@ -1020,6 +1023,11 @@ disk_cache_put(struct disk_cache *cache, const cache_key 
key,
const void *data, size_t size,
struct cache_item_metadata *cache_item_metadata)
 {
+   if (cache->blob_set_cb) {
+  cache->blob_set_cb(key, CACHE_KEY_SIZE, data, size);
+  return;
+   }
+
struct disk_cache_put_job *dc_job =
   create_put_job(cache, key, data, size, cache_item_metadata);
 
@@ -1082,6 +1090,29 @@ disk_cache_get(struct disk_cache *cache, const cache_key 
key, size_t *size)
if (size)
   *size = 0;
 
+   if (cache->blob_get_cb) {
+/* This is what Android EGL defines as the maxValueSize in egl_cache_t
+ * class implementation.
+ */
+#define MAX_BLOB_SIZE 64 * 1024
+  void *blob = malloc(MAX_BLOB_SIZE);
+  if (!blob)
+ return NULL;
+
+  signed long bytes =
+ cache->blob_get_cb(key, CACHE_KEY_SIZE, blob, MAX_BLOB_SIZE);
+
+  if (!bytes) {
+ free(blob);
+ return NULL;
+  }
+
+  if (size)
+ *size = bytes;
+  return blob;
+#undef MAX_BLOB_SIZE
+   }
+
filename = get_cache_file(cache, key);
if (filename == NULL)
   goto fail;
@@ -1197,6 +1228,11 @@ disk_cache_put_key(struct disk_cache *cache, const 
cache_key key)
int i = CPU_TO_LE32(*key_chunk) & CACHE_INDEX_KEY_MASK;
unsigned char *entry;
 
+   if (cache->blob_set_cb) {
+  cache->blob_set_cb(key, CACHE_KEY_SIZE, key_chunk, sizeof(uint32_t));
+  return;
+   }
+
if (!cache->path)
   return;
 
@@ -1219,6 +1255,11 @@ disk_cache_has_key(struct disk_cache *cache, const 
cache_key key)
int i = CPU_TO_LE32(*key_chunk) & CACHE_INDEX_KEY_MASK;
unsigned char *entry;
 
+   if (cache->blob_get_cb) {
+  uint32_t blob;
+  return cache->blob_get_cb(key, CACHE_KEY_SIZE, &blob, sizeof(uint32_t));
+   }
+
/* Try initializing path only once. */
if (cache->path_init_failed ||
(!cache->path && !disk_cache_path_init(cache)))
@@ -1242,4 +1283,12 @@ disk_cache_compute_key(struct disk_cache *cache, const 
void *data, size_t size,
_mesa_sha1_final(&ctx, key);
 }
 
+void
+disk_cache_set_callbacks(struct disk_cache *cache, disk_cache_set_cb set,
+ disk_cache_get_cb get)
+{
+   cache->blob_set_cb = set;
+   cache->blob_get_cb = get;
+}
+
 #endif /* ENABLE_SHADER_CACHE */
diff --git a/src/util/disk_cache.h b/src/util/disk_cache.h
index 488b297ead..3fae8a1358 100644
--- a/src/util/disk_cache.h
+++ b/src/util/disk_cache.h
@@ -50,6 +50,14 @@ typedef uint8_t cache_key[CACHE_KEY_SIZE];
 #define CACHE_ITEM_TYPE_UNKNOWN  0x0
 #define CACHE_ITEM_TYPE_GLSL 0x1
 
+typedef void
+(*disk_cache_set_cb) (const void *key, signed long keySize,
+  const void *value, signed long valueSize);
+
+typedef signed long
+(*disk_cache_get_cb) (const void *key, signed long keySize,
+  void *value, signed long valueSize);
+
 struct cache_item_metadata {
/**
 * The cache item type. This could be used to identify a GLSL cache item,
@@ -207,6 +215,10 @@ void
 disk_cache_compute_key(struct disk_cache *cache, const void *data, size_t size,
cache_key key);
 
+void
+disk_cache_set_callbacks(struct disk_cache *cache, disk_cache_set_cb set,
+ disk_cache_get_cb get);
+
 #else
 
 static inline struct disk_cache *
@@ -260,6 +272,13 @@ disk_cache_compute_key(struct disk_cache *cache, const 
void *data, size_t size,
return;
 }
 
+static inline void
+disk_cache_set_callbacks(struct disk_cache *cache, disk_cache_set_cb set,
+ disk_cache_get_cb get)
+{
+   return;
+}
+
 #endif /* ENABLE_SHADER_CACHE */
 
 #ifdef __cplusplus
-- 
2.14.3

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


[Mesa-dev] [PATCH 5/5] i965: add __DRI2_BLOB support and set cache functions

2018-01-22 Thread Tapani Pälli
Signed-off-by: Tapani Pälli 
---
 src/mesa/drivers/dri/i965/intel_screen.c | 21 +
 1 file changed, 21 insertions(+)

diff --git a/src/mesa/drivers/dri/i965/intel_screen.c 
b/src/mesa/drivers/dri/i965/intel_screen.c
index a4e34e9f2c..84009382c6 100644
--- a/src/mesa/drivers/dri/i965/intel_screen.c
+++ b/src/mesa/drivers/dri/i965/intel_screen.c
@@ -36,6 +36,7 @@
 #include "main/version.h"
 #include "swrast/s_renderbuffer.h"
 #include "util/ralloc.h"
+#include "util/disk_cache.h"
 #include "brw_defines.h"
 #include "brw_state.h"
 #include "compiler/nir/nir.h"
@@ -1493,6 +1494,19 @@ brw_query_renderer_string(__DRIscreen *dri_screen,
return -1;
 }
 
+static void
+brw_set_cache_funcs(__DRIcontext *dri_ctx,
+__DRIblobCacheSet set, __DRIblobCacheGet get)
+{
+   struct brw_context *brw = dri_ctx->driverPrivate;
+   struct gl_context *ctx = &brw->ctx;
+
+   if (!ctx->Cache)
+  return;
+
+   disk_cache_set_callbacks(ctx->Cache, set, get);
+}
+
 static const __DRI2rendererQueryExtension intelRendererQueryExtension = {
.base = { __DRI2_RENDERER_QUERY, 1 },
 
@@ -1504,6 +1518,11 @@ static const __DRIrobustnessExtension dri2Robustness = {
.base = { __DRI2_ROBUSTNESS, 1 }
 };
 
+static const __DRI2blobExtension intelBlobExtension = {
+   .base = { __DRI2_BLOB, 1 },
+   .set_cache_funcs = brw_set_cache_funcs
+};
+
 static const __DRIextension *screenExtensions[] = {
 &intelTexBufferExtension.base,
 &intelFenceExtension.base,
@@ -1512,6 +1531,7 @@ static const __DRIextension *screenExtensions[] = {
 &intelRendererQueryExtension.base,
 &dri2ConfigQueryExtension.base,
 &dri2NoErrorExtension.base,
+&intelBlobExtension.base,
 NULL
 };
 
@@ -1524,6 +1544,7 @@ static const __DRIextension 
*intelRobustScreenExtensions[] = {
 &dri2ConfigQueryExtension.base,
 &dri2Robustness.base,
 &dri2NoErrorExtension.base,
+&intelBlobExtension.base,
 NULL
 };
 
-- 
2.14.3

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


[Mesa-dev] [PATCH 3/5] disk cache: initialize cache path and index only when used

2018-01-22 Thread Tapani Pälli
This patch makes disk_cache initialize path and index lazily so
that we can utilize disk_cache without a path using callback
functionality introduced by next patch.

Signed-off-by: Tapani Pälli 
---
 src/util/disk_cache.c | 114 --
 1 file changed, 73 insertions(+), 41 deletions(-)

diff --git a/src/util/disk_cache.c b/src/util/disk_cache.c
index 2884d3c9c1..2fb07699b5 100644
--- a/src/util/disk_cache.c
+++ b/src/util/disk_cache.c
@@ -77,6 +77,7 @@
 struct disk_cache {
/* The path to the cache directory. */
char *path;
+   bool path_init_failed;
 
/* Thread queue for compressing and writing cache entries to disk */
struct util_queue cache_queue;
@@ -178,27 +179,18 @@ concatenate_and_mkdir(void *ctx, const char *path, const 
char *name)
   return NULL;
 }
 
-#define DRV_KEY_CPY(_dst, _src, _src_size) \
-do {   \
-   memcpy(_dst, _src, _src_size);  \
-   _dst += _src_size;  \
-} while (0);
-
-struct disk_cache *
-disk_cache_create(const char *gpu_name, const char *timestamp,
-  uint64_t driver_flags)
+static bool
+disk_cache_path_init(struct disk_cache *cache)
 {
-   void *local;
-   struct disk_cache *cache = NULL;
-   char *path, *max_size_str;
-   uint64_t max_size;
+   void *local = NULL;
+   char *path;
int fd = -1;
struct stat sb;
size_t size;
 
/* If running as a users other than the real user disable cache */
if (geteuid() != getuid())
-  return NULL;
+  goto fail;
 
/* A ralloc context for transient data during this invocation. */
local = ralloc_context(NULL);
@@ -273,10 +265,6 @@ disk_cache_create(const char *gpu_name, const char 
*timestamp,
  goto fail;
}
 
-   cache = ralloc(NULL, struct disk_cache);
-   if (cache == NULL)
-  goto fail;
-
cache->path = ralloc_strdup(cache, path);
if (cache->path == NULL)
   goto fail;
@@ -325,6 +313,58 @@ disk_cache_create(const char *gpu_name, const char 
*timestamp,
cache->size = (uint64_t *) cache->index_mmap;
cache->stored_keys = cache->index_mmap + sizeof(uint64_t);
 
+   /* 1 thread was chosen because we don't really care about getting things
+* to disk quickly just that it's not blocking other tasks.
+*
+* The queue will resize automatically when it's full, so adding new jobs
+* doesn't stall.
+*/
+   util_queue_init(&cache->cache_queue, "disk_cache", 32, 1,
+   UTIL_QUEUE_INIT_RESIZE_IF_FULL |
+   UTIL_QUEUE_INIT_USE_MINIMUM_PRIORITY);
+
+   ralloc_free(local);
+
+   return true;
+
+ fail:
+   if (fd != -1)
+  close(fd);
+
+   if (local)
+  ralloc_free(local);
+
+   cache->path_init_failed = true;
+
+   return false;
+}
+
+#define DRV_KEY_CPY(_dst, _src, _src_size) \
+do {   \
+   memcpy(_dst, _src, _src_size);  \
+   _dst += _src_size;  \
+} while (0);
+
+struct disk_cache *
+disk_cache_create(const char *gpu_name, const char *timestamp,
+  uint64_t driver_flags)
+{
+   struct disk_cache *cache = NULL;
+   char *max_size_str;
+   uint64_t max_size;
+
+   /* If running as a users other than the real user disable cache */
+   if (geteuid() != getuid())
+  return NULL;
+
+   /* At user request, disable shader cache entirely. */
+   if (env_var_as_boolean("MESA_GLSL_CACHE_DISABLE", false))
+  return NULL;
+
+   cache = rzalloc(NULL, struct disk_cache);
+   if (cache == NULL)
+  return NULL;
+
max_size = 0;
 
max_size_str = getenv("MESA_GLSL_CACHE_MAX_SIZE");
@@ -360,16 +400,6 @@ disk_cache_create(const char *gpu_name, const char 
*timestamp,
 
cache->max_size = max_size;
 
-   /* 1 thread was chosen because we don't really care about getting things
-* to disk quickly just that it's not blocking other tasks.
-*
-* The queue will resize automatically when it's full, so adding new jobs
-* doesn't stall.
-*/
-   util_queue_init(&cache->cache_queue, "disk_cache", 32, 1,
-   UTIL_QUEUE_INIT_RESIZE_IF_FULL |
-   UTIL_QUEUE_INIT_USE_MINIMUM_PRIORITY);
-
uint8_t cache_version = CACHE_VERSION;
size_t cv_size = sizeof(cache_version);
cache->driver_keys_blob_size = cv_size;
@@ -392,8 +422,10 @@ disk_cache_create(const char *gpu_name, const char 
*timestamp,
 
cache->driver_keys_blob =
   ralloc_size(cache, cache->driver_keys_blob_size);
-   if (!cache->driver_keys_blob)
-  goto fail;
+   if (!cache->driver_keys_blob) {
+  ralloc_free(cache);
+  return NULL;
+   }
 
uint8_t *drv_key_blob = cache->driver_keys_blob;
DRV_KEY_CPY(drv_key_blob, &cache_version, cv_size)
@@ -405,18 +437,7 @@ disk_cache_create(const char *gpu_name, const char 
*timestamp,
/* Seed our ra

[Mesa-dev] [PATCH 1/5] dri: add interface for EGL_ANDROID_blob_cache extension

2018-01-22 Thread Tapani Pälli
Signed-off-by: Tapani Pälli 
---
 include/GL/internal/dri_interface.h | 26 +-
 1 file changed, 25 insertions(+), 1 deletion(-)

diff --git a/include/GL/internal/dri_interface.h 
b/include/GL/internal/dri_interface.h
index 34a5c9fb01..de367d8f77 100644
--- a/include/GL/internal/dri_interface.h
+++ b/include/GL/internal/dri_interface.h
@@ -82,7 +82,7 @@ typedef struct __DRI2flushExtensionRec
__DRI2flushExtension;
 typedef struct __DRI2throttleExtensionRec  __DRI2throttleExtension;
 typedef struct __DRI2fenceExtensionRec  __DRI2fenceExtension;
 typedef struct __DRI2interopExtensionRec   __DRI2interopExtension;
-
+typedef struct __DRI2blobExtensionRec   __DRI2blobExtension;
 
 typedef struct __DRIimageLoaderExtensionRec __DRIimageLoaderExtension;
 typedef struct __DRIimageDriverExtensionRec __DRIimageDriverExtension;
@@ -336,6 +336,30 @@ struct __DRI2throttleExtensionRec {
enum __DRI2throttleReason reason);
 };
 
+/**
+ * Extension for EGL_ANDROID_blob_cache
+ */
+
+#define __DRI2_BLOB "DRI2_Blob"
+#define __DRI2_BLOB_VERSION 1
+
+typedef void
+(*__DRIblobCacheSet) (const void *key, signed long keySize,
+  const void *value, signed long valueSize);
+
+typedef signed long
+(*__DRIblobCacheGet) (const void *key, signed long keySize,
+  void *value, signed long valueSize);
+
+struct __DRI2blobExtensionRec {
+   __DRIextension base;
+
+   /**
+* Set cache functions for setting and getting cache entries.
+*/
+   void (*set_cache_funcs) (__DRIcontext *ctx,
+__DRIblobCacheSet set, __DRIblobCacheGet get);
+};
 
 /**
  * Extension for fences / synchronization objects.
-- 
2.14.3

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


[Mesa-dev] [PATCH v2 2/5] egl: add support for EGL_ANDROID_blob_cache

2018-01-22 Thread Tapani Pälli
v2: cleanup, move callbacks to _egl_display struct (Emil Velikov)

Signed-off-by: Tapani Pälli 
---
 src/egl/drivers/dri2/egl_dri2.c | 39 +++
 src/egl/drivers/dri2/egl_dri2.h |  1 +
 src/egl/main/eglapi.c   | 30 ++
 src/egl/main/eglapi.h   |  4 
 src/egl/main/egldisplay.h   |  4 
 src/egl/main/eglentrypoint.h|  1 +
 6 files changed, 79 insertions(+)

diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index d5a4f72e86..c323a4989d 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -458,6 +458,7 @@ static const struct dri2_extension_match 
optional_core_extensions[] = {
{ __DRI2_INTEROP, 1, offsetof(struct dri2_egl_display, interop) },
{ __DRI_IMAGE, 1, offsetof(struct dri2_egl_display, image) },
{ __DRI2_FLUSH_CONTROL, 1, offsetof(struct dri2_egl_display, flush_control) 
},
+   { __DRI2_BLOB, 1, offsetof(struct dri2_egl_display, blob) },
{ NULL, 0, 0 }
 };
 
@@ -727,6 +728,9 @@ dri2_setup_screen(_EGLDisplay *disp)
   }
}
 
+   if (dri2_dpy->blob)
+  disp->Extensions.ANDROID_blob_cache = EGL_TRUE;
+
disp->Extensions.KHR_reusable_sync = EGL_TRUE;
 
if (dri2_dpy->image) {
@@ -1470,6 +1474,28 @@ dri2_surf_update_fence_fd(_EGLContext *ctx,
dri2_surface_set_out_fence_fd(surf, fence_fd);
 }
 
+static void
+update_blob_cache_functions( _EGLDisplay *disp, _EGLContext *ctx)
+{
+   struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
+   struct dri2_egl_context *dri2_ctx = dri2_egl_context(ctx);
+
+   if (!ctx)
+  return;
+
+   /* No blob support. */
+   if (!dri2_dpy->blob)
+  return;
+
+   /* No functions to set. */
+   if (!disp->BlobCacheSet)
+  return;
+
+   dri2_dpy->blob->set_cache_funcs(dri2_ctx->dri_context,
+   disp->BlobCacheSet,
+   disp->BlobCacheGet);
+}
+
 /**
  * Called via eglMakeCurrent(), drv->API.MakeCurrent().
  */
@@ -1499,6 +1525,9 @@ dri2_make_current(_EGLDriver *drv, _EGLDisplay *disp, 
_EGLSurface *dsurf,
if (old_ctx)
   dri2_gl_flush();
 
+   /* Make sure cache functions are set for new context. */
+   update_blob_cache_functions(disp, ctx);
+
ddraw = (dsurf) ? dri2_dpy->vtbl->get_dri_drawable(dsurf) : NULL;
rdraw = (rsurf) ? dri2_dpy->vtbl->get_dri_drawable(rsurf) : NULL;
cctx = (dri2_ctx) ? dri2_ctx->dri_context : NULL;
@@ -3016,6 +3045,15 @@ dri2_dup_native_fence_fd(_EGLDriver *drv, _EGLDisplay 
*dpy, _EGLSync *sync)
return dup(sync->SyncFd);
 }
 
+static void
+dri2_set_blob_cache_funcs(_EGLDriver *drv, _EGLDisplay *dpy,
+  EGLSetBlobFuncANDROID set,
+  EGLGetBlobFuncANDROID get)
+{
+   _EGLContext *ctx = _eglGetCurrentContext();
+   update_blob_cache_functions(dpy, ctx);
+}
+
 static EGLint
 dri2_client_wait_sync(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSync *sync,
   EGLint flags, EGLTime timeout)
@@ -3234,6 +3272,7 @@ _eglBuiltInDriver(void)
dri2_drv->API.GLInteropQueryDeviceInfo = dri2_interop_query_device_info;
dri2_drv->API.GLInteropExportObject = dri2_interop_export_object;
dri2_drv->API.DupNativeFenceFDANDROID = dri2_dup_native_fence_fd;
+   dri2_drv->API.SetBlobCacheFuncsANDROID = dri2_set_blob_cache_funcs;
 
dri2_drv->Name = "DRI2";
 
diff --git a/src/egl/drivers/dri2/egl_dri2.h b/src/egl/drivers/dri2/egl_dri2.h
index cc76c73eab..c49156fbb6 100644
--- a/src/egl/drivers/dri2/egl_dri2.h
+++ b/src/egl/drivers/dri2/egl_dri2.h
@@ -171,6 +171,7 @@ struct dri2_egl_display
const __DRInoErrorExtension*no_error;
const __DRI2configQueryExtension *config;
const __DRI2fenceExtension *fence;
+   const __DRI2blobExtension *blob;
const __DRI2rendererQueryExtension *rendererQuery;
const __DRI2interopExtension *interop;
int   fd;
diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c
index 5110688f2d..f2ba260060 100644
--- a/src/egl/main/eglapi.c
+++ b/src/egl/main/eglapi.c
@@ -476,6 +476,7 @@ _eglCreateExtensionsString(_EGLDisplay *dpy)
char *exts = dpy->ExtensionsString;
 
/* Please keep these sorted alphabetically. */
+   _EGL_CHECK_EXTENSION(ANDROID_blob_cache);
_EGL_CHECK_EXTENSION(ANDROID_framebuffer_target);
_EGL_CHECK_EXTENSION(ANDROID_image_native_buffer);
_EGL_CHECK_EXTENSION(ANDROID_native_fence_sync);
@@ -2522,6 +2523,35 @@ eglQueryDmaBufModifiersEXT(EGLDisplay dpy, EGLint 
format, EGLint max_modifiers,
RETURN_EGL_EVAL(disp, ret);
 }
 
+static void EGLAPIENTRY
+eglSetBlobCacheFuncsANDROID(EGLDisplay *dpy, EGLSetBlobFuncANDROID set,
+EGLGetBlobFuncANDROID get)
+{
+   _EGLDisplay *disp = _eglLockDisplay(dpy);
+   _EGLDriver *drv = _eglCheckDisplay(disp, __func__);
+
+   if (!set || !get) {
+  _eglError(EG

[Mesa-dev] [PATCH 0/5] EGL_ANDROID_blob_cache

2018-01-22 Thread Tapani Pälli
Another go at EGL_ANDROID_blob_cache, some patches are re-sent but I 
thought it would be easier to read when sending all patches at once.

Most important change here is that I've done refactoring to disk cache 
so that it can live without path/index. Path will get generated only 
when cache is actually used. This makes it possible to implement 
disk_cache_has_key and disk_cache_put_key for EGL_ANDROID_blob_cache.

This functionality can be tested on desktop with any EGL app using this
branch:

https://cgit.freedesktop.org/~tpalli/mesa/log/?h=ANDROID_blob_cache_debug_v2

I've tested regular disk cache and blob cache on desktop with these 
changes, and blob cache functionality on Android.

Thanks;

Tapani Pälli (5):
  dri: add interface for EGL_ANDROID_blob_cache extension
  egl: add support for EGL_ANDROID_blob_cache
  disk cache: initialize cache path and index only when used
  disk cache: add callback functionality
  i965: add __DRI2_BLOB support and set cache functions

 include/GL/internal/dri_interface.h  |  26 -
 src/egl/drivers/dri2/egl_dri2.c  |  39 
 src/egl/drivers/dri2/egl_dri2.h  |   1 +
 src/egl/main/eglapi.c|  30 ++
 src/egl/main/eglapi.h|   4 +
 src/egl/main/egldisplay.h|   4 +
 src/egl/main/eglentrypoint.h |   1 +
 src/mesa/drivers/dri/i965/intel_screen.c |  21 
 src/util/disk_cache.c| 163 +++
 src/util/disk_cache.h|  19 
 10 files changed, 266 insertions(+), 42 deletions(-)

-- 
2.14.3

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


[Mesa-dev] [PATCH 1/3] intel: add new common header gen_defines.h

2018-01-22 Thread Tapani Pälli
Signed-off-by: Tapani Pälli 
---
 src/intel/common/gen_defines.h | 52 ++
 1 file changed, 52 insertions(+)
 create mode 100644 src/intel/common/gen_defines.h

diff --git a/src/intel/common/gen_defines.h b/src/intel/common/gen_defines.h
new file mode 100644
index 00..f8daa84431
--- /dev/null
+++ b/src/intel/common/gen_defines.h
@@ -0,0 +1,52 @@
+/*
+ * Copyright © 2018 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 COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef GEN_DEFINES_H
+#define GEN_DEFINES_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+/**
+ * \file gen_defines.h
+ *
+ * Common defines we want to share between GL And Vulkan.
+ */
+
+#define GEN_CONTEXT_LOW_PRIORITY ((I915_CONTEXT_MIN_USER_PRIORITY-1)/2)
+#define GEN_CONTEXT_MEDIUM_PRIORITY (I915_CONTEXT_DEFAULT_PRIORITY)
+#define GEN_CONTEXT_HIGH_PRIORITY ((I915_CONTEXT_MAX_USER_PRIORITY+1)/2)
+/* We don't have a strict notion of RT (yet, and when we do it is likely
+ * to be more complicated than a mere priority value!), but we can give
+ * it the absolute most priority available to us. By convention, this
+ * is higher than any other client, except for blocked interactive
+ * clients.
+ */
+#define GEN_CONTEXT_REALTIME_PRIORITY I915_CONTEXT_MAX_USER_PRIORITY
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* GEN_DEFINES_H */
-- 
2.14.3

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


[Mesa-dev] [PATCH 2/3] i965: use context priority definitions from gen_defines.h

2018-01-22 Thread Tapani Pälli
Signed-off-by: Tapani Pälli 
---
 src/mesa/drivers/dri/i965/brw_bufmgr.h   | 4 
 src/mesa/drivers/dri/i965/brw_context.c  | 8 +---
 src/mesa/drivers/dri/i965/intel_screen.c | 8 +---
 3 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_bufmgr.h 
b/src/mesa/drivers/dri/i965/brw_bufmgr.h
index a3745d6667..48c8407f87 100644
--- a/src/mesa/drivers/dri/i965/brw_bufmgr.h
+++ b/src/mesa/drivers/dri/i965/brw_bufmgr.h
@@ -323,10 +323,6 @@ int brw_bo_wait(struct brw_bo *bo, int64_t timeout_ns);
 
 uint32_t brw_create_hw_context(struct brw_bufmgr *bufmgr);
 
-#define BRW_CONTEXT_LOW_PRIORITY ((I915_CONTEXT_MIN_USER_PRIORITY-1)/2)
-#define BRW_CONTEXT_MEDIUM_PRIORITY (I915_CONTEXT_DEFAULT_PRIORITY)
-#define BRW_CONTEXT_HIGH_PRIORITY ((I915_CONTEXT_MAX_USER_PRIORITY+1)/2)
-
 int brw_hw_context_set_priority(struct brw_bufmgr *bufmgr,
 uint32_t ctx_id,
 int priority);
diff --git a/src/mesa/drivers/dri/i965/brw_context.c 
b/src/mesa/drivers/dri/i965/brw_context.c
index b830e71247..f0d036f938 100644
--- a/src/mesa/drivers/dri/i965/brw_context.c
+++ b/src/mesa/drivers/dri/i965/brw_context.c
@@ -75,6 +75,8 @@
 #include "util/debug.h"
 #include "isl/isl.h"
 
+#include "common/gen_defines.h"
+
 /***
  * Mesa's Driver Functions
  ***/
@@ -979,14 +981,14 @@ brwCreateContext(gl_api api,
  return false;
   }
 
-  int hw_priority = BRW_CONTEXT_MEDIUM_PRIORITY;
+  int hw_priority = GEN_CONTEXT_MEDIUM_PRIORITY;
   if (ctx_config->attribute_mask & __DRIVER_CONTEXT_ATTRIB_PRIORITY) {
  switch (ctx_config->priority) {
  case __DRI_CTX_PRIORITY_LOW:
-hw_priority = BRW_CONTEXT_LOW_PRIORITY;
+hw_priority = GEN_CONTEXT_LOW_PRIORITY;
 break;
  case __DRI_CTX_PRIORITY_HIGH:
-hw_priority = BRW_CONTEXT_HIGH_PRIORITY;
+hw_priority = GEN_CONTEXT_HIGH_PRIORITY;
 break;
  }
   }
diff --git a/src/mesa/drivers/dri/i965/intel_screen.c 
b/src/mesa/drivers/dri/i965/intel_screen.c
index a4e34e9f2c..385b64ad94 100644
--- a/src/mesa/drivers/dri/i965/intel_screen.c
+++ b/src/mesa/drivers/dri/i965/intel_screen.c
@@ -43,6 +43,8 @@
 #include "utils.h"
 #include "util/xmlpool.h"
 
+#include "common/gen_defines.h"
+
 static const __DRIconfigOptionsExtension brw_config_options = {
.base = { __DRI_CONFIG_OPTIONS, 1 },
.xml =
@@ -1452,14 +1454,14 @@ brw_query_renderer_integer(__DRIscreen *dri_screen,
case __DRI2_RENDERER_HAS_CONTEXT_PRIORITY:
   value[0] = 0;
   if (brw_hw_context_set_priority(screen->bufmgr,
- 0, BRW_CONTEXT_HIGH_PRIORITY) == 0)
+ 0, GEN_CONTEXT_HIGH_PRIORITY) == 0)
  value[0] |= __DRI2_RENDERER_HAS_CONTEXT_PRIORITY_HIGH;
   if (brw_hw_context_set_priority(screen->bufmgr,
- 0, BRW_CONTEXT_LOW_PRIORITY) == 0)
+ 0, GEN_CONTEXT_LOW_PRIORITY) == 0)
  value[0] |= __DRI2_RENDERER_HAS_CONTEXT_PRIORITY_LOW;
   /* reset to default last, just in case */
   if (brw_hw_context_set_priority(screen->bufmgr,
- 0, BRW_CONTEXT_MEDIUM_PRIORITY) == 0)
+ 0, GEN_CONTEXT_MEDIUM_PRIORITY) == 0)
  value[0] |= __DRI2_RENDERER_HAS_CONTEXT_PRIORITY_MEDIUM;
   return 0;
case __DRI2_RENDERER_HAS_FRAMEBUFFER_SRGB:
-- 
2.14.3

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


[Mesa-dev] [PATCH v3 3/3] anv: implement VK_EXT_global_priority extension

2018-01-22 Thread Tapani Pälli
v2: add ANV_CONTEXT_REALTIME_PRIORITY (Chris)
use unreachable with unknown priority (Samuel)

v3: add stubs in gem_stubs.c (Emil)
use priority defines from gen_defines.h

Signed-off-by: Tapani Pälli 
Reviewed-by: Samuel Iglesias Gonsálvez  (v2)
Reviewed-by: Chris Wilson  (v2)
---
 src/intel/vulkan/anv_device.c  | 25 +++
 src/intel/vulkan/anv_extensions.py |  2 ++
 src/intel/vulkan/anv_gem.c | 51 ++
 src/intel/vulkan/anv_gem_stubs.c   | 10 
 src/intel/vulkan/anv_private.h |  3 +++
 5 files changed, 91 insertions(+)

diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c
index 777abd8757..42ebc19f2b 100644
--- a/src/intel/vulkan/anv_device.c
+++ b/src/intel/vulkan/anv_device.c
@@ -369,6 +369,9 @@ anv_physical_device_init(struct anv_physical_device *device,
device->has_syncobj_wait = device->has_syncobj &&
   anv_gem_supports_syncobj_wait(fd);
 
+   if (anv_gem_has_context_priority(fd))
+  device->has_context_priority = true;
+
bool swizzled = anv_gem_get_bit6_swizzle(fd, I915_TILING_X);
 
/* Starting with Gen10, the timestamp frequency of the command streamer may
@@ -1205,6 +1208,15 @@ VkResult anv_CreateDevice(
   }
}
 
+   /* Check if client specified queue priority. */
+   const VkDeviceQueueGlobalPriorityCreateInfoEXT *queue_priority =
+  vk_find_struct_const(pCreateInfo->pQueueCreateInfos[0].pNext,
+   DEVICE_QUEUE_GLOBAL_PRIORITY_CREATE_INFO_EXT);
+
+   VkQueueGlobalPriorityEXT priority =
+  queue_priority ? queue_priority->globalPriority :
+ VK_QUEUE_GLOBAL_PRIORITY_MEDIUM_EXT;
+
device = vk_alloc2(&physical_device->instance->alloc, pAllocator,
sizeof(*device), 8,
VK_SYSTEM_ALLOCATION_SCOPE_DEVICE);
@@ -1234,6 +1246,19 @@ VkResult anv_CreateDevice(
   goto fail_fd;
}
 
+   /* As per spec, the driver implementation may deny requests to acquire
+* a priority above the default priority (MEDIUM) if the caller does not
+* have sufficient privileges. In this scenario VK_ERROR_NOT_PERMITTED_EXT
+* is returned.
+*/
+   if (physical_device->has_context_priority) {
+  int err = anv_gem_set_context_priority(device, priority);
+  if (err != 0 && priority > VK_QUEUE_GLOBAL_PRIORITY_MEDIUM_EXT) {
+ result = vk_error(VK_ERROR_NOT_PERMITTED_EXT);
+ goto fail_fd;
+  }
+   }
+
device->info = physical_device->info;
device->isl_dev = physical_device->isl_dev;
 
diff --git a/src/intel/vulkan/anv_extensions.py 
b/src/intel/vulkan/anv_extensions.py
index adfebca985..aacf39248f 100644
--- a/src/intel/vulkan/anv_extensions.py
+++ b/src/intel/vulkan/anv_extensions.py
@@ -86,6 +86,8 @@ EXTENSIONS = [
 Extension('VK_KHX_multiview', 1, True),
 Extension('VK_EXT_debug_report',  8, True),
 Extension('VK_EXT_external_memory_dma_buf',   1, True),
+Extension('VK_EXT_global_priority',   1,
+  'device->has_context_priority'),
 ]
 
 class VkVersion:
diff --git a/src/intel/vulkan/anv_gem.c b/src/intel/vulkan/anv_gem.c
index 34c0989108..7f83820429 100644
--- a/src/intel/vulkan/anv_gem.c
+++ b/src/intel/vulkan/anv_gem.c
@@ -30,6 +30,7 @@
 #include 
 
 #include "anv_private.h"
+#include "common/gen_defines.h"
 
 static int
 anv_ioctl(int fd, unsigned long request, void *arg)
@@ -302,6 +303,56 @@ close_and_return:
return swizzled;
 }
 
+static int
+vk_priority_to_anv(int priority)
+{
+   switch (priority) {
+   case VK_QUEUE_GLOBAL_PRIORITY_LOW_EXT:
+  return GEN_CONTEXT_LOW_PRIORITY;
+   case VK_QUEUE_GLOBAL_PRIORITY_MEDIUM_EXT:
+  return GEN_CONTEXT_MEDIUM_PRIORITY;
+   case VK_QUEUE_GLOBAL_PRIORITY_HIGH_EXT:
+  return GEN_CONTEXT_HIGH_PRIORITY;
+   case VK_QUEUE_GLOBAL_PRIORITY_REALTIME_EXT:
+  return GEN_CONTEXT_REALTIME_PRIORITY;
+   default:
+  unreachable("Invalid priority");
+   }
+}
+
+static int
+_anv_gem_set_context_priority(int fd,
+  int context_id,
+  int priority)
+{
+   struct drm_i915_gem_context_param p = {
+  .ctx_id = context_id,
+  .param = I915_CONTEXT_PARAM_PRIORITY,
+  .value = vk_priority_to_anv(priority),
+   };
+   int err = 0;
+
+   if (anv_ioctl(fd, DRM_IOCTL_I915_GEM_CONTEXT_SETPARAM, &p))
+  err = -errno;
+
+   return err;
+}
+
+int
+anv_gem_set_context_priority(struct anv_device *device,
+ int priority)
+{
+   return _anv_gem_set_context_priority(device->fd, device->context_id,
+priority);
+}
+
+bool
+anv_gem_has_context_priority(int fd)
+{
+   return !_anv_gem_set_context_priority(fd, 0,
+ 

Re: [Mesa-dev] [PATCH] i965: Accept CONTEXT_ATTRIB_PRIORITY for brwCreateContext

2018-01-22 Thread Tapani Pälli

Reviewed-by: Tapani Pälli 

On 01/20/2018 02:29 AM, Chris Wilson wrote:

The forward port of commit 6d87500fe12e ("dri: Change
__DriverApiRec::CreateContext to take a struct for attribs") failed to
adapt the set of allowed attributes for the earlier introduction of
context priorities (commit 1617fca6d12e "i965: Pass the EGL/DRI context
priority through to the kernel").

Fixes: 6d87500fe12e ("dri: Change __DriverApiRec::CreateContext to take a struct for 
attribs")
Signed-off-by: Chris Wilson 
Cc: Adam Jackson 
Cc: Nicolai Hähnle 
Cc: Emil Velikov 
Cc: Kenneth Graunke 
---
  src/mesa/drivers/dri/i965/brw_context.c | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/mesa/drivers/dri/i965/brw_context.c 
b/src/mesa/drivers/dri/i965/brw_context.c
index c30eae420c..0eb9aba948 100644
--- a/src/mesa/drivers/dri/i965/brw_context.c
+++ b/src/mesa/drivers/dri/i965/brw_context.c
@@ -860,7 +860,9 @@ brwCreateContext(gl_api api,
return false;
 }
  
-   if (ctx_config->attribute_mask & ~__DRIVER_CONTEXT_ATTRIB_RESET_STRATEGY) {

+   if (ctx_config->attribute_mask &
+   ~(__DRIVER_CONTEXT_ATTRIB_RESET_STRATEGY |
+ __DRIVER_CONTEXT_ATTRIB_PRIORITY)) {
*dri_ctx_error = __DRI_CTX_ERROR_UNKNOWN_ATTRIBUTE;
return false;
 }


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


Re: [Mesa-dev] [PATCH] mesa: Only require independent blending for GLES 3.2.

2018-01-21 Thread Tapani Pälli



On 01/22/2018 08:48 AM, Ilia Mirkin wrote:
What es3 does require, though, is mrt. Maybe add something that ensures 
that mrt is supported?


I guess that would be EXT_draw_buffers? That is currently enabled with 
'dummy_true'.



On Jan 19, 2018 08:39, "Eric Anholt" > wrote:


We've been requiring this since GLES 3.0 was introduced, but the
GLES 3.2
spec is the one that has "Supporting blending on a per-draw-buffer
basis"
in the new features.  V3D 3.3 would require lowering blending to shader
code to implement independent blending.
---
  src/mesa/main/version.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/mesa/main/version.c b/src/mesa/main/version.c
index 68079f4ebbba..1fce8fe7ca9c 100644
--- a/src/mesa/main/version.c
+++ b/src/mesa/main/version.c
@@ -516,7 +516,6 @@ compute_version_es2(const struct gl_extensions
*extensions,
                           extensions->ARB_texture_float &&
                           extensions->ARB_texture_rg &&
                           extensions->ARB_depth_buffer_float &&
-                         extensions->EXT_draw_buffers2 &&
                           /* extensions->ARB_framebuffer_object && */
                           extensions->EXT_framebuffer_sRGB &&
                           extensions->EXT_packed_float &&
@@ -546,6 +545,7 @@ compute_version_es2(const struct gl_extensions
*extensions,
                           extensions->ARB_gpu_shader5 &&
                           extensions->EXT_shader_integer_mix);
     const bool ver_3_2 = (ver_3_1 &&
+                         extensions->EXT_draw_buffers2 &&
                           extensions->KHR_blend_equation_advanced &&
                           extensions->KHR_robustness &&
  
extensions->KHR_texture_compression_astc_ldr &&

--
2.15.0

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




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


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


Re: [Mesa-dev] [PATCH] mesa: enable ASTC/ETC1 compressed textures

2018-01-21 Thread Tapani Pälli



On 01/19/2018 12:44 PM, Juan A. Suarez Romero wrote:

Anyone could take a look at this patch?



Can you pinpoint where the mentioned tests are located, which suite?


Thanks in advance!


J.A.

On Thu, 2018-01-11 at 16:35 +0100, Juan A. Suarez Romero wrote:

Enable these kind of texture when proper extensions are available.

Fixes KHR-GLES2.texture_3d.* with these textures.
---
  src/mesa/main/teximage.c | 26 +++---
  1 file changed, 19 insertions(+), 7 deletions(-)

diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
index e5f8bb0718f..a9940de88b1 100644
--- a/src/mesa/main/teximage.c
+++ b/src/mesa/main/teximage.c
@@ -1487,6 +1487,9 @@ _mesa_target_can_be_compressed(const struct gl_context 
*ctx, GLenum target,
break;
 case GL_TEXTURE_3D:
switch (layout) {
+  case MESA_FORMAT_LAYOUT_ETC1:
+ target_can_be_compresed = 
ctx->Extensions.OES_compressed_ETC1_RGB8_texture;
+ break;
case MESA_FORMAT_LAYOUT_ETC2:
   /* See ETC2/EAC comment in case GL_TEXTURE_CUBE_MAP_ARRAY. */
   if (_mesa_is_gles3(ctx))
@@ -4648,10 +4651,12 @@ out:
   */
  static GLboolean
  compressed_subtexture_target_check(struct gl_context *ctx, GLenum target,
-   GLint dims, GLenum format, bool dsa,
+   GLint dims, GLenum intFormat, bool dsa,
 const char *caller)
  {
 GLboolean targetOK;
+   mesa_format format;
+   enum mesa_format_layout layout;
  
 if (dsa && target == GL_TEXTURE_RECTANGLE) {

_mesa_error(ctx, GL_INVALID_OPERATION, "%s(invalid target %s)", caller,
@@ -4712,21 +4717,28 @@ compressed_subtexture_target_check(struct gl_context 
*ctx, GLenum target,
* which is (at this time) only bptc. Otherwise we'd say s3tc (and
* more) are valid here, which they are not, but of course not
* mentioned by core spec.
+  *
+  * We add also other formats supported due extensions.
*/
- switch (format) {
+ format = _mesa_glenum_to_compressed_format(intFormat);
+ layout = _mesa_get_format_layout(format);
+ switch (layout) {
   /* These are the only 3D compression formats supported at this time 
*/
- case GL_COMPRESSED_RGBA_BPTC_UNORM:
- case GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM:
- case GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT:
- case GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT:
+ case MESA_FORMAT_LAYOUT_BPTC:
  /* valid format */
  break;
+ case MESA_FORMAT_LAYOUT_ASTC:
+targetOK = ctx->Extensions.KHR_texture_compression_astc_ldr;
+break;
+ case MESA_FORMAT_LAYOUT_ETC1:
+targetOK = ctx->Extensions.OES_compressed_ETC1_RGB8_texture;
+break;
   default:
  /* invalid format */
  _mesa_error(ctx, GL_INVALID_OPERATION,
  "%s(invalid target %s for format %s)", caller,
  _mesa_enum_to_string(target),
-_mesa_enum_to_string(format));
+_mesa_enum_to_string(intFormat));
  return GL_TRUE;
   }
   break;

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


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


[Mesa-dev] [PATCH v2] anv: implement VK_EXT_global_priority extension

2018-01-19 Thread Tapani Pälli
v2: add ANV_CONTEXT_REALTIME_PRIORITY (Chris)
use unreachable with unknown priority (Samuel)

Signed-off-by: Tapani Pälli 
---

Small crucible test available here:
https://cgit.freedesktop.org/~tpalli/crucible/commit/?h=VK_EXT_global_priority

 src/intel/vulkan/anv_device.c  | 25 +++
 src/intel/vulkan/anv_extensions.py |  2 ++
 src/intel/vulkan/anv_gem.c | 50 ++
 src/intel/vulkan/anv_private.h | 14 +++
 4 files changed, 91 insertions(+)

diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c
index 777abd8757..42ebc19f2b 100644
--- a/src/intel/vulkan/anv_device.c
+++ b/src/intel/vulkan/anv_device.c
@@ -369,6 +369,9 @@ anv_physical_device_init(struct anv_physical_device *device,
device->has_syncobj_wait = device->has_syncobj &&
   anv_gem_supports_syncobj_wait(fd);
 
+   if (anv_gem_has_context_priority(fd))
+  device->has_context_priority = true;
+
bool swizzled = anv_gem_get_bit6_swizzle(fd, I915_TILING_X);
 
/* Starting with Gen10, the timestamp frequency of the command streamer may
@@ -1205,6 +1208,15 @@ VkResult anv_CreateDevice(
   }
}
 
+   /* Check if client specified queue priority. */
+   const VkDeviceQueueGlobalPriorityCreateInfoEXT *queue_priority =
+  vk_find_struct_const(pCreateInfo->pQueueCreateInfos[0].pNext,
+   DEVICE_QUEUE_GLOBAL_PRIORITY_CREATE_INFO_EXT);
+
+   VkQueueGlobalPriorityEXT priority =
+  queue_priority ? queue_priority->globalPriority :
+ VK_QUEUE_GLOBAL_PRIORITY_MEDIUM_EXT;
+
device = vk_alloc2(&physical_device->instance->alloc, pAllocator,
sizeof(*device), 8,
VK_SYSTEM_ALLOCATION_SCOPE_DEVICE);
@@ -1234,6 +1246,19 @@ VkResult anv_CreateDevice(
   goto fail_fd;
}
 
+   /* As per spec, the driver implementation may deny requests to acquire
+* a priority above the default priority (MEDIUM) if the caller does not
+* have sufficient privileges. In this scenario VK_ERROR_NOT_PERMITTED_EXT
+* is returned.
+*/
+   if (physical_device->has_context_priority) {
+  int err = anv_gem_set_context_priority(device, priority);
+  if (err != 0 && priority > VK_QUEUE_GLOBAL_PRIORITY_MEDIUM_EXT) {
+ result = vk_error(VK_ERROR_NOT_PERMITTED_EXT);
+ goto fail_fd;
+  }
+   }
+
device->info = physical_device->info;
device->isl_dev = physical_device->isl_dev;
 
diff --git a/src/intel/vulkan/anv_extensions.py 
b/src/intel/vulkan/anv_extensions.py
index adfebca985..aacf39248f 100644
--- a/src/intel/vulkan/anv_extensions.py
+++ b/src/intel/vulkan/anv_extensions.py
@@ -86,6 +86,8 @@ EXTENSIONS = [
 Extension('VK_KHX_multiview', 1, True),
 Extension('VK_EXT_debug_report',  8, True),
 Extension('VK_EXT_external_memory_dma_buf',   1, True),
+Extension('VK_EXT_global_priority',   1,
+  'device->has_context_priority'),
 ]
 
 class VkVersion:
diff --git a/src/intel/vulkan/anv_gem.c b/src/intel/vulkan/anv_gem.c
index 34c0989108..59732f191f 100644
--- a/src/intel/vulkan/anv_gem.c
+++ b/src/intel/vulkan/anv_gem.c
@@ -302,6 +302,56 @@ close_and_return:
return swizzled;
 }
 
+static int
+vk_priority_to_anv(int priority)
+{
+   switch (priority) {
+   case VK_QUEUE_GLOBAL_PRIORITY_LOW_EXT:
+  return ANV_CONTEXT_LOW_PRIORITY;
+   case VK_QUEUE_GLOBAL_PRIORITY_MEDIUM_EXT:
+  return ANV_CONTEXT_MEDIUM_PRIORITY;
+   case VK_QUEUE_GLOBAL_PRIORITY_HIGH_EXT:
+  return ANV_CONTEXT_HIGH_PRIORITY;
+   case VK_QUEUE_GLOBAL_PRIORITY_REALTIME_EXT:
+  return ANV_CONTEXT_REALTIME_PRIORITY;
+   default:
+  unreachable("Invalid priority");
+   }
+}
+
+static int
+_anv_gem_set_context_priority(int fd,
+  int context_id,
+  int priority)
+{
+   struct drm_i915_gem_context_param p = {
+  .ctx_id = context_id,
+  .param = I915_CONTEXT_PARAM_PRIORITY,
+  .value = vk_priority_to_anv(priority),
+   };
+   int err = 0;
+
+   if (anv_ioctl(fd, DRM_IOCTL_I915_GEM_CONTEXT_SETPARAM, &p))
+  err = -errno;
+
+   return err;
+}
+
+int
+anv_gem_set_context_priority(struct anv_device *device,
+ int priority)
+{
+   return _anv_gem_set_context_priority(device->fd, device->context_id,
+priority);
+}
+
+bool
+anv_gem_has_context_priority(int fd)
+{
+   return !_anv_gem_set_context_priority(fd, 0,
+ VK_QUEUE_GLOBAL_PRIORITY_MEDIUM_EXT);
+}
+
 int
 anv_gem_create_context(struct anv_device *device)
 {
diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h
index ed711e9434..c24528fade 100644
--- a/src/i

Re: [Mesa-dev] [PATCH] anv: implement VK_EXT_global_priority extension

2018-01-19 Thread Tapani Pälli



On 01/19/2018 01:20 PM, Samuel Iglesias Gonsálvez wrote:



On 19/01/18 12:11, Tapani Pälli wrote:



On 01/19/2018 01:08 PM, Samuel Iglesias Gonsálvez wrote:



On 19/01/18 11:44, Tapani Pälli wrote:

Signed-off-by: Tapani Pälli 
---

Small crucible test available here:
https://cgit.freedesktop.org/~tpalli/crucible/commit/?h=VK_EXT_global_priority


   src/intel/vulkan/anv_device.c  | 25 +++
   src/intel/vulkan/anv_extensions.py |  2 ++
   src/intel/vulkan/anv_gem.c | 49
++
   src/intel/vulkan/anv_private.h |  7 ++
   4 files changed, 83 insertions(+)

diff --git a/src/intel/vulkan/anv_device.c
b/src/intel/vulkan/anv_device.c
index 777abd8757..42ebc19f2b 100644
--- a/src/intel/vulkan/anv_device.c
+++ b/src/intel/vulkan/anv_device.c
@@ -369,6 +369,9 @@ anv_physical_device_init(struct
anv_physical_device *device,
  device->has_syncobj_wait = device->has_syncobj &&
     anv_gem_supports_syncobj_wait(fd);
   +   if (anv_gem_has_context_priority(fd))
+  device->has_context_priority = true;
+
  bool swizzled = anv_gem_get_bit6_swizzle(fd, I915_TILING_X);
    /* Starting with Gen10, the timestamp frequency of the
command streamer may
@@ -1205,6 +1208,15 @@ VkResult anv_CreateDevice(
     }
  }
   +   /* Check if client specified queue priority. */
+   const VkDeviceQueueGlobalPriorityCreateInfoEXT *queue_priority =
+  vk_find_struct_const(pCreateInfo->pQueueCreateInfos[0].pNext,
+
DEVICE_QUEUE_GLOBAL_PRIORITY_CREATE_INFO_EXT);
+
+   VkQueueGlobalPriorityEXT priority =
+  queue_priority ? queue_priority->globalPriority :
+ VK_QUEUE_GLOBAL_PRIORITY_MEDIUM_EXT;
+
  device = vk_alloc2(&physical_device->instance->alloc, pAllocator,
  sizeof(*device), 8,
  VK_SYSTEM_ALLOCATION_SCOPE_DEVICE);
@@ -1234,6 +1246,19 @@ VkResult anv_CreateDevice(
     goto fail_fd;
  }
   +   /* As per spec, the driver implementation may deny requests to
acquire
+    * a priority above the default priority (MEDIUM) if the caller
does not
+    * have sufficient privileges. In this scenario
VK_ERROR_NOT_PERMITTED_EXT
+    * is returned.
+    */
+   if (physical_device->has_context_priority) {
+  int err = anv_gem_set_context_priority(device, priority);
+  if (err != 0 && priority >
VK_QUEUE_GLOBAL_PRIORITY_MEDIUM_EXT) {
+ result = vk_error(VK_ERROR_NOT_PERMITTED_EXT);
+ goto fail_fd;
+  }
+   }
+
  device->info = physical_device->info;
  device->isl_dev = physical_device->isl_dev;
   diff --git a/src/intel/vulkan/anv_extensions.py
b/src/intel/vulkan/anv_extensions.py
index adfebca985..aacf39248f 100644
--- a/src/intel/vulkan/anv_extensions.py
+++ b/src/intel/vulkan/anv_extensions.py
@@ -86,6 +86,8 @@ EXTENSIONS = [
   Extension('VK_KHX_multiview', 1, True),
   Extension('VK_EXT_debug_report',  8, True),
   Extension('VK_EXT_external_memory_dma_buf',   1, True),
+    Extension('VK_EXT_global_priority',   1,
+  'device->has_context_priority'),
   ]
     class VkVersion:
diff --git a/src/intel/vulkan/anv_gem.c b/src/intel/vulkan/anv_gem.c
index 34c0989108..46069dcdc7 100644
--- a/src/intel/vulkan/anv_gem.c
+++ b/src/intel/vulkan/anv_gem.c
@@ -302,6 +302,55 @@ close_and_return:
  return swizzled;
   }
   +static int
+vk_priority_to_anv(int priority)
+{
+   switch (priority) {
+   case VK_QUEUE_GLOBAL_PRIORITY_LOW_EXT:
+  return ANV_CONTEXT_LOW_PRIORITY;
+   case VK_QUEUE_GLOBAL_PRIORITY_MEDIUM_EXT:
+  return ANV_CONTEXT_MEDIUM_PRIORITY;
+   case VK_QUEUE_GLOBAL_PRIORITY_HIGH_EXT:
+  return ANV_CONTEXT_HIGH_PRIORITY;
+   case VK_QUEUE_GLOBAL_PRIORITY_REALTIME_EXT:
+   default:
+  return -1;


Is this right? We are returning -1 on
VK_QUEUE_GLOBAL_PRIORITY_REALTIME_EX, which should be the highest
priority, according to the spec.

Checking Intel kernel driver's sources, it checks the given priority in
struct drm_i915_gem_context_param is within the range of
I915_CONTEXT_MAX_USER_PRIORITY and I915_CONTEXT_MIN_USER_PRIORITY, whose
values are 1023 and -1023, respectively. So at the end, you are setting
the priority to be one unit lower than I915_CONTEXT_DEFAULT_PRIORITY.

What do you want to do here? Give more priority to the realtime case or
indicate that it is not supported?


Argh, yep intention was to say it is not supported. I've not changed
it for ANV_CONTEXT_REALTIME_PRIORITY but I guess default case should
be something else, maybe just set medium?



For the realtime case: you can do Chris solution or set it to a wrong
value (x > MAX for example) to indicate it is not supported.

For the default case: no other values are supported in the enum now, so
you can either add an

Re: [Mesa-dev] [PATCH 7/7] android: set '/sdcard/' as MESA_GLSL_CACHE_DIR by default

2018-01-19 Thread Tapani Pälli



On 01/19/2018 01:03 PM, Tapani Pälli wrote:



On 01/19/2018 11:22 AM, Jordan Justen wrote:

On 2018-01-18 22:08:17, Tapani Pälli wrote:



On 01/18/2018 08:18 PM, Jordan Justen wrote:

On 2018-01-15 04:31:43, Tapani Pälli wrote:

This can/should be modified depending on needs. AFAIK by default,
this is the only path that can be read/written to by anyone.

Signed-off-by: Tapani Pälli 
---
   Android.common.mk | 1 +
   1 file changed, 1 insertion(+)

diff --git a/Android.common.mk b/Android.common.mk
index 52dc7bff3b..7edbbfc0f2 100644
--- a/Android.common.mk
+++ b/Android.common.mk
@@ -47,6 +47,7 @@ LOCAL_CFLAGS += \
   LOCAL_CFLAGS += \
  -DANDROID_API_LEVEL=$(PLATFORM_SDK_VERSION) \
  -DENABLE_SHADER_CACHE \
+   -DMESA_GLSL_CACHE_DIR="/sdcard" \


Is this used when EGL_ANDROID_blob_cache is being used?

My thought is that if we are running under android with
EGL_ANDROID_blob_cache, then we should never attempt to write any
files with src/util/disk_cache.c. This might cause a little rework,
since the shader cache want to write/manage the index file, but can we
skip this and only use the blob cache read/write function when
EGL_ANDROID_blob_cache is available?


I'm a bit pessimistic about that. Since cache location depends on
running app that would mean every app has it's own index (that not
really a problem though but is different from desktop).


I suspect that the blob_cache is app specific. Therefore it also makes
sense that the index would be app specific.


The big problem I see there that index will be then 'just another
cache entry', I'll have to get more familiar with Android's
implementation to see if there would be way to make this entry
'special' so that it would not touch it.


My suggestion was that we should scrap the index entirely when in
EGL_ANDROID_blob_cache mode. Essentially the Android OS is managing
the cache index for us, so hopefully we don't need to maintain one.


One issue to tackle is that currently _mesa_glsl_compile_shader uses 
disk_cache_has_key() for detecting if we can skip shader compilation. 
This uses 'stored_keys' which is mmap of the index file.


I guess this could be done by inserting items for those shaders to 
blob_cache so disk_cache_has_key() could use get() for implementing this 
functionality. It seemed easier (and more optimal) to go with existing 
'index' for this but I can try alternative approach also.


So maybe to further summarize, I wanted to use existing codebase as much 
as is but I'll try implementing has_key and put_key separately for 
blob_cache.


Thanks;

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


Re: [Mesa-dev] [PATCH] anv: implement VK_EXT_global_priority extension

2018-01-19 Thread Tapani Pälli



On 01/19/2018 01:08 PM, Samuel Iglesias Gonsálvez wrote:



On 19/01/18 11:44, Tapani Pälli wrote:

Signed-off-by: Tapani Pälli 
---

Small crucible test available here:
https://cgit.freedesktop.org/~tpalli/crucible/commit/?h=VK_EXT_global_priority

  src/intel/vulkan/anv_device.c  | 25 +++
  src/intel/vulkan/anv_extensions.py |  2 ++
  src/intel/vulkan/anv_gem.c | 49 ++
  src/intel/vulkan/anv_private.h |  7 ++
  4 files changed, 83 insertions(+)

diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c
index 777abd8757..42ebc19f2b 100644
--- a/src/intel/vulkan/anv_device.c
+++ b/src/intel/vulkan/anv_device.c
@@ -369,6 +369,9 @@ anv_physical_device_init(struct anv_physical_device *device,
 device->has_syncobj_wait = device->has_syncobj &&
anv_gem_supports_syncobj_wait(fd);
  
+   if (anv_gem_has_context_priority(fd))

+  device->has_context_priority = true;
+
 bool swizzled = anv_gem_get_bit6_swizzle(fd, I915_TILING_X);
  
 /* Starting with Gen10, the timestamp frequency of the command streamer may

@@ -1205,6 +1208,15 @@ VkResult anv_CreateDevice(
}
 }
  
+   /* Check if client specified queue priority. */

+   const VkDeviceQueueGlobalPriorityCreateInfoEXT *queue_priority =
+  vk_find_struct_const(pCreateInfo->pQueueCreateInfos[0].pNext,
+   DEVICE_QUEUE_GLOBAL_PRIORITY_CREATE_INFO_EXT);
+
+   VkQueueGlobalPriorityEXT priority =
+  queue_priority ? queue_priority->globalPriority :
+ VK_QUEUE_GLOBAL_PRIORITY_MEDIUM_EXT;
+
 device = vk_alloc2(&physical_device->instance->alloc, pAllocator,
 sizeof(*device), 8,
 VK_SYSTEM_ALLOCATION_SCOPE_DEVICE);
@@ -1234,6 +1246,19 @@ VkResult anv_CreateDevice(
goto fail_fd;
 }
  
+   /* As per spec, the driver implementation may deny requests to acquire

+* a priority above the default priority (MEDIUM) if the caller does not
+* have sufficient privileges. In this scenario VK_ERROR_NOT_PERMITTED_EXT
+* is returned.
+*/
+   if (physical_device->has_context_priority) {
+  int err = anv_gem_set_context_priority(device, priority);
+  if (err != 0 && priority > VK_QUEUE_GLOBAL_PRIORITY_MEDIUM_EXT) {
+ result = vk_error(VK_ERROR_NOT_PERMITTED_EXT);
+ goto fail_fd;
+  }
+   }
+
 device->info = physical_device->info;
 device->isl_dev = physical_device->isl_dev;
  
diff --git a/src/intel/vulkan/anv_extensions.py b/src/intel/vulkan/anv_extensions.py

index adfebca985..aacf39248f 100644
--- a/src/intel/vulkan/anv_extensions.py
+++ b/src/intel/vulkan/anv_extensions.py
@@ -86,6 +86,8 @@ EXTENSIONS = [
  Extension('VK_KHX_multiview', 1, True),
  Extension('VK_EXT_debug_report',  8, True),
  Extension('VK_EXT_external_memory_dma_buf',   1, True),
+Extension('VK_EXT_global_priority',   1,
+  'device->has_context_priority'),
  ]
  
  class VkVersion:

diff --git a/src/intel/vulkan/anv_gem.c b/src/intel/vulkan/anv_gem.c
index 34c0989108..46069dcdc7 100644
--- a/src/intel/vulkan/anv_gem.c
+++ b/src/intel/vulkan/anv_gem.c
@@ -302,6 +302,55 @@ close_and_return:
 return swizzled;
  }
  
+static int

+vk_priority_to_anv(int priority)
+{
+   switch (priority) {
+   case VK_QUEUE_GLOBAL_PRIORITY_LOW_EXT:
+  return ANV_CONTEXT_LOW_PRIORITY;
+   case VK_QUEUE_GLOBAL_PRIORITY_MEDIUM_EXT:
+  return ANV_CONTEXT_MEDIUM_PRIORITY;
+   case VK_QUEUE_GLOBAL_PRIORITY_HIGH_EXT:
+  return ANV_CONTEXT_HIGH_PRIORITY;
+   case VK_QUEUE_GLOBAL_PRIORITY_REALTIME_EXT:
+   default:
+  return -1;


Is this right? We are returning -1 on
VK_QUEUE_GLOBAL_PRIORITY_REALTIME_EX, which should be the highest
priority, according to the spec.

Checking Intel kernel driver's sources, it checks the given priority in
struct drm_i915_gem_context_param is within the range of
I915_CONTEXT_MAX_USER_PRIORITY and I915_CONTEXT_MIN_USER_PRIORITY, whose
values are 1023 and -1023, respectively. So at the end, you are setting
the priority to be one unit lower than I915_CONTEXT_DEFAULT_PRIORITY.

What do you want to do here? Give more priority to the realtime case or
indicate that it is not supported?


Argh, yep intention was to say it is not supported. I've not changed it 
for ANV_CONTEXT_REALTIME_PRIORITY but I guess default case should be 
something else, maybe just set medium?




Sam

+   }
+}
+
+static int
+_anv_gem_set_context_priority(int fd,
+  int context_id,
+  int priority)
+{
+   struct drm_i915_gem_context_param p = {
+  .ctx_id = context_id,
+  .param = I915_CONTEXT_PARAM_PRIORITY,
+  .value = vk_priority_to_an

Re: [Mesa-dev] [PATCH] anv: implement VK_EXT_global_priority extension

2018-01-19 Thread Tapani Pälli



On 01/19/2018 01:00 PM, Chris Wilson wrote:

Quoting Tapani Pälli (2018-01-19 10:44:49)

diff --git a/src/intel/vulkan/anv_gem.c b/src/intel/vulkan/anv_gem.c
index 34c0989108..46069dcdc7 100644
--- a/src/intel/vulkan/anv_gem.c
+++ b/src/intel/vulkan/anv_gem.c
@@ -302,6 +302,55 @@ close_and_return:
 return swizzled;
  }
  
+static int

+vk_priority_to_anv(int priority)
+{
+   switch (priority) {
+   case VK_QUEUE_GLOBAL_PRIORITY_LOW_EXT:
+  return ANV_CONTEXT_LOW_PRIORITY;
+   case VK_QUEUE_GLOBAL_PRIORITY_MEDIUM_EXT:
+  return ANV_CONTEXT_MEDIUM_PRIORITY;
+   case VK_QUEUE_GLOBAL_PRIORITY_HIGH_EXT:
+  return ANV_CONTEXT_HIGH_PRIORITY;
+   case VK_QUEUE_GLOBAL_PRIORITY_REALTIME_EXT:


/* We don't have a strict notion of RT (yet, and when we do it is likely
  * to be more complicated than a mere priority value!), but we can give
  * it the absolute most priority available to us. By convention, this
  * is higher than any other client, except for blocked interactive
  * clients.
  */
#define ANV_CONTEXT_RT_PRIORITY I915_CONTEXT_MAX_USER_PRIORITY
return ANV_CONTEXT_RT_PRIORITY;


OK, will add this.

Thanks Chris!

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


Re: [Mesa-dev] [PATCH 7/7] android: set '/sdcard/' as MESA_GLSL_CACHE_DIR by default

2018-01-19 Thread Tapani Pälli



On 01/19/2018 11:22 AM, Jordan Justen wrote:

On 2018-01-18 22:08:17, Tapani Pälli wrote:



On 01/18/2018 08:18 PM, Jordan Justen wrote:

On 2018-01-15 04:31:43, Tapani Pälli wrote:

This can/should be modified depending on needs. AFAIK by default,
this is the only path that can be read/written to by anyone.

Signed-off-by: Tapani Pälli 
---
   Android.common.mk | 1 +
   1 file changed, 1 insertion(+)

diff --git a/Android.common.mk b/Android.common.mk
index 52dc7bff3b..7edbbfc0f2 100644
--- a/Android.common.mk
+++ b/Android.common.mk
@@ -47,6 +47,7 @@ LOCAL_CFLAGS += \
   LOCAL_CFLAGS += \
  -DANDROID_API_LEVEL=$(PLATFORM_SDK_VERSION) \
  -DENABLE_SHADER_CACHE \
+   -DMESA_GLSL_CACHE_DIR="/sdcard" \


Is this used when EGL_ANDROID_blob_cache is being used?

My thought is that if we are running under android with
EGL_ANDROID_blob_cache, then we should never attempt to write any
files with src/util/disk_cache.c. This might cause a little rework,
since the shader cache want to write/manage the index file, but can we
skip this and only use the blob cache read/write function when
EGL_ANDROID_blob_cache is available?


I'm a bit pessimistic about that. Since cache location depends on
running app that would mean every app has it's own index (that not
really a problem though but is different from desktop).


I suspect that the blob_cache is app specific. Therefore it also makes
sense that the index would be app specific.


The big problem I see there that index will be then 'just another
cache entry', I'll have to get more familiar with Android's
implementation to see if there would be way to make this entry
'special' so that it would not touch it.


My suggestion was that we should scrap the index entirely when in
EGL_ANDROID_blob_cache mode. Essentially the Android OS is managing
the cache index for us, so hopefully we don't need to maintain one.


One issue to tackle is that currently _mesa_glsl_compile_shader uses 
disk_cache_has_key() for detecting if we can skip shader compilation. 
This uses 'stored_keys' which is mmap of the index file.


I guess this could be done by inserting items for those shaders to 
blob_cache so disk_cache_has_key() could use get() for implementing this 
functionality. It seemed easier (and more optimal) to go with existing 
'index' for this but I can try alternative approach also.



I wouldn't be surprise if you told me that I'm not thinking about
something that the disk cache provides that EGL_ANDROID_blob_cache
couldn't, but it seems like we could rely on the OS to manage the
index.



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


[Mesa-dev] [PATCH] anv: implement VK_EXT_global_priority extension

2018-01-19 Thread Tapani Pälli
Signed-off-by: Tapani Pälli 
---

Small crucible test available here:
https://cgit.freedesktop.org/~tpalli/crucible/commit/?h=VK_EXT_global_priority

 src/intel/vulkan/anv_device.c  | 25 +++
 src/intel/vulkan/anv_extensions.py |  2 ++
 src/intel/vulkan/anv_gem.c | 49 ++
 src/intel/vulkan/anv_private.h |  7 ++
 4 files changed, 83 insertions(+)

diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c
index 777abd8757..42ebc19f2b 100644
--- a/src/intel/vulkan/anv_device.c
+++ b/src/intel/vulkan/anv_device.c
@@ -369,6 +369,9 @@ anv_physical_device_init(struct anv_physical_device *device,
device->has_syncobj_wait = device->has_syncobj &&
   anv_gem_supports_syncobj_wait(fd);
 
+   if (anv_gem_has_context_priority(fd))
+  device->has_context_priority = true;
+
bool swizzled = anv_gem_get_bit6_swizzle(fd, I915_TILING_X);
 
/* Starting with Gen10, the timestamp frequency of the command streamer may
@@ -1205,6 +1208,15 @@ VkResult anv_CreateDevice(
   }
}
 
+   /* Check if client specified queue priority. */
+   const VkDeviceQueueGlobalPriorityCreateInfoEXT *queue_priority =
+  vk_find_struct_const(pCreateInfo->pQueueCreateInfos[0].pNext,
+   DEVICE_QUEUE_GLOBAL_PRIORITY_CREATE_INFO_EXT);
+
+   VkQueueGlobalPriorityEXT priority =
+  queue_priority ? queue_priority->globalPriority :
+ VK_QUEUE_GLOBAL_PRIORITY_MEDIUM_EXT;
+
device = vk_alloc2(&physical_device->instance->alloc, pAllocator,
sizeof(*device), 8,
VK_SYSTEM_ALLOCATION_SCOPE_DEVICE);
@@ -1234,6 +1246,19 @@ VkResult anv_CreateDevice(
   goto fail_fd;
}
 
+   /* As per spec, the driver implementation may deny requests to acquire
+* a priority above the default priority (MEDIUM) if the caller does not
+* have sufficient privileges. In this scenario VK_ERROR_NOT_PERMITTED_EXT
+* is returned.
+*/
+   if (physical_device->has_context_priority) {
+  int err = anv_gem_set_context_priority(device, priority);
+  if (err != 0 && priority > VK_QUEUE_GLOBAL_PRIORITY_MEDIUM_EXT) {
+ result = vk_error(VK_ERROR_NOT_PERMITTED_EXT);
+ goto fail_fd;
+  }
+   }
+
device->info = physical_device->info;
device->isl_dev = physical_device->isl_dev;
 
diff --git a/src/intel/vulkan/anv_extensions.py 
b/src/intel/vulkan/anv_extensions.py
index adfebca985..aacf39248f 100644
--- a/src/intel/vulkan/anv_extensions.py
+++ b/src/intel/vulkan/anv_extensions.py
@@ -86,6 +86,8 @@ EXTENSIONS = [
 Extension('VK_KHX_multiview', 1, True),
 Extension('VK_EXT_debug_report',  8, True),
 Extension('VK_EXT_external_memory_dma_buf',   1, True),
+Extension('VK_EXT_global_priority',   1,
+  'device->has_context_priority'),
 ]
 
 class VkVersion:
diff --git a/src/intel/vulkan/anv_gem.c b/src/intel/vulkan/anv_gem.c
index 34c0989108..46069dcdc7 100644
--- a/src/intel/vulkan/anv_gem.c
+++ b/src/intel/vulkan/anv_gem.c
@@ -302,6 +302,55 @@ close_and_return:
return swizzled;
 }
 
+static int
+vk_priority_to_anv(int priority)
+{
+   switch (priority) {
+   case VK_QUEUE_GLOBAL_PRIORITY_LOW_EXT:
+  return ANV_CONTEXT_LOW_PRIORITY;
+   case VK_QUEUE_GLOBAL_PRIORITY_MEDIUM_EXT:
+  return ANV_CONTEXT_MEDIUM_PRIORITY;
+   case VK_QUEUE_GLOBAL_PRIORITY_HIGH_EXT:
+  return ANV_CONTEXT_HIGH_PRIORITY;
+   case VK_QUEUE_GLOBAL_PRIORITY_REALTIME_EXT:
+   default:
+  return -1;
+   }
+}
+
+static int
+_anv_gem_set_context_priority(int fd,
+  int context_id,
+  int priority)
+{
+   struct drm_i915_gem_context_param p = {
+  .ctx_id = context_id,
+  .param = I915_CONTEXT_PARAM_PRIORITY,
+  .value = vk_priority_to_anv(priority),
+   };
+   int err = 0;
+
+   if (anv_ioctl(fd, DRM_IOCTL_I915_GEM_CONTEXT_SETPARAM, &p))
+  err = -errno;
+
+   return err;
+}
+
+int
+anv_gem_set_context_priority(struct anv_device *device,
+ int priority)
+{
+   return _anv_gem_set_context_priority(device->fd, device->context_id,
+priority);
+}
+
+bool
+anv_gem_has_context_priority(int fd)
+{
+   return !_anv_gem_set_context_priority(fd, 0,
+ VK_QUEUE_GLOBAL_PRIORITY_MEDIUM_EXT);
+}
+
 int
 anv_gem_create_context(struct anv_device *device)
 {
diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h
index ed711e9434..caea3d96b4 100644
--- a/src/intel/vulkan/anv_private.h
+++ b/src/intel/vulkan/anv_private.h
@@ -106,6 +106,10 @@ struct gen_l3_config;
 #define ANV_SVGS_VB_INDEXMAX_VBS
 #define ANV_DRAWID_VB_INDEX (MA

Re: [Mesa-dev] [PATCH] mesa: Only require independent blending for GLES 3.2.

2018-01-19 Thread Tapani Pälli

Yep, that is addition to GLES 3.2 spec.

Reviewed-by: Tapani Pälli 

On 01/19/2018 07:36 AM, Eric Anholt wrote:

We've been requiring this since GLES 3.0 was introduced, but the GLES 3.2
spec is the one that has "Supporting blending on a per-draw-buffer basis"
in the new features.  V3D 3.3 would require lowering blending to shader
code to implement independent blending.
---
  src/mesa/main/version.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/mesa/main/version.c b/src/mesa/main/version.c
index 68079f4ebbba..1fce8fe7ca9c 100644
--- a/src/mesa/main/version.c
+++ b/src/mesa/main/version.c
@@ -516,7 +516,6 @@ compute_version_es2(const struct gl_extensions *extensions,
   extensions->ARB_texture_float &&
   extensions->ARB_texture_rg &&
   extensions->ARB_depth_buffer_float &&
- extensions->EXT_draw_buffers2 &&
   /* extensions->ARB_framebuffer_object && */
   extensions->EXT_framebuffer_sRGB &&
   extensions->EXT_packed_float &&
@@ -546,6 +545,7 @@ compute_version_es2(const struct gl_extensions *extensions,
   extensions->ARB_gpu_shader5 &&
   extensions->EXT_shader_integer_mix);
 const bool ver_3_2 = (ver_3_1 &&
+ extensions->EXT_draw_buffers2 &&
   extensions->KHR_blend_equation_advanced &&
   extensions->KHR_robustness &&
   extensions->KHR_texture_compression_astc_ldr &&


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


Re: [Mesa-dev] [PATCH] anv: avoid segmentation fault due to vk_error()

2018-01-19 Thread Tapani Pälli

Reviewed-by: Tapani Pälli 

(Fixes e5b1bd6ab8)

On 01/19/2018 09:59 AM, Samuel Iglesias Gonsálvez wrote:

vk_error() is a macro that calls __vk_errorf() with instance == NULL.

Then, __vk_errorf() passes a pointer to instance->debug_report_callbacks
to vk_debug_error(), which segfaults as this pointer is invalid but not
NULL.

Signed-off-by: Samuel Iglesias Gonsálvez 
---
  src/intel/vulkan/anv_util.c | 18 ++
  1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/src/intel/vulkan/anv_util.c b/src/intel/vulkan/anv_util.c
index 6b31224d7f1..3c1803aa056 100644
--- a/src/intel/vulkan/anv_util.c
+++ b/src/intel/vulkan/anv_util.c
@@ -99,14 +99,16 @@ __vk_errorf(struct anv_instance *instance, const void 
*object,
snprintf(report, sizeof(report), "%s:%d: %s", file, line, error_str);
 }
  
-   vk_debug_report(&instance->debug_report_callbacks,

-   VK_DEBUG_REPORT_ERROR_BIT_EXT,
-   type,
-   (uint64_t) (uintptr_t) object,
-   line,
-   0,
-   "anv",
-   report);
+   if (instance) {
+  vk_debug_report(&instance->debug_report_callbacks,
+  VK_DEBUG_REPORT_ERROR_BIT_EXT,
+  type,
+  (uint64_t) (uintptr_t) object,
+  line,
+  0,
+  "anv",
+  report);
+   }
  
 intel_loge("%s", report);
  


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


Re: [Mesa-dev] [PATCH] egl: do not expose EGL_EXT_pixel_format_float yet

2018-01-18 Thread Tapani Pälli



On 01/18/2018 03:31 PM, Emil Velikov wrote:

On 18 January 2018 at 06:05, Tapani Pälli  wrote:



On 01/17/2018 11:59 PM, Rob Herring wrote:


On Wed, Jan 17, 2018 at 12:27 PM, Tapani Pälli 
wrote:


Let's expose this only when we have formats. There are some
known issues when this is exposed without formats (on Android).



This is fixed now at least for master.



OK cool .. then I guess we don't really need to disable this.


Here is the patch [1] in case your tree/checkout doesn't have it.

-Emil

[1] https://android-review.googlesource.com/c/platform/frameworks/base/+/550746



Thanks! We should probably pick this up to Android-IA.

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


[Mesa-dev] [PATCH v2] egl: add support for EGL_ANDROID_blob_cache

2018-01-18 Thread Tapani Pälli
v2: cleanup, move callbacks to _egl_display struct (Emil Velikov)

Signed-off-by: Tapani Pälli 
---
 src/egl/drivers/dri2/egl_dri2.c | 39 +++
 src/egl/drivers/dri2/egl_dri2.h |  1 +
 src/egl/main/eglapi.c   | 30 ++
 src/egl/main/eglapi.h   |  4 
 src/egl/main/egldisplay.h   |  4 
 src/egl/main/eglentrypoint.h|  1 +
 6 files changed, 79 insertions(+)

diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index d5a4f72e86..c323a4989d 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -458,6 +458,7 @@ static const struct dri2_extension_match 
optional_core_extensions[] = {
{ __DRI2_INTEROP, 1, offsetof(struct dri2_egl_display, interop) },
{ __DRI_IMAGE, 1, offsetof(struct dri2_egl_display, image) },
{ __DRI2_FLUSH_CONTROL, 1, offsetof(struct dri2_egl_display, flush_control) 
},
+   { __DRI2_BLOB, 1, offsetof(struct dri2_egl_display, blob) },
{ NULL, 0, 0 }
 };
 
@@ -727,6 +728,9 @@ dri2_setup_screen(_EGLDisplay *disp)
   }
}
 
+   if (dri2_dpy->blob)
+  disp->Extensions.ANDROID_blob_cache = EGL_TRUE;
+
disp->Extensions.KHR_reusable_sync = EGL_TRUE;
 
if (dri2_dpy->image) {
@@ -1470,6 +1474,28 @@ dri2_surf_update_fence_fd(_EGLContext *ctx,
dri2_surface_set_out_fence_fd(surf, fence_fd);
 }
 
+static void
+update_blob_cache_functions( _EGLDisplay *disp, _EGLContext *ctx)
+{
+   struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
+   struct dri2_egl_context *dri2_ctx = dri2_egl_context(ctx);
+
+   if (!ctx)
+  return;
+
+   /* No blob support. */
+   if (!dri2_dpy->blob)
+  return;
+
+   /* No functions to set. */
+   if (!disp->BlobCacheSet)
+  return;
+
+   dri2_dpy->blob->set_cache_funcs(dri2_ctx->dri_context,
+   disp->BlobCacheSet,
+   disp->BlobCacheGet);
+}
+
 /**
  * Called via eglMakeCurrent(), drv->API.MakeCurrent().
  */
@@ -1499,6 +1525,9 @@ dri2_make_current(_EGLDriver *drv, _EGLDisplay *disp, 
_EGLSurface *dsurf,
if (old_ctx)
   dri2_gl_flush();
 
+   /* Make sure cache functions are set for new context. */
+   update_blob_cache_functions(disp, ctx);
+
ddraw = (dsurf) ? dri2_dpy->vtbl->get_dri_drawable(dsurf) : NULL;
rdraw = (rsurf) ? dri2_dpy->vtbl->get_dri_drawable(rsurf) : NULL;
cctx = (dri2_ctx) ? dri2_ctx->dri_context : NULL;
@@ -3016,6 +3045,15 @@ dri2_dup_native_fence_fd(_EGLDriver *drv, _EGLDisplay 
*dpy, _EGLSync *sync)
return dup(sync->SyncFd);
 }
 
+static void
+dri2_set_blob_cache_funcs(_EGLDriver *drv, _EGLDisplay *dpy,
+  EGLSetBlobFuncANDROID set,
+  EGLGetBlobFuncANDROID get)
+{
+   _EGLContext *ctx = _eglGetCurrentContext();
+   update_blob_cache_functions(dpy, ctx);
+}
+
 static EGLint
 dri2_client_wait_sync(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSync *sync,
   EGLint flags, EGLTime timeout)
@@ -3234,6 +3272,7 @@ _eglBuiltInDriver(void)
dri2_drv->API.GLInteropQueryDeviceInfo = dri2_interop_query_device_info;
dri2_drv->API.GLInteropExportObject = dri2_interop_export_object;
dri2_drv->API.DupNativeFenceFDANDROID = dri2_dup_native_fence_fd;
+   dri2_drv->API.SetBlobCacheFuncsANDROID = dri2_set_blob_cache_funcs;
 
dri2_drv->Name = "DRI2";
 
diff --git a/src/egl/drivers/dri2/egl_dri2.h b/src/egl/drivers/dri2/egl_dri2.h
index cc76c73eab..c49156fbb6 100644
--- a/src/egl/drivers/dri2/egl_dri2.h
+++ b/src/egl/drivers/dri2/egl_dri2.h
@@ -171,6 +171,7 @@ struct dri2_egl_display
const __DRInoErrorExtension*no_error;
const __DRI2configQueryExtension *config;
const __DRI2fenceExtension *fence;
+   const __DRI2blobExtension *blob;
const __DRI2rendererQueryExtension *rendererQuery;
const __DRI2interopExtension *interop;
int   fd;
diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c
index 5110688f2d..f2ba260060 100644
--- a/src/egl/main/eglapi.c
+++ b/src/egl/main/eglapi.c
@@ -476,6 +476,7 @@ _eglCreateExtensionsString(_EGLDisplay *dpy)
char *exts = dpy->ExtensionsString;
 
/* Please keep these sorted alphabetically. */
+   _EGL_CHECK_EXTENSION(ANDROID_blob_cache);
_EGL_CHECK_EXTENSION(ANDROID_framebuffer_target);
_EGL_CHECK_EXTENSION(ANDROID_image_native_buffer);
_EGL_CHECK_EXTENSION(ANDROID_native_fence_sync);
@@ -2522,6 +2523,35 @@ eglQueryDmaBufModifiersEXT(EGLDisplay dpy, EGLint 
format, EGLint max_modifiers,
RETURN_EGL_EVAL(disp, ret);
 }
 
+static void EGLAPIENTRY
+eglSetBlobCacheFuncsANDROID(EGLDisplay *dpy, EGLSetBlobFuncANDROID set,
+EGLGetBlobFuncANDROID get)
+{
+   _EGLDisplay *disp = _eglLockDisplay(dpy);
+   _EGLDriver *drv = _eglCheckDisplay(disp, __func__);
+
+   if (!set || !get) {
+  _eglError(EG

Re: [Mesa-dev] [PATCH 2/7] egl: add support for EGL_ANDROID_blob_cache

2018-01-18 Thread Tapani Pälli



On 01/18/2018 04:55 PM, Emil Velikov wrote:

On 17 January 2018 at 16:11, Tapani Pälli  wrote:



On 17.01.2018 13:28, Nicolai Hähnle wrote:


On 16.01.2018 18:45, Emil Velikov wrote:


Hi Tapani,

On 15 January 2018 at 12:31, Tapani Pälli  wrote:


+static void
+update_blob_cache_functions(struct dri2_egl_display *dri2_dpy,
+struct dri2_egl_context *dri2_ctx)
+{
+   if (!dri2_dpy || !dri2_ctx)
+  return;


AFAICT dri2_dpy can never be NULL.


+
+   /* No blob support. */
+   if (!dri2_dpy->blob)
+  return;
+
+   /* No functions to set. */
+   if (!dri2_dpy->blob_cache_set)
+  return;
+
+   dri2_dpy->blob->set_cache_funcs(dri2_ctx->dri_context,
+   dri2_dpy->blob_cache_set,
+   dri2_dpy->blob_cache_get);
+}
+


I'm wondering why you opted to make set_cache_funcs dri_context
specific as opposed to dri_screen.
The latter seems to align better to EGLDisplay.

Plus doing so will simplify the existing code - no hunk in
dri2_make_current, no dri2_dpy->blob/blob_cache_set checks, etc.



Yes, please make it a screen thing. It just makes more sense, and there's
precedent in Gallium, where the disk-cache is a per-pipe_screen object as
well.



I chose context because eventually I need to access disk_cache which is part
of gl_context. I'm not sure how would I propagate the set/get there from
dri_screen?


Gallium does the following during create_context. I'm not sure if
there's any particular reason why i965 cannot do the same.
Tim, you've worked a fair bit in the area do you see any drawbacks?

ctx->Cache = pipe->screen->det_dist_shader_cache(pipe->screen);



One problem is that client might set the callbacks only after context 
creation so we need to be able to do this during set_cache_funcs(). Now 
it works fine because we pass context there.


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


Re: [Mesa-dev] [PATCH 6/7] android: ignore MESA_GLSL_CACHE_DISABLE setting

2018-01-18 Thread Tapani Pälli



On 01/18/2018 04:59 PM, Emil Velikov wrote:

On 17 January 2018 at 08:12, Tapani Pälli  wrote:



On 16.01.2018 11:02, Jordan Justen wrote:


On 2018-01-15 04:31:42, Tapani Pälli wrote:


Signed-off-by: Tapani Pälli 
---
   src/mesa/drivers/dri/i965/brw_disk_cache.c | 2 ++
   src/util/disk_cache.c  | 2 ++
   2 files changed, 4 insertions(+)

diff --git a/src/mesa/drivers/dri/i965/brw_disk_cache.c
b/src/mesa/drivers/dri/i965/brw_disk_cache.c
index 65bb52726e..4df4504666 100644
--- a/src/mesa/drivers/dri/i965/brw_disk_cache.c
+++ b/src/mesa/drivers/dri/i965/brw_disk_cache.c
@@ -405,8 +405,10 @@ void
   brw_disk_cache_init(struct brw_context *brw)
   {
   #ifdef ENABLE_SHADER_CACHE
+#ifndef ANDROID
  if (env_var_as_boolean("MESA_GLSL_CACHE_DISABLE", true))
 return;
+#endif



Arguably, if we don't want to enable the shader cache in i965, then we
probably wouldn't want to enable EGL_ANDROID_blob_cache that hits the
same paths.

Since the 18.0 branch is happening soon, two questions arise:

1. Should we enable the shader cache on i965 by default in the 18.0
 release.

2. If not, should we enable it on master after the 18.0 branch.

I guess if neither of these are yes, we could discuss whether it is
okay to enable this Android feature even though we don't want to
enable the shader cache on i965.


  char renderer[10];
  MAYBE_UNUSED int len = snprintf(renderer, sizeof(renderer),
"i965_%04x",
diff --git a/src/util/disk_cache.c b/src/util/disk_cache.c
index d7891e3b70..3c98089e69 100644
--- a/src/util/disk_cache.c
+++ b/src/util/disk_cache.c
@@ -208,9 +208,11 @@ disk_cache_create(const char *gpu_name, const char
*timestamp,
  if (local == NULL)
 goto fail;
   +#ifndef ANDROID
  /* At user request, disable shader cache entirely. */
  if (env_var_as_boolean("MESA_GLSL_CACHE_DISABLE", false))
 goto fail;
+#endif



This just allows someone to force the cache feature off. This should
be safe, so I think we should leave it.



True, will change the patch. This patch was actually a bit of extra and does
not need to land on master, we can enable it on master at same time as for
Linux desktop (whenever that happens). If Android-IA wants to enable it,
they can use this patch or similar.


Setting the env. variable might be easier than patching it out.
Adds the benefit of toggling on/off via a simple config file change,
instead of building a complete image ;-)

Or perhaps the Android security model is blocking envvar manipulation?


This environment variable would need to be there when Surfaceflinger 
starts, so I guess it means having that in init.environ.rc. I can try if 
it gets propagated to everyone from there. Then one needs to do only 
stop/start cycle or reboot and no need to build and copy new mesa library.


One flexible option would be also to use drirc (which we do have), but 
then you need to do start/stop cycle as well.


In any case, I think this patch should be scrapped, toggling it on can 
be separate patch in Android tree.


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


Re: [Mesa-dev] Logging infrastructure?

2018-01-18 Thread Tapani Pälli

Hi;

On 01/18/2018 11:44 PM, Chuck Atkins wrote:
Is there a logging infrastructure currently available to drivers in 
Mesa?  I was looking to clean up some of swr's debug / info output and 
have it conditional on the MESA_DEBUG and LIBGL_DEBUG variables but then 
I realized that it's really something useful all across mesa so there 
may already be something there for it.  If not though, I'd be interested 
in adding some very light weight functions for just that purpose could 
be used by any driver rather than just fprintf(stderr, ...);




IMO infrastructure in src/intel/common/intel_log.h by Chad could be 
moved to src/util as a 'common Mesa thing'?


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


Re: [Mesa-dev] [PATCH 7/7] android: set '/sdcard/' as MESA_GLSL_CACHE_DIR by default

2018-01-18 Thread Tapani Pälli



On 01/18/2018 08:18 PM, Jordan Justen wrote:

On 2018-01-15 04:31:43, Tapani Pälli wrote:

This can/should be modified depending on needs. AFAIK by default,
this is the only path that can be read/written to by anyone.

Signed-off-by: Tapani Pälli 
---
  Android.common.mk | 1 +
  1 file changed, 1 insertion(+)

diff --git a/Android.common.mk b/Android.common.mk
index 52dc7bff3b..7edbbfc0f2 100644
--- a/Android.common.mk
+++ b/Android.common.mk
@@ -47,6 +47,7 @@ LOCAL_CFLAGS += \
  LOCAL_CFLAGS += \
 -DANDROID_API_LEVEL=$(PLATFORM_SDK_VERSION) \
 -DENABLE_SHADER_CACHE \
+   -DMESA_GLSL_CACHE_DIR="/sdcard" \


Is this used when EGL_ANDROID_blob_cache is being used?

My thought is that if we are running under android with
EGL_ANDROID_blob_cache, then we should never attempt to write any
files with src/util/disk_cache.c. This might cause a little rework,
since the shader cache want to write/manage the index file, but can we
skip this and only use the blob cache read/write function when
EGL_ANDROID_blob_cache is available?


I'm a bit pessimistic about that. Since cache location depends on 
running app that would mean every app has it's own index (that not 
really a problem though but is different from desktop). The big problem 
I see there that index will be then 'just another cache entry', I'll 
have to get more familiar with Android's implementation to see if there 
would be way to make this entry 'special' so that it would not touch it.


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


Re: [Mesa-dev] [PATCH 0/7] EGL_ANDROID_blob_cache

2018-01-18 Thread Tapani Pälli



On 01/18/2018 05:49 PM, Nicolai Hähnle wrote:

On 17.01.2018 17:10, Tapani Pälli wrote:



On 17.01.2018 13:34, Nicolai Hähnle wrote:

On 15.01.2018 13:31, Tapani Pälli wrote:

Hello;

Here's a refactored series of EGL_ANDROID_blob_cache. Now cache
functions are stored in disk_cache struct and the functionality
called within existing disk_cache put/get code. Problems/errors
that existed with earlier series are gone.

On Android cache index file is created to MESA_GLSL_CACHE_DIR
and blobs are  generated under '/data/user_de/0' in application
specific paths:


Can't we let the "cache index" be managed by the ANDROID_blob_cache 
as well? That seems to me more in the spirit of what that extension 
is about, and would avoid polluting stuff like /sdcard.


The cache index file is used for two purposes:

- Keeping track of the size of the cache. This use is obsoleted 
enterely by ANDROID_blob_cache.


- Keeping track of keys where only their presence is relevant and no 
data is associated. These could easily be treated as empty (0 byte 
sized) blobs.


I guess it could be possible, for every app we would create index when 
disk_cache gets created. I guess only issue could be that Android 
might go and remove the index from cache when it decides to resize it 
and then we would loose it even though there would be items in cache. 
I can try how this would work.


Entries can be kicked out of the on-disk index (which is really a bit of 
a misnomer) as well if there's a hash collision.


I believe this functionality is only used as a marker to indicate that 
the GLSL compile step can be skipped. So losing an entry in there 
shouldn't cause any damage.


What I meant is that if we would store index by using set() function, 
the index itself would be just another entry for Android's cache, it can 
decide to remove it when it manages cache size.



Cheers,
Nicolai






Cheers,
Nicolai





androidia_64:/ # find /data/user_de/0/ -name *shader*
/data/user_de/0/com.android.settings/code_cache/com.android.opengl.shaders_cache 

/data/user_de/0/com.android.gallery3d/code_cache/com.android.opengl.shaders_cache 

/data/user_de/0/com.android.systemui/code_cache/com.android.opengl.shaders_cache 

/data/user_de/0/com.rovio.angrybirdsspace.ads/code_cache/com.android.opengl.shaders_cache 



(this part is managed by Android but may be interesting to know).

Also SurfaceFlinger manages its own cache as seen in the log output:
01-15 07:40:26.329  2129  2129 D SurfaceFlinger: shader cache 
generated - 24 shaders in 57.687504 ms


I'm not sure if /sdcard is sane default but I've tried everything
else (/cache, /data/cache) and failed because of permission errors.

Thanks;

Tapani Pälli (7):
   dri: add interface for EGL_ANDROID_blob_cache extension
   egl: add support for EGL_ANDROID_blob_cache
   disk cache: add callback functionality
   disk cache: support setting MESA_GLSL_CACHE_DIR at compile time
   i965: add __DRI2_BLOB support and set cache functions
   android: ignore MESA_GLSL_CACHE_DISABLE setting
   android: set '/sdcard/' as MESA_GLSL_CACHE_DIR by default

  Android.common.mk  |  1 +
  include/GL/internal/dri_interface.h    | 26 +-
  src/egl/drivers/dri2/egl_dri2.c    | 43 


  src/egl/drivers/dri2/egl_dri2.h    |  4 +++
  src/egl/main/eglapi.c  | 29 
  src/egl/main/eglapi.h  |  4 +++
  src/egl/main/egldisplay.h  |  3 ++
  src/egl/main/eglentrypoint.h   |  1 +
  src/mesa/drivers/dri/i965/brw_disk_cache.c |  2 ++
  src/mesa/drivers/dri/i965/intel_screen.c   | 21 
  src/util/disk_cache.c  | 54 
+-

  src/util/disk_cache.h  | 19 +++
  12 files changed, 205 insertions(+), 2 deletions(-)








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


Re: [Mesa-dev] [PATCH] egl: do not expose EGL_EXT_pixel_format_float yet

2018-01-18 Thread Tapani Pälli



On 01/17/2018 11:59 PM, Rob Herring wrote:

On Wed, Jan 17, 2018 at 12:27 PM, Tapani Pälli  wrote:

Let's expose this only when we have formats. There are some
known issues when this is exposed without formats (on Android).


This is fixed now at least for master.



OK cool .. then I guess we don't really need to disable this.

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


Re: [Mesa-dev] [PATCH 7/7] android: set '/sdcard/' as MESA_GLSL_CACHE_DIR by default

2018-01-18 Thread Tapani Pälli



On 01/18/2018 12:03 AM, Rob Herring wrote:

On Mon, Jan 15, 2018 at 6:31 AM, Tapani Pälli  wrote:

This can/should be modified depending on needs. AFAIK by default,
this is the only path that can be read/written to by anyone.

Signed-off-by: Tapani Pälli 
---
  Android.common.mk | 1 +
  1 file changed, 1 insertion(+)

diff --git a/Android.common.mk b/Android.common.mk
index 52dc7bff3b..7edbbfc0f2 100644
--- a/Android.common.mk
+++ b/Android.common.mk
@@ -47,6 +47,7 @@ LOCAL_CFLAGS += \
  LOCAL_CFLAGS += \
 -DANDROID_API_LEVEL=$(PLATFORM_SDK_VERSION) \
 -DENABLE_SHADER_CACHE \
+   -DMESA_GLSL_CACHE_DIR="/sdcard" \


Isn't this a legacy path? I'm not really sure. Seems like somewhere
under /cache would be more appropriate.


I tested '/cache/', and '/data/cache' but got 'Operation not permitted' 
for the apps :/ Only settings app was able to write cache there, rest of 
the apps not. It was likely the first app that wrote cache or has 
different set of permissions? Or is it possible that Android-IA has 
messed up the permissions for these paths, not sure what the standard 
permissions are?




 -D__STDC_CONSTANT_MACROS \
 -D__STDC_LIMIT_MACROS \
 -DHAVE___BUILTIN_EXPECT \
--
2.14.3

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


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


[Mesa-dev] [PATCH] egl: do not expose EGL_EXT_pixel_format_float yet

2018-01-17 Thread Tapani Pälli
Let's expose this only when we have formats. There are some
known issues when this is exposed without formats (on Android).

Signed-off-by: Tapani Pälli 
---
 src/egl/drivers/dri2/egl_dri2.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index d5a4f72e86..548a3942d6 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -695,8 +695,6 @@ dri2_setup_screen(_EGLDisplay *disp)
   dri2_renderer_query_integer(dri2_dpy,
   __DRI2_RENDERER_HAS_CONTEXT_PRIORITY);
 
-   disp->Extensions.EXT_pixel_format_float = EGL_TRUE;
-
if (dri2_renderer_query_integer(dri2_dpy,
__DRI2_RENDERER_HAS_FRAMEBUFFER_SRGB))
   disp->Extensions.KHR_gl_colorspace = EGL_TRUE;
-- 
2.13.6

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


Re: [Mesa-dev] [PATCH 2/7] egl: add support for EGL_ANDROID_blob_cache

2018-01-17 Thread Tapani Pälli



On 17.01.2018 13:28, Nicolai Hähnle wrote:

On 16.01.2018 18:45, Emil Velikov wrote:

Hi Tapani,

On 15 January 2018 at 12:31, Tapani Pälli  wrote:


+static void
+update_blob_cache_functions(struct dri2_egl_display *dri2_dpy,
+    struct dri2_egl_context *dri2_ctx)
+{
+   if (!dri2_dpy || !dri2_ctx)
+  return;

AFAICT dri2_dpy can never be NULL.


+
+   /* No blob support. */
+   if (!dri2_dpy->blob)
+  return;
+
+   /* No functions to set. */
+   if (!dri2_dpy->blob_cache_set)
+  return;
+
+   dri2_dpy->blob->set_cache_funcs(dri2_ctx->dri_context,
+   dri2_dpy->blob_cache_set,
+   dri2_dpy->blob_cache_get);
+}
+

I'm wondering why you opted to make set_cache_funcs dri_context
specific as opposed to dri_screen.
The latter seems to align better to EGLDisplay.

Plus doing so will simplify the existing code - no hunk in
dri2_make_current, no dri2_dpy->blob/blob_cache_set checks, etc.


Yes, please make it a screen thing. It just makes more sense, and 
there's precedent in Gallium, where the disk-cache is a per-pipe_screen 
object as well.


I chose context because eventually I need to access disk_cache which is 
part of gl_context. I'm not sure how would I propagate the set/get there 
from dri_screen?




Thanks,
Nicolai






@@ -230,6 +231,9 @@ struct dri2_egl_display

 bool  is_render_node;
 bool  is_different_gpu;
+
+   EGLSetBlobFuncANDROID blob_cache_set;
+   EGLGetBlobFuncANDROID blob_cache_get;

These two are part of the EGL API, so they are better suited in struct
_egl_display.

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





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


Re: [Mesa-dev] [PATCH 0/7] EGL_ANDROID_blob_cache

2018-01-17 Thread Tapani Pälli



On 17.01.2018 13:34, Nicolai Hähnle wrote:

On 15.01.2018 13:31, Tapani Pälli wrote:

Hello;

Here's a refactored series of EGL_ANDROID_blob_cache. Now cache
functions are stored in disk_cache struct and the functionality
called within existing disk_cache put/get code. Problems/errors
that existed with earlier series are gone.

On Android cache index file is created to MESA_GLSL_CACHE_DIR
and blobs are  generated under '/data/user_de/0' in application
specific paths:


Can't we let the "cache index" be managed by the ANDROID_blob_cache as 
well? That seems to me more in the spirit of what that extension is 
about, and would avoid polluting stuff like /sdcard.


The cache index file is used for two purposes:

- Keeping track of the size of the cache. This use is obsoleted enterely 
by ANDROID_blob_cache.


- Keeping track of keys where only their presence is relevant and no 
data is associated. These could easily be treated as empty (0 byte 
sized) blobs.


I guess it could be possible, for every app we would create index when 
disk_cache gets created. I guess only issue could be that Android might 
go and remove the index from cache when it decides to resize it and then 
we would loose it even though there would be items in cache. I can try 
how this would work.




Cheers,
Nicolai





androidia_64:/ # find /data/user_de/0/ -name *shader*
/data/user_de/0/com.android.settings/code_cache/com.android.opengl.shaders_cache 

/data/user_de/0/com.android.gallery3d/code_cache/com.android.opengl.shaders_cache 

/data/user_de/0/com.android.systemui/code_cache/com.android.opengl.shaders_cache 

/data/user_de/0/com.rovio.angrybirdsspace.ads/code_cache/com.android.opengl.shaders_cache 



(this part is managed by Android but may be interesting to know).

Also SurfaceFlinger manages its own cache as seen in the log output:
01-15 07:40:26.329  2129  2129 D SurfaceFlinger: shader cache 
generated - 24 shaders in 57.687504 ms


I'm not sure if /sdcard is sane default but I've tried everything
else (/cache, /data/cache) and failed because of permission errors.

Thanks;

Tapani Pälli (7):
   dri: add interface for EGL_ANDROID_blob_cache extension
   egl: add support for EGL_ANDROID_blob_cache
   disk cache: add callback functionality
   disk cache: support setting MESA_GLSL_CACHE_DIR at compile time
   i965: add __DRI2_BLOB support and set cache functions
   android: ignore MESA_GLSL_CACHE_DISABLE setting
   android: set '/sdcard/' as MESA_GLSL_CACHE_DIR by default

  Android.common.mk  |  1 +
  include/GL/internal/dri_interface.h    | 26 +-
  src/egl/drivers/dri2/egl_dri2.c    | 43 


  src/egl/drivers/dri2/egl_dri2.h    |  4 +++
  src/egl/main/eglapi.c  | 29 
  src/egl/main/eglapi.h  |  4 +++
  src/egl/main/egldisplay.h  |  3 ++
  src/egl/main/eglentrypoint.h   |  1 +
  src/mesa/drivers/dri/i965/brw_disk_cache.c |  2 ++
  src/mesa/drivers/dri/i965/intel_screen.c   | 21 
  src/util/disk_cache.c  | 54 
+-

  src/util/disk_cache.h  | 19 +++
  12 files changed, 205 insertions(+), 2 deletions(-)





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


Re: [Mesa-dev] Mesa 18.0.0 release plan

2018-01-17 Thread Tapani Pälli



On 17.01.2018 16:03, Emil Velikov wrote:

On 16 January 2018 at 21:57, Kenneth Graunke  wrote:

On Tuesday, January 16, 2018 11:18:13 AM PST Emil Velikov wrote:

Hi all,

As you've know the Mesa 18.0.0 release plan has been available for a while
on the mesa3d.org website [1].

In case you've missed it here it is:

  Jan 19 2018 - Feature freeze/Release candidate 1
  Jan 26 2018 - Release candidate 2
  Feb 02 2018 - Release candidate 3
  Feb 09 2018 - Release candidate 4/final release

This gives us half a week until the branch point.

As this is shorter notice than usual, I'm open to adjusting the schedule by a
week. Do let me know ASAP, if we should go that route.

As always - do list features/sets that you'd like to see merged. Thus we can
all have a clear idea and prioritise accordingly.

Thanks
Emil

[1] https://www.mesa3d.org/release-calendar.html


A few observations and some questions...

Although 17.3 was branched in late October, 17.3.0 wasn't released until
December 8th - about 6 weeks ago.  17.3.x also shipped with a pretty
catastrophic DRI3 bug that caused tons of applications to segfault,
which was fixed by 897c54d522ab960a879b763a15e489f630c491ee, but that
hasn't yet made it into a shipping 17.3.x release.  Arguably, I think
17.3.3 is going to be the first usable 17.3.x release.

So...is it too early to branch for 18.0?


Perhaps. The way I try to look at it is the volume of development as
opposed to when bug X or Y is fixed.
Sadly bugs never end, yet users can evaluate which ones they can live
with. At least temporarily.

I realise it sounds mean/etc. but such is reality.


- Have distros picked up 17.3.x yet?

Quick and dirty check says yes*

Gentoo   yes 17.3.1 as testing;17.2.7 as stable
Debian   yes 17.3.2 in unstable;   13.0.6 in stable
Ubuntu   no  17.2.4 in bionic; 17.2.2 in artful <<< The exception
openSUSE yes 17.3.2 in Tumbleweed; 17.0.5 Leap 42.3
Fedora   yes 17.3.0 in Rawhide,17.2.4 FC27
Arch yes 17.3.2


- Is there anything in master that people are excited about shipping?


Here's a quick list. Pretty sure people will fancy some bits.

- GL/GLES
GL 4.3 and GLES 3.1 on r600/evergreen+
Disk cache support for i965 (disabled by default)
ARB_get_program_binary with 1 format on i965 \o/

- GLX/EGL
GLX_ARB_context_flush_control
EGL_KHR_context_flush_control
EGL_IMG_context_priority for freedreno
EGL_EXT_pixel_format_float, with 0 advertised float formats :-\


I've been planning to revert this but forgot about it. Let's revert 
before 18.0 and bring back only when we have actual formats behind it.



- Vulkan ANV
VK_EXT_external_memory_dma_buf
Alpha Gen 10 support

- Vulkan RADV
VK_KHR_external_fence*
VK_KHR_get_surface_capabilities2
VK_EXT_discard_rectangles
VK_EXT_external_memory_dma_buf
VK_AMD_shader_info

- Vulkan common
Generic DRI_PRIME support (not 100% sure if that one landed yet)

- Initial VC5 support
Simulator only


- There are about 2 months of work since the 17.3.x branch point
   (half of October, all of November, about half of December because
   so many people were on holidays).


Indeed, commit count reflects that ~2.2k for 18.0 with ~2.5k for 17.3.
Yet again, numbers always go up and down through the year. Be that
winter festivities, (late) summer vacations, other.


I'm wondering if a mid-February branch point and March release would
make more sense, just to space them out.  Then again, I've also
suggested doing 3 releases a year in the past, since I thought they were
too close together.  So, if people disagree, I'm totally fine with that.


I think this is _the_ question. Might be worth bringing up to
mesa-maintainers@ so that distro people can (find easier and) chip-in.

Personally I'm fine with either three or four releases. As mentioned
by Nicolai, using 3 will make it a bit harder to fit around
distribution schedules though.

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


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


Re: [Mesa-dev] [PATCH 2/7] egl: add support for EGL_ANDROID_blob_cache

2018-01-17 Thread Tapani Pälli



On 16.01.2018 19:45, Emil Velikov wrote:

Hi Tapani,

On 15 January 2018 at 12:31, Tapani Pälli  wrote:


+static void
+update_blob_cache_functions(struct dri2_egl_display *dri2_dpy,
+struct dri2_egl_context *dri2_ctx)
+{
+   if (!dri2_dpy || !dri2_ctx)
+  return;

AFAICT dri2_dpy can never be NULL.


Yeah, that check can be removed.

It was because of my 'debug framework' (see eariler RFC). It was hit 
when running PIGLIT_PLATFORM=gbm and during Piglit teardown we end up 
here from eglMakeCurrent that called drv->API.SetBlobCacheFuncsANDROID 
(and which is called during __run_exit_handlers) and display is then 
0x0. But it won't ever happen without my 'debug framework' addition.




+
+   /* No blob support. */
+   if (!dri2_dpy->blob)
+  return;
+
+   /* No functions to set. */
+   if (!dri2_dpy->blob_cache_set)
+  return;
+
+   dri2_dpy->blob->set_cache_funcs(dri2_ctx->dri_context,
+   dri2_dpy->blob_cache_set,
+   dri2_dpy->blob_cache_get);
+}
+

I'm wondering why you opted to make set_cache_funcs dri_context
specific as opposed to dri_screen.
The latter seems to align better to EGLDisplay.

Plus doing so will simplify the existing code - no hunk in
dri2_make_current, no dri2_dpy->blob/blob_cache_set checks, etc.


It's an extension so we would still need dri2_dpy->blob check but maybe 
not so much checks overall .. I'll see how that would look. Thanks!





@@ -230,6 +231,9 @@ struct dri2_egl_display

 bool  is_render_node;
 bool  is_different_gpu;
+
+   EGLSetBlobFuncANDROID blob_cache_set;
+   EGLGetBlobFuncANDROID blob_cache_get;

These two are part of the EGL API, so they are better suited in struct
_egl_display.


OK, will move them there.

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


Re: [Mesa-dev] [PATCH 6/7] android: ignore MESA_GLSL_CACHE_DISABLE setting

2018-01-17 Thread Tapani Pälli



On 16.01.2018 11:02, Jordan Justen wrote:

On 2018-01-15 04:31:42, Tapani Pälli wrote:

Signed-off-by: Tapani Pälli 
---
  src/mesa/drivers/dri/i965/brw_disk_cache.c | 2 ++
  src/util/disk_cache.c  | 2 ++
  2 files changed, 4 insertions(+)

diff --git a/src/mesa/drivers/dri/i965/brw_disk_cache.c 
b/src/mesa/drivers/dri/i965/brw_disk_cache.c
index 65bb52726e..4df4504666 100644
--- a/src/mesa/drivers/dri/i965/brw_disk_cache.c
+++ b/src/mesa/drivers/dri/i965/brw_disk_cache.c
@@ -405,8 +405,10 @@ void
  brw_disk_cache_init(struct brw_context *brw)
  {
  #ifdef ENABLE_SHADER_CACHE
+#ifndef ANDROID
 if (env_var_as_boolean("MESA_GLSL_CACHE_DISABLE", true))
return;
+#endif


Arguably, if we don't want to enable the shader cache in i965, then we
probably wouldn't want to enable EGL_ANDROID_blob_cache that hits the
same paths.

Since the 18.0 branch is happening soon, two questions arise:

1. Should we enable the shader cache on i965 by default in the 18.0
release.

2. If not, should we enable it on master after the 18.0 branch.

I guess if neither of these are yes, we could discuss whether it is
okay to enable this Android feature even though we don't want to
enable the shader cache on i965.


 char renderer[10];
 MAYBE_UNUSED int len = snprintf(renderer, sizeof(renderer), "i965_%04x",
diff --git a/src/util/disk_cache.c b/src/util/disk_cache.c
index d7891e3b70..3c98089e69 100644
--- a/src/util/disk_cache.c
+++ b/src/util/disk_cache.c
@@ -208,9 +208,11 @@ disk_cache_create(const char *gpu_name, const char 
*timestamp,
 if (local == NULL)
goto fail;
  
+#ifndef ANDROID

 /* At user request, disable shader cache entirely. */
 if (env_var_as_boolean("MESA_GLSL_CACHE_DISABLE", false))
goto fail;
+#endif


This just allows someone to force the cache feature off. This should
be safe, so I think we should leave it.


True, will change the patch. This patch was actually a bit of extra and 
does not need to land on master, we can enable it on master at same time 
as for Linux desktop (whenever that happens). If Android-IA wants to 
enable it, they can use this patch or similar.




-Jordan


 /* Determine path for cache based on the first defined name as follows:
  *
--
2.14.3

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

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


Re: [Mesa-dev] [PATCH] st/dri: Default ALLOW_RGB10_CONFIGS to false on gallium as well.

2018-01-15 Thread Tapani Pälli

Reviewed-by: Tapani Pälli 

On 16.01.2018 06:39, Mario Kleiner wrote:

For consistency with the i965 default of "off".

Signed-off-by: Mario Kleiner 
---
  src/gallium/auxiliary/pipe-loader/driinfo_gallium.h | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/gallium/auxiliary/pipe-loader/driinfo_gallium.h 
b/src/gallium/auxiliary/pipe-loader/driinfo_gallium.h
index 505aae4..446bc06 100644
--- a/src/gallium/auxiliary/pipe-loader/driinfo_gallium.h
+++ b/src/gallium/auxiliary/pipe-loader/driinfo_gallium.h
@@ -32,5 +32,5 @@ DRI_CONF_SECTION_END
  DRI_CONF_SECTION_MISCELLANEOUS
 DRI_CONF_ALWAYS_HAVE_DEPTH_BUFFER("false")
 DRI_CONF_GLSL_ZERO_INIT("false")
-   DRI_CONF_ALLOW_RGB10_CONFIGS("true")
+   DRI_CONF_ALLOW_RGB10_CONFIGS("false")
  DRI_CONF_SECTION_END


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


[Mesa-dev] [PATCH 2/7] egl: add support for EGL_ANDROID_blob_cache

2018-01-15 Thread Tapani Pälli
Signed-off-by: Tapani Pälli 
---
 src/egl/drivers/dri2/egl_dri2.c | 43 +
 src/egl/drivers/dri2/egl_dri2.h |  4 
 src/egl/main/eglapi.c   | 29 +++
 src/egl/main/eglapi.h   |  4 
 src/egl/main/egldisplay.h   |  3 +++
 src/egl/main/eglentrypoint.h|  1 +
 6 files changed, 84 insertions(+)

diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index d5a4f72e86..f9d0223fe2 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -458,6 +458,7 @@ static const struct dri2_extension_match 
optional_core_extensions[] = {
{ __DRI2_INTEROP, 1, offsetof(struct dri2_egl_display, interop) },
{ __DRI_IMAGE, 1, offsetof(struct dri2_egl_display, image) },
{ __DRI2_FLUSH_CONTROL, 1, offsetof(struct dri2_egl_display, flush_control) 
},
+   { __DRI2_BLOB, 1, offsetof(struct dri2_egl_display, blob) },
{ NULL, 0, 0 }
 };
 
@@ -727,6 +728,9 @@ dri2_setup_screen(_EGLDisplay *disp)
   }
}
 
+   if (dri2_dpy->blob)
+  disp->Extensions.ANDROID_blob_cache = EGL_TRUE;
+
disp->Extensions.KHR_reusable_sync = EGL_TRUE;
 
if (dri2_dpy->image) {
@@ -1470,6 +1474,26 @@ dri2_surf_update_fence_fd(_EGLContext *ctx,
dri2_surface_set_out_fence_fd(surf, fence_fd);
 }
 
+static void
+update_blob_cache_functions(struct dri2_egl_display *dri2_dpy,
+struct dri2_egl_context *dri2_ctx)
+{
+   if (!dri2_dpy || !dri2_ctx)
+  return;
+
+   /* No blob support. */
+   if (!dri2_dpy->blob)
+  return;
+
+   /* No functions to set. */
+   if (!dri2_dpy->blob_cache_set)
+  return;
+
+   dri2_dpy->blob->set_cache_funcs(dri2_ctx->dri_context,
+   dri2_dpy->blob_cache_set,
+   dri2_dpy->blob_cache_get);
+}
+
 /**
  * Called via eglMakeCurrent(), drv->API.MakeCurrent().
  */
@@ -1499,6 +1523,9 @@ dri2_make_current(_EGLDriver *drv, _EGLDisplay *disp, 
_EGLSurface *dsurf,
if (old_ctx)
   dri2_gl_flush();
 
+   /* Make sure cache functions are set for new context. */
+   update_blob_cache_functions(dri2_dpy, dri2_ctx);
+
ddraw = (dsurf) ? dri2_dpy->vtbl->get_dri_drawable(dsurf) : NULL;
rdraw = (rsurf) ? dri2_dpy->vtbl->get_dri_drawable(rsurf) : NULL;
cctx = (dri2_ctx) ? dri2_ctx->dri_context : NULL;
@@ -3016,6 +3043,21 @@ dri2_dup_native_fence_fd(_EGLDriver *drv, _EGLDisplay 
*dpy, _EGLSync *sync)
return dup(sync->SyncFd);
 }
 
+static void
+dri2_set_blob_cache_funcs(_EGLDriver *drv, _EGLDisplay *dpy,
+  EGLSetBlobFuncANDROID set,
+  EGLGetBlobFuncANDROID get)
+{
+   _EGLContext *ctx = _eglGetCurrentContext();
+   struct dri2_egl_display *dri2_dpy = dri2_egl_display(dpy);
+   struct dri2_egl_context *dri2_ctx = dri2_egl_context(ctx);
+
+   dri2_dpy->blob_cache_set = set;
+   dri2_dpy->blob_cache_get = get;
+
+   update_blob_cache_functions(dri2_dpy, dri2_ctx);
+}
+
 static EGLint
 dri2_client_wait_sync(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSync *sync,
   EGLint flags, EGLTime timeout)
@@ -3234,6 +3276,7 @@ _eglBuiltInDriver(void)
dri2_drv->API.GLInteropQueryDeviceInfo = dri2_interop_query_device_info;
dri2_drv->API.GLInteropExportObject = dri2_interop_export_object;
dri2_drv->API.DupNativeFenceFDANDROID = dri2_dup_native_fence_fd;
+   dri2_drv->API.SetBlobCacheFuncsANDROID = dri2_set_blob_cache_funcs;
 
dri2_drv->Name = "DRI2";
 
diff --git a/src/egl/drivers/dri2/egl_dri2.h b/src/egl/drivers/dri2/egl_dri2.h
index cc76c73eab..a6777ad3f1 100644
--- a/src/egl/drivers/dri2/egl_dri2.h
+++ b/src/egl/drivers/dri2/egl_dri2.h
@@ -171,6 +171,7 @@ struct dri2_egl_display
const __DRInoErrorExtension*no_error;
const __DRI2configQueryExtension *config;
const __DRI2fenceExtension *fence;
+   const __DRI2blobExtension *blob;
const __DRI2rendererQueryExtension *rendererQuery;
const __DRI2interopExtension *interop;
int   fd;
@@ -230,6 +231,9 @@ struct dri2_egl_display
 
bool  is_render_node;
bool  is_different_gpu;
+
+   EGLSetBlobFuncANDROID blob_cache_set;
+   EGLGetBlobFuncANDROID blob_cache_get;
 };
 
 struct dri2_egl_context
diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c
index 5110688f2d..b8d64a913c 100644
--- a/src/egl/main/eglapi.c
+++ b/src/egl/main/eglapi.c
@@ -476,6 +476,7 @@ _eglCreateExtensionsString(_EGLDisplay *dpy)
char *exts = dpy->ExtensionsString;
 
/* Please keep these sorted alphabetically. */
+   _EGL_CHECK_EXTENSION(ANDROID_blob_cache);
_EGL_CHECK_EXTENSION(ANDROID_framebuffer_target);
_EGL_CHECK_EXTENSION(ANDROID_image_native_buffer);
_EGL_CHECK_EXTENSION(ANDROID_native_fence_sync);
@@ -2522,6 +2523,34 @@ eglQueryDmaBufModifiersEXT(EGLDisplay dpy,

[Mesa-dev] [PATCH 5/7] i965: add __DRI2_BLOB support and set cache functions

2018-01-15 Thread Tapani Pälli
Signed-off-by: Tapani Pälli 
---
 src/mesa/drivers/dri/i965/intel_screen.c | 21 +
 1 file changed, 21 insertions(+)

diff --git a/src/mesa/drivers/dri/i965/intel_screen.c 
b/src/mesa/drivers/dri/i965/intel_screen.c
index 08032c9b22..4c19304f14 100644
--- a/src/mesa/drivers/dri/i965/intel_screen.c
+++ b/src/mesa/drivers/dri/i965/intel_screen.c
@@ -36,6 +36,7 @@
 #include "main/version.h"
 #include "swrast/s_renderbuffer.h"
 #include "util/ralloc.h"
+#include "util/disk_cache.h"
 #include "brw_defines.h"
 #include "brw_state.h"
 #include "compiler/nir/nir.h"
@@ -1484,6 +1485,19 @@ brw_query_renderer_string(__DRIscreen *dri_screen,
return -1;
 }
 
+static void
+brw_set_cache_funcs(__DRIcontext *dri_ctx,
+__DRIblobCacheSet set, __DRIblobCacheGet get)
+{
+   struct brw_context *brw = dri_ctx->driverPrivate;
+   struct gl_context *ctx = &brw->ctx;
+
+   if (!ctx->Cache)
+  return;
+
+   disk_cache_set_callbacks(ctx->Cache, set, get);
+}
+
 static const __DRI2rendererQueryExtension intelRendererQueryExtension = {
.base = { __DRI2_RENDERER_QUERY, 1 },
 
@@ -1495,6 +1509,11 @@ static const __DRIrobustnessExtension dri2Robustness = {
.base = { __DRI2_ROBUSTNESS, 1 }
 };
 
+static const __DRI2blobExtension intelBlobExtension = {
+   .base = { __DRI2_BLOB, 1 },
+   .set_cache_funcs = brw_set_cache_funcs
+};
+
 static const __DRIextension *screenExtensions[] = {
 &intelTexBufferExtension.base,
 &intelFenceExtension.base,
@@ -1504,6 +1523,7 @@ static const __DRIextension *screenExtensions[] = {
 &dri2ConfigQueryExtension.base,
 &dri2NoErrorExtension.base,
 &dri2FlushControlExtension.base,
+&intelBlobExtension.base,
 NULL
 };
 
@@ -1517,6 +1537,7 @@ static const __DRIextension 
*intelRobustScreenExtensions[] = {
 &dri2FlushControlExtension.base,
 &dri2Robustness.base,
 &dri2NoErrorExtension.base,
+&intelBlobExtension.base,
 NULL
 };
 
-- 
2.14.3

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


[Mesa-dev] [PATCH 6/7] android: ignore MESA_GLSL_CACHE_DISABLE setting

2018-01-15 Thread Tapani Pälli
Signed-off-by: Tapani Pälli 
---
 src/mesa/drivers/dri/i965/brw_disk_cache.c | 2 ++
 src/util/disk_cache.c  | 2 ++
 2 files changed, 4 insertions(+)

diff --git a/src/mesa/drivers/dri/i965/brw_disk_cache.c 
b/src/mesa/drivers/dri/i965/brw_disk_cache.c
index 65bb52726e..4df4504666 100644
--- a/src/mesa/drivers/dri/i965/brw_disk_cache.c
+++ b/src/mesa/drivers/dri/i965/brw_disk_cache.c
@@ -405,8 +405,10 @@ void
 brw_disk_cache_init(struct brw_context *brw)
 {
 #ifdef ENABLE_SHADER_CACHE
+#ifndef ANDROID
if (env_var_as_boolean("MESA_GLSL_CACHE_DISABLE", true))
   return;
+#endif
 
char renderer[10];
MAYBE_UNUSED int len = snprintf(renderer, sizeof(renderer), "i965_%04x",
diff --git a/src/util/disk_cache.c b/src/util/disk_cache.c
index d7891e3b70..3c98089e69 100644
--- a/src/util/disk_cache.c
+++ b/src/util/disk_cache.c
@@ -208,9 +208,11 @@ disk_cache_create(const char *gpu_name, const char 
*timestamp,
if (local == NULL)
   goto fail;
 
+#ifndef ANDROID
/* At user request, disable shader cache entirely. */
if (env_var_as_boolean("MESA_GLSL_CACHE_DISABLE", false))
   goto fail;
+#endif
 
/* Determine path for cache based on the first defined name as follows:
 *
-- 
2.14.3

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


[Mesa-dev] [PATCH 4/7] disk cache: support setting MESA_GLSL_CACHE_DIR at compile time

2018-01-15 Thread Tapani Pälli
Signed-off-by: Tapani Pälli 
---
 src/util/disk_cache.c | 13 -
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/src/util/disk_cache.c b/src/util/disk_cache.c
index b71363bcf3..d7891e3b70 100644
--- a/src/util/disk_cache.c
+++ b/src/util/disk_cache.c
@@ -47,6 +47,7 @@
 #include "util/mesa-sha1.h"
 #include "util/ralloc.h"
 #include "main/errors.h"
+#include "main/macros.h"
 
 #include "disk_cache.h"
 
@@ -213,7 +214,8 @@ disk_cache_create(const char *gpu_name, const char 
*timestamp,
 
/* Determine path for cache based on the first defined name as follows:
 *
-*   $MESA_GLSL_CACHE_DIR
+*   $MESA_GLSL_CACHE_DIR as environment variable
+*   $MESA_GLSL_CACHE_DIR as compile time option
 *   $XDG_CACHE_HOME/mesa_shader_cache
 *   /.cache/mesa_shader_cache
 */
@@ -227,6 +229,15 @@ disk_cache_create(const char *gpu_name, const char 
*timestamp,
  goto fail;
}
 
+#ifdef MESA_GLSL_CACHE_DIR
+#define STR(x) STRINGIFY(x)
+   path = concatenate_and_mkdir(local, STR(MESA_GLSL_CACHE_DIR),
+CACHE_DIR_NAME);
+   if (path == NULL)
+  goto fail;
+#undef STR
+#endif
+
if (path == NULL) {
   char *xdg_cache_home = getenv("XDG_CACHE_HOME");
 
-- 
2.14.3

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


[Mesa-dev] [PATCH 3/7] disk cache: add callback functionality

2018-01-15 Thread Tapani Pälli
Signed-off-by: Tapani Pälli 
---
 src/util/disk_cache.c | 39 +++
 src/util/disk_cache.h | 19 +++
 2 files changed, 58 insertions(+)

diff --git a/src/util/disk_cache.c b/src/util/disk_cache.c
index 7ebfa8c045..b71363bcf3 100644
--- a/src/util/disk_cache.c
+++ b/src/util/disk_cache.c
@@ -99,6 +99,9 @@ struct disk_cache {
/* Driver cache keys. */
uint8_t *driver_keys_blob;
size_t driver_keys_blob_size;
+
+   disk_cache_set_cb blob_set_cb;
+   disk_cache_get_cb blob_get_cb;
 };
 
 struct disk_cache_put_job {
@@ -995,6 +998,11 @@ disk_cache_put(struct disk_cache *cache, const cache_key 
key,
const void *data, size_t size,
struct cache_item_metadata *cache_item_metadata)
 {
+   if (cache->blob_set_cb) {
+  cache->blob_set_cb(key, CACHE_KEY_SIZE, data, size);
+  return;
+   }
+
struct disk_cache_put_job *dc_job =
   create_put_job(cache, key, data, size, cache_item_metadata);
 
@@ -1057,6 +1065,29 @@ disk_cache_get(struct disk_cache *cache, const cache_key 
key, size_t *size)
if (size)
   *size = 0;
 
+   if (cache->blob_get_cb) {
+/* This is what Android EGL defines as the maxValueSize in egl_cache_t
+ * class implementation.
+ */
+#define MAX_BLOB_SIZE 64 * 1024
+  void *blob = malloc(MAX_BLOB_SIZE);
+  if (!blob)
+ return NULL;
+
+  signed long bytes =
+ cache->blob_get_cb(key, CACHE_KEY_SIZE, blob, MAX_BLOB_SIZE);
+
+  if (!bytes) {
+ free(blob);
+ return NULL;
+  }
+
+  if (size)
+ *size = bytes;
+  return blob;
+#undef MAX_BLOB_SIZE
+   }
+
filename = get_cache_file(cache, key);
if (filename == NULL)
   goto fail;
@@ -1209,4 +1240,12 @@ disk_cache_compute_key(struct disk_cache *cache, const 
void *data, size_t size,
_mesa_sha1_final(&ctx, key);
 }
 
+void
+disk_cache_set_callbacks(struct disk_cache *cache, disk_cache_set_cb set,
+ disk_cache_get_cb get)
+{
+   cache->blob_set_cb = set;
+   cache->blob_get_cb = get;
+}
+
 #endif /* ENABLE_SHADER_CACHE */
diff --git a/src/util/disk_cache.h b/src/util/disk_cache.h
index 488b297ead..3fae8a1358 100644
--- a/src/util/disk_cache.h
+++ b/src/util/disk_cache.h
@@ -50,6 +50,14 @@ typedef uint8_t cache_key[CACHE_KEY_SIZE];
 #define CACHE_ITEM_TYPE_UNKNOWN  0x0
 #define CACHE_ITEM_TYPE_GLSL 0x1
 
+typedef void
+(*disk_cache_set_cb) (const void *key, signed long keySize,
+  const void *value, signed long valueSize);
+
+typedef signed long
+(*disk_cache_get_cb) (const void *key, signed long keySize,
+  void *value, signed long valueSize);
+
 struct cache_item_metadata {
/**
 * The cache item type. This could be used to identify a GLSL cache item,
@@ -207,6 +215,10 @@ void
 disk_cache_compute_key(struct disk_cache *cache, const void *data, size_t size,
cache_key key);
 
+void
+disk_cache_set_callbacks(struct disk_cache *cache, disk_cache_set_cb set,
+ disk_cache_get_cb get);
+
 #else
 
 static inline struct disk_cache *
@@ -260,6 +272,13 @@ disk_cache_compute_key(struct disk_cache *cache, const 
void *data, size_t size,
return;
 }
 
+static inline void
+disk_cache_set_callbacks(struct disk_cache *cache, disk_cache_set_cb set,
+ disk_cache_get_cb get)
+{
+   return;
+}
+
 #endif /* ENABLE_SHADER_CACHE */
 
 #ifdef __cplusplus
-- 
2.14.3

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


[Mesa-dev] [PATCH 0/7] EGL_ANDROID_blob_cache

2018-01-15 Thread Tapani Pälli
Hello;

Here's a refactored series of EGL_ANDROID_blob_cache. Now cache 
functions are stored in disk_cache struct and the functionality 
called within existing disk_cache put/get code. Problems/errors 
that existed with earlier series are gone.

On Android cache index file is created to MESA_GLSL_CACHE_DIR 
and blobs are  generated under '/data/user_de/0' in application 
specific paths:

androidia_64:/ # find /data/user_de/0/ -name *shader*
/data/user_de/0/com.android.settings/code_cache/com.android.opengl.shaders_cache
/data/user_de/0/com.android.gallery3d/code_cache/com.android.opengl.shaders_cache
/data/user_de/0/com.android.systemui/code_cache/com.android.opengl.shaders_cache
/data/user_de/0/com.rovio.angrybirdsspace.ads/code_cache/com.android.opengl.shaders_cache

(this part is managed by Android but may be interesting to know).

Also SurfaceFlinger manages its own cache as seen in the log output:
01-15 07:40:26.329  2129  2129 D SurfaceFlinger: shader cache generated - 24 
shaders in 57.687504 ms

I'm not sure if /sdcard is sane default but I've tried everything 
else (/cache, /data/cache) and failed because of permission errors.

Thanks;

Tapani Pälli (7):
  dri: add interface for EGL_ANDROID_blob_cache extension
  egl: add support for EGL_ANDROID_blob_cache
  disk cache: add callback functionality
  disk cache: support setting MESA_GLSL_CACHE_DIR at compile time
  i965: add __DRI2_BLOB support and set cache functions
  android: ignore MESA_GLSL_CACHE_DISABLE setting
  android: set '/sdcard/' as MESA_GLSL_CACHE_DIR by default

 Android.common.mk  |  1 +
 include/GL/internal/dri_interface.h| 26 +-
 src/egl/drivers/dri2/egl_dri2.c| 43 
 src/egl/drivers/dri2/egl_dri2.h|  4 +++
 src/egl/main/eglapi.c  | 29 
 src/egl/main/eglapi.h  |  4 +++
 src/egl/main/egldisplay.h  |  3 ++
 src/egl/main/eglentrypoint.h   |  1 +
 src/mesa/drivers/dri/i965/brw_disk_cache.c |  2 ++
 src/mesa/drivers/dri/i965/intel_screen.c   | 21 
 src/util/disk_cache.c  | 54 +-
 src/util/disk_cache.h  | 19 +++
 12 files changed, 205 insertions(+), 2 deletions(-)

-- 
2.14.3

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


[Mesa-dev] [PATCH 7/7] android: set '/sdcard/' as MESA_GLSL_CACHE_DIR by default

2018-01-15 Thread Tapani Pälli
This can/should be modified depending on needs. AFAIK by default,
this is the only path that can be read/written to by anyone.

Signed-off-by: Tapani Pälli 
---
 Android.common.mk | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Android.common.mk b/Android.common.mk
index 52dc7bff3b..7edbbfc0f2 100644
--- a/Android.common.mk
+++ b/Android.common.mk
@@ -47,6 +47,7 @@ LOCAL_CFLAGS += \
 LOCAL_CFLAGS += \
-DANDROID_API_LEVEL=$(PLATFORM_SDK_VERSION) \
-DENABLE_SHADER_CACHE \
+   -DMESA_GLSL_CACHE_DIR="/sdcard" \
-D__STDC_CONSTANT_MACROS \
-D__STDC_LIMIT_MACROS \
-DHAVE___BUILTIN_EXPECT \
-- 
2.14.3

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


[Mesa-dev] [PATCH 1/7] dri: add interface for EGL_ANDROID_blob_cache extension

2018-01-15 Thread Tapani Pälli
Signed-off-by: Tapani Pälli 
---
 include/GL/internal/dri_interface.h | 26 +-
 1 file changed, 25 insertions(+), 1 deletion(-)

diff --git a/include/GL/internal/dri_interface.h 
b/include/GL/internal/dri_interface.h
index 34a5c9fb01..de367d8f77 100644
--- a/include/GL/internal/dri_interface.h
+++ b/include/GL/internal/dri_interface.h
@@ -82,7 +82,7 @@ typedef struct __DRI2flushExtensionRec
__DRI2flushExtension;
 typedef struct __DRI2throttleExtensionRec  __DRI2throttleExtension;
 typedef struct __DRI2fenceExtensionRec  __DRI2fenceExtension;
 typedef struct __DRI2interopExtensionRec   __DRI2interopExtension;
-
+typedef struct __DRI2blobExtensionRec   __DRI2blobExtension;
 
 typedef struct __DRIimageLoaderExtensionRec __DRIimageLoaderExtension;
 typedef struct __DRIimageDriverExtensionRec __DRIimageDriverExtension;
@@ -336,6 +336,30 @@ struct __DRI2throttleExtensionRec {
enum __DRI2throttleReason reason);
 };
 
+/**
+ * Extension for EGL_ANDROID_blob_cache
+ */
+
+#define __DRI2_BLOB "DRI2_Blob"
+#define __DRI2_BLOB_VERSION 1
+
+typedef void
+(*__DRIblobCacheSet) (const void *key, signed long keySize,
+  const void *value, signed long valueSize);
+
+typedef signed long
+(*__DRIblobCacheGet) (const void *key, signed long keySize,
+  void *value, signed long valueSize);
+
+struct __DRI2blobExtensionRec {
+   __DRIextension base;
+
+   /**
+* Set cache functions for setting and getting cache entries.
+*/
+   void (*set_cache_funcs) (__DRIcontext *ctx,
+__DRIblobCacheSet set, __DRIblobCacheGet get);
+};
 
 /**
  * Extension for fences / synchronization objects.
-- 
2.14.3

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


Re: [Mesa-dev] [PATCH] glsl/linker: link-error using the same name in unnamed block and outside

2018-01-15 Thread Tapani Pälli



On 01/15/2018 12:56 PM, Juan A. Suarez Romero wrote:

On Thu, 2018-01-11 at 16:51 +0100, Juan A. Suarez Romero wrote:

On Wed, 2018-01-10 at 14:04 +0200, Tapani Pälli wrote:


On 01/08/2018 03:19 PM, Juan A. Suarez Romero wrote:

Please, could someone take a look at this patch? Thanks in advance.



This looks correct to me. Is there some dEQP/Piglit test for this situation?



Yes. It fixes KHR-GL*.shaders.uniform_block.common.name_matching.

I'll include the tests in the commit message.



Tapani, with the previous comment about adding the fixed test in the
commit message, is this Rb ?


Yes, r-b!


Thanks!



J.A.




J.A.

On Mon, 2017-12-04 at 17:35 +0100, Juan A. Suarez Romero wrote:

According with OpenGL GLSL 4.20 spec, section 4.3.9, page 57:

 "It is a link-time error if any particular shader interface
  contains:
- two different blocks, each having no instance name, and each
  having a member of the same name, or
- a variable outside a block, and a block with no instance name,
  where the variable has the same name as a member in the block."

This means that it is a link error if for example we have a vertex
shader with the following definition.

"layout(location=0) uniform Data { float a; float b; };"

and a fragment shader with:

"uniform float a;"

As in both cases we refer to both uniforms as "a", and thus using
glGetUniformLocation() wouldn't know which one we mean.
---
   src/compiler/glsl/linker.cpp | 23 +++
   1 file changed, 23 insertions(+)

diff --git a/src/compiler/glsl/linker.cpp b/src/compiler/glsl/linker.cpp
index 33fd76deae9..b6de7b54ae3 100644
--- a/src/compiler/glsl/linker.cpp
+++ b/src/compiler/glsl/linker.cpp
@@ -,6 +,29 @@ cross_validate_globals(struct gl_shader_program *prog,
   return;
}
   
+ /* In OpenGL GLSL 4.20 spec, section 4.3.9, page 57:

+  *
+  *   "It is a link-time error if any particular shader interface
+  *contains:
+  *
+  *- two different blocks, each having no instance name, and each
+  *  having a member of the same name, or
+  *
+  *- a variable outside a block, and a block with no instance name,
+  *  where the variable has the same name as a member in the 
block."
+  */
+ if (var->data.mode == existing->data.mode &&
+ var->get_interface_type() != existing->get_interface_type()) {
+linker_error(prog, "declarations for %s `%s` are in "
+ "%s and %s\n",
+ mode_string(var), var->name,
+ existing->get_interface_type() ?
+   existing->get_interface_type()->name : "outside a 
block",
+ var->get_interface_type() ?
+   var->get_interface_type()->name : "outside a 
block");
+
+return;
+ }
/* Only in GLSL ES 3.10, the precision qualifier should not match
 * between block members defined in matched block names within a
 * shader interface.


___
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 mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] dri_util: remove ALLOW_RGB10_CONFIGS option (v2)

2018-01-11 Thread Tapani Pälli

Hi;

On 11.01.2018 20:20, Mario Kleiner wrote:

On 01/11/2018 09:14 AM, Tapani Pälli wrote:
Yes, but as it broke regular visuals (on some of our testing machines 
as well) we needed a fast fix for this.


While this is an issue, I think the visual corruption has higher 
priority than this. This can be fixed meanwhile or afterwards when 
things work OK. Now it can be toggled true in intel_screen.c when 
debugging/investigating the issue.




That regression in Bug 104536, could you only reproduce it on "Ubuntu 
16.04 or 17.04 respectively, with latest git versions of libdrm, mesa, 
xserver, xlibs, and the drm-tip kernel." as David Weinehall reported in 
private message?


So far this has been only seen in CI machines. (I've been busy with 
something else ATM but I will also try to get to this one soon.)



Does it require X-Server from git master?


Yes, this is how those machines do, it's the latest components of the 
graphics stack.


Because testing here on Intel Ivybridge and Skylake with KUbuntu 16.04.3 
LTS and the distribution-provided X-Server 1.19.3 and the Unity-7 + 
Compiz standard Ubuntu 16.04 GUI, i can't reproduce the visual 
corruption from that screenshot in bug 104536?, neither with the 
intel-ddx nor the modesetting-ddx used by default, neither depth 24 nor 
depth 30.


What I've understood (from some bugs related to problems with sRGB 
visuals) is that with X server master there are a lot more visuals in 
general and as example can be multiple 32bit visuals (which did not 
happen before). This could possibly explain why these issues cannot be 
reproduced on LTS provided Xorg.


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


Re: [Mesa-dev] [PATCH] i965/screen: Allow drirc to set 'allow_rgb10_configs' again.

2018-01-11 Thread Tapani Pälli

Yeah that works, thanks Mario!

Reviewed-by: Tapani Pälli 

On 11.01.2018 18:00, Mario Kleiner wrote:

Since setup of ALLOW_RGB10_CONFIGS was moved to i965's own
brw_config_options.xml, this was hard-coded to false and
could not be overriden by drirc. Add some parsing into
i965's private screen->optionCache to enable drirc again.

Fixes: b391fb26df9f1b ("dri_util: remove ALLOW_RGB10_CONFIGS option (v2)")
Signed-off-by: Mario Kleiner 
Cc: Marek Olšák 
Cc: Tapani Pälli 
---
  src/mesa/drivers/dri/i965/intel_screen.c | 7 ++-
  1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/mesa/drivers/dri/i965/intel_screen.c 
b/src/mesa/drivers/dri/i965/intel_screen.c
index 08032c9..eb4b569 100644
--- a/src/mesa/drivers/dri/i965/intel_screen.c
+++ b/src/mesa/drivers/dri/i965/intel_screen.c
@@ -2397,7 +2397,12 @@ __DRIconfig **intelInitScreen2(__DRIscreen *dri_screen)
return NULL;
 }
 /* parse information in __driConfigOptions */
-   driParseOptionInfo(&screen->optionCache, brw_config_options.xml);
+   driOptionCache options;
+   memset(&options, 0, sizeof(options));
+
+   driParseOptionInfo(&options, brw_config_options.xml);
+   driParseConfigFiles(&screen->optionCache, &options, dri_screen->myNum, 
"i965");
+   driDestroyOptionCache(&options);
  
 screen->driScrnPriv = dri_screen;

 dri_screen->driverPrivate = (void *) screen;


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


Re: [Mesa-dev] [PATCH] dri_util: remove ALLOW_RGB10_CONFIGS option (v2)

2018-01-11 Thread Tapani Pälli



On 01/11/2018 08:14 AM, Mario Kleiner wrote:

On 01/10/2018 07:04 AM, Tapani Pälli wrote:

Hi Marek;

This one works but only if you add

DRI_CONF_ALLOW_RGB10_CONFIGS("false")

to the DRI_CONF_SECTION_MISCELLANEOUS section in intel_screen. With 
that change: Reviewed-by: Tapani Pälli 




With this patch now committed to master, rgb10 visuals on i965 are 
completely dead, as far as my testing goes. rgb10 is always off, and the 
'allow_rgb10_configs' option in drirc gets ignored for enumeration of 
visuals/fbconfigs, e.g., in glxinfo.


Before it worked on my machines, defaulted to on, and could be 
controlled via drirc.


Yes, but as it broke regular visuals (on some of our testing machines as 
well) we needed a fast fix for this.


As far as i can see, setting up &screen->optionCache for i965 happens 
too late, only at glXCreateContext() time -> brwCreateContext() -> 
brw_process_driconf_options().


The old way read the options file as part of driCreateNewScreen2(), 
which was called as part of __glXInitialize, e.g., from 
glXChooseVisual() -- early enough to affect the enumeration/selection of 
visuals.


So i don't know if the old way was the right way, but it did give the 
right behavior for i965 whereas the new one doesn't.


Ideas?


While this is an issue, I think the visual corruption has higher 
priority than this. This can be fixed meanwhile or afterwards when 
things work OK. Now it can be toggled true in intel_screen.c when 
debugging/investigating the issue.




-mario



On 01/09/2018 04:04 PM, Marek Olšák wrote:

From: Marek Olšák 

This is unused because it's for libGL/libEGL, not drivers.

v2: i965 was wrong, because it used dri_util instead of its own config.
---
  src/mesa/drivers/dri/common/dri_util.c   | 4 
  src/mesa/drivers/dri/i965/intel_screen.c | 2 +-
  2 files changed, 1 insertion(+), 5 deletions(-)

diff --git a/src/mesa/drivers/dri/common/dri_util.c 
b/src/mesa/drivers/dri/common/dri_util.c

index d4fba0b..e6a7d23 100644
--- a/src/mesa/drivers/dri/common/dri_util.c
+++ b/src/mesa/drivers/dri/common/dri_util.c
@@ -48,24 +48,20 @@
  #include "main/version.h"
  #include "main/debug_output.h"
  #include "main/errors.h"
  #include "main/macros.h"
  const char __dri2ConfigOptions[] =
 DRI_CONF_BEGIN
    DRI_CONF_SECTION_PERFORMANCE
   DRI_CONF_VBLANK_MODE(DRI_CONF_VBLANK_DEF_INTERVAL_1)
    DRI_CONF_SECTION_END
-
-  DRI_CONF_SECTION_MISCELLANEOUS
- DRI_CONF_ALLOW_RGB10_CONFIGS("true")
-  DRI_CONF_SECTION_END
 DRI_CONF_END;
  /*/
  /** \name Screen handling functions  */
  /*/
  /*@{*/
  static void
  setupLoaderExtensions(__DRIscreen *psp,
    const __DRIextension **extensions)
diff --git a/src/mesa/drivers/dri/i965/intel_screen.c 
b/src/mesa/drivers/dri/i965/intel_screen.c

index 3e016b5..89db821 100644
--- a/src/mesa/drivers/dri/i965/intel_screen.c
+++ b/src/mesa/drivers/dri/i965/intel_screen.c
@@ -2057,21 +2057,21 @@ intel_screen_make_configs(__DRIscreen 
*dri_screen)

 __DRIconfig **configs = NULL;
 /* Expose only BGRA ordering if the loader doesn't support RGBA 
ordering. */

 unsigned num_formats;
 if (intel_loader_get_cap(dri_screen, DRI_LOADER_CAP_RGBA_ORDERING))
    num_formats = ARRAY_SIZE(formats);
 else
    num_formats = ARRAY_SIZE(formats) - 2; /* all - RGBA_ORDERING 
formats */

 /* Shall we expose 10 bpc formats? */
-   bool allow_rgb10_configs = driQueryOptionb(&dri_screen->optionCache,
+   bool allow_rgb10_configs = driQueryOptionb(&screen->optionCache,
    "allow_rgb10_configs");
 /* Generate singlesample configs without accumulation buffer. */
 for (unsigned i = 0; i < num_formats; i++) {
    __DRIconfig **new_configs;
    int num_depth_stencil_bits = 2;
    if (!allow_rgb10_configs &&
    (formats[i] == MESA_FORMAT_B10G10R10A2_UNORM ||
 formats[i] == MESA_FORMAT_B10G10R10X2_UNORM))


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

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


Re: [Mesa-dev] [RFC 07/10] mesa: add program blob cache functionality

2018-01-10 Thread Tapani Pälli



On 01/11/2018 12:43 AM, Jordan Justen wrote:

On 2018-01-08 23:48:19, Tapani Pälli wrote:

Cache set and get are called in similar fashion as what is happening
with disk cache. Functionality requires ARB_get_program_binary and
EGL_ANDROID_blob_cache support.

Signed-off-by: Tapani Pälli 
---
  src/mesa/Makefile.sources  |   2 +
  src/mesa/main/program_blob_cache.c | 141 +
  src/mesa/main/program_blob_cache.h |  48 +
  src/mesa/meson.build   |   2 +
  src/mesa/program/ir_to_mesa.cpp|   9 ++-
  5 files changed, 201 insertions(+), 1 deletion(-)
  create mode 100644 src/mesa/main/program_blob_cache.c
  create mode 100644 src/mesa/main/program_blob_cache.h

diff --git a/src/mesa/Makefile.sources b/src/mesa/Makefile.sources
index 53fa486364..bbcfdb425e 100644
--- a/src/mesa/Makefile.sources
+++ b/src/mesa/Makefile.sources
@@ -177,6 +177,8 @@ MAIN_FILES = \
 main/polygon.h \
 main/program_binary.c \
 main/program_binary.h \
+   main/program_blob_cache.c \
+   main/program_blob_cache.h \
 main/program_resource.c \
 main/program_resource.h \
 main/querymatrix.c \
diff --git a/src/mesa/main/program_blob_cache.c 
b/src/mesa/main/program_blob_cache.c
new file mode 100644
index 00..0b3ea1a549
--- /dev/null
+++ b/src/mesa/main/program_blob_cache.c
@@ -0,0 +1,141 @@
+/*
+ * Mesa 3-D graphics library
+ *
+ * Copyright (C) 2018 Intel Corporation.  All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, 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 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 "main/errors.h"
+#include "main/mtypes.h"
+#include "main/shaderobj.h"
+#include "main/program_binary.h"
+#include "util/mesa-sha1.h"
+#include "compiler/glsl/program.h"
+
+#include "program_blob_cache.h"
+
+/* This is what Android EGL defines as the maxValueSize in egl_cache_t
+ * class implementation.
+ */
+#define MAX_BLOB_SIZE 64 * 1024
+
+static void
+generate_sha1_string(struct gl_context *ctx, struct gl_shader_program *shProg,
+ char *key)
+{
+   char *buf = create_shader_program_keystr(ctx, shProg);
+   struct mesa_sha1 sha_ctx;
+   unsigned char sha1str[20];
+
+   /* Add driver sha1 to the key string. */
+   uint8_t driver_sha1[20];
+   char driver_sha1buf[41];
+
+   ctx->Driver.GetProgramBinaryDriverSHA1(ctx, driver_sha1);
+   _mesa_sha1_format(driver_sha1buf, driver_sha1);
+   ralloc_asprintf_append(&buf, "%s", driver_sha1buf);
+
+   _mesa_sha1_init(&sha_ctx);
+   _mesa_sha1_update(&sha_ctx, buf, strlen(buf));
+   _mesa_sha1_final(&sha_ctx, sha1str);
+   _mesa_sha1_format(key, sha1str);
+
+   ralloc_free(buf);
+}
+
+void
+_mesa_blob_cache_set(struct gl_context *ctx,
+ struct gl_shader_program *shProg)
+{
+   assert(shProg->data->LinkStatus == linking_success);
+
+   /* ARB_get_program_binary support required. */
+   if (!ctx->blobCacheSet || !ctx->Driver.GetProgramBinaryDriverSHA1)
+  return;
+
+   /* Skip cache for fixed-function programs and programs that use
+* transform feedback.
+*/
+   if (!shProg->Name || shProg->TransformFeedback.NumVarying > 0)
+  return;
+
+   GLint length;
+   _mesa_get_program_binary_length(ctx, shProg, &length);


I see this is built on GetProgramBinary. That might be fine, but what
if we utilized the blob read/write as an alternative storage for the
general disk shader cache?

It would allow us to skip compiling the GLSL.


I thought it before but decided to go with GetProgramBinary since it 
seemed more straightforward at that point. Hooking with disk_cache makes 
perfect sense though, I will try this out and see what I can come up with.



I haven't looked much yet, but I didn't see anything that might
explain the texture issue you noted. It is possible that it might go
aw

Re: [Mesa-dev] [PATCH 1/2] vulkan: move anv VK_EXT_debug_report implementation to common code.

2018-01-10 Thread Tapani Pälli
This LGTM. You are taking away the instance constructor/destructor 
callback but it wasn't used anyway so that's fine. If someone needs it, 
it can be added later.


Reviewed-by: Tapani Pälli 

On 01/09/2018 04:04 PM, Bas Nieuwenhuizen wrote:

For also using it in radv. I moved the remaining stubs back to
anv_device.c as they were just trivial.

This does not move the vk_errorf/anv_perf_warn or the object
type macros, as those depend on anv types and logging.
---
  src/intel/Makefile.sources |  1 -
  src/intel/vulkan/anv_device.c  | 54 +++---
  src/intel/vulkan/anv_private.h | 28 +--
  src/intel/vulkan/anv_util.c| 32 
  src/intel/vulkan/meson.build   |  1 -
  src/vulkan/Makefile.sources|  2 +
  src/vulkan/util/meson.build|  2 +
  .../util/vk_debug_report.c}| 85 +++---
  src/vulkan/util/vk_debug_report.h  | 72 ++
  9 files changed, 182 insertions(+), 95 deletions(-)
  rename src/{intel/vulkan/anv_debug_report.c => vulkan/util/vk_debug_report.c} 
(56%)
  create mode 100644 src/vulkan/util/vk_debug_report.h

diff --git a/src/intel/Makefile.sources b/src/intel/Makefile.sources
index 1c62bad816..7f8379c66a 100644
--- a/src/intel/Makefile.sources
+++ b/src/intel/Makefile.sources
@@ -209,7 +209,6 @@ VULKAN_FILES := \
vulkan/anv_batch_chain.c \
vulkan/anv_blorp.c \
vulkan/anv_cmd_buffer.c \
-   vulkan/anv_debug_report.c \
vulkan/anv_descriptor_set.c \
vulkan/anv_device.c \
vulkan/anv_dump.c \
diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c
index 680f5a752d..1c2590e11c 100644
--- a/src/intel/vulkan/anv_device.c
+++ b/src/intel/vulkan/anv_device.c
@@ -482,6 +482,7 @@ VkResult anv_CreateInstance(
  VkInstance* pInstance)
  {
 struct anv_instance *instance;
+   VkResult result;
  
 assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO);
  
@@ -541,18 +542,10 @@ VkResult anv_CreateInstance(

 instance->apiVersion = client_version;
 instance->physicalDeviceCount = -1;
  
-   if (pthread_mutex_init(&instance->callbacks_mutex, NULL) != 0) {

+   result = vk_debug_report_instance_init(&instance->debug_report_callbacks);
+   if (result != VK_SUCCESS) {
vk_free2(&default_alloc, pAllocator, instance);
-  return vk_error(VK_ERROR_INITIALIZATION_FAILED);
-   }
-
-   list_inithead(&instance->callbacks);
-
-   /* Store report debug callback to be used during DestroyInstance. */
-   if (ctor_cb) {
-  instance->destroy_debug_cb.flags = ctor_cb->flags;
-  instance->destroy_debug_cb.callback = ctor_cb->pfnCallback;
-  instance->destroy_debug_cb.data = ctor_cb->pUserData;
+  return vk_error(result);
 }
  
 _mesa_locale_init();

@@ -581,7 +574,7 @@ void anv_DestroyInstance(
  
 VG(VALGRIND_DESTROY_MEMPOOL(instance));
  
-   pthread_mutex_destroy(&instance->callbacks_mutex);

+   vk_debug_report_instance_destroy(&instance->debug_report_callbacks);
  
 _mesa_locale_fini();
  
@@ -1066,6 +1059,43 @@ PFN_vkVoidFunction anv_GetDeviceProcAddr(

 return anv_lookup_entrypoint(&device->info, pName);
  }
  
+VkResult

+anv_CreateDebugReportCallbackEXT(VkInstance _instance,
+ const VkDebugReportCallbackCreateInfoEXT* 
pCreateInfo,
+ const VkAllocationCallbacks* pAllocator,
+ VkDebugReportCallbackEXT* pCallback)
+{
+   ANV_FROM_HANDLE(anv_instance, instance, _instance);
+   return vk_create_debug_report_callback(&instance->debug_report_callbacks,
+  pCreateInfo, pAllocator, 
&instance->alloc,
+  pCallback);
+}
+
+void
+anv_DestroyDebugReportCallbackEXT(VkInstance _instance,
+  VkDebugReportCallbackEXT _callback,
+  const VkAllocationCallbacks* pAllocator)
+{
+   ANV_FROM_HANDLE(anv_instance, instance, _instance);
+   vk_destroy_debug_report_callback(&instance->debug_report_callbacks,
+_callback, pAllocator, &instance->alloc);
+}
+
+void
+anv_DebugReportMessageEXT(VkInstance _instance,
+  VkDebugReportFlagsEXT flags,
+  VkDebugReportObjectTypeEXT objectType,
+  uint64_t object,
+  size_t location,
+  int32_t messageCode,
+  const char* pLayerPrefix,
+  const char* pMessage)
+{
+   ANV_FROM_HANDLE(anv_instance, instance, _instance);
+   vk_debug_report(&instance

Re: [Mesa-dev] [PATCH] glsl/linker: link-error using the same name in unnamed block and outside

2018-01-10 Thread Tapani Pälli



On 01/08/2018 03:19 PM, Juan A. Suarez Romero wrote:

Please, could someone take a look at this patch? Thanks in advance.



This looks correct to me. Is there some dEQP/Piglit test for this situation?


J.A.

On Mon, 2017-12-04 at 17:35 +0100, Juan A. Suarez Romero wrote:

According with OpenGL GLSL 4.20 spec, section 4.3.9, page 57:

"It is a link-time error if any particular shader interface
 contains:
   - two different blocks, each having no instance name, and each
 having a member of the same name, or
   - a variable outside a block, and a block with no instance name,
 where the variable has the same name as a member in the block."

This means that it is a link error if for example we have a vertex
shader with the following definition.

   "layout(location=0) uniform Data { float a; float b; };"

and a fragment shader with:

   "uniform float a;"

As in both cases we refer to both uniforms as "a", and thus using
glGetUniformLocation() wouldn't know which one we mean.
---
  src/compiler/glsl/linker.cpp | 23 +++
  1 file changed, 23 insertions(+)

diff --git a/src/compiler/glsl/linker.cpp b/src/compiler/glsl/linker.cpp
index 33fd76deae9..b6de7b54ae3 100644
--- a/src/compiler/glsl/linker.cpp
+++ b/src/compiler/glsl/linker.cpp
@@ -,6 +,29 @@ cross_validate_globals(struct gl_shader_program *prog,
  return;
   }
  
+ /* In OpenGL GLSL 4.20 spec, section 4.3.9, page 57:

+  *
+  *   "It is a link-time error if any particular shader interface
+  *contains:
+  *
+  *- two different blocks, each having no instance name, and each
+  *  having a member of the same name, or
+  *
+  *- a variable outside a block, and a block with no instance name,
+  *  where the variable has the same name as a member in the 
block."
+  */
+ if (var->data.mode == existing->data.mode &&
+ var->get_interface_type() != existing->get_interface_type()) {
+linker_error(prog, "declarations for %s `%s` are in "
+ "%s and %s\n",
+ mode_string(var), var->name,
+ existing->get_interface_type() ?
+   existing->get_interface_type()->name : "outside a 
block",
+ var->get_interface_type() ?
+   var->get_interface_type()->name : "outside a 
block");
+
+return;
+ }
   /* Only in GLSL ES 3.10, the precision qualifier should not match
* between block members defined in matched block names within a
* shader interface.

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


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


Re: [Mesa-dev] [RFC 04/10] glsl: add function to create unique string from shader program

2018-01-10 Thread Tapani Pälli



On 01/09/2018 04:30 PM, Eric Engestrom wrote:

On Tuesday, 2018-01-09 09:48:16 +0200, Tapani Pälli wrote:

Patch moves existing functionality from shader_cache_read_program_metadata
to a helper function.

Signed-off-by: Tapani Pälli 
---
  src/compiler/Makefile.sources  |  1 +
  src/compiler/glsl/meson.build  |  1 +
  src/compiler/glsl/program.cpp  | 88 ++
  src/compiler/glsl/program.h| 12 --
  src/compiler/glsl/shader_cache.cpp | 55 +---
  5 files changed, 100 insertions(+), 57 deletions(-)
  create mode 100644 src/compiler/glsl/program.cpp


[snip]

diff --git a/src/compiler/glsl/program.h b/src/compiler/glsl/program.h
index 480379b10b..ae349113e0 100644
--- a/src/compiler/glsl/program.h
+++ b/src/compiler/glsl/program.h
@@ -25,18 +25,22 @@
  #ifndef GLSL_PROGRAM_H
  #define GLSL_PROGRAM_H
  
-#ifdef __cplusplus

-extern "C" {
-#endif
-
  struct gl_context;
  struct gl_shader;
  struct gl_shader_program;
  
+#ifdef __cplusplus

+extern "C" {
+#endif
+


Unrelated hunk, but also I'm not convinced this is right. Either C++
does mangle struct names and this needs to be inside the `extern "C"`,
or it doesn't and moving it outside won't change anything, right?



Yes this is not needed, I can't recall what happened here but will 
remove this hunk!


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


Re: [Mesa-dev] [PATCH] dri_util: remove ALLOW_RGB10_CONFIGS option (v2)

2018-01-09 Thread Tapani Pälli

Hi Marek;

This one works but only if you add

DRI_CONF_ALLOW_RGB10_CONFIGS("false")

to the DRI_CONF_SECTION_MISCELLANEOUS section in intel_screen. With that 
change: Reviewed-by: Tapani Pälli 



On 01/09/2018 04:04 PM, Marek Olšák wrote:

From: Marek Olšák 

This is unused because it's for libGL/libEGL, not drivers.

v2: i965 was wrong, because it used dri_util instead of its own config.
---
  src/mesa/drivers/dri/common/dri_util.c   | 4 
  src/mesa/drivers/dri/i965/intel_screen.c | 2 +-
  2 files changed, 1 insertion(+), 5 deletions(-)

diff --git a/src/mesa/drivers/dri/common/dri_util.c 
b/src/mesa/drivers/dri/common/dri_util.c
index d4fba0b..e6a7d23 100644
--- a/src/mesa/drivers/dri/common/dri_util.c
+++ b/src/mesa/drivers/dri/common/dri_util.c
@@ -48,24 +48,20 @@
  #include "main/version.h"
  #include "main/debug_output.h"
  #include "main/errors.h"
  #include "main/macros.h"
  
  const char __dri2ConfigOptions[] =

 DRI_CONF_BEGIN
DRI_CONF_SECTION_PERFORMANCE
   DRI_CONF_VBLANK_MODE(DRI_CONF_VBLANK_DEF_INTERVAL_1)
DRI_CONF_SECTION_END
-
-  DRI_CONF_SECTION_MISCELLANEOUS
- DRI_CONF_ALLOW_RGB10_CONFIGS("true")
-  DRI_CONF_SECTION_END
 DRI_CONF_END;
  
  /*/

  /** \name Screen handling functions  */
  /*/
  /*@{*/
  
  static void

  setupLoaderExtensions(__DRIscreen *psp,
  const __DRIextension **extensions)
diff --git a/src/mesa/drivers/dri/i965/intel_screen.c 
b/src/mesa/drivers/dri/i965/intel_screen.c
index 3e016b5..89db821 100644
--- a/src/mesa/drivers/dri/i965/intel_screen.c
+++ b/src/mesa/drivers/dri/i965/intel_screen.c
@@ -2057,21 +2057,21 @@ intel_screen_make_configs(__DRIscreen *dri_screen)
 __DRIconfig **configs = NULL;
  
 /* Expose only BGRA ordering if the loader doesn't support RGBA ordering. */

 unsigned num_formats;
 if (intel_loader_get_cap(dri_screen, DRI_LOADER_CAP_RGBA_ORDERING))
num_formats = ARRAY_SIZE(formats);
 else
num_formats = ARRAY_SIZE(formats) - 2; /* all - RGBA_ORDERING formats */
  
 /* Shall we expose 10 bpc formats? */

-   bool allow_rgb10_configs = driQueryOptionb(&dri_screen->optionCache,
+   bool allow_rgb10_configs = driQueryOptionb(&screen->optionCache,
"allow_rgb10_configs");
  
 /* Generate singlesample configs without accumulation buffer. */

 for (unsigned i = 0; i < num_formats; i++) {
__DRIconfig **new_configs;
int num_depth_stencil_bits = 2;
  
if (!allow_rgb10_configs &&

(formats[i] == MESA_FORMAT_B10G10R10A2_UNORM ||
 formats[i] == MESA_FORMAT_B10G10R10X2_UNORM))


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


Re: [Mesa-dev] [RFC 07/10] mesa: add program blob cache functionality

2018-01-09 Thread Tapani Pälli



On 01/09/2018 05:05 PM, Eric Engestrom wrote:

On Tuesday, 2018-01-09 09:48:19 +0200, Tapani Pälli wrote:

Cache set and get are called in similar fashion as what is happening
with disk cache. Functionality requires ARB_get_program_binary and
EGL_ANDROID_blob_cache support.

Signed-off-by: Tapani Pälli 
---
  src/mesa/Makefile.sources  |   2 +
  src/mesa/main/program_blob_cache.c | 141 +
  src/mesa/main/program_blob_cache.h |  48 +
  src/mesa/meson.build   |   2 +
  src/mesa/program/ir_to_mesa.cpp|   9 ++-
  5 files changed, 201 insertions(+), 1 deletion(-)
  create mode 100644 src/mesa/main/program_blob_cache.c
  create mode 100644 src/mesa/main/program_blob_cache.h

diff --git a/src/mesa/Makefile.sources b/src/mesa/Makefile.sources
index 53fa486364..bbcfdb425e 100644
--- a/src/mesa/Makefile.sources
+++ b/src/mesa/Makefile.sources
@@ -177,6 +177,8 @@ MAIN_FILES = \
main/polygon.h \
main/program_binary.c \
main/program_binary.h \
+   main/program_blob_cache.c \
+   main/program_blob_cache.h \
main/program_resource.c \
main/program_resource.h \
main/querymatrix.c \
diff --git a/src/mesa/main/program_blob_cache.c 
b/src/mesa/main/program_blob_cache.c
new file mode 100644
index 00..0b3ea1a549
--- /dev/null
+++ b/src/mesa/main/program_blob_cache.c
@@ -0,0 +1,141 @@
+/*
+ * Mesa 3-D graphics library
+ *
+ * Copyright (C) 2018 Intel Corporation.  All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, 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 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 "main/errors.h"
+#include "main/mtypes.h"
+#include "main/shaderobj.h"
+#include "main/program_binary.h"
+#include "util/mesa-sha1.h"
+#include "compiler/glsl/program.h"
+
+#include "program_blob_cache.h"
+
+/* This is what Android EGL defines as the maxValueSize in egl_cache_t
+ * class implementation.
+ */
+#define MAX_BLOB_SIZE 64 * 1024
+
+static void
+generate_sha1_string(struct gl_context *ctx, struct gl_shader_program *shProg,
+ char *key)
+{
+   char *buf = create_shader_program_keystr(ctx, shProg);
+   struct mesa_sha1 sha_ctx;
+   unsigned char sha1str[20];
+
+   /* Add driver sha1 to the key string. */
+   uint8_t driver_sha1[20];
+   char driver_sha1buf[41];
+
+   ctx->Driver.GetProgramBinaryDriverSHA1(ctx, driver_sha1);
+   _mesa_sha1_format(driver_sha1buf, driver_sha1);
+   ralloc_asprintf_append(&buf, "%s", driver_sha1buf);
+
+   _mesa_sha1_init(&sha_ctx);
+   _mesa_sha1_update(&sha_ctx, buf, strlen(buf));
+   _mesa_sha1_final(&sha_ctx, sha1str);
+   _mesa_sha1_format(key, sha1str);
+
+   ralloc_free(buf);
+}
+
+void
+_mesa_blob_cache_set(struct gl_context *ctx,
+ struct gl_shader_program *shProg)
+{
+   assert(shProg->data->LinkStatus == linking_success);
+
+   /* ARB_get_program_binary support required. */
+   if (!ctx->blobCacheSet || !ctx->Driver.GetProgramBinaryDriverSHA1)
+  return;
+
+   /* Skip cache for fixed-function programs and programs that use
+* transform feedback.
+*/
+   if (!shProg->Name || shProg->TransformFeedback.NumVarying > 0)
+  return;
+
+   GLint length;
+   _mesa_get_program_binary_length(ctx, shProg, &length);
+
+   /* Skip cache if exceeds max blob size. */
+   if (length > MAX_BLOB_SIZE)
+  return;
+
+   char *blob = (char *) malloc (length);


Nit: in C, malloc returns (void*) so the cast is unnecessary, and the
space after malloc looks weird :)


Yes, will clean this up.


+
+   if (!blob)
+  return;
+
+   GLsizei real_len;
+   GLenum format;
+   _mesa_get_program_binary(ctx, shProg, length, &real_len,
+&format, blob);
+
+   assert(format == GL_PROGRAM_BINARY_FORMAT_MESA);
+
+   char key[41];
+   genera

Re: [Mesa-dev] [PATCH] dri_util: remove ALLOW_RGB10_CONFIGS option

2018-01-09 Thread Tapani Pälli



On 01/09/2018 08:37 AM, Tapani Pälli wrote:


On 01/08/2018 06:59 PM, Marek Olšák wrote:

From: Marek Olšák 

This is unused because it's for libGL/libEGL, not drivers.


IMO this is not enough, you would need to also remove the query for this 
as well (driQueryOptionb in intel_screen.c), otherwise we hit assertion. 
Maybe just set bool allow_rgb10_configs = false for now?


If I'm correct I think assertion should be happening with 
src/gallium/state_trackers/dri/dri_screen.c as well.






---
  src/mesa/drivers/dri/common/dri_util.c | 4 
  1 file changed, 4 deletions(-)

diff --git a/src/mesa/drivers/dri/common/dri_util.c 
b/src/mesa/drivers/dri/common/dri_util.c

index d4fba0b..e6a7d23 100644
--- a/src/mesa/drivers/dri/common/dri_util.c
+++ b/src/mesa/drivers/dri/common/dri_util.c
@@ -48,24 +48,20 @@
  #include "main/version.h"
  #include "main/debug_output.h"
  #include "main/errors.h"
  #include "main/macros.h"
  const char __dri2ConfigOptions[] =
 DRI_CONF_BEGIN
    DRI_CONF_SECTION_PERFORMANCE
   DRI_CONF_VBLANK_MODE(DRI_CONF_VBLANK_DEF_INTERVAL_1)
    DRI_CONF_SECTION_END
-
-  DRI_CONF_SECTION_MISCELLANEOUS
- DRI_CONF_ALLOW_RGB10_CONFIGS("true")
-  DRI_CONF_SECTION_END
 DRI_CONF_END;
  /*/
  /** \name Screen handling functions  */
  /*/
  /*@{*/
  static void
  setupLoaderExtensions(__DRIscreen *psp,
    const __DRIextension **extensions)


___
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] [RFC 06/10] glsl: create shader sha1 if disk cache or blob cache is active

2018-01-08 Thread Tapani Pälli
Signed-off-by: Tapani Pälli 
---
 src/compiler/glsl/glsl_parser_extras.cpp | 26 ++
 src/util/disk_cache.c|  5 +++--
 2 files changed, 17 insertions(+), 14 deletions(-)

diff --git a/src/compiler/glsl/glsl_parser_extras.cpp 
b/src/compiler/glsl/glsl_parser_extras.cpp
index 59821732b9..6003ddb277 100644
--- a/src/compiler/glsl/glsl_parser_extras.cpp
+++ b/src/compiler/glsl/glsl_parser_extras.cpp
@@ -2038,22 +2038,24 @@ _mesa_glsl_compile_shader(struct gl_context *ctx, 
struct gl_shader *shader,
   shader->FallbackSource : shader->Source;
 
if (!force_recompile) {
-  if (ctx->Cache) {
- char buf[41];
+  /* Compute sha1 if using disk cache or ANDROID blob cache. */
+  if (ctx->Cache || ctx->blobCacheSet) {
  disk_cache_compute_key(ctx->Cache, source, strlen(source),
 shader->sha1);
- if (disk_cache_has_key(ctx->Cache, shader->sha1)) {
-/* We've seen this shader before and know it compiles */
-if (ctx->_Shader->Flags & GLSL_CACHE_INFO) {
-   _mesa_sha1_format(buf, shader->sha1);
-   fprintf(stderr, "deferring compile of shader: %s\n", buf);
-}
-shader->CompileStatus = compile_skipped;
+  }
 
-free((void *)shader->FallbackSource);
-shader->FallbackSource = NULL;
-return;
+  if (ctx->Cache && disk_cache_has_key(ctx->Cache, shader->sha1)) {
+ /* We've seen this shader before and know it compiles */
+ if (ctx->_Shader->Flags & GLSL_CACHE_INFO) {
+char buf[41];
+_mesa_sha1_format(buf, shader->sha1);
+fprintf(stderr, "deferring compile of shader: %s\n", buf);
  }
+ shader->CompileStatus = compile_skipped;
+
+ free((void *)shader->FallbackSource);
+ shader->FallbackSource = NULL;
+ return;
   }
} else {
   /* We should only ever end up here if a re-compile has been forced by a
diff --git a/src/util/disk_cache.c b/src/util/disk_cache.c
index 7ebfa8c045..d8e92d66fe 100644
--- a/src/util/disk_cache.c
+++ b/src/util/disk_cache.c
@@ -1203,8 +1203,9 @@ disk_cache_compute_key(struct disk_cache *cache, const 
void *data, size_t size,
struct mesa_sha1 ctx;
 
_mesa_sha1_init(&ctx);
-   _mesa_sha1_update(&ctx, cache->driver_keys_blob,
- cache->driver_keys_blob_size);
+   if (cache)
+  _mesa_sha1_update(&ctx, cache->driver_keys_blob,
+cache->driver_keys_blob_size);
_mesa_sha1_update(&ctx, data, size);
_mesa_sha1_final(&ctx, key);
 }
-- 
2.14.3

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


[Mesa-dev] [RFC 10/10] egl: XXX debug framework for EGL_ANDROID_blob_cache

2018-01-08 Thread Tapani Pälli
Patch disables EGL_ANDROID_blob_cache and sets own get/set
cache functions internally, this makes any EGL app to utilize
cache automatically.

Signed-off-by: Tapani Pälli 
---
 src/egl/drivers/dri2/egl_dri2.c |  3 --
 src/egl/main/eglapi.c   | 77 +
 2 files changed, 77 insertions(+), 3 deletions(-)

diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index f9d0223fe2..e24dab1589 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -728,9 +728,6 @@ dri2_setup_screen(_EGLDisplay *disp)
   }
}
 
-   if (dri2_dpy->blob)
-  disp->Extensions.ANDROID_blob_cache = EGL_TRUE;
-
disp->Extensions.KHR_reusable_sync = EGL_TRUE;
 
if (dri2_dpy->image) {
diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c
index b8d64a913c..5cd70c1afe 100644
--- a/src/egl/main/eglapi.c
+++ b/src/egl/main/eglapi.c
@@ -790,6 +790,80 @@ eglDestroyContext(EGLDisplay dpy, EGLContext ctx)
RETURN_EGL_EVAL(disp, ret);
 }
 
+static void*
+_load_file(const char *path, uint64_t *size)
+{
+  FILE *in = fopen(path, "r");
+
+  if (!in)
+return NULL;
+
+  fseek(in, 0, SEEK_END);
+  long file_size = ftell(in);
+  rewind(in);
+
+  printf("%s: %s, size is %ld\n", __func__, path, file_size);
+
+  char *data = (char *) malloc (file_size);
+
+  fread(data, file_size, 1, in);
+  fclose(in);
+
+  *size = file_size;
+  return data;
+}
+
+static void
+_save_file(const char *path, const void *data, uint64_t size)
+{
+  printf("%s: %s, size is %ld\n", __func__, path, size);
+
+  FILE *out = fopen(path, "w");
+
+  if (!out) {
+fprintf(stderr, "failed to open file for writing:\npath (%s)\n", path);
+return;
+  }
+
+  fwrite(data, size, 1, out);
+  fclose(out);
+}
+
+static void
+mesa_set(const void* key, EGLsizeiANDROID keySize, const void* value, 
EGLsizeiANDROID valueSize)
+{
+  if (valueSize < 2000)
+return;
+
+  char tmp[256];
+  snprintf(tmp, 256, "/tmp/%s", key);
+
+  _save_file(tmp, value, valueSize);
+}
+
+static EGLsizeiANDROID
+mesa_get(const void* key, EGLsizeiANDROID keySize, void* value, 
EGLsizeiANDROID valueSize)
+{
+  uint64_t size;
+
+  char tmp[256];
+  snprintf(tmp, 256, "/tmp/%s", key);
+
+  void *data = _load_file(tmp, &size);
+
+  if (!data)
+return 0;
+
+  if (size > valueSize) {
+free(data);
+return 0;
+  }
+
+  memcpy(value, data, size);
+  free(data);
+  return size;
+}
+
 
 EGLBoolean EGLAPIENTRY
 eglMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read,
@@ -845,6 +919,9 @@ eglMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface 
read,
 
ret = drv->API.MakeCurrent(drv, disp, draw_surf, read_surf, context);
 
+   /* Debug EGL_ANDROID_blob_cache */
+   drv->API.SetBlobCacheFuncsANDROID(drv, disp, mesa_set, mesa_get);
+
RETURN_EGL_EVAL(disp, ret);
 }
 
-- 
2.14.3

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


[Mesa-dev] [RFC 08/10] egl: add support for EGL_ANDROID_blob_cache

2018-01-08 Thread Tapani Pälli
Signed-off-by: Tapani Pälli 
---
 src/egl/drivers/dri2/egl_dri2.c | 43 +
 src/egl/drivers/dri2/egl_dri2.h |  4 
 src/egl/main/eglapi.c   | 29 +++
 src/egl/main/eglapi.h   |  4 
 src/egl/main/egldisplay.h   |  3 +++
 src/egl/main/eglentrypoint.h|  1 +
 6 files changed, 84 insertions(+)

diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index d5a4f72e86..f9d0223fe2 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -458,6 +458,7 @@ static const struct dri2_extension_match 
optional_core_extensions[] = {
{ __DRI2_INTEROP, 1, offsetof(struct dri2_egl_display, interop) },
{ __DRI_IMAGE, 1, offsetof(struct dri2_egl_display, image) },
{ __DRI2_FLUSH_CONTROL, 1, offsetof(struct dri2_egl_display, flush_control) 
},
+   { __DRI2_BLOB, 1, offsetof(struct dri2_egl_display, blob) },
{ NULL, 0, 0 }
 };
 
@@ -727,6 +728,9 @@ dri2_setup_screen(_EGLDisplay *disp)
   }
}
 
+   if (dri2_dpy->blob)
+  disp->Extensions.ANDROID_blob_cache = EGL_TRUE;
+
disp->Extensions.KHR_reusable_sync = EGL_TRUE;
 
if (dri2_dpy->image) {
@@ -1470,6 +1474,26 @@ dri2_surf_update_fence_fd(_EGLContext *ctx,
dri2_surface_set_out_fence_fd(surf, fence_fd);
 }
 
+static void
+update_blob_cache_functions(struct dri2_egl_display *dri2_dpy,
+struct dri2_egl_context *dri2_ctx)
+{
+   if (!dri2_dpy || !dri2_ctx)
+  return;
+
+   /* No blob support. */
+   if (!dri2_dpy->blob)
+  return;
+
+   /* No functions to set. */
+   if (!dri2_dpy->blob_cache_set)
+  return;
+
+   dri2_dpy->blob->set_cache_funcs(dri2_ctx->dri_context,
+   dri2_dpy->blob_cache_set,
+   dri2_dpy->blob_cache_get);
+}
+
 /**
  * Called via eglMakeCurrent(), drv->API.MakeCurrent().
  */
@@ -1499,6 +1523,9 @@ dri2_make_current(_EGLDriver *drv, _EGLDisplay *disp, 
_EGLSurface *dsurf,
if (old_ctx)
   dri2_gl_flush();
 
+   /* Make sure cache functions are set for new context. */
+   update_blob_cache_functions(dri2_dpy, dri2_ctx);
+
ddraw = (dsurf) ? dri2_dpy->vtbl->get_dri_drawable(dsurf) : NULL;
rdraw = (rsurf) ? dri2_dpy->vtbl->get_dri_drawable(rsurf) : NULL;
cctx = (dri2_ctx) ? dri2_ctx->dri_context : NULL;
@@ -3016,6 +3043,21 @@ dri2_dup_native_fence_fd(_EGLDriver *drv, _EGLDisplay 
*dpy, _EGLSync *sync)
return dup(sync->SyncFd);
 }
 
+static void
+dri2_set_blob_cache_funcs(_EGLDriver *drv, _EGLDisplay *dpy,
+  EGLSetBlobFuncANDROID set,
+  EGLGetBlobFuncANDROID get)
+{
+   _EGLContext *ctx = _eglGetCurrentContext();
+   struct dri2_egl_display *dri2_dpy = dri2_egl_display(dpy);
+   struct dri2_egl_context *dri2_ctx = dri2_egl_context(ctx);
+
+   dri2_dpy->blob_cache_set = set;
+   dri2_dpy->blob_cache_get = get;
+
+   update_blob_cache_functions(dri2_dpy, dri2_ctx);
+}
+
 static EGLint
 dri2_client_wait_sync(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSync *sync,
   EGLint flags, EGLTime timeout)
@@ -3234,6 +3276,7 @@ _eglBuiltInDriver(void)
dri2_drv->API.GLInteropQueryDeviceInfo = dri2_interop_query_device_info;
dri2_drv->API.GLInteropExportObject = dri2_interop_export_object;
dri2_drv->API.DupNativeFenceFDANDROID = dri2_dup_native_fence_fd;
+   dri2_drv->API.SetBlobCacheFuncsANDROID = dri2_set_blob_cache_funcs;
 
dri2_drv->Name = "DRI2";
 
diff --git a/src/egl/drivers/dri2/egl_dri2.h b/src/egl/drivers/dri2/egl_dri2.h
index cc76c73eab..a6777ad3f1 100644
--- a/src/egl/drivers/dri2/egl_dri2.h
+++ b/src/egl/drivers/dri2/egl_dri2.h
@@ -171,6 +171,7 @@ struct dri2_egl_display
const __DRInoErrorExtension*no_error;
const __DRI2configQueryExtension *config;
const __DRI2fenceExtension *fence;
+   const __DRI2blobExtension *blob;
const __DRI2rendererQueryExtension *rendererQuery;
const __DRI2interopExtension *interop;
int   fd;
@@ -230,6 +231,9 @@ struct dri2_egl_display
 
bool  is_render_node;
bool  is_different_gpu;
+
+   EGLSetBlobFuncANDROID blob_cache_set;
+   EGLGetBlobFuncANDROID blob_cache_get;
 };
 
 struct dri2_egl_context
diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c
index 5110688f2d..b8d64a913c 100644
--- a/src/egl/main/eglapi.c
+++ b/src/egl/main/eglapi.c
@@ -476,6 +476,7 @@ _eglCreateExtensionsString(_EGLDisplay *dpy)
char *exts = dpy->ExtensionsString;
 
/* Please keep these sorted alphabetically. */
+   _EGL_CHECK_EXTENSION(ANDROID_blob_cache);
_EGL_CHECK_EXTENSION(ANDROID_framebuffer_target);
_EGL_CHECK_EXTENSION(ANDROID_image_native_buffer);
_EGL_CHECK_EXTENSION(ANDROID_native_fence_sync);
@@ -2522,6 +2523,34 @@ eglQueryDmaBufModifiersEXT(EGLDisplay dpy,

[Mesa-dev] [RFC 07/10] mesa: add program blob cache functionality

2018-01-08 Thread Tapani Pälli
Cache set and get are called in similar fashion as what is happening
with disk cache. Functionality requires ARB_get_program_binary and
EGL_ANDROID_blob_cache support.

Signed-off-by: Tapani Pälli 
---
 src/mesa/Makefile.sources  |   2 +
 src/mesa/main/program_blob_cache.c | 141 +
 src/mesa/main/program_blob_cache.h |  48 +
 src/mesa/meson.build   |   2 +
 src/mesa/program/ir_to_mesa.cpp|   9 ++-
 5 files changed, 201 insertions(+), 1 deletion(-)
 create mode 100644 src/mesa/main/program_blob_cache.c
 create mode 100644 src/mesa/main/program_blob_cache.h

diff --git a/src/mesa/Makefile.sources b/src/mesa/Makefile.sources
index 53fa486364..bbcfdb425e 100644
--- a/src/mesa/Makefile.sources
+++ b/src/mesa/Makefile.sources
@@ -177,6 +177,8 @@ MAIN_FILES = \
main/polygon.h \
main/program_binary.c \
main/program_binary.h \
+   main/program_blob_cache.c \
+   main/program_blob_cache.h \
main/program_resource.c \
main/program_resource.h \
main/querymatrix.c \
diff --git a/src/mesa/main/program_blob_cache.c 
b/src/mesa/main/program_blob_cache.c
new file mode 100644
index 00..0b3ea1a549
--- /dev/null
+++ b/src/mesa/main/program_blob_cache.c
@@ -0,0 +1,141 @@
+/*
+ * Mesa 3-D graphics library
+ *
+ * Copyright (C) 2018 Intel Corporation.  All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, 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 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 "main/errors.h"
+#include "main/mtypes.h"
+#include "main/shaderobj.h"
+#include "main/program_binary.h"
+#include "util/mesa-sha1.h"
+#include "compiler/glsl/program.h"
+
+#include "program_blob_cache.h"
+
+/* This is what Android EGL defines as the maxValueSize in egl_cache_t
+ * class implementation.
+ */
+#define MAX_BLOB_SIZE 64 * 1024
+
+static void
+generate_sha1_string(struct gl_context *ctx, struct gl_shader_program *shProg,
+ char *key)
+{
+   char *buf = create_shader_program_keystr(ctx, shProg);
+   struct mesa_sha1 sha_ctx;
+   unsigned char sha1str[20];
+
+   /* Add driver sha1 to the key string. */
+   uint8_t driver_sha1[20];
+   char driver_sha1buf[41];
+
+   ctx->Driver.GetProgramBinaryDriverSHA1(ctx, driver_sha1);
+   _mesa_sha1_format(driver_sha1buf, driver_sha1);
+   ralloc_asprintf_append(&buf, "%s", driver_sha1buf);
+
+   _mesa_sha1_init(&sha_ctx);
+   _mesa_sha1_update(&sha_ctx, buf, strlen(buf));
+   _mesa_sha1_final(&sha_ctx, sha1str);
+   _mesa_sha1_format(key, sha1str);
+
+   ralloc_free(buf);
+}
+
+void
+_mesa_blob_cache_set(struct gl_context *ctx,
+ struct gl_shader_program *shProg)
+{
+   assert(shProg->data->LinkStatus == linking_success);
+
+   /* ARB_get_program_binary support required. */
+   if (!ctx->blobCacheSet || !ctx->Driver.GetProgramBinaryDriverSHA1)
+  return;
+
+   /* Skip cache for fixed-function programs and programs that use
+* transform feedback.
+*/
+   if (!shProg->Name || shProg->TransformFeedback.NumVarying > 0)
+  return;
+
+   GLint length;
+   _mesa_get_program_binary_length(ctx, shProg, &length);
+
+   /* Skip cache if exceeds max blob size. */
+   if (length > MAX_BLOB_SIZE)
+  return;
+
+   char *blob = (char *) malloc (length);
+
+   if (!blob)
+  return;
+
+   GLsizei real_len;
+   GLenum format;
+   _mesa_get_program_binary(ctx, shProg, length, &real_len,
+&format, blob);
+
+   assert(format == GL_PROGRAM_BINARY_FORMAT_MESA);
+
+   char key[41];
+   generate_sha1_string(ctx, shProg, key);
+
+   ctx->blobCacheSet(key, 41, blob, real_len);
+   free(blob);
+}
+
+void
+_mesa_blob_cache_get(struct gl_context *ctx,
+ struct gl_shader_program *shProg)
+{
+   /* ARB_get_program_binary support required. */

[Mesa-dev] [RFC 09/10] i965: add __DRI2_BLOB support and set cache functions

2018-01-08 Thread Tapani Pälli
Signed-off-by: Tapani Pälli 
---
 src/mesa/drivers/dri/i965/intel_screen.c | 18 ++
 1 file changed, 18 insertions(+)

diff --git a/src/mesa/drivers/dri/i965/intel_screen.c 
b/src/mesa/drivers/dri/i965/intel_screen.c
index 3e016b5b7a..01752700cf 100644
--- a/src/mesa/drivers/dri/i965/intel_screen.c
+++ b/src/mesa/drivers/dri/i965/intel_screen.c
@@ -1483,6 +1483,17 @@ brw_query_renderer_string(__DRIscreen *dri_screen,
return -1;
 }
 
+static void
+brw_set_cache_funcs(__DRIcontext *dri_ctx,
+__DRIblobCacheSet set, __DRIblobCacheGet get)
+{
+   struct brw_context *brw = dri_ctx->driverPrivate;
+   struct gl_context *ctx = &brw->ctx;
+
+   ctx->blobCacheSet = set;
+   ctx->blobCacheGet = get;
+}
+
 static const __DRI2rendererQueryExtension intelRendererQueryExtension = {
.base = { __DRI2_RENDERER_QUERY, 1 },
 
@@ -1494,6 +1505,11 @@ static const __DRIrobustnessExtension dri2Robustness = {
.base = { __DRI2_ROBUSTNESS, 1 }
 };
 
+static const __DRI2blobExtension intelBlobExtension = {
+   .base = { __DRI2_BLOB, 1 },
+   .set_cache_funcs = brw_set_cache_funcs
+};
+
 static const __DRIextension *screenExtensions[] = {
 &intelTexBufferExtension.base,
 &intelFenceExtension.base,
@@ -1503,6 +1519,7 @@ static const __DRIextension *screenExtensions[] = {
 &dri2ConfigQueryExtension.base,
 &dri2NoErrorExtension.base,
 &dri2FlushControlExtension.base,
+&intelBlobExtension.base,
 NULL
 };
 
@@ -1516,6 +1533,7 @@ static const __DRIextension 
*intelRobustScreenExtensions[] = {
 &dri2FlushControlExtension.base,
 &dri2Robustness.base,
 &dri2NoErrorExtension.base,
+&intelBlobExtension.base,
 NULL
 };
 
-- 
2.14.3

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


[Mesa-dev] [RFC 02/10] android: disable disk cache on Android

2018-01-08 Thread Tapani Pälli
Original reason why this was enabled was to get sha1 functionality
which used to be guarded by shader cache define. Instead of disk
cache, Android will utilize EGL_ANDROID_blob_cache for caching.

Signed-off-by: Tapani Pälli 
---
 Android.common.mk | 1 -
 1 file changed, 1 deletion(-)

diff --git a/Android.common.mk b/Android.common.mk
index d9f871c08c..6fd90f8895 100644
--- a/Android.common.mk
+++ b/Android.common.mk
@@ -46,7 +46,6 @@ LOCAL_CFLAGS += \
 # here to fix the radeonsi build.
 LOCAL_CFLAGS += \
-DANDROID_API_LEVEL=$(PLATFORM_SDK_VERSION) \
-   -DENABLE_SHADER_CACHE \
-D__STDC_CONSTANT_MACROS \
-D__STDC_LIMIT_MACROS \
-DHAVE___BUILTIN_EXPECT \
-- 
2.14.3

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


[Mesa-dev] [RFC 00/10] EGL_ANDROID_blob_cache RFC

2018-01-08 Thread Tapani Pälli
Hi;

This series enables EGL_ANDROID_blob_cache extension. Overall approach
is to skip linking of shader programs by utilizing functionality of
ARB_get_program_binary extension.

2 first patches are separate and could be pushed in, rest is RFC and 
last patch is additional debug patch that makes Mesa use this cache 
for all EGL apps.

With the last patch I've verified functionality on desktop using 
following apps: glmark2-es, Synmark, glbenchmark2.7.0 (could not make
new gfxbench versions work with EGL ..) and a 3rd party OpenGL ES 2.0
game engine that has relatively complex shaders.

*BUT* there are big issues when using this on Android. Main issue is
that textures are missing from some of the hwui (library used to render
android ui elements) programs. I'm continuing to debug this but wanted
to share to approach and see if someone might spot issues with the
implementation.

Any comments appreciated, thanks!

Tapani Pälli (10):
  glsl: cleanup shader_cache header guard
  android: disable disk cache on Android
  dri: add interface for EGL_ANDROID_blob_cache extension
  glsl: add function to create unique string from shader program
  mesa: add set and get functions to gl_context
  glsl: create shader sha1 if disk cache or blob cache is active
  mesa: add program blob cache functionality
  egl: add support for EGL_ANDROID_blob_cache
  i965: add __DRI2_BLOB support and set cache functions
  egl: XXX debug framework for EGL_ANDROID_blob_cache

 Android.common.mk|   1 -
 include/GL/internal/dri_interface.h  |  26 +-
 src/compiler/Makefile.sources|   1 +
 src/compiler/glsl/glsl_parser_extras.cpp |  26 +++---
 src/compiler/glsl/meson.build|   1 +
 src/compiler/glsl/program.cpp|  88 +++
 src/compiler/glsl/program.h  |  12 ++-
 src/compiler/glsl/shader_cache.cpp   |  55 +---
 src/compiler/glsl/shader_cache.h |   6 +-
 src/egl/drivers/dri2/egl_dri2.c  |  40 +
 src/egl/drivers/dri2/egl_dri2.h  |   4 +
 src/egl/main/eglapi.c| 106 +++
 src/egl/main/eglapi.h|   4 +
 src/egl/main/egldisplay.h|   3 +
 src/egl/main/eglentrypoint.h |   1 +
 src/mesa/Makefile.sources|   2 +
 src/mesa/drivers/dri/i965/intel_screen.c |  18 
 src/mesa/main/mtypes.h   |  16 
 src/mesa/main/program_blob_cache.c   | 141 +++
 src/mesa/main/program_blob_cache.h   |  48 +++
 src/mesa/meson.build |   2 +
 src/mesa/program/ir_to_mesa.cpp  |   9 +-
 src/util/disk_cache.c|   5 +-
 23 files changed, 538 insertions(+), 77 deletions(-)
 create mode 100644 src/compiler/glsl/program.cpp
 create mode 100644 src/mesa/main/program_blob_cache.c
 create mode 100644 src/mesa/main/program_blob_cache.h

-- 
2.14.3

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


[Mesa-dev] [RFC 04/10] glsl: add function to create unique string from shader program

2018-01-08 Thread Tapani Pälli
Patch moves existing functionality from shader_cache_read_program_metadata
to a helper function.

Signed-off-by: Tapani Pälli 
---
 src/compiler/Makefile.sources  |  1 +
 src/compiler/glsl/meson.build  |  1 +
 src/compiler/glsl/program.cpp  | 88 ++
 src/compiler/glsl/program.h| 12 --
 src/compiler/glsl/shader_cache.cpp | 55 +---
 5 files changed, 100 insertions(+), 57 deletions(-)
 create mode 100644 src/compiler/glsl/program.cpp

diff --git a/src/compiler/Makefile.sources b/src/compiler/Makefile.sources
index d3f746f5f9..e3dfacf98c 100644
--- a/src/compiler/Makefile.sources
+++ b/src/compiler/Makefile.sources
@@ -136,6 +136,7 @@ LIBGLSL_FILES = \
glsl/opt_swizzle.cpp \
glsl/opt_tree_grafting.cpp \
glsl/opt_vectorize.cpp \
+   glsl/program.cpp \
glsl/program.h \
glsl/propagate_invariance.cpp \
glsl/s_expression.cpp \
diff --git a/src/compiler/glsl/meson.build b/src/compiler/glsl/meson.build
index 6aaa9bab05..5d8d8d4530 100644
--- a/src/compiler/glsl/meson.build
+++ b/src/compiler/glsl/meson.build
@@ -175,6 +175,7 @@ files_libglsl = files(
   'opt_swizzle.cpp',
   'opt_tree_grafting.cpp',
   'opt_vectorize.cpp',
+  'program.cpp',
   'program.h',
   'propagate_invariance.cpp',
   's_expression.cpp',
diff --git a/src/compiler/glsl/program.cpp b/src/compiler/glsl/program.cpp
new file mode 100644
index 00..df7124485d
--- /dev/null
+++ b/src/compiler/glsl/program.cpp
@@ -0,0 +1,88 @@
+/*
+ * Copyright © 2018 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 "main/mtypes.h"
+#include "util/mesa-sha1.h"
+#include "string_to_uint_map.h"
+#include "program.h"
+
+static void
+create_binding_str(const char *key, unsigned value, void *closure)
+{
+   char **bindings_str = (char **) closure;
+   ralloc_asprintf_append(bindings_str, "%s:%u,", key, value);
+}
+
+extern "C" char *
+create_shader_program_keystr(struct gl_context *ctx,
+ struct gl_shader_program *prog)
+{
+   /* Include bindings when creating sha1. These bindings change the resulting
+* binary so they are just as important as the shader source.
+*/
+   char *buf = ralloc_strdup(NULL, "vb: ");
+   prog->AttributeBindings->iterate(create_binding_str, &buf);
+   ralloc_strcat(&buf, "fb: ");
+   prog->FragDataBindings->iterate(create_binding_str, &buf);
+   ralloc_strcat(&buf, "fbi: ");
+   prog->FragDataIndexBindings->iterate(create_binding_str, &buf);
+
+   /* SSO has an effect on the linked program so include this when generating
+* the sha also.
+*/
+   ralloc_asprintf_append(&buf, "sso: %s\n",
+  prog->SeparateShader ? "T" : "F");
+
+   /* A shader might end up producing different output depending on the glsl
+* version supported by the compiler. For example a different path might be
+* taken by the preprocessor, so add the version to the hash input.
+*/
+   ralloc_asprintf_append(&buf, "api: %d glsl: %d fglsl: %d\n",
+  ctx->API, ctx->Const.GLSLVersion,
+  ctx->Const.ForceGLSLVersion);
+
+   /* We run the preprocessor on shaders after hashing them, so we need to
+* add any extension override vars to the hash. If we don't do this the
+* preprocessor could result in different output and we could load the
+* wrong shader.
+*/
+   char *ext_override = getenv("MESA_EXTENSION_OVERRIDE");
+   if (ext_override) {
+  ralloc_asprintf_append(&buf, "ext:%s", ext_override);
+   }

[Mesa-dev] [RFC 03/10] dri: add interface for EGL_ANDROID_blob_cache extension

2018-01-08 Thread Tapani Pälli
Signed-off-by: Tapani Pälli 
---
 include/GL/internal/dri_interface.h | 26 +-
 1 file changed, 25 insertions(+), 1 deletion(-)

diff --git a/include/GL/internal/dri_interface.h 
b/include/GL/internal/dri_interface.h
index 34a5c9fb01..de367d8f77 100644
--- a/include/GL/internal/dri_interface.h
+++ b/include/GL/internal/dri_interface.h
@@ -82,7 +82,7 @@ typedef struct __DRI2flushExtensionRec
__DRI2flushExtension;
 typedef struct __DRI2throttleExtensionRec  __DRI2throttleExtension;
 typedef struct __DRI2fenceExtensionRec  __DRI2fenceExtension;
 typedef struct __DRI2interopExtensionRec   __DRI2interopExtension;
-
+typedef struct __DRI2blobExtensionRec   __DRI2blobExtension;
 
 typedef struct __DRIimageLoaderExtensionRec __DRIimageLoaderExtension;
 typedef struct __DRIimageDriverExtensionRec __DRIimageDriverExtension;
@@ -336,6 +336,30 @@ struct __DRI2throttleExtensionRec {
enum __DRI2throttleReason reason);
 };
 
+/**
+ * Extension for EGL_ANDROID_blob_cache
+ */
+
+#define __DRI2_BLOB "DRI2_Blob"
+#define __DRI2_BLOB_VERSION 1
+
+typedef void
+(*__DRIblobCacheSet) (const void *key, signed long keySize,
+  const void *value, signed long valueSize);
+
+typedef signed long
+(*__DRIblobCacheGet) (const void *key, signed long keySize,
+  void *value, signed long valueSize);
+
+struct __DRI2blobExtensionRec {
+   __DRIextension base;
+
+   /**
+* Set cache functions for setting and getting cache entries.
+*/
+   void (*set_cache_funcs) (__DRIcontext *ctx,
+__DRIblobCacheSet set, __DRIblobCacheGet get);
+};
 
 /**
  * Extension for fences / synchronization objects.
-- 
2.14.3

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


[Mesa-dev] [RFC 05/10] mesa: add set and get functions to gl_context

2018-01-08 Thread Tapani Pälli
These will be utilized by EGL_ANDROID_blob_cache extension.

Signed-off-by: Tapani Pälli 
---
 src/mesa/main/mtypes.h | 16 
 1 file changed, 16 insertions(+)

diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index a4f1e78f41..073b6c8536 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -4702,6 +4702,14 @@ struct gl_memory_object
GLboolean Dedicated;/**< import memory from a dedicated allocation */
 };
 
+typedef void
+(*mesa_blob_cache_set_cb) (const void *key, signed long keySize,
+   const void *value, signed long valueSize);
+
+typedef signed long
+(*mesa_blob_cache_get_cb) (const void *key, signed long keySize,
+   void *value, signed long valueSize);
+
 /**
  * Mesa rendering context.
  *
@@ -5074,6 +5082,14 @@ struct gl_context
struct hash_table_u64 *ResidentTextureHandles;
struct hash_table_u64 *ResidentImageHandles;
/*@}*/
+
+   /**
+* \name EGL_ANDROID_blob_cache
+*/
+   /*@{*/
+   mesa_blob_cache_set_cb blobCacheSet;
+   mesa_blob_cache_get_cb blobCacheGet;
+   /*@}*/
 };
 
 /**
-- 
2.14.3

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


[Mesa-dev] [RFC 01/10] glsl: cleanup shader_cache header guard

2018-01-08 Thread Tapani Pälli
Signed-off-by: Tapani Pälli 
---
 src/compiler/glsl/shader_cache.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/compiler/glsl/shader_cache.h b/src/compiler/glsl/shader_cache.h
index c0598f37e8..eeefb3aeb2 100644
--- a/src/compiler/glsl/shader_cache.h
+++ b/src/compiler/glsl/shader_cache.h
@@ -21,8 +21,8 @@
  * DEALINGS IN THE SOFTWARE.
  */
 
-#ifndef SHADER_CACHE
-#define SHADER_CACHE
+#ifndef SHADER_CACHE_H
+#define SHADER_CACHE_H
 
 #include "util/disk_cache.h"
 
@@ -34,4 +34,4 @@ bool
 shader_cache_read_program_metadata(struct gl_context *ctx,
struct gl_shader_program *prog);
 
-#endif /* GLSL_SYMBOL_TABLE */
+#endif /* SHADER_CACHE_H */
-- 
2.14.3

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


Re: [Mesa-dev] [PATCH] dri_util: remove ALLOW_RGB10_CONFIGS option

2018-01-08 Thread Tapani Pälli


On 01/08/2018 06:59 PM, Marek Olšák wrote:

From: Marek Olšák 

This is unused because it's for libGL/libEGL, not drivers.


IMO this is not enough, you would need to also remove the query for this 
as well (driQueryOptionb in intel_screen.c), otherwise we hit assertion. 
Maybe just set bool allow_rgb10_configs = false for now?




---
  src/mesa/drivers/dri/common/dri_util.c | 4 
  1 file changed, 4 deletions(-)

diff --git a/src/mesa/drivers/dri/common/dri_util.c 
b/src/mesa/drivers/dri/common/dri_util.c
index d4fba0b..e6a7d23 100644
--- a/src/mesa/drivers/dri/common/dri_util.c
+++ b/src/mesa/drivers/dri/common/dri_util.c
@@ -48,24 +48,20 @@
  #include "main/version.h"
  #include "main/debug_output.h"
  #include "main/errors.h"
  #include "main/macros.h"
  
  const char __dri2ConfigOptions[] =

 DRI_CONF_BEGIN
DRI_CONF_SECTION_PERFORMANCE
   DRI_CONF_VBLANK_MODE(DRI_CONF_VBLANK_DEF_INTERVAL_1)
DRI_CONF_SECTION_END
-
-  DRI_CONF_SECTION_MISCELLANEOUS
- DRI_CONF_ALLOW_RGB10_CONFIGS("true")
-  DRI_CONF_SECTION_END
 DRI_CONF_END;
  
  /*/

  /** \name Screen handling functions  */
  /*/
  /*@{*/
  
  static void

  setupLoaderExtensions(__DRIscreen *psp,
  const __DRIextension **extensions)


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


Re: [Mesa-dev] [PATCH 07/22] dri/common: Add option to allow exposure of 10 bpc color configs. (v2)

2018-01-08 Thread Tapani Pälli



On 01/08/2018 01:55 AM, Steven Newbury wrote:

On Fri, 2017-12-15 at 23:04 +0100, Mario Kleiner wrote:

Some clients may not like RGB10X2 and RGB10A2 fbconfigs and
visuals. Add a new driconf option 'allow_rgb10_configs' to
allow per application enable/disable.

The option defaults to enabled.

v2: Rename expose_rgb10_configs to allow_rgb10_configs,
 as suggested by Emil. Add comment to option parsing,
 to make sure it stays before the ->InitScreen().

Signed-off-by: Mario Kleiner 
Reviewed-by: Tapani Pälli 
Reviewed-by: Marek Olšák 
---
  src/mesa/drivers/dri/common/dri_util.c | 12 
  src/util/xmlpool/t_options.h   |  5 +
  2 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/src/mesa/drivers/dri/common/dri_util.c
b/src/mesa/drivers/dri/common/dri_util.c
index d504751..d4fba0b 100644
--- a/src/mesa/drivers/dri/common/dri_util.c
+++ b/src/mesa/drivers/dri/common/dri_util.c
@@ -55,6 +55,10 @@ const char __dri2ConfigOptions[] =
DRI_CONF_SECTION_PERFORMANCE
   DRI_CONF_VBLANK_MODE(DRI_CONF_VBLANK_DEF_INTERVAL_1)
DRI_CONF_SECTION_END
+
+  DRI_CONF_SECTION_MISCELLANEOUS
+ DRI_CONF_ALLOW_RGB10_CONFIGS("true")
+  DRI_CONF_SECTION_END
 DRI_CONF_END;
  

This isn't exposing the driconf option for me with IVB HD4000.  Adding
the option to the same section in
src/mesa/drivers/dri/i965/intel_screen.c did work though.

Mind you having this default as true (which it does whether or not the
option is available) is really bad here.  On my LVDS display (which
presumably isn't supporting 10bpc even if the chipset does, means by
default my display colours are completely corrupted.

What's more, the driconf option doesn't address Wayland compositors,
for example GDM with Wayland doesn't respect the option but uses, I
guess, a default config which happens to be 10bpc.



I thought I knew how drirc works ... but seems like this is not the 
case. I thought driver could override this option by introducing same 
section in it's own drirc but that does not seem to work :/ I think we 
should set this globally false for now (until compositor issues are 
resolved) and also fix the option to work in a way that individual 
driver can set this value.


FYI I filed but about this here:
https://bugs.freedesktop.org/show_bug.cgi?id=104536

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


Re: [Mesa-dev] [PATCH] egl/android: Fix build break with dri2_initialize_android _EGLDisplay parameter

2018-01-03 Thread Tapani Pälli

Reviewed-by: Tapani Pälli 

On 01/03/2018 06:28 PM, Rob Herring wrote:

Commit 2f421651aca9 ("egl: let each platform decided how to handle
LIBGL_ALWAYS_SOFTWARE") broke the build due to copy-n-paste of misnamed
function parameter.:

src/egl/drivers/dri2/platform_android.c:1183:8: error: use of undeclared 
identifier 'disp'

Rather than just fixing 'disp', rename the function parameter 'dpy' to
'disp' to align with the other EGL platforms' implementations.

Fixes: 2f421651aca9 ("egl: let each platform decided how to handle 
LIBGL_ALWAYS_SOFTWARE")
Cc: Eric Engestrom 
Signed-off-by: Rob Herring 
---
  src/egl/drivers/dri2/platform_android.c | 30 +++---
  1 file changed, 15 insertions(+), 15 deletions(-)

diff --git a/src/egl/drivers/dri2/platform_android.c 
b/src/egl/drivers/dri2/platform_android.c
index 34e3ef66bfeb..4f25cb746915 100644
--- a/src/egl/drivers/dri2/platform_android.c
+++ b/src/egl/drivers/dri2/platform_android.c
@@ -1173,7 +1173,7 @@ static const __DRIextension 
*droid_image_loader_extensions[] = {
  };
  
  EGLBoolean

-dri2_initialize_android(_EGLDriver *drv, _EGLDisplay *dpy)
+dri2_initialize_android(_EGLDriver *drv, _EGLDisplay *disp)
  {
 struct dri2_egl_display *dri2_dpy;
 const char *err;
@@ -1197,7 +1197,7 @@ dri2_initialize_android(_EGLDriver *drv, _EGLDisplay *dpy)
goto cleanup;
 }
  
-   dpy->DriverData = (void *) dri2_dpy;

+   disp->DriverData = (void *) dri2_dpy;
  
 dri2_dpy->fd = droid_open_device(dri2_dpy);

 if (dri2_dpy->fd < 0) {
@@ -1217,43 +1217,43 @@ dri2_initialize_android(_EGLDriver *drv, _EGLDisplay 
*dpy)
  * the __DRI_DRI2_LOADER extension */
 if (!dri2_dpy->is_render_node) {
dri2_dpy->loader_extensions = droid_dri2_loader_extensions;
-  if (!dri2_load_driver(dpy)) {
+  if (!dri2_load_driver(disp)) {
   err = "DRI2: failed to load driver";
   goto cleanup;
}
 } else {
dri2_dpy->loader_extensions = droid_image_loader_extensions;
-  if (!dri2_load_driver_dri3(dpy)) {
+  if (!dri2_load_driver_dri3(disp)) {
   err = "DRI3: failed to load driver";
   goto cleanup;
}
 }
  
-   if (!dri2_create_screen(dpy)) {

+   if (!dri2_create_screen(disp)) {
err = "DRI2: failed to create screen";
goto cleanup;
 }
  
-   if (!dri2_setup_extensions(dpy)) {

+   if (!dri2_setup_extensions(disp)) {
err = "DRI2: failed to setup extensions";
goto cleanup;
 }
  
-   dri2_setup_screen(dpy);

+   dri2_setup_screen(disp);
  
-   if (!droid_add_configs_for_visuals(drv, dpy)) {

+   if (!droid_add_configs_for_visuals(drv, disp)) {
err = "DRI2: failed to add configs";
goto cleanup;
 }
  
-   dpy->Extensions.ANDROID_framebuffer_target = EGL_TRUE;

-   dpy->Extensions.ANDROID_image_native_buffer = EGL_TRUE;
-   dpy->Extensions.ANDROID_recordable = EGL_TRUE;
-   dpy->Extensions.EXT_buffer_age = EGL_TRUE;
+   disp->Extensions.ANDROID_framebuffer_target = EGL_TRUE;
+   disp->Extensions.ANDROID_image_native_buffer = EGL_TRUE;
+   disp->Extensions.ANDROID_recordable = EGL_TRUE;
+   disp->Extensions.EXT_buffer_age = EGL_TRUE;
  #if ANDROID_API_LEVEL >= 23
-   dpy->Extensions.KHR_partial_update = EGL_TRUE;
+   disp->Extensions.KHR_partial_update = EGL_TRUE;
  #endif
-   dpy->Extensions.KHR_image = EGL_TRUE;
+   disp->Extensions.KHR_image = EGL_TRUE;
  
 /* Fill vtbl last to prevent accidentally calling virtual function during

  * initialization.
@@ -1263,6 +1263,6 @@ dri2_initialize_android(_EGLDriver *drv, _EGLDisplay *dpy)
 return EGL_TRUE;
  
  cleanup:

-   dri2_display_destroy(dpy);
+   dri2_display_destroy(disp);
 return _eglError(EGL_NOT_INITIALIZED, err);
  }


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


Re: [Mesa-dev] Retrieving useful debug infos about (AMD) Mesa and Firefox quirks

2018-01-02 Thread Tapani Pälli

Hi;

On 01/02/2018 10:46 PM, Germano Massullo wrote:

Hi everyone!

Bugreport

"Latest mesa breaks firefox on kde plasma with compositing on" 
https://bugs.freedesktop.org/show_bug.cgi?id=103699


is about Intel cards, and it looks like the bug has been fixed with an 
Intel only patch. Personally, I am experiencing the same bug on AMDGPU 
(FOSS) driver, RX480 card, so I opened bugreport 
https://bugs.freedesktop.org/show_bug.cgi?id=104216


As I mentioned in bug #103699, this is a different bug/issue. With 
#103699, Firefox menus (separate windows than browser itself) are 
invisible and there are no black or white squares as in your report.


Since my Firefox user experienced has been ruined since several weeks, I 
would like to ask you if it is anything I can do to retireve more useful 
infos for you Mesa developers.


Thank you very much


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


Re: [Mesa-dev] [PATCH 13/16] meta: Track temporary textures using gl_texture_object instead of GL API object handle

2017-12-21 Thread Tapani Pälli



On 19.12.2017 02:14, Ian Romanick wrote:

From: Ian Romanick 

Signed-off-by: Ian Romanick 
---
  src/mesa/drivers/common/meta.c  | 43 ++---
  src/mesa/drivers/common/meta.h  |  2 +-
  src/mesa/drivers/common/meta_blit.c |  8 ---
  3 files changed, 36 insertions(+), 17 deletions(-)

diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c
index 52d959a..be490d5 100644
--- a/src/mesa/drivers/common/meta.c
+++ b/src/mesa/drivers/common/meta.c
@@ -1228,6 +1228,8 @@ invert_z(GLfloat normZ)
  static void
  init_temp_texture(struct gl_context *ctx, struct temp_texture *tex)
  {
+   GLuint texObj;
+


this declaration could've been moved closer to the usage but since it's 
removed later ... it does not really matter :)



 /* prefer texture rectangle */
 if (_mesa_is_desktop_gl(ctx) && ctx->Extensions.NV_texture_rectangle) {
tex->Target = GL_TEXTURE_RECTANGLE;
@@ -1243,16 +1245,22 @@ init_temp_texture(struct gl_context *ctx, struct 
temp_texture *tex)
 tex->MinSize = 16;  /* 16 x 16 at least */
 assert(tex->MaxSize > 0);
  
-   _mesa_GenTextures(1, &tex->TexObj);

+   _mesa_GenTextures(1, &texObj);
+   tex->tex_obj = NULL;
+
+   if (texObj == 0)
+  return;
+
+   tex->tex_obj = _mesa_lookup_texture(ctx, texObj);
  }
  
  static void

  cleanup_temp_texture(struct temp_texture *tex)
  {
-   if (!tex->TexObj)
+   if (tex->tex_obj == NULL)
   return;
-   _mesa_DeleteTextures(1, &tex->TexObj);
-   tex->TexObj = 0;
+   _mesa_DeleteTextures(1, &tex->tex_obj->Name);
+   tex->tex_obj = NULL;
  }
  
  
@@ -1265,7 +1273,7 @@ _mesa_meta_get_temp_texture(struct gl_context *ctx)

  {
 struct temp_texture *tex = &ctx->Meta->TempTex;
  
-   if (!tex->TexObj) {

+   if (tex->tex_obj == NULL) {
init_temp_texture(ctx, tex);
 }
  
@@ -1283,7 +1291,7 @@ get_bitmap_temp_texture(struct gl_context *ctx)

  {
 struct temp_texture *tex = &ctx->Meta->Bitmap.Tex;
  
-   if (!tex->TexObj) {

+   if (tex->tex_obj == NULL) {
init_temp_texture(ctx, tex);
 }
  
@@ -1299,7 +1307,7 @@ _mesa_meta_get_temp_depth_texture(struct gl_context *ctx)

  {
 struct temp_texture *tex = &ctx->Meta->Blit.depthTex;
  
-   if (!tex->TexObj) {

+   if (tex->tex_obj == NULL) {
init_temp_texture(ctx, tex);
 }
  
@@ -1378,9 +1386,11 @@ _mesa_meta_setup_copypix_texture(struct gl_context *ctx,

  {
 bool newTex;
  
-   _mesa_BindTexture(tex->Target, tex->TexObj);

-   _mesa_TexParameteri(tex->Target, GL_TEXTURE_MIN_FILTER, filter);
-   _mesa_TexParameteri(tex->Target, GL_TEXTURE_MAG_FILTER, filter);
+   _mesa_BindTexture(tex->Target, tex->tex_obj->Name);
+   _mesa_texture_parameteriv(ctx, tex->tex_obj, GL_TEXTURE_MIN_FILTER,
+ (GLint *) &filter, false);
+   _mesa_texture_parameteriv(ctx, tex->tex_obj, GL_TEXTURE_MAG_FILTER,
+ (GLint *) &filter, false);
 _mesa_TexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
  
 newTex = _mesa_meta_alloc_texture(tex, width, height, intFormat);

@@ -1422,9 +1432,16 @@ _mesa_meta_setup_drawpix_texture(struct gl_context *ctx,
   GLenum format, GLenum type,
   const GLvoid *pixels)
  {
-   _mesa_BindTexture(tex->Target, tex->TexObj);
-   _mesa_TexParameteri(tex->Target, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
-   _mesa_TexParameteri(tex->Target, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+   /* GLint so the compiler won't complain about type signedness mismatch in
+* the call to _mesa_texture_parameteriv below.
+*/
+   static const GLint filter = GL_NEAREST;
+
+   _mesa_BindTexture(tex->Target, tex->tex_obj->Name);
+   _mesa_texture_parameteriv(ctx, tex->tex_obj, GL_TEXTURE_MIN_FILTER, &filter,
+ false);
+   _mesa_texture_parameteriv(ctx, tex->tex_obj, GL_TEXTURE_MAG_FILTER, &filter,
+ false);
 _mesa_TexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
  
 /* copy pixel data to texture */

diff --git a/src/mesa/drivers/common/meta.h b/src/mesa/drivers/common/meta.h
index 252b236..6d51854 100644
--- a/src/mesa/drivers/common/meta.h
+++ b/src/mesa/drivers/common/meta.h
@@ -200,7 +200,7 @@ struct save_state
   */
  struct temp_texture
  {
-   GLuint TexObj;
+   struct gl_texture_object *tex_obj;
 GLenum Target; /**< GL_TEXTURE_2D or GL_TEXTURE_RECTANGLE */
 GLsizei MinSize;   /**< Min texture size to allocate */
 GLsizei MaxSize;   /**< Max possible texture size */
diff --git a/src/mesa/drivers/common/meta_blit.c 
b/src/mesa/drivers/common/meta_blit.c
index 0c08109..95dfa64 100644
--- a/src/mesa/drivers/common/meta_blit.c
+++ b/src/mesa/drivers/common/meta_blit.c
@@ -674,7 +674,7 @@ blitframebuffer_texture(struct gl_context *ctx,
}
  
srcLevel = 0;

-  texObj = _mesa_lookup_texture(ctx, meta_temp_texture->TexObj);
+  texObj = meta_temp_texture->

Re: [Mesa-dev] [PATCH 16/16] meta: Don't pollute the texture namespace

2017-12-21 Thread Tapani Pälli

series is
Reviewed-by: Tapani Pälli 

On 19.12.2017 02:14, Ian Romanick wrote:

From: Ian Romanick 

tl;dr: For many types of GL object, we can *NEVER* use the Gen function.

In OpenGL ES (all versions!) and OpenGL compatibility profile,
applications don't have to call Gen functions.  The GL spec is very
clear about how you can mix-and-match generated names and non-generated
names: you can use any name you want for a particular object type until
you call the Gen function for that object type.

Here's the problem scenario:

  - Application calls a meta function that generates a name.  The first
Gen will probably return 1.

  - Application decides to use the same name for an object of the same
type without calling Gen.  Many demo programs use names 1, 2, 3,
etc. without calling Gen.

  - Application calls the meta function again, and the meta function
replaces the data.  The application's data is lost, and the app
fails.  Have fun debugging that.

Signed-off-by: Ian Romanick 
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=92363
---
  src/mesa/drivers/common/meta.c  | 21 ++---
  src/mesa/drivers/common/meta_blit.c | 18 --
  2 files changed, 10 insertions(+), 29 deletions(-)

diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c
index 55d803f..f4830ec 100644
--- a/src/mesa/drivers/common/meta.c
+++ b/src/mesa/drivers/common/meta.c
@@ -98,7 +98,8 @@ meta_clear(struct gl_context *ctx, GLbitfield buffers, bool 
glsl);
  static struct blit_shader *
  choose_blit_shader(GLenum target, struct blit_shader_table *table);
  
-static void cleanup_temp_texture(struct temp_texture *tex);

+static void cleanup_temp_texture(struct gl_context *ctx,
+ struct temp_texture *tex);
  static void meta_glsl_clear_cleanup(struct gl_context *ctx,
  struct clear_state *clear);
  static void meta_decompress_cleanup(struct gl_context *ctx,
@@ -418,7 +419,7 @@ _mesa_meta_free(struct gl_context *ctx)
 _mesa_meta_glsl_blit_cleanup(ctx, &ctx->Meta->Blit);
 meta_glsl_clear_cleanup(ctx, &ctx->Meta->Clear);
 _mesa_meta_glsl_generate_mipmap_cleanup(ctx, &ctx->Meta->Mipmap);
-   cleanup_temp_texture(&ctx->Meta->TempTex);
+   cleanup_temp_texture(ctx, &ctx->Meta->TempTex);
 meta_decompress_cleanup(ctx, &ctx->Meta->Decompress);
 meta_drawpix_cleanup(ctx, &ctx->Meta->DrawPix);
 if (old_context)
@@ -1228,8 +1229,6 @@ invert_z(GLfloat normZ)
  static void
  init_temp_texture(struct gl_context *ctx, struct temp_texture *tex)
  {
-   GLuint texObj;
-
 /* prefer texture rectangle */
 if (_mesa_is_desktop_gl(ctx) && ctx->Extensions.NV_texture_rectangle) {
tex->Target = GL_TEXTURE_RECTANGLE;
@@ -1245,21 +1244,13 @@ init_temp_texture(struct gl_context *ctx, struct 
temp_texture *tex)
 tex->MinSize = 16;  /* 16 x 16 at least */
 assert(tex->MaxSize > 0);
  
-   _mesa_CreateTextures(tex->Target, 1, &texObj);

-   tex->tex_obj = NULL;
-
-   if (texObj == 0)
-  return;
-
-   tex->tex_obj = _mesa_lookup_texture(ctx, texObj);
+   tex->tex_obj = ctx->Driver.NewTextureObject(ctx, 0xDEADBEEF, tex->Target);
  }
  
  static void

-cleanup_temp_texture(struct temp_texture *tex)
+cleanup_temp_texture(struct gl_context *ctx, struct temp_texture *tex)
  {
-   if (tex->tex_obj == NULL)
- return;
-   _mesa_DeleteTextures(1, &tex->tex_obj->Name);
+   _mesa_delete_nameless_texture(ctx, tex->tex_obj);
 tex->tex_obj = NULL;
  }
  
diff --git a/src/mesa/drivers/common/meta_blit.c b/src/mesa/drivers/common/meta_blit.c

index 95dfa64..496ef28 100644
--- a/src/mesa/drivers/common/meta_blit.c
+++ b/src/mesa/drivers/common/meta_blit.c
@@ -879,9 +879,7 @@ _mesa_meta_fb_tex_blit_end(struct gl_context *ctx, GLenum 
target,
 _mesa_bind_sampler(ctx, ctx->Texture.CurrentUnit, blit->samp_obj_save);
 _mesa_reference_sampler_object(ctx, &blit->samp_obj_save, NULL);
 _mesa_reference_sampler_object(ctx, &blit->samp_obj, NULL);
-
-   if (blit->temp_tex_obj)
-  _mesa_DeleteTextures(1, &blit->temp_tex_obj->Name);
+   _mesa_delete_nameless_texture(ctx, blit->temp_tex_obj);
  }
  
  struct gl_texture_object *

@@ -890,20 +888,14 @@ _mesa_meta_texture_object_from_renderbuffer(struct 
gl_context *ctx,
  {
 struct gl_texture_image *texImage;
 struct gl_texture_object *texObj;
-   GLuint tempTex;
 const GLenum target = rb->NumSamples > 1
? GL_TEXTURE_2D_MULTISAMPLE : GL_TEXTURE_2D;
  
-   tempTex = 0;

-   _mesa_CreateTextures(target, 1, &tempTex);
-   if (tempTex == 0)
-  return NULL;
-
-   texObj = _mesa_lookup_texture(ctx, tempTex);
+   texObj = ctx->Driver.NewTextureObject(ctx, 0xDEADBEEF, target);
 texImage = _mesa_get_tex_image(ctx, texObj,

Re: [Mesa-dev] [PATCH 03/16] mesa: Add _mesa_bind_texture method

2017-12-20 Thread Tapani Pälli



On 20.12.2017 20:04, Tapani Pälli wrote:



On 20.12.2017 01:36, Ian Romanick wrote:

On 12/19/2017 03:45 AM, Tapani Pälli wrote:



On 12/19/2017 01:39 PM, Tapani Pälli wrote:



On 12/19/2017 02:14 AM, Ian Romanick wrote:

From: Ian Romanick 

Light-weight glBindTexture for internal use.

Signed-off-by: Ian Romanick 
---
   src/mesa/main/texobj.c | 17 -
   src/mesa/main/texobj.h |  4 +++-
   2 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/src/mesa/main/texobj.c b/src/mesa/main/texobj.c
index db40598..cd9f43c 100644
--- a/src/mesa/main/texobj.c
+++ b/src/mesa/main/texobj.c
@@ -1692,6 +1692,22 @@ bind_texture_object(struct gl_context *ctx,
unsigned unit,
  }
   }


This could have some documentation block that says when it is used and
what are the differences with bind_texture?


(some small comment like "Light-weight glBindTexture for internal use."
could do)


I've added this locally:

/**
  * Light-weight bind texture for internal users
  *
  * This is really just \c finish_texture_init plus \c 
bind_texture_object.

  * This is intended to be used by internal Mesa functions that use
  * \c _mesa_CreateTexture and need to bind textures (e.g., meta).
  */


That looks good!

I've been going through here with rest of the set (I'm not very familiar 
with meta so this takes time :/) and I'm wondering how do you test the 
blitframebuffer changes? I tried to disable blorp and use only meta for 
frambuffer blits but then lots of things fail with 'Invalid blit' with 
the assertion here:


--- 8< ---
    if (devinfo->gen >= 8 && (mask & GL_STENCIL_BUFFER_BIT)) {
   assert(!"Invalid blit");
    }
--- 8< ---

I can see that blitframebuffer works fine for color buffers though when 
debugging with game engine that does some color blits


OK now I realized meta does not do stencil, so it would be color and 
depth blit tests only. I'll do some further testing with that.







Patches 1,2,3
Reviewed-by: Tapani Pälli 


+void
+_mesa_bind_texture(struct gl_context *ctx, GLenum target,
+   struct gl_texture_object *tex_obj)
+{
+   const GLint targetIndex = _mesa_tex_target_to_index(ctx, target);
+
+   assert(targetIndex >= 0 && targetIndex < NUM_TEXTURE_TARGETS);
+
+   if (tex_obj->Target == 0)
+  finish_texture_init(ctx, target, tex_obj, targetIndex);
+
+   assert(tex_obj->Target == target);
+   assert(tex_obj->TargetIndex == targetIndex);
+
+   bind_texture_object(ctx, ctx->Texture.CurrentUnit, tex_obj);
+}
   /**
    * Implement glBindTexture().  Do error checking, look-up or create
a new
@@ -1764,7 +1780,6 @@ bind_texture(struct gl_context *ctx, GLenum
target, GLuint texName,
  bind_texture_object(ctx, ctx->Texture.CurrentUnit, newTexObj);
   }
-
   void GLAPIENTRY
   _mesa_BindTexture_no_error(GLenum target, GLuint texName)
   {
diff --git a/src/mesa/main/texobj.h b/src/mesa/main/texobj.h
index 8dea853..f2d78ac 100644
--- a/src/mesa/main/texobj.h
+++ b/src/mesa/main/texobj.h
@@ -175,7 +175,9 @@ extern void
   _mesa_delete_nameless_texture(struct gl_context *ctx,
 struct gl_texture_object *texObj);
-
+extern void
+_mesa_bind_texture(struct gl_context *ctx, GLenum target,
+   struct gl_texture_object *tex_obj);
   /*@}*/
   /**


___
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 mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 03/16] mesa: Add _mesa_bind_texture method

2017-12-20 Thread Tapani Pälli



On 20.12.2017 01:36, Ian Romanick wrote:

On 12/19/2017 03:45 AM, Tapani Pälli wrote:



On 12/19/2017 01:39 PM, Tapani Pälli wrote:



On 12/19/2017 02:14 AM, Ian Romanick wrote:

From: Ian Romanick 

Light-weight glBindTexture for internal use.

Signed-off-by: Ian Romanick 
---
   src/mesa/main/texobj.c | 17 -
   src/mesa/main/texobj.h |  4 +++-
   2 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/src/mesa/main/texobj.c b/src/mesa/main/texobj.c
index db40598..cd9f43c 100644
--- a/src/mesa/main/texobj.c
+++ b/src/mesa/main/texobj.c
@@ -1692,6 +1692,22 @@ bind_texture_object(struct gl_context *ctx,
unsigned unit,
  }
   }


This could have some documentation block that says when it is used and
what are the differences with bind_texture?


(some small comment like "Light-weight glBindTexture for internal use."
could do)


I've added this locally:

/**
  * Light-weight bind texture for internal users
  *
  * This is really just \c finish_texture_init plus \c bind_texture_object.
  * This is intended to be used by internal Mesa functions that use
  * \c _mesa_CreateTexture and need to bind textures (e.g., meta).
  */


That looks good!

I've been going through here with rest of the set (I'm not very familiar 
with meta so this takes time :/) and I'm wondering how do you test the 
blitframebuffer changes? I tried to disable blorp and use only meta for 
frambuffer blits but then lots of things fail with 'Invalid blit' with 
the assertion here:


--- 8< ---
   if (devinfo->gen >= 8 && (mask & GL_STENCIL_BUFFER_BIT)) {
  assert(!"Invalid blit");
   }
--- 8< ---

I can see that blitframebuffer works fine for color buffers though when 
debugging with game engine that does some color blits.





Patches 1,2,3
Reviewed-by: Tapani Pälli 


+void
+_mesa_bind_texture(struct gl_context *ctx, GLenum target,
+   struct gl_texture_object *tex_obj)
+{
+   const GLint targetIndex = _mesa_tex_target_to_index(ctx, target);
+
+   assert(targetIndex >= 0 && targetIndex < NUM_TEXTURE_TARGETS);
+
+   if (tex_obj->Target == 0)
+  finish_texture_init(ctx, target, tex_obj, targetIndex);
+
+   assert(tex_obj->Target == target);
+   assert(tex_obj->TargetIndex == targetIndex);
+
+   bind_texture_object(ctx, ctx->Texture.CurrentUnit, tex_obj);
+}
   /**
    * Implement glBindTexture().  Do error checking, look-up or create
a new
@@ -1764,7 +1780,6 @@ bind_texture(struct gl_context *ctx, GLenum
target, GLuint texName,
  bind_texture_object(ctx, ctx->Texture.CurrentUnit, newTexObj);
   }
-
   void GLAPIENTRY
   _mesa_BindTexture_no_error(GLenum target, GLuint texName)
   {
diff --git a/src/mesa/main/texobj.h b/src/mesa/main/texobj.h
index 8dea853..f2d78ac 100644
--- a/src/mesa/main/texobj.h
+++ b/src/mesa/main/texobj.h
@@ -175,7 +175,9 @@ extern void
   _mesa_delete_nameless_texture(struct gl_context *ctx,
     struct gl_texture_object *texObj);
-
+extern void
+_mesa_bind_texture(struct gl_context *ctx, GLenum target,
+   struct gl_texture_object *tex_obj);
   /*@}*/
   /**


___
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] drirc: set allow_glsl_cross_stage_interpolation_mismatch for more games

2017-12-19 Thread Tapani Pälli
Signed-off-by: Tapani Pälli 
Suggested-by: Darius Spitznagel 
https://bugs.freedesktop.org/show_bug.cgi?id=104288
---
 src/util/drirc | 8 
 1 file changed, 8 insertions(+)

diff --git a/src/util/drirc b/src/util/drirc
index 73d27c07b0..bdc90227c6 100644
--- a/src/util/drirc
+++ b/src/util/drirc
@@ -168,6 +168,14 @@ TODO: document the other workarounds.
 
 
 
+
+
+
+
+
+
+
+
 
 
-- 
2.13.6

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


Re: [Mesa-dev] [PATCH 05/16] meta/blit: Don't restore state of the temporary texture

2017-12-19 Thread Tapani Pälli

patches 4,5
Reviewed-by: Tapani Pälli 

On 12/19/2017 02:14 AM, Ian Romanick wrote:

From: Ian Romanick 

It's about to be destroyed, so there's no point.

Signed-off-by: Ian Romanick 
---
  src/mesa/drivers/common/meta_blit.c | 48 +
  1 file changed, 27 insertions(+), 21 deletions(-)

diff --git a/src/mesa/drivers/common/meta_blit.c 
b/src/mesa/drivers/common/meta_blit.c
index 6322b64..66714b1 100644
--- a/src/mesa/drivers/common/meta_blit.c
+++ b/src/mesa/drivers/common/meta_blit.c
@@ -841,30 +841,36 @@ _mesa_meta_fb_tex_blit_end(struct gl_context *ctx, GLenum 
target,
 struct gl_texture_object *const texObj =
_mesa_get_current_tex_object(ctx, target);
  
-   /* Restore texture object state, the texture binding will

-* be restored by _mesa_meta_end().
-*
-* If the target restricts values for base level or max level, we assume
-* that the original values were valid.
-*/
-   if (blit->baseLevelSave != texObj->BaseLevel)
-  _mesa_texture_parameteriv(ctx, texObj, GL_TEXTURE_BASE_LEVEL,
-&blit->baseLevelSave, false);
-
-   if (blit->maxLevelSave != texObj->MaxLevel)
-  _mesa_texture_parameteriv(ctx, texObj, GL_TEXTURE_MAX_LEVEL,
-&blit->maxLevelSave, false);
+   /* Either there is no temporary texture or the temporary texture is bound. 
*/
+   assert(blit->tempTex == 0 || texObj->Name == blit->tempTex);
  
-   /* If ARB_stencil_texturing is not supported, the mode won't have changed. */

-   if (texObj->StencilSampling != blit->stencilSamplingSave) {
-  /* GLint so the compiler won't complain about type signedness mismatch
-   * in the call to _mesa_texture_parameteriv below.
+   /* Restore texture object state, the texture binding will be restored by
+* _mesa_meta_end().  If the texture is the temporary texture that is about
+* to be destroyed, don't bother restoring its state.
+*/
+   if (blit->tempTex == 0) {
+  /* If the target restricts values for base level or max level, we assume
+   * that the original values were valid.
 */
-  const GLint param = blit->stencilSamplingSave ?
- GL_STENCIL_INDEX : GL_DEPTH_COMPONENT;
+  if (blit->baseLevelSave != texObj->BaseLevel)
+ _mesa_texture_parameteriv(ctx, texObj, GL_TEXTURE_BASE_LEVEL,
+   &blit->baseLevelSave, false);
+
+  if (blit->maxLevelSave != texObj->MaxLevel)
+ _mesa_texture_parameteriv(ctx, texObj, GL_TEXTURE_MAX_LEVEL,
+   &blit->maxLevelSave, false);
+
+  /* If ARB_stencil_texturing is not supported, the mode won't have 
changed. */
+  if (texObj->StencilSampling != blit->stencilSamplingSave) {
+ /* GLint so the compiler won't complain about type signedness mismatch
+  * in the call to _mesa_texture_parameteriv below.
+  */
+ const GLint param = blit->stencilSamplingSave ?
+GL_STENCIL_INDEX : GL_DEPTH_COMPONENT;
  
-  _mesa_texture_parameteriv(ctx, texObj, GL_DEPTH_STENCIL_TEXTURE_MODE,

-¶m, false);
+ _mesa_texture_parameteriv(ctx, texObj, GL_DEPTH_STENCIL_TEXTURE_MODE,
+   ¶m, false);
+  }
 }
  
 _mesa_bind_sampler(ctx, ctx->Texture.CurrentUnit, blit->samp_obj_save);



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


Re: [Mesa-dev] [PATCH 03/16] mesa: Add _mesa_bind_texture method

2017-12-19 Thread Tapani Pälli



On 12/19/2017 01:39 PM, Tapani Pälli wrote:



On 12/19/2017 02:14 AM, Ian Romanick wrote:

From: Ian Romanick 

Light-weight glBindTexture for internal use.

Signed-off-by: Ian Romanick 
---
  src/mesa/main/texobj.c | 17 -
  src/mesa/main/texobj.h |  4 +++-
  2 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/src/mesa/main/texobj.c b/src/mesa/main/texobj.c
index db40598..cd9f43c 100644
--- a/src/mesa/main/texobj.c
+++ b/src/mesa/main/texobj.c
@@ -1692,6 +1692,22 @@ bind_texture_object(struct gl_context *ctx, 
unsigned unit,

 }
  }


This could have some documentation block that says when it is used and 
what are the differences with bind_texture?


(some small comment like "Light-weight glBindTexture for internal use." 
could do)


Patches 1,2,3
Reviewed-by: Tapani Pälli 


+void
+_mesa_bind_texture(struct gl_context *ctx, GLenum target,
+   struct gl_texture_object *tex_obj)
+{
+   const GLint targetIndex = _mesa_tex_target_to_index(ctx, target);
+
+   assert(targetIndex >= 0 && targetIndex < NUM_TEXTURE_TARGETS);
+
+   if (tex_obj->Target == 0)
+  finish_texture_init(ctx, target, tex_obj, targetIndex);
+
+   assert(tex_obj->Target == target);
+   assert(tex_obj->TargetIndex == targetIndex);
+
+   bind_texture_object(ctx, ctx->Texture.CurrentUnit, tex_obj);
+}
  /**
   * Implement glBindTexture().  Do error checking, look-up or create 
a new
@@ -1764,7 +1780,6 @@ bind_texture(struct gl_context *ctx, GLenum 
target, GLuint texName,

 bind_texture_object(ctx, ctx->Texture.CurrentUnit, newTexObj);
  }
-
  void GLAPIENTRY
  _mesa_BindTexture_no_error(GLenum target, GLuint texName)
  {
diff --git a/src/mesa/main/texobj.h b/src/mesa/main/texobj.h
index 8dea853..f2d78ac 100644
--- a/src/mesa/main/texobj.h
+++ b/src/mesa/main/texobj.h
@@ -175,7 +175,9 @@ extern void
  _mesa_delete_nameless_texture(struct gl_context *ctx,
    struct gl_texture_object *texObj);
-
+extern void
+_mesa_bind_texture(struct gl_context *ctx, GLenum target,
+   struct gl_texture_object *tex_obj);
  /*@}*/
  /**


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

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


Re: [Mesa-dev] [PATCH 03/16] mesa: Add _mesa_bind_texture method

2017-12-19 Thread Tapani Pälli



On 12/19/2017 02:14 AM, Ian Romanick wrote:

From: Ian Romanick 

Light-weight glBindTexture for internal use.

Signed-off-by: Ian Romanick 
---
  src/mesa/main/texobj.c | 17 -
  src/mesa/main/texobj.h |  4 +++-
  2 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/src/mesa/main/texobj.c b/src/mesa/main/texobj.c
index db40598..cd9f43c 100644
--- a/src/mesa/main/texobj.c
+++ b/src/mesa/main/texobj.c
@@ -1692,6 +1692,22 @@ bind_texture_object(struct gl_context *ctx, unsigned 
unit,
 }
  }


This could have some documentation block that says when it is used and 
what are the differences with bind_texture?



+void
+_mesa_bind_texture(struct gl_context *ctx, GLenum target,
+   struct gl_texture_object *tex_obj)
+{
+   const GLint targetIndex = _mesa_tex_target_to_index(ctx, target);
+
+   assert(targetIndex >= 0 && targetIndex < NUM_TEXTURE_TARGETS);
+
+   if (tex_obj->Target == 0)
+  finish_texture_init(ctx, target, tex_obj, targetIndex);
+
+   assert(tex_obj->Target == target);
+   assert(tex_obj->TargetIndex == targetIndex);
+
+   bind_texture_object(ctx, ctx->Texture.CurrentUnit, tex_obj);
+}
  
  /**

   * Implement glBindTexture().  Do error checking, look-up or create a new
@@ -1764,7 +1780,6 @@ bind_texture(struct gl_context *ctx, GLenum target, 
GLuint texName,
 bind_texture_object(ctx, ctx->Texture.CurrentUnit, newTexObj);
  }
  
-

  void GLAPIENTRY
  _mesa_BindTexture_no_error(GLenum target, GLuint texName)
  {
diff --git a/src/mesa/main/texobj.h b/src/mesa/main/texobj.h
index 8dea853..f2d78ac 100644
--- a/src/mesa/main/texobj.h
+++ b/src/mesa/main/texobj.h
@@ -175,7 +175,9 @@ extern void
  _mesa_delete_nameless_texture(struct gl_context *ctx,
struct gl_texture_object *texObj);
  
-

+extern void
+_mesa_bind_texture(struct gl_context *ctx, GLenum target,
+   struct gl_texture_object *tex_obj);
  /*@}*/
  
  /**



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


Re: [Mesa-dev] [PATCH 3/9] glsl: minor simplification in assign_varying_locations()

2017-12-19 Thread Tapani Pälli



On 12/19/2017 11:14 AM, Timothy Arceri wrote:

On 19/12/17 19:47, Tapani Pälli wrote:

On 12/18/2017 10:47 PM, Brian Paul wrote:

---
  src/compiler/glsl/link_varyings.cpp | 8 +++-
  1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/src/compiler/glsl/link_varyings.cpp 
b/src/compiler/glsl/link_varyings.cpp

index 9039c3b..6d74f9a 100644
--- a/src/compiler/glsl/link_varyings.cpp
+++ b/src/compiler/glsl/link_varyings.cpp
@@ -2514,11 +2514,9 @@ assign_varying_locations(struct gl_context *ctx,
 */
    foreach_in_list(ir_instruction, node, consumer->ir) {
   ir_variable *const input_var = node->as_variable();
-
- if (input_var == NULL || input_var->data.mode != 
ir_var_shader_in)

-    continue;
-
- matches.record(NULL, input_var);
+ if (input_var && input_var->data.mode == ir_var_shader_in) {
+    matches.record(NULL, input_var);
+ }


this file seems to have mixed style overall but new code should be 
without braces when we have just one line inside?


I'm pretty sure we have no rules about this. We have had bugs in the 
past due to missing braces on if statements so personally I'm fine with 
braces around single lines.


Ok, I always thought there is a convention to this but I might have 
imagined it. I'm fine leaving it as it is.






    }
 }


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

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


Re: [Mesa-dev] [PATCH 08/16] meta/blit: Since _mesa_meta_bind_rb_as_tex_image has only one output, return it

2017-12-19 Thread Tapani Pälli

Nice cleanup, patches 6,7,8
Reviewed-by: Tapani Pälli 

On 12/19/2017 02:14 AM, Ian Romanick wrote:

From: Ian Romanick 

Signed-off-by: Ian Romanick 
---
  src/mesa/drivers/common/meta.h  |  5 ++---
  src/mesa/drivers/common/meta_blit.c | 23 ---
  2 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/src/mesa/drivers/common/meta.h b/src/mesa/drivers/common/meta.h
index 128c342..a41de8b 100644
--- a/src/mesa/drivers/common/meta.h
+++ b/src/mesa/drivers/common/meta.h
@@ -462,10 +462,9 @@ extern void
  _mesa_meta_fb_tex_blit_end(struct gl_context *ctx, GLenum target,
 struct fb_tex_blit_state *blit);
  
-extern GLboolean

+extern struct gl_texture_object *
  _mesa_meta_bind_rb_as_tex_image(struct gl_context *ctx,
-struct gl_renderbuffer *rb,
-struct gl_texture_object **texObj);
+struct gl_renderbuffer *rb);
  
  struct gl_sampler_object *

  _mesa_meta_setup_sampler(struct gl_context *ctx,
diff --git a/src/mesa/drivers/common/meta_blit.c 
b/src/mesa/drivers/common/meta_blit.c
index 4e660d2..d33624d 100644
--- a/src/mesa/drivers/common/meta_blit.c
+++ b/src/mesa/drivers/common/meta_blit.c
@@ -640,7 +640,8 @@ blitframebuffer_texture(struct gl_context *ctx,
srcLevel = readAtt->TextureLevel;
texObj = readAtt->Texture;
 } else if (!readAtt->Texture && ctx->Driver.BindRenderbufferTexImage) {
-  if (!_mesa_meta_bind_rb_as_tex_image(ctx, rb, &texObj))
+  texObj = _mesa_meta_bind_rb_as_tex_image(ctx, rb);
+  if (texObj == NULL)
   return false;
  
fb_tex_blit.tempTex = texObj->Name;

@@ -882,12 +883,12 @@ _mesa_meta_fb_tex_blit_end(struct gl_context *ctx, GLenum 
target,
_mesa_DeleteTextures(1, &blit->tempTex);
  }
  
-GLboolean

+struct gl_texture_object *
  _mesa_meta_bind_rb_as_tex_image(struct gl_context *ctx,
-struct gl_renderbuffer *rb,
-struct gl_texture_object **texObj)
+struct gl_renderbuffer *rb)
  {
 struct gl_texture_image *texImage;
+   struct gl_texture_object *texObj;
 GLuint tempTex;
 const GLenum target = rb->NumSamples > 1
? GL_TEXTURE_2D_MULTISAMPLE : GL_TEXTURE_2D;
@@ -895,15 +896,15 @@ _mesa_meta_bind_rb_as_tex_image(struct gl_context *ctx,
 tempTex = 0;
 _mesa_GenTextures(1, &tempTex);
 if (tempTex == 0)
-  return false;
+  return NULL;
  
 _mesa_BindTexture(target, tempTex);

-   *texObj = _mesa_lookup_texture(ctx, tempTex);
-   texImage = _mesa_get_tex_image(ctx, *texObj, target, 0);
+   texObj = _mesa_lookup_texture(ctx, tempTex);
+   texImage = _mesa_get_tex_image(ctx, texObj, target, 0);
  
 if (!ctx->Driver.BindRenderbufferTexImage(ctx, rb, texImage)) {

_mesa_DeleteTextures(1, &tempTex);
-  return false;
+  return NULL;
 }
  
 if (ctx->Driver.FinishRenderTexture && !rb->NeedsFinishRenderTexture) {

@@ -911,9 +912,9 @@ _mesa_meta_bind_rb_as_tex_image(struct gl_context *ctx,
ctx->Driver.FinishRenderTexture(ctx, rb);
 }
  
-   assert(target == (*texObj)->Target);

-   assert(tempTex == (*texObj)->Name);
-   return true;
+   assert(target == texObj->Target);
+   assert(tempTex == texObj->Name);
+   return texObj;
  }
  
  struct gl_sampler_object *



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


Re: [Mesa-dev] [PATCH 3/9] glsl: minor simplification in assign_varying_locations()

2017-12-19 Thread Tapani Pälli



On 12/18/2017 10:47 PM, Brian Paul wrote:

---
  src/compiler/glsl/link_varyings.cpp | 8 +++-
  1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/src/compiler/glsl/link_varyings.cpp 
b/src/compiler/glsl/link_varyings.cpp
index 9039c3b..6d74f9a 100644
--- a/src/compiler/glsl/link_varyings.cpp
+++ b/src/compiler/glsl/link_varyings.cpp
@@ -2514,11 +2514,9 @@ assign_varying_locations(struct gl_context *ctx,
 */
foreach_in_list(ir_instruction, node, consumer->ir) {
   ir_variable *const input_var = node->as_variable();
-
- if (input_var == NULL || input_var->data.mode != ir_var_shader_in)
-continue;
-
- matches.record(NULL, input_var);
+ if (input_var && input_var->data.mode == ir_var_shader_in) {
+matches.record(NULL, input_var);
+ }


this file seems to have mixed style overall but new code should be 
without braces when we have just one line inside?



}
 }
  


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


Re: [Mesa-dev] [PATCH 1/9] glsl: trivial comment fix in lower_packed_varyings.cpp

2017-12-19 Thread Tapani Pälli



On 12/18/2017 10:47 PM, Brian Paul wrote:

---
  src/compiler/glsl/lower_packed_varyings.cpp | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/compiler/glsl/lower_packed_varyings.cpp 
b/src/compiler/glsl/lower_packed_varyings.cpp
index 1aec7ee..b840d26 100644
--- a/src/compiler/glsl/lower_packed_varyings.cpp
+++ b/src/compiler/glsl/lower_packed_varyings.cpp
@@ -766,7 +766,7 @@ lower_packed_varyings_visitor::needs_lowering(ir_variable 
*var)
 /* Override disable_varying_packing if the var is only used by transform
  * feedback. Also override it if transform feedback is enabled and the
  * variable is an array, struct or matrix as the elements of these types
-* will always has the same interpolation and therefore asre safe to pack.
+* will always has the same interpolation and therefore are safe to pack.


Maybe also change 'has' to 'have'?



  */
 const glsl_type *type = var->type;
 if (disable_varying_packing && !var->data.is_xfb_only &&


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


Re: [Mesa-dev] [PATCH 22/22] mesa: Add GL_UNSIGNED_INT_2_10_10_10_REV OES read type for BGRX1010102.

2017-12-18 Thread Tapani Pälli

Reviewed-by: Tapani Pälli 

On 12/16/2017 12:05 AM, Mario Kleiner wrote:

As Marek noted, the GL_RGBA + GL_UNSIGNED_INT_2_10_10_10_REV type
combo is also good for readback of BGRX1010102 framebuffers, not
only for BGRA1010102 framebuffers for use with glReadPixels()
under GLES, so add it for the GL_IMPLEMENTATION_COLOR_READ_TYPE_OES
query.

Successfully tested on gallium r600 driver with a (quickly hacked
for RGBA 10 10 10 0) dEQP testcase
dEQP-EGL.functional.wide_color.window_1010102_colorspace_default.

Suggested-by: Marek Olšák 
Signed-off-by: Mario Kleiner 
---
  src/mesa/main/framebuffer.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/mesa/main/framebuffer.c b/src/mesa/main/framebuffer.c
index a0de669..e103f31 100644
--- a/src/mesa/main/framebuffer.c
+++ b/src/mesa/main/framebuffer.c
@@ -889,7 +889,8 @@ _mesa_get_color_read_type(struct gl_context *ctx,
if (format == MESA_FORMAT_B5G6R5_UNORM)
   return GL_UNSIGNED_SHORT_5_6_5;
  
-  if (format == MESA_FORMAT_B10G10R10A2_UNORM)

+  if (format == MESA_FORMAT_B10G10R10A2_UNORM ||
+  format == MESA_FORMAT_B10G10R10X2_UNORM)
   return GL_UNSIGNED_INT_2_10_10_10_REV;
  
switch (data_type) {



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


Re: [Mesa-dev] [PATCH 1/2] android: fix vulkan driver futex usage issues

2017-12-17 Thread Tapani Pälli

Ping ..

These 2 patches are required because build is broken without them (when 
vulkan=true in build options). This patch should be renamed as "fix 
undefined futex API references" or something better like that.



On 12/12/2017 10:01 AM, Tapani Pälli wrote:

Fixes: f98a2768ca "mesa: Add new fast mtx_t mutex type for basic use cases"
Signed-off-by: Tapani Pälli 
---
  Android.common.mk | 1 +
  1 file changed, 1 insertion(+)

diff --git a/Android.common.mk b/Android.common.mk
index 103e3fec61..d9f871c08c 100644
--- a/Android.common.mk
+++ b/Android.common.mk
@@ -69,6 +69,7 @@ LOCAL_CFLAGS += \
-DHAVE_PTHREAD=1 \
-DHAVE_DLADDR \
-DHAVE_DL_ITERATE_PHDR \
+   -DHAVE_LINUX_FUTEX_H \
-DMAJOR_IN_SYSMACROS \
-fvisibility=hidden \
-Wno-sign-compare


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


Re: [Mesa-dev] [PATCH 0/4] GL_EXT_disjoint_timer_query series

2017-12-14 Thread Tapani Pälli



On 14.12.2017 21:20, Ian Romanick wrote:

Since you remembered to modify dispatch_sanity.cpp in patch 2, I'm going
to assume that 'make check' still passes.  If that's the case, the series is

Reviewed-by: Ian Romanick 


Yes, 'make check' passes;

Thanks for the review Ian!



On 12/14/2017 04:03 AM, Tapani Pälli wrote:

Hi;

Here's a revisited GL_EXT_disjoint_timer_query series. One patch got
dropped (as discussed with Lionel) and enabling is now via
EXT_disjoint_timer_query boolean as was intended (Ian).

Thanks;

Tapani Pälli (4):
   mesa: add DisjointOperation to gl_shared_state
   glapi: add GL_EXT_disjoint_timer_query
   mesa: GL_EXT_disjoint_timer_query extension API bits
   i965: enable EXT_disjoint_timer_query extension

  src/mapi/glapi/gen/es_EXT.xml| 16 
  src/mapi/glapi/gen/gl_API.xml|  4 ++--
  src/mesa/drivers/dri/i965/intel_extensions.c |  2 ++
  src/mesa/main/extensions_table.h |  1 +
  src/mesa/main/get.c  | 17 +
  src/mesa/main/get_hash_params.py |  5 +
  src/mesa/main/glheader.h |  4 
  src/mesa/main/mtypes.h   |  9 +
  src/mesa/main/queryobj.c |  3 ++-
  src/mesa/main/robustness.c   |  1 +
  src/mesa/main/tests/dispatch_sanity.cpp  |  5 +
  11 files changed, 64 insertions(+), 3 deletions(-)




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


[Mesa-dev] [PATCH 1/4] mesa: add DisjointOperation to gl_shared_state

2017-12-14 Thread Tapani Pälli
This state will be used by EXT_disjoint_timer_query. As first
usage, patch sets DisjointOperation true when gpu reset happens.

Signed-off-by: Tapani Pälli 
Reviewed-by: Lionel Landwerlin 
---
 src/mesa/main/mtypes.h | 8 
 src/mesa/main/robustness.c | 1 +
 2 files changed, 9 insertions(+)

diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index b372921e9f..0aac49402e 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -3310,6 +3310,14 @@ struct gl_shared_state
/** EXT_external_objects */
struct _mesa_HashTable *MemoryObjects;
 
+   /**
+* Some context in this share group was affected by a disjoint
+* operation. This operation can be anything that has effects on
+* values of timer queries in such manner that they become invalid for
+* performance metrics. As example gpu reset, counter overflow or gpu
+* frequency changes.
+*/
+   bool DisjointOperation;
 };
 
 
diff --git a/src/mesa/main/robustness.c b/src/mesa/main/robustness.c
index a61c07f125..e7d7007da4 100644
--- a/src/mesa/main/robustness.c
+++ b/src/mesa/main/robustness.c
@@ -145,6 +145,7 @@ _mesa_GetGraphicsResetStatusARB( void )
*/
   if (status != GL_NO_ERROR) {
  ctx->Shared->ShareGroupReset = true;
+ ctx->Shared->DisjointOperation = true;
   } else if (ctx->Shared->ShareGroupReset && !ctx->ShareGroupReset) {
  status = GL_INNOCENT_CONTEXT_RESET_ARB;
   }
-- 
2.14.3

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


[Mesa-dev] [PATCH 4/4] i965: enable EXT_disjoint_timer_query extension

2017-12-14 Thread Tapani Pälli
Following dEQP cases pass:
   dEQP-EGL.functional.get_proc_address.extension.gl_ext_disjoint_timer_query
   dEQP-EGL.functional.client_extensions.disjoint

Piglit test 'ext_disjoint_timer_query-simple' passes with these changes.

No changes/regression observed in Intel CI.

Signed-off-by: Tapani Pälli 
---
 src/mesa/drivers/dri/i965/intel_extensions.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/mesa/drivers/dri/i965/intel_extensions.c 
b/src/mesa/drivers/dri/i965/intel_extensions.c
index 4d17393948..cc961e051f 100644
--- a/src/mesa/drivers/dri/i965/intel_extensions.c
+++ b/src/mesa/drivers/dri/i965/intel_extensions.c
@@ -197,6 +197,8 @@ intelInitExtensions(struct gl_context *ctx)
   ctx->Extensions.OES_sample_variables = true;
 
   ctx->Extensions.ARB_timer_query = brw->screen->hw_has_timestamp;
+  ctx->Extensions.EXT_disjoint_timer_query =
+ ctx->Extensions.ARB_timer_query;
 
   /* Only enable this in core profile because other parts of Mesa behave
* slightly differently when the extension is enabled.
-- 
2.14.3

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


[Mesa-dev] [PATCH 3/4] mesa: GL_EXT_disjoint_timer_query extension API bits

2017-12-14 Thread Tapani Pälli
Patch adds GL_GPU_DISJOINT_EXT and enables to use timer queries when
EXT_disjoint_timer_query is enabled.

v2: enable extension only when EXT_disjoint_timer_query set

Signed-off-by: Tapani Pälli 
Reviewed-by: Lionel Landwerlin  (v1)
---
 src/mesa/main/extensions_table.h |  1 +
 src/mesa/main/get.c  | 17 +
 src/mesa/main/get_hash_params.py |  5 +
 src/mesa/main/glheader.h |  4 
 src/mesa/main/mtypes.h   |  1 +
 src/mesa/main/queryobj.c |  3 ++-
 6 files changed, 30 insertions(+), 1 deletion(-)

diff --git a/src/mesa/main/extensions_table.h b/src/mesa/main/extensions_table.h
index ab15ceb941..3dec6ea12f 100644
--- a/src/mesa/main/extensions_table.h
+++ b/src/mesa/main/extensions_table.h
@@ -210,6 +210,7 @@ EXT(EXT_copy_image  , OES_copy_image
 EXT(EXT_copy_texture, dummy_true   
  , GLL,  x ,  x ,  x , 1995)
 EXT(EXT_depth_bounds_test   , EXT_depth_bounds_test
  , GLL, GLC,  x ,  x , 2002)
 EXT(EXT_discard_framebuffer , dummy_true   
  ,  x ,  x , ES1, ES2, 2009)
+EXT(EXT_disjoint_timer_query, EXT_disjoint_timer_query 
  ,  x ,  x ,  x , ES2, 2016)
 EXT(EXT_draw_buffers, dummy_true   
  ,  x ,  x ,  x , ES2, 2012)
 EXT(EXT_draw_buffers2   , EXT_draw_buffers2
  , GLL, GLC,  x ,  x , 2006)
 EXT(EXT_draw_buffers_indexed, ARB_draw_buffers_blend   
  ,  x ,  x ,  x ,  30, 2014)
diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c
index c1b1a89ee0..7f2d72aa4b 100644
--- a/src/mesa/main/get.c
+++ b/src/mesa/main/get.c
@@ -578,6 +578,13 @@ static const int extra_EXT_provoking_vertex_32[] = {
EXTRA_END
 };
 
+static const int extra_EXT_disjoint_timer_query[] = {
+   EXTRA_API_ES2,
+   EXTRA_API_ES3,
+   EXT(EXT_disjoint_timer_query),
+   EXTRA_END
+};
+
 
 /* This is the big table describing all the enums we accept in
  * glGet*v().  The table is partitioned into six parts: enums
@@ -1160,6 +1167,16 @@ find_custom_value(struct gl_context *ctx, const struct 
value_desc *d, union valu
  v->value_int_n.ints[0] = GL_PROGRAM_BINARY_FORMAT_MESA;
   }
   break;
+   /* GL_EXT_disjoint_timer_query */
+   case GL_GPU_DISJOINT_EXT:
+  {
+ simple_mtx_lock(&ctx->Shared->Mutex);
+ v->value_int = ctx->Shared->DisjointOperation;
+ /* Reset state as expected by the spec. */
+ ctx->Shared->DisjointOperation = false;
+ simple_mtx_unlock(&ctx->Shared->Mutex);
+  }
+  break;
}
 }
 
diff --git a/src/mesa/main/get_hash_params.py b/src/mesa/main/get_hash_params.py
index eac250a1ec..bc71574cca 100644
--- a/src/mesa/main/get_hash_params.py
+++ b/src/mesa/main/get_hash_params.py
@@ -254,6 +254,11 @@ descriptor=[
   [ "POINT_SIZE_ARRAY_BUFFER_BINDING_OES", "LOC_CUSTOM, TYPE_INT, 0, NO_EXTRA" 
],
 ]},
 
+# Enums in GLES2, GLES3
+{ "apis": ["GLES2", "GLES3"], "params": [
+  [ "GPU_DISJOINT_EXT", "LOC_CUSTOM, TYPE_INT, 0, 
extra_EXT_disjoint_timer_query" ],
+]},
+
 { "apis": ["GL", "GL_CORE", "GLES2"], "params": [
 # == GL_MAX_TEXTURE_COORDS_NV
   [ "MAX_TEXTURE_COORDS_ARB", "CONTEXT_INT(Const.MaxTextureCoordUnits), 
extra_ARB_fragment_program" ],
diff --git a/src/mesa/main/glheader.h b/src/mesa/main/glheader.h
index 3f2a923782..35a442a77b 100644
--- a/src/mesa/main/glheader.h
+++ b/src/mesa/main/glheader.h
@@ -144,6 +144,10 @@ typedef void *GLeglImageOES;
 #define GL_FRAGMENT_SHADER_DISCARDS_SAMPLES_EXT 0x8A52
 #endif
 
+#ifndef GL_EXT_disjoint_timer_query
+#define GL_GPU_DISJOINT_EXT 0x8FBB
+#endif
+
 /* Inexplicably, GL_HALF_FLOAT_OES has a different value than GL_HALF_FLOAT.
  */
 #ifndef GL_HALF_FLOAT_OES
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 0aac49402e..a29d78b101 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -4168,6 +4168,7 @@ struct gl_extensions
GLboolean EXT_blend_func_separate;
GLboolean EXT_blend_minmax;
GLboolean EXT_depth_bounds_test;
+   GLboolean EXT_disjoint_timer_query;
GLboolean EXT_draw_buffers2;
GLboolean EXT_framebuffer_multisample;
GLboolean EXT_framebuffer_multisample_blit_scaled;
diff --git a/src/mesa/main/queryobj.c b/src/mesa/main/queryobj.c
index d966814a76..79600d7db1 100644
--- a/src/mesa/main/queryobj.c
+++ b/src/mesa/main/queryobj.c
@@ -822,7 +822,8 @@ get_query_object(struct gl_context *ctx, const char *func,
if (buf && buf != ctx->Shared->NullBufferObj) {
   bool is_64bit = ptype == GL_INT64_ARB ||
  ptype == GL_UNSIGNED_INT64_ARB;
-  if (!ctx->

[Mesa-dev] [PATCH 2/4] glapi: add GL_EXT_disjoint_timer_query

2017-12-14 Thread Tapani Pälli
Most entrypoints already available via other extensions like
GL_EXT_occlusion_query_boolean, GL_EXT_timer_query.

Signed-off-by: Tapani Pälli 
Reviewed-by: Lionel Landwerlin 
---
 src/mapi/glapi/gen/es_EXT.xml   | 16 
 src/mapi/glapi/gen/gl_API.xml   |  4 ++--
 src/mesa/main/tests/dispatch_sanity.cpp |  5 +
 3 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/src/mapi/glapi/gen/es_EXT.xml b/src/mapi/glapi/gen/es_EXT.xml
index f19007366f..e5104259b6 100644
--- a/src/mapi/glapi/gen/es_EXT.xml
+++ b/src/mapi/glapi/gen/es_EXT.xml
@@ -847,6 +847,22 @@
 
 
 
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
 
 
 
diff --git a/src/mapi/glapi/gen/gl_API.xml b/src/mapi/glapi/gen/gl_API.xml
index d3594cfe19..d13a3bfd83 100644
--- a/src/mapi/glapi/gen/gl_API.xml
+++ b/src/mapi/glapi/gen/gl_API.xml
@@ -12944,12 +12944,12 @@
 
 
 
-
+
 
 
 
 
-
+
 
 
 
diff --git a/src/mesa/main/tests/dispatch_sanity.cpp 
b/src/mesa/main/tests/dispatch_sanity.cpp
index 00754deb46..d697343627 100644
--- a/src/mesa/main/tests/dispatch_sanity.cpp
+++ b/src/mesa/main/tests/dispatch_sanity.cpp
@@ -2441,6 +2441,11 @@ const struct function gles2_functions_possible[] = {
{ "glGetQueryObjectivEXT", 20, -1 },
{ "glGetQueryObjectuivEXT", 20, -1 },
 
+   /* GL_EXT_disjoint_timer_query */
+   { "glGetQueryObjecti64vEXT", 20, -1 },
+   { "glGetQueryObjectui64vEXT", 20, -1 },
+   { "glQueryCounterEXT", 20, -1 },
+
{ NULL, 0, -1 }
 };
 
-- 
2.14.3

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


[Mesa-dev] [PATCH 0/4] GL_EXT_disjoint_timer_query series

2017-12-14 Thread Tapani Pälli
Hi;

Here's a revisited GL_EXT_disjoint_timer_query series. One patch got
dropped (as discussed with Lionel) and enabling is now via
EXT_disjoint_timer_query boolean as was intended (Ian).

Thanks;

Tapani Pälli (4):
  mesa: add DisjointOperation to gl_shared_state
  glapi: add GL_EXT_disjoint_timer_query
  mesa: GL_EXT_disjoint_timer_query extension API bits
  i965: enable EXT_disjoint_timer_query extension

 src/mapi/glapi/gen/es_EXT.xml| 16 
 src/mapi/glapi/gen/gl_API.xml|  4 ++--
 src/mesa/drivers/dri/i965/intel_extensions.c |  2 ++
 src/mesa/main/extensions_table.h |  1 +
 src/mesa/main/get.c  | 17 +
 src/mesa/main/get_hash_params.py |  5 +
 src/mesa/main/glheader.h |  4 
 src/mesa/main/mtypes.h   |  9 +
 src/mesa/main/queryobj.c |  3 ++-
 src/mesa/main/robustness.c   |  1 +
 src/mesa/main/tests/dispatch_sanity.cpp  |  5 +
 11 files changed, 64 insertions(+), 3 deletions(-)

-- 
2.14.3

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


Re: [Mesa-dev] [PATCH 4/4] mesa: enable GL_EXT_disjoint_timer_query extension

2017-12-13 Thread Tapani Pälli



On 12/12/2017 07:00 PM, Ian Romanick wrote:

On 11/19/2017 11:18 PM, Tapani Pälli wrote:

Add GL_GPU_DISJOINT_EXT and enable extension when ARB_timer_query
is supported by the driver.

Following dEQP cases pass:
dEQP-EGL.functional.get_proc_address.extension.gl_ext_disjoint_timer_query
dEQP-EGL.functional.client_extensions.disjoint

Piglit test 'ext_disjoint_timer_query-simple' passes with these changes.

No changes/regression observed in Intel CI.

Signed-off-by: Tapani Pälli 
---
  src/mesa/main/extensions_table.h |  1 +
  src/mesa/main/get.c  | 17 +
  src/mesa/main/get_hash_params.py |  5 +
  src/mesa/main/glheader.h |  4 
  src/mesa/main/mtypes.h   |  1 +
  src/mesa/main/queryobj.c |  3 ++-
  6 files changed, 30 insertions(+), 1 deletion(-)

diff --git a/src/mesa/main/extensions_table.h b/src/mesa/main/extensions_table.h
index 5b66e7d30d..78f0d35feb 100644
--- a/src/mesa/main/extensions_table.h
+++ b/src/mesa/main/extensions_table.h
@@ -209,6 +209,7 @@ EXT(EXT_copy_image  , OES_copy_image
  EXT(EXT_copy_texture, dummy_true  
   , GLL,  x ,  x ,  x , 1995)
  EXT(EXT_depth_bounds_test   , EXT_depth_bounds_test   
   , GLL, GLC,  x ,  x , 2002)
  EXT(EXT_discard_framebuffer , dummy_true  
   ,  x ,  x , ES1, ES2, 2009)
+EXT(EXT_disjoint_timer_query, ARB_timer_query  
  ,  x ,  x ,  x , ES2, 2016)

  ^^^

This should be EXT_disjoint_timer_query, right?  All of the things below
seem to use that flag.


Right, seems like I did not think this through. Earlier I thought we 
could simply turn it on for all drivers that support ARB_timer_query 
(and robustness) but seems not all the drivers do so we need to toggle 
it on separately. I will need to update this one and add a separate 
patch to toggle it on in the i965 driver.




  EXT(EXT_draw_buffers, dummy_true  
   ,  x ,  x ,  x , ES2, 2012)
  EXT(EXT_draw_buffers2   , EXT_draw_buffers2   
   , GLL, GLC,  x ,  x , 2006)
  EXT(EXT_draw_buffers_indexed, ARB_draw_buffers_blend  
   ,  x ,  x ,  x ,  30, 2014)
diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c
index ea8d932b18..6c0d1f7e9a 100644
--- a/src/mesa/main/get.c
+++ b/src/mesa/main/get.c
@@ -578,6 +578,13 @@ static const int extra_EXT_provoking_vertex_32[] = {
 EXTRA_END
  };
  
+static const int extra_EXT_disjoint_timer_query[] = {

+   EXTRA_API_ES2,
+   EXTRA_API_ES3,
+   EXT(EXT_disjoint_timer_query),
+   EXTRA_END
+};
+
  
  /* This is the big table describing all the enums we accept in

   * glGet*v().  The table is partitioned into six parts: enums
@@ -1151,6 +1158,16 @@ find_custom_value(struct gl_context *ctx, const struct 
value_desc *d, union valu
   }
}
break;
+   /* GL_EXT_disjoint_timer_query */
+   case GL_GPU_DISJOINT_EXT:
+  {
+ simple_mtx_lock(&ctx->Shared->Mutex);
+ v->value_int = ctx->Shared->DisjointOperation;
+ /* Reset state as expected by the spec. */
+ ctx->Shared->DisjointOperation = false;
+ simple_mtx_unlock(&ctx->Shared->Mutex);
+  }
+  break;
 }
  }
  
diff --git a/src/mesa/main/get_hash_params.py b/src/mesa/main/get_hash_params.py

index 20ef6e4977..55a956da84 100644
--- a/src/mesa/main/get_hash_params.py
+++ b/src/mesa/main/get_hash_params.py
@@ -254,6 +254,11 @@ descriptor=[
[ "POINT_SIZE_ARRAY_BUFFER_BINDING_OES", "LOC_CUSTOM, TYPE_INT, 0, 
NO_EXTRA" ],
  ]},
  
+# Enums in GLES2, GLES3

+{ "apis": ["GLES2", "GLES3"], "params": [
+  [ "GPU_DISJOINT_EXT", "LOC_CUSTOM, TYPE_INT, 0, 
extra_EXT_disjoint_timer_query" ],
+]},
+
  { "apis": ["GL", "GL_CORE", "GLES2"], "params": [
  # == GL_MAX_TEXTURE_COORDS_NV
[ "MAX_TEXTURE_COORDS_ARB", "CONTEXT_INT(Const.MaxTextureCoordUnits), 
extra_ARB_fragment_program" ],
diff --git a/src/mesa/main/glheader.h b/src/mesa/main/glheader.h
index 3f2a923782..35a442a77b 100644
--- a/src/mesa/main/glheader.h
+++ b/src/mesa/main/glheader.h
@@ -144,6 +144,10 @@ typedef void *GLeglImageOES;
  #define GL_FRAGMENT_SHADER_DISCARDS_SAMPLES_EXT 0x8A52
  #endif
  
+#ifndef GL_EXT_disjoint_timer_query

+#define GL_GPU_DISJOINT_EXT 0x8FBB
+#endif
+
  /* Inexplicably, GL_HALF_FLOAT_OES has a different value than GL_HALF_FLOAT.
   */
  #ifndef GL_HALF_FLOAT_OES
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 4cb6a74d69..9ed8d86688 100644
--- a/src/mesa/main/mtypes.h
+

[Mesa-dev] [PATCH 1/2] android: fix vulkan driver futex usage issues

2017-12-12 Thread Tapani Pälli
Fixes: f98a2768ca "mesa: Add new fast mtx_t mutex type for basic use cases"
Signed-off-by: Tapani Pälli 
---
 Android.common.mk | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Android.common.mk b/Android.common.mk
index 103e3fec61..d9f871c08c 100644
--- a/Android.common.mk
+++ b/Android.common.mk
@@ -69,6 +69,7 @@ LOCAL_CFLAGS += \
-DHAVE_PTHREAD=1 \
-DHAVE_DLADDR \
-DHAVE_DL_ITERATE_PHDR \
+   -DHAVE_LINUX_FUTEX_H \
-DMAJOR_IN_SYSMACROS \
-fvisibility=hidden \
-Wno-sign-compare
-- 
2.14.3

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


[Mesa-dev] [PATCH 2/2] android: fix vulkan driver build

2017-12-12 Thread Tapani Pälli
fixes undefined references by adding missing wsi common API

Signed-off-by: Tapani Pälli 
---
 src/vulkan/Android.mk | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/vulkan/Android.mk b/src/vulkan/Android.mk
index 47c5c51081..6d6df938ab 100644
--- a/src/vulkan/Android.mk
+++ b/src/vulkan/Android.mk
@@ -36,12 +36,13 @@ LOCAL_MODULE_CLASS := STATIC_LIBRARIES
 intermediates := $(call local-generated-sources-dir)
 
 LOCAL_C_INCLUDES := \
-   $(MESA_TOP)/include/vulkan
+   $(MESA_TOP)/include/vulkan \
+   $(MESA_TOP)/src/vulkan/util
 
 LOCAL_GENERATED_SOURCES := $(addprefix $(intermediates)/, \
$(VULKAN_UTIL_GENERATED_FILES))
 
-LOCAL_SRC_FILES := $(VULKAN_UTIL_FILES)
+LOCAL_SRC_FILES := $(VULKAN_UTIL_FILES) $(VULKAN_WSI_FILES)
 
 vulkan_api_xml = $(MESA_TOP)/src/vulkan/registry/vk.xml
 vk_android_native_buffer_xml = 
$(MESA_TOP)/src/vulkan/registry/vk_android_native_buffer.xml
-- 
2.14.3

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


Re: [Mesa-dev] [PATCH] egl/android: Provide an option for the backend to expose KHR_image

2017-12-07 Thread Tapani Pälli



On 12/07/2017 08:45 PM, Emil Velikov wrote:

Hi Harish,

On 7 December 2017 at 13:34, Harish Krupo  wrote:

 From android cts 8.0_r4, a new test case checks if all the required egl
extensions are exposed. In the current implementation we expose KHR_image
if KHR_image_base and KHR_image_pixmap are supported but KHR_image spec
does not mandate the existence of both the extensions.
This patch preserves the current check and also provides the backend
with an option to expose the KHR_image extension.

Test: run cts -m CtsOpenGLTestCases -t \
android.opengl.cts.OpenGlEsVersionTest#testRequiredEglExtensions



A couple of things that come to mind. Hope that I'm not loosing my
marbles ... too badly.

The KHR_image_pixmap extension lists the following as dependency:

 The EGL implementation must define an EGLNativePixmapType (although it
 is not required either to export any EGLConfigs supporting rendering to
 native pixmaps, or to support eglCreatePixmapSurface).

At the same time 'implementations' define the type even ones that lack
native pixmaps - Wayland, GBM, ...

(A) If one is to ignore that 'detail' we could simply toggle all of
KHR_image_pixmap across the board and simplify things a bit.
(B) if native pixmaps is a must - we have a bug in GBM as it
advertises KHR_image_pixmap.


I was considering this when someone mailed me about this issue but it 
seems to me that enabling KHR_image_pixmap could bring harm, there could 
be some existing user (be it a compositor, game or framework) that then 
might expect pixmap configs to exist and not just type definition. It 
would be interesting to try this out though, this would be the simplest 
path to take?






Signed-off-by: Harish Krupo 
---
  src/egl/drivers/dri2/platform_android.c | 1 +
  src/egl/main/eglapi.c   | 3 ++-
  src/egl/main/egldisplay.h   | 1 +
  3 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/egl/drivers/dri2/platform_android.c 
b/src/egl/drivers/dri2/platform_android.c
index 63223e9a69..0459cc8be2 100644
--- a/src/egl/drivers/dri2/platform_android.c
+++ b/src/egl/drivers/dri2/platform_android.c
@@ -1212,6 +1212,7 @@ dri2_initialize_android(_EGLDriver *drv, _EGLDisplay *dpy)
  #if ANDROID_API_LEVEL >= 23
 dpy->Extensions.KHR_partial_update = EGL_TRUE;
  #endif
+   dpy->Extensions.KHR_image = EGL_TRUE;


A: all of KHR_image* can will be a single boot
B: add _EGLDisplay::has_native_pixmap (or alike) and toggle KHR_image
and KHR_image_pixmap as applicable in egl_dri2.c
One can go without ::has_native_pixmap - we have platform type in
::Platform so we can deduce it locally.

Change the guards in _eglCreate/DestroyImageCommon as both KHR_image
and not KHR_image_base provide the entry points.
Personally I'd add an assert(...KHR_image) since it's close to
impossible to trigger.



 /* Fill vtbl last to prevent accidentally calling virtual function during
  * initialization.
diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c
index cec67425e1..5110688f2d 100644
--- a/src/egl/main/eglapi.c
+++ b/src/egl/main/eglapi.c
@@ -504,7 +504,8 @@ _eglCreateExtensionsString(_EGLDisplay *dpy)
 _EGL_CHECK_EXTENSION(KHR_gl_texture_3D_image);
 _EGL_CHECK_EXTENSION(KHR_gl_texture_cubemap_image);
 if (dpy->Extensions.KHR_image_base && dpy->Extensions.KHR_image_pixmap)
-  _eglAppendExtension(&exts, "EGL_KHR_image");
+  dpy->Extensions.KHR_image = EGL_TRUE;

It's very misleading to set the extension bool in a function called
CreateExtensionString :-\

Depending on how A/B goes we can move that to dri2_setup_screen or the
specific platform*.c.

With the assert() (rest can be done as follow-up) the patch is
Reviewed-by: Emil Velikov 

-Emil


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


<    1   2   3   4   5   6   7   8   9   10   >