[Mesa-dev] [Bug 103699] Latest mesa breaks firefox on kde plasma with compositing on

2017-11-16 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=103699

--- Comment #12 from Tapani Pälli  ---
Created attachment 135537
  --> https://bugs.freedesktop.org/attachment.cgi?id=135537=edit
workaround

This patch (that simply rearranges visuals) fixes the issue.

-- 
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


[Mesa-dev] [PATCH] llvmpipe: fix snorm blending

2017-11-16 Thread sroland
From: Roland Scheidegger 

The blend math gets a bit funky due to inverse blend factors being
in range [0,2] rather than [-1,1], our normalized math can't really
cover this.
src_alpha_saturate blend factor has a similar problem too.
(Note that piglit fbo-blending-formats test is mostly useless for
anything but unorm formats, since not just all src/dst values are
between [0,1], but the tests are crafted in a way that the results
are between [0,1] too.)
---
 src/gallium/auxiliary/gallivm/lp_bld_arit.c |  10 +-
 src/gallium/auxiliary/gallivm/lp_bld_arit.h |   7 ++
 src/gallium/drivers/llvmpipe/lp_bld_blend.c | 120 +++-
 src/gallium/drivers/llvmpipe/lp_bld_blend_aos.c |  28 --
 4 files changed, 149 insertions(+), 16 deletions(-)

diff --git a/src/gallium/auxiliary/gallivm/lp_bld_arit.c 
b/src/gallium/auxiliary/gallivm/lp_bld_arit.c
index a1edd34..628dedd 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_arit.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_arit.c
@@ -548,10 +548,10 @@ lp_build_add(struct lp_build_context *bld,
if(a == bld->undef || b == bld->undef)
   return bld->undef;
 
-   if(bld->type.norm) {
+   if(type.norm) {
   const char *intrinsic = NULL;
 
-  if(a == bld->one || b == bld->one)
+  if(!type.sign && (a == bld->one || b == bld->one))
 return bld->one;
 
   if (!type.floating && !type.fixed) {
@@ -849,10 +849,10 @@ lp_build_sub(struct lp_build_context *bld,
if(a == b)
   return bld->zero;
 
-   if(bld->type.norm) {
+   if(type.norm) {
   const char *intrinsic = NULL;
 
-  if(b == bld->one)
+  if(!type.sign && b == bld->one)
 return bld->zero;
 
   if (!type.floating && !type.fixed) {
@@ -963,7 +963,7 @@ lp_build_sub(struct lp_build_context *bld,
  * @sa Michael Herf, The "double blend trick", May 2000, 
  * http://www.stereopsis.com/doubleblend.html
  */
-static LLVMValueRef
+LLVMValueRef
 lp_build_mul_norm(struct gallivm_state *gallivm,
   struct lp_type wide_type,
   LLVMValueRef a, LLVMValueRef b)
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_arit.h 
b/src/gallium/auxiliary/gallivm/lp_bld_arit.h
index 2a4137a..f5b2800 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_arit.h
+++ b/src/gallium/auxiliary/gallivm/lp_bld_arit.h
@@ -71,6 +71,13 @@ lp_build_sub(struct lp_build_context *bld,
  LLVMValueRef a,
  LLVMValueRef b);
 
+
+LLVMValueRef
+lp_build_mul_norm(struct gallivm_state *gallivm,
+  struct lp_type wide_type,
+  LLVMValueRef a,
+  LLVMValueRef b);
+
 LLVMValueRef
 lp_build_mul(struct lp_build_context *bld,
  LLVMValueRef a,
diff --git a/src/gallium/drivers/llvmpipe/lp_bld_blend.c 
b/src/gallium/drivers/llvmpipe/lp_bld_blend.c
index 1feb415..bd886dc 100644
--- a/src/gallium/drivers/llvmpipe/lp_bld_blend.c
+++ b/src/gallium/drivers/llvmpipe/lp_bld_blend.c
@@ -35,6 +35,7 @@
 #include "gallivm/lp_bld_swizzle.h"
 #include "gallivm/lp_bld_flow.h"
 #include "gallivm/lp_bld_debug.h"
+#include "gallivm/lp_bld_pack.h"
 
 #include "lp_bld_blend.h"
 
@@ -86,6 +87,56 @@ lp_build_blend_factor_complementary(unsigned src_factor, 
unsigned dst_factor)
 
 
 /**
+ * Whether this is a inverse blend factor
+ */
+static inline boolean
+is_inverse_factor(unsigned factor)
+{
+   return factor > 0x11;
+}
+
+
+/**
+ * Calculates the (expanded to wider type) multiplication
+ * of 2 normalized numbers.
+ */
+static void
+lp_build_mul_norm_expand(struct lp_build_context *bld,
+ LLVMValueRef a, LLVMValueRef b,
+ LLVMValueRef *resl, LLVMValueRef *resh,
+ boolean signedness_differs)
+{
+   const struct lp_type type = bld->type;
+   struct lp_type wide_type = lp_wider_type(type);
+   struct lp_type wide_type2 = wide_type;
+   struct lp_type type2 = type;
+   LLVMValueRef al, ah, bl, bh;
+
+   assert(lp_check_value(type, a));
+   assert(lp_check_value(type, b));
+   assert(!type.floating && !type.fixed && type.norm);
+
+   if(a == bld->zero || b == bld->zero) {
+  LLVMValueRef zero = LLVMConstNull(lp_build_vec_type(bld->gallivm, 
wide_type));
+  *resl = zero;
+  *resh = zero;
+  return;
+   }
+
+   if (signedness_differs) {
+  type2.sign = !type.sign;
+  wide_type2.sign = !wide_type2.sign;
+   }
+
+   lp_build_unpack2_native(bld->gallivm, type, wide_type, a, , );
+   lp_build_unpack2_native(bld->gallivm, type2, wide_type2, b, , );
+
+   *resl = lp_build_mul_norm(bld->gallivm, wide_type, al, bl);
+   *resh = lp_build_mul_norm(bld->gallivm, wide_type, ah, bh);
+}
+
+
+/**
  * @sa http://www.opengl.org/sdk/docs/man/xhtml/glBlendEquationSeparate.xml
  */
 LLVMValueRef
@@ -192,9 +243,72 @@ lp_build_blend(struct lp_build_context *bld,
if (optimise_only)
   return NULL;
 
-   src_term = lp_build_mul(bld, src, src_factor);
-   dst_term = lp_build_mul(bld, dst, dst_factor);
-   

Re: [Mesa-dev] [PATCH 01/28] vulkan/wsi: use function ptr definitions from the spec.

2017-11-16 Thread Jason Ekstrand
On November 16, 2017 21:40:42 Michael Schellenberger Costa 
 wrote:



Hi Jason,

-Ursprüngliche Nachricht-
Von: mesa-dev [mailto:mesa-dev-boun...@lists.freedesktop.org] Im Auftrag 
von Jason Ekstrand

Gesendet: Donnerstag, 16. November 2017 22:29
An: mesa-dev@lists.freedesktop.org
Cc: Dave Airlie 
Betreff: [Mesa-dev] [PATCH 01/28] vulkan/wsi: use function ptr definitions 
from the spec.


From: Dave Airlie 

This just seems cleaner, and we may expand this in future.

Signed-off-by: Dave Airlie 
---
 src/amd/vulkan/radv_wsi.c   | 3 ++-
 src/intel/vulkan/anv_wsi.c  | 3 ++-
 src/vulkan/wsi/wsi_common.h | 6 +++---
 src/vulkan/wsi/wsi_common_wayland.c | 2 +-
 4 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/src/amd/vulkan/radv_wsi.c b/src/amd/vulkan/radv_wsi.c
index 64f5b0d..98346ca 100644
--- a/src/amd/vulkan/radv_wsi.c
+++ b/src/amd/vulkan/radv_wsi.c
@@ -29,8 +29,9 @@
 #include "vk_util.h"
 #include "util/macros.h"

+#define WSI_CB(x) .x = radv_##x
 MAYBE_UNUSED static const struct wsi_callbacks wsi_cbs = {
-   .get_phys_device_format_properties = 
radv_GetPhysicalDeviceFormatProperties,

+   WSI_CB(GetPhysicalDeviceFormatProperties),

The indentation is wrong here.


Actually, the rest of this files uses tabs.  The old indentation was wrong.


--Michael

 };

 VkResult
diff --git a/src/intel/vulkan/anv_wsi.c b/src/intel/vulkan/anv_wsi.c
index 08d83cd..945b011 100644
--- a/src/intel/vulkan/anv_wsi.c
+++ b/src/intel/vulkan/anv_wsi.c
@@ -27,8 +27,9 @@
 #include "vk_util.h"

 #ifdef VK_USE_PLATFORM_WAYLAND_KHR
+#define WSI_CB(x) .x = anv_##x
 static const struct wsi_callbacks wsi_cbs = {
-   .get_phys_device_format_properties = anv_GetPhysicalDeviceFormatProperties,
+   WSI_CB(GetPhysicalDeviceFormatProperties),
 };
 #endif

diff --git a/src/vulkan/wsi/wsi_common.h b/src/vulkan/wsi/wsi_common.h
index 8166b7d..7be0182 100644
--- a/src/vulkan/wsi/wsi_common.h
+++ b/src/vulkan/wsi/wsi_common.h
@@ -118,11 +118,11 @@ struct wsi_device {
 struct wsi_interface *  wsi[VK_ICD_WSI_PLATFORM_MAX];
 };

+#define WSI_CB(cb) PFN_vk##cb cb
 struct wsi_callbacks {
-   void (*get_phys_device_format_properties)(VkPhysicalDevice physicalDevice,
- VkFormat format,
- VkFormatProperties 
*pFormatProperties);

+   WSI_CB(GetPhysicalDeviceFormatProperties);
 };
+#undef WSI_CB

 #define WSI_DEFINE_NONDISP_HANDLE_CASTS(__wsi_type, __VkType)  \
\
diff --git a/src/vulkan/wsi/wsi_common_wayland.c 
b/src/vulkan/wsi/wsi_common_wayland.c

index 4c94cd6..b93c3d7 100644
--- a/src/vulkan/wsi/wsi_common_wayland.c
+++ b/src/vulkan/wsi/wsi_common_wayland.c
@@ -84,7 +84,7 @@ wsi_wl_display_add_vk_format(struct wsi_wl_display 
*display, VkFormat format)

/* Don't add formats that aren't renderable. */
VkFormatProperties props;

-   
display->wsi_wl->cbs->get_phys_device_format_properties(display->wsi_wl->physical_device,
+   
display->wsi_wl->cbs->GetPhysicalDeviceFormatProperties(display->wsi_wl->physical_device,

format, );
if (!(props.optimalTilingFeatures & VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT))
   return;
--
2.5.0.400.gff86faf

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




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


Re: [Mesa-dev] [PATCH 07/18] intel/compiler: fix for memmove argument on annotating error

2017-11-16 Thread Matt Turner
On Wed, Nov 15, 2017 at 12:13 AM, Rogovin, Kevin
 wrote:
> I have just seen that I have had an epic brain lapse on this.
>
> The code is pretty clear, the correct value of count should be ann_count - i. 
> This is because:
>   a. The value of ann_count is the value of the array size BEFORE the insert; 
> this is clear from the code within the if (offset + ..) where it increments 
> ann_count.
>  b. Since ann_count is the size before the insert, it should move the content 
> in the open range [i, ann_count) to [i + 1, ann_count + 1); thus the number 
> of elements is given by ann_count - i.
>
> Changing the count to ann_count - i does the right thing, and also makes it 
> quite clear that Matt is correct on patch 11: that it was just papering over 
> a bug from using the wrong count value.

I think I used the wrong data structure :)

I reproduced the problem you were having and then got tired of
thinking about how to memmove elements. I rewrote the annotation code
yesterday to use a linked list, which is much more natural. I just
sent the patches. Attached is a patch you can squash into your series
in order to make it work on top of my series.

> However, once this is done, the build does assert() on some shaders that I 
> have; this is because it fails to understand some registers.

I think that's a result of the disassembler not knowing how to
disassemble sends/sendsc. Both Toni and Neil have written patches for
that. I'll see if I can rebase them.


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


[Mesa-dev] [PATCH 2/4] i965: Simplify annotation_insert_error()

2017-11-16 Thread Matt Turner
---
 src/intel/compiler/intel_asm_annotation.c | 15 ++-
 1 file changed, 6 insertions(+), 9 deletions(-)

diff --git a/src/intel/compiler/intel_asm_annotation.c 
b/src/intel/compiler/intel_asm_annotation.c
index b07a545a12..26ab4b9818 100644
--- a/src/intel/compiler/intel_asm_annotation.c
+++ b/src/intel/compiler/intel_asm_annotation.c
@@ -159,8 +159,6 @@ void
 annotation_insert_error(struct annotation_info *annotation, unsigned offset,
 const char *error)
 {
-   struct annotation *ann;
-
if (!annotation->ann_count)
   return;
 
@@ -175,7 +173,6 @@ annotation_insert_error(struct annotation_info *annotation, 
unsigned offset,
for (int i = 0; i < annotation->ann_count; i++) {
   struct annotation *cur = >ann[i];
   struct annotation *next = >ann[i + 1];
-  ann = cur;
 
   if (next->offset <= offset)
  continue;
@@ -190,11 +187,11 @@ annotation_insert_error(struct annotation_info 
*annotation, unsigned offset,
  next->block_start = NULL;
  annotation->ann_count++;
   }
-  break;
-   }
 
-   if (ann->error)
-  ralloc_strcat(>error, error);
-   else
-  ann->error = ralloc_strdup(annotation->mem_ctx, error);
+  if (cur->error)
+ ralloc_strcat(>error, error);
+  else
+ cur->error = ralloc_strdup(annotation->mem_ctx, error);
+  return;
+   }
 }
-- 
2.13.6

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


[Mesa-dev] [PATCH 3/4] i965: Rewrite disassembly annotation code

2017-11-16 Thread Matt Turner
The old code used an array to store each "instruction group" (the new,
better name than the old overloaded "annotation"), and required a
memmove() to shift elements over in the array when we needed to split a
group so that we could add an error message. This was confusing and
difficult to get right, not the least of which was  because the array
has a tail sentinel not included in .ann_count.

Instead use a linked list, a data structure made for efficient
insertion.
---
I'm admittedly doing a fair number of things in this patch. If requested,
I can attempt to split it up into smaller pieces.

 src/intel/compiler/brw_compile_clip.c |   2 +-
 src/intel/compiler/brw_eu.h   |   4 +-
 src/intel/compiler/brw_eu_compact.c   |  26 +++--
 src/intel/compiler/brw_eu_validate.c  |   6 +-
 src/intel/compiler/brw_fs_generator.cpp   |  21 ++--
 src/intel/compiler/brw_vec4_generator.cpp |  18 ++--
 src/intel/compiler/intel_asm_annotation.c | 173 +++---
 src/intel/compiler/intel_asm_annotation.h |  38 ---
 src/intel/compiler/test_eu_validate.cpp   |  17 ++-
 src/intel/tools/disasm.c  |  40 +++
 src/mesa/drivers/dri/i965/brw_ff_gs.c |   2 +-
 11 files changed, 177 insertions(+), 170 deletions(-)

diff --git a/src/intel/compiler/brw_compile_clip.c 
b/src/intel/compiler/brw_compile_clip.c
index 83788e4b64..c04d1a8277 100644
--- a/src/intel/compiler/brw_compile_clip.c
+++ b/src/intel/compiler/brw_compile_clip.c
@@ -79,7 +79,7 @@ brw_compile_clip(const struct brw_compiler *compiler,
   unreachable("not reached");
}
 
-   brw_compact_instructions(, 0, 0, NULL);
+   brw_compact_instructions(, 0, NULL);
 
*prog_data = c.prog_data;
 
diff --git a/src/intel/compiler/brw_eu.h b/src/intel/compiler/brw_eu.h
index 95503d5513..d66988da56 100644
--- a/src/intel/compiler/brw_eu.h
+++ b/src/intel/compiler/brw_eu.h
@@ -548,7 +548,7 @@ enum brw_conditional_mod brw_swap_cmod(uint32_t cmod);
 /* brw_eu_compact.c */
 void brw_init_compaction_tables(const struct gen_device_info *devinfo);
 void brw_compact_instructions(struct brw_codegen *p, int start_offset,
-  int num_annotations, struct annotation 
*annotation);
+  struct disasm_info *disasm);
 void brw_uncompact_instruction(const struct gen_device_info *devinfo,
brw_inst *dst, brw_compact_inst *src);
 bool brw_try_compact_instruction(const struct gen_device_info *devinfo,
@@ -560,7 +560,7 @@ void brw_debug_compact_uncompact(const struct 
gen_device_info *devinfo,
 /* brw_eu_validate.c */
 bool brw_validate_instructions(const struct gen_device_info *devinfo,
const void *assembly, int start_offset, int 
end_offset,
-   struct annotation_info *annotation);
+   struct disasm_info *disasm);
 
 static inline int
 next_offset(const struct gen_device_info *devinfo, void *store, int offset)
diff --git a/src/intel/compiler/brw_eu_compact.c 
b/src/intel/compiler/brw_eu_compact.c
index a9da46957a..3a3875356d 100644
--- a/src/intel/compiler/brw_eu_compact.c
+++ b/src/intel/compiler/brw_eu_compact.c
@@ -1486,7 +1486,7 @@ brw_init_compaction_tables(const struct gen_device_info 
*devinfo)
 
 void
 brw_compact_instructions(struct brw_codegen *p, int start_offset,
- int num_annotations, struct annotation *annotation)
+ struct disasm_info *disasm)
 {
if (unlikely(INTEL_DEBUG & DEBUG_NO_COMPACTION))
   return;
@@ -1501,7 +1501,7 @@ brw_compact_instructions(struct brw_codegen *p, int 
start_offset,
/* For an instruction at byte offset 8*i after compaction, this was its IP
 * (in 16-byte units) before compaction.
 */
-   int old_ip[(p->next_insn_offset - start_offset) / sizeof(brw_compact_inst)];
+   int old_ip[(p->next_insn_offset - start_offset) / sizeof(brw_compact_inst) 
+ 1];
 
if (devinfo->gen == 4 && !devinfo->is_g4x)
   return;
@@ -1556,6 +1556,12 @@ brw_compact_instructions(struct brw_codegen *p, int 
start_offset,
   }
}
 
+   /* Add an entry for the ending offset of the program. This greatly
+* simplifies the linked list walk at the end of the function.
+*/
+   old_ip[offset / sizeof(brw_compact_inst)] =
+  (p->next_insn_offset - start_offset) / sizeof(brw_inst);
+
/* Fix up control flow offsets. */
p->next_insn_offset = start_offset + offset;
for (offset = 0; offset < p->next_insn_offset - start_offset;
@@ -1651,21 +1657,21 @@ brw_compact_instructions(struct brw_codegen *p, int 
start_offset,
}
p->nr_insn = p->next_insn_offset / sizeof(brw_inst);
 
-   /* Update the instruction offsets for each annotation. */
-   if (annotation) {
-  for (int offset = 0, i = 0; i < num_annotations; i++) {
+   /* Update the instruction offsets for each group. */
+   if (disasm) {
+  int offset = 0;
+
+  foreach_list_typed(struct 

[Mesa-dev] [PATCH 4/4] i965: Rename intel_asm_annotation -> brw_disasm_info

2017-11-16 Thread Matt Turner
It was the only file named intel_* in the compiler.
---
 src/intel/Makefile.sources   | 6 +++---
 src/intel/compiler/{intel_asm_annotation.c => brw_disasm_info.c} | 2 +-
 src/intel/compiler/{intel_asm_annotation.h => brw_disasm_info.h} | 0
 src/intel/compiler/brw_eu.h  | 2 +-
 src/intel/compiler/brw_eu_compact.c  | 2 +-
 src/intel/compiler/meson.build   | 4 ++--
 6 files changed, 8 insertions(+), 8 deletions(-)
 rename src/intel/compiler/{intel_asm_annotation.c => brw_disasm_info.c} (99%)
 rename src/intel/compiler/{intel_asm_annotation.h => brw_disasm_info.h} (100%)

diff --git a/src/intel/Makefile.sources b/src/intel/Makefile.sources
index 5a09e6d916..cdb10ece35 100644
--- a/src/intel/Makefile.sources
+++ b/src/intel/Makefile.sources
@@ -38,6 +38,8 @@ COMPILER_FILES = \
compiler/brw_dead_control_flow.cpp \
compiler/brw_dead_control_flow.h \
compiler/brw_disasm.c \
+   compiler/brw_disasm_info.c \
+   compiler/brw_disasm_info.h \
compiler/brw_eu.c \
compiler/brw_eu_compact.c \
compiler/brw_eu_defines.h \
@@ -115,9 +117,7 @@ COMPILER_FILES = \
compiler/brw_vue_map.c \
compiler/brw_wm_iz.cpp \
compiler/gen6_gs_visitor.cpp \
-   compiler/gen6_gs_visitor.h \
-   compiler/intel_asm_annotation.c \
-   compiler/intel_asm_annotation.h
+   compiler/gen6_gs_visitor.h
 
 COMPILER_GENERATED_FILES = \
compiler/brw_nir_trig_workarounds.c
diff --git a/src/intel/compiler/intel_asm_annotation.c 
b/src/intel/compiler/brw_disasm_info.c
similarity index 99%
rename from src/intel/compiler/intel_asm_annotation.c
rename to src/intel/compiler/brw_disasm_info.c
index fa37f248d1..9d3962b94d 100644
--- a/src/intel/compiler/intel_asm_annotation.c
+++ b/src/intel/compiler/brw_disasm_info.c
@@ -23,8 +23,8 @@
 
 #include "brw_cfg.h"
 #include "brw_eu.h"
+#include "brw_disasm_info.h"
 #include "common/gen_debug.h"
-#include "intel_asm_annotation.h"
 #include "compiler/nir/nir.h"
 
 __attribute__((weak)) void nir_print_instr(const nir_instr *instr, FILE *fp) {}
diff --git a/src/intel/compiler/intel_asm_annotation.h 
b/src/intel/compiler/brw_disasm_info.h
similarity index 100%
rename from src/intel/compiler/intel_asm_annotation.h
rename to src/intel/compiler/brw_disasm_info.h
diff --git a/src/intel/compiler/brw_eu.h b/src/intel/compiler/brw_eu.h
index d66988da56..b5a206b3f1 100644
--- a/src/intel/compiler/brw_eu.h
+++ b/src/intel/compiler/brw_eu.h
@@ -37,7 +37,7 @@
 #include "brw_inst.h"
 #include "brw_eu_defines.h"
 #include "brw_reg.h"
-#include "intel_asm_annotation.h"
+#include "brw_disasm_info.h"
 
 #ifdef __cplusplus
 extern "C" {
diff --git a/src/intel/compiler/brw_eu_compact.c 
b/src/intel/compiler/brw_eu_compact.c
index 3a3875356d..3680adc801 100644
--- a/src/intel/compiler/brw_eu_compact.c
+++ b/src/intel/compiler/brw_eu_compact.c
@@ -74,7 +74,7 @@
 
 #include "brw_eu.h"
 #include "brw_shader.h"
-#include "intel_asm_annotation.h"
+#include "brw_disasm_info.h"
 #include "common/gen_debug.h"
 
 static const uint32_t g45_control_index_table[32] = {
diff --git a/src/intel/compiler/meson.build b/src/intel/compiler/meson.build
index d6fb8f4a64..fe0a1f6e8a 100644
--- a/src/intel/compiler/meson.build
+++ b/src/intel/compiler/meson.build
@@ -34,6 +34,8 @@ libintel_compiler_files = files(
   'brw_dead_control_flow.cpp',
   'brw_dead_control_flow.h',
   'brw_disasm.c',
+  'brw_disasm_info.c',
+  'brw_disasm_info.h',
   'brw_eu.c',
   'brw_eu_compact.c',
   'brw_eu_defines.h',
@@ -112,8 +114,6 @@ libintel_compiler_files = files(
   'brw_wm_iz.cpp',
   'gen6_gs_visitor.cpp',
   'gen6_gs_visitor.h',
-  'intel_asm_annotation.c',
-  'intel_asm_annotation.h',
 )
 
 brw_nir_trig = custom_target(
-- 
2.13.6

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


[Mesa-dev] [PATCH 1/4] i965: Move common code out of #ifdef

2017-11-16 Thread Matt Turner
I'm going to change the call in a later patch and with the difference in
indentation level it wasn't immediately obvious that the calls were
identical.
---
 src/intel/compiler/brw_fs_generator.cpp   | 7 ++-
 src/intel/compiler/brw_vec4_generator.cpp | 6 ++
 2 files changed, 4 insertions(+), 9 deletions(-)

diff --git a/src/intel/compiler/brw_fs_generator.cpp 
b/src/intel/compiler/brw_fs_generator.cpp
index 46f9a338ea..96691ac3ff 100644
--- a/src/intel/compiler/brw_fs_generator.cpp
+++ b/src/intel/compiler/brw_fs_generator.cpp
@@ -2192,17 +2192,14 @@ fs_generator::generate_code(const cfg_t *cfg, int 
dispatch_width)
annotation_finalize(, p->next_insn_offset);
 
 #ifndef NDEBUG
-   bool validated = brw_validate_instructions(devinfo, p->store,
-  start_offset,
-  p->next_insn_offset,
-  );
+   bool validated =
 #else
if (unlikely(debug_flag))
+#endif
   brw_validate_instructions(devinfo, p->store,
 start_offset,
 p->next_insn_offset,
 );
-#endif
 
int before_size = p->next_insn_offset - start_offset;
brw_compact_instructions(p, start_offset, annotation.ann_count,
diff --git a/src/intel/compiler/brw_vec4_generator.cpp 
b/src/intel/compiler/brw_vec4_generator.cpp
index bde4110e54..63831e4ad6 100644
--- a/src/intel/compiler/brw_vec4_generator.cpp
+++ b/src/intel/compiler/brw_vec4_generator.cpp
@@ -2178,15 +2178,13 @@ generate_code(struct brw_codegen *p,
annotation_finalize(, p->next_insn_offset);
 
 #ifndef NDEBUG
-   bool validated = brw_validate_instructions(devinfo, p->store,
-  0, p->next_insn_offset,
-  );
+   bool validated =
 #else
if (unlikely(debug_flag))
+#endif
   brw_validate_instructions(devinfo, p->store,
 0, p->next_insn_offset,
 );
-#endif
 
int before_size = p->next_insn_offset;
brw_compact_instructions(p, 0, annotation.ann_count, annotation.ann);
-- 
2.13.6

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


Re: [Mesa-dev] [PATCH] egl: refactor color_buffers structure for deduplicating (v2)

2017-11-16 Thread Tomasz Figa
Hi Gwan-gyeong,

Thanks for the patch!

On Wed, Nov 15, 2017 at 11:27 PM, Gwan-gyeong Mun  wrote:
> This is added for preventing adding of new color buffers structure and back*
> when new platform backend is added.
> This refactoring separates out the common and platform specific bits.
> This makes odd casting in the platform_foo.c but it prevents adding of new
> ifdef magic.
> Because of color_buffers array size is different on android and wayland /drm,
> it adds COLOR_BUFFERS_SIZE macro.
>  - android's color buffers array size is 3.
>drm & wayland's color buffers array size is 4.
>
> Fixes from Rob's review:
>  - refactor to separate out the common and platform specific bits.
>
> Fixes from Emil's review:
>  - use suggested color buffers structure shape.
>it makes a buffer pointer of each platform to void pointer type.
>
> v2: Fixes from Emil's review
>   a) change ifdef macro of "HAVE_WAYLAND_PLATFORM or HAVE_DRM_PLATFORM" to
>  "HAVE_ANDROID_PLATFORM" for COLOR_BUFFERS_SIZE.
>   b) drop the unneeded indentation of comment.
>   c) drop ifdef macro of HAVE_WAYLAND_PLATFORM from color_buffers structure
>  for more generic and widespread helpers.
>   d) drop unneeded $native_type -> void * cast and viceversa.
>   e) create the local native_buffer of $native_type and cast on assignment.
>
> Signed-off-by: Mun Gwan-gyeong 

The Android part looks good to me:

Reviewed-by: Tomasz Figa 

I think this patch actually enables us to do some further cleanup in
Android part. I'll try to send follow up patches in near future.

Best regards,
Tomasz

> ---
>  src/egl/drivers/dri2/egl_dri2.h | 32 --
>  src/egl/drivers/dri2/platform_android.c | 10 +++---
>  src/egl/drivers/dri2/platform_drm.c | 60 
> ++---
>  src/egl/drivers/dri2/platform_wayland.c | 41 +++---
>  4 files changed, 73 insertions(+), 70 deletions(-)
>
> diff --git a/src/egl/drivers/dri2/egl_dri2.h b/src/egl/drivers/dri2/egl_dri2.h
> index 0ec8f44dce..cbeedadd4b 100644
> --- a/src/egl/drivers/dri2/egl_dri2.h
> +++ b/src/egl/drivers/dri2/egl_dri2.h
> @@ -65,6 +65,15 @@ struct zwp_linux_dmabuf_v1;
>
>  #endif /* HAVE_ANDROID_PLATFORM */
>
> +#ifdef HAVE_ANDROID_PLATFORM
> +/* Usually Android uses at most triple buffers in ANativeWindow so hardcode
> + * the number of color_buffers to 3.
> + */
> +#define COLOR_BUFFERS_SIZE 3
> +#else
> +#define COLOR_BUFFERS_SIZE 4
> +#endif
> +
>  #include "eglconfig.h"
>  #include "eglcontext.h"
>  #include "egldisplay.h"
> @@ -280,39 +289,26 @@ struct dri2_egl_surface
> /* EGL-owned buffers */
> __DRIbuffer   *local_buffers[__DRI_BUFFER_COUNT];
>
> -#if defined(HAVE_WAYLAND_PLATFORM) || defined(HAVE_DRM_PLATFORM)
> +   /* Used to record all the buffers created by each platform's native window
> +* and their ages.
> +*/
> struct {
> -#ifdef HAVE_WAYLAND_PLATFORM
> -  struct wl_buffer   *wl_buffer;
> +  void *native_buffer; // aka wl_buffer/gbm_bo/ANativeWindowBuffer
>__DRIimage *dri_image;
>/* for is_different_gpu case. NULL else */
>__DRIimage *linear_copy;
>/* for swrast */
>void *data;
>int data_size;
> -#endif
> -#ifdef HAVE_DRM_PLATFORM
> -  struct gbm_bo   *bo;
> -#endif
>boollocked;
>int age;
> -   } color_buffers[4], *back, *current;
> -#endif
> +   } color_buffers[COLOR_BUFFERS_SIZE], *back, *current;
>
>  #ifdef HAVE_ANDROID_PLATFORM
> struct ANativeWindow *window;
> struct ANativeWindowBuffer *buffer;
> __DRIimage *dri_image_back;
> __DRIimage *dri_image_front;
> -
> -   /* Used to record all the buffers created by ANativeWindow and their ages.
> -* Usually Android uses at most triple buffers in ANativeWindow
> -* so hardcode the number of color_buffers to 3.
> -*/
> -   struct {
> -  struct ANativeWindowBuffer *buffer;
> -  int age;
> -   } color_buffers[3], *back;
>  #endif
>
>  #if defined(HAVE_SURFACELESS_PLATFORM)
> diff --git a/src/egl/drivers/dri2/platform_android.c 
> b/src/egl/drivers/dri2/platform_android.c
> index 63223e9a69..24e5ddebf9 100644
> --- a/src/egl/drivers/dri2/platform_android.c
> +++ b/src/egl/drivers/dri2/platform_android.c
> @@ -193,10 +193,10 @@ droid_window_dequeue_buffer(struct dri2_egl_surface 
> *dri2_surf)
>  */
> EGLBoolean updated = EGL_FALSE;
> for (int i = 0; i < ARRAY_SIZE(dri2_surf->color_buffers); i++) {
> -  if (!dri2_surf->color_buffers[i].buffer) {
> - dri2_surf->color_buffers[i].buffer = dri2_surf->buffer;
> +  if (!dri2_surf->color_buffers[i].native_buffer) {
> + dri2_surf->color_buffers[i].native_buffer = dri2_surf->buffer;
>}
> -  if (dri2_surf->color_buffers[i].buffer == dri2_surf->buffer) {
> +  if (dri2_surf->color_buffers[i].native_buffer == dri2_surf->buffer) {
>   

[Mesa-dev] [PATCH] r600: add ARB_shader_storage_buffer_object support (v2)

2017-11-16 Thread Dave Airlie
From: Dave Airlie 

This just builds on the image support. Evergreen only has ssbo
for fragment and compute no other stages.

v2: handle images and ssbo in the same shader properly (Ilia)
---
 docs/features.txt|   4 +-
 src/gallium/drivers/r600/evergreen_state.c   | 131 ++-
 src/gallium/drivers/r600/r600_pipe.c |   7 +-
 src/gallium/drivers/r600/r600_pipe.h |   4 +-
 src/gallium/drivers/r600/r600_shader.c   |  85 -
 src/gallium/drivers/r600/r600_state_common.c |  18 
 6 files changed, 238 insertions(+), 11 deletions(-)

diff --git a/docs/features.txt b/docs/features.txt
index 29a9688..59db21b 100644
--- a/docs/features.txt
+++ b/docs/features.txt
@@ -179,7 +179,7 @@ GL 4.3, GLSL 4.30 -- all DONE: i965/gen8+, nvc0, radeonsi
   GL_ARB_program_interface_queryDONE (all drivers)
   GL_ARB_robust_buffer_access_behavior  DONE (i965)
   GL_ARB_shader_image_size  DONE (i965, r600, 
softpipe)
-  GL_ARB_shader_storage_buffer_object   DONE (i965, softpipe)
+  GL_ARB_shader_storage_buffer_object   DONE (i965, r600, 
softpipe)
   GL_ARB_stencil_texturing  DONE (i965/hsw+, nv50, 
r600, llvmpipe, softpipe, swr)
   GL_ARB_texture_buffer_range   DONE (nv50, i965, 
r600, llvmpipe)
   GL_ARB_texture_query_levels   DONE (all drivers that 
support GLSL 1.30)
@@ -249,7 +249,7 @@ GLES3.1, GLSL ES 3.1 -- all DONE: i965/hsw+, nvc0, radeonsi
   GL_ARB_shader_atomic_counters DONE (i965/gen7+, 
r600, softpipe)
   GL_ARB_shader_image_load_storeDONE (i965/gen7+, 
r600, softpipe)
   GL_ARB_shader_image_size  DONE (i965/gen7+, 
r600, softpipe)
-  GL_ARB_shader_storage_buffer_object   DONE (i965/gen7+, 
softpipe)
+  GL_ARB_shader_storage_buffer_object   DONE (i965/gen7+, 
r600, softpipe)
   GL_ARB_shading_language_packing   DONE (all drivers)
   GL_ARB_separate_shader_objectsDONE (all drivers)
   GL_ARB_stencil_texturing  DONE (nv50, r600, 
llvmpipe, softpipe, swr)
diff --git a/src/gallium/drivers/r600/evergreen_state.c 
b/src/gallium/drivers/r600/evergreen_state.c
index 5a3a851..66af679 100644
--- a/src/gallium/drivers/r600/evergreen_state.c
+++ b/src/gallium/drivers/r600/evergreen_state.c
@@ -614,6 +614,7 @@ struct eg_buf_res_params {
unsigned size;
unsigned char swizzle[4];
bool uncached;
+   bool force_swizzle;
 };
 
 static void evergreen_fill_buffer_resource_words(struct r600_context *rctx,
@@ -635,7 +636,10 @@ static void evergreen_fill_buffer_resource_words(struct 
r600_context *rctx,
 
desc = util_format_description(params->pipe_format);
 
-   swizzle_res = r600_get_swizzle_combined(desc->swizzle, params->swizzle, 
TRUE);
+   if (params->force_swizzle)
+   swizzle_res = r600_get_swizzle_combined(params->swizzle, NULL, 
TRUE);
+   else
+   swizzle_res = r600_get_swizzle_combined(desc->swizzle, 
params->swizzle, TRUE);
 
va = tmp->resource.gpu_address + params->offset;
*skip_mip_address_reloc = true;
@@ -1029,7 +1033,7 @@ static void evergreen_set_color_surface_buffer(struct 
r600_context *rctx,
 {
unsigned format, swap, ntype, endian;
const struct util_format_description *desc;
-   unsigned block_size = align(util_format_get_blocksize(res->b.b.format), 
4);
+   unsigned block_size = util_format_get_blocksize(res->b.b.format);
unsigned pitch_alignment =
MAX2(64, rctx->screen->b.info.pipe_interleave_bytes / 
block_size);
unsigned pitch = align(res->b.b.width0, pitch_alignment);
@@ -1776,6 +1780,14 @@ static void evergreen_emit_fragment_image_state(struct 
r600_context *rctx, struc
   R600_IMAGE_REAL_RESOURCE_OFFSET);
 }
 
+static void evergreen_emit_fragment_buffer_state(struct r600_context *rctx, 
struct r600_atom *atom)
+{
+   int offset = util_bitcount(rctx->fragment_images.enabled_mask);
+   evergreen_emit_image_state(rctx, atom,
+  R600_IMAGE_IMMED_RESOURCE_OFFSET + offset,
+  R600_IMAGE_REAL_RESOURCE_OFFSET + offset);
+}
+
 static void evergreen_emit_framebuffer_state(struct r600_context *rctx, struct 
r600_atom *atom)
 {
struct radeon_winsys_cs *cs = rctx->b.gfx.cs;
@@ -1852,6 +1864,7 @@ static void evergreen_emit_framebuffer_state(struct 
r600_context *rctx, struct r
i++;
}
i += util_bitcount(rctx->fragment_images.enabled_mask);
+   i += util_bitcount(rctx->fragment_buffers.enabled_mask);
for (; i < 8 ; i++)
radeon_set_context_reg(cs, 

Re: [Mesa-dev] [PATCH 00/28] vulkan/wsi: Rework WSI to look a lot more like a layer

2017-11-16 Thread Jason Ekstrand
I just force-pushed my branch with some changes as per Dave to more
explicitly enable implicit sync when allocating memory objects.

On Thu, Nov 16, 2017 at 1:28 PM, Jason Ekstrand 
wrote:

> This patch series is the combined brain-child of Dave and myself.  The
> objective is to rewrite Vulkan WSI to look as much like a layer as possible
> and to reduce the driver <-> WSI interface.  We try very hard to have as
> many of the WSI details as possible in common code and to use standard
> Vulkan interfaces for everything.  Among other things, this means that
> prime support is now implemented in an entirely driver-agnostic way and the
> driver doesn't even know it's happening.  As a side-effect anv now has
> prime support.
>
> Eventually, someone could pull what's left out into a proper layer and we
> could drop WSI support from our drivers entirely.  There are a fiew pieces
> of work that would be required to do this:
>
>  1) Write all of the annoying layer bits.  There are some short-cuts that
> we can take because we're not in a layer and those will have to go.
>
>  2) Define a VK_MESA_legacy_swapchain_image extension to replace the hack
> introduced in patch 8.
>
>  3) It looks like modifiers support will land before the official Vulkan
> extensions get finished.  It will have to be ported to the official
> extensions.
>
>  4) Figure out what to do about the fence in AcquireNextImage. In a future
> world of explicit synchronization, we can just import the sync_file
> from X or the Wayland compositor, but with implicit sync like we have
> today, it's a bit harder.  Right now, the helper in wsi_common does
> nothing with it and trusts the caller to handle it.
>
> The two drivers handle this differently today.  In anv, we do a dummy
> QueueSubmit to trigger the fence while radv triggers it a bit more
> manually.  In both cases, we trigger the fence immediately and trust in
> the GEM's implicit synchronization to sort things out for us.  We can't
> use the anv method as directly with radv because no queue is passed in
> so we don't know what queue to use in the dummy QueueSubmit.  (In ANV,
> we only have the one queue so that isn't a problem.)
>
>
> Dave, I tried to pull patches from your series where practical but, because
> we did things in a different order, it frequently wasn't.  If you want to
> claim credit for any of these patches, just say so and I'll --reset-author
> on them.
>
> The series can be found on freedesktop.org here:
>
> https://cgit.freedesktop.org/~jekstrand/mesa/log/?h=wip/vulkan-wsi-prime
>
>
> Cc: Dave Airlie 
> Cc: Daniel Stone 
> Cc: Chad Versace 
> Cc: James Jones 
>
> Daniel Stone (1):
>   vulkan/wsi: Add a wsi_image structure
>
> Dave Airlie (4):
>   vulkan/wsi: use function ptr definitions from the spec.
>   radv/wsi: drop allocate memory special case
>   radv/wsi: Move the guts of QueuePresent to wsi common
>   vulkan/wsi: move swapchain create/destroy to common code
>
> Jason Ekstrand (23):
>   vulkan/wsi/x11: Handle the geometry check earlier in create_swapchain
>   vulkan/wsi: Add a wsi_device_init function
>   vulkan/wsi: Add wsi_swapchain_init/finish functions
>   vulkan/wsi: Implement prime in a completely generic way
>   anv/image: Add a return value to bind_memory_plane
>   vulkan/wsi: Add a mock image creation extension
>   anv/image: Implement the wsi "extension"
>   radv/image: Implement the wsi "extension"
>   vulkan/wsi: Do image creation in common code
>   vulkan/wsi: Add a WSI_FROM_HANDLE macro
>   vulkan/wsi: Refactor result handling in queue_present
>   vulkan/wsi: Only wait on semaphores on the first swapchain
>   vulkan/wsi: Set a proper pWaitDstStageMask on the dummy submit
>   anv/wsi: Use the common QueuePresent code
>   anv/wsi: Enable prime support
>   vulkan/wsi: Move get_images into common code
>   vulkan/wsi: Move prime blitting into queue_present
>   vulkan/wsi: Add a helper for AcquireNextImage
>   vulkan/wsi: Move wsi_swapchain to wsi_common_private.h
>   vulkan/wsi: Drop the can_handle_different_gpu parameter from
> get_support
>   vulkan/wsi: Add wrappers for all of the surface queries
>   vulkan/wsi: Drop some unneeded cruft from the API
>   vulkan/wsi: Initialize individual WSI interfaces in wsi_device_init
>
>  src/amd/vulkan/radv_device.c|  18 +-
>  src/amd/vulkan/radv_image.c |  15 +-
>  src/amd/vulkan/radv_private.h   |  10 -
>  src/amd/vulkan/radv_wsi.c   | 472 +++---
>  src/intel/vulkan/anv_image.c|  71 +++-
>  src/intel/vulkan/anv_private.h  |   2 +
>  src/intel/vulkan/anv_wsi.c  | 347 +++-
>  src/vulkan/Makefile.sources |   2 +
>  src/vulkan/wsi/meson.build  |   2 +
>  src/vulkan/wsi/wsi_common.c | 763 ++
> ++
>  

[Mesa-dev] [PATCH 4/5] gallium: Make a helper for doing Z32_FLOAT_S8X24_UINT mappings.

2017-11-16 Thread Eric Anholt
---
 src/gallium/auxiliary/util/u_transfer.c | 118 
 src/gallium/auxiliary/util/u_transfer.h |  18 +
 2 files changed, 136 insertions(+)

diff --git a/src/gallium/auxiliary/util/u_transfer.c 
b/src/gallium/auxiliary/util/u_transfer.c
index 3d3c5eb42cd4..f941e648b33b 100644
--- a/src/gallium/auxiliary/util/u_transfer.c
+++ b/src/gallium/auxiliary/util/u_transfer.c
@@ -1,4 +1,5 @@
 #include "pipe/p_context.h"
+#include "util/u_format_zs.h"
 #include "util/u_surface.h"
 #include "util/u_inlines.h"
 #include "util/u_transfer.h"
@@ -272,3 +273,120 @@ void u_transfer_unmap_msaa_helper(struct pipe_context 
*pctx,
pipe_resource_reference(>ss, NULL);
free(trans);
 }
+
+struct u_transfer_z32f_s8_helper {
+   struct pipe_transfer base;
+   struct pipe_transfer *z_ptrans;
+   struct pipe_transfer *s_ptrans;
+   void *z, *s;
+   void *merged;
+};
+
+/**
+ * Helper to implement the PIPE_FORMAT_Z32_FLOAT_S8X24_UINT mappings when the
+ * driver stores the Z and S in separate resources.
+ *
+ * We malloc temporary storage, map each resource, and use the CPU to pack the
+ * values into the temporary.  Note that a callback is used, so the triver can
+ * avoid recursing.
+ *
+ * Note that the driver's unmap will be called with our ptrans: They need to
+ * detect it and call u_transfer_unmap_z32f_s8_helper() and return
+ * immediately.
+ */
+void *
+u_transfer_map_z32f_s8_helper(struct pipe_context *pctx,
+  struct pipe_resource *z,
+  struct pipe_resource *s,
+  unsigned level, unsigned usage,
+  const struct pipe_box *box,
+  struct pipe_transfer **pptrans,
+  void *(*transfer_map)(struct pipe_context *pctx,
+struct pipe_resource *prsc,
+unsigned level, unsigned 
usage,
+const struct pipe_box *box,
+struct pipe_transfer 
**pptrans))
+{
+   struct u_transfer_z32f_s8_helper *trans = calloc(1, sizeof(*trans));
+   if (!trans)
+  return NULL;
+   struct pipe_transfer *ptrans = >base;
+
+   pipe_resource_reference(>resource, z);
+   ptrans->level = level;
+   ptrans->usage = usage;
+   ptrans->box = *box;
+
+   trans->z = transfer_map(pctx, z, level, usage, box,
+   >z_ptrans);
+   if (!trans->z)
+  goto fail_unref;
+   trans->s = transfer_map(pctx, s, level, usage, box,
+   >s_ptrans);
+   if (!trans->s)
+  goto fail_unmap_z;
+
+   ptrans->stride = 8 * box->width;
+   trans->merged = malloc(ptrans->stride * box->height);
+   if (!trans->merged)
+  goto fail_unmap_s;
+
+   if (usage & PIPE_TRANSFER_READ) {
+  util_format_z32_float_s8x24_uint_pack_z_float(trans->merged,
+ptrans->stride,
+trans->z,
+trans->z_ptrans->stride,
+box->width,
+box->height);
+  util_format_z32_float_s8x24_uint_pack_s_8uint(trans->merged,
+ptrans->stride,
+trans->s,
+trans->s_ptrans->stride,
+box->width,
+box->height);
+   }
+
+   *pptrans = ptrans;
+   return trans->merged;
+
+ fail_unmap_s:
+   pctx->transfer_unmap(pctx, trans->s_ptrans);
+ fail_unmap_z:
+   pctx->transfer_unmap(pctx, trans->z_ptrans);
+ fail_unref:
+   pipe_resource_reference(>resource, NULL);
+   free(trans);
+   return NULL;
+}
+
+void u_transfer_unmap_z32f_s8_helper(struct pipe_context *pctx,
+ struct pipe_transfer *ptrans,
+ void (*transfer_unmap)(struct 
pipe_context *pctx,
+struct 
pipe_transfer *ptrans))
+{
+   struct u_transfer_z32f_s8_helper *trans =
+  (struct u_transfer_z32f_s8_helper *)ptrans;
+
+   if (ptrans->usage & PIPE_TRANSFER_WRITE) {
+  uint32_t width = ptrans->box.width;
+  uint32_t height = ptrans->box.height;
+
+  util_format_z32_float_s8x24_uint_unpack_z_float(trans->z,
+  trans->z_ptrans->stride,
+  trans->merged,
+  ptrans->stride,
+  width, height);
+  util_format_z32_float_s8x24_uint_unpack_s_8uint(trans->s,
+

[Mesa-dev] [PATCH 1/5] gallium: Add helpers for MSAA resolves in pipe_transfer_map()/unmap().

2017-11-16 Thread Eric Anholt
I had replicated this code from vc4 to vc5, but it's something that most
drivers will need to do in a similar way.
---
 src/gallium/auxiliary/util/u_transfer.c | 119 
 src/gallium/auxiliary/util/u_transfer.h |  10 +++
 2 files changed, 129 insertions(+)

diff --git a/src/gallium/auxiliary/util/u_transfer.c 
b/src/gallium/auxiliary/util/u_transfer.c
index ba4b9dcc6b34..3d3c5eb42cd4 100644
--- a/src/gallium/auxiliary/util/u_transfer.c
+++ b/src/gallium/auxiliary/util/u_transfer.c
@@ -153,3 +153,122 @@ void u_transfer_unmap_vtbl( struct pipe_context *pipe,
struct u_resource *ur = u_resource(transfer->resource);
ur->vtbl->transfer_unmap(pipe, transfer);
 }
+
+struct u_transfer_msaa_helper {
+   struct pipe_transfer base;
+   struct pipe_resource *ss;
+   struct pipe_transfer *wrapped;
+};
+
+/**
+ * Helper to implement the implicit MSAA resolve necessary in the
+ * pipe_transfer API.
+ *
+ * The driver should call this when the resource is multisampled.  We create a
+ * temporary single-sampled texture, blit to do the resolve if needed, and
+ * then call back to the driver to map the single-sampled texture.
+ *
+ * Note that the driver's unmap will be called with our ptrans: They need to
+ * detect it and call u_transfer_unmap_msaa_helper() and return immediately.
+ */
+void *
+u_transfer_map_msaa_helper(struct pipe_context *pctx,
+   struct pipe_resource *prsc,
+   unsigned level, unsigned usage,
+   const struct pipe_box *box,
+   struct pipe_transfer **pptrans)
+{
+   struct pipe_screen *pscreen = pctx->screen;
+   assert(prsc->nr_samples > 1);
+
+   struct u_transfer_msaa_helper *trans = calloc(1, sizeof(*trans));
+   if (!trans)
+  return NULL;
+   struct pipe_transfer *ptrans = >base;
+
+   pipe_resource_reference(>resource, prsc);
+   ptrans->level = level;
+   ptrans->usage = usage;
+   ptrans->box = *box;
+
+   struct pipe_resource temp_setup = {
+  .target = prsc->target,
+  .format = prsc->format,
+  .width0 = box->width,
+  .height0 = box->height,
+  .depth0 = 1,
+  .array_size = 1,
+   };
+   trans->ss = pscreen->resource_create(pscreen, _setup);
+   if (!trans->ss) {
+  free(trans);
+  return NULL;
+   }
+
+   if (usage & PIPE_TRANSFER_READ) {
+  struct pipe_blit_info blit;
+  memset(, 0, sizeof(blit));
+
+  blit.src.resource = ptrans->resource;
+  blit.src.format = ptrans->resource->format;
+  blit.src.level = ptrans->level;
+  blit.src.box = *box;
+
+  blit.dst.resource = trans->ss;
+  blit.dst.format = trans->ss->format;
+  blit.dst.box.width = box->width;
+  blit.dst.box.height = box->height;
+  blit.dst.box.depth = 1;
+
+  blit.mask = util_format_get_mask(prsc->format);
+  blit.filter = PIPE_TEX_FILTER_NEAREST;
+
+  pctx->blit(pctx, );
+   }
+
+   void *ss_map = pctx->transfer_map(pctx, trans->ss, 0, usage, box,
+ >wrapped);
+   if (!ss_map) {
+  free(trans);
+  return NULL;
+   }
+
+   *pptrans = ptrans;
+   return ss_map;
+}
+
+void u_transfer_unmap_msaa_helper(struct pipe_context *pctx,
+  struct pipe_transfer *ptrans)
+{
+   struct u_transfer_msaa_helper *trans =
+  (struct u_transfer_msaa_helper *)ptrans;
+
+   /* Unmap the single-sample resource, finishing whatever driver side storing
+* is necessary.
+*/
+   pipe_transfer_unmap(pctx, trans->wrapped);
+
+   if (ptrans->usage & PIPE_TRANSFER_WRITE) {
+  struct pipe_blit_info blit;
+  memset(, 0, sizeof(blit));
+
+  blit.src.resource = trans->ss;
+  blit.src.format = trans->ss->format;
+  blit.src.box.width = ptrans->box.width;
+  blit.src.box.height = ptrans->box.height;
+  blit.src.box.depth = 1;
+
+  blit.dst.resource = ptrans->resource;
+  blit.dst.format = ptrans->resource->format;
+  blit.dst.level = ptrans->level;
+  blit.dst.box = ptrans->box;
+
+  blit.mask = util_format_get_mask(ptrans->resource->format);
+  blit.filter = PIPE_TEX_FILTER_NEAREST;
+
+  pctx->blit(pctx, );
+   }
+
+   pipe_resource_reference(>ss, NULL);
+   free(trans);
+}
diff --git a/src/gallium/auxiliary/util/u_transfer.h 
b/src/gallium/auxiliary/util/u_transfer.h
index 14084983daf9..237930c06007 100644
--- a/src/gallium/auxiliary/util/u_transfer.h
+++ b/src/gallium/auxiliary/util/u_transfer.h
@@ -14,6 +14,16 @@ struct winsys_handle;
 extern "C" {
 #endif
 
+void *
+u_transfer_map_msaa_helper(struct pipe_context *pctx,
+   struct pipe_resource *prsc,
+   unsigned level, unsigned usage,
+   const struct pipe_box *box,
+   struct pipe_transfer **pptrans);
+
+void u_transfer_unmap_msaa_helper(struct pipe_context *pctx,
+  struct pipe_transfer *ptrans);
+
 boolean 

[Mesa-dev] [PATCH 5/5] broadcom/vc5: Start adding support for rendering to Z32F_S8X24_UINT.

2017-11-16 Thread Eric Anholt
There may be some more RCL work to be done (I think I need to split my Z/S
stores when doing separate stencil), but this gets piglit's "texwrap
GL_ARB_depth_buffer_float." working.
---
 src/gallium/drivers/vc5/vc5_rcl.c  | 22 +
 src/gallium/drivers/vc5/vc5_resource.c | 85 --
 src/gallium/drivers/vc5/vc5_resource.h |  6 +++
 src/gallium/drivers/vc5/vc5_screen.c   |  6 +++
 4 files changed, 116 insertions(+), 3 deletions(-)

diff --git a/src/gallium/drivers/vc5/vc5_rcl.c 
b/src/gallium/drivers/vc5/vc5_rcl.c
index 22d6eed781c7..2c82eece9a6b 100644
--- a/src/gallium/drivers/vc5/vc5_rcl.c
+++ b/src/gallium/drivers/vc5/vc5_rcl.c
@@ -331,6 +331,28 @@ vc5_emit_rcl(struct vc5_job *job)
 
 if (job->resolve & PIPE_CLEAR_DEPTHSTENCIL)
 rsc->writes++;
+
+/* Emit the separate stencil packet if we have a resource for
+ * it.  The HW will only load/store this buffer if the
+ * Z/Stencil config doesn't have stencil in its format.
+ */
+if (rsc->separate_stencil) {
+cl_emit(>rcl,
+
TILE_RENDERING_MODE_CONFIGURATION_Z_STENCIL_CONFIG,
+zs) {
+zs.address =
+cl_address(rsc->separate_stencil->bo,
+   
surf->separate_stencil_offset);
+
+zs.z_stencil_id = 1; /* Separate stencil */
+
+zs.padded_height_of_output_image_in_uif_blocks 
=
+
surf->separate_stencil_padded_height_of_output_image_in_uif_blocks;
+
+assert(surf->tiling != VC5_TILING_RASTER);
+zs.memory_format = 
surf->separate_stencil_tiling;
+}
+}
 }
 
 /* Ends rendering mode config. */
diff --git a/src/gallium/drivers/vc5/vc5_resource.c 
b/src/gallium/drivers/vc5/vc5_resource.c
index 04aeb0e008b9..7a26c5afde48 100644
--- a/src/gallium/drivers/vc5/vc5_resource.c
+++ b/src/gallium/drivers/vc5/vc5_resource.c
@@ -28,6 +28,7 @@
 #include "util/u_inlines.h"
 #include "util/u_surface.h"
 #include "util/u_upload_mgr.h"
+#include "util/u_format_zs.h"
 
 #include "drm_fourcc.h"
 #include "vc5_screen.h"
@@ -280,11 +281,52 @@ fail:
 return NULL;
 }
 
+/* Decomposes a PIPE_FORMAT_Z32_FLOAT_S8X24_UINT transfer into mappings of
+ * each resource into a temporary buffer using the gallium helper.
+ *
+ * This has to be a separate function from vc5_resource_transfer_map() to
+ * prevent infinite recusion.
+ */
+static void *
+vc5_resource_transfer_map_z32f_wrapper(struct pipe_context *pctx,
+   struct pipe_resource *prsc,
+   unsigned level, unsigned usage,
+   const struct pipe_box *box,
+   struct pipe_transfer **pptrans)
+{
+if (prsc->format != PIPE_FORMAT_Z32_FLOAT_S8X24_UINT) {
+return vc5_resource_transfer_map(pctx, prsc, level, usage,
+ box, pptrans);
+}
+
+struct vc5_resource *rsc = vc5_resource(prsc);
+return u_transfer_map_z32f_s8_helper(pctx, prsc,
+ >separate_stencil->base,
+ level, usage,
+ box, pptrans, 
vc5_resource_transfer_map);
+}
+
+static void
+vc5_resource_transfer_unmap_z32f_wrapper(struct pipe_context *pctx,
+ struct pipe_transfer *ptrans)
+{
+if (ptrans->resource->format == PIPE_FORMAT_Z32_FLOAT_S8X24_UINT) {
+u_transfer_unmap_z32f_s8_helper(pctx, ptrans,
+vc5_resource_transfer_unmap);
+} else {
+vc5_resource_transfer_unmap(pctx, ptrans);
+}
+}
+
 static void
 vc5_resource_destroy(struct pipe_screen *pscreen,
  struct pipe_resource *prsc)
 {
 struct vc5_resource *rsc = vc5_resource(prsc);
+
+if (rsc->separate_stencil)
+vc5_resource_destroy(pscreen, >separate_stencil->base);
+
 vc5_bo_unreference(>bo);
 free(rsc);
 }
@@ -434,7 +476,13 @@ vc5_resource_setup(struct pipe_screen *pscreen,
 prsc->screen = pscreen;
 
 if (prsc->nr_samples <= 1) {
-rsc->cpp = util_format_get_blocksize(prsc->format);
+/* For Z32F+S8X24, the stencil is stored separately and this
+ * rsc will just be the Z32F.
+ */
+if (prsc->format == PIPE_FORMAT_Z32_FLOAT_S8X24_UINT)
+rsc->cpp = 4;
+else
+  

[Mesa-dev] [PATCH 0/5] gallium transfer_map() helpers (MSAA, Z32F_S8X24).

2017-11-16 Thread Eric Anholt
Having been frustrated with duplicating this code into yet another
driver, I made some little helpers for u_transfer so others don't have
to go through this.

I'm not pleased with needing the callback for Z32F, and the recursion
feels dangerous if you're doing both of them, but it does seem to
work.

Eric Anholt (5):
  gallium: Add helpers for MSAA resolves in pipe_transfer_map()/unmap().
  broadcom/vc4: Switch to using the u_transfer_map_msaa_helper().
  broadcom/vc5: Switch to using u_transfer_map_msaa_helper().
  gallium: Make a helper for doing Z32_FLOAT_S8X24_UINT mappings.
  broadcom/vc5: Start adding support for rendering to Z32F_S8X24_UINT.

 src/gallium/auxiliary/util/u_transfer.c | 237 
 src/gallium/auxiliary/util/u_transfer.h |  28 
 src/gallium/drivers/vc4/vc4_resource.c  | 104 ++
 src/gallium/drivers/vc4/vc4_resource.h  |   3 -
 src/gallium/drivers/vc5/vc5_rcl.c   |  22 +++
 src/gallium/drivers/vc5/vc5_resource.c  | 188 +
 src/gallium/drivers/vc5/vc5_resource.h  |   9 +-
 src/gallium/drivers/vc5/vc5_screen.c|   6 +
 8 files changed, 401 insertions(+), 196 deletions(-)

-- 
2.15.0

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


[Mesa-dev] [PATCH 2/5] broadcom/vc4: Switch to using the u_transfer_map_msaa_helper().

2017-11-16 Thread Eric Anholt
---
 src/gallium/drivers/vc4/vc4_resource.c | 104 -
 src/gallium/drivers/vc4/vc4_resource.h |   3 -
 2 files changed, 10 insertions(+), 97 deletions(-)

diff --git a/src/gallium/drivers/vc4/vc4_resource.c 
b/src/gallium/drivers/vc4/vc4_resource.c
index cdcbcc917e0d..b97e09414acc 100644
--- a/src/gallium/drivers/vc4/vc4_resource.c
+++ b/src/gallium/drivers/vc4/vc4_resource.c
@@ -75,19 +75,15 @@ static void
 vc4_resource_transfer_unmap(struct pipe_context *pctx,
 struct pipe_transfer *ptrans)
 {
+if (ptrans->resource->nr_samples > 1)
+return u_transfer_unmap_msaa_helper(pctx, ptrans);
+
 struct vc4_context *vc4 = vc4_context(pctx);
 struct vc4_transfer *trans = vc4_transfer(ptrans);
 
 if (trans->map) {
-struct vc4_resource *rsc;
-struct vc4_resource_slice *slice;
-if (trans->ss_resource) {
-rsc = vc4_resource(trans->ss_resource);
-slice = >slices[0];
-} else {
-rsc = vc4_resource(ptrans->resource);
-slice = >slices[ptrans->level];
-}
+struct vc4_resource *rsc = vc4_resource(ptrans->resource);
+struct vc4_resource_slice *slice = >slices[ptrans->level];
 
 if (ptrans->usage & PIPE_TRANSFER_WRITE) {
 vc4_store_tiled_image(rsc->bo->map + slice->offset +
@@ -100,51 +96,10 @@ vc4_resource_transfer_unmap(struct pipe_context *pctx,
 free(trans->map);
 }
 
-if (trans->ss_resource && (ptrans->usage & PIPE_TRANSFER_WRITE)) {
-struct pipe_blit_info blit;
-memset(, 0, sizeof(blit));
-
-blit.src.resource = trans->ss_resource;
-blit.src.format = trans->ss_resource->format;
-blit.src.box.width = trans->ss_box.width;
-blit.src.box.height = trans->ss_box.height;
-blit.src.box.depth = 1;
-
-blit.dst.resource = ptrans->resource;
-blit.dst.format = ptrans->resource->format;
-blit.dst.level = ptrans->level;
-blit.dst.box = trans->ss_box;
-
-blit.mask = util_format_get_mask(ptrans->resource->format);
-blit.filter = PIPE_TEX_FILTER_NEAREST;
-
-pctx->blit(pctx, );
-
-pipe_resource_reference(>ss_resource, NULL);
-}
-
 pipe_resource_reference(>resource, NULL);
 slab_free(>transfer_pool, ptrans);
 }
 
-static struct pipe_resource *
-vc4_get_temp_resource(struct pipe_context *pctx,
-  struct pipe_resource *prsc,
-  const struct pipe_box *box)
-{
-struct pipe_resource temp_setup;
-
-memset(_setup, 0, sizeof(temp_setup));
-temp_setup.target = prsc->target;
-temp_setup.format = prsc->format;
-temp_setup.width0 = box->width;
-temp_setup.height0 = box->height;
-temp_setup.depth0 = 1;
-temp_setup.array_size = 1;
-
-return pctx->screen->resource_create(pctx->screen, _setup);
-}
-
 static void *
 vc4_resource_transfer_map(struct pipe_context *pctx,
   struct pipe_resource *prsc,
@@ -159,6 +114,11 @@ vc4_resource_transfer_map(struct pipe_context *pctx,
 enum pipe_format format = prsc->format;
 char *buf;
 
+if (prsc->nr_samples > 1) {
+return u_transfer_map_msaa_helper(pctx, prsc, level, usage,
+  box, pptrans);
+}
+
 /* Upgrade DISCARD_RANGE to WHOLE_RESOURCE if the whole resource is
  * being mapped.
  */
@@ -218,50 +178,6 @@ vc4_resource_transfer_map(struct pipe_context *pctx,
 ptrans->usage = usage;
 ptrans->box = *box;
 
-/* If the resource is multisampled, we need to resolve to single
- * sample.  This seems like it should be handled at a higher layer.
- */
-if (prsc->nr_samples > 1) {
-trans->ss_resource = vc4_get_temp_resource(pctx, prsc, box);
-if (!trans->ss_resource)
-goto fail;
-assert(!trans->ss_resource->nr_samples);
-
-/* The ptrans->box gets modified for tile alignment, so save
- * the original box for unmap time.
- */
-trans->ss_box = *box;
-
-if (usage & PIPE_TRANSFER_READ) {
-struct pipe_blit_info blit;
-memset(, 0, sizeof(blit));
-
-blit.src.resource = ptrans->resource;
-blit.src.format = ptrans->resource->format;
-blit.src.level = ptrans->level;
-blit.src.box = trans->ss_box;
-
- 

[Mesa-dev] [PATCH 3/5] broadcom/vc5: Switch to using u_transfer_map_msaa_helper().

2017-11-16 Thread Eric Anholt
---
 src/gallium/drivers/vc5/vc5_resource.c | 103 -
 src/gallium/drivers/vc5/vc5_resource.h |   3 -
 2 files changed, 10 insertions(+), 96 deletions(-)

diff --git a/src/gallium/drivers/vc5/vc5_resource.c 
b/src/gallium/drivers/vc5/vc5_resource.c
index dad238f89fba..04aeb0e008b9 100644
--- a/src/gallium/drivers/vc5/vc5_resource.c
+++ b/src/gallium/drivers/vc5/vc5_resource.c
@@ -118,19 +118,15 @@ static void
 vc5_resource_transfer_unmap(struct pipe_context *pctx,
 struct pipe_transfer *ptrans)
 {
+if (ptrans->resource->nr_samples > 1)
+return u_transfer_unmap_msaa_helper(pctx, ptrans);
+
 struct vc5_context *vc5 = vc5_context(pctx);
 struct vc5_transfer *trans = vc5_transfer(ptrans);
 
 if (trans->map) {
-struct vc5_resource *rsc;
-struct vc5_resource_slice *slice;
-if (trans->ss_resource) {
-rsc = vc5_resource(trans->ss_resource);
-slice = >slices[0];
-} else {
-rsc = vc5_resource(ptrans->resource);
-slice = >slices[ptrans->level];
-}
+struct vc5_resource *rsc = vc5_resource(ptrans->resource);
+struct vc5_resource_slice *slice = >slices[ptrans->level];
 
 if (ptrans->usage & PIPE_TRANSFER_WRITE) {
 vc5_store_tiled_image(rsc->bo->map + slice->offset +
@@ -144,50 +140,10 @@ vc5_resource_transfer_unmap(struct pipe_context *pctx,
 free(trans->map);
 }
 
-if (trans->ss_resource && (ptrans->usage & PIPE_TRANSFER_WRITE)) {
-struct pipe_blit_info blit;
-memset(, 0, sizeof(blit));
-
-blit.src.resource = trans->ss_resource;
-blit.src.format = trans->ss_resource->format;
-blit.src.box.width = trans->ss_box.width;
-blit.src.box.height = trans->ss_box.height;
-blit.src.box.depth = 1;
-
-blit.dst.resource = ptrans->resource;
-blit.dst.format = ptrans->resource->format;
-blit.dst.level = ptrans->level;
-blit.dst.box = trans->ss_box;
-
-blit.mask = util_format_get_mask(ptrans->resource->format);
-blit.filter = PIPE_TEX_FILTER_NEAREST;
-
-pctx->blit(pctx, );
-
-pipe_resource_reference(>ss_resource, NULL);
-}
-
 pipe_resource_reference(>resource, NULL);
 slab_free(>transfer_pool, ptrans);
 }
 
-static struct pipe_resource *
-vc5_get_temp_resource(struct pipe_context *pctx,
-  struct pipe_resource *prsc,
-  const struct pipe_box *box)
-{
-struct pipe_resource temp_setup;
-
-memset(_setup, 0, sizeof(temp_setup));
-temp_setup.target = prsc->target;
-temp_setup.format = prsc->format;
-temp_setup.width0 = box->width;
-temp_setup.height0 = box->height;
-temp_setup.depth0 = 1;
-temp_setup.array_size = 1;
-
-return pctx->screen->resource_create(pctx->screen, _setup);
-}
 
 static void *
 vc5_resource_transfer_map(struct pipe_context *pctx,
@@ -203,6 +159,11 @@ vc5_resource_transfer_map(struct pipe_context *pctx,
 enum pipe_format format = prsc->format;
 char *buf;
 
+if (prsc->nr_samples > 1) {
+return u_transfer_map_msaa_helper(pctx, prsc, level, usage,
+  box, pptrans);
+}
+
 /* Upgrade DISCARD_RANGE to WHOLE_RESOURCE if the whole resource is
  * being mapped.
  */
@@ -265,50 +226,6 @@ vc5_resource_transfer_map(struct pipe_context *pctx,
 ptrans->usage = usage;
 ptrans->box = *box;
 
-/* If the resource is multisampled, we need to resolve to single
- * sample.  This seems like it should be handled at a higher layer.
- */
-if (prsc->nr_samples > 1) {
-trans->ss_resource = vc5_get_temp_resource(pctx, prsc, box);
-if (!trans->ss_resource)
-goto fail;
-assert(!trans->ss_resource->nr_samples);
-
-/* The ptrans->box gets modified for tile alignment, so save
- * the original box for unmap time.
- */
-trans->ss_box = *box;
-
-if (usage & PIPE_TRANSFER_READ) {
-struct pipe_blit_info blit;
-memset(, 0, sizeof(blit));
-
-blit.src.resource = ptrans->resource;
-blit.src.format = ptrans->resource->format;
-blit.src.level = ptrans->level;
-blit.src.box = trans->ss_box;
-
-blit.dst.resource = trans->ss_resource;
-

Re: [Mesa-dev] [PATCH 1/2] st/mesa: don't move ssbo after atomic buffers if we support hw atomics

2017-11-16 Thread Ilia Mirkin
Reviewed-by: Ilia Mirkin 

On Thu, Nov 16, 2017 at 9:05 PM, Dave Airlie  wrote:
> From: Dave Airlie 
>
> There is no need to have these overlap if we support hw atomics.
>
> Signed-off-by: Dave Airlie 
> ---
>  src/mesa/state_tracker/st_atom_storagebuf.c |  8 +---
>  src/mesa/state_tracker/st_glsl_to_tgsi.cpp  | 14 --
>  2 files changed, 13 insertions(+), 9 deletions(-)
>
> diff --git a/src/mesa/state_tracker/st_atom_storagebuf.c 
> b/src/mesa/state_tracker/st_atom_storagebuf.c
> index a31a8fd..2c55af3 100644
> --- a/src/mesa/state_tracker/st_atom_storagebuf.c
> +++ b/src/mesa/state_tracker/st_atom_storagebuf.c
> @@ -47,12 +47,14 @@ st_bind_ssbos(struct st_context *st, struct gl_program 
> *prog,
> unsigned i;
> struct pipe_shader_buffer buffers[MAX_SHADER_STORAGE_BUFFERS];
> struct gl_program_constants *c;
> -
> +   int buffer_base;
> if (!prog || !st->pipe->set_shader_buffers)
>return;
>
> c = >ctx->Const.Program[prog->info.stage];
>
> +   buffer_base = st->has_hw_atomics ? 0 : c->MaxAtomicBuffers;
> +
> for (i = 0; i < prog->info.num_ssbos; i++) {
>struct gl_buffer_binding *binding;
>struct st_buffer_object *st_obj;
> @@ -79,13 +81,13 @@ st_bind_ssbos(struct st_context *st, struct gl_program 
> *prog,
>   sb->buffer_size = 0;
>}
> }
> -   st->pipe->set_shader_buffers(st->pipe, shader_type, c->MaxAtomicBuffers,
> +   st->pipe->set_shader_buffers(st->pipe, shader_type, buffer_base,
>  prog->info.num_ssbos, buffers);
> /* clear out any stale shader buffers */
> if (prog->info.num_ssbos < c->MaxShaderStorageBlocks)
>st->pipe->set_shader_buffers(
>  st->pipe, shader_type,
> -c->MaxAtomicBuffers + prog->info.num_ssbos,
> +buffer_base + prog->info.num_ssbos,
>  c->MaxShaderStorageBlocks - prog->info.num_ssbos,
>  NULL);
>  }
> diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp 
> b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
> index 93b5cc7..a863eb2 100644
> --- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
> +++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
> @@ -2128,10 +2128,10 @@ glsl_to_tgsi_visitor::visit_expression(ir_expression* 
> ir, st_src_reg *op)
>
> case ir_unop_get_buffer_size: {
>ir_constant *const_offset = ir->operands[0]->as_constant();
> +  int buf_base = ctx->st->has_hw_atomics ? 0 : 
> ctx->Const.Program[shader->Stage].MaxAtomicBuffers;
>st_src_reg buffer(
>  PROGRAM_BUFFER,
> -ctx->Const.Program[shader->Stage].MaxAtomicBuffers +
> -(const_offset ? const_offset->value.u[0] : 0),
> +buf_base + (const_offset ? const_offset->value.u[0] : 0),
>  GLSL_TYPE_UINT);
>if (!const_offset) {
>   buffer.reladdr = ralloc(mem_ctx, st_src_reg);
> @@ -3352,11 +3352,10 @@ glsl_to_tgsi_visitor::visit_ssbo_intrinsic(ir_call 
> *ir)
> ir_rvalue *offset = ((ir_instruction *)param)->as_rvalue();
>
> ir_constant *const_block = block->as_constant();
> -
> +   int buf_base = st_context(ctx)->has_hw_atomics ? 0 : 
> ctx->Const.Program[shader->Stage].MaxAtomicBuffers;
> st_src_reg buffer(
>   PROGRAM_BUFFER,
> - ctx->Const.Program[shader->Stage].MaxAtomicBuffers +
> - (const_block ? const_block->value.u[0] : 0),
> + buf_base + (const_block ? const_block->value.u[0] : 0),
>   GLSL_TYPE_UINT);
>
> if (!const_block) {
> @@ -6581,7 +6580,10 @@ st_translate_program(
>
>assert(prog->info.num_ssbos <= frag_const->MaxShaderStorageBlocks);
>for (i = 0; i < prog->info.num_ssbos; i++) {
> - unsigned index = frag_const->MaxAtomicBuffers + i;
> + unsigned index = i;
> + if (!st_context(ctx)->has_hw_atomics)
> +index += frag_const->MaxAtomicBuffers;
> +
>   t->buffers[index] = ureg_DECL_buffer(ureg, index, false);
>}
> }
> --
> 2.9.5
>
> ___
> 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 2/2] r600: add ARB_shader_storage_buffer_object support

2017-11-16 Thread Dave Airlie
From: Dave Airlie 

This just builds on the image support. Evergreen only has ssbo
for fragment and compute no other stages.
---
 docs/features.txt|   4 +-
 src/gallium/drivers/r600/evergreen_state.c   | 131 ++-
 src/gallium/drivers/r600/r600_pipe.c |   7 +-
 src/gallium/drivers/r600/r600_pipe.h |   4 +-
 src/gallium/drivers/r600/r600_shader.c   |  75 ++-
 src/gallium/drivers/r600/r600_state_common.c |  18 
 6 files changed, 230 insertions(+), 9 deletions(-)

diff --git a/docs/features.txt b/docs/features.txt
index 29a9688..59db21b 100644
--- a/docs/features.txt
+++ b/docs/features.txt
@@ -179,7 +179,7 @@ GL 4.3, GLSL 4.30 -- all DONE: i965/gen8+, nvc0, radeonsi
   GL_ARB_program_interface_queryDONE (all drivers)
   GL_ARB_robust_buffer_access_behavior  DONE (i965)
   GL_ARB_shader_image_size  DONE (i965, r600, 
softpipe)
-  GL_ARB_shader_storage_buffer_object   DONE (i965, softpipe)
+  GL_ARB_shader_storage_buffer_object   DONE (i965, r600, 
softpipe)
   GL_ARB_stencil_texturing  DONE (i965/hsw+, nv50, 
r600, llvmpipe, softpipe, swr)
   GL_ARB_texture_buffer_range   DONE (nv50, i965, 
r600, llvmpipe)
   GL_ARB_texture_query_levels   DONE (all drivers that 
support GLSL 1.30)
@@ -249,7 +249,7 @@ GLES3.1, GLSL ES 3.1 -- all DONE: i965/hsw+, nvc0, radeonsi
   GL_ARB_shader_atomic_counters DONE (i965/gen7+, 
r600, softpipe)
   GL_ARB_shader_image_load_storeDONE (i965/gen7+, 
r600, softpipe)
   GL_ARB_shader_image_size  DONE (i965/gen7+, 
r600, softpipe)
-  GL_ARB_shader_storage_buffer_object   DONE (i965/gen7+, 
softpipe)
+  GL_ARB_shader_storage_buffer_object   DONE (i965/gen7+, 
r600, softpipe)
   GL_ARB_shading_language_packing   DONE (all drivers)
   GL_ARB_separate_shader_objectsDONE (all drivers)
   GL_ARB_stencil_texturing  DONE (nv50, r600, 
llvmpipe, softpipe, swr)
diff --git a/src/gallium/drivers/r600/evergreen_state.c 
b/src/gallium/drivers/r600/evergreen_state.c
index 5a3a851..66af679 100644
--- a/src/gallium/drivers/r600/evergreen_state.c
+++ b/src/gallium/drivers/r600/evergreen_state.c
@@ -614,6 +614,7 @@ struct eg_buf_res_params {
unsigned size;
unsigned char swizzle[4];
bool uncached;
+   bool force_swizzle;
 };
 
 static void evergreen_fill_buffer_resource_words(struct r600_context *rctx,
@@ -635,7 +636,10 @@ static void evergreen_fill_buffer_resource_words(struct 
r600_context *rctx,
 
desc = util_format_description(params->pipe_format);
 
-   swizzle_res = r600_get_swizzle_combined(desc->swizzle, params->swizzle, 
TRUE);
+   if (params->force_swizzle)
+   swizzle_res = r600_get_swizzle_combined(params->swizzle, NULL, 
TRUE);
+   else
+   swizzle_res = r600_get_swizzle_combined(desc->swizzle, 
params->swizzle, TRUE);
 
va = tmp->resource.gpu_address + params->offset;
*skip_mip_address_reloc = true;
@@ -1029,7 +1033,7 @@ static void evergreen_set_color_surface_buffer(struct 
r600_context *rctx,
 {
unsigned format, swap, ntype, endian;
const struct util_format_description *desc;
-   unsigned block_size = align(util_format_get_blocksize(res->b.b.format), 
4);
+   unsigned block_size = util_format_get_blocksize(res->b.b.format);
unsigned pitch_alignment =
MAX2(64, rctx->screen->b.info.pipe_interleave_bytes / 
block_size);
unsigned pitch = align(res->b.b.width0, pitch_alignment);
@@ -1776,6 +1780,14 @@ static void evergreen_emit_fragment_image_state(struct 
r600_context *rctx, struc
   R600_IMAGE_REAL_RESOURCE_OFFSET);
 }
 
+static void evergreen_emit_fragment_buffer_state(struct r600_context *rctx, 
struct r600_atom *atom)
+{
+   int offset = util_bitcount(rctx->fragment_images.enabled_mask);
+   evergreen_emit_image_state(rctx, atom,
+  R600_IMAGE_IMMED_RESOURCE_OFFSET + offset,
+  R600_IMAGE_REAL_RESOURCE_OFFSET + offset);
+}
+
 static void evergreen_emit_framebuffer_state(struct r600_context *rctx, struct 
r600_atom *atom)
 {
struct radeon_winsys_cs *cs = rctx->b.gfx.cs;
@@ -1852,6 +1864,7 @@ static void evergreen_emit_framebuffer_state(struct 
r600_context *rctx, struct r
i++;
}
i += util_bitcount(rctx->fragment_images.enabled_mask);
+   i += util_bitcount(rctx->fragment_buffers.enabled_mask);
for (; i < 8 ; i++)
radeon_set_context_reg(cs, R_028C70_CB_COLOR0_INFO + i * 0x3C, 
0);
for (; i < 12; i++)
@@ -1966,7 +1979,7 

[Mesa-dev] [PATCH 1/2] st/mesa: don't move ssbo after atomic buffers if we support hw atomics

2017-11-16 Thread Dave Airlie
From: Dave Airlie 

There is no need to have these overlap if we support hw atomics.

Signed-off-by: Dave Airlie 
---
 src/mesa/state_tracker/st_atom_storagebuf.c |  8 +---
 src/mesa/state_tracker/st_glsl_to_tgsi.cpp  | 14 --
 2 files changed, 13 insertions(+), 9 deletions(-)

diff --git a/src/mesa/state_tracker/st_atom_storagebuf.c 
b/src/mesa/state_tracker/st_atom_storagebuf.c
index a31a8fd..2c55af3 100644
--- a/src/mesa/state_tracker/st_atom_storagebuf.c
+++ b/src/mesa/state_tracker/st_atom_storagebuf.c
@@ -47,12 +47,14 @@ st_bind_ssbos(struct st_context *st, struct gl_program 
*prog,
unsigned i;
struct pipe_shader_buffer buffers[MAX_SHADER_STORAGE_BUFFERS];
struct gl_program_constants *c;
-
+   int buffer_base;
if (!prog || !st->pipe->set_shader_buffers)
   return;
 
c = >ctx->Const.Program[prog->info.stage];
 
+   buffer_base = st->has_hw_atomics ? 0 : c->MaxAtomicBuffers;
+
for (i = 0; i < prog->info.num_ssbos; i++) {
   struct gl_buffer_binding *binding;
   struct st_buffer_object *st_obj;
@@ -79,13 +81,13 @@ st_bind_ssbos(struct st_context *st, struct gl_program 
*prog,
  sb->buffer_size = 0;
   }
}
-   st->pipe->set_shader_buffers(st->pipe, shader_type, c->MaxAtomicBuffers,
+   st->pipe->set_shader_buffers(st->pipe, shader_type, buffer_base,
 prog->info.num_ssbos, buffers);
/* clear out any stale shader buffers */
if (prog->info.num_ssbos < c->MaxShaderStorageBlocks)
   st->pipe->set_shader_buffers(
 st->pipe, shader_type,
-c->MaxAtomicBuffers + prog->info.num_ssbos,
+buffer_base + prog->info.num_ssbos,
 c->MaxShaderStorageBlocks - prog->info.num_ssbos,
 NULL);
 }
diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp 
b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index 93b5cc7..a863eb2 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -2128,10 +2128,10 @@ glsl_to_tgsi_visitor::visit_expression(ir_expression* 
ir, st_src_reg *op)
 
case ir_unop_get_buffer_size: {
   ir_constant *const_offset = ir->operands[0]->as_constant();
+  int buf_base = ctx->st->has_hw_atomics ? 0 : 
ctx->Const.Program[shader->Stage].MaxAtomicBuffers;
   st_src_reg buffer(
 PROGRAM_BUFFER,
-ctx->Const.Program[shader->Stage].MaxAtomicBuffers +
-(const_offset ? const_offset->value.u[0] : 0),
+buf_base + (const_offset ? const_offset->value.u[0] : 0),
 GLSL_TYPE_UINT);
   if (!const_offset) {
  buffer.reladdr = ralloc(mem_ctx, st_src_reg);
@@ -3352,11 +3352,10 @@ glsl_to_tgsi_visitor::visit_ssbo_intrinsic(ir_call *ir)
ir_rvalue *offset = ((ir_instruction *)param)->as_rvalue();
 
ir_constant *const_block = block->as_constant();
-
+   int buf_base = st_context(ctx)->has_hw_atomics ? 0 : 
ctx->Const.Program[shader->Stage].MaxAtomicBuffers;
st_src_reg buffer(
  PROGRAM_BUFFER,
- ctx->Const.Program[shader->Stage].MaxAtomicBuffers +
- (const_block ? const_block->value.u[0] : 0),
+ buf_base + (const_block ? const_block->value.u[0] : 0),
  GLSL_TYPE_UINT);
 
if (!const_block) {
@@ -6581,7 +6580,10 @@ st_translate_program(
 
   assert(prog->info.num_ssbos <= frag_const->MaxShaderStorageBlocks);
   for (i = 0; i < prog->info.num_ssbos; i++) {
- unsigned index = frag_const->MaxAtomicBuffers + i;
+ unsigned index = i;
+ if (!st_context(ctx)->has_hw_atomics)
+index += frag_const->MaxAtomicBuffers;
+
  t->buffers[index] = ureg_DECL_buffer(ureg, index, false);
   }
}
-- 
2.9.5

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


[Mesa-dev] [PATCH] radv: Implement VK_KHR_get_surface_capabilities2

2017-11-16 Thread Jason Ekstrand
The WSI core code does all the hard work.  Just add the wrappers and
turn it on.
---
 src/amd/vulkan/radv_extensions.py |  1 +
 src/amd/vulkan/radv_wsi.c | 26 ++
 2 files changed, 27 insertions(+)

diff --git a/src/amd/vulkan/radv_extensions.py 
b/src/amd/vulkan/radv_extensions.py
index eeb679d..edb132d 100644
--- a/src/amd/vulkan/radv_extensions.py
+++ b/src/amd/vulkan/radv_extensions.py
@@ -61,6 +61,7 @@ EXTENSIONS = [
 Extension('VK_KHR_external_semaphore_fd', 1, 
'device->rad_info.has_syncobj'),
 Extension('VK_KHR_get_memory_requirements2',  1, True),
 Extension('VK_KHR_get_physical_device_properties2',   1, True),
+Extension('VK_KHR_get_surface_capabilities2', 1, True),
 Extension('VK_KHR_image_format_list', 1, True),
 Extension('VK_KHR_incremental_present',   1, True),
 Extension('VK_KHR_maintenance1',  1, True),
diff --git a/src/amd/vulkan/radv_wsi.c b/src/amd/vulkan/radv_wsi.c
index cb61eb6..51e8ec6 100644
--- a/src/amd/vulkan/radv_wsi.c
+++ b/src/amd/vulkan/radv_wsi.c
@@ -90,6 +90,18 @@ VkResult radv_GetPhysicalDeviceSurfaceCapabilitiesKHR(
   pSurfaceCapabilities);
 }
 
+VkResult radv_GetPhysicalDeviceSurfaceCapabilities2KHR(
+   VkPhysicalDevicephysicalDevice,
+   const VkPhysicalDeviceSurfaceInfo2KHR*  pSurfaceInfo,
+   VkSurfaceCapabilities2KHR*  pSurfaceCapabilities)
+{
+   RADV_FROM_HANDLE(radv_physical_device, device, physicalDevice);
+
+   return wsi_common_get_surface_capabilities2(>wsi_device,
+   pSurfaceInfo,
+   pSurfaceCapabilities);
+}
+
 VkResult radv_GetPhysicalDeviceSurfaceFormatsKHR(
VkPhysicalDevicephysicalDevice,
VkSurfaceKHRsurface,
@@ -104,6 +116,20 @@ VkResult radv_GetPhysicalDeviceSurfaceFormatsKHR(
  pSurfaceFormats);
 }
 
+VkResult radv_GetPhysicalDeviceSurfaceFormats2KHR(
+   VkPhysicalDevicephysicalDevice,
+   const VkPhysicalDeviceSurfaceInfo2KHR*  pSurfaceInfo,
+   uint32_t*   pSurfaceFormatCount,
+   VkSurfaceFormat2KHR*pSurfaceFormats)
+{
+   RADV_FROM_HANDLE(radv_physical_device, device, physicalDevice);
+
+   return wsi_common_get_surface_formats2(>wsi_device,
+  pSurfaceInfo,
+  pSurfaceFormatCount,
+  pSurfaceFormats);
+}
+
 VkResult radv_GetPhysicalDeviceSurfacePresentModesKHR(
VkPhysicalDevicephysicalDevice,
VkSurfaceKHRsurface,
-- 
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] st/glsl_to_nir: don't generate nir twice for gs

2017-11-16 Thread Marek Olšák
With the typo fixed:

Reviewed-by: Marek Olšák 

Marek

On Thu, Nov 16, 2017 at 1:16 AM, Timothy Arceri  wrote:
> This was left out of c980a3aa3133
> ---
>  src/mesa/state_tracker/st_program.c | 10 ++
>  1 file changed, 2 insertions(+), 8 deletions(-)
>
> diff --git a/src/mesa/state_tracker/st_program.c 
> b/src/mesa/state_tracker/st_program.c
> index 97b2e1234b..dc81a17289 100644
> --- a/src/mesa/state_tracker/st_program.c
> +++ b/src/mesa/state_tracker/st_program.c
> @@ -1424,29 +1424,23 @@ st_translate_program_common(struct st_context *st,
>
>  /**
>   * Translate a geometry program to create a new variant.
>   */
>  bool
>  st_translate_geometry_program(struct st_context *st,
>struct st_common_program *stgp)
>  {
> struct ureg_program *ureg;
>
> -   if (stgp->shader_program) {
> -  nir_shader *nir = st_glsl_to_nir(st, >Base, stgp->shader_program,
> -   MESA_SHADER_GEOMETRY);
> -
> -  stgp->tgsi.type = PIPE_SHADER_IR_NIR;
> -  stgp->tgsi.ir.nir = nir;
> -
> +   /* We have already compiler to NIR so just return */
> +   if (stgp->shader_program)
>return true;
> -   }
>
> ureg = ureg_create_with_screen(PIPE_SHADER_GEOMETRY, st->pipe->screen);
> if (ureg == NULL)
>return false;
>
> ureg_property(ureg, TGSI_PROPERTY_GS_INPUT_PRIM,
>   stgp->Base.info.gs.input_primitive);
> ureg_property(ureg, TGSI_PROPERTY_GS_OUTPUT_PRIM,
>   stgp->Base.info.gs.output_primitive);
> ureg_property(ureg, TGSI_PROPERTY_GS_MAX_OUTPUT_VERTICES,
> --
> 2.14.3
>
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] i965: Upload invariant state once at the start of the batch on Gen4-5.

2017-11-16 Thread Jason Ekstrand
Sounds like a plan.

Reviewed-by: Jason Ekstrand 

On Thu, Nov 16, 2017 at 12:37 AM, Kenneth Graunke 
wrote:

> We want to emit invariant state at the start of a render batch.  In the
> past, this more or less happened: a new batch flagged BRW_NEW_CONTEXT
> (because we don't have hardware contexts), which triggered the
> brw_invariant_state atom.  So, it would be emitted before any 3D
> drawing.  (Technically, there might be some BLT commands in the batch
> because Gen4-5 have a single combined render/BLT ring, but that should
> be harmless).
>
> With the advent of BLORP, this broke.  The first item in a batch might
> be a BLORP operation, which bypasses the normal draw upload path.  So,
> we need to ensure invariant state happens first.  To do that, we just
> upload it when creating a new batch.  On Gen6+ we'd need to worry about
> whether it's a RENDER or BLT batch, but because we have a combined ring,
> this approach should work fine on Gen4-5.
>
> Seems to fix GPU hangs when playing hardware accelerated video with
> mpv -hwdec=vaapi on Ironlake.
>
> Cc: mesa-sta...@lists.freedesktop.org
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=103529
> ---
>  src/mesa/drivers/dri/i965/brw_misc_state.c| 9 -
>  src/mesa/drivers/dri/i965/brw_state.h | 1 -
>  src/mesa/drivers/dri/i965/genX_state_upload.c | 2 --
>  src/mesa/drivers/dri/i965/intel_batchbuffer.c | 4 +++-
>  4 files changed, 3 insertions(+), 13 deletions(-)
>
> diff --git a/src/mesa/drivers/dri/i965/brw_misc_state.c
> b/src/mesa/drivers/dri/i965/brw_misc_state.c
> index fd96485d574..94d5c9783db 100644
> --- a/src/mesa/drivers/dri/i965/brw_misc_state.c
> +++ b/src/mesa/drivers/dri/i965/brw_misc_state.c
> @@ -560,15 +560,6 @@ brw_upload_invariant_state(struct brw_context *brw)
> ADVANCE_BATCH();
>  }
>
> -const struct brw_tracked_state brw_invariant_state = {
> -   .dirty = {
> -  .mesa = 0,
> -  .brw = BRW_NEW_BLORP |
> - BRW_NEW_CONTEXT,
> -   },
> -   .emit = brw_upload_invariant_state
> -};
> -
>  /**
>   * Define the base addresses which some state is referenced from.
>   *
> diff --git a/src/mesa/drivers/dri/i965/brw_state.h
> b/src/mesa/drivers/dri/i965/brw_state.h
> index cf13eca3438..ad508950f78 100644
> --- a/src/mesa/drivers/dri/i965/brw_state.h
> +++ b/src/mesa/drivers/dri/i965/brw_state.h
> @@ -51,7 +51,6 @@ extern const struct brw_tracked_state
> brw_wm_pull_constants;
>  extern const struct brw_tracked_state brw_cs_pull_constants;
>  extern const struct brw_tracked_state brw_constant_buffer;
>  extern const struct brw_tracked_state brw_curbe_offsets;
> -extern const struct brw_tracked_state brw_invariant_state;
>  extern const struct brw_tracked_state brw_binding_table_pointers;
>  extern const struct brw_tracked_state brw_depthbuffer;
>  extern const struct brw_tracked_state brw_recalculate_urb_fence;
> diff --git a/src/mesa/drivers/dri/i965/genX_state_upload.c
> b/src/mesa/drivers/dri/i965/genX_state_upload.c
> index d4b0de850c9..112f48181b0 100644
> --- a/src/mesa/drivers/dri/i965/genX_state_upload.c
> +++ b/src/mesa/drivers/dri/i965/genX_state_upload.c
> @@ -5366,8 +5366,6 @@ genX(init_atoms)(struct brw_context *brw)
>
>/* Command packets:
> */
> -  _invariant_state,
> -
>_binding_table_pointers,
>(blend_constant_color),
>
> diff --git a/src/mesa/drivers/dri/i965/intel_batchbuffer.c
> b/src/mesa/drivers/dri/i965/intel_batchbuffer.c
> index bbe13f34cef..3412b1d0a5f 100644
> --- a/src/mesa/drivers/dri/i965/intel_batchbuffer.c
> +++ b/src/mesa/drivers/dri/i965/intel_batchbuffer.c
> @@ -601,8 +601,10 @@ brw_new_batch(struct brw_context *brw)
>  * would otherwise be stored in the context (which for all intents and
>  * purposes means everything).
>  */
> -   if (brw->hw_ctx == 0)
> +   if (brw->hw_ctx == 0) {
>brw->ctx.NewDriverState |= BRW_NEW_CONTEXT;
> +  brw_upload_invariant_state(brw);
> +   }
>
> brw->ctx.NewDriverState |= BRW_NEW_BATCH;
>
> --
> 2.15.0
>
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH v3] meson: Enable SSE4.1 optimizations

2017-11-16 Thread Dylan Baker
This patch checks for an and then enables sse4.1 optimizations if the
host machine will be x86/x86_64.

v2: - Don't compile code, it's unnecessary since we require a compiler
  which always has SSE4.1 (Matt)
v3: - x64 -> x86_64 (Matt)

Signed-off-by: Dylan Baker 
Reviewed-by: Eric Engestrom  (v1)
---
 meson.build  | 15 ++-
 src/mesa/meson.build | 14 +++---
 2 files changed, 25 insertions(+), 4 deletions(-)

diff --git a/meson.build b/meson.build
index 383ebb36662..049c9a24e4a 100644
--- a/meson.build
+++ b/meson.build
@@ -502,7 +502,20 @@ foreach a : ['-Wno-override-init', 
'-Wno-initializer-overrides']
   endif
 endforeach
 
-# TODO: SSE41 (which is only required for core mesa)
+if host_machine.cpu_family().startswith('x86')
+  pre_args += '-DHAVE_SSE41'
+  with_sse41 = true
+  sse41_args = ['-msse4.1']
+
+  # GCC on x86 (not x86_64) with -msse* assumes a 16 byte aligned stack, but
+  # that's not guaranteed
+  if host_machine.cpu_family() == 'x86'
+sse41_args += '-mstackrealign'
+  endif
+else
+  with_sse41 = false
+  sse41_args = []
+endif
 
 # Check for GCC style atomics
 if cc.compiles('int main() { int n; return __atomic_load_n(, 
__ATOMIC_ACQUIRE); }',
diff --git a/src/mesa/meson.build b/src/mesa/meson.build
index b839fd02981..05a3a9ac55d 100644
--- a/src/mesa/meson.build
+++ b/src/mesa/meson.build
@@ -592,9 +592,6 @@ files_libmesa_gallium = files(
   'state_tracker/st_vdpau.h',
 )
 
-# TODO: sse41
-libmesa_sse41 = []
-
 matypes_h = []
 if with_asm_arch == 'x86' or with_asm_arch == 'x86_64'
   gen_matypes = executable(
@@ -692,6 +689,17 @@ files_libmesa_common += [
   sha1_h,
 ]
 
+if with_sse41
+  libmesa_sse41 = static_library(
+'mesa_sse41',
+files('main/streaming-load-memcpy.c', 'main/sse_minmax.c'),
+c_args : [c_vis_args, c_msvc_compat_args, sse41_args],
+include_directories : inc_common,
+  )
+else
+  libmesa_sse41 = []
+endif
+
 libmesa_classic = static_library(
   'mesa_classic',
   [files_libmesa_common, files_libmesa_classic],
-- 
2.15.0

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


Re: [Mesa-dev] Has anyone stressed radeonsi memory?

2017-11-16 Thread Marek Olšák
What is the staging area? Note that radeonsi creates all textures in
VRAM. The driver allocates its own staging copy (in RAM) for each
texture upload and deallocates it after the upload is done. The driver
also doesn't release memory immediately; it keeps it and recycles it
for future allocations, or releases it when it's unused for some time.
It makes staging allocations for texture uploads very cheap. If OGRE
does some of that too, it just adds unnecessary work and memory usage.

Marek

On Tue, Nov 14, 2017 at 6:43 PM, Michel Dänzer  wrote:
> On 13/11/17 04:39 AM, Matias N. Goldberg wrote:
>>
>> I am on a Radeon RX 560 2GB; using mesa git-57c8ead0cd (So... not too new 
>> not too old), Kernel 4.12.10
>>
>> I've been having complaints about our WIP branch of Ogre 2.2 about out of 
>> memory crashes, and I fixed them.
>>
>> I made a stress test where 495 textures with very different resolutions 
>> (most of them not power-of-2), and total memory from those textures is 
>> around 700MB (for some reason radentop reports all 2GB of my card are used 
>> during this stress test).
>> Additionally, 495 cubes (one cube for each texture) are rendered to screen 
>> to ensure driver keeps them resident.
>>
>> The problem is, we have different strategies:
>> 1. In one extreme, we can load every texture to a staging region, one at a 
>> time; and then from staging region copy to the final texture.
>> 2. In the other extreme, we load all textures to RAM at once, and use one 
>> giant staging region.
>>
>> Loading everything at once causes a GL_OUT_OF_MEMORY while creating the 
>> staging area of 700MB. Ok... sounds sorta reasonable.
>>
>> But things get interesting when loading using a staging area of 512MB:
>> 1. Loading goes fine.
>> 2. For a time, everything works fine.
>> 3. If I hide all cubes so that they aren't shown anymore:
>> 1. Framerate usually goes way down (not always), like 8 fps or so 
>> (should be at 1000 fps while empty, around 200 fps while showing the cubes).
>> How slow it becomes is not consistent.2. radeontop shows consumption 
>> goes down a lot (like half or more).
>> 3. A few seconds later, I almost always get a crash (SIGBUS) while 
>> writing to an UBO buffer that had been persistently mapped (non-coherent) 
>> since the beginning of the application.
>> 4. Running through valgrind, I don't get a crash.
>> 5. There are no errors reported by OpenGL.
>> 4. I don't get a crash if I never hide the cubes.
>>
>> Using a smaller staging area (256MB or lower) everything is always fine.
>>
>> So... is this behavior expected?
>> Am I uncovering a weird bug in how radeonsi/amdgpu-pro handle memory pages?
>
> Are you using the amdgpu kernel driver from an amdgpu-pro release or
> from the upstream Linux kernel? (If you're not sure, provide the dmesg
> output and Xorg log file)
>
> If the latter, can you try a 4.13 or 4.14 kernel and see if that works
> better?
>
>
>> I'd normally update to latest git, then create a test if the problem 
>> persists; but I've pulled latest git and saw that it required me to 
>> recompile llvm as well...
>
> Why, doesn't your distro have LLVM development packages?
>
>
> --
> Earthling Michel Dänzer   |   http://www.amd.com
> Libre software enthusiast | Mesa and X developer
> ___
> 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 v4 07/13] meson: extend install_megadrivers script to handle symmlinking

2017-11-16 Thread Dylan Baker
Which is required for the gallium media state trackers.

v4: - Make the full version the hard link and the partial so versiions
  the symlinks

Signed-off-by: Dylan Baker 
---
 bin/install_megadrivers.py | 19 ++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/bin/install_megadrivers.py b/bin/install_megadrivers.py
index a98d7dd177b..0415e5829eb 100755
--- a/bin/install_megadrivers.py
+++ b/bin/install_megadrivers.py
@@ -33,6 +33,7 @@ def main():
 parser.add_argument('megadriver')
 parser.add_argument('libdir')
 parser.add_argument('drivers', nargs='+')
+parser.add_argument('--so-version', action='append', default=[])
 args = parser.parse_args()
 
 to = os.path.join(os.environ.get('MESON_INSTALL_DESTDIR_PREFIX'), 
args.libdir)
@@ -43,11 +44,27 @@ def main():
 shutil.copy(args.megadriver, master)
 
 for each in args.drivers:
-driver = os.path.join(to, each)
+driver_name = os.path.join(to, each)
+
+if args.so_version:
+driver = '{}.{}'.format(driver_name, args.so_version[0])
+else:
+driver = driver_name
+
 if os.path.exists(driver):
 os.unlink(driver)
 print('installing {} to {}'.format(args.megadriver, driver))
 os.link(master, driver)
+
+if args.so_version:
+for v in args.so_version[1:]:
+if v:
+name = '{}.{}'.format(driver_name, v)
+else:
+name = driver_name
+if os.path.exists(name):
+os.unlink(name)
+os.symlink(driver, name)
 os.unlink(master)
 
 
-- 
2.15.0

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


[Mesa-dev] [PATCH v4 08/13] meson: drop gallium-media argument

2017-11-16 Thread Dylan Baker
This argument is the wrong approach for handling gallium media state
trackers, since it doesn't allow for an auto option. Instead we'll use
tristates, which do allow for auto.

This option has never been wired to anything anyway.

Signed-off-by: Dylan Baker 
---
 meson.build   | 17 -
 meson_options.txt |  6 --
 2 files changed, 23 deletions(-)

diff --git a/meson.build b/meson.build
index 7452066a167..ccbdd8cee47 100644
--- a/meson.build
+++ b/meson.build
@@ -348,23 +348,6 @@ if with_dri or with_gallium
   endif
 endif
 
-with_gallium_xvmc = false
-with_gallium_vdpau = false
-with_gallium_omx = false  # this is bellagio
-with_gallium_va = false
-with_gallium_media = false
-dep_va = []
-_drivers = get_option('gallium-media')
-if _drivers != ''
-  _split = _drivers.split(',')
-  with_gallium_xvmc = _split.contains('xvmc')
-  with_gallium_vdpau = _split.contains('vdpau')
-  with_gallium_omx = _split.contains('omx')
-  with_gallium_va = _split.contains('va')
-  with_gallium_media = (with_gallium_xvmc or with_gallium_vdpau or
-with_gallium_omx or with_gallium_va)
-endif
-
 gl_pkgconfig_c_flags = []
 if with_platform_x11
   if with_any_vk or (with_glx == 'dri' and with_dri_platform == 'drm')
diff --git a/meson_options.txt b/meson_options.txt
index 6c9cd33998c..119bec15709 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -49,12 +49,6 @@ option(
   value : 'auto',
   description : 'comma separated list of gallium drivers to build. If this is 
set to auto all drivers applicable to the target OS/architecture will be built'
 )
-option(
-  'gallium-media',
-  type : 'string',
-  value : '',
-  description : 'comma separated list of gallium media APIs to build 
(omx,va,vdpau,xvmc).'
-)
 option(
   'vulkan-drivers',
   type : 'string',
-- 
2.15.0

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


[Mesa-dev] [PATCH v4 13/13] meson: build gallium xa state tracker

2017-11-16 Thread Dylan Baker
v2: - set with_gallium_xa when -Dgallium-xa=true
- install pkg config file

Signed-off-by: Dylan Baker 
---
 meson.build   | 22 
 meson_options.txt |  7 +++
 src/gallium/meson.build   |  7 ++-
 src/gallium/state_trackers/xa/meson.build | 45 +
 src/gallium/targets/xa/meson.build| 84 +++
 5 files changed, 164 insertions(+), 1 deletion(-)
 create mode 100644 src/gallium/state_trackers/xa/meson.build
 create mode 100644 src/gallium/targets/xa/meson.build

diff --git a/meson.build b/meson.build
index bda1642ad5e..408a3892bac 100644
--- a/meson.build
+++ b/meson.build
@@ -525,6 +525,28 @@ if va_drivers_path == ''
   va_drivers_path = join_paths(get_option('libdir'), 'dri')
 endif
 
+_xa = get_option('gallium-xa')
+if _xa == 'auto'
+  if not ['linux', 'bsd'].contains(host_machine.system())
+with_gallium_xa = false
+  elif not (with_gallium_nouveau or with_gallium_freedreno or with_gallium_i915
+or with_gallium_svga)
+with_gallium_xa = false
+  else
+with_gallium_xa = true
+  endif
+elif _xa == 'true'
+  if not ['linux', 'bsd'].contains(host_machine.system())
+error('XA state tracker can only be built on unix-like OSes.')
+  elif not (with_gallium_nouveau or with_gallium_freedreno or with_gallium_i915
+or with_gallium_svga)
+error('XA state tracker requires at least one of the following gallium 
drivers: nouveau, freedreno, i915, svga.')
+  endif
+  with_gallium_xa = true
+else
+  with_gallium_xa = false
+endif
+
 gl_pkgconfig_c_flags = []
 if with_platform_x11
   if with_any_vk or (with_glx == 'dri' and with_dri_platform == 'drm')
diff --git a/meson_options.txt b/meson_options.txt
index 0a9f7a9e403..bdeb1b7f587 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -101,6 +101,13 @@ option(
   value : '',
   description : 'path to put va libraries. defaults to $libdir/dri.'
 )
+option(
+  'gallium-xa',
+  type : 'combo',
+  value : 'auto',
+  choices : ['auto', 'true', 'false'],
+  description : 'enable gallium xa state tracker.',
+)
 option(
   'vulkan-drivers',
   type : 'string',
diff --git a/src/gallium/meson.build b/src/gallium/meson.build
index c379b600d87..8a072322a28 100644
--- a/src/gallium/meson.build
+++ b/src/gallium/meson.build
@@ -111,6 +111,9 @@ endif
 if with_gallium_va
   subdir('state_trackers/va')
 endif
+if with_gallium_xa
+  subdir('state_trackers/xa')
+endif
 # TODO: SWR
 # TODO: clover
 if with_dri and with_gallium
@@ -134,6 +137,8 @@ endif
 if with_gallium_va
   subdir('targets/va')
 endif
-# TODO: xa
+if with_gallium_xa
+  subdir('targets/xa')
+endif
 # TODO: nine
 # TODO: tests
diff --git a/src/gallium/state_trackers/xa/meson.build 
b/src/gallium/state_trackers/xa/meson.build
new file mode 100644
index 000..109abc10b7d
--- /dev/null
+++ b/src/gallium/state_trackers/xa/meson.build
@@ -0,0 +1,45 @@
+# Copyright © 2017 Intel Corporation
+
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+# SOFTWARE.
+
+xa_version = ['2', '3', '0']
+
+xa_conf = configuration_data()
+xa_conf.set('XA_MAJOR', xa_version[0])
+xa_conf.set('XA_MINOR', xa_version[1])
+xa_conf.set('XA_PATCH', xa_version[2])
+
+xa_tracker_h = configure_file(
+  configuration : xa_conf,
+  input : 'xa_tracker.h.in',
+  output : 'xa_tracker.h',
+  install_dir : get_option('includedir'),
+)
+
+libxa_st = static_library(
+  'xa_st',
+  [xa_tracker_h, files(
+'xa_composite.c', 'xa_context.c', 'xa_renderer.c', 'xa_tgsi.c',
+'xa_tracker.c', 'xa_yuv.c',
+  )],
+  c_args : [c_vis_args, '-pedantic'],
+  include_directories : inc_common,
+)
+
+install_headers('xa_composite.h', 'xa_context.h')
diff --git a/src/gallium/targets/xa/meson.build 
b/src/gallium/targets/xa/meson.build
new file mode 100644
index 000..013b8a0
--- /dev/null
+++ b/src/gallium/targets/xa/meson.build
@@ -0,0 +1,84 @@
+# Copyright © 2017 Intel Corporation
+

[Mesa-dev] [PATCH v4 05/13] meson: build svga driver on linux

2017-11-16 Thread Dylan Baker
Build tested only.

Signed-off-by: Dylan Baker 
---
 meson.build |  6 ++-
 src/gallium/drivers/svga/meson.build| 88 +
 src/gallium/meson.build |  5 +-
 src/gallium/targets/dri/meson.build |  5 ++
 src/gallium/winsys/svga/drm/meson.build | 45 +
 5 files changed, 146 insertions(+), 3 deletions(-)
 create mode 100644 src/gallium/drivers/svga/meson.build
 create mode 100644 src/gallium/winsys/svga/drm/meson.build

diff --git a/meson.build b/meson.build
index 4aa3dba4ee6..532176d2121 100644
--- a/meson.build
+++ b/meson.build
@@ -128,14 +128,15 @@ with_gallium_vc5 = false
 with_gallium_etnaviv = false
 with_gallium_imx = false
 with_gallium_i915 = false
+with_gallium_svga = false
 _drivers = get_option('gallium-drivers')
 if _drivers == 'auto'
   if not ['darwin', 'windows'].contains(host_machine.system())
 # TODO: PPC, Sparc
 if ['x86', 'x86_64'].contains(host_machine.cpu_family())
-  _drivers = 'r300,r600,radeonsi,nouveau,swrast'
+  _drivers = 'r300,r600,radeonsi,nouveau,svga,swrast'
 elif ['arm', 'aarch64'].contains(host_machine.cpu_family())
-  _drivers = 'pl111,vc4,vc5,freedreno,etnaviv,imx,swrast'
+  _drivers = 'pl111,vc4,vc5,freedreno,etnaviv,imx,svga,swrast'
 else
   error('Unknown architecture. Please pass -Dgallium-drivers to set driver 
options. Patches gladly accepted to fix this.')
 endif
@@ -157,6 +158,7 @@ if _drivers != ''
   with_gallium_etnaviv = _split.contains('etnaviv')
   with_gallium_imx = _split.contains('imx')
   with_gallium_i915 = _split.contains('i915')
+  with_gallium_svga = _split.contains('svga')
   with_gallium = true
 endif
 
diff --git a/src/gallium/drivers/svga/meson.build 
b/src/gallium/drivers/svga/meson.build
new file mode 100644
index 000..d9a7da95a33
--- /dev/null
+++ b/src/gallium/drivers/svga/meson.build
@@ -0,0 +1,88 @@
+# Copyright © 2017 Intel Corporation
+
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+# SOFTWARE.
+
+files_svga = files(
+  'svga_cmd.c',
+  'svga_cmd_vgpu10.c',
+  'svga_context.c',
+  'svga_draw_arrays.c',
+  'svga_draw.c',
+  'svga_draw_elements.c',
+  'svga_format.c',
+  'svga_link.c',
+  'svga_msg.c',
+  'svga_pipe_blend.c',
+  'svga_pipe_blit.c',
+  'svga_pipe_clear.c',
+  'svga_pipe_constants.c',
+  'svga_pipe_depthstencil.c',
+  'svga_pipe_draw.c',
+  'svga_pipe_flush.c',
+  'svga_pipe_fs.c',
+  'svga_pipe_gs.c',
+  'svga_pipe_misc.c',
+  'svga_pipe_query.c',
+  'svga_pipe_rasterizer.c',
+  'svga_pipe_sampler.c',
+  'svga_pipe_streamout.c',
+  'svga_pipe_vertex.c',
+  'svga_pipe_vs.c',
+  'svga_resource_buffer.c',
+  'svga_resource_buffer_upload.c',
+  'svga_resource.c',
+  'svga_resource_texture.c',
+  'svga_sampler_view.c',
+  'svga_screen.c',
+  'svga_screen_cache.c',
+  'svga_shader.c',
+  'svga_state.c',
+  'svga_state_constants.c',
+  'svga_state_framebuffer.c',
+  'svga_state_fs.c',
+  'svga_state_gs.c',
+  'svga_state_need_swtnl.c',
+  'svga_state_rss.c',
+  'svga_state_sampler.c',
+  'svga_state_tgsi_transform.c',
+  'svga_state_tss.c',
+  'svga_state_vdecl.c',
+  'svga_state_vs.c',
+  'svga_surface.c',
+  'svga_swtnl_backend.c',
+  'svga_swtnl_draw.c',
+  'svga_swtnl_state.c',
+  'svga_tgsi.c',
+  'svga_tgsi_decl_sm30.c',
+  'svga_tgsi_insn.c',
+  'svga_tgsi_vgpu10.c',
+  'svgadump/svga_dump.c',
+  'svgadump/svga_shader_dump.c',
+  'svgadump/svga_shader_op.c',
+)
+
+libsvga = static_library(
+  'svga',
+  files_svga,
+  c_args : [c_vis_args, c_msvc_compat_args],
+  include_directories : [
+inc_src, inc_include, inc_gallium, inc_gallium_aux,
+include_directories('include')
+  ],
+)
diff --git a/src/gallium/meson.build b/src/gallium/meson.build
index 2568e5ddcfc..2a4cb66ad7a 100644
--- a/src/gallium/meson.build
+++ b/src/gallium/meson.build
@@ -81,6 +81,10 @@ if with_gallium_i915
   subdir('winsys/i915/drm')
   subdir('drivers/i915')
 endif
+if with_gallium_svga
+  

[Mesa-dev] [PATCH v4 02/13] meson: build i915g driver

2017-11-16 Thread Dylan Baker
Build tested only.

Signed-off-by: Dylan Baker 
---
 meson.build |  7 +++-
 src/gallium/drivers/i915/meson.build| 70 +
 src/gallium/meson.build |  7 ++--
 src/gallium/targets/dri/meson.build |  5 +++
 src/gallium/winsys/i915/drm/meson.build | 31 +++
 5 files changed, 116 insertions(+), 4 deletions(-)
 create mode 100644 src/gallium/drivers/i915/meson.build
 create mode 100644 src/gallium/winsys/i915/drm/meson.build

diff --git a/meson.build b/meson.build
index 87d435fcb71..cbeeef5a749 100644
--- a/meson.build
+++ b/meson.build
@@ -125,6 +125,7 @@ with_gallium_vc4 = false
 with_gallium_vc5 = false
 with_gallium_etnaviv = false
 with_gallium_imx = false
+with_gallium_i915 = false
 _drivers = get_option('gallium-drivers')
 if _drivers == 'auto'
   if not ['darwin', 'windows'].contains(host_machine.system())
@@ -151,6 +152,7 @@ if _drivers != ''
   with_gallium_vc5 = _split.contains('vc5')
   with_gallium_etnaviv = _split.contains('etnaviv')
   with_gallium_imx = _split.contains('imx')
+  with_gallium_i915 = _split.contains('i915')
   with_gallium = true
 endif
 
@@ -180,12 +182,15 @@ endif
 if with_dri_swrast and with_gallium_softpipe
   error('Only one swrast provider can be built')
 endif
+if with_dri_i915 and with_gallium_i915
+  error('Only one i915 provider can be built')
+endif
 if with_gallium_imx and not with_gallium_etnaviv
   error('IMX driver requires etnaviv driver')
 endif
 
 dep_libdrm_intel = []
-if with_dri_i915
+if with_dri_i915 or with_gallium_i915
   dep_libdrm_intel = dependency('libdrm_intel', version : '>= 2.4.75')
 endif
 
diff --git a/src/gallium/drivers/i915/meson.build 
b/src/gallium/drivers/i915/meson.build
new file mode 100644
index 000..17f0f6adf8f
--- /dev/null
+++ b/src/gallium/drivers/i915/meson.build
@@ -0,0 +1,70 @@
+# Copyright © 2017 Intel Corporation
+
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+# SOFTWARE.
+
+files_i915 = files(
+  'i915_batchbuffer.h',
+  'i915_batch.h',
+  'i915_blit.c',
+  'i915_blit.h',
+  'i915_clear.c',
+  'i915_context.c',
+  'i915_context.h',
+  'i915_debug.c',
+  'i915_debug_fp.c',
+  'i915_debug.h',
+  'i915_debug_private.h',
+  'i915_flush.c',
+  'i915_fpc_emit.c',
+  'i915_fpc.h',
+  'i915_fpc_optimize.c',
+  'i915_fpc_translate.c',
+  'i915_prim_emit.c',
+  'i915_prim_vbuf.c',
+  'i915_public.h',
+  'i915_query.c',
+  'i915_query.h',
+  'i915_reg.h',
+  'i915_resource_buffer.c',
+  'i915_resource.c',
+  'i915_resource.h',
+  'i915_resource_texture.c',
+  'i915_screen.c',
+  'i915_screen.h',
+  'i915_state.c',
+  'i915_state_derived.c',
+  'i915_state_dynamic.c',
+  'i915_state_emit.c',
+  'i915_state_fpc.c',
+  'i915_state.h',
+  'i915_state_immediate.c',
+  'i915_state_inlines.h',
+  'i915_state_sampler.c',
+  'i915_state_static.c',
+  'i915_surface.c',
+  'i915_surface.h',
+  'i915_winsys.h',
+)
+
+libi915 = static_library(
+  'i915',
+  files_i915,
+  c_args : [c_vis_args],
+  include_directories : [inc_include, inc_src, inc_gallium, inc_gallium_aux],
+)
diff --git a/src/gallium/meson.build b/src/gallium/meson.build
index 7ccf4819079..715fee86d0a 100644
--- a/src/gallium/meson.build
+++ b/src/gallium/meson.build
@@ -70,17 +70,18 @@ endif
 if with_gallium_imx
   subdir('winsys/imx/drm')
 endif
-if with_glx == 'gallium-xlib'
-  subdir('winsys/sw/xlib')
+if with_gallium_i915
+  subdir('winsys/i915/drm')
+  subdir('drivers/i915')
 endif
 subdir('state_trackers/dri')
 if with_osmesa == 'gallium'
   subdir('state_trackers/osmesa')
 endif
 if with_glx == 'gallium-xlib'
+  subdir('winsys/sw/xlib')
   subdir('state_trackers/glx/xlib')
 endif
-# TODO: i915
 # TODO: SVGA
 # TODO: r300
 # TODO: r600
diff --git a/src/gallium/targets/dri/meson.build 
b/src/gallium/targets/dri/meson.build
index c591b75d037..de97e8afeaf 100644
--- a/src/gallium/targets/dri/meson.build
+++ b/src/gallium/targets/dri/meson.build
@@ -107,6 +107,11 @@ if 

[Mesa-dev] [PATCH v4 10/13] meson: build gallium xvmc state tracker

2017-11-16 Thread Dylan Baker
v2: - set with_gallium_xvmc when -Dgallium-xvmc=true
- Install megadrivers properly
- only use cflags from pkg-config, don't add linker flags.
v4: - make use of the install_megadrivers.py changes

Signed-off-by: Dylan Baker 
---
 meson.build | 40 +-
 meson_options.txt   | 13 +
 src/gallium/meson.build |  7 ++-
 src/gallium/state_trackers/xvmc/meson.build | 53 +++
 src/gallium/targets/xvmc/meson.build| 81 +
 5 files changed, 192 insertions(+), 2 deletions(-)
 create mode 100644 src/gallium/state_trackers/xvmc/meson.build
 create mode 100644 src/gallium/targets/xvmc/meson.build

diff --git a/meson.build b/meson.build
index 0f8733f7651..9e4460e15c5 100644
--- a/meson.build
+++ b/meson.build
@@ -391,6 +391,44 @@ if vdpau_drivers_path == ''
   vdpau_drivers_path = join_paths(get_option('libdir'), 'vdpau')
 endif
 
+dep_xvmc = []
+_xvmc = get_option('gallium-xvmc')
+if _xvmc == 'auto'
+  if not ['linux', 'bsd'].contains(host_machine.system())
+with_gallium_xvmc = false
+  elif not with_platform_x11
+with_gallium_xvmc = false
+  elif not (with_gallium_r600 or with_gallium_nouveau)
+with_gallium_xvmc = false
+  else
+dep_xvmc = dependency('xvmc', version : '>= 1.0.6', required : false)
+with_gallium_xvmc = dep_xvmc.found()
+  endif
+elif _xvmc == 'true'
+  if not ['linux', 'bsd'].contains(host_machine.system())
+error('XVMC state tracker can only be build on unix-like OSes.')
+  elif not with_platform_x11
+error('XVMC state tracker requires X11 support.')
+with_gallium_xvmc = false
+  elif not (with_gallium_r600 or with_gallium_nouveau)
+error('XVMC state tracker requires at least one of the following gallium 
drivers: r600, nouveau.')
+  endif
+  dep_xvmc = dependency('xvmc', version : '>= 1.0.6')
+  with_gallium_xvmc = true
+else
+  with_gallium_xvmc = false
+endif
+if with_gallium_xvmc
+  dep_xvmc = declare_dependency(
+compile_args : dep_xvmc.get_pkgconfig_variable('cflags').split()
+  )
+endif
+
+xvmc_drivers_path = get_option('xvmc-libs-path')
+if xvmc_drivers_path == ''
+  xvmc_drivers_path = get_option('libdir')
+endif
+
 gl_pkgconfig_c_flags = []
 if with_platform_x11
   if with_any_vk or (with_glx == 'dri' and with_dri_platform == 'drm')
@@ -898,7 +936,7 @@ if with_platform_x11
 dep_xxf86vm = dependency('xxf86vm', required : false)
   endif
   if (with_any_vk or (with_glx == 'dri' and with_dri_platform == 'drm') or
-  with_gallium_vdpau)
+  (with_gallium_vdpau or with_gallium_xvmc))
 dep_xcb = dependency('xcb')
 dep_x11_xcb = dependency('x11-xcb')
 dep_xcb_dri2 = dependency('xcb-dri2', version : '>= 1.8')
diff --git a/meson_options.txt b/meson_options.txt
index 78b78a92dbf..f0de44e751b 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -62,6 +62,19 @@ option(
   value : '',
   description : 'path to put vdpau libraries. defaults to $libdir/vdpau.'
 )
+option(
+  'gallium-xvmc',
+  type : 'combo',
+  value : 'auto',
+  choices : ['auto', 'true', 'false'],
+  description : 'enable gallium xvmc state tracker.',
+)
+option(
+  'xvmc-libs-path',
+  type : 'string',
+  value : '',
+  description : 'path to put xvmc libraries. defaults to $libdir.'
+)
 option(
   'vulkan-drivers',
   type : 'string',
diff --git a/src/gallium/meson.build b/src/gallium/meson.build
index 446710e1495..a8317a53552 100644
--- a/src/gallium/meson.build
+++ b/src/gallium/meson.build
@@ -102,6 +102,9 @@ endif
 if with_gallium_vdpau
   subdir('state_trackers/vdpau')
 endif
+if with_gallium_xvmc
+  subdir('state_trackers/xvmc')
+endif
 # TODO: SWR
 # TODO: clover
 if with_dri and with_gallium
@@ -116,9 +119,11 @@ endif
 if with_gallium_vdpau
   subdir('targets/vdpau')
 endif
+if with_gallium_xvmc
+  subdir('targets/xvmc')
+endif
 # TODO: OMX
 # TODO: VA
 # TODO: xa
-# TODO: xvmc
 # TODO: nine
 # TODO: tests
diff --git a/src/gallium/state_trackers/xvmc/meson.build 
b/src/gallium/state_trackers/xvmc/meson.build
new file mode 100644
index 000..a1022c164b1
--- /dev/null
+++ b/src/gallium/state_trackers/xvmc/meson.build
@@ -0,0 +1,53 @@
+# Copyright © 2017 Intel Corporation
+
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 

[Mesa-dev] [PATCH v4 09/13] meson: build gallium vdpau state tracker

2017-11-16 Thread Dylan Baker
v2: - set with_gallium_vdpau when -Dgallium-vdpau=true
- Install megadriver hard links and symlinks
- only use cflags from pkg-config, don't add linker flags.
v4: - make use of the install_megadrivers.py changes

Signed-off-by: Dylan Baker 
---
 meson.build  |  46 +++-
 meson_options.txt|  13 
 src/gallium/meson.build  |   7 +-
 src/gallium/state_trackers/vdpau/meson.build |  32 +
 src/gallium/targets/vdpau/meson.build| 100 +++
 5 files changed, 196 insertions(+), 2 deletions(-)
 create mode 100644 src/gallium/state_trackers/vdpau/meson.build
 create mode 100644 src/gallium/targets/vdpau/meson.build

diff --git a/meson.build b/meson.build
index ccbdd8cee47..0f8733f7651 100644
--- a/meson.build
+++ b/meson.build
@@ -348,6 +348,49 @@ if with_dri or with_gallium
   endif
 endif
 
+dep_vdpau = []
+_vdpau = get_option('gallium-vdpau')
+if _vdpau == 'auto'
+  if not ['linux', 'bsd'].contains(host_machine.system())
+with_gallium_vdpau = false
+  elif not with_platform_x11
+with_gallium_vdpau = false
+  elif not (with_gallium_r300 or with_gallium_r600 or with_gallium_radeonsi or
+with_gallium_nouveau)
+with_gallium_vdpau = false
+  else
+dep_vdpau = dependency('vdpau', version : '>= 1.1', required : false)
+with_gallium_vdpau = dep_vdpau.found()
+  endif
+elif _vdpau == 'true'
+  if not ['linux', 'bsd'].contains(host_machine.system())
+error('VDPAU state tracker can only be build on unix-like OSes.')
+  elif not with_platform_x11
+error('VDPAU state tracker requires X11 support.')
+with_gallium_vdpau = false
+  elif not (with_gallium_r300 or with_gallium_r600 or with_gallium_radeonsi or
+with_gallium_nouveau)
+error('VDPAU state tracker requires at least one of the following gallium 
drivers: r300, r600, radeonsi, nouveau.')
+  endif
+  dep_vdpau = dependency('vdpau', version : '>= 1.1')
+  with_gallium_vdpau = true
+else
+  with_gallium_vdpau = false
+endif
+if with_gallium_vdpau
+  dep_vdpau = declare_dependency(
+compile_args : dep_vdpau.get_pkgconfig_variable('cflags').split()
+  )
+endif
+
+if with_gallium_vdpau
+  pre_args += '-DHAVE_ST_VDPAU'
+endif
+vdpau_drivers_path = get_option('vdpau-libs-path')
+if vdpau_drivers_path == ''
+  vdpau_drivers_path = join_paths(get_option('libdir'), 'vdpau')
+endif
+
 gl_pkgconfig_c_flags = []
 if with_platform_x11
   if with_any_vk or (with_glx == 'dri' and with_dri_platform == 'drm')
@@ -854,7 +897,8 @@ if with_platform_x11
 dep_xcb_glx = dependency('xcb-glx', version : '>= 1.8.1')
 dep_xxf86vm = dependency('xxf86vm', required : false)
   endif
-  if with_any_vk or (with_glx == 'dri' and with_dri_platform == 'drm')
+  if (with_any_vk or (with_glx == 'dri' and with_dri_platform == 'drm') or
+  with_gallium_vdpau)
 dep_xcb = dependency('xcb')
 dep_x11_xcb = dependency('x11-xcb')
 dep_xcb_dri2 = dependency('xcb-dri2', version : '>= 1.8')
diff --git a/meson_options.txt b/meson_options.txt
index 119bec15709..78b78a92dbf 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -49,6 +49,19 @@ option(
   value : 'auto',
   description : 'comma separated list of gallium drivers to build. If this is 
set to auto all drivers applicable to the target OS/architecture will be built'
 )
+option(
+  'gallium-vdpau',
+  type : 'combo',
+  value : 'auto',
+  choices : ['auto', 'true', 'false'],
+  description : 'enable gallium vdpau state tracker.',
+)
+option(
+  'vdpau-libs-path',
+  type : 'string',
+  value : '',
+  description : 'path to put vdpau libraries. defaults to $libdir/vdpau.'
+)
 option(
   'vulkan-drivers',
   type : 'string',
diff --git a/src/gallium/meson.build b/src/gallium/meson.build
index 8e8b1466f12..446710e1495 100644
--- a/src/gallium/meson.build
+++ b/src/gallium/meson.build
@@ -99,6 +99,9 @@ if with_glx == 'gallium-xlib'
   subdir('winsys/sw/xlib')
   subdir('state_trackers/glx/xlib')
 endif
+if with_gallium_vdpau
+  subdir('state_trackers/vdpau')
+endif
 # TODO: SWR
 # TODO: clover
 if with_dri and with_gallium
@@ -110,9 +113,11 @@ endif
 if with_glx == 'gallium-xlib'
   subdir('targets/libgl-xlib')
 endif
+if with_gallium_vdpau
+  subdir('targets/vdpau')
+endif
 # TODO: OMX
 # TODO: VA
-# TODO: vdpau
 # TODO: xa
 # TODO: xvmc
 # TODO: nine
diff --git a/src/gallium/state_trackers/vdpau/meson.build 
b/src/gallium/state_trackers/vdpau/meson.build
new file mode 100644
index 000..9678b79ef6c
--- /dev/null
+++ b/src/gallium/state_trackers/vdpau/meson.build
@@ -0,0 +1,32 @@
+# Copyright © 2017 Intel Corproration
+
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, 

[Mesa-dev] [PATCH v4 12/13] meson: build gallium va state tracker

2017-11-16 Thread Dylan Baker
v2: - set with_gallium_va when -Dgallium-va=true
- Fix megadrivers install
- only use cflags from pkg-config, don't add linker flags.
- Don't get version from pkg-config, it's not tracking the same
  version information.
v4: - Fix variable double-assignment

Signed-off-by: Dylan Baker 
---
 meson.build   | 41 +-
 meson_options.txt | 13 +
 src/gallium/meson.build   |  7 ++-
 src/gallium/state_trackers/va/meson.build | 39 ++
 src/gallium/targets/va/meson.build| 89 +++
 5 files changed, 187 insertions(+), 2 deletions(-)
 create mode 100644 src/gallium/state_trackers/va/meson.build
 create mode 100644 src/gallium/targets/va/meson.build

diff --git a/meson.build b/meson.build
index 2fffd66861d..bda1642ad5e 100644
--- a/meson.build
+++ b/meson.build
@@ -487,6 +487,44 @@ if with_gallium_omx
   )
 endif
 
+dep_va = []
+_va = get_option('gallium-va')
+if _va == 'auto'
+  if not ['linux', 'bsd'].contains(host_machine.system())
+with_gallium_va = false
+  elif not with_platform_x11
+with_gallium_va = false
+  elif not (with_gallium_r600 or with_gallium_radeonsi or with_gallium_nouveau)
+with_gallium_va = false
+  else
+dep_va = dependency('libva', version : '>= 0.38.0', required : false)
+with_gallium_va = dep_va.found()
+  endif
+elif _va == 'true'
+  if not ['linux', 'bsd'].contains(host_machine.system())
+error('VA state tracker can only be built on unix-like OSes.')
+  elif not (with_platform_x11 or with_platform_drm)
+error('VA state tracker requires X11 or drm or wayland platform support.')
+with_gallium_va = false
+  elif not (with_gallium_r600 or with_gallium_radeonsi or with_gallium_nouveau)
+error('VA state tracker requires at least one of the following gallium 
drivers: r600, radeonsi, nouveau.')
+  endif
+  dep_va = dependency('libva', version : '>= 0.38.0')
+  with_gallium_va = true
+else
+  with_gallium_va = false
+endif
+if with_gallium_va
+  dep_va = declare_dependency(
+compile_args : dep_va.get_pkgconfig_variable('cflags').split()
+  )
+endif
+
+va_drivers_path = get_option('va-libs-path')
+if va_drivers_path == ''
+  va_drivers_path = join_paths(get_option('libdir'), 'dri')
+endif
+
 gl_pkgconfig_c_flags = []
 if with_platform_x11
   if with_any_vk or (with_glx == 'dri' and with_dri_platform == 'drm')
@@ -994,7 +1032,8 @@ if with_platform_x11
 dep_xxf86vm = dependency('xxf86vm', required : false)
   endif
   if (with_any_vk or (with_glx == 'dri' and with_dri_platform == 'drm') or
-  (with_gallium_vdpau or with_gallium_xvmc or with_gallium_omx))
+  (with_gallium_vdpau or with_gallium_xvmc or with_gallium_omx or
+   with_gallium_xa))
 dep_xcb = dependency('xcb')
 dep_x11_xcb = dependency('x11-xcb')
 dep_xcb_dri2 = dependency('xcb-dri2', version : '>= 1.8')
diff --git a/meson_options.txt b/meson_options.txt
index 8ee216d5b8a..0a9f7a9e403 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -88,6 +88,19 @@ option(
   value : '',
   description : 'path to put omx libraries. defaults to omx-bellagio 
pkg-config pluginsdir.'
 )
+option(
+  'gallium-va',
+  type : 'combo',
+  value : 'auto',
+  choices : ['auto', 'true', 'false'],
+  description : 'enable gallium va state tracker.',
+)
+option(
+  'va-libs-path',
+  type : 'string',
+  value : '',
+  description : 'path to put va libraries. defaults to $libdir/dri.'
+)
 option(
   'vulkan-drivers',
   type : 'string',
diff --git a/src/gallium/meson.build b/src/gallium/meson.build
index c17dba51ff2..c379b600d87 100644
--- a/src/gallium/meson.build
+++ b/src/gallium/meson.build
@@ -108,6 +108,9 @@ endif
 if with_gallium_omx
   subdir('state_trackers/omx_bellagio')
 endif
+if with_gallium_va
+  subdir('state_trackers/va')
+endif
 # TODO: SWR
 # TODO: clover
 if with_dri and with_gallium
@@ -128,7 +131,9 @@ endif
 if with_gallium_omx
   subdir('targets/omx-bellagio')
 endif
-# TODO: VA
+if with_gallium_va
+  subdir('targets/va')
+endif
 # TODO: xa
 # TODO: nine
 # TODO: tests
diff --git a/src/gallium/state_trackers/va/meson.build 
b/src/gallium/state_trackers/va/meson.build
new file mode 100644
index 000..56e68e9e28d
--- /dev/null
+++ b/src/gallium/state_trackers/va/meson.build
@@ -0,0 +1,39 @@
+# Copyright © 2017 Intel Corporation
+
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.

[Mesa-dev] [PATCH v4 11/13] meson: build gallium omx state tracker

2017-11-16 Thread Dylan Baker
v2: - set with_gallium_omx when -Dgallium-omx=true
- Fix detection of omx plugins dir
- only use cflags from pkg-config, don't add linker flags.

Signed-off-by: Dylan Baker 
---
 meson.build| 60 -
 meson_options.txt  | 13 
 src/gallium/meson.build|  7 +-
 .../state_trackers/omx_bellagio/meson.build| 30 +
 src/gallium/targets/omx-bellagio/meson.build   | 77 ++
 5 files changed, 185 insertions(+), 2 deletions(-)
 create mode 100644 src/gallium/state_trackers/omx_bellagio/meson.build
 create mode 100644 src/gallium/targets/omx-bellagio/meson.build

diff --git a/meson.build b/meson.build
index 9e4460e15c5..2fffd66861d 100644
--- a/meson.build
+++ b/meson.build
@@ -429,6 +429,64 @@ if xvmc_drivers_path == ''
   xvmc_drivers_path = get_option('libdir')
 endif
 
+dep_omx = []
+_omx = get_option('gallium-omx')
+if _omx == 'auto'
+  if not ['linux', 'bsd'].contains(host_machine.system())
+with_gallium_omx = false
+  elif not with_platform_x11
+with_gallium_omx = false
+  elif not (with_gallium_r600 or with_gallium_radeonsi or with_gallium_nouveau)
+with_gallium_omx = false
+  else
+dep_omx = dependency('libomxil-bellagio', required : false)
+with_gallium_omx = dep_omx.found()
+  endif
+elif _omx == 'true'
+  if not ['linux', 'bsd'].contains(host_machine.system())
+error('OMX state tracker can only be built on unix-like OSes.')
+  elif not (with_platform_x11 or with_platform_drm)
+error('OMX state tracker requires X11 or drm platform support.')
+with_gallium_omx = false
+  elif not (with_gallium_r600 or with_gallium_radeonsi or with_gallium_nouveau)
+error('OMX state tracker requires at least one of the following gallium 
drivers: r600, radeonsi, nouveau.')
+  endif
+  dep_omx = dependency('libomxil-bellagio')
+  with_gallium_omx = true
+else
+  with_gallium_omx = false
+endif
+
+omx_drivers_path = get_option('omx-libs-path')
+if with_gallium_omx
+  # Figure out where to put the omx driver.
+  # FIXME: this could all be vastly simplified by adding a 'defined_variable'
+  # argument to meson's get_pkgconfig_variable method.
+  if omx_drivers_path == ''
+_omx_libdir = dep_omx.get_pkgconfig_variable('libdir')
+_omx_drivers_dir = dep_omx.get_pkgconfig_variable('pluginsdir')
+if _omx_libdir == get_option('libdir')
+  omx_drivers_path = _omx_drivers_dir
+else
+  _omx_base_dir = []
+  # This will fail on windows. Does OMX run on windows?
+  _omx_libdir = _omx_libdir.split('/')
+  _omx_drivers_dir = _omx_drivers_dir.split('/')
+  foreach o : _omx_drivers_dir
+if not _omx_libdir.contains(o)
+  _omx_base_dir += o
+endif
+  endforeach
+  omx_drivers_path = join_paths(get_option('libdir'), _omx_base_dir)
+endif
+  endif
+endif
+if with_gallium_omx
+  dep_omx = declare_dependency(
+compile_args : dep_omx.get_pkgconfig_variable('cflags').split()
+  )
+endif
+
 gl_pkgconfig_c_flags = []
 if with_platform_x11
   if with_any_vk or (with_glx == 'dri' and with_dri_platform == 'drm')
@@ -936,7 +994,7 @@ if with_platform_x11
 dep_xxf86vm = dependency('xxf86vm', required : false)
   endif
   if (with_any_vk or (with_glx == 'dri' and with_dri_platform == 'drm') or
-  (with_gallium_vdpau or with_gallium_xvmc))
+  (with_gallium_vdpau or with_gallium_xvmc or with_gallium_omx))
 dep_xcb = dependency('xcb')
 dep_x11_xcb = dependency('x11-xcb')
 dep_xcb_dri2 = dependency('xcb-dri2', version : '>= 1.8')
diff --git a/meson_options.txt b/meson_options.txt
index f0de44e751b..8ee216d5b8a 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -75,6 +75,19 @@ option(
   value : '',
   description : 'path to put xvmc libraries. defaults to $libdir.'
 )
+option(
+  'gallium-omx',
+  type : 'combo',
+  value : 'auto',
+  choices : ['auto', 'true', 'false'],
+  description : 'enable gallium omx bellagio state tracker.',
+)
+option(
+  'omx-libs-path',
+  type : 'string',
+  value : '',
+  description : 'path to put omx libraries. defaults to omx-bellagio 
pkg-config pluginsdir.'
+)
 option(
   'vulkan-drivers',
   type : 'string',
diff --git a/src/gallium/meson.build b/src/gallium/meson.build
index a8317a53552..c17dba51ff2 100644
--- a/src/gallium/meson.build
+++ b/src/gallium/meson.build
@@ -105,6 +105,9 @@ endif
 if with_gallium_xvmc
   subdir('state_trackers/xvmc')
 endif
+if with_gallium_omx
+  subdir('state_trackers/omx_bellagio')
+endif
 # TODO: SWR
 # TODO: clover
 if with_dri and with_gallium
@@ -122,7 +125,9 @@ endif
 if with_gallium_xvmc
   subdir('targets/xvmc')
 endif
-# TODO: OMX
+if with_gallium_omx
+  subdir('targets/omx-bellagio')
+endif
 # TODO: VA
 # TODO: xa
 # TODO: nine
diff --git a/src/gallium/state_trackers/omx_bellagio/meson.build 
b/src/gallium/state_trackers/omx_bellagio/meson.build
new file mode 

[Mesa-dev] [PATCH v4 01/13] meson: add proper LLVM modules to check for RadeonSI as well

2017-11-16 Thread Dylan Baker
Signed-off-by: Dylan Baker 
---
 meson.build | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/meson.build b/meson.build
index 383ebb36662..87d435fcb71 100644
--- a/meson.build
+++ b/meson.build
@@ -702,7 +702,7 @@ if with_gallium_freedreno
 endif
 
 llvm_modules = ['bitwriter', 'engine', 'mcdisassembler', 'mcjit']
-if with_amd_vk
+if with_amd_vk or with_gallium_radeonsi # TODO: r600
   llvm_modules += ['amdgpu', 'bitreader', 'ipo']
 endif
 dep_llvm = []
-- 
2.15.0

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


[Mesa-dev] [PATCH v4 06/13] meson: build virgl driver

2017-11-16 Thread Dylan Baker
Build tested only.

Signed-off-by: Dylan Baker 
---
 meson.build| 16 
 src/gallium/drivers/virgl/meson.build  | 39 ++
 src/gallium/meson.build|  7 +-
 src/gallium/targets/dri/meson.build|  5 
 src/gallium/winsys/virgl/drm/meson.build   | 27 +
 src/gallium/winsys/virgl/vtest/meson.build | 26 
 6 files changed, 114 insertions(+), 6 deletions(-)
 create mode 100644 src/gallium/drivers/virgl/meson.build
 create mode 100644 src/gallium/winsys/virgl/drm/meson.build
 create mode 100644 src/gallium/winsys/virgl/vtest/meson.build

diff --git a/meson.build b/meson.build
index 532176d2121..7452066a167 100644
--- a/meson.build
+++ b/meson.build
@@ -129,14 +129,15 @@ with_gallium_etnaviv = false
 with_gallium_imx = false
 with_gallium_i915 = false
 with_gallium_svga = false
+with_gallium_virgl = false
 _drivers = get_option('gallium-drivers')
 if _drivers == 'auto'
   if not ['darwin', 'windows'].contains(host_machine.system())
 # TODO: PPC, Sparc
 if ['x86', 'x86_64'].contains(host_machine.cpu_family())
-  _drivers = 'r300,r600,radeonsi,nouveau,svga,swrast'
+  _drivers = 'r300,r600,radeonsi,nouveau,virgl,svga,swrast'
 elif ['arm', 'aarch64'].contains(host_machine.cpu_family())
-  _drivers = 'pl111,vc4,vc5,freedreno,etnaviv,imx,svga,swrast'
+  _drivers = 'pl111,vc4,vc5,freedreno,etnaviv,imx,virgl,svga,swrast'
 else
   error('Unknown architecture. Please pass -Dgallium-drivers to set driver 
options. Patches gladly accepted to fix this.')
 endif
@@ -159,6 +160,7 @@ if _drivers != ''
   with_gallium_imx = _split.contains('imx')
   with_gallium_i915 = _split.contains('i915')
   with_gallium_svga = _split.contains('svga')
+  with_gallium_virgl = _split.contains('virgl')
   with_gallium = true
 endif
 
@@ -273,9 +275,13 @@ else
   with_egl = false
 endif
 
-# TODO: or virgl
-if with_egl and with_gallium_radeonsi and not (with_platform_drm or 
with_platform_surfaceless)
-  error('RadeonSI requires drm or surfaceless platform when using EGL')
+if with_egl and not (with_platform_drm or with_platform_surfaceless)
+  if with_gallium_radeonsi
+error('RadeonSI requires drm or surfaceless platform when using EGL')
+  endif
+  if with_gallium_virgl
+error('Virgl requires drm or surfaceless platform when using EGL')
+  endif
 endif
 
 pre_args += '-DGLX_USE_TLS'
diff --git a/src/gallium/drivers/virgl/meson.build 
b/src/gallium/drivers/virgl/meson.build
new file mode 100644
index 000..8284f548927
--- /dev/null
+++ b/src/gallium/drivers/virgl/meson.build
@@ -0,0 +1,39 @@
+# Copyright © 2017 Intel Corporation
+
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+# SOFTWARE.
+
+files_libvirgl = files(
+  'virgl_buffer.c',
+  'virgl_context.c',
+  'virgl_encode.c',
+  'virgl_query.c',
+  'virgl_resource.c',
+  'virgl_screen.c',
+  'virgl_streamout.c',
+  'virgl_texture.c',
+  'virgl_tgsi.c',
+)
+
+libvirgl = static_library(
+  'virgl',
+  files_libvirgl,
+  c_args : c_vis_args,
+  include_directories : inc_common,
+  dependencies : dep_libdrm,
+)
diff --git a/src/gallium/meson.build b/src/gallium/meson.build
index 2a4cb66ad7a..8e8b1466f12 100644
--- a/src/gallium/meson.build
+++ b/src/gallium/meson.build
@@ -1,4 +1,5 @@
 # Copyright © 2017 Dylan Baker
+# Copyright © 2017 Intel Corporation
 
 # Permission is hereby granted, free of charge, to any person obtaining a copy
 # of this software and associated documentation files (the "Software"), to deal
@@ -85,6 +86,11 @@ if with_gallium_svga
   subdir('drivers/svga')
   subdir('winsys/svga/drm')
 endif
+if with_gallium_virgl
+  subdir('drivers/virgl')
+  subdir('winsys/virgl/drm')
+  subdir('winsys/virgl/vtest')
+endif
 subdir('state_trackers/dri')
 if with_osmesa == 'gallium'
   subdir('state_trackers/osmesa')
@@ -94,7 +100,6 @@ if with_glx == 'gallium-xlib'
   

[Mesa-dev] [PATCH v4 04/13] meson: build r600 driver

2017-11-16 Thread Dylan Baker
v4: - Ensure inc_amd_common defined when radeonsi is disabled (needed by
  r600)

Signed-off-by: Dylan Baker 
Tested-by: Aaron Watry 
---
 meson.build  |  22 --
 src/amd/common/meson.build   |   2 -
 src/gallium/drivers/r600/meson.build | 128 +++
 src/gallium/meson.build  |   6 +-
 src/gallium/targets/dri/meson.build  |   7 +-
 src/meson.build  |   1 +
 6 files changed, 155 insertions(+), 11 deletions(-)
 create mode 100644 src/gallium/drivers/r600/meson.build

diff --git a/meson.build b/meson.build
index 8e52b70e201..4aa3dba4ee6 100644
--- a/meson.build
+++ b/meson.build
@@ -119,6 +119,7 @@ with_gallium = false
 with_gallium_pl111 = false
 with_gallium_radeonsi = false
 with_gallium_r300 = false
+with_gallium_r600 = false
 with_gallium_nouveau = false
 with_gallium_freedreno = false
 with_gallium_softpipe = false
@@ -132,7 +133,7 @@ if _drivers == 'auto'
   if not ['darwin', 'windows'].contains(host_machine.system())
 # TODO: PPC, Sparc
 if ['x86', 'x86_64'].contains(host_machine.cpu_family())
-  _drivers = 'r300,radeonsi,nouveau,swrast'
+  _drivers = 'r300,r600,radeonsi,nouveau,swrast'
 elif ['arm', 'aarch64'].contains(host_machine.cpu_family())
   _drivers = 'pl111,vc4,vc5,freedreno,etnaviv,imx,swrast'
 else
@@ -147,6 +148,7 @@ if _drivers != ''
   with_gallium_pl111 = _split.contains('pl111')
   with_gallium_radeonsi = _split.contains('radeonsi')
   with_gallium_r300 = _split.contains('r300')
+  with_gallium_r600 = _split.contains('r600')
   with_gallium_nouveau = _split.contains('nouveau')
   with_gallium_freedreno = _split.contains('freedreno')
   with_gallium_softpipe = _split.contains('swrast')
@@ -678,9 +680,13 @@ dep_thread = dependency('threads')
 if dep_thread.found() and host_machine.system() != 'windows'
   pre_args += '-DHAVE_PTHREAD'
 endif
-dep_elf = dependency('libelf', required : false)
-if not dep_elf.found() and (with_amd_vk or with_gallium_radeonsi) # TODO: 
clover, r600
-  dep_elf = cc.find_library('elf')
+if with_amd_vk or with_gallium_radeonsi or with_gallium_r600 # TODO: clover
+  dep_elf = dependency('libelf', required : false)
+  if not dep_elf.found()
+dep_elf = cc.find_library('elf')
+  endif
+else
+  dep_elf = []
 endif
 dep_expat = dependency('expat')
 # this only exists on linux so either this is linux and it will be found, or
@@ -695,7 +701,8 @@ dep_libdrm_freedreno = []
 if with_amd_vk or with_gallium_radeonsi
   dep_libdrm_amdgpu = dependency('libdrm_amdgpu', version : '>= 2.4.88')
 endif
-if with_gallium_radeonsi or with_dri_r100 or with_dri_r200 or with_gallium_r300
+if (with_gallium_radeonsi or with_dri_r100 or with_dri_r200 or
+with_gallium_r300 or with_gallium_r600)
   dep_libdrm_radeon = dependency('libdrm_radeon', version : '>= 2.4.71')
 endif
 if with_gallium_nouveau or with_dri_nouveau
@@ -709,8 +716,11 @@ if with_gallium_freedreno
 endif
 
 llvm_modules = ['bitwriter', 'engine', 'mcdisassembler', 'mcjit']
-if with_amd_vk or with_gallium_radeonsi # TODO: r600
+if with_amd_vk or with_gallium_radeonsi or with_gallium_r600
   llvm_modules += ['amdgpu', 'bitreader', 'ipo']
+  if with_gallium_r600
+llvm_modules += 'asmparser'
+  endif
 endif
 dep_llvm = []
 if with_llvm
diff --git a/src/amd/common/meson.build b/src/amd/common/meson.build
index 4fd7edc5cd3..8c526675c40 100644
--- a/src/amd/common/meson.build
+++ b/src/amd/common/meson.build
@@ -18,8 +18,6 @@
 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 # SOFTWARE.
 
-inc_amd_common = include_directories('.')
-
 sid_tables_h = custom_target(
   'sid_tables_h',
   input : ['sid_tables.py', 'sid.h', 'gfx9d.h'],
diff --git a/src/gallium/drivers/r600/meson.build 
b/src/gallium/drivers/r600/meson.build
new file mode 100644
index 000..411b550331d
--- /dev/null
+++ b/src/gallium/drivers/r600/meson.build
@@ -0,0 +1,128 @@
+# Copyright © 2017 Intel Corporation
+
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 

[Mesa-dev] [PATCH v4 03/13] meson: build r300 driver

2017-11-16 Thread Dylan Baker
This is build tested only

Signed-off-by: Dylan Baker 
---
 meson.build  |   6 +-
 src/gallium/drivers/r300/meson.build | 156 +++
 src/gallium/meson.build  |   9 +-
 src/gallium/targets/dri/meson.build  |  12 ++-
 4 files changed, 176 insertions(+), 7 deletions(-)
 create mode 100644 src/gallium/drivers/r300/meson.build

diff --git a/meson.build b/meson.build
index cbeeef5a749..8e52b70e201 100644
--- a/meson.build
+++ b/meson.build
@@ -118,6 +118,7 @@ endif
 with_gallium = false
 with_gallium_pl111 = false
 with_gallium_radeonsi = false
+with_gallium_r300 = false
 with_gallium_nouveau = false
 with_gallium_freedreno = false
 with_gallium_softpipe = false
@@ -131,7 +132,7 @@ if _drivers == 'auto'
   if not ['darwin', 'windows'].contains(host_machine.system())
 # TODO: PPC, Sparc
 if ['x86', 'x86_64'].contains(host_machine.cpu_family())
-  _drivers = 'radeonsi,nouveau,swrast'
+  _drivers = 'r300,radeonsi,nouveau,swrast'
 elif ['arm', 'aarch64'].contains(host_machine.cpu_family())
   _drivers = 'pl111,vc4,vc5,freedreno,etnaviv,imx,swrast'
 else
@@ -145,6 +146,7 @@ if _drivers != ''
   _split = _drivers.split(',')
   with_gallium_pl111 = _split.contains('pl111')
   with_gallium_radeonsi = _split.contains('radeonsi')
+  with_gallium_r300 = _split.contains('r300')
   with_gallium_nouveau = _split.contains('nouveau')
   with_gallium_freedreno = _split.contains('freedreno')
   with_gallium_softpipe = _split.contains('swrast')
@@ -693,7 +695,7 @@ dep_libdrm_freedreno = []
 if with_amd_vk or with_gallium_radeonsi
   dep_libdrm_amdgpu = dependency('libdrm_amdgpu', version : '>= 2.4.88')
 endif
-if with_gallium_radeonsi or with_dri_r100 or with_dri_r200
+if with_gallium_radeonsi or with_dri_r100 or with_dri_r200 or with_gallium_r300
   dep_libdrm_radeon = dependency('libdrm_radeon', version : '>= 2.4.71')
 endif
 if with_gallium_nouveau or with_dri_nouveau
diff --git a/src/gallium/drivers/r300/meson.build 
b/src/gallium/drivers/r300/meson.build
new file mode 100644
index 000..0d525d8d1b3
--- /dev/null
+++ b/src/gallium/drivers/r300/meson.build
@@ -0,0 +1,156 @@
+# Copyright © 2017 Intel Corporation
+
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+# SOFTWARE.
+
+files_r300 = files(
+  'r300_blit.c',
+  'r300_cb.h',
+  'r300_chipset.c',
+  'r300_chipset.h',
+  'r300_context.c',
+  'r300_context.h',
+  'r300_cs.h',
+  'r300_debug.c',
+  'r300_defines.h',
+  'r300_emit.c',
+  'r300_emit.h',
+  'r300_flush.c',
+  'r300_fs.c',
+  'r300_fs.h',
+  'r300_hyperz.c',
+  'r300_public.h',
+  'r300_query.c',
+  'r300_reg.h',
+  'r300_render.c',
+  'r300_render_stencilref.c',
+  'r300_render_translate.c',
+  'r300_resource.c',
+  'r300_screen_buffer.c',
+  'r300_screen_buffer.h',
+  'r300_screen.c',
+  'r300_screen.h',
+  'r300_shader_semantics.h',
+  'r300_state.c',
+  'r300_state_derived.c',
+  'r300_state_inlines.h',
+  'r300_texture.c',
+  'r300_texture_desc.c',
+  'r300_texture_desc.h',
+  'r300_texture.h',
+  'r300_tgsi_to_rc.c',
+  'r300_tgsi_to_rc.h',
+  'r300_transfer.c',
+  'r300_transfer.h',
+  'r300_vs.c',
+  'r300_vs_draw.c',
+  'r300_vs.h',
+  'compiler/memory_pool.c',
+  'compiler/memory_pool.h',
+  'compiler/r300_fragprog.c',
+  'compiler/r300_fragprog_emit.c',
+  'compiler/r300_fragprog.h',
+  'compiler/r300_fragprog_swizzle.c',
+  'compiler/r300_fragprog_swizzle.h',
+  'compiler/r3xx_fragprog.c',
+  'compiler/r3xx_vertprog.c',
+  'compiler/r3xx_vertprog_dump.c',
+  'compiler/r500_fragprog.c',
+  'compiler/r500_fragprog_emit.c',
+  'compiler/r500_fragprog.h',
+  'compiler/radeon_code.c',
+  'compiler/radeon_code.h',
+  'compiler/radeon_compiler.c',
+  'compiler/radeon_compiler.h',
+  'compiler/radeon_compiler_util.c',
+  'compiler/radeon_compiler_util.h',
+  'compiler/radeon_dataflow.c',
+  'compiler/radeon_dataflow_deadcode.c',
+  'compiler/radeon_dataflow.h',
+  

Re: [Mesa-dev] [PATCH] amd: build addrlib with C++11

2017-11-16 Thread Marek Olšák
Reviewed-by: Marek Olšák 

Marek

On Wed, Nov 15, 2017 at 12:55 PM, Nicolai Hähnle  wrote:
> From: Nicolai Hähnle 
>
> It is required for LLVM anyway.
>
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=103658
> Fixes: 7f33e94e43a6 ("amd/addrlib: update to latest version")
> ---
>  src/amd/Makefile.addrlib.am | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/amd/Makefile.addrlib.am b/src/amd/Makefile.addrlib.am
> index 46689637f9b..90dfe963445 100644
> --- a/src/amd/Makefile.addrlib.am
> +++ b/src/amd/Makefile.addrlib.am
> @@ -26,15 +26,15 @@ addrlib_libamdgpu_addrlib_la_CPPFLAGS = \
> -I$(srcdir)/common \
> -I$(srcdir)/addrlib \
> -I$(srcdir)/addrlib/core \
> -I$(srcdir)/addrlib/inc/chip/gfx9 \
> -I$(srcdir)/addrlib/inc/chip/r800 \
> -I$(srcdir)/addrlib/gfx9/chip \
> -I$(srcdir)/addrlib/r800/chip \
> -DBRAHMA_BUILD=1
>
>  addrlib_libamdgpu_addrlib_la_CXXFLAGS = \
> -   $(VISIBILITY_CXXFLAGS)
> +   $(VISIBILITY_CXXFLAGS) $(CXX11_CXXFLAGS)
>
>  noinst_LTLIBRARIES += $(ADDRLIB_LIBS)
>
>  addrlib_libamdgpu_addrlib_la_SOURCES = $(ADDRLIB_FILES)
> --
> 2.11.0
>
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] svga: add missing PIPE_SHADER_CAP_MAX_HW_ATOMIC_COUNTER* cases

2017-11-16 Thread Dave Airlie
On 17 November 2017 at 09:41, Charmaine Lee  wrote:
>
> Reviewed-by: Charmaine Lee 
>

Oops,

Acked-by: Dave Airlie 
> 
> From: Brian Paul 
> Sent: Thursday, November 16, 2017 3:36:15 PM
> To: mesa-dev@lists.freedesktop.org
> Cc: Charmaine Lee; Neha Bhende
> Subject: [PATCH] svga: add missing PIPE_SHADER_CAP_MAX_HW_ATOMIC_COUNTER* 
> cases
>
> ---
>  src/gallium/drivers/svga/svga_screen.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/src/gallium/drivers/svga/svga_screen.c 
> b/src/gallium/drivers/svga/svga_screen.c
> index 8621640..ab604b9 100644
> --- a/src/gallium/drivers/svga/svga_screen.c
> +++ b/src/gallium/drivers/svga/svga_screen.c
> @@ -708,6 +708,8 @@ vgpu10_get_shader_param(struct pipe_screen *screen,
> case PIPE_SHADER_CAP_LOWER_IF_THRESHOLD:
> case PIPE_SHADER_CAP_TGSI_SKIP_MERGE_REGISTERS:
> case PIPE_SHADER_CAP_INT64_ATOMICS:
> +   case PIPE_SHADER_CAP_MAX_HW_ATOMIC_COUNTERS:
> +   case PIPE_SHADER_CAP_MAX_HW_ATOMIC_COUNTER_BUFFERS:
>return 0;
> case PIPE_SHADER_CAP_MAX_UNROLL_ITERATIONS_HINT:
>return 32;
> --
> 1.9.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] amd: build addrlib with C++11

2017-11-16 Thread Vinson Lee
On Wed, Nov 15, 2017 at 3:55 AM, Nicolai Hähnle  wrote:
> From: Nicolai Hähnle 
>
> It is required for LLVM anyway.
>
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=103658
> Fixes: 7f33e94e43a6 ("amd/addrlib: update to latest version")
> ---
>  src/amd/Makefile.addrlib.am | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/amd/Makefile.addrlib.am b/src/amd/Makefile.addrlib.am
> index 46689637f9b..90dfe963445 100644
> --- a/src/amd/Makefile.addrlib.am
> +++ b/src/amd/Makefile.addrlib.am
> @@ -26,15 +26,15 @@ addrlib_libamdgpu_addrlib_la_CPPFLAGS = \
> -I$(srcdir)/common \
> -I$(srcdir)/addrlib \
> -I$(srcdir)/addrlib/core \
> -I$(srcdir)/addrlib/inc/chip/gfx9 \
> -I$(srcdir)/addrlib/inc/chip/r800 \
> -I$(srcdir)/addrlib/gfx9/chip \
> -I$(srcdir)/addrlib/r800/chip \
> -DBRAHMA_BUILD=1
>
>  addrlib_libamdgpu_addrlib_la_CXXFLAGS = \
> -   $(VISIBILITY_CXXFLAGS)
> +   $(VISIBILITY_CXXFLAGS) $(CXX11_CXXFLAGS)
>
>  noinst_LTLIBRARIES += $(ADDRLIB_LIBS)
>
>  addrlib_libamdgpu_addrlib_la_SOURCES = $(ADDRLIB_FILES)
> --
> 2.11.0
>
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev


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


Re: [Mesa-dev] [PATCH] svga: add missing PIPE_SHADER_CAP_MAX_HW_ATOMIC_COUNTER* cases

2017-11-16 Thread Charmaine Lee

Reviewed-by: Charmaine Lee 


From: Brian Paul 
Sent: Thursday, November 16, 2017 3:36:15 PM
To: mesa-dev@lists.freedesktop.org
Cc: Charmaine Lee; Neha Bhende
Subject: [PATCH] svga: add missing PIPE_SHADER_CAP_MAX_HW_ATOMIC_COUNTER* cases

---
 src/gallium/drivers/svga/svga_screen.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/gallium/drivers/svga/svga_screen.c 
b/src/gallium/drivers/svga/svga_screen.c
index 8621640..ab604b9 100644
--- a/src/gallium/drivers/svga/svga_screen.c
+++ b/src/gallium/drivers/svga/svga_screen.c
@@ -708,6 +708,8 @@ vgpu10_get_shader_param(struct pipe_screen *screen,
case PIPE_SHADER_CAP_LOWER_IF_THRESHOLD:
case PIPE_SHADER_CAP_TGSI_SKIP_MERGE_REGISTERS:
case PIPE_SHADER_CAP_INT64_ATOMICS:
+   case PIPE_SHADER_CAP_MAX_HW_ATOMIC_COUNTERS:
+   case PIPE_SHADER_CAP_MAX_HW_ATOMIC_COUNTER_BUFFERS:
   return 0;
case PIPE_SHADER_CAP_MAX_UNROLL_ITERATIONS_HINT:
   return 32;
--
1.9.1

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


[Mesa-dev] [PATCH] svga: add missing PIPE_SHADER_CAP_MAX_HW_ATOMIC_COUNTER* cases

2017-11-16 Thread Brian Paul
---
 src/gallium/drivers/svga/svga_screen.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/gallium/drivers/svga/svga_screen.c 
b/src/gallium/drivers/svga/svga_screen.c
index 8621640..ab604b9 100644
--- a/src/gallium/drivers/svga/svga_screen.c
+++ b/src/gallium/drivers/svga/svga_screen.c
@@ -708,6 +708,8 @@ vgpu10_get_shader_param(struct pipe_screen *screen,
case PIPE_SHADER_CAP_LOWER_IF_THRESHOLD:
case PIPE_SHADER_CAP_TGSI_SKIP_MERGE_REGISTERS:
case PIPE_SHADER_CAP_INT64_ATOMICS:
+   case PIPE_SHADER_CAP_MAX_HW_ATOMIC_COUNTERS:
+   case PIPE_SHADER_CAP_MAX_HW_ATOMIC_COUNTER_BUFFERS:
   return 0;
case PIPE_SHADER_CAP_MAX_UNROLL_ITERATIONS_HINT:
   return 32;
-- 
1.9.1

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


Re: [Mesa-dev] [PATCH] r600: shader CF_OP_VTX also doesn't use the EOP bit.

2017-11-16 Thread Dave Airlie
On 17 November 2017 at 08:00, Gert Wollny  wrote:
> Am Mittwoch, den 15.11.2017, 11:28 +1000 schrieb Dave Airlie:
>> On 15 November 2017 at 04:50, Gert Wollny 
>> wrote:
>> > Although the EOP bit is documented for the vertex fetch clause, it
>> > is not
>> > properly interpreted. As a result the piglit
>> >   spec/arb_tessellation_shader/execution/trivial-tess-gs_no-gs-
>> > inputs creates a TESS_EVAL shader that does not have an EOP clause,
>> > which might result in a GPU lockup.
>> >
>> > This patch forces an additional CF_OP_NOP group like it is already
>> > done for other final CF_OP groups.
>>
>> Although I think this is probably a good safety thing to add, I've
>> sent a patch that should make it unneeded, it would be good if you
>> could test it.
>
> Regardless o this, I wonder why with do CF_OP_VTK and CF_OP_TEX not
> emit the EOP bit on evergreen? The documentation says it is supported,
> and when I apply below path (changed white spaces to fit the mail
> size), then I don't see any lock-ups, the sb disassembler reports the
> EOP flag, I don't get valgrind errors in sb, and no piglit regressions.
>

Looks like you found the actual bug there, the fact we don't emit the eop bit
is probably responsible for lots of higher up workarounds.

Dave.

> best,
> Gert
>
> --- a/src/gallium/drivers/r600/eg_asm.c
> +++ b/src/gallium/drivers/r600/eg_asm.c
> @@ -71,10 +69,13 @@ int eg_bytecode_cf_build(struct r600_bytecode *bc,
> struct r600_bytecode_cf *cf)
> } else if (cfop->flags & CF_CLAUSE) {
>  /* CF_TEX/VTX (CF_ALU already handled above) */
>bc->bytecode[id++] = S_SQ_CF_WORD0_ADDR(cf->addr >> 1);
> -  bc->bytecode[id++] = S_SQ_CF_WORD1_CF_INST(opcode) |
> +  bc->bytecode[id] = S_SQ_CF_WORD1_CF_INST(opcode) |
>  S_SQ_CF_WORD1_BARRIER(1) |
>  S_SQ_CF_WORD1_VALID_PIXEL_MODE(cf->vpm) |
>  S_SQ_CF_WORD1_COUNT((cf->ndw / 4) - 1);
> + if (bc->chip_class == EVERGREEN) /* no EOP on cayman */
> +bc->bytecode[id] |=
>  S_SQ_CF_ALLOC_EXPORT_WORD1_END_OF_PROGRAM(cf->end_of_program);
> +id++;
> } else if (cfop->flags & CF_EXP) {
>  /* EXPORT instructions */
>  bc->bytecode[id++] =
> S_SQ_CF_ALLOC_EXPORT_WORD0_RW_GPR(cf->output.gpr) |
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH v2] meson: Enable SSE4.1 optimizations

2017-11-16 Thread Matt Turner
On Thu, Nov 16, 2017 at 2:46 PM, Dylan Baker  wrote:
> This patch checks for an and then enables sse4.1 optimizations if the
> host machine will be x86/x86_64.
>
> v2: - Don't compile code, it's unnecessary since we require a compiler
>   which always has SSE4.1 (Matt)
>
> Signed-off-by: Dylan Baker 
> Reviewed-by: Eric Engestrom  (v1)
> ---
>  meson.build  | 15 ++-
>  src/mesa/meson.build | 14 +++---
>  2 files changed, 25 insertions(+), 4 deletions(-)
>
> diff --git a/meson.build b/meson.build
> index 383ebb36662..2df4610a2fd 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -502,7 +502,20 @@ foreach a : ['-Wno-override-init', 
> '-Wno-initializer-overrides']
>endif
>  endforeach
>
> -# TODO: SSE41 (which is only required for core mesa)
> +if host_machine.cpu_family().startswith('x86')
> +  pre_args += '-DHAVE_SSE41'
> +  with_sse41 = true
> +  sse41_args = ['-msse4.1']
> +
> +  # GCC on x86 (not x64) with -msse* assumes a 16 byte aligned stack, but

Please s/x64/x86-64/ or s/x64/x86_64/ since you use .startswith('x86')
a few lines above (and I find x64 moniker annoying)
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH v2] meson: Enable SSE4.1 optimizations

2017-11-16 Thread Dylan Baker
This patch checks for an and then enables sse4.1 optimizations if the
host machine will be x86/x86_64.

v2: - Don't compile code, it's unnecessary since we require a compiler
  which always has SSE4.1 (Matt)

Signed-off-by: Dylan Baker 
Reviewed-by: Eric Engestrom  (v1)
---
 meson.build  | 15 ++-
 src/mesa/meson.build | 14 +++---
 2 files changed, 25 insertions(+), 4 deletions(-)

diff --git a/meson.build b/meson.build
index 383ebb36662..2df4610a2fd 100644
--- a/meson.build
+++ b/meson.build
@@ -502,7 +502,20 @@ foreach a : ['-Wno-override-init', 
'-Wno-initializer-overrides']
   endif
 endforeach
 
-# TODO: SSE41 (which is only required for core mesa)
+if host_machine.cpu_family().startswith('x86')
+  pre_args += '-DHAVE_SSE41'
+  with_sse41 = true
+  sse41_args = ['-msse4.1']
+
+  # GCC on x86 (not x64) with -msse* assumes a 16 byte aligned stack, but
+  # that's not guaranteed
+  if host_machine.cpu_family() == 'x86'
+sse41_args += '-mstackrealign'
+  endif
+else
+  with_sse41 = false
+  sse41_args = []
+endif
 
 # Check for GCC style atomics
 if cc.compiles('int main() { int n; return __atomic_load_n(, 
__ATOMIC_ACQUIRE); }',
diff --git a/src/mesa/meson.build b/src/mesa/meson.build
index b839fd02981..05a3a9ac55d 100644
--- a/src/mesa/meson.build
+++ b/src/mesa/meson.build
@@ -592,9 +592,6 @@ files_libmesa_gallium = files(
   'state_tracker/st_vdpau.h',
 )
 
-# TODO: sse41
-libmesa_sse41 = []
-
 matypes_h = []
 if with_asm_arch == 'x86' or with_asm_arch == 'x86_64'
   gen_matypes = executable(
@@ -692,6 +689,17 @@ files_libmesa_common += [
   sha1_h,
 ]
 
+if with_sse41
+  libmesa_sse41 = static_library(
+'mesa_sse41',
+files('main/streaming-load-memcpy.c', 'main/sse_minmax.c'),
+c_args : [c_vis_args, c_msvc_compat_args, sse41_args],
+include_directories : inc_common,
+  )
+else
+  libmesa_sse41 = []
+endif
+
 libmesa_classic = static_library(
   'mesa_classic',
   [files_libmesa_common, files_libmesa_classic],
-- 
2.15.0

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


Re: [Mesa-dev] [PATCH 1/4] meson: Enable SSE4.1 optimizations

2017-11-16 Thread Matt Turner
On Thu, Nov 16, 2017 at 2:19 PM, Dylan Baker  wrote:
> Quoting Matt Turner (2017-11-15 21:57:37)
>> On Wed, Nov 15, 2017 at 5:10 PM, Dylan Baker  wrote:
>> > This patch checks for an and then enables sse4.1 optimizations if the
>> > host machine will be x86/x86_64.
>>
>> There's some stack realignment stuff that probably needs to stay, but
>> depending on what gcc version we require we can just always enable SSE
>> 4.1. It's existed since GCC 4.3 (March 2008).
>
> Well, since we require 4.6 in the meson build unconditionally, I think that
> we can just set the stackalignment variable.
>
> So, we can just drop the whole compile check altogether in that case, correct?

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


Re: [Mesa-dev] [PATCH 1/4] meson: Enable SSE4.1 optimizations

2017-11-16 Thread Dylan Baker
Quoting Emil Velikov (2017-11-16 03:35:17)
> Hi Dylan,
> 
> On 16 November 2017 at 01:10, Dylan Baker  wrote:
> > This patch checks for an and then enables sse4.1 optimizations if the
> > host machine will be x86/x86_64.
> >
> Hell yeah, SSE is coming to town :-)
> 
> Will this work if the user disables SSE4.1, say via CFLAGS=-mno-sse4.1
> meson ...?
> My meson is still bit rough, so I could not quite grok ^^ by reading
> through the patch.
> 
> Thanks
> Emil

It'll explode horribly. Id didn't see any special handling of that in autotools
build though either, did I miss something?

Dylan


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


Re: [Mesa-dev] [PATCH 1/4] meson: Enable SSE4.1 optimizations

2017-11-16 Thread Dylan Baker
Quoting Matt Turner (2017-11-15 21:57:37)
> On Wed, Nov 15, 2017 at 5:10 PM, Dylan Baker  wrote:
> > This patch checks for an and then enables sse4.1 optimizations if the
> > host machine will be x86/x86_64.
> 
> There's some stack realignment stuff that probably needs to stay, but
> depending on what gcc version we require we can just always enable SSE
> 4.1. It's existed since GCC 4.3 (March 2008).

Well, since we require 4.6 in the meson build unconditionally, I think that
we can just set the stackalignment variable.

So, we can just drop the whole compile check altogether in that case, correct?

Dylan


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


Re: [Mesa-dev] [PATCH 3/4] meson: Fix TODO for missing dl_iterate_phdr function

2017-11-16 Thread Dylan Baker
Quoting Emil Velikov (2017-11-16 05:21:50)
> On 16 November 2017 at 01:11, Dylan Baker  wrote:
> > This function is required for both the Intel "Anvil" vulkan driver and
> > the i965 GL driver. Error out if either of those is enabled but this
> > function isn't found.
> >
> > Signed-off-by: Dylan Baker 
> > ---
> >  meson.build | 6 --
> >  1 file changed, 4 insertions(+), 2 deletions(-)
> >
> > diff --git a/meson.build b/meson.build
> > index 261c4753427..5ac2ebc9e5d 100644
> > --- a/meson.build
> > +++ b/meson.build
> > @@ -672,8 +672,10 @@ endif
> >
> >  if cc.has_function('dl_iterate_phdr')
> >pre_args += '-DHAVE_DL_ITERATE_PHDR'
> > -else
> > -  # TODO: this is required for vulkan
> > +elif with_intel_vk
> > +  error('Intel "Anvil" Vulkan driver requires the dl_iterate_phdr 
> > function')
> > +elif with_dri_i965 and get_option('shader-cache')
> > +  error('Intel i965 GL driver requires dl_iterate_phdr when built with 
> > shader caching.')
> >  endif
> >
> One idea for the future: factor out the else case into a helper
> function, so that it simpler to read and can be extended easily.

meson doesn't have user definable functions. On the other hand, if we dropped
the shader-cache option altoghether we could just combine this into:
 error('The Intel "Anvil" and "i965" drivers require the dl_iterate_phdr 
function')

> 
> As-is patch is:
> Reviewed-by: Emil Velikov 
> 
> Side note: can we drop the shader-cache option?
> 
> Thanks
> Emil


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


Re: [Mesa-dev] [PATCH 2/4] meson: disable x86 asm in fewer cases.

2017-11-16 Thread Dylan Baker
Quoting Eric Engestrom (2017-11-16 03:46:04)
> On Wednesday, 2017-11-15 17:11:00 -0800, Dylan Baker wrote:
> > This patch allows building asm for x86 on x86_64 platforms, when the
> > operating system is the same. Previously cross compile always turned off
> > assembly. This allows using a cross file to cross compile x86 binaries
> > on x86_64 with asm.
> > 
> > This could probably be relaxed further thanks to meson's "exe_wrapper",
> > which is way to specify an emulator or compatibility layer (wine) that
> > can run the foreign binaries on the build system. Since the meson build
> > at this point only supports building on Linux I can't test this and I
> > don't want to write/enable code that cannot even be build tested.
> > 
> > Signed-off-by: Dylan Baker 
> > ---
> >  meson.build | 17 ++---
> >  1 file changed, 10 insertions(+), 7 deletions(-)
> > 
> > diff --git a/meson.build b/meson.build
> > index 0d201c711a0..261c4753427 100644
> > --- a/meson.build
> > +++ b/meson.build
> > @@ -554,13 +554,16 @@ endif
> >  
> >  # TODO: texture-float (gallium/mesa only)
> >  
> > -# TODO: cross-compiling. I don't think this is relavent to meson
> > -
> > -# FIXME: enable asm when cross compiler
> > -# This is doable (autotools does it), but it's not of immediate concern
> > -if meson.is_cross_build() and host_machine.cpu_family().startswith('x86')
> > -  message('Cross compiling, disabling x86/x86_64 asm')
> > -  with_asm = false
> > +# Building x86 assembly code requires running x86 binaries. It is possible 
> > for
> > +# x86_64 OSes to run x86 binaries, so don't disable asm in those cases
> > +# TODO: it should be possible to use an exe_wrapper to run the binary 
> > durring
> 
> "during"
> 
> > +# the build. 
> > +if meson.is_cross_build() 
> > +  if (not (build_machine.cpu_family() == 'x86_64' and 
> > host_machine.cpu_family() == 'x86')
> > +  and build_machine.system() == host_machine.system())
> > +message('Cross compiling to x86 from non-x86, disabling asm')
> > +with_asm = false
> > +  endif
> 
> This looks off to me.
> Shouldn't the `and build_os==host_os` be `or not build_os==host_os`?
> 
> In other words, if cross-building on the same os from 64bit to 32bit,
> allow asm, and otherwise disable it?
> 
> If so, you could factor the `not` out, and it would be:
>   if not (build_os==host_os and build==64bit and host==32bit)
> with_asm = false

This is covering for a very specific case. As part of the x86 and x64 asm
process we build an executable matypes, which needs to be of the target
architecture, because it detects how big certain structs are, and returns those
values.

So this can be built only in 1 cross compiling case, x64 building x86 (since x64
can run x86 binaries), and only if the OSes are the same (unless we had
exe_wrapper, but I haven't gotten there yet).

However, I think you're right that the not should apply to both conditions, or
the second hsould be build != host. Does that seem correct?



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


Re: [Mesa-dev] [PATCH] r600: shader CF_OP_VTX also doesn't use the EOP bit.

2017-11-16 Thread Gert Wollny
Am Mittwoch, den 15.11.2017, 11:28 +1000 schrieb Dave Airlie:
> On 15 November 2017 at 04:50, Gert Wollny 
> wrote:
> > Although the EOP bit is documented for the vertex fetch clause, it
> > is not
> > properly interpreted. As a result the piglit
> >   spec/arb_tessellation_shader/execution/trivial-tess-gs_no-gs-
> > inputs creates a TESS_EVAL shader that does not have an EOP clause,
> > which might result in a GPU lockup.
> > 
> > This patch forces an additional CF_OP_NOP group like it is already
> > done for other final CF_OP groups.
> 
> Although I think this is probably a good safety thing to add, I've
> sent a patch that should make it unneeded, it would be good if you
> could test it.

Regardless o this, I wonder why with do CF_OP_VTK and CF_OP_TEX not
emit the EOP bit on evergreen? The documentation says it is supported,
and when I apply below path (changed white spaces to fit the mail
size), then I don't see any lock-ups, the sb disassembler reports the
EOP flag, I don't get valgrind errors in sb, and no piglit regressions.

best, 
Gert 

--- a/src/gallium/drivers/r600/eg_asm.c
+++ b/src/gallium/drivers/r600/eg_asm.c
@@ -71,10 +69,13 @@ int eg_bytecode_cf_build(struct r600_bytecode *bc,
struct r600_bytecode_cf *cf)
} else if (cfop->flags & CF_CLAUSE) {
 /* CF_TEX/VTX (CF_ALU already handled above) */
   bc->bytecode[id++] = S_SQ_CF_WORD0_ADDR(cf->addr >> 1);
-  bc->bytecode[id++] = S_SQ_CF_WORD1_CF_INST(opcode) |
+  bc->bytecode[id] = S_SQ_CF_WORD1_CF_INST(opcode) |
 S_SQ_CF_WORD1_BARRIER(1) |
 S_SQ_CF_WORD1_VALID_PIXEL_MODE(cf->vpm) |
 S_SQ_CF_WORD1_COUNT((cf->ndw / 4) - 1);
+     if (bc->chip_class == EVERGREEN) /* no EOP on cayman */
+bc->bytecode[id] |= 
 S_SQ_CF_ALLOC_EXPORT_WORD1_END_OF_PROGRAM(cf->end_of_program);
+id++;
} else if (cfop->flags & CF_EXP) {
 /* EXPORT instructions */
 bc->bytecode[id++] =
S_SQ_CF_ALLOC_EXPORT_WORD0_RW_GPR(cf->output.gpr) |
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH v2 17/29] mesa/main/framebuffer.h: Fix one -Wsign-compare warning in ?: construct.

2017-11-16 Thread Gert Wollny
Am Donnerstag, den 16.11.2017, 17:13 + schrieb Emil Velikov:
> On 16 November 2017 at 15:09, Gert Wollny 
> wrote:
> > Explicitely convert on value to the target type.
> > 
> > Signed-off-by: Gert Wollny 
> > Reviewed-by: Brian Paul 
> > ---
> >  src/mesa/main/framebuffer.h | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/src/mesa/main/framebuffer.h
> > b/src/mesa/main/framebuffer.h
> > index bc6e7bc31a..bffa21dcea 100644
> > --- a/src/mesa/main/framebuffer.h
> > +++ b/src/mesa/main/framebuffer.h
> > @@ -93,7 +93,7 @@ static inline GLuint
> >  _mesa_geometric_samples(const struct gl_framebuffer *buffer)
> >  {
> > return buffer->_HasAttachments ?
> > -  buffer->Visual.samples :
> > +  (GLuint)buffer->Visual.samples :
> 
> samples and sampleBuffers are as described in the ARB_multisample /
> SGIS_multisample spec.
> 
> According to the spec both of these are 'Z + Non-negative integer or
> enumerated value' Worth doing that instead?

After having a short look into it, I guess it is doable, but I'd then
prefer to drop this patch from the series and do this separately, i.e.
really track this value to make its use consistent (also with respect
to function parameters etc). 

Best, 
Gert 


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


Re: [Mesa-dev] [PATCH 1/2] mesa: Implement ARB_texture_filter_minmax

2017-11-16 Thread Ian Romanick
On 11/16/2017 11:57 AM, Ilia Mirkin wrote:
> On Thu, Nov 16, 2017 at 2:49 PM, Ian Romanick  wrote:
>> On 11/14/2017 02:54 PM, Scott D Phillips wrote:
>>> This extension provides a new texture and sampler parameter
>>> (TEXTURE_REDUCTION_MODE_ARB) which allows applications to produce
>>> a filtered texel value by computing a component-wise minimum (MIN)
>>> or maximum (MAX) of the texels that would normally be averaged.
>>> ---
>>> CTS tests KHR-GL45.texture_filter_minmax_tests.* need a little TLC to
>>> pass with this series. Details in VK-GL-CTS issue: 849
>>>
>>>  src/mesa/main/attrib.c   |  4 
>>>  src/mesa/main/extensions_table.h |  1 +
>>>  src/mesa/main/formatquery.c  | 10 ++
>>>  src/mesa/main/mtypes.h   |  2 ++
>>>  src/mesa/main/samplerobj.c   | 37 +
>>>  src/mesa/main/texobj.c   |  2 ++
>>>  src/mesa/main/texobj.h   |  2 +-
>>>  src/mesa/main/texparam.c | 33 +
>>>  8 files changed, 90 insertions(+), 1 deletion(-)
>>>
>>
>> [lots of stuff trimmed]
>>
>>> diff --git a/src/mesa/main/extensions_table.h 
>>> b/src/mesa/main/extensions_table.h
>>> index 5b66e7d30d..c51ad80742 100644
>>> --- a/src/mesa/main/extensions_table.h
>>> +++ b/src/mesa/main/extensions_table.h
>>> @@ -146,6 +146,7 @@ EXT(ARB_texture_env_combine , 
>>> ARB_texture_env_combine
>>>  EXT(ARB_texture_env_crossbar, ARB_texture_env_crossbar 
>>>   , GLL,  x ,  x ,  x , 2001)
>>>  EXT(ARB_texture_env_dot3, ARB_texture_env_dot3 
>>>   , GLL,  x ,  x ,  x , 2001)
>>>  EXT(ARB_texture_filter_anisotropic  , 
>>> ARB_texture_filter_anisotropic , GLL, GLC,  x ,  x , 2017)
>>> +EXT(ARB_texture_filter_minmax   , ARB_texture_filter_minmax
>>>   , GLL, GLC,  x ,  x , 2017)
>>
>> Is this right?  The extension says OpenGL 3.3 is required, and we don't
>> (until Marek is done) do OpenGL 3.3 compatibility profile.
> 
> FWIW I took the view that spec writers are lazy on
> EXT_polygon_offset_clamp, which had similar text. Is this a bad thing
> to do? Should we stick to the text of the specs to the letter?
> 
> There are various GL 4.2/4.3 exts which require the previous GL
> version as well but we expose them anyways.
> 
> IMHO it's reasonable to be relaxed about this, unless there are
> obvious interactions that need explicit consideration. [Perhaps that's
> the case here, although I can't think of anything.]

Yeah, usually.  This spec depends on glGetInternalformat* too... so I
guess that's either 3.3 or GL_ARB_internalformat_query?  I thought
GL_ARB_internalformat_query was always enabled, but it's not.  It does
seem unlikely that a driver would have GL_ARB_texture_filter_minmax and
not have GL_ARB_internalformat_query.

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


[Mesa-dev] [PATCH 24/28] vulkan/wsi: Move wsi_swapchain to wsi_common_private.h

2017-11-16 Thread Jason Ekstrand
The drivers no longer poke at this directly.
---
 src/vulkan/wsi/wsi_common.h | 46 +
 src/vulkan/wsi/wsi_common_private.h | 46 +
 2 files changed, 47 insertions(+), 45 deletions(-)

diff --git a/src/vulkan/wsi/wsi_common.h b/src/vulkan/wsi/wsi_common.h
index 10b4607..6755b7a 100644
--- a/src/vulkan/wsi/wsi_common.h
+++ b/src/vulkan/wsi/wsi_common.h
@@ -41,32 +41,7 @@ struct wsi_image_create_info {
 };
 
 struct wsi_device;
-
-struct wsi_swapchain {
-   const struct wsi_device *wsi;
-
-   VkDevice device;
-   VkAllocationCallbacks alloc;
-   VkFence fences[3];
-   VkPresentModeKHR present_mode;
-   uint32_t image_count;
-
-   bool use_prime_blit;
-
-   /* Command pools, one per queue family */
-   VkCommandPool *cmd_pools;
-
-   VkResult (*destroy)(struct wsi_swapchain *swapchain,
-   const VkAllocationCallbacks *pAllocator);
-   struct wsi_image *(*get_wsi_image)(struct wsi_swapchain *swapchain,
-  uint32_t image_index);
-   VkResult (*acquire_next_image)(struct wsi_swapchain *swap_chain,
-  uint64_t timeout, VkSemaphore semaphore,
-  uint32_t *image_index);
-   VkResult (*queue_present)(struct wsi_swapchain *swap_chain,
- uint32_t image_index,
- const VkPresentRegionKHR *damage);
-};
+struct wsi_swapchain;
 
 struct wsi_interface {
VkResult (*get_support)(VkIcdSurfaceBase *surface,
@@ -158,25 +133,6 @@ struct wsi_callbacks {
 };
 #undef WSI_CB
 
-#define WSI_DEFINE_NONDISP_HANDLE_CASTS(__wsi_type, __VkType)  \
-   \
-   static inline struct __wsi_type *   \
-   __wsi_type ## _from_handle(__VkType _handle)\
-   {   \
-  return (struct __wsi_type *)(uintptr_t) _handle; \
-   }   \
-   \
-   static inline __VkType  \
-   __wsi_type ## _to_handle(struct __wsi_type *_obj)   \
-   {   \
-  return (__VkType)(uintptr_t) _obj;   \
-   }
-
-#define WSI_FROM_HANDLE(__wsi_type, __name, __handle) \
-   struct __wsi_type *__name = __wsi_type ## _from_handle(__handle)
-
-WSI_DEFINE_NONDISP_HANDLE_CASTS(wsi_swapchain, VkSwapchainKHR)
-
 #define ICD_DEFINE_NONDISP_HANDLE_CASTS(__VkIcdType, __VkType) \
\
static inline __VkIcdType * \
diff --git a/src/vulkan/wsi/wsi_common_private.h 
b/src/vulkan/wsi/wsi_common_private.h
index 28abf6c..3fa68f0 100644
--- a/src/vulkan/wsi/wsi_common_private.h
+++ b/src/vulkan/wsi/wsi_common_private.h
@@ -41,6 +41,32 @@ struct wsi_image {
int fd;
 };
 
+struct wsi_swapchain {
+   const struct wsi_device *wsi;
+
+   VkDevice device;
+   VkAllocationCallbacks alloc;
+   VkFence fences[3];
+   VkPresentModeKHR present_mode;
+   uint32_t image_count;
+
+   bool use_prime_blit;
+
+   /* Command pools, one per queue family */
+   VkCommandPool *cmd_pools;
+
+   VkResult (*destroy)(struct wsi_swapchain *swapchain,
+   const VkAllocationCallbacks *pAllocator);
+   struct wsi_image *(*get_wsi_image)(struct wsi_swapchain *swapchain,
+  uint32_t image_index);
+   VkResult (*acquire_next_image)(struct wsi_swapchain *swap_chain,
+  uint64_t timeout, VkSemaphore semaphore,
+  uint32_t *image_index);
+   VkResult (*queue_present)(struct wsi_swapchain *swap_chain,
+ uint32_t image_index,
+ const VkPresentRegionKHR *damage);
+};
+
 VkResult
 wsi_swapchain_init(const struct wsi_device *wsi,
struct wsi_swapchain *chain,
@@ -64,4 +90,24 @@ void
 wsi_destroy_image(const struct wsi_swapchain *chain,
   struct wsi_image *image);
 
+
+#define WSI_DEFINE_NONDISP_HANDLE_CASTS(__wsi_type, __VkType)  \
+   \
+   static inline struct __wsi_type *   \
+   __wsi_type ## _from_handle(__VkType _handle)\
+   {   \
+  return (struct __wsi_type *)(uintptr_t) _handle; \
+   }   \
+

[Mesa-dev] [PATCH 26/28] vulkan/wsi: Add wrappers for all of the surface queries

2017-11-16 Thread Jason Ekstrand
This lets us move wsi_interface to wsi_common_private.h
---
 src/amd/vulkan/radv_wsi.c   | 41 ++--
 src/intel/vulkan/anv_wsi.c  | 51 +++-
 src/vulkan/wsi/wsi_common.c | 77 +
 src/vulkan/wsi/wsi_common.h | 72 +-
 src/vulkan/wsi/wsi_common_private.h | 34 
 5 files changed, 192 insertions(+), 83 deletions(-)

diff --git a/src/amd/vulkan/radv_wsi.c b/src/amd/vulkan/radv_wsi.c
index 1ddc6c9..22ace6f 100644
--- a/src/amd/vulkan/radv_wsi.c
+++ b/src/amd/vulkan/radv_wsi.c
@@ -105,56 +105,57 @@ void radv_DestroySurfaceKHR(
 VkResult radv_GetPhysicalDeviceSurfaceSupportKHR(
VkPhysicalDevicephysicalDevice,
uint32_tqueueFamilyIndex,
-   VkSurfaceKHR_surface,
+   VkSurfaceKHRsurface,
VkBool32*   pSupported)
 {
RADV_FROM_HANDLE(radv_physical_device, device, physicalDevice);
-   ICD_FROM_HANDLE(VkIcdSurfaceBase, surface, _surface);
-   struct wsi_interface *iface = device->wsi_device.wsi[surface->platform];
 
-   return iface->get_support(surface, >wsi_device,
- >instance->alloc,
- queueFamilyIndex, device->local_fd, 
pSupported);
+   return wsi_common_get_surface_support(>wsi_device,
+ device->local_fd,
+ queueFamilyIndex,
+ surface,
+ >instance->alloc,
+ pSupported);
 }
 
 VkResult radv_GetPhysicalDeviceSurfaceCapabilitiesKHR(
VkPhysicalDevicephysicalDevice,
-   VkSurfaceKHR_surface,
+   VkSurfaceKHRsurface,
VkSurfaceCapabilitiesKHR*   pSurfaceCapabilities)
 {
RADV_FROM_HANDLE(radv_physical_device, device, physicalDevice);
-   ICD_FROM_HANDLE(VkIcdSurfaceBase, surface, _surface);
-   struct wsi_interface *iface = device->wsi_device.wsi[surface->platform];
 
-   return iface->get_capabilities(surface, pSurfaceCapabilities);
+   return wsi_common_get_surface_capabilities(>wsi_device,
+  surface,
+  pSurfaceCapabilities);
 }
 
 VkResult radv_GetPhysicalDeviceSurfaceFormatsKHR(
VkPhysicalDevicephysicalDevice,
-   VkSurfaceKHR_surface,
+   VkSurfaceKHRsurface,
uint32_t*   pSurfaceFormatCount,
VkSurfaceFormatKHR* pSurfaceFormats)
 {
RADV_FROM_HANDLE(radv_physical_device, device, physicalDevice);
-   ICD_FROM_HANDLE(VkIcdSurfaceBase, surface, _surface);
-   struct wsi_interface *iface = device->wsi_device.wsi[surface->platform];
 
-   return iface->get_formats(surface, >wsi_device, 
pSurfaceFormatCount,
- pSurfaceFormats);
+   return wsi_common_get_surface_formats(>wsi_device,
+ surface,
+ pSurfaceFormatCount,
+ pSurfaceFormats);
 }
 
 VkResult radv_GetPhysicalDeviceSurfacePresentModesKHR(
VkPhysicalDevicephysicalDevice,
-   VkSurfaceKHR_surface,
+   VkSurfaceKHRsurface,
uint32_t*   pPresentModeCount,
VkPresentModeKHR*   pPresentModes)
 {
RADV_FROM_HANDLE(radv_physical_device, device, physicalDevice);
-   ICD_FROM_HANDLE(VkIcdSurfaceBase, surface, _surface);
-   struct wsi_interface *iface = device->wsi_device.wsi[surface->platform];
 
-   return iface->get_present_modes(surface, pPresentModeCount,
-   pPresentModes);
+   return wsi_common_get_surface_present_modes(>wsi_device,
+   surface,
+   pPresentModeCount,
+   pPresentModes);
 }
 
 VkResult radv_CreateSwapchainKHR(
diff --git a/src/intel/vulkan/anv_wsi.c b/src/intel/vulkan/anv_wsi.c
index 5c09d3b..6ff8ebd 100644
--- a/src/intel/vulkan/anv_wsi.c
+++ b/src/intel/vulkan/anv_wsi.c
@@ -107,28 +107,29 @@ void anv_DestroySurfaceKHR(
 VkResult anv_GetPhysicalDeviceSurfaceSupportKHR(
 VkPhysicalDevicephysicalDevice,
 

[Mesa-dev] [PATCH 25/28] vulkan/wsi: Drop the can_handle_different_gpu parameter from get_support

2017-11-16 Thread Jason Ekstrand
Both anv and radv can handle prime now.
---
 src/amd/vulkan/radv_wsi.c   | 2 +-
 src/intel/vulkan/anv_wsi.c  | 2 +-
 src/vulkan/wsi/wsi_common.h | 1 -
 src/vulkan/wsi/wsi_common_wayland.c | 1 -
 src/vulkan/wsi/wsi_common_x11.c | 5 -
 5 files changed, 2 insertions(+), 9 deletions(-)

diff --git a/src/amd/vulkan/radv_wsi.c b/src/amd/vulkan/radv_wsi.c
index 9e732e8..1ddc6c9 100644
--- a/src/amd/vulkan/radv_wsi.c
+++ b/src/amd/vulkan/radv_wsi.c
@@ -114,7 +114,7 @@ VkResult radv_GetPhysicalDeviceSurfaceSupportKHR(
 
return iface->get_support(surface, >wsi_device,
  >instance->alloc,
- queueFamilyIndex, device->local_fd, true, 
pSupported);
+ queueFamilyIndex, device->local_fd, 
pSupported);
 }
 
 VkResult radv_GetPhysicalDeviceSurfaceCapabilitiesKHR(
diff --git a/src/intel/vulkan/anv_wsi.c b/src/intel/vulkan/anv_wsi.c
index 6f5aaf6..5c09d3b 100644
--- a/src/intel/vulkan/anv_wsi.c
+++ b/src/intel/vulkan/anv_wsi.c
@@ -116,7 +116,7 @@ VkResult anv_GetPhysicalDeviceSurfaceSupportKHR(
 
return iface->get_support(surface, >wsi_device,
  >instance->alloc,
- queueFamilyIndex, device->local_fd, true, 
pSupported);
+ queueFamilyIndex, device->local_fd, pSupported);
 }
 
 VkResult anv_GetPhysicalDeviceSurfaceCapabilitiesKHR(
diff --git a/src/vulkan/wsi/wsi_common.h b/src/vulkan/wsi/wsi_common.h
index 6755b7a..f814292 100644
--- a/src/vulkan/wsi/wsi_common.h
+++ b/src/vulkan/wsi/wsi_common.h
@@ -49,7 +49,6 @@ struct wsi_interface {
const VkAllocationCallbacks *alloc,
uint32_t queueFamilyIndex,
int local_fd,
-   bool can_handle_different_gpu,
VkBool32* pSupported);
VkResult (*get_capabilities)(VkIcdSurfaceBase *surface,
 VkSurfaceCapabilitiesKHR* 
pSurfaceCapabilities);
diff --git a/src/vulkan/wsi/wsi_common_wayland.c 
b/src/vulkan/wsi/wsi_common_wayland.c
index fed2e8f..3e2ff49 100644
--- a/src/vulkan/wsi/wsi_common_wayland.c
+++ b/src/vulkan/wsi/wsi_common_wayland.c
@@ -400,7 +400,6 @@ wsi_wl_surface_get_support(VkIcdSurfaceBase *surface,
const VkAllocationCallbacks *alloc,
uint32_t queueFamilyIndex,
int local_fd,
-   bool can_handle_different_gpu,
VkBool32* pSupported)
 {
*pSupported = true;
diff --git a/src/vulkan/wsi/wsi_common_x11.c b/src/vulkan/wsi/wsi_common_x11.c
index 04ce810..c29e0a2 100644
--- a/src/vulkan/wsi/wsi_common_x11.c
+++ b/src/vulkan/wsi/wsi_common_x11.c
@@ -405,7 +405,6 @@ x11_surface_get_support(VkIcdSurfaceBase *icd_surface,
 const VkAllocationCallbacks *alloc,
 uint32_t queueFamilyIndex,
 int local_fd,
-bool can_handle_different_gpu,
 VkBool32* pSupported)
 {
xcb_connection_t *conn = x11_surface_get_connection(icd_surface);
@@ -421,10 +420,6 @@ x11_surface_get_support(VkIcdSurfaceBase *icd_surface,
   return VK_SUCCESS;
}
 
-   if (!can_handle_different_gpu)
-  if (!wsi_x11_check_dri3_compatible(conn, local_fd))
- return false;
-
unsigned visual_depth;
if (!get_visualtype_for_window(conn, window, _depth)) {
   *pSupported = false;
-- 
2.5.0.400.gff86faf

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


[Mesa-dev] [PATCH 18/28] anv/wsi: Use the common QueuePresent code

2017-11-16 Thread Jason Ekstrand
---
 src/intel/vulkan/anv_wsi.c | 63 +-
 1 file changed, 6 insertions(+), 57 deletions(-)

diff --git a/src/intel/vulkan/anv_wsi.c b/src/intel/vulkan/anv_wsi.c
index b654db9..4d9f7df 100644
--- a/src/intel/vulkan/anv_wsi.c
+++ b/src/intel/vulkan/anv_wsi.c
@@ -287,62 +287,11 @@ VkResult anv_QueuePresentKHR(
 const VkPresentInfoKHR*  pPresentInfo)
 {
ANV_FROM_HANDLE(anv_queue, queue, _queue);
-   VkResult result = VK_SUCCESS;
-
-   const VkPresentRegionsKHR *regions =
-  vk_find_struct_const(pPresentInfo->pNext, PRESENT_REGIONS_KHR);
-
-   for (uint32_t i = 0; i < pPresentInfo->swapchainCount; i++) {
-  ANV_FROM_HANDLE(wsi_swapchain, swapchain, pPresentInfo->pSwapchains[i]);
-  VkResult item_result;
-
-  const VkPresentRegionKHR *region = NULL;
-  if (regions && regions->pRegions)
- region = >pRegions[i];
-
-  assert(anv_device_from_handle(swapchain->device) == queue->device);
-
-  if (swapchain->fences[0] == VK_NULL_HANDLE) {
- item_result = anv_CreateFence(anv_device_to_handle(queue->device),
-&(VkFenceCreateInfo) {
-   .sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO,
-   .flags = 0,
-}, >alloc, >fences[0]);
- if (pPresentInfo->pResults != NULL)
-pPresentInfo->pResults[i] = item_result;
- result = result == VK_SUCCESS ? item_result : result;
- if (item_result != VK_SUCCESS)
-continue;
-  } else {
- anv_ResetFences(anv_device_to_handle(queue->device),
- 1, >fences[0]);
-  }
-
-  anv_QueueSubmit(_queue, 0, NULL, swapchain->fences[0]);
-
-  item_result = swapchain->queue_present(swapchain,
- _queue,
- pPresentInfo->waitSemaphoreCount,
- pPresentInfo->pWaitSemaphores,
- pPresentInfo->pImageIndices[i],
- region);
-  /* TODO: What if one of them returns OUT_OF_DATE? */
-  if (pPresentInfo->pResults != NULL)
- pPresentInfo->pResults[i] = item_result;
-  result = result == VK_SUCCESS ? item_result : result;
-  if (item_result != VK_SUCCESS)
-continue;
-
-  VkFence last = swapchain->fences[2];
-  swapchain->fences[2] = swapchain->fences[1];
-  swapchain->fences[1] = swapchain->fences[0];
-  swapchain->fences[0] = last;
-
-  if (last != VK_NULL_HANDLE) {
- anv_WaitForFences(anv_device_to_handle(queue->device),
-   1, , true, 1);
-  }
-   }
+   struct anv_physical_device *pdevice =
+  >device->instance->physicalDevice;
 
-   return VK_SUCCESS;
+   return wsi_common_queue_present(>wsi_device,
+   anv_device_to_handle(queue->device),
+   _queue, 0,
+   pPresentInfo);
 }
-- 
2.5.0.400.gff86faf

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


[Mesa-dev] [PATCH 28/28] vulkan/wsi: Initialize individual WSI interfaces in wsi_device_init

2017-11-16 Thread Jason Ekstrand
Now that we have anv_device_init/finish functions, there's no reason to
have the individual driver do any more work than that.
---
 src/amd/vulkan/radv_wsi.c   | 36 ++--
 src/intel/vulkan/anv_wsi.c  | 36 ++--
 src/vulkan/wsi/wsi_common.c | 37 +++--
 src/vulkan/wsi/wsi_common.h | 19 +++
 src/vulkan/wsi/wsi_common_private.h | 10 ++
 5 files changed, 64 insertions(+), 74 deletions(-)

diff --git a/src/amd/vulkan/radv_wsi.c b/src/amd/vulkan/radv_wsi.c
index aa06944..cb61eb6 100644
--- a/src/amd/vulkan/radv_wsi.c
+++ b/src/amd/vulkan/radv_wsi.c
@@ -38,41 +38,17 @@ radv_wsi_proc_addr(VkPhysicalDevice physicalDevice, const 
char *pName)
 VkResult
 radv_init_wsi(struct radv_physical_device *physical_device)
 {
-   VkResult result;
-
-   wsi_device_init(_device->wsi_device,
-   radv_physical_device_to_handle(physical_device),
-   radv_wsi_proc_addr);
-
-#ifdef VK_USE_PLATFORM_XCB_KHR
-   result = wsi_x11_init_wsi(_device->wsi_device, 
_device->instance->alloc);
-   if (result != VK_SUCCESS)
-   return result;
-#endif
-
-#ifdef VK_USE_PLATFORM_WAYLAND_KHR
-   result = wsi_wl_init_wsi(_device->wsi_device, 
_device->instance->alloc,
-
radv_physical_device_to_handle(physical_device));
-   if (result != VK_SUCCESS) {
-#ifdef VK_USE_PLATFORM_XCB_KHR
-   wsi_x11_finish_wsi(_device->wsi_device, 
_device->instance->alloc);
-#endif
-   return result;
-   }
-#endif
-
-   return VK_SUCCESS;
+   return wsi_device_init(_device->wsi_device,
+  radv_physical_device_to_handle(physical_device),
+  radv_wsi_proc_addr,
+  _device->instance->alloc);
 }
 
 void
 radv_finish_wsi(struct radv_physical_device *physical_device)
 {
-#ifdef VK_USE_PLATFORM_WAYLAND_KHR
-   wsi_wl_finish_wsi(_device->wsi_device, 
_device->instance->alloc);
-#endif
-#ifdef VK_USE_PLATFORM_XCB_KHR
-   wsi_x11_finish_wsi(_device->wsi_device, 
_device->instance->alloc);
-#endif
+   wsi_device_finish(_device->wsi_device,
+ _device->instance->alloc);
 }
 
 void radv_DestroySurfaceKHR(
diff --git a/src/intel/vulkan/anv_wsi.c b/src/intel/vulkan/anv_wsi.c
index add983f..6082c3d 100644
--- a/src/intel/vulkan/anv_wsi.c
+++ b/src/intel/vulkan/anv_wsi.c
@@ -36,41 +36,17 @@ anv_wsi_proc_addr(VkPhysicalDevice physicalDevice, const 
char *pName)
 VkResult
 anv_init_wsi(struct anv_physical_device *physical_device)
 {
-   VkResult result;
-
-   wsi_device_init(_device->wsi_device,
-   anv_physical_device_to_handle(physical_device),
-   anv_wsi_proc_addr);
-
-#ifdef VK_USE_PLATFORM_XCB_KHR
-   result = wsi_x11_init_wsi(_device->wsi_device, 
_device->instance->alloc);
-   if (result != VK_SUCCESS)
-  return result;
-#endif
-
-#ifdef VK_USE_PLATFORM_WAYLAND_KHR
-   result = wsi_wl_init_wsi(_device->wsi_device, 
_device->instance->alloc,
-anv_physical_device_to_handle(physical_device));
-   if (result != VK_SUCCESS) {
-#ifdef VK_USE_PLATFORM_XCB_KHR
-  wsi_x11_finish_wsi(_device->wsi_device, 
_device->instance->alloc);
-#endif
-  return result;
-   }
-#endif
-
-   return VK_SUCCESS;
+   return wsi_device_init(_device->wsi_device,
+  anv_physical_device_to_handle(physical_device),
+  anv_wsi_proc_addr,
+  _device->instance->alloc);
 }
 
 void
 anv_finish_wsi(struct anv_physical_device *physical_device)
 {
-#ifdef VK_USE_PLATFORM_WAYLAND_KHR
-   wsi_wl_finish_wsi(_device->wsi_device, 
_device->instance->alloc);
-#endif
-#ifdef VK_USE_PLATFORM_XCB_KHR
-   wsi_x11_finish_wsi(_device->wsi_device, 
_device->instance->alloc);
-#endif
+   wsi_device_finish(_device->wsi_device,
+ _device->instance->alloc);
 }
 
 void anv_DestroySurfaceKHR(
diff --git a/src/vulkan/wsi/wsi_common.c b/src/vulkan/wsi/wsi_common.c
index cd98e95..595d76e 100644
--- a/src/vulkan/wsi/wsi_common.c
+++ b/src/vulkan/wsi/wsi_common.c
@@ -25,11 +25,14 @@
 #include "util/macros.h"
 #include "vk_util.h"
 
-void
+VkResult
 wsi_device_init(struct wsi_device *wsi,
 VkPhysicalDevice pdevice,
-WSI_FN_GetPhysicalDeviceProcAddr proc_addr)
+WSI_FN_GetPhysicalDeviceProcAddr proc_addr,
+const VkAllocationCallbacks *alloc)
 {
+   VkResult result;
+
memset(wsi, 0, sizeof(*wsi));
 
 #define WSI_GET_CB(func) \
@@ -69,6 +72,36 @@ wsi_device_init(struct wsi_device *wsi,
WSI_GET_CB(QueueSubmit);
WSI_GET_CB(WaitForFences);
 #undef WSI_GET_CB
+
+#ifdef VK_USE_PLATFORM_XCB_KHR
+   result = wsi_x11_init_wsi(wsi, alloc);
+   if (result != VK_SUCCESS)
+  return result;
+#endif
+
+#ifdef 

[Mesa-dev] [PATCH 21/28] vulkan/wsi: Move prime blitting into queue_present

2017-11-16 Thread Jason Ekstrand
This lets us save a QueueSubmit and it also makes prime a lot less
X11-specific.  Also, it means we can only wait on the semaphores once
instead of on every blit.
---
 src/vulkan/wsi/wsi_common.c | 41 +
 src/vulkan/wsi/wsi_common.h |  5 ++---
 src/vulkan/wsi/wsi_common_private.h |  7 ---
 src/vulkan/wsi/wsi_common_wayland.c |  3 ---
 src/vulkan/wsi/wsi_common_x11.c | 25 +++---
 5 files changed, 19 insertions(+), 62 deletions(-)

diff --git a/src/vulkan/wsi/wsi_common.c b/src/vulkan/wsi/wsi_common.c
index 35e49be..3d4488e 100644
--- a/src/vulkan/wsi/wsi_common.c
+++ b/src/vulkan/wsi/wsi_common.c
@@ -84,6 +84,7 @@ wsi_swapchain_init(const struct wsi_device *wsi,
chain->wsi = wsi;
chain->device = device;
chain->alloc = *pAllocator;
+   chain->use_prime_blit = false;
 
chain->cmd_pools =
   vk_zalloc(pAllocator, sizeof(VkCommandPool) * wsi->queue_family_count, 8,
@@ -475,30 +476,6 @@ wsi_destroy_image(const struct wsi_swapchain *chain,
 }
 
 VkResult
-wsi_prime_image_blit_to_linear(const struct wsi_swapchain *chain,
-   struct wsi_image *image,
-   VkQueue queue,
-   uint32_t waitSemaphoreCount,
-   const VkSemaphore *pWaitSemaphores)
-{
-   uint32_t queue_family = chain->wsi->queue_get_family_index(queue);
-
-   VkPipelineStageFlags stage_flags = VK_PIPELINE_STAGE_ALL_GRAPHICS_BIT;
-   const VkSubmitInfo submit_info = {
-  .sType = VK_STRUCTURE_TYPE_SUBMIT_INFO,
-  .pNext = NULL,
-  .waitSemaphoreCount = waitSemaphoreCount,
-  .pWaitSemaphores = pWaitSemaphores,
-  .pWaitDstStageMask = _flags,
-  .commandBufferCount = 1,
-  .pCommandBuffers = >prime.blit_cmd_buffers[queue_family],
-  .signalSemaphoreCount = 0,
-  .pSignalSemaphores = NULL,
-   };
-   return chain->wsi->QueueSubmit(queue, 1, _info, VK_NULL_HANDLE);
-}
-
-VkResult
 wsi_common_get_images(VkSwapchainKHR _swapchain,
   uint32_t *pSwapchainImageCount,
   VkImage *pSwapchainImages)
@@ -550,6 +527,7 @@ wsi_common_queue_present(const struct wsi_device *wsi,
  .sType = VK_STRUCTURE_TYPE_SUBMIT_INFO,
  .pNext = NULL,
   };
+
   VkPipelineStageFlags *stage_flags = NULL;
   if (i == 0) {
  /* We only need/want to wait on semaphores once.  After that, we're
@@ -573,6 +551,18 @@ wsi_common_queue_present(const struct wsi_device *wsi,
 
  submit_info.pWaitDstStageMask = stage_flags;
   }
+
+  if (swapchain->use_prime_blit) {
+ /* If we are using prime blits, we need to perform the blit now.  The
+  * command buffer is attached to the image.
+  */
+ struct wsi_image *image =
+swapchain->get_wsi_image(swapchain, 
pPresentInfo->pImageIndices[i]);
+ submit_info.commandBufferCount = 1;
+ submit_info.pCommandBuffers =
+>prime.blit_cmd_buffers[queue_family_index];
+  }
+
   result = wsi->QueueSubmit(queue, 1, _info, swapchain->fences[0]);
   vk_free(>alloc, stage_flags);
   if (result != VK_SUCCESS)
@@ -583,9 +573,6 @@ wsi_common_queue_present(const struct wsi_device *wsi,
  region = >pRegions[i];
 
   result = swapchain->queue_present(swapchain,
-queue,
-pPresentInfo->waitSemaphoreCount,
-pPresentInfo->pWaitSemaphores,
 pPresentInfo->pImageIndices[i],
 region);
   if (result != VK_SUCCESS)
diff --git a/src/vulkan/wsi/wsi_common.h b/src/vulkan/wsi/wsi_common.h
index ffd79c7..430f210 100644
--- a/src/vulkan/wsi/wsi_common.h
+++ b/src/vulkan/wsi/wsi_common.h
@@ -51,6 +51,8 @@ struct wsi_swapchain {
VkPresentModeKHR present_mode;
uint32_t image_count;
 
+   bool use_prime_blit;
+
/* Command pools, one per queue family */
VkCommandPool *cmd_pools;
 
@@ -62,9 +64,6 @@ struct wsi_swapchain {
   uint64_t timeout, VkSemaphore semaphore,
   uint32_t *image_index);
VkResult (*queue_present)(struct wsi_swapchain *swap_chain,
- VkQueue queue,
- uint32_t waitSemaphoreCount,
- const VkSemaphore *pWaitSemaphores,
  uint32_t image_index,
  const VkPresentRegionKHR *damage);
 };
diff --git a/src/vulkan/wsi/wsi_common_private.h 
b/src/vulkan/wsi/wsi_common_private.h
index ff8ca2a..28abf6c 100644
--- a/src/vulkan/wsi/wsi_common_private.h
+++ b/src/vulkan/wsi/wsi_common_private.h
@@ -64,11 +64,4 @@ void
 wsi_destroy_image(const struct wsi_swapchain *chain,
   struct wsi_image *image);
 
-VkResult

[Mesa-dev] [PATCH 22/28] vulkan/wsi: move swapchain create/destroy to common code

2017-11-16 Thread Jason Ekstrand
From: Dave Airlie 

v2 (Jason Ekstrand):
 - Rebase
 - Alter the names of the helpers to better match the vulkan entrypoints
 - Use the helpers in anv
---
 src/amd/vulkan/radv_wsi.c   | 42 --
 src/intel/vulkan/anv_wsi.c  | 35 +--
 src/vulkan/wsi/wsi_common.c | 38 ++
 src/vulkan/wsi/wsi_common.h | 12 
 4 files changed, 63 insertions(+), 64 deletions(-)

diff --git a/src/amd/vulkan/radv_wsi.c b/src/amd/vulkan/radv_wsi.c
index ed964c5..7791162 100644
--- a/src/amd/vulkan/radv_wsi.c
+++ b/src/amd/vulkan/radv_wsi.c
@@ -164,60 +164,34 @@ VkResult radv_CreateSwapchainKHR(
VkSwapchainKHR*  pSwapchain)
 {
RADV_FROM_HANDLE(radv_device, device, _device);
-   ICD_FROM_HANDLE(VkIcdSurfaceBase, surface, pCreateInfo->surface);
-   struct wsi_interface *iface =
-   device->physical_device->wsi_device.wsi[surface->platform];
-   struct wsi_swapchain *swapchain;
const VkAllocationCallbacks *alloc;
if (pAllocator)
alloc = pAllocator;
else
alloc = >alloc;
-   VkResult result = iface->create_swapchain(surface, _device,
- 
>physical_device->wsi_device,
- 
device->physical_device->local_fd,
- pCreateInfo,
- alloc,
- );
-   if (result != VK_SUCCESS)
-   return result;
-
-   if (pAllocator)
-   swapchain->alloc = *pAllocator;
-   else
-   swapchain->alloc = device->alloc;
-
-   for (unsigned i = 0; i < ARRAY_SIZE(swapchain->fences); i++)
-   swapchain->fences[i] = VK_NULL_HANDLE;
-
-   *pSwapchain = wsi_swapchain_to_handle(swapchain);
 
-   return VK_SUCCESS;
+   return wsi_common_create_swapchain(>physical_device->wsi_device,
+  radv_device_to_handle(device),
+  device->physical_device->local_fd,
+  pCreateInfo,
+  alloc,
+  pSwapchain);
 }
 
 void radv_DestroySwapchainKHR(
VkDevice _device,
-   VkSwapchainKHR   _swapchain,
+   VkSwapchainKHR   swapchain,
const VkAllocationCallbacks* pAllocator)
 {
RADV_FROM_HANDLE(radv_device, device, _device);
-   RADV_FROM_HANDLE(wsi_swapchain, swapchain, _swapchain);
const VkAllocationCallbacks *alloc;
 
-   if (!_swapchain)
-   return;
-
if (pAllocator)
alloc = pAllocator;
else
alloc = >alloc;
 
-   for (unsigned i = 0; i < ARRAY_SIZE(swapchain->fences); i++) {
-   if (swapchain->fences[i] != VK_NULL_HANDLE)
-   radv_DestroyFence(_device, swapchain->fences[i], 
pAllocator);
-   }
-
-   swapchain->destroy(swapchain, alloc);
+   wsi_common_destroy_swapchain(_device, swapchain, alloc);
 }
 
 VkResult radv_GetSwapchainImagesKHR(
diff --git a/src/intel/vulkan/anv_wsi.c b/src/intel/vulkan/anv_wsi.c
index eed378c..62368a1 100644
--- a/src/intel/vulkan/anv_wsi.c
+++ b/src/intel/vulkan/anv_wsi.c
@@ -193,57 +193,32 @@ VkResult anv_CreateSwapchainKHR(
 VkSwapchainKHR*  pSwapchain)
 {
ANV_FROM_HANDLE(anv_device, device, _device);
-   ICD_FROM_HANDLE(VkIcdSurfaceBase, surface, pCreateInfo->surface);
-   struct wsi_interface *iface =
-  device->instance->physicalDevice.wsi_device.wsi[surface->platform];
-   struct wsi_swapchain *swapchain;
+   struct wsi_device *wsi_device = 
>instance->physicalDevice.wsi_device;
const VkAllocationCallbacks *alloc;
 
if (pAllocator)
  alloc = pAllocator;
else
  alloc = >alloc;
-   VkResult result = iface->create_swapchain(surface, _device,
- 
>instance->physicalDevice.wsi_device,
- 
device->instance->physicalDevice.local_fd,
- pCreateInfo,
- alloc,
- );
-   if (result != VK_SUCCESS)
-  return result;
-
-   swapchain->alloc = *alloc;
 
-   for (unsigned i = 0; i < ARRAY_SIZE(swapchain->fences); i++)
-  swapchain->fences[i] = VK_NULL_HANDLE;
-
-   *pSwapchain = wsi_swapchain_to_handle(swapchain);
-
-   return VK_SUCCESS;
+   return wsi_common_create_swapchain(wsi_device, _device, device->fd,
+  pCreateInfo, alloc, pSwapchain);
 

[Mesa-dev] [PATCH 27/28] vulkan/wsi: Drop some unneeded cruft from the API

2017-11-16 Thread Jason Ekstrand
This drops the unneeded callbacks struct as well as the queue_get_family
callback we were using before we'd pulled QueuePresent inside.
---
 src/amd/vulkan/radv_wsi.c   | 18 +-
 src/intel/vulkan/anv_wsi.c  | 19 +--
 src/vulkan/wsi/wsi_common.c |  1 +
 src/vulkan/wsi/wsi_common.h | 17 ++---
 src/vulkan/wsi/wsi_common_wayland.c | 11 +--
 5 files changed, 10 insertions(+), 56 deletions(-)

diff --git a/src/amd/vulkan/radv_wsi.c b/src/amd/vulkan/radv_wsi.c
index 22ace6f..aa06944 100644
--- a/src/amd/vulkan/radv_wsi.c
+++ b/src/amd/vulkan/radv_wsi.c
@@ -29,24 +29,12 @@
 #include "vk_util.h"
 #include "util/macros.h"
 
-#define WSI_CB(x) .x = radv_##x
-MAYBE_UNUSED static const struct wsi_callbacks wsi_cbs = {
-   WSI_CB(GetPhysicalDeviceFormatProperties),
-};
-
 static PFN_vkVoidFunction
 radv_wsi_proc_addr(VkPhysicalDevice physicalDevice, const char *pName)
 {
return radv_lookup_entrypoint(pName);
 }
 
-static uint32_t
-anv_wsi_queue_get_family_index(VkQueue _queue)
-{
-   RADV_FROM_HANDLE(radv_queue, queue, _queue);
-   return queue->queue_family_index;
-}
-
 VkResult
 radv_init_wsi(struct radv_physical_device *physical_device)
 {
@@ -56,9 +44,6 @@ radv_init_wsi(struct radv_physical_device *physical_device)
radv_physical_device_to_handle(physical_device),
radv_wsi_proc_addr);
 
-   physical_device->wsi_device.queue_get_family_index =
-   anv_wsi_queue_get_family_index;
-
 #ifdef VK_USE_PLATFORM_XCB_KHR
result = wsi_x11_init_wsi(_device->wsi_device, 
_device->instance->alloc);
if (result != VK_SUCCESS)
@@ -67,8 +52,7 @@ radv_init_wsi(struct radv_physical_device *physical_device)
 
 #ifdef VK_USE_PLATFORM_WAYLAND_KHR
result = wsi_wl_init_wsi(_device->wsi_device, 
_device->instance->alloc,
-
radv_physical_device_to_handle(physical_device),
-_cbs);
+
radv_physical_device_to_handle(physical_device));
if (result != VK_SUCCESS) {
 #ifdef VK_USE_PLATFORM_XCB_KHR
wsi_x11_finish_wsi(_device->wsi_device, 
_device->instance->alloc);
diff --git a/src/intel/vulkan/anv_wsi.c b/src/intel/vulkan/anv_wsi.c
index 6ff8ebd..add983f 100644
--- a/src/intel/vulkan/anv_wsi.c
+++ b/src/intel/vulkan/anv_wsi.c
@@ -26,13 +26,6 @@
 #include "vk_format_info.h"
 #include "vk_util.h"
 
-#ifdef VK_USE_PLATFORM_WAYLAND_KHR
-#define WSI_CB(x) .x = anv_##x
-static const struct wsi_callbacks wsi_cbs = {
-   WSI_CB(GetPhysicalDeviceFormatProperties),
-};
-#endif
-
 static PFN_vkVoidFunction
 anv_wsi_proc_addr(VkPhysicalDevice physicalDevice, const char *pName)
 {
@@ -40,12 +33,6 @@ anv_wsi_proc_addr(VkPhysicalDevice physicalDevice, const 
char *pName)
return anv_lookup_entrypoint(_device->info, pName);
 }
 
-static uint32_t
-anv_wsi_queue_get_family_index(VkQueue queue)
-{
-   return 0;
-}
-
 VkResult
 anv_init_wsi(struct anv_physical_device *physical_device)
 {
@@ -55,9 +42,6 @@ anv_init_wsi(struct anv_physical_device *physical_device)
anv_physical_device_to_handle(physical_device),
anv_wsi_proc_addr);
 
-   physical_device->wsi_device.queue_get_family_index =
-  anv_wsi_queue_get_family_index;
-
 #ifdef VK_USE_PLATFORM_XCB_KHR
result = wsi_x11_init_wsi(_device->wsi_device, 
_device->instance->alloc);
if (result != VK_SUCCESS)
@@ -66,8 +50,7 @@ anv_init_wsi(struct anv_physical_device *physical_device)
 
 #ifdef VK_USE_PLATFORM_WAYLAND_KHR
result = wsi_wl_init_wsi(_device->wsi_device, 
_device->instance->alloc,
-anv_physical_device_to_handle(physical_device),
-_cbs);
+anv_physical_device_to_handle(physical_device));
if (result != VK_SUCCESS) {
 #ifdef VK_USE_PLATFORM_XCB_KHR
   wsi_x11_finish_wsi(_device->wsi_device, 
_device->instance->alloc);
diff --git a/src/vulkan/wsi/wsi_common.c b/src/vulkan/wsi/wsi_common.c
index f6a02df..cd98e95 100644
--- a/src/vulkan/wsi/wsi_common.c
+++ b/src/vulkan/wsi/wsi_common.c
@@ -64,6 +64,7 @@ wsi_device_init(struct wsi_device *wsi,
WSI_GET_CB(GetImageMemoryRequirements);
WSI_GET_CB(GetImageSubresourceLayout);
WSI_GET_CB(GetMemoryFdKHR);
+   WSI_GET_CB(GetPhysicalDeviceFormatProperties);
WSI_GET_CB(ResetFences);
WSI_GET_CB(QueueSubmit);
WSI_GET_CB(WaitForFences);
diff --git a/src/vulkan/wsi/wsi_common.h b/src/vulkan/wsi/wsi_common.h
index 34283a9..2225fe0 100644
--- a/src/vulkan/wsi/wsi_common.h
+++ b/src/vulkan/wsi/wsi_common.h
@@ -48,8 +48,6 @@ struct wsi_device {
VkPhysicalDeviceMemoryProperties memory_props;
uint32_t queue_family_count;
 
-   uint32_t (*queue_get_family_index)(VkQueue queue);
-
 #define WSI_CB(cb) PFN_vk##cb cb
WSI_CB(AllocateMemory);
WSI_CB(AllocateCommandBuffers);
@@ -72,6 +70,7 @@ struct 

[Mesa-dev] [PATCH 23/28] vulkan/wsi: Add a helper for AcquireNextImage

2017-11-16 Thread Jason Ekstrand
Unfortunately, due to the fact that AcquireNextImage does not take a
queue, the ANV trick for triggering the fence won't work in general.  We
leave dealing with the fence up to the caller for now.
---
 src/amd/vulkan/radv_wsi.c   | 15 ++-
 src/intel/vulkan/anv_wsi.c  | 19 +++
 src/vulkan/wsi/wsi_common.c | 14 ++
 src/vulkan/wsi/wsi_common.h |  8 
 4 files changed, 43 insertions(+), 13 deletions(-)

diff --git a/src/amd/vulkan/radv_wsi.c b/src/amd/vulkan/radv_wsi.c
index 7791162..9e732e8 100644
--- a/src/amd/vulkan/radv_wsi.c
+++ b/src/amd/vulkan/radv_wsi.c
@@ -206,18 +206,23 @@ VkResult radv_GetSwapchainImagesKHR(
 }
 
 VkResult radv_AcquireNextImageKHR(
-   VkDevice device,
-   VkSwapchainKHR   _swapchain,
+   VkDevice _device,
+   VkSwapchainKHR   swapchain,
uint64_t timeout,
VkSemaphore  semaphore,
VkFence  _fence,
uint32_t*pImageIndex)
 {
-   RADV_FROM_HANDLE(wsi_swapchain, swapchain, _swapchain);
+   RADV_FROM_HANDLE(radv_device, device, _device);
+   struct radv_physical_device *pdevice = device->physical_device;
RADV_FROM_HANDLE(radv_fence, fence, _fence);
 
-   VkResult result = swapchain->acquire_next_image(swapchain, timeout, 
semaphore,
-   pImageIndex);
+   VkResult result = wsi_common_acquire_next_image(>wsi_device,
+   _device,
+   swapchain,
+   timeout,
+   semaphore,
+   pImageIndex);
 
if (fence && (result == VK_SUCCESS || result == VK_SUBOPTIMAL_KHR)) {
fence->submitted = true;
diff --git a/src/intel/vulkan/anv_wsi.c b/src/intel/vulkan/anv_wsi.c
index 62368a1..6f5aaf6 100644
--- a/src/intel/vulkan/anv_wsi.c
+++ b/src/intel/vulkan/anv_wsi.c
@@ -234,24 +234,27 @@ VkResult anv_GetSwapchainImagesKHR(
 
 VkResult anv_AcquireNextImageKHR(
 VkDevice _device,
-VkSwapchainKHR   _swapchain,
+VkSwapchainKHR   swapchain,
 uint64_t timeout,
 VkSemaphore  semaphore,
-VkFence  _fence,
+VkFence  fence,
 uint32_t*pImageIndex)
 {
ANV_FROM_HANDLE(anv_device, device, _device);
-   ANV_FROM_HANDLE(wsi_swapchain, swapchain, _swapchain);
-   ANV_FROM_HANDLE(anv_fence, fence, _fence);
+   struct anv_physical_device *pdevice = >instance->physicalDevice;
 
-   VkResult result = swapchain->acquire_next_image(swapchain, timeout,
-   semaphore, pImageIndex);
+   VkResult result = wsi_common_acquire_next_image(>wsi_device,
+   _device,
+   swapchain,
+   timeout,
+   semaphore,
+   pImageIndex);
 
/* Thanks to implicit sync, the image is ready immediately.  However, we
 * should wait for the current GPU state to finish.
 */
-   if (fence)
-  anv_QueueSubmit(anv_queue_to_handle(>queue), 0, NULL, _fence);
+   if (fence != VK_NULL_HANDLE)
+  anv_QueueSubmit(anv_queue_to_handle(>queue), 0, NULL, fence);
 
return result;
 }
diff --git a/src/vulkan/wsi/wsi_common.c b/src/vulkan/wsi/wsi_common.c
index 3d5643d..5e35c96 100644
--- a/src/vulkan/wsi/wsi_common.c
+++ b/src/vulkan/wsi/wsi_common.c
@@ -531,6 +531,20 @@ wsi_common_get_images(VkSwapchainKHR _swapchain,
 }
 
 VkResult
+wsi_common_acquire_next_image(const struct wsi_device *wsi,
+  VkDevice device,
+  VkSwapchainKHR _swapchain,
+  uint64_t timeout,
+  VkSemaphore semaphore,
+  uint32_t *pImageIndex)
+{
+   WSI_FROM_HANDLE(wsi_swapchain, swapchain, _swapchain);
+
+   return swapchain->acquire_next_image(swapchain, timeout,
+semaphore, pImageIndex);
+}
+
+VkResult
 wsi_common_queue_present(const struct wsi_device *wsi,
  VkDevice device,
  VkQueue queue,
diff --git a/src/vulkan/wsi/wsi_common.h b/src/vulkan/wsi/wsi_common.h

[Mesa-dev] [PATCH 16/28] vulkan/wsi: Only wait on semaphores on the first swapchain

2017-11-16 Thread Jason Ekstrand
---
 src/vulkan/wsi/wsi_common.c | 9 +++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/vulkan/wsi/wsi_common.c b/src/vulkan/wsi/wsi_common.c
index 322f19b..4f92427 100644
--- a/src/vulkan/wsi/wsi_common.c
+++ b/src/vulkan/wsi/wsi_common.c
@@ -532,9 +532,14 @@ wsi_common_queue_present(const struct wsi_device *wsi,
   VkSubmitInfo submit_info = {
  .sType = VK_STRUCTURE_TYPE_SUBMIT_INFO,
  .pNext = NULL,
- .waitSemaphoreCount = pPresentInfo->waitSemaphoreCount,
- .pWaitSemaphores = pPresentInfo->pWaitSemaphores,
   };
+  if (i == 0) {
+ /* We only need/want to wait on semaphores once.  After that, we're
+  * guaranteed ordering since it all happens on the same queue.
+  */
+ submit_info.waitSemaphoreCount = pPresentInfo->waitSemaphoreCount,
+ submit_info.pWaitSemaphores = pPresentInfo->pWaitSemaphores,
+  }
   result = wsi->QueueSubmit(queue, 1, _info, swapchain->fences[0]);
   if (result != VK_SUCCESS)
  goto fail_present;
-- 
2.5.0.400.gff86faf

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


[Mesa-dev] [PATCH 17/28] vulkan/wsi: Set a proper pWaitDstStageMask on the dummy submit

2017-11-16 Thread Jason Ekstrand
Neither mesa driver really cares, but we should set it none the less for
the sake of correctness.
---
 src/vulkan/wsi/wsi_common.c | 17 +
 1 file changed, 17 insertions(+)

diff --git a/src/vulkan/wsi/wsi_common.c b/src/vulkan/wsi/wsi_common.c
index 4f92427..09528d7 100644
--- a/src/vulkan/wsi/wsi_common.c
+++ b/src/vulkan/wsi/wsi_common.c
@@ -533,14 +533,31 @@ wsi_common_queue_present(const struct wsi_device *wsi,
  .sType = VK_STRUCTURE_TYPE_SUBMIT_INFO,
  .pNext = NULL,
   };
+  VkPipelineStageFlags *stage_flags = NULL;
   if (i == 0) {
  /* We only need/want to wait on semaphores once.  After that, we're
   * guaranteed ordering since it all happens on the same queue.
   */
  submit_info.waitSemaphoreCount = pPresentInfo->waitSemaphoreCount,
  submit_info.pWaitSemaphores = pPresentInfo->pWaitSemaphores,
+
+ /* Set up the pWaitDstStageMasks */
+ stage_flags = vk_alloc(>alloc,
+sizeof(VkPipelineStageFlags) *
+pPresentInfo->waitSemaphoreCount,
+8,
+VK_SYSTEM_ALLOCATION_SCOPE_COMMAND);
+ if (!stage_flags) {
+result = VK_ERROR_OUT_OF_HOST_MEMORY;
+goto fail_present;
+ }
+ for (uint32_t s = 0; s < pPresentInfo->waitSemaphoreCount; s++)
+stage_flags[s] = VK_PIPELINE_STAGE_ALL_GRAPHICS_BIT;
+
+ submit_info.pWaitDstStageMask = stage_flags;
   }
   result = wsi->QueueSubmit(queue, 1, _info, swapchain->fences[0]);
+  vk_free(>alloc, stage_flags);
   if (result != VK_SUCCESS)
  goto fail_present;
 
-- 
2.5.0.400.gff86faf

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


[Mesa-dev] [PATCH 08/28] vulkan/wsi: Add a mock image creation extension

2017-11-16 Thread Jason Ekstrand
---
 src/vulkan/wsi/wsi_common.h | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/src/vulkan/wsi/wsi_common.h b/src/vulkan/wsi/wsi_common.h
index 9c1899c..0e1604a 100644
--- a/src/vulkan/wsi/wsi_common.h
+++ b/src/vulkan/wsi/wsi_common.h
@@ -30,6 +30,16 @@
 #include 
 #include 
 
+/* This is guaranteed to not collide with anything because it's in the
+ * VK_KHR_swapchain namespace but not actually used by the extension.
+ */
+#define WSI_STRUCTURE_TYPE_IMAGE_CREATE_INFO (VkStructureType)101002
+
+struct wsi_image_create_info {
+VkStructureType sType;
+const void *pNext;
+};
+
 struct wsi_image {
VkImage image;
VkDeviceMemory memory;
-- 
2.5.0.400.gff86faf

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


[Mesa-dev] [PATCH 15/28] vulkan/wsi: Refactor result handling in queue_present

2017-11-16 Thread Jason Ekstrand
---
 src/vulkan/wsi/wsi_common.c | 54 +++--
 1 file changed, 28 insertions(+), 26 deletions(-)

diff --git a/src/vulkan/wsi/wsi_common.c b/src/vulkan/wsi/wsi_common.c
index 5cb062e..322f19b 100644
--- a/src/vulkan/wsi/wsi_common.c
+++ b/src/vulkan/wsi/wsi_common.c
@@ -505,14 +505,14 @@ wsi_common_queue_present(const struct wsi_device *wsi,
  int queue_family_index,
  const VkPresentInfoKHR *pPresentInfo)
 {
-   VkResult result = VK_SUCCESS;
+   VkResult final_result = VK_SUCCESS;
 
const VkPresentRegionsKHR *regions =
   vk_find_struct_const(pPresentInfo->pNext, PRESENT_REGIONS_KHR);
 
for (uint32_t i = 0; i < pPresentInfo->swapchainCount; i++) {
   WSI_FROM_HANDLE(wsi_swapchain, swapchain, pPresentInfo->pSwapchains[i]);
-  VkResult item_result;
+  VkResult result;
 
   if (swapchain->fences[0] == VK_NULL_HANDLE) {
  const VkFenceCreateInfo fence_info = {
@@ -520,15 +520,11 @@ wsi_common_queue_present(const struct wsi_device *wsi,
 .pNext = NULL,
 .flags = 0,
  };
- item_result = wsi->CreateFence(device, _info,
->alloc,
->fences[0]);
- if (pPresentInfo->pResults != NULL)
-pPresentInfo->pResults[i] = item_result;
- result = result == VK_SUCCESS ? item_result : result;
- if (item_result != VK_SUCCESS) {
-continue;
- }
+ result = wsi->CreateFence(device, _info,
+   >alloc,
+   >fences[0]);
+ if (result != VK_SUCCESS)
+goto fail_present;
   } else {
  wsi->ResetFences(device, 1, >fences[0]);
   }
@@ -539,25 +535,22 @@ wsi_common_queue_present(const struct wsi_device *wsi,
  .waitSemaphoreCount = pPresentInfo->waitSemaphoreCount,
  .pWaitSemaphores = pPresentInfo->pWaitSemaphores,
   };
-  wsi->QueueSubmit(queue, 1, _info, swapchain->fences[0]);
+  result = wsi->QueueSubmit(queue, 1, _info, swapchain->fences[0]);
+  if (result != VK_SUCCESS)
+ goto fail_present;
 
   const VkPresentRegionKHR *region = NULL;
   if (regions && regions->pRegions)
  region = >pRegions[i];
 
-  item_result = swapchain->queue_present(swapchain,
- queue,
- pPresentInfo->waitSemaphoreCount,
- pPresentInfo->pWaitSemaphores,
- pPresentInfo->pImageIndices[i],
- region);
-
-  if (pPresentInfo->pResults != NULL)
- pPresentInfo->pResults[i] = item_result;
-  result = result == VK_SUCCESS ? item_result : result;
-  if (item_result != VK_SUCCESS) {
- continue;
-  }
+  result = swapchain->queue_present(swapchain,
+queue,
+pPresentInfo->waitSemaphoreCount,
+pPresentInfo->pWaitSemaphores,
+pPresentInfo->pImageIndices[i],
+region);
+  if (result != VK_SUCCESS)
+ goto fail_present;
 
   VkFence last = swapchain->fences[2];
   swapchain->fences[2] = swapchain->fences[1];
@@ -567,6 +560,15 @@ wsi_common_queue_present(const struct wsi_device *wsi,
   if (last != VK_NULL_HANDLE) {
  wsi->WaitForFences(device, 1, , true, 1);
   }
+
+   fail_present:
+  if (pPresentInfo->pResults != NULL)
+ pPresentInfo->pResults[i] = result;
+
+  /* Let the final result be our first unsuccessful result */
+  if (final_result == VK_SUCCESS)
+ final_result = result;
}
-   return VK_SUCCESS;   
+
+   return final_result;
 }
-- 
2.5.0.400.gff86faf

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


[Mesa-dev] [PATCH 19/28] anv/wsi: Enable prime support

2017-11-16 Thread Jason Ekstrand
Now that we're using the same common code as radv, we get prime support
for free.  Just enable it.
---
 src/intel/vulkan/anv_wsi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/intel/vulkan/anv_wsi.c b/src/intel/vulkan/anv_wsi.c
index 4d9f7df..975ad18 100644
--- a/src/intel/vulkan/anv_wsi.c
+++ b/src/intel/vulkan/anv_wsi.c
@@ -116,7 +116,7 @@ VkResult anv_GetPhysicalDeviceSurfaceSupportKHR(
 
return iface->get_support(surface, >wsi_device,
  >instance->alloc,
- queueFamilyIndex, device->local_fd, false, 
pSupported);
+ queueFamilyIndex, device->local_fd, true, 
pSupported);
 }
 
 VkResult anv_GetPhysicalDeviceSurfaceCapabilitiesKHR(
-- 
2.5.0.400.gff86faf

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


[Mesa-dev] [PATCH 20/28] vulkan/wsi: Move get_images into common code

2017-11-16 Thread Jason Ekstrand
This moves bits out of all four corners (anv, radv, x11, wayland) and
into the wsi common code.  We also switch to using an outarray to ensure
we get our return code right.
---
 src/amd/vulkan/radv_wsi.c   |  7 +++
 src/intel/vulkan/anv_wsi.c  |  7 +++
 src/vulkan/wsi/wsi_common.c | 17 +
 src/vulkan/wsi/wsi_common.h |  9 +++--
 src/vulkan/wsi/wsi_common_wayland.c | 28 +---
 src/vulkan/wsi/wsi_common_x11.c | 29 +
 6 files changed, 40 insertions(+), 57 deletions(-)

diff --git a/src/amd/vulkan/radv_wsi.c b/src/amd/vulkan/radv_wsi.c
index 0d1b479..ed964c5 100644
--- a/src/amd/vulkan/radv_wsi.c
+++ b/src/amd/vulkan/radv_wsi.c
@@ -222,13 +222,12 @@ void radv_DestroySwapchainKHR(
 
 VkResult radv_GetSwapchainImagesKHR(
VkDevice device,
-   VkSwapchainKHR   _swapchain,
+   VkSwapchainKHR   swapchain,
uint32_t*pSwapchainImageCount,
VkImage* pSwapchainImages)
 {
-   RADV_FROM_HANDLE(wsi_swapchain, swapchain, _swapchain);
-
-   return swapchain->get_images(swapchain, pSwapchainImageCount,
+   return wsi_common_get_images(swapchain,
+pSwapchainImageCount,
 pSwapchainImages);
 }
 
diff --git a/src/intel/vulkan/anv_wsi.c b/src/intel/vulkan/anv_wsi.c
index 975ad18..eed378c 100644
--- a/src/intel/vulkan/anv_wsi.c
+++ b/src/intel/vulkan/anv_wsi.c
@@ -248,13 +248,12 @@ void anv_DestroySwapchainKHR(
 
 VkResult anv_GetSwapchainImagesKHR(
 VkDevice device,
-VkSwapchainKHR   _swapchain,
+VkSwapchainKHR   swapchain,
 uint32_t*pSwapchainImageCount,
 VkImage* pSwapchainImages)
 {
-   ANV_FROM_HANDLE(wsi_swapchain, swapchain, _swapchain);
-
-   return swapchain->get_images(swapchain, pSwapchainImageCount,
+   return wsi_common_get_images(swapchain,
+pSwapchainImageCount,
 pSwapchainImages);
 }
 
diff --git a/src/vulkan/wsi/wsi_common.c b/src/vulkan/wsi/wsi_common.c
index 09528d7..35e49be 100644
--- a/src/vulkan/wsi/wsi_common.c
+++ b/src/vulkan/wsi/wsi_common.c
@@ -499,6 +499,23 @@ wsi_prime_image_blit_to_linear(const struct wsi_swapchain 
*chain,
 }
 
 VkResult
+wsi_common_get_images(VkSwapchainKHR _swapchain,
+  uint32_t *pSwapchainImageCount,
+  VkImage *pSwapchainImages)
+{
+   WSI_FROM_HANDLE(wsi_swapchain, swapchain, _swapchain);
+   VK_OUTARRAY_MAKE(images, pSwapchainImages, pSwapchainImageCount);
+
+   for (uint32_t i = 0; i < swapchain->image_count; i++) {
+  vk_outarray_append(, image) {
+ *image = swapchain->get_wsi_image(swapchain, i)->image;
+  }
+   }
+
+   return vk_outarray_status();
+}
+
+VkResult
 wsi_common_queue_present(const struct wsi_device *wsi,
  VkDevice device,
  VkQueue queue,
diff --git a/src/vulkan/wsi/wsi_common.h b/src/vulkan/wsi/wsi_common.h
index 4ce1579..ffd79c7 100644
--- a/src/vulkan/wsi/wsi_common.h
+++ b/src/vulkan/wsi/wsi_common.h
@@ -56,8 +56,8 @@ struct wsi_swapchain {
 
VkResult (*destroy)(struct wsi_swapchain *swapchain,
const VkAllocationCallbacks *pAllocator);
-   VkResult (*get_images)(struct wsi_swapchain *swapchain,
-  uint32_t *pCount, VkImage *pSwapchainImages);
+   struct wsi_image *(*get_wsi_image)(struct wsi_swapchain *swapchain,
+  uint32_t image_index);
VkResult (*acquire_next_image)(struct wsi_swapchain *swap_chain,
   uint64_t timeout, VkSemaphore semaphore,
   uint32_t *image_index);
@@ -209,6 +209,11 @@ void wsi_wl_finish_wsi(struct wsi_device *wsi_device,
const VkAllocationCallbacks *alloc);
 
 VkResult
+wsi_common_get_images(VkSwapchainKHR _swapchain,
+  uint32_t *pSwapchainImageCount,
+  VkImage *pSwapchainImages);
+
+VkResult
 wsi_common_queue_present(const struct wsi_device *wsi,
  VkDevice device_h,
  VkQueue queue_h,
diff --git a/src/vulkan/wsi/wsi_common_wayland.c 
b/src/vulkan/wsi/wsi_common_wayland.c
index 22c01b2..bf60a9b 100644
--- a/src/vulkan/wsi/wsi_common_wayland.c
+++ b/src/vulkan/wsi/wsi_common_wayland.c
@@ -582,30 +582,12 @@ struct wsi_wl_swapchain {
struct wsi_wl_image  images[0];
 };
 
-static VkResult
-wsi_wl_swapchain_get_images(struct wsi_swapchain *wsi_chain,
-uint32_t *pCount, VkImage 

[Mesa-dev] [PATCH 09/28] anv/image: Implement the wsi "extension"

2017-11-16 Thread Jason Ekstrand
---
 src/intel/vulkan/anv_image.c   | 43 +++---
 src/intel/vulkan/anv_private.h |  2 ++
 2 files changed, 42 insertions(+), 3 deletions(-)

diff --git a/src/intel/vulkan/anv_image.c b/src/intel/vulkan/anv_image.c
index 41fe3d8..3e94a76 100644
--- a/src/intel/vulkan/anv_image.c
+++ b/src/intel/vulkan/anv_image.c
@@ -91,7 +91,8 @@ choose_isl_surf_usage(VkImageCreateFlags vk_create_flags,
 }
 
 static isl_tiling_flags_t
-choose_isl_tiling_flags(const struct anv_image_create_info *anv_info)
+choose_isl_tiling_flags(const struct anv_image_create_info *anv_info,
+bool is_wsi_image)
 {
const VkImageCreateInfo *base_info = anv_info->vk_info;
isl_tiling_flags_t flags = 0;
@@ -100,7 +101,10 @@ choose_isl_tiling_flags(const struct anv_image_create_info 
*anv_info)
default:
   unreachable("bad VkImageTiling");
case VK_IMAGE_TILING_OPTIMAL:
-  flags = ISL_TILING_ANY_MASK;
+  if (is_wsi_image)
+ flags = ISL_TILING_X_BIT;
+  else
+ flags = ISL_TILING_ANY_MASK;
   break;
case VK_IMAGE_TILING_LINEAR:
   flags = ISL_TILING_LINEAR_BIT;
@@ -505,6 +509,18 @@ anv_image_create(VkDevice _device,
 
assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO);
 
+   bool is_wsi_image = false;
+   vk_foreach_struct_const(s, pCreateInfo->pNext) {
+  switch (s->sType) {
+  case WSI_STRUCTURE_TYPE_IMAGE_CREATE_INFO:
+ is_wsi_image = true;
+ break;
+  default:
+ anv_debug_ignored_stype(s->sType);
+ break;
+  }
+   }
+
anv_assert(pCreateInfo->mipLevels > 0);
anv_assert(pCreateInfo->arrayLayers > 0);
anv_assert(pCreateInfo->samples > 0);
@@ -527,13 +543,14 @@ anv_image_create(VkDevice _device,
image->samples = pCreateInfo->samples;
image->usage = pCreateInfo->usage;
image->tiling = pCreateInfo->tiling;
+   image->is_wsi_image = is_wsi_image;
image->disjoint = pCreateInfo->flags & VK_IMAGE_CREATE_DISJOINT_BIT_KHR;
 
const struct anv_format *format = anv_get_format(image->vk_format);
assert(format != NULL);
 
const isl_tiling_flags_t isl_tiling_flags =
-  choose_isl_tiling_flags(create_info);
+  choose_isl_tiling_flags(create_info, is_wsi_image);
 
image->n_planes = format->n_planes;
 
@@ -617,6 +634,26 @@ anv_image_bind_memory_plane(struct anv_device *device,
image->planes[plane].bo = memory->bo;
image->planes[plane].bo_offset = memory_offset;
 
+   if (image->is_wsi_image) {
+  /* We need to set the WRITE flag on window system buffers so that GEM
+   * will know we're writing to them and synchronize uses on other rings
+   * (eg if the display server uses the blitter ring).
+   */
+  memory->bo->flags &= ~EXEC_OBJECT_ASYNC;
+  memory->bo->flags |= EXEC_OBJECT_WRITE;
+
+  struct isl_surf *surf = >planes[0].surface.isl;
+  int ret = anv_gem_set_tiling(device, memory->bo->gem_handle,
+   surf->row_pitch,
+   isl_tiling_to_i915_tiling(surf->tiling));
+  if (ret) {
+ /* FINISHME: Choose a better error. */
+ return vk_errorf(device->instance, device,
+  VK_ERROR_OUT_OF_DEVICE_MEMORY,
+  "set_tiling failed: %m");
+  }
+   }
+
return VK_SUCCESS;
 }
 
diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h
index e17a52a..7d8a6bc 100644
--- a/src/intel/vulkan/anv_private.h
+++ b/src/intel/vulkan/anv_private.h
@@ -2340,6 +2340,8 @@ struct anv_image {
VkDeviceSize size;
uint32_t alignment;
 
+   bool is_wsi_image;
+
/* Whether the image is made of several underlying buffer objects rather a
 * single one with different offsets.
 */
-- 
2.5.0.400.gff86faf

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


[Mesa-dev] [PATCH 13/28] vulkan/wsi: Add a WSI_FROM_HANDLE macro

2017-11-16 Thread Jason Ekstrand
---
 src/vulkan/wsi/wsi_common.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/vulkan/wsi/wsi_common.h b/src/vulkan/wsi/wsi_common.h
index 6741157..be45042 100644
--- a/src/vulkan/wsi/wsi_common.h
+++ b/src/vulkan/wsi/wsi_common.h
@@ -169,6 +169,9 @@ struct wsi_callbacks {
   return (__VkType)(uintptr_t) _obj;   \
}
 
+#define WSI_FROM_HANDLE(__wsi_type, __name, __handle) \
+   struct __wsi_type *__name = __wsi_type ## _from_handle(__handle)
+
 WSI_DEFINE_NONDISP_HANDLE_CASTS(wsi_swapchain, VkSwapchainKHR)
 
 #define ICD_DEFINE_NONDISP_HANDLE_CASTS(__VkIcdType, __VkType) \
-- 
2.5.0.400.gff86faf

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


[Mesa-dev] [PATCH 14/28] radv/wsi: Move the guts of QueuePresent to wsi common

2017-11-16 Thread Jason Ekstrand
From: Dave Airlie 

v2 (Jason Ekstrand):
 - Better comit message
 - Rebase
 - Re-indent to follow wsi_common style
 - Drop the unneeded _swapchain from the newly added helper
 - Make the clone more true to the original (as per the rebase)
---
 src/amd/vulkan/radv_wsi.c   | 92 +++--
 src/vulkan/wsi/wsi_common.c | 78 ++
 src/vulkan/wsi/wsi_common.h | 10 +
 3 files changed, 93 insertions(+), 87 deletions(-)

diff --git a/src/amd/vulkan/radv_wsi.c b/src/amd/vulkan/radv_wsi.c
index b576514..0d1b479 100644
--- a/src/amd/vulkan/radv_wsi.c
+++ b/src/amd/vulkan/radv_wsi.c
@@ -258,91 +258,9 @@ VkResult radv_QueuePresentKHR(
const VkPresentInfoKHR*  pPresentInfo)
 {
RADV_FROM_HANDLE(radv_queue, queue, _queue);
-   VkResult result = VK_SUCCESS;
-   const VkPresentRegionsKHR *regions =
-vk_find_struct_const(pPresentInfo->pNext, PRESENT_REGIONS_KHR);
-
-   for (uint32_t i = 0; i < pPresentInfo->swapchainCount; i++) {
-   RADV_FROM_HANDLE(wsi_swapchain, swapchain, 
pPresentInfo->pSwapchains[i]);
-   struct radeon_winsys_cs *cs;
-   const VkPresentRegionKHR *region = NULL;
-   VkResult item_result;
-   struct radv_winsys_sem_info sem_info;
-
-   item_result = radv_alloc_sem_info(_info,
- 
pPresentInfo->waitSemaphoreCount,
- pPresentInfo->pWaitSemaphores,
- 0,
- NULL);
-   if (pPresentInfo->pResults != NULL)
-   pPresentInfo->pResults[i] = item_result;
-   result = result == VK_SUCCESS ? item_result : result;
-   if (item_result != VK_SUCCESS) {
-   radv_free_sem_info(_info);
-   continue;
-   }
-
-   assert(radv_device_from_handle(swapchain->device) == 
queue->device);
-   if (swapchain->fences[0] == VK_NULL_HANDLE) {
-   item_result = 
radv_CreateFence(radv_device_to_handle(queue->device),
- &(VkFenceCreateInfo) {
- .sType = 
VK_STRUCTURE_TYPE_FENCE_CREATE_INFO,
- .flags = 0,
- }, 
>alloc, >fences[0]);
-   if (pPresentInfo->pResults != NULL)
-   pPresentInfo->pResults[i] = item_result;
-   result = result == VK_SUCCESS ? item_result : result;
-   if (item_result != VK_SUCCESS) {
-   radv_free_sem_info(_info);
-   continue;
-   }
-   } else {
-   radv_ResetFences(radv_device_to_handle(queue->device),
-1, >fences[0]);
-   }
-
-   cs = queue->device->empty_cs[queue->queue_family_index];
-   RADV_FROM_HANDLE(radv_fence, fence, swapchain->fences[0]);
-   struct radeon_winsys_fence *base_fence = fence->fence;
-   struct radeon_winsys_ctx *ctx = queue->hw_ctx;
-
-   queue->device->ws->cs_submit(ctx, queue->queue_idx,
-,
-1, NULL, NULL,
-_info,
-false, base_fence);
-   fence->submitted = true;
-
-   if (regions && regions->pRegions)
-   region = >pRegions[i];
-
-   item_result = swapchain->queue_present(swapchain,
- _queue,
- 
pPresentInfo->waitSemaphoreCount,
- pPresentInfo->pWaitSemaphores,
- 
pPresentInfo->pImageIndices[i],
- region);
-   /* TODO: What if one of them returns OUT_OF_DATE? */
-   if (pPresentInfo->pResults != NULL)
-   pPresentInfo->pResults[i] = item_result;
-   result = result == VK_SUCCESS ? item_result : result;
-   if (item_result != VK_SUCCESS) {
-   radv_free_sem_info(_info);
-   continue;
-   }
-
-   VkFence last = swapchain->fences[2];
-   swapchain->fences[2] = swapchain->fences[1];
-   swapchain->fences[1] = swapchain->fences[0];
-   swapchain->fences[0] = last;
-
- 

[Mesa-dev] [PATCH 12/28] vulkan/wsi: Do image creation in common code

2017-11-16 Thread Jason Ekstrand
This uses the mock extension created in a previous commit to tell the
driver that the image it's just been asked to create is, in fact, a
window system image with whatever assumptions that implies.  There was a
lot of redundant code between the two drivers to do basically exactly
the same thing.
---
 src/amd/vulkan/radv_wsi.c   | 124 +---
 src/intel/vulkan/anv_wsi.c  | 122 +--
 src/vulkan/wsi/wsi_common.c | 111 +++-
 src/vulkan/wsi/wsi_common.h |  28 +---
 src/vulkan/wsi/wsi_common_private.h |  25 +++-
 src/vulkan/wsi/wsi_common_wayland.c |  13 +---
 src/vulkan/wsi/wsi_common_x11.c |  20 +-
 7 files changed, 140 insertions(+), 303 deletions(-)

diff --git a/src/amd/vulkan/radv_wsi.c b/src/amd/vulkan/radv_wsi.c
index 589eb5c..b576514 100644
--- a/src/amd/vulkan/radv_wsi.c
+++ b/src/amd/vulkan/radv_wsi.c
@@ -157,128 +157,6 @@ VkResult radv_GetPhysicalDeviceSurfacePresentModesKHR(
pPresentModes);
 }
 
-static VkResult
-radv_wsi_image_create(VkDevice device_h,
- const VkSwapchainCreateInfoKHR *pCreateInfo,
- const VkAllocationCallbacks* pAllocator,
- struct wsi_image *wsi_image)
-{
-   VkResult result = VK_SUCCESS;
-   struct radeon_surf *surface;
-   VkImage image_h;
-   struct radv_image *image;
-   int fd;
-   RADV_FROM_HANDLE(radv_device, device, device_h);
-
-   result = radv_image_create(device_h,
-  &(struct radv_image_create_info) {
-  .vk_info =
-  &(VkImageCreateInfo) {
-  .sType = 
VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO,
-  .imageType = 
VK_IMAGE_TYPE_2D,
-  .format = 
pCreateInfo->imageFormat,
-  .extent = {
-  .width = 
pCreateInfo->imageExtent.width,
-  .height = 
pCreateInfo->imageExtent.height,
-  .depth = 1
-  },
-  .mipLevels = 1,
-  .arrayLayers = 1,
-  .samples = 1,
-  /* FIXME: Need a way to use 
X tiling to allow scanout */
-  .tiling = 
VK_IMAGE_TILING_OPTIMAL,
-  .usage = 
VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT,
-  .flags = 0,
-  },
-  .scanout = true},
-  NULL,
-  _h);
-   if (result != VK_SUCCESS)
-   return result;
-
-   image = radv_image_from_handle(image_h);
-
-   VkDeviceMemory memory_h;
-
-   const VkMemoryDedicatedAllocateInfoKHR ded_alloc = {
-   .sType = VK_STRUCTURE_TYPE_MEMORY_DEDICATED_ALLOCATE_INFO_KHR,
-   .pNext = NULL,
-   .buffer = VK_NULL_HANDLE,
-   .image = image_h
-   };
-
-   /* Find the first VRAM memory type, or GART for PRIME images. */
-   int memory_type_index = -1;
-   for (int i = 0; i < 
device->physical_device->memory_properties.memoryTypeCount; ++i) {
-   bool is_local = 
!!(device->physical_device->memory_properties.memoryTypes[i].propertyFlags & 
VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT);
-   if (is_local) {
-   memory_type_index = i;
-   break;
-   }
-   }
-
-   /* fallback */
-   if (memory_type_index == -1)
-   memory_type_index = 0;
-
-   result = radv_alloc_memory(device_h,
-&(VkMemoryAllocateInfo) {
-.sType = 
VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO,
-.pNext = _alloc,
-.allocationSize = image->size,
-.memoryTypeIndex = 
memory_type_index,
-},
-NULL /* XXX: pAllocator */,
-RADV_MEM_IMPLICIT_SYNC,
-_h);
-   if (result != VK_SUCCESS)
-   goto fail_create_image;
-
-   radv_BindImageMemory(device_h, image_h, memory_h, 0);
-
-   

[Mesa-dev] [PATCH 11/28] radv/wsi: drop allocate memory special case

2017-11-16 Thread Jason Ekstrand
From: Dave Airlie 

Just check if image has scanout flag set

v2 (Jason Ekstrand):
 - Rebase
 - Also drop the now unused radv_mem_flag_bits enum
---
 src/amd/vulkan/radv_device.c  | 16 ++--
 src/amd/vulkan/radv_private.h | 10 --
 2 files changed, 6 insertions(+), 20 deletions(-)

diff --git a/src/amd/vulkan/radv_device.c b/src/amd/vulkan/radv_device.c
index 58a4604..46e9a14 100644
--- a/src/amd/vulkan/radv_device.c
+++ b/src/amd/vulkan/radv_device.c
@@ -2125,13 +2125,11 @@ bool radv_get_memory_fd(struct radv_device *device,
 pFD);
 }
 
-VkResult radv_alloc_memory(VkDevice_device,
-  const VkMemoryAllocateInfo* pAllocateInfo,
-  const VkAllocationCallbacks*pAllocator,
-  enum radv_mem_flags_bitsmem_flags,
-  VkDeviceMemory* pMem)
+static VkResult radv_alloc_memory(struct radv_device *device,
+ const VkMemoryAllocateInfo* pAllocateInfo,
+ const VkAllocationCallbacks*pAllocator,
+ VkDeviceMemory* pMem)
 {
-   RADV_FROM_HANDLE(radv_device, device, _device);
struct radv_device_memory *mem;
VkResult result;
enum radeon_bo_domain domain;
@@ -2195,9 +2193,6 @@ VkResult radv_alloc_memory(VkDevice   
 _device,
if (mem_type_index == RADV_MEM_TYPE_GTT_WRITE_COMBINE)
flags |= RADEON_FLAG_GTT_WC;
 
-   if (mem_flags & RADV_MEM_IMPLICIT_SYNC)
-   flags |= RADEON_FLAG_IMPLICIT_SYNC;
-
if (!dedicate_info && !import_info)
flags |= RADEON_FLAG_NO_INTERPROCESS_SHARING;
 
@@ -2226,7 +2221,8 @@ VkResult radv_AllocateMemory(
const VkAllocationCallbacks*pAllocator,
VkDeviceMemory* pMem)
 {
-   return radv_alloc_memory(_device, pAllocateInfo, pAllocator, 0, pMem);
+   RADV_FROM_HANDLE(radv_device, device, _device);
+   return radv_alloc_memory(device, pAllocateInfo, pAllocator, pMem);
 }
 
 void radv_FreeMemory(
diff --git a/src/amd/vulkan/radv_private.h b/src/amd/vulkan/radv_private.h
index 93f93b9..020405b 100644
--- a/src/amd/vulkan/radv_private.h
+++ b/src/amd/vulkan/radv_private.h
@@ -106,11 +106,6 @@ enum radv_mem_type {
RADV_MEM_TYPE_COUNT
 };
 
-enum radv_mem_flags_bits {
-   /* enable implicit synchronization when accessing the underlying bo */
-   RADV_MEM_IMPLICIT_SYNC = 1 << 0,
-};
-
 #define radv_printflike(a, b) __attribute__((__format__(__printf__, a, b)))
 
 static inline uint32_t
@@ -988,11 +983,6 @@ void radv_cmd_buffer_trace_emit(struct radv_cmd_buffer 
*cmd_buffer);
 bool radv_get_memory_fd(struct radv_device *device,
struct radv_device_memory *memory,
int *pFD);
-VkResult radv_alloc_memory(VkDevice _device,
-  const VkMemoryAllocateInfo* pAllocateInfo,
-  const VkAllocationCallbacks* pAllocator,
-  enum radv_mem_flags_bits flags,
-  VkDeviceMemory* pMem);
 
 /*
  * Takes x,y,z as exact numbers of invocations, instead of blocks.
-- 
2.5.0.400.gff86faf

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


[Mesa-dev] [PATCH 10/28] radv/image: Implement the wsi "extension"

2017-11-16 Thread Jason Ekstrand
---
 src/amd/vulkan/radv_device.c |  2 ++
 src/amd/vulkan/radv_image.c  | 15 +--
 2 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/src/amd/vulkan/radv_device.c b/src/amd/vulkan/radv_device.c
index 722c768..58a4604 100644
--- a/src/amd/vulkan/radv_device.c
+++ b/src/amd/vulkan/radv_device.c
@@ -2159,6 +2159,8 @@ VkResult radv_alloc_memory(VkDevice   
 _device,
if (dedicate_info) {
mem->image = radv_image_from_handle(dedicate_info->image);
mem->buffer = radv_buffer_from_handle(dedicate_info->buffer);
+   if (mem->image->surface.flags & RADEON_SURF_SCANOUT)
+   flags |= RADEON_FLAG_IMPLICIT_SYNC;
} else {
mem->image = NULL;
mem->buffer = NULL;
diff --git a/src/amd/vulkan/radv_image.c b/src/amd/vulkan/radv_image.c
index 163d35d..b4abec3 100644
--- a/src/amd/vulkan/radv_image.c
+++ b/src/amd/vulkan/radv_image.c
@@ -1113,11 +1113,22 @@ radv_CreateImage(VkDevice device,
 const VkAllocationCallbacks *pAllocator,
 VkImage *pImage)
 {
+   bool scanout = false;
+   vk_foreach_struct_const(s, pCreateInfo->pNext) {
+   switch (s->sType) {
+   case WSI_STRUCTURE_TYPE_IMAGE_CREATE_INFO:
+   scanout = true;
+   break;
+   default:
+   break;
+   }
+   }
+
return radv_image_create(device,
 &(struct radv_image_create_info) {
 .vk_info = pCreateInfo,
-.scanout = false,
-},
+.scanout = scanout,
+},
 pAllocator,
 pImage);
 }
-- 
2.5.0.400.gff86faf

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


[Mesa-dev] [PATCH 06/28] vulkan/wsi: Implement prime in a completely generic way

2017-11-16 Thread Jason Ekstrand
---
 src/amd/vulkan/radv_wsi.c   | 137 +++
 src/intel/vulkan/anv_wsi.c  |  14 +-
 src/vulkan/wsi/wsi_common.c | 338 +++-
 src/vulkan/wsi/wsi_common.h |  54 +-
 src/vulkan/wsi/wsi_common_private.h |  16 ++
 src/vulkan/wsi/wsi_common_wayland.c |   6 +-
 src/vulkan/wsi/wsi_common_x11.c |  87 +-
 7 files changed, 472 insertions(+), 180 deletions(-)

diff --git a/src/amd/vulkan/radv_wsi.c b/src/amd/vulkan/radv_wsi.c
index 247f7cc..589eb5c 100644
--- a/src/amd/vulkan/radv_wsi.c
+++ b/src/amd/vulkan/radv_wsi.c
@@ -40,6 +40,13 @@ radv_wsi_proc_addr(VkPhysicalDevice physicalDevice, const 
char *pName)
return radv_lookup_entrypoint(pName);
 }
 
+static uint32_t
+anv_wsi_queue_get_family_index(VkQueue _queue)
+{
+   RADV_FROM_HANDLE(radv_queue, queue, _queue);
+   return queue->queue_family_index;
+}
+
 VkResult
 radv_init_wsi(struct radv_physical_device *physical_device)
 {
@@ -49,6 +56,9 @@ radv_init_wsi(struct radv_physical_device *physical_device)
radv_physical_device_to_handle(physical_device),
radv_wsi_proc_addr);
 
+   physical_device->wsi_device.queue_get_family_index =
+   anv_wsi_queue_get_family_index;
+
 #ifdef VK_USE_PLATFORM_XCB_KHR
result = wsi_x11_init_wsi(_device->wsi_device, 
_device->instance->alloc);
if (result != VK_SUCCESS)
@@ -151,8 +161,6 @@ static VkResult
 radv_wsi_image_create(VkDevice device_h,
  const VkSwapchainCreateInfoKHR *pCreateInfo,
  const VkAllocationCallbacks* pAllocator,
- bool needs_linear_copy,
- bool linear,
  struct wsi_image *wsi_image)
 {
VkResult result = VK_SUCCESS;
@@ -178,7 +186,7 @@ radv_wsi_image_create(VkDevice device_h,
   .arrayLayers = 1,
   .samples = 1,
   /* FIXME: Need a way to use 
X tiling to allow scanout */
-  .tiling = linear ? 
VK_IMAGE_TILING_LINEAR : VK_IMAGE_TILING_OPTIMAL,
+  .tiling = 
VK_IMAGE_TILING_OPTIMAL,
   .usage = 
VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT,
   .flags = 0,
   },
@@ -203,7 +211,7 @@ radv_wsi_image_create(VkDevice device_h,
int memory_type_index = -1;
for (int i = 0; i < 
device->physical_device->memory_properties.memoryTypeCount; ++i) {
bool is_local = 
!!(device->physical_device->memory_properties.memoryTypes[i].propertyFlags & 
VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT);
-   if ((linear && !is_local) || (!linear && is_local)) {
+   if (is_local) {
memory_type_index = i;
break;
}
@@ -228,16 +236,10 @@ radv_wsi_image_create(VkDevice device_h,
 
radv_BindImageMemory(device_h, image_h, memory_h, 0);
 
-   /*
-* return the fd for the image in the no copy mode,
-* or the fd for the linear image if a copy is required.
-*/
-   if (!needs_linear_copy || (needs_linear_copy && linear)) {
-   RADV_FROM_HANDLE(radv_device_memory, memory, memory_h);
-   if (!radv_get_memory_fd(device, memory, ))
-   goto fail_alloc_memory;
-   wsi_image->fd = fd;
-   }
+   RADV_FROM_HANDLE(radv_device_memory, memory, memory_h);
+   if (!radv_get_memory_fd(device, memory, ))
+   goto fail_alloc_memory;
+   wsi_image->fd = fd;
 
surface = >surface;
 
@@ -277,94 +279,6 @@ static const struct wsi_image_fns radv_wsi_image_fns = {
.free_wsi_image = radv_wsi_image_free,
 };
 
-#define NUM_PRIME_POOLS RADV_QUEUE_TRANSFER
-static void
-radv_wsi_free_prime_command_buffers(struct radv_device *device,
-   struct wsi_swapchain *swapchain)
-{
-   const int num_pools = NUM_PRIME_POOLS;
-   const int num_images = swapchain->image_count;
-   int i;
-   for (i = 0; i < num_pools; i++) {
-   radv_FreeCommandBuffers(radv_device_to_handle(device),
-swapchain->cmd_pools[i],
-swapchain->image_count,
->cmd_buffers[i * num_images]);
-
-   radv_DestroyCommandPool(radv_device_to_handle(device),
-swapchain->cmd_pools[i],
->alloc);
-   }
-}
-
-static VkResult
-radv_wsi_create_prime_command_buffers(struct radv_device *device,
- const VkAllocationCallbacks *alloc,
-  

[Mesa-dev] [PATCH 07/28] anv/image: Add a return value to bind_memory_plane

2017-11-16 Thread Jason Ekstrand
---
 src/intel/vulkan/anv_image.c | 28 +++-
 1 file changed, 19 insertions(+), 9 deletions(-)

diff --git a/src/intel/vulkan/anv_image.c b/src/intel/vulkan/anv_image.c
index ba932ba..41fe3d8 100644
--- a/src/intel/vulkan/anv_image.c
+++ b/src/intel/vulkan/anv_image.c
@@ -599,22 +599,25 @@ anv_DestroyImage(VkDevice _device, VkImage _image,
vk_free2(>alloc, pAllocator, image);
 }
 
-static void anv_image_bind_memory_plane(struct anv_device *device,
-struct anv_image *image,
-uint32_t plane,
-struct anv_device_memory *memory,
-uint32_t memory_offset)
+static VkResult
+anv_image_bind_memory_plane(struct anv_device *device,
+struct anv_image *image,
+uint32_t plane,
+struct anv_device_memory *memory,
+uint32_t memory_offset)
 {
assert(!image->planes[plane].bo_is_owned);
 
if (!memory) {
   image->planes[plane].bo = NULL;
   image->planes[plane].bo_offset = 0;
-  return;
+  return VK_SUCCESS;
}
 
image->planes[plane].bo = memory->bo;
image->planes[plane].bo_offset = memory_offset;
+
+   return VK_SUCCESS;
 }
 
 VkResult anv_BindImageMemory(
@@ -626,12 +629,16 @@ VkResult anv_BindImageMemory(
ANV_FROM_HANDLE(anv_device, device, _device);
ANV_FROM_HANDLE(anv_device_memory, mem, _memory);
ANV_FROM_HANDLE(anv_image, image, _image);
+   VkResult result;
 
uint32_t aspect_bit;
anv_foreach_image_aspect_bit(aspect_bit, image, image->aspects) {
   uint32_t plane =
  anv_image_aspect_to_plane(image->aspects, 1UL << aspect_bit);
-  anv_image_bind_memory_plane(device, image, plane, mem, memoryOffset);
+  result = anv_image_bind_memory_plane(device, image, plane, mem,
+   memoryOffset);
+  if (result != VK_SUCCESS)
+ return result;
}
 
return VK_SUCCESS;
@@ -643,6 +650,7 @@ VkResult anv_BindImageMemory2KHR(
 const VkBindImageMemoryInfoKHR* pBindInfos)
 {
ANV_FROM_HANDLE(anv_device, device, _device);
+   VkResult result;
 
for (uint32_t i = 0; i < bindInfoCount; i++) {
   const VkBindImageMemoryInfoKHR *bind_info = [i];
@@ -669,8 +677,10 @@ VkResult anv_BindImageMemory2KHR(
   anv_foreach_image_aspect_bit(aspect_bit, image, aspects) {
  uint32_t plane =
 anv_image_aspect_to_plane(image->aspects, 1UL << aspect_bit);
- anv_image_bind_memory_plane(device, image, plane,
- mem, bind_info->memoryOffset);
+ result = anv_image_bind_memory_plane(device, image, plane,
+  mem, bind_info->memoryOffset);
+ if (result != VK_SUCCESS)
+return result;
   }
}
 
-- 
2.5.0.400.gff86faf

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


[Mesa-dev] [PATCH 05/28] vulkan/wsi: Add wsi_swapchain_init/finish functions

2017-11-16 Thread Jason Ekstrand
---
 src/vulkan/Makefile.sources |  1 +
 src/vulkan/wsi/meson.build  |  1 +
 src/vulkan/wsi/wsi_common.c | 23 ++-
 src/vulkan/wsi/wsi_common.h |  1 +
 src/vulkan/wsi/wsi_common_private.h | 37 +
 src/vulkan/wsi/wsi_common_wayland.c | 11 ++-
 src/vulkan/wsi/wsi_common_x11.c | 13 +++--
 7 files changed, 83 insertions(+), 4 deletions(-)
 create mode 100644 src/vulkan/wsi/wsi_common_private.h

diff --git a/src/vulkan/Makefile.sources b/src/vulkan/Makefile.sources
index 44cba8b..6e9a09c 100644
--- a/src/vulkan/Makefile.sources
+++ b/src/vulkan/Makefile.sources
@@ -2,6 +2,7 @@
 VULKAN_WSI_FILES := \
wsi/wsi_common.c \
wsi/wsi_common.h \
+   wsi/wsi_common_private.h \
wsi/wsi_common_queue.h
 
 VULKAN_WSI_WAYLAND_FILES := \
diff --git a/src/vulkan/wsi/meson.build b/src/vulkan/wsi/meson.build
index bfec376..bd0fd3c 100644
--- a/src/vulkan/wsi/meson.build
+++ b/src/vulkan/wsi/meson.build
@@ -24,6 +24,7 @@ vulkan_wsi_deps = []
 files_vulkan_wsi = files(
   'wsi_common.c',
   'wsi_common.h',
+  'wsi_common_private.h',
   'wsi_common_queue.h',
 )
 if with_platform_x11
diff --git a/src/vulkan/wsi/wsi_common.c b/src/vulkan/wsi/wsi_common.c
index 8c883b4..bb35237 100644
--- a/src/vulkan/wsi/wsi_common.c
+++ b/src/vulkan/wsi/wsi_common.c
@@ -21,7 +21,7 @@
  * IN THE SOFTWARE.
  */
 
-#include "wsi_common.h"
+#include "wsi_common_private.h"
 
 void
 wsi_device_init(struct wsi_device *wsi,
@@ -30,3 +30,24 @@ wsi_device_init(struct wsi_device *wsi,
 {
memset(wsi, 0, sizeof(*wsi));
 }
+
+VkResult
+wsi_swapchain_init(const struct wsi_device *wsi,
+   struct wsi_swapchain *chain,
+   VkDevice device,
+   const VkSwapchainCreateInfoKHR* pCreateInfo,
+   const VkAllocationCallbacks *pAllocator)
+{
+   memset(chain, 0, sizeof(*chain));
+
+   chain->wsi = wsi;
+   chain->device = device;
+   chain->alloc = *pAllocator;
+
+   return VK_SUCCESS;
+}
+
+void
+wsi_swapchain_finish(struct wsi_swapchain *chain)
+{
+}
diff --git a/src/vulkan/wsi/wsi_common.h b/src/vulkan/wsi/wsi_common.h
index 41d2c6d..15142f3 100644
--- a/src/vulkan/wsi/wsi_common.h
+++ b/src/vulkan/wsi/wsi_common.h
@@ -53,6 +53,7 @@ struct wsi_image_fns {
 };
 
 struct wsi_swapchain {
+   const struct wsi_device *wsi;
 
VkDevice device;
VkAllocationCallbacks alloc;
diff --git a/src/vulkan/wsi/wsi_common_private.h 
b/src/vulkan/wsi/wsi_common_private.h
new file mode 100644
index 000..d178df7
--- /dev/null
+++ b/src/vulkan/wsi/wsi_common_private.h
@@ -0,0 +1,37 @@
+/*
+ * Copyright © 2017 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+#ifndef WSI_COMMON_PRIVATE_H
+#define WSI_COMMON_PRIVATE_H
+
+#include "wsi_common.h"
+
+VkResult
+wsi_swapchain_init(const struct wsi_device *wsi,
+   struct wsi_swapchain *chain,
+   VkDevice device,
+   const VkSwapchainCreateInfoKHR *pCreateInfo,
+   const VkAllocationCallbacks *pAllocator);
+
+void wsi_swapchain_finish(struct wsi_swapchain *chain);
+
+#endif /* WSI_COMMON_PRIVATE_H */
diff --git a/src/vulkan/wsi/wsi_common_wayland.c 
b/src/vulkan/wsi/wsi_common_wayland.c
index c7c7da6..b75a4d0 100644
--- a/src/vulkan/wsi/wsi_common_wayland.c
+++ b/src/vulkan/wsi/wsi_common_wayland.c
@@ -32,6 +32,7 @@
 #include 
 
 #include "vk_util.h"
+#include "wsi_common_private.h"
 #include "wsi_common_wayland.h"
 #include "wayland-drm-client-protocol.h"
 
@@ -783,6 +784,8 @@ wsi_wl_swapchain_destroy(struct wsi_swapchain *wsi_chain,
if (chain->display)
   wsi_wl_display_unref(chain->display);
 
+   wsi_swapchain_finish(>base);
+
vk_free(pAllocator, chain);
 
return VK_SUCCESS;
@@ -814,6 +817,13 @@ wsi_wl_surface_create_swapchain(VkIcdSurfaceBase 
*icd_surface,
if (chain == 

[Mesa-dev] [PATCH 04/28] vulkan/wsi: Add a wsi_device_init function

2017-11-16 Thread Jason Ekstrand
This gives the opportunity to collect some function pointers if we'd
like which will be very useful in future.
---
 src/amd/vulkan/radv_wsi.c   | 10 +-
 src/intel/vulkan/anv_wsi.c  | 11 ++-
 src/vulkan/Makefile.sources |  1 +
 src/vulkan/wsi/meson.build  |  1 +
 src/vulkan/wsi/wsi_common.c | 32 
 src/vulkan/wsi/wsi_common.h |  7 +++
 6 files changed, 60 insertions(+), 2 deletions(-)
 create mode 100644 src/vulkan/wsi/wsi_common.c

diff --git a/src/amd/vulkan/radv_wsi.c b/src/amd/vulkan/radv_wsi.c
index f5f9a3f..247f7cc 100644
--- a/src/amd/vulkan/radv_wsi.c
+++ b/src/amd/vulkan/radv_wsi.c
@@ -34,12 +34,20 @@ MAYBE_UNUSED static const struct wsi_callbacks wsi_cbs = {
WSI_CB(GetPhysicalDeviceFormatProperties),
 };
 
+static PFN_vkVoidFunction
+radv_wsi_proc_addr(VkPhysicalDevice physicalDevice, const char *pName)
+{
+   return radv_lookup_entrypoint(pName);
+}
+
 VkResult
 radv_init_wsi(struct radv_physical_device *physical_device)
 {
VkResult result;
 
-   memset(physical_device->wsi_device.wsi, 0, 
sizeof(physical_device->wsi_device.wsi));
+   wsi_device_init(_device->wsi_device,
+   radv_physical_device_to_handle(physical_device),
+   radv_wsi_proc_addr);
 
 #ifdef VK_USE_PLATFORM_XCB_KHR
result = wsi_x11_init_wsi(_device->wsi_device, 
_device->instance->alloc);
diff --git a/src/intel/vulkan/anv_wsi.c b/src/intel/vulkan/anv_wsi.c
index d8c4885..f898a07 100644
--- a/src/intel/vulkan/anv_wsi.c
+++ b/src/intel/vulkan/anv_wsi.c
@@ -33,12 +33,21 @@ static const struct wsi_callbacks wsi_cbs = {
 };
 #endif
 
+static PFN_vkVoidFunction
+anv_wsi_proc_addr(VkPhysicalDevice physicalDevice, const char *pName)
+{
+   ANV_FROM_HANDLE(anv_physical_device, physical_device, physicalDevice);
+   return anv_lookup_entrypoint(_device->info, pName);
+}
+
 VkResult
 anv_init_wsi(struct anv_physical_device *physical_device)
 {
VkResult result;
 
-   memset(physical_device->wsi_device.wsi, 0, 
sizeof(physical_device->wsi_device.wsi));
+   wsi_device_init(_device->wsi_device,
+   anv_physical_device_to_handle(physical_device),
+   anv_wsi_proc_addr);
 
 #ifdef VK_USE_PLATFORM_XCB_KHR
result = wsi_x11_init_wsi(_device->wsi_device, 
_device->instance->alloc);
diff --git a/src/vulkan/Makefile.sources b/src/vulkan/Makefile.sources
index 2cf7218..44cba8b 100644
--- a/src/vulkan/Makefile.sources
+++ b/src/vulkan/Makefile.sources
@@ -1,5 +1,6 @@
 
 VULKAN_WSI_FILES := \
+   wsi/wsi_common.c \
wsi/wsi_common.h \
wsi/wsi_common_queue.h
 
diff --git a/src/vulkan/wsi/meson.build b/src/vulkan/wsi/meson.build
index 3aa02d5..bfec376 100644
--- a/src/vulkan/wsi/meson.build
+++ b/src/vulkan/wsi/meson.build
@@ -22,6 +22,7 @@ vulkan_wsi_args = []
 vulkan_wsi_deps = []
 
 files_vulkan_wsi = files(
+  'wsi_common.c',
   'wsi_common.h',
   'wsi_common_queue.h',
 )
diff --git a/src/vulkan/wsi/wsi_common.c b/src/vulkan/wsi/wsi_common.c
new file mode 100644
index 000..8c883b4
--- /dev/null
+++ b/src/vulkan/wsi/wsi_common.c
@@ -0,0 +1,32 @@
+/*
+ * Copyright © 2017 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#include "wsi_common.h"
+
+void
+wsi_device_init(struct wsi_device *wsi,
+VkPhysicalDevice pdevice,
+WSI_FN_GetPhysicalDeviceProcAddr proc_addr)
+{
+   memset(wsi, 0, sizeof(*wsi));
+}
diff --git a/src/vulkan/wsi/wsi_common.h b/src/vulkan/wsi/wsi_common.h
index 565219d..41d2c6d 100644
--- a/src/vulkan/wsi/wsi_common.h
+++ b/src/vulkan/wsi/wsi_common.h
@@ -121,6 +121,13 @@ struct wsi_device {
 struct wsi_interface *  wsi[VK_ICD_WSI_PLATFORM_MAX];
 };
 
+typedef PFN_vkVoidFunction (VKAPI_PTR 
*WSI_FN_GetPhysicalDeviceProcAddr)(VkPhysicalDevice physicalDevice, const char* 
pName);
+
+void
+wsi_device_init(struct wsi_device 

[Mesa-dev] [PATCH 03/28] vulkan/wsi/x11: Handle the geometry check earlier in create_swapchain

2017-11-16 Thread Jason Ekstrand
This fixes a potential leak if allocating the swapchain fails.  Since
geometry checking and bit-depth fetching is self-contained, it makes
sense to just do it first so we can delete the geometry reply.
---
 src/vulkan/wsi/wsi_common_x11.c | 19 ++-
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/src/vulkan/wsi/wsi_common_x11.c b/src/vulkan/wsi/wsi_common_x11.c
index 22b894e..51c103e 100644
--- a/src/vulkan/wsi/wsi_common_x11.c
+++ b/src/vulkan/wsi/wsi_common_x11.c
@@ -1107,19 +1107,21 @@ x11_surface_create_swapchain(VkIcdSurfaceBase 
*icd_surface,
 
const unsigned num_images = pCreateInfo->minImageCount;
 
-   size_t size = sizeof(*chain) + num_images * sizeof(chain->images[0]);
-   chain = vk_alloc(pAllocator, size, 8,
-  VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
-   if (chain == NULL)
-  return VK_ERROR_OUT_OF_HOST_MEMORY;
-
+   /* Check for whether or not we have a window up-front */
xcb_connection_t *conn = x11_surface_get_connection(icd_surface);
xcb_window_t window = x11_surface_get_window(icd_surface);
xcb_get_geometry_reply_t *geometry =
   xcb_get_geometry_reply(conn, xcb_get_geometry(conn, window), NULL);
-
if (geometry == NULL)
   return VK_ERROR_SURFACE_LOST_KHR;
+   const uint32_t bit_depth = geometry->depth;
+   free(geometry);
+
+   size_t size = sizeof(*chain) + num_images * sizeof(chain->images[0]);
+   chain = vk_alloc(pAllocator, size, 8,
+  VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
+   if (chain == NULL)
+  return VK_ERROR_OUT_OF_HOST_MEMORY;
 
chain->base.device = device;
chain->base.destroy = x11_swapchain_destroy;
@@ -1132,14 +1134,13 @@ x11_surface_create_swapchain(VkIcdSurfaceBase 
*icd_surface,
chain->base.image_count = num_images;
chain->conn = conn;
chain->window = window;
-   chain->depth = geometry->depth;
+   chain->depth = bit_depth;
chain->extent = pCreateInfo->imageExtent;
chain->send_sbc = 0;
chain->last_present_msc = 0;
chain->threaded = false;
chain->status = VK_SUCCESS;
 
-   free(geometry);
 
chain->base.needs_linear_copy = false;
if (!wsi_x11_check_dri3_compatible(conn, local_fd))
-- 
2.5.0.400.gff86faf

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


[Mesa-dev] [PATCH 02/28] vulkan/wsi: Add a wsi_image structure

2017-11-16 Thread Jason Ekstrand
From: Daniel Stone 

This is used to hold information about the allocated image, rather than
an ever-growing function argument list.

v2 (Jason Ekstrand):
 - Rename wsi_image_base to wsi_image

Signed-off-by: Daniel Stone 
Reviewed-by: Jason Ekstrand 
---
 src/amd/vulkan/radv_wsi.c   | 31 ++
 src/intel/vulkan/anv_wsi.c  | 25 +++---
 src/vulkan/wsi/wsi_common.h | 19 --
 src/vulkan/wsi/wsi_common_wayland.c | 31 +++---
 src/vulkan/wsi/wsi_common_x11.c | 52 ++---
 5 files changed, 65 insertions(+), 93 deletions(-)

diff --git a/src/amd/vulkan/radv_wsi.c b/src/amd/vulkan/radv_wsi.c
index 98346ca..f5f9a3f 100644
--- a/src/amd/vulkan/radv_wsi.c
+++ b/src/amd/vulkan/radv_wsi.c
@@ -145,11 +145,7 @@ radv_wsi_image_create(VkDevice device_h,
  const VkAllocationCallbacks* pAllocator,
  bool needs_linear_copy,
  bool linear,
- VkImage *image_p,
- VkDeviceMemory *memory_p,
- uint32_t *size,
- uint32_t *offset,
- uint32_t *row_pitch, int *fd_p)
+ struct wsi_image *wsi_image)
 {
VkResult result = VK_SUCCESS;
struct radeon_surf *surface;
@@ -232,20 +228,22 @@ radv_wsi_image_create(VkDevice device_h,
RADV_FROM_HANDLE(radv_device_memory, memory, memory_h);
if (!radv_get_memory_fd(device, memory, ))
goto fail_alloc_memory;
-   *fd_p = fd;
+   wsi_image->fd = fd;
}
 
surface = >surface;
 
-   *image_p = image_h;
-   *memory_p = memory_h;
-   *size = image->size;
-   *offset = image->offset;
-
+   wsi_image->image = image_h;
+   wsi_image->memory = memory_h;
+   wsi_image->size = image->size;
+   wsi_image->offset = image->offset;
if (device->physical_device->rad_info.chip_class >= GFX9)
-   *row_pitch = surface->u.gfx9.surf_pitch * surface->bpe;
+   wsi_image->row_pitch =
+   surface->u.gfx9.surf_pitch * surface->bpe;
else
-   *row_pitch = surface->u.legacy.level[0].nblk_x * surface->bpe;
+   wsi_image->row_pitch =
+   surface->u.legacy.level[0].nblk_x * surface->bpe;
+
return VK_SUCCESS;
  fail_alloc_memory:
radv_FreeMemory(device_h, memory_h, pAllocator);
@@ -259,12 +257,11 @@ fail_create_image:
 static void
 radv_wsi_image_free(VkDevice device,
const VkAllocationCallbacks* pAllocator,
-   VkImage image_h,
-   VkDeviceMemory memory_h)
+   struct wsi_image *wsi_image)
 {
-   radv_DestroyImage(device, image_h, pAllocator);
+   radv_DestroyImage(device, wsi_image->image, pAllocator);
 
-   radv_FreeMemory(device, memory_h, pAllocator);
+   radv_FreeMemory(device, wsi_image->memory, pAllocator);
 }
 
 static const struct wsi_image_fns radv_wsi_image_fns = {
diff --git a/src/intel/vulkan/anv_wsi.c b/src/intel/vulkan/anv_wsi.c
index 945b011..d8c4885 100644
--- a/src/intel/vulkan/anv_wsi.c
+++ b/src/intel/vulkan/anv_wsi.c
@@ -175,11 +175,7 @@ anv_wsi_image_create(VkDevice device_h,
  const VkAllocationCallbacks* pAllocator,
  bool different_gpu,
  bool linear,
- VkImage *image_p,
- VkDeviceMemory *memory_p,
- uint32_t *size,
- uint32_t *offset,
- uint32_t *row_pitch, int *fd_p)
+ struct wsi_image *wsi_image)
 {
struct anv_device *device = anv_device_from_handle(device_h);
VkImage image_h;
@@ -245,7 +241,6 @@ anv_wsi_image_create(VkDevice device_h,
struct anv_surface *surface = >planes[0].surface;
assert(surface->isl.tiling == ISL_TILING_X);
 
-   *row_pitch = surface->isl.row_pitch;
int ret = anv_gem_set_tiling(device, memory->bo->gem_handle,
 surface->isl.row_pitch, I915_TILING_X);
if (ret) {
@@ -265,11 +260,12 @@ anv_wsi_image_create(VkDevice device_h,
   goto fail_alloc_memory;
}
 
-   *image_p = image_h;
-   *memory_p = memory_h;
-   *fd_p = fd;
-   *size = image->size;
-   *offset = 0;
+   wsi_image->image = image_h;
+   wsi_image->memory = memory_h;
+   wsi_image->fd = fd;
+   wsi_image->size = image->size;
+   wsi_image->offset = 0;
+   wsi_image->row_pitch = surface->isl.row_pitch;
return VK_SUCCESS;
 fail_alloc_memory:
anv_FreeMemory(device_h, memory_h, pAllocator);
@@ -282,12 +278,11 @@ fail_create_image:
 static void
 anv_wsi_image_free(VkDevice device,
const VkAllocationCallbacks* pAllocator,
-   VkImage image_h,
-   

[Mesa-dev] [PATCH 01/28] vulkan/wsi: use function ptr definitions from the spec.

2017-11-16 Thread Jason Ekstrand
From: Dave Airlie 

This just seems cleaner, and we may expand this in future.

Signed-off-by: Dave Airlie 
---
 src/amd/vulkan/radv_wsi.c   | 3 ++-
 src/intel/vulkan/anv_wsi.c  | 3 ++-
 src/vulkan/wsi/wsi_common.h | 6 +++---
 src/vulkan/wsi/wsi_common_wayland.c | 2 +-
 4 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/src/amd/vulkan/radv_wsi.c b/src/amd/vulkan/radv_wsi.c
index 64f5b0d..98346ca 100644
--- a/src/amd/vulkan/radv_wsi.c
+++ b/src/amd/vulkan/radv_wsi.c
@@ -29,8 +29,9 @@
 #include "vk_util.h"
 #include "util/macros.h"
 
+#define WSI_CB(x) .x = radv_##x
 MAYBE_UNUSED static const struct wsi_callbacks wsi_cbs = {
-   .get_phys_device_format_properties = radv_GetPhysicalDeviceFormatProperties,
+   WSI_CB(GetPhysicalDeviceFormatProperties),
 };
 
 VkResult
diff --git a/src/intel/vulkan/anv_wsi.c b/src/intel/vulkan/anv_wsi.c
index 08d83cd..945b011 100644
--- a/src/intel/vulkan/anv_wsi.c
+++ b/src/intel/vulkan/anv_wsi.c
@@ -27,8 +27,9 @@
 #include "vk_util.h"
 
 #ifdef VK_USE_PLATFORM_WAYLAND_KHR
+#define WSI_CB(x) .x = anv_##x
 static const struct wsi_callbacks wsi_cbs = {
-   .get_phys_device_format_properties = anv_GetPhysicalDeviceFormatProperties,
+   WSI_CB(GetPhysicalDeviceFormatProperties),
 };
 #endif
 
diff --git a/src/vulkan/wsi/wsi_common.h b/src/vulkan/wsi/wsi_common.h
index 8166b7d..7be0182 100644
--- a/src/vulkan/wsi/wsi_common.h
+++ b/src/vulkan/wsi/wsi_common.h
@@ -118,11 +118,11 @@ struct wsi_device {
 struct wsi_interface *  wsi[VK_ICD_WSI_PLATFORM_MAX];
 };
 
+#define WSI_CB(cb) PFN_vk##cb cb
 struct wsi_callbacks {
-   void (*get_phys_device_format_properties)(VkPhysicalDevice physicalDevice,
- VkFormat format,
- VkFormatProperties 
*pFormatProperties);
+   WSI_CB(GetPhysicalDeviceFormatProperties);
 };
+#undef WSI_CB
 
 #define WSI_DEFINE_NONDISP_HANDLE_CASTS(__wsi_type, __VkType)  \
\
diff --git a/src/vulkan/wsi/wsi_common_wayland.c 
b/src/vulkan/wsi/wsi_common_wayland.c
index 4c94cd6..b93c3d7 100644
--- a/src/vulkan/wsi/wsi_common_wayland.c
+++ b/src/vulkan/wsi/wsi_common_wayland.c
@@ -84,7 +84,7 @@ wsi_wl_display_add_vk_format(struct wsi_wl_display *display, 
VkFormat format)
/* Don't add formats that aren't renderable. */
VkFormatProperties props;
 
-   
display->wsi_wl->cbs->get_phys_device_format_properties(display->wsi_wl->physical_device,
+   
display->wsi_wl->cbs->GetPhysicalDeviceFormatProperties(display->wsi_wl->physical_device,
format, );
if (!(props.optimalTilingFeatures & VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT))
   return;
-- 
2.5.0.400.gff86faf

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


[Mesa-dev] [PATCH 00/28] vulkan/wsi: Rework WSI to look a lot more like a layer

2017-11-16 Thread Jason Ekstrand
This patch series is the combined brain-child of Dave and myself.  The
objective is to rewrite Vulkan WSI to look as much like a layer as possible
and to reduce the driver <-> WSI interface.  We try very hard to have as
many of the WSI details as possible in common code and to use standard
Vulkan interfaces for everything.  Among other things, this means that
prime support is now implemented in an entirely driver-agnostic way and the
driver doesn't even know it's happening.  As a side-effect anv now has
prime support.

Eventually, someone could pull what's left out into a proper layer and we
could drop WSI support from our drivers entirely.  There are a fiew pieces
of work that would be required to do this:

 1) Write all of the annoying layer bits.  There are some short-cuts that
we can take because we're not in a layer and those will have to go.

 2) Define a VK_MESA_legacy_swapchain_image extension to replace the hack
introduced in patch 8.

 3) It looks like modifiers support will land before the official Vulkan
extensions get finished.  It will have to be ported to the official
extensions.

 4) Figure out what to do about the fence in AcquireNextImage. In a future
world of explicit synchronization, we can just import the sync_file
from X or the Wayland compositor, but with implicit sync like we have
today, it's a bit harder.  Right now, the helper in wsi_common does
nothing with it and trusts the caller to handle it.

The two drivers handle this differently today.  In anv, we do a dummy
QueueSubmit to trigger the fence while radv triggers it a bit more
manually.  In both cases, we trigger the fence immediately and trust in
the GEM's implicit synchronization to sort things out for us.  We can't
use the anv method as directly with radv because no queue is passed in
so we don't know what queue to use in the dummy QueueSubmit.  (In ANV,
we only have the one queue so that isn't a problem.)


Dave, I tried to pull patches from your series where practical but, because
we did things in a different order, it frequently wasn't.  If you want to
claim credit for any of these patches, just say so and I'll --reset-author
on them.

The series can be found on freedesktop.org here:

https://cgit.freedesktop.org/~jekstrand/mesa/log/?h=wip/vulkan-wsi-prime


Cc: Dave Airlie 
Cc: Daniel Stone 
Cc: Chad Versace 
Cc: James Jones 

Daniel Stone (1):
  vulkan/wsi: Add a wsi_image structure

Dave Airlie (4):
  vulkan/wsi: use function ptr definitions from the spec.
  radv/wsi: drop allocate memory special case
  radv/wsi: Move the guts of QueuePresent to wsi common
  vulkan/wsi: move swapchain create/destroy to common code

Jason Ekstrand (23):
  vulkan/wsi/x11: Handle the geometry check earlier in create_swapchain
  vulkan/wsi: Add a wsi_device_init function
  vulkan/wsi: Add wsi_swapchain_init/finish functions
  vulkan/wsi: Implement prime in a completely generic way
  anv/image: Add a return value to bind_memory_plane
  vulkan/wsi: Add a mock image creation extension
  anv/image: Implement the wsi "extension"
  radv/image: Implement the wsi "extension"
  vulkan/wsi: Do image creation in common code
  vulkan/wsi: Add a WSI_FROM_HANDLE macro
  vulkan/wsi: Refactor result handling in queue_present
  vulkan/wsi: Only wait on semaphores on the first swapchain
  vulkan/wsi: Set a proper pWaitDstStageMask on the dummy submit
  anv/wsi: Use the common QueuePresent code
  anv/wsi: Enable prime support
  vulkan/wsi: Move get_images into common code
  vulkan/wsi: Move prime blitting into queue_present
  vulkan/wsi: Add a helper for AcquireNextImage
  vulkan/wsi: Move wsi_swapchain to wsi_common_private.h
  vulkan/wsi: Drop the can_handle_different_gpu parameter from
get_support
  vulkan/wsi: Add wrappers for all of the surface queries
  vulkan/wsi: Drop some unneeded cruft from the API
  vulkan/wsi: Initialize individual WSI interfaces in wsi_device_init

 src/amd/vulkan/radv_device.c|  18 +-
 src/amd/vulkan/radv_image.c |  15 +-
 src/amd/vulkan/radv_private.h   |  10 -
 src/amd/vulkan/radv_wsi.c   | 472 +++---
 src/intel/vulkan/anv_image.c|  71 +++-
 src/intel/vulkan/anv_private.h  |   2 +
 src/intel/vulkan/anv_wsi.c  | 347 +++-
 src/vulkan/Makefile.sources |   2 +
 src/vulkan/wsi/meson.build  |   2 +
 src/vulkan/wsi/wsi_common.c | 763 
 src/vulkan/wsi/wsi_common.h | 223 ++-
 src/vulkan/wsi/wsi_common_private.h | 157 
 src/vulkan/wsi/wsi_common_wayland.c |  90 ++---
 src/vulkan/wsi/wsi_common_x11.c | 150 ++-
 14 files changed, 1310 insertions(+), 1012 deletions(-)
 create mode 100644 src/vulkan/wsi/wsi_common.c
 create mode 100644 src/vulkan/wsi/wsi_common_private.h

-- 
2.5.0.400.gff86faf


Re: [Mesa-dev] [PATCH v2 29/29] gallium/aux/util/u_tests.c: Fix warnigns triggered -Wmissing-field-initializers

2017-11-16 Thread Gert Wollny
Am Donnerstag, den 16.11.2017, 16:34 + schrieb Emil Velikov:
> On 16 November 2017 at 15:10, Gert Wollny 
> wrote:
> > * Use a designated initializer to silence the warning.
> > * fix one intention that was using tabs instead of spaces
> > 
> 
> Sigh, -Wmissing-field-initalizers warnings - it's perhaps the most
> annoying and inconsistent warning I've seen :-(
> 
> Originally the whole struct is initialised while now only a single
> component. Hence these changes are likely to introduce subtle bugs -
> today or X days down the line.

I see, I was already kind of reluctant to add this with the first first
version of the series. Probably it is the best to drop that patch for
now and think of something else to deal with this warning.

(Running things with valgrind should catch this though.) 

thanks for your insight, 
Gert 


> 
> > @@ -93,7 +93,7 @@ util_set_blend_normal(struct cso_context *cso)
> >  static void
> >  util_set_dsa_disable(struct cso_context *cso)
> >  {
> > -   struct pipe_depth_stencil_alpha_state dsa = {{0}};
> > +   struct pipe_depth_stencil_alpha_state dsa = {.depth = {0}};
> > 
> > cso_set_depth_stencil_alpha(cso, );
> 
> In this case - cso_set_depth_stencil_alpha() treats dsa as const ...
> So if further down the function anything other than .depth is read
> things are will end badly.
> 
> -Emil
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 1/2] mesa: Implement ARB_texture_filter_minmax

2017-11-16 Thread Ilia Mirkin
On Thu, Nov 16, 2017 at 2:57 PM, Ilia Mirkin  wrote:
> On Thu, Nov 16, 2017 at 2:49 PM, Ian Romanick  wrote:
>> On 11/14/2017 02:54 PM, Scott D Phillips wrote:
>>> This extension provides a new texture and sampler parameter
>>> (TEXTURE_REDUCTION_MODE_ARB) which allows applications to produce
>>> a filtered texel value by computing a component-wise minimum (MIN)
>>> or maximum (MAX) of the texels that would normally be averaged.
>>> ---
>>> CTS tests KHR-GL45.texture_filter_minmax_tests.* need a little TLC to
>>> pass with this series. Details in VK-GL-CTS issue: 849
>>>
>>>  src/mesa/main/attrib.c   |  4 
>>>  src/mesa/main/extensions_table.h |  1 +
>>>  src/mesa/main/formatquery.c  | 10 ++
>>>  src/mesa/main/mtypes.h   |  2 ++
>>>  src/mesa/main/samplerobj.c   | 37 +
>>>  src/mesa/main/texobj.c   |  2 ++
>>>  src/mesa/main/texobj.h   |  2 +-
>>>  src/mesa/main/texparam.c | 33 +
>>>  8 files changed, 90 insertions(+), 1 deletion(-)
>>>
>>
>> [lots of stuff trimmed]
>>
>>> diff --git a/src/mesa/main/extensions_table.h 
>>> b/src/mesa/main/extensions_table.h
>>> index 5b66e7d30d..c51ad80742 100644
>>> --- a/src/mesa/main/extensions_table.h
>>> +++ b/src/mesa/main/extensions_table.h
>>> @@ -146,6 +146,7 @@ EXT(ARB_texture_env_combine , 
>>> ARB_texture_env_combine
>>>  EXT(ARB_texture_env_crossbar, ARB_texture_env_crossbar 
>>>   , GLL,  x ,  x ,  x , 2001)
>>>  EXT(ARB_texture_env_dot3, ARB_texture_env_dot3 
>>>   , GLL,  x ,  x ,  x , 2001)
>>>  EXT(ARB_texture_filter_anisotropic  , 
>>> ARB_texture_filter_anisotropic , GLL, GLC,  x ,  x , 2017)
>>> +EXT(ARB_texture_filter_minmax   , ARB_texture_filter_minmax
>>>   , GLL, GLC,  x ,  x , 2017)
>>
>> Is this right?  The extension says OpenGL 3.3 is required, and we don't
>> (until Marek is done) do OpenGL 3.3 compatibility profile.
>
> FWIW I took the view that spec writers are lazy on
> EXT_polygon_offset_clamp, which had similar text. Is this a bad thing
> to do? Should we stick to the text of the specs to the letter?
>
> There are various GL 4.2/4.3 exts which require the previous GL
> version as well but we expose them anyways.
>
> IMHO it's reasonable to be relaxed about this, unless there are
> obvious interactions that need explicit consideration. [Perhaps that's
> the case here, although I can't think of anything.]

Oh, it depends on ARB_sampler_objects, and that functionality was core
in GL 3.3 - probably that's why the spec listed it that way.

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


Re: [Mesa-dev] [PATCH 1/2] mesa: Implement ARB_texture_filter_minmax

2017-11-16 Thread Ilia Mirkin
On Thu, Nov 16, 2017 at 2:49 PM, Ian Romanick  wrote:
> On 11/14/2017 02:54 PM, Scott D Phillips wrote:
>> This extension provides a new texture and sampler parameter
>> (TEXTURE_REDUCTION_MODE_ARB) which allows applications to produce
>> a filtered texel value by computing a component-wise minimum (MIN)
>> or maximum (MAX) of the texels that would normally be averaged.
>> ---
>> CTS tests KHR-GL45.texture_filter_minmax_tests.* need a little TLC to
>> pass with this series. Details in VK-GL-CTS issue: 849
>>
>>  src/mesa/main/attrib.c   |  4 
>>  src/mesa/main/extensions_table.h |  1 +
>>  src/mesa/main/formatquery.c  | 10 ++
>>  src/mesa/main/mtypes.h   |  2 ++
>>  src/mesa/main/samplerobj.c   | 37 +
>>  src/mesa/main/texobj.c   |  2 ++
>>  src/mesa/main/texobj.h   |  2 +-
>>  src/mesa/main/texparam.c | 33 +
>>  8 files changed, 90 insertions(+), 1 deletion(-)
>>
>
> [lots of stuff trimmed]
>
>> diff --git a/src/mesa/main/extensions_table.h 
>> b/src/mesa/main/extensions_table.h
>> index 5b66e7d30d..c51ad80742 100644
>> --- a/src/mesa/main/extensions_table.h
>> +++ b/src/mesa/main/extensions_table.h
>> @@ -146,6 +146,7 @@ EXT(ARB_texture_env_combine , 
>> ARB_texture_env_combine
>>  EXT(ARB_texture_env_crossbar, ARB_texture_env_crossbar  
>>  , GLL,  x ,  x ,  x , 2001)
>>  EXT(ARB_texture_env_dot3, ARB_texture_env_dot3  
>>  , GLL,  x ,  x ,  x , 2001)
>>  EXT(ARB_texture_filter_anisotropic  , 
>> ARB_texture_filter_anisotropic , GLL, GLC,  x ,  x , 2017)
>> +EXT(ARB_texture_filter_minmax   , ARB_texture_filter_minmax 
>>  , GLL, GLC,  x ,  x , 2017)
>
> Is this right?  The extension says OpenGL 3.3 is required, and we don't
> (until Marek is done) do OpenGL 3.3 compatibility profile.

FWIW I took the view that spec writers are lazy on
EXT_polygon_offset_clamp, which had similar text. Is this a bad thing
to do? Should we stick to the text of the specs to the letter?

There are various GL 4.2/4.3 exts which require the previous GL
version as well but we expose them anyways.

IMHO it's reasonable to be relaxed about this, unless there are
obvious interactions that need explicit consideration. [Perhaps that's
the case here, although I can't think of anything.]

Cheers,

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


Re: [Mesa-dev] [PATCH] util: add new ASSERT_BITFIELD_SIZE() macro (v3)

2017-11-16 Thread Ian Romanick
I like this.

Reviewed-by: Ian Romanick 

On 11/16/2017 10:17 AM, Brian Paul wrote:
> For checking that bitfields are large enough to hold the largest
> expected value.
> 
> v2: move into existing util/macros.h header where STATIC_ASSERT() lives.
> v3: add MAYBE_UNUSED to variable declaration
> ---
>  src/util/macros.h | 17 +
>  1 file changed, 17 insertions(+)
> 
> diff --git a/src/util/macros.h b/src/util/macros.h
> index a9a52a1..aa36253 100644
> --- a/src/util/macros.h
> +++ b/src/util/macros.h
> @@ -241,6 +241,23 @@ do {   \
>  #define ATTRIBUTE_NOINLINE
>  #endif
>  
> +
> +/**
> + * Check that STRUCT::FIELD can hold MAXVAL.  We use a lot of bitfields
> + * in Mesa/gallium.  We have to be sure they're of sufficient size to
> + * hold the largest expected value.
> + * Note that with MSVC, enums are signed and enum bitfields need one extra
> + * high bit (always zero) to ensure the max value is handled correctly.
> + * This macro will detect that with MSVC, but not GCC.
> + */
> +#define ASSERT_BITFIELD_SIZE(STRUCT, FIELD, MAXVAL) \
> +   do { \
> +  MAYBE_UNUSED STRUCT s;\
> +  s.FIELD = (MAXVAL); \
> +  assert((int) s.FIELD == (MAXVAL) && "Insufficient bitfield size!"); \
> +   } while (0)
> +
> +
>  /** Compute ceiling of integer quotient of A divided by B. */
>  #define DIV_ROUND_UP( A, B )  ( (A) % (B) == 0 ? (A)/(B) : (A)/(B)+1 )
>  
> 

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


Re: [Mesa-dev] [PATCH 2/2] i965: Implement ARB_texture_filter_minmax

2017-11-16 Thread Ian Romanick
On 11/14/2017 02:54 PM, Scott D Phillips wrote:
> On gen >= 9, minmax reduction modes are available as a flag in
> SAMPLER_STATE.
> ---
>  docs/features.txt |  2 +-
>  src/mesa/drivers/dri/i965/brw_formatquery.c   |  4 
>  src/mesa/drivers/dri/i965/genX_state_upload.c | 10 ++
>  src/mesa/drivers/dri/i965/intel_extensions.c  |  1 +
>  4 files changed, 16 insertions(+), 1 deletion(-)
> 
> diff --git a/docs/features.txt b/docs/features.txt
> index 86d07ba80b..9ec3f2b975 100644
> --- a/docs/features.txt
> +++ b/docs/features.txt
> @@ -312,7 +312,7 @@ Khronos, ARB, and OES extensions that are not part of any 
> OpenGL or OpenGL ES ve
>GL_ARB_sparse_texture not started
>GL_ARB_sparse_texture2not started
>GL_ARB_sparse_texture_clamp   not started
> -  GL_ARB_texture_filter_minmax  not started
> +  GL_ARB_texture_filter_minmax  DONE (i965)
>GL_EXT_memory_object  DONE (radeonsi)
>GL_EXT_memory_object_fd   DONE (radeonsi)
>GL_EXT_memory_object_win32not started
> diff --git a/src/mesa/drivers/dri/i965/brw_formatquery.c 
> b/src/mesa/drivers/dri/i965/brw_formatquery.c
> index 4f3b9e467b..bb2281f571 100644
> --- a/src/mesa/drivers/dri/i965/brw_formatquery.c
> +++ b/src/mesa/drivers/dri/i965/brw_formatquery.c
> @@ -107,6 +107,10 @@ brw_query_internal_format(struct gl_context *ctx, GLenum 
> target,
>break;
> }
>  
> +   case GL_TEXTURE_REDUCTION_MODE_ARB:
> +  params[0] = GL_TRUE;
> +  break;
> +

Can Gen9 actually support all formats?  When this was getting discussed
in Khronos, I thought we had some format restrictions.  This is the
difference between the EXT and the ARB extension.  If we don't actually
have any restrictions on Gen9, a good follow-on would be to add support
for the EXT... since that doesn't have the OpenGL 3.3 requirement and
has interactions with OpenGL ES.

I also thought that Gen8 could do some min/max modes.  Perhaps that's
where the restrictions were that I was thinking of...

> default:
>/* By default, we call the driver hook's fallback function from the 
> frontend,
> * which has generic implementation for all pnames.
> diff --git a/src/mesa/drivers/dri/i965/genX_state_upload.c 
> b/src/mesa/drivers/dri/i965/genX_state_upload.c
> index 453b8e4add..8af907648b 100644
> --- a/src/mesa/drivers/dri/i965/genX_state_upload.c
> +++ b/src/mesa/drivers/dri/i965/genX_state_upload.c
> @@ -5094,6 +5094,16 @@ genX(update_sampler_state)(struct brw_context *brw,
> samp_st.LODPreClampEnable = true;
>  #endif
>  
> +#if GEN_GEN >= 9
> +   if (sampler->ReductionMode != GL_WEIGHTED_AVERAGE_ARB) {
> +  samp_st.ReductionTypeEnable = true;
> +  if (sampler->ReductionMode == GL_MIN)
> + samp_st.ReductionType = MINIMUM;
> +  else
> + samp_st.ReductionType = MAXIMUM;
> +   }
> +#endif
> +
> GENX(SAMPLER_STATE_pack)(brw, sampler_state, _st);
>  }
>  
> diff --git a/src/mesa/drivers/dri/i965/intel_extensions.c 
> b/src/mesa/drivers/dri/i965/intel_extensions.c
> index 4d17393948..e280474875 100644
> --- a/src/mesa/drivers/dri/i965/intel_extensions.c
> +++ b/src/mesa/drivers/dri/i965/intel_extensions.c
> @@ -285,6 +285,7 @@ intelInitExtensions(struct gl_context *ctx)
> if (devinfo->gen >= 9) {
>ctx->Extensions.ANDROID_extension_pack_es31a = true;
>ctx->Extensions.ARB_shader_stencil_export = true;
> +  ctx->Extensions.ARB_texture_filter_minmax = true;
>ctx->Extensions.KHR_blend_equation_advanced_coherent = true;
>ctx->Extensions.KHR_texture_compression_astc_ldr = true;
>ctx->Extensions.KHR_texture_compression_astc_sliced_3d = true;
> 

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


Re: [Mesa-dev] [PATCH 1/2] mesa: Implement ARB_texture_filter_minmax

2017-11-16 Thread Ian Romanick
On 11/14/2017 02:54 PM, Scott D Phillips wrote:
> This extension provides a new texture and sampler parameter
> (TEXTURE_REDUCTION_MODE_ARB) which allows applications to produce
> a filtered texel value by computing a component-wise minimum (MIN)
> or maximum (MAX) of the texels that would normally be averaged.
> ---
> CTS tests KHR-GL45.texture_filter_minmax_tests.* need a little TLC to
> pass with this series. Details in VK-GL-CTS issue: 849
> 
>  src/mesa/main/attrib.c   |  4 
>  src/mesa/main/extensions_table.h |  1 +
>  src/mesa/main/formatquery.c  | 10 ++
>  src/mesa/main/mtypes.h   |  2 ++
>  src/mesa/main/samplerobj.c   | 37 +
>  src/mesa/main/texobj.c   |  2 ++
>  src/mesa/main/texobj.h   |  2 +-
>  src/mesa/main/texparam.c | 33 +
>  8 files changed, 90 insertions(+), 1 deletion(-)
> 

[lots of stuff trimmed]

> diff --git a/src/mesa/main/extensions_table.h 
> b/src/mesa/main/extensions_table.h
> index 5b66e7d30d..c51ad80742 100644
> --- a/src/mesa/main/extensions_table.h
> +++ b/src/mesa/main/extensions_table.h
> @@ -146,6 +146,7 @@ EXT(ARB_texture_env_combine , 
> ARB_texture_env_combine
>  EXT(ARB_texture_env_crossbar, ARB_texture_env_crossbar   
> , GLL,  x ,  x ,  x , 2001)
>  EXT(ARB_texture_env_dot3, ARB_texture_env_dot3   
> , GLL,  x ,  x ,  x , 2001)
>  EXT(ARB_texture_filter_anisotropic  , ARB_texture_filter_anisotropic 
> , GLL, GLC,  x ,  x , 2017)
> +EXT(ARB_texture_filter_minmax   , ARB_texture_filter_minmax  
> , GLL, GLC,  x ,  x , 2017)

Is this right?  The extension says OpenGL 3.3 is required, and we don't
(until Marek is done) do OpenGL 3.3 compatibility profile.

>  EXT(ARB_texture_float   , ARB_texture_float  
> , GLL, GLC,  x ,  x , 2004)
>  EXT(ARB_texture_gather  , ARB_texture_gather 
> , GLL, GLC,  x ,  x , 2009)
>  EXT(ARB_texture_mirror_clamp_to_edge, 
> ARB_texture_mirror_clamp_to_edge   , GLL, GLC,  x ,  x , 2013)
> diff --git a/src/mesa/main/texparam.c b/src/mesa/main/texparam.c
> index 4a0f61eda8..94883b2210 100644
> --- a/src/mesa/main/texparam.c
> +++ b/src/mesa/main/texparam.c
> @@ -630,6 +630,25 @@ set_tex_parameteri(struct gl_context *ctx,
>}
>goto invalid_pname;
>  
> +   case GL_TEXTURE_REDUCTION_MODE_ARB:
> +  if (ctx->Extensions.ARB_texture_filter_minmax) {
> +

Extra blank line here should be deleted.

> + if (!_mesa_target_allows_setting_sampler_parameters(texObj->Target))
> +goto invalid_enum;
> +
> + if (texObj->Sampler.ReductionMode == params[0])
> +return GL_FALSE;
> + if (params[0] == GL_MIN ||
> + params[0] == GL_MAX ||
> + params[0] == GL_WEIGHTED_AVERAGE_ARB) {
> +flush(ctx);
> +texObj->Sampler.ReductionMode = params[0];
> +return GL_TRUE;
> + }
> + goto invalid_param;
> +  }
> +  goto invalid_pname;
> +
> default:
>goto invalid_pname;
> }
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 3/4] meson: Fix TODO for missing dl_iterate_phdr function

2017-11-16 Thread Dylan Baker
Quoting Emil Velikov (2017-11-16 05:21:50)
> On 16 November 2017 at 01:11, Dylan Baker  wrote:
> > This function is required for both the Intel "Anvil" vulkan driver and
> > the i965 GL driver. Error out if either of those is enabled but this
> > function isn't found.
> >
> > Signed-off-by: Dylan Baker 
> > ---
> >  meson.build | 6 --
> >  1 file changed, 4 insertions(+), 2 deletions(-)
> >
> > diff --git a/meson.build b/meson.build
> > index 261c4753427..5ac2ebc9e5d 100644
> > --- a/meson.build
> > +++ b/meson.build
> > @@ -672,8 +672,10 @@ endif
> >
> >  if cc.has_function('dl_iterate_phdr')
> >pre_args += '-DHAVE_DL_ITERATE_PHDR'
> > -else
> > -  # TODO: this is required for vulkan
> > +elif with_intel_vk
> > +  error('Intel "Anvil" Vulkan driver requires the dl_iterate_phdr 
> > function')
> > +elif with_dri_i965 and get_option('shader-cache')
> > +  error('Intel i965 GL driver requires dl_iterate_phdr when built with 
> > shader caching.')
> >  endif
> >
> One idea for the future: factor out the else case into a helper
> function, so that it simpler to read and can be extended easily.
> 
> As-is patch is:
> Reviewed-by: Emil Velikov 
> 
> Side note: can we drop the shader-cache option?

Yes, I'm all for dropping options!

> 
> Thanks
> Emil


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


[Mesa-dev] [Bug 103784] [bisected] Egl changes breaks all of EGL

2017-11-16 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=103784

Dylan Baker  changed:

   What|Removed |Added

 Status|RESOLVED|VERIFIED

-- 
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


[Mesa-dev] [Bug 103784] [bisected] Egl changes breaks all of EGL

2017-11-16 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=103784

Emil Velikov  changed:

   What|Removed |Added

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

-- 
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


Re: [Mesa-dev] [PATCH] egl: pass the dri2_dpy to the $plat_teardown functions

2017-11-16 Thread Dylan Baker
Tested-by: Dylan Baker 
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=103784

Quoting Emil Velikov (2017-11-16 10:36:01)
> From: Emil Velikov 
> 
> Cc: Mark Janes 
> Fixes: 40a01c9a0ef ("egl/drm: move teardown code to the platform file")
> Fixes: 8d745abc009 ("egl/wayland: move teardown code to the platform file")
> Signed-off-by: Emil Velikov 
> ---
>  src/egl/drivers/dri2/egl_dri2.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
> index c362206a431..7cc9f20ba25 100644
> --- a/src/egl/drivers/dri2/egl_dri2.c
> +++ b/src/egl/drivers/dri2/egl_dri2.c
> @@ -992,10 +992,10 @@ dri2_display_destroy(_EGLDisplay *disp)
>dri2_teardown_x11(dri2_dpy);
>break;
> case _EGL_PLATFORM_DRM:
> -  dri2_teardown_drm(disp);
> +  dri2_teardown_drm(dri2_dpy);
>break;
> case _EGL_PLATFORM_WAYLAND:
> -  dri2_teardown_wayland(disp);
> +  dri2_teardown_wayland(dri2_dpy);
>break;
> default:
>/* TODO: add teardown for other platforms */
> -- 
> 2.15.0
> 
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev


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


[Mesa-dev] [Bug 103784] [bisected] Egl changes breaks all of EGL

2017-11-16 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=103784

--- Comment #2 from Emil Velikov  ---
I've posted a fix was on the list at the same moment you opened the bug.

https://patchwork.freedesktop.org/patch/188753/

-- 
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


Re: [Mesa-dev] [PATCH] etnaviv: Fix point sprite issue on HALTI0

2017-11-16 Thread Ilia Mirkin
On Thu, Nov 16, 2017 at 1:20 PM, Wladimir J. van der Laan
 wrote:
> On Thu, Nov 16, 2017 at 12:26:05PM -0500, Ilia Mirkin wrote:
>> On Thu, Nov 16, 2017 at 7:15 AM, Wladimir  wrote:
>
>> The point of the texcoord semantics is precisely point sprite
>> replacement. NVIDIA hardware (Fermi+) can only do point sprite
>> replacement on certain specially-located varyings, hence the texcoord
>> semantic was created. (And nv30 also has similar restrictions. nv50 is
>> unconstrained, go figure.)
>>
>> In legacy GL, only gl_TexCoord varyings may be replaced by point
>> sprites, and the gl_PointCoord is handled separately. I don't think ES
>> has an equivalent of point sprite coord replacements.
>>
>> Hardware without that restriction should probably not use the texcoord
>> semantic and just use GENERIC for everything.
>
> Thanks for the info - I know about nothing about legacy GL, too long
> ago for me.
>
> For Vivantes (HALTI4-) it is the case that any varying can be replaced by the
> point coordinate. This is used for the gl_PointCoord as well. So far so good.
>
> However the trouble is in how this interacts with flat shading. The same flag
> is used to mark varyings that should be interpolated when using flat
> shading (apparently everything except COLOR?).
>
> Currently the criterion for setting the flag is !=SEMANTIC_COLOR. This
> works for polygons, by allowing non-color varyings override flat shading, but
> breaks when rendering points, because we want GENERIC varyings to be simply
> passed through in that case - not replaced with the point coordinate!
>
> Which gives us the following varying state, for flat shaded and smooth 
> polygons
> and for points (where shading model is irrelevant) respectively:
>
>  GENERIC  T/PCOORD COLOR
> Flat11   0
> Smooth  xx   x
> Points  01   0
>
> (0=VARYING_USE_USED, 1=VARYING_USE_POINTCOORD, x=dont_care)
>
> Which is annoying as it means that shader state now depends on either the kind
> of primitive (which is per-draw), or the shading model (which is part of
> rasterizer state).

I take it your hardware doesn't support setting a different polygon
mode for front and back-facing triangles?

>
> Thinking of it, the latter is also an option, at least we don't have to
> "smuggle" per-draw info into the state emit call. But it's still
> quite more involved to fix than I expected :(

When you say flat shading ... are you talking about like "flat in vec4
bla", or like glShadeModel(GL_FLAT)? If the latter, note that this
only applies to gl_Color / gl_SecondaryColor. Not regular varyings.
The "flat" keyword can apply to any varying, of course.

These are totally separate concepts, I'd really recommend poring over
your traces again to see if you might have missed something. Here's
how it works on Adreno:

a3xx is easy:
https://cgit.freedesktop.org/mesa/mesa/tree/src/gallium/drivers/freedreno/a3xx/fd3_program.c#n386

a4xx+ is a little weird:
https://cgit.freedesktop.org/mesa/mesa/tree/src/gallium/drivers/freedreno/a4xx/fd4_program.c#n473
+
https://cgit.freedesktop.org/mesa/mesa/tree/src/gallium/drivers/freedreno/ir3/ir3_compiler_nir.c#n2945

(i.e. you have to load flat inputs specially on a4xx+)

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


[Mesa-dev] [Bug 103784] [bisected] Egl changes breaks all of EGL

2017-11-16 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=103784

--- Comment #1 from Dylan Baker  ---
You can easily verify this via:
wflinfo --platform gbm -a gl

-- 
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


[Mesa-dev] [Bug 103784] [bisected] Egl changes breaks all of EGL

2017-11-16 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=103784

Dylan Baker  changed:

   What|Removed |Added

 CC||baker.dyla...@gmail.com,
   ||clay...@craftyguy.net,
   ||mark.a.ja...@intel.com,
   ||mirlan.ax.tokonbekov@intel.
   ||com
   Priority|medium  |highest
   Assignee|mesa-dev@lists.freedesktop. |emil.l.veli...@gmail.com
   |org |

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


[Mesa-dev] [Bug 103784] [bisected] Egl changes breaks all of EGL

2017-11-16 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=103784

Dylan Baker  changed:

   What|Removed |Added

Summary|[bisected] Egl changes  |[bisected] Egl changes
   |breaks all all EGL  |breaks all of EGL

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


[Mesa-dev] [PATCH] egl: pass the dri2_dpy to the $plat_teardown functions

2017-11-16 Thread Emil Velikov
From: Emil Velikov 

Cc: Mark Janes 
Fixes: 40a01c9a0ef ("egl/drm: move teardown code to the platform file")
Fixes: 8d745abc009 ("egl/wayland: move teardown code to the platform file")
Signed-off-by: Emil Velikov 
---
 src/egl/drivers/dri2/egl_dri2.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index c362206a431..7cc9f20ba25 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -992,10 +992,10 @@ dri2_display_destroy(_EGLDisplay *disp)
   dri2_teardown_x11(dri2_dpy);
   break;
case _EGL_PLATFORM_DRM:
-  dri2_teardown_drm(disp);
+  dri2_teardown_drm(dri2_dpy);
   break;
case _EGL_PLATFORM_WAYLAND:
-  dri2_teardown_wayland(disp);
+  dri2_teardown_wayland(dri2_dpy);
   break;
default:
   /* TODO: add teardown for other platforms */
-- 
2.15.0

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


[Mesa-dev] [Bug 103784] [bisected] Egl changes breaks all all EGL

2017-11-16 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=103784

Bug ID: 103784
   Summary: [bisected] Egl changes breaks all all EGL
   Product: Mesa
   Version: git
  Hardware: Other
OS: All
Status: NEW
  Severity: critical
  Priority: medium
 Component: EGL
  Assignee: mesa-dev@lists.freedesktop.org
  Reporter: baker.dyla...@gmail.com
QA Contact: mesa-dev@lists.freedesktop.org

40a01c9a0ef2c8110d79c284976ef34c0f73be92 is the first bad commit
commit 40a01c9a0ef2c8110d79c284976ef34c0f73be92
Author: Emil Velikov 
Date:   Thu Nov 9 19:04:25 2017 +

egl/drm: move teardown code to the platform file

Signed-off-by: Emil Velikov 
Reviewed-by: Eric Engestrom 

:04 04 2b357f3f681f8c4a1a672dd7694f18b4866226d8
0b1507c3b436555f37c160ebed6757ebcd84e41a M  src

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


  1   2   3   >