[Mesa-dev] [PATCH] anv: Move size check from anv_bo_cache_import() to caller (v2)

2017-10-17 Thread Chad Versace
This change prepares for VK_ANDROID_native_buffer. When the user imports
a gralloc hande into a VkImage using VK_ANDROID_native_buffer, the user
provides no size. The driver must infer the size from the internals of
the gralloc buffer.

The patch is essentially a refactor patch.  It should change no behavior
other than improved debug messages.

v2:
  - Preserve behavior of aligning size to 4096 before checking. [for
jekstrand]
  - Check size with < instead of <=, to match behavior of commit c0a4f56
"anv: bo_cache: allow importing a BO larger than needed". [for chadv]
---
 src/intel/vulkan/anv_allocator.c | 21 +++--
 src/intel/vulkan/anv_device.c| 25 +++--
 src/intel/vulkan/anv_intel.c | 14 +-
 src/intel/vulkan/anv_private.h   |  2 +-
 src/intel/vulkan/anv_queue.c |  7 ++-
 5 files changed, 46 insertions(+), 23 deletions(-)

diff --git a/src/intel/vulkan/anv_allocator.c b/src/intel/vulkan/anv_allocator.c
index 401cea40e6..27eedb53aa 100644
--- a/src/intel/vulkan/anv_allocator.c
+++ b/src/intel/vulkan/anv_allocator.c
@@ -1272,13 +1272,10 @@ anv_bo_cache_alloc(struct anv_device *device,
 VkResult
 anv_bo_cache_import(struct anv_device *device,
 struct anv_bo_cache *cache,
-int fd, uint64_t size, struct anv_bo **bo_out)
+int fd, struct anv_bo **bo_out)
 {
pthread_mutex_lock(>mutex);
 
-   /* The kernel is going to give us whole pages anyway */
-   size = align_u64(size, 4096);
-
uint32_t gem_handle = anv_gem_fd_to_handle(device, fd);
if (!gem_handle) {
   pthread_mutex_unlock(>mutex);
@@ -1287,22 +1284,10 @@ anv_bo_cache_import(struct anv_device *device,
 
struct anv_cached_bo *bo = anv_bo_cache_lookup_locked(cache, gem_handle);
if (bo) {
-  if (bo->bo.size != size) {
- pthread_mutex_unlock(>mutex);
- return vk_error(VK_ERROR_INVALID_EXTERNAL_HANDLE_KHR);
-  }
   __sync_fetch_and_add(>refcount, 1);
} else {
-  /* For security purposes, we reject BO imports where the size does not
-   * match exactly.  This prevents a malicious client from passing a
-   * buffer to a trusted client, lying about the size, and telling the
-   * trusted client to try and texture from an image that goes
-   * out-of-bounds.  This sort of thing could lead to GPU hangs or worse
-   * in the trusted client.  The trusted client can protect itself against
-   * this sort of attack but only if it can trust the buffer size.
-   */
-  off_t import_size = lseek(fd, 0, SEEK_END);
-  if (import_size == (off_t)-1 || import_size < size) {
+  off_t size = lseek(fd, 0, SEEK_END);
+  if (size == (off_t)-1) {
  anv_gem_close(device, gem_handle);
  pthread_mutex_unlock(>mutex);
  return vk_error(VK_ERROR_INVALID_EXTERNAL_HANDLE_KHR);
diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c
index 1634b5158c..546ed2d0ca 100644
--- a/src/intel/vulkan/anv_device.c
+++ b/src/intel/vulkan/anv_device.c
@@ -1543,11 +1543,32 @@ VkResult anv_AllocateMemory(
  VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT_KHR);
 
   result = anv_bo_cache_import(device, >bo_cache,
-   fd_info->fd, pAllocateInfo->allocationSize,
-   >bo);
+   fd_info->fd, >bo);
   if (result != VK_SUCCESS)
  goto fail;
 
+  VkDeviceSize aligned_alloc_size =
+ align_u64(pAllocateInfo->allocationSize, 4096);
+
+  /* For security purposes, we reject importing the bo if it's smaller
+   * than the requested allocation size.  This prevents a malicious client
+   * from passing a buffer to a trusted client, lying about the size, and
+   * telling the trusted client to try and texture from an image that goes
+   * out-of-bounds.  This sort of thing could lead to GPU hangs or worse
+   * in the trusted client.  The trusted client can protect itself against
+   * this sort of attack but only if it can trust the buffer size.
+   */
+  if (mem->bo->size < aligned_alloc_size) {
+ result = vk_errorf(device->instace, device,
+VK_ERROR_INVALID_EXTERNAL_HANDLE_KHR,
+"aligned allocationSize too large for "
+"VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT_KHR: 
"
+"%"PRIu64"B > %"PRIu64"B",
+aligned_alloc_size, mem->bo->size);
+ anv_bo_cache_release(device, >bo_cache, mem->bo);
+ goto fail;
+  }
+
   /* From the Vulkan spec:
*
*"Importing memory from a file descriptor transfers ownership of
diff --git a/src/intel/vulkan/anv_intel.c b/src/intel/vulkan/anv_intel.c
index d6bad44091..885888e82d 100644
--- a/src/intel/vulkan/anv_intel.c
+++ b/src/intel/vulkan/anv_intel.c
@@ -76,10 +76,22 @@ 

Re: [Mesa-dev] Upstream support for FreeSync / Adaptive Sync

2017-10-17 Thread Ville Syrjälä
On Tue, Oct 17, 2017 at 09:00:56PM +0200, Nicolai Hähnle wrote:
> On 17.10.2017 16:09, Ville Syrjälä wrote:
> > On Tue, Oct 17, 2017 at 03:46:24PM +0200, Michel Dänzer wrote:
> >> On 17/10/17 02:22 PM, Daniel Vetter wrote:
> >>> On Tue, Oct 17, 2017 at 12:28:17PM +0200, Michel Dänzer wrote:
>  On 17/10/17 11:34 AM, Nicolai Hähnle wrote:
> >>>
> > Common sense suggests that there need to be two side to FreeSync / VESA
> > Adaptive Sync support:
> >
> > 1. Query the display capabilities. This means querying minimum / maximum
> > refresh duration, plus possibly a query for when the earliest/latest
> > timing of the *next* refresh.
> >
> > 2. Signal desired present time. This means passing a target timer value
> > instead of a target vblank count, e.g. something like this for the KMS
> > interface:
> >
> >    int drmModePageFlipTarget64(int fd, uint32_t crtc_id, uint32_t fb_id,
> >    uint32_t flags, void *user_data,
> >    uint64_t target);
> >
> >    + a flag to indicate whether target is the vblank count or the
> > CLOCK_MONOTONIC (?) time in ns.
> 
>  drmModePageFlip(Target) is part of the pre-atomic KMS API, but adapative
>  sync should probably only be supported via the atomic API, presumably
>  via output properties.
> >>>
> >>> +1
> >>>
> >>> At least now that DC is on track to land properly, and you want to do this
> >>> for DC-only anyway there's no reason to pimp the legacy interfaces
> >>> further. And atomic is soo much easier to extend.
> >>>
> >>> The big question imo is where we need to put the flag on the kms side,
> >>> since freesync is not just about presenting earlier, but also about
> >>> presenting later. But for backwards compat we can't stretch the refresh
> >>> rate by default for everyone, or clients that rely on high precision
> >>> timestamps and regular refresh will get a bad surprise.
> >>
> >> The idea described above is that adaptive sync would be used for flips
> >> with a target timestamp. Apps which don't want to use adaptive sync
> >> wouldn't set a target timestamp.
> >>
> >>
> >>> I think a boolean enable_freesync property is probably what we want, which
> >>> enables freesync for as long as it's set.
> >>
> >> The question then becomes under what circumstances the property is (not)
> >> set. Not sure offhand this will actually solve any problem, or just push
> >> it somewhere else.
> >>
> >>
> >>> Finally I'm not sure we want to insist on a target time for freesync. At
> >>> least as far as I understand things you just want "as soon as possible".
> >>> This might change with some of the VK/EGL/GLX extensions where you
> >>> specify a precise timing (media playback). But that needs a bit more work
> >>> to make it happen I think, so perhaps better to postpone.
> >>
> >> I don't see why. There's an obvious use case for this now, for video
> >> playback. At least VDPAU already has target timestamps for this.
> >>
> >>
> >>> Also note that right now no driver expect amdgpu has support for a target
> >>> vblank on a flip. That's imo another reason for not requiring target
> >>> support for at least basic freesync support.
> >>
> >> I think that's a bad reason. :) Adding it for atomic drivers shouldn't
> >> be that hard.
> > 
> > Apart from the actual implementation hurdles it does open up some new 
> > questions:
> 
> All good questions, thanks! Let me try to take a crack at them:
> 
> 
> > - Is it going to be per-plane or per-crtc?
> 
> My understanding is that planes are combined to form a single signal 
> that goes out to the monitor(s). The planes are scanned out together by 
> a crtc, so it should be per-crtc.

I guess one might imagine a compositor with one video player type of
client, and another game/benchmark type of client. If both clients queue
their next frames around the same time, the compositor might think to
combine them to a single atomic ioctl call. But it's possible the
video player client would want its frame presented much later than
the other client, which would require a per-plane timestamp.
But I guess it's not totally unreasonable to ask the compositor to
do two ioctls in this case since we aren't actually looking for a
single atomic update of two planes.

> 
> 
> > - What happens if the target timestamp is already stale?
> > - What happens if the target timestamp is good when it gets scheduled,
> >but can't be met once the fences and whatnot have signalled?
> 
> Treat it as "flip as soon as possible" in both cases.
> 
> 
> > - What happens if another operation is already queued with a more
> >recent timestamp?
> 
> This is a problem already today, isn't it? You could have two page flips 
> being queued before the next vblank. What happens in that case?

I think currently we get -EBUSY. But there's has been talk about
replacing queued flips, async flips, etc. so it seems like people
are starting 

[Mesa-dev] [PATCH] radv: don't create dummy fs when compiling compute stage

2017-10-17 Thread Timothy Arceri
Fixes: d1c9f30d7ff7 "radv: add radv_create_shaders() helper"
---
 src/amd/vulkan/radv_pipeline.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/amd/vulkan/radv_pipeline.c b/src/amd/vulkan/radv_pipeline.c
index 00315460c2..116e706f98 100644
--- a/src/amd/vulkan/radv_pipeline.c
+++ b/src/amd/vulkan/radv_pipeline.c
@@ -1604,21 +1604,21 @@ void radv_create_shaders(struct radv_pipeline *pipeline,
if (modules[MESA_SHADER_GEOMETRY]) {
struct radv_shader_variant *variants[MESA_SHADER_STAGES] = {0};
radv_create_shader_variants_from_pipeline_cache(device, cache, 
gs_copy_hash, variants);
pipeline->gs_copy_shader = variants[MESA_SHADER_GEOMETRY];
}
 
if (radv_create_shader_variants_from_pipeline_cache(device, cache, 
hash, pipeline->shaders) &&
(!modules[MESA_SHADER_GEOMETRY] || pipeline->gs_copy_shader))
return;
 
-   if (!modules[MESA_SHADER_FRAGMENT]) {
+   if (!modules[MESA_SHADER_FRAGMENT] && !modules[MESA_SHADER_COMPUTE]) {
nir_builder fs_b;
nir_builder_init_simple_shader(_b, NULL, 
MESA_SHADER_FRAGMENT, NULL);
fs_b.shader->info.name = ralloc_strdup(fs_b.shader, "noop_fs");
fs_m.nir = fs_b.shader;
modules[MESA_SHADER_FRAGMENT] = _m;
}
 
int prev = -1;
for (unsigned i = 0; i < MESA_SHADER_STAGES; ++i) {
const VkPipelineShaderStageCreateInfo *stage = pStages[i];
-- 
2.13.6

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


Re: [Mesa-dev] [PATCH 1/6] i965: Only put external handles into the handle ht

2017-10-17 Thread Kenneth Graunke
On Monday, October 16, 2017 12:38:04 PM PDT Chris Wilson wrote:
> Quoting Kenneth Graunke (2017-10-16 20:07:05)
> > Patches 2 and 5 look good to me as well.  I'd like to try out the
> > AMD_pinned_memory support with Left 4 Dead 2, as I know a bunch of
> > the Source 1 games use AMD_pinned_memory for better performance...
> > but those games apparently started crashing the GPU and I'm going
> > to have to look into that before I can really test these. :(
> 
> To be clear, started crashing before or after enabling
> AMD_pinned_memory? I think I have L4D2 lying around...
> -Chris

No, it's just been GPU hanging for a while now...haven't had time to
track it down. :(

--Ken


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


Re: [Mesa-dev] [PATCH] Fix the xf86vm meson dependency

2017-10-17 Thread Dylan Baker
I could have sworn this got fixed already, but clearly not.

reviewed-by: Dylan Baker 

On October 17, 2017 6:04:16 PM PDT, Nicholas Miell  wrote:
>The pkg-config file is called xxf86vm.
>
>Signed-off-by: Nicholas Miell 
>---
> meson.build | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
>diff --git a/meson.build b/meson.build
>index 33121600d0c..82c4d2ed12c 100644
>--- a/meson.build
>+++ b/meson.build
>@@ -678,7 +678,7 @@ if with_platform_x11
> dep_xdamage = dependency('xdamage', version : '>= 1.1')
> dep_xfixes = dependency('xfixes')
> dep_xcb_glx = dependency('xcb-glx', version : '>= 1.8.1')
>-dep_xf86vm = dependency('xf86vm', required : false)
>+dep_xf86vm = dependency('xxf86vm', required : false)
>   endif
>   if with_any_vk or (with_glx == 'dri' and with_dri_platform == 'drm')
> dep_xcb = dependency('xcb')
>-- 
>2.13.6
>
>___
>mesa-dev mailing list
>mesa-dev@lists.freedesktop.org
>https://lists.freedesktop.org/mailman/listinfo/mesa-dev
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH] Fix the xf86vm meson dependency

2017-10-17 Thread Nicholas Miell
The pkg-config file is called xxf86vm.

Signed-off-by: Nicholas Miell 
---
 meson.build | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/meson.build b/meson.build
index 33121600d0c..82c4d2ed12c 100644
--- a/meson.build
+++ b/meson.build
@@ -678,7 +678,7 @@ if with_platform_x11
 dep_xdamage = dependency('xdamage', version : '>= 1.1')
 dep_xfixes = dependency('xfixes')
 dep_xcb_glx = dependency('xcb-glx', version : '>= 1.8.1')
-dep_xf86vm = dependency('xf86vm', required : false)
+dep_xf86vm = dependency('xxf86vm', required : false)
   endif
   if with_any_vk or (with_glx == 'dri' and with_dri_platform == 'drm')
 dep_xcb = dependency('xcb')
-- 
2.13.6

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


Re: [Mesa-dev] [PATCH 07/10] anv: Move size check from anv_bo_cache_import() to caller

2017-10-17 Thread Jason Ekstrand
On Tue, Oct 17, 2017 at 5:27 PM, Chad Versace 
wrote:

> This change prepares for VK_ANDROID_native_buffer. When the user imports
> a gralloc hande into a VkImage using VK_ANDROID_native_buffer, the user
> provides no size. The driver must infer the size from the internals of
> the gralloc buffer.
>
> The patch is essentially a refactor patch.  It should change no behavior
> other than improved debug messages.
> ---
>
> Jason, you were right about the race; it poses no security problem.
>
> This patch replaces 07/10 in the series.
>
>
>
>  src/intel/vulkan/anv_allocator.c | 21 +++--
>  src/intel/vulkan/anv_device.c| 21 +++--
>  src/intel/vulkan/anv_intel.c | 12 +++-
>  src/intel/vulkan/anv_private.h   |  2 +-
>  src/intel/vulkan/anv_queue.c |  7 ++-
>  5 files changed, 40 insertions(+), 23 deletions(-)
>
> diff --git a/src/intel/vulkan/anv_allocator.c b/src/intel/vulkan/anv_
> allocator.c
> index 401cea40e6..27eedb53aa 100644
> --- a/src/intel/vulkan/anv_allocator.c
> +++ b/src/intel/vulkan/anv_allocator.c
> @@ -1272,13 +1272,10 @@ anv_bo_cache_alloc(struct anv_device *device,
>  VkResult
>  anv_bo_cache_import(struct anv_device *device,
>  struct anv_bo_cache *cache,
> -int fd, uint64_t size, struct anv_bo **bo_out)
> +int fd, struct anv_bo **bo_out)
>  {
> pthread_mutex_lock(>mutex);
>
> -   /* The kernel is going to give us whole pages anyway */
> -   size = align_u64(size, 4096);
> -
> uint32_t gem_handle = anv_gem_fd_to_handle(device, fd);
> if (!gem_handle) {
>pthread_mutex_unlock(>mutex);
> @@ -1287,22 +1284,10 @@ anv_bo_cache_import(struct anv_device *device,
>
> struct anv_cached_bo *bo = anv_bo_cache_lookup_locked(cache,
> gem_handle);
> if (bo) {
> -  if (bo->bo.size != size) {
> - pthread_mutex_unlock(>mutex);
> - return vk_error(VK_ERROR_INVALID_EXTERNAL_HANDLE_KHR);
> -  }
>__sync_fetch_and_add(>refcount, 1);
> } else {
> -  /* For security purposes, we reject BO imports where the size does
> not
> -   * match exactly.  This prevents a malicious client from passing a
> -   * buffer to a trusted client, lying about the size, and telling the
> -   * trusted client to try and texture from an image that goes
> -   * out-of-bounds.  This sort of thing could lead to GPU hangs or
> worse
> -   * in the trusted client.  The trusted client can protect itself
> against
> -   * this sort of attack but only if it can trust the buffer size.
> -   */
> -  off_t import_size = lseek(fd, 0, SEEK_END);
> -  if (import_size == (off_t)-1 || import_size < size) {
> +  off_t size = lseek(fd, 0, SEEK_END);
> +  if (size == (off_t)-1) {
>   anv_gem_close(device, gem_handle);
>   pthread_mutex_unlock(>mutex);
>   return vk_error(VK_ERROR_INVALID_EXTERNAL_HANDLE_KHR);
> diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c
> index 1634b5158c..900de9778c 100644
> --- a/src/intel/vulkan/anv_device.c
> +++ b/src/intel/vulkan/anv_device.c
> @@ -1543,11 +1543,28 @@ VkResult anv_AllocateMemory(
>   VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT_KHR);
>
>result = anv_bo_cache_import(device, >bo_cache,
> -   fd_info->fd,
> pAllocateInfo->allocationSize,
> -   >bo);
> +   fd_info->fd, >bo);
>if (result != VK_SUCCESS)
>   goto fail;
>
> +  /* For security purposes, we reject BO imports where the size does
> not
> +   * match exactly.  This prevents a malicious client from passing
> +   * a buffer to a trusted client, lying about the size, and telling
> the
> +   * trusted client to try and texture from an image that goes
> +   * out-of-bounds.  This sort of thing could lead to GPU hangs or
> worse
> +   * in the trusted client.  The trusted client can protect itself
> against
> +   * this sort of attack but only if it can trust the buffer size.
> +   */
> +  if (pAllocateInfo->allocationSize != mem->bo->size) {
>

You're not checking the aligned size like we were before.  Maybe make that
align_u64(pAllocateInfo->allocationSize, 4096)?  In any case, I don't think
it matters because the client will be getting the size based on an image
query which will likely be a multiple of 4k.  Still, it'd be nice to not
have a behavioral change.  With that,

Reviewed-by: Jason Ekstrand 


> + result = vk_errorf(device->instace, device,
> +VK_ERROR_INVALID_EXTERNAL_HANDLE_KHR,
> +"invalid allocationSize for
> VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT_KHR: "
> +"expected %"PRIu64"B, actual %"PRIu64"B",
> +mem->bo->size, 

Re: [Mesa-dev] [PATCH] llvmpipe: handle shader sample mask output

2017-10-17 Thread Brian Paul

LGTM.  Reviewed-by: Brian Paul 

On 10/17/2017 01:58 PM, srol...@vmware.com wrote:

From: Roland Scheidegger 

This probably isn't all that useful for GL, but there are apis where
sample_mask is a valid output even without msaa.
Just discard the pixel if the sample_mask doesn't include the bit for
sample 0.
---
  src/gallium/drivers/llvmpipe/lp_state_fs.c | 26 --
  1 file changed, 24 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/llvmpipe/lp_state_fs.c 
b/src/gallium/drivers/llvmpipe/lp_state_fs.c
index 05984b3..9223ce6 100644
--- a/src/gallium/drivers/llvmpipe/lp_state_fs.c
+++ b/src/gallium/drivers/llvmpipe/lp_state_fs.c
@@ -84,6 +84,7 @@
  #include "gallivm/lp_bld_flow.h"
  #include "gallivm/lp_bld_debug.h"
  #include "gallivm/lp_bld_arit.h"
+#include "gallivm/lp_bld_bitarit.h"
  #include "gallivm/lp_bld_pack.h"
  #include "gallivm/lp_bld_format.h"
  #include "gallivm/lp_bld_quad.h"
@@ -347,7 +348,8 @@ generate_fs_loop(struct gallivm_state *gallivm,
if (!shader->info.base.writes_z && !shader->info.base.writes_stencil) {
   if (key->alpha.enabled ||
   key->blend.alpha_to_coverage ||
- shader->info.base.uses_kill) {
+ shader->info.base.uses_kill ||
+ shader->info.base.writes_samplemask) {
  /* With alpha test and kill, can do the depth test early
   * and hopefully eliminate some quads.  But need to do a
   * special deferred depth write once the final mask value
@@ -516,6 +518,25 @@ generate_fs_loop(struct gallivm_state *gallivm,
}
 }

+   if (shader->info.base.writes_samplemask) {
+  int smaski = find_output_by_semantic(>info.base,
+   TGSI_SEMANTIC_SAMPLEMASK,
+   0);
+  LLVMValueRef smask;
+  struct lp_build_context smask_bld;
+  lp_build_context_init(_bld, gallivm, int_type);
+
+  assert(smaski >= 0);
+  smask = LLVMBuildLoad(builder, outputs[smaski][0], "smask");
+  /*
+   * Pixel is alive according to the first sample in the mask.
+   */
+  smask = LLVMBuildBitCast(builder, smask, smask_bld.vec_type, "");
+  smask = lp_build_and(_bld, smask, smask_bld.one);
+  smask = lp_build_cmp(_bld, PIPE_FUNC_NOTEQUAL, smask, 
smask_bld.zero);
+  lp_build_mask_update(, smask);
+   }
+
 /* Late Z test */
 if (depth_mode & LATE_DEPTH_TEST) {
int pos0 = find_output_by_semantic(>info.base,
@@ -2818,7 +2839,8 @@ generate_variant(struct llvmpipe_context *lp,
   !key->alpha.enabled &&
   !key->blend.alpha_to_coverage &&
   !key->depth.enabled &&
- !shader->info.base.uses_kill
+ !shader->info.base.uses_kill &&
+ !shader->info.base.writes_samplemask
? TRUE : FALSE;

 if ((shader->info.base.num_tokens <= 1) &&



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


[Mesa-dev] [PATCH 07/10] anv: Move size check from anv_bo_cache_import() to caller

2017-10-17 Thread Chad Versace
This change prepares for VK_ANDROID_native_buffer. When the user imports
a gralloc hande into a VkImage using VK_ANDROID_native_buffer, the user
provides no size. The driver must infer the size from the internals of
the gralloc buffer.

The patch is essentially a refactor patch.  It should change no behavior
other than improved debug messages.
---

Jason, you were right about the race; it poses no security problem.

This patch replaces 07/10 in the series.



 src/intel/vulkan/anv_allocator.c | 21 +++--
 src/intel/vulkan/anv_device.c| 21 +++--
 src/intel/vulkan/anv_intel.c | 12 +++-
 src/intel/vulkan/anv_private.h   |  2 +-
 src/intel/vulkan/anv_queue.c |  7 ++-
 5 files changed, 40 insertions(+), 23 deletions(-)

diff --git a/src/intel/vulkan/anv_allocator.c b/src/intel/vulkan/anv_allocator.c
index 401cea40e6..27eedb53aa 100644
--- a/src/intel/vulkan/anv_allocator.c
+++ b/src/intel/vulkan/anv_allocator.c
@@ -1272,13 +1272,10 @@ anv_bo_cache_alloc(struct anv_device *device,
 VkResult
 anv_bo_cache_import(struct anv_device *device,
 struct anv_bo_cache *cache,
-int fd, uint64_t size, struct anv_bo **bo_out)
+int fd, struct anv_bo **bo_out)
 {
pthread_mutex_lock(>mutex);
 
-   /* The kernel is going to give us whole pages anyway */
-   size = align_u64(size, 4096);
-
uint32_t gem_handle = anv_gem_fd_to_handle(device, fd);
if (!gem_handle) {
   pthread_mutex_unlock(>mutex);
@@ -1287,22 +1284,10 @@ anv_bo_cache_import(struct anv_device *device,
 
struct anv_cached_bo *bo = anv_bo_cache_lookup_locked(cache, gem_handle);
if (bo) {
-  if (bo->bo.size != size) {
- pthread_mutex_unlock(>mutex);
- return vk_error(VK_ERROR_INVALID_EXTERNAL_HANDLE_KHR);
-  }
   __sync_fetch_and_add(>refcount, 1);
} else {
-  /* For security purposes, we reject BO imports where the size does not
-   * match exactly.  This prevents a malicious client from passing a
-   * buffer to a trusted client, lying about the size, and telling the
-   * trusted client to try and texture from an image that goes
-   * out-of-bounds.  This sort of thing could lead to GPU hangs or worse
-   * in the trusted client.  The trusted client can protect itself against
-   * this sort of attack but only if it can trust the buffer size.
-   */
-  off_t import_size = lseek(fd, 0, SEEK_END);
-  if (import_size == (off_t)-1 || import_size < size) {
+  off_t size = lseek(fd, 0, SEEK_END);
+  if (size == (off_t)-1) {
  anv_gem_close(device, gem_handle);
  pthread_mutex_unlock(>mutex);
  return vk_error(VK_ERROR_INVALID_EXTERNAL_HANDLE_KHR);
diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c
index 1634b5158c..900de9778c 100644
--- a/src/intel/vulkan/anv_device.c
+++ b/src/intel/vulkan/anv_device.c
@@ -1543,11 +1543,28 @@ VkResult anv_AllocateMemory(
  VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT_KHR);
 
   result = anv_bo_cache_import(device, >bo_cache,
-   fd_info->fd, pAllocateInfo->allocationSize,
-   >bo);
+   fd_info->fd, >bo);
   if (result != VK_SUCCESS)
  goto fail;
 
+  /* For security purposes, we reject BO imports where the size does not
+   * match exactly.  This prevents a malicious client from passing
+   * a buffer to a trusted client, lying about the size, and telling the
+   * trusted client to try and texture from an image that goes
+   * out-of-bounds.  This sort of thing could lead to GPU hangs or worse
+   * in the trusted client.  The trusted client can protect itself against
+   * this sort of attack but only if it can trust the buffer size.
+   */
+  if (pAllocateInfo->allocationSize != mem->bo->size) {
+ result = vk_errorf(device->instace, device,
+VK_ERROR_INVALID_EXTERNAL_HANDLE_KHR,
+"invalid allocationSize for 
VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT_KHR: "
+"expected %"PRIu64"B, actual %"PRIu64"B",
+mem->bo->size, pAllocateInfo->allocationSize);
+ anv_bo_cache_release(device, >bo_cache, mem->bo);
+ goto fail;
+  }
+
   /* From the Vulkan spec:
*
*"Importing memory from a file descriptor transfers ownership of
diff --git a/src/intel/vulkan/anv_intel.c b/src/intel/vulkan/anv_intel.c
index d6bad44091..a80b1e4623 100644
--- a/src/intel/vulkan/anv_intel.c
+++ b/src/intel/vulkan/anv_intel.c
@@ -76,10 +76,20 @@ VkResult anv_CreateDmaBufImageINTEL(
image = anv_image_from_handle(image_h);
 
result = anv_bo_cache_import(device, >bo_cache,
-pCreateInfo->fd, image->size, >bo);
+

Re: [Mesa-dev] [PATCH 4/6] i965: Use blorp+userptr for GPU readback

2017-10-17 Thread Chris Wilson
Quoting Chris Wilson (2017-10-13 10:34:54)
> The primary benefit for this is that we get format conversion for
> "free", along with detiling and cache flushing (most relevant for !llc).
> Using the GPU does impose a bandwidth cost that is presumably better
> used for rendering, hence we limit the use to readback into client
> memory (not pbo) where we would need to stall on the GPU anyway.
> (Uploads remain direct/staged to avoid the synchronisation cost.)
> And we only use the GPU path if a direct read into client memory from
> video memory is unavailable.
> 
> The ultimate user of this is Xorg/glamor! On byt, bsw, bxt (and
> presumably but not measured ilk), x11perf -shmget500 is improved by
> 15-fold. Though conversely the overhead of executing and waiting upon an
> additional blorp batch is shown by x11perf -shmget10 being reduced by a
> factor of 2. I think it is fair to presume that large copies will
> dominate (and that the overhead of a single batch is something that we
> can iteratively reduce, for the benefit of all.) llc machines continue to
> use direct access where there is no format changes (which one hopes is
> the typical use case).

Ah, this needs some improvements to the direct read path
(intel_gettexsubimage_tiled_memcpy) to handle subimages for llc + Xorg.
I have those in the older patches to enable userptr readback, I'll dig
those out again.
-Chris
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] mesa: fix texture updates for ATI_fragment_shader

2017-10-17 Thread Timothy Arceri

On 18/10/17 09:37, Miklós Máté wrote:

On 16/10/17 01:59, Timothy Arceri wrote:

On 16/10/17 04:10, Miklós Máté wrote:

Hi,

I'd like to ask you to revert this change.

As Ian Romanick pointed out this makes ATI_fs behave like ARB_fp, 
however there is a major difference between the two: with ATI_fs 
there is no way of knowing the texture targets until the draw call. 
When an ATI_fs is created, st_init_atifs_prog() sets every texture 
target to TEXTURE_2D_BIT, and st_fixup_atifs() sets the correct one, 
but unfortunately _mesa_update_texture_state() is called between 
them. After this patch update_program_texture_state() validates the 
texture targets to match the bound texture units, and thus rejects 
sampling from cube maps. This results in broken rendering in Knights 
of the Old Republic.


Before reverting anything are you able to create a piglit test that 
reproduces the issue, so that this doesn't get broken again in future?
I've been meaning to create piglit tests for ATI_fs ever since I 
implemented it for gallium, I just couldn't find the time to do so. This 
regression a great incentive to start working on it.


That would be great. Thanks Miklós.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 1/2] nir: Add a safety check that we don't remove dead I/O vars after lowering.

2017-10-17 Thread Eric Anholt
Timothy Arceri  writes:

> On 18/10/17 07:52, Eric Anholt wrote:
>> The pass only looks at var load/store intrinsics, not input load/store
>> intrinsics, so assert that we don't see the other type.
>> ---
>> 
>> I tripped over this limitation when trying to use the NIR linking
>> helpers in vc4.
>> 
>>   src/compiler/nir/nir_remove_dead_variables.c | 20 
>>   1 file changed, 16 insertions(+), 4 deletions(-)
>> 
>> diff --git a/src/compiler/nir/nir_remove_dead_variables.c 
>> b/src/compiler/nir/nir_remove_dead_variables.c
>> index a1fe0de9c61f..7a676f2309c4 100644
>> --- a/src/compiler/nir/nir_remove_dead_variables.c
>> +++ b/src/compiler/nir/nir_remove_dead_variables.c
>> @@ -28,7 +28,8 @@
>>   #include "nir.h"
>>   
>>   static void
>> -add_var_use_intrinsic(nir_intrinsic_instr *instr, struct set *live)
>> +add_var_use_intrinsic(nir_intrinsic_instr *instr, struct set *live,
>> +  nir_variable_mode modes)
>>   {
>>  unsigned num_vars = nir_intrinsic_infos[instr->intrinsic].num_variables;
>>   
>> @@ -47,6 +48,16 @@ add_var_use_intrinsic(nir_intrinsic_instr *instr, struct 
>> set *live)
>> break;
>>  }
>>   
>> +  /* This pass can't be used on I/O variables after they've been
>> +   * lowered.
>> +   */
>
> Shouldn't this be aligned with the case rather since its not inside the 
> case? Either way both patches:
>
> Reviewed-by: Timothy Arceri 

Oh, yeah, that's emacs behavior that I don't like either.  Fixed.


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


Re: [Mesa-dev] [PATCH] meson: turn on pl111 not vc4 when pl111 driver specificed

2017-10-17 Thread Eric Anholt
Dylan Baker  writes:

> cc: Eric Anholt 
> fixes: 1918c9b1627d5403 ("meson: Add support for the pl111 driver.")
> Signed-off-by: Dylan Baker 
> ---
>
> I missed this when I was reviewing, but saw it looking at the change log when 
> I
> was rebasing some other work.

Reviewed and pushed, thanks!


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


[Mesa-dev] [PATCH] i965: Fix memmem compiler warnings.

2017-10-17 Thread Eric Anholt
gcc is throwing this warning in my meson build:

../src/intel/compiler/brw_eu_validate.c:50:11: warning
argument 1 null where non-null expected [-Wnonnull]
return memmem(haystack.str, haystack.len,
   ^~
  needle.str, needle.len) != NULL;
  ~~~

The first check for CONTAINS has a NULL error_msg.str and 0 len.  The
glibc implementation will exit without looking at any haystack bytes if
haystack.len < needle.len, so this was safe, but silence the warning
anyway by guarding against implementation variablility.

Fixes: 122ef3799d56 ("i965: Only insert error message if not already present")
---
 src/intel/compiler/brw_eu_validate.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/intel/compiler/brw_eu_validate.c 
b/src/intel/compiler/brw_eu_validate.c
index 9f72c650ddbd..f359599c38d3 100644
--- a/src/intel/compiler/brw_eu_validate.c
+++ b/src/intel/compiler/brw_eu_validate.c
@@ -47,7 +47,8 @@ cat(struct string *dest, const struct string src)
 static bool
 contains(const struct string haystack, const struct string needle)
 {
-   return memmem(haystack.str, haystack.len, needle.str, needle.len) != NULL;
+   return haystack.str && memmem(haystack.str, haystack.len,
+ needle.str, needle.len) != NULL;
 }
 #define CONTAINS(haystack, needle) \
contains(haystack, (struct string){needle, strlen(needle)})
-- 
2.14.2

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


Re: [Mesa-dev] [PATCH v2 07/52] intel/fs: Use a pair of 1-wide MOVs instead of SEL for any/all

2017-10-17 Thread Matt Turner
On Tue, Oct 17, 2017 at 2:53 PM, Jason Ekstrand  wrote:
> On Tue, Oct 17, 2017 at 2:18 PM, Matt Turner  wrote:
>>
>> On 10/12, Jason Ekstrand wrote:
>>>
>>> For some reason, the any/all predicates don't work properly with SIMD32.
>>> In particular, it appears that a SEL with a QtrCtrl of 2H doesn't read
>>> the correct subset of the flag register and you end up getting garbage
>>> in the second half.  Work around this by using a pair of 1-wide MOVs and
>>> scattering the result.  This fixes the any/all instructions for SIMD32.
>>
>>
>> Huh. I can see a lot of potential for hardware misbehavior here...
>>
>> Making things 1-wide makes a lot of sense, regardless of the bug you're
>> seeing. I'm in favor of that change.
>>
>> I picked a SEL instead of a predicated MOV instruction since the latter
>> is considered by our optimizer to be a partial write, and as such isn't
>> subject to CSE, etc. The difference is probably trivial, but I'd rather
>> just commit a patch to change things to be 1-wide, not s/SEL/MOV/, and
>> drop the added comments from the code.
>
>
> I'm pretty sure a 1-wide SEL is also going to be considered a partial write.

Oh, true. No preference then.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 1/2] nir: Add a safety check that we don't remove dead I/O vars after lowering.

2017-10-17 Thread Timothy Arceri



On 18/10/17 07:52, Eric Anholt wrote:

The pass only looks at var load/store intrinsics, not input load/store
intrinsics, so assert that we don't see the other type.
---

I tripped over this limitation when trying to use the NIR linking
helpers in vc4.

  src/compiler/nir/nir_remove_dead_variables.c | 20 
  1 file changed, 16 insertions(+), 4 deletions(-)

diff --git a/src/compiler/nir/nir_remove_dead_variables.c 
b/src/compiler/nir/nir_remove_dead_variables.c
index a1fe0de9c61f..7a676f2309c4 100644
--- a/src/compiler/nir/nir_remove_dead_variables.c
+++ b/src/compiler/nir/nir_remove_dead_variables.c
@@ -28,7 +28,8 @@
  #include "nir.h"
  
  static void

-add_var_use_intrinsic(nir_intrinsic_instr *instr, struct set *live)
+add_var_use_intrinsic(nir_intrinsic_instr *instr, struct set *live,
+  nir_variable_mode modes)
  {
 unsigned num_vars = nir_intrinsic_infos[instr->intrinsic].num_variables;
  
@@ -47,6 +48,16 @@ add_var_use_intrinsic(nir_intrinsic_instr *instr, struct set *live)

break;
 }
  
+  /* This pass can't be used on I/O variables after they've been

+   * lowered.
+   */


Shouldn't this be aligned with the case rather since its not inside the 
case? Either way both patches:


Reviewed-by: Timothy Arceri 


+   case nir_intrinsic_load_input:
+  assert(!(modes & nir_var_shader_in));
+  break;
+   case nir_intrinsic_store_output:
+  assert(!(modes & nir_var_shader_out));
+  break;
+
 default:
for (unsigned i = 0; i < num_vars; i++) {
   _mesa_set_add(live, instr->variables[i]->var);
@@ -84,7 +95,7 @@ add_var_use_tex(nir_tex_instr *instr, struct set *live)
  }
  
  static void

-add_var_use_shader(nir_shader *shader, struct set *live)
+add_var_use_shader(nir_shader *shader, struct set *live, nir_variable_mode 
modes)
  {
 nir_foreach_function(function, shader) {
if (function->impl) {
@@ -92,7 +103,8 @@ add_var_use_shader(nir_shader *shader, struct set *live)
  nir_foreach_instr(instr, block) {
 switch(instr->type) {
 case nir_instr_type_intrinsic:
-  add_var_use_intrinsic(nir_instr_as_intrinsic(instr), live);
+  add_var_use_intrinsic(nir_instr_as_intrinsic(instr), live,
+modes);
break;
  
 case nir_instr_type_call:

@@ -162,7 +174,7 @@ nir_remove_dead_variables(nir_shader *shader, 
nir_variable_mode modes)
 struct set *live =
_mesa_set_create(NULL, _mesa_hash_pointer, _mesa_key_pointer_equal);
  
-   add_var_use_shader(shader, live);

+   add_var_use_shader(shader, live, modes);
  
 if (modes & nir_var_uniform)

progress = remove_dead_vars(>uniforms, live) || progress;


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


Re: [Mesa-dev] [PATCH] mesa: fix texture updates for ATI_fragment_shader

2017-10-17 Thread Miklós Máté

On 16/10/17 01:59, Timothy Arceri wrote:

On 16/10/17 04:10, Miklós Máté wrote:

Hi,

I'd like to ask you to revert this change.

As Ian Romanick pointed out this makes ATI_fs behave like ARB_fp, 
however there is a major difference between the two: with ATI_fs 
there is no way of knowing the texture targets until the draw call. 
When an ATI_fs is created, st_init_atifs_prog() sets every texture 
target to TEXTURE_2D_BIT, and st_fixup_atifs() sets the correct one, 
but unfortunately _mesa_update_texture_state() is called between 
them. After this patch update_program_texture_state() validates the 
texture targets to match the bound texture units, and thus rejects 
sampling from cube maps. This results in broken rendering in Knights 
of the Old Republic.


Before reverting anything are you able to create a piglit test that 
reproduces the issue, so that this doesn't get broken again in future?
I've been meaning to create piglit tests for ATI_fs ever since I 
implemented it for gallium, I just couldn't find the time to do so. This 
regression a great incentive to start working on it.


MM



Ideally we would have one for the crash Marek is seeing also.




MM

On 27/09/17 17:39, Marek Olšák wrote:

From: Marek Olšák 

---
  src/mesa/main/texstate.c | 8 +---
  1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/mesa/main/texstate.c b/src/mesa/main/texstate.c
index 269e291..edd2253 100644
--- a/src/mesa/main/texstate.c
+++ b/src/mesa/main/texstate.c
@@ -833,23 +833,25 @@ update_ff_texture_state(struct gl_context *ctx,
  void
  _mesa_update_texture_state(struct gl_context *ctx)
  {
 struct gl_program *prog[MESA_SHADER_STAGES];
 int i;
 int old_max_unit = ctx->Texture._MaxEnabledTexImageUnit;
 BITSET_DECLARE(enabled_texture_units, 
MAX_COMBINED_TEXTURE_IMAGE_UNITS);

 memcpy(prog, ctx->_Shader->CurrentProgram, sizeof(prog));
-   if (prog[MESA_SHADER_FRAGMENT] == NULL &&
-   _mesa_arb_fragment_program_enabled(ctx)) {
-  prog[MESA_SHADER_FRAGMENT] = ctx->FragmentProgram.Current;
+   if (prog[MESA_SHADER_FRAGMENT] == NULL) {
+  if (_mesa_arb_fragment_program_enabled(ctx))
+ prog[MESA_SHADER_FRAGMENT] = ctx->FragmentProgram.Current;
+  else if (_mesa_ati_fragment_shader_enabled(ctx))
+ prog[MESA_SHADER_FRAGMENT] = 
ctx->ATIFragmentShader.Current->Program;

 }
 /* TODO: only set this if there are actual changes */
 ctx->NewState |= _NEW_TEXTURE_OBJECT | _NEW_TEXTURE_STATE;
 ctx->Texture._GenFlags = 0x0;
 ctx->Texture._TexMatEnabled = 0x0;
 ctx->Texture._TexGenEnabled = 0x0;
 ctx->Texture._MaxEnabledTexImageUnit = -1;
 ctx->Texture._EnabledCoordUnits = 0x0;



___
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 v2 07/52] intel/fs: Use a pair of 1-wide MOVs instead of SEL for any/all

2017-10-17 Thread Jason Ekstrand
On Tue, Oct 17, 2017 at 2:18 PM, Matt Turner  wrote:

> On 10/12, Jason Ekstrand wrote:
>
>> For some reason, the any/all predicates don't work properly with SIMD32.
>> In particular, it appears that a SEL with a QtrCtrl of 2H doesn't read
>> the correct subset of the flag register and you end up getting garbage
>> in the second half.  Work around this by using a pair of 1-wide MOVs and
>> scattering the result.  This fixes the any/all instructions for SIMD32.
>>
>
> Huh. I can see a lot of potential for hardware misbehavior here...
>
> Making things 1-wide makes a lot of sense, regardless of the bug you're
> seeing. I'm in favor of that change.
>
> I picked a SEL instead of a predicated MOV instruction since the latter
> is considered by our optimizer to be a partial write, and as such isn't
> subject to CSE, etc. The difference is probably trivial, but I'd rather
> just commit a patch to change things to be 1-wide, not s/SEL/MOV/, and
> drop the added comments from the code.
>

I'm pretty sure a 1-wide SEL is also going to be considered a partial write.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH] meson: turn on pl111 not vc4 when pl111 driver specificed

2017-10-17 Thread Dylan Baker
cc: Eric Anholt 
fixes: 1918c9b1627d5403 ("meson: Add support for the pl111 driver.")
Signed-off-by: Dylan Baker 
---

I missed this when I was reviewing, but saw it looking at the change log when I
was rebasing some other work.

 meson.build | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/meson.build b/meson.build
index 5c42102e12d..33121600d0c 100644
--- a/meson.build
+++ b/meson.build
@@ -100,7 +100,7 @@ with_gallium_vc5 = false
 _drivers = get_option('gallium-drivers')
 if _drivers != ''
   _split = _drivers.split(',')
-  with_gallium_vc4 = _split.contains('pl111')
+  with_gallium_pl111 = _split.contains('pl111')
   with_gallium_radeonsi = _split.contains('radeonsi')
   with_gallium_nouveau = _split.contains('nouveau')
   with_gallium_softpipe = _split.contains('swrast')
-- 
2.14.2

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


[Mesa-dev] [PATCH 5/5] gallium/util: don't call close() on Windows in u_tests.c

2017-10-17 Thread Brian Paul
---
 src/gallium/auxiliary/util/u_tests.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/gallium/auxiliary/util/u_tests.c 
b/src/gallium/auxiliary/util/u_tests.c
index 3cc79af..2548b46 100644
--- a/src/gallium/auxiliary/util/u_tests.c
+++ b/src/gallium/auxiliary/util/u_tests.c
@@ -567,6 +567,7 @@ test_sync_file_fences(struct pipe_context *ctx)
pass = pass && screen->fence_finish(screen, NULL, final_fence, 0);
 
/* Cleanup. */
+#ifndef PIPE_OS_WINDOWS
if (buf_fd >= 0)
   close(buf_fd);
if (tex_fd >= 0)
@@ -575,6 +576,7 @@ test_sync_file_fences(struct pipe_context *ctx)
   close(merged_fd);
if (final_fd >= 0)
   close(final_fd);
+#endif
 
screen->fence_reference(screen, _fence, NULL);
screen->fence_reference(screen, _fence, NULL);
-- 
1.9.1

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


[Mesa-dev] [PATCH 3/5] mesa: use util_strdup() macro in symbol_table.c

2017-10-17 Thread Brian Paul
---
 src/mesa/program/symbol_table.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/mesa/program/symbol_table.c b/src/mesa/program/symbol_table.c
index 37066c9..f5dacbb 100644
--- a/src/mesa/program/symbol_table.c
+++ b/src/mesa/program/symbol_table.c
@@ -24,6 +24,7 @@
 #include "main/imports.h"
 #include "symbol_table.h"
 #include "../../util/hash_table.h"
+#include "util/u_string.h"
 
 struct symbol {
/** Symbol name. */
@@ -192,7 +193,7 @@ _mesa_symbol_table_add_symbol(struct _mesa_symbol_table 
*table,
   new_sym->next_with_same_name = sym;
   new_sym->name = sym->name;
} else {
-  new_sym->name = strdup(name);
+  new_sym->name = util_strdup(name);
   if (new_sym->name == NULL) {
  free(new_sym);
  _mesa_error_no_memory(__func__);
@@ -264,7 +265,7 @@ _mesa_symbol_table_add_global_symbol(struct 
_mesa_symbol_table *table,
 
   sym->name = inner_sym->name;
} else {
-  sym->name = strdup(name);
+  sym->name = util_strdup(name);
   if (sym->name == NULL) {
  free(sym);
  _mesa_error_no_memory(__func__);
-- 
1.9.1

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


[Mesa-dev] [PATCH 1/5] gallium/util: replace gethostbyname() with getaddrinfo()

2017-10-17 Thread Brian Paul
Compiling with MSVC options /we4995 /we4996 (a subset of /sdl) generates
a warning that the gethostbyname() function is deprecated in favor of
getaddrinfo() or GetAddrInfoW().  Replace the call with getaddrinfo().

Untested.  There are no callers to u_socket_connect() in Gallium.
---
 src/gallium/auxiliary/util/u_network.c | 35 +-
 1 file changed, 22 insertions(+), 13 deletions(-)

diff --git a/src/gallium/auxiliary/util/u_network.c 
b/src/gallium/auxiliary/util/u_network.c
index 45b3691..a7a4d28 100644
--- a/src/gallium/auxiliary/util/u_network.c
+++ b/src/gallium/auxiliary/util/u_network.c
@@ -3,9 +3,11 @@
 #include "util/u_network.h"
 #include "util/u_debug.h"
 
+#include 
 #if defined(PIPE_SUBSYSTEM_WINDOWS_USER)
 #  include 
 #  include 
+#  include 
 #elif defined(PIPE_OS_LINUX) || defined(PIPE_OS_HAIKU) || \
defined(PIPE_OS_APPLE) || defined(PIPE_OS_CYGWIN) || 
defined(PIPE_OS_SOLARIS)
 #  include 
@@ -110,28 +112,35 @@ int
 u_socket_connect(const char *hostname, uint16_t port)
 {
 #if defined(PIPE_HAVE_SOCKETS)
-   int s;
-   struct sockaddr_in sa;
-   struct hostent *host = NULL;
+   int s, r;
+   struct addrinfo hints, *addr;
+   char portString[20];
 
-   memset(, 0, sizeof(struct sockaddr_in));
-   host = gethostbyname(hostname);
-   if (!host)
-  return -1;
+   memset(, 0, sizeof hints);
+   hints.ai_family = AF_UNSPEC; // AF_INET or AF_INET6 to force version
+   hints.ai_socktype = SOCK_STREAM;
 
-   memcpy((char *)_addr,host->h_addr_list[0],host->h_length);
-   sa.sin_family= host->h_addrtype;
-   sa.sin_port = htons(port);
+   snprintf(portString, sizeof(portString), "%d", port);
 
-   s = socket(host->h_addrtype, SOCK_STREAM, IPPROTO_TCP);
-   if (s < 0)
+   r = getaddrinfo(hostname, portString, NULL, );
+   if (r != 0) {
   return -1;
+   }
 
-   if (connect(s, (struct sockaddr *), sizeof(sa))) {
+   s = socket(addr->ai_family, SOCK_STREAM, IPPROTO_TCP);
+   if (s < 0) {
+  freeaddrinfo(addr);
+  return -1;
+   }
+
+   if (connect(s, addr->ai_addr, (int) addr->ai_addrlen)) {
   u_socket_close(s);
+  freeaddrinfo(addr);
   return -1;
}
 
+   freeaddrinfo(addr);
+
return s;
 #else
assert(0);
-- 
1.9.1

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


[Mesa-dev] [PATCH 4/5] mesa: use util_strdup() macro in u_debug_symbol.c

2017-10-17 Thread Brian Paul
---
 src/gallium/auxiliary/util/u_debug_symbol.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/gallium/auxiliary/util/u_debug_symbol.c 
b/src/gallium/auxiliary/util/u_debug_symbol.c
index 4b55523..8476043 100644
--- a/src/gallium/auxiliary/util/u_debug_symbol.c
+++ b/src/gallium/auxiliary/util/u_debug_symbol.c
@@ -309,7 +309,7 @@ debug_symbol_name_cached(const void *addr)
{
   char buf[1024];
   debug_symbol_name(addr, buf, sizeof(buf));
-  name = strdup(buf);
+  name = util_strdup(buf);
 
   util_hash_table_set(symbols_hash, (void*)addr, (void*)name);
}
-- 
1.9.1

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


[Mesa-dev] [PATCH 2/5] util: add util_strdup() wrapper macro

2017-10-17 Thread Brian Paul
To work around MSVC warning that strdup() is a deprecated POSIX function.
---
 src/util/u_string.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/util/u_string.h b/src/util/u_string.h
index fa0241e..ce45430 100644
--- a/src/util/u_string.h
+++ b/src/util/u_string.h
@@ -203,6 +203,7 @@ util_strstr(const char *haystack, const char *needle)
 
 
 #define util_strcasecmp stricmp
+#define util_strdup _strdup
 
 #else
 
@@ -217,6 +218,7 @@ util_strstr(const char *haystack, const char *needle)
 #define util_strncat strncat
 #define util_strstr strstr
 #define util_strcasecmp strcasecmp
+#define util_strdup strdup
 
 #endif
 
-- 
1.9.1

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


Re: [Mesa-dev] [PATCH 4/4] meson: build nouveau veaux driver

2017-10-17 Thread Dylan Baker
Quoting Ilia Mirkin (2017-10-17 12:02:05)
> On Tue, Oct 17, 2017 at 2:51 PM, Dylan Baker  wrote:
> > Gah. French is one of the few romance languages I've never learned even a 
> > little
> > of.
> >
> > Fixed locally, would you like me to send a v2?
> 
> I have faith in your sed -i skills. Hopefully you'll push it somewhere
> though so I can test it out (after you also provide some instructions
> for those of us who haven't really been following along).
> 
>   -ilia

https://github.com/dcbaker/mesa wip/meson-classic-drivers

Which should include the veaux -> vieux fix.

Here is an initial patch for meson docs, I'm sure there's more enhancements
necessary:
https://lists.freedesktop.org/archives/mesa-dev/2017-October/173188.html

Or the latest version
https://github.com/dcbaker/mesa meson-build-docs

Dylan


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


Re: [Mesa-dev] [PATCH v2 07/52] intel/fs: Use a pair of 1-wide MOVs instead of SEL for any/all

2017-10-17 Thread Matt Turner

On 10/12, Jason Ekstrand wrote:

For some reason, the any/all predicates don't work properly with SIMD32.
In particular, it appears that a SEL with a QtrCtrl of 2H doesn't read
the correct subset of the flag register and you end up getting garbage
in the second half.  Work around this by using a pair of 1-wide MOVs and
scattering the result.  This fixes the any/all instructions for SIMD32.


Huh. I can see a lot of potential for hardware misbehavior here...

Making things 1-wide makes a lot of sense, regardless of the bug you're
seeing. I'm in favor of that change.

I picked a SEL instead of a predicated MOV instruction since the latter
is considered by our optimizer to be a partial write, and as such isn't
subject to CSE, etc. The difference is probably trivial, but I'd rather
just commit a patch to change things to be 1-wide, not s/SEL/MOV/, and
drop the added comments from the code.

Assuming that still fixes the bug you see, that would be

Reviewed-by: Matt Turner 


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


Re: [Mesa-dev] [PATCH v2 6/8] egl: add dri2_egl_surface_destroy_image_front() helper (v2)

2017-10-17 Thread Gurchetan Singh
dri2_egl_surface_destroy_image_front
and dri2_egl_surface_destroy_image_back are almost identical.  Why don't
you just create a dri2_surface_free_image(struct dri2_egl_surface
*dri2_surf, __DRIimage **img) that you will call with both the front and
back images?  In addition, only platform_android has dri_image_back
and dri_image_front -- please keep the pre-processor checks.  You can,
however, merge the dri_image_front (used by platform_android) and front
(used by platform_surfaceless).

On Fri, Oct 6, 2017 at 2:38 PM, Gwan-gyeong Mun  wrote:

> To share common destroy dri_image_front code.
>
> In preparation to adding of new platform which uses this helper.
>
> v2:
>  - Move dri_image_front to outside of android ifdef block for removing of
>ifdef magic on dri2_egl_surface_destroy_image_front().
>  - Fixes from Eric's review:
>a) Split out series of refactor for helpers to a separate series.
>b) Add the new helper function and use them to replace the old code in
> the
>   same patch.
>
> Signed-off-by: Mun Gwan-gyeong 
> ---
>  src/egl/drivers/dri2/egl_dri2.c | 12 
>  src/egl/drivers/dri2/egl_dri2.h |  5 -
>  src/egl/drivers/dri2/platform_android.c |  7 +--
>  3 files changed, 17 insertions(+), 7 deletions(-)
>
> diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_
> dri2.c
> index bb4944358d..67ae33cdc9 100644
> --- a/src/egl/drivers/dri2/egl_dri2.c
> +++ b/src/egl/drivers/dri2/egl_dri2.c
> @@ -1127,6 +1127,18 @@ dri2_egl_surface_destroy_image_back(struct
> dri2_egl_surface *dri2_surf)
> }
>  }
>
> +void
> +dri2_egl_surface_destroy_image_front(struct dri2_egl_surface *dri2_surf)
> +{
> +   struct dri2_egl_display *dri2_dpy =
> +  dri2_egl_display(dri2_surf->base.Resource.Display);
> +
> +   if (dri2_surf->dri_image_front) {
> +  dri2_dpy->image->destroyImage(dri2_surf->dri_image_front);
> +  dri2_surf->dri_image_front = NULL;
> +   }
> +}
> +
>  /**
>   * Called via eglTerminate(), drv->API.Terminate().
>   *
> diff --git a/src/egl/drivers/dri2/egl_dri2.h b/src/egl/drivers/dri2/egl_
> dri2.h
> index 165749ebb1..83b9e368b2 100644
> --- a/src/egl/drivers/dri2/egl_dri2.h
> +++ b/src/egl/drivers/dri2/egl_dri2.h
> @@ -313,11 +313,11 @@ struct dri2_egl_surface
> } color_buffers[COLOR_BUFFERS_SIZE], *back, *current;
>
> __DRIimage *dri_image_back;
> +   __DRIimage *dri_image_front;
>
>  #ifdef HAVE_ANDROID_PLATFORM
> struct ANativeWindow *window;
> struct ANativeWindowBuffer *buffer;
> -   __DRIimage *dri_image_front;
>  #endif
>
>  #if defined(HAVE_SURFACELESS_PLATFORM)
> @@ -475,6 +475,9 @@ dri2_egl_surface_update_buffer_age(struct
> dri2_egl_surface *dri2_surf);
>  void
>  dri2_egl_surface_destroy_image_back(struct dri2_egl_surface *dri2_surf);
>
> +void
> +dri2_egl_surface_destroy_image_front(struct dri2_egl_surface *dri2_surf);
> +
>  EGLBoolean
>  dri2_init_surface(_EGLSurface *surf, _EGLDisplay *dpy, EGLint type,
>  _EGLConfig *conf, const EGLint *attrib_list, EGLBoolean
> enable_out_fence);
> diff --git a/src/egl/drivers/dri2/platform_android.c
> b/src/egl/drivers/dri2/platform_android.c
> index 421395b5d7..c98802774c 100644
> --- a/src/egl/drivers/dri2/platform_android.c
> +++ b/src/egl/drivers/dri2/platform_android.c
> @@ -354,12 +354,7 @@ droid_destroy_surface(_EGLDriver *drv, _EGLDisplay
> *disp, _EGLSurface *surf)
> }
>
> dri2_egl_surface_destroy_image_back(dri2_surf);
> -
> -   if (dri2_surf->dri_image_front) {
> -  _eglLog(_EGL_DEBUG, "%s : %d : destroy dri_image_front", __func__,
> __LINE__);
> -  dri2_dpy->image->destroyImage(dri2_surf->dri_image_front);
> -  dri2_surf->dri_image_front = NULL;
> -   }
> +   dri2_egl_surface_destroy_image_front(dri2_surf);
>
> dri2_dpy->core->destroyDrawable(dri2_surf->dri_drawable);
>
> --
> 2.14.2
>
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH v2 06/52] intel/fs: Use an explicit D type for vote any/all/eq intrinsics

2017-10-17 Thread Matt Turner

On 10/12, Jason Ekstrand wrote:

They return a boolean so this is the right type.  Unfortunately,
get_nir_dest has the annoying behavior of giving us a float type by
default.  This is mostly to work around the fact that gen7 has 64-bit
float but no Q types.


I'd really like to see a clearer explanation about what this fixes.
Something like

"These intrinsics will be used to implement X, Y, Z from $extension,
which support additional types (including 64-bit types). For 64-bit
types get_nir_dest() returns ..., so we need to force the type to D
since it always returns a bool."


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


[Mesa-dev] [PATCH 1/2] nir: Add a safety check that we don't remove dead I/O vars after lowering.

2017-10-17 Thread Eric Anholt
The pass only looks at var load/store intrinsics, not input load/store
intrinsics, so assert that we don't see the other type.
---

I tripped over this limitation when trying to use the NIR linking
helpers in vc4.

 src/compiler/nir/nir_remove_dead_variables.c | 20 
 1 file changed, 16 insertions(+), 4 deletions(-)

diff --git a/src/compiler/nir/nir_remove_dead_variables.c 
b/src/compiler/nir/nir_remove_dead_variables.c
index a1fe0de9c61f..7a676f2309c4 100644
--- a/src/compiler/nir/nir_remove_dead_variables.c
+++ b/src/compiler/nir/nir_remove_dead_variables.c
@@ -28,7 +28,8 @@
 #include "nir.h"
 
 static void
-add_var_use_intrinsic(nir_intrinsic_instr *instr, struct set *live)
+add_var_use_intrinsic(nir_intrinsic_instr *instr, struct set *live,
+  nir_variable_mode modes)
 {
unsigned num_vars = nir_intrinsic_infos[instr->intrinsic].num_variables;
 
@@ -47,6 +48,16 @@ add_var_use_intrinsic(nir_intrinsic_instr *instr, struct set 
*live)
   break;
}
 
+  /* This pass can't be used on I/O variables after they've been
+   * lowered.
+   */
+   case nir_intrinsic_load_input:
+  assert(!(modes & nir_var_shader_in));
+  break;
+   case nir_intrinsic_store_output:
+  assert(!(modes & nir_var_shader_out));
+  break;
+
default:
   for (unsigned i = 0; i < num_vars; i++) {
  _mesa_set_add(live, instr->variables[i]->var);
@@ -84,7 +95,7 @@ add_var_use_tex(nir_tex_instr *instr, struct set *live)
 }
 
 static void
-add_var_use_shader(nir_shader *shader, struct set *live)
+add_var_use_shader(nir_shader *shader, struct set *live, nir_variable_mode 
modes)
 {
nir_foreach_function(function, shader) {
   if (function->impl) {
@@ -92,7 +103,8 @@ add_var_use_shader(nir_shader *shader, struct set *live)
 nir_foreach_instr(instr, block) {
switch(instr->type) {
case nir_instr_type_intrinsic:
-  add_var_use_intrinsic(nir_instr_as_intrinsic(instr), live);
+  add_var_use_intrinsic(nir_instr_as_intrinsic(instr), live,
+modes);
   break;
 
case nir_instr_type_call:
@@ -162,7 +174,7 @@ nir_remove_dead_variables(nir_shader *shader, 
nir_variable_mode modes)
struct set *live =
   _mesa_set_create(NULL, _mesa_hash_pointer, _mesa_key_pointer_equal);
 
-   add_var_use_shader(shader, live);
+   add_var_use_shader(shader, live, modes);
 
if (modes & nir_var_uniform)
   progress = remove_dead_vars(>uniforms, live) || progress;
-- 
2.14.2

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


[Mesa-dev] [PATCH 2/2] nir: Print the components referenced for split or packed shader in/outs.

2017-10-17 Thread Eric Anholt
Having 4 variables all called "gl_in_TexCoord0@n" isn't very informative,
much better to see:

decl_var shader_in INTERP_MODE_NONE float gl_in_TexCoord0 (VARYING_SLOT_VAR0.x, 
1, 0)
decl_var shader_in INTERP_MODE_NONE float gl_in_TexCoord0@0 
(VARYING_SLOT_VAR0.y, 1, 0)
decl_var shader_in INTERP_MODE_NONE float gl_in_TexCoord0@1 
(VARYING_SLOT_VAR0.z, 1, 0)
decl_var shader_in INTERP_MODE_NONE float gl_in_TexCoord0@2 
(VARYING_SLOT_VAR0.w, 1, 0)
---
 src/compiler/nir/nir_print.c | 25 -
 1 file changed, 24 insertions(+), 1 deletion(-)

diff --git a/src/compiler/nir/nir_print.c b/src/compiler/nir/nir_print.c
index f4811fe8bc11..df7a2057bfb9 100644
--- a/src/compiler/nir/nir_print.c
+++ b/src/compiler/nir/nir_print.c
@@ -447,7 +447,30 @@ print_var_decl(nir_variable *var, print_state *state)
  loc = buf;
   }
 
-  fprintf(fp, " (%s, %u, %u)%s", loc, var->data.driver_location, 
var->data.binding,
+  /* For shader I/O vars that have been split to components or packed,
+   * print the fractional location within the input/output.
+   */
+  unsigned int num_components = glsl_get_components(var->type);
+  const char *components = NULL;
+  char components_local[6] = {'.' /* the rest is 0-filled */};
+  switch (var->data.mode) {
+  case nir_var_shader_in:
+  case nir_var_shader_out:
+ if (num_components != 4) {
+const char *xyzw = "xyzw";
+for (int i = 0; i < num_components; i++)
+   components_local[i + 1] = xyzw[i + var->data.location_frac];
+
+components = components_local;
+ }
+ break;
+  default:
+ break;
+  }
+
+  fprintf(fp, " (%s%s, %u, %u)%s", loc,
+  components ? components : "",
+  var->data.driver_location, var->data.binding,
   var->data.compact ? " compact" : "");
}
 
-- 
2.14.2

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


[Mesa-dev] [PATCH 2/2] ac: Silence a compiler warning about results[0].

2017-10-17 Thread Eric Anholt
We know that num_components will be > 0, but it doesn't.
---
 src/amd/common/ac_nir_to_llvm.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/amd/common/ac_nir_to_llvm.c b/src/amd/common/ac_nir_to_llvm.c
index 3ba3ebf051e2..07fa3fdf84b5 100644
--- a/src/amd/common/ac_nir_to_llvm.c
+++ b/src/amd/common/ac_nir_to_llvm.c
@@ -2390,6 +2390,7 @@ static LLVMValueRef visit_load_buffer(struct 
ac_nir_context *ctx,
 
}
 
+   assume(results[0]);
LLVMValueRef ret = results[0];
if (num_components > 4 || num_components == 3) {
LLVMValueRef masks[] = {
-- 
2.14.2

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


[Mesa-dev] [PATCH 1/2] ac: Fix a compiler warning for possibly undefined "name"

2017-10-17 Thread Eric Anholt
---
 src/amd/common/ac_llvm_build.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/amd/common/ac_llvm_build.c b/src/amd/common/ac_llvm_build.c
index 949f181aace0..2341d2135856 100644
--- a/src/amd/common/ac_llvm_build.c
+++ b/src/amd/common/ac_llvm_build.c
@@ -1257,7 +1257,7 @@ LLVMValueRef ac_build_image_opcode(struct ac_llvm_context 
*ctx,
LLVMTypeRef dst_type;
LLVMValueRef args[11];
unsigned num_args = 0;
-   const char *name;
+   const char *name = NULL;
char intr_name[128], type[64];
 
if (HAVE_LLVM >= 0x0400) {
-- 
2.14.2

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


Re: [Mesa-dev] [PATCH v2 2/8] egl: refactor color_buffers structure for deduplicating

2017-10-17 Thread Gurchetan Singh
Can you wrap color_buffers around:

#if defined(HAVE_WAYLAND_PLATFORM) || defined(HAVE_DRM_PLATFORM)
|| defined(HAVE_ANDROID_PLATFORM)

flags?  This is because platform_surfaceless has no native surfaces and
it's good to be explicit in that regard.

On Fri, Oct 6, 2017 at 2:38 PM, Gwan-gyeong Mun  wrote:

> This is added for preventing adding of new color buffers structure and
> back*
> when new platform backend is added.
> This refactoring separates out the common and platform specific bits.
> This makes odd casting in the platform_foo.c but it prevents adding of new
> ifdef magic.
> Because of color_buffers array size is different on android and wayland
> /drm,
> it adds COLOR_BUFFERS_SIZE macro.
>  - android's color buffers array size is 3.
>drm & wayland's color buffers array size is 4.
>
> Fixes from Rob's review:
>  - refactor to separate out the common and platform specific bits.
>
> Fixes from Emil's review:
>  - use suggested color buffers structure shape.
>it makes a buffer pointer of each platform to void pointer type.
>
> Signed-off-by: Mun Gwan-gyeong 
> ---
>  src/egl/drivers/dri2/egl_dri2.h | 30 +-
>  src/egl/drivers/dri2/platform_android.c | 10 +++---
>  src/egl/drivers/dri2/platform_drm.c | 55
> +
>  src/egl/drivers/dri2/platform_wayland.c | 46 +--
>  4 files changed, 71 insertions(+), 70 deletions(-)
>
> diff --git a/src/egl/drivers/dri2/egl_dri2.h
> b/src/egl/drivers/dri2/egl_dri2.h
> index 017895f0d9..08ccf24410 100644
> --- a/src/egl/drivers/dri2/egl_dri2.h
> +++ b/src/egl/drivers/dri2/egl_dri2.h
> @@ -65,6 +65,15 @@ struct zwp_linux_dmabuf_v1;
>
>  #endif /* HAVE_ANDROID_PLATFORM */
>
> +#if defined(HAVE_WAYLAND_PLATFORM) || defined(HAVE_DRM_PLATFORM)
> +#define COLOR_BUFFERS_SIZE 4
> +#else
> +   /* Usually Android uses at most triple buffers in ANativeWindow
> +* so hardcode the number of color_buffers to 3.
> +*/
> +#define COLOR_BUFFERS_SIZE 3
> +#endif
> +
>  #include "eglconfig.h"
>  #include "eglcontext.h"
>  #include "egldisplay.h"
> @@ -286,39 +295,28 @@ struct dri2_egl_surface
> /* EGL-owned buffers */
> __DRIbuffer   *local_buffers[__DRI_BUFFER_COUNT];
>
> -#if defined(HAVE_WAYLAND_PLATFORM) || defined(HAVE_DRM_PLATFORM)
> +   /* Used to record all the buffers created by each platform's native
> window
> +* and their ages.
> +*/
> struct {
> +  void *native_buffer; // aka wl_buffer/gbm_bo/ANativeWindowBuffer
>  #ifdef HAVE_WAYLAND_PLATFORM
> -  struct wl_buffer   *wl_buffer;
>__DRIimage *dri_image;
>/* for is_different_gpu case. NULL else */
>__DRIimage *linear_copy;
>/* for swrast */
>void *data;
>int data_size;
> -#endif
> -#ifdef HAVE_DRM_PLATFORM
> -  struct gbm_bo   *bo;
>  #endif
>boollocked;
>int age;
> -   } color_buffers[4], *back, *current;
> -#endif
> +   } color_buffers[COLOR_BUFFERS_SIZE], *back, *current;
>
>  #ifdef HAVE_ANDROID_PLATFORM
> struct ANativeWindow *window;
> struct ANativeWindowBuffer *buffer;
> __DRIimage *dri_image_back;
> __DRIimage *dri_image_front;
> -
> -   /* Used to record all the buffers created by ANativeWindow and their
> ages.
> -* Usually Android uses at most triple buffers in ANativeWindow
> -* so hardcode the number of color_buffers to 3.
> -*/
> -   struct {
> -  struct ANativeWindowBuffer *buffer;
> -  int age;
> -   } color_buffers[3], *back;
>  #endif
>
>  #if defined(HAVE_SURFACELESS_PLATFORM)
> diff --git a/src/egl/drivers/dri2/platform_android.c
> b/src/egl/drivers/dri2/platform_android.c
> index 0acbb38bd8..67e739c1fc 100644
> --- a/src/egl/drivers/dri2/platform_android.c
> +++ b/src/egl/drivers/dri2/platform_android.c
> @@ -193,10 +193,10 @@ droid_window_dequeue_buffer(struct dri2_egl_surface
> *dri2_surf)
>  */
> EGLBoolean updated = EGL_FALSE;
> for (int i = 0; i < ARRAY_SIZE(dri2_surf->color_buffers); i++) {
> -  if (!dri2_surf->color_buffers[i].buffer) {
> - dri2_surf->color_buffers[i].buffer = dri2_surf->buffer;
> +  if (!dri2_surf->color_buffers[i].native_buffer) {
> + dri2_surf->color_buffers[i].native_buffer = (void
> *)dri2_surf->buffer;
>}
> -  if (dri2_surf->color_buffers[i].buffer == dri2_surf->buffer) {
> +  if (dri2_surf->color_buffers[i].native_buffer == (void
> *)dri2_surf->buffer) {
>   dri2_surf->back = _surf->color_buffers[i];
>   updated = EGL_TRUE;
>   break;
> @@ -208,10 +208,10 @@ droid_window_dequeue_buffer(struct dri2_egl_surface
> *dri2_surf)
> * the color_buffers
> */
>for (int i = 0; i < ARRAY_SIZE(dri2_surf->color_buffers); i++) {
> - dri2_surf->color_buffers[i].buffer = NULL;
> + dri2_surf->color_buffers[i].native_buffer = NULL;
>   

Re: [Mesa-dev] [PATCH v2 05/52] intel/fs: Don't stomp f0.1 in SIMD16 ballot

2017-10-17 Thread Matt Turner

On 10/12, Jason Ekstrand wrote:

In fragment shaders f0.1 is used for discards so doing ballot after a
discard can potentially cause the discard to not happen.


Since

- SIMD32 currently only used in compute shaders
- discard only available in fragment shaders

this will fix discards in SIMD16 fragment shaders using ballotARB(), but
leaves it broken in SIMD32. Is that your understanding?

If so, expanding the commit message a little and leaving a FIXME might
be nice.


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


Re: [Mesa-dev] [PATCH] docs: add documentation for building with meson

2017-10-17 Thread Dylan Baker
Quoting Nicolai Hähnle (2017-10-17 13:40:00)
> On 17.10.2017 22:33, Dylan Baker wrote:
> > Quoting Nicolai Hähnle (2017-10-17 13:05:12)
> >> On 17.10.2017 21:21, Dylan Baker wrote:
> >>> +CC, CFLAGS, CXX, CXXFLAGS
> >>> +These environment variables
> >>> +control the C and C++ compilers used during the build. The default 
> >>> compilers
> >>> +depends on your operating system. Meson supports GCC, Clang, and MSVC as 
> >>> first
> >>> +class compilers. There is some support for the Intel ICC compiler. No 
> >>> other
> >>> +C/C++ compilers are currently supported.
> >>> +
> >>> +
> >>> +PKG_CONFIG_PATH
> >>> +The
> >>> +pkg-config utility is a hard requirement for configuring and
> >>> +building mesa. It is used to search for external libraries
> >>> +on the system. This environment variable is used to control the search
> >>> +path for pkg-config. For instance, setting
> >>> +PKG_CONFIG_PATH=/usr/X11R6/lib/pkgconfig will search for
> >>> +package metadata in /usr/X11R6 before the standard
> >>> +directories.
> >>> +
> >>> +
> >>
> >> Not knowing Meson, how do environment variables like CFLAGS, CC, etc.
> >> work? Are they "latched" when calling `meson $builddir`? When calling
> >> `meson configure`? Both? Does setting them have an effect when calling
> >> `ninja`?
> > 
> > I'll update this document as well, but for your edification: they are 
> > "latched"
> > by meson and stored in it's configuration information, they can be 
> > overwritten
> > when meson is initialized or re-initialized. That means that passing them to
> > "meson configure" won't change anything, since meson configure just touches
> > stored variables, but doesn't re-initialize. Passing them to ninja will 
> > only do
> > something if ninja decides that it needs to re-initialize, say if you touch 
> > a
> > meson.build file.
> 
> Thanks!
> 
> 
> > examples:
> >  CC=clang CXX=clang++ meson build-clang
> >  CC=notacompiler CXX=notacompiler ninja -C build
> > will result in building with clang/clang++
> > 
> >  touch meson.build
> >  CC=notacompiler CXX=notacompiler ninja -C build
> > nothing works, since ninja will re-initialize meson and it will read the
> > environment and set the compiler to notacompiler and fail.
> 
> :(
> 
> Presumably at least it doesn't break if CC and CXX are unset? In the 
> sense that the old values are kept?

Yes, if any of these are unset on subsequent re-initializations the previous
value is retained.
so:
  CC=clang CXX=clang++ meson build-clang
  CC=notacompiler CXX=notacompiler ninja -C build-clang clean
  touch meson.build
  ninja -C build-clang

Would build with clang, clean, and build with clang again.

Dylan

> 
> Cheers,
> Nicolai
> 
> 
> > 
> > I'll also add this to the documentation, but meson remembers options, and 
> > meson
> > configure only changes options that you supply so:
> >  meson build --prefix=/tmp
> >  meson configure build -Ddri-drivers=i965
> > will not reset the prefix.
> > 
> > Dylan
> > 
> 
> 
> -- 
> Lerne, wie die Welt wirklich ist,
> Aber vergiss niemals, wie sie sein sollte.


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


Re: [Mesa-dev] [PATCH] docs: add documentation for building with meson

2017-10-17 Thread Nicolai Hähnle

On 17.10.2017 22:33, Dylan Baker wrote:

Quoting Nicolai Hähnle (2017-10-17 13:05:12)

On 17.10.2017 21:21, Dylan Baker wrote:

+CC, CFLAGS, CXX, CXXFLAGS
+These environment variables
+control the C and C++ compilers used during the build. The default compilers
+depends on your operating system. Meson supports GCC, Clang, and MSVC as first
+class compilers. There is some support for the Intel ICC compiler. No other
+C/C++ compilers are currently supported.
+
+
+PKG_CONFIG_PATH
+The
+pkg-config utility is a hard requirement for configuring and
+building mesa. It is used to search for external libraries
+on the system. This environment variable is used to control the search
+path for pkg-config. For instance, setting
+PKG_CONFIG_PATH=/usr/X11R6/lib/pkgconfig will search for
+package metadata in /usr/X11R6 before the standard
+directories.
+
+


Not knowing Meson, how do environment variables like CFLAGS, CC, etc.
work? Are they "latched" when calling `meson $builddir`? When calling
`meson configure`? Both? Does setting them have an effect when calling
`ninja`?


I'll update this document as well, but for your edification: they are "latched"
by meson and stored in it's configuration information, they can be overwritten
when meson is initialized or re-initialized. That means that passing them to
"meson configure" won't change anything, since meson configure just touches
stored variables, but doesn't re-initialize. Passing them to ninja will only do
something if ninja decides that it needs to re-initialize, say if you touch a
meson.build file.


Thanks!



examples:
 CC=clang CXX=clang++ meson build-clang
 CC=notacompiler CXX=notacompiler ninja -C build
will result in building with clang/clang++

 touch meson.build
 CC=notacompiler CXX=notacompiler ninja -C build
nothing works, since ninja will re-initialize meson and it will read the
environment and set the compiler to notacompiler and fail.


:(

Presumably at least it doesn't break if CC and CXX are unset? In the 
sense that the old values are kept?


Cheers,
Nicolai




I'll also add this to the documentation, but meson remembers options, and meson
configure only changes options that you supply so:
 meson build --prefix=/tmp
 meson configure build -Ddri-drivers=i965
will not reset the prefix.

Dylan




--
Lerne, wie die Welt wirklich ist,
Aber vergiss niemals, wie sie sein sollte.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 0/5] etnaviv: support occlusion queries

2017-10-17 Thread Christian Gmeiner
This small patch series adds support for occlusion queries. This is
the last thing needed to expose desktop opengl 2.0! Not all piglits
for occlusion queries are passing but overall the results
are looking good.

Christian Gmeiner (5):
  etnaviv: update headers from rnndb
  etnaviv: add basic infrastructure for hw queries
  etnaviv: add support for occlusion queries
  etnaviv: enable occlusion query if GPU supports it
  etnaviv: fix implicit conversion warning

 src/gallium/drivers/etnaviv/Makefile.sources   |   2 +
 src/gallium/drivers/etnaviv/etnaviv_context.c  |  11 +
 src/gallium/drivers/etnaviv/etnaviv_context.h  |   3 +
 src/gallium/drivers/etnaviv/etnaviv_query.c|   3 +
 src/gallium/drivers/etnaviv/etnaviv_query.h|   2 +-
 src/gallium/drivers/etnaviv/etnaviv_query_hw.c | 291 
 src/gallium/drivers/etnaviv/etnaviv_query_hw.h |  90 +++
 src/gallium/drivers/etnaviv/etnaviv_query_sw.c |   2 +-
 src/gallium/drivers/etnaviv/etnaviv_screen.c   |   3 +-
 src/gallium/drivers/etnaviv/hw/cmdstream.xml.h |  36 ++-
 src/gallium/drivers/etnaviv/hw/common.xml.h| 117 
 src/gallium/drivers/etnaviv/hw/isa.xml.h   |   4 +-
 src/gallium/drivers/etnaviv/hw/state.xml.h | 197 --
 src/gallium/drivers/etnaviv/hw/state_3d.xml.h  | 357 -
 14 files changed, 1026 insertions(+), 92 deletions(-)
 create mode 100644 src/gallium/drivers/etnaviv/etnaviv_query_hw.c
 create mode 100644 src/gallium/drivers/etnaviv/etnaviv_query_hw.h

-- 
2.13.6

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


[Mesa-dev] [PATCH 5/5] etnaviv: fix implicit conversion warning

2017-10-17 Thread Christian Gmeiner
Galliums query_type used in APIs is unsigned.

Signed-off-by: Christian Gmeiner 
---
 src/gallium/drivers/etnaviv/etnaviv_query.h| 2 +-
 src/gallium/drivers/etnaviv/etnaviv_query_sw.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/etnaviv/etnaviv_query.h 
b/src/gallium/drivers/etnaviv/etnaviv_query.h
index e099e10f7c..8927266057 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_query.h
+++ b/src/gallium/drivers/etnaviv/etnaviv_query.h
@@ -44,7 +44,7 @@ struct etna_query_funcs {
 struct etna_query {
const struct etna_query_funcs *funcs;
bool active;
-   int type;
+   unsigned type;
 };
 
 static inline struct etna_query *
diff --git a/src/gallium/drivers/etnaviv/etnaviv_query_sw.c 
b/src/gallium/drivers/etnaviv/etnaviv_query_sw.c
index ea79467b61..dd9bac3850 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_query_sw.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_query_sw.c
@@ -42,7 +42,7 @@ etna_sw_destroy_query(struct etna_context *ctx, struct 
etna_query *q)
 }
 
 static uint64_t
-read_counter(struct etna_context *ctx, int type)
+read_counter(struct etna_context *ctx, unsigned type)
 {
switch (type) {
case PIPE_QUERY_PRIMITIVES_EMITTED:
-- 
2.13.6

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


Re: [Mesa-dev] [PATCH v2 1/8] egl: add dri2_egl_surface_free_outdated_buffers_and_update_size() helper (v2)

2017-10-17 Thread Gurchetan Singh
The naming is verbose and somewhat inconsistent.  We have:

dri2_init_surface
dri2_fini_surface
dri2_egl_surface_alloc_local_buffer
dri2_egl_surface_free_local_buffers

I suggest you implement the following convention:

dri2_surface_init
dri2_surface_fini
dri2_surface_alloc_attachment (instead of 'local_buffers')
dri2_surface_free_attachments  (instead of 'local_buffers')

and instead of dri2_egl_surface_free_outdated_buffers_and_update_size, we
can just have:

dri2_surface_update

And can you wrap these functions around the:

#if defined(HAVE_WAYLAND_PLATFORM) || defined(HAVE_DRM_PLATFORM)
|| defined(HAVE_ANDROID_PLATFORM)

pre-processors checks just to make clear what platforms use the attachment
(aka 'local_buffers') functionality.

On Tue, Oct 17, 2017 at 6:28 AM, Emil Velikov 
wrote:

> Hi Gwan-gyeong,
>
> On 6 October 2017 at 22:38, Gwan-gyeong Mun  wrote:
> > To share common free outdated buffers and update size code.
> > This compares width and height arguments with current egl surface
> dimension,
> > if the compared surface dimension is differ, then it free local buffers
> and
> > updates dimension.
> >
> > In preparation to adding of new platform which uses this helper.
> >
> > v2: Fixes from Eric's review:
> >a) Split out series of refactor for helpers to a separate series.
> >b) Add the new helper function and use them to replace the old code
> in the
> >   same patch.
> >
> > Signed-off-by: Mun Gwan-gyeong 
>
> The name dri2_egl_surface_free_outdated_buffers_and_update_size might
> be a bit long/too verbose, but I'm out of ideas for alternative.
> For the patch
> Reviewed-by: Emil Velikov 
>
> Side note:
> We should be able to reuse this for platform_wayland, in the future.
>
> -Emil
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 3/5] etnaviv: add support for occlusion queries

2017-10-17 Thread Christian Gmeiner
Passes most occlusion query piglits. The following piglits are broken:
- spec@arb_occlusion_query@occlusion_query_meta_fragments
- spec@arb_occlusion_query@occlusion_query_meta_save
- spec@arb_occlusion_query2@render

Signed-off-by: Christian Gmeiner 
---
 src/gallium/drivers/etnaviv/etnaviv_query_hw.c | 106 +
 1 file changed, 106 insertions(+)

diff --git a/src/gallium/drivers/etnaviv/etnaviv_query_hw.c 
b/src/gallium/drivers/etnaviv/etnaviv_query_hw.c
index a1dead335c..b9223e1361 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_query_hw.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_query_hw.c
@@ -30,9 +30,82 @@
 #include "util/u_memory.h"
 
 #include "etnaviv_context.h"
+#include "etnaviv_debug.h"
+#include "etnaviv_emit.h"
 #include "etnaviv_query_hw.h"
 #include "etnaviv_screen.h"
 
+/*
+ * Occlusion Query:
+ *
+ * OCCLUSION_COUNTER and OCCLUSION_PREDICATE differ only in how they
+ * interpret results
+ */
+
+static void
+occlusion_start(struct etna_hw_query *hq, struct etna_context *ctx)
+{
+   struct etna_resource *rsc = etna_resource(hq->prsc);
+   struct etna_reloc r = {
+  .bo = rsc->bo,
+  .flags = ETNA_RELOC_WRITE
+   };
+
+   if (hq->samples > 63) {
+  hq->samples = 63;
+  BUG("samples overflow");
+   }
+
+   r.offset = hq->samples * 8; /* 64bit value */
+
+   etna_set_state_reloc(ctx->stream, VIVS_GL_OCCLUSION_QUERY_ADDR, );
+}
+
+static void
+occlusion_stop(struct etna_hw_query *hq, struct etna_context *ctx)
+{
+   etna_set_state(ctx->stream, VIVS_GL_OCCLUSION_QUERY_CONTROL, 0x1DF5E76);
+}
+
+static void
+occlusion_suspend(struct etna_hw_query *hq, struct etna_context *ctx)
+{
+   occlusion_stop(hq, ctx);
+}
+
+static void
+occlusion_resume(struct etna_hw_query *hq, struct etna_context *ctx)
+{
+   hq->samples++;
+   occlusion_start(hq, ctx);
+}
+
+static void
+occlusion_counter_result(struct etna_hw_query *hq, void *buf,
+ union pipe_query_result *result)
+{
+   uint64_t sum = 0;
+   uint64_t *ptr = (uint64_t *)buf;
+
+   for (unsigned i = 0; i <= hq->samples; i++)
+  sum += *(ptr + i);
+
+   result->u64 = sum;
+}
+
+static void
+occlusion_predicate_result(struct etna_hw_query *hq, void *buf,
+   union pipe_query_result *result)
+{
+   uint64_t sum = 0;
+   uint64_t *ptr = (uint64_t *)buf;
+
+   for (unsigned i = 0; i <= hq->samples; i++)
+  sum += *(ptr + i);
+
+   result->b = !!sum;
+}
+
 static void
 etna_hw_destroy_query(struct etna_context *ctx, struct etna_query *q)
 {
@@ -44,6 +117,33 @@ etna_hw_destroy_query(struct etna_context *ctx, struct 
etna_query *q)
FREE(hq);
 }
 
+static const struct etna_hw_sample_provider occlusion_counter = {
+   .query_type = PIPE_QUERY_OCCLUSION_COUNTER,
+   .start = occlusion_start,
+   .stop = occlusion_stop,
+   .suspend = occlusion_suspend,
+   .resume = occlusion_resume,
+   .result = occlusion_counter_result,
+};
+
+static const struct etna_hw_sample_provider occlusion_predicate = {
+   .query_type = PIPE_QUERY_OCCLUSION_PREDICATE,
+   .start = occlusion_start,
+   .stop = occlusion_stop,
+   .suspend = occlusion_suspend,
+   .resume = occlusion_resume,
+   .result = occlusion_predicate_result,
+};
+
+static const struct etna_hw_sample_provider occlusion_predicate_conservative = 
{
+   .query_type = PIPE_QUERY_OCCLUSION_PREDICATE_CONSERVATIVE,
+   .start = occlusion_start,
+   .stop = occlusion_stop,
+   .suspend = occlusion_suspend,
+   .resume = occlusion_resume,
+   .result = occlusion_predicate_result,
+};
+
 static void
 realloc_query_bo(struct etna_context *ctx, struct etna_hw_query *hq)
 {
@@ -153,6 +253,12 @@ static inline const struct etna_hw_sample_provider *
 query_sample_provider(unsigned query_type)
 {
switch (query_type) {
+   case PIPE_QUERY_OCCLUSION_COUNTER:
+  return _counter;
+   case PIPE_QUERY_OCCLUSION_PREDICATE:
+  return _predicate;
+   case PIPE_QUERY_OCCLUSION_PREDICATE_CONSERVATIVE:
+  return _predicate_conservative;
default:
   return NULL;
}
-- 
2.13.6

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


[Mesa-dev] [PATCH 4/5] etnaviv: enable occlusion query if GPU supports it

2017-10-17 Thread Christian Gmeiner
Signed-off-by: Christian Gmeiner 
---
 src/gallium/drivers/etnaviv/etnaviv_screen.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/gallium/drivers/etnaviv/etnaviv_screen.c 
b/src/gallium/drivers/etnaviv/etnaviv_screen.c
index 738605a4f3..009bc73c14 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_screen.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_screen.c
@@ -319,8 +319,9 @@ etna_screen_get_param(struct pipe_screen *pscreen, enum 
pipe_cap param)
 
/* Timer queries. */
case PIPE_CAP_QUERY_TIME_ELAPSED:
-   case PIPE_CAP_OCCLUSION_QUERY:
   return 0;
+   case PIPE_CAP_OCCLUSION_QUERY:
+  return VIV_FEATURE(screen, chipMinorFeatures1, HALTI0);
case PIPE_CAP_QUERY_TIMESTAMP:
   return 1;
case PIPE_CAP_QUERY_PIPELINE_STATISTICS:
-- 
2.13.6

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


[Mesa-dev] [PATCH 2/5] etnaviv: add basic infrastructure for hw queries

2017-10-17 Thread Christian Gmeiner
No hardware query is supported yet.

Signed-off-by: Christian Gmeiner 
---
 src/gallium/drivers/etnaviv/Makefile.sources   |   2 +
 src/gallium/drivers/etnaviv/etnaviv_context.c  |  11 ++
 src/gallium/drivers/etnaviv/etnaviv_context.h  |   3 +
 src/gallium/drivers/etnaviv/etnaviv_query.c|   3 +
 src/gallium/drivers/etnaviv/etnaviv_query_hw.c | 185 +
 src/gallium/drivers/etnaviv/etnaviv_query_hw.h |  90 
 6 files changed, 294 insertions(+)
 create mode 100644 src/gallium/drivers/etnaviv/etnaviv_query_hw.c
 create mode 100644 src/gallium/drivers/etnaviv/etnaviv_query_hw.h

diff --git a/src/gallium/drivers/etnaviv/Makefile.sources 
b/src/gallium/drivers/etnaviv/Makefile.sources
index 60275c949d..ea8df807f6 100644
--- a/src/gallium/drivers/etnaviv/Makefile.sources
+++ b/src/gallium/drivers/etnaviv/Makefile.sources
@@ -27,6 +27,8 @@ C_SOURCES :=  \
etnaviv_internal.h \
etnaviv_query.c \
etnaviv_query.h \
+   etnaviv_query_hw.c \
+   etnaviv_query_hw.h \
etnaviv_query_sw.c \
etnaviv_query_sw.h \
etnaviv_rasterizer.c \
diff --git a/src/gallium/drivers/etnaviv/etnaviv_context.c 
b/src/gallium/drivers/etnaviv/etnaviv_context.c
index 67aab6a68c..65c20d2f83 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_context.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_context.c
@@ -34,6 +34,7 @@
 #include "etnaviv_emit.h"
 #include "etnaviv_fence.h"
 #include "etnaviv_query.h"
+#include "etnaviv_query_hw.h"
 #include "etnaviv_rasterizer.h"
 #include "etnaviv_screen.h"
 #include "etnaviv_shader.h"
@@ -260,6 +261,9 @@ etna_draw_vbo(struct pipe_context *pctx, const struct 
pipe_draw_info *info)
   if (ctx->sampler_view[i])
  resource_read(ctx, ctx->sampler_view[i]->texture);
 
+   list_for_each_entry(struct etna_hw_query, hq, >active_hw_queries, node)
+  resource_written(ctx, hq->prsc);
+
ctx->stats.prims_emitted += u_reduced_prims_for_vertices(info->mode, 
info->count);
ctx->stats.draw_calls++;
 
@@ -299,10 +303,16 @@ etna_flush(struct pipe_context *pctx, struct 
pipe_fence_handle **fence,
struct etna_context *ctx = etna_context(pctx);
int out_fence_fd = -1;
 
+   list_for_each_entry(struct etna_hw_query, hq, >active_hw_queries, node)
+  etna_hw_query_suspend(hq, ctx);
+
etna_cmd_stream_flush2(ctx->stream, ctx->in_fence_fd,
  (flags & PIPE_FLUSH_FENCE_FD) ? _fence_fd :
  NULL);
 
+   list_for_each_entry(struct etna_hw_query, hq, >active_hw_queries, node)
+  etna_hw_query_resume(hq, ctx);
+
if (fence)
   *fence = etna_fence_create(pctx, out_fence_fd);
 }
@@ -436,6 +446,7 @@ etna_context_create(struct pipe_screen *pscreen, void 
*priv, unsigned flags)
   goto fail;
 
slab_create_child(>transfer_pool, >transfer_pool);
+   list_inithead(>active_hw_queries);
 
return pctx;
 
diff --git a/src/gallium/drivers/etnaviv/etnaviv_context.h 
b/src/gallium/drivers/etnaviv/etnaviv_context.h
index bf2b265f5e..2903e0963d 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_context.h
+++ b/src/gallium/drivers/etnaviv/etnaviv_context.h
@@ -180,6 +180,9 @@ struct etna_context {
 
struct pipe_debug_callback debug;
int in_fence_fd;
+
+   /* list of active hardware queries */
+   struct list_head active_hw_queries;
 };
 
 static inline struct etna_context *
diff --git a/src/gallium/drivers/etnaviv/etnaviv_query.c 
b/src/gallium/drivers/etnaviv/etnaviv_query.c
index a416a7cb0f..9e897cd75a 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_query.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_query.c
@@ -30,6 +30,7 @@
 
 #include "etnaviv_context.h"
 #include "etnaviv_query.h"
+#include "etnaviv_query_hw.h"
 #include "etnaviv_query_sw.h"
 
 static struct pipe_query *
@@ -40,6 +41,8 @@ etna_create_query(struct pipe_context *pctx, unsigned 
query_type,
struct etna_query *q;
 
q = etna_sw_create_query(ctx, query_type);
+   if (!q)
+  q = etna_hw_create_query(ctx, query_type);
 
return (struct pipe_query *)q;
 }
diff --git a/src/gallium/drivers/etnaviv/etnaviv_query_hw.c 
b/src/gallium/drivers/etnaviv/etnaviv_query_hw.c
new file mode 100644
index 00..a1dead335c
--- /dev/null
+++ b/src/gallium/drivers/etnaviv/etnaviv_query_hw.c
@@ -0,0 +1,185 @@
+/*
+ * Copyright (c) 2017 Etnaviv Project
+ * Copyright (C) 2017 Zodiac Inflight Innovations
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sub license,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included 

[Mesa-dev] [PATCH 1/5] etnaviv: update headers from rnndb

2017-10-17 Thread Christian Gmeiner
Update to etna_viv commit 6c9c706.

Signed-off-by: Christian Gmeiner 
---
 src/gallium/drivers/etnaviv/hw/cmdstream.xml.h |  36 ++-
 src/gallium/drivers/etnaviv/hw/common.xml.h| 117 
 src/gallium/drivers/etnaviv/hw/isa.xml.h   |   4 +-
 src/gallium/drivers/etnaviv/hw/state.xml.h | 197 --
 src/gallium/drivers/etnaviv/hw/state_3d.xml.h  | 357 -
 5 files changed, 622 insertions(+), 89 deletions(-)

diff --git a/src/gallium/drivers/etnaviv/hw/cmdstream.xml.h 
b/src/gallium/drivers/etnaviv/hw/cmdstream.xml.h
index f8d76b0105..e12188ea52 100644
--- a/src/gallium/drivers/etnaviv/hw/cmdstream.xml.h
+++ b/src/gallium/drivers/etnaviv/hw/cmdstream.xml.h
@@ -8,9 +8,9 @@ http://0x04.net/cgit/index.cgi/rules-ng-ng
 git clone git://0x04.net/rules-ng-ng
 
 The rules-ng-ng source files this header was generated from are:
-- cmdstream.xml (  15289 bytes, from 2017-09-29 11:52:39)
-- copyright.xml (   1597 bytes, from 2016-12-08 16:37:56)
-- common.xml(  23529 bytes, from 2017-09-29 11:52:39)
+- cmdstream.xml (  16595 bytes, from 2017-10-05 21:20:32)
+- copyright.xml (   1597 bytes, from 2016-11-13 13:46:17)
+- common.xml(  26135 bytes, from 2017-10-05 21:20:32)
 
 Copyright (C) 2012-2017 by the following authors:
 - Wladimir J. van der Laan 
@@ -52,6 +52,8 @@ DEALINGS IN THE SOFTWARE.
 #define FE_OPCODE_RETURN   0x000b
 #define FE_OPCODE_DRAW_INSTANCED   0x000c
 #define FE_OPCODE_CHIP_SELECT  0x000d
+#define FE_OPCODE_WAIT_FENCE   0x000f
+#define FE_OPCODE_SNAP_PAGES   0x0013
 #define PRIMITIVE_TYPE_POINTS  0x0001
 #define PRIMITIVE_TYPE_LINES   0x0002
 #define PRIMITIVE_TYPE_LINE_STRIP  0x0003
@@ -192,6 +194,9 @@ DEALINGS IN THE SOFTWARE.
 #define VIV_FE_STALL_TOKEN_TO__MASK0x1f00
 #define VIV_FE_STALL_TOKEN_TO__SHIFT   8
 #define VIV_FE_STALL_TOKEN_TO(x)   (((x) << 
VIV_FE_STALL_TOKEN_TO__SHIFT) & VIV_FE_STALL_TOKEN_TO__MASK)
+#define VIV_FE_STALL_TOKEN_UNK28__MASK 0x3000
+#define VIV_FE_STALL_TOKEN_UNK28__SHIFT28
+#define VIV_FE_STALL_TOKEN_UNK28(x)(((x) << 
VIV_FE_STALL_TOKEN_UNK28__SHIFT) & VIV_FE_STALL_TOKEN_UNK28__MASK)
 
 #define VIV_FE_CALL0x
 
@@ -266,5 +271,30 @@ DEALINGS IN THE SOFTWARE.
 #define VIV_FE_DRAW_INSTANCED_START_INDEX__SHIFT   0
 #define VIV_FE_DRAW_INSTANCED_START_INDEX(x)   (((x) << 
VIV_FE_DRAW_INSTANCED_START_INDEX__SHIFT) & 
VIV_FE_DRAW_INSTANCED_START_INDEX__MASK)
 
+#define VIV_FE_WAIT_FENCE  0x
+
+#define VIV_FE_WAIT_FENCE_HEADER   0x
+#define VIV_FE_WAIT_FENCE_HEADER_OP__MASK  0xf800
+#define VIV_FE_WAIT_FENCE_HEADER_OP__SHIFT 27
+#define VIV_FE_WAIT_FENCE_HEADER_OP_WAIT_FENCE 0x7800
+#define VIV_FE_WAIT_FENCE_HEADER_UNK16__MASK   0x0003
+#define VIV_FE_WAIT_FENCE_HEADER_UNK16__SHIFT  16
+#define VIV_FE_WAIT_FENCE_HEADER_UNK16(x)  (((x) << 
VIV_FE_WAIT_FENCE_HEADER_UNK16__SHIFT) & VIV_FE_WAIT_FENCE_HEADER_UNK16__MASK)
+#define VIV_FE_WAIT_FENCE_HEADER_WAITCOUNT__MASK   0x
+#define VIV_FE_WAIT_FENCE_HEADER_WAITCOUNT__SHIFT  0
+#define VIV_FE_WAIT_FENCE_HEADER_WAITCOUNT(x)  (((x) << 
VIV_FE_WAIT_FENCE_HEADER_WAITCOUNT__SHIFT) & 
VIV_FE_WAIT_FENCE_HEADER_WAITCOUNT__MASK)
+
+#define VIV_FE_WAIT_FENCE_ADDRESS  0x0004
+
+#define VIV_FE_SNAP_PAGES  0x
+
+#define VIV_FE_SNAP_PAGES_HEADER   0x
+#define VIV_FE_SNAP_PAGES_HEADER_OP__MASK  0xf800
+#define VIV_FE_SNAP_PAGES_HEADER_OP__SHIFT 27
+#define VIV_FE_SNAP_PAGES_HEADER_OP_SNAP_PAGES 0x9800
+#define VIV_FE_SNAP_PAGES_HEADER_UNK0__MASK0x001f
+#define VIV_FE_SNAP_PAGES_HEADER_UNK0__SHIFT   0
+#define VIV_FE_SNAP_PAGES_HEADER_UNK0(x)   (((x) << 
VIV_FE_SNAP_PAGES_HEADER_UNK0__SHIFT) & VIV_FE_SNAP_PAGES_HEADER_UNK0__MASK)
+
 
 #endif /* CMDSTREAM_XML */
diff --git a/src/gallium/drivers/etnaviv/hw/common.xml.h 
b/src/gallium/drivers/etnaviv/hw/common.xml.h
index 85c4990b61..57369d741d 100644
--- a/src/gallium/drivers/etnaviv/hw/common.xml.h
+++ b/src/gallium/drivers/etnaviv/hw/common.xml.h
@@ -8,13 +8,13 @@ 

Re: [Mesa-dev] [PATCH] radv: remove XtoY_temps structs

2017-10-17 Thread Bas Nieuwenhuizen
r-b

On Tue, Oct 17, 2017 at 11:04 AM, Samuel Pitoiset
 wrote:
> Signed-off-by: Samuel Pitoiset 
> ---
>  src/amd/vulkan/radv_meta_bufimage.c | 62 
> -
>  1 file changed, 26 insertions(+), 36 deletions(-)
>
> diff --git a/src/amd/vulkan/radv_meta_bufimage.c 
> b/src/amd/vulkan/radv_meta_bufimage.c
> index f5bbf3cb90..dfd99aa75f 100644
> --- a/src/amd/vulkan/radv_meta_bufimage.c
> +++ b/src/amd/vulkan/radv_meta_bufimage.c
> @@ -823,14 +823,10 @@ create_bview(struct radv_cmd_buffer *cmd_buffer,
>
>  }
>
> -struct itob_temps {
> -   struct radv_image_view src_iview;
> -   struct radv_buffer_view dst_bview;
> -};
> -
>  static void
>  itob_bind_descriptors(struct radv_cmd_buffer *cmd_buffer,
> - struct itob_temps *tmp)
> + struct radv_image_view *src,
> + struct radv_buffer_view *dst)
>  {
> struct radv_device *device = cmd_buffer->device;
>
> @@ -849,7 +845,7 @@ itob_bind_descriptors(struct radv_cmd_buffer *cmd_buffer,
>   .pImageInfo = 
> (VkDescriptorImageInfo[]) {
>   {
>   
> .sampler = VK_NULL_HANDLE,
> - 
> .imageView = radv_image_view_to_handle(>src_iview),
> + 
> .imageView = radv_image_view_to_handle(src),
>   
> .imageLayout = VK_IMAGE_LAYOUT_GENERAL,
>   },
>   }
> @@ -860,7 +856,7 @@ itob_bind_descriptors(struct radv_cmd_buffer *cmd_buffer,
>   .dstArrayElement = 0,
>   .descriptorCount = 1,
>   .descriptorType = 
> VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER,
> - .pTexelBufferView = 
> (VkBufferView[])  { radv_buffer_view_to_handle(>dst_bview) },
> + .pTexelBufferView = 
> (VkBufferView[])  { radv_buffer_view_to_handle(dst) },
>   }
>   });
>  }
> @@ -874,11 +870,12 @@ radv_meta_image_to_buffer(struct radv_cmd_buffer 
> *cmd_buffer,
>  {
> VkPipeline pipeline = cmd_buffer->device->meta_state.itob.pipeline;
> struct radv_device *device = cmd_buffer->device;
> -   struct itob_temps temps;
> +   struct radv_image_view src_view;
> +   struct radv_buffer_view dst_view;
>
> -   create_iview(cmd_buffer, src, _iview);
> -   create_bview(cmd_buffer, dst->buffer, dst->offset, dst->format, 
> _bview);
> -   itob_bind_descriptors(cmd_buffer, );
> +   create_iview(cmd_buffer, src, _view);
> +   create_bview(cmd_buffer, dst->buffer, dst->offset, dst->format, 
> _view);
> +   itob_bind_descriptors(cmd_buffer, _view, _view);
>
>
> radv_CmdBindPipeline(radv_cmd_buffer_to_handle(cmd_buffer),
> @@ -899,14 +896,10 @@ radv_meta_image_to_buffer(struct radv_cmd_buffer 
> *cmd_buffer,
> }
>  }
>
> -struct btoi_temps {
> -   struct radv_buffer_view src_bview;
> -   struct radv_image_view dst_iview;
> -};
> -
>  static void
>  btoi_bind_descriptors(struct radv_cmd_buffer *cmd_buffer,
> - struct btoi_temps *tmp)
> + struct radv_buffer_view *src,
> + struct radv_image_view *dst)
>  {
> struct radv_device *device = cmd_buffer->device;
>
> @@ -922,7 +915,7 @@ btoi_bind_descriptors(struct radv_cmd_buffer *cmd_buffer,
>   .dstArrayElement = 0,
>   .descriptorCount = 1,
>   .descriptorType = 
> VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER,
> - .pTexelBufferView = 
> (VkBufferView[])  { radv_buffer_view_to_handle(>src_bview) },
> + .pTexelBufferView = 
> (VkBufferView[])  { radv_buffer_view_to_handle(src) },
>   },
>   {
>   .sType = 
> VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET,
> @@ -933,7 +926,7 @@ btoi_bind_descriptors(struct radv_cmd_buffer *cmd_buffer,
>   .pImageInfo = 
> (VkDescriptorImageInfo[]) {
>   {
>   

Re: [Mesa-dev] [PATCH] radv: use the dispatch initiator for indirect dispatches

2017-10-17 Thread Bas Nieuwenhuizen
r-b

On Tue, Oct 17, 2017 at 12:02 PM, Samuel Pitoiset
 wrote:
> Missed that when I allowed waves to be launched out-of-order.
>
> Signed-off-by: Samuel Pitoiset 
> ---
>  src/amd/vulkan/radv_cmd_buffer.c | 24 +---
>  1 file changed, 13 insertions(+), 11 deletions(-)
>
> diff --git a/src/amd/vulkan/radv_cmd_buffer.c 
> b/src/amd/vulkan/radv_cmd_buffer.c
> index 9ebdbb011a..5358ae71bd 100644
> --- a/src/amd/vulkan/radv_cmd_buffer.c
> +++ b/src/amd/vulkan/radv_cmd_buffer.c
> @@ -3322,6 +3322,7 @@ radv_emit_dispatch_packets(struct radv_cmd_buffer 
> *cmd_buffer,
> struct radeon_winsys *ws = cmd_buffer->device->ws;
> struct radeon_winsys_cs *cs = cmd_buffer->cs;
> struct ac_userdata_info *loc;
> +   unsigned dispatch_initiator;
> uint8_t grid_used;
>
> grid_used = compute_shader->info.info.cs.grid_components_used;
> @@ -3331,6 +3332,16 @@ radv_emit_dispatch_packets(struct radv_cmd_buffer 
> *cmd_buffer,
>
> MAYBE_UNUSED unsigned cdw_max = radeon_check_space(ws, cs, 25);
>
> +   dispatch_initiator = S_00B800_COMPUTE_SHADER_EN(1) |
> +S_00B800_FORCE_START_AT_000(1);
> +
> +   if (cmd_buffer->device->physical_device->rad_info.chip_class >= CIK) {
> +   /* If the KMD allows it (there is a KMD hw register for it),
> +* allow launching waves out-of-order.
> +*/
> +   dispatch_initiator |= S_00B800_ORDER_MODE(1);
> +   }
> +
> if (info->indirect) {
> uint64_t va = radv_buffer_get_va(info->indirect->bo);
>
> @@ -3356,7 +3367,7 @@ radv_emit_dispatch_packets(struct radv_cmd_buffer 
> *cmd_buffer,
> PKT3_SHADER_TYPE_S(1));
> radeon_emit(cs, va);
> radeon_emit(cs, va >> 32);
> -   radeon_emit(cs, 1);
> +   radeon_emit(cs, dispatch_initiator);
> } else {
> radeon_emit(cs, PKT3(PKT3_SET_BASE, 2, 0) |
> PKT3_SHADER_TYPE_S(1));
> @@ -3367,19 +3378,10 @@ radv_emit_dispatch_packets(struct radv_cmd_buffer 
> *cmd_buffer,
> radeon_emit(cs, PKT3(PKT3_DISPATCH_INDIRECT, 1, 0) |
> PKT3_SHADER_TYPE_S(1));
> radeon_emit(cs, 0);
> -   radeon_emit(cs, 1);
> +   radeon_emit(cs, dispatch_initiator);
> }
> } else {
> unsigned blocks[3] = { info->blocks[0], info->blocks[1], 
> info->blocks[2] };
> -   unsigned dispatch_initiator = S_00B800_COMPUTE_SHADER_EN(1) |
> - S_00B800_FORCE_START_AT_000(1);
> -
> -   if (cmd_buffer->device->physical_device->rad_info.chip_class 
> >= CIK) {
> -   /* If the KMD allows it (there is a KMD hw register 
> for
> -* it), allow launching waves out-of-order.
> -*/
> -   dispatch_initiator |= S_00B800_ORDER_MODE(1);
> -   }
>
> if (info->unaligned) {
> unsigned *cs_block_size = 
> compute_shader->info.cs.block_size;
> --
> 2.14.2
>
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] docs: add documentation for building with meson

2017-10-17 Thread Dylan Baker
Quoting Nicolai Hähnle (2017-10-17 13:05:12)
> On 17.10.2017 21:21, Dylan Baker wrote:
> > +CC, CFLAGS, CXX, CXXFLAGS
> > +These environment variables
> > +control the C and C++ compilers used during the build. The default 
> > compilers
> > +depends on your operating system. Meson supports GCC, Clang, and MSVC as 
> > first
> > +class compilers. There is some support for the Intel ICC compiler. No other
> > +C/C++ compilers are currently supported.
> > +
> > +
> > +PKG_CONFIG_PATH
> > +The
> > +pkg-config utility is a hard requirement for configuring and
> > +building mesa. It is used to search for external libraries
> > +on the system. This environment variable is used to control the search
> > +path for pkg-config. For instance, setting
> > +PKG_CONFIG_PATH=/usr/X11R6/lib/pkgconfig will search for
> > +package metadata in /usr/X11R6 before the standard
> > +directories.
> > +
> > +
> 
> Not knowing Meson, how do environment variables like CFLAGS, CC, etc. 
> work? Are they "latched" when calling `meson $builddir`? When calling 
> `meson configure`? Both? Does setting them have an effect when calling 
> `ninja`?

I'll update this document as well, but for your edification: they are "latched"
by meson and stored in it's configuration information, they can be overwritten
when meson is initialized or re-initialized. That means that passing them to
"meson configure" won't change anything, since meson configure just touches
stored variables, but doesn't re-initialize. Passing them to ninja will only do
something if ninja decides that it needs to re-initialize, say if you touch a
meson.build file.

examples:
CC=clang CXX=clang++ meson build-clang
CC=notacompiler CXX=notacompiler ninja -C build
will result in building with clang/clang++

touch meson.build
CC=notacompiler CXX=notacompiler ninja -C build
nothing works, since ninja will re-initialize meson and it will read the
environment and set the compiler to notacompiler and fail.

I'll also add this to the documentation, but meson remembers options, and meson
configure only changes options that you supply so:
meson build --prefix=/tmp
meson configure build -Ddri-drivers=i965
will not reset the prefix.

Dylan


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


Re: [Mesa-dev] [PATCH 3/4] meson: build r200 driver

2017-10-17 Thread Eric Anholt
Dylan Baker  writes:

> Build tested only
>
> Signed-off-by: Dylan Baker 
> ---
>  meson.build   |  4 +-
>  meson_options.txt |  2 +-
>  src/mesa/drivers/dri/meson.build  |  3 ++
>  src/mesa/drivers/dri/r200/meson.build | 91 
> +++
>  4 files changed, 98 insertions(+), 2 deletions(-)
>  create mode 100644 src/mesa/drivers/dri/r200/meson.build
>
> diff --git a/meson.build b/meson.build
> index e7f16767297..8761fce3dff 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -81,6 +81,7 @@ with_dri = false
>  with_dri_i915 = false
>  with_dri_i965 = false
>  with_dri_r100 = false
> +with_dri_r200 = false
>  with_dri_swrast = false
>  _drivers = get_option('dri-drivers')
>  if _drivers != ''
> @@ -88,6 +89,7 @@ if _drivers != ''
>with_dri_i915 = _split.contains('i915')
>with_dri_i965 = _split.contains('i965')
>with_dri_r100 = _split.contains('r100')
> +  with_dri_r200 = _split.contains('r200')
>with_dri_swrast = _split.contains('swrast')
>with_dri = true
>  endif
> @@ -563,7 +565,7 @@ dep_libdrm_nouveau = []
>  if with_amd_vk or with_gallium_radeonsi
>dep_libdrm_amdgpu = dependency('libdrm_amdgpu', version : '>= 2.4.84')
>  endif
> -if with_gallium_radeonsi or with_dri_r100 # older radeon too
> +if with_gallium_radeonsi or with_dri_r100 or with_dri_r200 # older radeon too
>dep_libdrm_radeon = dependency('libdrm_radeon', version : '>= 2.4.71')
>  endif

Now that there is older radeon being handled, I think the comment can be
removed.

Other than that, the series is:

Reviewed-by: Eric Anholt 


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


Re: [Mesa-dev] [PATCH] docs: add documentation for building with meson

2017-10-17 Thread Nicolai Hähnle

On 17.10.2017 21:21, Dylan Baker wrote:

+CC, CFLAGS, CXX, CXXFLAGS
+These environment variables
+control the C and C++ compilers used during the build. The default compilers
+depends on your operating system. Meson supports GCC, Clang, and MSVC as first
+class compilers. There is some support for the Intel ICC compiler. No other
+C/C++ compilers are currently supported.
+
+
+PKG_CONFIG_PATH
+The
+pkg-config utility is a hard requirement for configuring and
+building mesa. It is used to search for external libraries
+on the system. This environment variable is used to control the search
+path for pkg-config. For instance, setting
+PKG_CONFIG_PATH=/usr/X11R6/lib/pkgconfig will search for
+package metadata in /usr/X11R6 before the standard
+directories.
+
+


Not knowing Meson, how do environment variables like CFLAGS, CC, etc. 
work? Are they "latched" when calling `meson $builddir`? When calling 
`meson configure`? Both? Does setting them have an effect when calling 
`ninja`?


Some examples would be helpful.

Thanks,
Nicolai


+
+
+One of the oddities of meson is that some options are different when passed to
+the initial meson step than to meson configure. These options are passed as
+--option=foo to meson, but -Doption=foo to meson configure. Project defined
+options are always passed as -Doption=foo.
+
+
+For those coming from autotools be aware of the following:
+
+
+--buildtype/-Dbuildtype
+This option will set the compiler debug/optimisation levels (if the user
+hasn't already set them via the CFLAGS/CXXFLAGS) and macros to aid in
+debugging the Mesa libraries.
+
+Note that in meson this defaults to "debug", and  not setting it to
+"release" will yield non-optimal performance and binary size



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




--
Lerne, wie die Welt wirklich ist,
Aber vergiss niemals, wie sie sein sollte.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 7/7] glsl: Remove ir_binop_greater and ir_binop_lequal expressions

2017-10-17 Thread Nicolai Hähnle

Good riddance!

Reviewed-by: Nicolai Hähnle 

On 17.10.2017 20:14, Ian Romanick wrote:

From: Ian Romanick 

NIR does not have these instructions.  TGSI and Mesa IR both implement
them using < and >=, repsectively.  Removing them deletes a bunch of
code and means I don't have to add code to the SPIR-V generator for
them.

v2: Rebase on 2+ years of change... and fix a major bug added in the
rebase.

text   data bss dec hex filename
8255291  268856  294072 8818219  868e2b 32-bit i965_dri.so before
8254235  268856  294072 8817163  868a0b 32-bit i965_dri.so after
7815339  345592  420592 8581523  82f193 64-bit i965_dri.so before
7813995  345560  420592 8580147  82ec33 64-bit i965_dri.so after

Signed-off-by: Ian Romanick 
---
  src/compiler/glsl/ast_to_hir.cpp   | 13 --
  src/compiler/glsl/builtin_functions.cpp| 23 -
  src/compiler/glsl/glsl_to_nir.cpp  | 24 -
  src/compiler/glsl/ir.cpp   |  2 --
  src/compiler/glsl/ir_builder.cpp   |  4 +--
  src/compiler/glsl/ir_builder_print_visitor.cpp |  2 --
  src/compiler/glsl/ir_expression_operation.py   |  2 --
  src/compiler/glsl/ir_validate.cpp  |  2 --
  src/compiler/glsl/loop_analysis.cpp| 23 +++--
  src/compiler/glsl/opt_algebraic.cpp|  4 ---
  .../glsl/tests/lower_jumps/create_test_cases.py|  2 +-
  src/intel/compiler/brw_shader.cpp  |  4 ---
  src/mesa/program/ir_to_mesa.cpp| 30 --
  src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 20 ---
  14 files changed, 39 insertions(+), 116 deletions(-)

diff --git a/src/compiler/glsl/ast_to_hir.cpp b/src/compiler/glsl/ast_to_hir.cpp
index 6090ee9..441404f 100644
--- a/src/compiler/glsl/ast_to_hir.cpp
+++ b/src/compiler/glsl/ast_to_hir.cpp
@@ -1337,8 +1337,8 @@ ast_expression::do_hir(exec_list *instructions,
ir_binop_lshift,
ir_binop_rshift,
ir_binop_less,
-  ir_binop_greater,
-  ir_binop_lequal,
+  ir_binop_less,/* This is correct.  See the ast_greater case below. */
+  ir_binop_gequal,  /* This is correct.  See the ast_lequal case below. */
ir_binop_gequal,
ir_binop_all_equal,
ir_binop_any_nequal,
@@ -1487,6 +1487,15 @@ ast_expression::do_hir(exec_list *instructions,
assert(type->is_error()
   || (type->is_boolean() && type->is_scalar()));
  
+  /* Like NIR, GLSL IR does not have opcodes for > or <=.  Instead, swap

+   * the arguments and use < or >=.
+   */
+  if (this->oper == ast_greater || this->oper == ast_lequal) {
+ ir_rvalue *const tmp = op[0];
+ op[0] = op[1];
+ op[1] = tmp;
+  }
+
result = new(ctx) ir_expression(operations[this->oper], type,
op[0], op[1]);
error_emitted = type->is_error();
diff --git a/src/compiler/glsl/builtin_functions.cpp 
b/src/compiler/glsl/builtin_functions.cpp
index 9df9671..530cdc0 100644
--- a/src/compiler/glsl/builtin_functions.cpp
+++ b/src/compiler/glsl/builtin_functions.cpp
@@ -744,7 +744,8 @@ private:
  ir_expression_operation opcode,
  const glsl_type *return_type,
  const glsl_type *param0_type,
-const glsl_type *param1_type);
+const glsl_type *param1_type,
+bool swap_operands = false);
  
  #define B0(X) ir_function_signature *_##X();

  #define B1(X) ir_function_signature *_##X(const glsl_type *);
@@ -3634,12 +3635,18 @@ builtin_builder::binop(builtin_available_predicate 
avail,
 ir_expression_operation opcode,
 const glsl_type *return_type,
 const glsl_type *param0_type,
-   const glsl_type *param1_type)
+   const glsl_type *param1_type,
+   bool swap_operands)
  {
 ir_variable *x = in_var(param0_type, "x");
 ir_variable *y = in_var(param1_type, "y");
 MAKE_SIG(return_type, avail, 2, x, y);
-   body.emit(ret(expr(opcode, x, y)));
+
+   if (swap_operands)
+  body.emit(ret(expr(opcode, y, x)));
+   else
+  body.emit(ret(expr(opcode, x, y)));
+
 return sig;
  }
  
@@ -4972,16 +4979,18 @@ ir_function_signature *

  builtin_builder::_lessThanEqual(builtin_available_predicate avail,
  const glsl_type *type)
  {
-   return binop(avail, ir_binop_lequal,
-glsl_type::bvec(type->vector_elements), type, type);
+   return binop(avail, ir_binop_gequal,
+glsl_type::bvec(type->vector_elements), type, type,
+true);
  }
  
  

[Mesa-dev] [PATCH] llvmpipe: handle shader sample mask output

2017-10-17 Thread sroland
From: Roland Scheidegger 

This probably isn't all that useful for GL, but there are apis where
sample_mask is a valid output even without msaa.
Just discard the pixel if the sample_mask doesn't include the bit for
sample 0.
---
 src/gallium/drivers/llvmpipe/lp_state_fs.c | 26 --
 1 file changed, 24 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/llvmpipe/lp_state_fs.c 
b/src/gallium/drivers/llvmpipe/lp_state_fs.c
index 05984b3..9223ce6 100644
--- a/src/gallium/drivers/llvmpipe/lp_state_fs.c
+++ b/src/gallium/drivers/llvmpipe/lp_state_fs.c
@@ -84,6 +84,7 @@
 #include "gallivm/lp_bld_flow.h"
 #include "gallivm/lp_bld_debug.h"
 #include "gallivm/lp_bld_arit.h"
+#include "gallivm/lp_bld_bitarit.h"
 #include "gallivm/lp_bld_pack.h"
 #include "gallivm/lp_bld_format.h"
 #include "gallivm/lp_bld_quad.h"
@@ -347,7 +348,8 @@ generate_fs_loop(struct gallivm_state *gallivm,
   if (!shader->info.base.writes_z && !shader->info.base.writes_stencil) {
  if (key->alpha.enabled ||
  key->blend.alpha_to_coverage ||
- shader->info.base.uses_kill) {
+ shader->info.base.uses_kill ||
+ shader->info.base.writes_samplemask) {
 /* With alpha test and kill, can do the depth test early
  * and hopefully eliminate some quads.  But need to do a
  * special deferred depth write once the final mask value
@@ -516,6 +518,25 @@ generate_fs_loop(struct gallivm_state *gallivm,
   }
}
 
+   if (shader->info.base.writes_samplemask) {
+  int smaski = find_output_by_semantic(>info.base,
+   TGSI_SEMANTIC_SAMPLEMASK,
+   0);
+  LLVMValueRef smask;
+  struct lp_build_context smask_bld;
+  lp_build_context_init(_bld, gallivm, int_type);
+
+  assert(smaski >= 0);
+  smask = LLVMBuildLoad(builder, outputs[smaski][0], "smask");
+  /*
+   * Pixel is alive according to the first sample in the mask.
+   */
+  smask = LLVMBuildBitCast(builder, smask, smask_bld.vec_type, "");
+  smask = lp_build_and(_bld, smask, smask_bld.one);
+  smask = lp_build_cmp(_bld, PIPE_FUNC_NOTEQUAL, smask, 
smask_bld.zero);
+  lp_build_mask_update(, smask);
+   }
+
/* Late Z test */
if (depth_mode & LATE_DEPTH_TEST) {
   int pos0 = find_output_by_semantic(>info.base,
@@ -2818,7 +2839,8 @@ generate_variant(struct llvmpipe_context *lp,
  !key->alpha.enabled &&
  !key->blend.alpha_to_coverage &&
  !key->depth.enabled &&
- !shader->info.base.uses_kill
+ !shader->info.base.uses_kill &&
+ !shader->info.base.writes_samplemask
   ? TRUE : FALSE;
 
if ((shader->info.base.num_tokens <= 1) &&
-- 
2.7.4

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


Re: [Mesa-dev] [PATCH 5/7] glsl/parser: Return the glsl_type object from the lexer

2017-10-17 Thread Nicolai Hähnle

Patches 1-5:

Reviewed-by: Nicolai Hähnle 

On 17.10.2017 20:14, Ian Romanick wrote:

From: Ian Romanick 

This allows us to use a single token for every built-in type except void.

text   data bss dec hex filename
8275163  269336  294072 8838571  86ddab 32-bit i965_dri.so before
8255243  268856  294072 8818171  868dfb 32-bit i965_dri.so after
7836963  346552  420592 8604107  8349cb 64-bit i965_dri.so before
7815195  345592  420592 8581379  82f103 64-bit i965_dri.so after

Yes, the 64-bit binary shrinks by 21k.

Signed-off-by: Ian Romanick 
---
  src/compiler/glsl/glsl_lexer.ll  | 304 ++-
  src/compiler/glsl/glsl_parser.yy | 160 ++---
  2 files changed, 182 insertions(+), 282 deletions(-)

diff --git a/src/compiler/glsl/glsl_lexer.ll b/src/compiler/glsl/glsl_lexer.ll
index bdd8df1..5dad6ee 100644
--- a/src/compiler/glsl/glsl_lexer.ll
+++ b/src/compiler/glsl/glsl_lexer.ll
@@ -87,6 +87,34 @@ static int classify_identifier(struct _mesa_glsl_parse_state 
*, const char *,
 } while (0)
  
  /**

+ * Like KEYWORD_WITH_ALT, but used for built-in GLSL types
+ */
+#define TYPE_WITH_ALT(reserved_glsl, reserved_glsl_es, \
+ allowed_glsl, allowed_glsl_es,\
+ alt_expr, gtype)  \
+   do {
\
+  if (yyextra->is_version(allowed_glsl, allowed_glsl_es)\
+  || (alt_expr)) { \
+yylval->type = gtype;   \
+return BASIC_TYPE_TOK; \
+  } else if (yyextra->is_version(reserved_glsl, \
+ reserved_glsl_es)) {  \
+_mesa_glsl_error(yylloc, yyextra,  \
+ "illegal use of reserved word `%s'", yytext);   \
+return ERROR_TOK;  \
+  } else { \
+return classify_identifier(yyextra, yytext, yyleng, yylval);   \
+  }
\
+   } while (0)
+
+#define TYPE(reserved_glsl, reserved_glsl_es,  \
+ allowed_glsl, allowed_glsl_es,\
+ gtype)\
+   TYPE_WITH_ALT(reserved_glsl, reserved_glsl_es,  \
+ allowed_glsl, allowed_glsl_es,
\
+ false, gtype)
+
+/**
   * A macro for handling keywords that have been present in GLSL since
   * its origin, but were changed into reserved words in GLSL 3.00 ES.
   */
@@ -101,6 +129,21 @@ static int classify_identifier(struct 
_mesa_glsl_parse_state *, const char *,
}   
\
 } while (0)
  
+/**

+ * Like DEPRECATED_ES_KEYWORD, but for types
+ */
+#define DEPRECATED_ES_TYPE(gtype)  \
+   do {
\
+  if (yyextra->is_version(0, 300)) {\
+_mesa_glsl_error(yylloc, yyextra,  \
+ "illegal use of reserved word `%s'", yytext);   \
+return ERROR_TOK;  \
+  } else { \
+yylval->type = gtype;   \
+ return BASIC_TYPE_TOK;
\
+  }
\
+   } while (0)
+
  static int
  literal_integer(char *text, int len, struct _mesa_glsl_parse_state *state,
YYSTYPE *lval, YYLTYPE *lloc, int base)
@@ -285,10 +328,10 @@ HASH  ^{SPC}#{SPC}
  
  attribute	DEPRECATED_ES_KEYWORD(ATTRIBUTE);

  const return CONST_TOK;
-bool   return BOOL_TOK;
-float  return FLOAT_TOK;
-intreturn INT_TOK;
-uint   KEYWORD(130, 300, 130, 300, UINT_TOK);
+bool   { yylval->type = glsl_type::bool_type; return BASIC_TYPE_TOK; }
+float  { yylval->type = glsl_type::float_type; return BASIC_TYPE_TOK; }
+int{ yylval->type = glsl_type::int_type; return BASIC_TYPE_TOK; }
+uint   TYPE(130, 300, 130, 300, glsl_type::uint_type);
  
  break		return BREAK;

  continue  return CONTINUE;
@@ -300,30 +343,30 @@ ifreturn IF;
  discard   return DISCARD;
  return

Re: [Mesa-dev] [PATCH 6/7] glsl/parser: Track built-in types using the glsl_type directly

2017-10-17 Thread Nicolai Hähnle

On 17.10.2017 21:54, Nicolai Hähnle wrote:

On 17.10.2017 20:14, Ian Romanick wrote:

From: Ian Romanick 

    text   data    bss    dec    hex    filename
8255243 268856 294072    8818171 868dfb    32-bit 
i965_dri.so before
8255291 268856 294072    8818219 868e2b    32-bit 
i965_dri.so after
7815195 345592 420592    8581379 82f103    64-bit 
i965_dri.so before
7815339 345592 420592    8581523 82f193    64-bit 
i965_dri.so after


How does this change lead to such a big reduction, and shouldn't the 
lexer changes be in a separate patch?


Eh, never mind the first question, I was being stupid. The second one 
still stands, though :)




Cheers,
Nicolai



Signed-off-by: Ian Romanick 
---
  src/compiler/glsl/ast.h  | 13 +++--
  src/compiler/glsl/ast_to_hir.cpp |  4 +++-
  src/compiler/glsl/glsl_lexer.ll  | 21 +
  src/compiler/glsl/glsl_parser.yy |  2 +-
  4 files changed, 28 insertions(+), 12 deletions(-)

diff --git a/src/compiler/glsl/ast.h b/src/compiler/glsl/ast.h
index 1be86ac..eee2248 100644
--- a/src/compiler/glsl/ast.h
+++ b/src/compiler/glsl/ast.h
@@ -27,6 +27,7 @@
  #include "list.h"
  #include "glsl_parser_extras.h"
+#include "compiler/glsl_types.h"
  struct _mesa_glsl_parse_state;
@@ -853,7 +854,7 @@ class ast_type_specifier : public ast_node {
  public:
 /** Construct a type specifier from a type name */
 ast_type_specifier(const char *name)
-  : type_name(name), structure(NULL), array_specifier(NULL),
+  : type(NULL), type_name(name), structure(NULL), 
array_specifier(NULL),

  default_precision(ast_precision_none)
 {
    /* empty */
@@ -861,12 +862,19 @@ public:
 /** Construct a type specifier from a structure definition */
 ast_type_specifier(ast_struct_specifier *s)
-  : type_name(s->name), structure(s), array_specifier(NULL),
+  : type(NULL), type_name(s->name), structure(s), 
array_specifier(NULL),

  default_precision(ast_precision_none)
 {
    /* empty */
 }
+   ast_type_specifier(const glsl_type *t)
+  : type(t), type_name(t->name), structure(NULL), 
array_specifier(NULL),

+    default_precision(ast_precision_none)
+   {
+  /* empty */
+   }
+
 const struct glsl_type *glsl_type(const char **name,
   struct _mesa_glsl_parse_state *state)
    const;
@@ -875,6 +883,7 @@ public:
 ir_rvalue *hir(exec_list *, struct _mesa_glsl_parse_state *);
+   const struct glsl_type *type;
 const char *type_name;
 ast_struct_specifier *structure;
diff --git a/src/compiler/glsl/ast_to_hir.cpp 
b/src/compiler/glsl/ast_to_hir.cpp

index d7c8b47..6090ee9 100644
--- a/src/compiler/glsl/ast_to_hir.cpp
+++ b/src/compiler/glsl/ast_to_hir.cpp
@@ -2361,7 +2361,9 @@ ast_type_specifier::glsl_type(const char **name,
  {
 const struct glsl_type *type;
-   if (structure)
+   if (this->type != NULL)
+  type = this->type;
+   else if (structure)
    type = structure->type;
 else
    type = state->symbols->get_type(this->type_name);
diff --git a/src/compiler/glsl/glsl_lexer.ll 
b/src/compiler/glsl/glsl_lexer.ll

index 5dad6ee..d2278ba 100644
--- a/src/compiler/glsl/glsl_lexer.ll
+++ b/src/compiler/glsl/glsl_lexer.ll
@@ -132,18 +132,23 @@ static int classify_identifier(struct 
_mesa_glsl_parse_state *, const char *,

  /**
   * Like DEPRECATED_ES_KEYWORD, but for types
   */
-#define DEPRECATED_ES_TYPE(gtype)    \
+#define DEPRECATED_ES_TYPE_WITH_ALT(alt_expr, gtype)    \
 do {    \
    if (yyextra->is_version(0, 300)) {    \
- _mesa_glsl_error(yylloc, yyextra,    \
-  "illegal use of reserved word `%s'", yytext);    \
- return ERROR_TOK;    \
-  } else {    \
- yylval->type = gtype;    \
+ _mesa_glsl_error(yylloc, yyextra,    \
+  "illegal use of reserved word `%s'", 
yytext);    \

+ return ERROR_TOK;    \
+  } else if (alt_expr) {    \
+ yylval->type = gtype;    \
   return BASIC_TYPE_TOK;    \
+  } else {    \
+ return classify_identifier(yyextra, yytext, yyleng, 
yylval);    \

    }    \
 } while (0)
+#define DEPRECATED_ES_TYPE(gtype)    \
+   DEPRECATED_ES_TYPE_WITH_ALT(true, gtype)
+
  static int
  literal_integer(char *text, int len, struct _mesa_glsl_parse_state 
*state,

  YYSTYPE *lval, YYLTYPE *lloc, int base)
@@ -619,9 +624,9 @@ dmat4x4    TYPE_WITH_ALT(110, 100, 400, 0, 
yyextra->ARB_gpu_shader_fp64_enable, gl

  fvec2    KEYWORD(110, 100, 0, 0, FVEC2);
  fvec3    KEYWORD(110, 100, 0, 

Re: [Mesa-dev] [PATCH 6/7] glsl/parser: Track built-in types using the glsl_type directly

2017-10-17 Thread Nicolai Hähnle

On 17.10.2017 20:14, Ian Romanick wrote:

From: Ian Romanick 

text   data bss dec hex filename
8255243  268856  294072 8818171  868dfb 32-bit i965_dri.so before
8255291  268856  294072 8818219  868e2b 32-bit i965_dri.so after
7815195  345592  420592 8581379  82f103 64-bit i965_dri.so before
7815339  345592  420592 8581523  82f193 64-bit i965_dri.so after


How does this change lead to such a big reduction, and shouldn't the 
lexer changes be in a separate patch?


Cheers,
Nicolai



Signed-off-by: Ian Romanick 
---
  src/compiler/glsl/ast.h  | 13 +++--
  src/compiler/glsl/ast_to_hir.cpp |  4 +++-
  src/compiler/glsl/glsl_lexer.ll  | 21 +
  src/compiler/glsl/glsl_parser.yy |  2 +-
  4 files changed, 28 insertions(+), 12 deletions(-)

diff --git a/src/compiler/glsl/ast.h b/src/compiler/glsl/ast.h
index 1be86ac..eee2248 100644
--- a/src/compiler/glsl/ast.h
+++ b/src/compiler/glsl/ast.h
@@ -27,6 +27,7 @@
  
  #include "list.h"

  #include "glsl_parser_extras.h"
+#include "compiler/glsl_types.h"
  
  struct _mesa_glsl_parse_state;
  
@@ -853,7 +854,7 @@ class ast_type_specifier : public ast_node {

  public:
 /** Construct a type specifier from a type name */
 ast_type_specifier(const char *name)
-  : type_name(name), structure(NULL), array_specifier(NULL),
+  : type(NULL), type_name(name), structure(NULL), array_specifier(NULL),
default_precision(ast_precision_none)
 {
/* empty */
@@ -861,12 +862,19 @@ public:
  
 /** Construct a type specifier from a structure definition */

 ast_type_specifier(ast_struct_specifier *s)
-  : type_name(s->name), structure(s), array_specifier(NULL),
+  : type(NULL), type_name(s->name), structure(s), array_specifier(NULL),
default_precision(ast_precision_none)
 {
/* empty */
 }
  
+   ast_type_specifier(const glsl_type *t)

+  : type(t), type_name(t->name), structure(NULL), array_specifier(NULL),
+default_precision(ast_precision_none)
+   {
+  /* empty */
+   }
+
 const struct glsl_type *glsl_type(const char **name,
 struct _mesa_glsl_parse_state *state)
const;
@@ -875,6 +883,7 @@ public:
  
 ir_rvalue *hir(exec_list *, struct _mesa_glsl_parse_state *);
  
+   const struct glsl_type *type;

 const char *type_name;
 ast_struct_specifier *structure;
  
diff --git a/src/compiler/glsl/ast_to_hir.cpp b/src/compiler/glsl/ast_to_hir.cpp

index d7c8b47..6090ee9 100644
--- a/src/compiler/glsl/ast_to_hir.cpp
+++ b/src/compiler/glsl/ast_to_hir.cpp
@@ -2361,7 +2361,9 @@ ast_type_specifier::glsl_type(const char **name,
  {
 const struct glsl_type *type;
  
-   if (structure)

+   if (this->type != NULL)
+  type = this->type;
+   else if (structure)
type = structure->type;
 else
type = state->symbols->get_type(this->type_name);
diff --git a/src/compiler/glsl/glsl_lexer.ll b/src/compiler/glsl/glsl_lexer.ll
index 5dad6ee..d2278ba 100644
--- a/src/compiler/glsl/glsl_lexer.ll
+++ b/src/compiler/glsl/glsl_lexer.ll
@@ -132,18 +132,23 @@ static int classify_identifier(struct 
_mesa_glsl_parse_state *, const char *,
  /**
   * Like DEPRECATED_ES_KEYWORD, but for types
   */
-#define DEPRECATED_ES_TYPE(gtype)  \
+#define DEPRECATED_ES_TYPE_WITH_ALT(alt_expr, gtype)   \
 do {   
\
if (yyextra->is_version(0, 300)) {   \
-_mesa_glsl_error(yylloc, yyextra,  \
- "illegal use of reserved word `%s'", yytext);   \
-return ERROR_TOK;  \
-  } else { \
-yylval->type = gtype;   \
+ _mesa_glsl_error(yylloc, yyextra, \
+  "illegal use of reserved word `%s'", yytext);  \
+ return ERROR_TOK; \
+  } else if (alt_expr) {   \
+ yylval->type = gtype;  \
   return BASIC_TYPE_TOK;   
\
+  } else { \
+ return classify_identifier(yyextra, yytext, yyleng, yylval);  \
}   
\
 } while (0)
  
+#define DEPRECATED_ES_TYPE(gtype)	\

+   DEPRECATED_ES_TYPE_WITH_ALT(true, gtype)
+
  static int
  literal_integer(char *text, int len, struct _mesa_glsl_parse_state *state,
YYSTYPE *lval, YYLTYPE *lloc, int base)
@@ -619,9 +624,9 @@ dmat4x4   

Re: [Mesa-dev] [PATCH v3 02/43] mesa/st: Handle 16-bit types at st_glsl_storage_type_size()

2017-10-17 Thread Nicolai Hähnle

Patches 1 & 2:

Reviewed-by: Nicolai Hähnle 

On 12.10.2017 20:37, Jose Maria Casanova Crespo wrote:

From: Eduardo Lima Mitev 

This is basically to avoid "not handle in switch" warnings.

v2: Let the new types hit the assertion instead. (Marek Olšák
 and Jason Ekstrand)

Reviewed-by: Marek Olšák 
---
  src/mesa/state_tracker/st_glsl_types.cpp | 3 +++
  1 file changed, 3 insertions(+)

diff --git a/src/mesa/state_tracker/st_glsl_types.cpp 
b/src/mesa/state_tracker/st_glsl_types.cpp
index 50936025d9..e57fbc8f31 100644
--- a/src/mesa/state_tracker/st_glsl_types.cpp
+++ b/src/mesa/state_tracker/st_glsl_types.cpp
@@ -98,6 +98,9 @@ st_glsl_storage_type_size(const struct glsl_type *type, bool 
is_bindless)
 case GLSL_TYPE_VOID:
 case GLSL_TYPE_ERROR:
 case GLSL_TYPE_FUNCTION:
+   case GLSL_TYPE_FLOAT16:
+   case GLSL_TYPE_UINT16:
+   case GLSL_TYPE_INT16:
assert(!"Invalid type in type_size");
break;
 }




--
Lerne, wie die Welt wirklich ist,
Aber vergiss niemals, wie sie sein sollte.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 16/16] radeonsi: if there's just const buffer 0, set it in place of CONST/SSBO pointer

2017-10-17 Thread Nicolai Hähnle

On 17.10.2017 17:43, Marek Olšák wrote:

On Tue, Oct 17, 2017 at 2:25 PM, Nicolai Hähnle  wrote:

On 13.10.2017 14:04, Marek Olšák wrote:


From: Marek Olšák 

SI_SGPR_CONST_AND_SHADER_BUFFERS now contains the pointer to const buffer
0
if there is no other buffer there.

Benefits:
- there is no constbuf descriptor upload and shader load

It's assumed that all constant addresses are within bounds. Non-constant
addresses are clamped against the last declared CONST variable.
This only works if the state tracker ensures the bound constant buffer
matches what the shader needs.

Once we get 32-bit pointers, we can only do this for user constant buffers
where the driver is in charge of the upload so that it can guarantee a
32-bit
address.

The real performance benefit might not be measurable.

These apps get 100% theoretical benefit in all shaders (except where
noted):
- antichamber
- barman arkham origins
- borderlands 2
- borderlands pre-sequel
- brutal legend
- civilization BE
- CS:GO
- deadcore
- dota 2 -- most shaders
- europa universalis
- grid autosport -- most shaders
- left 4 dead 2
- legend of grimrock
- life is strange
- payday 2
- portal
- rocket league
- serious sam 3 bfe
- talos principle
- team fortress 2
- thea
- unigine heaven
- unigine valley -- also sanctuary and tropics
- wasteland 2
- xcom: enemy unknown & enemy within
- tesseract
- unity (engine)

Changed stats only:
  SGPRS: 2059998 -> 2086238 (1.27 %)
  VGPRS: 1626888 -> 1626904 (0.00 %)
  Spilled SGPRs: 7902 -> 7865 (-0.47 %)
  Code Size: 60924520 -> 60982660 (0.10 %) bytes
  Max Waves: 374539 -> 374526 (-0.00 %)
---
   src/gallium/drivers/radeonsi/si_descriptors.c | 23 +++--
   src/gallium/drivers/radeonsi/si_shader.c  | 72
+++
   src/gallium/drivers/radeonsi/si_shader.h  |  2 +-
   src/gallium/drivers/radeonsi/si_state.h   |  3 ++
   4 files changed, 87 insertions(+), 13 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_descriptors.c
b/src/gallium/drivers/radeonsi/si_descriptors.c
index 0c1fca8..da6efa8 100644
--- a/src/gallium/drivers/radeonsi/si_descriptors.c
+++ b/src/gallium/drivers/radeonsi/si_descriptors.c
@@ -119,20 +119,21 @@ static void si_init_descriptor_list(uint32_t
*desc_list,
 static void si_init_descriptors(struct si_descriptors *desc,
 unsigned shader_userdata_index,
 unsigned element_dw_size,
 unsigned num_elements)
   {
 desc->list = CALLOC(num_elements, element_dw_size * 4);
 desc->element_dw_size = element_dw_size;
 desc->num_elements = num_elements;
 desc->shader_userdata_offset = shader_userdata_index * 4;
+   desc->slot_index_to_bind_directly = -1;
   }
 static void si_release_descriptors(struct si_descriptors *desc)
   {
 r600_resource_reference(>buffer, NULL);
 FREE(desc->list);
   }
 static bool si_upload_descriptors(struct si_context *sctx,
   struct si_descriptors *desc)
@@ -141,20 +142,34 @@ static bool si_upload_descriptors(struct si_context
*sctx,
 unsigned first_slot_offset = desc->first_active_slot * slot_size;
 unsigned upload_size = desc->num_active_slots * slot_size;
 /* Skip the upload if no shader is using the descriptors.
dirty_mask
  * will stay dirty and the descriptors will be uploaded when there
is
  * a shader using them.
  */
 if (!upload_size)
 return true;
   + /* If there is just one active descriptor, bind it directly. */
+   if ((int)desc->first_active_slot ==
desc->slot_index_to_bind_directly &&
+   desc->num_active_slots == 1) {
+   uint32_t *descriptor =
>list[desc->slot_index_to_bind_directly *
+  desc->element_dw_size];
+
+   /* The buffer is already in the buffer list. */
+   r600_resource_reference(>buffer, NULL);
+   desc->gpu_list = NULL;
+   desc->gpu_address =
si_desc_extract_buffer_address(descriptor);
+   si_mark_atom_dirty(sctx, >shader_pointers.atom);
+   return true;
+   }
+
 uint32_t *ptr;
 int buffer_offset;
 u_upload_alloc(sctx->b.b.const_uploader, 0, upload_size,
si_optimal_tcc_alignment(sctx, upload_size),
(unsigned*)_offset,
(struct pipe_resource**)>buffer,
(void**));
 if (!desc->buffer) {
 desc->gpu_address = 0;
 return false; /* skip the draw call */
@@ -2524,38 +2539,40 @@ void si_init_all_descriptors(struct si_context
*sctx)
 int i;
 STATIC_ASSERT(GFX9_SGPR_TCS_CONST_AND_SHADER_BUFFERS % 2 == 0);
 STATIC_ASSERT(GFX9_SGPR_GS_CONST_AND_SHADER_BUFFERS % 2 == 0);
 

Re: [Mesa-dev] [PATCH] configure.ac: set -O0 on --enable-debug

2017-10-17 Thread Nicolai Hähnle

On 16.10.2017 20:31, Miklós Máté wrote:

On 16/10/17 13:21, Emil Velikov wrote:

Hi Miklós,

On 15 October 2017 at 18:46, Miklós Máté  wrote:

Autoconf sets CFLAGS="-g -O2" by default.

Signed-off-by: Miklós Máté 
---
  configure.ac | 4 
  1 file changed, 4 insertions(+)

diff --git a/configure.ac b/configure.ac
index 62d33a1941..c833d258ed 100644
--- a/configure.ac
+++ b/configure.ac
@@ -522,6 +522,8 @@ if test "x$enable_debug" = xyes; then
  fi
  if ! echo "$CFLAGS" | grep -q -e '-O'; then
  CFLAGS="$CFLAGS -O0"
+    else
+    CFLAGS=`echo $CFLAGS | sed -e s/-O./-O0/`
  fi
  fi
  if test "x$GXX" = xyes; then
@@ -530,6 +532,8 @@ if test "x$enable_debug" = xyes; then
  fi
  if ! echo "$CXXFLAGS" | grep -q -e '-O'; then
  CXXFLAGS="$CXXFLAGS -O0"
+    else
+    CXXFLAGS=`echo $CXXFLAGS | sed -e s/-O./-O0/`
Being the person who added -O0 in the first place I have to agree with 
others.

I don't think this is a good idea. But let me try to explain it from
another angle:

Regardless of the build system used, a general rule should apply - the
user has the final say.
Namely: if the user has set a optimisation level/flags in C*FLAGS
those must be honoured.

Yes it may be a bit confusing, if the use asks for "debug" build, yet
they explicitly set -O2/etc.

HTH
Emil


I thought the intent was to always set -O0 when called with --enable-debug.


FYI, a typical use-case is a build that is optimized but has assertions 
enabled.


Cheers,
Nicolai




Sorry for the misunderstanding.

MM

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



--
Lerne, wie die Welt wirklich ist,
Aber vergiss niemals, wie sie sein sollte.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] glsl/linker: produce error when invalid explicit locations are used

2017-10-17 Thread Nicolai Hähnle

On 16.10.2017 14:06, Iago Toral Quiroga wrote:

We only need to add a check to validate output locations here. For
inputs with invalid locations we will fail to link when we can't
find a matching output in the same (invalid) location.

Fixes:
KHR-GL45.enhanced_layouts.varying_location_limit


Reviewed-by: Nicolai Hähnle 



---
  src/compiler/glsl/link_varyings.cpp | 12 +++-
  src/compiler/glsl/link_varyings.h   |  3 ++-
  src/compiler/glsl/linker.cpp|  2 +-
  3 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/src/compiler/glsl/link_varyings.cpp 
b/src/compiler/glsl/link_varyings.cpp
index 29842ecacd..bdb70edf47 100644
--- a/src/compiler/glsl/link_varyings.cpp
+++ b/src/compiler/glsl/link_varyings.cpp
@@ -381,7 +381,8 @@ cross_validate_front_and_back_color(struct 
gl_shader_program *prog,
   * Validate that outputs from one stage match inputs of another
   */
  void
-cross_validate_outputs_to_inputs(struct gl_shader_program *prog,
+cross_validate_outputs_to_inputs(struct gl_context *ctx,
+ struct gl_shader_program *prog,
   gl_linked_shader *producer,
   gl_linked_shader *consumer)
  {
@@ -410,6 +411,15 @@ cross_validate_outputs_to_inputs(struct gl_shader_program 
*prog,
   unsigned slot_limit = idx + num_elements;
   unsigned last_comp;
  
+ unsigned slot_max =

+ctx->Const.Program[producer->Stage].MaxOutputComponents / 4;
+ if (slot_limit > slot_max) {
+linker_error(prog,
+ "Invalid location %u in %s shader\n",
+ idx, _mesa_shader_stage_to_string(producer->Stage));
+return;
+ }
+
   if (type->without_array()->is_record()) {
  /* The component qualifier can't be used on structs so just treat
   * all component slots as used.
diff --git a/src/compiler/glsl/link_varyings.h 
b/src/compiler/glsl/link_varyings.h
index 4e1f6d2e42..081b04ea38 100644
--- a/src/compiler/glsl/link_varyings.h
+++ b/src/compiler/glsl/link_varyings.h
@@ -300,7 +300,8 @@ link_varyings(struct gl_shader_program *prog, unsigned 
first, unsigned last,
struct gl_context *ctx, void *mem_ctx);
  
  void

-cross_validate_outputs_to_inputs(struct gl_shader_program *prog,
+cross_validate_outputs_to_inputs(struct gl_context *ctx,
+ struct gl_shader_program *prog,
   gl_linked_shader *producer,
   gl_linked_shader *consumer);
  
diff --git a/src/compiler/glsl/linker.cpp b/src/compiler/glsl/linker.cpp

index 03eb05bf63..3798309678 100644
--- a/src/compiler/glsl/linker.cpp
+++ b/src/compiler/glsl/linker.cpp
@@ -4929,7 +4929,7 @@ link_shaders(struct gl_context *ctx, struct 
gl_shader_program *prog)
if (!prog->data->LinkStatus)
   goto done;
  
-  cross_validate_outputs_to_inputs(prog,

+  cross_validate_outputs_to_inputs(ctx, prog,
 prog->_LinkedShaders[prev],
 prog->_LinkedShaders[i]);
if (!prog->data->LinkStatus)




--
Lerne, wie die Welt wirklich ist,
Aber vergiss niemals, wie sie sein sollte.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH] docs: add documentation for building with meson

2017-10-17 Thread Dylan Baker
Signed-off-by: Dylan Baker 
---

I'm sending this out now so that others can look at it, review it, and reference
it, but this should not end up in the 17.3 release, as the meson build for mesa
will not be ready to go into the 17.3 release.

 docs/contents.html |  1 +
 docs/meson.html| 99 ++
 2 files changed, 100 insertions(+)
 create mode 100644 docs/meson.html

diff --git a/docs/contents.html b/docs/contents.html
index d5455421091..9a86019e2f6 100644
--- a/docs/contents.html
+++ b/docs/contents.html
@@ -43,6 +43,7 @@
 Compiling / Installing
   
 Autoconf
+Meson
   
 
 Precompiled Libraries
diff --git a/docs/meson.html b/docs/meson.html
new file mode 100644
index 000..f45a62c9da4
--- /dev/null
+++ b/docs/meson.html
@@ -0,0 +1,99 @@
+http://www.w3.org/TR/html4/loose.dtd;>
+
+
+  
+  Compilation and Installation using Meson
+  
+
+
+
+
+  The Mesa 3D Graphics Library
+
+
+
+
+
+Compilation and Installation using Meson
+
+1. Basic Usage
+
+
+The meson program is used to configure the source directory and generates
+either a ninja build file, or visual studio build files. The meson Visual
+Studio?? backend is only available on Microsoft?? Windows??, and must be 
enabled
+via the --backend switch, as ninja is always the default. Meson only supports
+out-of-tree builds, and must be passed a directory to put built and generated
+sources into. We'll call that directory "build" for examples.
+
+
+
+meson build
+
+
+
+To see a description of your options you can run "meson configure". This will
+show your meson project configuration options as well as your local
+configuration options. One meson option to be aware of is that meson's default
+build type is "debug" (-O0 -g on gcc/clang).
+
+
+
+meson configure build
+
+
+Once you're run meson successfully you can use your configured backend to build
+the project, for Linux/*BSD and macOS that will be ninja. If you're unfamiliar
+with ninja, it automatically detects your CPU's and sets it's jobs
+appropriately. The -C option allows us to point ninja at the build directory
+without changing into it.
+
+
+ninja -C build
+
+
+
+This will produce libGL.so and/or several other libraries depending on the
+options you have chosen. Later, if you want to rebuild for a different
+configuration run ninja clean before rebuilding, or create a new
+out of tree build directory, meson supports an unlimited number of them, for 
+each configuration you want to build.
+
+
+CC, CFLAGS, CXX, CXXFLAGS
+These environment variables
+control the C and C++ compilers used during the build. The default compilers
+depends on your operating system. Meson supports GCC, Clang, and MSVC as first
+class compilers. There is some support for the Intel ICC compiler. No other
+C/C++ compilers are currently supported.
+
+
+PKG_CONFIG_PATH
+The
+pkg-config utility is a hard requirement for configuring and
+building mesa. It is used to search for external libraries
+on the system. This environment variable is used to control the search
+path for pkg-config. For instance, setting
+PKG_CONFIG_PATH=/usr/X11R6/lib/pkgconfig will search for
+package metadata in /usr/X11R6 before the standard
+directories.
+
+
+
+
+One of the oddities of meson is that some options are different when passed to
+the initial meson step than to meson configure. These options are passed as
+--option=foo to meson, but -Doption=foo to meson configure. Project defined
+options are always passed as -Doption=foo.
+
+
+For those coming from autotools be aware of the following:
+
+
+--buildtype/-Dbuildtype
+This option will set the compiler debug/optimisation levels (if the user
+hasn't already set them via the CFLAGS/CXXFLAGS) and macros to aid in
+debugging the Mesa libraries.
+
+Note that in meson this defaults to "debug", and  not setting it to
+"release" will yield non-optimal performance and binary size
-- 
2.14.2

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


Re: [Mesa-dev] [PATCH 4/4] meson: build nouveau veaux driver

2017-10-17 Thread Ilia Mirkin
On Tue, Oct 17, 2017 at 2:51 PM, Dylan Baker  wrote:
> Gah. French is one of the few romance languages I've never learned even a 
> little
> of.
>
> Fixed locally, would you like me to send a v2?

I have faith in your sed -i skills. Hopefully you'll push it somewhere
though so I can test it out (after you also provide some instructions
for those of us who haven't really been following along).

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


Re: [Mesa-dev] Upstream support for FreeSync / Adaptive Sync

2017-10-17 Thread Nicolai Hähnle

On 17.10.2017 19:16, Daniel Vetter wrote:

On Tue, Oct 17, 2017 at 5:40 PM, Michel Dänzer  wrote:

On 17/10/17 05:04 PM, Daniel Vetter wrote:

On Tue, Oct 17, 2017 at 03:46:24PM +0200, Michel Dänzer wrote:

On 17/10/17 02:22 PM, Daniel Vetter wrote:

On Tue, Oct 17, 2017 at 12:28:17PM +0200, Michel Dänzer wrote:

On 17/10/17 11:34 AM, Nicolai Hähnle wrote:



Common sense suggests that there need to be two side to FreeSync / VESA
Adaptive Sync support:

1. Query the display capabilities. This means querying minimum / maximum
refresh duration, plus possibly a query for when the earliest/latest
timing of the *next* refresh.

2. Signal desired present time. This means passing a target timer value
instead of a target vblank count, e.g. something like this for the KMS
interface:

   int drmModePageFlipTarget64(int fd, uint32_t crtc_id, uint32_t fb_id,
   uint32_t flags, void *user_data,
   uint64_t target);

   + a flag to indicate whether target is the vblank count or the
CLOCK_MONOTONIC (?) time in ns.


drmModePageFlip(Target) is part of the pre-atomic KMS API, but adapative
sync should probably only be supported via the atomic API, presumably
via output properties.


+1

At least now that DC is on track to land properly, and you want to do this
for DC-only anyway there's no reason to pimp the legacy interfaces
further. And atomic is soo much easier to extend.

The big question imo is where we need to put the flag on the kms side,
since freesync is not just about presenting earlier, but also about
presenting later. But for backwards compat we can't stretch the refresh
rate by default for everyone, or clients that rely on high precision
timestamps and regular refresh will get a bad surprise.


The idea described above is that adaptive sync would be used for flips
with a target timestamp. Apps which don't want to use adaptive sync
wouldn't set a target timestamp.



I think a boolean enable_freesync property is probably what we want, which
enables freesync for as long as it's set.


The question then becomes under what circumstances the property is (not)
set. Not sure offhand this will actually solve any problem, or just push
it somewhere else.


I thought that's what the driconf switch is for, with a policy of "please
schedule asap" instead of a specific timestamp.


The driconf switch is just for the user's intention to use adaptive sync
when possible. A property as you suggest cannot be set by the client
directly, because it can't know when adaptive sync can actually be used
(only when its window is fullscreen and using page flipping). So the
property would have to be set by the X server/driver / Wayland
compositor / ... instead. The question is whether such a property is
actually needed, or whether the kernel could just enable adaptive sync
when there's a flip with a target timestamp, and disable it when there's
a flip without a target timestamp, or something like that.


If your adaptive sync also supports extending the vblank beyond the
nominal limit, then you can't do that with a per-flip flag. Because
absent of a userspace requesting adaptive sync you must flip at the
nominal vrefresh rate. So if your userspace is a tad bit late with the
frame and would like to extend the frame to avoid missing a frame
entirely it'll be too late by the time the vblank actually gets
submitted. That's a bit a variation of what Ville brought up about
what we're going to do when the timestamp was missed by the time all
the depending fences signalled.


These are very good points. It does sound like we'd need both an 
"AdaptiveSync" boolean property and an (optional) "DesiredPresentTime" 
property.


The DesiredPresentTime property applies only to a single commit and 
could perhaps be left out in a first version. The AdaptiveSync property 
is persistent. When enabled, it means:


- handle page flip requests as soon as possible
- while no page flip is requested, delay vblank as long as possible

How does that sound?



Given all that I'm not sure whether requiring that userspace submits a
timestamp to get adaptive sync is a good idea (if we don't have an "as
soon as ready" flag at least), and the timestamp/flag at flip time
isn't enough either.


Finally I'm not sure we want to insist on a target time for freesync. At
least as far as I understand things you just want "as soon as possible".
This might change with some of the VK/EGL/GLX extensions where you
specify a precise timing (media playback). But that needs a bit more work
to make it happen I think, so perhaps better to postpone.


I don't see why. There's an obvious use case for this now, for video
playback. At least VDPAU already has target timestamps for this.



Also note that right now no driver expect amdgpu has support for a target
vblank on a flip. That's imo another reason for not requiring target
support for at least basic freesync support.


I think that's a bad reason. :) 

Re: [Mesa-dev] Upstream support for FreeSync / Adaptive Sync

2017-10-17 Thread Nicolai Hähnle

On 17.10.2017 16:09, Ville Syrjälä wrote:

On Tue, Oct 17, 2017 at 03:46:24PM +0200, Michel Dänzer wrote:

On 17/10/17 02:22 PM, Daniel Vetter wrote:

On Tue, Oct 17, 2017 at 12:28:17PM +0200, Michel Dänzer wrote:

On 17/10/17 11:34 AM, Nicolai Hähnle wrote:



Common sense suggests that there need to be two side to FreeSync / VESA
Adaptive Sync support:

1. Query the display capabilities. This means querying minimum / maximum
refresh duration, plus possibly a query for when the earliest/latest
timing of the *next* refresh.

2. Signal desired present time. This means passing a target timer value
instead of a target vblank count, e.g. something like this for the KMS
interface:

   int drmModePageFlipTarget64(int fd, uint32_t crtc_id, uint32_t fb_id,
   uint32_t flags, void *user_data,
   uint64_t target);

   + a flag to indicate whether target is the vblank count or the
CLOCK_MONOTONIC (?) time in ns.


drmModePageFlip(Target) is part of the pre-atomic KMS API, but adapative
sync should probably only be supported via the atomic API, presumably
via output properties.


+1

At least now that DC is on track to land properly, and you want to do this
for DC-only anyway there's no reason to pimp the legacy interfaces
further. And atomic is soo much easier to extend.

The big question imo is where we need to put the flag on the kms side,
since freesync is not just about presenting earlier, but also about
presenting later. But for backwards compat we can't stretch the refresh
rate by default for everyone, or clients that rely on high precision
timestamps and regular refresh will get a bad surprise.


The idea described above is that adaptive sync would be used for flips
with a target timestamp. Apps which don't want to use adaptive sync
wouldn't set a target timestamp.



I think a boolean enable_freesync property is probably what we want, which
enables freesync for as long as it's set.


The question then becomes under what circumstances the property is (not)
set. Not sure offhand this will actually solve any problem, or just push
it somewhere else.



Finally I'm not sure we want to insist on a target time for freesync. At
least as far as I understand things you just want "as soon as possible".
This might change with some of the VK/EGL/GLX extensions where you
specify a precise timing (media playback). But that needs a bit more work
to make it happen I think, so perhaps better to postpone.


I don't see why. There's an obvious use case for this now, for video
playback. At least VDPAU already has target timestamps for this.



Also note that right now no driver expect amdgpu has support for a target
vblank on a flip. That's imo another reason for not requiring target
support for at least basic freesync support.


I think that's a bad reason. :) Adding it for atomic drivers shouldn't
be that hard.


Apart from the actual implementation hurdles it does open up some new questions:


All good questions, thanks! Let me try to take a crack at them:



- Is it going to be per-plane or per-crtc?


My understanding is that planes are combined to form a single signal 
that goes out to the monitor(s). The planes are scanned out together by 
a crtc, so it should be per-crtc.




- What happens if the target timestamp is already stale?
- What happens if the target timestamp is good when it gets scheduled,
   but can't be met once the fences and whatnot have signalled?


Treat it as "flip as soon as possible" in both cases.



- What happens if another operation is already queued with a more
   recent timestamp?


This is a problem already today, isn't it? You could have two page flips 
being queued before the next vblank. What happens in that case?




- Apart from a pure timestamp do we want to move the OML_sync/swap_whatever
   msc remainder etc. semantics into the kernel as well? It's just
   another way to specify the target flip time after all.


A related question:

- What happens if the target timestamp is too late for the next vblank?

There's an argument to be made that late timestamps should just be 
treated as "delay the next vblank as late as possible". Such an option 
could be used by compositors for a power-saving mode.




I do like the idea, but clearly there's a bit of thought require to
make sure the semantics are good.


Agreed!

Cheers,
Nicolai
--
Lerne, wie die Welt wirklich ist,
Aber vergiss niemals, wie sie sein sollte.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH v2 04/52] intel/fs: Use ANY/ALL32 predicates in SIMD32

2017-10-17 Thread Matt Turner

On 10/12, Jason Ekstrand wrote:

We have ANY/ALL32 predicates and, for the most part, they work just
fine.  (See the next commit for more details.)  Also, due to the way
that flag registers are handled in hardware, instruction splitting is
able to split the CMP correctly.  Specifically, that hardware looks at
the execution group and knows to shift it's flag usage up correctly so a
2H instruction will write to f0.1 instead of f0.0.

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


Reviewed-by: Matt Turner 


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


Re: [Mesa-dev] [PATCH v2 03/52] intel/fs: Handle flag read/write aliasing in needs_src_copy

2017-10-17 Thread Matt Turner

On 10/12, Jason Ekstrand wrote:

In order to implement the ballot intrinsic, we do a MOV from flag
register to some GRF.  If that GRF is used in a SEL, cmod propagation
helpfully changes it into a MOV from the flag register with a cmod.
This is perfectly valid but when lower_simd_width comes along, it simply
splits into two instructions which both have conditional modifiers.
This is a problem since we're reading the flag register.  This commit
makes us check whether or not flags_written() overlaps with the flag
values that we are reading via the instruction source and, if we have
any interference, will force us to emit a copy of the source.

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


Reviewed-by: Matt Turner 


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


Re: [Mesa-dev] meson for remaining class drivers

2017-10-17 Thread Dylan Baker
Quoting Timothy Arceri (2017-10-16 18:05:38)
> On 17/10/17 11:55, Dylan Baker wrote:
> > Here is build support for the three remaining classic drivers, radeon 
> > (r100),
> > r200, and the nouveau-veaux driver. None of these are too crazy, but I don't
> > have hardware to test any of these.
> 
> I can probably test out r200 later tonight. However are you going to 
> update the building docs [1]? I haven't really been following this work 
> and I've got no idea how to use meson.
> 
> [1] https://www.mesa3d.org/install.html
> 
> > 
> > ___
> > mesa-dev mailing list
> > mesa-dev@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/mesa-dev
> > 

Yes! I will send a patch for that.

Dylan


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


Re: [Mesa-dev] [PATCH 4/4] meson: build nouveau veaux driver

2017-10-17 Thread Dylan Baker
Gah. French is one of the few romance languages I've never learned even a little
of.

Fixed locally, would you like me to send a v2?

Quoting Ilia Mirkin (2017-10-16 18:50:49)
> Old, not calves...
> 
> On Oct 16, 2017 8:56 PM, "Dylan Baker"  wrote:
> 
> Build tested only.
> 
> Signed-off-by: Dylan Baker 
> ---
>  meson.build                              |  4 +-
>  meson_options.txt                        |  2 +-
>  src/mesa/drivers/dri/meson.build         |  3 ++
>  src/mesa/drivers/dri/nouveau/meson.build | 92
> 
>  4 files changed, 99 insertions(+), 2 deletions(-)
>  create mode 100644 src/mesa/drivers/dri/nouveau/meson.build
> 
> diff --git a/meson.build b/meson.build
> index 8761fce3dff..40b1cda96ce 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -82,6 +82,7 @@ with_dri_i915 = false
>  with_dri_i965 = false
>  with_dri_r100 = false
>  with_dri_r200 = false
> +with_dri_nouveau = false
>  with_dri_swrast = false
>  _drivers = get_option('dri-drivers')
>  if _drivers != ''
> @@ -90,6 +91,7 @@ if _drivers != ''
>    with_dri_i965 = _split.contains('i965')
>    with_dri_r100 = _split.contains('r100')
>    with_dri_r200 = _split.contains('r200')
> +  with_dri_nouveau = _split.contains('nouveau')
>    with_dri_swrast = _split.contains('swrast')
>    with_dri = true
>  endif
> @@ -568,7 +570,7 @@ endif
>  if with_gallium_radeonsi or with_dri_r100 or with_dri_r200 # older radeon
> too
>    dep_libdrm_radeon = dependency('libdrm_radeon', version : '>= 2.4.71')
>  endif
> -if with_gallium_nouveau
> +if with_gallium_nouveau or with_dri_nouveau
>    dep_libdrm_nouveau = dependency('libdrm_nouveau', version : '>= 
> 2.4.66')
>  endif
> 
> diff --git a/meson_options.txt b/meson_options.txt
> index 25b3b77be2a..314fd2a9294 100644
> --- a/meson_options.txt
> +++ b/meson_options.txt
> @@ -34,7 +34,7 @@ option(
>  option(
>    'dri-drivers',
>    type : 'string',
> -  value : 'i915,i965,r100,r200',
> +  value : 'i915,i965,r100,r200,nouveau',
>    description : 'comma separated list of dri drivers to build.'
>  )
>  option(
> diff --git a/src/mesa/drivers/dri/meson.build 
> b/src/mesa/drivers/dri/meson.
> build
> index 5385dcc016f..ee1a1d95a64 100644
> --- a/src/mesa/drivers/dri/meson.build
> +++ b/src/mesa/drivers/dri/meson.build
> @@ -37,6 +37,9 @@ endif
>  if with_dri_r200
>    subdir('r200')
>  endif
> +if with_dri_nouveau
> +  subdir('nouveau')
> +endif
> 
>  if dri_drivers != []
>    libmesa_dri_drivers = shared_library(
> diff --git a/src/mesa/drivers/dri/nouveau/meson.build b/src/mesa/drivers/
> dri/nouveau/meson.build
> new file mode 100644
> index 000..07422f7041a
> --- /dev/null
> +++ b/src/mesa/drivers/dri/nouveau/meson.build
> @@ -0,0 +1,92 @@
> +# Copyright © 2017 Intel Corporation
> +
> +# Permission is hereby granted, free of charge, to any person obtaining a
> copy
> +# of this software and associated documentation files (the "Software"), 
> to
> deal
> +# in the Software without restriction, including without limitation the
> rights
> +# to use, copy, modify, merge, publish, distribute, sublicense, and/or
> sell
> +# copies of the Software, and to permit persons to whom the Software is
> +# furnished to do so, subject to the following conditions:
> +
> +# The above copyright notice and this permission notice shall be included
> in
> +# all copies or substantial portions of the Software.
> +
> +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
> OR
> +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 
> MERCHANTABILITY,
> +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
> THE
> +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
> FROM,
> +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
> IN THE
> +# SOFTWARE.
> +
> +files_nouveau_veaux = files(
> +  'nouveau_array.c',
> +  'nouveau_array.h',
> +  'nouveau_bufferobj.c',
> +  'nouveau_bufferobj.h',
> +  'nouveau_context.c',
> +  'nouveau_context.h',
> +  'nouveau_driver.c',
> +  'nouveau_driver.h',
> +  'nouveau_fbo.c',
> +  'nouveau_fbo.h',
> +  'nouveau_gldefs.h',
> +  'nouveau_local.h',
> +  'nouveau_render.h',
> +  'nouveau_scratch.c',
> +  'nouveau_scratch.h',
> +  'nouveau_screen.c',
> +  'nouveau_screen.h',
> +  'nouveau_span.c',
> +  'nouveau_state.c',
> +  'nouveau_state.h',
> +  

[Mesa-dev] [Bug 103312] meson/macOS: Dependency libdrm_intel found: NO

2017-10-17 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=103312

--- Comment #3 from Dylan Baker  ---
Currently I haven't tested building on any platform other than Linux for meson.
Honestly macOS isn't on my list of targets, I don't have a mac to test with and
my employer doesn't care about mesa with mac, but I'm planning to get windows
working which should fix issues like looking for libdrm and trying to build drm
drivers unconditionally.

In the mean time (or after windows support lands) if macOS is of interest to
you I'd be happy to review patches to support meson on macOS. If that's of
interest to you there is more work that needs to be done than just fixing the
list of drivers that are being built by default on non-free oses (xlib based
glx isn't building with meson yet, among other things.)

-- 
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] [Mesa-stable] [PATCH 3/4] i965/gen10: Enable float blend optimization

2017-10-17 Thread Anuj Phogat
On Thu, Oct 12, 2017 at 10:08 AM, Emil Velikov  wrote:
> Hi Anuj,
>
> On 3 October 2017 at 00:07, Anuj Phogat  wrote:
>> This optimization is enabled for previous generations too.
>> See Mesa commit c17e214a6b
>> On CNL this bit is moved to 3DSTATE_3D_MODE.
>>
>> Cc: mesa-sta...@lists.freedesktop.org
>> Signed-off-by: Anuj Phogat 
>> ---
> Seems like this (and 2/4 at least) haven't landed yet, so they won't
> be in 17.2.3.
>
> Normally we don't merge performance optimisations in stable, unless
> there's clear documentation about the gains they bring.
>
ok. Thanks for the heads up.

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


[Mesa-dev] [PATCH 2/7] glsl/parser: Silence unused parameter warning

2017-10-17 Thread Ian Romanick
From: Ian Romanick 

glsl/glsl_parser_extras.cpp: In constructor 
‘ast_struct_specifier::ast_struct_specifier(void*, const char*, 
ast_declarator_list*)’:
glsl/glsl_parser_extras.cpp:1675:50: warning: unused parameter ‘lin_ctx’ 
[-Wunused-parameter]
 ast_struct_specifier::ast_struct_specifier(void *lin_ctx, const char 
*identifier,
  ^~~

Signed-off-by: Ian Romanick 
---
 src/compiler/glsl/ast.h  | 4 ++--
 src/compiler/glsl/glsl_parser.yy | 4 ++--
 src/compiler/glsl/glsl_parser_extras.cpp | 2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/compiler/glsl/ast.h b/src/compiler/glsl/ast.h
index 3bf4b08..1be86ac 100644
--- a/src/compiler/glsl/ast.h
+++ b/src/compiler/glsl/ast.h
@@ -832,8 +832,8 @@ class ast_declarator_list;
 
 class ast_struct_specifier : public ast_node {
 public:
-   ast_struct_specifier(void *lin_ctx, const char *identifier,
-   ast_declarator_list *declarator_list);
+   ast_struct_specifier(const char *identifier,
+ast_declarator_list *declarator_list);
virtual void print(void) const;
 
virtual ir_rvalue *hir(exec_list *instructions,
diff --git a/src/compiler/glsl/glsl_parser.yy b/src/compiler/glsl/glsl_parser.yy
index 7b93d34..3e555cf 100644
--- a/src/compiler/glsl/glsl_parser.yy
+++ b/src/compiler/glsl/glsl_parser.yy
@@ -2377,14 +2377,14 @@ struct_specifier:
STRUCT any_identifier '{' struct_declaration_list '}'
{
   void *ctx = state->linalloc;
-  $$ = new(ctx) ast_struct_specifier(ctx, $2, $4);
+  $$ = new(ctx) ast_struct_specifier($2, $4);
   $$->set_location_range(@2, @5);
   state->symbols->add_type($2, glsl_type::void_type);
}
| STRUCT '{' struct_declaration_list '}'
{
   void *ctx = state->linalloc;
-  $$ = new(ctx) ast_struct_specifier(ctx, NULL, $3);
+  $$ = new(ctx) ast_struct_specifier(NULL, $3);
   $$->set_location_range(@2, @4);
}
;
diff --git a/src/compiler/glsl/glsl_parser_extras.cpp 
b/src/compiler/glsl/glsl_parser_extras.cpp
index 764c05a..d6d6f3d 100644
--- a/src/compiler/glsl/glsl_parser_extras.cpp
+++ b/src/compiler/glsl/glsl_parser_extras.cpp
@@ -1672,7 +1672,7 @@ ast_struct_specifier::print(void) const
 }
 
 
-ast_struct_specifier::ast_struct_specifier(void *lin_ctx, const char 
*identifier,
+ast_struct_specifier::ast_struct_specifier(const char *identifier,
   ast_declarator_list *declarator_list)
 {
if (identifier == NULL) {
-- 
2.9.5

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


[Mesa-dev] [PATCH 7/7] glsl: Remove ir_binop_greater and ir_binop_lequal expressions

2017-10-17 Thread Ian Romanick
From: Ian Romanick 

NIR does not have these instructions.  TGSI and Mesa IR both implement
them using < and >=, repsectively.  Removing them deletes a bunch of
code and means I don't have to add code to the SPIR-V generator for
them.

v2: Rebase on 2+ years of change... and fix a major bug added in the
rebase.

   textdata bss dec hex filename
8255291  268856  294072 8818219  868e2b 32-bit i965_dri.so before
8254235  268856  294072 8817163  868a0b 32-bit i965_dri.so after
7815339  345592  420592 8581523  82f193 64-bit i965_dri.so before
7813995  345560  420592 8580147  82ec33 64-bit i965_dri.so after

Signed-off-by: Ian Romanick 
---
 src/compiler/glsl/ast_to_hir.cpp   | 13 --
 src/compiler/glsl/builtin_functions.cpp| 23 -
 src/compiler/glsl/glsl_to_nir.cpp  | 24 -
 src/compiler/glsl/ir.cpp   |  2 --
 src/compiler/glsl/ir_builder.cpp   |  4 +--
 src/compiler/glsl/ir_builder_print_visitor.cpp |  2 --
 src/compiler/glsl/ir_expression_operation.py   |  2 --
 src/compiler/glsl/ir_validate.cpp  |  2 --
 src/compiler/glsl/loop_analysis.cpp| 23 +++--
 src/compiler/glsl/opt_algebraic.cpp|  4 ---
 .../glsl/tests/lower_jumps/create_test_cases.py|  2 +-
 src/intel/compiler/brw_shader.cpp  |  4 ---
 src/mesa/program/ir_to_mesa.cpp| 30 --
 src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 20 ---
 14 files changed, 39 insertions(+), 116 deletions(-)

diff --git a/src/compiler/glsl/ast_to_hir.cpp b/src/compiler/glsl/ast_to_hir.cpp
index 6090ee9..441404f 100644
--- a/src/compiler/glsl/ast_to_hir.cpp
+++ b/src/compiler/glsl/ast_to_hir.cpp
@@ -1337,8 +1337,8 @@ ast_expression::do_hir(exec_list *instructions,
   ir_binop_lshift,
   ir_binop_rshift,
   ir_binop_less,
-  ir_binop_greater,
-  ir_binop_lequal,
+  ir_binop_less,/* This is correct.  See the ast_greater case below. */
+  ir_binop_gequal,  /* This is correct.  See the ast_lequal case below. */
   ir_binop_gequal,
   ir_binop_all_equal,
   ir_binop_any_nequal,
@@ -1487,6 +1487,15 @@ ast_expression::do_hir(exec_list *instructions,
   assert(type->is_error()
  || (type->is_boolean() && type->is_scalar()));
 
+  /* Like NIR, GLSL IR does not have opcodes for > or <=.  Instead, swap
+   * the arguments and use < or >=.
+   */
+  if (this->oper == ast_greater || this->oper == ast_lequal) {
+ ir_rvalue *const tmp = op[0];
+ op[0] = op[1];
+ op[1] = tmp;
+  }
+
   result = new(ctx) ir_expression(operations[this->oper], type,
   op[0], op[1]);
   error_emitted = type->is_error();
diff --git a/src/compiler/glsl/builtin_functions.cpp 
b/src/compiler/glsl/builtin_functions.cpp
index 9df9671..530cdc0 100644
--- a/src/compiler/glsl/builtin_functions.cpp
+++ b/src/compiler/glsl/builtin_functions.cpp
@@ -744,7 +744,8 @@ private:
 ir_expression_operation opcode,
 const glsl_type *return_type,
 const glsl_type *param0_type,
-const glsl_type *param1_type);
+const glsl_type *param1_type,
+bool swap_operands = false);
 
 #define B0(X) ir_function_signature *_##X();
 #define B1(X) ir_function_signature *_##X(const glsl_type *);
@@ -3634,12 +3635,18 @@ builtin_builder::binop(builtin_available_predicate 
avail,
ir_expression_operation opcode,
const glsl_type *return_type,
const glsl_type *param0_type,
-   const glsl_type *param1_type)
+   const glsl_type *param1_type,
+   bool swap_operands)
 {
ir_variable *x = in_var(param0_type, "x");
ir_variable *y = in_var(param1_type, "y");
MAKE_SIG(return_type, avail, 2, x, y);
-   body.emit(ret(expr(opcode, x, y)));
+
+   if (swap_operands)
+  body.emit(ret(expr(opcode, y, x)));
+   else
+  body.emit(ret(expr(opcode, x, y)));
+
return sig;
 }
 
@@ -4972,16 +4979,18 @@ ir_function_signature *
 builtin_builder::_lessThanEqual(builtin_available_predicate avail,
 const glsl_type *type)
 {
-   return binop(avail, ir_binop_lequal,
-glsl_type::bvec(type->vector_elements), type, type);
+   return binop(avail, ir_binop_gequal,
+glsl_type::bvec(type->vector_elements), type, type,
+true);
 }
 
 ir_function_signature *
 builtin_builder::_greaterThan(builtin_available_predicate avail,
   const glsl_type *type)
 {
-   return binop(avail, 

[Mesa-dev] [PATCH 1/7] glsl: Silence unused parameter warnings

2017-10-17 Thread Ian Romanick
From: Ian Romanick 

glsl/standalone_scaffolding.cpp: In function ‘GLbitfield 
_mesa_program_state_flags(const gl_state_index*)’:
glsl/standalone_scaffolding.cpp:103:66: warning: unused parameter ‘state’ 
[-Wunused-parameter]
 _mesa_program_state_flags(const gl_state_index state[STATE_LENGTH])
  ^
glsl/standalone_scaffolding.cpp: In function ‘char* 
_mesa_program_state_string(const gl_state_index*)’:
glsl/standalone_scaffolding.cpp:109:67: warning: unused parameter ‘state’ 
[-Wunused-parameter]
 _mesa_program_state_string(const gl_state_index state[STATE_LENGTH])
   ^
glsl/standalone_scaffolding.cpp: In function ‘void 
_mesa_delete_shader(gl_context*, gl_shader*)’:
glsl/standalone_scaffolding.cpp:115:40: warning: unused parameter ‘ctx’ 
[-Wunused-parameter]
 _mesa_delete_shader(struct gl_context *ctx, struct gl_shader *sh)
^~~
glsl/standalone_scaffolding.cpp: In function ‘void 
_mesa_delete_linked_shader(gl_context*, gl_linked_shader*)’:
glsl/standalone_scaffolding.cpp:123:47: warning: unused parameter ‘ctx’ 
[-Wunused-parameter]
 _mesa_delete_linked_shader(struct gl_context *ctx,
   ^~~

Signed-off-by: Ian Romanick 
---
 src/compiler/glsl/standalone.cpp | 7 ---
 src/compiler/glsl/standalone_scaffolding.cpp | 8 
 2 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/src/compiler/glsl/standalone.cpp b/src/compiler/glsl/standalone.cpp
index 2f74813..85e94a1 100644
--- a/src/compiler/glsl/standalone.cpp
+++ b/src/compiler/glsl/standalone.cpp
@@ -101,7 +101,7 @@ private:
 };
 
 static void
-init_gl_program(struct gl_program *prog, GLenum target, bool is_arb_asm)
+init_gl_program(struct gl_program *prog, bool is_arb_asm)
 {
prog->RefCount = 1;
prog->Format = GL_PROGRAM_FORMAT_ASCII_ARB;
@@ -109,7 +109,8 @@ init_gl_program(struct gl_program *prog, GLenum target, 
bool is_arb_asm)
 }
 
 static struct gl_program *
-new_program(struct gl_context *ctx, GLenum target, GLuint id, bool is_arb_asm)
+new_program(UNUSED struct gl_context *ctx, GLenum target,
+UNUSED GLuint id, bool is_arb_asm)
 {
switch (target) {
case GL_VERTEX_PROGRAM_ARB: /* == GL_VERTEX_PROGRAM_NV */
@@ -119,7 +120,7 @@ new_program(struct gl_context *ctx, GLenum target, GLuint 
id, bool is_arb_asm)
case GL_FRAGMENT_PROGRAM_ARB:
case GL_COMPUTE_PROGRAM_NV: {
   struct gl_program *prog = rzalloc(NULL, struct gl_program);
-  init_gl_program(prog, target, is_arb_asm);
+  init_gl_program(prog, is_arb_asm);
   return prog;
}
default:
diff --git a/src/compiler/glsl/standalone_scaffolding.cpp 
b/src/compiler/glsl/standalone_scaffolding.cpp
index bc91682..34065a9 100644
--- a/src/compiler/glsl/standalone_scaffolding.cpp
+++ b/src/compiler/glsl/standalone_scaffolding.cpp
@@ -100,19 +100,19 @@ _mesa_new_shader(GLuint name, gl_shader_stage stage)
 }
 
 GLbitfield
-_mesa_program_state_flags(const gl_state_index state[STATE_LENGTH])
+_mesa_program_state_flags(UNUSED const gl_state_index state[STATE_LENGTH])
 {
return 0;
 }
 
 char *
-_mesa_program_state_string(const gl_state_index state[STATE_LENGTH])
+_mesa_program_state_string(UNUSED const gl_state_index state[STATE_LENGTH])
 {
return NULL;
 }
 
 void
-_mesa_delete_shader(struct gl_context *ctx, struct gl_shader *sh)
+_mesa_delete_shader(struct gl_context *, struct gl_shader *sh)
 {
free((void *)sh->Source);
free(sh->Label);
@@ -120,7 +120,7 @@ _mesa_delete_shader(struct gl_context *ctx, struct 
gl_shader *sh)
 }
 
 void
-_mesa_delete_linked_shader(struct gl_context *ctx,
+_mesa_delete_linked_shader(struct gl_context *,
struct gl_linked_shader *sh)
 {
ralloc_free(sh);
-- 
2.9.5

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


[Mesa-dev] [PATCH 6/7] glsl/parser: Track built-in types using the glsl_type directly

2017-10-17 Thread Ian Romanick
From: Ian Romanick 

   textdata bss dec hex filename
8255243  268856  294072 8818171  868dfb 32-bit i965_dri.so before
8255291  268856  294072 8818219  868e2b 32-bit i965_dri.so after
7815195  345592  420592 8581379  82f103 64-bit i965_dri.so before
7815339  345592  420592 8581523  82f193 64-bit i965_dri.so after

Signed-off-by: Ian Romanick 
---
 src/compiler/glsl/ast.h  | 13 +++--
 src/compiler/glsl/ast_to_hir.cpp |  4 +++-
 src/compiler/glsl/glsl_lexer.ll  | 21 +
 src/compiler/glsl/glsl_parser.yy |  2 +-
 4 files changed, 28 insertions(+), 12 deletions(-)

diff --git a/src/compiler/glsl/ast.h b/src/compiler/glsl/ast.h
index 1be86ac..eee2248 100644
--- a/src/compiler/glsl/ast.h
+++ b/src/compiler/glsl/ast.h
@@ -27,6 +27,7 @@
 
 #include "list.h"
 #include "glsl_parser_extras.h"
+#include "compiler/glsl_types.h"
 
 struct _mesa_glsl_parse_state;
 
@@ -853,7 +854,7 @@ class ast_type_specifier : public ast_node {
 public:
/** Construct a type specifier from a type name */
ast_type_specifier(const char *name) 
-  : type_name(name), structure(NULL), array_specifier(NULL),
+  : type(NULL), type_name(name), structure(NULL), array_specifier(NULL),
default_precision(ast_precision_none)
{
   /* empty */
@@ -861,12 +862,19 @@ public:
 
/** Construct a type specifier from a structure definition */
ast_type_specifier(ast_struct_specifier *s)
-  : type_name(s->name), structure(s), array_specifier(NULL),
+  : type(NULL), type_name(s->name), structure(s), array_specifier(NULL),
default_precision(ast_precision_none)
{
   /* empty */
}
 
+   ast_type_specifier(const glsl_type *t)
+  : type(t), type_name(t->name), structure(NULL), array_specifier(NULL),
+default_precision(ast_precision_none)
+   {
+  /* empty */
+   }
+
const struct glsl_type *glsl_type(const char **name,
 struct _mesa_glsl_parse_state *state)
   const;
@@ -875,6 +883,7 @@ public:
 
ir_rvalue *hir(exec_list *, struct _mesa_glsl_parse_state *);
 
+   const struct glsl_type *type;
const char *type_name;
ast_struct_specifier *structure;
 
diff --git a/src/compiler/glsl/ast_to_hir.cpp b/src/compiler/glsl/ast_to_hir.cpp
index d7c8b47..6090ee9 100644
--- a/src/compiler/glsl/ast_to_hir.cpp
+++ b/src/compiler/glsl/ast_to_hir.cpp
@@ -2361,7 +2361,9 @@ ast_type_specifier::glsl_type(const char **name,
 {
const struct glsl_type *type;
 
-   if (structure)
+   if (this->type != NULL)
+  type = this->type;
+   else if (structure)
   type = structure->type;
else
   type = state->symbols->get_type(this->type_name);
diff --git a/src/compiler/glsl/glsl_lexer.ll b/src/compiler/glsl/glsl_lexer.ll
index 5dad6ee..d2278ba 100644
--- a/src/compiler/glsl/glsl_lexer.ll
+++ b/src/compiler/glsl/glsl_lexer.ll
@@ -132,18 +132,23 @@ static int classify_identifier(struct 
_mesa_glsl_parse_state *, const char *,
 /**
  * Like DEPRECATED_ES_KEYWORD, but for types
  */
-#define DEPRECATED_ES_TYPE(gtype)  \
+#define DEPRECATED_ES_TYPE_WITH_ALT(alt_expr, gtype)   \
do {
\
   if (yyextra->is_version(0, 300)) {   \
-_mesa_glsl_error(yylloc, yyextra,  \
- "illegal use of reserved word `%s'", yytext); \
-return ERROR_TOK;  \
-  } else { \
-yylval->type = gtype;  \
+ _mesa_glsl_error(yylloc, yyextra, \
+  "illegal use of reserved word `%s'", yytext);
\
+ return ERROR_TOK; \
+  } else if (alt_expr) {   \
+ yylval->type = gtype; \
  return BASIC_TYPE_TOK;
\
+  } else { \
+ return classify_identifier(yyextra, yytext, yyleng, yylval);  \
   }
\
} while (0)
 
+#define DEPRECATED_ES_TYPE(gtype)  \
+   DEPRECATED_ES_TYPE_WITH_ALT(true, gtype)
+
 static int
 literal_integer(char *text, int len, struct _mesa_glsl_parse_state *state,
YYSTYPE *lval, YYLTYPE *lloc, int base)
@@ -619,9 +624,9 @@ dmat4x4 TYPE_WITH_ALT(110, 100, 400, 0, 
yyextra->ARB_gpu_shader_fp64_enable, gl
 fvec2  KEYWORD(110, 100, 0, 0, FVEC2);
 fvec3  KEYWORD(110, 100, 0, 0, FVEC3);
 fvec4  KEYWORD(110, 100, 0, 

[Mesa-dev] [PATCH 5/7] glsl/parser: Return the glsl_type object from the lexer

2017-10-17 Thread Ian Romanick
From: Ian Romanick 

This allows us to use a single token for every built-in type except void.

   textdata bss dec hex filename
8275163  269336  294072 8838571  86ddab 32-bit i965_dri.so before
8255243  268856  294072 8818171  868dfb 32-bit i965_dri.so after
7836963  346552  420592 8604107  8349cb 64-bit i965_dri.so before
7815195  345592  420592 8581379  82f103 64-bit i965_dri.so after

Yes, the 64-bit binary shrinks by 21k.

Signed-off-by: Ian Romanick 
---
 src/compiler/glsl/glsl_lexer.ll  | 304 ++-
 src/compiler/glsl/glsl_parser.yy | 160 ++---
 2 files changed, 182 insertions(+), 282 deletions(-)

diff --git a/src/compiler/glsl/glsl_lexer.ll b/src/compiler/glsl/glsl_lexer.ll
index bdd8df1..5dad6ee 100644
--- a/src/compiler/glsl/glsl_lexer.ll
+++ b/src/compiler/glsl/glsl_lexer.ll
@@ -87,6 +87,34 @@ static int classify_identifier(struct _mesa_glsl_parse_state 
*, const char *,
} while (0)
 
 /**
+ * Like KEYWORD_WITH_ALT, but used for built-in GLSL types
+ */
+#define TYPE_WITH_ALT(reserved_glsl, reserved_glsl_es, \
+ allowed_glsl, allowed_glsl_es,\
+ alt_expr, gtype)  \
+   do {
\
+  if (yyextra->is_version(allowed_glsl, allowed_glsl_es)   \
+  || (alt_expr)) { \
+yylval->type = gtype;  \
+return BASIC_TYPE_TOK; \
+  } else if (yyextra->is_version(reserved_glsl,\
+ reserved_glsl_es)) {  \
+_mesa_glsl_error(yylloc, yyextra,  \
+ "illegal use of reserved word `%s'", yytext); \
+return ERROR_TOK;  \
+  } else { \
+return classify_identifier(yyextra, yytext, yyleng, yylval);   \
+  }
\
+   } while (0)
+
+#define TYPE(reserved_glsl, reserved_glsl_es,  \
+ allowed_glsl, allowed_glsl_es,\
+ gtype)\
+   TYPE_WITH_ALT(reserved_glsl, reserved_glsl_es,  \
+ allowed_glsl, allowed_glsl_es,
\
+ false, gtype)
+
+/**
  * A macro for handling keywords that have been present in GLSL since
  * its origin, but were changed into reserved words in GLSL 3.00 ES.
  */
@@ -101,6 +129,21 @@ static int classify_identifier(struct 
_mesa_glsl_parse_state *, const char *,
   }
\
} while (0)
 
+/**
+ * Like DEPRECATED_ES_KEYWORD, but for types
+ */
+#define DEPRECATED_ES_TYPE(gtype)  \
+   do {
\
+  if (yyextra->is_version(0, 300)) {   \
+_mesa_glsl_error(yylloc, yyextra,  \
+ "illegal use of reserved word `%s'", yytext); \
+return ERROR_TOK;  \
+  } else { \
+yylval->type = gtype;  \
+ return BASIC_TYPE_TOK;
\
+  }
\
+   } while (0)
+
 static int
 literal_integer(char *text, int len, struct _mesa_glsl_parse_state *state,
YYSTYPE *lval, YYLTYPE *lloc, int base)
@@ -285,10 +328,10 @@ HASH  ^{SPC}#{SPC}
 
 attribute  DEPRECATED_ES_KEYWORD(ATTRIBUTE);
 const  return CONST_TOK;
-bool   return BOOL_TOK;
-float  return FLOAT_TOK;
-intreturn INT_TOK;
-uint   KEYWORD(130, 300, 130, 300, UINT_TOK);
+bool   { yylval->type = glsl_type::bool_type; return BASIC_TYPE_TOK; }
+float  { yylval->type = glsl_type::float_type; return BASIC_TYPE_TOK; }
+int{ yylval->type = glsl_type::int_type; return BASIC_TYPE_TOK; }
+uint   TYPE(130, 300, 130, 300, glsl_type::uint_type);
 
 break  return BREAK;
 continue   return CONTINUE;
@@ -300,30 +343,30 @@ ifreturn IF;
 discardreturn DISCARD;
 return return RETURN;
 
-bvec2  return BVEC2;
-bvec3  return BVEC3;
-bvec4  return BVEC4;
-ivec2  return IVEC2;
-ivec3  

[Mesa-dev] [PATCH 4/7] glsl/parser: Allocate identifier inside classify_identifier

2017-10-17 Thread Ian Romanick
From: Ian Romanick 

Passing YYSTYPE into classify_identifier enables a later patch.

   textdata bss dec hex filename
8310339  269336  294072 8873747  876713 32-bit i965_dri.so before
8275163  269336  294072 8838571  86ddab 32-bit i965_dri.so after
7845579  346552  420592 8612723  836b73 64-bit i965_dri.so before
7836963  346552  420592 8604107  8349cb 64-bit i965_dri.so after

Yes, the 64-bit binary shrinks by 8k.

Signed-off-by: Ian Romanick 
---
 src/compiler/glsl/glsl_lexer.ll | 44 ++---
 1 file changed, 15 insertions(+), 29 deletions(-)

diff --git a/src/compiler/glsl/glsl_lexer.ll b/src/compiler/glsl/glsl_lexer.ll
index 56519bf..bdd8df1 100644
--- a/src/compiler/glsl/glsl_lexer.ll
+++ b/src/compiler/glsl/glsl_lexer.ll
@@ -28,7 +28,8 @@
 #include "glsl_parser_extras.h"
 #include "glsl_parser.h"
 
-static int classify_identifier(struct _mesa_glsl_parse_state *, const char *);
+static int classify_identifier(struct _mesa_glsl_parse_state *, const char *,
+  unsigned name_len, YYSTYPE *output);
 
 #ifdef _MSC_VER
 #define YY_NO_UNISTD_H
@@ -81,14 +82,7 @@ static int classify_identifier(struct _mesa_glsl_parse_state 
*, const char *);
  "illegal use of reserved word `%s'", yytext); \
 return ERROR_TOK;  \
   } else { \
-/* We're not doing linear_strdup here, to avoid an implicit\
- * call on strlen() for the length of the string, as this is   \
- * already found by flex and stored in yyleng */   \
-void *mem_ctx = yyextra->linalloc; \
- char *id = (char *) linear_alloc_child(mem_ctx, yyleng + 1);   \
- memcpy(id, yytext, yyleng + 1);\
- yylval->identifier = id;   \
-return classify_identifier(yyextra, yytext);   \
+return classify_identifier(yyextra, yytext, yyleng, yylval);   \
   }
\
} while (0)
 
@@ -460,15 +454,7 @@ layout {
   || yyextra->ARB_tessellation_shader_enable) {
  return LAYOUT_TOK;
   } else {
- /* We're not doing linear_strdup here, to avoid an 
implicit call
-  * on strlen() for the length of the string, as this is 
already
-  * found by flex and stored in yyleng
-  */
-  void *mem_ctx = yyextra->linalloc;
-  char *id = (char *) linear_alloc_child(mem_ctx, yyleng + 
1);
-  memcpy(id, yytext, yyleng + 1);
-  yylval->identifier = id;
- return classify_identifier(yyextra, yytext);
+ return classify_identifier(yyextra, yytext, yyleng, 
yylval);
   }
}
 
@@ -637,21 +623,12 @@ u64vec4   KEYWORD_WITH_ALT(0, 0, 0, 0, 
yyextra->ARB_gpu_shader_int64_enable, U64V
 
 [_a-zA-Z][_a-zA-Z0-9]* {
struct _mesa_glsl_parse_state *state = yyextra;
-   void *ctx = state->linalloc;
if (state->es_shader && yyleng > 1024) {
   _mesa_glsl_error(yylloc, state,
"Identifier `%s' exceeds 1024 
characters",
yytext);
-   } else {
- /* We're not doing linear_strdup here, to avoid 
an implicit call
-  * on strlen() for the length of the string, as 
this is already
-  * found by flex and stored in yyleng
-  */
-  char *id = (char *) linear_alloc_child(ctx, 
yyleng + 1);
-  memcpy(id, yytext, yyleng + 1);
-  yylval->identifier = id;
}
-   return classify_identifier(state, yytext);
+   return classify_identifier(state, yytext, yyleng, 
yylval);
}
 
 \. { struct _mesa_glsl_parse_state *state = yyextra;
@@ -663,8 +640,17 @@ u64vec4KEYWORD_WITH_ALT(0, 0, 0, 0, 
yyextra->ARB_gpu_shader_int64_enable, U64V
 %%
 
 int
-classify_identifier(struct _mesa_glsl_parse_state *state, const char *name)
+classify_identifier(struct _mesa_glsl_parse_state *state, const char *name,
+unsigned name_len, YYSTYPE *output)
 {
+   /* We're not doing linear_strdup here, to avoid an implicit call on
+* strlen() for the length of the string, 

[Mesa-dev] [PATCH 3/7] glsl/parser: Move anonymous struct name handling to the parser

2017-10-17 Thread Ian Romanick
From: Ian Romanick 

There are two callers of the constructor, and they are right next to
each other.  Move the "#anon_struct" name handling to the parser so that
the conditional can be removed.

I've also deleted part of the comment (about the memory leak) because I
don't think it's quite accurate or relevant.

   textdata bss dec hex filename
8310399  269336  294072 8873807  87674f 32-bit i965_dri.so before
8310339  269336  294072 8873747  876713 32-bit i965_dri.so after
7845611  346552  420592 8612755  836b93 64-bit i965_dri.so before
7845579  346552  420592 8612723  836b73 64-bit i965_dri.so after

Signed-off-by: Ian Romanick 
---
 src/compiler/glsl/glsl_parser.yy | 10 +-
 src/compiler/glsl/glsl_parser_extras.cpp | 15 ++-
 2 files changed, 11 insertions(+), 14 deletions(-)

diff --git a/src/compiler/glsl/glsl_parser.yy b/src/compiler/glsl/glsl_parser.yy
index 3e555cf..58bbf6f 100644
--- a/src/compiler/glsl/glsl_parser.yy
+++ b/src/compiler/glsl/glsl_parser.yy
@@ -2384,7 +2384,15 @@ struct_specifier:
| STRUCT '{' struct_declaration_list '}'
{
   void *ctx = state->linalloc;
-  $$ = new(ctx) ast_struct_specifier(NULL, $3);
+
+  /* All anonymous structs have the same name. This simplifies matching of
+   * globals whose type is an unnamed struct.
+   *
+   * It also avoids a memory leak when the same shader is compiled over and
+   * over again.
+   */
+  $$ = new(ctx) ast_struct_specifier("#anon_struct", $3);
+
   $$->set_location_range(@2, @4);
}
;
diff --git a/src/compiler/glsl/glsl_parser_extras.cpp 
b/src/compiler/glsl/glsl_parser_extras.cpp
index d6d6f3d..65f12f7 100644
--- a/src/compiler/glsl/glsl_parser_extras.cpp
+++ b/src/compiler/glsl/glsl_parser_extras.cpp
@@ -1674,21 +1674,10 @@ ast_struct_specifier::print(void) const
 
 ast_struct_specifier::ast_struct_specifier(const char *identifier,
   ast_declarator_list *declarator_list)
+   : name(identifier), layout(NULL), declarations(), is_declaration(true),
+ type(NULL)
 {
-   if (identifier == NULL) {
-  /* All anonymous structs have the same name. This simplifies matching of
-   * globals whose type is an unnamed struct.
-   *
-   * It also avoids a memory leak when the same shader is compiled over and
-   * over again.
-   */
-  identifier = "#anon_struct";
-   }
-   name = identifier;
this->declarations.push_degenerate_list_at_head(_list->link);
-   is_declaration = true;
-   layout = NULL;
-   type = NULL;
 }
 
 void ast_subroutine_list::print(void) const
-- 
2.9.5

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


Re: [Mesa-dev] [PATCH mesa] meson: add missing radv_extensions.c generation for libvulkan_radeon

2017-10-17 Thread Dylan Baker
Quoting Eric Engestrom (2017-10-17 11:07:48)
> On Tuesday, 2017-10-17 17:04:13 +, Dylan Baker wrote:
> > Quoting Eric Engestrom (2017-10-17 08:23:26)
> > > On Tuesday, 2017-10-17 14:55:06 +, Andres Gomez wrote:
> > > > On Tue, 2017-10-17 at 12:00 +0100, Eric Engestrom wrote:
> > > > > Signed-off-by: Eric Engestrom 
> > > > 
> > > > I would add a line like:
> > > > 
> > > > fixes: 17201a2eb0b (radv: port to using updated anv 
> > > > entrypoint/extension generator.)
> > > 
> > > Thanks, I forgot to do that.
> > > 
> > > > 
> > > > > ---
> > > > >  src/amd/vulkan/meson.build | 10 +-
> > > > >  1 file changed, 9 insertions(+), 1 deletion(-)
> > > > > 
> > > > > diff --git a/src/amd/vulkan/meson.build b/src/amd/vulkan/meson.build
> > > > > index a5a4f81352807beac92d..6a416d988674504281c6 100644
> > > > > --- a/src/amd/vulkan/meson.build
> > > > > +++ b/src/amd/vulkan/meson.build
> > > > > @@ -26,6 +26,14 @@ radv_entrypoints = custom_target(
> > > > >   '--outdir', meson.current_build_dir()],
> > > > 
> > > > Since radv_entrypoints_gen.py depends on it and it is also explicit in
> > > > the Makefile.am, I think we should also add something like this here:
> > > > 
> > > > depend_files : files('radv_extensions.py'),
> > > 
> > > I'll send a separate patch for this, as it's unrelated to the break
> > > fixed here, but good catch, I didn't think to check inside the scripts.
> > > 
> > > Dylan, meson tracks includes in C files automatically, right? As in,
> > > a file including foo.h would get rebuilt if foo.h is touched, right?
> > > Any idea if the same is/can be done for python files?
> > > 
> > 
> > Meson tracks any files passed to a target as a source, and for compiled
> > languages will track anything that the compiler returns from it's depfiles.
> > For python you have to do this using the depend_files as Andres suggests.
> > 
> > Are we not doing that in the intel generator this is copied from?
> 
> `anv_entrypoints` does have it, not sure why it was missing for
> `radv_entrypoints`:

that's my bad.

> 
> > 
> > > > 
> > > > >  )
> > > > >  
> > > > > +radv_extensions = custom_target(
> > 
> > Could we call this radv_extensions_c, in keeping with the convention of the
> > other files? radv_entrypoints is kinda special since it's both a .c and .h 
> > file.
> 
> As I mentioned on IRC, I had already pushed this as it was a build fix,
> but I just pushed the rename in a separate commit.

Cool, thanks!

> 
> > 
> > With those two things fixed:
> > Reviewed-by: Dylan Baker 
> > 
> > > > > +  'radv_extensions.c',
> > > > > +  input : ['radv_extensions.py', vk_api_xml],
> > > > > +  output : ['radv_extensions.c'],
> > > > > +  command : [prog_python2, '@INPUT0@', '--xml', '@INPUT1@',
> > > > > + '--out', '@OUTPUT@'],
> > > > > +)
> > > > > +
> > > > >  vk_format_table_c = custom_target(
> > > > >'vk_format_table.c',
> > > > >input : ['vk_format_table.py', 'vk_format_layout.csv'],
> > > > > @@ -102,7 +110,7 @@ endif
> > > > >  
> > > > >  libvulkan_radeon = shared_library(
> > > > >'vulkan_radeon',
> > > > > -  [libradv_files, radv_entrypoints, nir_opcodes_h, 
> > > > > vk_format_table_c],
> > > > > +  [libradv_files, radv_entrypoints, radv_extensions, nir_opcodes_h, 
> > > > > vk_format_table_c],
> > > > >include_directories : [inc_common, inc_amd, inc_amd_common, 
> > > > > inc_compiler,
> > > > >   inc_vulkan_util, inc_vulkan_wsi],
> > > > >link_with : [libamd_common, libamdgpu_addrlib, libvulkan_util,
> > > > 
> > > > Other than that, this is:
> > > > 
> > > > Reviewed-by: Andres Gomez 
> > > > 
> > > > -- 
> > > > Br,
> > > > 
> > > > Andres
> 
> 


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


Re: [Mesa-dev] [PATCH 07/10] anv: Add sizeless anv_bo_cache_import()

2017-10-17 Thread Jason Ekstrand
On Tue, Oct 17, 2017 at 10:52 AM, Chad Versace 
wrote:

> On Mon 16 Oct 2017, Jason Ekstrand wrote:
> > On Mon, Oct 16, 2017 at 11:55 AM, Chad Versace <[1]
> chadvers...@chromium.org>
> > wrote:
> >
> > The patch renames anv_bo_cache_import() to
> > anv_bo_cache_import_with_size(); and adds a new variant,
> > anv_bo_cache_import(), that lacks the 'size' parameter. Same as
> > pre-patch, anv_bo_cache_import_with_size() continues to validate the
> > imported size.
> >
> > The patch is essentially a refactor patch.  It should change no
> existing
> > behavior.
> >
> > This split makes it easier to implement VK_ANDROID_native_buffer.
> When
> > the user imports a gralloc hande into a VkImage using
> > VK_ANDROID_native_buffer, the user provides no size. The driver must
> > infer the size from the internals of the gralloc buffer.
> > ---
> >  src/intel/vulkan/anv_allocator.c | 118
> +-
> > -
> >  src/intel/vulkan/anv_device.c|   7 ++-
> >  src/intel/vulkan/anv_intel.c |   5 +-
> >  src/intel/vulkan/anv_private.h   |   3 +
> >  src/intel/vulkan/anv_queue.c |   5 +-
> >  5 files changed, 90 insertions(+), 48 deletions(-)
> >
> > diff --git a/src/intel/vulkan/anv_allocator.c
> b/src/intel/vulkan/anv_
> > allocator.c
> > index 401cea40e6..1deecc36d7 100644
> > --- a/src/intel/vulkan/anv_allocator.c
> > +++ b/src/intel/vulkan/anv_allocator.c
> > @@ -1269,62 +1269,98 @@ anv_bo_cache_alloc(struct anv_device *device,
> > return VK_SUCCESS;
> >  }
> >
> > +static VkResult
> > +anv_bo_cache_import_locked(struct anv_device *device,
> > +   struct anv_bo_cache *cache,
> > +   int fd, struct anv_bo **bo_out)
> > +{
> > +   uint32_t gem_handle = anv_gem_fd_to_handle(device, fd);
> > +   if (!gem_handle)
> > +  return vk_error(VK_ERROR_INVALID_EXTERNAL_HANDLE_KHR);
> > +
> > +   struct anv_cached_bo *bo = anv_bo_cache_lookup_locked(cache,
> > gem_handle);
> > +   if (bo) {
> > +  __sync_fetch_and_add(>refcount, 1);
> > +  return VK_SUCCESS;
> > +   }
> > +
> > +   off_t size = lseek(fd, 0, SEEK_END);
> > +   if (size == (off_t)-1) {
> > +  anv_gem_close(device, gem_handle);
> > +  return vk_error(VK_ERROR_INVALID_EXTERNAL_HANDLE_KHR);
> > +   }
> > +
> > +   bo = vk_alloc(>alloc, sizeof(struct anv_cached_bo), 8,
> > + VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
> > +   if (!bo) {
> > +  anv_gem_close(device, gem_handle);
> > +  return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
> > +   }
> > +
> > +   bo->refcount = 1;
> > +   anv_bo_init(>bo, gem_handle, size);
> > +   _mesa_hash_table_insert(cache->bo_map, (void
> *)(uintptr_t)gem_handle,
> > bo);
> > +   *bo_out = >bo;
> > +
> > +   return VK_SUCCESS;
> > +}
> > +
> >  VkResult
> >  anv_bo_cache_import(struct anv_device *device,
> >  struct anv_bo_cache *cache,
> > -int fd, uint64_t size, struct anv_bo **bo_out)
> > +int fd, struct anv_bo **bo_out)
> >  {
> > +   VkResult result;
> > +
> > pthread_mutex_lock(>mutex);
> > +   result = anv_bo_cache_import_locked(device, cache, fd, bo_out);
> > +   pthread_mutex_unlock(>mutex);
> > +
> > +   return result;
> > +}
> > +
> > +VkResult
> > +anv_bo_cache_import_with_size(struct anv_device *device,
> > +  struct anv_bo_cache *cache,
> > +  int fd, uint64_t size,
> > +  struct anv_bo **bo_out)
> >
> >
> > I don't really like this function...  I'd rather we do the size checks
> in the
> > caller but we can do that refactor later.
>
> I don't believe the caller can check the size securely. See my comments
> below.
>
> >
> > +{
> > +   struct anv_bo *bo = NULL;
> > +   VkResult result;
> >
> > /* The kernel is going to give us whole pages anyway */
> > size = align_u64(size, 4096);
> >
> > -   uint32_t gem_handle = anv_gem_fd_to_handle(device, fd);
> > -   if (!gem_handle) {
> > +   pthread_mutex_lock(>mutex);
> > +
> > +   result = anv_bo_cache_import_locked(device, cache, fd, );
> > +   if (result != VK_SUCCESS) {
> >pthread_mutex_unlock(>mutex);
> > -  return vk_error(VK_ERROR_INVALID_EXTERNAL_HANDLE_KHR);
> > +  return result;
> > }
> >
> > -   struct anv_cached_bo *bo = anv_bo_cache_lookup_locked(cache,
> > gem_handle);
> > -   if (bo) {
> > -  if (bo->bo.size != size) {
> > - pthread_mutex_unlock(>mutex);
> > - return vk_error(VK_ERROR_INVALID_EXTERNAL_HANDLE_KHR);

Re: [Mesa-dev] [PATCH 07/10] anv: Add sizeless anv_bo_cache_import()

2017-10-17 Thread Jason Ekstrand
On Tue, Oct 17, 2017 at 10:52 AM, Chad Versace 
wrote:

> On Mon 16 Oct 2017, Jason Ekstrand wrote:
> > On Mon, Oct 16, 2017 at 11:55 AM, Chad Versace <[1]
> chadvers...@chromium.org>
> > wrote:
> >
> > The patch renames anv_bo_cache_import() to
> > anv_bo_cache_import_with_size(); and adds a new variant,
> > anv_bo_cache_import(), that lacks the 'size' parameter. Same as
> > pre-patch, anv_bo_cache_import_with_size() continues to validate the
> > imported size.
> >
> > The patch is essentially a refactor patch.  It should change no
> existing
> > behavior.
> >
> > This split makes it easier to implement VK_ANDROID_native_buffer.
> When
> > the user imports a gralloc hande into a VkImage using
> > VK_ANDROID_native_buffer, the user provides no size. The driver must
> > infer the size from the internals of the gralloc buffer.
> > ---
> >  src/intel/vulkan/anv_allocator.c | 118
> +-
> > -
> >  src/intel/vulkan/anv_device.c|   7 ++-
> >  src/intel/vulkan/anv_intel.c |   5 +-
> >  src/intel/vulkan/anv_private.h   |   3 +
> >  src/intel/vulkan/anv_queue.c |   5 +-
> >  5 files changed, 90 insertions(+), 48 deletions(-)
> >
> > diff --git a/src/intel/vulkan/anv_allocator.c
> b/src/intel/vulkan/anv_
> > allocator.c
> > index 401cea40e6..1deecc36d7 100644
> > --- a/src/intel/vulkan/anv_allocator.c
> > +++ b/src/intel/vulkan/anv_allocator.c
> > @@ -1269,62 +1269,98 @@ anv_bo_cache_alloc(struct anv_device *device,
> > return VK_SUCCESS;
> >  }
> >
> > +static VkResult
> > +anv_bo_cache_import_locked(struct anv_device *device,
> > +   struct anv_bo_cache *cache,
> > +   int fd, struct anv_bo **bo_out)
> > +{
> > +   uint32_t gem_handle = anv_gem_fd_to_handle(device, fd);
> > +   if (!gem_handle)
> > +  return vk_error(VK_ERROR_INVALID_EXTERNAL_HANDLE_KHR);
> > +
> > +   struct anv_cached_bo *bo = anv_bo_cache_lookup_locked(cache,
> > gem_handle);
> > +   if (bo) {
> > +  __sync_fetch_and_add(>refcount, 1);
> > +  return VK_SUCCESS;
> > +   }
> > +
> > +   off_t size = lseek(fd, 0, SEEK_END);
> > +   if (size == (off_t)-1) {
> > +  anv_gem_close(device, gem_handle);
> > +  return vk_error(VK_ERROR_INVALID_EXTERNAL_HANDLE_KHR);
> > +   }
> > +
> > +   bo = vk_alloc(>alloc, sizeof(struct anv_cached_bo), 8,
> > + VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
> > +   if (!bo) {
> > +  anv_gem_close(device, gem_handle);
> > +  return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
> > +   }
> > +
> > +   bo->refcount = 1;
> > +   anv_bo_init(>bo, gem_handle, size);
> > +   _mesa_hash_table_insert(cache->bo_map, (void
> *)(uintptr_t)gem_handle,
> > bo);
> > +   *bo_out = >bo;
> > +
> > +   return VK_SUCCESS;
> > +}
> > +
> >  VkResult
> >  anv_bo_cache_import(struct anv_device *device,
> >  struct anv_bo_cache *cache,
> > -int fd, uint64_t size, struct anv_bo **bo_out)
> > +int fd, struct anv_bo **bo_out)
> >  {
> > +   VkResult result;
> > +
> > pthread_mutex_lock(>mutex);
> > +   result = anv_bo_cache_import_locked(device, cache, fd, bo_out);
> > +   pthread_mutex_unlock(>mutex);
> > +
> > +   return result;
> > +}
> > +
> > +VkResult
> > +anv_bo_cache_import_with_size(struct anv_device *device,
> > +  struct anv_bo_cache *cache,
> > +  int fd, uint64_t size,
> > +  struct anv_bo **bo_out)
> >
> >
> > I don't really like this function...  I'd rather we do the size checks
> in the
> > caller but we can do that refactor later.
>
> I don't believe the caller can check the size securely. See my comments
> below.
>
> >
> > +{
> > +   struct anv_bo *bo = NULL;
> > +   VkResult result;
> >
> > /* The kernel is going to give us whole pages anyway */
> > size = align_u64(size, 4096);
> >
> > -   uint32_t gem_handle = anv_gem_fd_to_handle(device, fd);
> > -   if (!gem_handle) {
> > +   pthread_mutex_lock(>mutex);
> > +
> > +   result = anv_bo_cache_import_locked(device, cache, fd, );
> > +   if (result != VK_SUCCESS) {
> >pthread_mutex_unlock(>mutex);
> > -  return vk_error(VK_ERROR_INVALID_EXTERNAL_HANDLE_KHR);
> > +  return result;
> > }
> >
> > -   struct anv_cached_bo *bo = anv_bo_cache_lookup_locked(cache,
> > gem_handle);
> > -   if (bo) {
> > -  if (bo->bo.size != size) {
> > - pthread_mutex_unlock(>mutex);
> > - return vk_error(VK_ERROR_INVALID_EXTERNAL_HANDLE_KHR);

Re: [Mesa-dev] [PATCH mesa] meson: add missing radv_extensions.c generation for libvulkan_radeon

2017-10-17 Thread Eric Engestrom
On Tuesday, 2017-10-17 17:04:13 +, Dylan Baker wrote:
> Quoting Eric Engestrom (2017-10-17 08:23:26)
> > On Tuesday, 2017-10-17 14:55:06 +, Andres Gomez wrote:
> > > On Tue, 2017-10-17 at 12:00 +0100, Eric Engestrom wrote:
> > > > Signed-off-by: Eric Engestrom 
> > > 
> > > I would add a line like:
> > > 
> > > fixes: 17201a2eb0b (radv: port to using updated anv entrypoint/extension 
> > > generator.)
> > 
> > Thanks, I forgot to do that.
> > 
> > > 
> > > > ---
> > > >  src/amd/vulkan/meson.build | 10 +-
> > > >  1 file changed, 9 insertions(+), 1 deletion(-)
> > > > 
> > > > diff --git a/src/amd/vulkan/meson.build b/src/amd/vulkan/meson.build
> > > > index a5a4f81352807beac92d..6a416d988674504281c6 100644
> > > > --- a/src/amd/vulkan/meson.build
> > > > +++ b/src/amd/vulkan/meson.build
> > > > @@ -26,6 +26,14 @@ radv_entrypoints = custom_target(
> > > >   '--outdir', meson.current_build_dir()],
> > > 
> > > Since radv_entrypoints_gen.py depends on it and it is also explicit in
> > > the Makefile.am, I think we should also add something like this here:
> > > 
> > > depend_files : files('radv_extensions.py'),
> > 
> > I'll send a separate patch for this, as it's unrelated to the break
> > fixed here, but good catch, I didn't think to check inside the scripts.
> > 
> > Dylan, meson tracks includes in C files automatically, right? As in,
> > a file including foo.h would get rebuilt if foo.h is touched, right?
> > Any idea if the same is/can be done for python files?
> > 
> 
> Meson tracks any files passed to a target as a source, and for compiled
> languages will track anything that the compiler returns from it's depfiles.
> For python you have to do this using the depend_files as Andres suggests.
> 
> Are we not doing that in the intel generator this is copied from?

`anv_entrypoints` does have it, not sure why it was missing for
`radv_entrypoints`:

> 
> > > 
> > > >  )
> > > >  
> > > > +radv_extensions = custom_target(
> 
> Could we call this radv_extensions_c, in keeping with the convention of the
> other files? radv_entrypoints is kinda special since it's both a .c and .h 
> file.

As I mentioned on IRC, I had already pushed this as it was a build fix,
but I just pushed the rename in a separate commit.

> 
> With those two things fixed:
> Reviewed-by: Dylan Baker 
> 
> > > > +  'radv_extensions.c',
> > > > +  input : ['radv_extensions.py', vk_api_xml],
> > > > +  output : ['radv_extensions.c'],
> > > > +  command : [prog_python2, '@INPUT0@', '--xml', '@INPUT1@',
> > > > + '--out', '@OUTPUT@'],
> > > > +)
> > > > +
> > > >  vk_format_table_c = custom_target(
> > > >'vk_format_table.c',
> > > >input : ['vk_format_table.py', 'vk_format_layout.csv'],
> > > > @@ -102,7 +110,7 @@ endif
> > > >  
> > > >  libvulkan_radeon = shared_library(
> > > >'vulkan_radeon',
> > > > -  [libradv_files, radv_entrypoints, nir_opcodes_h, vk_format_table_c],
> > > > +  [libradv_files, radv_entrypoints, radv_extensions, nir_opcodes_h, 
> > > > vk_format_table_c],
> > > >include_directories : [inc_common, inc_amd, inc_amd_common, 
> > > > inc_compiler,
> > > >   inc_vulkan_util, inc_vulkan_wsi],
> > > >link_with : [libamd_common, libamdgpu_addrlib, libvulkan_util,
> > > 
> > > Other than that, this is:
> > > 
> > > Reviewed-by: Andres Gomez 
> > > 
> > > -- 
> > > Br,
> > > 
> > > Andres


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


Re: [Mesa-dev] [PATCH] squash! anv: Move close(fd) from anv_bo_cache_import to its callers

2017-10-17 Thread Jason Ekstrand
On Tue, Oct 17, 2017 at 10:46 AM, Chad Versace 
wrote:

> On Mon 16 Oct 2017, Jason Ekstrand wrote:
> > On October 16, 2017 4:18:45 PM Chad Versace 
> wrote:
> >
> > >
> > > Add missing close(fd) for case
> > > VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT_KHR,
> > > subcase ANV_SEMAPHORE_TYPE_BO.
> > > ---
> > >  src/intel/vulkan/anv_queue.c | 22 +++---
> > >  1 file changed, 11 insertions(+), 11 deletions(-)
> > >
> > > diff --git a/src/intel/vulkan/anv_queue.c
> b/src/intel/vulkan/anv_queue.c
> > > index e26254a87e..180c907781 100644
> > > --- a/src/intel/vulkan/anv_queue.c
> > > +++ b/src/intel/vulkan/anv_queue.c
> > > @@ -1020,17 +1020,6 @@ VkResult anv_ImportSemaphoreFdKHR(
> > >   new_impl.syncobj = anv_gem_syncobj_fd_to_handle(device, fd);
> > >   if (!new_impl.syncobj)
> > >  return vk_error(VK_ERROR_INVALID_EXTERNAL_HANDLE_KHR);
> > > -
> > > - /* From the Vulkan spec:
> > > -  *
> > > -  *"Importing semaphore state from a file descriptor
> transfers
> > > -  *ownership of the file descriptor from the application
> to the
> > > -  *Vulkan implementation. The application must not
> perform any
> > > -  *operations on the file descriptor after a successful
> import."
> > > -  *
> > > -  * If the import fails, we leave the file descriptor open.
> > > -  */
> > > - close(pImportSemaphoreFdInfo->fd);
> > >} else {
> > >   new_impl.type = ANV_SEMAPHORE_TYPE_BO;
> > >
> > > @@ -1044,6 +1033,17 @@ VkResult anv_ImportSemaphoreFdKHR(
> > >*/
> > >   assert(!(new_impl.bo->flags & EXEC_OBJECT_ASYNC));
> > >}
> > > +
> > > +  /* From the Vulkan spec:
> > > +   *
> > > +   *"Importing semaphore state from a file descriptor
> transfers
> > > +   *ownership of the file descriptor from the application to
> the
> > > +   *Vulkan implementation. The application must not perform
> any
> > > +   *operations on the file descriptor after a successful
> import."
> > > +   *
> > > +   * If the import fails, we leave the file descriptor open.
> > > +   */
> > > +  close(fd);
> >
> > Indentation looks off here.  Other than that, LGTM
>
> The indentation is intended. The expanded hunk looks like this. The
> close() catches both branches of the if-tree.
>
> case VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT_KHR:
> if (has_syncobj) {
> ...
> anv_gem_syncobj_fd_to_handle(dev, fd);
> if (fail)
> return error;
> } else {
> ...
> anv_bo_cache_import_with_size(dev, fd, ...);
> if (fail)
> return error;
> }
>
> close(fd);
>

Yes, but it looked, in patchwork, like it was indented 1 space too far.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 07/10] anv: Add sizeless anv_bo_cache_import()

2017-10-17 Thread Chad Versace
On Mon 16 Oct 2017, Jason Ekstrand wrote:
> On Mon, Oct 16, 2017 at 11:55 AM, Chad Versace <[1]chadvers...@chromium.org>
> wrote:
> 
> The patch renames anv_bo_cache_import() to
> anv_bo_cache_import_with_size(); and adds a new variant,
> anv_bo_cache_import(), that lacks the 'size' parameter. Same as
> pre-patch, anv_bo_cache_import_with_size() continues to validate the
> imported size.
> 
> The patch is essentially a refactor patch.  It should change no existing
> behavior.
> 
> This split makes it easier to implement VK_ANDROID_native_buffer. When
> the user imports a gralloc hande into a VkImage using
> VK_ANDROID_native_buffer, the user provides no size. The driver must
> infer the size from the internals of the gralloc buffer.
> ---
>  src/intel/vulkan/anv_allocator.c | 118 +-
> -
>  src/intel/vulkan/anv_device.c    |   7 ++-
>  src/intel/vulkan/anv_intel.c     |   5 +-
>  src/intel/vulkan/anv_private.h   |   3 +
>  src/intel/vulkan/anv_queue.c     |   5 +-
>  5 files changed, 90 insertions(+), 48 deletions(-)
> 
> diff --git a/src/intel/vulkan/anv_allocator.c b/src/intel/vulkan/anv_
> allocator.c
> index 401cea40e6..1deecc36d7 100644
> --- a/src/intel/vulkan/anv_allocator.c
> +++ b/src/intel/vulkan/anv_allocator.c
> @@ -1269,62 +1269,98 @@ anv_bo_cache_alloc(struct anv_device *device,
>     return VK_SUCCESS;
>  }
> 
> +static VkResult
> +anv_bo_cache_import_locked(struct anv_device *device,
> +                           struct anv_bo_cache *cache,
> +                           int fd, struct anv_bo **bo_out)
> +{
> +   uint32_t gem_handle = anv_gem_fd_to_handle(device, fd);
> +   if (!gem_handle)
> +      return vk_error(VK_ERROR_INVALID_EXTERNAL_HANDLE_KHR);
> +
> +   struct anv_cached_bo *bo = anv_bo_cache_lookup_locked(cache,
> gem_handle);
> +   if (bo) {
> +      __sync_fetch_and_add(>refcount, 1);
> +      return VK_SUCCESS;
> +   }
> +
> +   off_t size = lseek(fd, 0, SEEK_END);
> +   if (size == (off_t)-1) {
> +      anv_gem_close(device, gem_handle);
> +      return vk_error(VK_ERROR_INVALID_EXTERNAL_HANDLE_KHR);
> +   }
> +
> +   bo = vk_alloc(>alloc, sizeof(struct anv_cached_bo), 8,
> +                 VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
> +   if (!bo) {
> +      anv_gem_close(device, gem_handle);
> +      return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
> +   }
> +
> +   bo->refcount = 1;
> +   anv_bo_init(>bo, gem_handle, size);
> +   _mesa_hash_table_insert(cache->bo_map, (void *)(uintptr_t)gem_handle,
> bo);
> +   *bo_out = >bo;
> +
> +   return VK_SUCCESS;
> +}
> +
>  VkResult
>  anv_bo_cache_import(struct anv_device *device,
>                      struct anv_bo_cache *cache,
> -                    int fd, uint64_t size, struct anv_bo **bo_out)
> +                    int fd, struct anv_bo **bo_out)
>  {
> +   VkResult result;
> +
>     pthread_mutex_lock(>mutex);
> +   result = anv_bo_cache_import_locked(device, cache, fd, bo_out);
> +   pthread_mutex_unlock(>mutex);
> +
> +   return result;
> +}
> +
> +VkResult
> +anv_bo_cache_import_with_size(struct anv_device *device,
> +                              struct anv_bo_cache *cache,
> +                              int fd, uint64_t size,
> +                              struct anv_bo **bo_out)
> 
> 
> I don't really like this function...  I'd rather we do the size checks in the
> caller but we can do that refactor later.

I don't believe the caller can check the size securely. See my comments
below.

> 
> +{
> +   struct anv_bo *bo = NULL;
> +   VkResult result;
> 
>     /* The kernel is going to give us whole pages anyway */
>     size = align_u64(size, 4096);
> 
> -   uint32_t gem_handle = anv_gem_fd_to_handle(device, fd);
> -   if (!gem_handle) {
> +   pthread_mutex_lock(>mutex);
> +
> +   result = anv_bo_cache_import_locked(device, cache, fd, );
> +   if (result != VK_SUCCESS) {
>        pthread_mutex_unlock(>mutex);
> -      return vk_error(VK_ERROR_INVALID_EXTERNAL_HANDLE_KHR);
> +      return result;
>     }
> 
> -   struct anv_cached_bo *bo = anv_bo_cache_lookup_locked(cache,
> gem_handle);
> -   if (bo) {
> -      if (bo->bo.size != size) {
> -         pthread_mutex_unlock(>mutex);
> -         return vk_error(VK_ERROR_INVALID_EXTERNAL_HANDLE_KHR);
> -      }
> -      __sync_fetch_and_add(>refcount, 1);
> -   } else {
> -      /* For security purposes, we reject BO imports where the size does
> not
> -       * match exactly.  This prevents a malicious client from passing a
> -       * buffer to a trusted client, lying about the size, and telling 
> 

Re: [Mesa-dev] [PATCH] egl/dri2: disambiguate driver name

2017-10-17 Thread Eric Engestrom
On Tuesday, 2017-10-17 17:20:13 +, Emil Velikov wrote:
> On 17 October 2017 at 18:04, Kai Wasserbäch  
> wrote:
> > Hey Eric,
> > Eric Engestrom wrote on 17.10.2017 18:31:
> >> On Tuesday, 2017-10-17 15:26:00 +, Kai Wasserbäch wrote:
> >>> So far the Mesa-internal EGL driver "dri2" returned "DRI2" as its driver
> >>> name. This causes confusion, because there is a kernel interface by the
> >>> same name where a version 3 is available.
> >>
> >> What confusion? Do you have an example?
> >>
> >> I'm not really opposed to a change, but I don't see the benefit,
> >> especially of just adding this "MESA-" prefix...
> >
> > well, reading „EGL version string: 1.5 (DRI2)“ when calling eglinfo I 
> > assumed
> > that DRI3 was somehow not working on my setup (see
> > , 
> > which
> > I've included in the commit message). Michel then cleared up, that the 
> > interface
> > meant by the EGL version string is an internal Mesa interface which has 
> > nothing
> > to do with the more widely known X11 protocol extension.
> >
> > So I thought it best to clearly separate them. Ideally this internal 
> > interface
> > wouldn't be called "dri" at all, but I that's probably going a bit too far.
> >
> Yes name is a bit misleading, so I'm wondering if any of the following
> won't be better
>  - s/DRI2/DRI/ - might be tad confusing
>  - emit the corresponding DRI2 vs DRI3 - ideally, but might be fiddly
> to get sorted
>  - drop DRI2 all together - the other backends (glx yes glx and
> gallium) are long gone
> 
> What do you guys think?
> Emil

I vote remove. The only alternative is Haiku, and one would know if
that's what they were running.
I feel like this is part of the whole driver refactor ajax did in
b174a1ae720cb404738c "egl: Simplify the "driver" interface"

I'll send a patch removing the whole `name` thing tomorrow, if Kai
doesn't beat me to it :P
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] squash! anv: Move close(fd) from anv_bo_cache_import to its callers

2017-10-17 Thread Chad Versace
On Mon 16 Oct 2017, Jason Ekstrand wrote:
> On October 16, 2017 4:18:45 PM Chad Versace  wrote:
> 
> > 
> > Add missing close(fd) for case
> > VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT_KHR,
> > subcase ANV_SEMAPHORE_TYPE_BO.
> > ---
> >  src/intel/vulkan/anv_queue.c | 22 +++---
> >  1 file changed, 11 insertions(+), 11 deletions(-)
> > 
> > diff --git a/src/intel/vulkan/anv_queue.c b/src/intel/vulkan/anv_queue.c
> > index e26254a87e..180c907781 100644
> > --- a/src/intel/vulkan/anv_queue.c
> > +++ b/src/intel/vulkan/anv_queue.c
> > @@ -1020,17 +1020,6 @@ VkResult anv_ImportSemaphoreFdKHR(
> >   new_impl.syncobj = anv_gem_syncobj_fd_to_handle(device, fd);
> >   if (!new_impl.syncobj)
> >  return vk_error(VK_ERROR_INVALID_EXTERNAL_HANDLE_KHR);
> > -
> > - /* From the Vulkan spec:
> > -  *
> > -  *"Importing semaphore state from a file descriptor transfers
> > -  *ownership of the file descriptor from the application to the
> > -  *Vulkan implementation. The application must not perform any
> > -  *operations on the file descriptor after a successful 
> > import."
> > -  *
> > -  * If the import fails, we leave the file descriptor open.
> > -  */
> > - close(pImportSemaphoreFdInfo->fd);
> >} else {
> >   new_impl.type = ANV_SEMAPHORE_TYPE_BO;
> > 
> > @@ -1044,6 +1033,17 @@ VkResult anv_ImportSemaphoreFdKHR(
> >*/
> >   assert(!(new_impl.bo->flags & EXEC_OBJECT_ASYNC));
> >}
> > +
> > +  /* From the Vulkan spec:
> > +   *
> > +   *"Importing semaphore state from a file descriptor transfers
> > +   *ownership of the file descriptor from the application to the
> > +   *Vulkan implementation. The application must not perform any
> > +   *operations on the file descriptor after a successful import."
> > +   *
> > +   * If the import fails, we leave the file descriptor open.
> > +   */
> > +  close(fd);
> 
> Indentation looks off here.  Other than that, LGTM

The indentation is intended. The expanded hunk looks like this. The
close() catches both branches of the if-tree.

case VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT_KHR:
if (has_syncobj) {
...
anv_gem_syncobj_fd_to_handle(dev, fd);
if (fail)
return error;
} else {
...
anv_bo_cache_import_with_size(dev, fd, ...);
if (fail)
return error;
}

close(fd);
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH mesa] meson: add missing radv_extensions.c generation for libvulkan_radeon

2017-10-17 Thread Gert Wollny
Can't comment much on style, but it fixes the build, so 

Tested-by: Gert Wollny 

Am Dienstag, den 17.10.2017, 12:00 +0100 schrieb Eric Engestrom:
> Signed-off-by: Eric Engestrom 
> ---
>  src/amd/vulkan/meson.build | 10 +-
>  1 file changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git a/src/amd/vulkan/meson.build b/src/amd/vulkan/meson.build
> index a5a4f81352807beac92d..6a416d988674504281c6 100644
> --- a/src/amd/vulkan/meson.build
> +++ b/src/amd/vulkan/meson.build
> @@ -26,6 +26,14 @@ radv_entrypoints = custom_target(
>   '--outdir', meson.current_build_dir()],
>  )
>  
> +radv_extensions = custom_target(
> +  'radv_extensions.c',
> +  input : ['radv_extensions.py', vk_api_xml],
> +  output : ['radv_extensions.c'],
> +  command : [prog_python2, '@INPUT0@', '--xml', '@INPUT1@',
> + '--out', '@OUTPUT@'],
> +)
> +
>  vk_format_table_c = custom_target(
>'vk_format_table.c',
>input : ['vk_format_table.py', 'vk_format_layout.csv'],
> @@ -102,7 +110,7 @@ endif
>  
>  libvulkan_radeon = shared_library(
>'vulkan_radeon',
> -  [libradv_files, radv_entrypoints, nir_opcodes_h,
> vk_format_table_c],
> +  [libradv_files, radv_entrypoints, radv_extensions, nir_opcodes_h,
> vk_format_table_c],
>include_directories : [inc_common, inc_amd, inc_amd_common,
> inc_compiler,
>   inc_vulkan_util, inc_vulkan_wsi],
>link_with : [libamd_common, libamdgpu_addrlib, libvulkan_util,
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] egl/dri2: disambiguate driver name

2017-10-17 Thread Emil Velikov
On 17 October 2017 at 18:04, Kai Wasserbäch  wrote:
> Hey Eric,
> Eric Engestrom wrote on 17.10.2017 18:31:
>> On Tuesday, 2017-10-17 15:26:00 +, Kai Wasserbäch wrote:
>>> So far the Mesa-internal EGL driver "dri2" returned "DRI2" as its driver
>>> name. This causes confusion, because there is a kernel interface by the
>>> same name where a version 3 is available.
>>
>> What confusion? Do you have an example?
>>
>> I'm not really opposed to a change, but I don't see the benefit,
>> especially of just adding this "MESA-" prefix...
>
> well, reading „EGL version string: 1.5 (DRI2)“ when calling eglinfo I assumed
> that DRI3 was somehow not working on my setup (see
> , 
> which
> I've included in the commit message). Michel then cleared up, that the 
> interface
> meant by the EGL version string is an internal Mesa interface which has 
> nothing
> to do with the more widely known X11 protocol extension.
>
> So I thought it best to clearly separate them. Ideally this internal interface
> wouldn't be called "dri" at all, but I that's probably going a bit too far.
>
Yes name is a bit misleading, so I'm wondering if any of the following
won't be better
 - s/DRI2/DRI/ - might be tad confusing
 - emit the corresponding DRI2 vs DRI3 - ideally, but might be fiddly
to get sorted
 - drop DRI2 all together - the other backends (glx yes glx and
gallium) are long gone

What do you guys think?
Emil
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] Upstream support for FreeSync / Adaptive Sync

2017-10-17 Thread Daniel Vetter
On Tue, Oct 17, 2017 at 5:40 PM, Michel Dänzer  wrote:
> On 17/10/17 05:04 PM, Daniel Vetter wrote:
>> On Tue, Oct 17, 2017 at 03:46:24PM +0200, Michel Dänzer wrote:
>>> On 17/10/17 02:22 PM, Daniel Vetter wrote:
 On Tue, Oct 17, 2017 at 12:28:17PM +0200, Michel Dänzer wrote:
> On 17/10/17 11:34 AM, Nicolai Hähnle wrote:

>> Common sense suggests that there need to be two side to FreeSync / VESA
>> Adaptive Sync support:
>>
>> 1. Query the display capabilities. This means querying minimum / maximum
>> refresh duration, plus possibly a query for when the earliest/latest
>> timing of the *next* refresh.
>>
>> 2. Signal desired present time. This means passing a target timer value
>> instead of a target vblank count, e.g. something like this for the KMS
>> interface:
>>
>>   int drmModePageFlipTarget64(int fd, uint32_t crtc_id, uint32_t fb_id,
>>   uint32_t flags, void *user_data,
>>   uint64_t target);
>>
>>   + a flag to indicate whether target is the vblank count or the
>> CLOCK_MONOTONIC (?) time in ns.
>
> drmModePageFlip(Target) is part of the pre-atomic KMS API, but adapative
> sync should probably only be supported via the atomic API, presumably
> via output properties.

 +1

 At least now that DC is on track to land properly, and you want to do this
 for DC-only anyway there's no reason to pimp the legacy interfaces
 further. And atomic is soo much easier to extend.

 The big question imo is where we need to put the flag on the kms side,
 since freesync is not just about presenting earlier, but also about
 presenting later. But for backwards compat we can't stretch the refresh
 rate by default for everyone, or clients that rely on high precision
 timestamps and regular refresh will get a bad surprise.
>>>
>>> The idea described above is that adaptive sync would be used for flips
>>> with a target timestamp. Apps which don't want to use adaptive sync
>>> wouldn't set a target timestamp.
>>>
>>>
 I think a boolean enable_freesync property is probably what we want, which
 enables freesync for as long as it's set.
>>>
>>> The question then becomes under what circumstances the property is (not)
>>> set. Not sure offhand this will actually solve any problem, or just push
>>> it somewhere else.
>>
>> I thought that's what the driconf switch is for, with a policy of "please
>> schedule asap" instead of a specific timestamp.
>
> The driconf switch is just for the user's intention to use adaptive sync
> when possible. A property as you suggest cannot be set by the client
> directly, because it can't know when adaptive sync can actually be used
> (only when its window is fullscreen and using page flipping). So the
> property would have to be set by the X server/driver / Wayland
> compositor / ... instead. The question is whether such a property is
> actually needed, or whether the kernel could just enable adaptive sync
> when there's a flip with a target timestamp, and disable it when there's
> a flip without a target timestamp, or something like that.

If your adaptive sync also supports extending the vblank beyond the
nominal limit, then you can't do that with a per-flip flag. Because
absent of a userspace requesting adaptive sync you must flip at the
nominal vrefresh rate. So if your userspace is a tad bit late with the
frame and would like to extend the frame to avoid missing a frame
entirely it'll be too late by the time the vblank actually gets
submitted. That's a bit a variation of what Ville brought up about
what we're going to do when the timestamp was missed by the time all
the depending fences signalled.

Given all that I'm not sure whether requiring that userspace submits a
timestamp to get adaptive sync is a good idea (if we don't have an "as
soon as ready" flag at least), and the timestamp/flag at flip time
isn't enough either.

 Finally I'm not sure we want to insist on a target time for freesync. At
 least as far as I understand things you just want "as soon as possible".
 This might change with some of the VK/EGL/GLX extensions where you
 specify a precise timing (media playback). But that needs a bit more work
 to make it happen I think, so perhaps better to postpone.
>>>
>>> I don't see why. There's an obvious use case for this now, for video
>>> playback. At least VDPAU already has target timestamps for this.
>>>
>>>
 Also note that right now no driver expect amdgpu has support for a target
 vblank on a flip. That's imo another reason for not requiring target
 support for at least basic freesync support.
>>>
>>> I think that's a bad reason. :) Adding it for atomic drivers shouldn't
>>> be that hard.
>>
>> I thought the primary reason for adaptive sync is the adaptive frame rate
>> to cope with the occasional stall in games. If the 

[Mesa-dev] [PATCH] egl/dri2: disambiguate driver name (v2)

2017-10-17 Thread Kai Wasserbäch
So far the Mesa-internal EGL driver "dri2" returned "DRI2" as its driver
name. This causes confusion, because there is an X11 protocol extension
by the same name. To make matters worse, the protocol extension also has
a newer version called "DRI3", which then can lead a user to the
assumption that DRI3 is not used on the current system, even when it
should. While in truth the "DRI2" shown in the EGL version string refers
to an internal interface in Mesa, that has nothing to do with the X11
protocol extension at all.

This change attempts to make it clearer that the "dri2" name of the Mesa
EGL driver has nothing to do with the X11 protocol extension by
prepending "Mesa-" to the driver name shown in the brackets of the EGL
version string.

See the thread beginning at

for the exchange that sparked this patch.

v2:
 - Fix commit message. (Michel Dänzer)
 - Don't capitalise "Mesa" in the driver name. (Eric Engestrom)
Signed-off-by: Kai Wasserbäch 
---
 src/egl/drivers/dri2/egl_dri2.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index 77f09271f0..8a1f5d2503 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -3260,7 +3260,7 @@ _eglBuiltInDriver(void)
dri2_drv->base.API.GLInteropExportObject = dri2_interop_export_object;
dri2_drv->base.API.DupNativeFenceFDANDROID = dri2_dup_native_fence_fd;
 
-   dri2_drv->base.Name = "DRI2";
+   dri2_drv->base.Name = "Mesa-DRI2";
 
return _drv->base;
 }
-- 
2.14.2

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


[Mesa-dev] Mesa 17.2.3 release candidate

2017-10-17 Thread Emil Velikov
Hello list,

The candidate for the Mesa 17.2.3 is now available. Currently we have:
 - 54 queued
 - 8 nominated (outstanding)
 - and 2 rejected patches


In the current queue we have:


The Vulkan drivers ANV and RADV have multiple small fixes.

The EGL code has improved handling of the new wl_dmabuf codepath.

SWR no longer crashes when checking environment variables.

Other gallium drivers have also seen updates - freedreno, nouveau and radeonsi.
The gallivm module, used by llvmpipe et al. has gained little endian
PPC64 fixes.

The VA and VDPAU state-trackers have seems improvements handling
interlaced videos.

We're using python3 compatible constructs which gives us SCons 3.0 support.

Take a look at section "Mesa stable queue" for more information.


Testing reports/general approval


Any testing reports (or general approval of the state of the branch)
will be greatly appreciated.

The plan is to have 17.2.3 Wednesday (18th of October), around or
shortly after 18:00 GMT.

If you have any questions or suggestions - be that about the current
patch queue or otherwise, please go ahead.


Trivial merge conflicts
---

commit f2fc1685177ff4886e1dddc1595558ea7f0696b1
Author: Nicolai Hähnle 

glsl/lower_instruction: handle denorms and overflow in ldexp correctly

(cherry picked from commit 93bf9c114b7c54e4faf342810bd848527b7d0a80)


commit 1146591d4ba053426d16e47ae0835aa00e033dee
Author: Dave Airlie 

radv: emit fmuladd instead of fma to llvm.

(cherry picked from commit 4e93d6baae2d00540b9bee0decff700d1aa6b247)


commit 41ec2af2a8bfefa7295e691bacb44e69a88fec21
Author: Dave Airlie 

radv: lower ffma in nir.

(cherry picked from commit 2c61594d84911f486aa2edb4b8e561e780139d20)


commit 74a28d85de57fa72f7121be7631aaf702014ccb4
Author: Nicolai Hähnle 

radeonsi: clamp depth comparison value only for fixed point formats

(cherry picked from commit 4c56e070296be6f53bfc1a3a4c864f12c035d3a4)


Cheers,
Emil


Mesa stable queue
-

Nominated (8)
=

Dave Airlie (1):
  radv/image: bump all the offset to uint64_t.

Emil Velikov (5):
  configure.ac: factor out detection for old and buggy llvm
  configure.ac: rework llvm libs handling for 3.9+
  Travis: add binutils 2.26 for a few more LLVM 3.9 builds
  configure.ac: add llvm_add_optional_component helper
  configure.ac: add missing LLVM components for OpenCL

Marek Olšák (1):
  Revert "mesa: fix texture updates for ATI_fragment_shader"

Samuel Pitoiset (1):
  radv: add the draw count buffer to the list of buffers


Queued (54)
===

Alex Smith (1):
  radv: Add R16G16B16A16_SNORM fast clear support

Bas Nieuwenhuizen (2):
  nir/spirv: Allow loop breaks in a switch body.
  radv: Only set the MTYPE flags on GFX9+.

Ben Crocker (4):
  gallivm: fix typo in debug_printf message
  gallivm: allow additional llc options
  gallivm/ppc64le: adjust VSX code generation control.
  gallivm/ppc64le: allow environmental control of Altivec code generation

Daniel Stone (2):
  egl/wayland: Check queryImage return for wl_buffer
  egl/wayland: Don't use dmabuf with no modifiers

Dave Airlie (2):
  radv: emit fmuladd instead of fma to llvm.
  radv: lower ffma in nir.

Emil Velikov (5):
  cherry-ignore: add "anv: Remove unreachable cases from
isl_format_for_size"
  cherry-ignore: add "anv/wsi: Allocate enough memory for the entire image"
  swr/rast: do not crash on NULL strings returned by getenv
  wayland-drm: use a copy of the wayland_drm_callbacks struct
  eglmesaext: add forward declaration for struct wl_buffers

Eric Engestrom (1):
  scons: use python3-compatible print()

Ilia Mirkin (2):
  nv50/ir: fix 64-bit integer shifts
  nv50,nvc0: fix push hint logic in presence of a start offset

Jason Ekstrand (6):
  intel/compiler: Don't cmod propagate into a saturated operation
  intel/compiler: Don't propagate cmod into integer multiplies
  glsl/blob: Return false from ensure_can_read on overrun
  glsl/blob: Return false from grow_to_fit if we've ever failed
  nir/opcodes: Fix constant-folding of ufind_msb
  nir: Get rid of the variable on vote intrinsics

Józef Kucia (3):
  anv: Fix vkCmdFillBuffer()
  spirv: Fix SpvOpAtomicISub
  anv: Do not assert() on VK_ATTACHMENT_UNUSED

Leo Liu (3):
  st/va: use pipe transfer_map to map upload buffer
  st/vdpau: don't re-allocate interlaced buffer with packed YUV format
  st/va: don't re-allocate interlaced buffer with pakced format

Lionel Landwerlin (4):
  intel: compiler: vec4: add missing default 0 lod
  anv/cmd_buffer: fix push descriptors with set > 0
  anv/cmd_buffer: Reset state in cmd_buffer_destroy
  anv: bo_cache: allow importing a BO larger than needed

Marek Olšák (3):
 

[Mesa-dev] [PATCH v3] compiler: Mark when input/ouput attribute at VS uses 16-bit (v2)

2017-10-17 Thread Jose Maria Casanova Crespo
New shader attribute to mark when a location has 16-bit
value. This patch includes support on mesa glsl and nir.

v2: Remove use of is_half_slot as is a duplicate of is_16bit
(Topi Pohjolainen)
---
 src/compiler/glsl_types.h  | 15 +++
 src/compiler/nir/nir_gather_info.c | 21 ++---
 src/compiler/shader_info.h |  2 ++
 3 files changed, 31 insertions(+), 7 deletions(-)

diff --git a/src/compiler/glsl_types.h b/src/compiler/glsl_types.h
index 32399df351..e35e8d8f88 100644
--- a/src/compiler/glsl_types.h
+++ b/src/compiler/glsl_types.h
@@ -93,6 +93,13 @@ static inline bool glsl_base_type_is_integer(enum 
glsl_base_type type)
   type == GLSL_TYPE_IMAGE;
 }
 
+static inline bool glsl_base_type_is_16bit(enum glsl_base_type type)
+{
+   return type == GLSL_TYPE_FLOAT16 ||
+  type == GLSL_TYPE_UINT16 ||
+  type == GLSL_TYPE_INT16;
+}
+
 enum glsl_sampler_dim {
GLSL_SAMPLER_DIM_1D = 0,
GLSL_SAMPLER_DIM_2D,
@@ -555,6 +562,14 @@ struct glsl_type {
}
 
/**
+* Query whether or not a type is 16-bit
+*/
+   bool is_16bit() const
+   {
+  return glsl_base_type_is_16bit(base_type);
+   }
+
+   /**
 * Query whether or not a type is a non-array boolean type
 */
bool is_boolean() const
diff --git a/src/compiler/nir/nir_gather_info.c 
b/src/compiler/nir/nir_gather_info.c
index ac87bec46c..cce64f9c84 100644
--- a/src/compiler/nir/nir_gather_info.c
+++ b/src/compiler/nir/nir_gather_info.c
@@ -212,14 +212,20 @@ gather_intrinsic_info(nir_intrinsic_instr *instr, 
nir_shader *shader)
  if (!try_mask_partial_io(shader, instr->variables[0]))
 mark_whole_variable(shader, var);
 
- /* We need to track which input_reads bits correspond to a
-  * dvec3/dvec4 input attribute */
+ /* We need to track which input_reads bits correspond to
+  * dvec3/dvec4 or 16-bit  input attributes */
  if (shader->stage == MESA_SHADER_VERTEX &&
- var->data.mode == nir_var_shader_in &&
- glsl_type_is_dual_slot(glsl_without_array(var->type))) {
-for (uint i = 0; i < glsl_count_attribute_slots(var->type, false); 
i++) {
-   int idx = var->data.location + i;
-   shader->info.double_inputs_read |= BITFIELD64_BIT(idx);
+ var->data.mode == nir_var_shader_in) {
+if (glsl_type_is_dual_slot(glsl_without_array(var->type))) {
+   for (uint i = 0; i < glsl_count_attribute_slots(var->type, 
false); i++) {
+  int idx = var->data.location + i;
+  shader->info.double_inputs_read |= BITFIELD64_BIT(idx);
+   }
+} else if (glsl_get_bit_size(glsl_without_array(var->type)) == 16) 
{
+   for (uint i = 0; i < glsl_count_attribute_slots(var->type, 
false); i++) {
+  int idx = var->data.location + i;
+  shader->info.half_inputs_read |= BITFIELD64_BIT(idx);
+   }
 }
  }
   }
@@ -312,6 +318,7 @@ nir_shader_gather_info(nir_shader *shader, 
nir_function_impl *entrypoint)
shader->info.outputs_written = 0;
shader->info.outputs_read = 0;
shader->info.double_inputs_read = 0;
+   shader->info.half_inputs_read = 0;
shader->info.patch_inputs_read = 0;
shader->info.patch_outputs_written = 0;
shader->info.system_values_read = 0;
diff --git a/src/compiler/shader_info.h b/src/compiler/shader_info.h
index 38413940d6..98111fa1e0 100644
--- a/src/compiler/shader_info.h
+++ b/src/compiler/shader_info.h
@@ -55,6 +55,8 @@ typedef struct shader_info {
uint64_t inputs_read;
/* Which inputs are actually read and are double */
uint64_t double_inputs_read;
+   /* Which inputs are actually read and are half */
+   uint64_t half_inputs_read;
/* Which outputs are actually written */
uint64_t outputs_written;
/* Which outputs are actually read */
-- 
2.13.6

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


Re: [Mesa-dev] [PATCH mesa] meson: add missing radv_extensions.c generation for libvulkan_radeon

2017-10-17 Thread Dylan Baker
Quoting Eric Engestrom (2017-10-17 08:23:26)
> On Tuesday, 2017-10-17 14:55:06 +, Andres Gomez wrote:
> > On Tue, 2017-10-17 at 12:00 +0100, Eric Engestrom wrote:
> > > Signed-off-by: Eric Engestrom 
> > 
> > I would add a line like:
> > 
> > fixes: 17201a2eb0b (radv: port to using updated anv entrypoint/extension 
> > generator.)
> 
> Thanks, I forgot to do that.
> 
> > 
> > > ---
> > >  src/amd/vulkan/meson.build | 10 +-
> > >  1 file changed, 9 insertions(+), 1 deletion(-)
> > > 
> > > diff --git a/src/amd/vulkan/meson.build b/src/amd/vulkan/meson.build
> > > index a5a4f81352807beac92d..6a416d988674504281c6 100644
> > > --- a/src/amd/vulkan/meson.build
> > > +++ b/src/amd/vulkan/meson.build
> > > @@ -26,6 +26,14 @@ radv_entrypoints = custom_target(
> > >   '--outdir', meson.current_build_dir()],
> > 
> > Since radv_entrypoints_gen.py depends on it and it is also explicit in
> > the Makefile.am, I think we should also add something like this here:
> > 
> > depend_files : files('radv_extensions.py'),
> 
> I'll send a separate patch for this, as it's unrelated to the break
> fixed here, but good catch, I didn't think to check inside the scripts.
> 
> Dylan, meson tracks includes in C files automatically, right? As in,
> a file including foo.h would get rebuilt if foo.h is touched, right?
> Any idea if the same is/can be done for python files?
> 

Meson tracks any files passed to a target as a source, and for compiled
languages will track anything that the compiler returns from it's depfiles.
For python you have to do this using the depend_files as Andres suggests.

Are we not doing that in the intel generator this is copied from?

> > 
> > >  )
> > >  
> > > +radv_extensions = custom_target(

Could we call this radv_extensions_c, in keeping with the convention of the
other files? radv_entrypoints is kinda special since it's both a .c and .h file.

With those two things fixed:
Reviewed-by: Dylan Baker 

> > > +  'radv_extensions.c',
> > > +  input : ['radv_extensions.py', vk_api_xml],
> > > +  output : ['radv_extensions.c'],
> > > +  command : [prog_python2, '@INPUT0@', '--xml', '@INPUT1@',
> > > + '--out', '@OUTPUT@'],
> > > +)
> > > +
> > >  vk_format_table_c = custom_target(
> > >'vk_format_table.c',
> > >input : ['vk_format_table.py', 'vk_format_layout.csv'],
> > > @@ -102,7 +110,7 @@ endif
> > >  
> > >  libvulkan_radeon = shared_library(
> > >'vulkan_radeon',
> > > -  [libradv_files, radv_entrypoints, nir_opcodes_h, vk_format_table_c],
> > > +  [libradv_files, radv_entrypoints, radv_extensions, nir_opcodes_h, 
> > > vk_format_table_c],
> > >include_directories : [inc_common, inc_amd, inc_amd_common, 
> > > inc_compiler,
> > >   inc_vulkan_util, inc_vulkan_wsi],
> > >link_with : [libamd_common, libamdgpu_addrlib, libvulkan_util,
> > 
> > Other than that, this is:
> > 
> > Reviewed-by: Andres Gomez 
> > 
> > -- 
> > Br,
> > 
> > Andres


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


Re: [Mesa-dev] [PATCH] egl/dri2: disambiguate driver name

2017-10-17 Thread Kai Wasserbäch
Hey Eric,
Eric Engestrom wrote on 17.10.2017 18:31:
> On Tuesday, 2017-10-17 15:26:00 +, Kai Wasserbäch wrote:
>> So far the Mesa-internal EGL driver "dri2" returned "DRI2" as its driver
>> name. This causes confusion, because there is a kernel interface by the
>> same name where a version 3 is available.
> 
> What confusion? Do you have an example?
> 
> I'm not really opposed to a change, but I don't see the benefit,
> especially of just adding this "MESA-" prefix...

well, reading „EGL version string: 1.5 (DRI2)“ when calling eglinfo I assumed
that DRI3 was somehow not working on my setup (see
, which
I've included in the commit message). Michel then cleared up, that the interface
meant by the EGL version string is an internal Mesa interface which has nothing
to do with the more widely known X11 protocol extension.

So I thought it best to clearly separate them. Ideally this internal interface
wouldn't be called "dri" at all, but I that's probably going a bit too far.

> (Nit: please spell it "Mesa", it's a name, not an acronym :)

Ok, I'll resend in a minute with the correction to the commit message Michel
pointed out.

Cheers,
Kai


>> This change attempts to make it clearer that the "dri2" name of the Mesa
>> EGL driver has nothing to do with that kernel interface and is rather a
>> Mesa internal versioning of an interface.
>>
>> See eg. the thread beginning at
>> 
>> for an example.
>>
>> Signed-off-by: Kai Wasserbäch 



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


Re: [Mesa-dev] [PATCH] egl/wayland: Support for KHR_partial_update

2017-10-17 Thread Eric Engestrom
On 17 October 2017 17:36:06 BST, Harish Krupo  
wrote:
> Hi Emil,
> 
> Thank you for the comments, will fix the code accordingly and send a
> v2 patch.
> I have answered the question inline.
> 
> Emil Velikov  writes:
> 
> > Hi Harish,
> >
> > Overall looks great, a few comments/questions inline.
> >
> > On 13 October 2017 at 19:49, Harish Krupo
>  wrote:
> >> This passes 33/37 deqp tests related to partial_update, 4 are not
> >> supported.
> >>
> >> Signed-off-by: Harish Krupo 
> >> ---
> >>  src/egl/drivers/dri2/platform_wayland.c | 68
> -
> >>  1 file changed, 59 insertions(+), 9 deletions(-)
> >>
> >> diff --git a/src/egl/drivers/dri2/platform_wayland.c
> b/src/egl/drivers/dri2/platform_wayland.c
> >> index 14db55ca74..483d588b92 100644
> >> --- a/src/egl/drivers/dri2/platform_wayland.c
> >> +++ b/src/egl/drivers/dri2/platform_wayland.c
> >> @@ -810,15 +810,39 @@ try_damage_buffer(struct dri2_egl_surface
> *dri2_surf,
> >> }
> >> return EGL_TRUE;
> >>  }
> >> +
> >>  /**
> >> - * Called via eglSwapBuffers(), drv->API.SwapBuffers().
> >> + * Called via eglSetDamageRegionKHR(), drv->API.SetDamageRegion().
> >>   */
> >>  static EGLBoolean
> >> -dri2_wl_swap_buffers_with_damage(_EGLDriver *drv,
> >> - _EGLDisplay *disp,
> >> - _EGLSurface *draw,
> >> - const EGLint *rects,
> >> - EGLint n_rects)
> >> +wl_set_damage_region(_EGLDriver *drv,
> > Yes, it might be a bit confusing, but please stay consistent and
> call
> > this dri2_wl_set_damage_region.
> >
> >> + _EGLDisplay *dpy,
> >> + _EGLSurface *surf,
> >> + const EGLint *rects,
> >> + EGLint n_rects)
> >> +{
> >> +   struct dri2_egl_surface *dri2_surf = dri2_egl_surface(surf);
> >> +
> >> +   /* The spec doesn't mention what should be returned in case of
> >> +* failure in setting the damage buffer with the window system,
> so
> >> +* setting the damage to maximum surface area
> >> +   */
> >> +   if (!n_rects || !try_damage_buffer(dri2_surf, rects, n_rects))
> {
> >> +  wl_surface_damage(dri2_surf->wl_surface_wrapper,
> >> +0, 0, INT32_MAX, INT32_MAX);
> >> +  return EGL_TRUE;
> > Drop this return - it's only confusing the reader.
> >
> >> +   }
> >> +
> >> +   return EGL_TRUE;
> > ... since this should suffice.
> >
> >> +}
> >> +
> >> +static EGLBoolean
> >> +dri2_wl_swap_buffers_common(_EGLDriver *drv,
> >> +_EGLDisplay *disp,
> >> +_EGLSurface *draw,
> >> +const EGLint *rects,
> >> +EGLint n_rects,
> >> +EGLBoolean with_damage)
> >>  {
> >> struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
> >> struct dri2_egl_surface *dri2_surf = dri2_egl_surface(draw);
> >> @@ -876,7 +900,17 @@ dri2_wl_swap_buffers_with_damage(_EGLDriver
> *drv,
> >> /* If the compositor doesn't support damage_buffer, we
> deliberately
> >>  * ignore the damage region and post maximum damage, due to
> >>  * https://bugs.freedesktop.org/78190 */
> >> -   if (!n_rects || !try_damage_buffer(dri2_surf, rects, n_rects))
> >> +
> >> +   if (!with_damage) {
> >> +
> >> +  /* If called from swapBuffers, check if the damage region
> >> +   * is already set, if not set to full damage
> >> +   */
> >> +  if (!dri2_surf->base.SetDamageRegionCalled)
> >> + wl_surface_damage(dri2_surf->wl_surface_wrapper,
> >> +   0, 0, INT32_MAX, INT32_MAX);
> >> +   }
> >> +   else if (!n_rects || !try_damage_buffer(dri2_surf, rects,
> n_rects))
> >>wl_surface_damage(dri2_surf->wl_surface_wrapper,
> >>  0, 0, INT32_MAX, INT32_MAX);
> >>
> >> @@ -912,6 +946,20 @@ dri2_wl_swap_buffers_with_damage(_EGLDriver
> *drv,
> >> return EGL_TRUE;
> >>  }
> >>
> >> +/**
> >> + * Called via eglSwapBuffers(), drv->API.SwapBuffers().
> >> + */
> >> +static EGLBoolean
> >> +dri2_wl_swap_buffers_with_damage(_EGLDriver *drv,
> >> + _EGLDisplay *disp,
> >> + _EGLSurface *draw,
> >> + const EGLint *rects,
> >> + EGLint n_rects)
> >> +{
> >> +   return dri2_wl_swap_buffers_common(drv, disp, draw,
> >> +  rects, n_rects, EGL_TRUE);
> > Hmm what will happen if use calls:
> >
> >   eglSetDamageRegionKHR(dpy, surf, rects, n_rects)
> >   ...
> >   eglSwapBuffersWithDamageKHR(dpy, surf, NULL, 0)
> >
> >
> > eglSwapBuffersWithDamageKHR should behave identical as
> eglSwapBuffers, correct?
> > If so, the proposed code seems buggy - we 

Re: [Mesa-dev] [PATCH] egl/dri2: disambiguate driver name

2017-10-17 Thread Eric Engestrom
On Tuesday, 2017-10-17 15:26:00 +, Kai Wasserbäch wrote:
> So far the Mesa-internal EGL driver "dri2" returned "DRI2" as its driver
> name. This causes confusion, because there is a kernel interface by the
> same name where a version 3 is available.

What confusion? Do you have an example?

I'm not really opposed to a change, but I don't see the benefit,
especially of just adding this "MESA-" prefix...

(Nit: please spell it "Mesa", it's a name, not an acronym :)

> 
> This change attempts to make it clearer that the "dri2" name of the Mesa
> EGL driver has nothing to do with that kernel interface and is rather a
> Mesa internal versioning of an interface.
> 
> See eg. the thread beginning at
> 
> for an example.
> 
> Signed-off-by: Kai Wasserbäch 
> ---
>  src/egl/drivers/dri2/egl_dri2.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
> index 77f09271f0..3991dfc84d 100644
> --- a/src/egl/drivers/dri2/egl_dri2.c
> +++ b/src/egl/drivers/dri2/egl_dri2.c
> @@ -3260,7 +3260,7 @@ _eglBuiltInDriver(void)
> dri2_drv->base.API.GLInteropExportObject = dri2_interop_export_object;
> dri2_drv->base.API.DupNativeFenceFDANDROID = dri2_dup_native_fence_fd;
>  
> -   dri2_drv->base.Name = "DRI2";
> +   dri2_drv->base.Name = "MESA-DRI2";
>  
> return _drv->base;
>  }
> -- 
> 2.14.2
> 
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 2/2] configure: enable the OpenCL ICD by default

2017-10-17 Thread Aaron Watry
On Mon, Oct 16, 2017 at 10:40 AM, Emil Velikov  wrote:
> From: Emil Velikov 
>
> Nearly all the distributions* that build Mesa OpenCL, enable the ICD.
> Since building a non-ICD driver has the chance of conflicting with
> existing OpenCL binary (libOpenCL.so).
>
> Furthermore, some applications expect the library to provide
> annotated/versioned symbols.
>
> https://lists.freedesktop.org/archives/mesa-dev/2017-September/171093.html
>
> *Fedora, Suse, Arch, Debian, Ubuntu, FreeBSD use the ICD
> Gentoo manages the conflicting files via eselect.
>
> Cc: Aaron Watry 

Series is Reviewed-By: Aaron Watry 

> Cc: Francisco Jerez 
> Cc: Matt Turner 
> Cc: Jan Vesely 
> Signed-off-by: Emil Velikov 
> ---
>  Makefile.am  | 1 +
>  configure.ac | 4 ++--
>  2 files changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/Makefile.am b/Makefile.am
> index a4f49d3d332..ec432b471d5 100644
> --- a/Makefile.am
> +++ b/Makefile.am
> @@ -35,6 +35,7 @@ AM_DISTCHECK_CONFIGURE_FLAGS = \
> --enable-glx-tls \
> --enable-nine \
> --enable-opencl \
> +   --enable-opencl-icd \
> --enable-opengl \
> --enable-va \
> --enable-vdpau \
> diff --git a/configure.ac b/configure.ac
> index 62d33a1941c..9728675ccb2 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -1269,9 +1269,9 @@ AC_ARG_ENABLE([opencl],
>  AC_ARG_ENABLE([opencl_icd],
> [AS_HELP_STRING([--enable-opencl-icd],
>[Build an OpenCL ICD library to be loaded by an ICD implementation
> -   @<:@default=disabled@:>@])],
> +   @<:@default=enabled@:>@])],
>  [enable_opencl_icd="$enableval"],
> -[enable_opencl_icd=no])
> +[enable_opencl_icd=yes])
>
>  AC_ARG_ENABLE([gallium-tests],
>  [AS_HELP_STRING([--enable-gallium-tests],
> --
> 2.14.1
>
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH v4 0/2] build system: Unify c++11 detection and used [was: configure+mesa/st:check -std=c++11 support and enable tests accordingly]

2017-10-17 Thread Chuck Atkins
>
> I also think adding a test for each C++11 feature used in the code is
>
too tedious, regardless of the build system, and it would really need a
> dedicated maintainer.
>

Certainly.  Rather than checking for everything, I think a code snippet
that just includes a few c++11-only headers would be sufficient and just
assume if those are there then you have a working c++11 std library.
That's all we're doing with the std=c++11 check anyways; i.e. we're
assuming that there's no need to specifically check for support of
range-for loops and lambda expressions separately.  Partial standard
implementation is less of an issue these days I think than in the early
C++11 years.

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


Re: [Mesa-dev] [PATCH] egl/dri2: disambiguate driver name

2017-10-17 Thread Kai Wasserbäch
Michel Dänzer wrote on 17.10.2017 17:42:
> On 17/10/17 05:26 PM, Kai Wasserbäch wrote:
>> So far the Mesa-internal EGL driver "dri2" returned "DRI2" as its driver
>> name. This causes confusion, because there is a kernel interface by the
>> same name where a version 3 is available.
>>
>> This change attempts to make it clearer that the "dri2" name of the Mesa
>> EGL driver has nothing to do with that kernel interface and is rather a
>> Mesa internal versioning of an interface.
> 
> DRI3 is an X11 protocol extension, not a kernel interface.

Ihrg, yes. Total brainfart there. Should I resend or can this be fixed when this
patch might be commited? As I do not have commit access somebody else would need
to do it then.

Cheers,
Kai



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


Re: [Mesa-dev] [PATCH 16/16] radeonsi: if there's just const buffer 0, set it in place of CONST/SSBO pointer

2017-10-17 Thread Marek Olšák
On Tue, Oct 17, 2017 at 2:25 PM, Nicolai Hähnle  wrote:
> On 13.10.2017 14:04, Marek Olšák wrote:
>>
>> From: Marek Olšák 
>>
>> SI_SGPR_CONST_AND_SHADER_BUFFERS now contains the pointer to const buffer
>> 0
>> if there is no other buffer there.
>>
>> Benefits:
>> - there is no constbuf descriptor upload and shader load
>>
>> It's assumed that all constant addresses are within bounds. Non-constant
>> addresses are clamped against the last declared CONST variable.
>> This only works if the state tracker ensures the bound constant buffer
>> matches what the shader needs.
>>
>> Once we get 32-bit pointers, we can only do this for user constant buffers
>> where the driver is in charge of the upload so that it can guarantee a
>> 32-bit
>> address.
>>
>> The real performance benefit might not be measurable.
>>
>> These apps get 100% theoretical benefit in all shaders (except where
>> noted):
>> - antichamber
>> - barman arkham origins
>> - borderlands 2
>> - borderlands pre-sequel
>> - brutal legend
>> - civilization BE
>> - CS:GO
>> - deadcore
>> - dota 2 -- most shaders
>> - europa universalis
>> - grid autosport -- most shaders
>> - left 4 dead 2
>> - legend of grimrock
>> - life is strange
>> - payday 2
>> - portal
>> - rocket league
>> - serious sam 3 bfe
>> - talos principle
>> - team fortress 2
>> - thea
>> - unigine heaven
>> - unigine valley -- also sanctuary and tropics
>> - wasteland 2
>> - xcom: enemy unknown & enemy within
>> - tesseract
>> - unity (engine)
>>
>> Changed stats only:
>>  SGPRS: 2059998 -> 2086238 (1.27 %)
>>  VGPRS: 1626888 -> 1626904 (0.00 %)
>>  Spilled SGPRs: 7902 -> 7865 (-0.47 %)
>>  Code Size: 60924520 -> 60982660 (0.10 %) bytes
>>  Max Waves: 374539 -> 374526 (-0.00 %)
>> ---
>>   src/gallium/drivers/radeonsi/si_descriptors.c | 23 +++--
>>   src/gallium/drivers/radeonsi/si_shader.c  | 72
>> +++
>>   src/gallium/drivers/radeonsi/si_shader.h  |  2 +-
>>   src/gallium/drivers/radeonsi/si_state.h   |  3 ++
>>   4 files changed, 87 insertions(+), 13 deletions(-)
>>
>> diff --git a/src/gallium/drivers/radeonsi/si_descriptors.c
>> b/src/gallium/drivers/radeonsi/si_descriptors.c
>> index 0c1fca8..da6efa8 100644
>> --- a/src/gallium/drivers/radeonsi/si_descriptors.c
>> +++ b/src/gallium/drivers/radeonsi/si_descriptors.c
>> @@ -119,20 +119,21 @@ static void si_init_descriptor_list(uint32_t
>> *desc_list,
>> static void si_init_descriptors(struct si_descriptors *desc,
>> unsigned shader_userdata_index,
>> unsigned element_dw_size,
>> unsigned num_elements)
>>   {
>> desc->list = CALLOC(num_elements, element_dw_size * 4);
>> desc->element_dw_size = element_dw_size;
>> desc->num_elements = num_elements;
>> desc->shader_userdata_offset = shader_userdata_index * 4;
>> +   desc->slot_index_to_bind_directly = -1;
>>   }
>> static void si_release_descriptors(struct si_descriptors *desc)
>>   {
>> r600_resource_reference(>buffer, NULL);
>> FREE(desc->list);
>>   }
>> static bool si_upload_descriptors(struct si_context *sctx,
>>   struct si_descriptors *desc)
>> @@ -141,20 +142,34 @@ static bool si_upload_descriptors(struct si_context
>> *sctx,
>> unsigned first_slot_offset = desc->first_active_slot * slot_size;
>> unsigned upload_size = desc->num_active_slots * slot_size;
>> /* Skip the upload if no shader is using the descriptors.
>> dirty_mask
>>  * will stay dirty and the descriptors will be uploaded when there
>> is
>>  * a shader using them.
>>  */
>> if (!upload_size)
>> return true;
>>   + /* If there is just one active descriptor, bind it directly. */
>> +   if ((int)desc->first_active_slot ==
>> desc->slot_index_to_bind_directly &&
>> +   desc->num_active_slots == 1) {
>> +   uint32_t *descriptor =
>> >list[desc->slot_index_to_bind_directly *
>> +  desc->element_dw_size];
>> +
>> +   /* The buffer is already in the buffer list. */
>> +   r600_resource_reference(>buffer, NULL);
>> +   desc->gpu_list = NULL;
>> +   desc->gpu_address =
>> si_desc_extract_buffer_address(descriptor);
>> +   si_mark_atom_dirty(sctx, >shader_pointers.atom);
>> +   return true;
>> +   }
>> +
>> uint32_t *ptr;
>> int buffer_offset;
>> u_upload_alloc(sctx->b.b.const_uploader, 0, upload_size,
>>si_optimal_tcc_alignment(sctx, upload_size),
>>(unsigned*)_offset,
>>(struct pipe_resource**)>buffer,
>>(void**));
>> if (!desc->buffer) {
>> desc->gpu_address = 0;
>>   

Re: [Mesa-dev] [PATCH] egl/wayland: Support for KHR_partial_update

2017-10-17 Thread Harish Krupo

Eric Engestrom  writes:

> On Monday, 2017-10-16 13:54:25 +, Emil Velikov wrote:
>> Hi Harish,
>> 
>> Overall looks great, a few comments/questions inline.
>> 
>
> I agree with everything Emil said :)
>
>> On 13 October 2017 at 19:49, Harish Krupo  wrote:
>> > This passes 33/37 deqp tests related to partial_update, 4 are not
>> > supported.
>
> Which 4 are not supported? It's definitely not obvious :)
> I'm guessing dEQP-EGL.functional.negative_partial_update.not_current_surface2
> isn't supported (pbuffer), but I can't tell which other ones would be
> unsupported.
>

Sorry, should have posted it.
Here are the ones not supported:
dEQP-EGL.functional.negative_partial_update.not_postable_surface
dEQP-EGL.functional.negative_partial_update.not_current_surface
dEQP-EGL.functional.negative_partial_update.buffer_preserved
dEQP-EGL.functional.negative_partial_update.not_current_surface2
Reason: No matching egl config found.

I will update the commit in v2.

>> >
>> > Signed-off-by: Harish Krupo 
>> > ---
>> >  src/egl/drivers/dri2/platform_wayland.c | 68 
>> > -
>> >  1 file changed, 59 insertions(+), 9 deletions(-)
>> >
>> > diff --git a/src/egl/drivers/dri2/platform_wayland.c 
>> > b/src/egl/drivers/dri2/platform_wayland.c
>> > index 14db55ca74..483d588b92 100644
>> > --- a/src/egl/drivers/dri2/platform_wayland.c
>> > +++ b/src/egl/drivers/dri2/platform_wayland.c
>> > @@ -810,15 +810,39 @@ try_damage_buffer(struct dri2_egl_surface *dri2_surf,
>> > }
>> > return EGL_TRUE;
>> >  }
>> > +
>> >  /**
>> > - * Called via eglSwapBuffers(), drv->API.SwapBuffers().
>> > + * Called via eglSetDamageRegionKHR(), drv->API.SetDamageRegion().
>> >   */
>> >  static EGLBoolean
>> > -dri2_wl_swap_buffers_with_damage(_EGLDriver *drv,
>> > - _EGLDisplay *disp,
>> > - _EGLSurface *draw,
>> > - const EGLint *rects,
>> > - EGLint n_rects)
>> > +wl_set_damage_region(_EGLDriver *drv,
>> Yes, it might be a bit confusing, but please stay consistent and call
>> this dri2_wl_set_damage_region.
>> 
>> > + _EGLDisplay *dpy,
>> > + _EGLSurface *surf,
>> > + const EGLint *rects,
>> > + EGLint n_rects)
>> > +{
>> > +   struct dri2_egl_surface *dri2_surf = dri2_egl_surface(surf);
>> > +
>> > +   /* The spec doesn't mention what should be returned in case of
>> > +* failure in setting the damage buffer with the window system, so
>> > +* setting the damage to maximum surface area
>> > +   */
>> > +   if (!n_rects || !try_damage_buffer(dri2_surf, rects, n_rects)) {
>> > +  wl_surface_damage(dri2_surf->wl_surface_wrapper,
>> > +0, 0, INT32_MAX, INT32_MAX);
>> > +  return EGL_TRUE;
>> Drop this return - it's only confusing the reader.
>> 
>> > +   }
>> > +
>> > +   return EGL_TRUE;
>> ... since this should suffice.
>> 
>> > +}
>> > +
>> > +static EGLBoolean
>> > +dri2_wl_swap_buffers_common(_EGLDriver *drv,
>> > +_EGLDisplay *disp,
>> > +_EGLSurface *draw,
>> > +const EGLint *rects,
>> > +EGLint n_rects,
>> > +EGLBoolean with_damage)
>> >  {
>> > struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
>> > struct dri2_egl_surface *dri2_surf = dri2_egl_surface(draw);
>> > @@ -876,7 +900,17 @@ dri2_wl_swap_buffers_with_damage(_EGLDriver *drv,
>> > /* If the compositor doesn't support damage_buffer, we deliberately
>> >  * ignore the damage region and post maximum damage, due to
>> >  * https://bugs.freedesktop.org/78190 */
>> > -   if (!n_rects || !try_damage_buffer(dri2_surf, rects, n_rects))
>> > +
>> > +   if (!with_damage) {
>> > +
>> > +  /* If called from swapBuffers, check if the damage region
>> > +   * is already set, if not set to full damage
>> > +   */
>> > +  if (!dri2_surf->base.SetDamageRegionCalled)
>> > + wl_surface_damage(dri2_surf->wl_surface_wrapper,
>> > +   0, 0, INT32_MAX, INT32_MAX);
>> > +   }
>> > +   else if (!n_rects || !try_damage_buffer(dri2_surf, rects, n_rects))
>> >wl_surface_damage(dri2_surf->wl_surface_wrapper,
>> >  0, 0, INT32_MAX, INT32_MAX);
>> >
>> > @@ -912,6 +946,20 @@ dri2_wl_swap_buffers_with_damage(_EGLDriver *drv,
>> > return EGL_TRUE;
>> >  }
>> >
>> > +/**
>> > + * Called via eglSwapBuffers(), drv->API.SwapBuffers().
>> > + */
>> > +static EGLBoolean
>> > +dri2_wl_swap_buffers_with_damage(_EGLDriver *drv,
>> > + _EGLDisplay *disp,
>> > + _EGLSurface *draw,
>> > + const EGLint *rects,
>> > +

Re: [Mesa-dev] [PATCH mesa] meson: add missing radv_extensions.c generation for libvulkan_radeon

2017-10-17 Thread Eric Engestrom
On Tuesday, 2017-10-17 14:55:06 +, Andres Gomez wrote:
> On Tue, 2017-10-17 at 12:00 +0100, Eric Engestrom wrote:
> > Signed-off-by: Eric Engestrom 
> 
> I would add a line like:
> 
> fixes: 17201a2eb0b (radv: port to using updated anv entrypoint/extension 
> generator.)

Thanks, I forgot to do that.

> 
> > ---
> >  src/amd/vulkan/meson.build | 10 +-
> >  1 file changed, 9 insertions(+), 1 deletion(-)
> > 
> > diff --git a/src/amd/vulkan/meson.build b/src/amd/vulkan/meson.build
> > index a5a4f81352807beac92d..6a416d988674504281c6 100644
> > --- a/src/amd/vulkan/meson.build
> > +++ b/src/amd/vulkan/meson.build
> > @@ -26,6 +26,14 @@ radv_entrypoints = custom_target(
> >   '--outdir', meson.current_build_dir()],
> 
> Since radv_entrypoints_gen.py depends on it and it is also explicit in
> the Makefile.am, I think we should also add something like this here:
> 
> depend_files : files('radv_extensions.py'),

I'll send a separate patch for this, as it's unrelated to the break
fixed here, but good catch, I didn't think to check inside the scripts.

Dylan, meson tracks includes in C files automatically, right? As in,
a file including foo.h would get rebuilt if foo.h is touched, right?
Any idea if the same is/can be done for python files?

> 
> >  )
> >  
> > +radv_extensions = custom_target(
> > +  'radv_extensions.c',
> > +  input : ['radv_extensions.py', vk_api_xml],
> > +  output : ['radv_extensions.c'],
> > +  command : [prog_python2, '@INPUT0@', '--xml', '@INPUT1@',
> > + '--out', '@OUTPUT@'],
> > +)
> > +
> >  vk_format_table_c = custom_target(
> >'vk_format_table.c',
> >input : ['vk_format_table.py', 'vk_format_layout.csv'],
> > @@ -102,7 +110,7 @@ endif
> >  
> >  libvulkan_radeon = shared_library(
> >'vulkan_radeon',
> > -  [libradv_files, radv_entrypoints, nir_opcodes_h, vk_format_table_c],
> > +  [libradv_files, radv_entrypoints, radv_extensions, nir_opcodes_h, 
> > vk_format_table_c],
> >include_directories : [inc_common, inc_amd, inc_amd_common, inc_compiler,
> >   inc_vulkan_util, inc_vulkan_wsi],
> >link_with : [libamd_common, libamdgpu_addrlib, libvulkan_util,
> 
> Other than that, this is:
> 
> Reviewed-by: Andres Gomez 
> 
> -- 
> Br,
> 
> Andres
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] Upstream support for FreeSync / Adaptive Sync

2017-10-17 Thread Daniel Vetter
On Tue, Oct 17, 2017 at 03:46:24PM +0200, Michel Dänzer wrote:
> On 17/10/17 02:22 PM, Daniel Vetter wrote:
> > On Tue, Oct 17, 2017 at 12:28:17PM +0200, Michel Dänzer wrote:
> >> On 17/10/17 11:34 AM, Nicolai Hähnle wrote:
> > 
> >>> Common sense suggests that there need to be two side to FreeSync / VESA
> >>> Adaptive Sync support:
> >>>
> >>> 1. Query the display capabilities. This means querying minimum / maximum
> >>> refresh duration, plus possibly a query for when the earliest/latest
> >>> timing of the *next* refresh.
> >>>
> >>> 2. Signal desired present time. This means passing a target timer value
> >>> instead of a target vblank count, e.g. something like this for the KMS
> >>> interface:
> >>>
> >>>   int drmModePageFlipTarget64(int fd, uint32_t crtc_id, uint32_t fb_id,
> >>>   uint32_t flags, void *user_data,
> >>>   uint64_t target);
> >>>
> >>>   + a flag to indicate whether target is the vblank count or the
> >>> CLOCK_MONOTONIC (?) time in ns.
> >>
> >> drmModePageFlip(Target) is part of the pre-atomic KMS API, but adapative
> >> sync should probably only be supported via the atomic API, presumably
> >> via output properties.
> > 
> > +1
> > 
> > At least now that DC is on track to land properly, and you want to do this
> > for DC-only anyway there's no reason to pimp the legacy interfaces
> > further. And atomic is soo much easier to extend.
> > 
> > The big question imo is where we need to put the flag on the kms side,
> > since freesync is not just about presenting earlier, but also about
> > presenting later. But for backwards compat we can't stretch the refresh
> > rate by default for everyone, or clients that rely on high precision
> > timestamps and regular refresh will get a bad surprise.
> 
> The idea described above is that adaptive sync would be used for flips
> with a target timestamp. Apps which don't want to use adaptive sync
> wouldn't set a target timestamp.
> 
> 
> > I think a boolean enable_freesync property is probably what we want, which
> > enables freesync for as long as it's set.
> 
> The question then becomes under what circumstances the property is (not)
> set. Not sure offhand this will actually solve any problem, or just push
> it somewhere else.

I thought that's what the driconf switch is for, with a policy of "please
schedule asap" instead of a specific timestamp.

> > Finally I'm not sure we want to insist on a target time for freesync. At
> > least as far as I understand things you just want "as soon as possible".
> > This might change with some of the VK/EGL/GLX extensions where you
> > specify a precise timing (media playback). But that needs a bit more work
> > to make it happen I think, so perhaps better to postpone.
> 
> I don't see why. There's an obvious use case for this now, for video
> playback. At least VDPAU already has target timestamps for this.
> 
> 
> > Also note that right now no driver expect amdgpu has support for a target
> > vblank on a flip. That's imo another reason for not requiring target
> > support for at least basic freesync support.
> 
> I think that's a bad reason. :) Adding it for atomic drivers shouldn't
> be that hard.

I thought the primary reason for adaptive sync is the adaptive frame rate
to cope with the occasional stall in games. If the intended use-case is
vr/media, then I agree going with timestamps from the beginning makes
sense. That still leaves the "schedule asap, with some leeway" mode. Or is
that (no longer) something we want?
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH v2 8/8] egl/wayland: add dri2_wl_free_buffers() helper

2017-10-17 Thread Emil Velikov
On 17 October 2017 at 15:07, Eric Engestrom  wrote:
> On Friday, 2017-10-06 21:38:35 +, Gwan-gyeong Mun wrote:
>> This deduplicates free routines of color_buffers array.
>>
>> Signed-off-by: Mun Gwan-gyeong 
>> ---
>>  src/egl/drivers/dri2/platform_wayland.c | 60 
>> +
>>  1 file changed, 31 insertions(+), 29 deletions(-)
>>
>> diff --git a/src/egl/drivers/dri2/platform_wayland.c 
>> b/src/egl/drivers/dri2/platform_wayland.c
>> index 1518a24b7c..cfe474cf58 100644
>> --- a/src/egl/drivers/dri2/platform_wayland.c
>> +++ b/src/egl/drivers/dri2/platform_wayland.c
>> @@ -253,6 +253,35 @@ dri2_wl_create_pixmap_surface(_EGLDriver *drv, 
>> _EGLDisplay *disp,
>> return NULL;
>>  }
>>
>> +static void
>> +dri2_wl_free_buffers(struct dri2_egl_surface *dri2_surf, bool check_lock)
>> +{
>> +   struct dri2_egl_display *dri2_dpy =
>> +  dri2_egl_display(dri2_surf->base.Resource.Display);
>> +
>> +   for (int i = 0; i < ARRAY_SIZE(dri2_surf->color_buffers); i++) {
>> +  if (dri2_surf->color_buffers[i].native_buffer) {
>> + if (check_lock && !dri2_surf->color_buffers[i].locked)
>> +wl_buffer_destroy((struct wl_buffer 
>> *)dri2_surf->color_buffers[i].native_buffer);
>> + else
>> +wl_buffer_destroy((struct wl_buffer 
>> *)dri2_surf->color_buffers[i].native_buffer);
>
> Both branches have the same code, should be a hint :P
> I think this should be:
>
>if (!check_lock || !dri2_surf->color_buffers[i].locked) {
>   wl_buffer_destroy((struct wl_buffer 
> *)dri2_surf->color_buffers[i].native_buffer);
Drop the unneeded cast?

>   dri2_surf->color_buffers[i].native_buffer = NULL;
>}
>
> without an `else`. You also want to remove the `native_buffer = NULL`
> from below, to avoid leaking locked buffers :)
>
I'm not sure if that's an actual leak. In either case, I'd leave that
as follow-up.

There are a few of instances where this can be used:
 - dri2_wl_destroy_surface, done
 - dri2_wl_release_buffers, done
 - update_buffers, todo
-  swrast_update_buffers, todo

Just an idea that came to mind, don't bother if you don't want to.
 - keep the platform specific buffer destroy (wl_buffer_destroy here)
in the platform code moving the rest as helper
 - plug the platform_android/platform_drm leak (?) by using the helper

Patches 5-7 look ok and are
Reviewed-by: Emil Velikov 

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


  1   2   >