Re: [Mesa-dev] [PATCH 5/5] i965/clear: Don't perform redundant depth clears

2017-07-23 Thread Jason Ekstrand
I just remembered that we never merged these.  IIRC, it's about 3% on 
Manhattan.



On June 14, 2017 6:54:41 PM Jason Ekstrand  wrote:


We already have this little optimization for color clears.  Now that
we're actually tracking whether or not a slice has any fast-clear
blocks, It's easy enough to add for depth clears too.
---
 src/mesa/drivers/dri/i965/brw_clear.c | 34 ---
 src/mesa/drivers/dri/i965/intel_mipmap_tree.c | 14 ++-
 2 files changed, 44 insertions(+), 4 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_clear.c 
b/src/mesa/drivers/dri/i965/brw_clear.c

index 99ddc4e..5fa4ae7 100644
--- a/src/mesa/drivers/dri/i965/brw_clear.c
+++ b/src/mesa/drivers/dri/i965/brw_clear.c
@@ -200,9 +200,37 @@ brw_fast_clear_depth(struct gl_context *ctx)
   mt->fast_clear_color.f32[0] = ctx->Depth.Clear;
}

-   intel_hiz_exec(brw, mt, depth_irb->mt_level,
-  depth_irb->mt_layer, num_layers,
-  BLORP_HIZ_OP_DEPTH_CLEAR);
+   bool need_clear = false;
+   for (unsigned a = 0; a < num_layers; a++) {
+  enum isl_aux_state aux_state =
+ intel_miptree_get_aux_state(mt, depth_irb->mt_level,
+ depth_irb->mt_layer + a);
+
+  if (aux_state != ISL_AUX_STATE_CLEAR) {
+ need_clear = true;
+ break;
+  }
+   }
+
+   if (!need_clear) {
+  /* If all of the layers we intend to clear are already in the clear
+   * state then simply updating the miptree fast clear value is sufficient
+   * to change their clear value.
+   */
+  return true;
+   }
+
+   for (unsigned a = 0; a < num_layers; a++) {
+  enum isl_aux_state aux_state =
+ intel_miptree_get_aux_state(mt, depth_irb->mt_level,
+ depth_irb->mt_layer + a);
+
+  if (aux_state != ISL_AUX_STATE_CLEAR) {
+ intel_hiz_exec(brw, mt, depth_irb->mt_level,
+depth_irb->mt_layer + a, 1,
+BLORP_HIZ_OP_DEPTH_CLEAR);
+  }
+   }

/* Now, the HiZ buffer contains data that needs to be resolved to the depth
 * buffer.
diff --git a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c 
b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c

index c19d2d5..8b893dd 100644
--- a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
+++ b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
@@ -2217,8 +2217,20 @@ intel_miptree_prepare_hiz_access(struct brw_context 
*brw,

  uint32_t level, uint32_t layer,
  bool hiz_supported, bool fast_clear_supported)
 {
+   enum isl_aux_state aux_state = intel_miptree_get_aux_state(mt, level, 
layer);

+
+   /* On Sandy Bridge, any usage of depth with HiZ enabled is liable to flush
+* out clear color blocks.  If the slice is in the clear state, it should
+* now be considered to be in the compressed with clear state.
+*/
+   if (brw->gen == 6 && aux_state == ISL_AUX_STATE_CLEAR && hiz_supported) {
+  assert(fast_clear_supported);
+  intel_miptree_set_aux_state(brw, mt, level, layer, 1,
+  ISL_AUX_STATE_COMPRESSED_CLEAR);
+   }
+
enum blorp_hiz_op hiz_op = BLORP_HIZ_OP_NONE;
-   switch (intel_miptree_get_aux_state(mt, level, layer)) {
+   switch (aux_state) {
case ISL_AUX_STATE_CLEAR:
case ISL_AUX_STATE_COMPRESSED_CLEAR:
   if (!hiz_supported || !fast_clear_supported)
--
2.5.0.400.gff86faf




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


Re: [Mesa-dev] [PATCH 1/2] egl/android: remove HAL_PIXEL_FORMAT_BGRA_8888 support

2017-07-23 Thread Tomasz Figa
On Mon, Jul 24, 2017 at 1:00 PM, Tomasz Figa  wrote:
> On Wed, Jul 12, 2017 at 1:34 AM, Rob Herring  wrote:
>> On Tue, Jul 11, 2017 at 9:34 AM, Tomasz Figa  wrote:
>>> On Tue, Jul 11, 2017 at 11:16 PM, Rob Herring  wrote:
 On Tue, Jul 11, 2017 at 8:27 AM, Emil Velikov  
 wrote:
> From: Emil Velikov 
>
> As said in the EGL_KHR_platform_android extensions
>
> For each EGLConfig that belongs to the Android platform, the
> EGL_NATIVE_VISUAL_ID attribute is an Android window format, such as
> WINDOW_FORMAT_RGBA_.
>
> Although it should be applicable overall.
>
> Even though we use HAL_PIXEL_FORMAT here, those are numerically
> identical to the  WINDOW_FORMAT_ and AHARDWAREBUFFER_FORMAT_ ones.
>
> Barring the said format of course. That one is only listed in HAL.
>
> Keep in mind that even if we try to use the said format, you'll get
> caught by droid_create_surface(). The function compares the format of
> the underlying window, against the NATIVE_VISUAL_ID of the config.
>
> Unfortunatelly it only prints a warning, rather than error out, likely
> leading to visual corruption.
>
> While SDL will even call ANativeWindow_setBuffersGeometry() with the
> wrong format, and conviniently ignore the [expected] failure.
>
> Cc: mesa-sta...@lists.freedesktop.org
> Cc: Chad Versace 
> Cc: Tomasz Figa 
> Signed-off-by: Emil Velikov 
> ---
> I'm about 99.99% sure the above is correct, but I haven't tested it.

 Isn't this going to break if there's no driver support for RGBA/RGBX
 which is the case for stable (and master for gallium drvs).
>>>
>>> First of all, Android hardcodes HAL_PIXEL_FORMAT_RGBA_ in a number
>>> of places, which means that those users use a patched Android. However
>>> I'm not sure if we can just break them like this. I'll leave it to you
>>> guys, though.
>>
>> Yes, patched to work around mesa's lack of RGBA/X support. Not sure
>> why they went this route. Maybe RGBA/X support in mesa was attempted
>> before.
>>
>>> Other than that, CTS seems to require only RGBA_ and RGB_565, so
>>> this change is not going to affect compliance with unpatched Android.
>>
>> Okay, good to know.
>
> I just found some interesting evidence that proves we should go
> forward with this patch:
>
> https://android.googlesource.com/platform/frameworks/native/+/master/opengl/libs/EGL/eglApi.cpp#455
>
> Basically this is the EGL wrapper that is used for everything on
> Android. Whenever eglCreateWindowSurface() is called, it goes through
> the linked function first, which explicitly limits all the supported
> formats to RGBA_, RGBX_ and RGB_565, by forcing one of those
> matching EGL config's component sizes on the given native window (the
> native_window_set_buffers_format() call).
>
> I don't know how this worked for me before, but essentially it makes
> it impossible to pass dEQP-EGL tests with RGBA (as per EGL config
> component widths only) window surface, because it's impossible to have
> eglCreateWindowSurface() accept BGRA_ and in result the config
> doesn't match the surface, which gives swapped channels in the
> buffers.
>
> Since the support for Gallium landed already, can we move forward with
> this patch?
>
> (If it's worth anything:)
> Acked-by: Tomasz Figa 

Ah, just one side note (should have checked on the patch again,
instead of relying on my apparently already incomplete memories). We
should keep EGL image support for the format, as it is surprisingly
used for some camera use cases, at least on some of our platforms. So
the only thing that should go away is the array item in
droid_add_configs_for_visuals().

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


Re: [Mesa-dev] [PATCH 1/2] egl/android: remove HAL_PIXEL_FORMAT_BGRA_8888 support

2017-07-23 Thread Tomasz Figa
On Wed, Jul 12, 2017 at 1:34 AM, Rob Herring  wrote:
> On Tue, Jul 11, 2017 at 9:34 AM, Tomasz Figa  wrote:
>> On Tue, Jul 11, 2017 at 11:16 PM, Rob Herring  wrote:
>>> On Tue, Jul 11, 2017 at 8:27 AM, Emil Velikov  
>>> wrote:
 From: Emil Velikov 

 As said in the EGL_KHR_platform_android extensions

 For each EGLConfig that belongs to the Android platform, the
 EGL_NATIVE_VISUAL_ID attribute is an Android window format, such as
 WINDOW_FORMAT_RGBA_.

 Although it should be applicable overall.

 Even though we use HAL_PIXEL_FORMAT here, those are numerically
 identical to the  WINDOW_FORMAT_ and AHARDWAREBUFFER_FORMAT_ ones.

 Barring the said format of course. That one is only listed in HAL.

 Keep in mind that even if we try to use the said format, you'll get
 caught by droid_create_surface(). The function compares the format of
 the underlying window, against the NATIVE_VISUAL_ID of the config.

 Unfortunatelly it only prints a warning, rather than error out, likely
 leading to visual corruption.

 While SDL will even call ANativeWindow_setBuffersGeometry() with the
 wrong format, and conviniently ignore the [expected] failure.

 Cc: mesa-sta...@lists.freedesktop.org
 Cc: Chad Versace 
 Cc: Tomasz Figa 
 Signed-off-by: Emil Velikov 
 ---
 I'm about 99.99% sure the above is correct, but I haven't tested it.
>>>
>>> Isn't this going to break if there's no driver support for RGBA/RGBX
>>> which is the case for stable (and master for gallium drvs).
>>
>> First of all, Android hardcodes HAL_PIXEL_FORMAT_RGBA_ in a number
>> of places, which means that those users use a patched Android. However
>> I'm not sure if we can just break them like this. I'll leave it to you
>> guys, though.
>
> Yes, patched to work around mesa's lack of RGBA/X support. Not sure
> why they went this route. Maybe RGBA/X support in mesa was attempted
> before.
>
>> Other than that, CTS seems to require only RGBA_ and RGB_565, so
>> this change is not going to affect compliance with unpatched Android.
>
> Okay, good to know.

I just found some interesting evidence that proves we should go
forward with this patch:

https://android.googlesource.com/platform/frameworks/native/+/master/opengl/libs/EGL/eglApi.cpp#455

Basically this is the EGL wrapper that is used for everything on
Android. Whenever eglCreateWindowSurface() is called, it goes through
the linked function first, which explicitly limits all the supported
formats to RGBA_, RGBX_ and RGB_565, by forcing one of those
matching EGL config's component sizes on the given native window (the
native_window_set_buffers_format() call).

I don't know how this worked for me before, but essentially it makes
it impossible to pass dEQP-EGL tests with RGBA (as per EGL config
component widths only) window surface, because it's impossible to have
eglCreateWindowSurface() accept BGRA_ and in result the config
doesn't match the surface, which gives swapped channels in the
buffers.

Since the support for Gallium landed already, can we move forward with
this patch?

(If it's worth anything:)
Acked-by: Tomasz Figa 

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


[Mesa-dev] [PATCH 5/5] i965: enable STD430 packing by default on IVB+

2017-07-23 Thread Timothy Arceri
---
 src/mesa/drivers/dri/i965/brw_context.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/src/mesa/drivers/dri/i965/brw_context.c 
b/src/mesa/drivers/dri/i965/brw_context.c
index d0b22d4..426adfa 100644
--- a/src/mesa/drivers/dri/i965/brw_context.c
+++ b/src/mesa/drivers/dri/i965/brw_context.c
@@ -675,6 +675,12 @@ brw_initialize_context_constants(struct brw_context *brw)
 
/* OES_primitive_bounding_box */
ctx->Const.NoPrimitiveBoundingBoxOutput = true;
+
+   /* TODO: we should be able to use STD430 packing by default on all hardware
+* but some CTS tests currently fail on SNB when this is enabled.
+*/
+   if (brw->gen >= 7)
+  ctx->Const.UseSTD430AsDefaultPacking = true;
 }
 
 static void
-- 
2.9.4

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


[Mesa-dev] [PATCH 4/5] glsl: pass UseSTD430AsDefaultPacking to where it will be used

2017-07-23 Thread Timothy Arceri
Here we also make use of the UseSTD430AsDefaultPacking constant
and call the new get_internal_ifc_packing() helper.
---
 src/compiler/glsl/ir_optimization.h   |  2 +-
 src/compiler/glsl/link_uniform_blocks.cpp | 17 +++
 src/compiler/glsl/link_uniforms.cpp   | 50 ---
 src/compiler/glsl/link_varyings.cpp   |  2 +-
 src/compiler/glsl/linker.cpp  | 20 -
 src/compiler/glsl/linker.h|  5 ++--
 src/compiler/glsl/lower_buffer_access.h   |  3 ++
 src/compiler/glsl/lower_ubo_reference.cpp | 33 +++-
 src/mesa/program/ir_to_mesa.cpp   |  3 +-
 9 files changed, 92 insertions(+), 43 deletions(-)

diff --git a/src/compiler/glsl/ir_optimization.h 
b/src/compiler/glsl/ir_optimization.h
index 82cdac9..573ddb4 100644
--- a/src/compiler/glsl/ir_optimization.h
+++ b/src/compiler/glsl/ir_optimization.h
@@ -146,7 +146,7 @@ bool lower_packing_builtins(exec_list *instructions, int 
op_mask);
 void lower_shared_reference(struct gl_linked_shader *shader,
 unsigned *shared_size);
 void lower_ubo_reference(struct gl_linked_shader *shader,
- bool clamp_block_indices);
+ bool clamp_block_indices, bool use_std430_as_default);
 void lower_packed_varyings(void *mem_ctx,
unsigned locations_used,
const uint8_t *components,
diff --git a/src/compiler/glsl/link_uniform_blocks.cpp 
b/src/compiler/glsl/link_uniform_blocks.cpp
index ef2f29d..683b296 100644
--- a/src/compiler/glsl/link_uniform_blocks.cpp
+++ b/src/compiler/glsl/link_uniform_blocks.cpp
@@ -34,10 +34,12 @@ namespace {
 class ubo_visitor : public program_resource_visitor {
 public:
ubo_visitor(void *mem_ctx, gl_uniform_buffer_variable *variables,
-   unsigned num_variables, struct gl_shader_program *prog)
+   unsigned num_variables, struct gl_shader_program *prog,
+   bool use_std430_as_default)
   : index(0), offset(0), buffer_size(0), variables(variables),
 num_variables(num_variables), mem_ctx(mem_ctx),
-is_array_instance(false), prog(prog)
+is_array_instance(false), prog(prog),
+use_std430_as_default(use_std430_as_default)
{
   /* empty */
}
@@ -47,7 +49,8 @@ public:
   this->offset = 0;
   this->buffer_size = 0;
   this->is_array_instance = strchr(name, ']') != NULL;
-  this->program_resource_visitor::process(type, name);
+  this->program_resource_visitor::process(type, name,
+  use_std430_as_default);
}
 
unsigned index;
@@ -181,6 +184,8 @@ private:
*/
   this->buffer_size = glsl_align(this->offset, 16);
}
+
+   bool use_std430_as_default;
 };
 
 class count_block_size : public program_resource_visitor {
@@ -352,7 +357,8 @@ create_buffer_blocks(void *mem_ctx, struct gl_context *ctx,
/* Add each variable from each uniform block to the API tracking
 * structures.
 */
-   ubo_visitor parcel(blocks, variables, num_variables, prog);
+   ubo_visitor parcel(blocks, variables, num_variables, prog,
+  ctx->Const.UseSTD430AsDefaultPacking);
 
unsigned i = 0;
struct hash_entry *entry;
@@ -438,7 +444,8 @@ link_uniform_blocks(void *mem_ctx,
   }
 
   block_size.num_active_uniforms = 0;
-  block_size.process(b->type->without_array(), "");
+  block_size.process(b->type->without_array(), "",
+ ctx->Const.UseSTD430AsDefaultPacking);
 
   if (b->array != NULL) {
  unsigned aoa_size = b->type->arrays_of_arrays_size();
diff --git a/src/compiler/glsl/link_uniforms.cpp 
b/src/compiler/glsl/link_uniforms.cpp
index 1b87c58..f7ee17e 100644
--- a/src/compiler/glsl/link_uniforms.cpp
+++ b/src/compiler/glsl/link_uniforms.cpp
@@ -43,14 +43,17 @@
 #define UNMAPPED_UNIFORM_LOC ~0u
 
 void
-program_resource_visitor::process(const glsl_type *type, const char *name)
+program_resource_visitor::process(const glsl_type *type, const char *name,
+  bool use_std430_as_default)
 {
assert(type->without_array()->is_record()
   || type->without_array()->is_interface());
 
unsigned record_array_count = 1;
char *name_copy = ralloc_strdup(NULL, name);
-   enum glsl_interface_packing packing = type->get_interface_packing();
+
+   enum glsl_interface_packing packing =
+  type->get_internal_ifc_packing(use_std430_as_default);
 
recursion(type, _copy, strlen(name), false, NULL, packing, false,
  record_array_count, NULL);
@@ -58,15 +61,16 @@ program_resource_visitor::process(const glsl_type *type, 
const char *name)
 }
 
 void
-program_resource_visitor::process(ir_variable *var)
+program_resource_visitor::process(ir_variable *var, bool use_std430_as_default)
 {
unsigned record_array_count = 1;
const bool row_major =
   var->data.matrix_layout 

[Mesa-dev] [PATCH 3/5] glsl: add get_internal_ifc_packing() type helper

2017-07-23 Thread Timothy Arceri
This is used to avoid code duplication when selecting the
packing type for shared and packed layouts.
---
 src/compiler/glsl_types.h | 21 +
 1 file changed, 21 insertions(+)

diff --git a/src/compiler/glsl_types.h b/src/compiler/glsl_types.h
index f67465e..3c18f6c 100644
--- a/src/compiler/glsl_types.h
+++ b/src/compiler/glsl_types.h
@@ -817,6 +817,27 @@ struct glsl_type {
}
 
/**
+* Get the type interface packing used internally. For shared and packing
+* layouts this is implementation defined.
+*/
+   enum glsl_interface_packing get_internal_ifc_packing(bool std430_supported) 
const
+   {
+  enum glsl_interface_packing packing = this->get_interface_packing();
+  if (packing == GLSL_INTERFACE_PACKING_STD140 ||
+  (!std430_supported &&
+   (packing == GLSL_INTERFACE_PACKING_SHARED ||
+packing == GLSL_INTERFACE_PACKING_PACKED))) {
+ return GLSL_INTERFACE_PACKING_STD140;
+  } else {
+ assert(packing == GLSL_INTERFACE_PACKING_STD430 ||
+(std430_supported &&
+ (packing == GLSL_INTERFACE_PACKING_SHARED ||
+  packing == GLSL_INTERFACE_PACKING_PACKED)));
+ return GLSL_INTERFACE_PACKING_STD430;
+  }
+   }
+
+   /**
 * Check if the type interface is row major
 */
bool get_interface_row_major() const
-- 
2.9.4

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


[Mesa-dev] [PATCH 2/5] mesa: add UseSTD430AsDefaultPacking constant

2017-07-23 Thread Timothy Arceri
This will be used to enable the STD430 layout as the default for
UBOs and SSBOs with layouts of shared/packed rather than STD140.
---
 src/mesa/main/mtypes.h | 9 +
 1 file changed, 9 insertions(+)

diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 4970329..751ff7c 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -3838,6 +3838,15 @@ struct gl_constants
GLboolean DisableVaryingPacking;
 
/**
+* UBOs and SSBOs can be packed tightly by the OpenGL implementation when
+* layout is set as shared (the default) or packed. However most Mesa 
drivers
+* just use STD140 for these layouts. This flag allows drivers to use STD430
+* for packed and shared layouts which allows arrays to be packed more
+* tightly.
+*/
+   bool UseSTD430AsDefaultPacking;
+
+   /**
 * Should meaningful names be generated for compiler temporary variables?
 *
 * Generally, it is not useful to have the compiler generate "meaningful"
-- 
2.9.4

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


[Mesa-dev] i965 use STD430 packing by default

2017-07-23 Thread Timothy Arceri
shared (the default) and packed layouts are decided by the implementation.
Currently we just pack them using the std140 layout. This change makes it so
we use the slightly more compact std430 layout on i965.

The number of changes in patch 4 is a little unfortunate however I decided this
was better than changing the type completely behind the scenes. Given the
complexity of the ifc linking/validation code I figured it would be better to
aviod adding to that confusion. Also I intent to switch gallium over to std430
which would mean once SNB is updated to work with this (I don't have the
hardware) we could drop most of patch 4 again.

This change should be pretty well covered by the CTS but I also have a few basic
piglit tests that I'll send out a bit later once I finish up the gallium 
support.

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


[Mesa-dev] [PATCH 1/5] compiler: move glsl_interface_packing enum to shader_enums.h

2017-07-23 Thread Timothy Arceri
This allows us to drop the duplicate gl_uniform_block_packing enum.
---
 src/compiler/glsl/link_uniform_blocks.cpp | 11 +--
 src/compiler/glsl_types.h |  9 ++---
 src/compiler/shader_enums.h   |  7 +++
 src/mesa/main/mtypes.h| 11 +--
 4 files changed, 11 insertions(+), 27 deletions(-)

diff --git a/src/compiler/glsl/link_uniform_blocks.cpp 
b/src/compiler/glsl/link_uniform_blocks.cpp
index 249a767..ef2f29d 100644
--- a/src/compiler/glsl/link_uniform_blocks.cpp
+++ b/src/compiler/glsl/link_uniform_blocks.cpp
@@ -280,7 +280,7 @@ process_block_array_leaf(const char *name,
blocks[i].Binding = (b->has_binding) ? b->binding + *binding_offset : 0;
 
blocks[i].UniformBufferSize = 0;
-   blocks[i]._Packing = gl_uniform_block_packing(type->interface_packing);
+   blocks[i]._Packing = glsl_interface_packing(type->interface_packing);
blocks[i]._RowMajor = type->get_interface_row_major();
blocks[i].linearized_array_index = linearized_index;
 
@@ -354,15 +354,6 @@ create_buffer_blocks(void *mem_ctx, struct gl_context *ctx,
 */
ubo_visitor parcel(blocks, variables, num_variables, prog);
 
-   STATIC_ASSERT(unsigned(GLSL_INTERFACE_PACKING_STD140)
- == unsigned(ubo_packing_std140));
-   STATIC_ASSERT(unsigned(GLSL_INTERFACE_PACKING_SHARED)
- == unsigned(ubo_packing_shared));
-   STATIC_ASSERT(unsigned(GLSL_INTERFACE_PACKING_PACKED)
- == unsigned(ubo_packing_packed));
-   STATIC_ASSERT(unsigned(GLSL_INTERFACE_PACKING_STD430)
- == unsigned(ubo_packing_std430));
-
unsigned i = 0;
struct hash_entry *entry;
hash_table_foreach (block_hash, entry) {
diff --git a/src/compiler/glsl_types.h b/src/compiler/glsl_types.h
index 2857dc9..f67465e 100644
--- a/src/compiler/glsl_types.h
+++ b/src/compiler/glsl_types.h
@@ -28,6 +28,8 @@
 #include 
 #include 
 
+#include "shader_enums.h"
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -101,13 +103,6 @@ enum glsl_sampler_dim {
GLSL_SAMPLER_DIM_SUBPASS_MS, /* for multisampled vulkan input attachments */
 };
 
-enum glsl_interface_packing {
-   GLSL_INTERFACE_PACKING_STD140,
-   GLSL_INTERFACE_PACKING_SHARED,
-   GLSL_INTERFACE_PACKING_PACKED,
-   GLSL_INTERFACE_PACKING_STD430
-};
-
 enum glsl_matrix_layout {
/**
 * The layout of the matrix is inherited from the object containing the
diff --git a/src/compiler/shader_enums.h b/src/compiler/shader_enums.h
index 352f270..2f20e68 100644
--- a/src/compiler/shader_enums.h
+++ b/src/compiler/shader_enums.h
@@ -567,6 +567,13 @@ enum glsl_interp_mode
INTERP_MODE_COUNT /**< Number of interpolation qualifiers */
 };
 
+enum glsl_interface_packing {
+   GLSL_INTERFACE_PACKING_STD140,
+   GLSL_INTERFACE_PACKING_SHARED,
+   GLSL_INTERFACE_PACKING_PACKED,
+   GLSL_INTERFACE_PACKING_STD430
+};
+
 const char *glsl_interp_mode_name(enum glsl_interp_mode qual);
 
 /**
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 3ce2df7..4970329 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -2645,15 +2645,6 @@ struct gl_uniform_buffer_variable
 };
 
 
-enum gl_uniform_block_packing
-{
-   ubo_packing_std140,
-   ubo_packing_shared,
-   ubo_packing_packed,
-   ubo_packing_std430
-};
-
-
 struct gl_uniform_block
 {
/** Declared name of the uniform block */
@@ -2699,7 +2690,7 @@ struct gl_uniform_block
 * This isn't accessible through the API, but it is used while
 * cross-validating uniform blocks.
 */
-   enum gl_uniform_block_packing _Packing;
+   enum glsl_interface_packing _Packing;
GLboolean _RowMajor;
 };
 
-- 
2.9.4

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


[Mesa-dev] [PATCH] radv: allow buffers to be shareable as well.

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

Buffers should report dedicated flags as well, so report the
same information for them as for images.

(alternately we can turn dedicated off for buffers maybe?)

Fixes CTS dEQP-VK.api.external.memory.opaque_fd.dedicated.buffer.info

Fixes: b70829708a (radv: Implement VK_KHR_external_memory)
Signed-off-by: Dave Airlie 
---
 src/amd/vulkan/radv_device.c  | 5 -
 src/amd/vulkan/radv_private.h | 1 +
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/amd/vulkan/radv_device.c b/src/amd/vulkan/radv_device.c
index 40b2f34..4b11a4f 100644
--- a/src/amd/vulkan/radv_device.c
+++ b/src/amd/vulkan/radv_device.c
@@ -2389,12 +2389,13 @@ void radv_GetBufferMemoryRequirements2KHR(
radv_GetBufferMemoryRequirements(device, pInfo->buffer,
 
>memoryRequirements);
 
+   RADV_FROM_HANDLE(radv_buffer, buffer, pInfo->buffer);
vk_foreach_struct(ext, pMemoryRequirements->pNext) {
switch (ext->sType) {
case VK_STRUCTURE_TYPE_MEMORY_DEDICATED_REQUIREMENTS_KHR: {
VkMemoryDedicatedRequirementsKHR *req =
   (VkMemoryDedicatedRequirementsKHR *) ext;
-   req->requiresDedicatedAllocation = false;
+   req->requiresDedicatedAllocation = buffer->shareable;
req->prefersDedicatedAllocation = 
req->requiresDedicatedAllocation;
break;
}
@@ -2878,6 +2879,8 @@ VkResult radv_CreateBuffer(
buffer->offset = 0;
buffer->flags = pCreateInfo->flags;
 
+   buffer->shareable = vk_find_struct_const(pCreateInfo->pNext,
+
EXTERNAL_MEMORY_BUFFER_CREATE_INFO_KHR) != NULL;
if (pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_BINDING_BIT) {
buffer->bo = device->ws->buffer_create(device->ws,
   align64(buffer->size, 
4096),
diff --git a/src/amd/vulkan/radv_private.h b/src/amd/vulkan/radv_private.h
index 8cd5ec0..ffb2490 100644
--- a/src/amd/vulkan/radv_private.h
+++ b/src/amd/vulkan/radv_private.h
@@ -637,6 +637,7 @@ struct radv_buffer {
VkBufferUsageFlags   usage;
VkBufferCreateFlags  flags;
 
+   bool shareable;
/* Set when bound */
struct radeon_winsys_bo *  bo;
VkDeviceSize offset;
-- 
2.9.4

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


Re: [Mesa-dev] [PATCH] radv: for external memory imports close the fd on import success

2017-07-23 Thread Jason Ekstrand

Reciewed-by: Jason Ekstrand 


On July 23, 2017 7:51:44 PM Dave Airlie  wrote:


From: Dave Airlie 

If we get an fd, we need to close it before returning.

Fixes CTS test 
dEQP-VK.api.external.memory.opaque_fd.dedicated.device_only.import_multiple_times


Fixes: b70829708a (radv: Implement VK_KHR_external_memory)
Signed-off-by: Dave Airlie 
---
 src/amd/vulkan/radv_device.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/amd/vulkan/radv_device.c b/src/amd/vulkan/radv_device.c
index 3f83b61..40b2f34 100644
--- a/src/amd/vulkan/radv_device.c
+++ b/src/amd/vulkan/radv_device.c
@@ -2253,8 +2253,10 @@ VkResult radv_AllocateMemory(
if (!mem->bo) {
result = VK_ERROR_INVALID_EXTERNAL_HANDLE_KHR;
goto fail;
-   } else
+   } else {
+   close(import_info->fd);
goto out_success;
+   }
}

uint64_t alloc_size = align_u64(pAllocateInfo->allocationSize, 4096);
--
2.9.4

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



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


[Mesa-dev] [PATCH] radv: for external memory imports close the fd on import success

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

If we get an fd, we need to close it before returning.

Fixes CTS test 
dEQP-VK.api.external.memory.opaque_fd.dedicated.device_only.import_multiple_times

Fixes: b70829708a (radv: Implement VK_KHR_external_memory)
Signed-off-by: Dave Airlie 
---
 src/amd/vulkan/radv_device.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/amd/vulkan/radv_device.c b/src/amd/vulkan/radv_device.c
index 3f83b61..40b2f34 100644
--- a/src/amd/vulkan/radv_device.c
+++ b/src/amd/vulkan/radv_device.c
@@ -2253,8 +2253,10 @@ VkResult radv_AllocateMemory(
if (!mem->bo) {
result = VK_ERROR_INVALID_EXTERNAL_HANDLE_KHR;
goto fail;
-   } else
+   } else {
+   close(import_info->fd);
goto out_success;
+   }
}
 
uint64_t alloc_size = align_u64(pAllocateInfo->allocationSize, 4096);
-- 
2.9.4

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


Re: [Mesa-dev] [PATCH] st/mesa: create framebuffer iface hash table per st manager

2017-07-23 Thread Brian Paul
Can you explain in the comment how/why this fixes the crash?  It's not 
obvious to me.


Patch looks OK, AFAICT.

Reviewed-by: Brian Paul 



On 07/23/2017 05:37 PM, Charmaine Lee wrote:

With this patch, framebuffer interface hash table is created
per state tracker manager.

Fixes crash with steam.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=101876
Fixes: 5124bf98239 ("st/mesa: add destroy_drawable interface")
Tested-by: Christoph Haag 
---
  src/gallium/include/state_tracker/st_api.h|  21 +
  src/gallium/state_trackers/dri/dri_drawable.c |   1 +
  src/gallium/state_trackers/dri/dri_screen.c   |   3 +
  src/gallium/state_trackers/glx/xlib/xm_api.c  |   3 +
  src/gallium/state_trackers/glx/xlib/xm_st.c   |   1 +
  src/gallium/state_trackers/wgl/stw_device.c   |   3 +
  src/gallium/state_trackers/wgl/stw_st.c   |   1 +
  src/mesa/state_tracker/st_manager.c   | 107 +++---
  8 files changed, 113 insertions(+), 27 deletions(-)

diff --git a/src/gallium/include/state_tracker/st_api.h 
b/src/gallium/include/state_tracker/st_api.h
index 9b660f7..bc62a69 100644
--- a/src/gallium/include/state_tracker/st_api.h
+++ b/src/gallium/include/state_tracker/st_api.h
@@ -284,6 +284,7 @@ struct st_context_attribs
  };

  struct st_context_iface;
+struct st_manager;

  /**
   * Represent a windowing system drawable.
@@ -317,6 +318,11 @@ struct st_framebuffer_iface
 uint32_t ID;

 /**
+* The state tracker manager that manages this object.
+*/
+   struct st_manager *state_manager;
+
+   /**
  * Available for the state tracker manager to use.
  */
 void *st_manager_private;
@@ -376,6 +382,11 @@ struct st_context_iface
 void *st_manager_private;

 /**
+* The state tracker manager that manages this object.
+*/
+   struct st_manager *state_manager;
+
+   /**
  * The CSO context associated with this context in case we need to draw
  * something before swap buffers.
  */
@@ -483,6 +494,16 @@ struct st_manager
  */
 void (*set_background_context)(struct st_context_iface *stctxi,
struct util_queue_monitoring *queue_info);
+
+   /**
+* Destroy any private data used by the state tracker manager.
+*/
+   void (*destroy)(struct st_manager *smapi);
+
+   /**
+* Available for the state tracker manager to use.
+*/
+   void *st_manager_private;
  };

  /**
diff --git a/src/gallium/state_trackers/dri/dri_drawable.c 
b/src/gallium/state_trackers/dri/dri_drawable.c
index c7df0f6..9e0dd6b 100644
--- a/src/gallium/state_trackers/dri/dri_drawable.c
+++ b/src/gallium/state_trackers/dri/dri_drawable.c
@@ -158,6 +158,7 @@ dri_create_buffer(__DRIscreen * sPriv,
 dPriv->driverPrivate = (void *)drawable;
 p_atomic_set(>base.stamp, 1);
 drawable->base.ID = p_atomic_inc_return(_ID);
+   drawable->base.state_manager = >base;

 return GL_TRUE;
  fail:
diff --git a/src/gallium/state_trackers/dri/dri_screen.c 
b/src/gallium/state_trackers/dri/dri_screen.c
index 1dd7bd3..59a850b 100644
--- a/src/gallium/state_trackers/dri/dri_screen.c
+++ b/src/gallium/state_trackers/dri/dri_screen.c
@@ -457,6 +457,9 @@ dri_destroy_option_cache(struct dri_screen * screen)
  void
  dri_destroy_screen_helper(struct dri_screen * screen)
  {
+   if (screen->base.destroy)
+  screen->base.destroy(>base);
+
 if (screen->st_api && screen->st_api->destroy)
screen->st_api->destroy(screen->st_api);

diff --git a/src/gallium/state_trackers/glx/xlib/xm_api.c 
b/src/gallium/state_trackers/glx/xlib/xm_api.c
index e4b1e9d..828253b 100644
--- a/src/gallium/state_trackers/glx/xlib/xm_api.c
+++ b/src/gallium/state_trackers/glx/xlib/xm_api.c
@@ -181,6 +181,9 @@ xmesa_close_display(Display *display)
  *xmdpy->screen->destroy(xmdpy->screen);
  * }
  */
+
+   if (xmdpy->smapi->destroy)
+  xmdpy->smapi->destroy(xmdpy->smapi);
 free(xmdpy->smapi);

 XFree((char *) info);
diff --git a/src/gallium/state_trackers/glx/xlib/xm_st.c 
b/src/gallium/state_trackers/glx/xlib/xm_st.c
index 6a0f4aa..0c42e65 100644
--- a/src/gallium/state_trackers/glx/xlib/xm_st.c
+++ b/src/gallium/state_trackers/glx/xlib/xm_st.c
@@ -304,6 +304,7 @@ xmesa_create_st_framebuffer(XMesaDisplay xmdpy, XMesaBuffer 
b)
 stfbi->flush_front = xmesa_st_framebuffer_flush_front;
 stfbi->validate = xmesa_st_framebuffer_validate;
 stfbi->ID = p_atomic_inc_return(_stfbi_ID);
+   stfbi->state_manager = xmdpy->smapi;
 p_atomic_set(>stamp, 1);
 stfbi->st_manager_private = (void *) xstfb;

diff --git a/src/gallium/state_trackers/wgl/stw_device.c 
b/src/gallium/state_trackers/wgl/stw_device.c
index 6c0f14d..b88e110 100644
--- a/src/gallium/state_trackers/wgl/stw_device.c
+++ b/src/gallium/state_trackers/wgl/stw_device.c
@@ -199,6 +199,9 @@ stw_cleanup(void)
 DeleteCriticalSection(_dev->fb_mutex);
 DeleteCriticalSection(_dev->ctx_mutex);

+   if 

[Mesa-dev] [Bug 101867] Launch options window renders black in Feral Games in current Mesa trunk

2017-07-23 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=101867

Michel Dänzer  changed:

   What|Removed |Added

 Attachment #132819|0   |1
is obsolete||

-- 
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] threaded opengl

2017-07-23 Thread Timothy Arceri

On 24/07/17 10:44, Mike Lothian wrote:
I think you also need to provide info on how much of a speed up it 
provides because some games are slower with glthread


Providing the CPU and GPU combo used for testing would also be useful so 
it can be noted in the commit message. This would be useful if someone

disputes the performance claim in future.



On Mon, 24 Jul 2017 at 01:33 siyia > wrote:


sorry executable is "mb_warband_linux" start.sh or mb_warband.sh are
local scripts to start the game so:



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



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


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


Re: [Mesa-dev] [PATCH 2/2] mesa: return GL_OUT_OF_MEMORY if NewSamplerObject fails

2017-07-23 Thread Timothy Arceri

please see the comment in patch 1. Otherwise 1-2 are:

Reviewed-by: Timothy Arceri 

On 21/07/17 22:42, Samuel Pitoiset wrote:

This is similar to other functions that create objects.

Signed-off-by: Samuel Pitoiset 
---
  src/mesa/main/samplerobj.c | 16 
  1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/src/mesa/main/samplerobj.c b/src/mesa/main/samplerobj.c
index a9c004fe71..7744ab2726 100644
--- a/src/mesa/main/samplerobj.c
+++ b/src/mesa/main/samplerobj.c
@@ -169,10 +169,18 @@ create_samplers(struct gl_context *ctx, GLsizei count, 
GLuint *samplers,
  
 /* Insert the ID and pointer to new sampler object into hash table */

 for (i = 0; i < count; i++) {
-  struct gl_sampler_object *sampObj =
- ctx->Driver.NewSamplerObject(ctx, first + i);
-  _mesa_HashInsertLocked(ctx->Shared->SamplerObjects, first + i, sampObj);
-  samplers[i] = first + i;
+  struct gl_sampler_object *sampObj;
+  GLuint name = first + i;
+
+  sampObj = ctx->Driver.NewSamplerObject(ctx, name);
+  if (!sampObj) {
+ _mesa_HashUnlockMutex(ctx->Shared->SamplerObjects);
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "%s", caller);
+ return;
+  }
+
+  _mesa_HashInsertLocked(ctx->Shared->SamplerObjects, name, sampObj);
+  samplers[i] = name;
 }
  
 _mesa_HashUnlockMutex(ctx->Shared->SamplerObjects);



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


Re: [Mesa-dev] [PATCH 1/2] mesa: pass the 'caller' function to create_samplers()

2017-07-23 Thread Timothy Arceri

On 21/07/17 22:42, Samuel Pitoiset wrote:

To return GL_OUT_OF_MEMORY if NewSamplerObject fails.

Signed-off-by: Samuel Pitoiset 
---
  src/mesa/main/samplerobj.c | 10 +-
  1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/mesa/main/samplerobj.c b/src/mesa/main/samplerobj.c
index 26e7725249..a9c004fe71 100644
--- a/src/mesa/main/samplerobj.c
+++ b/src/mesa/main/samplerobj.c
@@ -154,7 +154,8 @@ _mesa_new_sampler_object(struct gl_context *ctx, GLuint 
name)
  }
  
  static void

-create_samplers(struct gl_context *ctx, GLsizei count, GLuint *samplers)
+create_samplers(struct gl_context *ctx, GLsizei count, GLuint *samplers,
+const char *caller)
  {
 GLuint first;
 GLint i;
@@ -181,7 +182,6 @@ static void
  create_samplers_err(struct gl_context *ctx, GLsizei count, GLuint *samplers,
  const char *caller)
  {
-


I've been letting some of these go but white space fixes should be going 
into separate patches. Please try to do this in future.



 if (MESA_VERBOSE & VERBOSE_API)
_mesa_debug(ctx, "%s(%d)\n", caller, count);
  
@@ -190,14 +190,14 @@ create_samplers_err(struct gl_context *ctx, GLsizei count, GLuint *samplers,

return;
 }
  
-   create_samplers(ctx, count, samplers);

+   create_samplers(ctx, count, samplers, caller);
  }
  
  void GLAPIENTRY

  _mesa_GenSamplers_no_error(GLsizei count, GLuint *samplers)
  {
 GET_CURRENT_CONTEXT(ctx);
-   create_samplers(ctx, count, samplers);
+   create_samplers(ctx, count, samplers, "glGenSamplers");
  }
  
  void GLAPIENTRY

@@ -211,7 +211,7 @@ void GLAPIENTRY
  _mesa_CreateSamplers_no_error(GLsizei count, GLuint *samplers)
  {
 GET_CURRENT_CONTEXT(ctx);
-   create_samplers(ctx, count, samplers);
+   create_samplers(ctx, count, samplers, "glCreateSamplers");
  }
  
  void GLAPIENTRY



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


Re: [Mesa-dev] [PATCH 043/101] mesa: add KHR_no_error support to glPrimitiveRestartIndex()

2017-07-23 Thread Timothy Arceri

38-43:

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


Re: [Mesa-dev] [PATCH 7/7] i965: Drop non-LLC lunacy in the program cache code.

2017-07-23 Thread Kenneth Graunke
On Saturday, July 22, 2017 2:28:06 AM PDT Chris Wilson wrote:
> Considering the prevalence of sse4.1, another candidate is
> brw_get_buffer_subdata(), we could use a WC map there as well.

Your thinking is...avoid polluting the CPU cache, since we're basically
going to be reading a continuous chunk of buffer data once, and never
accessing it again?

UC + movntdqa might be pretty reasonable there.  WC doesn't buy us much
considering it's a read-only map but I guess it doesn't hurt either...

--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] threaded opengl

2017-07-23 Thread Mike Lothian
I think you also need to provide info on how much of a speed up it provides
because some games are slower with glthread

On Mon, 24 Jul 2017 at 01:33 siyia  wrote:

> sorry executable is "mb_warband_linux" start.sh or mb_warband.sh are
> local scripts to start the game so:
>
> 
>
> ___
> 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] threaded opengl

2017-07-23 Thread siyia
sorry executable is "mb_warband_linux" start.sh or mb_warband.sh are 
local scripts to start the game so:




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


Re: [Mesa-dev] Call for community testing: OpenGL multithreading is ready

2017-07-23 Thread siyia






~30% perfomance increase

name= siyia

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


Re: [Mesa-dev] [PATCH 036/101] mesa: add delete_vertex_arrays() helper

2017-07-23 Thread Timothy Arceri



On 22/07/17 03:39, Samuel Pitoiset wrote:

Signed-off-by: Samuel Pitoiset 
---
  src/mesa/main/arrayobj.c | 24 
  1 file changed, 16 insertions(+), 8 deletions(-)

diff --git a/src/mesa/main/arrayobj.c b/src/mesa/main/arrayobj.c
index 77c0206ecf..60a24663f7 100644
--- a/src/mesa/main/arrayobj.c
+++ b/src/mesa/main/arrayobj.c
@@ -466,17 +466,11 @@ _mesa_BindVertexArray(GLuint id)
   * \param n  Number of array objects to delete.
   * \param idsArray of \c n array object IDs.
   */
-void GLAPIENTRY
-_mesa_DeleteVertexArrays(GLsizei n, const GLuint *ids)
+static void
+delete_vertex_arrays(struct gl_context *ctx, GLsizei n, const GLuint *ids)
  {
-   GET_CURRENT_CONTEXT(ctx);
 GLsizei i;
  
-   if (n < 0) {

-  _mesa_error(ctx, GL_INVALID_VALUE, "glDeleteVertexArray(n)");
-  return;
-   }
-
 for (i = 0; i < n; i++) {
struct gl_vertex_array_object *obj = _mesa_lookup_vao(ctx, ids[i]);


Inside this loop there is a call:

   _mesa_BindVertexArray(0);

Because the id is always 0 this can be replaced with:

   _mesa_BindVertexArray_no_error(0);

With a follow-up patch that makes this change, that patch and 27-37 are:

Reviewed-by: Timothy Arceri 



  
@@ -505,6 +499,20 @@ _mesa_DeleteVertexArrays(GLsizei n, const GLuint *ids)

  }
  
  
+void GLAPIENTRY

+_mesa_DeleteVertexArrays(GLsizei n, const GLuint *ids)
+{
+   GET_CURRENT_CONTEXT(ctx);
+
+   if (n < 0) {
+  _mesa_error(ctx, GL_INVALID_VALUE, "glDeleteVertexArray(n)");
+  return;
+   }
+
+   delete_vertex_arrays(ctx, n, ids);
+}
+
+
  /**
   * Generate a set of unique array object IDs and store them in \c arrays.
   * Helper for _mesa_GenVertexArrays() and _mesa_CreateVertexArrays()


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


[Mesa-dev] [PATCH] st/mesa: create framebuffer iface hash table per st manager

2017-07-23 Thread Charmaine Lee
With this patch, framebuffer interface hash table is created
per state tracker manager.

Fixes crash with steam.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=101876
Fixes: 5124bf98239 ("st/mesa: add destroy_drawable interface")
Tested-by: Christoph Haag 
---
 src/gallium/include/state_tracker/st_api.h|  21 +
 src/gallium/state_trackers/dri/dri_drawable.c |   1 +
 src/gallium/state_trackers/dri/dri_screen.c   |   3 +
 src/gallium/state_trackers/glx/xlib/xm_api.c  |   3 +
 src/gallium/state_trackers/glx/xlib/xm_st.c   |   1 +
 src/gallium/state_trackers/wgl/stw_device.c   |   3 +
 src/gallium/state_trackers/wgl/stw_st.c   |   1 +
 src/mesa/state_tracker/st_manager.c   | 107 +++---
 8 files changed, 113 insertions(+), 27 deletions(-)

diff --git a/src/gallium/include/state_tracker/st_api.h 
b/src/gallium/include/state_tracker/st_api.h
index 9b660f7..bc62a69 100644
--- a/src/gallium/include/state_tracker/st_api.h
+++ b/src/gallium/include/state_tracker/st_api.h
@@ -284,6 +284,7 @@ struct st_context_attribs
 };
 
 struct st_context_iface;
+struct st_manager;
 
 /**
  * Represent a windowing system drawable.
@@ -317,6 +318,11 @@ struct st_framebuffer_iface
uint32_t ID;
 
/**
+* The state tracker manager that manages this object.
+*/
+   struct st_manager *state_manager;
+
+   /**
 * Available for the state tracker manager to use.
 */
void *st_manager_private;
@@ -376,6 +382,11 @@ struct st_context_iface
void *st_manager_private;
 
/**
+* The state tracker manager that manages this object.
+*/
+   struct st_manager *state_manager;
+
+   /**
 * The CSO context associated with this context in case we need to draw
 * something before swap buffers.
 */
@@ -483,6 +494,16 @@ struct st_manager
 */
void (*set_background_context)(struct st_context_iface *stctxi,
   struct util_queue_monitoring *queue_info);
+
+   /**
+* Destroy any private data used by the state tracker manager.
+*/
+   void (*destroy)(struct st_manager *smapi);
+
+   /**
+* Available for the state tracker manager to use.
+*/
+   void *st_manager_private;
 };
 
 /**
diff --git a/src/gallium/state_trackers/dri/dri_drawable.c 
b/src/gallium/state_trackers/dri/dri_drawable.c
index c7df0f6..9e0dd6b 100644
--- a/src/gallium/state_trackers/dri/dri_drawable.c
+++ b/src/gallium/state_trackers/dri/dri_drawable.c
@@ -158,6 +158,7 @@ dri_create_buffer(__DRIscreen * sPriv,
dPriv->driverPrivate = (void *)drawable;
p_atomic_set(>base.stamp, 1);
drawable->base.ID = p_atomic_inc_return(_ID);
+   drawable->base.state_manager = >base;
 
return GL_TRUE;
 fail:
diff --git a/src/gallium/state_trackers/dri/dri_screen.c 
b/src/gallium/state_trackers/dri/dri_screen.c
index 1dd7bd3..59a850b 100644
--- a/src/gallium/state_trackers/dri/dri_screen.c
+++ b/src/gallium/state_trackers/dri/dri_screen.c
@@ -457,6 +457,9 @@ dri_destroy_option_cache(struct dri_screen * screen)
 void
 dri_destroy_screen_helper(struct dri_screen * screen)
 {
+   if (screen->base.destroy)
+  screen->base.destroy(>base);
+
if (screen->st_api && screen->st_api->destroy)
   screen->st_api->destroy(screen->st_api);
 
diff --git a/src/gallium/state_trackers/glx/xlib/xm_api.c 
b/src/gallium/state_trackers/glx/xlib/xm_api.c
index e4b1e9d..828253b 100644
--- a/src/gallium/state_trackers/glx/xlib/xm_api.c
+++ b/src/gallium/state_trackers/glx/xlib/xm_api.c
@@ -181,6 +181,9 @@ xmesa_close_display(Display *display)
 *xmdpy->screen->destroy(xmdpy->screen);
 * }
 */
+
+   if (xmdpy->smapi->destroy)
+  xmdpy->smapi->destroy(xmdpy->smapi);
free(xmdpy->smapi);
 
XFree((char *) info);
diff --git a/src/gallium/state_trackers/glx/xlib/xm_st.c 
b/src/gallium/state_trackers/glx/xlib/xm_st.c
index 6a0f4aa..0c42e65 100644
--- a/src/gallium/state_trackers/glx/xlib/xm_st.c
+++ b/src/gallium/state_trackers/glx/xlib/xm_st.c
@@ -304,6 +304,7 @@ xmesa_create_st_framebuffer(XMesaDisplay xmdpy, XMesaBuffer 
b)
stfbi->flush_front = xmesa_st_framebuffer_flush_front;
stfbi->validate = xmesa_st_framebuffer_validate;
stfbi->ID = p_atomic_inc_return(_stfbi_ID);
+   stfbi->state_manager = xmdpy->smapi;
p_atomic_set(>stamp, 1);
stfbi->st_manager_private = (void *) xstfb;
 
diff --git a/src/gallium/state_trackers/wgl/stw_device.c 
b/src/gallium/state_trackers/wgl/stw_device.c
index 6c0f14d..b88e110 100644
--- a/src/gallium/state_trackers/wgl/stw_device.c
+++ b/src/gallium/state_trackers/wgl/stw_device.c
@@ -199,6 +199,9 @@ stw_cleanup(void)
DeleteCriticalSection(_dev->fb_mutex);
DeleteCriticalSection(_dev->ctx_mutex);
 
+   if (stw_dev->smapi->destroy)
+  stw_dev->smapi->destroy(stw_dev->smapi);
+
FREE(stw_dev->smapi);
stw_dev->stapi->destroy(stw_dev->stapi);
 
diff --git a/src/gallium/state_trackers/wgl/stw_st.c 
b/src/gallium/state_trackers/wgl/stw_st.c
index 

Re: [Mesa-dev] [PATCH] egl/wayland: Fix linking libEGL_common.la

2017-07-23 Thread Mike Lothian
If I try and compile mesa with clang (even using ld.bfd) I get these errors:

libtool: link: clang++ -m32 -fvisibility=hidden -Werror=pointer-arith
-Werror=vla -O2 -march=native -pipe -Wall -fno-math-errno
-fno-trapping-math -Qunused-arguments -O2 -march=native -pipe -fuse-ld=bfd
-o glsl_compiler glsl/main.o  glsl/.libs/libstandal
one.a -lz -lpthread -pthread
glsl/.libs/libstandalone.a(libmesautil_la-disk_cache.o): In function
`disk_cache_remove':
/var/tmp/portage/media-libs/mesa-/work/mesa-/src/util/disk_cache.c:(.text+0x752):
undefined reference to `__atomic_fetch_add_8'
glsl/.libs/libstandalone.a(libmesautil_la-disk_cache.o): In function
`cache_put':
/var/tmp/portage/media-libs/mesa-/work/mesa-/src/util/disk_cache.c:(.text+0xa76):
undefined reference to `__atomic_fetch_add_8'
/var/tmp/portage/media-libs/mesa-/work/mesa-/src/util/disk_cache.c:(.text+0xe40):
undefined reference to `__atomic_fetch_add_8'


On Mon, 24 Jul 2017 at 00:03 Mike Lothian  wrote:

> This is only an issue when using ld.gold, ld.bfd works fine which is
> probably why no one else has seen it. It only started being a problem when
> the dmabuff stuff landed and the makefiles were cleaned up
>
> I tried playing around with the dummy.cpp but I couldn't get it to trigger
> the c++ compiler
>
> On Fri, 21 Jul 2017 at 13:27 Emil Velikov 
> wrote:
>
>> On 20 July 2017 at 21:25, Mike Lothian  wrote:
>> > Because libmesautil.la includes string_to_uint_map.o, -lstdc++ is
>> > required for linking to succeed
>> >
>> It's a bit suspicious why not many others are seeing this issue.
>> Suspecting the GCC version/build flags has something to do here.
>>
>> > Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=101851
>> >
>> > Signed-off-by: Mike Lothian 
>> > ---
>> >  src/egl/Makefile.am | 2 +-
>> >  1 file changed, 1 insertion(+), 1 deletion(-)
>> >
>> > diff --git a/src/egl/Makefile.am b/src/egl/Makefile.am
>> > index 7c1a4929b8..830ed52b86 100644
>> > --- a/src/egl/Makefile.am
>> > +++ b/src/egl/Makefile.am
>> > @@ -83,7 +83,7 @@ AM_CFLAGS += $(WAYLAND_CFLAGS)
>> >  libEGL_common_la_LIBADD += $(WAYLAND_LIBS)
>> >  libEGL_common_la_LIBADD += $(LIBDRM_LIBS)
>> >  libEGL_common_la_LIBADD += $(top_builddir)/src/egl/wayland/wayland-drm/
>> libwayland-drm.la
>> > -libEGL_common_la_LIBADD += $(top_builddir)/src/util/libmesautil.la
>> > +libEGL_common_la_LIBADD += $(top_builddir)/src/util/libmesautil.la
>> -lstdc++
>>
>> As mentioned by Ken - ideally we won't be pulling C++ into libEGL. Can
>> you give try converting string_to_uint_map to C?
>> Alternatively use the dummy.cpp suggestion from Matt. We already have
>> some examples in the codebase.
>>
>> Thanks
>> Emil
>>
>
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] egl/wayland: Fix linking libEGL_common.la

2017-07-23 Thread Mike Lothian
This is only an issue when using ld.gold, ld.bfd works fine which is
probably why no one else has seen it. It only started being a problem when
the dmabuff stuff landed and the makefiles were cleaned up

I tried playing around with the dummy.cpp but I couldn't get it to trigger
the c++ compiler

On Fri, 21 Jul 2017 at 13:27 Emil Velikov  wrote:

> On 20 July 2017 at 21:25, Mike Lothian  wrote:
> > Because libmesautil.la includes string_to_uint_map.o, -lstdc++ is
> > required for linking to succeed
> >
> It's a bit suspicious why not many others are seeing this issue.
> Suspecting the GCC version/build flags has something to do here.
>
> > Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=101851
> >
> > Signed-off-by: Mike Lothian 
> > ---
> >  src/egl/Makefile.am | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/src/egl/Makefile.am b/src/egl/Makefile.am
> > index 7c1a4929b8..830ed52b86 100644
> > --- a/src/egl/Makefile.am
> > +++ b/src/egl/Makefile.am
> > @@ -83,7 +83,7 @@ AM_CFLAGS += $(WAYLAND_CFLAGS)
> >  libEGL_common_la_LIBADD += $(WAYLAND_LIBS)
> >  libEGL_common_la_LIBADD += $(LIBDRM_LIBS)
> >  libEGL_common_la_LIBADD += $(top_builddir)/src/egl/wayland/wayland-drm/
> libwayland-drm.la
> > -libEGL_common_la_LIBADD += $(top_builddir)/src/util/libmesautil.la
> > +libEGL_common_la_LIBADD += $(top_builddir)/src/util/libmesautil.la
> -lstdc++
>
> As mentioned by Ken - ideally we won't be pulling C++ into libEGL. Can
> you give try converting string_to_uint_map to C?
> Alternatively use the dummy.cpp suggestion from Matt. We already have
> some examples in the codebase.
>
> Thanks
> Emil
>
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH] radv: Don't segfault when exporting an image which hasn't been bound yet.

2017-07-23 Thread Bas Nieuwenhuizen
The image is set on Memory allocation already, but the image doesn't
have to have the BindImageMemory called yet. Luckily, we know offset
within a BO has to be 0 for dedicated allocations, so we can just
use the dummy 0 in the address calaculations.

Fixes CTS test 
dEQP-VK.api.external.memory.opaque_fd.dedicated.image.export_bind_import_bind

Signed-off-by: Bas Nieuwenhuizen 
Fixes: b70829708ac "radv: Implement VK_KHR_external_memory"
---
 src/amd/vulkan/radv_image.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/amd/vulkan/radv_image.c b/src/amd/vulkan/radv_image.c
index d8b7e8f421f..66cff526473 100644
--- a/src/amd/vulkan/radv_image.c
+++ b/src/amd/vulkan/radv_image.c
@@ -198,7 +198,7 @@ si_set_mutable_tex_desc_fields(struct radv_device *device,
   unsigned block_width, bool is_stencil,
   uint32_t *state)
 {
-   uint64_t gpu_address = device->ws->buffer_get_va(image->bo) + 
image->offset;
+   uint64_t gpu_address = image->bo ? device->ws->buffer_get_va(image->bo) 
+ image->offset : 0;
uint64_t va = gpu_address;
unsigned pitch = base_level_info->nblk_x * block_width;
enum chip_class chip_class = 
device->physical_device->rad_info.chip_class;
-- 
2.13.3

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


Re: [Mesa-dev] [PATCH 2/2] egl: add linux-dmabuf-unstable-v1-protocol.c to "nodist"

2017-07-23 Thread Andres Gomez
I'll be pushing already 1/2 and keep this on hold to see whether we
favor instead:
https://lists.freedesktop.org/archives/mesa-dev/2017-July/163730.html


On Thu, 2017-07-20 at 01:44 +0300, Andres Gomez wrote:
> This fixes `make distcheck`
> 
> > make[3]: *** No rule to make target 
> > 'drivers/dri2/linux-dmabuf-unstable-v1-protocol.c', needed by 'distdir'.  
> > Stop.
> > make[3]: Entering directory '/home/local/mesa/src/egl'
> > make[3]: Leaving directory '/home/local/mesa/src/egl'
> > make[2]: *** [distdir] Error 1
> > make[1]: *** [distdir] Error 1
> > make: *** [dist] Error 2
> 
> Fixes: 02cc359372 ("egl/wayland: Use linux-dmabuf interface for buffers")
> Cc: Emil Velikov 
> Signed-off-by: Andres Gomez 
> ---
>  src/egl/Makefile.am | 10 --
>  1 file changed, 8 insertions(+), 2 deletions(-)
> 
> diff --git a/src/egl/Makefile.am b/src/egl/Makefile.am
> index 7c1a4929b8..6ee1fb9be8 100644
> --- a/src/egl/Makefile.am
> +++ b/src/egl/Makefile.am
> @@ -44,10 +44,13 @@ noinst_LTLIBRARIES = libEGL_common.la
>  libEGL_common_la_SOURCES = \
>   $(LIBEGL_C_FILES)
>  
> +nodist_libEGL_common_la_SOURCES =
> +
>  libEGL_common_la_LIBADD = \
>   $(EGL_LIB_DEPS)
>  
>  dri2_backend_FILES =
> +nodist_dri2_backend_FILES =
>  dri3_backend_FILES =
>  
>  if HAVE_PLATFORM_X11
> @@ -84,8 +87,8 @@ libEGL_common_la_LIBADD += $(WAYLAND_LIBS)
>  libEGL_common_la_LIBADD += $(LIBDRM_LIBS)
>  libEGL_common_la_LIBADD += 
> $(top_builddir)/src/egl/wayland/wayland-drm/libwayland-drm.la
>  libEGL_common_la_LIBADD += $(top_builddir)/src/util/libmesautil.la
> -dri2_backend_FILES += drivers/dri2/platform_wayland.c\
> - drivers/dri2/linux-dmabuf-unstable-v1-protocol.c
> +dri2_backend_FILES += drivers/dri2/platform_wayland.c
> +nodist_dri2_backend_FILES += drivers/dri2/linux-dmabuf-unstable-v1-protocol.c
>  endif
>  
>  if HAVE_PLATFORM_DRM
> @@ -119,6 +122,9 @@ libEGL_common_la_SOURCES += \
>   $(dri2_backend_FILES) \
>   $(dri3_backend_FILES)
>  
> +nodist_libEGL_common_la_SOURCES += \
> + $(nodist_dri2_backend_FILES)
> +
>  libEGL_common_la_LIBADD += $(top_builddir)/src/loader/libloader.la
>  libEGL_common_la_LIBADD += $(DLOPEN_LIBS) $(LIBDRM_LIBS) $(CLOCK_LIB)
>  
-- 
Br,

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


Re: [Mesa-dev] [PATCH] configure.ac: rework wayland-protocols handling

2017-07-23 Thread Andres Gomez
On Mon, 2017-07-24 at 01:27 +0300, Andres Gomez wrote:
> This is:
> 
> Reviewed-by: Andres Gomez 

Mmmm ... I hit the send button too quickly.

Just wanted to mention that I share the same concerns than Daniel.
Would it be up to me, I would not be adding the generated files in the
release but I really don't have hard thoughts about it.

Therefore, if you would rather go with this solution, it is fine by me.


> 
> 
> On Fri, 2017-07-21 at 13:02 +0100, Emil Velikov wrote:
> > From: Emil Velikov 
> > 
> > At dist/distcheck time we need to ensure that all the files and their
> > respective dependencies are handled.
> > 
> > At the moment we'll bail out as the linux-dmabuf rules are guarded in a
> > conditional. Move them outside of it and drop the sources from
> > BUILT_SOURCES.
> > 
> > Thus the files will be generated only as needed, which will happen only
> > after the wayland-protocols dependency is enforced in configure.ac.
> > 
> > v2: add dependency tracking for the header
> > 
> > Cc: Andres Gomez 
> > Signed-off-by: Emil Velikov 
> > ---
> >  configure.ac| 13 ++---
> >  src/egl/Makefile.am | 13 +++--
> >  2 files changed, 17 insertions(+), 9 deletions(-)
> > 
> > diff --git a/configure.ac b/configure.ac
> > index 2689fc55e85..2736fbf201b 100644
> > --- a/configure.ac
> > +++ b/configure.ac
> > @@ -1681,19 +1681,26 @@ if test "x$WAYLAND_SCANNER" = x; then
> >  AC_PATH_PROG([WAYLAND_SCANNER], [wayland-scanner], [:])
> >  fi
> >  
> > +PKG_CHECK_EXISTS([wayland-protocols >= $WAYLAND_PROTOCOLS_REQUIRED], 
> > [have_wayland_protocols=yes], [have_wayland_protocols=no])
> > +if test "x$have_wayland_protocols" = xyes; then
> > +ac_wayland_protocols_pkgdatadir=`$PKG_CONFIG --variable=pkgdatadir 
> > wayland-protocols`
> > +fi
> > +AC_SUBST(WAYLAND_PROTOCOLS_DATADIR, $ac_wayland_protocols_pkgdatadir)
> > +
> >  # Do per platform setups and checks
> >  platforms=`IFS=', '; echo $with_platforms`
> >  for plat in $platforms; do
> >  case "$plat" in
> >  wayland)
> >  
> > -PKG_CHECK_MODULES([WAYLAND], [wayland-client >= $WAYLAND_REQUIRED 
> > wayland-server >= $WAYLAND_REQUIRED wayland-protocols >= 
> > $WAYLAND_PROTOCOLS_REQUIRED])
> > -ac_wayland_protocols_pkgdatadir=`$PKG_CONFIG --variable=pkgdatadir 
> > wayland-protocols`
> > -AC_SUBST(WAYLAND_PROTOCOLS_DATADIR, 
> > $ac_wayland_protocols_pkgdatadir)
> > +PKG_CHECK_MODULES([WAYLAND], [wayland-client >= $WAYLAND_REQUIRED 
> > wayland-server >= $WAYLAND_REQUIRED])
> >  
> >  if test "x$WAYLAND_SCANNER" = "x:"; then
> >  AC_MSG_ERROR([wayland-scanner is needed to compile the 
> > wayland platform])
> >  fi
> > +if test "x$have_wayland_protocols" = xno; then
> > +AC_MSG_ERROR([wayland-protocols >= 
> > $WAYLAND_PROTOCOLS_REQUIRED is needed to compile the wayland platform])
> > +fi
> >  DEFINES="$DEFINES -DHAVE_WAYLAND_PLATFORM"
> >  ;;
> >  
> > diff --git a/src/egl/Makefile.am b/src/egl/Makefile.am
> > index 7c1a4929b81..f881145c0e3 100644
> > --- a/src/egl/Makefile.am
> > +++ b/src/egl/Makefile.am
> > @@ -64,7 +64,6 @@ libEGL_common_la_LIBADD += 
> > $(top_builddir)/src/loader/libloader_dri3_helper.la
> >  endif
> >  endif
> >  
> > -if HAVE_PLATFORM_WAYLAND
> >  WL_DMABUF_XML = 
> > $(WAYLAND_PROTOCOLS_DATADIR)/unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml
> >  
> >  drivers/dri2/linux-dmabuf-unstable-v1-protocol.c: $(WL_DMABUF_XML)
> > @@ -75,17 +74,19 @@ 
> > drivers/dri2/linux-dmabuf-unstable-v1-client-protocol.h: $(WL_DMABUF_XML)
> > $(MKDIR_GEN)
> > $(AM_V_GEN)$(WAYLAND_SCANNER) client-header < $< > $@
> >  
> > -BUILT_SOURCES += \
> > -   drivers/dri2/linux-dmabuf-unstable-v1-protocol.c \
> > -   drivers/dri2/linux-dmabuf-unstable-v1-client-protocol.h
> > +drivers/dri2/linux-dmabuf-unstable-v1-protocol.lo: 
> > drivers/dri2/linux-dmabuf-unstable-v1-client-protocol.h
> > +drivers/dri2/egl_dri2.lo: 
> > drivers/dri2/linux-dmabuf-unstable-v1-client-protocol.h
> >  
> > +if HAVE_PLATFORM_WAYLAND
> >  AM_CFLAGS += $(WAYLAND_CFLAGS)
> >  libEGL_common_la_LIBADD += $(WAYLAND_LIBS)
> >  libEGL_common_la_LIBADD += $(LIBDRM_LIBS)
> >  libEGL_common_la_LIBADD += 
> > $(top_builddir)/src/egl/wayland/wayland-drm/libwayland-drm.la
> >  libEGL_common_la_LIBADD += $(top_builddir)/src/util/libmesautil.la
> > -dri2_backend_FILES += drivers/dri2/platform_wayland.c  \
> > -   drivers/dri2/linux-dmabuf-unstable-v1-protocol.c
> > +dri2_backend_FILES += \
> > +   drivers/dri2/platform_wayland.c \
> > +   drivers/dri2/linux-dmabuf-unstable-v1-protocol.c \
> > +   drivers/dri2/linux-dmabuf-unstable-v1-client-protocol.h
> >  endif
> >  
> >  if HAVE_PLATFORM_DRM
-- 
Br,

Andres
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org

Re: [Mesa-dev] [PATCH] configure.ac: rework wayland-protocols handling

2017-07-23 Thread Andres Gomez
This is:

Reviewed-by: Andres Gomez 


On Fri, 2017-07-21 at 13:02 +0100, Emil Velikov wrote:
> From: Emil Velikov 
> 
> At dist/distcheck time we need to ensure that all the files and their
> respective dependencies are handled.
> 
> At the moment we'll bail out as the linux-dmabuf rules are guarded in a
> conditional. Move them outside of it and drop the sources from
> BUILT_SOURCES.
> 
> Thus the files will be generated only as needed, which will happen only
> after the wayland-protocols dependency is enforced in configure.ac.
> 
> v2: add dependency tracking for the header
> 
> Cc: Andres Gomez 
> Signed-off-by: Emil Velikov 
> ---
>  configure.ac| 13 ++---
>  src/egl/Makefile.am | 13 +++--
>  2 files changed, 17 insertions(+), 9 deletions(-)
> 
> diff --git a/configure.ac b/configure.ac
> index 2689fc55e85..2736fbf201b 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -1681,19 +1681,26 @@ if test "x$WAYLAND_SCANNER" = x; then
>  AC_PATH_PROG([WAYLAND_SCANNER], [wayland-scanner], [:])
>  fi
>  
> +PKG_CHECK_EXISTS([wayland-protocols >= $WAYLAND_PROTOCOLS_REQUIRED], 
> [have_wayland_protocols=yes], [have_wayland_protocols=no])
> +if test "x$have_wayland_protocols" = xyes; then
> +ac_wayland_protocols_pkgdatadir=`$PKG_CONFIG --variable=pkgdatadir 
> wayland-protocols`
> +fi
> +AC_SUBST(WAYLAND_PROTOCOLS_DATADIR, $ac_wayland_protocols_pkgdatadir)
> +
>  # Do per platform setups and checks
>  platforms=`IFS=', '; echo $with_platforms`
>  for plat in $platforms; do
>  case "$plat" in
>  wayland)
>  
> -PKG_CHECK_MODULES([WAYLAND], [wayland-client >= $WAYLAND_REQUIRED 
> wayland-server >= $WAYLAND_REQUIRED wayland-protocols >= 
> $WAYLAND_PROTOCOLS_REQUIRED])
> -ac_wayland_protocols_pkgdatadir=`$PKG_CONFIG --variable=pkgdatadir 
> wayland-protocols`
> -AC_SUBST(WAYLAND_PROTOCOLS_DATADIR, $ac_wayland_protocols_pkgdatadir)
> +PKG_CHECK_MODULES([WAYLAND], [wayland-client >= $WAYLAND_REQUIRED 
> wayland-server >= $WAYLAND_REQUIRED])
>  
>  if test "x$WAYLAND_SCANNER" = "x:"; then
>  AC_MSG_ERROR([wayland-scanner is needed to compile the 
> wayland platform])
>  fi
> +if test "x$have_wayland_protocols" = xno; then
> +AC_MSG_ERROR([wayland-protocols >= 
> $WAYLAND_PROTOCOLS_REQUIRED is needed to compile the wayland platform])
> +fi
>  DEFINES="$DEFINES -DHAVE_WAYLAND_PLATFORM"
>  ;;
>  
> diff --git a/src/egl/Makefile.am b/src/egl/Makefile.am
> index 7c1a4929b81..f881145c0e3 100644
> --- a/src/egl/Makefile.am
> +++ b/src/egl/Makefile.am
> @@ -64,7 +64,6 @@ libEGL_common_la_LIBADD += 
> $(top_builddir)/src/loader/libloader_dri3_helper.la
>  endif
>  endif
>  
> -if HAVE_PLATFORM_WAYLAND
>  WL_DMABUF_XML = 
> $(WAYLAND_PROTOCOLS_DATADIR)/unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml
>  
>  drivers/dri2/linux-dmabuf-unstable-v1-protocol.c: $(WL_DMABUF_XML)
> @@ -75,17 +74,19 @@ drivers/dri2/linux-dmabuf-unstable-v1-client-protocol.h: 
> $(WL_DMABUF_XML)
>   $(MKDIR_GEN)
>   $(AM_V_GEN)$(WAYLAND_SCANNER) client-header < $< > $@
>  
> -BUILT_SOURCES += \
> - drivers/dri2/linux-dmabuf-unstable-v1-protocol.c \
> - drivers/dri2/linux-dmabuf-unstable-v1-client-protocol.h
> +drivers/dri2/linux-dmabuf-unstable-v1-protocol.lo: 
> drivers/dri2/linux-dmabuf-unstable-v1-client-protocol.h
> +drivers/dri2/egl_dri2.lo: 
> drivers/dri2/linux-dmabuf-unstable-v1-client-protocol.h
>  
> +if HAVE_PLATFORM_WAYLAND
>  AM_CFLAGS += $(WAYLAND_CFLAGS)
>  libEGL_common_la_LIBADD += $(WAYLAND_LIBS)
>  libEGL_common_la_LIBADD += $(LIBDRM_LIBS)
>  libEGL_common_la_LIBADD += 
> $(top_builddir)/src/egl/wayland/wayland-drm/libwayland-drm.la
>  libEGL_common_la_LIBADD += $(top_builddir)/src/util/libmesautil.la
> -dri2_backend_FILES += drivers/dri2/platform_wayland.c\
> - drivers/dri2/linux-dmabuf-unstable-v1-protocol.c
> +dri2_backend_FILES += \
> + drivers/dri2/platform_wayland.c \
> + drivers/dri2/linux-dmabuf-unstable-v1-protocol.c \
> + drivers/dri2/linux-dmabuf-unstable-v1-client-protocol.h
>  endif
>  
>  if HAVE_PLATFORM_DRM
-- 
Br,

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


[Mesa-dev] [PATCH] radv: Handle VK_ATTACHMENT_UNUSED in color attachments.

2017-07-23 Thread Bas Nieuwenhuizen
This just sets them to INVALID COLOR,  instead of shifting the
attachments together.

This also fixes a number of cases where we use it first and only
then check if it is VK_ATTACHMENT_UNUSED.

Signed-off-by: Bas Nieuwenhuizen 
Fixes: f4e499ec791 "radv: add initial non-conformant radv vulkan driver"
---
 src/amd/vulkan/radv_cmd_buffer.c  | 17 ++---
 src/amd/vulkan/radv_meta_clear.c  |  6 --
 src/amd/vulkan/radv_meta_resolve.c| 12 ++--
 src/amd/vulkan/radv_meta_resolve_cs.c |  7 +--
 src/amd/vulkan/radv_meta_resolve_fs.c |  7 +--
 src/amd/vulkan/radv_pipeline.c| 16 +++-
 6 files changed, 45 insertions(+), 20 deletions(-)

diff --git a/src/amd/vulkan/radv_cmd_buffer.c b/src/amd/vulkan/radv_cmd_buffer.c
index 058770bcbfd..4b087811710 100644
--- a/src/amd/vulkan/radv_cmd_buffer.c
+++ b/src/amd/vulkan/radv_cmd_buffer.c
@@ -1208,7 +1208,13 @@ radv_emit_framebuffer_state(struct radv_cmd_buffer 
*cmd_buffer)
struct radv_framebuffer *framebuffer = cmd_buffer->state.framebuffer;
const struct radv_subpass *subpass = cmd_buffer->state.subpass;
 
-   for (i = 0; i < subpass->color_count; ++i) {
+   for (i = 0; i < 8; ++i) {
+   if (i >= subpass->color_count || 
subpass->color_attachments[i].attachment == VK_ATTACHMENT_UNUSED) {
+   radeon_set_context_reg(cmd_buffer->cs, 
R_028C70_CB_COLOR0_INFO + i * 0x3C,
+  S_028C70_FORMAT(V_028C70_COLOR_INVALID));
+   continue;
+   }
+
int idx = subpass->color_attachments[i].attachment;
struct radv_attachment_info *att = 
>attachments[idx];
 
@@ -1220,10 +1226,6 @@ radv_emit_framebuffer_state(struct radv_cmd_buffer 
*cmd_buffer)
radv_load_color_clear_regs(cmd_buffer, att->attachment->image, 
i);
}
 
-   for (i = subpass->color_count; i < 8; i++)
-   radeon_set_context_reg(cmd_buffer->cs, R_028C70_CB_COLOR0_INFO 
+ i * 0x3C,
-  S_028C70_FORMAT(V_028C70_COLOR_INVALID));
-
if(subpass->depth_stencil_attachment.attachment != 
VK_ATTACHMENT_UNUSED) {
int idx = subpass->depth_stencil_attachment.attachment;
VkImageLayout layout = subpass->depth_stencil_attachment.layout;
@@ -1797,8 +1799,9 @@ radv_cmd_buffer_set_subpass(struct radv_cmd_buffer 
*cmd_buffer,
radv_subpass_barrier(cmd_buffer, >start_barrier);
 
for (unsigned i = 0; i < subpass->color_count; ++i) {
-   radv_handle_subpass_image_transition(cmd_buffer,
-   
subpass->color_attachments[i]);
+   if (subpass->color_attachments[i].attachment != 
VK_ATTACHMENT_UNUSED)
+   radv_handle_subpass_image_transition(cmd_buffer,
+
subpass->color_attachments[i]);
}
 
for (unsigned i = 0; i < subpass->input_count; ++i) {
diff --git a/src/amd/vulkan/radv_meta_clear.c b/src/amd/vulkan/radv_meta_clear.c
index 353e8382ca1..e9021915343 100644
--- a/src/amd/vulkan/radv_meta_clear.c
+++ b/src/amd/vulkan/radv_meta_clear.c
@@ -1080,7 +1080,8 @@ subpass_needs_clear(const struct radv_cmd_buffer 
*cmd_buffer)
ds = cmd_state->subpass->depth_stencil_attachment.attachment;
for (uint32_t i = 0; i < cmd_state->subpass->color_count; ++i) {
uint32_t a = 
cmd_state->subpass->color_attachments[i].attachment;
-   if (cmd_state->attachments[a].pending_clear_aspects) {
+   if (a != VK_ATTACHMENT_UNUSED &&
+   cmd_state->attachments[a].pending_clear_aspects) {
return true;
}
}
@@ -1120,7 +1121,8 @@ radv_cmd_buffer_clear_subpass(struct radv_cmd_buffer 
*cmd_buffer)
for (uint32_t i = 0; i < cmd_state->subpass->color_count; ++i) {
uint32_t a = 
cmd_state->subpass->color_attachments[i].attachment;
 
-   if (!cmd_state->attachments[a].pending_clear_aspects)
+   if (a == VK_ATTACHMENT_UNUSED ||
+   !cmd_state->attachments[a].pending_clear_aspects)
continue;
 
assert(cmd_state->attachments[a].pending_clear_aspects ==
diff --git a/src/amd/vulkan/radv_meta_resolve.c 
b/src/amd/vulkan/radv_meta_resolve.c
index a0edfb915cd..6cd0c381a54 100644
--- a/src/amd/vulkan/radv_meta_resolve.c
+++ b/src/amd/vulkan/radv_meta_resolve.c
@@ -560,6 +560,11 @@ radv_cmd_buffer_resolve_subpass(struct radv_cmd_buffer 
*cmd_buffer)
for (uint32_t i = 0; i < subpass->color_count; ++i) {
VkAttachmentReference src_att = subpass->color_attachments[i];
VkAttachmentReference dest_att = 
subpass->resolve_attachments[i];
+
+   if 

Re: [Mesa-dev] [PATCH] etnaviv: Clear lbl_usage array correctly

2017-07-23 Thread Christian Gmeiner
2017-07-23 13:24 GMT+02:00 Wladimir J. van der Laan :
> Fill the entire array instead of just a quarter. This avoids
> crashes with large shaders.
> (currently this never causes a problem because shaders larger than 2048/4
> instructions are not supported by this driver on any hardware, but it will
> cause problems in the future)
>
> Signed-off-by: Wladimir J. van der Laan 

Reviewed-by: Christian Gmeiner 

> ---
>  src/gallium/drivers/etnaviv/etnaviv_compiler.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/gallium/drivers/etnaviv/etnaviv_compiler.c 
> b/src/gallium/drivers/etnaviv/etnaviv_compiler.c
> index cc6bfc9..165ab74 100644
> --- a/src/gallium/drivers/etnaviv/etnaviv_compiler.c
> +++ b/src/gallium/drivers/etnaviv/etnaviv_compiler.c
> @@ -2353,7 +2353,7 @@ etna_compile_shader(struct etna_shader_variant *v)
> if (!c)
>return false;
>
> -   memset(>lbl_usage, -1, ARRAY_SIZE(c->lbl_usage));
> +   memset(>lbl_usage, -1, sizeof(c->lbl_usage));
>
> const struct tgsi_token *tokens = v->shader->tokens;
>
> --
> 2.7.4
>

greets
--
Christian Gmeiner, MSc

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


Re: [Mesa-dev] [PATCH] swr: fix transform feedback logic

2017-07-23 Thread Kyriazis, George

On Jul 23, 2017, at 1:51 PM, Ilia Mirkin 
> wrote:

On Sun, Jul 23, 2017 at 12:27 PM, Kyriazis, George
> wrote:

On Jul 23, 2017, at 11:21 AM, Ilia Mirkin 
> wrote:

On Sun, Jul 23, 2017 at 12:08 PM, George Kyriazis
> wrote:

The shader that is used to copy vertex data out of the vs/gs shaders to
the user-specified buffer (streamout os SO shader) was not using the
correct offsets.

Adjust the offsets that are used just for the SO shader:
- Make sure that position is handled in the same special way
as in the vs/gs shaders
- Use the correct offset to be passed in the core
- consolidate register slot mapping logic into one function, since it's
been calculated in 2 different places (one for calcuating the slot mask,
and one for the register offsets themselves

Also make room for all attibutes in the backend vertex area.

Fixes:
- all vtk GL2PS tests
- 18 piglit tests (16 ext_transform_feedback tests,
arb-quads-follow-provoking-vertex and primitive-type gl_points
---
src/gallium/drivers/swr/swr_draw.cpp  | 11 ---
src/gallium/drivers/swr/swr_state.cpp | 31 +--
src/gallium/drivers/swr/swr_state.h   |  3 +++
3 files changed, 40 insertions(+), 5 deletions(-)

diff --git a/src/gallium/drivers/swr/swr_draw.cpp
b/src/gallium/drivers/swr/swr_draw.cpp
index 62ad3f7..218de0f 100644
--- a/src/gallium/drivers/swr/swr_draw.cpp
+++ b/src/gallium/drivers/swr/swr_draw.cpp
@@ -26,6 +26,7 @@
#include "swr_resource.h"
#include "swr_fence.h"
#include "swr_query.h"
+#include "swr_state.h"
#include "jit_api.h"

#include "util/u_draw.h"
@@ -81,8 +82,11 @@ swr_draw_vbo(struct pipe_context *pipe, const struct
pipe_draw_info *info)
  offsets[output_buffer] = so->output[i].dst_offset;
   }

+unsigned attrib_slot = so->output[i].register_index;
+attrib_slot = swr_so_adjust_attrib(attrib_slot, ctx->vs);
+
   state.stream.decl[num].bufferIndex = output_buffer;
-state.stream.decl[num].attribSlot =
so->output[i].register_index - 1;
+state.stream.decl[num].attribSlot = attrib_slot;
   state.stream.decl[num].componentMask =
  ((1 << so->output[i].num_components) - 1)
  << so->output[i].start_component;
@@ -130,9 +134,10 @@ swr_draw_vbo(struct pipe_context *pipe, const struct
pipe_draw_info *info)
  SWR_FRONTEND_STATE feState = {0};

  feState.vsVertexSize =
-  VERTEX_ATTRIB_START_SLOT +
+  VERTEX_ATTRIB_START_SLOT
 + ctx->vs->info.base.num_outputs
-  - (ctx->vs->info.base.writes_position ? 1 : 0);
+  - (ctx->vs->info.base.writes_position ? 1 : 0)
+  + ctx->fs->info.base.num_outputs;

Why do you care about the number of fs outputs in the vertex size?

In theory, there shouldn’t be, but, as I said in my previous email, the clipper 
and dinner have some dependency that forces them to use the same vertex size.  
It could be changed, but it’s a much more intrusive change.


  if (ctx->rasterizer->flatshade_first) {
 feState.provokingVertex = {1, 0, 0};
diff --git a/src/gallium/drivers/swr/swr_state.cpp
b/src/gallium/drivers/swr/swr_state.cpp
index 501fdea..3e07929 100644
--- a/src/gallium/drivers/swr/swr_state.cpp
+++ b/src/gallium/drivers/swr/swr_state.cpp
@@ -345,13 +345,15 @@ swr_create_vs_state(struct pipe_context *pipe,
 // soState.streamToRasterizer not used

 for (uint32_t i = 0; i < stream_output->num_outputs; i++) {
+ unsigned attrib_slot = stream_output->output[i].register_index;
+ attrib_slot = swr_so_adjust_attrib(attrib_slot, swr_vs);
swr_vs->soState.streamMasks[stream_output->output[i].stream] |=
-1 << (stream_output->output[i].register_index - 1);
+(1 << attrib_slot);
 }
 for (uint32_t i = 0; i < MAX_SO_STREAMS; i++) {
   swr_vs->soState.streamNumEntries[i] =
_mm_popcnt_u32(swr_vs->soState.streamMasks[i]);
-swr_vs->soState.vertexAttribOffset[i] = VERTEX_ATTRIB_START_SLOT;
// TODO: optimize
+swr_vs->soState.vertexAttribOffset[i] = 0;
  }
  }

@@ -1777,6 +1779,31 @@ swr_update_derived(struct pipe_context *pipe,
  ctx->dirty = post_update_dirty_flags;
}

+unsigned
+swr_so_adjust_attrib(unsigned in_attrib,
+ swr_vertex_shader *swr_vs)
+{
+   ubyte semantic_name;
+   unsigned attrib;
+
+   attrib = in_attrib + VERTEX_ATTRIB_START_SLOT;
+
+   if (swr_vs) {
+  semantic_name = swr_vs->info.base.output_semantic_name[in_attrib];
+  if (semantic_name == TGSI_SEMANTIC_POSITION) {


But it's not just the position... there are plenty of other attributes
that need similar treatment. e.g. pointsize, layer, viewport index.


Yes, we want to deal with the other attributes, too, but lack the testing
time, due to the 17.2 schedule.  Since 

Re: [Mesa-dev] [PATCH] swr: fix transform feedback logic

2017-07-23 Thread Kyriazis, George

On Jul 23, 2017, at 1:42 PM, Rowley, Timothy O 
> wrote:


On Jul 23, 2017, at 11:08 AM, George Kyriazis 
> wrote:

The shader that is used to copy vertex data out of the vs/gs shaders to
the user-specified buffer (streamout os SO shader) was not using the
correct offsets.

Adjust the offsets that are used just for the SO shader:
- Make sure that position is handled in the same special way
as in the vs/gs shaders
- Use the correct offset to be passed in the core
- consolidate register slot mapping logic into one function, since it's
been calculated in 2 different places (one for calcuating the slot mask,
and one for the register offsets themselves

Also make room for all attibutes in the backend vertex area.

Add a comment to the commit indicating that as Ilia states, this is not a 
complete solution.

Ok


Fixes:
- all vtk GL2PS tests
- 18 piglit tests (16 ext_transform_feedback tests,
arb-quads-follow-provoking-vertex and primitive-type gl_points
---
src/gallium/drivers/swr/swr_draw.cpp  | 11 ---
src/gallium/drivers/swr/swr_state.cpp | 31 +--
src/gallium/drivers/swr/swr_state.h   |  3 +++
3 files changed, 40 insertions(+), 5 deletions(-)

diff --git a/src/gallium/drivers/swr/swr_draw.cpp 
b/src/gallium/drivers/swr/swr_draw.cpp
index 62ad3f7..218de0f 100644
--- a/src/gallium/drivers/swr/swr_draw.cpp
+++ b/src/gallium/drivers/swr/swr_draw.cpp
@@ -26,6 +26,7 @@
#include "swr_resource.h"
#include "swr_fence.h"
#include "swr_query.h"
+#include "swr_state.h"
#include "jit_api.h"

#include "util/u_draw.h"
@@ -81,8 +82,11 @@ swr_draw_vbo(struct pipe_context *pipe, const struct 
pipe_draw_info *info)
  offsets[output_buffer] = so->output[i].dst_offset;
   }

+unsigned attrib_slot = so->output[i].register_index;
+attrib_slot = swr_so_adjust_attrib(attrib_slot, ctx->vs);
+
   state.stream.decl[num].bufferIndex = output_buffer;
-state.stream.decl[num].attribSlot = so->output[i].register_index - 
1;
+state.stream.decl[num].attribSlot = attrib_slot;
   state.stream.decl[num].componentMask =
  ((1 << so->output[i].num_components) - 1)
  << so->output[i].start_component;
@@ -130,9 +134,10 @@ swr_draw_vbo(struct pipe_context *pipe, const struct 
pipe_draw_info *info)
  SWR_FRONTEND_STATE feState = {0};

  feState.vsVertexSize =
-  VERTEX_ATTRIB_START_SLOT +
+  VERTEX_ATTRIB_START_SLOT
 + ctx->vs->info.base.num_outputs
-  - (ctx->vs->info.base.writes_position ? 1 : 0);
+  - (ctx->vs->info.base.writes_position ? 1 : 0)
+  + ctx->fs->info.base.num_outputs;

Sizing vsVertexSize to essentially vs->num_outputs + fs->num_outputs seems odd, 
as the fe shouldn’t care about the number of outputs of the fs (inputs, maybe).

The clipper/binner code uses the stride (which originates from vsVertexSize) to 
create the intermediate vertices for the backend.  The sizes for the FE and BE 
are bound by the same size because of that.  In order to size the vertices to 
the absolute minimum size, you’ll have to do more intrusive changes in the core 
to decouple the two.

  if (ctx->rasterizer->flatshade_first) {
 feState.provokingVertex = {1, 0, 0};
diff --git a/src/gallium/drivers/swr/swr_state.cpp 
b/src/gallium/drivers/swr/swr_state.cpp
index 501fdea..3e07929 100644
--- a/src/gallium/drivers/swr/swr_state.cpp
+++ b/src/gallium/drivers/swr/swr_state.cpp
@@ -345,13 +345,15 @@ swr_create_vs_state(struct pipe_context *pipe,
 // soState.streamToRasterizer not used

 for (uint32_t i = 0; i < stream_output->num_outputs; i++) {
+ unsigned attrib_slot = stream_output->output[i].register_index;
+ attrib_slot = swr_so_adjust_attrib(attrib_slot, swr_vs);
swr_vs->soState.streamMasks[stream_output->output[i].stream] |=
-1 << (stream_output->output[i].register_index - 1);
+(1 << attrib_slot);
 }
 for (uint32_t i = 0; i < MAX_SO_STREAMS; i++) {
   swr_vs->soState.streamNumEntries[i] =
_mm_popcnt_u32(swr_vs->soState.streamMasks[i]);
-swr_vs->soState.vertexAttribOffset[i] = VERTEX_ATTRIB_START_SLOT; // 
TODO: optimize
+swr_vs->soState.vertexAttribOffset[i] = 0;
  }
  }

@@ -1777,6 +1779,31 @@ swr_update_derived(struct pipe_context *pipe,
  ctx->dirty = post_update_dirty_flags;
}

+unsigned
+swr_so_adjust_attrib(unsigned in_attrib,
+ swr_vertex_shader *swr_vs)
+{
+   ubyte semantic_name;
+   unsigned attrib;
+
+   attrib = in_attrib + VERTEX_ATTRIB_START_SLOT;
+
+   if (swr_vs) {
+  semantic_name = swr_vs->info.base.output_semantic_name[in_attrib];
+  if (semantic_name == TGSI_SEMANTIC_POSITION) {
+ attrib = VERTEX_POSITION_SLOT;
+  } else {
+ for (int i = 0; i < PIPE_MAX_SHADER_OUTPUTS; i++) {
+if 

Re: [Mesa-dev] [PATCH] swr: fix transform feedback logic

2017-07-23 Thread Ilia Mirkin
On Sun, Jul 23, 2017 at 12:27 PM, Kyriazis, George
 wrote:
>
> On Jul 23, 2017, at 11:21 AM, Ilia Mirkin  wrote:
>
> On Sun, Jul 23, 2017 at 12:08 PM, George Kyriazis
>  wrote:
>
> The shader that is used to copy vertex data out of the vs/gs shaders to
> the user-specified buffer (streamout os SO shader) was not using the
> correct offsets.
>
> Adjust the offsets that are used just for the SO shader:
> - Make sure that position is handled in the same special way
>  as in the vs/gs shaders
> - Use the correct offset to be passed in the core
> - consolidate register slot mapping logic into one function, since it's
>  been calculated in 2 different places (one for calcuating the slot mask,
>  and one for the register offsets themselves
>
> Also make room for all attibutes in the backend vertex area.
>
> Fixes:
> - all vtk GL2PS tests
> - 18 piglit tests (16 ext_transform_feedback tests,
>  arb-quads-follow-provoking-vertex and primitive-type gl_points
> ---
> src/gallium/drivers/swr/swr_draw.cpp  | 11 ---
> src/gallium/drivers/swr/swr_state.cpp | 31 +--
> src/gallium/drivers/swr/swr_state.h   |  3 +++
> 3 files changed, 40 insertions(+), 5 deletions(-)
>
> diff --git a/src/gallium/drivers/swr/swr_draw.cpp
> b/src/gallium/drivers/swr/swr_draw.cpp
> index 62ad3f7..218de0f 100644
> --- a/src/gallium/drivers/swr/swr_draw.cpp
> +++ b/src/gallium/drivers/swr/swr_draw.cpp
> @@ -26,6 +26,7 @@
> #include "swr_resource.h"
> #include "swr_fence.h"
> #include "swr_query.h"
> +#include "swr_state.h"
> #include "jit_api.h"
>
> #include "util/u_draw.h"
> @@ -81,8 +82,11 @@ swr_draw_vbo(struct pipe_context *pipe, const struct
> pipe_draw_info *info)
>offsets[output_buffer] = so->output[i].dst_offset;
> }
>
> +unsigned attrib_slot = so->output[i].register_index;
> +attrib_slot = swr_so_adjust_attrib(attrib_slot, ctx->vs);
> +
> state.stream.decl[num].bufferIndex = output_buffer;
> -state.stream.decl[num].attribSlot =
> so->output[i].register_index - 1;
> +state.stream.decl[num].attribSlot = attrib_slot;
> state.stream.decl[num].componentMask =
>((1 << so->output[i].num_components) - 1)
><< so->output[i].start_component;
> @@ -130,9 +134,10 @@ swr_draw_vbo(struct pipe_context *pipe, const struct
> pipe_draw_info *info)
>SWR_FRONTEND_STATE feState = {0};
>
>feState.vsVertexSize =
> -  VERTEX_ATTRIB_START_SLOT +
> +  VERTEX_ATTRIB_START_SLOT
>   + ctx->vs->info.base.num_outputs
> -  - (ctx->vs->info.base.writes_position ? 1 : 0);
> +  - (ctx->vs->info.base.writes_position ? 1 : 0)
> +  + ctx->fs->info.base.num_outputs;

Why do you care about the number of fs outputs in the vertex size?

>
>if (ctx->rasterizer->flatshade_first) {
>   feState.provokingVertex = {1, 0, 0};
> diff --git a/src/gallium/drivers/swr/swr_state.cpp
> b/src/gallium/drivers/swr/swr_state.cpp
> index 501fdea..3e07929 100644
> --- a/src/gallium/drivers/swr/swr_state.cpp
> +++ b/src/gallium/drivers/swr/swr_state.cpp
> @@ -345,13 +345,15 @@ swr_create_vs_state(struct pipe_context *pipe,
>   // soState.streamToRasterizer not used
>
>   for (uint32_t i = 0; i < stream_output->num_outputs; i++) {
> + unsigned attrib_slot = stream_output->output[i].register_index;
> + attrib_slot = swr_so_adjust_attrib(attrib_slot, swr_vs);
>  swr_vs->soState.streamMasks[stream_output->output[i].stream] |=
> -1 << (stream_output->output[i].register_index - 1);
> +(1 << attrib_slot);
>   }
>   for (uint32_t i = 0; i < MAX_SO_STREAMS; i++) {
> swr_vs->soState.streamNumEntries[i] =
>  _mm_popcnt_u32(swr_vs->soState.streamMasks[i]);
> -swr_vs->soState.vertexAttribOffset[i] = VERTEX_ATTRIB_START_SLOT;
> // TODO: optimize
> +swr_vs->soState.vertexAttribOffset[i] = 0;
>}
>}
>
> @@ -1777,6 +1779,31 @@ swr_update_derived(struct pipe_context *pipe,
>ctx->dirty = post_update_dirty_flags;
> }
>
> +unsigned
> +swr_so_adjust_attrib(unsigned in_attrib,
> + swr_vertex_shader *swr_vs)
> +{
> +   ubyte semantic_name;
> +   unsigned attrib;
> +
> +   attrib = in_attrib + VERTEX_ATTRIB_START_SLOT;
> +
> +   if (swr_vs) {
> +  semantic_name = swr_vs->info.base.output_semantic_name[in_attrib];
> +  if (semantic_name == TGSI_SEMANTIC_POSITION) {
>
>
> But it's not just the position... there are plenty of other attributes
> that need similar treatment. e.g. pointsize, layer, viewport index.
>
>
> Yes, we want to deal with the other attributes, too, but lack the testing
> time, due to the 17.2 schedule.  Since position fixes the vtk tests (that we
> are mostly concerned about), that is what this patch covers.  It’s in our
> plan to deal with the rest of the attributes in the near future 

Re: [Mesa-dev] [PATCH] swr: fix transform feedback logic

2017-07-23 Thread Rowley, Timothy O

> On Jul 23, 2017, at 11:08 AM, George Kyriazis  
> wrote:
> 
> The shader that is used to copy vertex data out of the vs/gs shaders to
> the user-specified buffer (streamout os SO shader) was not using the
> correct offsets.
> 
> Adjust the offsets that are used just for the SO shader:
> - Make sure that position is handled in the same special way
>  as in the vs/gs shaders
> - Use the correct offset to be passed in the core
> - consolidate register slot mapping logic into one function, since it's
>  been calculated in 2 different places (one for calcuating the slot mask,
>  and one for the register offsets themselves
> 
> Also make room for all attibutes in the backend vertex area.

Add a comment to the commit indicating that as Ilia states, this is not a 
complete solution.

> 
> Fixes:
> - all vtk GL2PS tests
> - 18 piglit tests (16 ext_transform_feedback tests,
>  arb-quads-follow-provoking-vertex and primitive-type gl_points
> ---
> src/gallium/drivers/swr/swr_draw.cpp  | 11 ---
> src/gallium/drivers/swr/swr_state.cpp | 31 +--
> src/gallium/drivers/swr/swr_state.h   |  3 +++
> 3 files changed, 40 insertions(+), 5 deletions(-)
> 
> diff --git a/src/gallium/drivers/swr/swr_draw.cpp 
> b/src/gallium/drivers/swr/swr_draw.cpp
> index 62ad3f7..218de0f 100644
> --- a/src/gallium/drivers/swr/swr_draw.cpp
> +++ b/src/gallium/drivers/swr/swr_draw.cpp
> @@ -26,6 +26,7 @@
> #include "swr_resource.h"
> #include "swr_fence.h"
> #include "swr_query.h"
> +#include "swr_state.h"
> #include "jit_api.h"
> 
> #include "util/u_draw.h"
> @@ -81,8 +82,11 @@ swr_draw_vbo(struct pipe_context *pipe, const struct 
> pipe_draw_info *info)
>offsets[output_buffer] = so->output[i].dst_offset;
> }
> 
> +unsigned attrib_slot = so->output[i].register_index;
> +attrib_slot = swr_so_adjust_attrib(attrib_slot, ctx->vs);
> +
> state.stream.decl[num].bufferIndex = output_buffer;
> -state.stream.decl[num].attribSlot = so->output[i].register_index 
> - 1;
> +state.stream.decl[num].attribSlot = attrib_slot;
> state.stream.decl[num].componentMask =
>((1 << so->output[i].num_components) - 1)
><< so->output[i].start_component;
> @@ -130,9 +134,10 @@ swr_draw_vbo(struct pipe_context *pipe, const struct 
> pipe_draw_info *info)
>SWR_FRONTEND_STATE feState = {0};
> 
>feState.vsVertexSize =
> -  VERTEX_ATTRIB_START_SLOT +
> +  VERTEX_ATTRIB_START_SLOT
>   + ctx->vs->info.base.num_outputs
> -  - (ctx->vs->info.base.writes_position ? 1 : 0);
> +  - (ctx->vs->info.base.writes_position ? 1 : 0)
> +  + ctx->fs->info.base.num_outputs;

Sizing vsVertexSize to essentially vs->num_outputs + fs->num_outputs seems odd, 
as the fe shouldn’t care about the number of outputs of the fs (inputs, maybe).

>if (ctx->rasterizer->flatshade_first) {
>   feState.provokingVertex = {1, 0, 0};
> diff --git a/src/gallium/drivers/swr/swr_state.cpp 
> b/src/gallium/drivers/swr/swr_state.cpp
> index 501fdea..3e07929 100644
> --- a/src/gallium/drivers/swr/swr_state.cpp
> +++ b/src/gallium/drivers/swr/swr_state.cpp
> @@ -345,13 +345,15 @@ swr_create_vs_state(struct pipe_context *pipe,
>   // soState.streamToRasterizer not used
> 
>   for (uint32_t i = 0; i < stream_output->num_outputs; i++) {
> + unsigned attrib_slot = stream_output->output[i].register_index;
> + attrib_slot = swr_so_adjust_attrib(attrib_slot, swr_vs);
>  swr_vs->soState.streamMasks[stream_output->output[i].stream] |=
> -1 << (stream_output->output[i].register_index - 1);
> +(1 << attrib_slot);
>   }
>   for (uint32_t i = 0; i < MAX_SO_STREAMS; i++) {
> swr_vs->soState.streamNumEntries[i] =
>  _mm_popcnt_u32(swr_vs->soState.streamMasks[i]);
> -swr_vs->soState.vertexAttribOffset[i] = VERTEX_ATTRIB_START_SLOT; // 
> TODO: optimize
> +swr_vs->soState.vertexAttribOffset[i] = 0;
>}
>}
> 
> @@ -1777,6 +1779,31 @@ swr_update_derived(struct pipe_context *pipe,
>ctx->dirty = post_update_dirty_flags;
> }
> 
> +unsigned
> +swr_so_adjust_attrib(unsigned in_attrib,
> + swr_vertex_shader *swr_vs)
> +{
> +   ubyte semantic_name;
> +   unsigned attrib;
> +
> +   attrib = in_attrib + VERTEX_ATTRIB_START_SLOT;
> +
> +   if (swr_vs) {
> +  semantic_name = swr_vs->info.base.output_semantic_name[in_attrib];
> +  if (semantic_name == TGSI_SEMANTIC_POSITION) {
> + attrib = VERTEX_POSITION_SLOT;
> +  } else {
> + for (int i = 0; i < PIPE_MAX_SHADER_OUTPUTS; i++) {
> +if (swr_vs->info.base.output_semantic_name[i] == 
> TGSI_SEMANTIC_POSITION) {
> +   attrib--;
> +   break;
> +}
> + }

Couldn’t this for loop be replaced with a “if 
(swr_vs->info.base.writes_position) attrib—;”?

> +  }

Re: [Mesa-dev] [PATCH 2/2] nv50/ir: improve POW lowering

2017-07-23 Thread Ilia Mirkin
This approach is generally right but implemented in the wrong place.
This "lowerPOW" happens pre-ssa. What actually needs to happen is that
this type of optimization is done at SSA time as part of
ConstantFolding. And the fallback for POW should be implemented as
part of the "legalize" step. That will potentially miss some
opportunities for CSE in case the same number is exponentiated to
different powers, but I think that's acceptable.

On Thu, Jun 22, 2017 at 3:28 PM, Karol Herbst  wrote:
> If the exponent is a small integer immediate value, we can lower POW to
> MULs instead to save a few instructions. Also MUL instructions execute
> faster than what we lower POW in the default case to.
>
> score change for GpuTest /test=pixmark_piano /benchmark /no_scorebox
> /msaa=0 /benchmark_duration_ms=6 /width=1024 /height=640:
> 1045 -> 1060
>
> changes in shader-db:
> total instructions in shared programs : 4350261 -> 4349451 (-0.02%)
> total gprs used in shared programs: 525853 -> 525861 (0.00%)
> total local used in shared programs   : 30081 -> 30081 (0.00%)
> total bytes used in shared programs   : 39865176 -> 39857712 (-0.02%)
>
> localgpr   inst  bytes
> helped   0   4 313 313
>   hurt   0  12   1   1
>
> Signed-off-by: Karol Herbst 
> ---
>  .../drivers/nouveau/codegen/nv50_ir_build_util.cpp | 49 
> ++
>  1 file changed, 49 insertions(+)
>
> diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_build_util.cpp 
> b/src/gallium/drivers/nouveau/codegen/nv50_ir_build_util.cpp
> index 5756e1b4d4..b31dcec1ab 100644
> --- a/src/gallium/drivers/nouveau/codegen/nv50_ir_build_util.cpp
> +++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_build_util.cpp
> @@ -640,6 +640,55 @@ bool
>  BuildUtil::lowerPOW(Instruction *i)
>  {
> LValue *val = getScratch();
> +   ImmediateValue imm;
> +
> +   if (i->src(1).getImmediate(imm)) {
> +  Value *src = i->getSrc(0);
> +  if (imm.isInteger(0)) {
> + i->op = OP_MOV;
> + i->setSrc(0, loadImm(NULL, 1));
> + i->setSrc(1, NULL);
> + return true;
> +  } else
> +  if (imm.isInteger(1)) {
> + i->op = OP_MOV;
> + i->setSrc(1, NULL);
> + return true;
> +  } else
> +  if (imm.isInteger(2)) {
> + i->op = OP_MUL;
> + i->setSrc(1, src);
> + return true;
> +  } else
> +  if (imm.isInteger(3)) {
> + mkOp2(OP_MUL, i->dType, val, src, src);
> + i->op = OP_MUL;
> + i->setSrc(1, val);
> + return true;
> +  } else
> +  if (imm.isInteger(4)) {
> + mkOp2(OP_MUL, i->dType, val, src, src);
> + i->op = OP_MUL;
> + i->setSrc(0, val);
> + i->setSrc(1, val);
> + return true;
> +  } else
> +  if (imm.isInteger(5)) {
> + mkOp2(OP_MUL, i->dType, val, src, src);
> + mkOp2(OP_MUL, i->dType, val, val, val);
> + i->op = OP_MUL;
> + i->setSrc(1, val);
> + return true;
> +  } else
> +  if (imm.isInteger(8)) {
> + mkOp2(OP_MUL, i->dType, val, src, src);
> + mkOp2(OP_MUL, i->dType, val, val, val);
> + i->op = OP_MUL;
> + i->setSrc(0, val);
> + i->setSrc(1, val);
> + return true;
> +  }
> +   }
>
> mkOp1(OP_LG2, TYPE_F32, val, i->getSrc(0));
> mkOp2(OP_MUL, TYPE_F32, val, i->getSrc(1), val)->dnz = 1;
> --
> 2.13.1
>
> ___
> 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] swr: fix transform feedback logic

2017-07-23 Thread Kyriazis, George

On Jul 23, 2017, at 11:21 AM, Ilia Mirkin 
> wrote:

On Sun, Jul 23, 2017 at 12:08 PM, George Kyriazis
> wrote:
The shader that is used to copy vertex data out of the vs/gs shaders to
the user-specified buffer (streamout os SO shader) was not using the
correct offsets.

Adjust the offsets that are used just for the SO shader:
- Make sure that position is handled in the same special way
 as in the vs/gs shaders
- Use the correct offset to be passed in the core
- consolidate register slot mapping logic into one function, since it's
 been calculated in 2 different places (one for calcuating the slot mask,
 and one for the register offsets themselves

Also make room for all attibutes in the backend vertex area.

Fixes:
- all vtk GL2PS tests
- 18 piglit tests (16 ext_transform_feedback tests,
 arb-quads-follow-provoking-vertex and primitive-type gl_points
---
src/gallium/drivers/swr/swr_draw.cpp  | 11 ---
src/gallium/drivers/swr/swr_state.cpp | 31 +--
src/gallium/drivers/swr/swr_state.h   |  3 +++
3 files changed, 40 insertions(+), 5 deletions(-)

diff --git a/src/gallium/drivers/swr/swr_draw.cpp 
b/src/gallium/drivers/swr/swr_draw.cpp
index 62ad3f7..218de0f 100644
--- a/src/gallium/drivers/swr/swr_draw.cpp
+++ b/src/gallium/drivers/swr/swr_draw.cpp
@@ -26,6 +26,7 @@
#include "swr_resource.h"
#include "swr_fence.h"
#include "swr_query.h"
+#include "swr_state.h"
#include "jit_api.h"

#include "util/u_draw.h"
@@ -81,8 +82,11 @@ swr_draw_vbo(struct pipe_context *pipe, const struct 
pipe_draw_info *info)
   offsets[output_buffer] = so->output[i].dst_offset;
}

+unsigned attrib_slot = so->output[i].register_index;
+attrib_slot = swr_so_adjust_attrib(attrib_slot, ctx->vs);
+
state.stream.decl[num].bufferIndex = output_buffer;
-state.stream.decl[num].attribSlot = so->output[i].register_index - 
1;
+state.stream.decl[num].attribSlot = attrib_slot;
state.stream.decl[num].componentMask =
   ((1 << so->output[i].num_components) - 1)
   << so->output[i].start_component;
@@ -130,9 +134,10 @@ swr_draw_vbo(struct pipe_context *pipe, const struct 
pipe_draw_info *info)
   SWR_FRONTEND_STATE feState = {0};

   feState.vsVertexSize =
-  VERTEX_ATTRIB_START_SLOT +
+  VERTEX_ATTRIB_START_SLOT
  + ctx->vs->info.base.num_outputs
-  - (ctx->vs->info.base.writes_position ? 1 : 0);
+  - (ctx->vs->info.base.writes_position ? 1 : 0)
+  + ctx->fs->info.base.num_outputs;

   if (ctx->rasterizer->flatshade_first) {
  feState.provokingVertex = {1, 0, 0};
diff --git a/src/gallium/drivers/swr/swr_state.cpp 
b/src/gallium/drivers/swr/swr_state.cpp
index 501fdea..3e07929 100644
--- a/src/gallium/drivers/swr/swr_state.cpp
+++ b/src/gallium/drivers/swr/swr_state.cpp
@@ -345,13 +345,15 @@ swr_create_vs_state(struct pipe_context *pipe,
  // soState.streamToRasterizer not used

  for (uint32_t i = 0; i < stream_output->num_outputs; i++) {
+ unsigned attrib_slot = stream_output->output[i].register_index;
+ attrib_slot = swr_so_adjust_attrib(attrib_slot, swr_vs);
 swr_vs->soState.streamMasks[stream_output->output[i].stream] |=
-1 << (stream_output->output[i].register_index - 1);
+(1 << attrib_slot);
  }
  for (uint32_t i = 0; i < MAX_SO_STREAMS; i++) {
swr_vs->soState.streamNumEntries[i] =
 _mm_popcnt_u32(swr_vs->soState.streamMasks[i]);
-swr_vs->soState.vertexAttribOffset[i] = VERTEX_ATTRIB_START_SLOT; // 
TODO: optimize
+swr_vs->soState.vertexAttribOffset[i] = 0;
   }
   }

@@ -1777,6 +1779,31 @@ swr_update_derived(struct pipe_context *pipe,
   ctx->dirty = post_update_dirty_flags;
}

+unsigned
+swr_so_adjust_attrib(unsigned in_attrib,
+ swr_vertex_shader *swr_vs)
+{
+   ubyte semantic_name;
+   unsigned attrib;
+
+   attrib = in_attrib + VERTEX_ATTRIB_START_SLOT;
+
+   if (swr_vs) {
+  semantic_name = swr_vs->info.base.output_semantic_name[in_attrib];
+  if (semantic_name == TGSI_SEMANTIC_POSITION) {

But it's not just the position... there are plenty of other attributes
that need similar treatment. e.g. pointsize, layer, viewport index.

Yes, we want to deal with the other attributes, too, but lack the testing time, 
due to the 17.2 schedule.  Since position fixes the vtk tests (that we are 
mostly concerned about), that is what this patch covers.  It’s in our plan to 
deal with the rest of the attributes in the near future (before we get 
distracted).

I tried to fix this a while back but IIRC my solution was left wanting:

https://github.com/imirkin/mesa/commits/swr

(see the WIP commits at the top).

I ended up getting distracted and never completed the work. Feel free
to copy/ignore/whatever the above commits. I also tried 

[Mesa-dev] [PATCH] amdgpu/addrlib: use initialization list in addrobject

2017-07-23 Thread Mystro256
Just a small patch to save a small amount of cycles, as it would be better
to use the initialization list here.

Bare with me if I sent this wrong, I don't typically use git-send-email.

Mystro256 (1):
  amdgpu/addrlib: use initialization list in addrobject

 src/amd/addrlib/core/addrobject.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

-- 
2.9.4

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


[Mesa-dev] [PATCH] amdgpu/addrlib: use initialization list in addrobject

2017-07-23 Thread Mystro256
---
 src/amd/addrlib/core/addrobject.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/amd/addrlib/core/addrobject.cpp 
b/src/amd/addrlib/core/addrobject.cpp
index dcdb1bf..ee2d9a9 100644
--- a/src/amd/addrlib/core/addrobject.cpp
+++ b/src/amd/addrlib/core/addrobject.cpp
@@ -61,9 +61,9 @@ Object::Object()
 *   Constructor for the Object class.
 

 */
-Object::Object(const Client* pClient)
+Object::Object(const Client* pClient):
+m_client (*pClient)
 {
-m_client = *pClient;
 }
 
 /**
-- 
2.9.4

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


Re: [Mesa-dev] [PATCH] swr: fix transform feedback logic

2017-07-23 Thread Ilia Mirkin
On Sun, Jul 23, 2017 at 12:08 PM, George Kyriazis
 wrote:
> The shader that is used to copy vertex data out of the vs/gs shaders to
> the user-specified buffer (streamout os SO shader) was not using the
> correct offsets.
>
> Adjust the offsets that are used just for the SO shader:
> - Make sure that position is handled in the same special way
>   as in the vs/gs shaders
> - Use the correct offset to be passed in the core
> - consolidate register slot mapping logic into one function, since it's
>   been calculated in 2 different places (one for calcuating the slot mask,
>   and one for the register offsets themselves
>
> Also make room for all attibutes in the backend vertex area.
>
> Fixes:
> - all vtk GL2PS tests
> - 18 piglit tests (16 ext_transform_feedback tests,
>   arb-quads-follow-provoking-vertex and primitive-type gl_points
> ---
>  src/gallium/drivers/swr/swr_draw.cpp  | 11 ---
>  src/gallium/drivers/swr/swr_state.cpp | 31 +--
>  src/gallium/drivers/swr/swr_state.h   |  3 +++
>  3 files changed, 40 insertions(+), 5 deletions(-)
>
> diff --git a/src/gallium/drivers/swr/swr_draw.cpp 
> b/src/gallium/drivers/swr/swr_draw.cpp
> index 62ad3f7..218de0f 100644
> --- a/src/gallium/drivers/swr/swr_draw.cpp
> +++ b/src/gallium/drivers/swr/swr_draw.cpp
> @@ -26,6 +26,7 @@
>  #include "swr_resource.h"
>  #include "swr_fence.h"
>  #include "swr_query.h"
> +#include "swr_state.h"
>  #include "jit_api.h"
>
>  #include "util/u_draw.h"
> @@ -81,8 +82,11 @@ swr_draw_vbo(struct pipe_context *pipe, const struct 
> pipe_draw_info *info)
> offsets[output_buffer] = so->output[i].dst_offset;
>  }
>
> +unsigned attrib_slot = so->output[i].register_index;
> +attrib_slot = swr_so_adjust_attrib(attrib_slot, ctx->vs);
> +
>  state.stream.decl[num].bufferIndex = output_buffer;
> -state.stream.decl[num].attribSlot = so->output[i].register_index 
> - 1;
> +state.stream.decl[num].attribSlot = attrib_slot;
>  state.stream.decl[num].componentMask =
> ((1 << so->output[i].num_components) - 1)
> << so->output[i].start_component;
> @@ -130,9 +134,10 @@ swr_draw_vbo(struct pipe_context *pipe, const struct 
> pipe_draw_info *info)
> SWR_FRONTEND_STATE feState = {0};
>
> feState.vsVertexSize =
> -  VERTEX_ATTRIB_START_SLOT +
> +  VERTEX_ATTRIB_START_SLOT
>+ ctx->vs->info.base.num_outputs
> -  - (ctx->vs->info.base.writes_position ? 1 : 0);
> +  - (ctx->vs->info.base.writes_position ? 1 : 0)
> +  + ctx->fs->info.base.num_outputs;
>
> if (ctx->rasterizer->flatshade_first) {
>feState.provokingVertex = {1, 0, 0};
> diff --git a/src/gallium/drivers/swr/swr_state.cpp 
> b/src/gallium/drivers/swr/swr_state.cpp
> index 501fdea..3e07929 100644
> --- a/src/gallium/drivers/swr/swr_state.cpp
> +++ b/src/gallium/drivers/swr/swr_state.cpp
> @@ -345,13 +345,15 @@ swr_create_vs_state(struct pipe_context *pipe,
>// soState.streamToRasterizer not used
>
>for (uint32_t i = 0; i < stream_output->num_outputs; i++) {
> + unsigned attrib_slot = stream_output->output[i].register_index;
> + attrib_slot = swr_so_adjust_attrib(attrib_slot, swr_vs);
>   swr_vs->soState.streamMasks[stream_output->output[i].stream] |=
> -1 << (stream_output->output[i].register_index - 1);
> +(1 << attrib_slot);
>}
>for (uint32_t i = 0; i < MAX_SO_STREAMS; i++) {
>  swr_vs->soState.streamNumEntries[i] =
>   _mm_popcnt_u32(swr_vs->soState.streamMasks[i]);
> -swr_vs->soState.vertexAttribOffset[i] = VERTEX_ATTRIB_START_SLOT; // 
> TODO: optimize
> +swr_vs->soState.vertexAttribOffset[i] = 0;
> }
> }
>
> @@ -1777,6 +1779,31 @@ swr_update_derived(struct pipe_context *pipe,
> ctx->dirty = post_update_dirty_flags;
>  }
>
> +unsigned
> +swr_so_adjust_attrib(unsigned in_attrib,
> + swr_vertex_shader *swr_vs)
> +{
> +   ubyte semantic_name;
> +   unsigned attrib;
> +
> +   attrib = in_attrib + VERTEX_ATTRIB_START_SLOT;
> +
> +   if (swr_vs) {
> +  semantic_name = swr_vs->info.base.output_semantic_name[in_attrib];
> +  if (semantic_name == TGSI_SEMANTIC_POSITION) {

But it's not just the position... there are plenty of other attributes
that need similar treatment. e.g. pointsize, layer, viewport index.

I tried to fix this a while back but IIRC my solution was left wanting:

https://github.com/imirkin/mesa/commits/swr

(see the WIP commits at the top).

I ended up getting distracted and never completed the work. Feel free
to copy/ignore/whatever the above commits. I also tried to provide a
ARB_tf2 impl as well (i.e. pause/resume).

> + attrib = VERTEX_POSITION_SLOT;
> +  } else {
> + for (int i = 0; i < PIPE_MAX_SHADER_OUTPUTS; i++) {
> +if 

[Mesa-dev] [PATCH] swr: fix transform feedback logic

2017-07-23 Thread George Kyriazis
The shader that is used to copy vertex data out of the vs/gs shaders to
the user-specified buffer (streamout os SO shader) was not using the
correct offsets.

Adjust the offsets that are used just for the SO shader:
- Make sure that position is handled in the same special way
  as in the vs/gs shaders
- Use the correct offset to be passed in the core
- consolidate register slot mapping logic into one function, since it's
  been calculated in 2 different places (one for calcuating the slot mask,
  and one for the register offsets themselves

Also make room for all attibutes in the backend vertex area.

Fixes:
- all vtk GL2PS tests
- 18 piglit tests (16 ext_transform_feedback tests,
  arb-quads-follow-provoking-vertex and primitive-type gl_points
---
 src/gallium/drivers/swr/swr_draw.cpp  | 11 ---
 src/gallium/drivers/swr/swr_state.cpp | 31 +--
 src/gallium/drivers/swr/swr_state.h   |  3 +++
 3 files changed, 40 insertions(+), 5 deletions(-)

diff --git a/src/gallium/drivers/swr/swr_draw.cpp 
b/src/gallium/drivers/swr/swr_draw.cpp
index 62ad3f7..218de0f 100644
--- a/src/gallium/drivers/swr/swr_draw.cpp
+++ b/src/gallium/drivers/swr/swr_draw.cpp
@@ -26,6 +26,7 @@
 #include "swr_resource.h"
 #include "swr_fence.h"
 #include "swr_query.h"
+#include "swr_state.h"
 #include "jit_api.h"
 
 #include "util/u_draw.h"
@@ -81,8 +82,11 @@ swr_draw_vbo(struct pipe_context *pipe, const struct 
pipe_draw_info *info)
offsets[output_buffer] = so->output[i].dst_offset;
 }
 
+unsigned attrib_slot = so->output[i].register_index;
+attrib_slot = swr_so_adjust_attrib(attrib_slot, ctx->vs);
+
 state.stream.decl[num].bufferIndex = output_buffer;
-state.stream.decl[num].attribSlot = so->output[i].register_index - 
1;
+state.stream.decl[num].attribSlot = attrib_slot;
 state.stream.decl[num].componentMask =
((1 << so->output[i].num_components) - 1)
<< so->output[i].start_component;
@@ -130,9 +134,10 @@ swr_draw_vbo(struct pipe_context *pipe, const struct 
pipe_draw_info *info)
SWR_FRONTEND_STATE feState = {0};
 
feState.vsVertexSize =
-  VERTEX_ATTRIB_START_SLOT +
+  VERTEX_ATTRIB_START_SLOT
   + ctx->vs->info.base.num_outputs
-  - (ctx->vs->info.base.writes_position ? 1 : 0);
+  - (ctx->vs->info.base.writes_position ? 1 : 0)
+  + ctx->fs->info.base.num_outputs;
 
if (ctx->rasterizer->flatshade_first) {
   feState.provokingVertex = {1, 0, 0};
diff --git a/src/gallium/drivers/swr/swr_state.cpp 
b/src/gallium/drivers/swr/swr_state.cpp
index 501fdea..3e07929 100644
--- a/src/gallium/drivers/swr/swr_state.cpp
+++ b/src/gallium/drivers/swr/swr_state.cpp
@@ -345,13 +345,15 @@ swr_create_vs_state(struct pipe_context *pipe,
   // soState.streamToRasterizer not used
 
   for (uint32_t i = 0; i < stream_output->num_outputs; i++) {
+ unsigned attrib_slot = stream_output->output[i].register_index;
+ attrib_slot = swr_so_adjust_attrib(attrib_slot, swr_vs);
  swr_vs->soState.streamMasks[stream_output->output[i].stream] |=
-1 << (stream_output->output[i].register_index - 1);
+(1 << attrib_slot);
   }
   for (uint32_t i = 0; i < MAX_SO_STREAMS; i++) {
 swr_vs->soState.streamNumEntries[i] =
  _mm_popcnt_u32(swr_vs->soState.streamMasks[i]);
-swr_vs->soState.vertexAttribOffset[i] = VERTEX_ATTRIB_START_SLOT; // 
TODO: optimize
+swr_vs->soState.vertexAttribOffset[i] = 0;
}
}
 
@@ -1777,6 +1779,31 @@ swr_update_derived(struct pipe_context *pipe,
ctx->dirty = post_update_dirty_flags;
 }
 
+unsigned
+swr_so_adjust_attrib(unsigned in_attrib,
+ swr_vertex_shader *swr_vs)
+{
+   ubyte semantic_name;
+   unsigned attrib;
+
+   attrib = in_attrib + VERTEX_ATTRIB_START_SLOT;
+
+   if (swr_vs) {
+  semantic_name = swr_vs->info.base.output_semantic_name[in_attrib];
+  if (semantic_name == TGSI_SEMANTIC_POSITION) {
+ attrib = VERTEX_POSITION_SLOT;
+  } else {
+ for (int i = 0; i < PIPE_MAX_SHADER_OUTPUTS; i++) {
+if (swr_vs->info.base.output_semantic_name[i] == 
TGSI_SEMANTIC_POSITION) {
+   attrib--;
+   break;
+}
+ }
+  }
+   }
+
+   return attrib;
+}
 
 static struct pipe_stream_output_target *
 swr_create_so_target(struct pipe_context *pipe,
diff --git a/src/gallium/drivers/swr/swr_state.h 
b/src/gallium/drivers/swr/swr_state.h
index 7940a96..8cbd463 100644
--- a/src/gallium/drivers/swr/swr_state.h
+++ b/src/gallium/drivers/swr/swr_state.h
@@ -110,6 +110,9 @@ struct swr_derived_state {
 void swr_update_derived(struct pipe_context *,
 const struct pipe_draw_info * = nullptr);
 
+unsigned swr_so_adjust_attrib(unsigned in_attrib,
+  swr_vertex_shader *swr_vs);
+
 /*
  * Conversion functions: 

[Mesa-dev] [PATCH] etnaviv: Clear lbl_usage array correctly

2017-07-23 Thread Wladimir J. van der Laan
Fill the entire array instead of just a quarter. This avoids
crashes with large shaders.
(currently this never causes a problem because shaders larger than 2048/4
instructions are not supported by this driver on any hardware, but it will
cause problems in the future)

Signed-off-by: Wladimir J. van der Laan 
---
 src/gallium/drivers/etnaviv/etnaviv_compiler.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/gallium/drivers/etnaviv/etnaviv_compiler.c 
b/src/gallium/drivers/etnaviv/etnaviv_compiler.c
index cc6bfc9..165ab74 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_compiler.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_compiler.c
@@ -2353,7 +2353,7 @@ etna_compile_shader(struct etna_shader_variant *v)
if (!c)
   return false;
 
-   memset(>lbl_usage, -1, ARRAY_SIZE(c->lbl_usage));
+   memset(>lbl_usage, -1, sizeof(c->lbl_usage));
 
const struct tgsi_token *tokens = v->shader->tokens;
 
-- 
2.7.4

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


[Mesa-dev] [Bug 97957] Awful screen tearing in a separate X server with DRI3

2017-07-23 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=97957

--- Comment #21 from Marcin Mielniczuk  ---
Thanks for fixing! I had a similar problems when using the modesetting driver,
I'll check if it's gone when this gets into a release. 

For completeness, I describe how the modesetting driver behaves with mesa :
whenever running Hedgewars with DRI3 enabled, I has a little screen tearing and
the display is blurry when moving around the cursor (moving around the
battlefield in the game). Disabling DRI3 (falling back to DRI2) fixed all
problems and the display was smooth again.
This happens even when running the game within a DE.

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