[Mesa-dev] [PATCH] glsl: set mask via initialization list rather than in constructor body

2017-05-19 Thread Timothy Arceri
Potentially more efficient as is may avoid the struct being initialised
twice.
---
 src/compiler/glsl/ir.cpp | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/src/compiler/glsl/ir.cpp b/src/compiler/glsl/ir.cpp
index 123de99..e55635b 100644
--- a/src/compiler/glsl/ir.cpp
+++ b/src/compiler/glsl/ir.cpp
@@ -1583,24 +1583,23 @@ ir_swizzle::ir_swizzle(ir_rvalue *val, unsigned x, 
unsigned y, unsigned z,
 }
 
 ir_swizzle::ir_swizzle(ir_rvalue *val, const unsigned *comp,
   unsigned count)
: ir_rvalue(ir_type_swizzle), val(val)
 {
this->init_mask(comp, count);
 }
 
 ir_swizzle::ir_swizzle(ir_rvalue *val, ir_swizzle_mask mask)
-   : ir_rvalue(ir_type_swizzle)
+   : ir_rvalue(ir_type_swizzle), mask(mask)
 {
this->val = val;
-   this->mask = mask;
this->type = glsl_type::get_instance(val->type->base_type,
mask.num_components, 1);
 }
 
 #define X 1
 #define R 5
 #define S 9
 #define I 13
 
 ir_swizzle *
-- 
2.9.4

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


[Mesa-dev] [PATCH 1/2] util/disk_cache: add new driver_flags param to cache keys

2017-05-19 Thread Timothy Arceri
This will be used for things such as adding driver specific environment
variables to the key. Allowing us to set environment vars that change
the shader and not have the driver ignore them if it finds existing
shaders in the cache.
---
 src/compiler/glsl/tests/cache_test.c  | 20 ++--
 src/gallium/drivers/nouveau/nouveau_screen.c  |  2 +-
 src/gallium/drivers/radeon/r600_pipe_common.c |  2 +-
 src/util/disk_cache.c |  8 +++-
 src/util/disk_cache.h |  6 --
 5 files changed, 23 insertions(+), 15 deletions(-)

diff --git a/src/compiler/glsl/tests/cache_test.c 
b/src/compiler/glsl/tests/cache_test.c
index bec1d24..af1b66f 100644
--- a/src/compiler/glsl/tests/cache_test.c
+++ b/src/compiler/glsl/tests/cache_test.c
@@ -152,61 +152,61 @@ check_directories_created(const char *cache_dir)
 static void
 test_disk_cache_create(void)
 {
struct disk_cache *cache;
int err;
 
/* Before doing anything else, ensure that with
 * MESA_GLSL_CACHE_DISABLE set, that disk_cache_create returns NULL.
 */
setenv("MESA_GLSL_CACHE_DISABLE", "1", 1);
-   cache = disk_cache_create("test", "make_check");
+   cache = disk_cache_create("test", "make_check", 0);
expect_null(cache, "disk_cache_create with MESA_GLSL_CACHE_DISABLE set");
 
unsetenv("MESA_GLSL_CACHE_DISABLE");
 
/* For the first real disk_cache_create() clear these environment
 * variables to test creation of cache in home directory.
 */
unsetenv("MESA_GLSL_CACHE_DIR");
unsetenv("XDG_CACHE_HOME");
 
-   cache = disk_cache_create("test", "make_check");
+   cache = disk_cache_create("test", "make_check", 0);
expect_non_null(cache, "disk_cache_create with no environment variables");
 
disk_cache_destroy(cache);
 
/* Test with XDG_CACHE_HOME set */
setenv("XDG_CACHE_HOME", CACHE_TEST_TMP "/xdg-cache-home", 1);
-   cache = disk_cache_create("test", "make_check");
+   cache = disk_cache_create("test", "make_check", 0);
expect_null(cache, "disk_cache_create with XDG_CACHE_HOME set with"
"a non-existing parent directory");
 
mkdir(CACHE_TEST_TMP, 0755);
-   cache = disk_cache_create("test", "make_check");
+   cache = disk_cache_create("test", "make_check", 0);
expect_non_null(cache, "disk_cache_create with XDG_CACHE_HOME set");
 
check_directories_created(CACHE_TEST_TMP "/xdg-cache-home/mesa");
 
disk_cache_destroy(cache);
 
/* Test with MESA_GLSL_CACHE_DIR set */
err = rmrf_local(CACHE_TEST_TMP);
expect_equal(err, 0, "Removing " CACHE_TEST_TMP);
 
setenv("MESA_GLSL_CACHE_DIR", CACHE_TEST_TMP "/mesa-glsl-cache-dir", 1);
-   cache = disk_cache_create("test", "make_check");
+   cache = disk_cache_create("test", "make_check", 0);
expect_null(cache, "disk_cache_create with MESA_GLSL_CACHE_DIR set with"
"a non-existing parent directory");
 
mkdir(CACHE_TEST_TMP, 0755);
-   cache = disk_cache_create("test", "make_check");
+   cache = disk_cache_create("test", "make_check", 0);
expect_non_null(cache, "disk_cache_create with MESA_GLSL_CACHE_DIR set");
 
check_directories_created(CACHE_TEST_TMP "/mesa-glsl-cache-dir/mesa");
 
disk_cache_destroy(cache);
 }
 
 static bool
 does_cache_contain(struct disk_cache *cache, const cache_key key)
 {
@@ -249,21 +249,21 @@ test_put_and_get(void)
char blob[] = "This is a blob of thirty-seven bytes";
uint8_t blob_key[20];
char string[] = "While this string has thirty-four";
uint8_t string_key[20];
char *result;
size_t size;
uint8_t *one_KB, *one_MB;
uint8_t one_KB_key[20], one_MB_key[20];
int count;
 
-   cache = disk_cache_create("test", "make_check");
+   cache = disk_cache_create("test", "make_check", 0);
 
disk_cache_compute_key(cache, blob, sizeof(blob), blob_key);
 
/* Ensure that disk_cache_get returns nothing before anything is added. */
result = disk_cache_get(cache, blob_key, );
expect_null(result, "disk_cache_get with non-existent item (pointer)");
expect_equal(size, 0, "disk_cache_get with non-existent item (size)");
 
/* Simple test of put and get. */
disk_cache_put(cache, blob_key, blob, sizeof(blob));
@@ -291,21 +291,21 @@ test_put_and_get(void)
result = disk_cache_get(cache, string_key, );
expect_equal_str(result, string, "2nd disk_cache_get of existing item 
(pointer)");
expect_equal(size, sizeof(string), "2nd disk_cache_get of existing item 
(size)");
 
free(result);
 
/* Set the cache size to 1KB and add a 1KB item to force an eviction. */
disk_cache_destroy(cache);
 
setenv("MESA_GLSL_CACHE_MAX_SIZE", "1K", 1);
-   cache = disk_cache_create("test", "make_check");
+   cache = disk_cache_create("test", "make_check", 0);
 
one_KB = calloc(1, 1024);
 
/* Obviously the SHA-1 hash of 1024 zero bytes isn't particularly
 * interesting. But we do have want to take some special care with
 * the hash we use here. 

[Mesa-dev] [PATCH 2/2] radeon: pass flags that can change shaders to disk_cache_create()

2017-05-19 Thread Timothy Arceri
I wasn't sure if I should filter the flags so that we only use
flags that actually change the shader output. To avoid manual
updates we just pass in everything for now.
---
 src/gallium/drivers/radeon/r600_pipe_common.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/gallium/drivers/radeon/r600_pipe_common.c 
b/src/gallium/drivers/radeon/r600_pipe_common.c
index 2d8feee..ac6c552 100644
--- a/src/gallium/drivers/radeon/r600_pipe_common.c
+++ b/src/gallium/drivers/radeon/r600_pipe_common.c
@@ -861,21 +861,22 @@ static void r600_disk_cache_create(struct 
r600_common_screen *rscreen)
if 
(disk_cache_get_function_timestamp(LLVMInitializeAMDGPUTargetInfo,
  _timestamp)) 
{
res = asprintf(_str, "%u_%u",
   mesa_timestamp, llvm_timestamp);
}
}
 #endif
if (res != -1) {
rscreen->disk_shader_cache =
disk_cache_create(r600_get_chip_name(rscreen),
- timestamp_str, 0);
+ timestamp_str,
+ rscreen->debug_flags);
free(timestamp_str);
}
}
 }
 
 static struct disk_cache *r600_get_disk_shader_cache(struct pipe_screen 
*pscreen)
 {
struct r600_common_screen *rscreen = (struct 
r600_common_screen*)pscreen;
return rscreen->disk_shader_cache;
 }
-- 
2.9.4

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


[Mesa-dev] [PATCH] etnaviv: Don't try to use the index buffer if size is zero

2017-05-19 Thread Tomeu Vizoso
If info->index_size is zero, info->index will point to uninitialized
memory.

Fatal signal 11 (SIGSEGV), code 2, fault addr 0xab5d07a3 in tid 20456 
(surfaceflinger)

Signed-off-by: Tomeu Vizoso 
Cc: etna...@lists.freedesktop.org
Cc: Marek Olšák 
Fixes: 330d0607ed60 ("gallium: remove pipe_index_buffer and set_index_buffer")
---
 src/gallium/drivers/etnaviv/etnaviv_context.c | 36 +++
 1 file changed, 20 insertions(+), 16 deletions(-)

diff --git a/src/gallium/drivers/etnaviv/etnaviv_context.c 
b/src/gallium/drivers/etnaviv/etnaviv_context.c
index 306cb6fc498d..dcda4088bfd5 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_context.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_context.c
@@ -178,24 +178,28 @@ etna_draw_vbo(struct pipe_context *pctx, const struct 
pipe_draw_info *info)
 
/* Upload a user index buffer. */
unsigned index_offset = 0;
-   struct pipe_resource *indexbuf = info->has_user_indices ? NULL : 
info->index.resource;
-   if (info->index_size && info->has_user_indices &&
-   !util_upload_index_buffer(pctx, info, , _offset)) {
-  BUG("Index buffer upload failed.");
-  return;
-   }
+   struct pipe_resource *indexbuf = NULL;
 
-   if (info->index_size && indexbuf) {
-  ctx->index_buffer.FE_INDEX_STREAM_BASE_ADDR.bo = 
etna_resource(indexbuf)->bo;
-  ctx->index_buffer.FE_INDEX_STREAM_BASE_ADDR.offset = index_offset;
-  ctx->index_buffer.FE_INDEX_STREAM_BASE_ADDR.flags = ETNA_RELOC_READ;
-  ctx->index_buffer.FE_INDEX_STREAM_CONTROL = 
translate_index_size(info->index_size);
-  ctx->dirty |= ETNA_DIRTY_INDEX_BUFFER;
-   }
+   if (info->index_size) {
+  indexbuf = info->has_user_indices ? NULL : info->index.resource;
+  if (info->has_user_indices &&
+  !util_upload_index_buffer(pctx, info, , _offset)) {
+ BUG("Index buffer upload failed.");
+ return;
+  }
 
-   if (info->index_size && !ctx->index_buffer.FE_INDEX_STREAM_BASE_ADDR.bo) {
-  BUG("Unsupported or no index buffer");
-  return;
+  if (indexbuf) {
+ ctx->index_buffer.FE_INDEX_STREAM_BASE_ADDR.bo = 
etna_resource(indexbuf)->bo;
+ ctx->index_buffer.FE_INDEX_STREAM_BASE_ADDR.offset = index_offset;
+ ctx->index_buffer.FE_INDEX_STREAM_BASE_ADDR.flags = ETNA_RELOC_READ;
+ ctx->index_buffer.FE_INDEX_STREAM_CONTROL = 
translate_index_size(info->index_size);
+ ctx->dirty |= ETNA_DIRTY_INDEX_BUFFER;
+  }
+
+  if (!ctx->index_buffer.FE_INDEX_STREAM_BASE_ADDR.bo) {
+ BUG("Unsupported or no index buffer");
+ return;
+  }
}
 
struct etna_shader_key key = {};
-- 
2.9.3

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


Re: [Mesa-dev] [PATCH 04/16] anv: Handle transitioning depth from UNDEFINED to other layouts

2017-05-19 Thread Nanley Chery
On Fri, May 19, 2017 at 05:18:12PM -0700, Jason Ekstrand wrote:
> On Fri, May 19, 2017 at 4:51 PM, Nanley Chery  wrote:
> 
> > On Thu, May 18, 2017 at 02:00:51PM -0700, Jason Ekstrand wrote:
> > > ---
> > >  src/intel/vulkan/anv_image.c   | 12 ++--
> > >  src/intel/vulkan/genX_cmd_buffer.c |  9 +
> > >  2 files changed, 11 insertions(+), 10 deletions(-)
> > >
> > > diff --git a/src/intel/vulkan/anv_image.c b/src/intel/vulkan/anv_image.c
> > > index d21e055..d65ef47 100644
> > > --- a/src/intel/vulkan/anv_image.c
> > > +++ b/src/intel/vulkan/anv_image.c
> > > @@ -488,12 +488,20 @@ anv_layout_to_aux_usage(const struct
> > gen_device_info * const devinfo,
> > > /* According to the Vulkan Spec, the following layouts are valid
> > only as
> > >  * initial layouts in a layout transition and don't support device
> > access.
> > >  */
> > > -   case VK_IMAGE_LAYOUT_UNDEFINED:
> > > -   case VK_IMAGE_LAYOUT_PREINITIALIZED:
> > > case VK_IMAGE_LAYOUT_RANGE_SIZE:
> > > case VK_IMAGE_LAYOUT_MAX_ENUM:
> > >unreachable("Invalid image layout for device access.");
> > >
> > > +   /* Undefined layouts
> > > +*
> > > +* The pre-initialized layout is equivalent to the undefined layout
> > for
> > > +* optimally-tiled images.  We can only do color compression (CCS or
> > HiZ)
> > > +* on tiled images.
> > > +*/
> > > +   case VK_IMAGE_LAYOUT_UNDEFINED:
> > > +   case VK_IMAGE_LAYOUT_PREINITIALIZED:
> > > +  return ISL_AUX_USAGE_NONE;
> > > +
> > >
> >
> > This function is defined to return the isl_aux_usage for "device access"
> > as described by the Vulkan spec. The user is not allowed to perform
> > device accesses in either of those layouts (11.4. Image Layouts). My
> > suggestion for dealing with this can be found below.
> >
> 
> I guess I don't really see why the "device access" distinction is useful.
> Perhaps you could explain?  Just plugging the two other layouts in seems to
> work fairly well.
> 
> 

This distinction has helped me to catch the UNDEFINED layout being used
in an unexpected place (to me at the time). genX_cmd_buffer.c:532.

At the time we were defining this function, we decided that the caller of
this function would be responsible for determining the best layout for
performing a layout transition. 

I suppose setting the usage to NONE isn't determining the optimal
layout, but rather a convenient layout. It's getting late, so I'll have
to give this more thought next week.

If we do decide to handle those enums here, I think we'll have to update
some comments in this function.

> > > /* Transfer Layouts
> > >  *
> > > diff --git a/src/intel/vulkan/genX_cmd_buffer.c
> > b/src/intel/vulkan/genX_cmd_buffer.c
> > > index 1f30a12..8d5f61b 100644
> > > --- a/src/intel/vulkan/genX_cmd_buffer.c
> > > +++ b/src/intel/vulkan/genX_cmd_buffer.c
> > > @@ -355,15 +355,8 @@ transition_depth_buffer(struct anv_cmd_buffer
> > *cmd_buffer,
> > >  * The undefined layout indicates that the user doesn't care about
> > the data
> > >  * that's currently in the buffer. Therefore, a data-preserving
> > resolve
> > >  * operation is not needed.
> > > -*
> > > -* The pre-initialized layout is equivalent to the undefined layout
> > for
> > > -* optimally-tiled images. Anv only exposes support for
> > optimally-tiled
> > > -* depth buffers.
> > >  */
> > > -   if (image->aux_usage != ISL_AUX_USAGE_HIZ ||
> > > -   initial_layout == final_layout ||
> > > -   initial_layout == VK_IMAGE_LAYOUT_UNDEFINED ||
> > > -   initial_layout == VK_IMAGE_LAYOUT_PREINITIALIZED)
> > > +   if (image->aux_usage != ISL_AUX_USAGE_HIZ || initial_layout ==
> > final_layout)
> > >return;
> > >
> >
> > I think we should keep this new condition and add another one below for
> > UNDEFINED and PREINITIALIZED in which we do the resolve early and
> > return.
> >
> > I don't mind adding a new condition because the original idea I had of
> > only comparing hiz_enabled and enable_hiz isn't optimal - for example,
> > we unnecessarily perform a resolve when going from a read-only
> > hiz-enabled layout to a hiz-disabled layout. (Thankfully, I haven't yet
> > found any apps that make such a transition.)
> >
> 
> I don't think that's unnecessary.  If the user goes
> 
> DEPTH_STENCIL_OPTIMAL
> SHADER_READ_ONLY_OPTIMAL
> TRANSFER_DST_OPTIMAL
> 
> we need to resolve somewhere in the chain.  The best I think we can hope
> for is another predicated resolve trick like you did for color buffers.
> 

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


Re: [Mesa-dev] [PATCH 1/9] mesa: Handle common extension checks with more compact code

2017-05-19 Thread Nanley Chery
On Fri, May 19, 2017 at 05:32:07PM -0700, Ian Romanick wrote:
> On 05/19/2017 05:07 PM, Ilia Mirkin wrote:
> > On Fri, May 19, 2017 at 7:29 PM, Ian Romanick  wrote:
> >> I missed that glsl_parser_extras.cpp has its own implementation of the
> >> has_XXX_foo() functions that take the API and version as explicit
> >> parameters.  Your patch predates that change.  There's room for some
> >> modest savings there too.
> > 
> > The main thing about those functions is that they have to be
> > out-of-line, as they're invoked via function pointer. Each one can be
> > cut down a little using your approach of statically looking at the cap
> > restrictions, but I don't think inlining can work. [I added that code
> > to (a) add "permission" checks to enable extensions in glsl and (b)
> > remove the duplication of adding #defines for all the ext names.]
> 
> Right.  I think there's two approaches to try.  The least intrusive is
> to try some of these tricks in the existing functions.  The more
> intrusive would be to generate the data into the table and modify
> _mesa_glsl_extension::compatible_with_state to use the data instead of
> calling the function.
> 
> I'm leaning towards the latter, but I haven't decided how I'd want to
> generate the data.  The method used by other users of
> main/extensions_table.h won't work because we only want a subset of
> extensions.  Hmm...
> 

I'll have to get back to this next week, but please don't feel blocked
on my comments. This may be the latter trick mentioned above, but if it
isn't, a third option is to initialize an array at context creation time
to describe which extensions are supported. That array is then looked up
in the helpers:
https://cgit.freedesktop.org/~nchery/mesa/log/?h=3/ext/init

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


Re: [Mesa-dev] [PATCH 1/9] mesa: Handle common extension checks with more compact code

2017-05-19 Thread Ian Romanick
On 05/19/2017 05:07 PM, Ilia Mirkin wrote:
> On Fri, May 19, 2017 at 7:29 PM, Ian Romanick  wrote:
>> I missed that glsl_parser_extras.cpp has its own implementation of the
>> has_XXX_foo() functions that take the API and version as explicit
>> parameters.  Your patch predates that change.  There's room for some
>> modest savings there too.
> 
> The main thing about those functions is that they have to be
> out-of-line, as they're invoked via function pointer. Each one can be
> cut down a little using your approach of statically looking at the cap
> restrictions, but I don't think inlining can work. [I added that code
> to (a) add "permission" checks to enable extensions in glsl and (b)
> remove the duplication of adding #defines for all the ext names.]

Right.  I think there's two approaches to try.  The least intrusive is
to try some of these tricks in the existing functions.  The more
intrusive would be to generate the data into the table and modify
_mesa_glsl_extension::compatible_with_state to use the data instead of
calling the function.

I'm leaning towards the latter, but I haven't decided how I'd want to
generate the data.  The method used by other users of
main/extensions_table.h won't work because we only want a subset of
extensions.  Hmm...

>   -ilia

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


[Mesa-dev] [Bug 101110] Build failure in GNOME Continuous

2017-05-19 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=101110

--- Comment #4 from Emil Velikov  ---
Correction - needs the following brown paper bag commit
48cd1919ff1 ("configure.ac: s/xcb-fixes/xcb-xfixes/")

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


[Mesa-dev] [Bug 101110] Build failure in GNOME Continuous

2017-05-19 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=101110

--- Comment #3 from Dieter Nützel  ---
Hello Emil,

shouldn't this look like this:

diff --git a/configure.ac b/configure.ac
index b788137d51..06883a9667 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1723,7 +1723,7 @@ fi
 if test x"$enable_dri3" = xyes; then
 DEFINES="$DEFINES -DHAVE_DRI3"

-dri3_modules="x11-xcb xcb >= $XCB_REQUIRED xcb-dri3 xcb-fixes xcb-present
xcb-sync xshmfence >= $XSHMFENCE_REQUIRED"
+dri3_modules="x11-xcb xcb >= $XCB_REQUIRED xcb-dri3 xcb-xfixes xcb-present
xcb-sync xshmfence >= $XSHMFENCE_REQUIRED"
 PKG_CHECK_MODULES([XCB_DRI3], [$dri3_modules])
 fi

_xcb-xfixes_ ???

Signed-off-by: Dieter Nützel 


Mesa git do NOT compile on my openSUSE Tumbleweed with your commit.

Greetings,
Dieter

BTW Look this right?
./autogen.sh --prefix=/usr/local --with-dri-drivers=""
--with-gallium-drivers=r600,radeonsi,swrast --with-platforms=drm,x11
--enable-nine --enable-texture-float --enable-opencl
--with-vulkan-drivers=radeon

Had add 'x11' to '--with-platforms=drm'

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


Re: [Mesa-dev] [PATCH 04/16] anv: Handle transitioning depth from UNDEFINED to other layouts

2017-05-19 Thread Jason Ekstrand
On Fri, May 19, 2017 at 4:51 PM, Nanley Chery  wrote:

> On Thu, May 18, 2017 at 02:00:51PM -0700, Jason Ekstrand wrote:
> > ---
> >  src/intel/vulkan/anv_image.c   | 12 ++--
> >  src/intel/vulkan/genX_cmd_buffer.c |  9 +
> >  2 files changed, 11 insertions(+), 10 deletions(-)
> >
> > diff --git a/src/intel/vulkan/anv_image.c b/src/intel/vulkan/anv_image.c
> > index d21e055..d65ef47 100644
> > --- a/src/intel/vulkan/anv_image.c
> > +++ b/src/intel/vulkan/anv_image.c
> > @@ -488,12 +488,20 @@ anv_layout_to_aux_usage(const struct
> gen_device_info * const devinfo,
> > /* According to the Vulkan Spec, the following layouts are valid
> only as
> >  * initial layouts in a layout transition and don't support device
> access.
> >  */
> > -   case VK_IMAGE_LAYOUT_UNDEFINED:
> > -   case VK_IMAGE_LAYOUT_PREINITIALIZED:
> > case VK_IMAGE_LAYOUT_RANGE_SIZE:
> > case VK_IMAGE_LAYOUT_MAX_ENUM:
> >unreachable("Invalid image layout for device access.");
> >
> > +   /* Undefined layouts
> > +*
> > +* The pre-initialized layout is equivalent to the undefined layout
> for
> > +* optimally-tiled images.  We can only do color compression (CCS or
> HiZ)
> > +* on tiled images.
> > +*/
> > +   case VK_IMAGE_LAYOUT_UNDEFINED:
> > +   case VK_IMAGE_LAYOUT_PREINITIALIZED:
> > +  return ISL_AUX_USAGE_NONE;
> > +
> >
>
> This function is defined to return the isl_aux_usage for "device access"
> as described by the Vulkan spec. The user is not allowed to perform
> device accesses in either of those layouts (11.4. Image Layouts). My
> suggestion for dealing with this can be found below.
>

I guess I don't really see why the "device access" distinction is useful.
Perhaps you could explain?  Just plugging the two other layouts in seems to
work fairly well.


> > /* Transfer Layouts
> >  *
> > diff --git a/src/intel/vulkan/genX_cmd_buffer.c
> b/src/intel/vulkan/genX_cmd_buffer.c
> > index 1f30a12..8d5f61b 100644
> > --- a/src/intel/vulkan/genX_cmd_buffer.c
> > +++ b/src/intel/vulkan/genX_cmd_buffer.c
> > @@ -355,15 +355,8 @@ transition_depth_buffer(struct anv_cmd_buffer
> *cmd_buffer,
> >  * The undefined layout indicates that the user doesn't care about
> the data
> >  * that's currently in the buffer. Therefore, a data-preserving
> resolve
> >  * operation is not needed.
> > -*
> > -* The pre-initialized layout is equivalent to the undefined layout
> for
> > -* optimally-tiled images. Anv only exposes support for
> optimally-tiled
> > -* depth buffers.
> >  */
> > -   if (image->aux_usage != ISL_AUX_USAGE_HIZ ||
> > -   initial_layout == final_layout ||
> > -   initial_layout == VK_IMAGE_LAYOUT_UNDEFINED ||
> > -   initial_layout == VK_IMAGE_LAYOUT_PREINITIALIZED)
> > +   if (image->aux_usage != ISL_AUX_USAGE_HIZ || initial_layout ==
> final_layout)
> >return;
> >
>
> I think we should keep this new condition and add another one below for
> UNDEFINED and PREINITIALIZED in which we do the resolve early and
> return.
>
> I don't mind adding a new condition because the original idea I had of
> only comparing hiz_enabled and enable_hiz isn't optimal - for example,
> we unnecessarily perform a resolve when going from a read-only
> hiz-enabled layout to a hiz-disabled layout. (Thankfully, I haven't yet
> found any apps that make such a transition.)
>

I don't think that's unnecessary.  If the user goes

DEPTH_STENCIL_OPTIMAL
SHADER_READ_ONLY_OPTIMAL
TRANSFER_DST_OPTIMAL

we need to resolve somewhere in the chain.  The best I think we can hope
for is another predicated resolve trick like you did for color buffers.

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


Re: [Mesa-dev] [PATCH] i965: Add RGBX8888 and RGBA8888 to EGL configure and reorder the list

2017-05-19 Thread Rob Herring
On Fri, May 19, 2017 at 12:57 PM, Emil Velikov  wrote:
> On 18 May 2017 at 23:01, Rob Herring  wrote:
>> On Thu, May 18, 2017 at 5:25 AM, Emil Velikov  
>> wrote:
>>> On 18 May 2017 at 05:10, Chih-Wei Huang  wrote:
 2017-05-18 12:01 GMT+08:00 Xu, Randy :
>
>> -Original Message-
>> From: Palli, Tapani
>> >
>> > It's just applied. Isn't it?
>> > Yesterday without this patch
>> > the color format is mismatch apparently.
>>
>> Yeah we do need this. TBH I don't quite understand why but will try to 
>> figure
>> it out. I remember we used to have a patch in Surfaceflinger at one point
>> because visual was hardcoded there and this might be related.
>>
>> // Tapani
>
> Sorry, that's for different issue, I mix it with RGB565 blending one.
> This patch is required because some Android GLES test apps, like 
> gl2_basic, need to create RGBA surface.

 Indeed it is.

 As Emil pointed out, the patch was merged before
 but reverted later since it broke desktop.

 So what's the current upstreaming plan?

>>> No idea about a plan, but how you can fix it once and for all:
>>>
>>> Extend the loader extension(s) to have a get_caps() callback,
>>> analogous to __DRIimageExtension::getCapabilities.
>>> Then the DRI module will query [the loader] and advertise the
>>> RGBX/RGBA visuals when possible.
>>
>> Could we do something compile time instead to enable just for Android?
>> Seems like a lot of complexity when the platform needing these pixel
>> formats doesn't need the backwards compatibility. Or maybe there are
>> other things needing this interface?
>>
> Having a short/mid term ifdef ANDROID is perfectly fine.
>
> Can we address some of the existing ones before/alongside the newly added 
> ones?
> Afacit the nouveau bits are no longer applicable.

Yeah. I don't explicitly warn for KK or less, but will add that and fix these.

> While for the
> gbm/egl 'use "gallium_dri.so"' one can either use your latest build
> rework or MESA_LOADER_DRIVER_OVERRIDE.

How does the build rework help? My only reservation with using an env
var is generally Android things don't rely on them and it would break
working systems. I'm not even completely certain I can set env vars
globally. It would be nice if the build system could set defaults for
env vars we could use.

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


Re: [Mesa-dev] [PATCH 1/9] mesa: Handle common extension checks with more compact code

2017-05-19 Thread Ilia Mirkin
On Fri, May 19, 2017 at 7:29 PM, Ian Romanick  wrote:
> I missed that glsl_parser_extras.cpp has its own implementation of the
> has_XXX_foo() functions that take the API and version as explicit
> parameters.  Your patch predates that change.  There's room for some
> modest savings there too.

The main thing about those functions is that they have to be
out-of-line, as they're invoked via function pointer. Each one can be
cut down a little using your approach of statically looking at the cap
restrictions, but I don't think inlining can work. [I added that code
to (a) add "permission" checks to enable extensions in glsl and (b)
remove the duplication of adding #defines for all the ext names.]

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


Re: [Mesa-dev] [PATCH 04/16] anv: Handle transitioning depth from UNDEFINED to other layouts

2017-05-19 Thread Nanley Chery
On Thu, May 18, 2017 at 02:00:51PM -0700, Jason Ekstrand wrote:
> ---
>  src/intel/vulkan/anv_image.c   | 12 ++--
>  src/intel/vulkan/genX_cmd_buffer.c |  9 +
>  2 files changed, 11 insertions(+), 10 deletions(-)
> 
> diff --git a/src/intel/vulkan/anv_image.c b/src/intel/vulkan/anv_image.c
> index d21e055..d65ef47 100644
> --- a/src/intel/vulkan/anv_image.c
> +++ b/src/intel/vulkan/anv_image.c
> @@ -488,12 +488,20 @@ anv_layout_to_aux_usage(const struct gen_device_info * 
> const devinfo,
> /* According to the Vulkan Spec, the following layouts are valid only as
>  * initial layouts in a layout transition and don't support device access.
>  */
> -   case VK_IMAGE_LAYOUT_UNDEFINED:
> -   case VK_IMAGE_LAYOUT_PREINITIALIZED:
> case VK_IMAGE_LAYOUT_RANGE_SIZE:
> case VK_IMAGE_LAYOUT_MAX_ENUM:
>unreachable("Invalid image layout for device access.");
>  
> +   /* Undefined layouts
> +*
> +* The pre-initialized layout is equivalent to the undefined layout for
> +* optimally-tiled images.  We can only do color compression (CCS or HiZ)
> +* on tiled images.
> +*/
> +   case VK_IMAGE_LAYOUT_UNDEFINED:
> +   case VK_IMAGE_LAYOUT_PREINITIALIZED:
> +  return ISL_AUX_USAGE_NONE;
> +
>  

This function is defined to return the isl_aux_usage for "device access"
as described by the Vulkan spec. The user is not allowed to perform
device accesses in either of those layouts (11.4. Image Layouts). My
suggestion for dealing with this can be found below.

> /* Transfer Layouts
>  *
> diff --git a/src/intel/vulkan/genX_cmd_buffer.c 
> b/src/intel/vulkan/genX_cmd_buffer.c
> index 1f30a12..8d5f61b 100644
> --- a/src/intel/vulkan/genX_cmd_buffer.c
> +++ b/src/intel/vulkan/genX_cmd_buffer.c
> @@ -355,15 +355,8 @@ transition_depth_buffer(struct anv_cmd_buffer 
> *cmd_buffer,
>  * The undefined layout indicates that the user doesn't care about the 
> data
>  * that's currently in the buffer. Therefore, a data-preserving resolve
>  * operation is not needed.
> -*
> -* The pre-initialized layout is equivalent to the undefined layout for
> -* optimally-tiled images. Anv only exposes support for optimally-tiled
> -* depth buffers.
>  */
> -   if (image->aux_usage != ISL_AUX_USAGE_HIZ ||
> -   initial_layout == final_layout ||
> -   initial_layout == VK_IMAGE_LAYOUT_UNDEFINED ||
> -   initial_layout == VK_IMAGE_LAYOUT_PREINITIALIZED)
> +   if (image->aux_usage != ISL_AUX_USAGE_HIZ || initial_layout == 
> final_layout)
>return;
>  

I think we should keep this new condition and add another one below for
UNDEFINED and PREINITIALIZED in which we do the resolve early and
return.

I don't mind adding a new condition because the original idea I had of
only comparing hiz_enabled and enable_hiz isn't optimal - for example,
we unnecessarily perform a resolve when going from a read-only
hiz-enabled layout to a hiz-disabled layout. (Thankfully, I haven't yet
found any apps that make such a transition.)

-Nanley

> const bool hiz_enabled = ISL_AUX_USAGE_HIZ ==
> -- 
> 2.5.0.400.gff86faf
> 
> ___
> 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] anv: Handle color layout transitions from the UNINITIALIZED layout

2017-05-19 Thread Nanley Chery
On Thu, May 18, 2017 at 02:00:50PM -0700, Jason Ekstrand wrote:
> This causes dEQP-VK.api.copy_and_blit.resolve_image.partial.* to start
> failing due to test bugs.  See CL 1031 for a test fix.
> ---
>  src/intel/vulkan/anv_blorp.c   | 40 
> ++
>  src/intel/vulkan/anv_private.h |  5 +
>  src/intel/vulkan/genX_cmd_buffer.c | 25 
>  3 files changed, 70 insertions(+)
> 
> diff --git a/src/intel/vulkan/anv_blorp.c b/src/intel/vulkan/anv_blorp.c
> index 7b6944a..51964c5 100644
> --- a/src/intel/vulkan/anv_blorp.c
> +++ b/src/intel/vulkan/anv_blorp.c
> @@ -1373,6 +1373,46 @@ void anv_CmdResolveImage(
> blorp_batch_finish();
>  }
>  
> +void
> +anv_image_ccs_ambiguate(struct anv_cmd_buffer *cmd_buffer,
> +const struct anv_image *image,
> +const VkImageSubresourceRange *subresourceRange)
> +{
> +   assert(image->type == VK_IMAGE_TYPE_3D || image->extent.depth == 1);
> +
> +   struct blorp_batch batch;
> +   blorp_batch_init(_buffer->device->blorp, , cmd_buffer, 0);
> +
> +   struct blorp_surf surf;
> +   get_blorp_surf_for_anv_image(image, VK_IMAGE_ASPECT_COLOR_BIT,
> +image->aux_usage, );
> +
> +   /* We're about to bind a CCS surface and render to it.  Who knows what 
> will
> +* happen to caching at that point.  It's probably best if we don't let
> +* this happen at the same time as other rendering.  Flush the render 
> cache
> +* and stall prior to this operation.
> +*/
> +   cmd_buffer->state.pending_pipe_bits |=
> +  ANV_PIPE_RENDER_TARGET_CACHE_FLUSH_BIT | ANV_PIPE_CS_STALL_BIT;
> +
> +   const uint32_t level_count = anv_get_levelCount(image, subresourceRange);
> +   const uint32_t layer_count = anv_get_layerCount(image, subresourceRange);
> +   for (uint32_t l = 0; l < level_count; l++) {
> +  const uint32_t level = subresourceRange->baseMipLevel + l;
> +
> +  for (uint32_t a = 0; a < layer_count; a++) {
> + const uint32_t layer = subresourceRange->baseArrayLayer + a;
> + const uint32_t depth = anv_minify(image->extent.depth, level);
> +
> + for (uint32_t z = 0; z < depth; z++)
> +blorp_ccs_ambiguate(, , level, layer, z);

This triple for loop is a cool way to think about 3D textures.

> +  }
> +   }
> +
> +   cmd_buffer->state.pending_pipe_bits |=
> +  ANV_PIPE_RENDER_TARGET_CACHE_FLUSH_BIT | ANV_PIPE_CS_STALL_BIT;
> +}
> +
>  static void
>  ccs_resolve_attachment(struct anv_cmd_buffer *cmd_buffer,
> struct blorp_batch *batch,
> diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h
> index 9b0dd67..10ad247 100644
> --- a/src/intel/vulkan/anv_private.h
> +++ b/src/intel/vulkan/anv_private.h
> @@ -2064,6 +2064,11 @@ anv_gen8_hiz_op_resolve(struct anv_cmd_buffer 
> *cmd_buffer,
>  const struct anv_image *image,
>  enum blorp_hiz_op op);
>  
> +void
> +anv_image_ccs_ambiguate(struct anv_cmd_buffer *cmd_buffer,
> +const struct anv_image *image,
> +const VkImageSubresourceRange *subresourceRange);
> +
>  enum isl_aux_usage
>  anv_layout_to_aux_usage(const struct gen_device_info * const devinfo,
>  const struct anv_image *image,
> diff --git a/src/intel/vulkan/genX_cmd_buffer.c 
> b/src/intel/vulkan/genX_cmd_buffer.c
> index ef9b7d0..1f30a12 100644
> --- a/src/intel/vulkan/genX_cmd_buffer.c
> +++ b/src/intel/vulkan/genX_cmd_buffer.c
> @@ -388,6 +388,24 @@ transition_depth_buffer(struct anv_cmd_buffer 
> *cmd_buffer,
>anv_gen8_hiz_op_resolve(cmd_buffer, image, hiz_op);
>  }
>  
> +static void
> +transition_color_buffer(struct anv_cmd_buffer *cmd_buffer,
> +const struct anv_image *image,
> +VkImageLayout initial_layout,
> +VkImageLayout final_layout,
> +const VkImageSubresourceRange *subresourceRange)
> +{
> +   if (image->aux_usage != ISL_AUX_USAGE_CCS_E)
> +  return;
> +
> +   if (initial_layout != VK_IMAGE_LAYOUT_UNDEFINED &&
> +   initial_layout != VK_IMAGE_LAYOUT_PREINITIALIZED)
> +  return;
> +
> +#if GEN_GEN >= 9
> +   anv_image_ccs_ambiguate(cmd_buffer, image, subresourceRange);
> +#endif
> +}
>  
>  /**
>   * Setup anv_cmd_state::attachments for vkCmdBeginRenderPass.
> @@ -976,6 +994,13 @@ void genX(CmdPipelineBarrier)(
>   pImageMemoryBarriers[i].oldLayout,
>   pImageMemoryBarriers[i].newLayout);
>}
> +  if (pImageMemoryBarriers[i].subresourceRange.aspectMask &
> +  VK_IMAGE_ASPECT_COLOR_BIT) {
> + transition_color_buffer(cmd_buffer, image,
> + pImageMemoryBarriers[i].oldLayout,
> + pImageMemoryBarriers[i].newLayout,
> +  

[Mesa-dev] [PATCH] docs: Document ASTC extension support for SKL and BXT

2017-05-19 Thread Nanley Chery
Cc: Anuj Phogat 
Signed-off-by: Nanley Chery 
---
 docs/features.txt | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/docs/features.txt b/docs/features.txt
index e18bf54a48..05d776be08 100644
--- a/docs/features.txt
+++ b/docs/features.txt
@@ -306,8 +306,8 @@ Khronos, ARB, and OES extensions that are not part of any 
OpenGL or OpenGL ES ve
   GL_ARB_transform_feedback_overflow_query  DONE (i965/gen6+)
   GL_KHR_blend_equation_advanced_coherent   DONE (i965/gen9+)
   GL_KHR_no_error   started (Timothy 
Arceri)
-  GL_KHR_texture_compression_astc_hdr   DONE (core only)
-  GL_KHR_texture_compression_astc_sliced_3d not started
+  GL_KHR_texture_compression_astc_hdr   DONE (i965/bxt+)
+  GL_KHR_texture_compression_astc_sliced_3d DONE (i965/gen9+)
   GL_OES_depth_texture_cube_map DONE (all drivers that 
support GLSL 1.30+)
   GL_OES_EGL_image  DONE (all drivers)
   GL_OES_EGL_image_external_essl3   not started
-- 
2.12.2

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


Re: [Mesa-dev] [PATCH 1/9] mesa: Handle common extension checks with more compact code

2017-05-19 Thread Ian Romanick
On 05/19/2017 10:28 AM, Nanley Chery wrote:
> On Fri, May 19, 2017 at 06:38:03AM -0700, Ian Romanick wrote:
>> From: Ian Romanick 
>>
>> The previous code handled everything with the general case.  I noticed
>> that every time I converted an open-coded check to use a
>> _mesa_has_EXT_foo() function, the text size of the driver increased.
>>
>> Almost all extensions only care what the current context API is, and
>> the version does not matter.  Handle those using more compact checks.
>>
>>text data bss dec hex filename
>> 7037675   235248   37280 7310203  6f8b7b 32-bit i965_dri.so before
>> 7034307   235248   37280 7306835  6f7e53 32-bit i965_dri.so after
>> 6679695   303400   50608 7033703  6b5367 64-bit i965_dri.so before
>> 6676143   303400   50608 7030151  6b4587 64-bit i965_dri.so after
> 
> Hi Ian,
> 
> I wrote a patch some time ago that reduces the cost of the extension
> checks by a lot more with less code. The only thing I think may need
> addressing is endianness. Would you consider using it instead if I
> reworked it and sent it out to the list? You can find it here:
> https://cgit.freedesktop.org/~nchery/mesa/commit/?h=1/ext/optimize=a02d88eba1d3129b27d3b5e6aaa976c3ca20cf79

I was not able to reproduce that result on current Mesa.  I had a lot
of trouble believing that more than 18% of our driver binary was
extension check code.  I also had a sick feeling that may have just
been the first stage of grief talking... :)  Are you able to reproduce
your original result?

I also tried a similar patch to yours that wouldn't have endianness
problems:

#define EXT(name_str, driver_cap, gll, glc, es1, es2, ...) \
static inline bool \
_mesa_has_##name_str(const struct gl_context *ctx) \
{  \
   static const uint8_t ver[4] = { (uint8_t)gll, (uint8_t)es1, (uint8_t)es2, 
(uint8_t)glc }; \
   return ctx->Extensions.driver_cap &&\
  (ctx->Extensions.Version >= ver[ctx->API]);  \
}

Here's what I got for all four methods:

7037675  235248   37280 7310203  6f8b7b 32-bit i965_dri.so before
7034307  235248   37280 7306835  6f7e53 32-bit i965_dri.so after idr
7038343  235248   37280 7310871  6f8e17 32-bit i965_dri.so after Nanley
7036271  235248   37280 7308799  6f85ff 32-bit i965_dri.so w/arrays

6679695  303400   50608 7033703  6b5367 64-bit i965_dri.so before
6676143  303400   50608 7030151  6b4587 64-bit i965_dri.so after idr
6684767  303400   50608 7038775  6b6737 64-bit i965_dri.so after Nanley
6678567  303400   50608 7032575  6b4eff 64-bit i965_dri.so w/arrays

For reference, I build with the same flags that Fedora 23 (I think?)
used for release builds:

-O2 -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong 
--param=ssp-buffer-size=4 -grecord-gcc-switches

And either "-m64 -mtune=generic" or "-m32 -march=i686 -mtune=atom
-fasynchronous-unwind-tables" depending on the platform.
--enable-debug is not passed to configure.

Even if I were able to reproduce your original result, there are still
two cases where your approach may generate more code than is necessary:

1. All of the APIs that support the extension use dummy_true.  There
are many examples of this, but I don't think there are many matching
users of _mesa_has_XXX_foo().

2. All of the APIs support the extension in any version.
GL_EXT_polygon_offset_clamp is an example.

I think we can blend the strengths to get something even better.

I missed that glsl_parser_extras.cpp has its own implementation of the
has_XXX_foo() functions that take the API and version as explicit
parameters.  Your patch predates that change.  There's room for some
modest savings there too.

I'll send a couple follow-up patches soon.

> Thanks,
> Nanley

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


Re: [Mesa-dev] [Mesa-stable] [PATCH] automake: add SWR LLVM gen_builder.hpp workaround

2017-05-19 Thread Emil Velikov
On 19 May 2017 at 20:50, Rowley, Timothy O  wrote:
> Thanks for doing this; I would have been hunting for the dist-hook: magic
> for a while.
>
> Tested “make dist” on llvm-3.9.0 (works) and llvm-4.0/llvm-svn (fails,
> expected desired behavior).
>
> Built result of llvm-3.9.0 “make dist” with llvm-4.0 and llvm-svn and it
> compiles/works.
>
Perfect, thanks for testing! Pushed in master + picked for 17.1.

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


[Mesa-dev] [Bug 101110] Build failure in GNOME Continuous

2017-05-19 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=101110

Emil Velikov  changed:

   What|Removed |Added

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

--- Comment #2 from Emil Velikov  ---
Should be fixes with the following. Thanks for the report.

commit 2100c5f7bef6b47bf96b026e689e835ca436a59b
Author: Emil Velikov 
Date:   Sat May 20 00:04:33 2017 +0100

configure.ac: add xcb-fixes to the XCB DRI3 list

The XCB module is used by the VL targets. Thus omitting it can lead to
link-time errors due to unresolved symbols.

Other DRI3 users such as the Vulkan WSI and the dri3 loader helper do
not use an update region in their xcb_present_pixmap() call. We will
look into that at a later stage.

Fixes: acf3d2afab0 ("configure: check once for DRI3 dependencies")
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=101110
Signed-off-by: Emil Velikov 

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


Re: [Mesa-dev] [PATCH 14/16] anv: Advertise both 32-bit and 48-bit heaps when we have enough memory

2017-05-19 Thread Jason Ekstrand
On Fri, May 19, 2017 at 2:53 PM, Gustaw Smolarczyk 
wrote:

> 2017-05-18 23:01 GMT+02:00 Jason Ekstrand :
> > ---
> >  src/intel/vulkan/anv_device.c | 42 ++
> ++--
> >  1 file changed, 36 insertions(+), 6 deletions(-)
> >
> > diff --git a/src/intel/vulkan/anv_device.c
> b/src/intel/vulkan/anv_device.c
> > index 6ea8dfe..8eed7f3 100644
> > --- a/src/intel/vulkan/anv_device.c
> > +++ b/src/intel/vulkan/anv_device.c
> > @@ -112,12 +112,42 @@ anv_physical_device_init_heaps(struct
> anv_physical_device *device, int fd)
> > if (result != VK_SUCCESS)
> >return result;
> >
> > -   device->memory.heap_count = 1;
> > -   device->memory.heaps[0] = (struct anv_memory_heap) {
> > -  .size = heap_size,
> > -  .flags = VK_MEMORY_HEAP_DEVICE_LOCAL_BIT,
> > -  .supports_48bit_addresses = device->supports_48bit_addresses,
> > -   };
> > +   if (heap_size <= 3ull * (1ull << 30)) {
> > +  /* In this case, everything fits nicely into the 32-bit address
> space,
> > +   * so there's no need for supporting 48bit addresses on
> clinet-allocated
>
> Probably a typo: s/clinet/client/
>

Thanks.


> > +   * memory objects.
> > +   */
> > +  device->memory.heap_count = 1;
> > +  device->memory.heaps[0] = (struct anv_memory_heap) {
> > + .size = heap_size,
> > + .flags = VK_MEMORY_HEAP_DEVICE_LOCAL_BIT,
> > + .supports_48bit_addresses = false,
> > +  };
> > +   } else {
> > +  /* Not everything will fit nicely into a 32-bit address space.
> In this
> > +   * case we need a 64-bit heap.  Advertise a small 32-bit heap and
> a
> > +   * larger 48-bit heap.  If we're in this case, then we have a
> total heap
> > +   * size larger than 3GiB which most likely means they have 8 GiB
> of
> > +   * video memory and so carving off 2 GiB for the 32-bit heap
> should be
> > +   * reasonable.
> > +   */
> > +  const uint32_t heap_size_32bit = 2ull * (1ull << 30);
> > +  const uint32_t heap_size_48bit = heap_size - heap_size_32bit;
>
> Is it really a good idea for these variables to be only 32-bit?
> Especially the second one.
>

Ugh... Good catch.  I've fixed both locally.  Thanks!
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH v13 27/36] i965: Change resolve flags to enum

2017-05-19 Thread Jason Ekstrand
So, I think I'm going to end up doing a fairly significant rework of
resolves over the course of the next couple of weeks.  Carry on with the
branch as is and I'll figure out how to rebase it on top of whatever
changes I do later.  But it'll probably be significant.  Just a heads up.

--Jason

On Fri, May 19, 2017 at 2:38 AM, Daniel Stone  wrote:

> From: Ben Widawsky 
>
> In the foreseeable future it doesn't seem to make sense to have multiple
> resolve flags. What does make sense is to have the caller give an
> indication to the lower layers what it things should be done for
> resolve. The enum change distinguishes this binary selection.
>
> v2: Make setting the hint more concise (Topi)
>
> Signed-off-by: Ben Widawsky 
> Acked-by: Daniel Stone 
> Reviewed-by: Topi Pohjolainen 
> Signed-off-by: Daniel Stone 
> ---
>  src/mesa/drivers/dri/i965/brw_blorp.c |  8 
>  src/mesa/drivers/dri/i965/brw_context.c   | 13 +++--
>  src/mesa/drivers/dri/i965/intel_mipmap_tree.c | 12 ++--
>  src/mesa/drivers/dri/i965/intel_mipmap_tree.h | 13 -
>  4 files changed, 25 insertions(+), 21 deletions(-)
>
> diff --git a/src/mesa/drivers/dri/i965/brw_blorp.c
> b/src/mesa/drivers/dri/i965/brw_blorp.c
> index b69cb4fc7b..938600875e 100644
> --- a/src/mesa/drivers/dri/i965/brw_blorp.c
> +++ b/src/mesa/drivers/dri/i965/brw_blorp.c
> @@ -210,12 +210,12 @@ blorp_surf_for_miptree(struct brw_context *brw,
>  surf->aux_usage = ISL_AUX_USAGE_NONE;
>   }
>} else if (!(safe_aux_usage & (1 << surf->aux_usage))) {
> - uint32_t flags = 0;
> - if (safe_aux_usage & (1 << ISL_AUX_USAGE_CCS_E))
> -flags |= INTEL_MIPTREE_IGNORE_CCS_E;
> + const enum intel_resolve_hint hint =
> +safe_aux_usage & (1 << ISL_AUX_USAGE_CCS_E) ?
> +INTEL_RESOLVE_HINT_IGNORE_CCS_E : 0;
>
>   intel_miptree_resolve_color(brw, mt,
> - *level, start_layer, num_layers,
> flags);
> + *level, start_layer, num_layers,
> hint);
>
>   assert(!intel_miptree_has_color_unresolved(mt, *level, 1,
>  start_layer,
> num_layers));
> diff --git a/src/mesa/drivers/dri/i965/brw_context.c
> b/src/mesa/drivers/dri/i965/brw_context.c
> index f0e08b9874..5e446abb1f 100644
> --- a/src/mesa/drivers/dri/i965/brw_context.c
> +++ b/src/mesa/drivers/dri/i965/brw_context.c
> @@ -259,9 +259,10 @@ intel_update_state(struct gl_context * ctx, GLuint
> new_state)
>/* Sampling engine understands lossless compression and resolving
> * those surfaces should be skipped for performance reasons.
> */
> -  const int flags = intel_texture_view_requires_resolve(brw,
> tex_obj) ?
> -   0 : INTEL_MIPTREE_IGNORE_CCS_E;
> -  intel_miptree_all_slices_resolve_color(brw, tex_obj->mt, flags);
> +  const enum intel_resolve_hint hint =
> + intel_texture_view_requires_resolve(brw, tex_obj) ? 0 :
> + INTEL_RESOLVE_HINT_IGNORE_CCS_E;
> +  intel_miptree_all_slices_resolve_color(brw, tex_obj->mt, hint);
>brw_render_cache_set_check_flush(brw, tex_obj->mt->bo);
>
>if (tex_obj->base.StencilSampling ||
> @@ -313,9 +314,9 @@ intel_update_state(struct gl_context * ctx, GLuint
> new_state)
>  intel_renderbuffer(fb->_ColorDrawBuffers[i]);
>
>   if (irb &&
> - intel_miptree_resolve_color(
> -brw, irb->mt, irb->mt_level, irb->mt_layer,
> irb->layer_count,
> -INTEL_MIPTREE_IGNORE_CCS_E))
> + intel_miptree_resolve_color(brw, irb->mt, irb->mt_level,
> + irb->mt_layer, irb->layer_count,
> + INTEL_RESOLVE_HINT_IGNORE_CCS_
> E))
>  brw_render_cache_set_check_flush(brw, irb->mt->bo);
>}
> }
> diff --git a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
> b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
> index b33afdeb3f..8a33010543 100644
> --- a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
> +++ b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
> @@ -2234,7 +2234,7 @@ intel_miptree_used_for_rendering(const struct
> brw_context *brw,
>  static bool
>  intel_miptree_needs_color_resolve(const struct brw_context *brw,
>const struct intel_mipmap_tree *mt,
> -  int flags)
> +  enum intel_resolve_hint hint)
>  {
> if (mt->aux_disable & INTEL_AUX_DISABLE_CCS)
>return false;
> @@ -2246,7 +2246,7 @@ intel_miptree_needs_color_resolve(const struct
> brw_context *brw,
>  * surfaces called "lossless compressed". These don't need to be always
>  * resolved.
>  */
> -   

[Mesa-dev] [Bug 101110] Build failure in GNOME Continuous

2017-05-19 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=101110

--- Comment #1 from Emil Velikov  ---
Seems like I've missed some corner case - I'm looking into it.

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


Re: [Mesa-dev] [PATCH 2/2] gallium: Add renderonly-based support for pl111+vc4.

2017-05-19 Thread Emil Velikov
On 19 May 2017 at 23:41, Emil Velikov  wrote:
> On 19 May 2017 at 23:21, Eric Anholt  wrote:
>> Emil Velikov  writes:
>>
>>> On 17 May 2017 at 20:13, Emil Velikov  wrote:
 On 17 May 2017 at 18:53, Eric Anholt  wrote:
> Emil Velikov  writes:
>
>> Hi Eric,
>>
>> On 11 May 2017 at 00:06, Eric Anholt  wrote:
>>> This follows the model of imx (display) and etnaviv (render): pl111 is a
>>> display-only device, so when asked to do GL for it, we see if we have a
>>> vc4 renderer, make the vc4 screen, and have vc4 call back to pl111 to do
>>> scanout allocations.
>>>
>>> The difference from etnaviv is that we share the same BO between vc4 and
>>> pl111, rather than having a vc4 bo and a pl11 bo and copies between the
>>> two.  The only mismatch between their requirements is that vc4 requires
>>> 4-pixel (at 32bpp) stride alignment, while pl111 requires that stride
>>> match width.  The kernel will reject any modesets to an incorrect 
>>> stride,
>>> so the 3D driver doesn't need to worry about that.
>>> ---
>> I'm not familiar with the hardware itself so I cannot comment on those.
>> There's a couple of small notes within, but overall the patch looks good.
>>
>>>  .travis.yml|  2 +-
>>>  Makefile.am|  2 +-
>> Yes, thank you!
>>
>>
>>> --- a/Android.mk
>>> +++ b/Android.mk
>>
>>>  classic_drivers := i915 i965
>>> -gallium_drivers := swrast freedreno i915g nouveau r300g r600g radeonsi 
>>> vmwgfx vc4 virgl
>>> +gallium_drivers := swrast freedreno i915g nouveau pl111 r300g r600g 
>>> radeonsi vmwgfx vc4 virgl
>>>
>> The recent Android cleanups by RobH which will cause a clash. The gist
>> is below, but feel free to skim through commit
>> 3f097396a1642bb7033002d0bdd37e194afce06a.
>>  - rework for the new gallium_drivers format
>>  - add a couple of lines in src/gallium/drivers/pl111/Android.mk
>> analogous to the vc4 - the "ifneq $HAVE_foo" hunk
>>  - drop the guard in src/gallium/Android.mk
>>
>>
>>> +++ b/src/gallium/winsys/pl111/drm/pl111_drm_winsys.c
>>
>>> -#include 
>>>  #include 
>>> +#include 
>>>
>>> -#include "vc4_drm_public.h"
>>> +#include "pl111_drm_public.h"
>>> +#include "vc4/drm/vc4_drm_public.h"
>>> +#include "xf86drm.h"
>>>
>>> -#include "vc4/vc4_screen.h"
>>> +#include "pipe/p_screen.h"
>>> +#include "renderonly/renderonly.h"
>>
>>> +#include "util/u_format.h"
>> Seems unused.
>>
>>>
>>> -struct pipe_screen *
>>> -vc4_drm_screen_create(int fd)
>>> +struct pipe_screen *pl111_drm_screen_create(int fd)
>>>  {
>>> -   return vc4_screen_create(fcntl(fd, F_DUPFD_CLOEXEC, 3));
>>> +   struct renderonly ro = {
>>> +  /* Passes the vc4-allocated BO through to the pl111 DRM device 
>>> using
>>> +   * PRIME buffer sharing.  The VC4 BO must be linear, which the 
>>> SCANOUT
>>> +   * flag on allocation will have ensured.
>>> +   */
>>> +  .create_for_resource = renderonly_create_gpu_import_for_resource,
>>> +  .kms_fd = fd,
>>> +  .gpu_fd = drmOpenWithType("vc4", NULL, DRM_NODE_RENDER),
>> Please don't use the drmOpen* API. It's a legacy dragon with very
>> subtle and inner workings.
>> Using drmGetDevice[s] should provide any information that you need.
>> Alternatively please let us know what's missing so we can address it.
>
> One this platform, there are exactly two devices, one is vc4 and the
> other is pl111.  drmOpenWithType is exactly the API we want, and if you
> want something else, then you should probably replace its insides
> instead of telling people to use a different API.

 Changing the insides also changes the behaviour, which could break users 
 :-\

>>> A couple of things from our IRC chat last night:
>>>
>>> - My suggestion was never meant as requirement or a blocker. Let along
>>> "exerting control" as you call it :-\
>>> It's aimed to save you/others time since the drmOpen* API
>>> implementation is aimed for UMS and broken for KMS drivers.
>>>
>>> - You asked a couple of times "how this can break", despite my pointer
>>> to DanielV's summary [1] and some encouragement to skim through the
>>> drmOpen* code yourself.
>>> Now a bit less tired, here it is the exact scenario how/why things are 
>>> broken.
>>>
>>> A) User opens the vc4 device and calls drmSetInterfaceVersion
>>> effectively populating the "unique name"
>>> Plymouth, modesetting ddx, Xserver itself and others can easily do so.
>>> B) Consecutive calls to  drmOpenWithType("vc4", NULL..) will fail
>>> since 

Re: [Mesa-dev] [PATCH 2/2] gallium: Add renderonly-based support for pl111+vc4.

2017-05-19 Thread Emil Velikov
On 19 May 2017 at 23:21, Eric Anholt  wrote:
> Emil Velikov  writes:
>
>> On 17 May 2017 at 20:13, Emil Velikov  wrote:
>>> On 17 May 2017 at 18:53, Eric Anholt  wrote:
 Emil Velikov  writes:

> Hi Eric,
>
> On 11 May 2017 at 00:06, Eric Anholt  wrote:
>> This follows the model of imx (display) and etnaviv (render): pl111 is a
>> display-only device, so when asked to do GL for it, we see if we have a
>> vc4 renderer, make the vc4 screen, and have vc4 call back to pl111 to do
>> scanout allocations.
>>
>> The difference from etnaviv is that we share the same BO between vc4 and
>> pl111, rather than having a vc4 bo and a pl11 bo and copies between the
>> two.  The only mismatch between their requirements is that vc4 requires
>> 4-pixel (at 32bpp) stride alignment, while pl111 requires that stride
>> match width.  The kernel will reject any modesets to an incorrect stride,
>> so the 3D driver doesn't need to worry about that.
>> ---
> I'm not familiar with the hardware itself so I cannot comment on those.
> There's a couple of small notes within, but overall the patch looks good.
>
>>  .travis.yml|  2 +-
>>  Makefile.am|  2 +-
> Yes, thank you!
>
>
>> --- a/Android.mk
>> +++ b/Android.mk
>
>>  classic_drivers := i915 i965
>> -gallium_drivers := swrast freedreno i915g nouveau r300g r600g radeonsi 
>> vmwgfx vc4 virgl
>> +gallium_drivers := swrast freedreno i915g nouveau pl111 r300g r600g 
>> radeonsi vmwgfx vc4 virgl
>>
> The recent Android cleanups by RobH which will cause a clash. The gist
> is below, but feel free to skim through commit
> 3f097396a1642bb7033002d0bdd37e194afce06a.
>  - rework for the new gallium_drivers format
>  - add a couple of lines in src/gallium/drivers/pl111/Android.mk
> analogous to the vc4 - the "ifneq $HAVE_foo" hunk
>  - drop the guard in src/gallium/Android.mk
>
>
>> +++ b/src/gallium/winsys/pl111/drm/pl111_drm_winsys.c
>
>> -#include 
>>  #include 
>> +#include 
>>
>> -#include "vc4_drm_public.h"
>> +#include "pl111_drm_public.h"
>> +#include "vc4/drm/vc4_drm_public.h"
>> +#include "xf86drm.h"
>>
>> -#include "vc4/vc4_screen.h"
>> +#include "pipe/p_screen.h"
>> +#include "renderonly/renderonly.h"
>
>> +#include "util/u_format.h"
> Seems unused.
>
>>
>> -struct pipe_screen *
>> -vc4_drm_screen_create(int fd)
>> +struct pipe_screen *pl111_drm_screen_create(int fd)
>>  {
>> -   return vc4_screen_create(fcntl(fd, F_DUPFD_CLOEXEC, 3));
>> +   struct renderonly ro = {
>> +  /* Passes the vc4-allocated BO through to the pl111 DRM device 
>> using
>> +   * PRIME buffer sharing.  The VC4 BO must be linear, which the 
>> SCANOUT
>> +   * flag on allocation will have ensured.
>> +   */
>> +  .create_for_resource = renderonly_create_gpu_import_for_resource,
>> +  .kms_fd = fd,
>> +  .gpu_fd = drmOpenWithType("vc4", NULL, DRM_NODE_RENDER),
> Please don't use the drmOpen* API. It's a legacy dragon with very
> subtle and inner workings.
> Using drmGetDevice[s] should provide any information that you need.
> Alternatively please let us know what's missing so we can address it.

 One this platform, there are exactly two devices, one is vc4 and the
 other is pl111.  drmOpenWithType is exactly the API we want, and if you
 want something else, then you should probably replace its insides
 instead of telling people to use a different API.
>>>
>>> Changing the insides also changes the behaviour, which could break users :-\
>>>
>> A couple of things from our IRC chat last night:
>>
>> - My suggestion was never meant as requirement or a blocker. Let along
>> "exerting control" as you call it :-\
>> It's aimed to save you/others time since the drmOpen* API
>> implementation is aimed for UMS and broken for KMS drivers.
>>
>> - You asked a couple of times "how this can break", despite my pointer
>> to DanielV's summary [1] and some encouragement to skim through the
>> drmOpen* code yourself.
>> Now a bit less tired, here it is the exact scenario how/why things are 
>> broken.
>>
>> A) User opens the vc4 device and calls drmSetInterfaceVersion
>> effectively populating the "unique name"
>> Plymouth, modesetting ddx, Xserver itself and others can easily do so.
>> B) Consecutive calls to  drmOpenWithType("vc4", NULL..) will fail
>> since the drmGetBusid/GET_UNIQUE return the non-zero "unique name".
>> That happens in drmOpenByName which considers the latter as "device
>> already opened".
>
> According to LIBGL_DEBUG=verbose, 

[Mesa-dev] [Bug 101110] Build failure in GNOME Continuous

2017-05-19 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=101110

Bug ID: 101110
   Summary: Build failure in GNOME Continuous
   Product: Mesa
   Version: git
  Hardware: Other
OS: All
Status: NEW
  Severity: normal
  Priority: medium
 Component: Other
  Assignee: mesa-dev@lists.freedesktop.org
  Reporter: eba...@gmail.com
QA Contact: mesa-dev@lists.freedesktop.org

Mesa compilation is failing in the GNOME Continuous integration builder:

script=../../../../../src/gallium/targets/xvmc/xvmc.sym   -Wl,-soname
-Wl,libXvMCgallium.so.1 -o .libs/libXvMCgallium.so.1.0.0
../../../../src/gallium/auxiliary/.libs/libgalliumvlwinsys.a(libgalliumvlwinsys_la-vl_winsys_dri3.o):
In function `vl_dri3_flush_frontbuffer':
/ostbuild/source/mesa/_build/src/gallium/auxiliary/../../../../src/gallium/auxiliary/vl/vl_winsys_dri3.c:571:
undefined reference to `xcb_xfixes_create_region'
../../../../src/gallium/auxiliary/.libs/libgalliumvlwinsys.a(libgalliumvlwinsys_la-vl_winsys_dri3.o):
In function `vl_dri3_screen_create':
/ostbuild/source/mesa/_build/src/gallium/auxiliary/../../../../src/gallium/auxiliary/vl/vl_winsys_dri3.c:768:
undefined reference to `xcb_xfixes_id'
/ostbuild/source/mesa/_build/src/gallium/auxiliary/../../../../src/gallium/auxiliary/vl/vl_winsys_dri3.c:775:
undefined reference to `xcb_xfixes_id'
/ostbuild/source/mesa/_build/src/gallium/auxiliary/../../../../src/gallium/auxiliary/vl/vl_winsys_dri3.c:779:
undefined reference to `xcb_xfixes_query_version'
/ostbuild/source/mesa/_build/src/gallium/auxiliary/../../../../src/gallium/auxiliary/vl/vl_winsys_dri3.c:781:
undefined reference to `xcb_xfixes_query_version_reply'

Full build log:
http://build.gnome.org/continuous/buildmaster/builds/2017/05/19/40/build/log-mesa.txt

Configuration options:

  "--disable-asm",
  "--enable-osmesa",
  "--with-dri-driverdir=/usr/lib/dri",
  "--enable-egl",
  "--enable-gles1",
  "--enable-gles2",
  "--with-egl-platforms=wayland,x11,drm",
  "--enable-shared-glapi",
  "--enable-gbm",
  "--enable-xa",
  "--with-llvm-config-dir=/usr/bin/llvm3.3",
  "--with-gallium-drivers=svga,r300,nouveau,swrast,virgl",
  "--enable-llvm",
  "--with-vulkan-drivers=intel",
  "--with-dri-drivers=nouveau,radeon,r200,i915,i965,swrast"

Configuration summary:

prefix:  /usr
exec_prefix: ${prefix}
libdir:  /usr/lib
includedir:  /usr/include

OpenGL:  yes (ES1: yes ES2: yes)

OSMesa:  libOSMesa

DRI platform:drm
DRI drivers: i915 i965 nouveau r200 radeon swrast 
DRI driver dir:  /usr/lib/dri
GLX: DRI-based

EGL: yes
EGL drivers: builtin:egl_dri2 builtin:egl_dri3
GBM: yes
EGL/Vulkan/VL platforms:   wayland x11 drm

Vulkan drivers:  intel 
Vulkan ICD dir:  ${datarootdir}/vulkan/icd.d

llvm:yes
llvm-config: /usr/bin/llvm3.3/x86_64-gnomeostree-linux-llvm-config
llvm-version:3.3

Gallium drivers: svga r300 nouveau swrast virgl
Gallium st:  mesa xa xvmc

HUD extra stats: no
HUD lmsensors:   no

Shared libs: yes
Static libs: no
Shared-glapi:yes

CFLAGS:  -g -m64 -mtune=generic -Wall -std=c99
-Werror=implicit-function-declaration -Werror=missing-prototypes
-fno-math-errno -fno-trapping-math
CXXFLAGS:-g -m64 -mtune=generic -Wall -fno-math-errno
-fno-trapping-math
LDFLAGS: 
Macros:  -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS
-D__STDC_LIMIT_MACROS -D_GNU_SOURCE -DUSE_SSE41 -DUSE_GCC_ATOMIC_BUILTINS
-DNDEBUG -DHAVE_XLOCALE_H -DHAVE_SYS_SYSCTL_H -DHAVE_STRTOF -DHAVE_MKOSTEMP
-DHAVE_DLOPEN -DHAVE_DL_ITERATE_PHDR -DHAVE_POSIX_MEMALIGN -DHAVE_LIBDRM
-DGLX_USE_DRM -DGLX_INDIRECT_RENDERING -DGLX_DIRECT_RENDERING -DGLX_USE_TLS
-DHAVE_WAYLAND_PLATFORM -DHAVE_X11_PLATFORM -DHAVE_DRM_PLATFORM -DHAVE_DRI3
-DENABLE_SHADER_CACHE -DHAVE_MINCORE -DHAVE_LLVM=0x0303
-DMESA_LLVM_VERSION_PATCH=0

LLVM_CFLAGS: -I/usr/include/llvm3.3 -D__STDC_CONSTANT_MACROS
-D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
LLVM_CXXFLAGS:   -I/usr/include/llvm3.3 -D__STDC_CONSTANT_MACROS
-D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
LLVM_CPPFLAGS:   -I/usr/include/llvm3.3 -D__STDC_CONSTANT_MACROS
-D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
LLVM_LDFLAGS:-L/usr/lib/llvm3.3  -lz -lpthread -lffi -ldl -lm 

PYTHON2: python2.7

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


Re: [Mesa-dev] [PATCH 2/2] gallium: Add renderonly-based support for pl111+vc4.

2017-05-19 Thread Eric Anholt
Emil Velikov  writes:

> On 17 May 2017 at 20:13, Emil Velikov  wrote:
>> On 17 May 2017 at 18:53, Eric Anholt  wrote:
>>> Emil Velikov  writes:
>>>
 Hi Eric,

 On 11 May 2017 at 00:06, Eric Anholt  wrote:
> This follows the model of imx (display) and etnaviv (render): pl111 is a
> display-only device, so when asked to do GL for it, we see if we have a
> vc4 renderer, make the vc4 screen, and have vc4 call back to pl111 to do
> scanout allocations.
>
> The difference from etnaviv is that we share the same BO between vc4 and
> pl111, rather than having a vc4 bo and a pl11 bo and copies between the
> two.  The only mismatch between their requirements is that vc4 requires
> 4-pixel (at 32bpp) stride alignment, while pl111 requires that stride
> match width.  The kernel will reject any modesets to an incorrect stride,
> so the 3D driver doesn't need to worry about that.
> ---
 I'm not familiar with the hardware itself so I cannot comment on those.
 There's a couple of small notes within, but overall the patch looks good.

>  .travis.yml|  2 +-
>  Makefile.am|  2 +-
 Yes, thank you!


> --- a/Android.mk
> +++ b/Android.mk

>  classic_drivers := i915 i965
> -gallium_drivers := swrast freedreno i915g nouveau r300g r600g radeonsi 
> vmwgfx vc4 virgl
> +gallium_drivers := swrast freedreno i915g nouveau pl111 r300g r600g 
> radeonsi vmwgfx vc4 virgl
>
 The recent Android cleanups by RobH which will cause a clash. The gist
 is below, but feel free to skim through commit
 3f097396a1642bb7033002d0bdd37e194afce06a.
  - rework for the new gallium_drivers format
  - add a couple of lines in src/gallium/drivers/pl111/Android.mk
 analogous to the vc4 - the "ifneq $HAVE_foo" hunk
  - drop the guard in src/gallium/Android.mk


> +++ b/src/gallium/winsys/pl111/drm/pl111_drm_winsys.c

> -#include 
>  #include 
> +#include 
>
> -#include "vc4_drm_public.h"
> +#include "pl111_drm_public.h"
> +#include "vc4/drm/vc4_drm_public.h"
> +#include "xf86drm.h"
>
> -#include "vc4/vc4_screen.h"
> +#include "pipe/p_screen.h"
> +#include "renderonly/renderonly.h"

> +#include "util/u_format.h"
 Seems unused.

>
> -struct pipe_screen *
> -vc4_drm_screen_create(int fd)
> +struct pipe_screen *pl111_drm_screen_create(int fd)
>  {
> -   return vc4_screen_create(fcntl(fd, F_DUPFD_CLOEXEC, 3));
> +   struct renderonly ro = {
> +  /* Passes the vc4-allocated BO through to the pl111 DRM device 
> using
> +   * PRIME buffer sharing.  The VC4 BO must be linear, which the 
> SCANOUT
> +   * flag on allocation will have ensured.
> +   */
> +  .create_for_resource = renderonly_create_gpu_import_for_resource,
> +  .kms_fd = fd,
> +  .gpu_fd = drmOpenWithType("vc4", NULL, DRM_NODE_RENDER),
 Please don't use the drmOpen* API. It's a legacy dragon with very
 subtle and inner workings.
 Using drmGetDevice[s] should provide any information that you need.
 Alternatively please let us know what's missing so we can address it.
>>>
>>> One this platform, there are exactly two devices, one is vc4 and the
>>> other is pl111.  drmOpenWithType is exactly the API we want, and if you
>>> want something else, then you should probably replace its insides
>>> instead of telling people to use a different API.
>>
>> Changing the insides also changes the behaviour, which could break users :-\
>>
> A couple of things from our IRC chat last night:
>
> - My suggestion was never meant as requirement or a blocker. Let along
> "exerting control" as you call it :-\
> It's aimed to save you/others time since the drmOpen* API
> implementation is aimed for UMS and broken for KMS drivers.
>
> - You asked a couple of times "how this can break", despite my pointer
> to DanielV's summary [1] and some encouragement to skim through the
> drmOpen* code yourself.
> Now a bit less tired, here it is the exact scenario how/why things are broken.
>
> A) User opens the vc4 device and calls drmSetInterfaceVersion
> effectively populating the "unique name"
> Plymouth, modesetting ddx, Xserver itself and others can easily do so.
> B) Consecutive calls to  drmOpenWithType("vc4", NULL..) will fail
> since the drmGetBusid/GET_UNIQUE return the non-zero "unique name".
> That happens in drmOpenByName which considers the latter as "device
> already opened".

According to LIBGL_DEBUG=verbose, drmGetBusid is returning NULL on this
platform.  drm_getunique() is banned on render nodes, resulting in an
EACCES and drmGetBusid returns NULL.

Thanks for *finally* explaining your 

[Mesa-dev] [PATCH] vulkan/wsi/wayland: Fix proxy wrappers for swapchain recreation

2017-05-19 Thread Philipp Zabel
Before the swapchain event queue is destroyed, all proxy objects that reference
it must be dropped. Otherwise we risk a use-after-free if a frame callback event
or buffer release events are received afterwards.
This happens when an application destroys and recreates a swapchain in FIFO
mode between two frames without using the VkSwapchainCreateInfoKHR::oldSwapchain
mechanism to keep the old swapchain until after the next redraw.

Fixes: 5034c615582a ("vulkan/wsi/wayland: Use proxy wrappers for swapchain")
Signed-off-by: Philipp Zabel 
Cc: mesa-sta...@lists.freedesktop.org
---
 src/vulkan/wsi/wsi_common_wayland.c | 13 ++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/src/vulkan/wsi/wsi_common_wayland.c 
b/src/vulkan/wsi/wsi_common_wayland.c
index 8950798882..644ed62b41 100644
--- a/src/vulkan/wsi/wsi_common_wayland.c
+++ b/src/vulkan/wsi/wsi_common_wayland.c
@@ -537,6 +537,7 @@ struct wsi_wl_swapchain {
struct wl_surface *  surface;
uint32_t surface_version;
struct wl_drm *  drm_wrapper;
+   struct wl_callback * frame;
 
VkExtent2D   extent;
VkFormat vk_format;
@@ -616,6 +617,7 @@ frame_handle_done(void *data, struct wl_callback *callback, 
uint32_t serial)
 {
struct wsi_wl_swapchain *chain = data;
 
+   chain->frame = NULL;
chain->fifo_ready = true;
 
wl_callback_destroy(callback);
@@ -658,8 +660,8 @@ wsi_wl_swapchain_queue_present(struct wsi_swapchain 
*wsi_chain,
}
 
if (chain->base.present_mode == VK_PRESENT_MODE_FIFO_KHR) {
-  struct wl_callback *frame = wl_surface_frame(chain->surface);
-  wl_callback_add_listener(frame, _listener, chain);
+  chain->frame = wl_surface_frame(chain->surface);
+  wl_callback_add_listener(chain->frame, _listener, chain);
   chain->fifo_ready = false;
}
 
@@ -741,12 +743,16 @@ wsi_wl_swapchain_destroy(struct wsi_swapchain *wsi_chain,
struct wsi_wl_swapchain *chain = (struct wsi_wl_swapchain *)wsi_chain;
 
for (uint32_t i = 0; i < chain->base.image_count; i++) {
-  if (chain->images[i].buffer)
+  if (chain->images[i].buffer) {
+ wl_buffer_destroy(chain->images[i].buffer);
  chain->base.image_fns->free_wsi_image(chain->base.device, pAllocator,
chain->images[i].image,
chain->images[i].memory);
+  }
}
 
+   if (chain->frame)
+  wl_callback_destroy(chain->frame);
if (chain->surface)
   wl_proxy_wrapper_destroy(chain->surface);
if (chain->drm_wrapper)
@@ -791,6 +797,7 @@ wsi_wl_surface_create_swapchain(VkIcdSurfaceBase 
*icd_surface,
chain->queue = NULL;
chain->surface = NULL;
chain->drm_wrapper = NULL;
+   chain->frame = NULL;
 
bool alpha = pCreateInfo->compositeAlpha ==
   VK_COMPOSITE_ALPHA_PRE_MULTIPLIED_BIT_KHR;
-- 
2.11.0

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


Re: [Mesa-dev] [PATCH 14/16] anv: Advertise both 32-bit and 48-bit heaps when we have enough memory

2017-05-19 Thread Gustaw Smolarczyk
2017-05-18 23:01 GMT+02:00 Jason Ekstrand :
> ---
>  src/intel/vulkan/anv_device.c | 42 --
>  1 file changed, 36 insertions(+), 6 deletions(-)
>
> diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c
> index 6ea8dfe..8eed7f3 100644
> --- a/src/intel/vulkan/anv_device.c
> +++ b/src/intel/vulkan/anv_device.c
> @@ -112,12 +112,42 @@ anv_physical_device_init_heaps(struct 
> anv_physical_device *device, int fd)
> if (result != VK_SUCCESS)
>return result;
>
> -   device->memory.heap_count = 1;
> -   device->memory.heaps[0] = (struct anv_memory_heap) {
> -  .size = heap_size,
> -  .flags = VK_MEMORY_HEAP_DEVICE_LOCAL_BIT,
> -  .supports_48bit_addresses = device->supports_48bit_addresses,
> -   };
> +   if (heap_size <= 3ull * (1ull << 30)) {
> +  /* In this case, everything fits nicely into the 32-bit address space,
> +   * so there's no need for supporting 48bit addresses on 
> clinet-allocated

Probably a typo: s/clinet/client/

> +   * memory objects.
> +   */
> +  device->memory.heap_count = 1;
> +  device->memory.heaps[0] = (struct anv_memory_heap) {
> + .size = heap_size,
> + .flags = VK_MEMORY_HEAP_DEVICE_LOCAL_BIT,
> + .supports_48bit_addresses = false,
> +  };
> +   } else {
> +  /* Not everything will fit nicely into a 32-bit address space.  In this
> +   * case we need a 64-bit heap.  Advertise a small 32-bit heap and a
> +   * larger 48-bit heap.  If we're in this case, then we have a total 
> heap
> +   * size larger than 3GiB which most likely means they have 8 GiB of
> +   * video memory and so carving off 2 GiB for the 32-bit heap should be
> +   * reasonable.
> +   */
> +  const uint32_t heap_size_32bit = 2ull * (1ull << 30);
> +  const uint32_t heap_size_48bit = heap_size - heap_size_32bit;

Is it really a good idea for these variables to be only 32-bit?
Especially the second one.

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


Re: [Mesa-dev] [PATCH 9/9] nouveau: s/nv04_surface_/nouveau_surface_/

2017-05-19 Thread Francisco Jerez
Ilia Mirkin  writes:

> I kinda see it both ways - yeah, the functions are the same and it's
> all shared, so your patch makes sense. OTOH, all of these functions
> (which do anything) have a nv04/nv10/nv20 prefix, which makes it
> easier to separate stuff out by generation if need be. So I think in a
> perfect world, the actual copy/fill functions would stay, while the
> helpers would move up to nouveau_surface (esp if one were to grow a
> nv10-specific impl). But this extends the API considerably, for
> basically silly reasons. But the current state of the driver is that
> there are no instances of BEGIN_NV04 or any pushbuf stuff in the
> nouveau_* files.
>
> Curro, since you're the original author of the driver, what do you
> think about this and the previous patch?
>

My intention here (and in most of the dri/nouveau driver codebase) was
to reserve the nouveau_ prefix for source files and functions managing
driver-wide hardware-independent data structures, and the nvXX_ prefixes
for the source files doing the actual hardware poking for generation
nvXX and later.  Does this explanation make the current split between
nv04_ and nouveau_surface seem more reasonable to you, Ian?

> On Fri, May 19, 2017 at 9:38 AM, Ian Romanick  wrote:
>> From: Ian Romanick 
>>
>> After moving the contents of nv04_surface.c to nouveau_surface.c, rename
>> all the functions.
>>
>> Signed-off-by: Ian Romanick 
>> Cc: Ilia Mirkin 
>> ---
>>  src/mesa/drivers/dri/nouveau/nouveau_surface.c | 60 
>> +-
>>  src/mesa/drivers/dri/nouveau/nouveau_surface.h | 18 
>>  src/mesa/drivers/dri/nouveau/nv04_context.c|  8 ++--
>>  src/mesa/drivers/dri/nouveau/nv10_context.c|  8 ++--
>>  src/mesa/drivers/dri/nouveau/nv20_context.c|  8 ++--
>>  5 files changed, 51 insertions(+), 51 deletions(-)
>>
>> diff --git a/src/mesa/drivers/dri/nouveau/nouveau_surface.c 
>> b/src/mesa/drivers/dri/nouveau/nouveau_surface.c
>> index af5c924..e3cd3c3 100644
>> --- a/src/mesa/drivers/dri/nouveau/nouveau_surface.c
>> +++ b/src/mesa/drivers/dri/nouveau/nouveau_surface.c
>> @@ -253,11 +253,11 @@ sifm_format(mesa_format format)
>>  }
>>
>>  static void
>> -nv04_surface_copy_swizzle(struct gl_context *ctx,
>> - struct nouveau_surface *dst,
>> - struct nouveau_surface *src,
>> - int dx, int dy, int sx, int sy,
>> - int w, int h)
>> +nouveau_surface_copy_swizzle(struct gl_context *ctx,
>> +struct nouveau_surface *dst,
>> +struct nouveau_surface *src,
>> +int dx, int dy, int sx, int sy,
>> +int w, int h)
>>  {
>> struct nouveau_pushbuf_refn refs[] = {
>> { src->bo, NOUVEAU_BO_RD | NOUVEAU_BO_VRAM | NOUVEAU_BO_GART 
>> },
>> @@ -334,11 +334,11 @@ nv04_surface_copy_swizzle(struct gl_context *ctx,
>>  }
>>
>>  static void
>> -nv04_surface_copy_m2mf(struct gl_context *ctx,
>> -  struct nouveau_surface *dst,
>> -  struct nouveau_surface *src,
>> -  int dx, int dy, int sx, int sy,
>> -  int w, int h)
>> +nouveau_surface_copy_m2mf(struct gl_context *ctx,
>> + struct nouveau_surface *dst,
>> + struct nouveau_surface *src,
>> + int dx, int dy, int sx, int sy,
>> + int w, int h)
>>  {
>> struct nouveau_pushbuf_refn refs[] = {
>> { src->bo, NOUVEAU_BO_RD | NOUVEAU_BO_VRAM | NOUVEAU_BO_GART 
>> },
>> @@ -422,11 +422,11 @@ get_swizzled_offset(struct nouveau_surface *s, 
>> unsigned x, unsigned y)
>>  }
>>
>>  static void
>> -nv04_surface_copy_cpu(struct gl_context *ctx,
>> - struct nouveau_surface *dst,
>> - struct nouveau_surface *src,
>> - int dx, int dy, int sx, int sy,
>> - int w, int h)
>> +nouveau_surface_copy_cpu(struct gl_context *ctx,
>> +struct nouveau_surface *dst,
>> +struct nouveau_surface *src,
>> +int dx, int dy, int sx, int sy,
>> +int w, int h)
>>  {
>> int x, y;
>> get_offset_t get_dst = (dst->layout == SWIZZLED ?
>> @@ -450,11 +450,11 @@ nv04_surface_copy_cpu(struct gl_context *ctx,
>>  }
>>
>>  void
>> -nv04_surface_copy(struct gl_context *ctx,
>> - struct nouveau_surface *dst,
>> - struct nouveau_surface *src,
>> - int dx, int dy, int sx, int sy,
>> - int w, int h)
>> +nouveau_surface_copy(struct gl_context *ctx,
>> +struct nouveau_surface *dst,
>> +struct nouveau_surface *src,
>> + 

Re: [Mesa-dev] [PATCH v13 24/36] i965/miptree: Add a return for updating of winsys

2017-05-19 Thread Jason Ekstrand
It's a bit annoying, but I think this would all make more sense if we moved
23 and 24 to before 19.  Then we could drop no_aux from 21.  Then again,
I'm sure Ben has some good reason why that's not practical and I'm fine
with leaving the order as-is.  It's hard to review but there's a lot of
detangling going on so I think that's somewhat expected.

On Fri, May 19, 2017 at 2:38 AM, Daniel Stone  wrote:

> From: Ben Widawsky 
>
> There is nothing particularly useful to do currently if the update
> fails, but there is no point carrying on either. As a result, this has a
> behavior change.
>
> v2: Make the return type a bool (Topi)
>
> v3: Don't leak the bo if update_winsys_renderbuffer fails. (Jason)
>
> Signed-off-by: Ben Widawsky 
> Acked-by: Daniel Stone 
> Reviewed-by: Topi Pohjolainen  (v2)
> Signed-off-by: Daniel Stone 
> ---
>  src/mesa/drivers/dri/i965/brw_context.c   | 16 ++--
>  src/mesa/drivers/dri/i965/intel_mipmap_tree.c |  6 +++---
>  src/mesa/drivers/dri/i965/intel_mipmap_tree.h |  2 +-
>  3 files changed, 14 insertions(+), 10 deletions(-)
>
> diff --git a/src/mesa/drivers/dri/i965/brw_context.c
> b/src/mesa/drivers/dri/i965/brw_context.c
> index 1a2b64f73e..3ae84fd332 100644
> --- a/src/mesa/drivers/dri/i965/brw_context.c
> +++ b/src/mesa/drivers/dri/i965/brw_context.c
> @@ -1660,9 +1660,12 @@ intel_process_dri2_buffer(struct brw_context *brw,
>return;
> }
>
> -   intel_update_winsys_renderbuffer_miptree(brw, rb, bo,
> -drawable->w, drawable->h,
> -buffer->pitch);
> +   if (!intel_update_winsys_renderbuffer_miptree(brw, rb, bo,
> + drawable->w, drawable->h,
> + buffer->pitch)) {
> +  brw_bo_unreference(bo);
> +  return;
> +   }
>
> if (_mesa_is_front_buffer_drawing(fb) &&
> (buffer->attachment == __DRI_BUFFER_FRONT_LEFT ||
> @@ -1721,9 +1724,10 @@ intel_update_image_buffer(struct brw_context
> *intel,
> if (!buffer->aux_offset)
>rb->no_aux = true;
>
> -   intel_update_winsys_renderbuffer_miptree(intel, rb, buffer->bo,
> -buffer->width, buffer->height,
> -buffer->pitch);
> +   if (!intel_update_winsys_renderbuffer_miptree(intel, rb, buffer->bo,
> + buffer->width,
> buffer->height,
> + buffer->pitch))
> +  return;
>
> if (_mesa_is_front_buffer_drawing(fb) &&
> buffer_type == __DRI_IMAGE_BUFFER_FRONT &&
> diff --git a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
> b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
> index 9dca5cc435..edda132f7b 100644
> --- a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
> +++ b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
> @@ -870,7 +870,7 @@ intel_miptree_create_for_image(struct brw_context
> *intel,
>   * that will contain the actual rendering (which is lazily resolved to
>   * irb->singlesample_mt).
>   */
> -void
> +bool
>  intel_update_winsys_renderbuffer_miptree(struct brw_context *intel,
>   struct intel_renderbuffer *irb,
>   struct brw_bo *bo,
> @@ -937,12 +937,12 @@ intel_update_winsys_renderbuffer_miptree(struct
> brw_context *intel,
>   irb->mt = multisample_mt;
>}
> }
> -   return;
> +   return true;
>
>  fail:
> intel_miptree_release(>singlesample_mt);
> intel_miptree_release(>mt);
> -   return;
> +   return false;
>  }
>
>  struct intel_mipmap_tree*
> diff --git a/src/mesa/drivers/dri/i965/intel_mipmap_tree.h
> b/src/mesa/drivers/dri/i965/intel_mipmap_tree.h
> index 8ec1278d0b..15e81300a2 100644
> --- a/src/mesa/drivers/dri/i965/intel_mipmap_tree.h
> +++ b/src/mesa/drivers/dri/i965/intel_mipmap_tree.h
> @@ -717,7 +717,7 @@ intel_miptree_create_for_image(struct brw_context
> *intel,
> uint32_t pitch,
> uint32_t layout_flags);
>
> -void
> +bool
>  intel_update_winsys_renderbuffer_miptree(struct brw_context *intel,
>   struct intel_renderbuffer *irb,
>   struct brw_bo *bo,
> --
> 2.13.0
>
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 2/2] i965: Enable ASTC HDR for Broxton

2017-05-19 Thread Nanley Chery
On Fri, May 19, 2017 at 10:41:22AM -0700, Anuj Phogat wrote:
> On Thu, May 18, 2017 at 3:53 PM, Nanley Chery  wrote:
> > This platform passes the following GLES3 tests:
> > ES3-CTS.functional.texture.compressed.astc.endpoint_value_hdr_cem_*
> >
> We've hdr tests in piglit as well. With those passing, both patches are:
> Reviewed-by: Anuj Phogat 
> 

I've confirmed the piglit tests to be passing as well. Thanks!

> > Signed-off-by: Nanley Chery 
> > ---
> >  src/mesa/drivers/dri/i965/intel_extensions.c | 3 +++
> >  1 file changed, 3 insertions(+)
> >
> > diff --git a/src/mesa/drivers/dri/i965/intel_extensions.c 
> > b/src/mesa/drivers/dri/i965/intel_extensions.c
> > index 26c074638e..e76f61de1d 100644
> > --- a/src/mesa/drivers/dri/i965/intel_extensions.c
> > +++ b/src/mesa/drivers/dri/i965/intel_extensions.c
> > @@ -285,6 +285,9 @@ intelInitExtensions(struct gl_context *ctx)
> >ctx->Extensions.ARB_post_depth_coverage = true;
> > }
> >
> > +   if (brw->is_broxton)
> > +  ctx->Extensions.KHR_texture_compression_astc_hdr = true;
> > +
> > if (brw->gen >= 6)
> >ctx->Extensions.INTEL_performance_query = true;
> >
> > --
> > 2.12.2
> >
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH v13 21/36] i965: Restructure CCS disabling

2017-05-19 Thread Jason Ekstrand
On Fri, May 19, 2017 at 2:38 AM, Daniel Stone  wrote:

> From: Ben Widawsky 
>
> Make the code only disable CCS when it has to, unlike before where it
> disabled CCS and enabled it when it could. This is much more inline with
> how it should work in a few patches, where we have fewer restrictions as
> to when we disable CCS.
>
> v2: Change CCS disabling to an assertion in layout creation (Topi)
>
> v3: Make sure to disable aux buffers when creating a miptree from a BO.
> Today, this only happens via intel_update_image_buffer. At the end of
> the modifier series, we should be able to undo this. Some fixes from
> Topi in here as well.
>
> Cc: "Pohjolainen, Topi" 
> Signed-off-by: Ben Widawsky 
>
> Topi's changes
>
> Signed-off-by: Daniel Stone 
> ---
>  src/mesa/drivers/dri/i965/brw_context.c   |  3 +++
>  src/mesa/drivers/dri/i965/intel_fbo.h |  7 +++
>  src/mesa/drivers/dri/i965/intel_mipmap_tree.c | 22 +-
>  3 files changed, 23 insertions(+), 9 deletions(-)
>
> diff --git a/src/mesa/drivers/dri/i965/brw_context.c
> b/src/mesa/drivers/dri/i965/brw_context.c
> index 5055dd76a8..1a2b64f73e 100644
> --- a/src/mesa/drivers/dri/i965/brw_context.c
> +++ b/src/mesa/drivers/dri/i965/brw_context.c
> @@ -1718,6 +1718,9 @@ intel_update_image_buffer(struct brw_context *intel,
> if (last_mt && last_mt->bo == buffer->bo)
>return;
>
> +   if (!buffer->aux_offset)
> +  rb->no_aux = true;
> +
> intel_update_winsys_renderbuffer_miptree(intel, rb, buffer->bo,
>  buffer->width, buffer->height,
>  buffer->pitch);
> diff --git a/src/mesa/drivers/dri/i965/intel_fbo.h
> b/src/mesa/drivers/dri/i965/intel_fbo.h
> index 08b82e8934..9265aab2e2 100644
> --- a/src/mesa/drivers/dri/i965/intel_fbo.h
> +++ b/src/mesa/drivers/dri/i965/intel_fbo.h
> @@ -111,6 +111,13 @@ struct intel_renderbuffer
>  * for the duration of a mapping.
>  */
> bool singlesample_mt_is_tmp;
> +
> +   /**
> +* Set to true if this buffer definitely does not have auxiliary data,
> like
> +* CCS, associated with it. It's generally to be used when importing a
> +* DRIimage, where that DRIimage had no modifier.
> +*/
> +   bool no_aux;
>

I think I would mildly prefer the stuff having to do with this bool to be
its own patch right after this one.


>  };
>
>
> diff --git a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
> b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
> index a8564d9573..9dca5cc435 100644
> --- a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
> +++ b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
> @@ -328,7 +328,6 @@ intel_miptree_create_layout(struct brw_context *brw,
> mt->logical_depth0 = depth0;
> mt->aux_disable = (layout_flags & MIPTREE_LAYOUT_DISABLE_AUX) != 0 ?
>INTEL_AUX_DISABLE_ALL : INTEL_AUX_DISABLE_NONE;
> -   mt->aux_disable |= INTEL_AUX_DISABLE_CCS;
> mt->is_scanout = (layout_flags & MIPTREE_LAYOUT_FOR_SCANOUT) != 0;
> exec_list_make_empty(>hiz_map);
> exec_list_make_empty(>color_resolve_map);
> @@ -521,6 +520,8 @@ intel_miptree_create_layout(struct brw_context *brw,
> } else if (brw->gen >= 9 && num_samples > 1) {
>layout_flags |= MIPTREE_LAYOUT_FORCE_HALIGN16;
> } else {
> +  mt->aux_disable |= INTEL_AUX_DISABLE_CCS;
> +
>const UNUSED bool is_lossless_compressed_aux =
>   brw->gen >= 9 && num_samples == 1 &&
>   mt->format == MESA_FORMAT_R_UINT32;
> @@ -696,7 +697,6 @@ intel_miptree_create(struct brw_context *brw,
>  */
> if (intel_tiling_supports_non_msrt_mcs(brw, mt->tiling) &&
> intel_miptree_supports_non_msrt_fast_clear(brw, mt)) {
> -  mt->aux_disable &= ~INTEL_AUX_DISABLE_CCS;
>assert(brw->gen < 8 || mt->halign == 16 || num_samples <= 1);
>
>/* On Gen9+ clients are not currently capable of consuming
> compressed
> @@ -710,8 +710,11 @@ intel_miptree_create(struct brw_context *brw,
>   intel_miptree_supports_lossless_compressed(brw, mt);
>
>if (is_lossless_compressed) {
> + assert((mt->aux_disable & INTEL_AUX_DISABLE_CCS) == 0);
>

Mind making this assert(!(thing)) rather than assert((thing) == 0)?  That
would match the one a few lines below.


>   intel_miptree_alloc_non_msrt_mcs(brw, mt,
> is_lossless_compressed);
>}
> +   } else {
> +  mt->aux_disable |= INTEL_AUX_DISABLE_CCS;
> }
>
> return mt;
> @@ -803,7 +806,7 @@ create_ccs_buf_for_image(struct brw_context *intel,
> mt->mcs_buf->qpitch = isl_surf_get_array_pitch_sa_
> rows(_ccs_surf);
>
> intel_miptree_init_mcs(intel, mt, 0);
> -   mt->aux_disable &= ~INTEL_AUX_DISABLE_CCS;
> +   assert(!(mt->aux_disable & INTEL_AUX_DISABLE_CCS));
> mt->msaa_layout = INTEL_MSAA_LAYOUT_CMS;
>
> return true;
> @@ -894,18 +897,19 @@ 

Re: [Mesa-dev] [Mesa-stable] [PATCH] automake: add SWR LLVM gen_builder.hpp workaround

2017-05-19 Thread Rowley, Timothy O
Thanks for doing this; I would have been hunting for the dist-hook: magic for a 
while.

Tested “make dist” on llvm-3.9.0 (works) and llvm-4.0/llvm-svn (fails, expected 
desired behavior).

Built result of llvm-3.9.0 “make dist” with llvm-4.0 and llvm-svn and it 
compiles/works.

Reviewed-by: Tim Rowley 
>

On May 19, 2017, at 12:31 PM, Emil Velikov 
> wrote:

From: Emil Velikov 
>

As gen_builder.hpp file is generated, it contains information that is
specific to the LLVM version it originates from.

As suggested by Tim, the file seems to be forwards compatible. So in
order to produce ship a file which will work everywhere we should be
using earlies supported LLVM - 3.9.

With this we're back on track and can build all of mesa without
python/mako/flex and friends.

In the long term we might want to see if the python generators can be
updated to produce LLVM version agnostic files. At least within the
range supported by SWR.

Cc: 
>
Cc: Chuck Atkins >
Cc: Tim Rowley >
Signed-off-by: Emil Velikov 
>
---
configure.ac|  4 
src/gallium/drivers/swr/Makefile.am | 41 ++---
2 files changed, 15 insertions(+), 30 deletions(-)

diff --git a/configure.ac b/configure.ac
index ce5301f3e45..3d10a4b8935 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2472,6 +2472,10 @@ if test -n "$with_gallium_drivers"; then
done
fi

+# XXX: Keep in sync with LLVM_REQUIRED_SWR
+AM_CONDITIONAL(SWR_INVALID_LLVM_VERSION, test "x$LLVM_VERSION" != x3.9.0 -a \
+  "x$LLVM_VERSION" != x3.9.1)
+
if test "x$enable_llvm" = "xyes" -a "$with_gallium_drivers"; then
llvm_require_version $LLVM_REQUIRED_GALLIUM "gallium"
llvm_add_default_components "gallium"
diff --git a/src/gallium/drivers/swr/Makefile.am 
b/src/gallium/drivers/swr/Makefile.am
index 0d71f52b1e6..7b2da074162 100644
--- a/src/gallium/drivers/swr/Makefile.am
+++ b/src/gallium/drivers/swr/Makefile.am
@@ -56,6 +56,7 @@ BUILT_SOURCES = \
rasterizer/codegen/gen_knobs.cpp \
rasterizer/codegen/gen_knobs.h \
rasterizer/jitter/gen_state_llvm.h \
+ rasterizer/jitter/gen_builder.hpp \
rasterizer/jitter/gen_builder_x86.hpp \
rasterizer/archrast/gen_ar_event.hpp \
rasterizer/archrast/gen_ar_event.cpp \
@@ -168,20 +169,6 @@ COMMON_LDFLAGS = \
$(LLVM_LDFLAGS)


-# XXX: As we cannot use BUILT_SOURCES (the files will end up in the dist
-# tarball) just annotate the dependency directly.
-# As the single direct user of gen_builder.hpp is a header (builder.h) trace 
all
-# the translusive users (one that use the latter header).
-rasterizer/jitter/blend_jit.cpp: rasterizer/jitter/gen_builder.hpp
-rasterizer/jitter/builder.cpp: rasterizer/jitter/gen_builder.hpp
-rasterizer/jitter/builder_misc.cpp: rasterizer/jitter/gen_builder.hpp
-rasterizer/jitter/fetch_jit.cpp: rasterizer/jitter/gen_builder.hpp
-rasterizer/jitter/streamout_jit.cpp: rasterizer/jitter/gen_builder.hpp
-swr_shader.cpp: rasterizer/jitter/gen_builder.hpp
-
-CLEANFILES = \
- rasterizer/jitter/gen_builder.hpp
-
lib_LTLIBRARIES = libswrAVX.la 
libswrAVX2.la

libswrAVX_la_CXXFLAGS = \
@@ -192,14 +179,6 @@ libswrAVX_la_CXXFLAGS = \
libswrAVX_la_SOURCES = \
$(COMMON_SOURCES)

-# XXX: Don't ship these generated sources for now, since they are specific
-# to the LLVM version they are generated from. Thus a release tarball
-# containing the said files, generated against eg. LLVM 3.8 will fail to build
-# on systems with other versions of LLVM eg. 3.7 or 3.6.
-# Move these back to BUILT_SOURCES once that is resolved.
-nodist_libswrAVX_la_SOURCES = \
- rasterizer/jitter/gen_builder.hpp
-
libswrAVX_la_LIBADD = \
$(COMMON_LIBADD)

@@ -214,14 +193,6 @@ libswrAVX2_la_CXXFLAGS = \
libswrAVX2_la_SOURCES = \
$(COMMON_SOURCES)

-# XXX: Don't ship these generated sources for now, since they are specific
-# to the LLVM version they are generated from. Thus a release tarball
-# containing the said files, generated against eg. LLVM 3.8 will fail to build
-# on systems with other versions of LLVM eg. 3.7 or 3.6.
-# Move these back to BUILT_SOURCES once that is resolved.
-nodist_libswrAVX2_la_SOURCES = \
- rasterizer/jitter/gen_builder.hpp
-
libswrAVX2_la_LIBADD = \
$(COMMON_LIBADD)

@@ -230,6 +201,16 @@ libswrAVX2_la_LDFLAGS = \

include $(top_srcdir)/install-gallium-links.mk

+# Generated gen_builder.hpp is not backwards compatible. So ship only one
+# created with the oldest supported version of LLVM.
+dist-hook:
+if SWR_INVALID_LLVM_VERSION
+ @echo 

Re: [Mesa-dev] [PATCH v13 16/36] i965: Remove same-FD restriction for imports

2017-05-19 Thread Jason Ekstrand
On Fri, May 19, 2017 at 2:37 AM, Daniel Stone  wrote:

> Intel hardware requires that all planes of an image come from the same
> buffer, which is currently implemented by testing that all FDs are
> numerically the same.
>
> However, when going through a winsys (e.g.) or anything which transits
> FDs individually, the FDs may be different even if the underlying buffer
> is the same.
>
> Since there is nothing we can do to detect this properly, just remove
> the test for now.
>

That's not actually true.  If two FDs point to the same underlying GEM bo,
then brw_bo_gem_create_from_prime (called below) will return the same
pointers for both of them.  What we really want to do is call that on all
of the FDs (or maybe all of the unique FDs?) and check that they're all the
same.


> Signed-off-by: Daniel Stone 
> ---
>  src/mesa/drivers/dri/i965/intel_screen.c | 5 -
>  1 file changed, 5 deletions(-)
>
> diff --git a/src/mesa/drivers/dri/i965/intel_screen.c
> b/src/mesa/drivers/dri/i965/intel_screen.c
> index 91ed128f83..69c450a431 100644
> --- a/src/mesa/drivers/dri/i965/intel_screen.c
> +++ b/src/mesa/drivers/dri/i965/intel_screen.c
> @@ -819,11 +819,6 @@ intel_create_image_from_fds(__DRIscreen *dri_screen,
> if (fds == NULL || num_fds < 1)
>return NULL;
>
> -   /* We only support all planes from the same bo */
> -   for (i = 0; i < num_fds; i++)
> -  if (fds[0] != fds[i])
> - return NULL;
> -
> f = intel_image_format_lookup(fourcc);
> if (f == NULL)
>return NULL;
> --
> 2.13.0
>
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH v13 07/36] egl: implement eglQueryDmaBufModifiersEXT

2017-05-19 Thread Jason Ekstrand
Just FYI: I'm not checking that you implement the EGL API correctly.  I'm
mostly checking for whether or not it's using DRI correctly.

On Fri, May 19, 2017 at 2:37 AM, Daniel Stone  wrote:

> From: Varad Gautam 
>
> query and return supported dmabuf format modifiers for
> EGL_EXT_image_dma_buf_import_modifiers.
>
> v2: move format check to the driver instead of making format queries
> here and then checking.
> v3: Check DRIimageExtension version before query (Daniel Stone)
>
> Signed-off-by: Varad Gautam 
> Reviewed-by: Daniel Stone 
> Signed-off-by: Daniel Stone 
> ---
>  src/egl/drivers/dri2/egl_dri2.c | 36 
>  src/egl/main/eglapi.c   | 20 
>  src/egl/main/eglapi.h   |  5 +
>  src/egl/main/eglentrypoint.h|  1 +
>  4 files changed, 62 insertions(+)
>
> diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_
> dri2.c
> index 55b6fcf1fc..1e0302359f 100644
> --- a/src/egl/drivers/dri2/egl_dri2.c
> +++ b/src/egl/drivers/dri2/egl_dri2.c
> @@ -2131,6 +2131,41 @@ dri2_query_dma_buf_formats(_EGLDriver *drv,
> _EGLDisplay *disp,
> return EGL_TRUE;
>  }
>
> +static EGLBoolean
> +dri2_query_dma_buf_modifiers(_EGLDriver *drv, _EGLDisplay *disp, EGLint
> format,
> + EGLint max, EGLuint64KHR *modifiers,
> + EGLBoolean *external_only, EGLint *count)
> +{
> +   struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
> +   EGLint i;
> +
> +   if (max < 0) {
> +  _eglError(EGL_BAD_PARAMETER, "invalid value for max count of
> formats");
> +  return EGL_FALSE;
> +   }
> +
> +   if (max > 0 && modifiers == NULL) {
> +  _eglError(EGL_BAD_PARAMETER, "invalid modifiers array");
> +  return EGL_FALSE;
> +   }
> +
> +   if (dri2_dpy->image->base.version < 16)
>

Check for the function pointer...


> +  return EGL_FALSE;
> +
> +   if (dri2_dpy->image->queryDmaBufModifiers(dri2_dpy->dri_screen,
> format,
> + max, modifiers,
> + count) == false) {
> +  _eglError(EGL_BAD_PARAMETER, "invalid format");
> +  return EGL_FALSE;
> +   }
> +   if (external_only != NULL) {
> +  for (i = 0; i < *count && i < max; i++)
> + external_only[i] = EGL_TRUE;
> +   }
> +
> +   return EGL_TRUE;
> +}
> +
>  /**
>   * The spec says:
>   *
> @@ -3064,6 +3099,7 @@ _eglBuiltInDriverDRI2(const char *args)
> dri2_drv->base.API.ExportDMABUFImageQueryMESA =
> dri2_export_dma_buf_image_query_mesa;
> dri2_drv->base.API.ExportDMABUFImageMESA = dri2_export_dma_buf_image_
> mesa;
> dri2_drv->base.API.QueryDmaBufFormatsEXT = dri2_query_dma_buf_formats;
> +   dri2_drv->base.API.QueryDmaBufModifiersEXT =
> dri2_query_dma_buf_modifiers;
>  #endif
>  #ifdef HAVE_WAYLAND_PLATFORM
> dri2_drv->base.API.BindWaylandDisplayWL =
> dri2_bind_wayland_display_wl;
> diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c
> index e83e3a414e..d0755ec652 100644
> --- a/src/egl/main/eglapi.c
> +++ b/src/egl/main/eglapi.c
> @@ -2403,6 +2403,26 @@ eglQueryDmaBufFormatsEXT(EGLDisplay dpy, EGLint
> max_formats,
> RETURN_EGL_EVAL(disp, ret);
>  }
>
> +static EGLBoolean EGLAPIENTRY
> +eglQueryDmaBufModifiersEXT(EGLDisplay dpy, EGLint format, EGLint
> max_modifiers,
> +   EGLuint64KHR *modifiers, EGLBoolean
> *external_only,
> +   EGLint *num_modifiers)
> +{
> +   _EGLDisplay *disp = _eglLockDisplay(dpy);
> +   _EGLDriver *drv;
> +   EGLBoolean ret;
> +
> +   _EGL_FUNC_START(NULL, EGL_NONE, NULL, EGL_FALSE);
> +
> +   _EGL_CHECK_DISPLAY(disp, EGL_FALSE, drv);
> +
> +   ret = drv->API.QueryDmaBufModifiersEXT(drv, disp, format,
> max_modifiers,
> +  modifiers, external_only,
> +  num_modifiers);
> +
> +   RETURN_EGL_EVAL(disp, ret);
> +}
> +
>  __eglMustCastToProperFunctionPointerType EGLAPIENTRY
>  eglGetProcAddress(const char *procname)
>  {
> diff --git a/src/egl/main/eglapi.h b/src/egl/main/eglapi.h
> index c9f98963db..cab3e9605a 100644
> --- a/src/egl/main/eglapi.h
> +++ b/src/egl/main/eglapi.h
> @@ -202,6 +202,11 @@ struct _egl_api
> EGLBoolean (*QueryDmaBufFormatsEXT)(_EGLDriver *drv, _EGLDisplay *dpy,
> EGLint max_formats, EGLint
> *formats,
> EGLint *num_formats);
> +   EGLBoolean (*QueryDmaBufModifiersEXT) (_EGLDriver *drv, _EGLDisplay
> *dpy,
> +  EGLint format, EGLint
> max_modifiers,
> +  EGLuint64KHR *modifiers,
> +  EGLBoolean *external_only,
> +  EGLint *num_modifiers);
>  };
>
>  

Re: [Mesa-dev] [PATCH v13 06/36] egl: implement eglQueryDmaBufFormatsEXT

2017-05-19 Thread Jason Ekstrand
On Fri, May 19, 2017 at 2:37 AM, Daniel Stone  wrote:

> From: Varad Gautam 
>
> allow egl clients to query the dmabuf formats supported on this platform.
>
> v2: return EGLBoolean.
> v3: Check DRIimageExtension version before querying (Daniel Stone)
>
> Signed-off-by: Louis-Francis Ratté-Boulianne 
> Signed-off-by: Varad Gautam 
> Reviewed-by: Daniel Stone 
> Signed-off-by: Daniel Stone 
> ---
>  src/egl/drivers/dri2/egl_dri2.c | 21 +
>  src/egl/main/eglapi.c   | 18 ++
>  src/egl/main/eglapi.h   |  4 
>  src/egl/main/eglentrypoint.h|  1 +
>  4 files changed, 44 insertions(+)
>
> diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_
> dri2.c
> index f06b5535c7..55b6fcf1fc 100644
> --- a/src/egl/drivers/dri2/egl_dri2.c
> +++ b/src/egl/drivers/dri2/egl_dri2.c
> @@ -2111,6 +2111,26 @@ dri2_check_dma_buf_format(const _EGLImageAttribs
> *attrs)
> return plane_n;
>  }
>
> +static EGLBoolean
> +dri2_query_dma_buf_formats(_EGLDriver *drv, _EGLDisplay *disp,
> +EGLint max, EGLint *formats, EGLint *count)
> +{
> +   struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
> +   if (max < 0 || (max > 0 && formats == NULL)) {
> +  _eglError(EGL_BAD_PARAMETER, "invalid value for max count of
> formats");
> +  return EGL_FALSE;
> +   }
> +
> +   if (dri2_dpy->image->base.version < 16)
>

I think you need to also check for the existance of the function pointer.


> +  return EGL_FALSE;
> +
> +   if (!dri2_dpy->image->queryDmaBufFormats(dri2_dpy->dri_screen, max,
> +formats, count))
> +  return EGL_FALSE;
> +
> +   return EGL_TRUE;
> +}
> +
>  /**
>   * The spec says:
>   *
> @@ -3043,6 +3063,7 @@ _eglBuiltInDriverDRI2(const char *args)
> dri2_drv->base.API.ExportDRMImageMESA = dri2_export_drm_image_mesa;
> dri2_drv->base.API.ExportDMABUFImageQueryMESA =
> dri2_export_dma_buf_image_query_mesa;
> dri2_drv->base.API.ExportDMABUFImageMESA = dri2_export_dma_buf_image_
> mesa;
> +   dri2_drv->base.API.QueryDmaBufFormatsEXT = dri2_query_dma_buf_formats;
>  #endif
>  #ifdef HAVE_WAYLAND_PLATFORM
> dri2_drv->base.API.BindWaylandDisplayWL =
> dri2_bind_wayland_display_wl;
> diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c
> index 9cea2f41ff..e83e3a414e 100644
> --- a/src/egl/main/eglapi.c
> +++ b/src/egl/main/eglapi.c
> @@ -2385,6 +2385,24 @@ _eglFunctionCompare(const void *key, const void
> *elem)
> return strcmp(procname, entrypoint->name);
>  }
>
> +static EGLBoolean EGLAPIENTRY
> +eglQueryDmaBufFormatsEXT(EGLDisplay dpy, EGLint max_formats,
> + EGLint *formats, EGLint *num_formats)
> +{
> +   _EGLDisplay *disp = _eglLockDisplay(dpy);
> +   _EGLDriver *drv;
> +   EGLBoolean ret;
> +
> +   _EGL_FUNC_START(NULL, EGL_NONE, NULL, EGL_FALSE);
> +
> +   _EGL_CHECK_DISPLAY(disp, EGL_FALSE, drv);
> +
> +   ret = drv->API.QueryDmaBufFormatsEXT(drv, disp, max_formats, formats,
> +num_formats);
> +
> +   RETURN_EGL_EVAL(disp, ret);
> +}
> +
>  __eglMustCastToProperFunctionPointerType EGLAPIENTRY
>  eglGetProcAddress(const char *procname)
>  {
> diff --git a/src/egl/main/eglapi.h b/src/egl/main/eglapi.h
> index 710c5d860a..c9f98963db 100644
> --- a/src/egl/main/eglapi.h
> +++ b/src/egl/main/eglapi.h
> @@ -198,6 +198,10 @@ struct _egl_api
> int (*GLInteropExportObject)(_EGLDisplay *dpy, _EGLContext *ctx,
>  struct mesa_glinterop_export_in *in,
>  struct mesa_glinterop_export_out *out);
> +
> +   EGLBoolean (*QueryDmaBufFormatsEXT)(_EGLDriver *drv, _EGLDisplay *dpy,
> +   EGLint max_formats, EGLint
> *formats,
> +   EGLint *num_formats);
>  };
>
>  #ifdef __cplusplus
> diff --git a/src/egl/main/eglentrypoint.h b/src/egl/main/eglentrypoint.h
> index e6318b9311..91536239e9 100644
> --- a/src/egl/main/eglentrypoint.h
> +++ b/src/egl/main/eglentrypoint.h
> @@ -56,6 +56,7 @@ EGL_ENTRYPOINT(eglPostSubBufferNV)
>  EGL_ENTRYPOINT(eglQueryAPI)
>  EGL_ENTRYPOINT(eglQueryContext)
>  EGL_ENTRYPOINT(eglQueryDebugKHR)
> +EGL_ENTRYPOINT(eglQueryDmaBufFormatsEXT)
>  EGL_ENTRYPOINT(eglQueryString)
>  EGL_ENTRYPOINT(eglQuerySurface)
>  EGL_ENTRYPOINT(eglQueryWaylandBufferWL)
> --
> 2.13.0
>
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH v13 05/36] dri: add queryDmaBufFormats and queryDmaBufModifiers to DRIimage

2017-05-19 Thread Jason Ekstrand
On Fri, May 19, 2017 at 2:37 AM, Daniel Stone  wrote:

> From: Varad Gautam 
>
> these allow querying the driver for supported dmabuf formats and
> modifiers.
>
> v2: move to __DRIimageExtension version 16.
> v3: return GLBoolean for error reporting, document params better.
>
> Signed-off-by: Varad Gautam 
> Reviewed-by: Daniel Stone 
> Signed-off-by: Daniel Stone 
> ---
>  include/GL/internal/dri_interface.h | 42 ++
> ++-
>  1 file changed, 41 insertions(+), 1 deletion(-)
>
> diff --git a/include/GL/internal/dri_interface.h
> b/include/GL/internal/dri_interface.h
> index 53b95dd93d..37bd48b0b6 100644
> --- a/include/GL/internal/dri_interface.h
> +++ b/include/GL/internal/dri_interface.h
> @@ -1137,7 +1137,7 @@ struct __DRIdri2ExtensionRec {
>   * extensions.
>   */
>  #define __DRI_IMAGE "DRI_IMAGE"
> -#define __DRI_IMAGE_VERSION 15
> +#define __DRI_IMAGE_VERSION 16
>

Do we really need to bump the extension version twice in one patch series?
Seems like we could just as easily merge this into patch 3.  Not that it
matters...


>
>  /**
>   * These formats correspond to the similarly named MESA_FORMAT_*
> @@ -1513,6 +1513,46 @@ struct __DRIimageExtensionRec {
>enum __DRIChromaSiting
> vert_siting,
>unsigned *error,
>void *loaderPrivate);
> +
> +   /*
> +* dmabuf format query to support EGL_EXT_image_dma_buf_import_
> modifiers.
> +*
> +* \param max  Maximum number of formats that can be accomodated
> into
> +* \param formats. If zero, no formats are returned -
> +* instead, the driver returns the total number of
> +* supported dmabuf formats in \param count.
> +* \param formats  Buffer to fill formats into.
> +* \param countCount of formats returned, or, total number of
> +* supported formats in case \param max is zero.
> +*
> +* Returns true on success.
> +*
> +* \since 16
> +*/
> +   GLboolean (*queryDmaBufFormats)(__DRIscreen *screen, int max, int
> *formats,
> +  int *count);
> +
> +   /*
> +* dmabuf format modifier query for a given format to support
> +* EGL_EXT_image_dma_buf_import_modifiers.
> +*
> +* \param fourccThe format to query modifiers for. If this format
> +*  is not supported by the driver, return false.
> +* \param max   Maximum number of modifiers that can be
> accomodated in
> +*  \param modifiers. If zero, no modifiers are
> returned -
> +*  instead, the driver returns the total number of
> +*  modifiers for \param format in \param count.
> +* \param modifiers Buffer to fill modifiers into.
> +* \param count Count of the modifiers returned, or, total number
> of
> +*  supported modifiers for \param fourcc in case
> +*  \param max is zero.
> +*
> +* Returns true upon success.
> +*
> +* \since 16
> +*/
> +   GLboolean (*queryDmaBufModifiers)(__DRIscreen *screen, int fourcc,
> int max,
> +uint64_t *modifiers, int *count);
>  };
>
>
> --
> 2.13.0
>
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] Android: r600: fix build when LLVM is disabled

2017-05-19 Thread Emil Velikov
Jfyi: feel free to add Fixes tag as you see fit. We parse though and
automatically nominate patches for -stable :-)
On 19 May 2017 at 13:04, Rob Herring  wrote:
> On Fri, May 12, 2017 at 11:55 AM, Rob Herring  wrote:
>> There's still an error after my recent clean-up if LLVM is not patched to
>> enable AMDGPU target:
>>
>> external/mesa3d/src/amd/common/ac_llvm_util.c:38:2: error: implicit 
>> declaration of function 'LLVMInitializeAMDGPUTargetInfo' is invalid in C99 
>> [-Werror,-Wimplicit-function-declaration]
>> LLVMInitializeAMDGPUTargetInfo();
>> ^
>> external/mesa3d/src/amd/common/ac_llvm_util.c:39:2: error: implicit 
>> declaration of function 'LLVMInitializeAMDGPUTarget' is invalid in C99 
>> [-Werror,-Wimplicit-function-declaration]
>> LLVMInitializeAMDGPUTarget();
>> ^
>> external/mesa3d/src/amd/common/ac_llvm_util.c:40:2: error: implicit 
>> declaration of function 'LLVMInitializeAMDGPUTargetMC' is invalid in C99 
>> [-Werror,-Wimplicit-function-declaration]
>> LLVMInitializeAMDGPUTargetMC();
>> ^
>> external/mesa3d/src/amd/common/ac_llvm_util.c:41:2: error: implicit 
>> declaration of function 'LLVMInitializeAMDGPUAsmPrinter' is invalid in C99 
>> [-Werror,-Wimplicit-function-declaration]
>> LLVMInitializeAMDGPUAsmPrinter();
>> ^
>>
>> We need to drop libmesa_amd_common when LLVM is disabled, however there's
>> still a dependency on include paths for ac_binary.h. So explicitly add the
>> include path when LLVM is disabled.
>
> Emil, can you please apply.
>
Done, alongside the virgl patch.
Might be worth getting a fd.o account [1] if you don't have one already.

Jfyi: feel free to add Fixes tag as you see fit. We parse though and
automatically nominate patches for -stable :-)

Thanks
Emil

[1] https://www.freedesktop.org/wiki/AccountRequests/
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH v13 04/36] egl/dri2: Create EGLImages with dmabuf modifiers

2017-05-19 Thread Jason Ekstrand
On Fri, May 19, 2017 at 2:37 AM, Daniel Stone  wrote:

> From: Varad Gautam 
>
> Allow creating EGLImages with dmabuf format modifiers when target is
> EGL_LINUX_DMA_BUF_EXT for EGL_EXT_image_dma_buf_import_modifiers.
>
> v2:
>  - clear modifier assembling and error label name (Eric Engestrom)
> v3:
>  - remove goto jumps within switch-case (Emil Velikov)
>  - treat zero as valid modifier (Daniel Stone)
>  - ensure same modifier across all dmabuf planes (Emil Velikov)
> v4:
>  - allow modifiers to add extra planes (Louis-Francis Ratté-Boulianne)
>
> Signed-off-by: Pekka Paalanen 
> Signed-off-by: Varad Gautam 
> Signed-off-by: Louis-Francis Ratté-Boulianne 
> Reviewed-by: Eric Engestrom 
> Reviewed-by: Daniel Stone 
> Signed-off-by: Daniel Stone 
> ---
>  src/egl/drivers/dri2/egl_dri2.c | 95 ++
> ++-
>  src/egl/main/eglimage.c | 48 +
>  src/egl/main/eglimage.h |  2 +
>  3 files changed, 134 insertions(+), 11 deletions(-)
>
> diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_
> dri2.c
> index ceffd281d5..f06b5535c7 100644
> --- a/src/egl/drivers/dri2/egl_dri2.c
> +++ b/src/egl/drivers/dri2/egl_dri2.c
> @@ -1949,6 +1949,33 @@ dri2_check_dma_buf_attribs(const _EGLImageAttribs
> *attrs)
>}
> }
>
> +   /**
> +* If  is EGL_LINUX_DMA_BUF_EXT, both or neither of the
> following
> +* attribute values may be given.
> +*
> +* This is referring to EGL_DMA_BUF_PLANE0_MODIFIER_LO_EXT and
> +* EGL_DMA_BUF_PLANE0_MODIFIER_HI_EXT, and the same for other planes.
> +*/
> +   for (i = 0; i < DMA_BUF_MAX_PLANES; ++i) {
> +  if (attrs->DMABufPlaneModifiersLo[i].IsPresent !=
> +  attrs->DMABufPlaneModifiersHi[i].IsPresent) {
> + _eglError(EGL_BAD_PARAMETER, "modifier attribute lo or hi
> missing");
> + return EGL_FALSE;
> +  }
> +   }
> +
> +   for (i = 0; i < DMA_BUF_MAX_PLANES; ++i) {
>

This loop could start at 1 instead of 0.  Also, you're checking that they
all match but you aren't checking that they're all present if the 0th is
present.  This also means that if 0 isn't present but 1 is, then you'll be
checking 1 against uninitialized data in 0.  I think we want to fail if
[0].IsPresent != [i].IsPresent.


> +  if (attrs->DMABufPlaneModifiersLo[i].IsPresent) {
> + if ((attrs->DMABufPlaneModifiersLo[0].Value !=
> + attrs->DMABufPlaneModifiersLo[i].Value) ||
> + (attrs->DMABufPlaneModifiersHi[0].Value !=
> + attrs->DMABufPlaneModifiersHi[i].Value)) {
> +_eglError(EGL_BAD_PARAMETER, "modifier attributes not equal");
> +return EGL_FALSE;
> + }
> +  }
> +   }
> +
> return EGL_TRUE;
>  }
>
> @@ -2057,7 +2084,25 @@ dri2_check_dma_buf_format(const _EGLImageAttribs
> *attrs)
> for (i = plane_n; i < DMA_BUF_MAX_PLANES; ++i) {
>if (attrs->DMABufPlaneFds[i].IsPresent ||
>attrs->DMABufPlaneOffsets[i].IsPresent ||
> -  attrs->DMABufPlanePitches[i].IsPresent) {
> +  attrs->DMABufPlanePitches[i].IsPresent ||
> +  attrs->DMABufPlaneModifiersLo[i].IsPresent ||
> +  attrs->DMABufPlaneModifiersHi[i].IsPresent) {
> +
> + /**
> +  * The modifiers extension spec says:
> +  *
> +  * "Modifiers may modify any attribute of a buffer import,
> including
> +  *  but not limited to adding extra planes to a format which
> +  *  otherwise does not have those planes. As an example, a
> modifier
> +  *  may add a plane for an external compression buffer to a
> +  *  single-plane format. The exact meaning and effect of any
> +  *  modifier is canonically defined by drm_fourcc.h, not as part
> of
> +  *  this extension."
> +  */
> + if (attrs->DMABufPlaneModifiersLo[i].IsPresent &&
> + attrs->DMABufPlaneModifiersHi[i].IsPresent)
> +continue;
> +
>   _eglError(EGL_BAD_ATTRIBUTE, "too many plane attributes");
>   return 0;
>}
> @@ -2090,6 +2135,8 @@ dri2_create_image_dma_buf(_EGLDisplay *disp,
> _EGLContext *ctx,
> int fds[DMA_BUF_MAX_PLANES];
> int pitches[DMA_BUF_MAX_PLANES];
> int offsets[DMA_BUF_MAX_PLANES];
> +   uint64_t modifiers[DMA_BUF_MAX_PLANES];
> +   bool has_modifier = false;
> unsigned error;
>
> /**
> @@ -2120,18 +2167,44 @@ dri2_create_image_dma_buf(_EGLDisplay *disp,
> _EGLContext *ctx,
>fds[i] = attrs.DMABufPlaneFds[i].Value;
>pitches[i] = attrs.DMABufPlanePitches[i].Value;
>offsets[i] = attrs.DMABufPlaneOffsets[i].Value;
> +  if (attrs.DMABufPlaneModifiersLo[i].IsPresent) {
> + modifiers[i] =
> +((uint64_t) 

Re: [Mesa-dev] [PATCH v13 03/36] dri: support DRIimage creation from dmabufs with modifiers

2017-05-19 Thread Jason Ekstrand
On Fri, May 19, 2017 at 2:37 AM, Daniel Stone  wrote:

> From: Pekka Paalanen 
>
> add createImageFromDmaBufs2 function which accepts per-plane dmabuf
> format modifiers.
>
> Signed-off-by: Pekka Paalanen 
> Signed-off-by: Varad Gautam 
> Reviewed-by: Daniel Stone 
> Signed-off-by: Daniel Stone 
> ---
>  include/GL/internal/dri_interface.h | 21 -
>  1 file changed, 20 insertions(+), 1 deletion(-)
>
> diff --git a/include/GL/internal/dri_interface.h
> b/include/GL/internal/dri_interface.h
> index c83056aa70..53b95dd93d 100644
> --- a/include/GL/internal/dri_interface.h
> +++ b/include/GL/internal/dri_interface.h
> @@ -1137,7 +1137,7 @@ struct __DRIdri2ExtensionRec {
>   * extensions.
>   */
>  #define __DRI_IMAGE "DRI_IMAGE"
> -#define __DRI_IMAGE_VERSION 14
> +#define __DRI_IMAGE_VERSION 15
>
>  /**
>   * These formats correspond to the similarly named MESA_FORMAT_*
> @@ -1494,6 +1494,25 @@ struct __DRIimageExtensionRec {
> const uint64_t *modifiers,
> const unsigned int
> modifier_count,
> void *loaderPrivate);
> +
> +   /*
> +* Like createImageFromDmaBufs, but takes also format modifiers.
> +*
> +* For EGL_EXT_image_dma_buf_import_modifiers.
> +*
> +* \since 15
> +*/
> +   __DRIimage *(*createImageFromDmaBufs2)(__DRIscreen *screen,
> +  int width, int height, int
> fourcc,
> +  int *fds, int num_fds,
> +  int *strides, int *offsets,
> +  uint64_t *modifiers,
>

As mentioned on IRC, modifiers are per-image so this doesn't need to be a
pointer.  Let's not make it one.  Also, would it make sense to move this up
by 2 lines and put it next to the fourcc format?


> +  enum __DRIYUVColorSpace
> color_space,
> +  enum __DRISampleRange
> sample_range,
> +  enum __DRIChromaSiting
> horiz_siting,
> +  enum __DRIChromaSiting
> vert_siting,
> +  unsigned *error,
> +  void *loaderPrivate);
>  };
>
>
> --
> 2.13.0
>
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] i965: Add RGBX8888 and RGBA8888 to EGL configure and reorder the list

2017-05-19 Thread Emil Velikov
On 18 May 2017 at 23:01, Rob Herring  wrote:
> On Thu, May 18, 2017 at 5:25 AM, Emil Velikov  
> wrote:
>> On 18 May 2017 at 05:10, Chih-Wei Huang  wrote:
>>> 2017-05-18 12:01 GMT+08:00 Xu, Randy :

> -Original Message-
> From: Palli, Tapani
> >
> > It's just applied. Isn't it?
> > Yesterday without this patch
> > the color format is mismatch apparently.
>
> Yeah we do need this. TBH I don't quite understand why but will try to 
> figure
> it out. I remember we used to have a patch in Surfaceflinger at one point
> because visual was hardcoded there and this might be related.
>
> // Tapani

 Sorry, that's for different issue, I mix it with RGB565 blending one.
 This patch is required because some Android GLES test apps, like 
 gl2_basic, need to create RGBA surface.
>>>
>>> Indeed it is.
>>>
>>> As Emil pointed out, the patch was merged before
>>> but reverted later since it broke desktop.
>>>
>>> So what's the current upstreaming plan?
>>>
>> No idea about a plan, but how you can fix it once and for all:
>>
>> Extend the loader extension(s) to have a get_caps() callback,
>> analogous to __DRIimageExtension::getCapabilities.
>> Then the DRI module will query [the loader] and advertise the
>> RGBX/RGBA visuals when possible.
>
> Could we do something compile time instead to enable just for Android?
> Seems like a lot of complexity when the platform needing these pixel
> formats doesn't need the backwards compatibility. Or maybe there are
> other things needing this interface?
>
Having a short/mid term ifdef ANDROID is perfectly fine.

Can we address some of the existing ones before/alongside the newly added ones?
Afacit the nouveau bits are no longer applicable. While for the
gbm/egl 'use "gallium_dri.so"' one can either use your latest build
rework or MESA_LOADER_DRIVER_OVERRIDE.

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


Re: [Mesa-dev] [PATCH 14/16] anv: Advertise both 32-bit and 48-bit heaps when we have enough memory

2017-05-19 Thread Jason Ekstrand
On Thu, May 18, 2017 at 2:01 PM, Jason Ekstrand 
wrote:

> ---
>  src/intel/vulkan/anv_device.c | 42 ++
> ++--
>  1 file changed, 36 insertions(+), 6 deletions(-)
>
> diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c
> index 6ea8dfe..8eed7f3 100644
> --- a/src/intel/vulkan/anv_device.c
> +++ b/src/intel/vulkan/anv_device.c
> @@ -112,12 +112,42 @@ anv_physical_device_init_heaps(struct
> anv_physical_device *device, int fd)
> if (result != VK_SUCCESS)
>return result;
>
> -   device->memory.heap_count = 1;
> -   device->memory.heaps[0] = (struct anv_memory_heap) {
> -  .size = heap_size,
> -  .flags = VK_MEMORY_HEAP_DEVICE_LOCAL_BIT,
> -  .supports_48bit_addresses = device->supports_48bit_addresses,
> -   };
> +   if (heap_size <= 3ull * (1ull << 30)) {
> +  /* In this case, everything fits nicely into the 32-bit address
> space,
> +   * so there's no need for supporting 48bit addresses on
> clinet-allocated
> +   * memory objects.
> +   */
> +  device->memory.heap_count = 1;
> +  device->memory.heaps[0] = (struct anv_memory_heap) {
> + .size = heap_size,
> + .flags = VK_MEMORY_HEAP_DEVICE_LOCAL_BIT,
> + .supports_48bit_addresses = false,
> +  };
> +   } else {
> +  /* Not everything will fit nicely into a 32-bit address space.  In
> this
> +   * case we need a 64-bit heap.  Advertise a small 32-bit heap and a
> +   * larger 48-bit heap.  If we're in this case, then we have a total
> heap
> +   * size larger than 3GiB which most likely means they have 8 GiB of
> +   * video memory and so carving off 2 GiB for the 32-bit heap should
> be
> +   * reasonable.
> +   */
> +  const uint32_t heap_size_32bit = 2ull * (1ull << 30);
>

FYI: I keep waflling on whether the 32-bit carve-out should be 2 GiB or 1
GiB.  No one should need more than 1 GiB for vertex buffers and it means
that, on my laptop, the space is split roughly in half (2 GiB and ~3 GiB)
which is a bit awkward.  I'm kind-of inclined to decrease it.  Opinions?


> +  const uint32_t heap_size_48bit = heap_size - heap_size_32bit;
> +
> +  assert(device->supports_48bit_addresses);
> +
> +  device->memory.heap_count = 2;
> +  device->memory.heaps[0] = (struct anv_memory_heap) {
> + .size = heap_size_48bit,
> + .flags = VK_MEMORY_HEAP_DEVICE_LOCAL_BIT,
> + .supports_48bit_addresses = true,
> +  };
> +  device->memory.heaps[1] = (struct anv_memory_heap) {
> + .size = heap_size_32bit,
> + .flags = VK_MEMORY_HEAP_DEVICE_LOCAL_BIT,
> + .supports_48bit_addresses = false,
> +  };
> +   }
>
> uint32_t type_count = 0;
> for (uint32_t heap = 0; heap < device->memory.heap_count; heap++) {
> --
> 2.5.0.400.gff86faf
>
>
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 1/2] anv: automake: list shared libraries after the static ones

2017-05-19 Thread Emil Velikov
From: Emil Velikov 

The compiler can discard the shared ones from the link chain, since
there is no user (the static libraries) before it on the command line.

Cc: mesa-sta...@lists.freedesktop.org
Reported-by: Laurent Carlier 
Signed-off-by: Emil Velikov 
---
 src/intel/Makefile.vulkan.am | 31 +++
 1 file changed, 15 insertions(+), 16 deletions(-)

diff --git a/src/intel/Makefile.vulkan.am b/src/intel/Makefile.vulkan.am
index ba6ab4fc93f..33cdc782d26 100644
--- a/src/intel/Makefile.vulkan.am
+++ b/src/intel/Makefile.vulkan.am
@@ -111,7 +111,21 @@ VULKAN_SOURCES = \
$(VULKAN_GENERATED_FILES) \
$(VULKAN_FILES)
 
-VULKAN_LIB_DEPS = $(LIBDRM_LIBS)
+VULKAN_LIB_DEPS = \
+   vulkan/libvulkan_common.la \
+   $(VULKAN_PER_GEN_LIBS) \
+   compiler/libintel_compiler.la \
+   common/libintel_common.la \
+   isl/libisl.la \
+   blorp/libblorp.la \
+   $(top_builddir)/src/vulkan/libvulkan_util.la \
+   $(top_builddir)/src/vulkan/libvulkan_wsi.la \
+   $(top_builddir)/src/compiler/nir/libnir.la \
+   $(top_builddir)/src/util/libmesautil.la \
+   $(LIBDRM_LIBS) \
+   $(PTHREAD_LIBS) \
+   $(DLOPEN_LIBS) \
+   -lm
 
 if HAVE_PLATFORM_X11
 VULKAN_CPPFLAGS += \
@@ -141,21 +155,6 @@ vulkan_libvulkan_common_la_SOURCES = $(VULKAN_SOURCES)
 vulkan_libvulkan_common_la_CFLAGS = $(VULKAN_CFLAGS)
 vulkan_libvulkan_common_la_CPPFLAGS = $(VULKAN_CPPFLAGS)
 
-VULKAN_LIB_DEPS += \
-   vulkan/libvulkan_common.la \
-   $(VULKAN_PER_GEN_LIBS) \
-   compiler/libintel_compiler.la \
-   common/libintel_common.la \
-   isl/libisl.la \
-   blorp/libblorp.la \
-   $(top_builddir)/src/vulkan/libvulkan_util.la \
-   $(top_builddir)/src/vulkan/libvulkan_wsi.la \
-   $(top_builddir)/src/compiler/nir/libnir.la \
-   $(top_builddir)/src/util/libmesautil.la \
-   $(PTHREAD_LIBS) \
-   $(DLOPEN_LIBS) \
-   -lm
-
 nodist_EXTRA_vulkan_libvulkan_intel_la_SOURCES = dummy.cpp
 vulkan_libvulkan_intel_la_SOURCES = $(VULKAN_GEM_FILES)
 vulkan_libvulkan_intel_la_LIBADD = $(VULKAN_LIB_DEPS)
-- 
2.12.2

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


[Mesa-dev] [PATCH 2/2] radv: automake: list shared libraries after the static ones

2017-05-19 Thread Emil Velikov
From: Emil Velikov 

Analogous to previous commit - the compiler can discard xcb + wayland
libs, since there is no user (the static libraries) before it on the
command line.

Cc: mesa-sta...@lists.freedesktop.org
Signed-off-by: Emil Velikov 
---
 src/amd/vulkan/Makefile.am | 35 ---
 1 file changed, 16 insertions(+), 19 deletions(-)

diff --git a/src/amd/vulkan/Makefile.am b/src/amd/vulkan/Makefile.am
index fbd9f5a0305..76a886dd79f 100644
--- a/src/amd/vulkan/Makefile.am
+++ b/src/amd/vulkan/Makefile.am
@@ -59,8 +59,22 @@ VULKAN_SOURCES = \
$(VULKAN_GENERATED_FILES) \
$(VULKAN_FILES)
 
-VULKAN_LIB_DEPS =
-
+VULKAN_LIB_DEPS = \
+   libvulkan_common.la \
+   $(top_builddir)/src/vulkan/libvulkan_util.la \
+   $(top_builddir)/src/vulkan/libvulkan_wsi.la \
+   $(top_builddir)/src/amd/common/libamd_common.la \
+   $(top_builddir)/src/amd/addrlib/libamdgpu_addrlib.la \
+   $(top_builddir)/src/compiler/nir/libnir.la \
+   $(top_builddir)/src/util/libmesautil.la \
+   $(LLVM_LIBS) \
+   $(LIBELF_LIBS) \
+   $(PTHREAD_LIBS) \
+   $(AMDGPU_LIBS) \
+   $(LIBDRM_LIBS) \
+   $(PTHREAD_LIBS) \
+   $(DLOPEN_LIBS) \
+   -lm
 
 if HAVE_PLATFORM_X11
 AM_CPPFLAGS += \
@@ -89,23 +103,6 @@ endif
 noinst_LTLIBRARIES = libvulkan_common.la
 libvulkan_common_la_SOURCES = $(VULKAN_SOURCES)
 
-VULKAN_LIB_DEPS += \
-   libvulkan_common.la \
-   $(top_builddir)/src/vulkan/libvulkan_util.la \
-   $(top_builddir)/src/vulkan/libvulkan_wsi.la \
-   $(top_builddir)/src/amd/common/libamd_common.la \
-   $(top_builddir)/src/amd/addrlib/libamdgpu_addrlib.la \
-   $(top_builddir)/src/compiler/nir/libnir.la \
-   $(top_builddir)/src/util/libmesautil.la \
-   $(LLVM_LIBS) \
-   $(LIBELF_LIBS) \
-   $(PTHREAD_LIBS) \
-   $(AMDGPU_LIBS) \
-   $(LIBDRM_LIBS) \
-   $(PTHREAD_LIBS) \
-   $(DLOPEN_LIBS) \
-   -lm
-
 nodist_EXTRA_libvulkan_radeon_la_SOURCES = dummy.cpp
 libvulkan_radeon_la_SOURCES = $(VULKAN_GEM_FILES)
 
-- 
2.12.2

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


Re: [Mesa-dev] [PATCH 2/2] i965: Enable ASTC HDR for Broxton

2017-05-19 Thread Anuj Phogat
On Thu, May 18, 2017 at 3:53 PM, Nanley Chery  wrote:
> This platform passes the following GLES3 tests:
> ES3-CTS.functional.texture.compressed.astc.endpoint_value_hdr_cem_*
>
We've hdr tests in piglit as well. With those passing, both patches are:
Reviewed-by: Anuj Phogat 

> Signed-off-by: Nanley Chery 
> ---
>  src/mesa/drivers/dri/i965/intel_extensions.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/src/mesa/drivers/dri/i965/intel_extensions.c 
> b/src/mesa/drivers/dri/i965/intel_extensions.c
> index 26c074638e..e76f61de1d 100644
> --- a/src/mesa/drivers/dri/i965/intel_extensions.c
> +++ b/src/mesa/drivers/dri/i965/intel_extensions.c
> @@ -285,6 +285,9 @@ intelInitExtensions(struct gl_context *ctx)
>ctx->Extensions.ARB_post_depth_coverage = true;
> }
>
> +   if (brw->is_broxton)
> +  ctx->Extensions.KHR_texture_compression_astc_hdr = true;
> +
> if (brw->gen >= 6)
>ctx->Extensions.INTEL_performance_query = true;
>
> --
> 2.12.2
>
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] Bug in 17.1.0-rc4 source packaging for swr?

2017-05-19 Thread Emil Velikov
On 19 May 2017 at 17:46, Rowley, Timothy O  wrote:
>
> > On May 19, 2017, at 10:26 AM, Emil Velikov  wrote:

> > The original idea by Tim sounds OK imho and I'm actually giving it a try.
> Are you referring to using a llvm-3.9 generated version?
Yes. Unless I've completely misinterpret and you had something else in mind.

> Did you envision
> me checking that in a gen_builder.h file,
Not sure where/how I hinted that - there should be no need for that.

> or removing the logic that omitted
> it from the tarball and somehow enforcing that a packaging build needs
> llvm-3.9?
>
This one here - patch is on the list. It should work until we can
think of a better solution.

> > FWIW the diff between 3.9 and 4.0 seems quite trivial - see below.
> > It should be possible to update the python scripts to handle most/all of
> > those.
> > Perhaps we can have this as a long term solution?
>
>
> At this point llvm seems to be stable in just having intrinsics being added;
> for a while there was some churn.  Unless/until the swr driver/rasterizer
> starts to take advantage of new llvm intrinsics, we should be fine using the
> 3.9 version.
>
What I was thinking is:
 - Parse through for required intrinsics/other and do not generate any
that are unused.

Perhaps it's too much hassle or even not possible? In that case,
forget I even mentioned it.

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


[Mesa-dev] [PATCH] automake: add SWR LLVM gen_builder.hpp workaround

2017-05-19 Thread Emil Velikov
From: Emil Velikov 

As gen_builder.hpp file is generated, it contains information that is
specific to the LLVM version it originates from.

As suggested by Tim, the file seems to be forwards compatible. So in
order to produce ship a file which will work everywhere we should be
using earlies supported LLVM - 3.9.

With this we're back on track and can build all of mesa without
python/mako/flex and friends.

In the long term we might want to see if the python generators can be
updated to produce LLVM version agnostic files. At least within the
range supported by SWR.

Cc: 
Cc: Chuck Atkins 
Cc: Tim Rowley 
Signed-off-by: Emil Velikov 
---
 configure.ac|  4 
 src/gallium/drivers/swr/Makefile.am | 41 ++---
 2 files changed, 15 insertions(+), 30 deletions(-)

diff --git a/configure.ac b/configure.ac
index ce5301f3e45..3d10a4b8935 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2472,6 +2472,10 @@ if test -n "$with_gallium_drivers"; then
 done
 fi
 
+# XXX: Keep in sync with LLVM_REQUIRED_SWR
+AM_CONDITIONAL(SWR_INVALID_LLVM_VERSION, test "x$LLVM_VERSION" != x3.9.0 -a \
+  "x$LLVM_VERSION" != x3.9.1)
+
 if test "x$enable_llvm" = "xyes" -a "$with_gallium_drivers"; then
 llvm_require_version $LLVM_REQUIRED_GALLIUM "gallium"
 llvm_add_default_components "gallium"
diff --git a/src/gallium/drivers/swr/Makefile.am 
b/src/gallium/drivers/swr/Makefile.am
index 0d71f52b1e6..7b2da074162 100644
--- a/src/gallium/drivers/swr/Makefile.am
+++ b/src/gallium/drivers/swr/Makefile.am
@@ -56,6 +56,7 @@ BUILT_SOURCES = \
rasterizer/codegen/gen_knobs.cpp \
rasterizer/codegen/gen_knobs.h \
rasterizer/jitter/gen_state_llvm.h \
+   rasterizer/jitter/gen_builder.hpp \
rasterizer/jitter/gen_builder_x86.hpp \
rasterizer/archrast/gen_ar_event.hpp \
rasterizer/archrast/gen_ar_event.cpp \
@@ -168,20 +169,6 @@ COMMON_LDFLAGS = \
$(LLVM_LDFLAGS)
 
 
-# XXX: As we cannot use BUILT_SOURCES (the files will end up in the dist
-# tarball) just annotate the dependency directly.
-# As the single direct user of gen_builder.hpp is a header (builder.h) trace 
all
-# the translusive users (one that use the latter header).
-rasterizer/jitter/blend_jit.cpp: rasterizer/jitter/gen_builder.hpp
-rasterizer/jitter/builder.cpp: rasterizer/jitter/gen_builder.hpp
-rasterizer/jitter/builder_misc.cpp: rasterizer/jitter/gen_builder.hpp
-rasterizer/jitter/fetch_jit.cpp: rasterizer/jitter/gen_builder.hpp
-rasterizer/jitter/streamout_jit.cpp: rasterizer/jitter/gen_builder.hpp
-swr_shader.cpp: rasterizer/jitter/gen_builder.hpp
-
-CLEANFILES = \
-   rasterizer/jitter/gen_builder.hpp
-
 lib_LTLIBRARIES = libswrAVX.la libswrAVX2.la
 
 libswrAVX_la_CXXFLAGS = \
@@ -192,14 +179,6 @@ libswrAVX_la_CXXFLAGS = \
 libswrAVX_la_SOURCES = \
$(COMMON_SOURCES)
 
-# XXX: Don't ship these generated sources for now, since they are specific
-# to the LLVM version they are generated from. Thus a release tarball
-# containing the said files, generated against eg. LLVM 3.8 will fail to build
-# on systems with other versions of LLVM eg. 3.7 or 3.6.
-# Move these back to BUILT_SOURCES once that is resolved.
-nodist_libswrAVX_la_SOURCES = \
-   rasterizer/jitter/gen_builder.hpp
-
 libswrAVX_la_LIBADD = \
$(COMMON_LIBADD)
 
@@ -214,14 +193,6 @@ libswrAVX2_la_CXXFLAGS = \
 libswrAVX2_la_SOURCES = \
$(COMMON_SOURCES)
 
-# XXX: Don't ship these generated sources for now, since they are specific
-# to the LLVM version they are generated from. Thus a release tarball
-# containing the said files, generated against eg. LLVM 3.8 will fail to build
-# on systems with other versions of LLVM eg. 3.7 or 3.6.
-# Move these back to BUILT_SOURCES once that is resolved.
-nodist_libswrAVX2_la_SOURCES = \
-   rasterizer/jitter/gen_builder.hpp
-
 libswrAVX2_la_LIBADD = \
$(COMMON_LIBADD)
 
@@ -230,6 +201,16 @@ libswrAVX2_la_LDFLAGS = \
 
 include $(top_srcdir)/install-gallium-links.mk
 
+# Generated gen_builder.hpp is not backwards compatible. So ship only one
+# created with the oldest supported version of LLVM.
+dist-hook:
+if SWR_INVALID_LLVM_VERSION
+   @echo "***"
+   @echo "LLVM 3.9.0 or LLVM 3.9.1 required to create the tarball"
+   @echo "***"
+   @test
+endif
+
 EXTRA_DIST = \
SConscript \
rasterizer/archrast/events.proto \
-- 
2.12.2

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


Re: [Mesa-dev] [PATCH] android: add -Wl, --build-id=sha1 to LDFLAGS for libvulkan_intel

2017-05-19 Thread Jason Ekstrand
Reviewed-by: Jason Ekstrand 

On Fri, May 19, 2017 at 4:25 AM, Tapani Pälli 
wrote:

> Just like is done on desktop and what is expected by the build-id code.
>
> Signed-off-by: Tapani Pälli 
> ---
>
> Jason, I commented before that this did not work but it seems I had other
> changes when testing that screwed up things, sorry for that, this works
> just fine!
>
>  src/intel/Android.vulkan.mk | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/src/intel/Android.vulkan.mk b/src/intel/Android.vulkan.mk
> index adb2a93..be23a00 100644
> --- a/src/intel/Android.vulkan.mk
> +++ b/src/intel/Android.vulkan.mk
> @@ -209,6 +209,8 @@ include $(CLEAR_VARS)
>  LOCAL_MODULE := libvulkan_intel
>  LOCAL_MODULE_CLASS := SHARED_LIBRARIES
>
> +LOCAL_LDFLAGS += -Wl,--build-id=sha1
> +
>  LOCAL_SRC_FILES := \
> $(VULKAN_GEM_FILES)
>
> --
> 2.9.3
>
>
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 1/9] mesa: Handle common extension checks with more compact code

2017-05-19 Thread Ilia Mirkin
On Fri, May 19, 2017 at 1:28 PM, Nanley Chery  wrote:
> The only thing I think may need
> addressing is endianness.

FYI, I'm happy to provide BE support, both reviewing code and testing.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 1/9] mesa: Handle common extension checks with more compact code

2017-05-19 Thread Nanley Chery
On Fri, May 19, 2017 at 06:38:03AM -0700, Ian Romanick wrote:
> From: Ian Romanick 
> 
> The previous code handled everything with the general case.  I noticed
> that every time I converted an open-coded check to use a
> _mesa_has_EXT_foo() function, the text size of the driver increased.
> 
> Almost all extensions only care what the current context API is, and
> the version does not matter.  Handle those using more compact checks.
> 
>text  data bss dec hex filename
> 7037675235248   37280 7310203  6f8b7b 32-bit i965_dri.so before
> 7034307235248   37280 7306835  6f7e53 32-bit i965_dri.so after
> 6679695303400   50608 7033703  6b5367 64-bit i965_dri.so before
> 6676143303400   50608 7030151  6b4587 64-bit i965_dri.so after
> 

Hi Ian,

I wrote a patch some time ago that reduces the cost of the extension
checks by a lot more with less code. The only thing I think may need
addressing is endianness. Would you consider using it instead if I
reworked it and sent it out to the list? You can find it here:
https://cgit.freedesktop.org/~nchery/mesa/commit/?h=1/ext/optimize=a02d88eba1d3129b27d3b5e6aaa976c3ca20cf79

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


Re: [Mesa-dev] [RFC PATCH 00/65] ARB_bindless_texture for RadeonSI

2017-05-19 Thread Samuel Pitoiset



On 05/19/2017 07:05 PM, Ilia Mirkin wrote:

Great work, Samuel! Is this available in a branch somewhere?


Thanks Ilia!

Here's the branch:
https://cgit.freedesktop.org/~hakzsam/mesa/log/?h=arb_bindless_texture



On Fri, May 19, 2017 at 12:52 PM, Samuel Pitoiset
 wrote:

Hi,

This series implements ARB_bindless_texture for RadeonSI.

Reminder: the GLSL compiler part is already upstream.

This series has been mainly tested with Feral games, here's the list of
existing games that use ARB_bindless_texture (though not by default):

- DXMD
- Hitman
- Dirt Rally
- Mad Max

Today, Feral announced "Warhammer 40,000: Dawn of War III" (called DOW3) which
is going to be released next month. This game *requires* ARB_bindless_texture,
that now explains why I did all this work. :-) So, we have ~3 weeks for merging
this whole series. It would be very nice to have DOW3 support at day one!

=== Tracking bindless problems ===

The following games have been successfully tested:

- Dirt Rally
- Hitman
- Mad Max
- DOW3

For these:

- No rendering issues
- No VM faults (ie. amdgpu.vm_debug=1)

However, DXMD is currently broken because the bindless_sampler layout qualifier
is missing, which ends up by reporting a ton of INVALID_OPERATION errors. Note
that Feral implemented bindless support against NV_bindless_texture and not
ARB_bindless_texture. The main difference is that bindless_sampler is implicit
for NV_* while it's required for ARB_*. Feral plan to fix this soon.

All ARB_bindless_texture piglit tests pass with this series.

=== Tracking regressions/changes ===

- No regressions with the Intel CI system
- One piglit regression that needs to be fixed
   (arb_texture_multisample-sample-position)
- No shader-db changes
- No CPU overhead (glxgears and Heaven in low)

=== Performance results for DOW3 ===

DOW3 exposes two bindless texture modes:
- mode 1: all bindless (ie. no bound samplers)
- mode 2: bound/bindless (ie. only bindless when the limit is reached)

CPU: Intel(R) Core(TM) i5-4460  CPU @ 3.20GHz
NVIDIA blob: 381.22

== GTX 1060 ==

LOW:
  - mode 1: 89 FPS
  - mode 2: 51 FPS

MEDIUM:
  - mode 1: 49 FPS
  - mode 2: 28 FPS

HIGH:
  - mode 1: 32 FPS
  - mode 2: 19 FPS

The GTX 1060 performs very well with the all bindless mode (default), while
the bound/bindless mode is not good at all.

== RX480 ==

LOW:
  - mode 1: 67 FPS (-32%)
  - mode 2: 75 FPS (+32%)

MEDIUM:
  - mode 1: 38 FPS (-28%)
  - mode 2: 44 FPS (+57%)

HIGH:
  - mode 1: 26 FPS (-23%)
  - mode 2: 29 FPS (+52%)

The RX 480 performs very well with the bound/bindless mode (default), while
the all bindless mode still has to be improved.

The most important bottleneck with the all bindless mode is the number of
buffers that have to be added for every command stream. The overhead in the
winsys and in the kernel (amdgpu_cs_ioctl) becomes important in this situation.
This mode is still clearly CPU bound and should be improved (see the "Future
work" section).

Btw, without any optimisations, it was around 35FPS in low (mode 1).

=== Performance results for other Feral titles ===

I didn't record any numbers because these games have been initially
developed/tested against the NVIDIA blob which it's unaffected by a VERY huge
number of resident handles. While the AMD stack is really slow in this
situation. Though, as I said, all Feral games that use bindless work fine, we
just need to improve perf on both sides.

=== Future work ===

I have some ideas to try in order to improve performance with RadeonSI. I will
work on this once this series is upstream.

Please review,
Thanks!

Samuel Pitoiset (65):
   mapi: add GL_ARB_bindless_texture entry points
   mesa: implement ARB_bindless_texture
   mesa: add support for unsigned 64-bit vertex attributes
   mesa: add support for glUniformHandleui64*ARB()
   mesa: refuse to update sampler parameters when a handle is allocated
   mesa: refuse to update tex parameters when a handle is allocated
   mesa: refuse to change textures when a handle is allocated
   mesa: refuse to change tex buffers when a handle is allocated
   mesa: keep track of the current variable in add_uniform_to_shader
   mesa: store bindless samplers as PROGRAM_UNIFORM
   mesa: add infrastructure for bindless samplers/images bound to units
   glsl: process uniform samplers declared bindless
   glsl: process uniform images declared bindless
   glsl: pass the ir_variable object to set_opaque_binding()
   glsl: set the explicit binding value for bindless samplers/images
   glsl: add ir_variable::is_bindless()
   mesa: add update_single_shader_texture_used() helper
   mesa: add update_single_program_texture_state() helper
   mesa: update textures for bindless samplers bound to texture units
   mesa: pass gl_program to _mesa_associate_uniform_storage()
   mesa: associate uniform storage to bindless samplers/images
   mesa: handle bindless uniforms bound to texture/image units
   mesa: get rid of a workaround for bindless in 

Re: [Mesa-dev] [RFC PATCH 00/65] ARB_bindless_texture for RadeonSI

2017-05-19 Thread Ilia Mirkin
Great work, Samuel! Is this available in a branch somewhere?

On Fri, May 19, 2017 at 12:52 PM, Samuel Pitoiset
 wrote:
> Hi,
>
> This series implements ARB_bindless_texture for RadeonSI.
>
> Reminder: the GLSL compiler part is already upstream.
>
> This series has been mainly tested with Feral games, here's the list of
> existing games that use ARB_bindless_texture (though not by default):
>
> - DXMD
> - Hitman
> - Dirt Rally
> - Mad Max
>
> Today, Feral announced "Warhammer 40,000: Dawn of War III" (called DOW3) which
> is going to be released next month. This game *requires* ARB_bindless_texture,
> that now explains why I did all this work. :-) So, we have ~3 weeks for 
> merging
> this whole series. It would be very nice to have DOW3 support at day one!
>
> === Tracking bindless problems ===
>
> The following games have been successfully tested:
>
> - Dirt Rally
> - Hitman
> - Mad Max
> - DOW3
>
> For these:
>
> - No rendering issues
> - No VM faults (ie. amdgpu.vm_debug=1)
>
> However, DXMD is currently broken because the bindless_sampler layout 
> qualifier
> is missing, which ends up by reporting a ton of INVALID_OPERATION errors. Note
> that Feral implemented bindless support against NV_bindless_texture and not
> ARB_bindless_texture. The main difference is that bindless_sampler is implicit
> for NV_* while it's required for ARB_*. Feral plan to fix this soon.
>
> All ARB_bindless_texture piglit tests pass with this series.
>
> === Tracking regressions/changes ===
>
> - No regressions with the Intel CI system
> - One piglit regression that needs to be fixed
>   (arb_texture_multisample-sample-position)
> - No shader-db changes
> - No CPU overhead (glxgears and Heaven in low)
>
> === Performance results for DOW3 ===
>
> DOW3 exposes two bindless texture modes:
> - mode 1: all bindless (ie. no bound samplers)
> - mode 2: bound/bindless (ie. only bindless when the limit is reached)
>
> CPU: Intel(R) Core(TM) i5-4460  CPU @ 3.20GHz
> NVIDIA blob: 381.22
>
> == GTX 1060 ==
>
> LOW:
>  - mode 1: 89 FPS
>  - mode 2: 51 FPS
>
> MEDIUM:
>  - mode 1: 49 FPS
>  - mode 2: 28 FPS
>
> HIGH:
>  - mode 1: 32 FPS
>  - mode 2: 19 FPS
>
> The GTX 1060 performs very well with the all bindless mode (default), while
> the bound/bindless mode is not good at all.
>
> == RX480 ==
>
> LOW:
>  - mode 1: 67 FPS (-32%)
>  - mode 2: 75 FPS (+32%)
>
> MEDIUM:
>  - mode 1: 38 FPS (-28%)
>  - mode 2: 44 FPS (+57%)
>
> HIGH:
>  - mode 1: 26 FPS (-23%)
>  - mode 2: 29 FPS (+52%)
>
> The RX 480 performs very well with the bound/bindless mode (default), while
> the all bindless mode still has to be improved.
>
> The most important bottleneck with the all bindless mode is the number of
> buffers that have to be added for every command stream. The overhead in the
> winsys and in the kernel (amdgpu_cs_ioctl) becomes important in this 
> situation.
> This mode is still clearly CPU bound and should be improved (see the "Future
> work" section).
>
> Btw, without any optimisations, it was around 35FPS in low (mode 1).
>
> === Performance results for other Feral titles ===
>
> I didn't record any numbers because these games have been initially
> developed/tested against the NVIDIA blob which it's unaffected by a VERY huge
> number of resident handles. While the AMD stack is really slow in this
> situation. Though, as I said, all Feral games that use bindless work fine, we
> just need to improve perf on both sides.
>
> === Future work ===
>
> I have some ideas to try in order to improve performance with RadeonSI. I will
> work on this once this series is upstream.
>
> Please review,
> Thanks!
>
> Samuel Pitoiset (65):
>   mapi: add GL_ARB_bindless_texture entry points
>   mesa: implement ARB_bindless_texture
>   mesa: add support for unsigned 64-bit vertex attributes
>   mesa: add support for glUniformHandleui64*ARB()
>   mesa: refuse to update sampler parameters when a handle is allocated
>   mesa: refuse to update tex parameters when a handle is allocated
>   mesa: refuse to change textures when a handle is allocated
>   mesa: refuse to change tex buffers when a handle is allocated
>   mesa: keep track of the current variable in add_uniform_to_shader
>   mesa: store bindless samplers as PROGRAM_UNIFORM
>   mesa: add infrastructure for bindless samplers/images bound to units
>   glsl: process uniform samplers declared bindless
>   glsl: process uniform images declared bindless
>   glsl: pass the ir_variable object to set_opaque_binding()
>   glsl: set the explicit binding value for bindless samplers/images
>   glsl: add ir_variable::is_bindless()
>   mesa: add update_single_shader_texture_used() helper
>   mesa: add update_single_program_texture_state() helper
>   mesa: update textures for bindless samplers bound to texture units
>   mesa: pass gl_program to _mesa_associate_uniform_storage()
>   mesa: associate uniform storage to bindless samplers/images
>   mesa: handle bindless uniforms bound to texture/image 

[Mesa-dev] [RFC PATCH 44/65] st/mesa: make bindless samplers/images bound to units resident

2017-05-19 Thread Samuel Pitoiset
Signed-off-by: Samuel Pitoiset 
---
 src/mesa/state_tracker/st_atom_constbuf.c |  6 ++
 src/mesa/state_tracker/st_texture.c   | 94 +++
 src/mesa/state_tracker/st_texture.h   |  8 +++
 3 files changed, 108 insertions(+)

diff --git a/src/mesa/state_tracker/st_atom_constbuf.c 
b/src/mesa/state_tracker/st_atom_constbuf.c
index 0c66994066..e4b585101d 100644
--- a/src/mesa/state_tracker/st_atom_constbuf.c
+++ b/src/mesa/state_tracker/st_atom_constbuf.c
@@ -80,6 +80,12 @@ void st_upload_constants(struct st_context *st, struct 
gl_program *prog)
   }
}
 
+   /* Make all bindless samplers/images bound texture/image units resident in
+* the context.
+*/
+   st_make_bound_samplers_resident(st, prog);
+   st_make_bound_images_resident(st, prog);
+
/* update constants */
if (params && params->NumParameters) {
   struct pipe_constant_buffer cb;
diff --git a/src/mesa/state_tracker/st_texture.c 
b/src/mesa/state_tracker/st_texture.c
index cde7759a61..74704b5c87 100644
--- a/src/mesa/state_tracker/st_texture.c
+++ b/src/mesa/state_tracker/st_texture.c
@@ -539,3 +539,97 @@ st_create_image_handle_from_unit(struct st_context *st,
 
return pipe->create_image_handle(pipe, );
 }
+
+
+/**
+ * Make all bindless samplers bound to texture units resident in the context.
+ */
+void
+st_make_bound_samplers_resident(struct st_context *st,
+struct gl_program *prog)
+{
+   enum pipe_shader_type shader = st_shader_stage_to_ptarget(prog->info.stage);
+   struct st_bound_handle *bound_handles = >bound_texture_handles[shader];
+   struct pipe_context *pipe = st->pipe;
+   GLuint64 handle;
+   int i;
+
+   /* Remove previous bound texture handles for this stage. */
+   st_destroy_bound_texture_handles_per_stage(st, shader);
+
+   if (likely(!prog->sh.HasBoundBindlessSampler))
+  return;
+
+   for (i = 0; i < prog->sh.NumBindlessSamplers; i++) {
+  struct gl_bindless_sampler *sampler = >sh.BindlessSamplers[i];
+
+  if (!sampler->bound)
+ continue;
+
+  /* Request a new texture handle from the driver and make it resident. */
+  handle = st_create_texture_handle_from_unit(st, prog, sampler->unit);
+  if (!handle)
+ continue;
+
+  pipe->make_texture_handle_resident(st->pipe, handle, true);
+
+  /* Overwrite the texture unit value by the resident handle before
+   * uploading the constant buffer.
+   */
+  *(uint64_t *)sampler->data = handle;
+
+  /* Store the handle in the context. */
+  bound_handles->handles = (uint64_t *)
+ realloc(bound_handles->handles,
+ (bound_handles->num_handles + 1) * sizeof(uint64_t));
+  bound_handles->handles[bound_handles->num_handles] = handle;
+  bound_handles->num_handles++;
+   }
+}
+
+
+/**
+ * Make all bindless images bound to image units resident in the context.
+ */
+void
+st_make_bound_images_resident(struct st_context *st,
+  struct gl_program *prog)
+{
+   enum pipe_shader_type shader = st_shader_stage_to_ptarget(prog->info.stage);
+   struct st_bound_handle *bound_handles = >bound_image_handles[shader];
+   struct pipe_context *pipe = st->pipe;
+   GLuint64 handle;
+   int i;
+
+   /* Remove previous bound image handles for this stage. */
+   st_destroy_bound_image_handles_per_stage(st, shader);
+
+   if (likely(!prog->sh.HasBoundBindlessImage))
+  return;
+
+   for (i = 0; i < prog->sh.NumBindlessImages; i++) {
+  struct gl_bindless_image *image = >sh.BindlessImages[i];
+
+  if (!image->bound)
+ continue;
+
+  /* Request a new image handle from the driver and make it resident. */
+  handle = st_create_image_handle_from_unit(st, prog, image->unit);
+  if (!handle)
+ continue;
+
+  pipe->make_image_handle_resident(st->pipe, handle, GL_READ_WRITE, true);
+
+  /* Overwrite the image unit value by the resident handle before uploading
+   * the constant buffer.
+   */
+  *(uint64_t *)image->data = handle;
+
+  /* Store the handle in the context. */
+  bound_handles->handles = (uint64_t *)
+ realloc(bound_handles->handles,
+ (bound_handles->num_handles + 1) * sizeof(uint64_t));
+  bound_handles->handles[bound_handles->num_handles] = handle;
+  bound_handles->num_handles++;
+   }
+}
diff --git a/src/mesa/state_tracker/st_texture.h 
b/src/mesa/state_tracker/st_texture.h
index b97814cb16..c9b778bcb6 100644
--- a/src/mesa/state_tracker/st_texture.h
+++ b/src/mesa/state_tracker/st_texture.h
@@ -284,4 +284,12 @@ st_update_single_texture(struct st_context *st,
  struct pipe_sampler_view **sampler_view,
  GLuint texUnit, unsigned glsl_version);
 
+void
+st_make_bound_samplers_resident(struct st_context *st,
+struct gl_program *prog);
+
+void
+st_make_bound_images_resident(struct st_context 

[Mesa-dev] [RFC PATCH 18/65] mesa: add update_single_program_texture_state() helper

2017-05-19 Thread Samuel Pitoiset
This will also be used for looping over bindless samplers bound
to texture units.

Signed-off-by: Samuel Pitoiset 
---
 src/mesa/main/texstate.c | 36 +++-
 1 file changed, 23 insertions(+), 13 deletions(-)

diff --git a/src/mesa/main/texstate.c b/src/mesa/main/texstate.c
index 1aac3cdbd8..4fd853f386 100644
--- a/src/mesa/main/texstate.c
+++ b/src/mesa/main/texstate.c
@@ -612,15 +612,13 @@ update_texgen(struct gl_context *ctx)
 
 static struct gl_texture_object *
 update_single_program_texture(struct gl_context *ctx, struct gl_program *prog,
-  int s)
+  int unit)
 {
gl_texture_index target_index;
struct gl_texture_unit *texUnit;
struct gl_texture_object *texObj;
struct gl_sampler_object *sampler;
-   int unit;
 
-   unit = prog->SamplerUnits[s];
texUnit = >Texture.Unit[unit];
 
/* Note: If more than one bit was set in TexturesUsed[unit], then we should
@@ -666,6 +664,24 @@ update_single_program_texture(struct gl_context *ctx, 
struct gl_program *prog,
return texObj;
 }
 
+static inline void
+update_single_program_texture_state(struct gl_context *ctx,
+struct gl_program *prog,
+int unit,
+BITSET_WORD *enabled_texture_units)
+{
+   struct gl_texture_object *texObj;
+
+   texObj = update_single_program_texture(ctx, prog, unit);
+   if (!texObj)
+  return;
+
+   _mesa_reference_texobj(>Texture.Unit[unit]._Current, texObj);
+   BITSET_SET(enabled_texture_units, unit);
+   ctx->Texture._MaxEnabledTexImageUnit =
+  MAX2(ctx->Texture._MaxEnabledTexImageUnit, (int)unit);
+}
+
 static void
 update_program_texture_state(struct gl_context *ctx, struct gl_program **prog,
  BITSET_WORD *enabled_texture_units)
@@ -682,16 +698,10 @@ update_program_texture_state(struct gl_context *ctx, 
struct gl_program **prog,
 
   while (mask) {
  const int s = u_bit_scan();
- struct gl_texture_object *texObj;
-
- texObj = update_single_program_texture(ctx, prog[i], s);
- if (texObj) {
-int unit = prog[i]->SamplerUnits[s];
-_mesa_reference_texobj(>Texture.Unit[unit]._Current, texObj);
-BITSET_SET(enabled_texture_units, unit);
-ctx->Texture._MaxEnabledTexImageUnit =
-   MAX2(ctx->Texture._MaxEnabledTexImageUnit, (int)unit);
- }
+
+ update_single_program_texture_state(ctx, prog[i],
+ prog[i]->SamplerUnits[s],
+ enabled_texture_units);
   }
}
 
-- 
2.13.0

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


[Mesa-dev] [RFC PATCH 50/65] radeonsi: add si_set_sampler_view_desc() helper

2017-05-19 Thread Samuel Pitoiset
To share some common code between bound and bindless textures.

Signed-off-by: Samuel Pitoiset 
---
 src/gallium/drivers/radeonsi/si_descriptors.c | 95 +++
 1 file changed, 52 insertions(+), 43 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_descriptors.c 
b/src/gallium/drivers/radeonsi/si_descriptors.c
index b2fe6a3de7..e73dbc9f9f 100644
--- a/src/gallium/drivers/radeonsi/si_descriptors.c
+++ b/src/gallium/drivers/radeonsi/si_descriptors.c
@@ -488,6 +488,54 @@ void si_set_mutable_tex_desc_fields(struct si_screen 
*sscreen,
}
 }
 
+static void si_set_sampler_view_desc(struct si_context *sctx,
+struct si_sampler_view *sview,
+struct si_sampler_state *sstate,
+uint32_t *desc)
+{
+   struct pipe_sampler_view *view = >base;
+   struct r600_texture *rtex = (struct r600_texture *)view->texture;
+   bool is_buffer = rtex->resource.b.b.target == PIPE_BUFFER;
+
+   if (unlikely(!is_buffer && sview->dcc_incompatible)) {
+   if (vi_dcc_enabled(rtex, view->u.tex.first_level))
+   if (!r600_texture_disable_dcc(>b, rtex))
+   sctx->b.decompress_dcc(>b.b, rtex);
+
+   sview->dcc_incompatible = false;
+   }
+
+   assert(rtex); /* views with texture == NULL aren't supported */
+   memcpy(desc, sview->state, 8*4);
+
+   if (is_buffer) {
+   si_set_buf_desc_address(>resource,
+   sview->base.u.buf.offset,
+   desc + 4);
+   } else {
+   bool is_separate_stencil = rtex->db_compatible &&
+  sview->is_stencil_sampler;
+
+   si_set_mutable_tex_desc_fields(sctx->screen, rtex,
+  sview->base_level_info,
+  sview->base_level,
+  sview->base.u.tex.first_level,
+  sview->block_width,
+  is_separate_stencil,
+  desc);
+   }
+
+   if (!is_buffer && rtex->fmask.size) {
+   memcpy(desc + 8, sview->fmask_state, 8*4);
+   } else {
+   /* Disable FMASK and bind sampler state in [12:15]. */
+   memcpy(desc + 8, null_texture_descriptor, 4*4);
+
+   if (sstate)
+   memcpy(desc + 12, sstate->val, 4*4);
+   }
+}
+
 static void si_set_sampler_view(struct si_context *sctx,
unsigned shader,
unsigned slot, struct pipe_sampler_view *view,
@@ -504,53 +552,14 @@ static void si_set_sampler_view(struct si_context *sctx,
 
if (view) {
struct r600_texture *rtex = (struct r600_texture 
*)view->texture;
-   bool is_buffer = rtex->resource.b.b.target == PIPE_BUFFER;
-
-   if (unlikely(!is_buffer && rview->dcc_incompatible)) {
-   if (vi_dcc_enabled(rtex, view->u.tex.first_level))
-   if (!r600_texture_disable_dcc(>b, rtex))
-   sctx->b.decompress_dcc(>b.b, 
rtex);
 
-   rview->dcc_incompatible = false;
-   }
+   si_set_sampler_view_desc(sctx, rview,
+views->sampler_states[slot], desc);
 
-   assert(rtex); /* views with texture == NULL aren't supported */
-   pipe_sampler_view_reference(>views[slot], view);
-   memcpy(desc, rview->state, 8*4);
-
-   if (is_buffer) {
+   if (rtex->resource.b.b.target == PIPE_BUFFER)
rtex->resource.bind_history |= PIPE_BIND_SAMPLER_VIEW;
 
-   si_set_buf_desc_address(>resource,
-   view->u.buf.offset,
-   desc + 4);
-   } else {
-   bool is_separate_stencil =
-   rtex->db_compatible &&
-   rview->is_stencil_sampler;
-
-   si_set_mutable_tex_desc_fields(sctx->screen, rtex,
-  rview->base_level_info,
-  rview->base_level,
-  
rview->base.u.tex.first_level,
-  rview->block_width,
-  is_separate_stencil,
-  desc);
-   }
-
-   if (!is_buffer && rtex->fmask.size) {
-   

[Mesa-dev] [RFC PATCH 60/65] radeonsi: only decompress resident textures/images when used

2017-05-19 Thread Samuel Pitoiset
When current bound shaders don't use any bindless textures or
images, we shouldn't try to decompress the resident resources.

Signed-off-by: Samuel Pitoiset 
---
 src/gallium/drivers/radeonsi/si_blit.c | 12 
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_blit.c 
b/src/gallium/drivers/radeonsi/si_blit.c
index 0cf3ea79b9..299a52a0da 100644
--- a/src/gallium/drivers/radeonsi/si_blit.c
+++ b/src/gallium/drivers/radeonsi/si_blit.c
@@ -773,8 +773,10 @@ void si_decompress_graphics_textures(struct si_context 
*sctx)
 
si_decompress_textures(sctx, u_bit_consecutive(0, 
SI_NUM_GRAPHICS_SHADERS));
 
-   si_decompress_resident_textures(sctx);
-   si_decompress_resident_images(sctx);
+   if (si_graphics_uses_bindless_samplers(sctx))
+   si_decompress_resident_textures(sctx);
+   if (si_graphics_uses_bindless_images(sctx))
+   si_decompress_resident_images(sctx);
 }
 
 void si_decompress_compute_textures(struct si_context *sctx)
@@ -784,8 +786,10 @@ void si_decompress_compute_textures(struct si_context 
*sctx)
 
si_decompress_textures(sctx, 1 << PIPE_SHADER_COMPUTE);
 
-   si_decompress_resident_textures(sctx);
-   si_decompress_resident_images(sctx);
+   if (si_compute_uses_bindless_samplers(sctx))
+   si_decompress_resident_textures(sctx);
+   if (si_compute_uses_bindless_images(sctx))
+   si_decompress_resident_images(sctx);
 }
 
 static void si_clear(struct pipe_context *ctx, unsigned buffers,
-- 
2.13.0

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


[Mesa-dev] [RFC PATCH 25/65] gallium: add ARB_bindless_texture interface

2017-05-19 Thread Samuel Pitoiset
Signed-off-by: Samuel Pitoiset 
---
 src/gallium/include/pipe/p_context.h | 16 
 1 file changed, 16 insertions(+)

diff --git a/src/gallium/include/pipe/p_context.h 
b/src/gallium/include/pipe/p_context.h
index 4b75386a65..83eb1c9b08 100644
--- a/src/gallium/include/pipe/p_context.h
+++ b/src/gallium/include/pipe/p_context.h
@@ -766,6 +766,22 @@ struct pipe_context {
   unsigned last_level,
   unsigned first_layer,
   unsigned last_layer);
+
+   /**
+* Bindless texture/image handles interface.
+*/
+   uint64_t (*create_texture_handle)(struct pipe_context *ctx,
+ struct pipe_resource *res,
+ struct pipe_sampler_view *view,
+ const struct pipe_sampler_state *state);
+   void (*delete_texture_handle)(struct pipe_context *ctx, uint64_t handle);
+   void (*make_texture_handle_resident)(struct pipe_context *ctx,
+uint64_t handle, bool resident);
+   uint64_t (*create_image_handle)(struct pipe_context *ctx,
+   const struct pipe_image_view *image);
+   void (*delete_image_handle)(struct pipe_context *ctx, uint64_t handle);
+   void (*make_image_handle_resident)(struct pipe_context *ctx, uint64_t 
handle,
+  unsigned access, bool resident);
 };
 
 
-- 
2.13.0

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


[Mesa-dev] [RFC PATCH 61/65] radeonsi: upload new descriptors when resident buffers are invalidated

2017-05-19 Thread Samuel Pitoiset
When texture buffers are invalidated the addr in the resident
descriptor has to be updated but we can't create a new descriptor
because the resident handle has to be the same.

Instead, use the WRITE_DATA packet which allows to update memory
directly but graphics/compute have to be idle in case the GPU is
reading the descriptor.

Signed-off-by: Samuel Pitoiset 
---
 src/gallium/drivers/radeon/r600_pipe_common.h |   4 +
 src/gallium/drivers/radeonsi/si_descriptors.c | 121 ++
 src/gallium/drivers/radeonsi/si_pipe.h|   3 +
 3 files changed, 128 insertions(+)

diff --git a/src/gallium/drivers/radeon/r600_pipe_common.h 
b/src/gallium/drivers/radeon/r600_pipe_common.h
index b17b690fab..6c4df2e733 100644
--- a/src/gallium/drivers/radeon/r600_pipe_common.h
+++ b/src/gallium/drivers/radeon/r600_pipe_common.h
@@ -181,6 +181,10 @@ struct r600_resource {
 
/* Whether the resource has been exported via resource_get_handle. */
unsignedexternal_usage; /* PIPE_HANDLE_USAGE_* 
*/
+
+   /* Whether this resource is referenced by bindless handles. */
+   booltexture_handle_allocated;
+   boolimage_handle_allocated;
 };
 
 struct r600_transfer {
diff --git a/src/gallium/drivers/radeonsi/si_descriptors.c 
b/src/gallium/drivers/radeonsi/si_descriptors.c
index 05559d90d7..6adad06757 100644
--- a/src/gallium/drivers/radeonsi/si_descriptors.c
+++ b/src/gallium/drivers/radeonsi/si_descriptors.c
@@ -1849,6 +1849,55 @@ static void si_rebind_buffer(struct pipe_context *ctx, 
struct pipe_resource *buf
}
}
}
+
+   /* Bindless texture handles */
+   if (rbuffer->texture_handle_allocated) {
+   for (i = 0; i < sctx->num_resident_tex_handles; i++) {
+   struct si_texture_handle *tex_handle =
+   sctx->resident_tex_handles[i];
+   struct si_sampler_view *sview = tex_handle->view;
+   struct si_resident_descriptor *desc = tex_handle->desc;
+
+   if (sview->base.texture == buf) {
+   si_set_buf_desc_address(rbuffer,
+   
sview->base.u.buf.offset,
+   >desc_list[4]);
+   desc->dirty = true;
+   sctx->resident_descriptors_dirty = true;
+
+   radeon_add_to_buffer_list_check_mem(
+   >b, >b.gfx, rbuffer,
+   RADEON_USAGE_READ,
+   RADEON_PRIO_SAMPLER_BUFFER, true);
+   }
+   }
+   }
+
+   /* Bindless image handles */
+   if (rbuffer->image_handle_allocated) {
+   for (i = 0; i < sctx->num_resident_img_handles; i++) {
+   struct si_image_handle *img_handle =
+   sctx->resident_img_handles[i];
+   struct pipe_image_view *view = _handle->view;
+   struct si_resident_descriptor *desc = img_handle->desc;
+
+   if (view->resource == buf) {
+   if (view->access & PIPE_IMAGE_ACCESS_WRITE)
+   si_mark_image_range_valid(view);
+
+   si_set_buf_desc_address(rbuffer,
+   view->u.buf.offset,
+   >desc_list[4]);
+   desc->dirty = true;
+   sctx->resident_descriptors_dirty = true;
+
+   radeon_add_to_buffer_list_check_mem(
+   >b, >b.gfx, rbuffer,
+   RADEON_USAGE_READWRITE,
+   RADEON_PRIO_SAMPLER_BUFFER, true);
+   }
+   }
+   }
 }
 
 /* Reallocate a buffer a update all resource bindings where the buffer is
@@ -2365,6 +2414,8 @@ si_create_resident_descriptor(struct si_context *sctx, 
uint32_t *desc_list,
util_memcpy_cpu_to_le32(ptr + desc->offset, desc_list, size);
sscreen->b.ws->buffer_unmap(desc->buffer->buf);
 
+   memcpy(desc->desc_list, desc_list, sizeof(desc->desc_list));
+
return desc;
 }
 
@@ -2415,6 +2466,8 @@ static uint64_t si_create_texture_handle(struct 
pipe_context *ctx,
return 0;
}
 
+   r600_resource(sview->base.texture)->texture_handle_allocated = true;
+
return handle;
 }
 
@@ -2521,6 +2574,8 @@ static uint64_t si_create_image_handle(struct 
pipe_context *ctx,
return 0;
}
 
+   

[Mesa-dev] [RFC PATCH 39/65] st/mesa: make update_single_texture() non-static

2017-05-19 Thread Samuel Pitoiset
Signed-off-by: Samuel Pitoiset 
---
 src/mesa/state_tracker/st_atom_texture.c | 15 +--
 src/mesa/state_tracker/st_texture.h  |  5 +
 2 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/src/mesa/state_tracker/st_atom_texture.c 
b/src/mesa/state_tracker/st_atom_texture.c
index a99bc1a188..f9d726a609 100644
--- a/src/mesa/state_tracker/st_atom_texture.c
+++ b/src/mesa/state_tracker/st_atom_texture.c
@@ -52,10 +52,13 @@
 #include "cso_cache/cso_context.h"
 
 
-static GLboolean
-update_single_texture(struct st_context *st,
-  struct pipe_sampler_view **sampler_view,
- GLuint texUnit, unsigned glsl_version)
+/**
+ * Get a pipe_sampler_view object from a texture unit.
+ */
+GLboolean
+st_update_single_texture(struct st_context *st,
+ struct pipe_sampler_view **sampler_view,
+ GLuint texUnit, unsigned glsl_version)
 {
struct gl_context *ctx = st->ctx;
const struct gl_sampler_object *samp;
@@ -129,8 +132,8 @@ update_textures(struct st_context *st,
  const GLuint texUnit = prog->SamplerUnits[unit];
  GLboolean retval;
 
- retval = update_single_texture(st, _view, texUnit,
-glsl_version);
+ retval = st_update_single_texture(st, _view, texUnit,
+   glsl_version);
  if (retval == GL_FALSE)
 continue;
 
diff --git a/src/mesa/state_tracker/st_texture.h 
b/src/mesa/state_tracker/st_texture.h
index 1b4d1a3ea2..8eb0b4be47 100644
--- a/src/mesa/state_tracker/st_texture.h
+++ b/src/mesa/state_tracker/st_texture.h
@@ -264,4 +264,9 @@ st_convert_sampler(const struct st_context *st,
const struct gl_sampler_object *msamp,
struct pipe_sampler_state *sampler);
 
+GLboolean
+st_update_single_texture(struct st_context *st,
+ struct pipe_sampler_view **sampler_view,
+ GLuint texUnit, unsigned glsl_version);
+
 #endif
-- 
2.13.0

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


[Mesa-dev] [RFC PATCH 37/65] tgsi/scan: record bindless samplers/images usage

2017-05-19 Thread Samuel Pitoiset
Signed-off-by: Samuel Pitoiset 
---
 src/gallium/auxiliary/tgsi/tgsi_scan.c | 37 ++
 src/gallium/auxiliary/tgsi/tgsi_scan.h |  2 ++
 2 files changed, 39 insertions(+)

diff --git a/src/gallium/auxiliary/tgsi/tgsi_scan.c 
b/src/gallium/auxiliary/tgsi/tgsi_scan.c
index d1ef769ec4..d9c8db7c78 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_scan.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_scan.c
@@ -367,6 +367,43 @@ scan_instruction(struct tgsi_shader_info *info,
case TGSI_OPCODE_ENDLOOP:
   (*current_depth)--;
   break;
+   case TGSI_OPCODE_TEX:
+   case TGSI_OPCODE_TEX_LZ:
+   case TGSI_OPCODE_TXB:
+   case TGSI_OPCODE_TXD:
+   case TGSI_OPCODE_TXL:
+   case TGSI_OPCODE_TXP:
+   case TGSI_OPCODE_TXQ:
+   case TGSI_OPCODE_TXQS:
+   case TGSI_OPCODE_TXF:
+   case TGSI_OPCODE_TXF_LZ:
+   case TGSI_OPCODE_TEX2:
+   case TGSI_OPCODE_TXB2:
+   case TGSI_OPCODE_TXL2:
+   case TGSI_OPCODE_TG4:
+   case TGSI_OPCODE_LODQ:
+  if (fullinst->Texture.Bindless)
+ info->uses_bindless_samplers = true;
+  break;
+   case TGSI_OPCODE_RESQ:
+   case TGSI_OPCODE_LOAD:
+   case TGSI_OPCODE_ATOMUADD:
+   case TGSI_OPCODE_ATOMXCHG:
+   case TGSI_OPCODE_ATOMCAS:
+   case TGSI_OPCODE_ATOMAND:
+   case TGSI_OPCODE_ATOMOR:
+   case TGSI_OPCODE_ATOMXOR:
+   case TGSI_OPCODE_ATOMUMIN:
+   case TGSI_OPCODE_ATOMUMAX:
+   case TGSI_OPCODE_ATOMIMIN:
+   case TGSI_OPCODE_ATOMIMAX:
+  if (fullinst->Memory.Bindless)
+ info->uses_bindless_images = true;
+  break;
+   case TGSI_OPCODE_STORE:
+  if (fullinst->Memory.Bindless)
+ info->uses_bindless_images = true;
+  break;
default:
   break;
}
diff --git a/src/gallium/auxiliary/tgsi/tgsi_scan.h 
b/src/gallium/auxiliary/tgsi/tgsi_scan.h
index 98387c982c..473a0b6568 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_scan.h
+++ b/src/gallium/auxiliary/tgsi/tgsi_scan.h
@@ -135,6 +135,8 @@ struct tgsi_shader_info
boolean is_msaa_sampler[PIPE_MAX_SAMPLERS];
boolean uses_doubles; /**< uses any of the double instructions */
boolean uses_derivatives;
+   boolean uses_bindless_samplers;
+   boolean uses_bindless_images;
unsigned clipdist_writemask;
unsigned culldist_writemask;
unsigned num_written_culldistance;
-- 
2.13.0

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


[Mesa-dev] [RFC PATCH 65/65] radeonsi: enable ARB_bindless_texture

2017-05-19 Thread Samuel Pitoiset
This has only been tested on RX480.

Signed-off-by: Samuel Pitoiset 
---
 docs/features.txt  | 2 +-
 docs/relnotes/17.2.0.html  | 1 +
 src/gallium/drivers/radeonsi/si_pipe.c | 4 +++-
 3 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/docs/features.txt b/docs/features.txt
index e18bf54a48..bbf81d45f0 100644
--- a/docs/features.txt
+++ b/docs/features.txt
@@ -277,7 +277,7 @@ GLES3.2, GLSL ES 3.2 -- all DONE: i965/gen9+
 
 Khronos, ARB, and OES extensions that are not part of any OpenGL or OpenGL ES 
version:
 
-  GL_ARB_bindless_texture   started (airlied)
+  GL_ARB_bindless_texture   DONE (radeonsi)
   GL_ARB_cl_event   not started
   GL_ARB_compute_variable_group_sizeDONE (nvc0, radeonsi)
   GL_ARB_ES3_2_compatibilityDONE (i965/gen8+)
diff --git a/docs/relnotes/17.2.0.html b/docs/relnotes/17.2.0.html
index 426bb72a51..4561451186 100644
--- a/docs/relnotes/17.2.0.html
+++ b/docs/relnotes/17.2.0.html
@@ -44,6 +44,7 @@ Note: some of the new features are only available with 
certain drivers.
 
 
 
+GL_ARB_bindless_texture on radeonsi
 GL_ARB_shader_viewport_layer_array on nvc0 (GM200+)
 GL_AMD_vertex_shader_layer on nvc0 (GM200+)
 GL_AMD_vertex_shader_viewport_index on nvc0 (GM200+)
diff --git a/src/gallium/drivers/radeonsi/si_pipe.c 
b/src/gallium/drivers/radeonsi/si_pipe.c
index 2bb2b3baa7..c071973f87 100644
--- a/src/gallium/drivers/radeonsi/si_pipe.c
+++ b/src/gallium/drivers/radeonsi/si_pipe.c
@@ -475,6 +475,9 @@ static int si_get_param(struct pipe_screen* pscreen, enum 
pipe_cap param)
case PIPE_CAP_DOUBLES:
case PIPE_CAP_TGSI_TEX_TXF_LZ:
case PIPE_CAP_TGSI_TES_LAYER_VIEWPORT:
+   case PIPE_CAP_BINDLESS_TEXTURE:
+   return 1;
+
case PIPE_CAP_INT64:
case PIPE_CAP_INT64_DIVMOD:
case PIPE_CAP_TGSI_CLOCK:
@@ -556,7 +559,6 @@ static int si_get_param(struct pipe_screen* pscreen, enum 
pipe_cap param)
case PIPE_CAP_TGSI_MUL_ZERO_WINS:
case PIPE_CAP_UMA:
case PIPE_CAP_POLYGON_MODE_FILL_RECTANGLE:
-   case PIPE_CAP_BINDLESS_TEXTURE:
return 0;
 
case PIPE_CAP_QUERY_BUFFER_OBJECT:
-- 
2.13.0

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


[Mesa-dev] [RFC PATCH 36/65] st/glsl_to_tgsi: teach rename_temp_registers() about bindless samplers

2017-05-19 Thread Samuel Pitoiset
Signed-off-by: Samuel Pitoiset 
---
 src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp 
b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index ee1afdcd08..c69eefe013 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -4797,6 +4797,12 @@ glsl_to_tgsi_visitor::rename_temp_registers(int 
num_renames, struct rename_reg_p
   inst->tex_offsets[j].index = renames[k].new_reg;
   }
 
+  if (inst->resource.file == PROGRAM_TEMPORARY) {
+ for (k = 0; k < num_renames; k++)
+if (inst->resource.index == renames[k].old_reg)
+   inst->resource.index = renames[k].new_reg;
+  }
+
   for (j = 0; j < num_inst_dst_regs(inst); j++) {
  if (inst->dst[j].file == PROGRAM_TEMPORARY)
  for (k = 0; k < num_renames; k++)
-- 
2.13.0

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


[Mesa-dev] [RFC PATCH 57/65] radeonsi: decompress resident textures/images before graphics/compute

2017-05-19 Thread Samuel Pitoiset
Similar to the existing decompression code path except that it
loops over the list of resident textures/images.

Signed-off-by: Samuel Pitoiset 
---
 src/gallium/drivers/radeonsi/si_blit.c| 67 +--
 src/gallium/drivers/radeonsi/si_descriptors.c | 44 ++
 src/gallium/drivers/radeonsi/si_pipe.h|  3 ++
 3 files changed, 111 insertions(+), 3 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_blit.c 
b/src/gallium/drivers/radeonsi/si_blit.c
index 4078f2498b..32041695e2 100644
--- a/src/gallium/drivers/radeonsi/si_blit.c
+++ b/src/gallium/drivers/radeonsi/si_blit.c
@@ -22,6 +22,7 @@
  */
 
 #include "si_pipe.h"
+#include "si_compute.h"
 #include "util/u_format.h"
 #include "util/u_surface.h"
 
@@ -680,9 +681,6 @@ static void si_decompress_textures(struct si_context *sctx, 
unsigned shader_mask
 {
unsigned compressed_colortex_counter, mask;
 
-   if (sctx->blitter->running)
-   return;
-
/* Update the compressed_colortex_mask if necessary. */
compressed_colortex_counter = 
p_atomic_read(>screen->b.compressed_colortex_counter);
if (compressed_colortex_counter != 
sctx->b.last_compressed_colortex_counter) {
@@ -709,14 +707,77 @@ static void si_decompress_textures(struct si_context 
*sctx, unsigned shader_mask
si_check_render_feedback(sctx);
 }
 
+static void si_decompress_resident_textures(struct si_context *sctx)
+{
+   unsigned i;
+
+   for (i = 0; i < sctx->num_resident_tex_handles; i++) {
+   struct si_texture_handle *tex_handle =
+   sctx->resident_tex_handles[i];
+   struct si_sampler_view *sview = tex_handle->view;
+   struct pipe_sampler_view *view = >base;
+   struct r600_texture *tex;
+
+   assert(view);
+   tex = (struct r600_texture *)view->texture;
+
+   if (view->texture->target == PIPE_BUFFER)
+   continue;
+
+   if (tex_handle->compressed_colortex)
+   si_decompress_color_texture(sctx, tex, 
view->u.tex.first_level,
+   view->u.tex.last_level);
+
+   if (tex_handle->depth_texture)
+   si_flush_depth_texture(sctx, tex,
+   sview->is_stencil_sampler ? PIPE_MASK_S : 
PIPE_MASK_Z,
+   view->u.tex.first_level, view->u.tex.last_level,
+   0, util_max_layer(>resource.b.b, 
view->u.tex.first_level));
+   }
+}
+
+static void si_decompress_resident_images(struct si_context *sctx)
+{
+   unsigned i;
+
+   for (i = 0; i < sctx->num_resident_img_handles; i++) {
+   struct si_image_handle *img_handle =
+   sctx->resident_img_handles[i];
+   struct pipe_image_view *view = _handle->view;
+   struct r600_texture *tex;
+
+   assert(view);
+   tex = (struct r600_texture *)view->resource;
+
+   if (view->resource->target == PIPE_BUFFER)
+   continue;
+
+   if (img_handle->compressed_colortex)
+   si_decompress_color_texture(sctx, tex, 
view->u.tex.level,
+   view->u.tex.level);
+   }
+}
+
 void si_decompress_graphics_textures(struct si_context *sctx)
 {
+   if (sctx->blitter->running)
+   return;
+
si_decompress_textures(sctx, u_bit_consecutive(0, 
SI_NUM_GRAPHICS_SHADERS));
+
+   si_decompress_resident_textures(sctx);
+   si_decompress_resident_images(sctx);
 }
 
 void si_decompress_compute_textures(struct si_context *sctx)
 {
+   if (sctx->blitter->running)
+   return;
+
si_decompress_textures(sctx, 1 << PIPE_SHADER_COMPUTE);
+
+   si_decompress_resident_textures(sctx);
+   si_decompress_resident_images(sctx);
 }
 
 static void si_clear(struct pipe_context *ctx, unsigned buffers,
diff --git a/src/gallium/drivers/radeonsi/si_descriptors.c 
b/src/gallium/drivers/radeonsi/si_descriptors.c
index e459f19d66..05559d90d7 100644
--- a/src/gallium/drivers/radeonsi/si_descriptors.c
+++ b/src/gallium/drivers/radeonsi/si_descriptors.c
@@ -1624,6 +1624,40 @@ static void si_set_polygon_stipple(struct pipe_context 
*ctx,
 
 /* TEXTURE METADATA ENABLE/DISABLE */
 
+static void
+si_resident_handles_update_compressed_colortex(struct si_context *sctx)
+{
+   unsigned i;
+
+   for (i = 0; i < sctx->num_resident_tex_handles; i++) {
+   struct si_texture_handle *tex_handle =
+   sctx->resident_tex_handles[i];
+   struct si_sampler_view *sview = tex_handle->view;
+   struct pipe_resource *res = sview->base.texture;
+
+   if (res && res->target != PIPE_BUFFER) {
+   struct r600_texture *rtex = (struct r600_texture 

[Mesa-dev] [RFC PATCH 53/65] radeonsi: add all resident buffers to the current CS

2017-05-19 Thread Samuel Pitoiset
Resident buffers have to be added to every new command stream.
Though, this could be slightly improved when current shaders
don't use any bindless textures/images but usually applications
tend to use bindless for almost every draw call, and the winsys
thread might help when buffers are added early.

Signed-off-by: Samuel Pitoiset 
---
 src/gallium/drivers/radeonsi/si_descriptors.c | 36 +++
 src/gallium/drivers/radeonsi/si_hw_context.c  |  1 +
 src/gallium/drivers/radeonsi/si_state.h   |  1 +
 3 files changed, 38 insertions(+)

diff --git a/src/gallium/drivers/radeonsi/si_descriptors.c 
b/src/gallium/drivers/radeonsi/si_descriptors.c
index a687506f7f..12f7ead619 100644
--- a/src/gallium/drivers/radeonsi/si_descriptors.c
+++ b/src/gallium/drivers/radeonsi/si_descriptors.c
@@ -2527,6 +2527,42 @@ static void si_make_image_handle_resident(struct 
pipe_context *ctx,
 }
 
 
+void si_all_resident_buffers_begin_new_cs(struct si_context *sctx)
+{
+   unsigned i;
+
+   /* Add all resident descriptors. */
+   for (i = 0; i < sctx->num_resident_descriptors; i++) {
+   struct r600_resource *desc = sctx->resident_descriptors[i];
+
+   radeon_add_to_buffer_list(>b, >b.gfx, desc,
+ RADEON_USAGE_READ,
+ RADEON_PRIO_DESCRIPTORS);
+   }
+
+   /* Add all resident texture handles. */
+   for (i = 0; i < sctx->num_resident_tex_handles; i++) {
+   struct si_texture_handle *tex_handle =
+   sctx->resident_tex_handles[i];
+   struct si_sampler_view *sview = tex_handle->view;
+
+   si_sampler_view_add_buffer(sctx, sview->base.texture,
+  RADEON_USAGE_READ,
+  sview->is_stencil_sampler, false);
+   }
+
+   /* Add all resident image handles. */
+   for (i = 0; i < sctx->num_resident_img_handles; i++) {
+   struct si_image_handle *img_handle =
+   sctx->resident_img_handles[i];
+   struct pipe_image_view *view = _handle->view;
+
+   si_sampler_view_add_buffer(sctx, view->resource,
+  RADEON_USAGE_READWRITE,
+  false, false);
+   }
+}
+
 /* INIT/DEINIT/UPLOAD */
 
 /* GFX9 has only 4KB of CE, while previous chips had 32KB. In order
diff --git a/src/gallium/drivers/radeonsi/si_hw_context.c 
b/src/gallium/drivers/radeonsi/si_hw_context.c
index 92c09cb633..345825af00 100644
--- a/src/gallium/drivers/radeonsi/si_hw_context.c
+++ b/src/gallium/drivers/radeonsi/si_hw_context.c
@@ -235,6 +235,7 @@ void si_begin_new_cs(struct si_context *ctx)
si_mark_atom_dirty(ctx, >b.streamout.enable_atom);
si_mark_atom_dirty(ctx, >b.render_cond_atom);
si_all_descriptors_begin_new_cs(ctx);
+   si_all_resident_buffers_begin_new_cs(ctx);
 
ctx->b.scissors.dirty_mask = (1 << R600_MAX_VIEWPORTS) - 1;
ctx->b.viewports.dirty_mask = (1 << R600_MAX_VIEWPORTS) - 1;
diff --git a/src/gallium/drivers/radeonsi/si_state.h 
b/src/gallium/drivers/radeonsi/si_state.h
index 3e9016c84a..e46af570d4 100644
--- a/src/gallium/drivers/radeonsi/si_state.h
+++ b/src/gallium/drivers/radeonsi/si_state.h
@@ -323,6 +323,7 @@ bool si_upload_graphics_shader_descriptors(struct 
si_context *sctx);
 bool si_upload_compute_shader_descriptors(struct si_context *sctx);
 void si_release_all_descriptors(struct si_context *sctx);
 void si_all_descriptors_begin_new_cs(struct si_context *sctx);
+void si_all_resident_buffers_begin_new_cs(struct si_context *sctx);
 void si_upload_const_buffer(struct si_context *sctx, struct r600_resource 
**rbuffer,
const uint8_t *ptr, unsigned size, uint32_t 
*const_offset);
 void si_update_all_texture_descriptors(struct si_context *sctx);
-- 
2.13.0

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


[Mesa-dev] [RFC PATCH 54/65] radeonsi: only add descriptors in presence of resident handles

2017-05-19 Thread Samuel Pitoiset
This won't help much except for applications that use a ton
of resident handles. Though, this will reduce the winsys
overhead a little bit.

Signed-off-by: Samuel Pitoiset 
---
 src/gallium/drivers/radeonsi/si_descriptors.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/src/gallium/drivers/radeonsi/si_descriptors.c 
b/src/gallium/drivers/radeonsi/si_descriptors.c
index 12f7ead619..44a4b16712 100644
--- a/src/gallium/drivers/radeonsi/si_descriptors.c
+++ b/src/gallium/drivers/radeonsi/si_descriptors.c
@@ -2531,6 +2531,11 @@ void si_all_resident_buffers_begin_new_cs(struct 
si_context *sctx)
 {
unsigned i;
 
+   /* Skip adding the resident descriptors when no handles are resident.
+*/
+   if (!sctx->num_resident_tex_handles && !sctx->num_resident_img_handles)
+   return;
+
/* Add all resident descriptors. */
for (i = 0; i < sctx->num_resident_descriptors; i++) {
struct r600_resource *desc = sctx->resident_descriptors[i];
-- 
2.13.0

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


[Mesa-dev] [RFC PATCH 62/65] radeonsi: invalidate buffers which are made resident if needed

2017-05-19 Thread Samuel Pitoiset
When a buffer becomes resident, check if it has been invalidated,
if so update the descriptor and the dirty flag.

Signed-off-by: Samuel Pitoiset 
---
 src/gallium/drivers/radeonsi/si_descriptors.c | 34 +++
 1 file changed, 34 insertions(+)

diff --git a/src/gallium/drivers/radeonsi/si_descriptors.c 
b/src/gallium/drivers/radeonsi/si_descriptors.c
index 6adad06757..0866c54c23 100644
--- a/src/gallium/drivers/radeonsi/si_descriptors.c
+++ b/src/gallium/drivers/radeonsi/si_descriptors.c
@@ -2419,6 +2419,32 @@ si_create_resident_descriptor(struct si_context *sctx, 
uint32_t *desc_list,
return desc;
 }
 
+static void si_invalidate_resident_buf_desc(struct si_context *sctx,
+   struct si_resident_descriptor *desc,
+   struct pipe_resource *resource,
+   uint64_t offset)
+{
+   struct r600_resource *buf = r600_resource(resource);
+   uint32_t *desc_list = desc->desc_list;
+   uint64_t old_desc_va;
+
+   assert(resource->target == PIPE_BUFFER);
+
+   /* Retrieve the old buffer addr from the descriptor. */
+   old_desc_va  = desc_list[0];
+   old_desc_va |= ((uint64_t)G_008F04_BASE_ADDRESS_HI(desc_list[1]) << 32);
+
+   if (old_desc_va != buf->gpu_address + offset) {
+   /* The buffer has been invalidated when the handle wasn't
+* resident, update the descriptor and the dirty flag.
+*/
+   si_set_buf_desc_address(buf, offset, _list[4]);
+
+   desc->dirty = true;
+   sctx->resident_descriptors_dirty = true;
+   }
+}
+
 static uint64_t si_create_texture_handle(struct pipe_context *ctx,
 struct pipe_resource *texture,
 struct pipe_sampler_view *view,
@@ -2515,6 +2541,10 @@ static void si_make_texture_handle_resident(struct 
pipe_context *ctx,
is_compressed_colortex(rtex);
 
si_update_check_render_feedback(sctx, rtex);
+   } else {
+   si_invalidate_resident_buf_desc(sctx, tex_handle->desc,
+   sview->base.texture,
+   
sview->base.u.buf.offset);
}
 
si_add_resident_tex_handle(sctx, tex_handle);
@@ -2624,6 +2654,10 @@ static void si_make_image_handle_resident(struct 
pipe_context *ctx,
is_compressed_colortex(rtex);
 
si_update_check_render_feedback(sctx, rtex);
+   } else {
+   si_invalidate_resident_buf_desc(sctx, img_handle->desc,
+   view->resource,
+   view->u.buf.offset);
}
 
si_add_resident_img_handle(sctx, img_handle);
-- 
2.13.0

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


[Mesa-dev] [RFC PATCH 59/65] radeonsi: track use of bindless samplers/images from tgsi_shader_info

2017-05-19 Thread Samuel Pitoiset
This adds some new helper functions to know if the current draw
call (or dispatch compute) is using bindless samplers/images,
based on TGSI analysis.

Signed-off-by: Samuel Pitoiset 
---
 src/gallium/drivers/radeonsi/si_compute.c |  2 ++
 src/gallium/drivers/radeonsi/si_compute.h | 14 ++
 src/gallium/drivers/radeonsi/si_pipe.h| 20 
 src/gallium/drivers/radeonsi/si_shader.h  | 12 
 4 files changed, 48 insertions(+)

diff --git a/src/gallium/drivers/radeonsi/si_compute.c 
b/src/gallium/drivers/radeonsi/si_compute.c
index 4c980668d3..61fab7ddb0 100644
--- a/src/gallium/drivers/radeonsi/si_compute.c
+++ b/src/gallium/drivers/radeonsi/si_compute.c
@@ -108,6 +108,8 @@ static void si_create_compute_state_async(void *job, int 
thread_index)
program->shader.is_monolithic = true;
program->uses_grid_size = sel.info.uses_grid_size;
program->uses_block_size = sel.info.uses_block_size;
+   program->uses_bindless_samplers = sel.info.uses_bindless_samplers;
+   program->uses_bindless_images = sel.info.uses_bindless_images;
 
if (si_shader_create(program->screen, tm, >shader, debug)) {
program->shader.compilation_failed = true;
diff --git a/src/gallium/drivers/radeonsi/si_compute.h 
b/src/gallium/drivers/radeonsi/si_compute.h
index 764d708c4f..3cf1538267 100644
--- a/src/gallium/drivers/radeonsi/si_compute.h
+++ b/src/gallium/drivers/radeonsi/si_compute.h
@@ -49,6 +49,20 @@ struct si_compute {
unsigned variable_group_size : 1;
unsigned uses_grid_size:1;
unsigned uses_block_size:1;
+   unsigned uses_bindless_samplers:1;
+   unsigned uses_bindless_images:1;
 };
 
+static inline bool
+si_compute_uses_bindless_samplers(struct si_context *sctx)
+{
+   return sctx->cs_shader_state.program->uses_bindless_samplers;
+}
+
+static inline bool
+si_compute_uses_bindless_images(struct si_context *sctx)
+{
+   return sctx->cs_shader_state.program->uses_bindless_images;
+}
+
 #endif /* SI_COMPUTE_H */
diff --git a/src/gallium/drivers/radeonsi/si_pipe.h 
b/src/gallium/drivers/radeonsi/si_pipe.h
index 8d8efbda1f..c52b364959 100644
--- a/src/gallium/drivers/radeonsi/si_pipe.h
+++ b/src/gallium/drivers/radeonsi/si_pipe.h
@@ -544,6 +544,26 @@ static inline struct tgsi_shader_info 
*si_get_vs_info(struct si_context *sctx)
return NULL;
 }
 
+static inline bool
+si_graphics_uses_bindless_samplers(struct si_context *sctx)
+{
+   return si_shader_uses_bindless_samplers(sctx->vs_shader.cso)  ||
+  si_shader_uses_bindless_samplers(sctx->gs_shader.cso)  ||
+  si_shader_uses_bindless_samplers(sctx->ps_shader.cso)  ||
+  si_shader_uses_bindless_samplers(sctx->tcs_shader.cso) ||
+  si_shader_uses_bindless_samplers(sctx->tes_shader.cso);
+}
+
+static inline bool
+si_graphics_uses_bindless_images(struct si_context *sctx)
+{
+   return si_shader_uses_bindless_images(sctx->vs_shader.cso)  ||
+  si_shader_uses_bindless_images(sctx->gs_shader.cso)  ||
+  si_shader_uses_bindless_images(sctx->ps_shader.cso)  ||
+  si_shader_uses_bindless_images(sctx->tcs_shader.cso) ||
+  si_shader_uses_bindless_images(sctx->tes_shader.cso);
+}
+
 static inline struct si_shader* si_get_vs_state(struct si_context *sctx)
 {
if (sctx->gs_shader.current)
diff --git a/src/gallium/drivers/radeonsi/si_shader.h 
b/src/gallium/drivers/radeonsi/si_shader.h
index aab902b4c7..87bbbf9c2a 100644
--- a/src/gallium/drivers/radeonsi/si_shader.h
+++ b/src/gallium/drivers/radeonsi/si_shader.h
@@ -622,4 +622,16 @@ si_get_main_shader_part(struct si_shader_selector *sel,
return >main_shader_part;
 }
 
+static inline bool
+si_shader_uses_bindless_samplers(struct si_shader_selector *selector)
+{
+   return selector ? selector->info.uses_bindless_samplers : false;
+}
+
+static inline bool
+si_shader_uses_bindless_images(struct si_shader_selector *selector)
+{
+   return selector ? selector->info.uses_bindless_images : false;
+}
+
 #endif
-- 
2.13.0

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


[Mesa-dev] [RFC PATCH 45/65] st/mesa: do not release sampler views for resident textures

2017-05-19 Thread Samuel Pitoiset
When a texture is referenced by one or more texture handles,
it might be resident and we shouldn't release the sampler views.

Signed-off-by: Samuel Pitoiset 
---
 src/mesa/state_tracker/st_sampler_view.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/src/mesa/state_tracker/st_sampler_view.c 
b/src/mesa/state_tracker/st_sampler_view.c
index c78a987486..690b50087c 100644
--- a/src/mesa/state_tracker/st_sampler_view.c
+++ b/src/mesa/state_tracker/st_sampler_view.c
@@ -115,6 +115,12 @@ st_texture_release_all_sampler_views(struct st_context *st,
 {
GLuint i;
 
+   if (stObj->base.HandleAllocated) {
+  /* Do not release sampler views when a texture is referenced by one or
+   * more texture handles because the texture might be resident. */
+  return;
+   }
+
/* XXX This should use sampler_views[i]->pipe, not st->pipe */
for (i = 0; i < stObj->num_sampler_views; ++i)
   pipe_sampler_view_release(st->pipe, >sampler_views[i]);
-- 
2.13.0

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


[Mesa-dev] [RFC PATCH 51/65] radeonsi: add si_set_shader_image_desc() helper

2017-05-19 Thread Samuel Pitoiset
To share some common code between bound and bindless images.

Signed-off-by: Samuel Pitoiset 
---
 src/gallium/drivers/radeonsi/si_descriptors.c | 78 ---
 1 file changed, 46 insertions(+), 32 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_descriptors.c 
b/src/gallium/drivers/radeonsi/si_descriptors.c
index e73dbc9f9f..abe39de583 100644
--- a/src/gallium/drivers/radeonsi/si_descriptors.c
+++ b/src/gallium/drivers/radeonsi/si_descriptors.c
@@ -748,28 +748,16 @@ si_mark_image_range_valid(const struct pipe_image_view 
*view)
   view->u.buf.offset + view->u.buf.size);
 }
 
-static void si_set_shader_image(struct si_context *ctx,
-   unsigned shader,
-   unsigned slot, const struct pipe_image_view 
*view,
-   bool skip_decompress)
+static void si_set_shader_image_desc(struct si_context *ctx,
+const struct pipe_image_view *view,
+bool skip_decompress,
+uint32_t *desc)
 {
struct si_screen *screen = ctx->screen;
-   struct si_images_info *images = >images[shader];
-   struct si_descriptors *descs = si_sampler_and_image_descriptors(ctx, 
shader);
struct r600_resource *res;
-   unsigned desc_slot = si_get_image_slot(slot);
-   uint32_t *desc = descs->list + desc_slot * 8;
-
-   if (!view || !view->resource) {
-   si_disable_shader_image(ctx, shader, slot);
-   return;
-   }
 
res = (struct r600_resource *)view->resource;
 
-   if (>views[slot] != view)
-   util_copy_image_view(>views[slot], view);
-
if (res->b.b.target == PIPE_BUFFER) {
if (view->access & PIPE_IMAGE_ACCESS_WRITE)
si_mark_image_range_valid(view);
@@ -779,9 +767,6 @@ static void si_set_shader_image(struct si_context *ctx,
  view->u.buf.offset,
  view->u.buf.size, desc);
si_set_buf_desc_address(res, view->u.buf.offset, desc + 4);
-
-   images->compressed_colortex_mask &= ~(1 << slot);
-   res->bind_history |= PIPE_BIND_SHADER_IMAGE;
} else {
static const unsigned char swizzle[4] = { 0, 1, 2, 3 };
struct r600_texture *tex = (struct r600_texture *)res;
@@ -799,22 +784,10 @@ static void si_set_shader_image(struct si_context *ctx,
 * The decompression is relatively cheap if the surface
 * has been decompressed already.
 */
-   if (r600_texture_disable_dcc(>b, tex))
-   uses_dcc = false;
-   else
+   if (!r600_texture_disable_dcc(>b, tex))
ctx->b.decompress_dcc(>b.b, tex);
}
 
-   if (is_compressed_colortex(tex)) {
-   images->compressed_colortex_mask |= 1 << slot;
-   } else {
-   images->compressed_colortex_mask &= ~(1 << slot);
-   }
-
-   if (uses_dcc &&
-   p_atomic_read(>framebuffers_bound))
-   ctx->need_check_render_feedback = true;
-
if (ctx->b.chip_class >= GFX9) {
/* Always set the base address. The swizzle modes don't
 * allow setting mipmap level offsets as the base.
@@ -850,6 +823,47 @@ static void si_set_shader_image(struct si_context *ctx,
   
util_format_get_blockwidth(view->format),
   false, desc);
}
+}
+
+static void si_set_shader_image(struct si_context *ctx,
+   unsigned shader,
+   unsigned slot, const struct pipe_image_view 
*view,
+   bool skip_decompress)
+{
+   struct si_images_info *images = >images[shader];
+   struct si_descriptors *descs = si_sampler_and_image_descriptors(ctx, 
shader);
+   struct r600_resource *res;
+   unsigned desc_slot = si_get_image_slot(slot);
+   uint32_t *desc = descs->list + desc_slot * 8;
+
+   if (!view || !view->resource) {
+   si_disable_shader_image(ctx, shader, slot);
+   return;
+   }
+
+   res = (struct r600_resource *)view->resource;
+
+   if (>views[slot] != view)
+   util_copy_image_view(>views[slot], view);
+
+   si_set_shader_image_desc(ctx, view, skip_decompress, desc);
+
+   if (res->b.b.target == PIPE_BUFFER) {
+   images->compressed_colortex_mask &= ~(1 << slot);
+   res->bind_history |= PIPE_BIND_SHADER_IMAGE;
+   } else {
+   struct 

[Mesa-dev] [RFC PATCH 64/65] radeonsi: add support for loading bindless images

2017-05-19 Thread Samuel Pitoiset
Signed-off-by: Samuel Pitoiset 
---
 src/gallium/drivers/radeonsi/si_shader_tgsi_mem.c | 31 ++-
 1 file changed, 25 insertions(+), 6 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_shader_tgsi_mem.c 
b/src/gallium/drivers/radeonsi/si_shader_tgsi_mem.c
index c9397c2fb8..1447a552b9 100644
--- a/src/gallium/drivers/radeonsi/si_shader_tgsi_mem.c
+++ b/src/gallium/drivers/radeonsi/si_shader_tgsi_mem.c
@@ -184,7 +184,10 @@ image_fetch_rsrc(
LLVMValueRef index;
bool dcc_off = is_store;
 
-   assert(image->Register.File == TGSI_FILE_IMAGE);
+   assert(image->Register.File == TGSI_FILE_IMAGE ||
+  image->Register.File == TGSI_FILE_CONSTANT ||
+  image->Register.File == TGSI_FILE_TEMPORARY ||
+  image->Register.File == TGSI_FILE_INPUT);
 
if (!image->Register.Indirect) {
const struct tgsi_shader_info *info = bld_base->info;
@@ -214,6 +217,18 @@ image_fetch_rsrc(
 index, "");
}
 
+   if (image->Register.File != TGSI_FILE_IMAGE) {
+   struct gallivm_state *gallivm = >gallivm;
+   LLVMBuilderRef builder = gallivm->builder;
+
+   LLVMValueRef ptr =
+   lp_build_emit_fetch_src(bld_base, image,
+   TGSI_TYPE_UNSIGNED64, 0);
+   rsrc_ptr = LLVMBuildIntToPtr(builder, ptr,
+si_const_array(ctx->v8i32, 0), "");
+   index = LLVMConstInt(ctx->i32, 0, 0);
+   }
+
*rsrc = load_image_desc(ctx, rsrc_ptr, index, target);
if (dcc_off && target != TGSI_TEXTURE_BUFFER)
*rsrc = force_dcc_off(ctx, *rsrc);
@@ -373,7 +388,8 @@ static void load_fetch_args(
 
buffer_append_args(ctx, emit_data, rsrc, ctx->i32_0,
   offset, false, false);
-   } else if (inst->Src[0].Register.File == TGSI_FILE_IMAGE) {
+   } else if (inst->Src[0].Register.File == TGSI_FILE_IMAGE ||
+  inst->Memory.Bindless) {
LLVMValueRef coords;
 
image_fetch_rsrc(bld_base, >Src[0], false, target, );
@@ -538,8 +554,9 @@ static bool is_oneway_access_only(const struct 
tgsi_full_instruction *inst,
 * images.
 */
if (inst->Src[0].Register.File == TGSI_FILE_BUFFER ||
-   (inst->Src[0].Register.File == TGSI_FILE_IMAGE &&
-inst->Memory.Texture == TGSI_TEXTURE_BUFFER)) {
+   (inst->Memory.Texture == TGSI_TEXTURE_BUFFER &&
+(inst->Src[0].Register.File == TGSI_FILE_IMAGE ||
+ inst->Memory.Bindless))) {
if (!shader_buffers_reverse_access_mask &&
!(info->images_buffers & images_reverse_access_mask))
return true;
@@ -640,7 +657,8 @@ static void store_fetch_args(
 
buffer_append_args(ctx, emit_data, rsrc, ctx->i32_0,
   offset, false, false);
-   } else if (inst->Dst[0].Register.File == TGSI_FILE_IMAGE) {
+   } else if (inst->Dst[0].Register.File == TGSI_FILE_IMAGE ||
+  inst->Memory.Bindless) {
unsigned target = inst->Memory.Texture;
LLVMValueRef coords;
 
@@ -859,7 +877,8 @@ static void atomic_fetch_args(
 
buffer_append_args(ctx, emit_data, rsrc, ctx->i32_0,
   offset, true, false);
-   } else if (inst->Src[0].Register.File == TGSI_FILE_IMAGE) {
+   } else if (inst->Src[0].Register.File == TGSI_FILE_IMAGE ||
+  inst->Memory.Bindless) {
unsigned target = inst->Memory.Texture;
LLVMValueRef coords;
 
-- 
2.13.0

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


[Mesa-dev] [RFC PATCH 46/65] st/mesa: disable per-context seamless cubemap when using texture handles

2017-05-19 Thread Samuel Pitoiset
The ARB_bindless_texture spec say:

   "If ARB_seamless_cubemap (or OpenGL 4.0, which includes it) is
supported, the per-context seamless cubemap enable is ignored
and treated as disabled when using texture handles."

   "If AMD_seamless_cubemap_per_texture is supported, the seamless
cube map texture parameter of the underlying texture does apply
when texture handles are used."

Signed-off-by: Samuel Pitoiset 
---
 src/mesa/state_tracker/st_atom_sampler.c | 18 --
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/src/mesa/state_tracker/st_atom_sampler.c 
b/src/mesa/state_tracker/st_atom_sampler.c
index c6d992fbb0..116c5380cf 100644
--- a/src/mesa/state_tracker/st_atom_sampler.c
+++ b/src/mesa/state_tracker/st_atom_sampler.c
@@ -226,8 +226,22 @@ st_convert_sampler(const struct st_context *st,
   sampler->compare_func = st_compare_func_to_pipe(msamp->CompareFunc);
}
 
-   sampler->seamless_cube_map =
-  ctx->Texture.CubeMapSeamless || msamp->CubeMapSeamless;
+   if (msamp->HandleAllocated) {
+  /* The ARB_bindless_texture spec says:
+   *
+   * "If ARB_seamless_cubemap (or OpenGL 4.0, which includes it) is
+   *  supported, the per-context seamless cubemap enable is ignored and
+   *  treated as disabled when using texture handles."
+   *
+   * "If AMD_seamless_cubemap_per_texture is supported, the seamless cube
+   *  map texture parameter of the underlying texture does apply when
+   *  texture handles are used."
+   */
+  sampler->seamless_cube_map = msamp->CubeMapSeamless;
+   } else {
+  sampler->seamless_cube_map =
+ ctx->Texture.CubeMapSeamless || msamp->CubeMapSeamless;
+   }
 }
 
 /**
-- 
2.13.0

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


[Mesa-dev] [RFC PATCH 63/65] radeonsi: add support for loading bindless samplers

2017-05-19 Thread Samuel Pitoiset
Signed-off-by: Samuel Pitoiset 
---
 src/gallium/drivers/radeonsi/si_shader_tgsi_mem.c | 17 -
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/src/gallium/drivers/radeonsi/si_shader_tgsi_mem.c 
b/src/gallium/drivers/radeonsi/si_shader_tgsi_mem.c
index bd8ecb70f8..c9397c2fb8 100644
--- a/src/gallium/drivers/radeonsi/si_shader_tgsi_mem.c
+++ b/src/gallium/drivers/radeonsi/si_shader_tgsi_mem.c
@@ -1207,6 +1207,20 @@ static void tex_fetch_ptrs(
 si_get_sampler_slot(reg->Register.Index), 
0);
}
 
+   if (reg->Register.File != TGSI_FILE_SAMPLER) {
+   struct gallivm_state *gallivm = >gallivm;
+   LLVMBuilderRef builder = gallivm->builder;
+
+   assert(inst->Texture.Bindless);
+
+   LLVMValueRef ptr =
+   lp_build_emit_fetch_src(bld_base, reg,
+   TGSI_TYPE_UNSIGNED64, 0);
+   list = LLVMBuildIntToPtr(builder, ptr,
+si_const_array(ctx->v8i32, 0), "");
+   index = LLVMConstInt(ctx->i32, 0, 0);
+   }
+
if (target == TGSI_TEXTURE_BUFFER)
*res_ptr = load_sampler_desc(ctx, list, index, DESC_BUFFER);
else
@@ -1786,7 +1800,8 @@ static void build_tex_intrinsic(const struct 
lp_build_tgsi_action *action,
opcode == TGSI_OPCODE_TG4) {
const unsigned src_idx = 2;
 
-   assert(inst->Src[src_idx].Register.File == TGSI_FILE_SAMPLER);
+   assert(inst->Src[src_idx].Register.File == TGSI_FILE_SAMPLER ||
+  inst->Texture.Bindless);
assert(inst->Texture.ReturnType != TGSI_RETURN_TYPE_UNKNOWN);
 
if (inst->Texture.ReturnType == TGSI_RETURN_TYPE_SINT ||
-- 
2.13.0

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


[Mesa-dev] [RFC PATCH 48/65] radeonsi: add a slab allocator for resident descriptors

2017-05-19 Thread Samuel Pitoiset
For each texture/image handles, we need to allocate a new
buffer for the resident descriptor. But when the number of
buffers added to the current CS becomes high, the overhead
in the winsys (and in the kernel) is important.

To reduce this bottleneck, the idea is to suballocate the
resident descriptors using a slab similar to the one used
in the winsys.

Currently, a buffer can hold 1024 resident descriptors but
this limit is arbitrary and could be changed in the future
for some reasons. Once a slab is allocated the "base" buffer
is added to a per-context residency list.

Signed-off-by: Samuel Pitoiset 
---
 src/gallium/drivers/radeonsi/si_descriptors.c | 150 ++
 src/gallium/drivers/radeonsi/si_pipe.c|  10 ++
 src/gallium/drivers/radeonsi/si_pipe.h|  15 +++
 src/gallium/drivers/radeonsi/si_state.h   |   8 ++
 4 files changed, 183 insertions(+)

diff --git a/src/gallium/drivers/radeonsi/si_descriptors.c 
b/src/gallium/drivers/radeonsi/si_descriptors.c
index 61eb2f10be..d337fc3f11 100644
--- a/src/gallium/drivers/radeonsi/si_descriptors.c
+++ b/src/gallium/drivers/radeonsi/si_descriptors.c
@@ -2005,6 +2005,156 @@ void si_emit_compute_shader_userdata(struct si_context 
*sctx)
sctx->shader_pointers_dirty &= ~compute_mask;
 }
 
+/* BINDLESS */
+
+static int si_add_resident_descriptor(struct si_context *sctx,
+ struct r600_resource *desc)
+{
+   int idx;
+
+   /* New resident descriptor, check if the backing array is large enough. 
*/
+   if (sctx->num_resident_descriptors >= sctx->max_resident_descriptors) {
+   unsigned new_max_descriptors =
+   MAX2(1, sctx->max_resident_descriptors * 2);
+   struct r600_resource **new_descriptors =
+   REALLOC(sctx->resident_descriptors,
+   sctx->num_resident_descriptors * 
(sizeof(*new_descriptors)),
+   new_max_descriptors * sizeof(*new_descriptors));
+
+   if (new_descriptors) {
+   sctx->resident_descriptors = new_descriptors;
+   sctx->max_resident_descriptors = new_max_descriptors;
+   } else {
+   fprintf(stderr, "si_add_resident_descriptor: "
+   "allocation failed\n");
+   return -1;
+   }
+   }
+
+   idx = sctx->num_resident_descriptors;
+   sctx->resident_descriptors[idx] = desc;
+   sctx->num_resident_descriptors++;
+
+   return 0;
+}
+
+static void si_del_resident_descriptor(struct si_context *sctx,
+  struct r600_resource *desc)
+{
+   unsigned i;
+   int size;
+
+   for (i = 0; i < sctx->num_resident_descriptors; i++) {
+   if (sctx->resident_descriptors[i] != desc)
+   continue;
+
+   if (i < sctx->num_resident_descriptors - 1) {
+   size = sizeof(*sctx->resident_descriptors) *
+   (sctx->num_resident_descriptors - 1 - i);
+
+   memmove(>resident_descriptors[i],
+   >resident_descriptors[i + 1], size);
+   }
+
+   sctx->num_resident_descriptors--;
+   return;
+   }
+}
+
+struct si_resident_descriptor_slab
+{
+   struct pb_slab base;
+   struct r600_resource *buffer;
+   struct si_resident_descriptor *entries;
+};
+
+bool si_resident_descriptor_can_reclaim_slab(void *priv,
+struct pb_slab_entry *entry)
+{
+   struct si_context *sctx = priv;
+   struct radeon_winsys *ws = sctx->b.ws;
+   struct si_resident_descriptor *desc = NULL; /* fix container_of */
+
+   desc = container_of(entry, desc, entry);
+
+   if (ws->cs_is_buffer_referenced(sctx->b.gfx.cs, desc->buffer->buf,
+   RADEON_USAGE_READ)) {
+   /* Do not allow to reclaim the buffer if the resident
+* descriptor is currently used.
+*/
+   return false;
+   }
+
+   return true;
+}
+
+struct pb_slab *si_resident_descriptor_slab_alloc(void *priv, unsigned heap,
+ unsigned entry_size,
+ unsigned group_index)
+{
+   struct si_context *sctx = priv;
+   struct si_screen *sscreen = sctx->screen;
+   struct si_resident_descriptor_slab *slab;
+
+   slab = CALLOC_STRUCT(si_resident_descriptor_slab);
+   if (!slab)
+   return NULL;
+
+   /* Create a buffer in VRAM for 1024 resident descriptors. */
+   slab->buffer = (struct r600_resource *)
+   pipe_buffer_create(>b.b, 0,
+  PIPE_USAGE_IMMUTABLE, 64 * 1024);
+   if (!slab->buffer)
+ 

[Mesa-dev] [RFC PATCH 34/65] st/glsl_to_tgsi: add support for bindless pack/unpack operations

2017-05-19 Thread Samuel Pitoiset
Signed-off-by: Samuel Pitoiset 
---
 src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 9 -
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp 
b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index 264b43c10b..f30544eb4c 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -2328,6 +2328,10 @@ glsl_to_tgsi_visitor::visit_expression(ir_expression* 
ir, st_src_reg *op)
case ir_unop_pack_int_2x32:
case ir_unop_unpack_uint_2x32:
case ir_unop_pack_uint_2x32:
+   case ir_unop_unpack_sampler_2x32:
+   case ir_unop_pack_sampler_2x32:
+   case ir_unop_unpack_image_2x32:
+   case ir_unop_pack_image_2x32:
   emit_asm(ir, TGSI_OPCODE_MOV, result_dst, op[0]);
   break;
 
@@ -2486,11 +2490,6 @@ glsl_to_tgsi_visitor::visit_expression(ir_expression* 
ir, st_src_reg *op)
case ir_unop_unpack_snorm_4x8:
case ir_unop_unpack_unorm_4x8:
 
-   case ir_unop_unpack_sampler_2x32:
-   case ir_unop_pack_sampler_2x32:
-   case ir_unop_unpack_image_2x32:
-   case ir_unop_pack_image_2x32:
-
case ir_quadop_vector:
case ir_binop_vector_extract:
case ir_triop_vector_insert:
-- 
2.13.0

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


[Mesa-dev] [RFC PATCH 42/65] st/mesa: add st_create_{texture, image}_handle_from_unit() helper

2017-05-19 Thread Samuel Pitoiset
Signed-off-by: Samuel Pitoiset 
---
 src/mesa/state_tracker/st_texture.c | 42 +
 1 file changed, 42 insertions(+)

diff --git a/src/mesa/state_tracker/st_texture.c 
b/src/mesa/state_tracker/st_texture.c
index 2e9856dcdf..65f86f2b4f 100644
--- a/src/mesa/state_tracker/st_texture.c
+++ b/src/mesa/state_tracker/st_texture.c
@@ -420,3 +420,45 @@ st_create_color_map_texture(struct gl_context *ctx)
   texSize, texSize, 1, 1, 0, PIPE_BIND_SAMPLER_VIEW);
return pt;
 }
+
+
+/**
+ * Create a texture handle from a texture unit.
+ */
+static GLuint64
+st_create_texture_handle_from_unit(struct st_context *st,
+   struct gl_program *prog, GLuint texUnit)
+{
+   struct gl_context *ctx = st->ctx;
+   struct gl_texture_object *texObj;
+   struct pipe_context *pipe = st->pipe;
+   struct pipe_sampler_view *view;
+   struct pipe_sampler_state sampler;
+
+   if (!st_update_single_texture(st, , texUnit, prog->sh.data->Version))
+  return 0;
+
+   st_convert_sampler_from_unit(st, , texUnit);
+
+   texObj = ctx->Texture.Unit[texUnit]._Current;
+   assert(texObj);
+
+   return pipe->create_texture_handle(pipe, st_texture_object(texObj)->pt,
+  view, );
+}
+
+
+/**
+ * Create an image handle from an image unit.
+ */
+static GLuint64
+st_create_image_handle_from_unit(struct st_context *st,
+ struct gl_program *prog, GLuint imgUnit)
+{
+   struct pipe_context *pipe = st->pipe;
+   struct pipe_image_view img;
+
+   st_convert_image_from_unit(st, , imgUnit);
+
+   return pipe->create_image_handle(pipe, );
+}
-- 
2.13.0

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


[Mesa-dev] [RFC PATCH 41/65] st/mesa: add st_convert_image_from_unit() helper

2017-05-19 Thread Samuel Pitoiset
Signed-off-by: Samuel Pitoiset 
---
 src/mesa/state_tracker/st_atom_image.c | 33 ++---
 src/mesa/state_tracker/st_texture.h|  5 +
 2 files changed, 27 insertions(+), 11 deletions(-)

diff --git a/src/mesa/state_tracker/st_atom_image.c 
b/src/mesa/state_tracker/st_atom_image.c
index 381eca191a..5b914637a2 100644
--- a/src/mesa/state_tracker/st_atom_image.c
+++ b/src/mesa/state_tracker/st_atom_image.c
@@ -102,6 +102,27 @@ st_convert_image(const struct st_context *st, const struct 
gl_image_unit *u,
}
 }
 
+/**
+ * Get a pipe_image_view object from an image unit.
+ */
+void
+st_convert_image_from_unit(const struct st_context *st,
+   struct pipe_image_view *img,
+   GLuint imgUnit)
+{
+   struct gl_image_unit *u = >ctx->ImageUnits[imgUnit];
+   struct st_texture_object *stObj = st_texture_object(u->TexObj);
+
+   if (!_mesa_is_image_unit_valid(st->ctx, u) ||
+   !st_finalize_texture(st->ctx, st->pipe, u->TexObj, 0) ||
+   !stObj->pt) {
+  memset(img, 0, sizeof(*img));
+  return;
+   }
+
+   st_convert_image(st, u, img);
+}
+
 static void
 st_bind_images(struct st_context *st, struct gl_program *prog,
enum pipe_shader_type shader_type)
@@ -116,19 +137,9 @@ st_bind_images(struct st_context *st, struct gl_program 
*prog,
c = >ctx->Const.Program[prog->info.stage];
 
for (i = 0; i < prog->info.num_images; i++) {
-  struct gl_image_unit *u =
- >ctx->ImageUnits[prog->sh.ImageUnits[i]];
-  struct st_texture_object *stObj = st_texture_object(u->TexObj);
   struct pipe_image_view *img = [i];
 
-  if (!_mesa_is_image_unit_valid(st->ctx, u) ||
-  !st_finalize_texture(st->ctx, st->pipe, u->TexObj, 0) ||
-  !stObj->pt) {
- memset(img, 0, sizeof(*img));
- continue;
-  }
-
-  st_convert_image(st, u, img);
+  st_convert_image_from_unit(st, img, prog->sh.ImageUnits[i]);
}
cso_set_shader_images(st->cso_context, shader_type, 0,
  prog->info.num_images, images);
diff --git a/src/mesa/state_tracker/st_texture.h 
b/src/mesa/state_tracker/st_texture.h
index e73de2f1d3..7f8a0cb841 100644
--- a/src/mesa/state_tracker/st_texture.h
+++ b/src/mesa/state_tracker/st_texture.h
@@ -259,6 +259,11 @@ st_convert_image(const struct st_context *st, const struct 
gl_image_unit *u,
  struct pipe_image_view *img);
 
 void
+st_convert_image_from_unit(const struct st_context *st,
+   struct pipe_image_view *img,
+   GLuint imgUnit);
+
+void
 st_convert_sampler(const struct st_context *st,
const struct gl_texture_object *texobj,
const struct gl_sampler_object *msamp,
-- 
2.13.0

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


[Mesa-dev] [RFC PATCH 27/65] trace: add ARB_bindless_texture support

2017-05-19 Thread Samuel Pitoiset
Signed-off-by: Samuel Pitoiset 
---
 src/gallium/drivers/trace/tr_context.c | 114 +
 1 file changed, 114 insertions(+)

diff --git a/src/gallium/drivers/trace/tr_context.c 
b/src/gallium/drivers/trace/tr_context.c
index c5563a4844..6639f783a5 100644
--- a/src/gallium/drivers/trace/tr_context.c
+++ b/src/gallium/drivers/trace/tr_context.c
@@ -1704,6 +1704,114 @@ static void trace_context_launch_grid(struct 
pipe_context *_pipe,
trace_dump_call_end();
 }
 
+static uint64_t trace_context_create_texture_handle(struct pipe_context *_pipe,
+struct pipe_resource *res,
+struct pipe_sampler_view 
*view,
+const struct 
pipe_sampler_state *state)
+{
+   struct trace_context *tr_ctx = trace_context(_pipe);
+   struct pipe_context *pipe = tr_ctx->pipe;
+   uint64_t handle;
+
+   trace_dump_call_begin("pipe_context", "create_texture_handle");
+   trace_dump_arg(ptr, pipe);
+   trace_dump_arg(ptr, res);
+   trace_dump_arg(ptr, view);
+   trace_dump_arg_begin("state");
+   trace_dump_arg(sampler_state, state);
+   trace_dump_arg_end();
+
+   handle = pipe->create_texture_handle(pipe, res, view, state);
+
+   trace_dump_ret(uint, handle);
+   trace_dump_call_end();
+
+   return handle;
+}
+
+static void trace_context_delete_texture_handle(struct pipe_context *_pipe,
+uint64_t handle)
+{
+   struct trace_context *tr_ctx = trace_context(_pipe);
+   struct pipe_context *pipe = tr_ctx->pipe;
+
+   trace_dump_call_begin("pipe_context", "delete_texture_handle");
+   trace_dump_arg(ptr, pipe);
+   trace_dump_arg(uint, handle);
+   trace_dump_call_end();
+
+   pipe->delete_texture_handle(pipe, handle);
+}
+
+static void trace_context_make_texture_handle_resident(struct pipe_context 
*_pipe,
+   uint64_t handle,
+   bool resident)
+{
+   struct trace_context *tr_ctx = trace_context(_pipe);
+   struct pipe_context *pipe = tr_ctx->pipe;
+
+   trace_dump_call_begin("pipe_context", "make_texture_handle_resident");
+   trace_dump_arg(ptr, pipe);
+   trace_dump_arg(uint, handle);
+   trace_dump_arg(bool, resident);
+   trace_dump_call_end();
+
+   pipe->make_texture_handle_resident(pipe, handle, resident);
+}
+
+static uint64_t trace_context_create_image_handle(struct pipe_context *_pipe,
+  const struct pipe_image_view 
*image)
+{
+   struct trace_context *tr_ctx = trace_context(_pipe);
+   struct pipe_context *pipe = tr_ctx->pipe;
+   uint64_t handle;
+
+   trace_dump_call_begin("pipe_context", "create_image_handle");
+   trace_dump_arg(ptr, pipe);
+   trace_dump_arg_begin("image");
+   trace_dump_image_view(image);
+   trace_dump_arg_end();
+
+   handle = pipe->create_image_handle(pipe, image);
+
+   trace_dump_ret(uint, handle);
+   trace_dump_call_end();
+
+   return handle;
+}
+
+static void trace_context_delete_image_handle(struct pipe_context *_pipe,
+  uint64_t handle)
+{
+   struct trace_context *tr_ctx = trace_context(_pipe);
+   struct pipe_context *pipe = tr_ctx->pipe;
+
+   trace_dump_call_begin("pipe_context", "delete_image_handle");
+   trace_dump_arg(ptr, pipe);
+   trace_dump_arg(uint, handle);
+   trace_dump_call_end();
+
+   pipe->delete_image_handle(pipe, handle);
+}
+
+static void trace_context_make_image_handle_resident(struct pipe_context 
*_pipe,
+uint64_t handle,
+unsigned access,
+bool resident)
+{
+   struct trace_context *tr_ctx = trace_context(_pipe);
+   struct pipe_context *pipe = tr_ctx->pipe;
+
+   trace_dump_call_begin("pipe_context", "make_image_handle_resident");
+   trace_dump_arg(ptr, pipe);
+   trace_dump_arg(uint, handle);
+   trace_dump_arg(uint, access);
+   trace_dump_arg(bool, resident);
+   trace_dump_call_end();
+
+   pipe->make_image_handle_resident(pipe, handle, access, resident);
+}
+
 struct pipe_context *
 trace_context_create(struct trace_screen *tr_scr,
  struct pipe_context *pipe)
@@ -1805,6 +1913,12 @@ trace_context_create(struct trace_screen *tr_scr,
TR_CTX_INIT(set_shader_buffers);
TR_CTX_INIT(launch_grid);
TR_CTX_INIT(set_shader_images);
+   TR_CTX_INIT(create_texture_handle);
+   TR_CTX_INIT(delete_texture_handle);
+   TR_CTX_INIT(make_texture_handle_resident);
+   TR_CTX_INIT(create_image_handle);
+   TR_CTX_INIT(delete_image_handle);
+   TR_CTX_INIT(make_image_handle_resident);
 
TR_CTX_INIT(transfer_map);
TR_CTX_INIT(transfer_unmap);
-- 
2.13.0

___
mesa-dev mailing list

[Mesa-dev] [RFC PATCH 40/65] st/mesa: make convert_sampler_from_unit() non-static

2017-05-19 Thread Samuel Pitoiset
Signed-off-by: Samuel Pitoiset 
---
 src/mesa/state_tracker/st_atom_sampler.c | 14 --
 src/mesa/state_tracker/st_texture.h  |  5 +
 2 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/src/mesa/state_tracker/st_atom_sampler.c 
b/src/mesa/state_tracker/st_atom_sampler.c
index f33e334bb9..c6d992fbb0 100644
--- a/src/mesa/state_tracker/st_atom_sampler.c
+++ b/src/mesa/state_tracker/st_atom_sampler.c
@@ -230,11 +230,13 @@ st_convert_sampler(const struct st_context *st,
   ctx->Texture.CubeMapSeamless || msamp->CubeMapSeamless;
 }
 
-
-static void
-convert_sampler_from_unit(const struct st_context *st,
-  struct pipe_sampler_state *sampler,
-  GLuint texUnit)
+/**
+ * Get a pipe_sampler_state object from a texture unit.
+ */
+void
+st_convert_sampler_from_unit(const struct st_context *st,
+ struct pipe_sampler_state *sampler,
+ GLuint texUnit)
 {
const struct gl_texture_object *texobj;
struct gl_context *ctx = st->ctx;
@@ -282,7 +284,7 @@ update_shader_samplers(struct st_context *st,
   if (samplers_used & 1) {
  const GLuint texUnit = prog->SamplerUnits[unit];
 
- convert_sampler_from_unit(st, sampler, texUnit);
+ st_convert_sampler_from_unit(st, sampler, texUnit);
  states[unit] = sampler;
  *num_samplers = unit + 1;
   }
diff --git a/src/mesa/state_tracker/st_texture.h 
b/src/mesa/state_tracker/st_texture.h
index 8eb0b4be47..e73de2f1d3 100644
--- a/src/mesa/state_tracker/st_texture.h
+++ b/src/mesa/state_tracker/st_texture.h
@@ -264,6 +264,11 @@ st_convert_sampler(const struct st_context *st,
const struct gl_sampler_object *msamp,
struct pipe_sampler_state *sampler);
 
+void
+st_convert_sampler_from_unit(const struct st_context *st,
+ struct pipe_sampler_state *sampler,
+ GLuint texUnit);
+
 GLboolean
 st_update_single_texture(struct st_context *st,
  struct pipe_sampler_view **sampler_view,
-- 
2.13.0

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


[Mesa-dev] [RFC PATCH 38/65] st/mesa: implement ARB_bindless_texture

2017-05-19 Thread Samuel Pitoiset
Signed-off-by: Samuel Pitoiset 
---
 src/mesa/state_tracker/st_cb_texture.c | 84 ++
 1 file changed, 84 insertions(+)

diff --git a/src/mesa/state_tracker/st_cb_texture.c 
b/src/mesa/state_tracker/st_cb_texture.c
index 99c59f77a3..fabf78e7a7 100644
--- a/src/mesa/state_tracker/st_cb_texture.c
+++ b/src/mesa/state_tracker/st_cb_texture.c
@@ -2880,6 +2880,82 @@ st_TexParameter(struct gl_context *ctx,
 }
 
 
+static GLuint64
+st_NewTextureHandle(struct gl_context *ctx, struct gl_texture_object *texObj,
+struct gl_sampler_object *sampObj)
+{
+   struct st_context *st = st_context(ctx);
+   struct st_texture_object *stObj = st_texture_object(texObj);
+   struct pipe_context *pipe = st->pipe;
+   struct pipe_sampler_view *view;
+   struct pipe_sampler_state sampler;
+
+   if (!st_finalize_texture(ctx, pipe, texObj, 0))
+  return 0;
+
+   st_convert_sampler(st, texObj, sampObj, );
+
+   view = st_get_texture_sampler_view_from_stobj(st, stObj, sampObj, 0);
+
+   return pipe->create_texture_handle(pipe, stObj->pt, view, );
+}
+
+
+static void
+st_DeleteTextureHandle(struct gl_context *ctx, GLuint64 handle)
+{
+   struct st_context *st = st_context(ctx);
+   struct pipe_context *pipe = st->pipe;
+
+   pipe->delete_texture_handle(pipe, handle);
+}
+
+
+static void
+st_MakeTextureHandleResident(struct gl_context *ctx, GLuint64 handle,
+ bool resident)
+{
+   struct st_context *st = st_context(ctx);
+   struct pipe_context *pipe = st->pipe;
+
+   pipe->make_texture_handle_resident(pipe, handle, resident);
+}
+
+
+static GLuint64
+st_NewImageHandle(struct gl_context *ctx, struct gl_image_unit *imgObj)
+{
+   struct st_context *st = st_context(ctx);
+   struct pipe_context *pipe = st->pipe;
+   struct pipe_image_view image;
+
+   st_convert_image(st, imgObj, );
+
+   return pipe->create_image_handle(pipe, );
+}
+
+
+static void
+st_DeleteImageHandle(struct gl_context *ctx, GLuint64 handle)
+{
+   struct st_context *st = st_context(ctx);
+   struct pipe_context *pipe = st->pipe;
+
+   pipe->delete_image_handle(pipe, handle);
+}
+
+
+static void
+st_MakeImageHandleResident(struct gl_context *ctx, GLuint64 handle,
+   GLenum access, bool resident)
+{
+   struct st_context *st = st_context(ctx);
+   struct pipe_context *pipe = st->pipe;
+
+   pipe->make_image_handle_resident(pipe, handle, access, resident);
+}
+
+
 void
 st_init_texture_functions(struct dd_function_table *functions)
 {
@@ -2914,4 +2990,12 @@ st_init_texture_functions(struct dd_function_table 
*functions)
functions->ClearTexSubImage = st_ClearTexSubImage;
 
functions->TexParameter = st_TexParameter;
+
+   /* bindless functions */
+   functions->NewTextureHandle = st_NewTextureHandle;
+   functions->DeleteTextureHandle = st_DeleteTextureHandle;
+   functions->MakeTextureHandleResident = st_MakeTextureHandleResident;
+   functions->NewImageHandle = st_NewImageHandle;
+   functions->DeleteImageHandle = st_DeleteImageHandle;
+   functions->MakeImageHandleResident = st_MakeImageHandleResident;
 }
-- 
2.13.0

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


[Mesa-dev] [RFC PATCH 47/65] st/mesa: enable ARB_bindless_texture

2017-05-19 Thread Samuel Pitoiset
Signed-off-by: Samuel Pitoiset 
---
 src/mesa/state_tracker/st_extensions.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/mesa/state_tracker/st_extensions.c 
b/src/mesa/state_tracker/st_extensions.c
index 2fa7ba7797..80695580cb 100644
--- a/src/mesa/state_tracker/st_extensions.c
+++ b/src/mesa/state_tracker/st_extensions.c
@@ -577,6 +577,7 @@ void st_init_extensions(struct pipe_screen *screen,
 
static const struct st_extension_cap_mapping cap_mapping[] = {
   { o(ARB_base_instance),PIPE_CAP_START_INSTANCE   
},
+  { o(ARB_bindless_texture), PIPE_CAP_BINDLESS_TEXTURE 
},
   { o(ARB_buffer_storage),   
PIPE_CAP_BUFFER_MAP_PERSISTENT_COHERENT   },
   { o(ARB_clear_texture),PIPE_CAP_CLEAR_TEXTURE
},
   { o(ARB_clip_control), PIPE_CAP_CLIP_HALFZ   
},
-- 
2.13.0

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


[Mesa-dev] [RFC PATCH 43/65] st/mesa: add infrastructure for storing bound texture/image handles

2017-05-19 Thread Samuel Pitoiset
Signed-off-by: Samuel Pitoiset 
---
 src/mesa/state_tracker/st_context.c |  2 +
 src/mesa/state_tracker/st_context.h | 11 ++
 src/mesa/state_tracker/st_texture.c | 77 +
 src/mesa/state_tracker/st_texture.h |  5 +++
 4 files changed, 95 insertions(+)

diff --git a/src/mesa/state_tracker/st_context.c 
b/src/mesa/state_tracker/st_context.c
index c901764668..4dcc160b50 100644
--- a/src/mesa/state_tracker/st_context.c
+++ b/src/mesa/state_tracker/st_context.c
@@ -292,6 +292,8 @@ st_destroy_context_priv(struct st_context *st, bool 
destroy_pipe)
st_destroy_drawtex(st);
st_destroy_perfmon(st);
st_destroy_pbo_helpers(st);
+   st_destroy_bound_texture_handles(st);
+   st_destroy_bound_image_handles(st);
 
for (shader = 0; shader < ARRAY_SIZE(st->state.sampler_views); shader++) {
   for (i = 0; i < ARRAY_SIZE(st->state.sampler_views[0]); i++) {
diff --git a/src/mesa/state_tracker/st_context.h 
b/src/mesa/state_tracker/st_context.h
index 520cd8d462..16f29669be 100644
--- a/src/mesa/state_tracker/st_context.h
+++ b/src/mesa/state_tracker/st_context.h
@@ -79,6 +79,12 @@ struct st_bitmap_cache
ubyte *buffer;
 };
 
+struct st_bound_handle
+{
+   unsigned num_handles;
+   uint64_t *handles;
+};
+
 struct st_context
 {
struct st_context_iface iface;
@@ -271,6 +277,11 @@ struct st_context
struct st_perf_monitor_group *perfmon;
 
enum pipe_reset_status reset_status;
+
+   /* Array of bound texture/image handles which are resident in the context.
+*/
+   struct st_bound_handle bound_texture_handles[PIPE_SHADER_TYPES];
+   struct st_bound_handle bound_image_handles[PIPE_SHADER_TYPES];
 };
 
 
diff --git a/src/mesa/state_tracker/st_texture.c 
b/src/mesa/state_tracker/st_texture.c
index 65f86f2b4f..cde7759a61 100644
--- a/src/mesa/state_tracker/st_texture.c
+++ b/src/mesa/state_tracker/st_texture.c
@@ -421,6 +421,83 @@ st_create_color_map_texture(struct gl_context *ctx)
return pt;
 }
 
+/**
+ * Destroy bound texture handles for the given stage.
+ */
+static void
+st_destroy_bound_texture_handles_per_stage(struct st_context *st,
+   enum pipe_shader_type shader)
+{
+   struct st_bound_handle *bound_handles = >bound_texture_handles[shader];
+   struct pipe_context *pipe = st->pipe;
+   unsigned i;
+
+   if (likely(!bound_handles->num_handles))
+  return;
+
+   for (i = 0; i < bound_handles->num_handles; i++) {
+  uint64_t handle = bound_handles->handles[i];
+
+  pipe->make_texture_handle_resident(pipe, handle, false);
+  pipe->delete_texture_handle(pipe, handle);
+   }
+   free(bound_handles->handles);
+   bound_handles->num_handles = 0;
+}
+
+
+/**
+ * Destroy all bound texture handles in the context.
+ */
+void
+st_destroy_bound_texture_handles(struct st_context *st)
+{
+   unsigned i;
+
+   for (i = 0; i < PIPE_SHADER_TYPES; i++) {
+  st_destroy_bound_texture_handles_per_stage(st, i);
+   }
+}
+
+
+/**
+ * Destroy bound image handles for the given stage.
+ */
+static void
+st_destroy_bound_image_handles_per_stage(struct st_context *st,
+ enum pipe_shader_type shader)
+{
+   struct st_bound_handle *bound_handles = >bound_image_handles[shader];
+   struct pipe_context *pipe = st->pipe;
+   unsigned i;
+
+   if (likely(!bound_handles->num_handles))
+  return;
+
+   for (i = 0; i < bound_handles->num_handles; i++) {
+  uint64_t handle = bound_handles->handles[i];
+
+  pipe->make_image_handle_resident(pipe, handle, GL_READ_WRITE, false);
+  pipe->delete_image_handle(pipe, handle);
+   }
+   free(bound_handles->handles);
+   bound_handles->num_handles = 0;
+}
+
+
+/**
+ * Destroy all bound image handles in the context.
+ */
+void
+st_destroy_bound_image_handles(struct st_context *st)
+{
+   unsigned i;
+
+   for (i = 0; i < PIPE_SHADER_TYPES; i++) {
+  st_destroy_bound_image_handles_per_stage(st, i);
+   }
+}
+
 
 /**
  * Create a texture handle from a texture unit.
diff --git a/src/mesa/state_tracker/st_texture.h 
b/src/mesa/state_tracker/st_texture.h
index 7f8a0cb841..b97814cb16 100644
--- a/src/mesa/state_tracker/st_texture.h
+++ b/src/mesa/state_tracker/st_texture.h
@@ -250,6 +250,11 @@ st_texture_image_copy(struct pipe_context *pipe,
 extern struct pipe_resource *
 st_create_color_map_texture(struct gl_context *ctx);
 
+void
+st_destroy_bound_texture_handles(struct st_context *st);
+
+void
+st_destroy_bound_image_handles(struct st_context *st);
 
 bool
 st_etc_fallback(struct st_context *st, struct gl_texture_image *texImage);
-- 
2.13.0

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


[Mesa-dev] [RFC PATCH 56/65] radeonsi: decompress DCC for resident textures/images

2017-05-19 Thread Samuel Pitoiset
Analogous to bound textures/images. We should also update the
resident descriptors and disable COMPRESSION_EN for avoiding
useless DCC fetches, but I postpone this optimization for a
separate series.

Signed-off-by: Samuel Pitoiset 
---
 src/gallium/drivers/radeonsi/si_blit.c| 52 +++
 src/gallium/drivers/radeonsi/si_descriptors.c | 16 +
 2 files changed, 68 insertions(+)

diff --git a/src/gallium/drivers/radeonsi/si_blit.c 
b/src/gallium/drivers/radeonsi/si_blit.c
index 998288dba2..4078f2498b 100644
--- a/src/gallium/drivers/radeonsi/si_blit.c
+++ b/src/gallium/drivers/radeonsi/si_blit.c
@@ -611,6 +611,54 @@ static void si_check_render_feedback_images(struct 
si_context *sctx,
}
 }
 
+static void si_check_render_feedback_resident_textures(struct si_context *sctx)
+{
+   unsigned i;
+
+   for (i = 0; i < sctx->num_resident_tex_handles; i++) {
+   struct si_texture_handle *tex_handle =
+   sctx->resident_tex_handles[i];
+   struct pipe_sampler_view *view;
+   struct r600_texture *tex;
+
+   view = _handle->view->base;
+   if (view->texture->target == PIPE_BUFFER)
+   continue;
+
+   tex = (struct r600_texture *)view->texture;
+
+   si_check_render_feedback_texture(sctx, tex,
+view->u.tex.first_level,
+view->u.tex.last_level,
+view->u.tex.first_layer,
+view->u.tex.last_layer);
+   }
+}
+
+static void si_check_render_feedback_resident_images(struct si_context *sctx)
+{
+   unsigned i;
+
+   for (i = 0; i < sctx->num_resident_img_handles; i++) {
+   struct si_image_handle *img_handle =
+   sctx->resident_img_handles[i];
+   struct pipe_image_view *view;
+   struct r600_texture *tex;
+
+   view = _handle->view;
+   if (view->resource->target == PIPE_BUFFER)
+   continue;
+
+   tex = (struct r600_texture *)view->resource;
+
+   si_check_render_feedback_texture(sctx, tex,
+view->u.tex.level,
+view->u.tex.level,
+view->u.tex.first_layer,
+view->u.tex.last_layer);
+   }
+}
+
 static void si_check_render_feedback(struct si_context *sctx)
 {
 
@@ -621,6 +669,10 @@ static void si_check_render_feedback(struct si_context 
*sctx)
si_check_render_feedback_images(sctx, >images[i]);
si_check_render_feedback_textures(sctx, >samplers[i]);
}
+
+   si_check_render_feedback_resident_images(sctx);
+   si_check_render_feedback_resident_textures(sctx);
+
sctx->need_check_render_feedback = false;
 }
 
diff --git a/src/gallium/drivers/radeonsi/si_descriptors.c 
b/src/gallium/drivers/radeonsi/si_descriptors.c
index 810dd8e89a..e459f19d66 100644
--- a/src/gallium/drivers/radeonsi/si_descriptors.c
+++ b/src/gallium/drivers/radeonsi/si_descriptors.c
@@ -2416,6 +2416,13 @@ static void si_make_texture_handle_resident(struct 
pipe_context *ctx,
sview = tex_handle->view;
 
if (resident) {
+   if (sview->base.texture->target != PIPE_BUFFER) {
+   struct r600_texture *rtex =
+   (struct r600_texture *)sview->base.texture;
+
+   si_update_check_render_feedback(sctx, rtex);
+   }
+
si_add_resident_tex_handle(sctx, tex_handle);
 
/* Add the buffers to the current CS in case si_begin_new_cs()
@@ -2511,6 +2518,15 @@ static void si_make_image_handle_resident(struct 
pipe_context *ctx,
view = _handle->view;
 
if (resident) {
+   struct r600_resource *res =
+   (struct r600_resource *)view->resource;
+
+   if (res->b.b.target != PIPE_BUFFER) {
+   struct r600_texture *rtex = (struct r600_texture *)res;
+
+   si_update_check_render_feedback(sctx, rtex);
+   }
+
si_add_resident_img_handle(sctx, img_handle);
 
/* Add the buffers to the current CS in case si_begin_new_cs()
-- 
2.13.0

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


[Mesa-dev] [RFC PATCH 55/65] radeonsi: add si_update_check_render_feedback() helper

2017-05-19 Thread Samuel Pitoiset
Signed-off-by: Samuel Pitoiset 
---
 src/gallium/drivers/radeonsi/si_descriptors.c | 15 +--
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_descriptors.c 
b/src/gallium/drivers/radeonsi/si_descriptors.c
index 44a4b16712..810dd8e89a 100644
--- a/src/gallium/drivers/radeonsi/si_descriptors.c
+++ b/src/gallium/drivers/radeonsi/si_descriptors.c
@@ -613,6 +613,13 @@ static void si_update_compressed_tex_shader_mask(struct 
si_context *sctx,
sctx->compressed_tex_shader_mask &= ~shader_bit;
 }
 
+static void si_update_check_render_feedback(struct si_context *sctx,
+   struct r600_texture *rtex)
+{
+   if (rtex->dcc_offset && p_atomic_read(>framebuffers_bound))
+   sctx->need_check_render_feedback = true;
+}
+
 static void si_set_sampler_views(struct pipe_context *ctx,
 enum pipe_shader_type shader, unsigned start,
  unsigned count,
@@ -653,9 +660,7 @@ static void si_set_sampler_views(struct pipe_context *ctx,
samplers->compressed_colortex_mask &= ~(1u << 
slot);
}
 
-   if (rtex->dcc_offset &&
-   p_atomic_read(>framebuffers_bound))
-   sctx->need_check_render_feedback = true;
+   si_update_check_render_feedback(sctx, rtex);
} else {
samplers->depth_texture_mask &= ~(1u << slot);
samplers->compressed_colortex_mask &= ~(1u << slot);
@@ -861,9 +866,7 @@ static void si_set_shader_image(struct si_context *ctx,
images->compressed_colortex_mask &= ~(1 << slot);
}
 
-   if (tex->dcc_offset &&
-   p_atomic_read(>framebuffers_bound))
-   ctx->need_check_render_feedback = true;
+   si_update_check_render_feedback(ctx, tex);
}
 
images->enabled_mask |= 1u << slot;
-- 
2.13.0

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


[Mesa-dev] [RFC PATCH 58/65] radeonsi: isolate real framebuffer changes from the decompression passes

2017-05-19 Thread Samuel Pitoiset
When a stencil buffer is part of the framebuffer state, it is
decompressed but because it's bindles, all draw calls set
stencil_dirty_level_mask to 1.

Signed-off-by: Samuel Pitoiset 
---
 src/gallium/drivers/radeonsi/si_blit.c  |  8 
 src/gallium/drivers/radeonsi/si_pipe.h  |  1 +
 src/gallium/drivers/radeonsi/si_state.c | 10 --
 3 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_blit.c 
b/src/gallium/drivers/radeonsi/si_blit.c
index 32041695e2..0cf3ea79b9 100644
--- a/src/gallium/drivers/radeonsi/si_blit.c
+++ b/src/gallium/drivers/radeonsi/si_blit.c
@@ -235,12 +235,16 @@ si_blit_decompress_zs_planes_in_place(struct si_context 
*sctx,
 
zsurf = sctx->b.b.create_surface(>b.b, 
>resource.b.b, _tmpl);
 
+   sctx->decompression_enabled = true;
+
si_blitter_begin(>b.b, SI_DECOMPRESS);
util_blitter_custom_depth_stencil(sctx->blitter, zsurf, 
NULL, ~0,
  
sctx->custom_dsa_flush,
  1.0f);
si_blitter_end(>b.b);
 
+   sctx->decompression_enabled = false;
+
pipe_surface_reference(, NULL);
}
 
@@ -454,10 +458,14 @@ static void si_blit_decompress_color(struct pipe_context 
*ctx,
surf_tmpl.u.tex.last_layer = layer;
cbsurf = ctx->create_surface(ctx, >resource.b.b, 
_tmpl);
 
+   sctx->decompression_enabled = true;
+
si_blitter_begin(ctx, SI_DECOMPRESS);
util_blitter_custom_color(sctx->blitter, cbsurf, 
custom_blend);
si_blitter_end(ctx);
 
+   sctx->decompression_enabled = false;
+
pipe_surface_reference(, NULL);
}
 
diff --git a/src/gallium/drivers/radeonsi/si_pipe.h 
b/src/gallium/drivers/radeonsi/si_pipe.h
index 7dafa77c37..8d8efbda1f 100644
--- a/src/gallium/drivers/radeonsi/si_pipe.h
+++ b/src/gallium/drivers/radeonsi/si_pipe.h
@@ -402,6 +402,7 @@ struct si_context {
 
/* Other state */
bool need_check_render_feedback;
+   booldecompression_enabled;
 
/* Precomputed IA_MULTI_VGT_PARAM */
union si_vgt_param_key  ia_multi_vgt_param_key;
diff --git a/src/gallium/drivers/radeonsi/si_state.c 
b/src/gallium/drivers/radeonsi/si_state.c
index 363f32170a..7256ec0c62 100644
--- a/src/gallium/drivers/radeonsi/si_state.c
+++ b/src/gallium/drivers/radeonsi/si_state.c
@@ -2611,9 +2611,15 @@ static void si_set_framebuffer_state(struct pipe_context 
*ctx,
si_mark_atom_dirty(sctx, >msaa_sample_locs.atom);
}
 
-   sctx->need_check_render_feedback = true;
sctx->do_update_shaders = true;
-   sctx->framebuffer.do_update_surf_dirtiness = true;
+
+   if (!sctx->decompression_enabled) {
+   /* Prevent textures decompression when the framebuffer state
+* changes come from the decompression passes themselves.
+*/
+   sctx->need_check_render_feedback = true;
+   sctx->framebuffer.do_update_surf_dirtiness = true;
+   }
 }
 
 static void si_emit_framebuffer_state(struct si_context *sctx, struct 
r600_atom *atom)
-- 
2.13.0

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


[Mesa-dev] [RFC PATCH 29/65] tgsi: add new Bindless flag to tgsi_instruction_texture

2017-05-19 Thread Samuel Pitoiset
Old-style images are identified using TGSI_FILE_SAMPLER, but
bindless samplers can be TGSI_FILE_CONSTANT or TGSI_FILE_TEMPORARY.

To avoid backend compilers to be confused, this adds a new flag
that will only be set for bindless samplers.

Signed-off-by: Samuel Pitoiset 
---
 src/gallium/auxiliary/tgsi/tgsi_build.c|  4 
 src/gallium/auxiliary/tgsi/tgsi_ureg.c |  9 ++---
 src/gallium/auxiliary/tgsi/tgsi_ureg.h | 10 ++
 src/gallium/include/pipe/p_shader_tokens.h |  3 ++-
 src/mesa/state_tracker/st_atifs_to_tgsi.c  |  2 +-
 src/mesa/state_tracker/st_glsl_to_tgsi.cpp |  2 +-
 src/mesa/state_tracker/st_mesa_to_tgsi.c   |  2 +-
 7 files changed, 21 insertions(+), 11 deletions(-)

diff --git a/src/gallium/auxiliary/tgsi/tgsi_build.c 
b/src/gallium/auxiliary/tgsi/tgsi_build.c
index 00843241f8..be1931e482 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_build.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_build.c
@@ -721,6 +721,7 @@ tgsi_default_instruction_texture( void )
instruction_texture.Texture = TGSI_TEXTURE_UNKNOWN;
instruction_texture.NumOffsets = 0;
instruction_texture.ReturnType = TGSI_RETURN_TYPE_UNKNOWN;
+   instruction_texture.Bindless = 0;
instruction_texture.Padding = 0;
 
return instruction_texture;
@@ -731,6 +732,7 @@ tgsi_build_instruction_texture(
unsigned texture,
unsigned num_offsets,
unsigned return_type,
+   unsigned bindless,
struct tgsi_token *prev_token,
struct tgsi_instruction *instruction,
struct tgsi_header *header )
@@ -740,6 +742,7 @@ tgsi_build_instruction_texture(
instruction_texture.Texture = texture;
instruction_texture.NumOffsets = num_offsets;
instruction_texture.ReturnType = return_type;
+   instruction_texture.Bindless = bindless;
instruction_texture.Padding = 0;
instruction->Texture = 1;
 
@@ -1095,6 +1098,7 @@ tgsi_build_full_instruction(
  full_inst->Texture.Texture,
  full_inst->Texture.NumOffsets,
  full_inst->Texture.ReturnType,
+ full_inst->Texture.Bindless,
  prev_token,
  instruction,
  header   );
diff --git a/src/gallium/auxiliary/tgsi/tgsi_ureg.c 
b/src/gallium/auxiliary/tgsi/tgsi_ureg.c
index 5bd779728a..8efa95f009 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_ureg.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_ureg.c
@@ -1289,7 +1289,8 @@ ureg_fixup_label(struct ureg_program *ureg,
 void
 ureg_emit_texture(struct ureg_program *ureg,
   unsigned extended_token,
-  unsigned target, unsigned return_type, unsigned num_offsets)
+  unsigned target, unsigned return_type, unsigned num_offsets,
+  unsigned bindless)
 {
union tgsi_any_token *out, *insn;
 
@@ -1302,6 +1303,7 @@ ureg_emit_texture(struct ureg_program *ureg,
out[0].insn_texture.Texture = target;
out[0].insn_texture.NumOffsets = num_offsets;
out[0].insn_texture.ReturnType = return_type;
+   out[0].insn_texture.Bindless = bindless;
 }
 
 void
@@ -1391,7 +1393,8 @@ ureg_tex_insn(struct ureg_program *ureg,
   const struct tgsi_texture_offset *texoffsets,
   unsigned nr_offset,
   const struct ureg_src *src,
-  unsigned nr_src )
+  unsigned nr_src,
+  unsigned bindless)
 {
struct ureg_emit_insn_result insn;
unsigned i;
@@ -1410,7 +1413,7 @@ ureg_tex_insn(struct ureg_program *ureg,
  nr_src);
 
ureg_emit_texture( ureg, insn.extended_token, target, return_type,
-  nr_offset );
+  nr_offset, bindless );
 
for (i = 0; i < nr_offset; i++)
   ureg_emit_texture_offset( ureg, [i]);
diff --git a/src/gallium/auxiliary/tgsi/tgsi_ureg.h 
b/src/gallium/auxiliary/tgsi/tgsi_ureg.h
index 54f95ba565..9e30a41ff7 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_ureg.h
+++ b/src/gallium/auxiliary/tgsi/tgsi_ureg.h
@@ -559,7 +559,8 @@ ureg_tex_insn(struct ureg_program *ureg,
   const struct tgsi_texture_offset *texoffsets,
   unsigned nr_offset,
   const struct ureg_src *src,
-  unsigned nr_src );
+  unsigned nr_src,
+  unsigned bindless);
 
 
 void
@@ -597,7 +598,8 @@ ureg_emit_label(struct ureg_program *ureg,
 void
 ureg_emit_texture(struct ureg_program *ureg,
   unsigned insn_token,
-  unsigned target, unsigned return_type, unsigned num_offsets);
+  unsigned target, unsigned return_type, unsigned num_offsets,
+  unsigned bindless);
 
 void
 ureg_emit_texture_offset(struct ureg_program *ureg,
@@ -759,7 +761,7 @@ static inline void ureg_##op( struct ureg_program *ureg,
\
  1, \
  2);\
ureg_emit_texture( ureg, insn.extended_token, target,\
-

[Mesa-dev] [RFC PATCH 52/65] radeonsi: implement ARB_bindless_texture

2017-05-19 Thread Samuel Pitoiset
This implements the Gallium interface. Decompression of resident
textures/images will follow in the next patches.

Signed-off-by: Samuel Pitoiset 
---
 src/gallium/drivers/radeonsi/si_descriptors.c | 340 ++
 src/gallium/drivers/radeonsi/si_pipe.c|  12 +
 src/gallium/drivers/radeonsi/si_pipe.h|  26 ++
 3 files changed, 378 insertions(+)

diff --git a/src/gallium/drivers/radeonsi/si_descriptors.c 
b/src/gallium/drivers/radeonsi/si_descriptors.c
index abe39de583..a687506f7f 100644
--- a/src/gallium/drivers/radeonsi/si_descriptors.c
+++ b/src/gallium/drivers/radeonsi/si_descriptors.c
@@ -60,6 +60,7 @@
 #include "sid.h"
 #include "gfx9d.h"
 
+#include "util/hash_table.h"
 #include "util/u_format.h"
 #include "util/u_memory.h"
 #include "util/u_upload_mgr.h"
@@ -2193,6 +2194,339 @@ void si_resident_descriptor_slab_free(void *priv, 
struct pb_slab *pslab)
FREE(slab);
 }
 
+static int si_add_resident_tex_handle(struct si_context *sctx,
+ struct si_texture_handle *tex_handle)
+{
+   int idx;
+
+   /* New resident handle, check if the backing array is large enough. */
+   if (sctx->num_resident_tex_handles >= sctx->max_resident_tex_handles) {
+   unsigned new_max_handles =
+   MAX2(1, sctx->max_resident_tex_handles * 2);
+   struct si_texture_handle **new_handles =
+   REALLOC(sctx->resident_tex_handles,
+   sctx->num_resident_tex_handles * 
(sizeof(*new_handles)),
+   new_max_handles * sizeof(*new_handles));
+
+   if (new_handles) {
+   sctx->resident_tex_handles = new_handles;
+   sctx->max_resident_tex_handles = new_max_handles;
+   } else {
+   fprintf(stderr, "si_add_resident_tex_handle: "
+   "allocation failed\n");
+   return -1;
+   }
+   }
+
+   idx = sctx->num_resident_tex_handles;
+   sctx->resident_tex_handles[idx] = tex_handle;
+   sctx->num_resident_tex_handles++;
+
+   return 0;
+}
+
+static void si_del_resident_tex_handle(struct si_context *sctx,
+  struct si_texture_handle *tex_handle)
+{
+   unsigned i;
+   int size;
+
+   for (i = 0; i < sctx->num_resident_tex_handles; i++) {
+   if (sctx->resident_tex_handles[i] != tex_handle)
+   continue;
+
+   if (i < sctx->num_resident_tex_handles - 1) {
+   size = sizeof(*sctx->resident_tex_handles) *
+   (sctx->num_resident_tex_handles - 1 - i);
+
+   memmove(>resident_tex_handles[i],
+   >resident_tex_handles[i + 1], size);
+   }
+
+   sctx->num_resident_tex_handles--;
+   return;
+   }
+}
+
+static int si_add_resident_img_handle(struct si_context *sctx,
+ struct si_image_handle *img_handle)
+{
+   int idx;
+
+   /* New resident handle, check if the backing array is large enough. */
+   if (sctx->num_resident_img_handles >= sctx->max_resident_img_handles) {
+   unsigned new_max_handles =
+   MAX2(1, sctx->max_resident_img_handles * 2);
+   struct si_image_handle **new_handles =
+   REALLOC(sctx->resident_img_handles,
+   sctx->num_resident_img_handles * 
(sizeof(*new_handles)),
+   new_max_handles * sizeof(*new_handles));
+
+   if (new_handles) {
+   sctx->resident_img_handles = new_handles;
+   sctx->max_resident_img_handles = new_max_handles;
+   } else {
+   fprintf(stderr, "si_add_resident_img_handle: "
+   "allocation failed\n");
+   return -1;
+   }
+   }
+
+   idx = sctx->num_resident_img_handles;
+   sctx->resident_img_handles[idx] = img_handle;
+   sctx->num_resident_img_handles++;
+
+   return 0;
+}
+
+static void si_del_resident_img_handle(struct si_context *sctx,
+  struct si_image_handle *img_handle)
+{
+   unsigned i;
+   int size;
+
+   for (i = 0; i < sctx->num_resident_img_handles; i++) {
+   if (sctx->resident_img_handles[i] != img_handle)
+   continue;
+
+   if (i < sctx->num_resident_img_handles - 1) {
+   size = sizeof(*sctx->resident_img_handles) *
+   (sctx->num_resident_img_handles - 1 - i);
+
+   memmove(>resident_img_handles[i],
+   >resident_img_handles[i + 1], size);
+   }
+
+

[Mesa-dev] [RFC PATCH 49/65] radeonsi: add si_init_descriptor_list() helper

2017-05-19 Thread Samuel Pitoiset
This will be used in order to initialize resident descriptors
for bindless textures/images.

Signed-off-by: Samuel Pitoiset 
---
 src/gallium/drivers/radeonsi/si_descriptors.c | 15 +++
 1 file changed, 15 insertions(+)

diff --git a/src/gallium/drivers/radeonsi/si_descriptors.c 
b/src/gallium/drivers/radeonsi/si_descriptors.c
index d337fc3f11..b2fe6a3de7 100644
--- a/src/gallium/drivers/radeonsi/si_descriptors.c
+++ b/src/gallium/drivers/radeonsi/si_descriptors.c
@@ -95,6 +95,21 @@ static uint32_t null_image_descriptor[8] = {
 * descriptor */
 };
 
+static void si_init_descriptor_list(uint32_t *desc_list,
+   unsigned element_dw_size,
+   unsigned num_elements,
+   const uint32_t *null_descriptor)
+{
+   int i;
+
+   /* Initialize the array to NULL descriptors if the element size is 8. */
+   if (null_descriptor) {
+   assert(element_dw_size % 8 == 0);
+   for (i = 0; i < num_elements * element_dw_size / 8; i++)
+   memcpy(desc_list + i * 8, null_descriptor, 8 * 4);
+   }
+}
+
 static void si_init_descriptors(struct si_context *sctx,
struct si_descriptors *desc,
unsigned shader_userdata_index,
-- 
2.13.0

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


[Mesa-dev] [RFC PATCH 24/65] gallium: add PIPE_CAP_BINDLESS_TEXTURE

2017-05-19 Thread Samuel Pitoiset
Whether bindless texture operations are supported by the
underlying driver.

Signed-off-by: Samuel Pitoiset 
---
 src/gallium/docs/source/screen.rst   | 2 ++
 src/gallium/drivers/etnaviv/etnaviv_screen.c | 1 +
 src/gallium/drivers/freedreno/freedreno_screen.c | 1 +
 src/gallium/drivers/i915/i915_screen.c   | 1 +
 src/gallium/drivers/llvmpipe/lp_screen.c | 1 +
 src/gallium/drivers/nouveau/nv30/nv30_screen.c   | 1 +
 src/gallium/drivers/nouveau/nv50/nv50_screen.c   | 1 +
 src/gallium/drivers/nouveau/nvc0/nvc0_screen.c   | 1 +
 src/gallium/drivers/r300/r300_screen.c   | 1 +
 src/gallium/drivers/r600/r600_pipe.c | 1 +
 src/gallium/drivers/radeonsi/si_pipe.c   | 1 +
 src/gallium/drivers/softpipe/sp_screen.c | 1 +
 src/gallium/drivers/svga/svga_screen.c   | 1 +
 src/gallium/drivers/swr/swr_screen.cpp   | 1 +
 src/gallium/drivers/vc4/vc4_screen.c | 1 +
 src/gallium/drivers/virgl/virgl_screen.c | 1 +
 src/gallium/include/pipe/p_defines.h | 1 +
 17 files changed, 18 insertions(+)

diff --git a/src/gallium/docs/source/screen.rst 
b/src/gallium/docs/source/screen.rst
index 871669c0d9..fa524d419c 100644
--- a/src/gallium/docs/source/screen.rst
+++ b/src/gallium/docs/source/screen.rst
@@ -392,6 +392,8 @@ The integer capabilities:
 * ``PIPE_CAP_CAN_BIND_CONST_BUFFER_AS_VERTEX``: Whether a buffer with just
   PIPE_BIND_CONSTANT_BUFFER can be legally passed to set_vertex_buffers.
 * ``PIPE_CAP_ALLOW_MAPPED_BUFFERS_DURING_EXECUTION``: As the name says.
+* ``PIPE_CAP_BINDLESS_TEXTURE``: Whether bindless texture operations are
+  supported.
 
 
 .. _pipe_capf:
diff --git a/src/gallium/drivers/etnaviv/etnaviv_screen.c 
b/src/gallium/drivers/etnaviv/etnaviv_screen.c
index bf13184ad6..5d10f76815 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_screen.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_screen.c
@@ -256,6 +256,7 @@ etna_screen_get_param(struct pipe_screen *pscreen, enum 
pipe_cap param)
case PIPE_CAP_TGSI_TES_LAYER_VIEWPORT:
case PIPE_CAP_CAN_BIND_CONST_BUFFER_AS_VERTEX:
case PIPE_CAP_ALLOW_MAPPED_BUFFERS_DURING_EXECUTION:
+   case PIPE_CAP_BINDLESS_TEXTURE:
   return 0;
 
/* Stream output. */
diff --git a/src/gallium/drivers/freedreno/freedreno_screen.c 
b/src/gallium/drivers/freedreno/freedreno_screen.c
index a00afd3fa4..eb3ac61d6c 100644
--- a/src/gallium/drivers/freedreno/freedreno_screen.c
+++ b/src/gallium/drivers/freedreno/freedreno_screen.c
@@ -315,6 +315,7 @@ fd_screen_get_param(struct pipe_screen *pscreen, enum 
pipe_cap param)
case PIPE_CAP_TGSI_TES_LAYER_VIEWPORT:
case PIPE_CAP_CAN_BIND_CONST_BUFFER_AS_VERTEX:
case PIPE_CAP_ALLOW_MAPPED_BUFFERS_DURING_EXECUTION:
+   case PIPE_CAP_BINDLESS_TEXTURE:
return 0;
 
case PIPE_CAP_MAX_VIEWPORTS:
diff --git a/src/gallium/drivers/i915/i915_screen.c 
b/src/gallium/drivers/i915/i915_screen.c
index 1cf9441ef1..3ee59ab9fb 100644
--- a/src/gallium/drivers/i915/i915_screen.c
+++ b/src/gallium/drivers/i915/i915_screen.c
@@ -308,6 +308,7 @@ i915_get_param(struct pipe_screen *screen, enum pipe_cap 
cap)
case PIPE_CAP_TGSI_TES_LAYER_VIEWPORT:
case PIPE_CAP_CAN_BIND_CONST_BUFFER_AS_VERTEX:
case PIPE_CAP_ALLOW_MAPPED_BUFFERS_DURING_EXECUTION:
+   case PIPE_CAP_BINDLESS_TEXTURE:
   return 0;
 
case PIPE_CAP_MAX_VIEWPORTS:
diff --git a/src/gallium/drivers/llvmpipe/lp_screen.c 
b/src/gallium/drivers/llvmpipe/lp_screen.c
index 656de49549..de954c44c0 100644
--- a/src/gallium/drivers/llvmpipe/lp_screen.c
+++ b/src/gallium/drivers/llvmpipe/lp_screen.c
@@ -354,6 +354,7 @@ llvmpipe_get_param(struct pipe_screen *screen, enum 
pipe_cap param)
case PIPE_CAP_TGSI_TES_LAYER_VIEWPORT:
case PIPE_CAP_CAN_BIND_CONST_BUFFER_AS_VERTEX:
case PIPE_CAP_ALLOW_MAPPED_BUFFERS_DURING_EXECUTION:
+   case PIPE_CAP_BINDLESS_TEXTURE:
   return 0;
}
/* should only get here on unhandled cases */
diff --git a/src/gallium/drivers/nouveau/nv30/nv30_screen.c 
b/src/gallium/drivers/nouveau/nv30/nv30_screen.c
index e8d14bfea4..58c4f42f13 100644
--- a/src/gallium/drivers/nouveau/nv30/nv30_screen.c
+++ b/src/gallium/drivers/nouveau/nv30/nv30_screen.c
@@ -218,6 +218,7 @@ nv30_screen_get_param(struct pipe_screen *pscreen, enum 
pipe_cap param)
case PIPE_CAP_TGSI_BALLOT:
case PIPE_CAP_TGSI_TES_LAYER_VIEWPORT:
case PIPE_CAP_CAN_BIND_CONST_BUFFER_AS_VERTEX:
+   case PIPE_CAP_BINDLESS_TEXTURE:
   return 0;
 
case PIPE_CAP_VENDOR_ID:
diff --git a/src/gallium/drivers/nouveau/nv50/nv50_screen.c 
b/src/gallium/drivers/nouveau/nv50/nv50_screen.c
index 59afd14fac..e0b959cc4c 100644
--- a/src/gallium/drivers/nouveau/nv50/nv50_screen.c
+++ b/src/gallium/drivers/nouveau/nv50/nv50_screen.c
@@ -270,6 +270,7 @@ nv50_screen_get_param(struct pipe_screen *pscreen, enum 
pipe_cap param)
case PIPE_CAP_SPARSE_BUFFER_PAGE_SIZE:
case PIPE_CAP_TGSI_BALLOT:
case 

[Mesa-dev] [RFC PATCH 28/65] tc: add ARB_bindless_texture support

2017-05-19 Thread Samuel Pitoiset
Signed-off-by: Samuel Pitoiset 
---
 src/gallium/auxiliary/util/u_threaded_context.c| 147 +
 .../auxiliary/util/u_threaded_context_calls.h  |   4 +
 2 files changed, 151 insertions(+)

diff --git a/src/gallium/auxiliary/util/u_threaded_context.c 
b/src/gallium/auxiliary/util/u_threaded_context.c
index 8ea7f8aa26..36c2e4ed46 100644
--- a/src/gallium/auxiliary/util/u_threaded_context.c
+++ b/src/gallium/auxiliary/util/u_threaded_context.c
@@ -1086,6 +1086,147 @@ tc_stream_output_target_destroy(struct pipe_context 
*_pipe,
 
 
 /
+ * bindless
+ */
+
+static uint64_t
+tc_create_texture_handle(struct pipe_context *_pipe,
+ struct pipe_resource *res,
+ struct pipe_sampler_view *view,
+ const struct pipe_sampler_state *state)
+{
+   struct threaded_context *tc = threaded_context(_pipe);
+   struct pipe_context *pipe = tc->pipe;
+
+   tc_sync(tc);
+   return pipe->create_texture_handle(pipe, res, view, state);
+}
+
+struct tc_delete_texture_handle
+{
+   uint64_t handle;
+};
+
+static void
+tc_call_delete_texture_handle(struct pipe_context *pipe,
+  union tc_payload *payload)
+{
+   struct tc_delete_texture_handle *p =
+  (struct tc_delete_texture_handle *)payload;
+
+   pipe->delete_texture_handle(pipe, p->handle);
+}
+
+static void
+tc_delete_texture_handle(struct pipe_context *_pipe, uint64_t handle)
+{
+   struct threaded_context *tc = threaded_context(_pipe);
+   struct tc_delete_texture_handle *p =
+  tc_add_struct_typed_call(tc, TC_CALL_delete_texture_handle,
+   tc_delete_texture_handle);
+
+   p->handle = handle;
+}
+
+struct tc_make_texture_handle_resident
+{
+   uint64_t handle;
+   bool resident;
+};
+
+static void
+tc_call_make_texture_handle_resident(struct pipe_context *pipe,
+ union tc_payload *payload)
+{
+   struct tc_make_texture_handle_resident *p =
+  (struct tc_make_texture_handle_resident *)payload;
+
+   pipe->make_texture_handle_resident(pipe, p->handle, p->resident);
+}
+
+static void
+tc_make_texture_handle_resident(struct pipe_context *_pipe, uint64_t handle,
+bool resident)
+{
+   struct threaded_context *tc = threaded_context(_pipe);
+   struct tc_make_texture_handle_resident *p =
+  tc_add_struct_typed_call(tc, TC_CALL_make_texture_handle_resident,
+   tc_make_texture_handle_resident);
+
+   p->handle = handle;
+   p->resident = resident;
+}
+
+static uint64_t
+tc_create_image_handle(struct pipe_context *_pipe,
+   const struct pipe_image_view *image)
+{
+   struct threaded_context *tc = threaded_context(_pipe);
+   struct pipe_context *pipe = tc->pipe;
+
+   tc_sync(tc);
+   return pipe->create_image_handle(pipe, image);
+}
+
+struct tc_delete_image_handle
+{
+   uint64_t handle;
+};
+
+static void
+tc_call_delete_image_handle(struct pipe_context *pipe,
+union tc_payload *payload)
+{
+   struct tc_delete_image_handle *p =
+  (struct tc_delete_image_handle *)payload;
+
+   pipe->delete_image_handle(pipe, p->handle);
+}
+
+static void
+tc_delete_image_handle(struct pipe_context *_pipe, uint64_t handle)
+{
+   struct threaded_context *tc = threaded_context(_pipe);
+   struct tc_delete_image_handle *p =
+  tc_add_struct_typed_call(tc, TC_CALL_delete_image_handle,
+   tc_delete_image_handle);
+
+   p->handle = handle;
+}
+
+struct tc_make_image_handle_resident
+{
+   uint64_t handle;
+   unsigned access;
+   bool resident;
+};
+
+static void
+tc_call_make_image_handle_resident(struct pipe_context *pipe,
+ union tc_payload *payload)
+{
+   struct tc_make_image_handle_resident *p =
+  (struct tc_make_image_handle_resident *)payload;
+
+   pipe->make_image_handle_resident(pipe, p->handle, p->access, p->resident);
+}
+
+static void
+tc_make_image_handle_resident(struct pipe_context *_pipe, uint64_t handle,
+  unsigned access, bool resident)
+{
+   struct threaded_context *tc = threaded_context(_pipe);
+   struct tc_make_image_handle_resident *p =
+  tc_add_struct_typed_call(tc, TC_CALL_make_image_handle_resident,
+   tc_make_image_handle_resident);
+
+   p->handle = handle;
+   p->access = access;
+   p->resident = resident;
+}
+
+
+/
  * transfer
  */
 
@@ -2311,6 +2452,12 @@ threaded_context_create(struct pipe_context *pipe,
CTX_INIT(create_fence_fd);
CTX_INIT(fence_server_sync);
CTX_INIT(get_timestamp);
+   CTX_INIT(create_texture_handle);
+   CTX_INIT(delete_texture_handle);
+   CTX_INIT(make_texture_handle_resident);
+   CTX_INIT(create_image_handle);
+   

[Mesa-dev] [RFC PATCH 10/65] mesa: store bindless samplers as PROGRAM_UNIFORM

2017-05-19 Thread Samuel Pitoiset
Old-style samplers (ie. bound samplers) are stored as
PROGRAM_SAMPLER, while bindless ones are PROGRAM_UNIFORM.

Signed-off-by: Samuel Pitoiset 
---
 src/mesa/program/ir_to_mesa.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp
index a1a788e9e8..8ed249f8ca 100644
--- a/src/mesa/program/ir_to_mesa.cpp
+++ b/src/mesa/program/ir_to_mesa.cpp
@@ -2462,7 +2462,7 @@ add_uniform_to_shader::visit_field(const glsl_type *type, 
const char *name,
}
 
gl_register_file file;
-   if (type->without_array()->is_sampler()) {
+   if (type->without_array()->is_sampler() && !var->data.bindless) {
   file = PROGRAM_SAMPLER;
} else {
   file = PROGRAM_UNIFORM;
-- 
2.13.0

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


[Mesa-dev] [RFC PATCH 20/65] mesa: pass gl_program to _mesa_associate_uniform_storage()

2017-05-19 Thread Samuel Pitoiset
Signed-off-by: Samuel Pitoiset 
---
 src/mesa/program/ir_to_mesa.cpp| 7 ---
 src/mesa/program/ir_to_mesa.h  | 4 ++--
 src/mesa/state_tracker/st_glsl_to_nir.cpp  | 3 +--
 src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 3 +--
 src/mesa/state_tracker/st_shader_cache.c   | 3 +--
 5 files changed, 9 insertions(+), 11 deletions(-)

diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp
index 8ed249f8ca..5e6304036d 100644
--- a/src/mesa/program/ir_to_mesa.cpp
+++ b/src/mesa/program/ir_to_mesa.cpp
@@ -2537,9 +2537,11 @@ _mesa_generate_parameters_list_for_uniforms(struct 
gl_shader_program
 void
 _mesa_associate_uniform_storage(struct gl_context *ctx,
 struct gl_shader_program *shader_program,
-struct gl_program_parameter_list *params,
+struct gl_program *prog,
 bool propagate_to_storage)
 {
+   struct gl_program_parameter_list *params = prog->Parameters;
+
/* After adding each uniform to the parameter list, connect the storage for
 * the parameter with the tracking structure used by the API for the
 * uniform.
@@ -2987,8 +2989,7 @@ get_mesa_program(struct gl_context *ctx,
 * prog->ParameterValues to get reallocated (e.g., anything that adds a
 * program constant) has to happen before creating this linkage.
 */
-   _mesa_associate_uniform_storage(ctx, shader_program, prog->Parameters,
-   true);
+   _mesa_associate_uniform_storage(ctx, shader_program, prog, true);
if (!shader_program->data->LinkStatus) {
   goto fail_exit;
}
diff --git a/src/mesa/program/ir_to_mesa.h b/src/mesa/program/ir_to_mesa.h
index 09446197b2..e3d364455c 100644
--- a/src/mesa/program/ir_to_mesa.h
+++ b/src/mesa/program/ir_to_mesa.h
@@ -45,8 +45,8 @@ _mesa_generate_parameters_list_for_uniforms(struct 
gl_shader_program
*params);
 void
 _mesa_associate_uniform_storage(struct gl_context *ctx,
-   struct gl_shader_program *shader_program,
-struct gl_program_parameter_list *params,
+struct gl_shader_program *shader_program,
+struct gl_program *prog,
 bool propagate_to_storage);
 
 #ifdef __cplusplus
diff --git a/src/mesa/state_tracker/st_glsl_to_nir.cpp 
b/src/mesa/state_tracker/st_glsl_to_nir.cpp
index fd5eeea0f9..524eefa236 100644
--- a/src/mesa/state_tracker/st_glsl_to_nir.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_nir.cpp
@@ -436,8 +436,7 @@ st_nir_get_mesa_program(struct gl_context *ctx,
 * prog->ParameterValues to get reallocated (e.g., anything that adds a
 * program constant) has to happen before creating this linkage.
 */
-   _mesa_associate_uniform_storage(ctx, shader_program, prog->Parameters,
-   true);
+   _mesa_associate_uniform_storage(ctx, shader_program, prog, true);
 
struct st_vertex_program *stvp;
struct st_fragment_program *stfp;
diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp 
b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index 76cd4dc3a5..7571e7d495 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -6805,8 +6805,7 @@ get_mesa_program_tgsi(struct gl_context *ctx,
 * prog->ParameterValues to get reallocated (e.g., anything that adds a
 * program constant) has to happen before creating this linkage.
 */
-   _mesa_associate_uniform_storage(ctx, shader_program, prog->Parameters,
-   true);
+   _mesa_associate_uniform_storage(ctx, shader_program, prog, true);
if (!shader_program->data->LinkStatus) {
   free_glsl_to_tgsi_visitor(v);
   _mesa_reference_program(ctx, >Program, NULL);
diff --git a/src/mesa/state_tracker/st_shader_cache.c 
b/src/mesa/state_tracker/st_shader_cache.c
index 23416c0c3f..068b4e20bb 100644
--- a/src/mesa/state_tracker/st_shader_cache.c
+++ b/src/mesa/state_tracker/st_shader_cache.c
@@ -360,8 +360,7 @@ st_load_tgsi_from_disk_cache(struct gl_context *ctx,
  }
 
  st_set_prog_affected_state_flags(glprog);
- _mesa_associate_uniform_storage(ctx, prog, glprog->Parameters,
- false);
+ _mesa_associate_uniform_storage(ctx, prog, glprog, false);
 
  free(buffer);
   } else {
-- 
2.13.0

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


[Mesa-dev] [RFC PATCH 26/65] ddebug: add ARB_bindless_texture support

2017-05-19 Thread Samuel Pitoiset
Signed-off-by: Samuel Pitoiset 
---
 src/gallium/drivers/ddebug/dd_context.c | 61 +
 1 file changed, 61 insertions(+)

diff --git a/src/gallium/drivers/ddebug/dd_context.c 
b/src/gallium/drivers/ddebug/dd_context.c
index 8260d4f869..8a07411c46 100644
--- a/src/gallium/drivers/ddebug/dd_context.c
+++ b/src/gallium/drivers/ddebug/dd_context.c
@@ -764,6 +764,61 @@ dd_context_dump_debug_state(struct pipe_context *_pipe, 
FILE *stream,
return pipe->dump_debug_state(pipe, stream, flags);
 }
 
+static uint64_t
+dd_context_create_texture_handle(struct pipe_context *_pipe,
+ struct pipe_resource *res,
+ struct pipe_sampler_view *view,
+ const struct pipe_sampler_state *state)
+{
+   struct pipe_context *pipe = dd_context(_pipe)->pipe;
+
+   return pipe->create_texture_handle(pipe, res, view, state);
+}
+
+static void
+dd_context_delete_texture_handle(struct pipe_context *_pipe, uint64_t handle)
+{
+   struct pipe_context *pipe = dd_context(_pipe)->pipe;
+
+   pipe->delete_texture_handle(pipe, handle);
+}
+
+static void
+dd_context_make_texture_handle_resident(struct pipe_context *_pipe,
+uint64_t handle, bool resident)
+{
+   struct pipe_context *pipe = dd_context(_pipe)->pipe;
+
+   pipe->make_texture_handle_resident(pipe, handle, resident);
+}
+
+static uint64_t
+dd_context_create_image_handle(struct pipe_context *_pipe,
+   const struct pipe_image_view *image)
+{
+   struct pipe_context *pipe = dd_context(_pipe)->pipe;
+
+   return pipe->create_image_handle(pipe, image);
+}
+
+static void
+dd_context_delete_image_handle(struct pipe_context *_pipe, uint64_t handle)
+{
+   struct pipe_context *pipe = dd_context(_pipe)->pipe;
+
+   pipe->delete_image_handle(pipe, handle);
+}
+
+static void
+dd_context_make_image_handle_resident(struct pipe_context *_pipe,
+  uint64_t handle, unsigned access,
+  bool resident)
+{
+   struct pipe_context *pipe = dd_context(_pipe)->pipe;
+
+   pipe->make_image_handle_resident(pipe, handle, access, resident);
+}
+
 struct pipe_context *
 dd_context_create(struct dd_screen *dscreen, struct pipe_context *pipe)
 {
@@ -866,6 +921,12 @@ dd_context_create(struct dd_screen *dscreen, struct 
pipe_context *pipe)
CTX_INIT(set_device_reset_callback);
CTX_INIT(dump_debug_state);
CTX_INIT(emit_string_marker);
+   CTX_INIT(create_texture_handle);
+   CTX_INIT(delete_texture_handle);
+   CTX_INIT(make_texture_handle_resident);
+   CTX_INIT(create_image_handle);
+   CTX_INIT(delete_image_handle);
+   CTX_INIT(make_image_handle_resident);
 
dd_init_draw_functions(dctx);
 
-- 
2.13.0

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


[Mesa-dev] [RFC PATCH 22/65] mesa: handle bindless uniforms bound to texture/image units

2017-05-19 Thread Samuel Pitoiset
Signed-off-by: Samuel Pitoiset 
---
 src/mesa/main/uniform_query.cpp | 122 ++--
 1 file changed, 116 insertions(+), 6 deletions(-)

diff --git a/src/mesa/main/uniform_query.cpp b/src/mesa/main/uniform_query.cpp
index cc145f29e9..be04e48d53 100644
--- a/src/mesa/main/uniform_query.cpp
+++ b/src/mesa/main/uniform_query.cpp
@@ -993,9 +993,25 @@ _mesa_uniform(GLint location, GLsizei count, const GLvoid 
*values,
  bool changed = false;
  for (int j = 0; j < count; j++) {
 unsigned unit = uni->opaque[i].index + offset + j;
-if (sh->Program->SamplerUnits[unit] != ((unsigned *) values)[j]) {
-   sh->Program->SamplerUnits[unit] = ((unsigned *) values)[j];
-   changed = true;
+unsigned value = ((unsigned *)values)[j];
+
+if (uni->is_bindless) {
+   struct gl_bindless_sampler *sampler =
+  >Program->sh.BindlessSamplers[unit];
+
+   /* Mark this bindless sampler as bound to a texture unit.
+*/
+   if (sampler->unit != value) {
+  sampler->unit = value;
+  changed = true;
+   }
+   sampler->bound = true;
+   sh->Program->sh.HasBoundBindlessSampler = true;
+} else {
+   if (sh->Program->SamplerUnits[unit] != value) {
+  sh->Program->SamplerUnits[unit] = value;
+  changed = true;
+   }
 }
  }
 
@@ -1024,9 +1040,23 @@ _mesa_uniform(GLint location, GLsizei count, const 
GLvoid *values,
  if (!uni->opaque[i].active)
 continue;
 
- for (int j = 0; j < count; j++)
-sh->Program->sh.ImageUnits[uni->opaque[i].index + offset + j] =
-   ((GLint *) values)[j];
+ for (int j = 0; j < count; j++) {
+unsigned unit = uni->opaque[i].index + offset + j;
+unsigned value = ((unsigned *)values)[j];
+
+if (uni->is_bindless) {
+   struct gl_bindless_image *image =
+  >Program->sh.BindlessImages[unit];
+
+   /* Mark this bindless image as bound to an image unit.
+*/
+   image->unit = value;
+   image->bound = true;
+   sh->Program->sh.HasBoundBindlessImage = true;
+} else {
+   sh->Program->sh.ImageUnits[unit] = value;
+}
+ }
   }
 
   ctx->NewDriverState |= ctx->DriverFlags.NewImageUnits;
@@ -1173,6 +1203,40 @@ _mesa_uniform_matrix(GLint location, GLsizei count,
_mesa_propagate_uniforms_to_driver_storage(uni, offset, count);
 }
 
+static void
+update_bound_bindless_sampler_flag(struct gl_program *prog)
+{
+   unsigned i;
+
+   if (likely(!prog->sh.HasBoundBindlessSampler))
+  return;
+
+   for (i = 0; i < prog->sh.NumBindlessSamplers; i++) {
+  struct gl_bindless_sampler *sampler = >sh.BindlessSamplers[i];
+
+  if (sampler->bound)
+ return;
+   }
+   prog->sh.HasBoundBindlessSampler = false;
+}
+
+static void
+update_bound_bindless_image_flag(struct gl_program *prog)
+{
+   unsigned i;
+
+   if (likely(!prog->sh.HasBoundBindlessImage))
+  return;
+
+   for (i = 0; i < prog->sh.NumBindlessImages; i++) {
+  struct gl_bindless_image *image = >sh.BindlessImages[i];
+
+  if (image->bound)
+ return;
+   }
+   prog->sh.HasBoundBindlessImage = false;
+}
+
 /**
  * Called via glUniformHandleui64*ARB() functions.
  */
@@ -1236,6 +1300,52 @@ _mesa_uniform_handle(GLint location, GLsizei count, 
const GLvoid *values,
   sizeof(uni->storage[0]) * components * count * size_mul);
 
_mesa_propagate_uniforms_to_driver_storage(uni, offset, count);
+
+   if (uni->type->is_sampler()) {
+  /* Mark this bindless sampler as not bound to a texture unit because
+   * it refers to a texture handle.
+   */
+  for (int i = 0; i < MESA_SHADER_STAGES; i++) {
+ struct gl_linked_shader *const sh = shProg->_LinkedShaders[i];
+
+ /* If the shader stage doesn't use the sampler uniform, skip this. */
+ if (!uni->opaque[i].active)
+continue;
+
+ for (int j = 0; j < count; j++) {
+unsigned unit = uni->opaque[i].index + offset + j;
+struct gl_bindless_sampler *sampler =
+   >Program->sh.BindlessSamplers[unit];
+
+sampler->bound = false;
+ }
+
+ update_bound_bindless_sampler_flag(sh->Program);
+  }
+   }
+
+   if (uni->type->is_image()) {
+  /* Mark this bindless image as not bound to an image unit because it
+   * refers to a texture handle.
+   */
+  for (int i = 0; i < MESA_SHADER_STAGES; i++) {
+ struct gl_linked_shader *sh = shProg->_LinkedShaders[i];
+
+ /* If the shader stage doesn't use the sampler uniform, skip this. */
+ if (!uni->opaque[i].active)

[Mesa-dev] [RFC PATCH 33/65] st/glsl_to_tgsi: add support for bindless images

2017-05-19 Thread Samuel Pitoiset
Signed-off-by: Samuel Pitoiset 
---
 src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 78 --
 1 file changed, 63 insertions(+), 15 deletions(-)

diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp 
b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index 5734d0e456..264b43c10b 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -288,7 +288,7 @@ public:
 
st_dst_reg dst[2];
st_src_reg src[4];
-   st_src_reg resource; /**< sampler or buffer register */
+   st_src_reg resource; /**< sampler, image or buffer register */
st_src_reg *tex_offsets;
 
/** Pointer to the ir source this tree came from for debugging */
@@ -3765,15 +3765,46 @@ glsl_to_tgsi_visitor::visit_image_intrinsic(ir_call *ir)
exec_node *param = ir->actual_parameters.get_head();
 
ir_dereference *img = (ir_dereference *)param;
-   const ir_variable *imgvar = img->variable_referenced();
-   const glsl_type *type = imgvar->type->without_array();
+   const struct glsl_struct_field *struct_field = NULL;
unsigned sampler_array_size = 1, sampler_base = 0;
+   unsigned memory_coherent, memory_volatile, memory_restrict, image_format;
+   const ir_variable *imgvar;
+   const glsl_type *type;
+
+   if (img->ir_type == ir_type_dereference_record) {
+  ir_dereference_record *r = img->as_dereference_record();
+  const glsl_type *struct_type = r->record->type;
+
+  for (unsigned i = 0; i < struct_type->length; i++) {
+ if (!strcmp(struct_type->fields.structure[i].name, r->field)) {
+struct_field = _type->fields.structure[i];
+break;
+ }
+  }
+  assert(struct_field);
+   }
+
+   imgvar = img->variable_referenced();
+
+   if (struct_field) {
+  type = struct_field->type;
+  memory_coherent = struct_field->memory_coherent;
+  memory_volatile = struct_field->memory_volatile;
+  memory_restrict = struct_field->memory_restrict;
+  image_format = struct_field->image_format;
+   } else {
+  type = imgvar->type->without_array();
+  memory_coherent = imgvar->data.memory_coherent;
+  memory_volatile = imgvar->data.memory_volatile;
+  memory_restrict = imgvar->data.memory_restrict;
+  image_format = imgvar->data.image_format;
+   }
 
st_src_reg reladdr;
st_src_reg image(PROGRAM_IMAGE, 0, GLSL_TYPE_UINT);
 
get_deref_offsets(img, _array_size, _base,
- (uint16_t*), , true);
+ (uint16_t*), , 
!imgvar->is_bindless());
 
if (reladdr.file != PROGRAM_UNDEFINED) {
   image.reladdr = ralloc(mem_ctx, st_src_reg);
@@ -3886,19 +3917,27 @@ glsl_to_tgsi_visitor::visit_image_intrinsic(ir_call *ir)
  inst->dst[0].writemask = WRITEMASK_XYZW;
}
 
-   inst->resource = image;
-   inst->sampler_array_size = sampler_array_size;
-   inst->sampler_base = sampler_base;
+   if (imgvar->is_bindless()) {
+  img->accept(this);
+  inst->resource = this->result;
+  inst->resource.swizzle = MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_Y,
+ SWIZZLE_X, SWIZZLE_Y);
+  inst->bindless = 1;
+   } else {
+  inst->resource = image;
+  inst->sampler_array_size = sampler_array_size;
+  inst->sampler_base = sampler_base;
+   }
 
inst->tex_target = type->sampler_index();
inst->image_format = st_mesa_format_to_pipe_format(st_context(ctx),
- _mesa_get_shader_image_format(imgvar->data.image_format));
+ _mesa_get_shader_image_format(image_format));
 
-   if (imgvar->data.memory_coherent)
+   if (memory_coherent)
   inst->buffer_access |= TGSI_MEMORY_COHERENT;
-   if (imgvar->data.memory_restrict)
+   if (memory_restrict)
   inst->buffer_access |= TGSI_MEMORY_RESTRICT;
-   if (imgvar->data.memory_volatile)
+   if (memory_volatile)
   inst->buffer_access |= TGSI_MEMORY_VOLATILE;
 }
 
@@ -5911,7 +5950,12 @@ compile_tgsi_instruction(struct st_translate *t,
   } else if (inst->resource.file == PROGRAM_BUFFER) {
  src[0] = t->buffers[inst->resource.index];
   } else {
- src[0] = t->images[inst->resource.index];
+ if (inst->resource.file == PROGRAM_IMAGE) {
+src[0] = t->images[inst->resource.index];
+ } else {
+/* Bindless images. */
+src[0] = translate_src(t, >resource);
+ }
  tex_target = st_translate_texture_target(inst->tex_target, 
inst->tex_shadow);
   }
   if (inst->resource.reladdr)
@@ -5919,7 +5963,7 @@ compile_tgsi_instruction(struct st_translate *t,
   assert(src[0].File != TGSI_FILE_NULL);
   ureg_memory_insn(ureg, inst->op, dst, num_dst, src, num_src,
inst->buffer_access,
-   tex_target, inst->image_format, 0);
+   tex_target, inst->image_format, inst->bindless);
   break;
 
case TGSI_OPCODE_STORE:
@@ -5928,7 +5972,11 @@ 

[Mesa-dev] [RFC PATCH 32/65] st/glsl_to_tgsi: add support for bindless samplers

2017-05-19 Thread Samuel Pitoiset
Signed-off-by: Samuel Pitoiset 
---
 src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 27 +--
 1 file changed, 21 insertions(+), 6 deletions(-)

diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp 
b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index ef6597e083..5734d0e456 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -306,6 +306,7 @@ public:
unsigned tex_offset_num_offset:3;
unsigned dead_mask:4; /**< Used in dead code elimination */
unsigned buffer_access:3; /**< buffer access type */
+   unsigned bindless:1; /**< bindless sampler/image */
 
const struct tgsi_opcode_info *info;
 };
@@ -4154,6 +4155,7 @@ glsl_to_tgsi_visitor::visit(ir_texture *ir)
const glsl_type *sampler_type = ir->sampler->type;
unsigned sampler_array_size = 1, sampler_base = 0;
bool is_cube_array = false, is_cube_shadow = false;
+   ir_variable *var = ir->sampler->variable_referenced();
unsigned i;
 
/* if we are a cube array sampler or a cube shadow */
@@ -4386,7 +4388,7 @@ glsl_to_tgsi_visitor::visit(ir_texture *ir)
st_src_reg sampler(PROGRAM_SAMPLER, 0, GLSL_TYPE_UINT);
 
get_deref_offsets(ir->sampler, _array_size, _base,
- (uint16_t *), , true);
+ (uint16_t *), , 
!var->is_bindless());
 
if (reladdr.file != PROGRAM_UNDEFINED) {
   sampler.reladdr = ralloc(mem_ctx, st_src_reg);
@@ -4423,9 +4425,17 @@ glsl_to_tgsi_visitor::visit(ir_texture *ir)
if (ir->shadow_comparator)
   inst->tex_shadow = GL_TRUE;
 
-   inst->resource = sampler;
-   inst->sampler_array_size = sampler_array_size;
-   inst->sampler_base = sampler_base;
+   if (var->is_bindless()) {
+  ir->sampler->accept(this);
+  inst->resource = this->result;
+  inst->resource.swizzle = MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_Y,
+ SWIZZLE_X, SWIZZLE_Y);
+  inst->bindless = 1;
+   } else {
+  inst->resource = sampler;
+  inst->sampler_array_size = sampler_array_size;
+  inst->sampler_base = sampler_base;
+   }
 
if (ir->offset) {
   if (!inst->tex_offsets)
@@ -5856,7 +5866,12 @@ compile_tgsi_instruction(struct st_translate *t,
case TGSI_OPCODE_TXL2:
case TGSI_OPCODE_TG4:
case TGSI_OPCODE_LODQ:
-  src[num_src] = t->samplers[inst->resource.index];
+  if (inst->resource.file == PROGRAM_SAMPLER) {
+ src[num_src] = t->samplers[inst->resource.index];
+  } else {
+ /* Bindless samplers. */
+ src[num_src] = translate_src(t, >resource);
+  }
   assert(src[num_src].File != TGSI_FILE_NULL);
   if (inst->resource.reladdr)
  src[num_src] =
@@ -5873,7 +5888,7 @@ compile_tgsi_instruction(struct st_translate *t,
 tex_target,
 st_translate_texture_type(inst->tex_type),
 texoffsets, inst->tex_offset_num_offset,
-src, num_src, 0);
+src, num_src, inst->bindless);
   return;
 
case TGSI_OPCODE_RESQ:
-- 
2.13.0

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


[Mesa-dev] [RFC PATCH 17/65] mesa: add update_single_shader_texture_used() helper

2017-05-19 Thread Samuel Pitoiset
This will also be used for looping over bindless samplers bound
to texture units.

Signed-off-by: Samuel Pitoiset 
---
 src/mesa/main/uniforms.c | 67 +++-
 1 file changed, 38 insertions(+), 29 deletions(-)

diff --git a/src/mesa/main/uniforms.c b/src/mesa/main/uniforms.c
index 67c238e4f3..6706f794d7 100644
--- a/src/mesa/main/uniforms.c
+++ b/src/mesa/main/uniforms.c
@@ -63,6 +63,40 @@
  * TEXTURE_2D_INDEX, TEXTURE_3D_INDEX, etc.
  * We'll use that info for state validation before rendering.
  */
+static inline void
+update_single_shader_texture_used(struct gl_shader_program *shProg,
+  struct gl_program *prog,
+  GLuint unit, GLuint target)
+{
+   gl_shader_stage prog_stage =
+  _mesa_program_enum_to_shader_stage(prog->Target);
+
+   assert(unit < ARRAY_SIZE(prog->TexturesUsed));
+   assert(target < NUM_TEXTURE_TARGETS);
+
+   /* From section 7.10 (Samplers) of the OpenGL 4.5 spec:
+*
+* "It is not allowed to have variables of different sampler types pointing
+*  to the same texture image unit within a program object."
+*/
+   unsigned stages_mask = shProg->data->linked_stages;
+   while (stages_mask) {
+  const int stage = u_bit_scan(_mask);
+
+  /* Skip validation if we are yet to update textures used in this
+   * stage.
+   */
+  if (prog_stage < stage)
+ break;
+
+  struct gl_program *glprog = shProg->_LinkedShaders[stage]->Program;
+  if (glprog->TexturesUsed[unit] & ~(1 << target))
+ shProg->SamplersValidated = GL_FALSE;
+   }
+
+   prog->TexturesUsed[unit] |= (1 << target);
+}
+
 void
 _mesa_update_shader_textures_used(struct gl_shader_program *shProg,
   struct gl_program *prog)
@@ -78,35 +112,10 @@ _mesa_update_shader_textures_used(struct gl_shader_program 
*shProg,
 
while (mask) {
   const int s = u_bit_scan();
-  GLuint unit = prog->SamplerUnits[s];
-  GLuint tgt = prog->sh.SamplerTargets[s];
-  assert(unit < ARRAY_SIZE(prog->TexturesUsed));
-  assert(tgt < NUM_TEXTURE_TARGETS);
-
-  /* The types of the samplers associated with a particular texture
-   * unit must be an exact match.  Page 74 (page 89 of the PDF) of the
-   * OpenGL 3.3 core spec says:
-   *
-   * "It is not allowed to have variables of different sampler
-   * types pointing to the same texture image unit within a program
-   * object."
-   */
-  unsigned stages_mask = shProg->data->linked_stages;
-  while (stages_mask) {
- const int stage = u_bit_scan(_mask);
-
- /* Skip validation if we are yet to update textures used in this
-  * stage.
-  */
- if (prog_stage < stage)
-break;
-
- struct gl_program *glprog = shProg->_LinkedShaders[stage]->Program;
- if (glprog->TexturesUsed[unit] & ~(1 << tgt))
-shProg->SamplersValidated = GL_FALSE;
-  }
-
-  prog->TexturesUsed[unit] |= (1 << tgt);
+
+  update_single_shader_texture_used(shProg, prog,
+prog->SamplerUnits[s],
+prog->sh.SamplerTargets[s]);
}
 }
 
-- 
2.13.0

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


[Mesa-dev] [RFC PATCH 21/65] mesa: associate uniform storage to bindless samplers/images

2017-05-19 Thread Samuel Pitoiset
When a bindless sampler/image is bound to a texture/image unit,
we have to overwrite the constant value by the resident handle
directly in the constant buffer before the next draw.

One solution is to keep track of a pointer to the data.

Signed-off-by: Samuel Pitoiset 
---
 src/mesa/program/ir_to_mesa.cpp | 25 +
 1 file changed, 25 insertions(+)

diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp
index 5e6304036d..0c3ffd2e22 100644
--- a/src/mesa/program/ir_to_mesa.cpp
+++ b/src/mesa/program/ir_to_mesa.cpp
@@ -2541,6 +2541,7 @@ _mesa_associate_uniform_storage(struct gl_context *ctx,
 bool propagate_to_storage)
 {
struct gl_program_parameter_list *params = prog->Parameters;
+   gl_shader_stage shader_type = prog->info.stage;
 
/* After adding each uniform to the parameter list, connect the storage for
 * the parameter with the tracking structure used by the API for the
@@ -2623,6 +2624,30 @@ _mesa_associate_uniform_storage(struct gl_context *ctx,
  format,
  >ParameterValues[i]);
 
+ /* When a bindless sampler/image is bound to a texture/image unit, we
+  * have to overwrite the constant value by the resident handle
+  * directly in the constant buffer before the next draw. One solution
+  * is to keep track a pointer to the base of the data.
+  */
+ if (storage->is_bindless && (prog->sh.NumBindlessSamplers ||
+  prog->sh.NumBindlessImages)) {
+unsigned array_elements = MAX2(1, storage->array_elements);
+
+for (unsigned j = 0; j < array_elements; ++j) {
+   unsigned unit = storage->opaque[shader_type].index + j;
+
+   if (storage->type->without_array()->is_sampler()) {
+  assert(unit >= 0 && unit < prog->sh.NumBindlessSamplers);
+  prog->sh.BindlessSamplers[unit].data =
+ >ParameterValues[i] + j;
+   } else if (storage->type->without_array()->is_image()) {
+  assert(unit >= 0 && unit < prog->sh.NumBindlessImages);
+  prog->sh.BindlessImages[unit].data =
+ >ParameterValues[i] + j;
+   }
+}
+ }
+
  /* After attaching the driver's storage to the uniform, propagate any
   * data from the linker's backing store.  This will cause values from
   * initializers in the source code to be copied over.
-- 
2.13.0

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


[Mesa-dev] [RFC PATCH 23/65] mesa: get rid of a workaround for bindless in _mesa_get_uniform()

2017-05-19 Thread Samuel Pitoiset
The ARB_bindless_texture spec says:

   "When a sampler or image uniform's value is queried via any
of the GetUniform* commands, the returned value will reflect
the most recently set value through either UniformHandle* or
Uniform1i*, converted to the requested type."

Signed-off-by: Samuel Pitoiset 
---
 src/compiler/glsl/ir_uniform.h |  6 ++
 src/compiler/glsl/shader_cache.cpp |  2 ++
 src/mesa/main/uniform_query.cpp| 22 +-
 3 files changed, 25 insertions(+), 5 deletions(-)

diff --git a/src/compiler/glsl/ir_uniform.h b/src/compiler/glsl/ir_uniform.h
index 9841df8cde..f375d8359d 100644
--- a/src/compiler/glsl/ir_uniform.h
+++ b/src/compiler/glsl/ir_uniform.h
@@ -207,6 +207,12 @@ struct gl_uniform_storage {
 * layout qualifier as specified by ARB_bindless_texture.
 */
bool is_bindless;
+
+   /**
+* Whether this uniform variable is declared with the bindless_sampler or
+* bindless_image and used with a texture/image handle.
+*/
+   bool is_bindless_handle;
 };
 
 #ifdef __cplusplus
diff --git a/src/compiler/glsl/shader_cache.cpp 
b/src/compiler/glsl/shader_cache.cpp
index 6811cb2f50..3fe3135bd7 100644
--- a/src/compiler/glsl/shader_cache.cpp
+++ b/src/compiler/glsl/shader_cache.cpp
@@ -579,6 +579,7 @@ write_uniforms(struct blob *metadata, struct 
gl_shader_program *prog)
   blob_write_uint32(metadata, prog->data->UniformStorage[i].matrix_stride);
   blob_write_uint32(metadata, prog->data->UniformStorage[i].row_major);
   blob_write_uint32(metadata, prog->data->UniformStorage[i].is_bindless);
+  blob_write_uint32(metadata, 
prog->data->UniformStorage[i].is_bindless_handle);
   blob_write_uint32(metadata,
 
prog->data->UniformStorage[i].num_compatible_subroutines);
   blob_write_uint32(metadata,
@@ -644,6 +645,7 @@ read_uniforms(struct blob_reader *metadata, struct 
gl_shader_program *prog)
   uniforms[i].matrix_stride = blob_read_uint32(metadata);
   uniforms[i].row_major = blob_read_uint32(metadata);
   uniforms[i].is_bindless = blob_read_uint32(metadata);
+  uniforms[i].is_bindless_handle = blob_read_uint32(metadata);
   uniforms[i].num_compatible_subroutines = blob_read_uint32(metadata);
   uniforms[i].top_level_array_size = blob_read_uint32(metadata);
   uniforms[i].top_level_array_stride = blob_read_uint32(metadata);
diff --git a/src/mesa/main/uniform_query.cpp b/src/mesa/main/uniform_query.cpp
index be04e48d53..78a852377d 100644
--- a/src/mesa/main/uniform_query.cpp
+++ b/src/mesa/main/uniform_query.cpp
@@ -322,12 +322,20 @@ _mesa_get_uniform(struct gl_context *ctx, GLuint program, 
GLint location,
 
{
   unsigned elements = uni->type->components();
-  /* XXX: Remove the sampler/image check workarounds when bindless is fully
-   * implemented.
-   */
-  const int dmul =
- (uni->type->is_64bit() && !uni->type->is_sampler() && 
!uni->type->is_image()) ? 2 : 1;
   const int rmul = glsl_base_type_is_64bit(returnType) ? 2 : 1;
+  int dmul = uni->type->is_64bit() ? 2 : 1;
+
+  if ((uni->type->is_sampler() || uni->type->is_image()) &&
+  !uni->is_bindless_handle) {
+ /* The ARB_bindless_texture spec says:
+  *
+  * "When a sampler or image uniform's value is queried via any of the
+  *  GetUniform* commands, the returned value will reflect the most
+  *  recently set value through either UniformHandle* or Uniform1i*,
+  *  converted to the requested type."
+  */
+ dmul = 1;
+  }
 
   /* Calculate the source base address *BEFORE* modifying elements to
* account for the size of the user's buffer.
@@ -1007,6 +1015,7 @@ _mesa_uniform(GLint location, GLsizei count, const GLvoid 
*values,
}
sampler->bound = true;
sh->Program->sh.HasBoundBindlessSampler = true;
+   uni->is_bindless_handle = false;
 } else {
if (sh->Program->SamplerUnits[unit] != value) {
   sh->Program->SamplerUnits[unit] = value;
@@ -1053,6 +1062,7 @@ _mesa_uniform(GLint location, GLsizei count, const GLvoid 
*values,
image->unit = value;
image->bound = true;
sh->Program->sh.HasBoundBindlessImage = true;
+   uni->is_bindless_handle = false;
 } else {
sh->Program->sh.ImageUnits[unit] = value;
 }
@@ -1318,6 +1328,7 @@ _mesa_uniform_handle(GLint location, GLsizei count, const 
GLvoid *values,
>Program->sh.BindlessSamplers[unit];
 
 sampler->bound = false;
+uni->is_bindless_handle = true;
  }
 
  update_bound_bindless_sampler_flag(sh->Program);
@@ -1341,6 +1352,7 @@ _mesa_uniform_handle(GLint location, GLsizei count, const 
GLvoid *values,
>Program->sh.BindlessImages[unit];
 

[Mesa-dev] [RFC PATCH 31/65] tgsi/ureg: accept TGSI_FILE_{CONSTANT, INPUT} for dst registers

2017-05-19 Thread Samuel Pitoiset
For example, TGSI_OPCODE_STORE for bindless images might use
a constant buffer or a shader input.

Signed-off-by: Samuel Pitoiset 
---
 src/gallium/auxiliary/tgsi/tgsi_ureg.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/src/gallium/auxiliary/tgsi/tgsi_ureg.c 
b/src/gallium/auxiliary/tgsi/tgsi_ureg.c
index faed1e2708..6c51af3453 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_ureg.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_ureg.c
@@ -1140,8 +1140,6 @@ ureg_emit_dst( struct ureg_program *ureg,
unsigned n = 0;
 
assert(dst.File != TGSI_FILE_NULL);
-   assert(dst.File != TGSI_FILE_CONSTANT);
-   assert(dst.File != TGSI_FILE_INPUT);
assert(dst.File != TGSI_FILE_SAMPLER);
assert(dst.File != TGSI_FILE_SAMPLER_VIEW);
assert(dst.File != TGSI_FILE_IMMEDIATE);
-- 
2.13.0

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


[Mesa-dev] [RFC PATCH 30/65] tgsi: add new Bindless flag to tgsi_instruction_memory

2017-05-19 Thread Samuel Pitoiset
Old-style images are identified using TGSI_FILE_IMAGE, but
bindless images can be TGSI_FILE_CONSTANT or TGSI_FILE_TEMPORARY.

To avoid backend compilers to be confused, this adds a new flag
that will only be set for bindless images.

Signed-off-by: Samuel Pitoiset 
---
 src/gallium/auxiliary/tgsi/tgsi_build.c|  4 
 src/gallium/auxiliary/tgsi/tgsi_ureg.c | 10 +++---
 src/gallium/auxiliary/tgsi/tgsi_ureg.h |  6 --
 src/gallium/include/pipe/p_shader_tokens.h |  3 ++-
 src/mesa/state_tracker/st_glsl_to_tgsi.cpp |  4 ++--
 src/mesa/state_tracker/st_pbo.c|  2 +-
 6 files changed, 20 insertions(+), 9 deletions(-)

diff --git a/src/gallium/auxiliary/tgsi/tgsi_build.c 
b/src/gallium/auxiliary/tgsi/tgsi_build.c
index be1931e482..1aa2fd12d4 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_build.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_build.c
@@ -759,6 +759,7 @@ tgsi_default_instruction_memory( void )
instruction_memory.Qualifier = 0;
instruction_memory.Texture = 0;
instruction_memory.Format = 0;
+   instruction_memory.Bindless = 0;
instruction_memory.Padding = 0;
 
return instruction_memory;
@@ -769,6 +770,7 @@ tgsi_build_instruction_memory(
unsigned qualifier,
unsigned texture,
unsigned format,
+   unsigned bindless,
struct tgsi_token *prev_token,
struct tgsi_instruction *instruction,
struct tgsi_header *header )
@@ -778,6 +780,7 @@ tgsi_build_instruction_memory(
instruction_memory.Qualifier = qualifier;
instruction_memory.Texture = texture;
instruction_memory.Format = format;
+   instruction_memory.Bindless = bindless;
instruction_memory.Padding = 0;
instruction->Memory = 1;
 
@@ -1137,6 +1140,7 @@ tgsi_build_full_instruction(
  full_inst->Memory.Qualifier,
  full_inst->Memory.Texture,
  full_inst->Memory.Format,
+ full_inst->Memory.Bindless,
  prev_token,
  instruction,
  header );
diff --git a/src/gallium/auxiliary/tgsi/tgsi_ureg.c 
b/src/gallium/auxiliary/tgsi/tgsi_ureg.c
index 8efa95f009..faed1e2708 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_ureg.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_ureg.c
@@ -1324,7 +1324,8 @@ ureg_emit_memory(struct ureg_program *ureg,
  unsigned extended_token,
  unsigned qualifier,
  unsigned texture,
- unsigned format)
+ unsigned format,
+ unsigned bindless)
 {
union tgsi_any_token *out, *insn;
 
@@ -1337,6 +1338,7 @@ ureg_emit_memory(struct ureg_program *ureg,
out[0].insn_memory.Qualifier = qualifier;
out[0].insn_memory.Texture = texture;
out[0].insn_memory.Format = format;
+   out[0].insn_memory.Bindless = bindless;
 }
 
 void
@@ -1437,7 +1439,8 @@ ureg_memory_insn(struct ureg_program *ureg,
  unsigned nr_src,
  unsigned qualifier,
  unsigned texture,
- unsigned format)
+ unsigned format,
+ unsigned bindless)
 {
struct ureg_emit_insn_result insn;
unsigned i;
@@ -1448,7 +1451,8 @@ ureg_memory_insn(struct ureg_program *ureg,
  nr_dst,
  nr_src);
 
-   ureg_emit_memory(ureg, insn.extended_token, qualifier, texture, format);
+   ureg_emit_memory(ureg, insn.extended_token, qualifier, texture, format,
+bindless);
 
for (i = 0; i < nr_dst; i++)
   ureg_emit_dst(ureg, dst[i]);
diff --git a/src/gallium/auxiliary/tgsi/tgsi_ureg.h 
b/src/gallium/auxiliary/tgsi/tgsi_ureg.h
index 9e30a41ff7..fe8620149a 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_ureg.h
+++ b/src/gallium/auxiliary/tgsi/tgsi_ureg.h
@@ -572,7 +572,8 @@ ureg_memory_insn(struct ureg_program *ureg,
  unsigned nr_src,
  unsigned qualifier,
  unsigned texture,
- unsigned format);
+ unsigned format,
+ unsigned bindless);
 
 /***
  * Internal instruction helpers, don't call these directly:
@@ -610,7 +611,8 @@ ureg_emit_memory(struct ureg_program *ureg,
  unsigned insn_token,
  unsigned qualifier,
  unsigned texture,
- unsigned format);
+ unsigned format,
+ unsigned bindless);
 
 void 
 ureg_emit_dst( struct ureg_program *ureg,
diff --git a/src/gallium/include/pipe/p_shader_tokens.h 
b/src/gallium/include/pipe/p_shader_tokens.h
index 2665eb4235..a4c68b1dbb 100644
--- a/src/gallium/include/pipe/p_shader_tokens.h
+++ b/src/gallium/include/pipe/p_shader_tokens.h
@@ -797,7 +797,8 @@ struct tgsi_instruction_memory
unsigned Qualifier : 3;  /* TGSI_MEMORY_ */
unsigned Texture   : 8;  /* only for images: TGSI_TEXTURE_ */
unsigned Format: 10; /* only for images: PIPE_FORMAT_ */
-   unsigned Padding   : 11;
+   

[Mesa-dev] [RFC PATCH 35/65] st/glsl_to_tgsi: teach the DCE pass about bindless samplers/images

2017-05-19 Thread Samuel Pitoiset
When a texture (or an image) instruction uses a bindless sampler
(respectively a bindless image), make sure the DCE pass won't
remove code when the resource is a temporary variable.

Signed-off-by: Samuel Pitoiset 
---
 src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 15 +++
 1 file changed, 15 insertions(+)

diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp 
b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index f30544eb4c..ee1afdcd08 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -5247,6 +5247,21 @@ glsl_to_tgsi_visitor::eliminate_dead_code(void)
}
 }
  }
+
+ if (inst->resource.file == PROGRAM_TEMPORARY) {
+int src_chans;
+
+src_chans  = 1 << GET_SWZ(inst->resource.swizzle, 0);
+src_chans |= 1 << GET_SWZ(inst->resource.swizzle, 1);
+src_chans |= 1 << GET_SWZ(inst->resource.swizzle, 2);
+src_chans |= 1 << GET_SWZ(inst->resource.swizzle, 3);
+
+for (int c = 0; c < 4; c++) {
+   if (src_chans & (1 << c))
+  writes[4 * inst->resource.index + c] = NULL;
+}
+ }
+
  break;
   }
 
-- 
2.13.0

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


  1   2   3   >